parent
082adfa550
commit
9265fa10ad
@ -1,222 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-accesspoint.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
// TQt
|
||||
#include <tqguardedptr.h>
|
||||
|
||||
// TQT_DBus includes
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqdbusconnection.h>
|
||||
#include <tqdbuserror.h>
|
||||
|
||||
// NM includes
|
||||
#include <NetworkManager.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-accesspoint.h"
|
||||
#include "dbus/accesspointproxy.h"
|
||||
|
||||
class AccessPointPrivate
|
||||
{
|
||||
public:
|
||||
AccessPointPrivate(TQString objpath = TQString(), const DBus::AccessPointProxy* proxy = NULL)
|
||||
: nmAccessPoint(proxy)
|
||||
, objPath(objpath)
|
||||
{
|
||||
}
|
||||
|
||||
~AccessPointPrivate() { }
|
||||
|
||||
// pointer to the shared DBus proxy
|
||||
TQGuardedPtr<const DBus::AccessPointProxy> nmAccessPoint;
|
||||
// DBus object path
|
||||
TQString objPath;
|
||||
|
||||
// Properties
|
||||
TQ_UINT32 flags;
|
||||
TQ_UINT32 wpaFlags;
|
||||
TQ_UINT32 rsnFlags;
|
||||
TQValueList<TQ_UINT8> ssid;
|
||||
TQ_UINT32 freq;
|
||||
TQString hwAddress;
|
||||
TQ_INT32 mode;
|
||||
TQ_UINT32 rate;
|
||||
TQ_UINT8 strength;
|
||||
};
|
||||
|
||||
TQ_UINT32 AccessPoint::getFlags() const
|
||||
{
|
||||
return d->flags;
|
||||
}
|
||||
|
||||
TQ_UINT32 AccessPoint::getWpaFlags() const
|
||||
{
|
||||
return d->wpaFlags;
|
||||
}
|
||||
|
||||
TQ_UINT32 AccessPoint::getRsnFlags() const
|
||||
{
|
||||
return d->rsnFlags;
|
||||
}
|
||||
|
||||
TQValueList<TQ_UINT8> AccessPoint::getSsid() const
|
||||
{
|
||||
return d->ssid;
|
||||
}
|
||||
|
||||
TQ_UINT32 AccessPoint::getFrequency() const
|
||||
{
|
||||
return d->freq;
|
||||
}
|
||||
|
||||
TQString AccessPoint::getHwAddress() const
|
||||
{
|
||||
return d->hwAddress;
|
||||
}
|
||||
|
||||
TQ_INT32 AccessPoint::getMode() const
|
||||
{
|
||||
return d->mode;
|
||||
}
|
||||
|
||||
TQ_UINT32 AccessPoint::getRate() const
|
||||
{
|
||||
return d->rate;
|
||||
}
|
||||
|
||||
TQ_UINT8 AccessPoint::getStrength() const
|
||||
{
|
||||
return d->strength;
|
||||
}
|
||||
|
||||
const TQByteArray AccessPoint::getSsidByteArray() const
|
||||
{
|
||||
// FIXME: Wow, thats ugly
|
||||
TQValueList<TQ_UINT8> ssid = d->ssid;
|
||||
TQByteArray ret_ssid(ssid.count());
|
||||
TQByteArray::Iterator byteit = ret_ssid.begin();
|
||||
for (TQValueList<TQ_UINT8>::iterator it = ssid.begin(); it != ssid.end(); ++it)
|
||||
{
|
||||
(*byteit) = (*it);
|
||||
++byteit;
|
||||
}
|
||||
return ret_ssid;
|
||||
}
|
||||
|
||||
TQString AccessPoint::getDisplaySsid() const
|
||||
{
|
||||
return TQString(getSsidByteArray());
|
||||
}
|
||||
|
||||
bool AccessPoint::isEncrypted() const
|
||||
{
|
||||
return (getFlags() && NM_802_11_AP_FLAGS_PRIVACY);
|
||||
}
|
||||
|
||||
void AccessPoint::slotPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>& properties)
|
||||
{
|
||||
updateProperties();
|
||||
}
|
||||
|
||||
void AccessPoint::updateProperties()
|
||||
{
|
||||
//TODO do this proper-like
|
||||
TQT_DBusError err;
|
||||
if (d->nmAccessPoint.isNull())
|
||||
return;
|
||||
|
||||
d->flags = d->nmAccessPoint->getFlags(err);
|
||||
d->wpaFlags = d->nmAccessPoint->getWpaFlags(err);
|
||||
d->rsnFlags = d->nmAccessPoint->getRsnFlags(err);
|
||||
d->ssid = d->nmAccessPoint->getSsid(err);
|
||||
d->freq = d->nmAccessPoint->getFrequency(err);
|
||||
d->hwAddress = d->nmAccessPoint->getHwAddress(err);
|
||||
d->mode = d->nmAccessPoint->getMode(err);
|
||||
d->rate = d->nmAccessPoint->getMaxBitrate(err);
|
||||
d->strength = d->nmAccessPoint->getStrength(err);
|
||||
emit strengthChanged(d->strength);
|
||||
}
|
||||
|
||||
TQString AccessPoint::getObjectPath() const
|
||||
{
|
||||
return d->objPath;
|
||||
}
|
||||
|
||||
bool AccessPoint::isValid() const
|
||||
{
|
||||
return !(d->objPath.isEmpty());
|
||||
}
|
||||
|
||||
bool AccessPoint::operator== (const AccessPoint& other) const
|
||||
{
|
||||
return (other.getObjectPath() == getObjectPath());
|
||||
}
|
||||
#if 0
|
||||
AccessPoint& AccessPoint::operator= (const AccessPoint& other)
|
||||
{
|
||||
kdDebug() << "AccessPoint::operator=\n" << endl;
|
||||
d->objPath = other.d->objPath;
|
||||
d->nmAccessPoint = other.d->nmAccessPoint;
|
||||
connect(d->nmAccessPoint, TQT_SIGNAL(PropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)), this, TQT_SLOT(slotPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)));
|
||||
|
||||
updateProperties();
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
AccessPoint::AccessPoint(TQString obj_path, TQObject * parent, const char * name)
|
||||
: TQObject(parent, name)
|
||||
{
|
||||
DBus::AccessPointProxy * proxy = new DBus::AccessPointProxy(NM_DBUS_SERVICE, obj_path);
|
||||
proxy->setConnection(TQT_DBusConnection::systemBus());
|
||||
d = new AccessPointPrivate(obj_path, proxy);
|
||||
|
||||
if (!d->nmAccessPoint.isNull())
|
||||
connect(d->nmAccessPoint, TQT_SIGNAL(PropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)), this, TQT_SLOT(slotPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)));
|
||||
|
||||
updateProperties();
|
||||
}
|
||||
#if 0
|
||||
// copy constructor
|
||||
AccessPoint::AccessPoint(const AccessPoint& other)
|
||||
: TQObject()
|
||||
{
|
||||
// just copy the private data from other
|
||||
d = new AccessPointPrivate(*other.d);
|
||||
|
||||
if (!d->nmAccessPoint.isNull())
|
||||
connect(d->nmAccessPoint, TQT_SIGNAL(PropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)), this, TQT_SLOT(slotPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)));
|
||||
|
||||
updateProperties();
|
||||
}
|
||||
#endif
|
||||
AccessPoint::~AccessPoint()
|
||||
{
|
||||
delete d->nmAccessPoint;
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
#include "knetworkmanager-accesspoint.moc"
|
@ -1,75 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-device.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||||
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_ACCESSPOINT_H
|
||||
#define KNETWORKMANAGER_ACCESSPOINT_H
|
||||
|
||||
#include "knetworkmanager.h"
|
||||
#include <tqdbusvariant.h>
|
||||
|
||||
class AccessPointPrivate;
|
||||
namespace DBus
|
||||
{
|
||||
class AccessPointProxy;
|
||||
};
|
||||
|
||||
class AccessPoint : public TQObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AccessPoint (const AccessPoint&);
|
||||
AccessPoint (TQString objpath = TQString(), TQObject * parent = 0, const char * name = 0);
|
||||
~AccessPoint ();
|
||||
|
||||
AccessPoint& operator= (const AccessPoint& other);
|
||||
bool operator== (const AccessPoint& other) const;
|
||||
|
||||
TQ_UINT32 getFlags() const;
|
||||
TQ_UINT32 getWpaFlags() const;
|
||||
TQ_UINT32 getRsnFlags() const;
|
||||
TQValueList<TQ_UINT8> getSsid() const;
|
||||
TQ_UINT32 getFrequency() const;
|
||||
TQString getHwAddress() const;
|
||||
TQ_INT32 getMode() const;
|
||||
TQ_UINT32 getRate() const;
|
||||
TQ_UINT8 getStrength() const;
|
||||
TQString getDisplaySsid() const;
|
||||
const TQByteArray getSsidByteArray() const;
|
||||
bool isEncrypted() const;
|
||||
TQString getObjectPath() const;
|
||||
bool isValid() const;
|
||||
signals:
|
||||
void strengthChanged(TQ_UINT8);
|
||||
private slots:
|
||||
void slotPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>& properties);
|
||||
void updateProperties();
|
||||
|
||||
private:
|
||||
|
||||
AccessPointPrivate * d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_DEVICE_H */
|
@ -1,67 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-cdma_device.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
// KDE includes
|
||||
#include <kdebug.h>
|
||||
|
||||
// TQt includes
|
||||
#include <tqhostaddress.h>
|
||||
|
||||
// TQT_DBus includes
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqdbusconnection.h>
|
||||
|
||||
// NM includes
|
||||
#include <NetworkManager.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-cdma_device.h"
|
||||
#include "dbus/cdmaproxy.h"
|
||||
|
||||
class CDMADevicePrivate
|
||||
{
|
||||
public:
|
||||
CDMADevicePrivate(TQString service, TQString obj_path)
|
||||
: nmCDMA(service, obj_path)
|
||||
{}
|
||||
~CDMADevicePrivate() {}
|
||||
|
||||
DBus::CDMADeviceProxy nmCDMA;
|
||||
};
|
||||
|
||||
CDMADevice::CDMADevice (const TQString & obj_path)
|
||||
: CellularDevice(obj_path)
|
||||
{
|
||||
d = new CDMADevicePrivate(NM_DBUS_SERVICE, obj_path);
|
||||
d->nmCDMA.setConnection(TQT_DBusConnection::systemBus());
|
||||
}
|
||||
|
||||
CDMADevice::~CDMADevice ()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
#include "knetworkmanager-cdma_device.moc"
|
@ -1,51 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-cdma_device.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_CDMADEVICE_H
|
||||
#define KNETWORKMANAGER_CDMADEVICE_H
|
||||
|
||||
// std includes
|
||||
#include <stdint.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-cellular_device.h"
|
||||
|
||||
class KNetworkManager;
|
||||
|
||||
class CDMADevicePrivate;
|
||||
|
||||
class CDMADevice : public CellularDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CDMADevice (const TQString & obj_path );
|
||||
~CDMADevice ();
|
||||
|
||||
private:
|
||||
CDMADevicePrivate * d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_CDMADEVICE_H */
|
@ -1,37 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-cellular_device.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
*
|
||||
* Author: Will Stephenson <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager-cellular_device.h"
|
||||
|
||||
CellularDevice::CellularDevice (const TQString & obj_path)
|
||||
: Device(obj_path)
|
||||
{
|
||||
}
|
||||
|
||||
CellularDevice::~CellularDevice()
|
||||
{
|
||||
}
|
||||
|
||||
#include "knetworkmanager-cellular_device.moc"
|
@ -1,40 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-cellular_device.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
*
|
||||
* Author: Will Stephenson <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_CELLULARDEVICE_H
|
||||
#define KNETWORKMANAGER_CELLULARDEVICE_H
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager-device.h"
|
||||
|
||||
class CellularDevice : public Device
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CellularDevice (const TQString & obj_path );
|
||||
~CellularDevice ();
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_CELLULARDEVICE_H */
|
@ -1,296 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-connection.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/* qt headers */
|
||||
#include <tqvaluelist.h>
|
||||
|
||||
/* kde headers */
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
|
||||
/* TQDbus headers */
|
||||
#include <tqdbusconnection.h>
|
||||
#include <tqdbusobjectpath.h>
|
||||
#include <tqdbusdata.h>
|
||||
#include <tqdbusdatamap.h>
|
||||
#include <tqdbusvariant.h>
|
||||
|
||||
/* knetworkmanager headers */
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-connection.h"
|
||||
#include "knetworkmanager-connection_dbus.h"
|
||||
#include "knetworkmanager-connection_secrets_dbus.h"
|
||||
#include "knetworkmanager-connection_setting.h"
|
||||
#include "knetworkmanager-nmsettings.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern unsigned char vpn_new_credentials_needed;
|
||||
|
||||
using namespace ConnectionSettings;
|
||||
|
||||
namespace ConnectionSettings
|
||||
{
|
||||
|
||||
class ConnectionPrivate
|
||||
{
|
||||
public:
|
||||
ConnectionPrivate(Connection* parent)
|
||||
{
|
||||
conn_dbus = new ConnectionDBus(parent);
|
||||
conn_secrets_dbus = new ConnectionSecretsDBus(parent);
|
||||
secrets_requested = false;
|
||||
}
|
||||
~ConnectionPrivate() {}
|
||||
|
||||
TQT_DBusObjectPath obj_path;
|
||||
ConnectionDBus* conn_dbus;
|
||||
ConnectionSecretsDBus* conn_secrets_dbus;
|
||||
TQValueList<ConnectionSetting*> settings;
|
||||
TQString specific_object;
|
||||
bool secrets_requested;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
class Connection
|
||||
*/
|
||||
Connection::Connection()
|
||||
{
|
||||
d = new ConnectionPrivate(this);
|
||||
|
||||
NMSettings* nmSettings = NMSettings::getInstance();
|
||||
d->obj_path = nmSettings->getObjPathForConnection();
|
||||
|
||||
TQT_DBusConnection conn = TQT_DBusConnection::systemBus();
|
||||
|
||||
if (!registerObject(conn, objectPath()))
|
||||
kdError() << "registerobjectpath failed" << endl;
|
||||
|
||||
// get notified whenever NM needs a secret
|
||||
connect(d->conn_secrets_dbus, TQT_SIGNAL(SecretsNeeded(const TQString&, const TQStringList&, bool)), this, TQT_SLOT(slotSecretsNeeded(const TQString&, const TQStringList&, bool)));
|
||||
}
|
||||
|
||||
Connection::~Connection()
|
||||
{
|
||||
for (TQValueList<ConnectionSetting*>::Iterator it= d->settings.begin(); it != d->settings.end(); ++it)
|
||||
{
|
||||
delete (*it);
|
||||
*it = NULL;
|
||||
}
|
||||
delete d;
|
||||
}
|
||||
|
||||
ConnectionSetting*
|
||||
Connection::getSetting(const TQString& type) const
|
||||
{
|
||||
// find a setting by its type
|
||||
for (TQValueList<ConnectionSetting*>::ConstIterator it = d->settings.begin(); it != d->settings.end(); ++it)
|
||||
{
|
||||
if ((*it)->getType() == type)
|
||||
return (*it);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TQValueList<ConnectionSetting*>
|
||||
Connection::getSettings() const
|
||||
{
|
||||
return d->settings;
|
||||
}
|
||||
|
||||
void
|
||||
Connection::appendSetting(ConnectionSetting* setting)
|
||||
{
|
||||
// that's our setting now :)
|
||||
d->settings.append(setting);
|
||||
connect(setting, TQT_SIGNAL(validityChanged()), this, TQT_SLOT(slotSettingValidityChanged()));
|
||||
}
|
||||
|
||||
void
|
||||
Connection::setSpecificObject(const TQString& obj_path)
|
||||
{
|
||||
d->specific_object = obj_path;
|
||||
}
|
||||
|
||||
TQString
|
||||
Connection::getSpecificObject() const
|
||||
{
|
||||
return d->specific_object;
|
||||
}
|
||||
|
||||
TQT_DBusObjectPath
|
||||
Connection::getObjectPath() const
|
||||
{
|
||||
return d->obj_path;
|
||||
}
|
||||
|
||||
TQString
|
||||
Connection::objectPath() const
|
||||
{
|
||||
return d->obj_path;
|
||||
}
|
||||
|
||||
bool
|
||||
Connection::isValid() const
|
||||
{
|
||||
bool retval = true;
|
||||
// check if every enabled setting is valid
|
||||
for (TQValueList<ConnectionSetting*>::ConstIterator it = d->settings.begin(); it != d->settings.end(); ++it)
|
||||
{
|
||||
if ((*it)->getEnabled())
|
||||
retval &= (*it)->isValid();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
Connection::slotSecretsNeeded(const TQString& setting_name, const TQStringList& hints, bool request_new)
|
||||
{
|
||||
printf("Connection::slotSecretsNeeded %s, new: %s\n\r", setting_name.ascii(), (request_new ? "yes" : "no"));
|
||||
kdDebug() << "Connection::slotSecretsNeeded " << setting_name.ascii() << ", new: " << (request_new ? "yes" : "no") << endl;
|
||||
ConnectionSetting* setting = getSetting(setting_name);
|
||||
|
||||
// If needed, request new VPN credentials
|
||||
if (strcmp("vpn", setting_name.ascii()) == 0) {
|
||||
if (vpn_new_credentials_needed == 1) {
|
||||
vpn_new_credentials_needed = 0;
|
||||
request_new = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!setting)
|
||||
{
|
||||
// send an error to NM
|
||||
d->conn_secrets_dbus->SendGetSecretsReply(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!request_new && setting->hasSecrets())
|
||||
{
|
||||
// if the setting has secrets just send them
|
||||
d->conn_secrets_dbus->SendGetSecretsReply(setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
// NetworkManager asks for new secrets, ask user for new secrets/retry
|
||||
d->secrets_requested = true;
|
||||
emit SecretsNeeded(this, setting, hints, request_new);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Connection::slotSecretsProvided(ConnectionSetting* setting)
|
||||
{
|
||||
if (!d->secrets_requested)
|
||||
return;
|
||||
|
||||
if (!setting)
|
||||
{
|
||||
// send all settings to NM
|
||||
d->conn_secrets_dbus->SendGetSecretsReply(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we have the secrets already send them to NM
|
||||
d->conn_secrets_dbus->SendGetSecretsReply(setting);
|
||||
}
|
||||
d->secrets_requested = false;
|
||||
}
|
||||
|
||||
void
|
||||
Connection::slotSecretsError()
|
||||
{
|
||||
if (!d->secrets_requested)
|
||||
return;
|
||||
|
||||
d->conn_secrets_dbus->SendGetSecretsError();
|
||||
d->secrets_requested = false;
|
||||
}
|
||||
|
||||
TQT_DBusObjectBase*
|
||||
Connection::createInterface(const TQString& interfaceName)
|
||||
{
|
||||
// the interfaces are already created, just return the right one
|
||||
if (interfaceName == NM_DBUS_IFACE_SETTINGS_CONNECTION)
|
||||
return d->conn_dbus;
|
||||
|
||||
if (interfaceName == NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS)
|
||||
return d->conn_secrets_dbus;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TQString
|
||||
Connection::getType()
|
||||
{
|
||||
return TQString();
|
||||
}
|
||||
|
||||
void
|
||||
Connection::slotSettingValidityChanged()
|
||||
{
|
||||
emit validityChanged();
|
||||
}
|
||||
|
||||
void
|
||||
Connection::slotAboutToBeRemoved()
|
||||
{
|
||||
d->conn_dbus->slotAboutToBeRemoved();
|
||||
}
|
||||
void
|
||||
Connection::slotUpdated()
|
||||
{
|
||||
d->conn_dbus->slotUpdated();
|
||||
}
|
||||
|
||||
void
|
||||
Connection::updateSettings(Connection* conn)
|
||||
{
|
||||
TQValueList<ConnectionSetting*> settings = conn->getSettings();
|
||||
// copy all settings over to the new connection
|
||||
for (TQValueList<ConnectionSetting*>::Iterator it = settings.begin(); it != settings.end(); ++it)
|
||||
{
|
||||
ConnectionSetting* other_setting = *it;
|
||||
ConnectionSetting* my_setting = getSetting(other_setting->getType());
|
||||
if (my_setting)
|
||||
{
|
||||
my_setting->fromMap(other_setting->toMap());
|
||||
my_setting->fromSecretsMap(other_setting->toSecretsMap(false));
|
||||
}
|
||||
else
|
||||
{
|
||||
// should not happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Connection::awaitingSecrets()
|
||||
{
|
||||
return d->secrets_requested;
|
||||
}
|
||||
|
||||
#include "knetworkmanager-connection.moc"
|
@ -1,131 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-connection.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_CONNECTION_H
|
||||
#define KNETWORKMANAGER_CONNECTION_H
|
||||
|
||||
#include <tqmap.h>
|
||||
#include <tqobject.h>
|
||||
|
||||
#include "knetworkmanager-connection_setting.h"
|
||||
|
||||
class AccessPoint;
|
||||
class TQT_DBusObjectPath;
|
||||
|
||||
namespace ConnectionSettings
|
||||
{
|
||||
|
||||
class WirelessSecurity;
|
||||
class Connection;
|
||||
class ConnectionSetting;
|
||||
class ConnectionPrivate;
|
||||
class Info;
|
||||
class Wired;
|
||||
class Wireless;
|
||||
class WirelessSecurity;
|
||||
class IPv4;
|
||||
|
||||
typedef TQMap<TQString, SettingsMap> ConnectionMap;
|
||||
|
||||
// a connection wraps multiple settings
|
||||
class Connection : public TQObject, DBus::ConnectionNode
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Connection();
|
||||
virtual ~Connection();
|
||||
|
||||
virtual TQString getID() const = 0;
|
||||
virtual void setID(const TQString& id) = 0;
|
||||
|
||||
// get a specific setting
|
||||
ConnectionSetting* getSetting(const TQString&) const;
|
||||
|
||||
// get all settings of this connection
|
||||
TQValueList<ConnectionSetting*> getSettings() const;
|
||||
|
||||
// attach a new setting
|
||||
virtual void appendSetting(ConnectionSetting* setting);
|
||||
|
||||
// ugly stuff introduced by NM
|
||||
void setSpecificObject(const TQString&);
|
||||
TQString getSpecificObject() const;
|
||||
|
||||
// sometimes its usefull to have the object_path
|
||||
TQT_DBusObjectPath getObjectPath() const;
|
||||
|
||||
// is the connection valid?
|
||||
virtual bool isValid() const;
|
||||
|
||||
// the connections type (only for KNM use)
|
||||
virtual TQString getType();
|
||||
|
||||
// duplicate
|
||||
virtual Connection* duplicate() = 0;
|
||||
|
||||
// update the settings from another connection
|
||||
void updateSettings(Connection*);
|
||||
|
||||
// true if the NM requested new secrets for this connection
|
||||
bool awaitingSecrets();
|
||||
|
||||
public slots:
|
||||
|
||||
// gets called from NM when it needs the secrets
|
||||
void slotSecretsNeeded(const TQString& setting_name, const TQStringList& hints, bool request_new);
|
||||
|
||||
// gets called when the GUI provided new secrets
|
||||
void slotSecretsProvided(ConnectionSetting* setting);
|
||||
|
||||
// signal a failure in getting new secrets
|
||||
void slotSecretsError();
|
||||
|
||||
// gets called when a settings validity changes
|
||||
void slotSettingValidityChanged();
|
||||
|
||||
// gets called when the connection is about to be removed
|
||||
void slotAboutToBeRemoved();
|
||||
|
||||
// gets called when the connections settings changed
|
||||
void slotUpdated();
|
||||
|
||||
protected:
|
||||
// implementations for ConnectionNode
|
||||
TQT_DBusObjectBase* createInterface(const TQString& interfaceName);
|
||||
TQString objectPath() const;
|
||||
|
||||
signals:
|
||||
|
||||
// signal when we need new secrets
|
||||
void SecretsNeeded(Connection* connection, ConnectionSetting* setting, const TQStringList& hints, bool request_new);
|
||||
|
||||
// signal gets emitted when connections validity changes
|
||||
void validityChanged();
|
||||
|
||||
private:
|
||||
ConnectionPrivate* d;
|
||||
};
|
||||
}
|
||||
#endif /* KNETWORKMANAGER_CONNECTION_H */
|
@ -1,200 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/* qt headers */
|
||||
#include <tqvaluelist.h>
|
||||
|
||||
/* kde headers */
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
|
||||
/* TQDbus headers */
|
||||
#include <tqdbusconnection.h>
|
||||
#include <tqdbusobjectpath.h>
|
||||
#include <tqdbusdata.h>
|
||||
#include <tqdbusdatamap.h>
|
||||
#include <tqdbusvariant.h>
|
||||
#include <tqdbuserror.h>
|
||||
|
||||
/* NM headers */
|
||||
#include <NetworkManager.h>
|
||||
|
||||
/* knetworkmanager headers */
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-connection.h"
|
||||
#include "knetworkmanager-connection_dbus.h"
|
||||
#include "knetworkmanager-connection_setting.h"
|
||||
#include "knetworkmanager-nmsettings.h"
|
||||
#include "xmlmarshaller.h"
|
||||
|
||||
using namespace ConnectionSettings;
|
||||
|
||||
namespace ConnectionSettings
|
||||
{
|
||||
|
||||
class ConnectionDBusPrivate
|
||||
{
|
||||
public:
|
||||
ConnectionDBusPrivate() {}
|
||||
~ConnectionDBusPrivate() {}
|
||||
|
||||
ConnectionSettings::Connection* parent;
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
class Connection
|
||||
*/
|
||||
ConnectionDBus::ConnectionDBus(ConnectionSettings::Connection* parent)
|
||||
: TQObject(parent)
|
||||
{
|
||||
d = new ConnectionDBusPrivate();
|
||||
d->parent = parent;
|
||||
}
|
||||
|
||||
ConnectionDBus::~ConnectionDBus()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool
|
||||
ConnectionDBus::GetID(TQString& id, TQT_DBusError& /*error*/)
|
||||
{
|
||||
kdDebug() << "Connection::GetID" << endl;
|
||||
id = d->parent->getID();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ConnectionDBus::GetSettings(TQT_DBusDataMap<TQString>& settings, TQT_DBusError& /*error*/)
|
||||
{
|
||||
kdDebug() << "Connection::GetSettings, obj: " << objectPath().ascii() << endl;
|
||||
|
||||
TQValueList<ConnectionSetting*> all_settings = d->parent->getSettings();
|
||||
|
||||
// FIXME: ugly conversions, ask Kevin on how to make it better
|
||||
for (TQValueList<ConnectionSetting*>::Iterator it = all_settings.begin(); it != all_settings.end(); ++it)
|
||||
{
|
||||
kdDebug() << " Processing Setting '" << (*it)->getType().ascii() << "'" << endl;
|
||||
// only append this setting if it is really used
|
||||
if (!(*it)->getEnabled())
|
||||
{
|
||||
kdDebug() << " Setting '" << (*it)->getType().ascii() << "' is not enabled, discarding" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(*it)->isValid())
|
||||
{
|
||||
kdDebug() << " Setting '" << (*it)->getType().ascii() << "' is not valid, discarding" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
// copy the settingsmap over to a variantmap
|
||||
TQMap<TQString, TQT_DBusData> map = (*it)->toMap();
|
||||
|
||||
// only take used settings
|
||||
if (map.size() == 0)
|
||||
{
|
||||
kdDebug() << " Setting '" << (*it)->getType().ascii() << "' is empty, discarding" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
kdDebug() << " Attach setting '" << (*it)->getType().ascii() << "'" << endl;
|
||||
|
||||
TQMap<TQString, TQT_DBusVariant> variant_map;
|
||||
|
||||
for (TQMap<TQString, TQT_DBusData>::Iterator it2 = map.begin(); it2 != map.end(); ++it2)
|
||||
{
|
||||
TQString dataxml = XMLMarshaller::fromTQT_DBusData(it2.data());
|
||||
kdDebug() << " " << it2.key().ascii() << ": " << dataxml.replace('\n', ' ').ascii() << endl;
|
||||
TQT_DBusVariant var;
|
||||
var.value = it2.data();
|
||||
var.signature = var.value.buildDBusSignature();
|
||||
variant_map.insert(it2.key(), var);
|
||||
}
|
||||
|
||||
// convert the variantma
|
||||
TQT_DBusDataMap<TQString> map2 = TQT_DBusDataMap<TQString>(variant_map);
|
||||
TQT_DBusData data = TQT_DBusData::fromStringKeyMap(map2);
|
||||
|
||||
// insert this setting
|
||||
settings.insert((*it)->getType(), data);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ConnectionDBus::Update(const TQT_DBusDataMap<TQString>& properties, TQT_DBusError& error)
|
||||
{
|
||||
// FIXME
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ConnectionDBus::Delete(TQT_DBusError& error)
|
||||
{
|
||||
// FIXME
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConnectionDBus::handleMethodReply(const TQT_DBusMessage& reply)
|
||||
{
|
||||
TQT_DBusConnection::systemBus().send(reply);
|
||||
}
|
||||
|
||||
bool
|
||||
ConnectionDBus::handleSignalSend(const TQT_DBusMessage& reply)
|
||||
{
|
||||
TQT_DBusConnection::systemBus().send(reply);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
TQString
|
||||
ConnectionDBus::objectPath() const
|
||||
{
|
||||
return TQString(d->parent->getObjectPath());
|
||||
}
|
||||
|
||||
void
|
||||
ConnectionDBus::slotAboutToBeRemoved()
|
||||
{
|
||||
// tell NM about us being removed
|
||||
emitRemoved();
|
||||
}
|
||||
|
||||
void
|
||||
ConnectionDBus::slotUpdated()
|
||||
{
|
||||
TQT_DBusDataMap<TQString> settings;
|
||||
TQT_DBusError error;
|
||||
if (GetSettings(settings, error))
|
||||
emitUpdated(settings);
|
||||
}
|
||||
|
||||
#include "knetworkmanager-connection_dbus.moc"
|
@ -1,77 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-devicestore_dbus.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_CONNECTION_DBUS_H
|
||||
#define KNETWORKMANAGER_CONNECTION_DBUS_H
|
||||
|
||||
#include <hal/libhal.h>
|
||||
#include <stdint.h>
|
||||
#include <tqhostaddress.h>
|
||||
#include <tqmap.h>
|
||||
#include <tqvariant.h>
|
||||
#include <tqobject.h>
|
||||
|
||||
#include "knetworkmanager-connection_setting.h"
|
||||
#include "dbus/connection.h"
|
||||
#include "dbus/connectionnode.h"
|
||||
|
||||
class TQT_DBusObjectPath;
|
||||
|
||||
namespace ConnectionSettings
|
||||
{
|
||||
|
||||
class Connection;
|
||||
class ConnectionSetting;
|
||||
class ConnectionDBusPrivate;
|
||||
|
||||
// DBUS abstraction for a connection
|
||||
class ConnectionDBus : public TQObject, public DBus::Connection
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConnectionDBus(ConnectionSettings::Connection* parent);
|
||||
~ConnectionDBus();
|
||||
|
||||
public slots:
|
||||
void slotAboutToBeRemoved();
|
||||
void slotUpdated();
|
||||
|
||||
protected:
|
||||
// implementations of the Setting DBus-interface
|
||||
bool GetID(TQString& id, TQT_DBusError& error);
|
||||
bool GetSettings(TQT_DBusDataMap<TQString>& settings, TQT_DBusError& error);
|
||||
bool Update(const TQT_DBusDataMap<TQString>& properties, TQT_DBusError& error);
|
||||
bool Delete(TQT_DBusError& error);
|
||||
|
||||
// used from both interfaces
|
||||
void handleMethodReply(const TQT_DBusMessage& reply);
|
||||
bool handleSignalSend(const TQT_DBusMessage& reply);
|
||||
TQString objectPath() const;
|
||||
|
||||
private:
|
||||
ConnectionDBusPrivate* d;
|
||||
};
|
||||
}
|
||||
#endif /* KNETWORKMANAGER_CONNECTION_DBUS_H */
|
@ -1,230 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-devicestore_dbus.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/* qt headers */
|
||||
#include <tqhostaddress.h>
|
||||
#include <tqvariant.h>
|
||||
#include <tqvaluelist.h>
|
||||
|
||||
/* kde headers */
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
|
||||
/* TQDbus headers */
|
||||
#include <tqdbusconnection.h>
|
||||
#include <tqdbusobjectpath.h>
|
||||
#include <tqdbusdata.h>
|
||||
#include <tqdbusdatalist.h>
|
||||
#include <tqdbusdatamap.h>
|
||||
#include <tqdbusvariant.h>
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqdbusmessage.h>
|
||||
|
||||
/* NM headers */
|
||||
#include <NetworkManager.h>
|
||||
|
||||
/* knetworkmanager headers */
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-connection.h"
|
||||
#include "knetworkmanager-connection_secrets_dbus.h"
|
||||
#include "knetworkmanager-connection_dbus.h"
|
||||
#include "knetworkmanager-connection_setting.h"
|
||||
#include "knetworkmanager-connection_setting_info.h"
|
||||
#include "knetworkmanager-connection_setting_ipv4.h"
|
||||
#include "knetworkmanager-connection_setting_wired.h"
|
||||
#include "knetworkmanager-connection_setting_wireless.h"
|
||||
#include "knetworkmanager-connection_setting_wireless_security.h"
|
||||
#include "knetworkmanager-accesspoint.h"
|
||||
#include "knetworkmanager-nmsettings.h"
|
||||
#include "xmlmarshaller.h"
|
||||
#include "stdio.h"
|
||||
|
||||
using namespace ConnectionSettings;
|
||||
|
||||
namespace ConnectionSettings
|
||||
{
|
||||
|
||||
class ConnectionSecretsDBusPrivate
|
||||
{
|
||||
public:
|
||||
ConnectionSecretsDBusPrivate(Connection* par)
|
||||
: parent(par)
|
||||
, currentRequest(-1)
|
||||
{}
|
||||
~ConnectionSecretsDBusPrivate() {}
|
||||
|
||||
Connection* parent;
|
||||
int currentRequest;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
class Connection
|
||||
*/
|
||||
ConnectionSecretsDBus::ConnectionSecretsDBus(Connection* parent)
|
||||
: TQObject(parent)
|
||||
{
|
||||
d = new ConnectionSecretsDBusPrivate(parent);
|
||||
}
|
||||
|
||||
ConnectionSecretsDBus::~ConnectionSecretsDBus()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void
|
||||
ConnectionSecretsDBus::SendGetSecretsError()
|
||||
{
|
||||
GetSecretsAsyncError(d->currentRequest, TQT_DBusError::stdFailed("Requested setting is empty"));
|
||||
}
|
||||
|
||||
void
|
||||
ConnectionSecretsDBus::SendGetSecretsReply(ConnectionSettings::ConnectionSetting* setting)
|
||||
{
|
||||
TQT_DBusMessage reply;
|
||||
|
||||
kdDebug() << "SendGetSecretsReply1 id " << d->currentRequest << endl;
|
||||
|
||||
// if no secret is needed we should not send one, right?
|
||||
if (d->currentRequest < 0)
|
||||
return;
|
||||
kdDebug() << "SendGetSecretsReply2" << endl;
|
||||
/*
|
||||
// no such setting
|
||||
if (!setting)
|
||||
{
|
||||
GetSecretsAsyncError(d->currentRequest, TQT_DBusError::stdFailed("Requested setting is unknown"));
|
||||
}
|
||||
else
|
||||
{
|
||||
kdDebud() << "SendGetSecretsReply3" << endl;
|
||||
// copy the settingsmap over to a variantmap
|
||||
TQMap<TQString, TQT_DBusData> map = setting->toSecretsMap();
|
||||
|
||||
// only take used settings
|
||||
if (map.size() == 0)
|
||||
{
|
||||
kdDebug() << "SendGetSecretsReply4" << endl;
|
||||
GetSecretsAsyncError(d->currentRequest, TQT_DBusError::stdFailed("Requested setting is empty"));
|
||||
}
|
||||
else
|
||||
{
|
||||
kdDebug() << "SendGetSecretsReply5" << endl;
|
||||
TQT_DBusDataMap<TQString> secrets(map);
|
||||
|
||||
TQMap<TQString, TQT_DBusVariant> secrets;
|
||||
for (TQMap<TQString, TQT_DBusData>::Iterator it2 = map.begin(); it2 != map.end(); ++it2)
|
||||
{
|
||||
TQT_DBusVariant var;
|
||||
var.value = it2.data();
|
||||
var.signature = var.value.buildDBusSignature();
|
||||
secrets.insert(it2.key(), var);
|
||||
}
|
||||
kdDebug() << "SendGetSecretsReply6" << endl;
|
||||
|
||||
GetSecretsAsyncReply(d->currentRequest, secrets);
|
||||
}
|
||||
}*/
|
||||
|
||||
TQT_DBusDataMap<TQString> settings;
|
||||
TQValueList<ConnectionSetting*> all_settings = d->parent->getSettings();
|
||||
|
||||
// FIXME: ugly conversions, ask Kevin on how to make it better
|
||||
for (TQValueList<ConnectionSetting*>::Iterator it = all_settings.begin(); it != all_settings.end(); ++it)
|
||||
{
|
||||
kdDebug() << " Processing Setting '" << (*it)->getType().ascii() << "'" << endl;
|
||||
if (!(*it)->isValid())
|
||||
{
|
||||
kdDebug() << " Setting '" << (*it)->getType().ascii() << "' is not valid, discarding" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
// copy the settingsmap over to a variantmap
|
||||
TQMap<TQString, TQT_DBusData> map = (*it)->toSecretsMap();
|
||||
|
||||
// only take used settings
|
||||
if (map.size() == 0)
|
||||
{
|
||||
kdDebug() << " Setting '" << (*it)->getType().ascii() << "' is empty, discarding" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
kdDebug() << " Attach setting '" << (*it)->getType().ascii() << "'" << endl;
|
||||
|
||||
TQMap<TQString, TQT_DBusVariant> variant_map;
|
||||
|
||||
for (TQMap<TQString, TQT_DBusData>::Iterator it2 = map.begin(); it2 != map.end(); ++it2)
|
||||
{
|
||||
TQString dataxml = XMLMarshaller::fromTQT_DBusData(it2.data());
|
||||
kdDebug() << " " << it2.key().ascii() << ": " << dataxml.replace('\n', ' ').ascii() << endl;
|
||||
TQT_DBusVariant var;
|
||||
var.value = it2.data();
|
||||
var.signature = var.value.buildDBusSignature();
|
||||
variant_map.insert(it2.key(), var);
|
||||
}
|
||||
|
||||
// convert the variantma
|
||||
TQT_DBusDataMap<TQString> map2 = TQT_DBusDataMap<TQString>(variant_map);
|
||||
TQT_DBusData data = TQT_DBusData::fromStringKeyMap(map2);
|
||||
|
||||
// insert this setting
|
||||
settings.insert((*it)->getType(), data);
|
||||
}
|
||||
|
||||
GetSecretsAsyncReply(d->currentRequest, settings);
|
||||
d->currentRequest = -1;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
ConnectionSecretsDBus::GetSecretsAsync(int id, const TQString& setting_name, const TQStringList& hints, bool request_new)
|
||||
{
|
||||
printf("Connection::GetSecretsAsync for setting %s, %s\n\r", setting_name.ascii(), id);
|
||||
kdDebug() << "Connection::GetSecretsAsync for setting " << setting_name.ascii() << ", " << id << endl;
|
||||
d->currentRequest = id;
|
||||
emit SecretsNeeded(setting_name, hints, request_new);
|
||||
}
|
||||
|
||||
void
|
||||
ConnectionSecretsDBus::handleMethodReply(const TQT_DBusMessage& reply)
|
||||
{
|
||||
TQT_DBusConnection::systemBus().send(reply);
|
||||
}
|
||||
|
||||
bool
|
||||
ConnectionSecretsDBus::handleSignalSend(const TQT_DBusMessage& reply)
|
||||
{
|
||||
TQT_DBusConnection::systemBus().send(reply);
|
||||
return true;
|
||||
}
|
||||
|
||||
TQString
|
||||
ConnectionSecretsDBus::objectPath() const
|
||||
{
|
||||
return TQString(d->parent->getObjectPath());
|
||||
}
|
||||
|
||||
|
||||
#include "knetworkmanager-connection_secrets_dbus.moc"
|
@ -1,76 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-devicestore_dbus.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_CONNECTION_SECRETS_DBUS_H
|
||||
#define KNETWORKMANAGER_CONNECTION_SECRETS_DBUS_H
|
||||
|
||||
#include <hal/libhal.h>
|
||||
#include <stdint.h>
|
||||
#include <tqhostaddress.h>
|
||||
#include <tqmap.h>
|
||||
#include <tqvariant.h>
|
||||
#include <tqobject.h>
|
||||
|
||||
#include "knetworkmanager-connection_setting.h"
|
||||
#include "dbus/connection.h"
|
||||
#include "dbus/connectionnode.h"
|
||||
|
||||
class AccessPoint;
|
||||
class TQT_DBusObjectPath;
|
||||
namespace ConnectionSettings
|
||||
{
|
||||
|
||||
class WirelessSecurity;
|
||||
class Connection;
|
||||
class ConnectionSetting;
|
||||
class ConnectionSecretsDBusPrivate;
|
||||
|
||||
// a connection wraps multiple settings
|
||||
class ConnectionSecretsDBus : public TQObject, public DBus::Secrets
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConnectionSecretsDBus(ConnectionSettings::Connection* parent);
|
||||
virtual ~ConnectionSecretsDBus();
|
||||
|
||||
void SendGetSecretsReply(ConnectionSettings::ConnectionSetting* setting);
|
||||
void SendGetSecretsError();
|
||||
|
||||
protected:
|
||||
// implementation of the Secrets DBus-interface
|
||||
void GetSecretsAsync(int, const TQString&, const TQStringList&, bool);
|
||||
void handleMethodReply(const TQT_DBusMessage& reply);
|
||||
bool handleSignalSend(const TQT_DBusMessage& reply);
|
||||
TQString objectPath() const;
|
||||
|
||||
signals:
|
||||
void SecretsNeeded(const TQString& setting_name, const TQStringList& hints, bool request_new);
|
||||
|
||||
private:
|
||||
ConnectionSecretsDBusPrivate* d;
|
||||
};
|
||||
|
||||
}
|
||||
#endif /* KNETWORKMANAGER_CONNECTION_SECRETS_DBUS_H */
|
@ -1,191 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-connection_store.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <tqtimer.h>
|
||||
#include <tquuid.h>
|
||||
#include <tqdbusobjectpath.h>
|
||||
|
||||
#include <kstaticdeleter.h>
|
||||
#include <kapplication.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "knetworkmanager-connection_store.h"
|
||||
#include "knetworkmanager-connection.h"
|
||||
#include "knetworkmanager-connection_setting.h"
|
||||
#include "knetworkmanager-connection_setting_info.h"
|
||||
#include "knetworkmanager-connection_setting_ipv4.h"
|
||||
#include "knetworkmanager-connection_setting_wired.h"
|
||||
#include "knetworkmanager-connection_setting_wireless.h"
|
||||
#include "knetworkmanager-connection_setting_wireless_security.h"
|
||||
|
||||
using namespace ConnectionSettings;
|
||||
|
||||
static KStaticDeleter<ConnectionStore> sd;
|
||||
|
||||
ConnectionStore* ConnectionStore::_instance = NULL;
|
||||
|
||||
ConnectionStore*
|
||||
ConnectionStore::getInstance()
|
||||
{
|
||||
if (_instance)
|
||||
return _instance;
|
||||
return sd.setObject(_instance, new ConnectionStore());
|
||||
}
|
||||
|
||||
ConnectionStore::ConnectionStore()
|
||||
: _connectionList()
|
||||
{
|
||||
// defer the connection init a bit
|
||||
TQTimer::singleShot(0, this, TQT_SLOT(slotInit()));
|
||||
}
|
||||
|
||||
ConnectionStore::~ConnectionStore()
|
||||
{
|
||||
for (TQValueList<Connection*>::Iterator it = _connectionList.begin(); it != _connectionList.end(); ++it)
|
||||
{
|
||||
delete (*it);
|
||||
*it = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ConnectionStore::slotInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
ConnectionStore::slotSecretsNeeded(Connection* conn, ConnectionSetting* setting, const TQStringList& hints, bool request_new)
|
||||
{
|
||||
kdDebug() << "ConnectionStore::slotSecretsNeeded" << endl;
|
||||
emit SecretsNeeded(conn, setting, hints, request_new);
|
||||
}
|
||||
|
||||
void
|
||||
ConnectionStore::addConnection(Connection* con)
|
||||
{
|
||||
if (_connectionList.find(con) != _connectionList.end())
|
||||
{
|
||||
con->slotUpdated();
|
||||
emit signalConnectionUpdated(con);
|
||||
return;
|
||||
}
|
||||
|
||||
// check if the connection has an ID already
|
||||
if (con->getID().isEmpty())
|
||||
{
|
||||
// set unique id for this connection
|
||||
con->setID(createNewConnectionID());
|
||||
}
|
||||
|
||||
// we own the connection now
|
||||
_connectionList.append(con);
|
||||
|
||||
// let's get notified if the connection asks for new secrets
|
||||
connect(con, TQT_SIGNAL(SecretsNeeded(Connection*, ConnectionSetting*, const TQStringList&, bool)),
|
||||
this, TQT_SLOT(slotSecretsNeeded(Connection*, ConnectionSetting*, const TQStringList&, bool)));
|
||||
|
||||
// new connection, ring ring
|
||||
emit signalConnectionAdded(con);
|
||||
}
|
||||
|
||||
void
|
||||
ConnectionStore::removeConnection(Connection* con)
|
||||
{
|
||||
// check if the connection is != NULL
|
||||
if (!con)
|
||||
return;
|
||||
|
||||
// remove the object from our list
|
||||
if (_connectionList.remove(con) == 0)
|
||||
return;
|
||||
|
||||
// notify everybody about the removed connection
|
||||
emit signalConnectionRemoved(con);
|
||||
|
||||
// delete the connection, it will deregister itself from NM
|
||||
con->slotAboutToBeRemoved();
|
||||
delete con;
|
||||
}
|
||||
|
||||
Connection*
|
||||
ConnectionStore::getConnection(const TQString& obj_path)
|
||||
{
|
||||
// find a connection by obj_path
|
||||
TQValueList<Connection*>::Iterator it = _connectionList.begin();
|
||||
for (; it != _connectionList.end(); ++it)
|
||||
if (TQString((*it)->getObjectPath()) == obj_path)
|
||||
return (*it);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TQValueList<Connection*>
|
||||
ConnectionStore::getConnections(const TQString& type)
|
||||
{
|
||||
// return a list of connection
|
||||
if (type.isEmpty())
|
||||
return _connectionList;
|
||||
else
|
||||
{
|
||||
TQValueList<Connection*> ret;
|
||||
for (TQValueList<Connection*>::Iterator it = _connectionList.begin(); it != _connectionList.end(); ++it)
|
||||
{
|
||||
if ( (*it)->getType() == type)
|
||||
ret.append(*it);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
TQString
|
||||
ConnectionStore::createNewConnectionID()
|
||||
{
|
||||
bool unique;
|
||||
TQString id;
|
||||
|
||||
do
|
||||
{
|
||||
unique = true;
|
||||
|
||||
// 16 bytes of randomness should be enougth for getting a unique ID
|
||||
id = TQUuid::createUuid().toString();
|
||||
id = id.replace("{","");
|
||||
id = id.replace("}","");
|
||||
|
||||
// nevertheless check if the id is used already
|
||||
TQValueList<Connection*>::Iterator it = _connectionList.begin();
|
||||
for (; it != _connectionList.end(); ++it)
|
||||
{
|
||||
if ((*it)->getID() == id)
|
||||
{
|
||||
unique = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (unique == false);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
#include "knetworkmanager-connection_store.moc"
|
@ -1,88 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-connection_store.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_CONNECTION_STORE_H
|
||||
#define KNETWORKMANAGER_CONNECTION_STORE_H
|
||||
|
||||
#include <tqvaluelist.h>
|
||||
#include <tqobject.h>
|
||||
|
||||
namespace ConnectionSettings
|
||||
{
|
||||
class Connection;
|
||||
class ConnectionSetting;
|
||||
}
|
||||
|
||||
using namespace ConnectionSettings;
|
||||
|
||||
class ConnectionStore : public TQObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
static ConnectionStore* getInstance();
|
||||
~ConnectionStore();
|
||||
|
||||
// add a new connection to the store
|
||||
void addConnection(ConnectionSettings::Connection*);
|
||||
|
||||
// get all connections
|
||||
TQValueList<ConnectionSettings::Connection*> getConnections(const TQString& type = TQString());
|
||||
|
||||
// get a connection by ID
|
||||
ConnectionSettings::Connection* getConnection(const TQString&);
|
||||
|
||||
// delete the specified connection from the store and delete it
|
||||
void removeConnection(ConnectionSettings::Connection*);
|
||||
|
||||
public slots:
|
||||
// has to be called as response to the signal SecretsNeeded
|
||||
void slotSecretsNeeded(Connection* connection, ConnectionSetting* setting, const TQStringList& hints, bool request_new);
|
||||
|
||||
signals:
|
||||
// emitted when a new connection is added to the store
|
||||
void signalConnectionAdded(ConnectionSettings::Connection*);
|
||||
|
||||
// emitted when a connection was updated
|
||||
void signalConnectionUpdated(ConnectionSettings::Connection*);
|
||||
|
||||
// emitted when a connection is removed from the store
|
||||
void signalConnectionRemoved(ConnectionSettings::Connection*);
|
||||
|
||||
// emitted when a connection needs new secrets
|
||||
void SecretsNeeded(ConnectionSettings::Connection* connection, ConnectionSettings::ConnectionSetting* setting, const TQStringList& hints, bool request_new);
|
||||
|
||||
private slots:
|
||||
void slotInit();
|
||||
|
||||
private:
|
||||
ConnectionStore();
|
||||
TQString createNewConnectionID();
|
||||
|
||||
TQValueList<ConnectionSettings::Connection*> _connectionList;
|
||||
static ConnectionStore* _instance;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_CONNECTION_STORE_H */
|
@ -1,166 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-device.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||||
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-nm_proxy.h"
|
||||
#include "knetworkmanager-device.h"
|
||||
#include "dbus/deviceproxy.h"
|
||||
#include "knetworkmanager-hal_device_proxy.h"
|
||||
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <tqhostaddress.h>
|
||||
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqdbusconnection.h>
|
||||
#include <tqdbusproxy.h>
|
||||
|
||||
|
||||
class NMDeviceProxy : public DBus::DeviceProxy
|
||||
{
|
||||
public:
|
||||
NMDeviceProxy(const TQString& service, const TQString& path, TQObject* parent = 0, const char* name = 0)
|
||||
: DeviceProxy(service, path, parent, name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TQString getObjectPath() const
|
||||
{
|
||||
return m_baseProxy->path();
|
||||
}
|
||||
};
|
||||
|
||||
class DevicePrivate
|
||||
{
|
||||
public:
|
||||
DevicePrivate(TQString service, TQString obj_path)
|
||||
: nmDevice(service, obj_path)
|
||||
, halDevice(NULL)
|
||||
{}
|
||||
~DevicePrivate() {}
|
||||
|
||||
NMDeviceProxy nmDevice;
|
||||
HalDeviceProxy* halDevice;
|
||||
};
|
||||
|
||||
TQ_UINT32 Device::getDeviceType() const
|
||||
{
|
||||
TQT_DBusError err;
|
||||
TQ_UINT32 type = d->nmDevice.getDeviceType(err);
|
||||
kdWarning() << k_funcinfo << err.name() << err.message() << endl;
|
||||
return type;
|
||||
}
|
||||
|
||||
TQString Device::getInterface() const
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmDevice.getInterface(err);
|
||||
}
|
||||
|
||||
TQString Device::getUdi() const
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmDevice.getUdi(err);
|
||||
}
|
||||
|
||||
TQString Device::getDriver() const
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmDevice.getDriver(err);
|
||||
}
|
||||
|
||||
TQ_UINT32 Device::getCapabilities() const
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmDevice.getCapabilities(err);
|
||||
}
|
||||
|
||||
TQ_INT32 Device::getIp4Address() const
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmDevice.getIp4Address(err);
|
||||
}
|
||||
|
||||
NMDeviceState Device::getState() const
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return (NMDeviceState)d->nmDevice.getState(err);
|
||||
}
|
||||
|
||||
TQString Device::getVendor() const
|
||||
{
|
||||
// FIXME: ask hal
|
||||
return "";
|
||||
}
|
||||
|
||||
TQString Device::getProduct() const
|
||||
{
|
||||
// FIXME: ask hal
|
||||
return "";
|
||||
}
|
||||
|
||||
TQString Device::getObjectPath() const
|
||||
{
|
||||
return d->nmDevice.getObjectPath();
|
||||
}
|
||||
|
||||
void Device::slotStateChanged(TQ_UINT32 state)
|
||||
{
|
||||
emit StateChanged((NMDeviceState)state);
|
||||
}
|
||||
|
||||
void Device::slotDeactivate()
|
||||
{
|
||||
// FIXME: the method was removed from NM API, use nm_proxy instead
|
||||
NMProxy* nm = NMProxy::getInstance();
|
||||
|
||||
nm->deactivateDevice(this);
|
||||
|
||||
// TQT_DBusError err;
|
||||
// d->nmDevice.Deactivate(err);
|
||||
}
|
||||
|
||||
Device::Device (const TQString & obj_path)
|
||||
{
|
||||
d = new DevicePrivate(NM_DBUS_SERVICE, obj_path);
|
||||
|
||||
// create the NM Device Proxy
|
||||
d->nmDevice.setConnection(TQT_DBusConnection::systemBus());
|
||||
|
||||
connect(&(d->nmDevice), TQT_SIGNAL(StateChanged(TQ_UINT32)), this, TQT_SLOT(slotStateChanged(TQ_UINT32)));
|
||||
// d->halDevice = new HalDeviceProxy();
|
||||
}
|
||||
|
||||
Device::~Device ()
|
||||
{
|
||||
// delete d->halDevice;
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
#include "knetworkmanager-device.moc"
|
@ -1,72 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-device.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||||
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_DEVICE_H
|
||||
#define KNETWORKMANAGER_DEVICE_H
|
||||
|
||||
#include "knetworkmanager.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class KNetworkManager;
|
||||
class Network;
|
||||
class IP4Config;
|
||||
|
||||
class DevicePrivate;
|
||||
|
||||
class Device : public TQObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Device (const TQString & obj_path );
|
||||
~Device ();
|
||||
|
||||
TQ_UINT32 getDeviceType() const;
|
||||
TQString getInterface() const;
|
||||
TQString getUdi() const;
|
||||
TQString getDriver() const;
|
||||
TQ_UINT32 getCapabilities() const;
|
||||
TQ_INT32 getIp4Address() const;
|
||||
NMDeviceState getState() const;
|
||||
// FIXME: should return IPv4-objects
|
||||
// TQDBusObjectPath getIp4Config() const;
|
||||
|
||||
TQString getVendor() const;
|
||||
TQString getProduct() const;
|
||||
TQString getObjectPath() const;
|
||||
|
||||
signals:
|
||||
void StateChanged(NMDeviceState);
|
||||
|
||||
public slots:
|
||||
void slotStateChanged(TQ_UINT32);
|
||||
void slotDeactivate();
|
||||
|
||||
private:
|
||||
DevicePrivate * d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_DEVICE_H */
|
@ -1,220 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-devicestore.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-devicestore.h"
|
||||
#include "knetworkmanager-wired_device.h"
|
||||
#include "knetworkmanager-wireless_device.h"
|
||||
#include "knetworkmanager-gsm_device.h"
|
||||
#include "knetworkmanager-cdma_device.h"
|
||||
#include "knetworkmanager-device.h"
|
||||
#include "knetworkmanager-nm_proxy.h"
|
||||
#include "dbus/deviceproxy.h"
|
||||
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqdbusobjectpath.h>
|
||||
#include <tqdbusconnection.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#if !defined(NM_CHECK_VERSION)
|
||||
#define NM_CHECK_VERSION(x,y,z) 0
|
||||
#endif
|
||||
|
||||
class DeviceStorePrivate
|
||||
{
|
||||
public:
|
||||
DeviceStorePrivate() {}
|
||||
~DeviceStorePrivate() {}
|
||||
|
||||
TQMap<TQString, Device*> devices;
|
||||
static DeviceStore* store;
|
||||
};
|
||||
|
||||
DeviceStore* DeviceStorePrivate::store = NULL;
|
||||
|
||||
DeviceStore* DeviceStore::getInstance()
|
||||
{
|
||||
if (DeviceStorePrivate::store)
|
||||
return DeviceStorePrivate::store;
|
||||
return (DeviceStorePrivate::store = new DeviceStore());
|
||||
}
|
||||
|
||||
void DeviceStore::slotDeviceRemoved(const TQT_DBusObjectPath & obj_path)
|
||||
{
|
||||
kdDebug() << "DeviceStore::slotDeviceRemoved" << endl;
|
||||
TQMap<TQString, Device*>::Iterator it = d->devices.find(TQString(obj_path));
|
||||
if (it != d->devices.end())
|
||||
{
|
||||
// remove this device
|
||||
Device* dev = it.data();
|
||||
|
||||
emit DeviceRemoved(dev);
|
||||
|
||||
d->devices.remove(it);
|
||||
delete dev;
|
||||
dev = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceStore::slotDeviceAdded(const TQT_DBusObjectPath & obj_path)
|
||||
{
|
||||
// just start an update
|
||||
Device* dev = createDevice(obj_path);
|
||||
if (dev)
|
||||
emit DeviceAdded(dev);
|
||||
}
|
||||
|
||||
Device* DeviceStore::createDevice(const TQT_DBusObjectPath &obj_path)
|
||||
{
|
||||
TQT_DBusError err;
|
||||
// if we have this device already in our list goto the next one
|
||||
TQMap<TQString, Device*>::Iterator it = d->devices.find(obj_path);
|
||||
if ( it != d->devices.end())
|
||||
return it.data();
|
||||
|
||||
// FIXME: ugly stuff is going on here, better pass the DeviceProxy to the Device's constructor instead of the object_path
|
||||
DBus::DeviceProxy* dev = new DBus::DeviceProxy(NM_DBUS_SERVICE, obj_path);
|
||||
Device* new_dev = NULL;
|
||||
|
||||
if (dev)
|
||||
{
|
||||
dev->setConnection(TQT_DBusConnection::systemBus());
|
||||
TQ_UINT32 type = dev->getDeviceType(err);
|
||||
|
||||
//printf("Device obj_path: %s\n\r", obj_path->data());
|
||||
|
||||
// FIXME: This should not be hardcoded, it would be better if wireless, wired etc. modules register their device type
|
||||
// select the right device type and create the appropriate objects
|
||||
switch(type)
|
||||
{
|
||||
#if NM_CHECK_VERSION(0,8,992)
|
||||
case NM_DEVICE_TYPE_WIFI:
|
||||
#else
|
||||
case DEVICE_TYPE_802_11_WIRELESS:
|
||||
#endif
|
||||
new_dev = new WirelessDevice(obj_path);
|
||||
break;
|
||||
#if NM_CHECK_VERSION(0,8,992)
|
||||
case NM_DEVICE_TYPE_ETHERNET:
|
||||
#else
|
||||
case DEVICE_TYPE_802_3_ETHERNET:
|
||||
#endif
|
||||
new_dev = new WiredDevice(obj_path);
|
||||
break;
|
||||
#if NM_CHECK_VERSION(0,8,992)
|
||||
case NM_DEVICE_TYPE_MODEM:
|
||||
#else
|
||||
case DEVICE_TYPE_GSM:
|
||||
#endif
|
||||
new_dev = new GSMDevice(obj_path);
|
||||
break;
|
||||
#if NM_CHECK_VERSION(0,8,992)
|
||||
#else
|
||||
case DEVICE_TYPE_CDMA:
|
||||
#endif
|
||||
new_dev = new CDMADevice(obj_path);
|
||||
break;
|
||||
default:
|
||||
kdWarning() << k_funcinfo << "Unknown devicetype" << endl;
|
||||
new_dev = new Device(obj_path);
|
||||
break;
|
||||
}
|
||||
|
||||
// insert the new device into our list
|
||||
if (new_dev)
|
||||
d->devices.insert(obj_path, new_dev);
|
||||
|
||||
delete dev;
|
||||
}
|
||||
else
|
||||
kdWarning() << k_funcinfo << "Dev is Null" << endl;
|
||||
|
||||
return new_dev;
|
||||
}
|
||||
|
||||
void DeviceStore::updateDevices()
|
||||
{
|
||||
NMProxy* nm = NMProxy::getInstance();
|
||||
TQValueList<TQT_DBusObjectPath> obj_paths;
|
||||
TQT_DBusError err;
|
||||
|
||||
// get a list of NM devices
|
||||
nm->GetDevices(obj_paths, err);
|
||||
|
||||
// create a list of KNM devices
|
||||
for (TQValueList<TQT_DBusObjectPath>::Iterator it = obj_paths.begin(); it != obj_paths.end(); ++it)
|
||||
{
|
||||
createDevice((*it));
|
||||
}
|
||||
}
|
||||
|
||||
TQValueList<Device*> DeviceStore::getDevices(TQ_UINT32 type)
|
||||
{
|
||||
updateDevices();
|
||||
|
||||
if (type == 0)
|
||||
return d->devices.values();
|
||||
else
|
||||
{
|
||||
// only return devices of a special type
|
||||
TQValueList<Device*> devs;
|
||||
for (TQMap<TQString, Device*>::Iterator it = d->devices.begin(); it != d->devices.end(); ++it)
|
||||
{
|
||||
if (it.data()->getDeviceType() == type)
|
||||
devs.append(it.data());
|
||||
}
|
||||
return devs;
|
||||
}
|
||||
}
|
||||
|
||||
Device* DeviceStore::getDevice(TQT_DBusObjectPath objpath)
|
||||
{
|
||||
return d->devices[objpath];
|
||||
}
|
||||
|
||||
DeviceStore::DeviceStore ( TQObject * parent, const char * name ) : TQObject( parent, name )
|
||||
{
|
||||
d = new DeviceStorePrivate();
|
||||
|
||||
// get notified from NM when devices are added or removed
|
||||
NMProxy* nm = NMProxy::getInstance();
|
||||
connect(nm, TQT_SIGNAL(DeviceAdded(const TQT_DBusObjectPath& )), this, TQT_SLOT(slotDeviceAdded(const TQT_DBusObjectPath&)));
|
||||
connect(nm, TQT_SIGNAL(DeviceRemoved(const TQT_DBusObjectPath& )), this, TQT_SLOT(slotDeviceRemoved(const TQT_DBusObjectPath&)));
|
||||
}
|
||||
|
||||
DeviceStore::~DeviceStore ()
|
||||
{
|
||||
// delete all devicepointers
|
||||
while (d->devices.begin() != d->devices.end())
|
||||
delete d->devices.begin().data();
|
||||
|
||||
// delete private data
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
#include "knetworkmanager-devicestore.moc"
|
@ -1,65 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-devicestore.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||||
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_DEVICESTORE_H
|
||||
#define KNETWORKMANAGER_DEVICESTORE_H
|
||||
|
||||
#include "knetworkmanager.h"
|
||||
|
||||
class TQT_DBusObjectPath;
|
||||
class DeviceStorePrivate;
|
||||
class Device;
|
||||
|
||||
class DeviceStore : public TQObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
static DeviceStore* getInstance();
|
||||
TQValueList<Device*> getDevices(TQ_UINT32 type = 0);
|
||||
Device* getDevice(TQT_DBusObjectPath);
|
||||
|
||||
public slots:
|
||||
void slotDeviceAdded(const TQT_DBusObjectPath&);
|
||||
void slotDeviceRemoved(const TQT_DBusObjectPath&);
|
||||
|
||||
protected:
|
||||
DeviceStore ( TQObject * parent = 0, const char * name = 0);
|
||||
~DeviceStore ();
|
||||
|
||||
signals:
|
||||
void DeviceStoreChanged();
|
||||
void DeviceAdded(Device*);
|
||||
void DeviceRemoved(Device*);
|
||||
|
||||
private:
|
||||
void updateDevices();
|
||||
Device* createDevice(const TQT_DBusObjectPath&);
|
||||
|
||||
DeviceStorePrivate* d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_DEVICESTORE_H */
|
@ -1,67 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-gsm_device.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
// KDE includes
|
||||
#include <kdebug.h>
|
||||
|
||||
// TQt includes
|
||||
#include <tqhostaddress.h>
|
||||
|
||||
// TQT_DBus includes
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqdbusconnection.h>
|
||||
|
||||
// NM includes
|
||||
#include <NetworkManager.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-gsm_device.h"
|
||||
#include "dbus/gsmproxy.h"
|
||||
|
||||
class GSMDevicePrivate
|
||||
{
|
||||
public:
|
||||
GSMDevicePrivate(TQString service, TQString obj_path)
|
||||
: nmGSM(service, obj_path)
|
||||
{}
|
||||
~GSMDevicePrivate() {}
|
||||
|
||||
DBus::GSMDeviceProxy nmGSM;
|
||||
};
|
||||
|
||||
GSMDevice::GSMDevice (const TQString & obj_path)
|
||||
: CellularDevice(obj_path)
|
||||
{
|
||||
d = new GSMDevicePrivate(NM_DBUS_SERVICE, obj_path);
|
||||
d->nmGSM.setConnection(TQT_DBusConnection::systemBus());
|
||||
}
|
||||
|
||||
GSMDevice::~GSMDevice ()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
#include "knetworkmanager-gsm_device.moc"
|
@ -1,51 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-gsm_device.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_GSMDEVICE_H
|
||||
#define KNETWORKMANAGER_GSMDEVICE_H
|
||||
|
||||
// std includes
|
||||
#include <stdint.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-cellular_device.h"
|
||||
|
||||
class KNetworkManager;
|
||||
|
||||
class GSMDevicePrivate;
|
||||
|
||||
class GSMDevice : public CellularDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GSMDevice (const TQString & obj_path );
|
||||
~GSMDevice ();
|
||||
|
||||
private:
|
||||
GSMDevicePrivate * d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_GSMDEVICE_H */
|
@ -1,126 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-device.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||||
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-hal_device_proxy.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <tqhostaddress.h>
|
||||
|
||||
class HalDeviceProxyPrivate
|
||||
{
|
||||
public:
|
||||
HalDeviceProxyPrivate() {}
|
||||
~HalDeviceProxyPrivate() {}
|
||||
|
||||
void getHalProperty (const TQCString& udi, const TQCString& property, TQCString& result);
|
||||
|
||||
TQString udi;
|
||||
};
|
||||
|
||||
HalDeviceProxy::HalDeviceProxy (const TQString & udi)
|
||||
{
|
||||
d = new HalDeviceProxyPrivate;
|
||||
d->udi = udi;
|
||||
}
|
||||
|
||||
HalDeviceProxy::~HalDeviceProxy ()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bustype
|
||||
HalDeviceProxy::getBustype () const
|
||||
{
|
||||
TQCString device_udi = d->udi.utf8();
|
||||
TQCString parent_udi = "";
|
||||
TQCString subsystem = "";
|
||||
|
||||
d->getHalProperty (device_udi, "info.parent", parent_udi);
|
||||
d->getHalProperty (parent_udi, "linux.subsystem", subsystem);
|
||||
|
||||
if (TQString::compare (subsystem, "pci") == 0)
|
||||
return BUS_PCI;
|
||||
else if (TQString::compare (subsystem, "usb") == 0)
|
||||
return BUS_USB;
|
||||
else if (TQString::compare (subsystem, "pcmcia") == 0)
|
||||
return BUS_PCMCIA;
|
||||
else
|
||||
return BUS_UNKNOWN;
|
||||
}
|
||||
|
||||
TQString
|
||||
HalDeviceProxy::getProduct () const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
TQString
|
||||
HalDeviceProxy::getVendor () const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void
|
||||
HalDeviceProxyPrivate::getHalProperty (const TQCString& udi, const TQCString& property, TQCString& result)
|
||||
{
|
||||
//FIXME: convert to qt3-dbus-api
|
||||
/*
|
||||
DBusConnection* con = _ctx->getDBus ()->getConnection ();
|
||||
LibHalContext* hal_ctx = NULL;
|
||||
char* prop_val = NULL;
|
||||
|
||||
if (!con || !property) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!dbus_bus_name_has_owner (con, "org.freedesktop.Hal", NULL)) {
|
||||
kdDebug() << "Error: HAL seems not to be running." << endl;
|
||||
goto out;
|
||||
}
|
||||
|
||||
hal_ctx = libhal_ctx_new ();
|
||||
|
||||
if (!libhal_ctx_set_dbus_connection (hal_ctx, con)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!libhal_ctx_init (hal_ctx, NULL)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
prop_val = libhal_device_get_property_string (hal_ctx, udi, property, NULL);
|
||||
result = prop_val;
|
||||
libhal_free_string (prop_val);
|
||||
out:
|
||||
if (hal_ctx) {
|
||||
libhal_ctx_shutdown (hal_ctx, NULL);
|
||||
libhal_ctx_free (hal_ctx);
|
||||
}
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
#include "knetworkmanager-hal_device_proxy.moc"
|
@ -1,65 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-device.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||||
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_HALDEVICEPROXY_H
|
||||
#define KNETWORKMANAGER_HALDEVICEPROXY_H
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
|
||||
// HAL includes
|
||||
#include <hal/libhal.h>
|
||||
|
||||
// std includes
|
||||
#include <stdint.h>
|
||||
|
||||
class KNetworkManager;
|
||||
|
||||
enum bustype {
|
||||
BUS_PCI = 0,
|
||||
BUS_USB = 1,
|
||||
BUS_PCMCIA = 2,
|
||||
BUS_UNKNOWN = 15
|
||||
};
|
||||
|
||||
class HalDeviceProxyPrivate;
|
||||
|
||||
class HalDeviceProxy : public TQObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HalDeviceProxy (const TQString & udi);
|
||||
~HalDeviceProxy ();
|
||||
|
||||
bustype getBustype (void) const;
|
||||
TQString getProduct (void) const;
|
||||
TQString getVendor (void) const;
|
||||
|
||||
private:
|
||||
HalDeviceProxyPrivate * d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_HALDEVICEPROXY_H */
|
@ -1,329 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-device.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||||
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
// KDE includes
|
||||
#include <kdebug.h>
|
||||
|
||||
// TQtDBus includes
|
||||
#include <tqdbusconnection.h>
|
||||
#include <tqdbusproxy.h>
|
||||
#include <tqdbusdata.h>
|
||||
#include <tqdbusdatalist.h>
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqdbusobjectpath.h>
|
||||
|
||||
// NM includes
|
||||
#include <NetworkManager.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-nm_proxy.h"
|
||||
#include "knetworkmanager-device.h"
|
||||
#include "knetworkmanager-devicestore.h"
|
||||
#include "knetworkmanager-connection.h"
|
||||
#include "knetworkmanager-connection_store.h"
|
||||
#include "dbus/activeconnectionproxy.h"
|
||||
|
||||
class NMProxyPrivate
|
||||
{
|
||||
public:
|
||||
NMProxyPrivate()
|
||||
{}
|
||||
|
||||
static NMProxy* nm;
|
||||
};
|
||||
|
||||
NMProxy* NMProxyPrivate::nm = NULL;
|
||||
|
||||
Device* NMProxy::getDefaultDevice()
|
||||
{
|
||||
TQT_DBusObjectPath connpath = getDefaultActiveConnection();
|
||||
if (!connpath.isEmpty())
|
||||
{
|
||||
TQT_DBusObjectPath devpath = getDeviceForActiveConnection(connpath);
|
||||
if (!devpath.isEmpty())
|
||||
return DeviceStore::getInstance()->getDevice(devpath);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TQT_DBusObjectPath NMProxy::getDeviceForActiveConnection(TQT_DBusObjectPath act_conn_path)
|
||||
{
|
||||
TQT_DBusError err;
|
||||
|
||||
// we need a proxy for every active connection
|
||||
DBus::ActiveConnectionProxy* act_conn = new DBus::ActiveConnectionProxy(NM_DBUS_SERVICE, act_conn_path);
|
||||
act_conn->setConnection(TQT_DBusConnection::systemBus());
|
||||
|
||||
if (act_conn)
|
||||
{
|
||||
// get details about the active connection
|
||||
TQValueList<TQT_DBusObjectPath> devs = act_conn->getDevices(err);
|
||||
if (!devs.isEmpty())
|
||||
return devs.first();
|
||||
delete act_conn;
|
||||
}
|
||||
|
||||
return TQT_DBusObjectPath();
|
||||
|
||||
}
|
||||
|
||||
TQT_DBusObjectPath NMProxy::getDefaultActiveConnection()
|
||||
{
|
||||
TQT_DBusError err;
|
||||
TQValueList<TQT_DBusObjectPath> connections;
|
||||
|
||||
// get a list of all active connections from NM
|
||||
connections = NetworkManagerProxy::getActiveConnections(err);
|
||||
|
||||
for (TQValueList<TQT_DBusObjectPath>::Iterator it = connections.begin(); it != connections.end(); ++it)
|
||||
{
|
||||
// we need a proxy for every active connection
|
||||
DBus::ActiveConnectionProxy* act_conn = new DBus::ActiveConnectionProxy(NM_DBUS_SERVICE, (*it));
|
||||
act_conn->setConnection(TQT_DBusConnection::systemBus());
|
||||
|
||||
if (act_conn)
|
||||
{
|
||||
if (act_conn->getDefault(err))
|
||||
{
|
||||
delete act_conn;
|
||||
return *it;
|
||||
}
|
||||
delete act_conn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return TQT_DBusObjectPath();
|
||||
|
||||
}
|
||||
|
||||
ConnectionSettings::Connection* NMProxy::getActiveConnection(const Device* dev)
|
||||
{
|
||||
TQT_DBusError err;
|
||||
TQValueList<TQT_DBusObjectPath> connections;
|
||||
|
||||
// get a list of all active connections from NM
|
||||
connections = NetworkManagerProxy::getActiveConnections(err);
|
||||
|
||||
for (TQValueList<TQT_DBusObjectPath>::Iterator it = connections.begin(); it != connections.end(); ++it)
|
||||
{
|
||||
// we need a proxy for every active connection
|
||||
DBus::ActiveConnectionProxy* act_conn = new DBus::ActiveConnectionProxy(NM_DBUS_SERVICE, (*it));
|
||||
act_conn->setConnection(TQT_DBusConnection::systemBus());
|
||||
|
||||
if (act_conn)
|
||||
{
|
||||
// get details about the active connection
|
||||
TQString service = act_conn->getServiceName(err);
|
||||
TQT_DBusObjectPath conn = act_conn->getConnection(err);
|
||||
TQT_DBusObjectPath specific_obj = act_conn->getSpecificObject(err);
|
||||
TQValueList<TQT_DBusObjectPath> devs = act_conn->getDevices(err);
|
||||
for (TQValueList<TQT_DBusObjectPath>::Iterator it2 = devs.begin(); it2 != devs.end(); ++it2)
|
||||
{
|
||||
if (TQString(*it2) == dev->getObjectPath())
|
||||
{
|
||||
// here is the connection we were looking for
|
||||
ConnectionStore* cstore = ConnectionStore::getInstance();
|
||||
if (cstore)
|
||||
return cstore->getConnection(TQString(conn));
|
||||
}
|
||||
}
|
||||
delete act_conn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TQValueList<TQPair<ConnectionSettings::Connection*, Device*> > NMProxy::getActiveConnectionsMap()
|
||||
{
|
||||
TQT_DBusError err;
|
||||
TQValueList<TQT_DBusObjectPath> connections;
|
||||
TQValueList<TQPair<ConnectionSettings::Connection*, Device*> > map;
|
||||
ConnectionStore* cstore = ConnectionStore::getInstance();
|
||||
DeviceStore* dstore = DeviceStore::getInstance();
|
||||
bool found = false;
|
||||
|
||||
if (!dstore || !cstore)
|
||||
return map;
|
||||
|
||||
// get a list of all active connections from NM
|
||||
connections = NetworkManagerProxy::getActiveConnections(err);
|
||||
|
||||
for (TQValueList<TQT_DBusObjectPath>::Iterator it = connections.begin(); it != connections.end(); ++it)
|
||||
{
|
||||
// we need a proxy for every active connection
|
||||
DBus::ActiveConnectionProxy* act_conn = new DBus::ActiveConnectionProxy(NM_DBUS_SERVICE, (*it));
|
||||
act_conn->setConnection(TQT_DBusConnection::systemBus());
|
||||
|
||||
if (act_conn)
|
||||
{
|
||||
// get details about the active connection
|
||||
TQString service = act_conn->getServiceName(err);
|
||||
TQT_DBusObjectPath conn = act_conn->getConnection(err);
|
||||
TQT_DBusObjectPath specific_obj = act_conn->getSpecificObject(err);
|
||||
TQValueList<TQT_DBusObjectPath> devs = act_conn->getDevices(err);
|
||||
found = false;
|
||||
for (TQValueList<TQT_DBusObjectPath>::Iterator it2 = devs.begin(); it2 != devs.end(); ++it2)
|
||||
{
|
||||
Device* device = dstore->getDevice(*it2);
|
||||
ConnectionSettings::Connection* connection = cstore->getConnection(TQString(conn));
|
||||
if (connection)
|
||||
{
|
||||
map.append(TQPair<ConnectionSettings::Connection*, Device*>(connection, device));
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
// no device found for this connection -> just add it without device
|
||||
ConnectionSettings::Connection* connection = cstore->getConnection(TQString(conn));
|
||||
if (connection)
|
||||
map.append(TQPair<ConnectionSettings::Connection*, Device*>(connection, NULL));
|
||||
}
|
||||
delete act_conn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
NMProxy::NMProxy()
|
||||
: NetworkManagerProxy(NM_DBUS_SERVICE, NM_DBUS_PATH)
|
||||
{
|
||||
d = new NMProxyPrivate();
|
||||
NetworkManagerProxy::setConnection(TQT_DBusConnection::systemBus());
|
||||
}
|
||||
|
||||
void NMProxy::deactivateConnection(const ConnectionSettings::Connection* conn, const Device* dev)
|
||||
{
|
||||
TQT_DBusError err;
|
||||
TQValueList<TQT_DBusObjectPath> connections;
|
||||
|
||||
// get a list of all active connections from NM
|
||||
connections = NetworkManagerProxy::getActiveConnections(err);
|
||||
|
||||
for (TQValueList<TQT_DBusObjectPath>::Iterator it = connections.begin(); it != connections.end(); ++it)
|
||||
{
|
||||
// we need a proxy for every active connection
|
||||
DBus::ActiveConnectionProxy* act_conn = new DBus::ActiveConnectionProxy(NM_DBUS_SERVICE, (*it));
|
||||
act_conn->setConnection(TQT_DBusConnection::systemBus());
|
||||
|
||||
if (act_conn)
|
||||
{
|
||||
if (act_conn->getConnection(err) == conn->getObjectPath())
|
||||
{
|
||||
if (dev)
|
||||
{
|
||||
// get details about the active connection
|
||||
TQValueList<TQT_DBusObjectPath> devs = act_conn->getDevices(err);
|
||||
for (TQValueList<TQT_DBusObjectPath>::Iterator it2 = devs.begin(); it2 != devs.end(); ++it2)
|
||||
{
|
||||
if (TQString(*it2) == dev->getObjectPath())
|
||||
{
|
||||
// this is the right one
|
||||
DeactivateConnection(*it, err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DeactivateConnection(*it, err);
|
||||
}
|
||||
}
|
||||
delete act_conn;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NMProxy::deactivateConnectionPath(TQT_DBusObjectPath obj_path)
|
||||
{
|
||||
TQT_DBusError err;
|
||||
DeactivateConnection(obj_path, err);
|
||||
}
|
||||
|
||||
void NMProxy::deactivateDevice(const Device* dev)
|
||||
{
|
||||
TQT_DBusError err;
|
||||
TQValueList<TQT_DBusObjectPath> connections;
|
||||
|
||||
// get a list of all active connections from NM
|
||||
connections = NetworkManagerProxy::getActiveConnections(err);
|
||||
|
||||
for (TQValueList<TQT_DBusObjectPath>::Iterator it = connections.begin(); it != connections.end(); ++it)
|
||||
{
|
||||
// we need a proxy for every active connection
|
||||
DBus::ActiveConnectionProxy* act_conn = new DBus::ActiveConnectionProxy(NM_DBUS_SERVICE, (*it));
|
||||
act_conn->setConnection(TQT_DBusConnection::systemBus());
|
||||
|
||||
if (act_conn)
|
||||
{
|
||||
// get details about the active connection
|
||||
TQValueList<TQT_DBusObjectPath> devs = act_conn->getDevices(err);
|
||||
for (TQValueList<TQT_DBusObjectPath>::Iterator it2 = devs.begin(); it2 != devs.end(); ++it2)
|
||||
{
|
||||
if (TQString(*it2) == dev->getObjectPath())
|
||||
{
|
||||
// this is the right one
|
||||
DeactivateConnection(*it, err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
delete act_conn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool NMProxy::isNMRunning()
|
||||
{
|
||||
// Ask DBus if the NetworkManager service is available
|
||||
TQT_DBusProxy* proxy = new TQT_DBusProxy("org.freedesktop.DBus", "/", "org.freedesktop.DBus", TQT_DBusConnection::systemBus());
|
||||
TQValueList<TQT_DBusData> params;
|
||||
params.append(TQT_DBusData::fromString(NM_DBUS_SERVICE));
|
||||
TQT_DBusMessage reply = proxy->sendWithReply("NameHasOwner", params);
|
||||
bool ret = reply.first().toBool();
|
||||
delete proxy;
|
||||
return ret;
|
||||
}
|
||||
|
||||
NMProxy::~NMProxy()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
NMProxy* NMProxy::getInstance()
|
||||
{
|
||||
if (NMProxyPrivate::nm)
|
||||
return NMProxyPrivate::nm;
|
||||
return (NMProxyPrivate::nm = new NMProxy());
|
||||
}
|
||||
|
||||
|
||||
#include "knetworkmanager-nm_proxy.moc"
|
@ -1,62 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-nm_proxy.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_NMPROXY_H
|
||||
#define KNETWORKMANAGER_NMPROXY_H
|
||||
|
||||
#include "dbus/networkmanagerproxy.h"
|
||||
|
||||
namespace ConnectionSettings
|
||||
{
|
||||
class Connection;
|
||||
}
|
||||
class Device;
|
||||
class NMProxyPrivate;
|
||||
|
||||
class NMProxy : public DBus::NetworkManagerProxy
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static NMProxy* getInstance();
|
||||
|
||||
Device* getDefaultDevice();
|
||||
TQT_DBusObjectPath getDeviceForActiveConnection(TQT_DBusObjectPath act_conn);
|
||||
TQT_DBusObjectPath getDefaultActiveConnection();
|
||||
ConnectionSettings::Connection* getActiveConnection(const Device* dev);
|
||||
void deactivateDevice(const Device* dev);
|
||||
void deactivateConnection(const ConnectionSettings::Connection* conn, const Device* dev);
|
||||
void deactivateConnectionPath(TQT_DBusObjectPath obj_path);
|
||||
TQValueList<TQPair<ConnectionSettings::Connection*, Device*> > getActiveConnectionsMap();
|
||||
bool isNMRunning();
|
||||
|
||||
protected:
|
||||
NMProxy ();
|
||||
~NMProxy ();
|
||||
|
||||
private:
|
||||
NMProxyPrivate * d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_NMPROXY_H */
|
@ -1,634 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-storage.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
* Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <tqtimer.h>
|
||||
|
||||
#include <kglobal.h>
|
||||
#include <kconfig.h>
|
||||
#include <kstaticdeleter.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "knetworkmanager-storage.h"
|
||||
#include "knetworkmanager-connection_store.h"
|
||||
#include "knetworkmanager-wireless_connection.h"
|
||||
#include "knetworkmanager-wired_connection.h"
|
||||
#include "knetworkmanager-cdma_connection.h"
|
||||
#include "knetworkmanager-gsm_connection.h"
|
||||
#include "knetworkmanager-vpn_connection.h"
|
||||
#include "knetworkmanager-connection.h"
|
||||
#include "knetworkmanager-connection_setting.h"
|
||||
#include "xmlmarshaller.h"
|
||||
#include "knetworkmanager-connection_setting_info.h"
|
||||
#include "knetworkmanager-connection_setting_wired.h"
|
||||
#include "knetworkmanager-connection_setting_wireless.h"
|
||||
#include "knetworkmanager-connection_setting_wireless_security.h"
|
||||
#include "knetworkmanager-connection_setting_ipv4.h"
|
||||
|
||||
using namespace ConnectionSettings;
|
||||
|
||||
static KStaticDeleter<Storage> sd2;
|
||||
|
||||
// private stuff
|
||||
class StoragePrivate
|
||||
{
|
||||
public:
|
||||
StoragePrivate() {};
|
||||
~StoragePrivate() {};
|
||||
|
||||
static Storage* _instance;
|
||||
};
|
||||
|
||||
Storage* StoragePrivate::_instance = NULL;
|
||||
|
||||
Storage*
|
||||
Storage::getInstance()
|
||||
{
|
||||
if (StoragePrivate::_instance)
|
||||
return StoragePrivate::_instance;
|
||||
return sd2.setObject(StoragePrivate::_instance, new Storage());
|
||||
}
|
||||
|
||||
Storage::Storage()
|
||||
{
|
||||
d = new StoragePrivate();
|
||||
|
||||
// defer the connection init a bit
|
||||
TQTimer::singleShot(0, this, TQT_SLOT(slotInit()));
|
||||
}
|
||||
|
||||
Storage::~Storage()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void
|
||||
Storage::slotInit()
|
||||
{
|
||||
ConnectionStore* cstore = ConnectionStore::getInstance();
|
||||
|
||||
// we want to get notified whenever a new connection is created, edited or deleted
|
||||
connect(cstore, TQT_SIGNAL(signalConnectionAdded(ConnectionSettings::Connection*)), this, TQT_SLOT(slotConnectionAdded(ConnectionSettings::Connection*)));
|
||||
connect(cstore, TQT_SIGNAL(signalConnectionRemoved(ConnectionSettings::Connection*)), this, TQT_SLOT(slotConnectionRemoved(ConnectionSettings::Connection*)));
|
||||
}
|
||||
|
||||
void
|
||||
Storage::slotConnectionAdded(Connection* con)
|
||||
{
|
||||
// connection added, save it
|
||||
saveConnection(con);
|
||||
KGlobal::config()->sync();
|
||||
}
|
||||
|
||||
void
|
||||
Storage::slotConnectionRemoved(Connection* con)
|
||||
{
|
||||
// find the appropriate connection and delete it from the storage
|
||||
deleteConnection(con);
|
||||
KGlobal::config()->sync();
|
||||
}
|
||||
|
||||
Connection*
|
||||
Storage::createConnectionByType(const TQString& cType)
|
||||
{
|
||||
// TODO: use a factory class here
|
||||
if (cType == NM_SETTING_WIRELESS_SETTING_NAME)
|
||||
return new WirelessConnection();
|
||||
else if (cType == NM_SETTING_WIRED_SETTING_NAME)
|
||||
return new WiredConnection();
|
||||
else if(cType == NM_SETTING_CDMA_SETTING_NAME)
|
||||
return new CDMAConnection();
|
||||
else if(cType == NM_SETTING_GSM_SETTING_NAME)
|
||||
return new GSMConnection();
|
||||
else if (cType == NM_SETTING_VPN_SETTING_NAME)
|
||||
return new VPNConnection();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Storage::restoreConnections()
|
||||
{
|
||||
kdDebug() << k_funcinfo << endl;
|
||||
// let's read all connections from the config-file and add them to the connection-store
|
||||
ConnectionStore* store = ConnectionStore::getInstance();
|
||||
TQStringList groups = KGlobal::config()->groupList();
|
||||
const TQStringList::Iterator end = groups.end();
|
||||
for ( TQStringList::Iterator it = groups.begin(); it != end; ++it )
|
||||
{
|
||||
if ( !(*it).startsWith( "Connection_" ) )
|
||||
continue;
|
||||
|
||||
// restore that connection
|
||||
Connection* conn = NULL;
|
||||
if ( (conn = restoreConnection(*it)) != NULL)
|
||||
{
|
||||
// add the connection to the store
|
||||
store->addConnection(conn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Connection*
|
||||
Storage::restoreConnection(const TQString& grpname)
|
||||
{
|
||||
Connection* conn = NULL;
|
||||
kdDebug() << k_funcinfo << " " << grpname << endl;
|
||||
|
||||
// we have a connection to restore
|
||||
KConfigGroup grp( KGlobal::config(), grpname);
|
||||
TQString id = grp.readEntry("Id");
|
||||
TQString cType = grp.readEntry("Type");
|
||||
|
||||
// ID is needed!
|
||||
if (id.isEmpty() || cType.isEmpty())
|
||||
return NULL;
|
||||
|
||||
// create a new connection object by its type
|
||||
conn = createConnectionByType(cType);
|
||||
|
||||
// check if the connection was successfully created
|
||||
if (!conn)
|
||||
return NULL;
|
||||
|
||||
// set the connection ID
|
||||
conn->setID(id);
|
||||
|
||||
// restore all appropriate settings
|
||||
TQStringList settings = grp.readListEntry("Settings");
|
||||
|
||||
for (TQStringList::ConstIterator it = settings.begin(); it != settings.end(); ++it)
|
||||
{
|
||||
if ( !restoreSetting(conn, *it) )
|
||||
{
|
||||
// setting could not be restored -> Error
|
||||
kdDebug() << " Connection " << id.ascii() << " could not be restored." << endl;
|
||||
kdError() << k_funcinfo << " Connection " << id << " could not be restored." << endl;
|
||||
delete conn;
|
||||
conn = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// restore all appropriate secrets
|
||||
TQStringList secrets = grp.readListEntry("Secrets");
|
||||
|
||||
for (TQStringList::ConstIterator it = secrets.begin(); it != secrets.end(); ++it)
|
||||
{
|
||||
if ( !restoreSecrets(conn, *it) )
|
||||
{
|
||||
// setting could not be restored -> Error
|
||||
kdDebug() << " Connection " << id.ascii() << " could not be restored." << endl;
|
||||
kdError() << k_funcinfo << " Connection " << id << " could not be restored." << endl;
|
||||
delete conn;
|
||||
conn = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::restoreSetting(Connection* conn, const TQString& setting_grp_name)
|
||||
{
|
||||
kdDebug() << k_funcinfo << " " << setting_grp_name << endl;
|
||||
kdDebug() << "restore setting: " << setting_grp_name.ascii() << endl;
|
||||
|
||||
KConfigGroup setting_grp(KGlobal::config(), setting_grp_name);
|
||||
TQMap<TQString, TQString> config_map = KGlobal::config()->entryMap(setting_grp_name);
|
||||
TQString type = setting_grp.readEntry("Type");
|
||||
|
||||
// get the appropriate setting from the connection
|
||||
ConnectionSetting* setting = conn->getSetting(type);
|
||||
if (!setting)
|
||||
{
|
||||
kdWarning() << k_funcinfo << "Connection " << conn->getID() << ": Setting " << type << " could not be restored" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the SettingsMap from kconfig
|
||||
SettingsMap map;
|
||||
for(TQMap<TQString, TQString>::ConstIterator it = config_map.begin(); it != config_map.end(); ++it)
|
||||
{
|
||||
if (!it.key().startsWith("Value_"))
|
||||
continue;
|
||||
|
||||
TQString key = it.key();
|
||||
// get the original name
|
||||
key.replace("Value_", "");
|
||||
|
||||
TQString xmldata = it.data();
|
||||
TQT_DBusData dbusdata = XMLMarshaller::toTQT_DBusData(xmldata);
|
||||
|
||||
map.insert(key, dbusdata);
|
||||
}
|
||||
|
||||
// restore the setting from the generated map
|
||||
setting->fromMap(map);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::restoreSecrets(Connection* conn, const TQString& secrets_grp_name)
|
||||
{
|
||||
kdDebug() << k_funcinfo << " " << secrets_grp_name << endl;
|
||||
kdDebug() << "restore secret: " << secrets_grp_name.ascii() << endl;
|
||||
|
||||
KConfigGroup secrets_grp(KGlobal::config(), secrets_grp_name);
|
||||
TQMap<TQString, TQString> config_map = KGlobal::config()->entryMap(secrets_grp_name);
|
||||
TQString type = secrets_grp.readEntry("Type");
|
||||
|
||||
// get the appropriate setting from the connection
|
||||
ConnectionSetting* setting = conn->getSetting(type);
|
||||
if (!setting)
|
||||
{
|
||||
kdWarning() << k_funcinfo << "Connection " << conn->getID() << ": Secrets for setting " << type << " could not be restored" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the SettingsMap from kconfig
|
||||
SettingsMap map;
|
||||
for(TQMap<TQString, TQString>::ConstIterator it = config_map.begin(); it != config_map.end(); ++it)
|
||||
{
|
||||
if (!it.key().startsWith("Value_"))
|
||||
continue;
|
||||
|
||||
TQString key = it.key();
|
||||
// get the original name
|
||||
key.replace("Value_", "");
|
||||
|
||||
TQString xmldata = it.data();
|
||||
TQT_DBusData dbusdata = XMLMarshaller::toTQT_DBusData(xmldata);
|
||||
|
||||
map.insert(key, dbusdata);
|
||||
}
|
||||
|
||||
// restore the setting from the generated map
|
||||
setting->fromSecretsMap(map);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::restoreVPNSecrets(Connection* conn, const TQString& secrets_grp_name)
|
||||
{
|
||||
kdDebug() << k_funcinfo << " " << secrets_grp_name << endl;
|
||||
kdDebug() << "restore secret: " << secrets_grp_name.ascii() << endl;
|
||||
|
||||
KConfigGroup secrets_grp(KGlobal::config(), secrets_grp_name);
|
||||
TQMap<TQString, TQString> config_map = KGlobal::config()->entryMap(secrets_grp_name);
|
||||
TQString type = secrets_grp.readEntry("Type");
|
||||
|
||||
// get the appropriate setting from the connection
|
||||
ConnectionSetting* setting = conn->getSetting(type);
|
||||
if (!setting)
|
||||
{
|
||||
kdWarning() << k_funcinfo << "Connection " << conn->getID() << ": Secrets for setting " << type << " could not be restored" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the SettingsMap from kconfig
|
||||
SettingsMap map;
|
||||
for(TQMap<TQString, TQString>::ConstIterator it = config_map.begin(); it != config_map.end(); ++it)
|
||||
{
|
||||
if (!it.key().startsWith("Value_"))
|
||||
continue;
|
||||
|
||||
TQString key = it.key();
|
||||
// get the original name
|
||||
key.replace("Value_", "");
|
||||
|
||||
TQString xmldata = it.data();
|
||||
TQT_DBusData dbusdata = XMLMarshaller::toTQT_DBusData(xmldata);
|
||||
|
||||
map.insert(key, dbusdata);
|
||||
}
|
||||
|
||||
// restore the setting from the generated map
|
||||
setting->fromSecretsMap(map);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Storage::saveConnections()
|
||||
{
|
||||
kdDebug() << k_funcinfo << endl;
|
||||
kdDebug() << "Storage::saveConnections" << endl;
|
||||
printf("Storage::saveConnections\n\r");
|
||||
// write all connections we get from the connection-store to disk
|
||||
ConnectionStore* store = ConnectionStore::getInstance();
|
||||
TQValueList<ConnectionSettings::Connection*> connections = store->getConnections();
|
||||
|
||||
for (TQValueList<ConnectionSettings::Connection*>::ConstIterator it = connections.begin(); it != connections.end(); ++it)
|
||||
{
|
||||
// save this connection
|
||||
saveConnection(*it);
|
||||
}
|
||||
KGlobal::config()->sync();
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::saveConnection(Connection* conn)
|
||||
{
|
||||
KConfig* config = KGlobal::config();
|
||||
TQString id = conn->getID();
|
||||
TQString cType = conn->getType();
|
||||
|
||||
kdDebug() << k_funcinfo << " <" << id << ">" << endl;
|
||||
kdDebug() << "Storage::saveConnection " << id.ascii() << endl;
|
||||
|
||||
// connections without id are evil
|
||||
if (id.isEmpty() || cType.isEmpty())
|
||||
return false;
|
||||
|
||||
// let's get the config group for this connection
|
||||
KConfigGroup grp(config, TQString("Connection_%1").arg(id));
|
||||
TQStringList settings_grps;
|
||||
TQStringList secrets_grps;
|
||||
|
||||
// save the connections settings to the configfile
|
||||
if (saveConnectionSettings(conn, settings_grps, secrets_grps))
|
||||
{
|
||||
grp.writeEntry("Type", cType);
|
||||
grp.writeEntry("Id", id);
|
||||
// save the list of settings groups
|
||||
grp.writeEntry("Settings", settings_grps);
|
||||
grp.writeEntry("Secrets", secrets_grps);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::saveConnectionSettings(Connection* conn, TQStringList& settings_grps, TQStringList& secrets_grps)
|
||||
{
|
||||
TQString id = conn->getID();
|
||||
|
||||
// connections without id are evil
|
||||
if (id.isEmpty())
|
||||
return false;
|
||||
|
||||
// iterate over all settings
|
||||
TQValueList<ConnectionSetting*> settings = conn->getSettings();
|
||||
TQString setting_grp;
|
||||
TQString secrets_grp;
|
||||
|
||||
// save all settings
|
||||
for (TQValueList<ConnectionSetting*>::ConstIterator it = settings.begin(); it != settings.end(); ++it)
|
||||
{
|
||||
if (!saveConnectionSetting(conn, *it, setting_grp))
|
||||
return false;
|
||||
|
||||
if ((*it)->hasSecrets())
|
||||
{
|
||||
if (!saveConnectionSecrets(conn, *it, secrets_grp))
|
||||
return false;
|
||||
secrets_grps.append(secrets_grp);
|
||||
}
|
||||
|
||||
settings_grps.append(setting_grp);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::saveConnectionSetting(Connection* conn, ConnectionSetting* setting, TQString& setting_grp)
|
||||
{
|
||||
KConfig* config = KGlobal::config();
|
||||
TQString id = conn->getID();
|
||||
TQString type = setting->getType();
|
||||
|
||||
kdDebug() << k_funcinfo << " <" << id << "> <" << type << ">" << endl;
|
||||
|
||||
// ID is necessary
|
||||
if (id.isEmpty())
|
||||
return false;
|
||||
|
||||
// get a group for this setting
|
||||
setting_grp = TQString("ConnectionSetting_%1_%2").arg(id).arg(type);
|
||||
KConfigGroup grp(config, setting_grp);
|
||||
|
||||
// write the type
|
||||
grp.writeEntry("Type", type);
|
||||
|
||||
// write the values
|
||||
SettingsMap map = setting->toMap();
|
||||
for (SettingsMap::ConstIterator it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
kdDebug() << k_funcinfo << " " << TQString("Value_%1").arg(it.key()) << " = " << XMLMarshaller::fromTQT_DBusData( it.data() )<< endl;
|
||||
grp.writeEntry(TQString("Value_%1").arg(it.key()), XMLMarshaller::fromTQT_DBusData( it.data() ));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::saveConnectionSecrets(Connection* conn, ConnectionSetting* setting, TQString& setting_grp)
|
||||
{
|
||||
KConfig* config = KGlobal::config();
|
||||
TQString id = conn->getID();
|
||||
TQString type = setting->getType();
|
||||
bool storage_requested;
|
||||
|
||||
kdDebug() << k_funcinfo << " <" << id << "> <" << type << ">" << endl;
|
||||
|
||||
// ID is necessary
|
||||
if (id.isEmpty())
|
||||
return false;
|
||||
|
||||
// see if permanent storage was requested by the user
|
||||
SettingsMap setting_map = setting->toMap();
|
||||
storage_requested = true;
|
||||
for (SettingsMap::ConstIterator it = setting_map.begin(); it != setting_map.end(); ++it)
|
||||
{
|
||||
if (it.key() == "Commit to disk") {
|
||||
if (XMLMarshaller::fromTQT_DBusData(it.data()) == TQString("true")) {
|
||||
storage_requested = true;
|
||||
}
|
||||
if (XMLMarshaller::fromTQT_DBusData(it.data()) == TQString("false")) {
|
||||
storage_requested = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("Secrets storage requested: %d\n\r", storage_requested);
|
||||
|
||||
// get a group for this setting
|
||||
setting_grp = TQString("ConnectionSecrets_%1_%2").arg(id).arg(type);
|
||||
KConfigGroup grp(config, setting_grp);
|
||||
|
||||
// write the type
|
||||
grp.writeEntry("Type", type);
|
||||
|
||||
// write the values
|
||||
SettingsMap map = setting->toSecretsMap(false);
|
||||
for (SettingsMap::ConstIterator it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
kdDebug() << k_funcinfo << " " << TQString("Value_%1").arg(it.key()) << " = " << XMLMarshaller::fromTQT_DBusData( it.data() )<< endl;
|
||||
if (storage_requested == true) {
|
||||
grp.writeEntry(TQString("Value_%1").arg(it.key()), XMLMarshaller::fromTQT_DBusData( it.data() ));
|
||||
}
|
||||
else {
|
||||
grp.writeEntry(TQString("Value_%1").arg(it.key()), TQString("") );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::hasSecretsStored(Connection* connection)
|
||||
{
|
||||
TQString id = connection->getID();
|
||||
|
||||
// ID is necessary
|
||||
if (id.isEmpty())
|
||||
return false;
|
||||
|
||||
TQValueList<ConnectionSetting*> settings = connection->getSettings();
|
||||
for (TQValueList<ConnectionSetting*>::Iterator it = settings.begin(); it != settings.end(); ++it)
|
||||
{
|
||||
if (hasSecretsStored(connection, *it))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Storage::hasSecretsStored(Connection* connection, ConnectionSetting* setting)
|
||||
{
|
||||
TQString id = connection->getID();
|
||||
TQString type = setting->getType();
|
||||
|
||||
kdDebug() << "Storage::hasSecretsStored" << endl;
|
||||
|
||||
// ID is necessary
|
||||
if (id.isEmpty())
|
||||
return false;
|
||||
|
||||
// get a group for this setting
|
||||
TQString setting_grp_name = TQString("ConnectionSecrets_%1_%2").arg(id).arg(type);
|
||||
|
||||
TQMap<TQString, TQString> config_map = KGlobal::config()->entryMap(setting_grp_name);
|
||||
|
||||
return !(config_map.isEmpty());
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::restoreAllSecrets(Connection* connection)
|
||||
{
|
||||
TQString id = connection->getID();
|
||||
bool retval = true;
|
||||
|
||||
if (id.isEmpty())
|
||||
return false;
|
||||
|
||||
TQValueList<ConnectionSetting*> settings = connection->getSettings();
|
||||
for (TQValueList<ConnectionSetting*>::Iterator it = settings.begin(); it != settings.end(); ++it)
|
||||
{
|
||||
if (hasSecretsStored(connection, *it))
|
||||
if (!restoreSecrets(connection, *it))
|
||||
retval = false;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::restoreSecrets(Connection* connection, ConnectionSetting* setting)
|
||||
{
|
||||
TQString id = connection->getID();
|
||||
TQString type = setting->getType();
|
||||
|
||||
kdDebug() << "Storage::restoreSecrets" << endl;
|
||||
// ID is necessary
|
||||
if (id.isEmpty())
|
||||
return false;
|
||||
|
||||
// get a group for this setting
|
||||
TQString setting_grp = TQString("ConnectionSecrets_%1_%2").arg(id).arg(type);
|
||||
|
||||
// restore the setting
|
||||
return restoreSecrets(connection, setting_grp);
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::restoreVPNSecrets(Connection* connection, ConnectionSetting* setting)
|
||||
{
|
||||
TQString id = connection->getID();
|
||||
TQString type = setting->getType();
|
||||
|
||||
printf("Storage::restoreVPNSecrets\n\r");
|
||||
kdDebug() << "Storage::restoreVPNSecrets" << endl;
|
||||
// ID is necessary
|
||||
if (id.isEmpty())
|
||||
return false;
|
||||
|
||||
// get a group for this setting
|
||||
TQString setting_grp = TQString("ConnectionSecrets_%1_%2").arg(id).arg(type);
|
||||
|
||||
// restore the setting
|
||||
return restoreVPNSecrets(connection, setting_grp);
|
||||
}
|
||||
|
||||
bool
|
||||
Storage::deleteConnection(Connection* conn)
|
||||
{
|
||||
KConfig* config = KGlobal::config();
|
||||
TQString id = conn->getID();
|
||||
TQString cType = conn->getType();
|
||||
|
||||
kdDebug() << k_funcinfo << " <" << id << ">" << endl;
|
||||
kdDebug() << "Storage::deleteConnection " << id.ascii() << endl;
|
||||
|
||||
// connections without id are evil
|
||||
if (id.isEmpty() || cType.isEmpty())
|
||||
return false;
|
||||
|
||||
// let's get the config group for this connection
|
||||
KConfigGroup grp(config, TQString("Connection_%1").arg(id));
|
||||
|
||||
|
||||
// delete all associated settings
|
||||
TQStringList settings = grp.readListEntry("Settings");
|
||||
|
||||
for (TQStringList::ConstIterator it = settings.begin(); it != settings.end(); ++it)
|
||||
{
|
||||
KConfigGroup setting(config, *it);
|
||||
setting.deleteGroup();
|
||||
}
|
||||
|
||||
// delete all associated secrets
|
||||
TQStringList secrets = grp.readListEntry("Secrets");
|
||||
|
||||
for (TQStringList::ConstIterator it = secrets.begin(); it != secrets.end(); ++it)
|
||||
{
|
||||
KConfigGroup setting(config, *it);
|
||||
setting.deleteGroup();
|
||||
}
|
||||
|
||||
grp.deleteGroup();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "knetworkmanager-storage.moc"
|
@ -1,101 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-storage.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_STORAGE_H
|
||||
#define KNETWORKMANAGER_STORAGE_H
|
||||
|
||||
#include <tqvaluelist.h>
|
||||
#include <tqobject.h>
|
||||
|
||||
namespace ConnectionSettings
|
||||
{
|
||||
class Connection;
|
||||
class ConnectionSetting;
|
||||
}
|
||||
|
||||
using namespace ConnectionSettings;
|
||||
|
||||
class StoragePrivate;
|
||||
|
||||
// This class abstracts the storage of settings and connections to the disk
|
||||
class Storage : public TQObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
// Singleton
|
||||
static Storage* getInstance();
|
||||
|
||||
// restore all available connections
|
||||
void restoreConnections();
|
||||
|
||||
// save all connections to the config file
|
||||
void saveConnections();
|
||||
|
||||
// restore all settings secrets as they are not restored automatically
|
||||
bool restoreAllSecrets(Connection*);
|
||||
|
||||
// restore a settings secrets as they are not restored automatically
|
||||
bool restoreSecrets(Connection*, ConnectionSetting*);
|
||||
|
||||
bool restoreVPNSecrets(Connection*, ConnectionSetting*);
|
||||
|
||||
// check whether we have the secrets stored, either in KWallet or in the configfile
|
||||
bool hasSecretsStored(Connection*, ConnectionSetting*);
|
||||
bool hasSecretsStored(Connection*);
|
||||
|
||||
~Storage();
|
||||
public slots:
|
||||
void slotInit();
|
||||
|
||||
// called for every newly created connection
|
||||
void slotConnectionAdded(ConnectionSettings::Connection*);
|
||||
|
||||
// called for every removed connection
|
||||
void slotConnectionRemoved(ConnectionSettings::Connection*);
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
Storage();
|
||||
|
||||
Connection* createConnectionByType(const TQString&);
|
||||
|
||||
Connection* restoreConnection(const TQString&);
|
||||
bool restoreSecrets(Connection*, const TQString&);
|
||||
bool restoreVPNSecrets(Connection*, const TQString&);
|
||||
bool restoreSetting(Connection*, const TQString&);
|
||||
|
||||
bool saveConnection(Connection* conn);
|
||||
bool saveConnectionSettings(Connection* conn, TQStringList&, TQStringList&);
|
||||
bool saveConnectionSetting(Connection* conn, ConnectionSetting* setting, TQString& grp);
|
||||
bool saveConnectionSecrets(Connection* conn, ConnectionSetting* setting, TQString& grp);
|
||||
|
||||
bool deleteConnection(Connection* conn);
|
||||
|
||||
StoragePrivate* d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_STORAGE_H */
|
@ -1,75 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-vpn_device.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
// KDE includes
|
||||
#include <kdebug.h>
|
||||
|
||||
// TQt includes
|
||||
#include <tqhostaddress.h>
|
||||
|
||||
// TQT_DBus includes
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqdbusconnection.h>
|
||||
|
||||
// NM includes
|
||||
#include <NetworkManager.h>
|
||||
#include <NetworkManagerVPN.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-vpn_device.h"
|
||||
#include "dbus/vpnconnectionproxy.h"
|
||||
#include "knetworkmanager-hal_device_proxy.h"
|
||||
|
||||
class VPNDevicePrivate
|
||||
{
|
||||
public:
|
||||
VPNDevicePrivate(TQString service, TQString obj_path)
|
||||
: nmVPN(service, obj_path)
|
||||
{}
|
||||
~VPNDevicePrivate() {}
|
||||
|
||||
DBus::VPNConnectionProxy nmVPN;
|
||||
};
|
||||
|
||||
TQ_UINT32 VPNDevice::getState()
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmVPN.getVpnState(err);
|
||||
}
|
||||
|
||||
VPNDevice::VPNDevice (const TQString & obj_path)
|
||||
: Device(obj_path)
|
||||
{
|
||||
d = new VPNDevicePrivate(NM_DBUS_IFACE_SETTINGS_CONNECTION, obj_path);
|
||||
d->nmVPN.setConnection(TQT_DBusConnection::systemBus());
|
||||
}
|
||||
|
||||
VPNDevice::~VPNDevice ()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
#include "knetworkmanager-vpn_device.moc"
|
@ -1,53 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-wired_device.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_VPNDEVICE_H
|
||||
#define KNETWORKMANAGER_VPNDEVICE_H
|
||||
|
||||
// std includes
|
||||
#include <stdint.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-device.h"
|
||||
|
||||
class KNetworkManager;
|
||||
|
||||
class VPNDevicePrivate;
|
||||
|
||||
class VPNDevice : public Device
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VPNDevice (const TQString & obj_path );
|
||||
~VPNDevice ();
|
||||
|
||||
TQ_UINT32 getState();
|
||||
|
||||
private:
|
||||
VPNDevicePrivate * d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_VPNDEVICE_H */
|
@ -1,86 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-wired_device.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
// KDE includes
|
||||
#include <kdebug.h>
|
||||
|
||||
// TQt includes
|
||||
#include <tqhostaddress.h>
|
||||
|
||||
// TQT_DBus includes
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqdbusconnection.h>
|
||||
|
||||
// NM includes
|
||||
#include <NetworkManager.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-wired_device.h"
|
||||
#include "dbus/wiredproxy.h"
|
||||
#include "knetworkmanager-hal_device_proxy.h"
|
||||
|
||||
class WiredDevicePrivate
|
||||
{
|
||||
public:
|
||||
WiredDevicePrivate(TQString service, TQString obj_path)
|
||||
: nmWired(service, obj_path)
|
||||
{}
|
||||
~WiredDevicePrivate() {}
|
||||
|
||||
DBus::WiredDeviceProxy nmWired;
|
||||
};
|
||||
|
||||
TQString WiredDevice::getHwAddress()
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmWired.getHwAddress(err);
|
||||
}
|
||||
|
||||
TQ_UINT32 WiredDevice::getSpeed()
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmWired.getSpeed(err);
|
||||
}
|
||||
|
||||
bool WiredDevice::getCarrier() const
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmWired.getCarrier(err);
|
||||
}
|
||||
|
||||
WiredDevice::WiredDevice (const TQString & obj_path)
|
||||
: Device(obj_path)
|
||||
{
|
||||
d = new WiredDevicePrivate(NM_DBUS_SERVICE, obj_path);
|
||||
d->nmWired.setConnection(TQT_DBusConnection::systemBus());
|
||||
}
|
||||
|
||||
WiredDevice::~WiredDevice ()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
#include "knetworkmanager-wired_device.moc"
|
@ -1,55 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-wired_device.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_WIREDDEVICE_H
|
||||
#define KNETWORKMANAGER_WIREDDEVICE_H
|
||||
|
||||
// std includes
|
||||
#include <stdint.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-device.h"
|
||||
|
||||
class KNetworkManager;
|
||||
|
||||
class WiredDevicePrivate;
|
||||
|
||||
class WiredDevice : public Device
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WiredDevice (const TQString & obj_path );
|
||||
~WiredDevice ();
|
||||
|
||||
TQString getHwAddress();
|
||||
TQ_UINT32 getSpeed();
|
||||
bool getCarrier() const;
|
||||
|
||||
private:
|
||||
WiredDevicePrivate * d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_WIREDDEVICE_H */
|
@ -1,207 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-device.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||||
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
// NM includes
|
||||
#include <NetworkManager.h>
|
||||
|
||||
// KNM includes
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-wireless_device.h"
|
||||
#include "dbus/accesspointproxy.h"
|
||||
#include "dbus/wirelessproxy.h"
|
||||
#include "knetworkmanager-accesspoint.h"
|
||||
|
||||
// KDE includes
|
||||
#include <kdebug.h>
|
||||
|
||||
// TQt includes
|
||||
#include <tqhostaddress.h>
|
||||
#include <tqmap.h>
|
||||
#include <tqvaluelist.h>
|
||||
|
||||
// TQt-Dbus includes
|
||||
#include <tqdbusconnection.h>
|
||||
#include <tqdbuserror.h>
|
||||
#include <tqdbusobjectpath.h>
|
||||
|
||||
class WirelessDevicePrivate
|
||||
{
|
||||
public:
|
||||
WirelessDevicePrivate(TQString service, TQString obj_path)
|
||||
: nmWireless(service, obj_path)
|
||||
{}
|
||||
|
||||
~WirelessDevicePrivate()
|
||||
{
|
||||
// cleanup the AP-list
|
||||
for (TQMap<TQT_DBusObjectPath, AccessPoint*>::Iterator it = aps.begin(); it != aps.end(); ++it)
|
||||
{
|
||||
AccessPoint* p = it.data();
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
DBus::WirelessDeviceProxy nmWireless;
|
||||
TQMap<TQT_DBusObjectPath, AccessPoint *> aps;
|
||||
};
|
||||
|
||||
WirelessDevice::WirelessDevice (const TQString & obj_path)
|
||||
: Device(obj_path)
|
||||
{
|
||||
d = new WirelessDevicePrivate(NM_DBUS_SERVICE, obj_path);
|
||||
d->nmWireless.setConnection(TQT_DBusConnection::systemBus());
|
||||
|
||||
// get notified when the devices properties change
|
||||
connect(&(d->nmWireless), TQT_SIGNAL(PropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)), this, TQT_SLOT(slotPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)));
|
||||
connect(&(d->nmWireless), TQT_SIGNAL(AccessPointAdded(const TQT_DBusObjectPath&)), this, TQT_SLOT(slotAccessPointAdded(const TQT_DBusObjectPath&)));
|
||||
connect(&(d->nmWireless), TQT_SIGNAL(AccessPointRemoved(const TQT_DBusObjectPath&)), this, TQT_SLOT(slotAccessPointRemoved(const TQT_DBusObjectPath&)));
|
||||
}
|
||||
|
||||
WirelessDevice::~WirelessDevice ()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void WirelessDevice::slotPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>& properties)
|
||||
{
|
||||
// TODO: optimization: emit different signals for each property
|
||||
emit propertiesChanged();
|
||||
}
|
||||
|
||||
void WirelessDevice::slotAccessPointAdded(const TQT_DBusObjectPath& obj_path)
|
||||
{
|
||||
AccessPoint* ap = 0;
|
||||
|
||||
if ( !d->aps.contains(obj_path)) {
|
||||
// we do not know this AP yet, add it to the list
|
||||
ap = new AccessPoint(obj_path, this, "access_point_object");
|
||||
d->aps.insert(obj_path, ap);
|
||||
}
|
||||
else
|
||||
ap = d->aps[obj_path];
|
||||
|
||||
// notify about the new accesspoint
|
||||
emit accessPointAdded(ap);
|
||||
}
|
||||
|
||||
void WirelessDevice::slotAccessPointRemoved(const TQT_DBusObjectPath& obj_path)
|
||||
{
|
||||
AccessPoint* ap = 0;
|
||||
|
||||
if ( d->aps.contains(obj_path)) {
|
||||
ap = d->aps[obj_path];
|
||||
|
||||
// notify about the AP removal
|
||||
emit accessPointRemoved(obj_path);
|
||||
|
||||
// remove the appropriate AP from our list
|
||||
d->aps.remove(obj_path);
|
||||
delete ap;
|
||||
}
|
||||
else
|
||||
{
|
||||
// nothing we can do here
|
||||
kdDebug() << k_funcinfo << "NM requests removal of unknown AP " << obj_path << endl;
|
||||
}
|
||||
}
|
||||
|
||||
TQValueList<AccessPoint*> WirelessDevice::accessPoints()
|
||||
{
|
||||
// update our AP list
|
||||
if (d->aps.isEmpty()) {
|
||||
updateAPList();
|
||||
}
|
||||
|
||||
return d->aps.values();
|
||||
}
|
||||
|
||||
void WirelessDevice::updateAPList()
|
||||
{
|
||||
TQT_DBusError err;
|
||||
TQValueList<TQT_DBusObjectPath> aps;
|
||||
|
||||
// get the APs from NM
|
||||
if (d->nmWireless.GetAccessPoints(aps, err))
|
||||
{
|
||||
// for each AP
|
||||
for (TQValueList<TQT_DBusObjectPath>::iterator it = aps.begin(); it != aps.end(); ++it)
|
||||
{
|
||||
// create an AP-object for each objectpath
|
||||
if (d->aps.contains(*it)) {
|
||||
continue;
|
||||
}
|
||||
AccessPoint* ap = new AccessPoint(*it, this, "access_point_object");
|
||||
d->aps.insert(*it, ap);
|
||||
}
|
||||
}
|
||||
else
|
||||
kdWarning() << k_funcinfo << "Could not get a list of wireless accesspoints over DBus." << endl;
|
||||
|
||||
}
|
||||
|
||||
TQValueList<AccessPoint*> WirelessDevice::accessPointsForEssid( TQByteArray essid)
|
||||
{
|
||||
TQValueList<AccessPoint*> aps;
|
||||
// the DBus proxy is shared
|
||||
for (TQMap<TQT_DBusObjectPath, AccessPoint*>::Iterator it = d->aps.begin(); it != d->aps.end(); ++it)
|
||||
{
|
||||
AccessPoint * ap = it.data();
|
||||
if (essid.isNull() || (ap && ap->getSsidByteArray() == essid))
|
||||
aps.append(ap);
|
||||
}
|
||||
return aps;
|
||||
}
|
||||
|
||||
AccessPoint * WirelessDevice::getActiveAccessPoint()
|
||||
{
|
||||
TQT_DBusError err;
|
||||
TQT_DBusObjectPath obj_path;
|
||||
|
||||
AccessPoint * ap = 0;
|
||||
//fixme, listen to signal and use cached value
|
||||
obj_path = d->nmWireless.getActiveAccessPoint(err);
|
||||
if (!obj_path.isEmpty()) {
|
||||
if (d->aps.contains(obj_path)) {
|
||||
ap = d->aps[obj_path];
|
||||
} else {
|
||||
kdWarning() << k_funcinfo << "No object for active access point found!" << endl;
|
||||
}
|
||||
}
|
||||
return ap;
|
||||
}
|
||||
|
||||
TQ_UINT32 WirelessDevice::getWirelessCapabilities() const
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmWireless.getWirelessCapabilities(err);
|
||||
}
|
||||
|
||||
TQ_UINT32 WirelessDevice::getBitrate() const
|
||||
{
|
||||
TQT_DBusError err;
|
||||
return d->nmWireless.getBitrate(err);
|
||||
}
|
||||
|
||||
#include "knetworkmanager-wireless_device.moc"
|
@ -1,70 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* knetworkmanager-device.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2005, 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||||
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_WIRELESS_DEVICE_H
|
||||
#define KNETWORKMANAGER_WIRELESS_DEVICE_H
|
||||
|
||||
#include "knetworkmanager.h"
|
||||
#include "knetworkmanager-device.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <tqdbusvariant.h>
|
||||
|
||||
class KNetworkManager;
|
||||
class AccessPoint;
|
||||
class WirelessDevicePrivate;
|
||||
|
||||
class WirelessDevice : public Device
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WirelessDevice (const TQString & obj_path );
|
||||
~WirelessDevice ();
|
||||
|
||||
TQ_UINT32 getWirelessCapabilities() const;
|
||||
TQValueList<AccessPoint*> accessPointsForEssid(TQByteArray essid = TQByteArray());
|
||||
TQValueList<AccessPoint*> accessPoints();
|
||||
AccessPoint * getActiveAccessPoint();
|
||||
TQ_UINT32 getBitrate() const;
|
||||
|
||||
public slots:
|
||||
void slotPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>& properties);
|
||||
void slotAccessPointAdded(const TQT_DBusObjectPath&);
|
||||
void slotAccessPointRemoved(const TQT_DBusObjectPath&);
|
||||
|
||||
signals:
|
||||
void propertiesChanged();
|
||||
void accessPointAdded(AccessPoint *);
|
||||
void accessPointRemoved(const TQString &);
|
||||
|
||||
private:
|
||||
void updateAPList();
|
||||
|
||||
WirelessDevicePrivate * d;
|
||||
};
|
||||
|
||||
#endif /* KNETWORKMANAGER_WIRELESS_DEVICE_H */
|
@ -1,54 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* secret_storage_plugin.cpp - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <tqobject.h>
|
||||
|
||||
#include "secret_storage_plugin.h"
|
||||
|
||||
SecretStoragePlugin::SecretStoragePlugin(TQObject* parent, const char* name, const TQStringList& args)
|
||||
: Plugin(parent, name, args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SecretStoragePlugin::~SecretStoragePlugin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool SecretStoragePlugin::saveSecret(TQString& key, TQMap<TQString, TQString>& secrets)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void SecretStoragePlugin::restoreSecretsAsync(TQString& key)
|
||||
{
|
||||
// just emit an error
|
||||
TQMap<TQString, TQString> empty;
|
||||
emit signalSecretsRestored(key, empty, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "secret_storage_plugin.moc"
|
@ -1,53 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* secret_storage_plugin.h - A NetworkManager frontend for KDE
|
||||
*
|
||||
* Copyright (C) 2006 Novell, Inc.
|
||||
*
|
||||
* Author: Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef KNETWORKMANAGER_SECRET_STORAGE_PLUGIN_H
|
||||
#define KNETWORKMANAGER_SECRET_STORAGE_PLUGIN_H
|
||||
|
||||
#include <tqwidget.h>
|
||||
#include <tqmap.h>
|
||||
#include <tqdbusdata.h>
|
||||
#include <tqdbusvariant.h>
|
||||
#include "knetworkmanager-plugin.h"
|
||||
|
||||
#define KNETWORKMANAGER_SECRET_STORAGE_PLUGIN "KNetworkManager/SecretStoragePlugin"
|
||||
|
||||
class SecretStoragePlugin : public Plugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SecretStoragePlugin(TQObject*, const char*, const TQStringList&);
|
||||
virtual ~SecretStoragePlugin();
|
||||
|
||||
virtual bool saveSecret(TQString& key, TQMap<TQString, TQString>& secrets);
|
||||
virtual void restoreSecretsAsync(TQString& key);
|
||||
|
||||
signals:
|
||||
void signalSecretsRestored(TQString& key, TQMap<TQString, TQString>, bool);
|
||||
};
|
||||
|
||||
|
||||
#endif /* KNETWORKMANAGER_SECRET_STORAGE_PLUGIN_H */
|
||||
|
Loading…
Reference in new issue