File: ConnectionEditor.cpp

package info (click to toggle)
l2tp-ipsec-vpn 1.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,396 kB
  • sloc: cpp: 9,952; xml: 400; makefile: 139; sh: 78
file content (73 lines) | stat: -rw-r--r-- 2,502 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * $Id: ConnectionEditor.cpp 87 2011-04-20 09:21:12Z werner $
 *
 * File:   ConnectionEditor.cpp
 * Author: Werner Jaeger
 *
 * Created on August 30, 2010, 12:59 PM
 *
 * Copyright 2010 Werner Jaeger.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "dialogs/ConnectionEditorDialog.h"
#include "models/ConnectionsModel.h"
#include "settings/ConnectionSettings.h"
#include "L2tpIPsecVpnApplication.h"

#include "ConnectionEditor.h"

ConnectionEditor::ConnectionEditor(L2tpIPsecVpnApplication& application, QObject* pParent) : QObject(pParent), m_Application(application), m_pConnectionEditorDialog(application.mode() == L2tpIPsecVpnApplication::APPLYSETTINGS ? NULL : new ConnectionEditorDialog)
{
   if (m_pConnectionEditorDialog)
   {
      connect(m_pConnectionEditorDialog, SIGNAL(connectionAdded(const QString&)), this, SLOT(onConnectionAdded(const QString&)));
      connect(m_pConnectionEditorDialog, SIGNAL(connectionRemoved(const QString&)), this, SLOT(onConnectionRemoved(const QString&)));
   }
}

ConnectionEditor::~ConnectionEditor()
{
   if (m_pConnectionEditorDialog)
      delete m_pConnectionEditorDialog;
}

int ConnectionEditor::exec()
{
   int iRet(0);

   if (!m_pConnectionEditorDialog)
   {
      ConnectionsModel* pConnectionsModel(new ConnectionsModel());
      ConnectionSettings* pConnectionSettings(new ConnectionSettings());
      iRet = (ConnectionEditorDialog::applySettings(pConnectionsModel, pConnectionSettings) ? 0 : 1);
      delete pConnectionsModel;
      delete pConnectionSettings;
   }
   else
      iRet = (m_pConnectionEditorDialog->exec() == QDialog::Accepted ? 0 : 1);

   return(iRet);
}

void ConnectionEditor::onConnectionAdded(const QString& strName)
{
   m_Application.sendConnectionAddedMessage(strName);
}

void ConnectionEditor::onConnectionRemoved(const QString& strName)
{
   m_Application.sendConnectionRemovedMessage(strName);
}