1
/***************************************************************************
3
* knetworkmanager-nminfo.cpp - A NetworkManager frontend for KDE
5
* Copyright (C) 2005, 2006 Novell, Inc.
7
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
8
* Valentine Sinitsyn <e_val@inbox.ru>
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
**************************************************************************/
27
#include "knetworkmanager.h"
28
#include "knetworkmanager-nminfo_dbus.h"
29
#include "knetworkmanager-dialogfab.h"
30
#include "knetworkmanager-encryption.h"
31
#include "knetworkmanager-storage.h"
32
#include "knetworkmanager-synchronizer.h"
33
#include "knetworkmanager-vpn.h"
35
#include "knetworkmanager-nminfo.h"
38
NetworkManagerInfo::userInteraction (void)
40
NetworkManagerInfoDBus::userInteraction ();
44
NetworkManagerInfo::sendPassphrase (Network* net)
46
NetworkManagerInfoDBus::sendKeyForNetwork (net);
50
NetworkManagerInfo::sendPassphraseError ()
52
NetworkManagerInfoDBus::sendGetKeyError ();
56
NetworkManagerInfo::acquirePassphrase (QString obj_path, QString net_path, QString essid, bool new_key)
58
kdDebug () << k_funcinfo << " fork ahead: user or storage" << endl;
60
DeviceStore *store = _ctx->getDeviceStore ();
61
Device *dev = store->getDevice (obj_path);
62
Synchronizer sync(dev);
63
sync.setSources(Synchronizer::Storage | Synchronizer::New);
64
Network *net = sync.synchronize(essid, net_path);
68
/* Steps for obtaining the key:
69
* First, look in the Encryption object - maybe it was already loaded
70
* Second, look in the wallet - maybe it is here
74
Encryption *enc = net->getEncryption ();
76
if (enc->isValid (essid) || (enc->restoreKey() && enc->isValid (essid))) {
77
kdDebug () << k_funcinfo << "responding to getKeyForNetwork " << net->getEssid () << endl;
83
kdDebug () << k_funcinfo << " asking user: getKeyForNetwork " << essid << endl;
84
AcquirePasswordDialog* dlg = new AcquirePasswordDialog (_ctx->getTray (), "PassphraseDialog", true, WDestructiveClose, _ctx, obj_path, net_path, essid);
93
NetworkManagerInfo::getNetworks ()
95
return KNetworkManagerStorage::getInstance ()->networks ();
99
NetworkManagerInfo::getNetworkProperties (const QString & essid)
101
return KNetworkManagerStorage::getInstance ()->networkProperties (essid);
105
NetworkManagerInfo::emitNetworkUpdated (Network* net, bool automatic)
107
emit networkUpdated (net, automatic);
111
NetworkManagerInfo::getVPNConnection (const QString & name)
113
VPN* vpn = _ctx->getVPN ();
114
VPNConnection* vpnConnection = NULL;
116
if (vpn && vpn->isAvailable ()) {
117
VPNList* vpnList = vpn->getVPNList ();
119
for (VPNList::iterator i = vpnList->begin (); i != vpnList->end (); ++i) {
120
if ((*i)->getName () == name)
125
return vpnConnection;
129
NetworkManagerInfo::getVPNConnectionNames ()
131
VPN* vpn = _ctx->getVPN ();
132
QStringList vpnConnectionNames;
134
if (vpn && vpn->isAvailable ()) {
135
VPNList* vpnList = vpn->getVPNList ();
137
for (VPNList::iterator i = vpnList->begin (); i != vpnList->end (); ++i) {
138
vpnConnectionNames.append ((*i)->getName ());
142
return vpnConnectionNames;
146
NetworkManagerInfo::push (KNetworkManager* ctx)
148
NetworkManagerInfoDBus::push (ctx);
152
NetworkManagerInfo::NetworkManagerInfo ()
157
NetworkManagerInfo::~NetworkManagerInfo ()
162
#include "knetworkmanager-nminfo.moc"