Index: Messages.sh =================================================================== --- Messages.sh (revision 864988) +++ Messages.sh (revision 1010672) @@ -1,4 +0,0 @@ -#! /usr/bin/env bash -$EXTRACTRC `find . -name '*.ui' -o -name '*.rc'` >> rc.cpp -$XGETTEXT *.cpp widgets/*.cpp libs/ui/*.cpp libs/storage/*.cpp -o $podir/plasma_applet_networkmanager.pot -rm -f rc.cpp Index: connection.cpp =================================================================== --- connection.cpp (revision 864988) +++ connection.cpp (revision 1010672) @@ -1,73 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "connection.h" -#include "connectionadaptor.h" -#include "marshallarguments.h" - -#include - -Connection::Connection(QObject *parent) - : QObject(parent) -{ - qDBusRegisterMetaType< QMap > >(); - qDBusRegisterMetaType< QMap >(); - - new ConnectionAdaptor(this); - - QDBusConnection::systemBus().registerObject(objectPath(), this); -} - -Connection::~Connection() -{ - QDBusConnection::systemBus().unregisterObject(objectPath()); -} - -QString Connection::objectPath() -{ - kDebug() << "returning incorrect path, fix this function!"; - return QString(NM_DBUS_PATH_SETTINGS_CONNECTION); -} - -QString Connection::GetID() const -{ - return settingsMap["name"]; -} - -void Connection::Update(QMap > changedParameters) -{ - foreach (const QString &key1, changedParameters.keys()) { - foreach (const QString &key2, changedParameters[key1].keys()) { - connectionMap[key1][key2] = changedParameters[key1][key2]; - } - } - emit Updated(changedParameters); -} - -void Connection::Delete() -{ - emit Removed() -} - -QMap > Connection::GetSettings() -{ - return settingsMap; -} - -#include "connection.moc" Index: nmmenu.cpp =================================================================== --- nmmenu.cpp (revision 864988) +++ nmmenu.cpp (revision 1010672) @@ -1,104 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "nmmenu.h" - -#include - -NMMenu::NMMenu(QWidget *parent) - : KMenu(parent), - networkConfig(), - m_addProfile(new QAction(i18n("Manage profiles..."), this)), - m_wifiNetworks(new QAction(i18n("Connect to wireless networks..."), this)), - m_sep1(new QAction(this)), - m_sep2(new QAction(this)) -{ - connect(m_addProfile, SIGNAL(triggered()), this, SIGNAL(manageProfilesRequested())); - connect(m_wifiNetworks, SIGNAL(triggered()), this, SIGNAL(scanForNetworksRequested())); - m_sep1->setSeparator(true); - m_sep2->setSeparator(true); -} - -NMMenu::~NMMenu() -{ - deleteAllProfiles(); - disconnect(m_addProfile, SIGNAL(triggered()), this, SIGNAL(manageProfilesRequested())); - disconnect(m_wifiNetworks, SIGNAL(triggered()), this, SIGNAL(scanForNetworksRequested())); -} - -void NMMenu::setConfig(KConfigGroup config) -{ - if (!config.isValid()) { - return; - } - - networkConfig = config; - - //build menu template - this->clear(); - this->addAction(m_addProfile); - this->addAction(m_sep1); - this->addAction(m_wifiNetworks); - this->addAction(m_sep2); - - //load network profiles - foreach (const QString &profile, networkConfig.groupList()) { - profileAdded(profile); - } -} - -void NMMenu::profileAdded(const QString &profile) -{ - QAction *action = new QAction(profile, this); - m_menuMap.insert(action, profile); - connect(action, SIGNAL(triggered()), this, SLOT(itemClicked())); - this->addAction(action); -} - -void NMMenu::profileRemoved(const QString &profile) -{ - QAction *action = m_menuMap.key(profile); - disconnect(action, SIGNAL(triggered()), this, SLOT(itemClicked())); - this->removeAction(action); - delete action; -} - -void NMMenu::reloadProfiles() -{ - deleteAllProfiles(); - foreach (const QString &profile, networkConfig.groupList()) { - profileAdded(profile); - } -} - -void NMMenu::deleteAllProfiles() -{ - foreach (QAction *action, m_menuMap.keys()) { - disconnect(action, SIGNAL(triggered()), this, SLOT(itemClicked())); - removeAction(action); - delete action; - } -} - -void NMMenu::itemClicked() -{ - emit launchProfileRequested(m_menuMap.value((QAction*)sender())); -} - -#include "nmmenu.moc" Index: connection.h =================================================================== --- connection.h (revision 864988) +++ connection.h (revision 1010672) @@ -1,52 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef CONNECTION_H -#define CONNECTION_H - -#include -#include -#include -#include - -class Connection : public QObject -{ - Q_OBJECT - Q_CLASSINFO("Settings Interface", "org.freedesktop.NetworkManagerSettings.Connection") - - public: - Connection(QObject *parent=0); - ~Connections(); - - QString objectPath(); - - //export to dbus - Q_SCRIPTABLE QString GetID() const; - Q_SCRIPTABLE void Update(QMap > changedParameters); - Q_SCRIPTABLE void Delete(); - Q_SCRIPTABLE QMap > GetSettings(); - - Q_SIGNALS: - void Updated(QMap >); - void Removed(); - private: - QMap > settingsMap; -}; - -#endif \ No newline at end of file Index: nmmenu.h =================================================================== --- nmmenu.h (revision 864988) +++ nmmenu.h (revision 1010672) @@ -1,57 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef NMMENU_H -#define NMMENU_H - -#include -#include - -#include -#include - -class NMMenu : public KMenu -{ - Q_OBJECT - - public: - NMMenu(QWidget *parent=0); - ~NMMenu(); - - void setConfig(KConfigGroup config); - - public Q_SLOTS: - void profileAdded(const QString &profile); - void profileRemoved(const QString &profile); - void itemClicked(); - void reloadProfiles(); - - Q_SIGNALS: - void manageProfilesRequested(); - void scanForNetworksRequested(); - void launchProfileRequested(const QString &profile); - - private: - void deleteAllProfiles(); - KConfigGroup networkConfig; - QHash m_menuMap; - QAction *m_addProfile, *m_wifiNetworks, *m_sep1, *m_sep2; -}; - -#endif //NMMENU_H Index: plasma-applet-networkmanager.desktop =================================================================== --- plasma-applet-networkmanager.desktop (revision 864988) +++ plasma-applet-networkmanager.desktop (revision 1010672) @@ -1,41 +0,0 @@ -[Desktop Entry] -Name=Network Manager -Name[el]=Διαχειριστής δικτύου -Name[et]=Võrguhaldur -Name[ga]=Bainisteoir an Líonra -Name[gl]=Xestor da rede -Name[km]=កម្មវិធី​គ្រប់គ្រង​បណ្ដាញ -Name[pt]=Gestor de Rede -Name[pt_BR]=Gestor de Rede -Name[sv]=Nätverkshantering -Name[tr]=Ağ Yöneticisi -Name[uk]=Менеджер мережі -Name[x-test]=xxNetwork Managerxx -Comment=Network Manager Plasmoid -Comment[el]=Πλασμοειδές διαχείρισης δικτύου -Comment[es]=Plasmoide Network Manager -Comment[et]=Võrguhalduri plasmoid -Comment[fr]=Plasmoïde de gestion du réseau -Comment[ga]=Plasmoid Bainisteora Líonra -Comment[gl]=Plasmoide de xestión da rede -Comment[km]=Plasmoid កម្មវិធី​គ្រប់គ្រង​បណ្ដាញ -Comment[pt]=Plasmóide de Gestão da Rede -Comment[pt_BR]=Plasmóide de Gestão da Rede -Comment[sv]=Plasmoid för nätverkshantering -Comment[tr]=Ağ Yönetici Programcığı -Comment[uk]=Плазмоїд менеджера мережі -Comment[x-test]=xxNetwork Manager Plasmoidxx -Type=Service -X-KDE-ServiceTypes=Plasma/Applet - -X-KDE-Library=plasma_applet_networkmanager -X-KDE-PluginInfo-Author=Christopher Blauvelt -X-KDE-PluginInfo-Email=cblauvelt@gmail.com -X-KDE-PluginInfo-Name=networkmanager -X-KDE-PluginInfo-Version=0.1 -X-KDE-PluginInfo-Website=http://plasma.kde.org/ -X-KDE-PluginInfo-Category=System Management -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true - Index: networksettings.cpp =================================================================== --- networksettings.cpp (revision 864988) +++ networksettings.cpp (revision 1010672) @@ -1,77 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "networksettings.h" -#include "networksettingsadaptor.h" -#include "marshallarguments.h" - -#include - -#include "NetworkManager.h" - -NetworkSettings::NetworkSettings() -{ - //declare types - qDBusRegisterMetaType< QList >(); - - new NetworkSettingsAdaptor(this); - - QDBusConnection dbus = QDBusConnection::systemBus(); - dbus.registerObject(objectPath(), this); -} - -NetworkSettings::~NetworkSettings() -{ - QDBusConnection dbus = QDBusConnection::systemBus(); - dbus.unregisterObject(objectPath()); -} - -bool NetworkSettings::loadSettings(const KConfigGroup &settings) -{ - clearConnections(); - QStringList interfaceNames = settings.readEntry("InterfaceNameList", QStringList()).toStringList(); - foreach (const QString &interfaceName, interfacesNames) { - - } - return true; -} - -QList NetworkSettings::ListConnections() const -{ - QList pathList; - foreach(const QString &connName, connectionMap.keys()) { - pathList << QDBusObjectPath(connectionMap[connName]->objectPath()); - } - return pathList; -} - -void NetworkSettings::clearConnections() -{ - foreach (const QString &conn, connectionMap.keys()) { - connectionMap[conn]->Delete(); - connectionMap.remove(conn); - } -} - -QString NetworkSettings::objectPath() -{ - return QString(NM_DBUS_PATH_SETTINGS); -} - -#include "networksettings.moc" Index: secrets.h =================================================================== --- secrets.h (revision 864988) +++ secrets.h (revision 1010672) @@ -1,64 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef SECRETS_H -#define SECRETS_H - -#include -#include -#include -#include - -//DBus specific includes -#include -#include -#include -#include - -#include - -class Secrets : public QObject, protected QDBusContext -{ - Q_OBJECT - Q_CLASSINFO("Secrets Interface", "org.freedesktop.NetworkManagerSettings.Connection.Secrets") - - public: - Secrets(QObject *parent=0); - ~Secrets(); - - bool loadSettings(const KConfigGroup &group); - - Q_SCRIPTABLE QMap > GetSecrets(QString setting_name, QStringList hints, bool request_new); - - private: - Q_INVOKABLE void processRequest(); - KConfigGroup config; - QMap > secrets; - - //dbus objects - QDBusConnection conn; - QDBusMessage message; - - //stored settings for the delayed response - QString settingName; - QStringList hints; - bool requestNew; -}; - -#endif Index: networksettings.h =================================================================== --- networksettings.h (revision 864988) +++ networksettings.h (revision 1010672) @@ -1,55 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef NETWORK_SETTINGS_H -#define NETWORK_SETTINGS_H - -#include -#include -#include -#include - -//DBus specific includes -#include - -#include - -class NetworkSettings : public QObject -{ - Q_OBJECT - Q_CLASSINFO("Settings Interface", "org.freedesktop.NetworkManagerSettings") - - public: - NetworkSettings(QObject *parent=0); - ~NetworkSettings(); - - bool loadSettings(const KConfigGroup &settings); - Q_SCRIPTABLE QList ListConnections() const; - - Q_SIGNALS: - void NewConnection(QDbusObjectPath); - - private: - void clearConnections(); - QString objectPath() const; - - QMap connectionMap; -}; - -#endif \ No newline at end of file Index: networkmanager.cpp =================================================================== --- networkmanager.cpp (revision 864988) +++ networkmanager.cpp (revision 1010672) @@ -1,427 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "networkmanager.h" - -#include -#include -#include -#include - -//solid specific includes -//solid is only used directly until Plasma::Services are complete. -#include -#include -#include -#include -#include - -//kde specific includes -#include -#include -#include -#include - -NetworkManager::NetworkManager(QObject *parent, const QVariantList &args) - : Plasma::Applet(parent, args), - m_profileConfig(), - m_svgFile("networkmanager/networkmanager"), - m_icon(this), - m_elementName("app-knetworkmanager"), - m_networkEngine(0), - m_iconSize(64,64), - m_profileMenu(new NMMenu()), - m_profileDlg(0), - m_interfaceList(), - m_activeProfile(), - m_currentInterfaceIndex(-1), - m_stayConnected(false) -{ - setHasConfigurationInterface(false); - m_icon.setImagePath(m_svgFile); -} - -void NetworkManager::init() -{ - KConfigGroup gconfig = globalConfig(); - m_profileConfig= KConfigGroup(&gconfig, "Profiles"); - m_profileMenu->setConfig(m_profileConfig); - connect(m_profileMenu, SIGNAL(manageProfilesRequested()), this, SLOT(manageProfiles())); - connect(m_profileMenu, SIGNAL(scanForNetworksRequested()), this, SLOT(scanForNetworks())); - connect(m_profileMenu, SIGNAL(launchProfileRequested(const QString&)), this, SLOT(launchProfile(const QString&))); - connect(this, SIGNAL(clicked(QPointF)), this, SLOT(showMenu(QPointF))); - - m_icon.setContainsMultipleImages(false); - m_icon.resize(size()); - - setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - - m_networkEngine = dataEngine("networkmanager"); - if (!m_networkEngine) { - setFailedToLaunch(true, i18n("The Network Manager data engine could not be loaded. Please check to ensure it is installed.")); - } - m_networkEngine->connectSource("Network Management", this); - - Plasma::DataEngine::Data data = m_networkEngine->query("Network Management"); - if (data["Status"].toString() == "Unknown") { - setFailedToLaunch(true, i18n("Solid could not determine your connection status. Ensure that you have a network backend installed.")); - } - m_elementName = data["icon"].toString(); - - if (m_elementName.isEmpty()) { - //something is wrong here. - setFailedToLaunch(true, i18n("Network Manager could not determine your connection status.")); - } -} - -NetworkManager::~NetworkManager() -{ - if (!hasFailedToLaunch()) { - disconnect(m_profileMenu, SIGNAL(manageProfilesRequested()), this, SLOT(manageProfiles())); - disconnect(m_profileMenu, SIGNAL(scanForNetworksRequested()), this, SLOT(scanForNetworks())); - disconnect(m_profileMenu, SIGNAL(launchProfileRequested(const QString&)), this, SLOT(launchProfile(const QString&))); - disconnect(this, SIGNAL(clicked(QPointF)), this, SLOT(showMenu(QPointF))); - } - delete m_profileMenu; -} - -void NetworkManager::constraintsEvent(Plasma::Constraints constraints) -{ - if (constraints & Plasma::FormFactorConstraint) { - if (formFactor() == Plasma::Vertical) { - kDebug() << "Vertical FormFactor"; - // TODO: set background(true) on panel causes 0 height, so do not use it - setBackgroundHints(NoBackground); - } else if (formFactor() == Plasma::Horizontal) { - kDebug() << "Horizontal FormFactor"; - // TODO: set background(true) on panel causes 0 height, so do not use it - setBackgroundHints(NoBackground); - } else if (formFactor() == Plasma::Planar) { - kDebug() << "Planar FormFactor"; - setBackgroundHints(DefaultBackground); - } else if (formFactor() == Plasma::MediaCenter) { - kDebug() << "MediaCenter FormFactor"; - setBackgroundHints(DefaultBackground); - } else { - kDebug() << "Other FormFactor" << formFactor(); - setBackgroundHints(DefaultBackground); - } - } - - if (constraints & Plasma::SizeConstraint) { - m_icon.resize(size()); - } -} - -void NetworkManager::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect) -{ - if (&contentsRect == 0) { - Applet::paintInterface(p,option,contentsRect); - return; - } - - paintNetworkStatus(p,contentsRect); -} - -void NetworkManager::paintNetworkStatus(QPainter *p, const QRect &contentsRect) -{ - if(!m_elementName.isEmpty()) { - m_icon.paint(p,contentsRect,m_elementName); - } /*else { - kDebug() << "Couldn't find a valid icon. Tried: " << m_elementName; - }*/ -} - -Qt::Orientations NetworkManager::expandingDirections() const -{ - if (formFactor() == Plasma::Horizontal) { - return Qt::Vertical; - } else { - return Qt::Horizontal; - } -} - -void NetworkManager::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() != Qt::LeftButton) { - QGraphicsItem::mousePressEvent(event); - return; - } - - m_clickStartPos = scenePos(); -} - -void NetworkManager::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() != Qt::LeftButton) { - QGraphicsItem::mousePressEvent(event); - return; - } - if (m_clickStartPos == scenePos()) { - if (boundingRect().contains(event->pos())) { - emit clicked(event->pos()); - } - } -} - -void NetworkManager::dataUpdated(const QString &source, const Plasma::DataEngine::Data &data) -{ - if (source == "Network Management") { - m_elementName = data["icon"].toString(); - } else if (data["NetworkType"].toString() == "NetworkInterface") { - int index = m_interfaceList.indexOf(source); - if (index == -1) { - kDebug() << "Source could not be found. Ensure that signals are being cleaned up when a new profile is loaded."; - return; - } - if (index == m_currentInterfaceIndex && data["Connection State"] == "Failed") { - kDebug() << "Network Connection failed. Trying next . . . "; - onNetworkConnectionFailed(); - } - if (data["Link Up"].toBool() != m_interfaceUpList[index]) { - if (data["Link Up"].toBool()) { - kDebug() << "A new interface has come online."; - onInterfaceLinkUp(index); - } else { - kDebug() << "A new interface has gone offline."; - onNetworkConnectionFailed(); - } - } - m_interfaceUpList[index] = data["Link Up"].toBool(); - } - update(); -} - -void NetworkManager::showMenu(QPointF clickedPos) -{ - Q_UNUSED(clickedPos) - - m_profileMenu->popup(popupPosition(m_profileMenu->geometry().size())); -} - -void NetworkManager::manageProfiles() -{ - if (m_profileDlg == 0) { - kDebug() << "Creating a new profile."; - m_profileDlg = new KDialog(); - m_profileDlg->setCaption("Manage Profiles"); - m_profileDlg->setButtons( KDialog::Ok | KDialog::Cancel); - m_manageProfile = new ManageProfileWidget(m_profileDlg); - m_manageProfile->setConfig(m_profileConfig); - m_profileDlg->setMainWidget(m_manageProfile); - connect(m_profileDlg, SIGNAL(okClicked()), m_profileMenu, SLOT(reloadProfiles())); - connect(m_profileDlg, SIGNAL(okClicked()), this, SLOT(saveConfig())); - } - m_profileDlg->show(); -} - -void NetworkManager::scanForNetworks() -{ - kDebug() << "Scanning for networks."; -} - -void NetworkManager::launchProfile(const QString &profile) -{ - kDebug() << profile << " has been launched."; - - deactivateCurrentProfile(); - loadProfile(profile); - activateCurrentProfile(); -} - -void NetworkManager::deactivateCurrentProfile() -{ - //don't try to reconnect when the network is taken down - /*m_stayConnected = false; - disconnectInterface(m_currentInterfaceIndex); - m_activeProfile.clear(); - m_currentInterfaceIndex=-1; - - if (m_interfaceList.isEmpty()) { - return; - }*/ -} - -void NetworkManager::loadProfile(const QString &profile) -{ - //unload previous profile - /*foreach (const QString &interface, m_interfaceList) { - //disconnect all sources - m_networkEngine->disconnectSource(interface, this); - } - m_interfaceList.clear(); - m_interfaceUpList.clear(); - - //load the new profile - m_stayConnected = true; - m_activeProfile = profile; - - KConfigGroup config(&m_profileConfig, profile); - m_interfaceList = config.readEntry("InterfaceList", QStringList()); - foreach (const QString &interface, m_interfaceList) { - m_networkEngine->connectSource(interface, this); - m_interfaceUpList << m_networkEngine->query(interface)["Link Up"].toBool(); - }*/return; -} - -void NetworkManager::activateCurrentProfile() -{ - /*if (m_interfaceList.isEmpty()) { - kDebug() << "No profile has been loaded."; - return; - } - - connectInterface(0);//connect to the first interface*/ - return; -} - -void NetworkManager::disconnectInterface(int interfaceIndex) -{ - /*if (interfaceIndex < 0 || interfaceIndex >= m_interfaceList.size()) { - kDebug() << "Tried to load an out-of-bound interface number: " << interfaceIndex << ". Only " << m_interfaceList.size() << " are known."; - return; - } - - Solid::Control::NetworkInterface *iface = Solid::Control::NetworkManager::findNetworkInterface(m_interfaceList[interfaceIndex]); - if (iface == 0) { - kDebug() << "The interface \"" << m_interfaceList[interfaceIndex] << "\" could not be found."; - return; - } - Solid::Control::Network *activeNetwork = iface.findNetwork(iface.activeNetwork()); - if (activeNetwork != 0) { - return;//FIXME: the instruction below causes a crash. This should change with the Solid::Control::Network* re-write - //activeNetwork->setActivated(false); - }*/return; -} - -void NetworkManager::connectInterface(int interfaceIndex) -{ - /*if (interfaceIndex < 0 || interfaceIndex >= m_interfaceList.size()) { - kDebug() << "Tried to load an out-of-bound interface number: " << interfaceIndex << ". Only " << m_interfaceList.size() << " are known."; - return; - } - m_currentInterfaceIndex = interfaceIndex; - - Solid::Control::NetworkInterface *iface(m_interfaceList[m_currentInterfaceIndex]); - if (iface.type() == Solid::Control::NetworkInterface::Ieee8023) { - connectWiredNetwork(iface); - } else if(iface.type() == Solid::Control::NetworkInterface::Ieee80211) { - connectWirelessNetwork(iface); - }*/return; -} - -void NetworkManager::connectWiredNetwork(Solid::Control::NetworkInterface *iface) -{ - /*if (!iface.isValid() ) { - kDebug() << "Wired interface could not be created."; - return; - } - - Solid::Control::Network *network = iface.networks()[0]; - network->setActivated(true);*/return; -} - -void NetworkManager::connectWirelessNetwork(Solid::Control::NetworkInterface *iface) -{ - /*if (!iface.isValid() ) { - kDebug() << "Wired interface could not be created."; - return; - } - - KConfigGroup config(&m_profileConfig, m_activeProfile); - foreach (Solid::Control::Network *network, iface.networks()) { - Solid::Control::WirelessNetwork *wifiNet = (Solid::Control::WirelessNetwork*)network; - if(wifiNet->essid() == config.readEntry("ESSID", QString())) { - kDebug() << wifiNet->essid() << " found. Connecting . . . "; - loadEncryption((Solid::Control::WirelessNetwork*)network, config); - network->setActivated(true); - } - }*/return; -} - -void NetworkManager::loadEncryption(Solid::Control::WirelessNetworkInterface *wifiNet, const KConfigGroup &config) -{ - /*int encType = config.readEntry("WirelessSecurityType", (int)EncryptionSettingsWidget::None); - kDebug() << "Using encryption type: " << encType; - - KConfigGroup authGroup(&config, "Encryption"); - Solid::Control::Authentication *auth; - Solid::Control::Authentication::SecretMap secrets; - - switch (encType) { - case EncryptionSettingsWidget::None: - kDebug() << "No encryption loaded."; - auth = new Solid::Control::AuthenticationNone(); - break; - case EncryptionSettingsWidget::Wep: - kDebug() << "Using Wep."; - Solid::Control::AuthenticationWep *authwep = new Solid::Control::AuthenticationWep();; - authwep->setType((Solid::Control::AuthenticationWep::WepType)authGroup.readEntry("WEPEncryptionKeyType", 0)); - authwep->setMethod((Solid::Control::AuthenticationWep::WepMethod)authGroup.readEntry("WEPAuthentication", 0)); - int wepType = authGroup.readEntry("WEPType", 0); - if (wepType == 0) { - authwep->setKeyLength(64); - } else { - authwep->setKeyLength(128); - } - switch(authwep->type()) { - case EncryptionSettingsWidget::Ascii: - case EncryptionSettingsWidget::Hex: - secrets["key"] = authGroup.readEntry(QString("WEPStaticKey%1").arg(authGroup.readEntry("WEPKey", 0)+1), QString());//key is zero indexed. - authwep->setSecrets(secrets); - break; - case EncryptionSettingsWidget::Passphrase: - secrets["key"] = authGroup.readEntry("WEPPassphrase", QString()); - authwep->setSecrets(secrets); - break; - } - auth = dynamic_cast(authwep); - break; - } - wifiNet->setAuthentication(auth);*/return; -} - -void NetworkManager::onNetworkConnectionFailed() -{ - /*kDebug() << "Connection failed."; - //connection failed. Try to connect to the next network. - if (m_currentInterfaceIndex+1 == m_interfaceList.size()) { - kDebug() << "All interfaces have failed. Aborting."; - return; - } - - if (m_stayConnected) { - connectInterface(m_currentInterfaceIndex+1); - }*/return; -} - -void NetworkManager::onInterfaceLinkUp(int interfaceIndex) -{ - /*if (interfaceIndex < m_currentInterfaceIndex) { - disconnectInterface(m_currentInterfaceIndex); - connectInterface(interfaceIndex); //note that if this fails the previous interface will eventually become active again. - }*/return; -} - -void NetworkManager::saveConfig() -{ - globalConfig().sync(); -} - -#include "networkmanager.moc" Index: networkmanager.h =================================================================== --- networkmanager.h (revision 864988) +++ networkmanager.h (revision 1010672) @@ -1,112 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef NETWORKMANAGER_H -#define NETWORKMANAGER_H - -#include "nmmenu.h" -#include "widgets/manageprofilewidget.h" - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -class QPointF; -class QGraphicsSceneMouseEvent; - -class NetworkManager : public Plasma::Applet -{ - Q_OBJECT - - public: - NetworkManager(QObject *parent, const QVariantList &args); - ~NetworkManager(); - - void init(); - Qt::Orientations expandingDirections() const; - void paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &rect); - - public Q_SLOTS: - void dataUpdated(const QString &source, const Plasma::DataEngine::Data &data); - void showMenu(QPointF clickedPos); - void manageProfiles(); - void scanForNetworks(); - void launchProfile(const QString &profile); - void saveConfig(); - - Q_SIGNALS: - void clicked(QPointF clickedPos); - - protected: - void constraintsEvent(Plasma::Constraints constraints); - - private: - void paintNetworkStatus(QPainter *p, const QRect &contentsRect); - - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - - //interface activation methods - //TODO: move these to the dataengine once Plasma::Services are implemented - void loadProfile(const QString &profile); - void activateCurrentProfile(); - void deactivateCurrentProfile(); - void connectInterface(int interfaceIndex); - void disconnectInterface(int interfaceIndex); - void connectWiredNetwork(Solid::Control::NetworkInterface *iface); - void connectWirelessNetwork(Solid::Control::NetworkInterface *iface); - void loadEncryption(Solid::Control::WirelessNetworkInterface *wifiNet, const KConfigGroup &config); - void onNetworkConnectionFailed(); - void onInterfaceLinkUp(int interfaceIndex); - - KConfigGroup m_profileConfig; - QString m_svgFile; - Plasma::Svg m_icon; - QString m_elementName; - Plasma::DataEngine *m_networkEngine; - QSizeF m_iconSize; - QPointF m_clickStartPos; - - //creation and selection of profiles - NMMenu *m_profileMenu; - KDialog *m_profileDlg; - ManageProfileWidget *m_manageProfile; - - //connection management - QStringList m_interfaceList; - QList m_interfaceUpList; - QString m_activeProfile; - int m_currentInterfaceIndex; - bool m_stayConnected; -}; - -K_EXPORT_PLASMA_APPLET(networkmanager, NetworkManager) - -#endif Index: networkmanagement.notifyrc =================================================================== --- networkmanagement.notifyrc (revision 0) +++ networkmanagement.notifyrc (revision 1010672) @@ -0,0 +1,593 @@ +[Global] +Name=Network Management +Name[da]=Netværkshåndtering +Name[de]=Netzwerkverwaltung +Name[et]=Võrguhaldur +Name[fr]=Gestion du réseau +Name[ga]=Bainisteoireacht an Líonra +Name[gl]=Xestión da rede +Name[km]=ការ​​គ្រប់គ្រង​បណ្ដាញ +Name[pt]=Gestão de Rede +Name[pt_BR]=Gestão de Rede +Name[ro]=Gestiunea rețelei +Name[sv]=Nätverkshantering +Name[tr]=Ağ Yönetimi +Name[uk]=Керування мережею +Name[x-test]=xxNetwork Managementxx +IconName=networkmanager +Comment=Network Management +Comment[da]=Netværkshåndtering +Comment[de]=Netzwerkverwaltung +Comment[et]=Võrguhaldur +Comment[fr]=Gestion réseau +Comment[ga]=Bainisteoireacht an Líonra +Comment[gl]=Xestión da rede +Comment[km]=ការ​​គ្រប់គ្រង​បណ្ដាញ +Comment[nds]=Nettwarkpleeg +Comment[pt]=Gestão de Rede +Comment[pt_BR]=Gerenciamento de rede +Comment[ro]=Gestiunea rețelei +Comment[sv]=Nätverkshantering +Comment[tr]=Ağ Yönetimi +Comment[uk]=Керування мережею +Comment[x-test]=xxNetwork Managementxx +Version=3 + +[Context/connectiontype] +Name=Network Connection Type +Name[da]=Type af netværksforbindelse +Name[pt]=Tipo da Ligação de Rede +Name[pt_BR]=Tipo da Ligação de Rede +Name[ro]=Tipul conexiunii de rețea +Name[sv]=Typ av nätverksanslutning +Name[tr]=Ağ Bağlantısı Tipi +Name[uk]=Тип мережного з'єднання +Name[x-test]=xxNetwork Connection Typexx + +[Event/hwadded] +Name=Network Interface Attached +Name[da]=Netkort tilsluttet +Name[de]=Netzwerkschnittstelle angeschlossen +Name[el]=Σύναψη διασύνδεσης δικτύου +Name[et]=Võrguliides on ühendatud +Name[fr]=Interface réseau attachée +Name[gl]=Engadiuse unha interface de rede +Name[ja]=ネットワークインターフェースの追加 +Name[km]=ចំណុច​ប្រទាក់​បណ្ដាញ​បាន​ភ្ជាប់ +Name[lt]=Prijungta tinklo sąsaja +Name[nds]=Nettwarkkoppelsteed toföögt +Name[pa]=ਨੈੱਟਵਰਕ ਇੰਟਰਫੇਸ ਅਟੈਚਮੈਂਟ +Name[pt]=Interface de Rede Ligada +Name[pt_BR]=Interface de rede conectada +Name[ro]=Interfață de rețea atașată +Name[sv]=Nätverksgränssnitt anslutet +Name[tr]=Ağ Arayüzü Takıldı +Name[uk]=Доданий інтерфейс мережі +Name[x-test]=xxNetwork Interface Attachedxx +Comment=A network interface was attached +Comment[da]=Et netkort blev tilsluttet +Comment[de]=Eine Netzwerkschnittstelle wurde angeschlossen +Comment[el]=Έγινε σύναψη μιας διασύνδεσης δικτύου +Comment[et]=Võrguliides on ühendatud +Comment[fr]=Une interface réseau a été attachée +Comment[ga]=Ceanglaíodh comhéadan líonra +Comment[gl]=Engadiuse unha interface de rede +Comment[ja]=ネットワークインターフェースが追加されました +Comment[km]=ចំណុច​ប្រទាក់​បណ្ដាញ​ត្រូវ​បាន​ភ្ជាប់ +Comment[lt]=Prijungta tinklo sąsaja +Comment[nds]=En Nettwarkkoppelsteed wöör toföögt +Comment[nl]=Er was een netwerkinterface aangesloten +Comment[pa]=ਇੱਕ ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਜੁੜਿਆ +Comment[pt]=Foi ligada uma interface de rede +Comment[pt_BR]=Uma interface de rede foi conectada +Comment[ro]=A fost atașată o interfață de rețea +Comment[sv]=Ett nätverksgränssnitt har anslutits +Comment[tr]=Bir ağ arayüzü takıldı +Comment[uk]=Було додано інтерфейс мережі +Comment[x-test]=xxA network interface was attachedxx +Action=Popup + +[Event/hwremoved] +Name=Network Interface Removed +Name[da]=Netkort fjernet +Name[de]=Netzwerkschnittstelle entfernt +Name[el]=Αφαίρεση διασύνδεσης δικτύου +Name[et]=Võrguliides on eemaldatud +Name[fr]=Interface réseau retirée +Name[ga]=Baineadh Comhéadan Líonra +Name[gl]=Eliminouse unha interface de rede +Name[ja]=ネットワークインターフェースの削除 +Name[km]=បាន​យក​ចំណុច​ប្រទាក់​បណ្ដាញ​ចេញ +Name[lt]=Pašalinta tinklo sąsaja +Name[nds]=Nettwarkkoppelsteed wegmaakt +Name[pa]=ਇੱਕ ਨੈੱਟਵਰਕ ਇੰਟਰਫੇਸ ਹਟਾਇਆ +Name[pt]=Interface de Rede Removida +Name[pt_BR]=Interface de rede removida +Name[ro]=Interfață de rețea eliminată +Name[sv]=Nätverksgränssnitt borttaget +Name[tr]=Ağ Arayüzü Çıkarıldı +Name[uk]=Вилучено інтерфейс мережі +Name[x-test]=xxNetwork Interface Removedxx +Comment=A network interface was removed +Comment[da]=Et netkort blev fjernet +Comment[de]=Eine Netzwerkschnittstelle wurde entfernt +Comment[el]=Έγινε αφαίρεση μιας διασύνδεσης δικτύου +Comment[et]=Võrguliides on eemaldatud +Comment[fr]=Une interface réseau a été retirée +Comment[ga]=Baineadh comhéadan líonra +Comment[gl]=Eliminouse unha interface de rede +Comment[ja]=ネットワークインターフェースが削除されました +Comment[km]=ចំណុច​ប្រទាក់​បណ្ដាញ​ត្រូវ​បាន​យក​ចេញ +Comment[lt]=Tinklo sąsaja buvo pašalinta +Comment[nds]=En Nettwarkkoppelsteed wöör wegmaakt +Comment[nl]=Er was een netwerkinterface verwijderd +Comment[pa]=ਇੱਕ ਨੈੱਟਵਰਕ ਇੰਟਰਫੇਸ ਹਟਾਇਆ ਗਿਆ +Comment[pt]=Foi removida uma interface de rede +Comment[pt_BR]=Uma interface de rede foi removida +Comment[ro]=A fost eliminată o interfață de rețea +Comment[sv]=Ett nätverksgränssnitt har tagits bort +Comment[tr]=Bir ağ arayüzü çıkarıldı +Comment[uk]=Було вилучено інтерфейс мережі +Comment[x-test]=xxA network interface was removedxx + +[Event/networkappeared] +Name=Found Wireless Network +Name[da]=Fandt trådløst netværk +Name[de]=Drahtloses Netzwerk gefunden +Name[el]=Βρέθηκε ασύρματο δίκτυο +Name[et]=Leiti juhtmeta võrk +Name[fr]=Réseau sans fil découvert +Name[ga]=Aimsíodh Líonra Gan Sreang +Name[gl]=Atopouse unha rede sen fíos +Name[ja]=ワイヤレスネットワークを検出 +Name[km]=រក​ឃើញ​បណ្ដាញ​ឥតខ្សែ +Name[lt]=Rastas bevielis tinklas +Name[nds]=Funknettwark funnen +Name[pa]=ਬੇਤਾਰ ਨੈੱਟਵਰਕ ਲੱਭਿਆ +Name[pt]=Rede Sem-Fios Descoberta +Name[pt_BR]=Rede sem fio encontrada +Name[ro]=Rețea fără fir găsită +Name[sv]=Hittade trådlöst nätverk +Name[tr]=Kablosuz Ağ Bulundu +Name[uk]=Знайдено бездротову мережу +Name[x-test]=xxFound Wireless Networkxx +Comment=A wireless network appeared +Comment[da]=Et trådløst netværk er dukket op +Comment[de]=Ein drahtloses Netzwerk wurde entdeckt +Comment[el]=Βρέθηκε ένα ασύρματο δίκτυο +Comment[et]=Saadavale ilmus juhtmeta võrk +Comment[fr]=Un réseau sans fil est apparu +Comment[gl]=Apareceu unha rede sen fíos +Comment[ja]=ワイヤレスネットワークが現れました +Comment[km]=បណ្ដាញ​ឥតខ្សែ​បានបង្ហាញ +Comment[lt]=Atsirado bevielis tinklas +Comment[nds]=En Funknettwark is opdukt +Comment[pa]=ਇੱਕ ਬੇਤਾਰ ਨੈੱਟਵਰਕ ਉਪਲੱਬਧ ਹੋਇਆ +Comment[pt]=Apareceu uma rede sem-fios +Comment[pt_BR]=Um rede sem fio apareceu +Comment[ro]=A apărut o rețea fără fir +Comment[sv]=Ett trådlöst nätverk dök upp +Comment[tr]=Bir kablosuz ağ görüldü +Comment[uk]=Встановлено зв’язок з бездротовою мережею +Comment[x-test]=xxA wireless network appearedxx + +[Event/networkdisappeared] +Name=Lost Wireless Network +Name[da]=Mistede trådløst netværk +Name[de]=Drahtloses Netzwerk verloren +Name[el]=Απώλεια ασύρματου δικτύου +Name[et]=Juhtmeta võrk kadus +Name[fr]=Réseau sans fil perdu +Name[ga]=Cailleadh Líonra Gan Sreang +Name[gl]=Perdeuse unha rede sen fíos +Name[ja]=ワイヤレスネットワークの消失 +Name[km]=បាត់​បណ្ដាញ​ឥតខ្សែ +Name[nds]=Funknettwark wegkamen +Name[pa]=ਬੇਤਾਰ ਨੈੱਟਵਰਕ ਗੁਆਚਾ +Name[pt]=Rede Sem-Fios Perdida +Name[pt_BR]=Rede sem fio perdida +Name[ro]=Rețea fără fir pierdută +Name[sv]=Förlorade trådlöst nätverk +Name[tr]=Kablosuz Ağ Kaybedildi +Name[uk]=Втрачено зв’язок з радіомережею +Name[x-test]=xxLost Wireless Networkxx +Comment=A wireless network disappeared +Comment[da]=Et trådløst netværk forsvandt +Comment[de]=Ein drahtloses Netzwerk ist nicht mehr vorhanden +Comment[el]=΄Ενα ασύρματο δίκτυο εξαφανίστηκε +Comment[et]=Juhtmeta võrk kadus +Comment[fr]=Un réseau sans fil a disparu +Comment[gl]=Desapareceu unha rede sen fíos +Comment[ja]=ワイヤレスネットワークが消えました +Comment[km]=បណ្ដាញ​ឥតខ្សែ​មិន​បានបង្ហាញ​ទេ +Comment[lt]=Bevielis tinklas išnyko +Comment[nds]=En Funknettwark is weg +Comment[pa]=ਇੱਕ ਬੇਤਾਰ ਨੈੱਟਵਰਕ ਖਤਮ ਹੋ ਗਿਆ +Comment[pt]=Desapareceu uma rede sem-fios +Comment[pt_BR]=Uma rede sem fio desapareceu +Comment[ro]=A dispărut o rețea fără fir +Comment[sv]=Ett trådlöst nätverk försvann +Comment[tr]=Bir kablosuz ağ kayboldu +Comment[uk]=Зв’язок з бездротовою мережею увірвався +Comment[x-test]=xxA wireless network disappearedxx + +[Event/userconnectionattempt] +Name=Establishing Network Connection +Name[da]=Opretter netværksforbindelse +Name[de]=Netzwerkverbindung wird hergestellt +Name[el]=Εδραίωση σύνδεσης δικτύου +Name[et]=Võrguühenduse loomine +Name[fr]=Établissement de la connexion réseau +Name[ga]=Ceangal Líonra á Bhunú +Name[gl]=A estabelecer unha conexión de rede +Name[ja]=ネットワーク接続を確立 +Name[km]=បង្កើត​ការ​តភ្ជាប់បណ្ដាញ +Name[lt]=Jungiamasi prie tinklo +Name[nds]=Tokoppeln na Nettwark +Name[nl]=Netwerkverbinding opzetten +Name[pa]=ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਬਣਾਇਆ ਜਾ ਰਿਹਾ ਹੈ +Name[pt]=A Estabelecer a Ligação à Rede +Name[pt_BR]=Estabelecendo conexão de rede +Name[ro]=Stabilire conexiune de rețea +Name[sv]=Upprättar nätverksanslutning +Name[tr]=Ağ Bağlantısı Yapılıyor +Name[uk]=Встановлення мережевого з'єднання +Name[x-test]=xxEstablishing Network Connectionxx +Comment=The user started making a connection +Comment[pt]=O utilizador começou a estabelecer uma ligação +Comment[pt_BR]=O utilizador começou a estabelecer uma ligação +Comment[ro]=Utilizatorul a început să facă o conexiune +Comment[sv]=Användaren håller på att göra en anslutning +Comment[uk]=Користувач почав створення з’єднання +Comment[x-test]=xxThe user started making a connectionxx + +[Event/autoconnectionattempt] +Name=Establishing Network Connection +Name[da]=Opretter netværksforbindelse +Name[de]=Netzwerkverbindung wird hergestellt +Name[el]=Εδραίωση σύνδεσης δικτύου +Name[et]=Võrguühenduse loomine +Name[fr]=Établissement de la connexion réseau +Name[ga]=Ceangal Líonra á Bhunú +Name[gl]=A estabelecer unha conexión de rede +Name[ja]=ネットワーク接続を確立 +Name[km]=បង្កើត​ការ​តភ្ជាប់បណ្ដាញ +Name[lt]=Jungiamasi prie tinklo +Name[nds]=Tokoppeln na Nettwark +Name[nl]=Netwerkverbinding opzetten +Name[pa]=ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਬਣਾਇਆ ਜਾ ਰਿਹਾ ਹੈ +Name[pt]=A Estabelecer a Ligação à Rede +Name[pt_BR]=Estabelecendo conexão de rede +Name[ro]=Stabilire conexiune de rețea +Name[sv]=Upprättar nätverksanslutning +Name[tr]=Ağ Bağlantısı Yapılıyor +Name[uk]=Встановлення мережевого з'єднання +Name[x-test]=xxEstablishing Network Connectionxx +Comment=A connection is being started automatically +Comment[pt]=Uma ligação está a ser iniciada automaticamente +Comment[pt_BR]=Uma ligação está a ser iniciada automaticamente +Comment[ro]=O conexiune este pornită automat +Comment[sv]=En anslutning håller på att startas automatiskt +Comment[uk]=Процедуру з’єднання було розпочато автоматично +Comment[x-test]=xxA connection is being started automaticallyxx +Action=Popup + +[Event/connecting] +Name=Establishing Network Connection +Name[da]=Opretter netværksforbindelse +Name[de]=Netzwerkverbindung wird hergestellt +Name[el]=Εδραίωση σύνδεσης δικτύου +Name[et]=Võrguühenduse loomine +Name[fr]=Établissement de la connexion réseau +Name[ga]=Ceangal Líonra á Bhunú +Name[gl]=A estabelecer unha conexión de rede +Name[ja]=ネットワーク接続を確立 +Name[km]=បង្កើត​ការ​តភ្ជាប់បណ្ដាញ +Name[lt]=Jungiamasi prie tinklo +Name[nds]=Tokoppeln na Nettwark +Name[nl]=Netwerkverbinding opzetten +Name[pa]=ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਬਣਾਇਆ ਜਾ ਰਿਹਾ ਹੈ +Name[pt]=A Estabelecer a Ligação à Rede +Name[pt_BR]=Estabelecendo conexão de rede +Name[ro]=Stabilire conexiune de rețea +Name[sv]=Upprättar nätverksanslutning +Name[tr]=Ağ Bağlantısı Yapılıyor +Name[uk]=Встановлення мережевого з'єднання +Name[x-test]=xxEstablishing Network Connectionxx +Comment=A network connection attempt was begun +Comment[da]=Et netværksforbindelsesforsøg er påbegyndt +Comment[de]=Ein Verbindungsversuch wurde begonnen +Comment[el]=Αρχή προσπάθειας σύνδεσης δικτύου +Comment[et]=Alustati võrguühenduse loomist +Comment[fr]=Une tentative d'établissement de la connexion réseau a débuté +Comment[gl]=Comezou un intento de conexión á rede +Comment[ja]=ネットワーク接続の確立を開始 +Comment[km]=កា​រប៉ុនប៉ង​តភ្ជាប់បណ្ដាញ​ត្រូវ​បាន​ចាប់ផ្ដើម +Comment[lt]=Buvo pradėtas bandymas prisijungti prie tinklo +Comment[nds]=Mit Tokoppeln na en Nettwark anfungen +Comment[nl]=Een poging tot een netwerkverbinding is begonnen +Comment[pa]=ਇੱਕ ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਬਣਾਉਣ ਦੀ ਕੋਸ਼ਿਸ਼ ਕੀਤੀ ਗਈ +Comment[pt]=Iniciou-se uma tentativa de ligação à rede +Comment[pt_BR]=Uma tentativa de conexão foi iniciada +Comment[ro]=A început o tentativă de conectare la rețea +Comment[sv]=Ett försök att ansluta till nätverket har påbörjats +Comment[tr]=Bir ağ bağlantı girişimi başlatıldı +Comment[uk]=Було розпочато спробу встановлення мережевого з’єднання +Comment[x-test]=xxA network connection attempt was begunxx +Action=Popup + +[Event/disconnected] +Name=Network Connection Disconnected +Name[da]=Netværksforbindelse afbrudt +Name[de]=Netzwerkverbindung getrennt +Name[el]=Αποσύνδεση σύνδεσης δικτύου +Name[et]=Võrguühendus on katkestatud +Name[fr]=Déconnecté du réseau +Name[gl]=Desconectouse dunha rede +Name[ja]=ネットワーク接続の切断 +Name[km]=ការ​តភ្ជាប់​បណ្ដាញ​ត្រូវ​បានផ្ដាច់ +Name[lt]=Atjungtas tinklo ryšys +Name[nds]=Vun Nettwark afkoppelt +Name[nl]=Netwerkverbinding verbroken +Name[pa]=ਇੱਕ ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਡਿਸ-ਕੁਨੈਕਟ +Name[pt]=Ligação de Rede Desligada +Name[pt_BR]=Conexão de rede desconectada +Name[ro]=Conexiune de rețea deconectată +Name[sv]=Nätverksanslutning nerkopplad +Name[tr]=Ağ Bağlantısı Kapatıldı +Name[uk]=Мережеве з’єднання розірвано +Name[x-test]=xxNetwork Connection Disconnectedxx +Comment=A network connection was disconnected +Comment[da]=En netværksforbindelse blev afbrudt +Comment[de]=Eine Netzwerkverbindung wurde getrennt +Comment[el]=Αποσύνδεση μιας σύνδεσης δικτύου +Comment[et]=Võrguühendus on katkestatud +Comment[fr]=Une connexion réseau est tombée +Comment[gl]=Unha conexión de rede foi desconectada +Comment[ja]=ネットワーク接続が切断されました +Comment[km]=កា​រតភ្ជាប់​បណ្ដាញ​ត្រូវ​បាន​ផ្ដាច់ +Comment[lt]=TInklo ryšys buvo atjungtas +Comment[nds]=En Nettwark-Verbinnen wöör afkoppelt +Comment[nl]=Een netwerkverbinding was verbroken +Comment[pa]=ਇੱਕ ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਡਿਸ-ਕੁਨੈਕਟ ਕੀਤਾ +Comment[pt]=A ligação de rede terminou +Comment[pt_BR]=Uma conexão de rede foi desconectada +Comment[ro]=A fost deconectată o conexiune de rețea +Comment[sv]=En nätverksanslutning har kopplats ner +Comment[tr]=Bir ağ bağlantısı kapatıldı +Comment[uk]=Мережеве з’єднання було розірвано +Comment[x-test]=xxA network connection was disconnectedxx + +[Event/connected] +Name=Network Connection Succeeded +Name[da]=Netværksforbindelse gennemført +Name[de]=Netzwerkverbindung erfolgreich hergestellt +Name[el]=Επιτυχής σύνδεση δικτύου +Name[et]=Võrguühenduse loomine õnnestus +Name[fr]=Connexion réseau réussie +Name[ga]=D'éirigh le Ceangal Líonra +Name[gl]=Unha conexión á rede tivo éxito +Name[ja]=ネットワーク接続成功 +Name[km]=កា​រតភ្ជាប់​បានជោគជ័យ +Name[lt]=Sėkmingai prisijungta prie tinklo +Name[nds]=Mit Spood na Nettwark tokoppelt +Name[nl]=Netwerkverbinding geslaagd +Name[pa]=ਇੱਕ ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਸਫ਼ਲ ਰਿਹਾ +Name[pt]=Ligação à Rede com Sucesso +Name[pt_BR]=Conexão da rede bem sucedida +Name[ro]=Conexiunea la rețea a reușit +Name[sv]=Nätverksanslutning lyckades +Name[tr]=Ağ Bağlantısı Başarılı +Name[uk]=Успішне з’єднання з мережею +Name[x-test]=xxNetwork Connection Succeededxx +Comment=A network connection was established +Comment[da]=En netværksforbindelse blev oprettet +Comment[de]=Eine Netzwerkverbindung wurde erfolgreich hergestellt +Comment[el]=Έγινε εδραίωση μιας σύνδεσης δικτύου +Comment[et]=Loodi võrguühendus +Comment[fr]=Une connexion réseau a été établie +Comment[ga]=Bunaíodh ceangal líonra +Comment[gl]=Estabeleceuse unha conexión á rede +Comment[ja]=ネットワーク接続が確立されました +Comment[km]=កា​រតភ្ជាប់បណ្ដាញ​ត្រូវ​បានបង្កើត +Comment[lt]=Tinklo ryšys buvo prijungtas +Comment[nds]=En Nettwark-Verbinnen wöör opstellt +Comment[nl]=Een netwerkverbinding is opgezet +Comment[pa]=ਇੱਕ ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਬਣਾਇਆ ਗਿਆ +Comment[pt]=Foi estabelecida uma ligação à rede +Comment[pt_BR]=Uma conexão de rede foi estabelecida +Comment[ro]=A fost stabilită o conexiune de rețea +Comment[sv]=En nätverksanslutning har upprättats +Comment[tr]=Bir ağ bağlantısı oluşturuldu +Comment[uk]=Було встановлено з’єднання з мережею +Comment[x-test]=xxA network connection was establishedxx +Action=Popup + +[Event/connfailed] +Name=Network Connection Failed +Name[da]=Netværksforbindelse mislykkedes +Name[de]=Netzwerkverbindung fehlgeschlagen +Name[el]=Αποτυχία σύνδεσης δικτύου +Name[et]=Võrguühenduse loomine nurjus +Name[fr]=Échec de connexion réseau +Name[ga]=Theip ar Cheangal Líonra +Name[gl]=Fallou unha conexión á rede +Name[ja]=ネットワーク接続失敗 +Name[km]=បានបរាជ័យ​ក្នុងកា​រតភ្ជាប់បណ្ដាញ +Name[lt]=Tinklo ryšys nepavyko +Name[nds]=Tokoppeln na Nettwark fehlslaan +Name[nl]=Netwerkverbinding is mislukt +Name[pa]=ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਫੇਲ੍ਹ ਹੈ +Name[pt]=Ligação à Rede sem Sucesso +Name[pt_BR]=Falha na conexão de rede +Name[ro]=Conexiunea de rețea a eșuat +Name[sv]=Nätverksanslutning misslyckades +Name[tr]=Ağ Bağlantısı Başarısız +Name[uk]=Спроба встановлення з'єднання зазнала невдачі +Name[x-test]=xxNetwork Connection Failedxx +Comment=A network connection attempt failed +Comment[da]=Et netværksforbindelsesforsøg mislykkedes +Comment[de]=Ein Verbindungsversuch ist fehlgeschlagen +Comment[el]=Αποτυχία προσπάθειας σύνδεσης με ένα δίκτυο +Comment[et]=Katse luua võrguühendust nurjus +Comment[fr]=Une tentative de connexion réseau a échoué +Comment[gl]=Fallou un intento de conectar cunha rede +Comment[ja]=ネットワーク接続を確立できませんでした +Comment[km]=​បានបរាជ័យ​ក្នុង​​ការ​ប៉ុនប៉ង​តភ្ជាប់បណ្ដាញ +Comment[lt]=Bandymas prisijungti prie tinklo nepavyko +Comment[nds]=Dat Tokoppeln na en Nettwark is fehlslaan +Comment[nl]=Een poging tot een netwerkverbinding is mislukt +Comment[pa]=ਇੱਕ ਨੈੱਟਵਰਕ ਕੁਨੈਕਸ਼ਨ ਕੋਸ਼ਿਸ਼ ਫੇਲ੍ਹ ਹੋਈ +Comment[pt]=A tentativa de ligação à rede foi mal-sucedida +Comment[pt_BR]=Uma tentativa de conexão de rede falhou +Comment[ro]=O tentativă de conectare la rețea a eșuat +Comment[sv]=Försök att ansluta till ett nätverk misslyckades +Comment[tr]=Bir ağa bağlanma girişimi başarısızlığa uğradı +Comment[uk]=Спроба встановлення з’єднання зазнала невдачі +Comment[x-test]=xxA network connection attempt failedxx +Action=Popup + +[Event/rfoff] +Name=Radio Hardware Switched Off +Name[de]=Hardware für drahtlose Verbindungen ausgeschaltet +Name[el]=Ασύρματο υλικό επικοινωνίας κλειστό +Name[et]=Raadioriistvara lülitati välja +Name[fr]=Extinction du matériel radio +Name[gl]=Apagouse o hardware de radio +Name[km]=បានបិទ​ផ្នែក​រឹង​វិទ្យុ +Name[nds]=Funkreedschap utmaakt +Name[pa]=ਰੇਡੀਓ ਹਾਰਡਵੇਅਰ ਬੰਦ ਹੈ +Name[pt]='Hardware' de Rádio Desligado +Name[pt_BR]='Hardware' de Rádio Desligado +Name[ro]=Echipament radio deconectat +Name[sv]=Radiohårdvara avstängd +Name[tr]=Radyo Donanımı Kapatıldı +Name[uk]=Радіозв’язок апаратно вимкнено +Name[x-test]=xxRadio Hardware Switched Offxx +Comment=Wireless transceivers disabled by hardware switch +Comment[de]=Die Hardware für drahtlose Verbindungen wurde am Gerät ausgeschaltet +Comment[el]=Απενεργοποίηση ασύρματων συσκευών μέσω ενός διακόπτη υλικού +Comment[et]=Riistvaralüliti keelas juhtmeta ühenduse vastuvõtjad +Comment[fr]=Désactivation matérielle des émetteurs / récepteurs sans fil +Comment[gl]=Os transceptores wireless foron desactivados polo conmutador hardware +Comment[km]=បានបិទ​ឧបករណ៍​បម្លែង​ឥតខ្សែ​ដោយ​កា​រប្ដូរ​ផ្នែក​រឹង +Comment[lt]=Bevieliai siųstuvai-imtuvai uždrausti aparatiniu jungikliu +Comment[nds]=Funkreedschap mit Hardwareschalter utmaakt +Comment[pa]=ਬੇਤਾਰ ਟਰਾਂਸਸੀਵਰ ਹਾਰਡਵੇਅਰ ਬਟਨ ਤੋਂ ਬੰਦ ਹੈ +Comment[pt]=Os receptores/transmissores sem-fios foram desligados pelo interruptor +Comment[pt_BR]=Os receptores/transmissores sem-fios foram desligados pelo interruptor +Comment[sv]=Trådlös sändning och mottagning inaktiverad av hårdvarubrytare +Comment[tr]=Kablosuz alıcılar, donanım düğmesi tarafından kapatıldı +Comment[uk]=Бездротовий приймач-передавач було вимкнено апаратним тумблером +Comment[x-test]=xxWireless transceivers disabled by hardware switchxx +Action=Popup + +[Event/rfon] +Name=Radio Hardware Switched On +Name[de]=Hardware für drahtlose Verbindungen eingeschaltet +Name[el]=Ασύρματο υλικό επικοινωνίας ενεργό +Name[et]=Raadioriistvara lülitati sisse +Name[fr]=Activation du matériel radio +Name[gl]=Acendeuse o hardware de radio +Name[km]=បានបើក​ផ្នែក​រឹង​វិទ្យុ +Name[nds]=Funkreedschap anmaakt +Name[pa]=ਰੇਡੀਓ ਹਾਰਡਵੇਅਰ ਚਾਲੂ ਹੈ +Name[pt]='Hardware' de Rádio Ligado +Name[pt_BR]='Hardware' de Rádio Ligado +Name[ro]=Echipament radio conectat +Name[sv]=Radiohårdvara aktiverad +Name[tr]=Radyo Donanımı Açıldı +Name[uk]=Радіозв’язок апаратно увімкнено +Name[x-test]=xxRadio Hardware Switched Onxx +Comment=Wireless transceivers enabled +Comment[de]=Hardware für drahtlose Verbindungen aktiviert +Comment[el]=Ενεργοποίηση ασύρματων συσκευών +Comment[et]=Juhtmeta ühenduse vastuvõtjad on lubatud +Comment[fr]=Activation matérielle des émetteurs / récepteurs sans fil +Comment[gl]=Habilitáronse os transceptores wireless +Comment[km]=បានបើក​ឧបករណ៍​បម្លែង​ឥតខ្សែ +Comment[lt]=Bevieliai siųstuvai-imtuvai įgalinti +Comment[nds]=En Funkreedschap wöör anmaakt +Comment[pa]=ਬੇਤਾਰ ਟਰਾਂਸਸੀਵਰ ਚਾਲੂ ਹੈ +Comment[pt]=Os receptores/transmissores sem-fios foram ligados +Comment[pt_BR]=Transceptor sem fio habilitado +Comment[ro]=Transmițători fără fir activați +Comment[sv]=Trådlös sändning och mottagning aktiverad +Comment[tr]=Kablosuz alıcılar etkinleştirildi +Comment[uk]=Увімкнено бездротовий приймач-передавач +Comment[x-test]=xxWireless transceivers enabledxx +Action=Popup + +[Event/lowsignal] +Name=Low Wireless Signal Strength +Name[de]=Niedrige Signalstärke +Name[el]=Χαμηλή ισχύ σήματος ασύρματου +Name[et]=Juhtmeta ühenduse nõrk signaal +Name[fr]=Faible puissance du signal sans fil +Name[gl]=A potencia do sinal wifi é baixa +Name[km]=កម្លាំង​សញ្ញា​ឥតខ្សែ​ទាប +Name[lt]=Žemas bevielio signalo stipris +Name[nds]=Siet Funksignaal-Stärk +Name[pa]=ਘੱਟ ਬੇਤਾਰ ਸਿਗਨਲ ਤਾਕਤ +Name[pt]=Potência do Sinal Sem-Fios Fraca +Name[pt_BR]=Potência do Sinal Sem-Fios Fraca +Name[ro]=Semnal rețea fără fir slab +Name[sv]=Låg trådlös signalstyrka +Name[tr]=Düşük kablosuz sinyali +Name[uk]=Низька потужність радіосигналу +Name[x-test]=xxLow Wireless Signal Strengthxx +Comment=The wireless signal strength is low +Comment[de]=Die Signalstärke der drahtlosen Verbindung ist niedrig +Comment[el]=Η ασύρματη ισχύ του σήματος είναι χαμηλή +Comment[et]=Juhtmeta ühenduse signaal on nõrk +Comment[fr]=Le signal sans fil est faible +Comment[gl]=A potencia do sinal wireless é baixa +Comment[km]=កម្លាំង​សញ្ញា​ឥតខ្សែ​គឺ​ទាប +Comment[lt]=Bevielis signalas yra silpnas +Comment[nds]=De Stärk vun't Funksignaal is siet +Comment[pa]=ਬੇਤਾਰ ਸਿਗਨਲ ਦੀ ਤਾਕਤ ਘੱਟ ਹੈ +Comment[pt]=A potência do sinal sem-fios é fraca +Comment[pt_BR]=A potência do sinal sem-fios é fraca +Comment[ro]=Semnalul rețelei fără fir este slab +Comment[sv]=Den trådlösa signalstyrkan är låg +Comment[tr]=Kablosuz sinyal gücü düşük +Comment[uk]=Занизька потужність радіосигналу +Comment[x-test]=xxThe wireless signal strength is lowxx +Action=Popup + +[Event/ifacestatechange] +Name=Interface changed state +Name[pt]=A interface mudou de estado +Name[pt_BR]=A interface mudou de estado +Name[ro]=Interfața și-a modificat starea +Name[sv]=Gränssnitt ändrade tillstånd +Name[uk]=Змінений стан інтерфейсу +Name[x-test]=xxInterface changed statexx +Comment=An interface changed state +Comment[pt]=Uma interface de rede mudou de estado +Comment[pt_BR]=Uma interface de rede mudou de estado +Comment[ro]=O interfață și-a modificat starea +Comment[sv]=Ett gränssnitt har ändrat sitt tillstånd +Comment[uk]=Змінений стан інтерфейсу +Comment[x-test]=xxAn interface changed statexx + +[Event/networkingdisabled] +Name=Network management disabled +Name[da]=Netværkshåndtering deaktiveret +Name[pt]=Gestão de rede desactivada +Name[pt_BR]=Gestão de rede desactivada +Name[ro]=Gestiunea rețelei a fost dezactivată +Name[sv]=Nätverkshantering inaktiverad +Name[tr]=Ağ yönetimi pasifleştirildi +Name[uk]=Керування мережею вимкнено +Name[x-test]=xxNetwork management disabledxx +Comment=The network management subsystem was stopped or restarted +Comment[da]=Undersystemet til netværkshåndtering blev stoppet eller genstartet +Comment[pt]=O sub-sistema de gestão da rede foi parado ou reiniciado +Comment[pt_BR]=O sub-sistema de gestão da rede foi parado ou reiniciado +Comment[ro]=Subsistemul de gestiune a rețelei a fost oprit sau repornit +Comment[sv]=Delsystemet för nätverkshantering stoppades eller startades om +Comment[uk]=Систему керування мережею було зупинено або перезапущено +Comment[x-test]=xxThe network management subsystem was stopped or restartedxx +Action=Popup + Property changes on: networkmanagement.notifyrc ___________________________________________________________________ Added: svn:mergeinfo Index: applet/networkmanagement.svg =================================================================== --- applet/networkmanagement.svg (revision 0) +++ applet/networkmanagement.svg (revision 1010672) @@ -0,0 +1,611 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property changes on: applet/networkmanagement.svg ___________________________________________________________________ Added: svn:mergeinfo Index: applet/activatableitem.h =================================================================== --- applet/activatableitem.h (revision 0) +++ applet/activatableitem.h (revision 1010672) @@ -0,0 +1,50 @@ +/* +Copyright 2008 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef ABSTRACTCONNECTABLEITEM_H +#define ABSTRACTCONNECTABLEITEM_H + +#include + +#include "remoteinterfaceconnection.h" + +class RemoteActivatable; + +class ActivatableItem : public Plasma::IconWidget +{ +Q_OBJECT +public: + ActivatableItem(RemoteActivatable *, QGraphicsItem * parent = 0); + virtual ~ActivatableItem(); + virtual void setupItem() = 0; +signals: + /** * Indicate that the 'connect' button was clicked. Used by the containing InterfaceGroup to + * tell the manager to activate the connection on one of its devices + */ + void clicked(ActivatableItem *); +protected Q_SLOTS: + void emitClicked(); +protected: + RemoteActivatable * m_activatable; + + RemoteInterfaceConnection* interfaceConnection() const; +}; + +#endif // ABSTRACTCONNECTABLEITEM_H Index: applet/interfaceconnectionitem.h =================================================================== --- applet/interfaceconnectionitem.h (revision 0) +++ applet/interfaceconnectionitem.h (revision 1010672) @@ -0,0 +1,53 @@ +/* +Copyright 2008,2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef APPLET_CONNECTIONITEM_H +#define APPLET_CONNECTIONITEM_H + +#include "activatableitem.h" + +class QGraphicsGridLayout; + + + +namespace Plasma +{ + class IconWidget; +} + +/** + * Represents an inactive connection + */ +class InterfaceConnectionItem : public ActivatableItem +{ +Q_OBJECT +public: + InterfaceConnectionItem(RemoteInterfaceConnection *, QGraphicsItem * parent = 0); + virtual ~InterfaceConnectionItem(); + //RemoteInterfaceConnection * interfaceConnection() const; + void setupItem(); +protected: + QGraphicsGridLayout * m_layout; + Plasma::IconWidget * m_icon; + Plasma::IconWidget * m_connectButton; +}; + +#endif //#define APPLET_CONNECTIONITEM_H + Index: applet/hiddenwirelessnetworkitem.h =================================================================== --- applet/hiddenwirelessnetworkitem.h (revision 0) +++ applet/hiddenwirelessnetworkitem.h (revision 1010672) @@ -0,0 +1,77 @@ +/* +Copyright 2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef HIDDENWIRELESSNETWORKITEM_H +#define HIDDENWIRELESSNETWORKITEM_H + +#include "wirelessnetwork.h" +#include "wirelessnetworkitem.h" + +class AbstractWirelessNetwork; +class QGraphicsLinearLayout; + +namespace Plasma +{ + class IconWidget; + class LineEdit; +} + +class HiddenWirelessNetwork : public AbstractWirelessNetwork +{ +Q_OBJECT +public: + HiddenWirelessNetwork(QObject * parent); + ~HiddenWirelessNetwork(); + QString ssid() const; + void setSsid(const QString & ssid); + int strength() const; + Solid::Control::AccessPoint * referenceAccessPoint() const; +private: + QString m_ssid; +}; + +class HiddenWirelessNetworkItem : public AbstractWirelessNetworkItem +{ +Q_OBJECT +public: + HiddenWirelessNetworkItem(QGraphicsItem * parent = 0); + virtual ~HiddenWirelessNetworkItem(); + void setupItem(); +public Q_SLOTS: + /* + * called if the user hits Esc or the popup is hidden + * safe to call repeatedly + */ + void resetSsidEntry(); +private Q_SLOTS: + /* + * switch into SSID entry mode + * safe to call repeatedly + */ + void connectClicked(); + // called if the user hits Enter + void ssidEntered(); +private: + static QString s_defaultText; + QGraphicsLinearLayout * m_layout; + Plasma::IconWidget * m_connect; + Plasma::LineEdit * m_ssidEdit; +}; +#endif // HIDDENWIRELESSNETWORKITEM_H Index: applet/applet_wip.h =================================================================== --- applet/applet_wip.h (revision 0) +++ applet/applet_wip.h (revision 1010672) @@ -0,0 +1,53 @@ +/* +Copyright 2008,2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef PLASMA_NETWORKMANAGER_APPLET_H +#define PLASMA_NETWORKMANAGER_APPLET_H + +#include +#include + +class InterfaceGroup; +class RemoteActivatableList; + +class NetworkManagerApplet : public Plasma::Applet +{ +Q_OBJECT +public: + NetworkManagerApplet(QObject * parent, const QVariantList & args); + ~NetworkManagerApplet(); + /* reimp Plasma::Applet */ + void init(); + /* reimp Plasma::Applet */ + void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem * option, const QRect & rect); + /* reimp Plasma::Applet */ + //QSizeF sizeHint(const Qt::SizeHint which, const QSizeF& constraint) const; + /* reimp Plasma::Applet */ + //Qt::Orientations expandingDirections() const; + /* reimp Plasma::Applet */ + void constraintsEvent(Plasma::Constraints constraints); + Plasma::Svg *m_svg; +}; + +#endif + + + + Index: applet/wiredinterfaceitem.cpp =================================================================== --- applet/wiredinterfaceitem.cpp (revision 0) +++ applet/wiredinterfaceitem.cpp (revision 1010672) @@ -0,0 +1,65 @@ +/* +Copyright 2008 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "wiredinterfaceitem.h" + +#include +#include + +#include "remoteinterfaceconnection.h" + +WiredInterfaceItem::WiredInterfaceItem(Solid::Control::WiredNetworkInterface * iface, InterfaceItem::NameDisplayMode mode, QGraphicsItem* parent) +: InterfaceItem(iface, mode, parent), m_wiredIface(iface) +{ + m_unavailableText = i18nc("Network cable of interface is not plugged in", "Not plugged in"); +} + +WiredInterfaceItem::~WiredInterfaceItem() +{ + +} + +void WiredInterfaceItem::connectButtonClicked() +{ + kDebug(); + switch ( m_iface->connectionState()) { + case Solid::Control::NetworkInterface::Unavailable: + // impossible, but nothing to do + break; + case Solid::Control::NetworkInterface::Disconnected: + case Solid::Control::NetworkInterface::Failed: + kDebug() << "TODO: activate default connection."; + break; + case Solid::Control::NetworkInterface::Preparing: + case Solid::Control::NetworkInterface::Configuring: + case Solid::Control::NetworkInterface::NeedAuth: + case Solid::Control::NetworkInterface::IPConfig: + case Solid::Control::NetworkInterface::Activated: // deactivate active connections + //foreach (const ActiveConnectionPair &connection, m_activeConnections) { + // Solid::Control::NetworkManager::deactivateConnection(connection.second->path()); + //} + break; + case Solid::Control::NetworkInterface::Unmanaged: + case Solid::Control::NetworkInterface::UnknownState: + break; + } +} + +// vim: sw=4 sts=4 et tw=100 Index: applet/plasma-applet-networkmanagement.desktop =================================================================== --- applet/plasma-applet-networkmanagement.desktop (revision 0) +++ applet/plasma-applet-networkmanagement.desktop (revision 1010672) @@ -0,0 +1,45 @@ +[Desktop Entry] +Name=Network Management +Name[da]=Netværkshåndtering +Name[de]=Netzwerkverwaltung +Name[et]=Võrguhaldur +Name[fr]=Gestion du réseau +Name[ga]=Bainisteoireacht an Líonra +Name[gl]=Xestión da rede +Name[km]=ការ​​គ្រប់គ្រង​បណ្ដាញ +Name[pt]=Gestão de Rede +Name[pt_BR]=Gestão de Rede +Name[ro]=Gestiunea rețelei +Name[sv]=Nätverkshantering +Name[tr]=Ağ Yönetimi +Name[uk]=Керування мережею +Name[x-test]=xxNetwork Managementxx +Comment=Network status and control utility +Comment[da]=Værktøj til netværksstatus og -kontrol +Comment[de]=Dienstprogramm für Netzwerkstatus und -kontrolle +Comment[et]=Võrgu oleku ja juhtimise tööriist +Comment[fr]=Outil présentant le statut du réseau et permettant son contrôle +Comment[gl]=Utensilio de estado e control da rede +Comment[km]=ស្ថានភាព​បណ្ដាញ​ និង​ការ​ត្រួតពិនិត្យ​ឧបករណ៍ +Comment[pt]=Utilitário de estado e controlo da rede +Comment[pt_BR]=Utilitário de estado e controlo da rede +Comment[ro]=Utilitar de gestiune și control al rețelei +Comment[sv]=Verktyg för nätverksstatus och kontroll +Comment[uk]=Інструмент стеження за станом і керування мережею +Comment[x-test]=xxNetwork status and control utilityxx +Type=Service +X-KDE-ServiceTypes=Plasma/Applet +Icon=networkmanager + +X-KDE-Library=plasma_applet_networkmanagement +X-KDE-PluginInfo-Author=Will Stephenson +X-KDE-PluginInfo-Email=wstephenson@kde.org +X-KDE-PluginInfo-Name=networkmanagement +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=http://plasma.kde.org/ +X-KDE-PluginInfo-Category=Network +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +X-Plasma-NotificationArea=true + Property changes on: applet/plasma-applet-networkmanagement.desktop ___________________________________________________________________ Added: svn:mergeinfo Index: applet/pics/ox32-action-accesspoint.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: applet/pics/ox32-action-accesspoint.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: applet/pics/accesspoint.svg =================================================================== --- applet/pics/accesspoint.svg (revision 0) +++ applet/pics/accesspoint.svg (revision 1010672) @@ -0,0 +1,120 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + Index: applet/pics/CMakeLists.txt =================================================================== --- applet/pics/CMakeLists.txt (revision 0) +++ applet/pics/CMakeLists.txt (revision 1010672) @@ -0,0 +1 @@ +kde4_install_icons(${ICON_INSTALL_DIR}) Index: applet/activatablelistwidget.cpp =================================================================== --- applet/activatablelistwidget.cpp (revision 0) +++ applet/activatablelistwidget.cpp (revision 1010672) @@ -0,0 +1,151 @@ +/* +Copyright 2008, 2009 Sebastian Kügler + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +// Own +#include "activatablelistwidget.h" + +// Qt +#include + +// KDE +#include + +// Plasma +#include +#include + +// networkmanagement lib +#include "remoteactivatable.h" +#include "remoteactivatablelist.h" +#include "remoteinterfaceconnection.h" +#include "remotewirelessnetwork.h" +#include "activatableitem.h" + +// networkmanagement applet +#include "interfaceconnectionitem.h" +#include "wirelessnetworkitem.h" + +ActivatableListWidget::ActivatableListWidget(RemoteActivatableList* activatables, QGraphicsWidget* parent) : Plasma::ScrollWidget(parent), + m_activatables(activatables), + m_layout(0) +{ + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); // for testing + //setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + //setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_widget = new QGraphicsWidget(this); + m_widget->setMinimumSize(240, 50); + m_layout = new QGraphicsLinearLayout(m_widget); + m_layout->setOrientation(Qt::Vertical); + m_layout->setSpacing(1); + m_widget->setLayout(m_layout); + setWidget(m_widget); +} + +void ActivatableListWidget::init() +{ + listAppeared(); + connect(m_activatables, SIGNAL(activatableAdded(RemoteActivatable*)), + SLOT(activatableAdded(RemoteActivatable *))); + connect(m_activatables, SIGNAL(activatableRemoved(RemoteActivatable*)), + SLOT(activatableRemoved(RemoteActivatable *))); + + connect(m_activatables, SIGNAL(appeared()), SLOT(listAppeared())); + connect(m_activatables, SIGNAL(disappeared()), SLOT(listDisappeared())); +} + +ActivatableListWidget::~ActivatableListWidget() +{ +} + +void ActivatableListWidget::addType(Knm::Activatable::ActivatableType type) +{ + if (!m_types.contains(type)) { + m_types.append(type); + } +} + +bool ActivatableListWidget::accept(RemoteActivatable * activatable) const +{ + return m_types.contains(activatable->activatableType()); +} + +ActivatableItem * ActivatableListWidget::createItem(RemoteActivatable * activatable) +{ + ActivatableItem* ai = 0; + switch (activatable->activatableType()) { + case Knm::Activatable::WirelessNetwork: + case Knm::Activatable::WirelessInterfaceConnection: + { // Wireless + kDebug() << "Creating Wireless thingie" << activatable->deviceUni(); + WirelessNetworkItem* wni = new WirelessNetworkItem(static_cast(activatable), m_widget); + ai = wni; + break; + } + default: + case Knm::Activatable::InterfaceConnection: + { + kDebug() << "Creating InterfaceConnection" << activatable->deviceUni(); + ai = new InterfaceConnectionItem(static_cast(activatable), m_widget); + break; + } + } + + Q_ASSERT(ai); + ai->setupItem(); + m_layout->addItem(ai); + m_itemIndex[activatable] = ai; + return ai; +} + +void ActivatableListWidget::listAppeared() +{ + foreach (RemoteActivatable* remote, m_activatables->activatables()) { + if (accept(remote)) { + createItem(remote); + } + } +} + +void ActivatableListWidget::listDisappeared() +{ + foreach (ActivatableItem* item, m_itemIndex) { + m_layout->removeItem(item); + delete item; + } + m_itemIndex.clear(); +} + +void ActivatableListWidget::activatableAdded(RemoteActivatable * added) +{ + kDebug(); + if (accept(added)) { + createItem(added); + } +} + +void ActivatableListWidget::activatableRemoved(RemoteActivatable * removed) +{ + m_layout->removeItem(m_itemIndex[removed]); + delete m_itemIndex[removed]; + m_itemIndex.remove(removed); +} + +// vim: sw=4 sts=4 et tw=100 Index: applet/interfaceitem.cpp =================================================================== --- applet/interfaceitem.cpp (revision 0) +++ applet/interfaceitem.cpp (revision 1010672) @@ -0,0 +1,399 @@ +/* +Copyright 2008,2009 Will Stephenson +Copyright 2008, 2009 Sebastian Kügler + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "interfaceitem.h" + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +InterfaceItem::InterfaceItem(Solid::Control::NetworkInterface * iface, NameDisplayMode mode, QGraphicsItem * parent) : Plasma::IconWidget(parent), + m_iface(iface), + m_connectionNameLabel(0), + m_connectionInfoLabel(0), + m_strengthMeter(0), + m_nameMode(mode), + m_enabled(false), + m_unavailableText(i18nc("Label for network interfaces that cannot be activated", "Unavailable")) +{ + setDrawBackground(true); + //setAcceptHoverEvents(false); + setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + Solid::Device* dev = new Solid::Device(m_iface->uni()); + m_interfaceName = dev->product(); + + m_layout = new QGraphicsGridLayout(this); + m_layout->setVerticalSpacing(0); + m_layout->setColumnSpacing(0, 8); + m_layout->setColumnSpacing(1, 4); + m_layout->setColumnSpacing(2, 6); + m_layout->setRowSpacing(0, 6); + m_layout->setRowSpacing(1, 6); + m_layout->setRowSpacing(2, 6); + m_layout->setPreferredWidth(240); + m_layout->setColumnFixedWidth(0, 48); + m_layout->setColumnMinimumWidth(1, 104); + m_layout->setColumnFixedWidth(2, 60); // FIXME: spacing? + m_layout->setColumnFixedWidth(3, 22); // FIXME: spacing? + + m_icon = new Plasma::IconWidget(this); + m_icon->setMinimumHeight(48); + m_icon->setMaximumHeight(48); + //m_icon->setAcceptHoverEvents(false); + m_layout->addItem(m_icon, 0, 0, 2, 1); + + QString icon; + switch (m_iface->type() ) { + case Solid::Control::NetworkInterface::Ieee8023: + icon = "network-wired"; + break; + case Solid::Control::NetworkInterface::Ieee80211: + icon = "network-wireless"; + break; + case Solid::Control::NetworkInterface::Serial: + // for updating our UI + connect(iface, SIGNAL(pppStats(uint,uint)), SLOT(pppStats(uint,uint))); + icon = "modem"; + break; + case Solid::Control::NetworkInterface::Gsm: + case Solid::Control::NetworkInterface::Cdma: + icon = "phone"; + break; + default: + icon = "network-wired"; + break; + } + m_icon->setIcon(icon); + //Plasma::IconWidget::setIcon(icon); + setDrawBackground(true); + // interface layout + m_ifaceNameLabel = new Plasma::Label(this); + m_ifaceNameLabel->nativeWidget()->setWordWrap(false); + //m_ifaceNameLabel->setMinimumWidth(176); + m_layout->addItem(m_ifaceNameLabel, 0, 1, 1, 2); + + m_connectButton = new Plasma::IconWidget(this); + m_connectButton->setMaximumHeight(22); + m_connectButton->setMaximumWidth(22); + m_connectButton->setIcon("dialog-ok"); + //m_connectButton->setToolTip(i18n("Connect wireless")); + m_connectButton->hide(); // Shown when hovered + + connect(m_connectButton, SIGNAL(clicked()), this, SLOT(connectButtonClicked())); + + m_layout->addItem(m_connectButton, 0, 3, 1, 1, Qt::AlignRight); + + // active connection name + m_connectionNameLabel = new Plasma::Label(this); + m_connectionNameLabel->setText(i18n("[not updated yet]")); // TODO: check connection status + m_connectionNameLabel->nativeWidget()->setFont(KGlobalSettings::smallestReadableFont()); + m_connectionNameLabel->nativeWidget()->setWordWrap(false); + m_layout->addItem(m_connectionNameLabel, 1, 1, 1, 2); + + // IP address + m_connectionInfoLabel = new Plasma::Label(this); + m_connectionInfoLabel->nativeWidget()->setFont(KGlobalSettings::smallestReadableFont()); + m_connectionInfoLabel->nativeWidget()->setWordWrap(false); + m_connectionInfoLabel->setText(i18n("IP Address: dum.my.ip.addr")); + m_layout->addItem(m_connectionInfoLabel, 2, 1, 1, 2, Qt::AlignCenter); + + if (m_iface->type() == Solid::Control::NetworkInterface::Ieee80211 || + m_iface->type() == Solid::Control::NetworkInterface::Cdma || + m_iface->type() == Solid::Control::NetworkInterface::Gsm ) { + // Signal strength meter + int meterHeight = 12; + m_strengthMeter = new Plasma::Meter(this); + m_strengthMeter->setMinimum(0); + m_strengthMeter->setMaximum(100); + m_strengthMeter->setValue(0); + m_strengthMeter->setMeterType(Plasma::Meter::BarMeterHorizontal); + m_strengthMeter->setPreferredSize(QSizeF(48, meterHeight)); + m_strengthMeter->setMaximumWidth(48); + m_strengthMeter->setMaximumHeight(meterHeight); + m_strengthMeter->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_strengthMeter->hide(); + m_layout->addItem(m_strengthMeter, 2, 0, 1, 1, Qt::AlignCenter); + //m_connectionInfoLabel->hide(); + + // m_strengthMeter->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + //m_layout->addItem(m_strengthMeter, 0, 1, 1, 1, Qt::AlignCenter); + + } + + // security + m_connectionInfoIcon = new Plasma::IconWidget(this); + //m_connectionInfoIcon->setIcon("object-unlocked"); // FIXME: set correct icon on start + m_connectionInfoIcon->setMinimumHeight(22); + m_connectionInfoIcon->setMinimumWidth(22); + m_connectionInfoIcon->setMaximumHeight(22); + //m_connectionInfoIcon->setAcceptHoverEvents(false); + //m_layout->addItem(m_connectionInfoStrengthLabel, 2, 2, 1, 1); + m_layout->addItem(m_connectionInfoIcon, 2, 3, 1, 1, Qt::AlignRight); + m_connectionInfoIcon->hide(); // hide by default, we'll enable it later + + // Forward state between icon and this widget + connect(m_icon, SIGNAL(pressed(bool)), this, SLOT(setPressed(bool))); + connect(this, SIGNAL(pressed(bool)), m_icon, SLOT(setPressed(bool))); + connect(m_icon, SIGNAL(clicked()), this, SLOT(itemClicked())); + + connect(this, SIGNAL(clicked()), this, SLOT(itemClicked())); + + connect(m_iface, SIGNAL(connectionStateChanged(int)), + this, SLOT(connectionStateChanged(int))); + connect(m_iface, SIGNAL(connectionStateChanged(int,int,int)), + this, SLOT(handleConnectionStateChange(int,int,int))); + connect(m_iface, SIGNAL(linkUpChanged(bool)), this, SLOT(setActive(bool))); + + if (m_iface->type() == Solid::Control::NetworkInterface::Ieee8023) { + Solid::Control::WiredNetworkInterface* wirediface = + static_cast(m_iface); + connect(wirediface, SIGNAL(carrierChanged(bool)), this, SLOT(setActive(bool))); + } + setNameDisplayMode(mode); + + connectionStateChanged(m_iface->connectionState()); + setLayout(m_layout); + m_layout->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + +} + +void InterfaceItem::itemClicked() +{ + emit clicked(m_iface->type()); +} + +QString InterfaceItem::label() +{ + return m_ifaceNameLabel->text(); +} + +void InterfaceItem::setActive(bool active) +{ + kDebug() << "+ + + + + + Active?" << active; + connectionStateChanged(m_iface->connectionState()); +} + +void InterfaceItem::setEnabled(bool enable) +{ + m_enabled = enable; + m_icon->setEnabled(enable); + m_connectionInfoLabel->setEnabled(enable); + m_connectionNameLabel->setEnabled(enable); + m_ifaceNameLabel->setEnabled(enable); + m_connectButton->setEnabled(enable); + m_connectionInfoIcon->setEnabled(enable); + if (m_strengthMeter) { + if (enable) { + m_strengthMeter->show(); + } else { + m_strengthMeter->hide(); + } + } +} + +InterfaceItem::~InterfaceItem() +{ +} + +void InterfaceItem::setNameDisplayMode(NameDisplayMode mode) +{ + m_nameMode = mode; + if ( m_nameMode == InterfaceName ) { + Solid::Device* dev = new Solid::Device(m_iface->uni()); + kDebug() << "Product:" << dev->product(); + m_ifaceNameLabel->setText(i18n("%1", dev->product())); + } else { + m_ifaceNameLabel->setText(i18nc("network interface name unknown", "Unknown Network Interface")); + } +} + +InterfaceItem::NameDisplayMode InterfaceItem::nameDisplayMode() const +{ + return m_nameMode; +} + +QString InterfaceItem::connectionName() +{ + // Default active connection's name is empty, room for improvement? + return QString(); +} + +void InterfaceItem::setConnectionInfo() +{ + connectionStateChanged(m_iface->connectionState()); + return; + if (m_connectionInfoLabel && m_connectionNameLabel) { + if (m_iface->connectionState() == Solid::Control::NetworkInterface::Activated) { + if (connectionName().isEmpty()) { + m_connectionNameLabel->setText(i18nc("interface is connected", "Connected")); + } else { + m_connectionNameLabel->setText(i18nc("wireless interface is connected", "Connected to %1", connectionName())); + } + m_connectionInfoLabel->setText(i18nc("ip address of the network interface", "Address: %1", currentIpAddress())); + //kDebug() << "addresses non-empty" << m_currentIp; + } + } +} + +QString InterfaceItem::currentIpAddress() +{ + if (m_iface->connectionState() != Solid::Control::NetworkInterface::Activated) { + return i18n("No IP address."); + } + Solid::Control::IPv4Config ip4Config = m_iface->ipV4Config(); + QList addresses = ip4Config.addresses(); + if (addresses.isEmpty()) { + return i18n("IP display error."); + } + QHostAddress addr(addresses.first().address()); + return addr.toString(); +} + +void InterfaceItem::pppStats(uint in, uint out) +{ + kDebug() << "PPP Stats. in:" << in << "out:" << out; +} + +void InterfaceItem::activeConnectionsChanged() +{ + setConnectionInfo(); +} + +void InterfaceItem::handleConnectionStateChange(int new_state, int old_state, int reason) +{ + Q_UNUSED(old_state); + Q_UNUSED(reason); + connectionStateChanged(new_state); +} + +void InterfaceItem::connectionStateChanged(int state) +{ + // TODO: + // get the active connections + // check if any of them affect our interface + // setActiveConnection on ourself + + // button to connect, disconnect + m_disconnect = false; + // Name and info labels + QString lname = QString(); + QString linfo = QString(); + + switch (state) { + case Solid::Control::NetworkInterface::Unavailable: + lname = i18n("Unavailable"); + linfo = QString(); + setEnabled(false); + break; + case Solid::Control::NetworkInterface::Disconnected: + lname = i18n("Disconnected"); + linfo = QString(); + setEnabled(true); + break; + case Solid::Control::NetworkInterface::Failed: + // set the disconnected icon + lname = i18nc("Notification text when a network interface connection attempt failed","Connection on %1 failed", m_interfaceName); + linfo = i18n("Connection failed"); + setEnabled(true); + break; + case Solid::Control::NetworkInterface::Preparing: + lname = i18n("Connecting..."); + linfo = i18n("Preparing network connection"); + m_disconnect = true; + setEnabled(true); + break; + case Solid::Control::NetworkInterface::Configuring: + lname = i18n("Connecting..."); + linfo = i18n("Configuring network connection"); + m_disconnect = true; + setEnabled(true); + break; + case Solid::Control::NetworkInterface::NeedAuth: + lname = i18n("Connecting..."); + linfo = i18n("Requesting authentication"); + m_disconnect = true; + setEnabled(true); + break; + case Solid::Control::NetworkInterface::IPConfig: + lname = i18n("Connecting..."); + linfo = i18n("Setting network address"); + setEnabled(true); + m_disconnect = true; + break; + case Solid::Control::NetworkInterface::Activated: + if (connectionName().isEmpty()) { + lname = i18nc("wireless interface is connected", "Connected"); + } else { + lname = i18nc("wireless interface is connected", "Connected to %1", connectionName()); + } + linfo = i18nc("ip address of the network interface", "Address: %1", currentIpAddress()); + m_disconnect = true; + setEnabled(true); + break; + case Solid::Control::NetworkInterface::Unmanaged: + lname = i18n("Unmanaged"); + linfo = QString(); + setEnabled(false); + break; + case Solid::Control::NetworkInterface::UnknownState: + lname = i18n("Unknown"); + linfo = QString(); + setEnabled(false); + break; + } + + // Update connect button + if (!m_disconnect) { + m_connectButton->setIcon("dialog-ok"); + m_connectButton->setToolTip(i18n("Connect")); + } else { + m_connectButton->setIcon("dialog-cancel"); + m_connectButton->setToolTip(i18n("Disconnect")); + } + m_connectionNameLabel->setText(lname); + m_connectionInfoLabel->setText(linfo); + + //kDebug() << "State changed" << lname << linfo; + + emit stateChanged(); +} + +QPixmap InterfaceItem::statePixmap(const QString &icon) { + // Which pixmap should we display with the notification? + return KIcon(icon).pixmap(QSize(KIconLoader::SizeMedium, KIconLoader::SizeMedium)); +} + +// vim: sw=4 sts=4 et tw=100 Index: applet/generic-types.h =================================================================== --- applet/generic-types.h (revision 0) +++ applet/generic-types.h (revision 1010672) @@ -0,0 +1,28 @@ +/* +Copyright 2008 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef SETTINGSSERVICE_GENERIC_TYPES_H +#define SETTINGSSERVICE_GENERIC_TYPES_H + +typedef QMap QVariantMapMap; +Q_DECLARE_METATYPE(QVariantMapMap) + +#endif + Index: applet/wirelessnetworkitem.cpp =================================================================== --- applet/wirelessnetworkitem.cpp (revision 0) +++ applet/wirelessnetworkitem.cpp (revision 1010672) @@ -0,0 +1,275 @@ +/* +Copyright 2008,2009 Sebastian Kügler +Copyright 2008,2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "wirelessnetworkitem.h" + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "remotewirelessnetwork.h" +#include "remotewirelessinterfaceconnection.h" +#include +#include "activatable.h" + +WirelessNetworkItem::WirelessNetworkItem(RemoteWirelessNetwork * remote, QGraphicsItem * parent) +: ActivatableItem(remote, parent), + m_security(0), + m_securityIcon(0), + m_securityIconName(0), + m_strength(0), + m_remote(remote) +{ + m_strengthMeter = new Plasma::Meter(this); + m_strength = 0; + + readSettings(); +} + +bool WirelessNetworkItem::readSettings() +{ + Solid::Control::AccessPoint::WpaFlags wpaFlags; + Solid::Control::AccessPoint::WpaFlags rsnFlags; + Solid::Control::AccessPoint::Capabilities capabilities; + Solid::Control::WirelessNetworkInterface::Capabilities interfaceCapabilities; + + //Solid::Control::WirelessNetworkInterface::Capabilities interfaceCapabilities() const; + + m_state = Knm::InterfaceConnection::Unknown; + int operationMode = 0; + Knm::Activatable::ActivatableType aType = m_remote->activatableType(); + if (aType == Knm::Activatable::WirelessInterfaceConnection) { + //kDebug() << "adding WirelessInterfaceConnection"; + RemoteWirelessInterfaceConnection* remoteconnection = static_cast(m_activatable); + m_ssid = remoteconnection->ssid(); + wpaFlags = remoteconnection->wpaFlags(); + rsnFlags = remoteconnection->rsnFlags(); + capabilities = remoteconnection->apCapabilities(); + interfaceCapabilities = remoteconnection->interfaceCapabilities(); + kDebug() << "========== RemoteActivationState" << remoteconnection->activationState(); + m_state = remoteconnection->activationState(); + connect(remoteconnection, SIGNAL(activationStateChanged(Knm::InterfaceConnection::ActivationState)), + SLOT(activationStateChanged(Knm::InterfaceConnection::ActivationState))); + RemoteWirelessObject * wobj = static_cast(remoteconnection); + operationMode = wobj->operationMode(); + } else if (aType == Knm::Activatable::WirelessNetwork) { + m_ssid = m_remote->ssid(); + wpaFlags = m_remote->wpaFlags(); + rsnFlags = m_remote->rsnFlags(); + capabilities = m_remote->apCapabilities(); + interfaceCapabilities = m_remote->interfaceCapabilities(); + RemoteWirelessObject * wobj = static_cast(m_remote); + operationMode = wobj->apCapabilities(); + } else { + return false; + } + + setStrength(m_remote->strength()); + connect(m_remote, SIGNAL(changed()), SLOT(update())); + connect(m_remote, SIGNAL(strengthChanged(int)), SLOT(setStrength(int))); + + Knm::WirelessSecurity::Type best = Knm::WirelessSecurity::best(interfaceCapabilities, true, (operationMode == Solid::Control::WirelessNetworkInterface::Adhoc), capabilities, wpaFlags, rsnFlags); + + m_securityIconName = Knm::WirelessSecurity::iconName(best); + m_securityIconToolTip = Knm::WirelessSecurity::shortToolTip(best); + return true; +} + +void WirelessNetworkItem::setupItem() +{ + //readSettings(); + //kDebug();// << "Connection Settings:" << m_connection->settings(); + //kDebug();// << "Security:" << m_connection->type() << m_security; + // painting of a non-active wifi network + /* + +----+-------------+-----+---+ + |icon essid |meter|sec| + +----+-------------+-----+---+ + */ + int rowHeight = 24; + int spacing = 4; + + m_layout = new QGraphicsGridLayout(this); + // First, third and fourth colunm are fixed width for the icons + m_layout->setColumnPreferredWidth(0, 160); + m_layout->setColumnFixedWidth(1, 60); + m_layout->setColumnFixedWidth(2, rowHeight); + m_layout->setColumnSpacing(1, spacing); + + // icon on the left + m_connectButton = new Plasma::IconWidget(this); + + if (interfaceConnection()) { + m_connectButton->setIcon("bookmarks"); // Known connection, we probably have credentials + m_connectButton->setText(interfaceConnection()->connectionName()); + } else { + m_connectButton->setText(m_ssid); + m_connectButton->setIcon("network-wireless"); // "New" network + } + m_connectButton->setMinimumWidth(160); + m_connectButton->setOrientation(Qt::Horizontal); +#if KDE_IS_VERSION(4,2,60) + m_connectButton->setTextBackgroundColor(QColor()); +#endif + //m_connectButton->setToolTip(i18nc("icon to connect to wireless network", "Connect to wireless network %1", ssid)); + m_connectButton->setMinimumHeight(rowHeight); + m_connectButton->setMaximumHeight(rowHeight); + m_layout->addItem(m_connectButton, 0, 0, 1, 1 ); + + m_strengthMeter = new Plasma::Meter(this); + m_strengthMeter->setMinimum(0); + m_strengthMeter->setMaximum(100); + m_strengthMeter->setValue(m_strength); + m_strengthMeter->setMeterType(Plasma::Meter::BarMeterHorizontal); + m_strengthMeter->setPreferredSize(QSizeF(60, rowHeight/2)); + m_strengthMeter->setMaximumHeight(rowHeight/2); + m_strengthMeter->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_layout->addItem(m_strengthMeter, 0, 1, 1, 1, Qt::AlignCenter); + + m_securityIcon = new Plasma::IconWidget(this); + m_securityIcon->setIcon(m_securityIconName); + m_securityIcon->setMinimumHeight(22); + m_securityIcon->setMaximumHeight(22); + m_securityIcon->setToolTip(m_securityIconToolTip); + m_layout->addItem(m_securityIcon, 0, 2, 1, 1, Qt::AlignLeft); + + connect(m_connectButton, SIGNAL(clicked()), this, SIGNAL(clicked())); + connect(this, SIGNAL(clicked()), this, SLOT(emitClicked())); + + // Forward clicks and presses between our widgets and this + connect(this, SIGNAL(pressed(bool)), m_connectButton, SLOT(setPressed(bool))); + connect(m_connectButton, SIGNAL(pressed(bool)), this, SLOT(setPressed(bool))); + connect(m_connectButton, SIGNAL(clicked()), this, SLOT(emitClicked())); + + connect(this, SIGNAL(pressed(bool)), m_securityIcon, SLOT(setPressed(bool))); + connect(m_securityIcon, SIGNAL(pressed(bool)), this, SLOT(setPressed(bool))); + connect(m_securityIcon, SIGNAL(clicked()), this, SLOT(emitClicked())); + + + update(); +} + +WirelessNetworkItem::~WirelessNetworkItem() +{ +} + +void WirelessNetworkItem::setStrength(int strength) +{ + kDebug() << m_ssid << "signal strength changed from " << m_strength << "to " << strength; + if (strength == m_strength) { + return; + } + m_strength = strength; + m_strengthMeter->setValue(m_strength); +} + +void WirelessNetworkItem::activationStateChanged(Knm::InterfaceConnection::ActivationState state) +{ + kDebug() << m_state << "changes to" << state; + if (m_state == state) { + return; + } + // Indicate the active interface + QString t; + if (interfaceConnection()) { + t = interfaceConnection()->connectionName(); + } else { + t = m_ssid; + } + //enum ActivationState { Unknown, Activating, Activated }; + if (interfaceConnection()) { + m_connectButton->setIcon("bookmarks"); // Known connection, we probably have credentials + m_connectButton->setText(interfaceConnection()->connectionName()); + + switch (m_state) { + //Knm::InterfaceConnection::ActivationState + case Knm::InterfaceConnection::Activated: + m_connectButton->setIcon("dialog-ok-apply"); // The active connection + t = QString("%1 (connected)").arg(t); + break; + case Knm::InterfaceConnection::Unknown: + break; + case Knm::InterfaceConnection::Activating: + t = QString("%1 (connecting...)").arg(t); + } + } else { + m_connectButton->setText(m_ssid); + m_connectButton->setIcon("network-wireless"); // "New" network + } + if (m_connectButton->text() != t) { + m_connectButton->setText(t); + } + m_state = state; + update(); +} + +/* +void WirelessNetworkItem::readSettings() +{ + + Knm::WirelessSecurity::Type best = Knm::WirelessSecurity::best(obj->interfaceCapabilities(), true, (obj->operationMode() == Solid::Control::WirelessNetworkInterface::Adhoc), obj->apCapabilities(), obj->wpaFlags(), obj->rsnFlags()); + security->setToolTip(Knm::WirelessSecurity::shortToolTip(best)); + security->setPixmap(SmallIcon(Knm::WirelessSecurity::iconName(best))); + + if (m_security.isEmpty()) { + m_securityIconName = "security-low"; + m_securityIconToolTip = i18nc("wireless network is not encrypted", "Unencrypted network"); + } else if (m_security == QLatin1String("wep")) { + // security-weak + m_securityIconName = "security-medium"; + m_securityIconToolTip = i18nc("tooltip of the security icon in the connection list", "Weakly encrypted network (WEP)"); + } else if (m_security == QLatin1String("wpa-psk")) { + // security-medium + m_securityIconName = "security-high"; + m_securityIconToolTip = i18nc("tooltip of the security icon in the connection list", "Encrypted network (WPA-PSK)"); + } else if (m_security == QLatin1String("wpa-eap")) { + // security-strong + m_securityIconName = "security-high"; + m_securityIconToolTip = i18nc("tooltip of the security icon in the connection list", "Encrypted network (WPA-PSK)"); + } else { + m_securityIconName = "security-low"; // FIXME: Shouldn't we always have a security setting? + m_securityIconToolTip = i18nc("tooltip of the security icon in the connection list", "Encrypted network (WPA-EAP)"); + } +} +*/ +RemoteWirelessNetwork * WirelessNetworkItem::wirelessNetworkItem() const +{ + return static_cast(m_activatable); +} + +void WirelessNetworkItem::update() +{ + kDebug() << "updating" << m_ssid << wirelessNetworkItem()->strength(); + setStrength(wirelessNetworkItem()->strength()); + return; +} + +// vim: sw=4 sts=4 et tw=100 Index: applet/nmextenderitem.cpp =================================================================== --- applet/nmextenderitem.cpp (revision 0) +++ applet/nmextenderitem.cpp (revision 1010672) @@ -0,0 +1,500 @@ +/* +Copyright 2008,2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +// Own +#include "nmextenderitem.h" + +// Qt +#include +#include + +// KDE +#include +#include +#include + +// Plasma +#include + +// Solid::Control +#include +#include +#include + +// client lib +#include "activatableitem.h" +#include "remoteactivatable.h" +#include "remoteactivatablelist.h" + +// More own includes +#include "interfaceitem.h" +#include "wirelessinterfaceitem.h" +#include "wiredinterfaceitem.h" +#include "activatablelistwidget.h" + +NMExtenderItem::NMExtenderItem(RemoteActivatableList * activatableList, Plasma::Extender * ext) +: Plasma::ExtenderItem(ext), + m_activatables(activatableList), + m_connectionTabs(0), + m_widget(0), + m_mainLayout(0), + m_leftWidget(0), + m_interfaceWidget(0), + m_leftLayout(0), + m_interfaceLayout(0), + m_wiredList(0), + m_wirelessList(0) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setName("nmextenderitem"); + setTitle(i18nc("Extender title", "Network Management")); + widget(); + init(); + + m_showWired = config().readEntry("showWired", true); + m_showWireless = config().readEntry("showWireless", true); + m_showCellular = config().readEntry("showCellular", true); + m_showVpn = config().readEntry("showVpn", true); +} + +NMExtenderItem::~NMExtenderItem() +{ +} + +void NMExtenderItem::init() +{ + kDebug() << "Adding interfaces initially"; + foreach (Solid::Control::NetworkInterface * iface, Solid::Control::NetworkManager::networkInterfaces()) { + addInterfaceInternal(iface); + kDebug() << "Network Interface:" << iface->interfaceName() << iface->driver() << iface->designSpeed(); + } + if (m_showWired) { + createTab(Knm::Activatable::InterfaceConnection); + } + if (m_showWireless) { + createTab(Knm::Activatable::WirelessInterfaceConnection); + } + if (m_showVpn) { + createTab(Knm::Activatable::VpnInterfaceConnection); + } + /* + // TODO: doesn't exist in Activatable + if (m_showCellular) { + createTab(Knm::Activatable:: + } + */ + // hook up signals to allow us to change the connection list depending on APs present, etc + connect(Solid::Control::NetworkManager::notifier(), SIGNAL(networkInterfaceAdded(const QString&)), + SLOT(interfaceAdded(const QString&))); + connect(Solid::Control::NetworkManager::notifier(), SIGNAL(networkInterfaceRemoved(const QString&)), + SLOT(interfaceRemoved(const QString&))); +} + +QGraphicsItem * NMExtenderItem::widget() +{ + if (!m_widget) { + kDebug() << "Creating widget"; + m_widget = new QGraphicsWidget(this); + m_widget->setMinimumWidth(500); + m_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + m_mainLayout = new QGraphicsGridLayout(m_widget); + //m_mainLayout = new QGraphicsLinearLayout(m_widget); + //m_mainLayout->setOrientation(Qt::Horizontal); + m_mainLayout->setColumnMinimumWidth(0, 200); + m_mainLayout->setColumnMinimumWidth(1, 340); + m_widget->setLayout(m_mainLayout); + + + m_leftWidget = new Plasma::Frame(m_widget); + m_leftWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_interfaceWidget = new QGraphicsWidget(m_leftWidget); + m_leftLayout = new QGraphicsLinearLayout(m_leftWidget); + m_leftLayout->setOrientation(Qt::Vertical); + + m_interfaceLayout = new QGraphicsLinearLayout(m_interfaceWidget); + m_interfaceLayout->setOrientation(Qt::Vertical); + //m_interfaceWidget->setLayout(m_interfaceLayout); + m_leftLayout->addItem(m_interfaceWidget); + m_leftLayout->addStretch(5); + + // Manage connections and flight-mode buttons + m_rfCheckBox = new Plasma::CheckBox(m_leftWidget); + m_rfCheckBox->setChecked(Solid::Control::NetworkManager::isWirelessEnabled()); + m_rfCheckBox->setEnabled(Solid::Control::NetworkManager::isWirelessHardwareEnabled()); + m_rfCheckBox->setText(i18nc("CheckBox to enable or disable wireless interface (rfkill)", "Enable wireless")); + m_leftLayout->addItem(m_rfCheckBox); + + connect(m_rfCheckBox, SIGNAL(toggled(bool)), SLOT(wirelessEnabledToggled(bool))); + connect(Solid::Control::NetworkManager::notifier(), SIGNAL(wirelessEnabledChanged(bool)), + this, SLOT(managerWirelessEnabledChanged(bool))); + connect(Solid::Control::NetworkManager::notifier(), SIGNAL(wirelessHardwareEnabledChanged(bool)), + this, SLOT(managerWirelessHardwareEnabledChanged(bool))); + + m_leftWidget->setLayout(m_leftLayout); + m_mainLayout->addItem(m_leftWidget, 0, 0); + + + m_rightWidget = new Plasma::Frame(m_widget); + m_rightWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_rightLayout = new QGraphicsLinearLayout(m_rightWidget); + m_rightLayout->setOrientation(Qt::Vertical); + // Tabs for activatables + m_connectionTabs = new Plasma::TabBar(m_rightWidget); + //m_connectionTabs->setTabBarShown(false); + m_connectionTabs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_connectionTabs->setPreferredSize(300, 240); + m_connectionTabs->setMinimumSize(280, 240); + + //m_mainLayout->addItem(m_connectionTabs, 0, 1, 1, 1); + m_rightLayout->addItem(m_connectionTabs); + + m_connectionsButton = new Plasma::IconWidget(m_rightWidget); + m_connectionsButton->setIcon("networkmanager"); + m_connectionsButton->setOrientation(Qt::Horizontal); + m_connectionsButton->setText(i18nc("button in general settings extender", "Manage Connections...")); + m_connectionsButton->setMaximumHeight(KIconLoader::SizeSmallMedium); + m_connectionsButton->setMinimumHeight(KIconLoader::SizeSmallMedium); + m_connectionsButton->setDrawBackground(true); +#if KDE_IS_VERSION(4,2,60) + m_connectionsButton->setTextBackgroundColor(QColor()); +#endif + + connect(m_connectionsButton, SIGNAL(activated()), this, SLOT(manageConnections())); + m_rightLayout->addItem(m_connectionsButton); + + m_mainLayout->addItem(m_rightWidget, 0, 1); + setWidget(m_widget); + } else { + //kDebug() << "widget non empty"; + } + //kDebug() << "widget() run"; + return m_widget; +} + +// Interfaces +void NMExtenderItem::interfaceAdded(const QString& uni) +{ + if (m_interfaces.keys().contains(uni)) { + return; + } + kDebug() << "Interface Added."; + Solid::Control::NetworkInterface * iface = Solid::Control::NetworkManager::findNetworkInterface(uni); + addInterfaceInternal(iface); + switchToDefaultTab(); +} + +void NMExtenderItem::interfaceRemoved(const QString& uni) +{ + if (m_interfaces.contains(uni)) { + InterfaceItem * item = m_interfaces.take(uni); + m_interfaceLayout->removeItem(item); + // TODO: remove tab + delete item; + } + switchToDefaultTab(); +} + +Solid::Control::NetworkInterface* NMExtenderItem::defaultInterface() +{ + // In fact we're returning the first available interface, + // and if there is none available just the first one we have + // and if we don't have one, 0. Make sure you check though. + if (!Solid::Control::NetworkManager::networkInterfaces().count()) { + return 0; + } + Solid::Control::NetworkInterface* iface = Solid::Control::NetworkManager::networkInterfaces().first(); + foreach (Solid::Control::NetworkInterface * _iface, Solid::Control::NetworkManager::networkInterfaces()) { + switch (_iface->connectionState()) { + case Solid::Control::NetworkInterface::Disconnected: + case Solid::Control::NetworkInterface::Failed: + case Solid::Control::NetworkInterface::Preparing: + case Solid::Control::NetworkInterface::Configuring: + case Solid::Control::NetworkInterface::NeedAuth: + case Solid::Control::NetworkInterface::IPConfig: + case Solid::Control::NetworkInterface::Activated: + return _iface; + break; + case Solid::Control::NetworkInterface::Unavailable: + case Solid::Control::NetworkInterface::Unmanaged: + case Solid::Control::NetworkInterface::UnknownState: + default: + break; + } + } + return iface; +} + + +void NMExtenderItem::addInterfaceInternal(Solid::Control::NetworkInterface* iface) +{ + Q_ASSERT(iface); + if (!m_interfaces.contains(iface->uni())) { + InterfaceItem * ifaceItem = 0; + QString icon; + switch (iface->type()) { + case Solid::Control::NetworkInterface::Ieee80211: + { + // Create the wireless interface item + WirelessInterfaceItem* wifiItem = 0; + wifiItem = new WirelessInterfaceItem(static_cast(iface), InterfaceItem::InterfaceName, this); + ifaceItem = wifiItem; + //connect(wirelessinterface, SIGNAL(stateChanged()), this, SLOT(updateNetworks())); + wifiItem->setEnabled(Solid::Control::NetworkManager::isWirelessEnabled()); + //createTab(ifaceItem, iface, i18nc("title of the wireless tab", "Wireless"), "network-wireless"); + kDebug() << "WiFi added"; + break; + } + case Solid::Control::NetworkInterface::Serial: + icon = "phone"; + case Solid::Control::NetworkInterface::Gsm: + icon = "phone"; + case Solid::Control::NetworkInterface::Cdma: + icon = "phone"; + case Solid::Control::NetworkInterface::Ieee8023: + icon = "network-wired"; + default: + { + // Create the interfaceitem + WiredInterfaceItem* wiredItem = 0; + ifaceItem = wiredItem = new WiredInterfaceItem(static_cast(iface), InterfaceItem::InterfaceName, this); + + // Add a wired tab + //createTab(wiredItem, iface, i18nc("title of the wired tab", "Wired"), icon); + break; + } + } + // Connect tab switching + connect(ifaceItem, SIGNAL(clicked(int)), this, SLOT(switchTab(int))); + // Catch connection changes + connect(iface, SIGNAL(connectionStateChanged(int,int,int)), this, SLOT(handleConnectionStateChange(int,int,int))); + connect(iface, SIGNAL(linkUpChanged(bool)), this, SLOT(switchToDefaultTab())); + m_interfaceLayout->addItem(ifaceItem); + m_interfaces.insert(iface->uni(), ifaceItem); + } +} + +void NMExtenderItem::createTab(Knm::Activatable::ActivatableType type) +{ + /* + enum ActivatableType { + InterfaceConnection, + WirelessInterfaceConnection, + WirelessNetwork, + UnconfiguredInterface, + VpnInterfaceConnection + }; + */ + QString name; + KIcon icon; + switch(type) { + case Knm::Activatable::InterfaceConnection: + { + if (!m_wiredList) { + m_wiredList = new ActivatableListWidget(m_activatables, m_connectionTabs); + m_wiredList->addType(Knm::Activatable::InterfaceConnection); + m_wiredList->init(); + name = i18nc("title of the wired tab", "Wired"); + icon = KIcon("network-wired"); + m_tabIndex[type] = m_connectionTabs->addTab(icon, name, m_wiredList); + } + break; + } + case Knm::Activatable::WirelessInterfaceConnection: + case Knm::Activatable::WirelessNetwork: + { + if (!m_wirelessList) { + m_wirelessList = new ActivatableListWidget(m_activatables, m_connectionTabs); + m_wirelessList->addType(Knm::Activatable::WirelessInterfaceConnection); + m_wirelessList->addType(Knm::Activatable::WirelessNetwork); + m_wirelessList->init(); + name = i18nc("title of the wireless tab", "Wireless"); + icon = KIcon("network-wireless"); + // All wireless stuff goes into one tab, marked as WirelessInterfaceConnection + // (no separation between those connections and WirelessNetworks) + m_tabIndex[Knm::Activatable::WirelessInterfaceConnection] = m_connectionTabs->addTab(icon, name, m_wirelessList); + } + break; + } + case Knm::Activatable::UnconfiguredInterface: + case Knm::Activatable::VpnInterfaceConnection: + { + m_vpnList = new ActivatableListWidget(m_activatables, m_connectionTabs); + m_vpnList->addType(Knm::Activatable::VpnInterfaceConnection); + m_vpnList->init(); + name = i18nc("VPN connections tab", "VPN"); + icon = KIcon("network-wired"); // FIXME: icon + kDebug() << "New VPN:" << name; + m_tabIndex[Knm::Activatable::VpnInterfaceConnection] = m_connectionTabs->addTab(icon, name, m_vpnList); + break; + } + } +} + +void NMExtenderItem::switchTab(int type) +{ + kDebug() << "Switching to ..." << type; + switch (type) { + case Solid::Control::NetworkInterface::Ieee80211: + { + m_connectionTabs->setCurrentIndex(m_tabIndex[Knm::Activatable::WirelessInterfaceConnection]); + break; + } + case Solid::Control::NetworkInterface::Serial: + case Solid::Control::NetworkInterface::Gsm: + case Solid::Control::NetworkInterface::Cdma: + case Solid::Control::NetworkInterface::Ieee8023: + default: + { + m_connectionTabs->setCurrentIndex(m_tabIndex[Knm::Activatable::InterfaceConnection]); + break; + } + } +} + +void NMExtenderItem::switchToDefaultTab() +{ + if (m_interfaces.count()) { + switchTab(defaultInterface()->type()); + } +} + +void NMExtenderItem::showWired(bool show) +{ + if (m_showWired == show) { + return; + } + kDebug() << "Show wired?" << show; + m_showWired = show; + if (!show) { + if (m_wiredList) { + kDebug() << "deleting the tab" << Knm::Activatable::InterfaceConnection; + m_connectionTabs->removeTab(m_tabIndex[Knm::Activatable::InterfaceConnection]); + //delete m_wiredList; + //m_wiredList = 0; this crashes at some point, but why? + m_tabIndex.remove(Knm::Activatable::InterfaceConnection); + } + } else { + createTab(Knm::Activatable::InterfaceConnection); + } + config().writeEntry("showWired", show); + emit configNeedsSaving(); +} + +void NMExtenderItem::showWireless(bool show) +{ + if (m_showWireless == show) { + return; + } + m_showWireless = show; + config().writeEntry("showWireless", show); + emit configNeedsSaving(); + // TODO +} + +void NMExtenderItem::showVpn(bool show) +{ + if (m_showVpn == show) { + return; + } + m_showVpn = show; + config().writeEntry("showVpn", show); + emit configNeedsSaving(); + // TODO +} + +void NMExtenderItem::showCellular(bool show) +{ + if (m_showCellular == show) { + return; + } + m_showCellular = show; + config().writeEntry("showCellular", show); + emit configNeedsSaving(); + // TODO +} + + +void NMExtenderItem::handleConnectionStateChange(int new_state, int old_state, int reason) +{ + Q_UNUSED( reason ); + // Switch to default tab if an interface has become available, or unavailable + if (available(new_state) != available(old_state)) { + switchToDefaultTab(); + } +} + +bool NMExtenderItem::available(int state) +{ + // Can an interface be used? + switch (state) { + case Solid::Control::NetworkInterface::Disconnected: + case Solid::Control::NetworkInterface::Failed: + case Solid::Control::NetworkInterface::Preparing: + case Solid::Control::NetworkInterface::Configuring: + case Solid::Control::NetworkInterface::NeedAuth: + case Solid::Control::NetworkInterface::IPConfig: + case Solid::Control::NetworkInterface::Activated: + return true; + break; + case Solid::Control::NetworkInterface::Unavailable: + case Solid::Control::NetworkInterface::Unmanaged: + case Solid::Control::NetworkInterface::UnknownState: + default: + return false; + break; + } + return false; +} + +void NMExtenderItem::wirelessEnabledToggled(bool checked) +{ + kDebug() << "Applet wireless enable switch toggled" << checked; + Solid::Control::NetworkManager::setWirelessEnabled(checked); +} + +void NMExtenderItem::managerWirelessEnabledChanged(bool enabled) +{ + kDebug() << "NM daemon changed wireless enable state" << enabled; + // it might have changed because we toggled the switch, + // but it might have been changed externally, so set it anyway + m_rfCheckBox->setChecked(enabled); + switchToDefaultTab(); +} + +void NMExtenderItem::managerWirelessHardwareEnabledChanged(bool enabled) +{ + kDebug() << "Hardware wireless enable switch state changed" << enabled; + m_rfCheckBox->setChecked(enabled && Solid::Control::NetworkManager::isWirelessEnabled()); + m_rfCheckBox->setEnabled(!enabled); + switchToDefaultTab(); +} + +void NMExtenderItem::manageConnections() +{ + //kDebug() << "opening connection management dialog"; + QStringList args; + args << "kcm_networkmanagement"; + KToolInvocation::kdeinitExec("kcmshell4", args); +} + + +// vim: sw=4 sts=4 et tw=100 + Index: applet/networkmanager.h =================================================================== --- applet/networkmanager.h (revision 0) +++ applet/networkmanager.h (revision 1010672) @@ -0,0 +1,148 @@ +/* +Copyright 2008,2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef PLASMA_NETWORKMANAGER_APPLET_H +#define PLASMA_NETWORKMANAGER_APPLET_H + +#include + +#include +#include +#include +#include + +#include "../libs/types.h" +//#include "vpnconnectiongroup.h" + +#include "ui_nmConfig.h" + +#include + +#include + +#include + +namespace Plasma +{ + class Applet; + class Extender; +} // namespace Plasma + +class NMExtenderItem; +class RemoteActivatableList; + +class NetworkManagerApplet : public Plasma::PopupApplet +{ +Q_OBJECT +public: + NetworkManagerApplet(QObject * parent, const QVariantList & args); + ~NetworkManagerApplet(); + /* reimp Plasma::Applet */ + void init(); + /* reimp Plasma::Applet */ + void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem * option, const QRect & rect); + /* reimp Plasma::Applet */ + //QSizeF sizeHint(const Qt::SizeHint which, const QSizeF& constraint) const; + /* reimp Plasma::Applet */ + //Qt::Orientations expandingDirections() const; + /* reimp Plasma::Applet */ + void constraintsEvent(Plasma::Constraints constraints); + virtual QList contextualActions(); + virtual void initExtenderItem(Plasma::ExtenderItem *); + + static QString connectionStateToString(Solid::Control::NetworkInterface::ConnectionState state); + + void loadExtender(); + +public Q_SLOTS: + /** + * Handle signals from NM if wireless was disabled in software + */ + void managerWirelessEnabledChanged(bool); + /** + * Handle signals from NM if wireless was disabled in hardware + */ + void managerWirelessHardwareEnabledChanged(bool); + /** + * Handle clicks to enable/disable enabled + */ + void userNetworkingEnabledChanged(bool); + /** + * Handle clicks to enable/disable wireless + */ + void userWirelessEnabledChanged(bool); + /** + * React to manager status changes + */ + void managerStatusChanged(Solid::Networking::Status); + +signals: + /** + * Tell the applet to show our KCModule + */ + //void manageConnections(); + +public Q_SLOTS: + +protected Q_SLOTS: + // called by Plasma::ToolTipManager + void toolTipAboutToShow(); + void configAccepted(); +protected: + void createConfigurationInterface(KConfigDialog *parent); + /** + * Reimplemented from Plasma::PopupApplet + */ + void popupEvent(bool); +private Q_SLOTS: + void networkInterfaceAdded(const QString& = QString()); + void networkInterfaceRemoved(const QString&); + void interfaceConnectionStateChanged(); + void manageConnections(); + // used to let the user easily hide VPN + void hideVpnGroup(); +private: + bool hasInterfaceOfType(Solid::Control::NetworkInterface::Type type); + void updateIcons(); + void paintDefaultInterface(Solid::Control::NetworkInterface*, QPainter *painter, const QStyleOptionGraphicsItem * option, const QRect & rect); + void paintWiredInterface(Solid::Control::NetworkInterface*, QPainter *painter, const QStyleOptionGraphicsItem * option, const QRect & rect); + void paintWirelessInterface(Solid::Control::NetworkInterface*, QPainter *painter, const QStyleOptionGraphicsItem * option, const QRect & rect); + Solid::Control::NetworkInterfaceList sortInterfacesByImportance(const Solid::Control::NetworkInterfaceList& interfaces) const; + bool m_iconPerDevice; + Plasma::Svg *m_svg; + Plasma::Svg *m_wirelessSvg; + QPixmap m_pixmapWiredConnected; + QPixmap m_pixmapWiredDisconnected; + Solid::Control::NetworkInterfaceList m_interfaces; + QString m_elementName; + Plasma::ToolTipContent m_toolTip; + // Configuration dialog + Ui::nmConfig ui; + + int m_numberWirelessShown; + RemoteActivatableList * m_activatableList; + NMExtenderItem* m_extenderItem; +}; + +#endif + + + + Index: applet/CMakeLists.txt =================================================================== --- applet/CMakeLists.txt (revision 0) +++ applet/CMakeLists.txt (revision 1010672) @@ -0,0 +1,35 @@ +include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../libs/client + ${CMAKE_CURRENT_SOURCE_DIR}/../libs/internals + ) + +add_subdirectory(pics) + +set(networkmanager_SRCS + networkmanager.cpp + + nmextenderitem.cpp + activatablelistwidget.cpp + + interfaceitem.cpp + wiredinterfaceitem.cpp + wirelessinterfaceitem.cpp + + activatableitem.cpp + interfaceconnectionitem.cpp + wirelessnetworkitem.cpp + ) + +kde4_add_ui_files(networkmanager_SRCS nmConfig.ui ) + +if(NOT I_KNOW_WHAT_IM_DOING) + set(networkmanager_SRCS applet_wip.cpp) + message(STATUS "Compiling dummy plasmoid because the real one is still work in progress...") +endif(NOT I_KNOW_WHAT_IM_DOING) + +kde4_add_plugin(plasma_applet_networkmanagement ${networkmanager_SRCS}) +target_link_libraries(plasma_applet_networkmanagement ${KDE4_PLASMA_LIBS} knmclient knminternals ${KDE4_KIO_LIBS} ${KDE4_SOLID_LIBS} solidcontrol) + +install(TARGETS plasma_applet_networkmanagement DESTINATION ${PLUGIN_INSTALL_DIR}) +install(FILES plasma-applet-networkmanagement.desktop DESTINATION ${SERVICES_INSTALL_DIR}) +install(FILES networkmanagement.svg networkmanagement-wireless.svgz DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/networkmanagement/) + Index: applet/activatableitem.cpp =================================================================== --- applet/activatableitem.cpp (revision 0) +++ applet/activatableitem.cpp (revision 1010672) @@ -0,0 +1,47 @@ +/* +Copyright 2008 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "activatableitem.h" +#include +#include "remoteactivatable.h" + +ActivatableItem::ActivatableItem(RemoteActivatable * remote, QGraphicsItem * parent) : Plasma::IconWidget(parent), m_activatable(remote) +{ + setDrawBackground(true); +} + +ActivatableItem::~ActivatableItem() +{ +} + +void ActivatableItem::emitClicked() +{ + //HACK this slot needs renaming + kDebug() << "EMIT CLICKED"; + m_activatable->activate(); + emit clicked(this); +} + +RemoteInterfaceConnection * ActivatableItem::interfaceConnection() const +{ + return qobject_cast(m_activatable); +} + +// vim: sw=4 sts=4 et tw=100 Index: applet/interfaceconnectionitem.cpp =================================================================== --- applet/interfaceconnectionitem.cpp (revision 0) +++ applet/interfaceconnectionitem.cpp (revision 1010672) @@ -0,0 +1,92 @@ +/* +Copyright 2008,2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "interfaceconnectionitem.h" + +#include + +#include +#include + +#include + +#include "remoteinterfaceconnection.h" + +InterfaceConnectionItem::InterfaceConnectionItem(RemoteInterfaceConnection * conn, QGraphicsItem * parent) +: ActivatableItem(conn, parent) +{ +} + +void InterfaceConnectionItem::setupItem() +{ + /* + // painting of a non-active connection wired connection + + +----+------------------+------+ + |icon| connection name |status| + +----+------------------+------+ + */ + int rowHeight = 24; + + m_layout = new QGraphicsGridLayout(this); + // last colunm has fixed width for the icon + m_layout->setColumnFixedWidth(2, rowHeight); + + // icon on the left + m_connectButton = new Plasma::IconWidget(this); + m_connectButton->setIcon("network-wired"); + if (interfaceConnection()) { + m_connectButton->setText(interfaceConnection()->connectionName()); + } else { + m_connectButton->setText("missing name"); + } + kDebug() << "====> init face connection" << m_connectButton->text(); + m_connectButton->setMinimumWidth(160); + m_connectButton->setMaximumHeight(rowHeight); + m_connectButton->setOrientation(Qt::Horizontal); +#if KDE_IS_VERSION(4,2,60) + m_connectButton->setTextBackgroundColor(QColor()); +#endif + + //m_connectButton->setToolTip(i18nc("button to connect to wired network", + // "Connect to wired network %1", m_connection->id())); + m_connectButton->setMinimumHeight(rowHeight); + m_connectButton->setMaximumHeight(rowHeight); + m_layout->addItem(m_connectButton, 0, 0, 1, 1 ); + + m_icon = new Plasma::IconWidget(this); + m_icon->setIcon("network-disconnect"); + m_icon->setMinimumHeight(22); + m_icon->setMaximumHeight(22); + m_layout->addItem(m_icon, 0, 2, 1, 1, Qt::AlignLeft); + + connect(m_connectButton, SIGNAL(clicked()), this, SIGNAL(clicked())); + connect(this, SIGNAL(clicked()), this, SLOT(emitClicked())); + connect(this, SIGNAL(pressed(bool)), m_connectButton, SLOT(setPressed(bool))); + connect(m_connectButton, SIGNAL(pressed(bool)), this, SLOT(setPressed(bool))); +} + +InterfaceConnectionItem::~InterfaceConnectionItem() +{ + +} + + +// vim: sw=4 sts=4 et tw=100 Index: applet/Messages.sh =================================================================== --- applet/Messages.sh (revision 0) +++ applet/Messages.sh (revision 1010672) @@ -0,0 +1,3 @@ +#!/bin/sh +$XGETTEXT *.cpp -o $podir/plasma_applet_networkmanagement.pot +rm -f rc.cpp Property changes on: applet/Messages.sh ___________________________________________________________________ Added: svn:executable + * Index: applet/hiddenwirelessnetworkitem.cpp =================================================================== --- applet/hiddenwirelessnetworkitem.cpp (revision 0) +++ applet/hiddenwirelessnetworkitem.cpp (revision 1010672) @@ -0,0 +1,118 @@ +/* +Copyright 2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "hiddenwirelessnetworkitem.h" + +#include + +#include +#include +#include +#include + +HiddenWirelessNetwork::HiddenWirelessNetwork(QObject * parent) : AbstractWirelessNetwork(parent) +{ + +} + +HiddenWirelessNetwork::~HiddenWirelessNetwork() +{ + +} + + +void HiddenWirelessNetwork::setSsid(const QString & ssid) +{ + m_ssid = ssid; +} + +QString HiddenWirelessNetwork::ssid() const +{ + return m_ssid; +} + +int HiddenWirelessNetwork::strength() const +{ + return -1; +} + +Solid::Control::AccessPoint * HiddenWirelessNetwork::referenceAccessPoint() const +{ + return 0; +} + +QString HiddenWirelessNetworkItem::s_defaultText = i18nc("default KLineEdit::clickMessage() for hidden wireless network SSID entry", "Enter hidden SSID and press "); + +HiddenWirelessNetworkItem::HiddenWirelessNetworkItem(QGraphicsItem * parent): AbstractWirelessNetworkItem(parent), m_layout(0), m_connect(0), m_ssidEdit(0) +{ + m_wirelessNetwork = new HiddenWirelessNetwork(this); +} + +HiddenWirelessNetworkItem::~HiddenWirelessNetworkItem() +{ +} + +void HiddenWirelessNetworkItem::setupItem() +{ + if (!m_layout) { + int rowHeight = 24; + + m_layout = new QGraphicsLinearLayout(this); + m_connect = new Plasma::IconWidget(this); + m_connect->setDrawBackground(true); + m_connect->setMaximumHeight(rowHeight); + m_connect->setText(i18nc("label for creating a connection to a hidden wireless network", "Connect to hidden network")); + m_layout->addItem(m_connect); + connect(m_connect, SIGNAL(activated()), SLOT(connectClicked())); + + m_ssidEdit = new Plasma::LineEdit(this); + m_ssidEdit->nativeWidget()->setClickMessage(s_defaultText); + m_ssidEdit->hide(); + connect(m_ssidEdit->nativeWidget(), SIGNAL(returnPressed()), SLOT(ssidEntered())); + } +} + +void HiddenWirelessNetworkItem::connectClicked() +{ + m_connect->hide(); + m_ssidEdit->show(); + //workarounds for QGraphicsLayout not being able to layout hidden widgets with a 0 size + m_layout->removeAt(0); + m_layout->addItem(m_ssidEdit); +} + +void HiddenWirelessNetworkItem::ssidEntered() +{ + qobject_cast(m_wirelessNetwork)->setSsid(m_ssidEdit->text()); + emitClicked(); +} + +void HiddenWirelessNetworkItem::resetSsidEntry() +{ + m_ssidEdit->nativeWidget()->clearFocus(); + m_ssidEdit->nativeWidget()->clear(); + m_ssidEdit->hide(); + m_connect->show(); + //workarounds for QGraphicsLayout not being able to layout hidden widgets with a 0 size + m_layout->removeAt(0); + m_layout->addItem(m_connect); +} + +// vim: sw=4 sts=4 et tw=100 Index: applet/wirelessinterfaceitem.h =================================================================== --- applet/wirelessinterfaceitem.h (revision 0) +++ applet/wirelessinterfaceitem.h (revision 1010672) @@ -0,0 +1,71 @@ +/* +Copyright 2008,2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef WIRELESSINTERFACEITEM_H +#define WIRELESSINTERFACEITEM_H + +#include +#include +#include "interfaceitem.h" + +namespace Solid +{ +namespace Control +{ + class AccessPoint; + class WirelessNetworkInterface; +} +} + +/** Represents a wireless network interface in the popup + * Provides custom UI for wireless connection status + * Maintains a list of wireless networks visible to this network interface, + * used by the interface's group to determine which connections are appropriate + */ +class WirelessInterfaceItem : public InterfaceItem +{ +Q_OBJECT +public: + WirelessInterfaceItem(Solid::Control::WirelessNetworkInterface * iface, InterfaceItem::NameDisplayMode mode, QGraphicsItem* parent = 0); + virtual ~WirelessInterfaceItem(); + /** + * The name of the connection, the SSID of any active network, + * or an invalid QString if none + */ + QString connectionName(); + /** @reimp InterfaceItem */ + virtual void setEnabled(bool enable); + +public Q_SLOTS: + void activeAccessPointChanged(const QString&); + void activeSignalStrengthChanged(int); + void accessPointDestroyed(QObject *); + void connectButtonClicked(); + +private: + void setConnectionInfo(); + + // returns a list of available accesspoint objects + QList availableAccessPoints() const; + + Solid::Control::WirelessNetworkInterface * m_wirelessIface; + Solid::Control::AccessPoint * m_activeAccessPoint; +}; +#endif // WIRELESSINTERFACEITEM_H Index: applet/applet_wip.cpp =================================================================== --- applet/applet_wip.cpp (revision 0) +++ applet/applet_wip.cpp (revision 1010672) @@ -0,0 +1,68 @@ +/* +Copyright 2008,2009 Will Stephenson +Copyright 2008 Sebastian Kügler + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "applet_wip.h" +#include +#include +#include +#include + +K_EXPORT_PLASMA_APPLET(networkmanagement, NetworkManagerApplet) + +NetworkManagerApplet::NetworkManagerApplet(QObject * parent, const QVariantList & args) + : Plasma::Applet(parent, args) +{ + setHasConfigurationInterface(false); + + setAspectRatioMode(Plasma::ConstrainedSquare); + setHasConfigurationInterface(true); + + kDebug() << "Displaying Work In Progress plasmoid to protect the innocent from crashing their plasma and spamming bko"; +} + +NetworkManagerApplet::~NetworkManagerApplet() +{ +} + +void NetworkManagerApplet::init() +{ + m_svg = new Plasma::Svg(this); + m_svg->setImagePath("networkmanagement/networkmanagement"); + + Plasma::ToolTipContent tip(i18nc("Warning message to deter non-developers from using this", "Network Management is changing!"), + i18nc("Tooltip sub text", "It is highly unstable and will crash your desktop.\n Until further notice, please use KDE 4 knetworkmanager instead."), + KIcon("networkmanager").pixmap(IconSize(KIconLoader::Desktop)) + ); + Plasma::ToolTipManager::self()->setContent(this, tip); +} + +void NetworkManagerApplet::constraintsEvent(Plasma::Constraints constraints) +{ + if (constraints & (Plasma::SizeConstraint | Plasma::FormFactorConstraint)) { + m_svg->resize(contentsRect().size().toSize()); + } +} + +void NetworkManagerApplet::paintInterface(QPainter * p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect) +{ + Q_UNUSED(option); + m_svg->paint(p, contentsRect, "cellular_connected"); +} Index: applet/wiredinterfaceitem.h =================================================================== --- applet/wiredinterfaceitem.h (revision 0) +++ applet/wiredinterfaceitem.h (revision 1010672) @@ -0,0 +1,49 @@ +/* +Copyright 2008 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef WIREDINTERFACEITEM_H +#define WIREDINTERFACEITEM_H + +#include +#include "interfaceitem.h" + +namespace Solid +{ +namespace Control +{ + class WiredNetworkInterface; +} +} + +/** + * Represents any network interface that uses IEEE 802.3 + */ +class WiredInterfaceItem : public InterfaceItem +{ +Q_OBJECT +public: + WiredInterfaceItem(Solid::Control::WiredNetworkInterface * iface, InterfaceItem::NameDisplayMode mode, QGraphicsItem* parent = 0); + virtual ~WiredInterfaceItem(); +public slots: + void connectButtonClicked(); +private: + Solid::Control::WiredNetworkInterface * m_wiredIface; +}; +#endif // SERIALINTERFACEITEM_H Index: applet/activatablelistwidget.h =================================================================== --- applet/activatablelistwidget.h (revision 0) +++ applet/activatablelistwidget.h (revision 1010672) @@ -0,0 +1,68 @@ +/* +Copyright 2008,2009 Sebastian Kügler + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef ACTIVATABLELISTWIDGET_H +#define ACTIVATABLELISTWIDGET_H + +#include + +#include +#include "activatable.h" +#include + +class QGraphicsLinearLayout; +class ActivatableItem; +class RemoteActivatableList; +class RemoteActivatable; + +class ActivatableListWidget: public Plasma::ScrollWidget +{ +Q_OBJECT +public: + ActivatableListWidget(RemoteActivatableList* activatables, QGraphicsWidget* parent = 0); + virtual ~ActivatableListWidget(); + + void init(); + void addType(Knm::Activatable::ActivatableType type); + bool accept(RemoteActivatable* activatable) const; + +public Q_SLOTS: + //virtual void activate(ActivatableItem*) = 0; + void activatableAdded(RemoteActivatable *); + void activatableRemoved(RemoteActivatable *); + void listDisappeared(); + void listAppeared(); + +Q_SIGNALS: + void connectionListUpdated(); + +private: + ActivatableItem* createItem(RemoteActivatable* conn); + int m_connectionType; + QList m_types; + + QHash m_itemIndex; + RemoteActivatableList* m_activatables; + //Solid::Control::NetworkInterface* m_iface; + QGraphicsLinearLayout* m_layout; + QGraphicsWidget* m_widget; + +}; +#endif // ACTIVATABLELISTWIDGET_H Index: applet/interfaceitem.h =================================================================== --- applet/interfaceitem.h (revision 0) +++ applet/interfaceitem.h (revision 1010672) @@ -0,0 +1,125 @@ +/* +Copyright 2008,2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef APPLET_INTERFACEITEM_H +#define APPLET_INTERFACEITEM_H + +#include +#include + +#include "interfaceconnection.h" + +#include +#include +#include +#include + +class QGraphicsGridLayout; +class QGraphicsLinearLayout; +namespace Solid +{ + namespace Control + { + class NetworkInterface; + } // namespace Control +} // namespace Solid + +class RemoteInterfaceConnection; + +/** + * Represents a single network interface + * Displays status, updates itself + * Allows deactivating any active connection + */ +class InterfaceItem : public Plasma::IconWidget +{ +Q_OBJECT +public: + enum NameDisplayMode {InterfaceName, HardwareName}; + InterfaceItem(Solid::Control::NetworkInterface * iface, NameDisplayMode mode = InterfaceName, QGraphicsItem* parent = 0); + virtual ~InterfaceItem(); + + void setNameDisplayMode(NameDisplayMode); + NameDisplayMode nameDisplayMode() const; + + virtual QString connectionName(); + //void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ); + QString label(); + +public Q_SLOTS: + void activeConnectionsChanged(); + void connectionStateChanged(int); + virtual void setEnabled(bool enable); + // also updates the connection info + virtual void setActive(bool active); + /** + * The button to connect the interface has been clicked + */ + virtual void connectButtonClicked() = 0; + +protected Q_SLOTS: + /** + * Remove any connections that were provided by this service + * from our active connection list + */ + void handleConnectionStateChange(int new_state, int old_state, int reason); + virtual void itemClicked(); + void pppStats(uint in, uint out); + +Q_SIGNALS: + void stateChanged(); + void clicked(int); + +protected: + /** + * Fill in interface type connection info + */ + virtual void setConnectionInfo(); + /** + * Give us a pixmap for an icon + */ + virtual QPixmap statePixmap(const QString &icon); + + /** + * The current IP address when the connection is active. + */ + virtual QString currentIpAddress(); + + Solid::Control::NetworkInterface * m_iface; + + QGraphicsGridLayout * m_layout; + QGraphicsLinearLayout * m_infoLayout; + Plasma::IconWidget * m_icon; + Plasma::IconWidget* m_connectButton; + Plasma::Label * m_ifaceNameLabel; + Plasma::Label * m_connectionNameLabel; + QGraphicsLinearLayout * m_connectionInfoLayout; + Plasma::Label * m_connectionInfoLabel; + Plasma::Meter * m_strengthMeter; + Plasma::Label * m_connectionInfoStrengthLabel; + Plasma::IconWidget * m_connectionInfoIcon; + NameDisplayMode m_nameMode; + bool m_enabled; + + QString m_unavailableText; + QString m_interfaceName; + bool m_disconnect; +}; +#endif // APPLET_INTERFACEWIDGET_H Index: applet/networkmanager.cpp =================================================================== --- applet/networkmanager.cpp (revision 0) +++ applet/networkmanager.cpp (revision 1010672) @@ -0,0 +1,722 @@ +/* +Copyright 2008,2009 Will Stephenson +Copyright 2008 Sebastian Kügler + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "networkmanager.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "remoteactivatablelist.h" + +#include "../libs/types.h" +#include "interfaceitem.h" +#include "nmextenderitem.h" + + + +K_EXPORT_PLASMA_APPLET(networkmanagement, NetworkManagerApplet) + +/* for qSort()ing */ +bool networkInterfaceLessThan(Solid::Control::NetworkInterface * if1, Solid::Control::NetworkInterface * if2); +bool networkInterfaceSameConnectionStateLessThan(Solid::Control::NetworkInterface * if1, Solid::Control::NetworkInterface * if2); + +NetworkManagerApplet::NetworkManagerApplet(QObject * parent, const QVariantList & args) + : Plasma::PopupApplet(parent, args), m_iconPerDevice(false), m_svg(0), m_wirelessSvg(0) +{ + setHasConfigurationInterface(false); + setPopupIcon(QIcon()); + //setPassivePopup(true); // only for testing ... + + Plasma::ToolTipManager::self()->registerWidget(this); + setAspectRatioMode(Plasma::ConstrainedSquare); + setHasConfigurationInterface(true); + m_svg = new Plasma::Svg(this); + m_svg->setImagePath("networkmanagement/networkmanagement"); + + m_wirelessSvg = new Plasma::Svg(this); + m_wirelessSvg->setImagePath("networkmanagement/networkmanagement-wireless"); + + m_interfaces = Solid::Control::NetworkManager::networkInterfaces(); + interfaceConnectionStateChanged(); + + m_activatableList = new RemoteActivatableList(this); + + // TODO: read config into m_extenderItem ... + // Now it is safe to create ExtenderItems and therefore InterfaceGroups + +} + +NetworkManagerApplet::~NetworkManagerApplet() +{ +} + +void NetworkManagerApplet::init() +{ + kDebug(); + KConfigGroup cg = config(); + m_iconPerDevice = cg.readEntry("IconPerDevice", false); + m_svg->resize(contentsRect().size()); + QObject::connect(Solid::Control::NetworkManager::notifier(), SIGNAL(networkInterfaceAdded(const QString&)), + this, SLOT(networkInterfaceAdded(const QString&))); + QObject::connect(Solid::Control::NetworkManager::notifier(), SIGNAL(networkInterfaceRemoved(const QString&)), + this, SLOT(networkInterfaceRemoved(const QString&))); + + QObject::connect(Solid::Control::NetworkManager::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)), + this, SLOT(managerStatusChanged(Solid::Networking::Status))); + + m_activatableList->init(); + + m_extenderItem = new NMExtenderItem(m_activatableList, extender()); + connect(m_extenderItem, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving())); +} + + +void NetworkManagerApplet::initExtenderItem(Plasma::ExtenderItem * eItem) +{ + // Let's just load a new one, hackish but works for now + if (eItem->name() == "nmextenderitem") { + eItem->destroy(); + } + return; +} + +void NetworkManagerApplet::constraintsEvent(Plasma::Constraints constraints) +{ + if (constraints & (Plasma::SizeConstraint | Plasma::FormFactorConstraint)) { + m_svg->resize(contentsRect().size().toSize()); + m_wirelessSvg->resize(contentsRect().size().toSize()); + updateIcons(); + } +} + +void NetworkManagerApplet::updateIcons() +{ + m_pixmapWiredConnected = KIcon("network-connect").pixmap(contentsRect().size().toSize()); + m_pixmapWiredDisconnected = KIcon("network-disconnect").pixmap(contentsRect().size().toSize()); +} + +void NetworkManagerApplet::createConfigurationInterface(KConfigDialog *parent) +{ + QWidget *widget = new QWidget(parent); + ui.setupUi(widget); + parent->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply ); + parent->addPage(widget, parent->windowTitle(), Applet::icon()); + connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted())); + connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted())); + + ui.showWired->setChecked(m_extenderItem->m_showWired); + ui.showWireless->setChecked(m_extenderItem->m_showWireless); + ui.showVpn->setChecked(m_extenderItem->m_showVpn); + ui.showCellular->setChecked(m_extenderItem->m_showCellular); + ui.numberOfWlans->setValue(m_numberWirelessShown); +} + +void NetworkManagerApplet::configAccepted() +{ + KConfigGroup cg = config(); + + if (m_extenderItem->m_showWired != ui.showWired->isChecked()) { + m_extenderItem->showWired(!m_extenderItem->m_showWired); + cg.writeEntry("showWired", m_extenderItem->m_showWired); + m_extenderItem->showWired(m_extenderItem->m_showWired); + kDebug() << "Wired Changed" << m_extenderItem->m_showWired; + } + if (m_extenderItem->m_showWireless != ui.showWireless->isChecked()) { + m_extenderItem->showWireless(!m_extenderItem->m_showWireless); + cg.writeEntry("showWireless", m_extenderItem->m_showWireless); + kDebug() << "Wireless Changed" << m_extenderItem->m_showWireless; + } + if (m_extenderItem->m_showCellular != ui.showCellular->isChecked()) { + m_extenderItem->showCellular(!m_extenderItem->m_showCellular); + cg.writeEntry("showCellular", m_extenderItem->m_showCellular); + kDebug() << "Gsm Changed" << m_extenderItem->m_showCellular; + } + if (m_extenderItem->m_showVpn != ui.showVpn->isChecked()) { + m_extenderItem->showVpn(!m_extenderItem->m_showVpn); + cg.writeEntry("showVpn", m_extenderItem->m_showVpn); + kDebug() << "VPN Changed" << m_extenderItem->m_showVpn; + } + + Plasma::Applet::configNeedsSaving(); + kDebug() << "config done"; +} + +QList NetworkManagerApplet::contextualActions() +{ + QAction* configAction = new QAction(KIcon("networkmanager"), i18n("Manage Connections..."), this); + connect(configAction, SIGNAL(triggered(bool)), this, SLOT(manageConnections())); + QList tempActions; + tempActions << configAction; + return tempActions; +} + +void NetworkManagerApplet::paintInterface(QPainter * p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect) +{ + // i can't figure out how to do layouting of multiple items in constraintsEvent properly, + // so only have 1 rather than hack something ugly that will be thrown out later + if (!m_interfaces.isEmpty()) { + Solid::Control::NetworkInterface *interface = m_interfaces.first(); + // TODO: figure out the default route and use that connection + //kDebug() << "most interesting interface to paint: " << interface->uni() << " with icon " << m_elementName; + + // Call the correct method to paint the applet, depending on the kind of connection + switch (interface->type() ) { + case Solid::Control::NetworkInterface::Ieee80211: + paintWirelessInterface(interface, p, option, contentsRect); + break; + case Solid::Control::NetworkInterface::Ieee8023: + paintWiredInterface(interface, p, option, contentsRect); + break; + case Solid::Control::NetworkInterface::Serial: + case Solid::Control::NetworkInterface::Gsm: + case Solid::Control::NetworkInterface::Cdma: + default: + paintDefaultInterface(interface, p, option, contentsRect); + break; + } + } +} + +void NetworkManagerApplet::paintDefaultInterface(Solid::Control::NetworkInterface* interface, QPainter * p, const QStyleOptionGraphicsItem * option, const QRect &contentsRect) +{ + Q_UNUSED(option); + Q_UNUSED(interface); + //kDebug() << " ============== Default Interface" << m_elementName; + m_svg->paint(p, contentsRect, m_elementName); +} + +void NetworkManagerApplet::paintWiredInterface(Solid::Control::NetworkInterface* interface, QPainter * p, const QStyleOptionGraphicsItem * option, const QRect &contentsRect) +{ + Q_UNUSED( option ); + if (interface->connectionState() == Solid::Control::NetworkInterface::Activated) { + p->drawPixmap(contentsRect.topLeft(), m_pixmapWiredConnected); + } else { + p->drawPixmap(contentsRect.topLeft(), m_pixmapWiredDisconnected); + } +} + +void NetworkManagerApplet::paintWirelessInterface(Solid::Control::NetworkInterface* interface, QPainter * p, const QStyleOptionGraphicsItem * option, const QRect &contentsRect) +{ + Q_UNUSED(option); + //kDebug() << interface->type(); + /* TODO: + enum ConnectionState{ UnknownState, Unmanaged, Unavailable, Disconnected, Preparing, + Configuring, NeedAuth, IPConfig, Activated, Failed }; + make use of this information... + */ + //kDebug() << " ============== Wireless Interface"; + switch (interface->connectionState()) { + case Solid::Control::NetworkInterface::UnknownState: + //kDebug() << " ... UnknownState"; + m_wirelessSvg->paint(p, contentsRect, "antenna"); + break; + case Solid::Control::NetworkInterface::Unmanaged: + //kDebug() << " ... Unmanaged"; + m_wirelessSvg->paint(p, contentsRect, "antenna"); + break; + case Solid::Control::NetworkInterface::Unavailable: + //kDebug() << " ... Unavailable"; + m_wirelessSvg->paint(p, contentsRect, "antenna"); + break; + case Solid::Control::NetworkInterface::Disconnected: + //kDebug() << " ... Disconnected"; + m_wirelessSvg->paint(p, contentsRect, "antenna"); + break; + case Solid::Control::NetworkInterface::Preparing: + //kDebug() << " ... Preparing"; + break; + case Solid::Control::NetworkInterface::Configuring: + //kDebug() << " ... Configuring"; + break; + case Solid::Control::NetworkInterface::NeedAuth: + //kDebug() << " ... NeedAuth"; + break; + case Solid::Control::NetworkInterface::IPConfig: + //kDebug() << " ... IPConfig"; + break; + case Solid::Control::NetworkInterface::Activated: + //kDebug() << " ... Activated"; + m_wirelessSvg->paint(p, contentsRect, "connected"); + m_wirelessSvg->paint(p, contentsRect, "antenna"); + break; + case Solid::Control::NetworkInterface::Failed: + //kDebug() << " ... Failed"; + m_wirelessSvg->paint(p, contentsRect, "antenna"); + break; + default: + //kDebug() << "dunno ..."; + break; + } +} + +/* Slots to react to changes from the daemon */ +void NetworkManagerApplet::networkInterfaceAdded(const QString & uni) +{ + Q_UNUSED(uni); + // update the tray icon + m_interfaces = Solid::Control::NetworkManager::networkInterfaces(); + foreach (Solid::Control::NetworkInterface* interface, m_interfaces) { + + // be aware of state changes + QObject::disconnect(interface, SIGNAL(connectionStateChanged(int)), this, SLOT(interfaceConnectionStateChanged())); + QObject::connect(interface, SIGNAL(connectionStateChanged(int)), this, SLOT(interfaceConnectionStateChanged())); + } + + interfaceConnectionStateChanged(); + update(); +} + +void NetworkManagerApplet::networkInterfaceRemoved(const QString & uni) +{ + Q_UNUSED(uni); + // update the tray icon + m_interfaces = Solid::Control::NetworkManager::networkInterfaces(); + foreach (Solid::Control::NetworkInterface * interface, m_interfaces) { + QObject::disconnect(interface, SIGNAL(connectionStateChanged(int)), this, SLOT(interfaceConnectionStateChanged())); + QObject::connect(interface, SIGNAL(connectionStateChanged(int)), this, SLOT(interfaceConnectionStateChanged())); + } + + // update extender visibility + KConfigGroup cg = config(); + + interfaceConnectionStateChanged(); + update(); + // kill any animations involving this interface +} + +void NetworkManagerApplet::interfaceConnectionStateChanged() +{ + /* Solid::Control::NetworkInterface * interface = dynamic_cast(sender()); + if (interface) + kDebug() << "Updating connection state ..." << interface->uni() << interface->type(); */ + // update appearance + QString elementNameToPaint; + if (!m_interfaces.isEmpty()) { + qSort(m_interfaces.begin(), m_interfaces.end(), networkInterfaceLessThan); + Solid::Control::NetworkInterface * interface = m_interfaces.first(); + switch (interface->type() ) { + case Solid::Control::NetworkInterface::Ieee8023: + elementNameToPaint = "wired"; + break; + case Solid::Control::NetworkInterface::Ieee80211: + elementNameToPaint = "wireless"; + break; + case Solid::Control::NetworkInterface::Serial: + elementNameToPaint = "ppp"; + break; + case Solid::Control::NetworkInterface::Gsm: + case Solid::Control::NetworkInterface::Cdma: + elementNameToPaint = "cellular"; + break; + default: + elementNameToPaint = "wired"; + break; + } + if (interface->connectionState() == Solid::Control::NetworkInterface::Activated) { + elementNameToPaint += "_connected"; + } else { + elementNameToPaint += "_disconnected"; + } + //kDebug() << "busy ... ?"; + switch (interface->connectionState()) { + case Solid::Control::NetworkInterface::Preparing: + case Solid::Control::NetworkInterface::Configuring: + case Solid::Control::NetworkInterface::NeedAuth: + case Solid::Control::NetworkInterface::IPConfig: + setBusy(true); + break; + default: + setBusy(false); + break; + } + } else { + elementNameToPaint = "nointerfaces"; + } + + if (elementNameToPaint != m_elementName) { + m_elementName = elementNameToPaint; + update(); + } +} + +void NetworkManagerApplet::toolTipAboutToShow() +{ + Solid::Control::NetworkInterfaceList interfaces + = Solid::Control::NetworkManager::networkInterfaces(); + if (interfaces.isEmpty()) { + m_toolTip = Plasma::ToolTipContent(QString(), + i18nc("Tooltip sub text", "No network interfaces"), + KIcon("networkmanager").pixmap(IconSize(KIconLoader::Desktop)) + ); + } else { + QString subText; + qSort(interfaces.begin(), interfaces.end(), networkInterfaceLessThan); + bool hasActive = false; + bool iconChanged = false; + QString icon = "networkmanager"; + foreach (Solid::Control::NetworkInterface *iface, interfaces) { + if (!subText.isEmpty()) { + subText += QLatin1String("

"); + } + if (iface->connectionState() != Solid::Control::NetworkInterface::Unavailable) { + hasActive = true; + Solid::Device* dev = new Solid::Device(iface->uni()); + QString product = dev->product(); + QString ifaceName = iface->interfaceName(); + subText += QString::fromLatin1("%1: %2").arg(product).arg(connectionStateToString(iface->connectionState())); + Solid::Control::IPv4Config ip4Config = iface->ipV4Config(); + QList addresses = ip4Config.addresses(); + if (!addresses.isEmpty()) { + QHostAddress addr(addresses.first().address()); + QString currentIp = addr.toString(); + subText += QString::fromLatin1("
") + i18nc("Display of the IP (network) address in the tooltip", "Address: %1", currentIp); + } + // Show the first active connection's icon, otherwise the networkmanager icon + if (!iconChanged && iface->connectionState() == Solid::Control::NetworkInterface::Activated) { + switch (iface->type()) { + case Solid::Control::NetworkInterface::Ieee8023: + icon = "network-wired"; + break; + case Solid::Control::NetworkInterface::Ieee80211: + icon = "network-wireless"; + break; + case Solid::Control::NetworkInterface::Serial: + case Solid::Control::NetworkInterface::Gsm: + case Solid::Control::NetworkInterface::Cdma: + default: + icon = "phone"; + break; + } + iconChanged = true; // we only want the first one + } + } + } + if (!hasActive) { + subText += i18nc("tooltip, all interfaces are down", "Disconnected"); + } + m_toolTip = Plasma::ToolTipContent(QString(), + subText, + KIcon(icon).pixmap(IconSize(KIconLoader::Desktop)) + ); + } + Plasma::ToolTipManager::self()->setContent(this, m_toolTip); +} + +QString NetworkManagerApplet::connectionStateToString(Solid::Control::NetworkInterface::ConnectionState state) +{ + QString stateString; + switch (state) { + case Solid::Control::NetworkInterface::UnknownState: + stateString = i18nc("description of unknown network interface state", "Unknown"); + break; + case Solid::Control::NetworkInterface::Unmanaged: + stateString = i18nc("description of unmanaged network interface state", "Unmanaged"); + break; + case Solid::Control::NetworkInterface::Unavailable: + stateString = i18nc("description of unavailable network interface state", "Unavailable"); + break; + case Solid::Control::NetworkInterface::Disconnected: + stateString = i18nc("description of unconnected network interface state", "Not connected"); + break; + case Solid::Control::NetworkInterface::Preparing: + stateString = i18nc("description of preparing to connect network interface state", "Preparing to connect"); + break; + case Solid::Control::NetworkInterface::Configuring: + stateString = i18nc("description of configuring hardware network interface state", "Configuring interface"); + break; + case Solid::Control::NetworkInterface::NeedAuth: + stateString = i18nc("description of waiting for authentication network interface state", "Waiting for authorization"); + break; + case Solid::Control::NetworkInterface::IPConfig: + stateString = i18nc("network interface doing dhcp request in most cases", "Setting network address"); + break; + case Solid::Control::NetworkInterface::Activated: + stateString = i18nc("network interface connected state label", "Connected"); + break; + case Solid::Control::NetworkInterface::Failed: + stateString = i18nc("network interface connection failed state label", "Connection Failed"); + break; + default: + stateString = I18N_NOOP("UNKNOWN STATE FIX ME"); + } + return stateString; +} + +bool networkInterfaceLessThan(Solid::Control::NetworkInterface *if1, Solid::Control::NetworkInterface * if2) +{ + /* + * status merging algorithm + * In descending order of importance: + * - Connecting devices + * - Cellular devices (because of cost) + * - = PPP devices + * - Ethernet devices + * - Wireless devices + * - Connected devices + * - order as above + * - Disconnected devices + * - order as above + */ + enum { Connecting, Connected, Disconnected } if2status = Disconnected, if1status = Disconnected; + switch (if1->connectionState()) { + case Solid::Control::NetworkInterface::Preparing: + case Solid::Control::NetworkInterface::Configuring: + case Solid::Control::NetworkInterface::NeedAuth: + case Solid::Control::NetworkInterface::IPConfig: + if1status = Connecting; + break; + case Solid::Control::NetworkInterface::Activated: + if1status = Connected; + break; + default: // all kind of disconnected + break; + } + switch (if2->connectionState()) { + case Solid::Control::NetworkInterface::Preparing: + case Solid::Control::NetworkInterface::Configuring: + case Solid::Control::NetworkInterface::NeedAuth: + case Solid::Control::NetworkInterface::IPConfig: + if2status = Connecting; + break; + case Solid::Control::NetworkInterface::Activated: + if2status = Connected; + break; + default: // all kind of disconnected + break; + } + switch (if1status) { + case Connecting: + return if2status != Connecting || networkInterfaceSameConnectionStateLessThan(if1, if2); + break; + case Connected: + if ( if2status == Connecting) + return false; + return if2status != Connected || networkInterfaceSameConnectionStateLessThan(if1, if2); + break; + case Disconnected: + if ( if2status == Disconnected) + return networkInterfaceSameConnectionStateLessThan(if1, if2); + return false; + break; + } + // satisfy compiler + return false; +} + +bool networkInterfaceSameConnectionStateLessThan(Solid::Control::NetworkInterface * if1, Solid::Control::NetworkInterface * if2) +{ + bool lessThan = false; + switch (if1->type() ) { + case Solid::Control::NetworkInterface::Ieee8023: + switch (if2->type()) { + case Solid::Control::NetworkInterface::Ieee8023: + lessThan = if1->uni() < if2->uni(); + break; + case Solid::Control::NetworkInterface::Ieee80211: + lessThan = true; + break; + case Solid::Control::NetworkInterface::Serial: + case Solid::Control::NetworkInterface::Gsm: + case Solid::Control::NetworkInterface::Cdma: + default: + lessThan = false; + break; + } + break; + case Solid::Control::NetworkInterface::Ieee80211: + switch (if2->type()) { + case Solid::Control::NetworkInterface::Ieee8023: + lessThan = false; + break; + case Solid::Control::NetworkInterface::Ieee80211: + lessThan = if1->uni() < if2->uni(); + break; + case Solid::Control::NetworkInterface::Serial: + case Solid::Control::NetworkInterface::Gsm: + case Solid::Control::NetworkInterface::Cdma: + lessThan = false; + break; + default: + lessThan = true; + break; + } + break; + case Solid::Control::NetworkInterface::Serial: + switch (if2->type()) { + case Solid::Control::NetworkInterface::Ieee8023: + case Solid::Control::NetworkInterface::Ieee80211: + lessThan = true; + break; + case Solid::Control::NetworkInterface::Serial: + lessThan = if1->uni() < if2->uni(); + break; + case Solid::Control::NetworkInterface::Gsm: + case Solid::Control::NetworkInterface::Cdma: + lessThan = false; + break; + default: + lessThan = true; + break; + } + break; + case Solid::Control::NetworkInterface::Gsm: + switch (if2->type()) { + case Solid::Control::NetworkInterface::Ieee8023: + case Solid::Control::NetworkInterface::Ieee80211: + case Solid::Control::NetworkInterface::Serial: + lessThan = true; + break; + case Solid::Control::NetworkInterface::Gsm: + lessThan = if1->uni() < if2->uni(); + break; + case Solid::Control::NetworkInterface::Cdma: + lessThan = false; + break; + default: + lessThan = true; + break; + } + break; + case Solid::Control::NetworkInterface::Cdma: + switch (if2->type()) { + case Solid::Control::NetworkInterface::Ieee8023: + case Solid::Control::NetworkInterface::Ieee80211: + case Solid::Control::NetworkInterface::Serial: + case Solid::Control::NetworkInterface::Gsm: + lessThan = true; + break; + case Solid::Control::NetworkInterface::Cdma: + lessThan = if1->uni() < if2->uni(); + break; + default: + lessThan = true; + break; + } + break; + default: + lessThan = false; + } + return lessThan; +} + +void NetworkManagerApplet::manageConnections() +{ + //kDebug() << "opening connection management dialog"; + QStringList args; + args << "kcm_networkmanagement"; + KToolInvocation::kdeinitExec("kcmshell4", args); + hidePopup(); +} + +void NetworkManagerApplet::loadExtender() +{ + Plasma::ExtenderItem *eItem = extender()->item("networkmanagement"); + if (eItem) { + eItem->destroy(); // Apparently, we need to "refresh the extenderitem + } + eItem = new NMExtenderItem(m_activatableList, extender()); + eItem->setName("networkmanagement"); + eItem->setTitle(i18nc("Label for extender","Network Management")); + eItem->widget(); +} + +void NetworkManagerApplet::managerWirelessEnabledChanged(bool ) +{ +} + +void NetworkManagerApplet::managerWirelessHardwareEnabledChanged(bool enabled) +{ + Q_UNUSED( enabled ); + // TODO: in theory, this shouldn't be necessary since all interfaceitems + // should react to changes by themselves +} + +void NetworkManagerApplet::userNetworkingEnabledChanged(bool enabled) +{ + kDebug() << enabled; + Solid::Control::NetworkManager::setNetworkingEnabled(enabled); +} + +void NetworkManagerApplet::userWirelessEnabledChanged(bool enabled) +{ + kDebug() << enabled; + Solid::Control::NetworkManager::setWirelessEnabled(enabled); +} + +void NetworkManagerApplet::managerStatusChanged(Solid::Networking::Status status) +{ + if (Solid::Networking::Unknown == status ) { + // FIXME: Do something smart + } else { + // ... + } +} + +bool NetworkManagerApplet::hasInterfaceOfType(Solid::Control::NetworkInterface::Type type) +{ + foreach (Solid::Control::NetworkInterface * interface, m_interfaces) { + if (interface->type() == type) { + return true; + } + } + return false; +} + +void NetworkManagerApplet::hideVpnGroup() +{ + m_extenderItem->m_showVpn = false; + KConfigGroup cg = config(); + cg.writeEntry("showVpn", m_extenderItem->m_showVpn); + m_extenderItem->showVpn(false); + Plasma::Applet::configNeedsSaving(); +} + +void NetworkManagerApplet::popupEvent(bool show) +{ + // Notify the wireless extender of popup events so it can revert its hidden wireless network + // item to button mode + if (show && m_extenderItem) { + m_extenderItem->switchToDefaultTab(); + } + return; +} + +#include "networkmanager.moc" Index: applet/networkmanagement-wireless.svgz =================================================================== --- applet/networkmanagement-wireless.svgz (revision 0) +++ applet/networkmanagement-wireless.svgz (revision 1010672) @@ -0,0 +1,66 @@ +][s"G~`+JyhZm1c'h(Ԍ(DN- +T ^Usϓw}t>x6 l8\=wY,a27_zLSo?}ry}us`2^]vz=\|z8?'ppNһt\\_]TUu>fww"Ԝ. +χ4 +QB{ĕ=-VeW16U+|J+u4&&|{_Y$|P3M~*?X2\f +ȴ.tqUCp \xo?-!SfIFpf + .g?m:=砊"A_6|/P.?Wm:Z\a ǘn}x_2fr"Lϡߤ~6_FI=H>jO{,9ЍWQ0-`"|*8%+m"ujw']cKď_̗@C;ɇЛǷcC(Db`6|৴?e!E6z&ԺOEzUs\f}Qh\&@{hq6 |5^_.:hc75ƛ{®>6r4Ч54"{a,Ub$ iEn;R!޹Nۋ +fgmh4c-&3D#iggղCxUʞM*(l!'·FaAh*G~Xl-CKaωDBht8- +)Ӣ|_И~@/ܾX +,&qcNxF7ɤ-6ZjيkBؚ$١2v[$r#f2_l Q`M|?o2wmF{bR0[/Cq.!a s.s0١XzM4Xz?MρVS*!ŗz0 =uFZ>`T|#󡑻ܝӟPK2Spd~(sүÆy:~hVosrqsHnL_e<.?!UC7'~ +P[ +* +Bh~l~wsq_O?Dw)=/=T­B3џz` +$-* + +PnUSƲƲ i#ڮ^xL1qsc [c;tkYb\ܨ@($(X<+V{včß2hdc +%8r"ёL$*Y3N1fl@1&<x1Ѐ36@ˊ&M&L30"X˽5QQx.Xd ‹AII‹$K40O+j!(TK0y[^`ׄWب<V T"/G= H,6tfSY +|{Fe +61-#J<圆,ͼ323v}p.[\l#6?8RtB(5(_1z+'Q\Jhg_׸DDD3ND,ƕ|Z:@F(Jp9x]/iu{KU'H5C[ OU~AÜyWRоQtXXw2ζQ[& 0 +g9 $T+Xq>>+VLQO6jTP1MD ^\@*3FٌvR-]6z Dxfy +psy3rGu #I +(A@6Q36OIj՘6 + +2o\Px/LYx p/,HsxZ'Y c +f}΅V30܌onİ9& 1l4 1,ܮP> +QWYjsEYt( +DI%Y8I|i)< +^Cqz0G ·BQBqƛ1dx3 Nk-*(bՂ!;UIa_Fo+PHIsH[7Μ6 hĸgR4>ar0Liyj< +cߠNarZǓoxo_<\dT*ۜ/_h1fLu!聙ӚJDPKf YK[ >![3c5Kz=H˃㤓NEFqsItYvBnJp׶W嫌 +qF9MeF +!n95Q`*P$O iBJ)v%t-:&J$3"':W=a8TwObeo,i3}8{fwtNY-,?[QhqqE]C݁{Vi|N&U +B_]ZV.q-aOG&u.1.FbxbL]/Q ˊ +%>׿]"nP]zJs9<{7wWRVNwVRd%dܙ,;S@pՌ(oɶ.L)6!>MS Jv:h Ķչ|oJPsez/SL%L(0k݁Vy#w, ji`ci\V4$'󈣳+K6B7 K(`iˌht +(D)Qt9)cZe iR$ +~О"ps`9.j ;8P'Th6d`;! +fS-w>1 A\QED3CHS.G%x e+:zb@W$'X(f9 +OMEX+S#4$ ^|J(YMS!x&A R:`e +/` +/xj%J 0kWt2!1n]V3_eC28<1APhM ֐)8QmViZh?,p$=r=#T&97 +@$D}%q Xp^ tw3&[BXqr f@K(Ғ K +! - +XZBq);-g $ L-Be\ZR^1M8!u~)Ζ9 7BآP,dTiJ{si(LnpF2kBP,[J +UdQMt7 +*J( + nmConfig + + + + 0 + 0 + 397 + 211 + + + + + 0 + 0 + + + + + 200 + 700 + + + + Configure the System Bar + + + + + + <b>Appearance</b> + + + + + + + Show &wired connections + + + + + + + Show w&ireless connections + + + + + + + Show &mobile broadband + + + + + + + Show &VPN connections + + + + + + + Qt::Horizontal + + + + + + + + + + + + + 0 + 0 + + + + &Show this many wireless networks + + + numberOfWlans + + + + + + + + + Qt::Vertical + + + + 20 + 21 + + + + + + + + + Index: applet/wirelessnetworkitem.h =================================================================== --- applet/wirelessnetworkitem.h (revision 0) +++ applet/wirelessnetworkitem.h (revision 1010672) @@ -0,0 +1,71 @@ +/* +Copyright 2008 Sebastian Kügler +Copyright 2008,2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef APPLET_WIRELESSNETWORKITEM_H +#define APPLET_WIRELESSNETWORKITEM_H + +#include "activatableitem.h" + +class QGraphicsGridLayout; + +namespace Plasma +{ + class IconWidget; + class Label; + class Meter; +} + +class RemoteWirelessNetwork; +/** * Represents an wireless network for which no connection exists + */ +class WirelessNetworkItem : public ActivatableItem +{ +Q_OBJECT +public: + WirelessNetworkItem(RemoteWirelessNetwork * remote, QGraphicsItem * parent = 0); + virtual ~WirelessNetworkItem(); + void setupItem(); + +private Q_SLOTS: + void setStrength(int strength); + void update(); + void activationStateChanged(Knm::InterfaceConnection::ActivationState state); + +private: + RemoteWirelessNetwork * wirelessNetworkItem() const; + bool readSettings(); + QGraphicsGridLayout * m_layout; + Plasma::IconWidget * m_icon; + Plasma::Label * m_ssidLabel; + Plasma::Meter * m_strengthMeter; + Plasma::IconWidget * m_connectButton; + QString m_security; + Plasma::IconWidget * m_securityIcon; + QString m_securityIconName; + QString m_securityIconToolTip; + int m_strength; + QString m_ssid; + RemoteWirelessNetwork * m_remote; + Knm::InterfaceConnection::ActivationState m_state; +}; + +#endif //#define APPLET_WIRELESSCONNECTIONITEM_H + Index: applet/nmextenderitem.h =================================================================== --- applet/nmextenderitem.h (revision 0) +++ applet/nmextenderitem.h (revision 1010672) @@ -0,0 +1,115 @@ +/* +Copyright 2009 Sebastian Kügler + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef NMEXTENDERITEM_H +#define NMEXTENDERITEM_H + +#include +//#include +//#include + +#include +#include +#include +#include +#include +#include + +#include + +#include "activatable.h" + +class QGraphicsLinearLayout; +class QGraphicsGridLayout; +class ActivatableItem; + +class RemoteActivatable; +class RemoteActivatableList; + +class ActivatableListWidget; +class InterfaceItem; + +class NMExtenderItem: public Plasma::ExtenderItem +{ +Q_OBJECT +public: + NMExtenderItem(RemoteActivatableList *, Plasma::Extender * ext = 0); + virtual ~NMExtenderItem(); + + void init(); + virtual QGraphicsItem * widget(); + Solid::Control::NetworkInterface* defaultInterface(); + bool available(int state); + + bool m_showWired; + bool m_showWireless; + bool m_showVpn; + bool m_showCellular; + +public Q_SLOTS: + void interfaceAdded(const QString&); + void interfaceRemoved(const QString&); + void switchTab(int type); // Takes networkinterface type + void switchToDefaultTab(); + void managerWirelessEnabledChanged(bool); + void managerWirelessHardwareEnabledChanged(bool); + void wirelessEnabledToggled(bool checked); + void manageConnections(); + void handleConnectionStateChange(int new_state, int old_state, int reason); + + void showWired(bool show); + void showWireless(bool show); + void showVpn(bool show); + void showCellular(bool show); + +Q_SIGNALS: + void connectionListUpdated(); + void configNeedsSaving(); + +private: + void addInterfaceInternal(Solid::Control::NetworkInterface *); + void createTab(Knm::Activatable::ActivatableType type); + + RemoteActivatableList* m_activatables; + // uni, interfaceitem mapping + QHash m_interfaces; + // ActivatableType, index of tab mapping + QHash m_tabIndex; + + Plasma::TabBar* m_connectionTabs; + + QGraphicsWidget* m_widget; + QGraphicsGridLayout* m_mainLayout; + Plasma::Frame* m_leftWidget; + Plasma::Frame* m_rightWidget; + QGraphicsWidget* m_interfaceWidget; + QGraphicsLinearLayout* m_leftLayout; + QGraphicsLinearLayout* m_rightLayout; + QGraphicsLinearLayout* m_interfaceLayout; + + Plasma::CheckBox* m_rfCheckBox; + Plasma::IconWidget* m_connectionsButton; + + ActivatableListWidget* m_wiredList; + ActivatableListWidget* m_wirelessList; + ActivatableListWidget* m_vpnList; +}; + +#endif // NMEXTENDERITEM_H Index: applet/wirelessinterfaceitem.cpp =================================================================== --- applet/wirelessinterfaceitem.cpp (revision 0) +++ applet/wirelessinterfaceitem.cpp (revision 1010672) @@ -0,0 +1,134 @@ +/* +Copyright 2008,2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "wirelessinterfaceitem.h" + +#include + +#include +#include +#include +#include +#include + +WirelessInterfaceItem::WirelessInterfaceItem(Solid::Control::WirelessNetworkInterface * iface, InterfaceItem::NameDisplayMode mode, QGraphicsItem* parent) +: InterfaceItem(iface, mode, parent), m_wirelessIface(iface), m_activeAccessPoint(0) +{ + // for updating our UI + connect(iface, SIGNAL(activeAccessPointChanged(const QString&)), + SLOT(activeAccessPointChanged(const QString&))); + + activeAccessPointChanged(m_wirelessIface->activeAccessPoint()); +} + +WirelessInterfaceItem::~WirelessInterfaceItem() +{ +} + +void WirelessInterfaceItem::activeAccessPointChanged(const QString &uni) +{ + kDebug() << "*** AP changed:" << uni << "***"; + // this is not called when the device is deactivated.. + if (m_activeAccessPoint) { + m_activeAccessPoint->disconnect(this); + m_activeAccessPoint = 0; + } + if (uni != "/") { + m_activeAccessPoint = m_wirelessIface->findAccessPoint(uni); + kDebug() << "new:" << m_activeAccessPoint; + if (m_activeAccessPoint) { + connect(m_activeAccessPoint, SIGNAL(signalStrengthChanged(int)), SLOT(activeSignalStrengthChanged(int))); + connect(m_activeAccessPoint, SIGNAL(destroyed(QObject*)), + SLOT(accessPointDestroyed(QObject*))); + } + } + setConnectionInfo(); +} + +QString WirelessInterfaceItem::connectionName() +{ + if (m_activeAccessPoint) { + return m_activeAccessPoint->ssid(); + } + return QString(); +} + +void WirelessInterfaceItem::activeSignalStrengthChanged(int) +{ + setConnectionInfo(); +} + +void WirelessInterfaceItem::accessPointDestroyed(QObject* ap) +{ + kDebug() << "*** AP gone ***"; + if (ap == m_activeAccessPoint) { + m_activeAccessPoint = 0; + } +} + +void WirelessInterfaceItem::connectButtonClicked() +{ + // TODO +} + +void WirelessInterfaceItem::setConnectionInfo() +{ + InterfaceItem::setConnectionInfo(); // Sets the labels + switch ( m_iface->connectionState()) { + case Solid::Control::NetworkInterface::Unavailable: + case Solid::Control::NetworkInterface::Disconnected: + case Solid::Control::NetworkInterface::Failed: + m_strengthMeter->hide(); + m_connectionInfoIcon->hide(); + break; + default: + { + if (m_activeAccessPoint) { + if (m_strengthMeter) { + m_strengthMeter->setValue(m_activeAccessPoint->signalStrength()); + m_strengthMeter->show(); + m_connectionInfoIcon->show(); + } + } + break; + } + } +} + +QList WirelessInterfaceItem::availableAccessPoints() const +{ + QList retVal; + AccessPointList aps = m_wirelessIface->accessPoints(); //NOTE: AccessPointList is a QStringList + foreach (const QString &ap, aps) { + Solid::Control::AccessPoint *accesspoint = m_wirelessIface->findAccessPoint(ap); + if(accesspoint) { + retVal << accesspoint; + } + } + return retVal; +} + +void WirelessInterfaceItem::setEnabled(bool enable) +{ + m_strengthMeter->setEnabled(enable); + InterfaceItem::setEnabled(enable); +} + +// vim: sw=4 sts=4 et tw=100 Index: libs/internals/knmserviceprefs.kcfg =================================================================== --- libs/internals/knmserviceprefs.kcfg (revision 0) +++ libs/internals/knmserviceprefs.kcfg (revision 1010672) @@ -0,0 +1,42 @@ + + + + kwallet.h + "connectionpersistence.h" + + + + + + + + (KWallet::Wallet::isEnabled() ? Knm::ConnectionPersistence::Secure : Knm::ConnectionPersistence::PlainText) + + + + + + + + + true + + + + + 1 + 1 + 5 + + + + 31 + + + interface:type,interface:name,interface:hardwareaddress,interface:driver,interface:status,interface:bitrate,ipv4:address,ipv4:nameservers,ipv4:domains + + + Index: libs/internals/connection.cpp =================================================================== --- libs/internals/connection.cpp (revision 0) +++ libs/internals/connection.cpp (revision 1010672) @@ -0,0 +1,252 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#include "connection.h" + +#include "settings/802-11-wireless-security.h" +#include "settings/802-11-wireless.h" +#include "settings/802-1x.h" +#include "settings/802-3-ethernet.h" +#include "settings/cdma.h" +#include "settings/gsm.h" +#include "settings/ipv4.h" +#include "settings/ppp.h" +#include "settings/pppoe.h" +#include "settings/serial.h" +#include "settings/vpn.h" + +using namespace Knm; + +QString Connection::typeAsString(Connection::Type type) +{ + QString typeString; + switch (type) { + case Wired: + typeString = QLatin1String("802-3-ethernet"); + break; + case Wireless: + typeString = QLatin1String("802-11-wireless"); + break; + case Gsm: + typeString = QLatin1String("gsm"); + break; + case Cdma: + typeString = QLatin1String("cdma"); + break; + case Vpn: + typeString = QLatin1String("vpn"); + break; + case Pppoe: + typeString = QLatin1String("pppoe"); + break; + default: + break; + } + return typeString; +} + +Connection::Type Connection::typeFromString(const QString & typeString) +{ + Connection::Type type = Wired; + if (typeString == QLatin1String("802-3-ethernet")) { + type = Wired; + } else if (typeString == QLatin1String("802-11-wireless")) { + type = Wireless; + } else if (typeString == QLatin1String("gsm")) { + type = Gsm; + } else if (typeString == QLatin1String("cdma")) { + type = Cdma; + } else if (typeString == QLatin1String("vpn")) { + type = Vpn; + } else if (typeString == QLatin1String("pppoe")) { + type = Pppoe; + } + return type; +} + +Connection::Type typeFromString(const QString & type); + +Connection::Connection(const QString & name, const Connection::Type type) + : m_name(name), m_uuid(QUuid::createUuid()), m_type(type), m_autoConnect(false) +{ + init(); +} + +Connection::Connection(const QUuid & uuid, const Connection::Type type) + : m_uuid(uuid), m_type(type), m_autoConnect(false) +{ + init(); +} + +Connection::~Connection() +{ + qDeleteAll(m_settings); +} + +void Connection::init() +{ + switch (m_type) { + case Cdma: + addSetting(new CdmaSetting()); + addSetting(new Ipv4Setting()); + addSetting(new PppSetting()); + addSetting(new SerialSetting()); + break; + case Gsm: + addSetting(new GsmSetting()); + addSetting(new Ipv4Setting()); + addSetting(new PppSetting()); + addSetting(new SerialSetting()); + break; + case Pppoe: + addSetting(new Ipv4Setting()); + addSetting(new PppSetting()); + addSetting(new PppoeSetting()); + addSetting(new WiredSetting()); + break; + case Vpn: + addSetting(new VpnSetting()); + break; + case Wired: + addSetting(new Ipv4Setting()); + addSetting(new Security8021xSetting()); + addSetting(new WiredSetting()); + break; + case Wireless: + addSetting(new Ipv4Setting()); + addSetting(new Security8021xSetting()); + addSetting(new WirelessSetting()); + addSetting(new WirelessSecuritySetting()); + break; + } +} + +QString Connection::name() const +{ + return m_name; +} + +QUuid Connection::uuid() const +{ + return m_uuid; +} + +Connection::Type Connection::type() const +{ + return m_type; +} + +bool Connection::autoConnect() const +{ + return m_autoConnect; +} + +QDateTime Connection::timestamp() const +{ + return m_timestamp; +} + +QList Connection::settings() const +{ + return m_settings; +} + +Setting * Connection::setting(Setting::Type settingType) const +{ + Setting * foundSetting = 0; + foreach (Setting * setting, m_settings) { + if (setting->type() == settingType) { + foundSetting = setting; + break; + } + } + return foundSetting; +} + +void Connection::setName(const QString & name) +{ + m_name = name; +} + +void Connection::setUuid(const QUuid & uuid) +{ + m_uuid = uuid; +} + +void Connection::setTimestamp(const QDateTime & timestamp) +{ + m_timestamp = timestamp; +} + +void Connection::setAutoConnect(bool autoConnect) +{ + m_autoConnect = autoConnect; +} + +void Connection::updateTimestamp() +{ + m_timestamp = QDateTime::currentDateTime(); +} + +void Connection::addSetting(Setting * newSetting) +{ + m_settings.append(newSetting); +} + +bool Connection::hasSecrets() const +{ + bool connectionHasSecrets = false; + foreach (Setting * setting, m_settings) { + if (setting->hasSecrets()) { + connectionHasSecrets = true; + break; + } + } + return connectionHasSecrets; +} + +bool Connection::secretsAvailable() const +{ + bool allSecretsAvailable = true; + foreach (Setting * setting, m_settings) { + if (setting->hasSecrets() && !setting->secretsAvailable()) { + allSecretsAvailable = false; + break; + } + } + return allSecretsAvailable; +} + +void Connection::setOrigin(const QString & origin) +{ + m_origin = origin; +} + +QString Connection::origin() const +{ + return m_origin; +} + +void Connection::setType(Connection::Type type) +{ + m_type = type; +} + +// vim: sw=4 sts=4 et tw=100 Index: libs/internals/schemas/vpn.kcfgc =================================================================== --- libs/internals/schemas/vpn.kcfgc (revision 0) +++ libs/internals/schemas/vpn.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=vpn.kcfg +ClassName=Vpn +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/cdma.kcfgc =================================================================== --- libs/internals/schemas/cdma.kcfgc (revision 0) +++ libs/internals/schemas/cdma.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=cdma.kcfg +ClassName=Cdma +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/serial.kcfg =================================================================== --- libs/internals/schemas/serial.kcfg (revision 0) +++ libs/internals/schemas/serial.kcfg (revision 1010672) @@ -0,0 +1,37 @@ + + + + + + + + + + + 8 + + + + + + + + + + None + + + + + 1 + + + + + + + + Property changes on: libs/internals/schemas/serial.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/serial.kcfgc =================================================================== --- libs/internals/schemas/serial.kcfgc (revision 0) +++ libs/internals/schemas/serial.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=serial.kcfg +ClassName=Serial +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/ipv4.kcfg =================================================================== --- libs/internals/schemas/ipv4.kcfg (revision 0) +++ libs/internals/schemas/ipv4.kcfg (revision 1010672) @@ -0,0 +1,47 @@ + + + + + + + Choose the way to set the IP address of this connection + + + + + + + 42 + + + + List of Domain Name System servers to use + + + + List of domains to search for a hostname + + + + + List of IP addresses to configure on this connection + + + + Ignore DNS servers returned by DHCP and use the configured servers instead + + + + + + Property changes on: libs/internals/schemas/ipv4.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/pppoe.kcfg =================================================================== --- libs/internals/schemas/pppoe.kcfg (revision 0) +++ libs/internals/schemas/pppoe.kcfg (revision 1010672) @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + Property changes on: libs/internals/schemas/pppoe.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/802-11-wireless.kcfg =================================================================== --- libs/internals/schemas/802-11-wireless.kcfg (revision 0) +++ libs/internals/schemas/802-11-wireless.kcfg (revision 1010672) @@ -0,0 +1,66 @@ + + + + + + + Service Set IDentifier (network name) + + + + + + + 0 + + + + + + + + + 1 + + + + + + + + + + Basic Service Set IDentifier of the access point to use + + + + + + + + + + + + Hardware address to set on the wireless network interface + + + + 0 + Maximum Transmit Unit + + + + + + + + + + + + + Property changes on: libs/internals/schemas/802-11-wireless.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/802-3-ethernet.kcfg =================================================================== --- libs/internals/schemas/802-3-ethernet.kcfg (revision 0) +++ libs/internals/schemas/802-3-ethernet.kcfg (revision 1010672) @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + Whether the Ethernet interface should use duplex communications + + + + + + + + + true + + + + + + + + + + 0 + Maximum Transfer Unit to use + + + + + + Property changes on: libs/internals/schemas/802-3-ethernet.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/ipv4.kcfgc =================================================================== --- libs/internals/schemas/ipv4.kcfgc (revision 0) +++ libs/internals/schemas/ipv4.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=ipv4.kcfg +ClassName=Ipv4 +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/pppoe.kcfgc =================================================================== --- libs/internals/schemas/pppoe.kcfgc (revision 0) +++ libs/internals/schemas/pppoe.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=pppoe.kcfg +ClassName=Pppoe +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/802-11-wireless.kcfgc =================================================================== --- libs/internals/schemas/802-11-wireless.kcfgc (revision 0) +++ libs/internals/schemas/802-11-wireless.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=802-11-wireless.kcfg +ClassName=Wireless +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/gsm.kcfg =================================================================== --- libs/internals/schemas/gsm.kcfg (revision 0) +++ libs/internals/schemas/gsm.kcfg (revision 1010672) @@ -0,0 +1,47 @@ + + + + + + + + *99# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property changes on: libs/internals/schemas/gsm.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/802-11-wireless-security.kcfg =================================================================== --- libs/internals/schemas/802-11-wireless-security.kcfg (revision 0) +++ libs/internals/schemas/802-11-wireless-security.kcfg (revision 1010672) @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + None + + + + + + + + + + + 42 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property changes on: libs/internals/schemas/802-11-wireless-security.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/802-3-ethernet.kcfgc =================================================================== --- libs/internals/schemas/802-3-ethernet.kcfgc (revision 0) +++ libs/internals/schemas/802-3-ethernet.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=802-3-ethernet.kcfg +ClassName=Wired +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/gsm.kcfgc =================================================================== --- libs/internals/schemas/gsm.kcfgc (revision 0) +++ libs/internals/schemas/gsm.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=gsm.kcfg +ClassName=Gsm +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/802-11-wireless-security.kcfgc =================================================================== --- libs/internals/schemas/802-11-wireless-security.kcfgc (revision 0) +++ libs/internals/schemas/802-11-wireless-security.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=802-11-wireless-security.kcfg +ClassName=WirelessSecurity +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/ppp.kcfg =================================================================== --- libs/internals/schemas/ppp.kcfg (revision 0) +++ libs/internals/schemas/ppp.kcfg (revision 1010672) @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Property changes on: libs/internals/schemas/ppp.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/connection.kcfg =================================================================== --- libs/internals/schemas/connection.kcfg (revision 0) +++ libs/internals/schemas/connection.kcfg (revision 1010672) @@ -0,0 +1,39 @@ + + + + + + + A name that uniquely identifies a connection + + + + Specifies the connection type, defines which devices it can activate and which other settings the connection should contain + + + + Should the networking system always try to activate this connection? + + + + The date and time that the connection was last activated + + + + Unique connection identifier + + + + + + Property changes on: libs/internals/schemas/connection.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/802-1x.kcfg =================================================================== --- libs/internals/schemas/802-1x.kcfg (revision 0) +++ libs/internals/schemas/802-1x.kcfg (revision 1010672) @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + none + + + + + + + + + + + + + + none + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + false + + + + + + Property changes on: libs/internals/schemas/802-1x.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/802-1x.kcfgc =================================================================== --- libs/internals/schemas/802-1x.kcfgc (revision 0) +++ libs/internals/schemas/802-1x.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=802-1x.kcfg +ClassName=Security8021x +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/ppp.kcfgc =================================================================== --- libs/internals/schemas/ppp.kcfgc (revision 0) +++ libs/internals/schemas/ppp.kcfgc (revision 1010672) @@ -0,0 +1,5 @@ +File=ppp.kcfg +ClassName=Ppp +Mutators=true +Visibility=KNMINTERNALS_EXPORT +NameSpace=Knm Index: libs/internals/schemas/vpn.kcfg =================================================================== --- libs/internals/schemas/vpn.kcfg (revision 0) +++ libs/internals/schemas/vpn.kcfg (revision 1010672) @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Property changes on: libs/internals/schemas/vpn.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/schemas/cdma.kcfg =================================================================== --- libs/internals/schemas/cdma.kcfg (revision 0) +++ libs/internals/schemas/cdma.kcfg (revision 1010672) @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + Property changes on: libs/internals/schemas/cdma.kcfg ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/wirelessinterfaceconnection.h =================================================================== --- libs/internals/wirelessinterfaceconnection.h (revision 0) +++ libs/internals/wirelessinterfaceconnection.h (revision 1010672) @@ -0,0 +1,50 @@ +/* +Copyright 2008 Frederik Gladhorn +Copyright 2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef KNM_EXTERNALS_WIRELESSINTERFACECONNECTION_H +#define KNM_EXTERNALS_WIRELESSINTERFACECONNECTION_H + +#include "interfaceconnection.h" +#include "wirelessobject.h" + +#include "knminternals_export.h" + +namespace Knm { + +class KNMINTERNALS_EXPORT WirelessInterfaceConnection : public InterfaceConnection, public WirelessObject +{ +Q_OBJECT +Q_PROPERTY(QString ssid READ ssid) +Q_PROPERTY(int strength READ strength) +Q_PROPERTY(uint wpaFlags READ wpaFlags) +Q_PROPERTY(uint rsnFlags READ rsnFlags) + +public: + WirelessInterfaceConnection(const QString & ssid, int strength, Solid::Control::WirelessNetworkInterface::Capabilities interfaceCapabilities, Solid::Control::AccessPoint::Capabilities apCapabilities, Solid::Control::AccessPoint::WpaFlags wpaFlags, Solid::Control::AccessPoint::WpaFlags rsnFlags, Solid::Control::WirelessNetworkInterface::OperationMode mode, const QUuid & connectionUuid, const QString & connectionName, const QString & deviceUni, QObject * parent); + virtual ~WirelessInterfaceConnection(); +signals: + void strengthChanged(int); +public Q_SLOTS: + void setStrength(int); +}; +} // namespace + +#endif Index: libs/internals/regenerate_patch_from_clean =================================================================== --- libs/internals/regenerate_patch_from_clean (revision 0) +++ libs/internals/regenerate_patch_from_clean (revision 1010672) @@ -0,0 +1 @@ +diff -ur origsettings/ settings > settings_hand_edits.diff Index: libs/internals/connectionpersistence.cpp =================================================================== --- libs/internals/connectionpersistence.cpp (revision 0) +++ libs/internals/connectionpersistence.cpp (revision 1010672) @@ -0,0 +1,277 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#include "connectionpersistence.h" + +#include +#include + +#include "connection.h" +#include "setting.h" +#include "settingpersistence.h" + +#include "settings/802-11-wireless.h" +#include "settings/802-11-wirelesspersistence.h" +#include "settings/802-11-wireless-security.h" +#include "settings/802-11-wireless-securitypersistence.h" +#include "settings/802-1x.h" +#include "settings/802-1xpersistence.h" +#include "settings/802-3-ethernet.h" +#include "settings/802-3-ethernetpersistence.h" +#include "settings/cdma.h" +#include "settings/cdmapersistence.h" +#include "settings/gsm.h" +#include "settings/gsmpersistence.h" +#include "settings/ipv4.h" +#include "settings/ipv4persistence.h" +#include "settings/ppp.h" +#include "settings/ppppersistence.h" +#include "settings/pppoe.h" +#include "settings/pppoepersistence.h" +#include "settings/serial.h" +#include "settings/serialpersistence.h" +#include "settings/vpn.h" +#include "settings/vpnpersistence.h" + +using namespace Knm; + +const QString ConnectionPersistence::NETWORKMANAGEMENT_RCFILE = QLatin1String("networkmanagementrc"); +const QString ConnectionPersistence::CONNECTION_PERSISTENCE_PATH = QLatin1String("networkmanagement/connections/"); + +QString ConnectionPersistence::s_walletFolderName = QLatin1String("Network Management"); + +WId ConnectionPersistence::s_walletWId = 0; + +ConnectionPersistence::ConnectionPersistence(Connection * conn, KSharedConfig::Ptr config, SecretStorageMode mode) + : m_connection(conn), m_config(config), m_storageMode(mode) +{ +} + +ConnectionPersistence::ConnectionPersistence(KSharedConfig::Ptr config, SecretStorageMode mode) + : m_config(config), m_storageMode(mode) +{ + KConfigGroup connection(config, "connection"); + QString uuid = connection.readEntry("uuid"); + QString type = connection.readEntry("type"); + if (uuid.isEmpty() || type.isEmpty()) { + m_connection = 0; + } else { + m_connection = new Connection(QUuid(uuid), Connection::typeFromString(type)); + kDebug() << m_connection->uuid(); + } +} + + +ConnectionPersistence::~ConnectionPersistence() +{ + qDeleteAll(m_persistences.values()); +} + +Connection * ConnectionPersistence::connection() const +{ + return m_connection; +} + +SettingPersistence * ConnectionPersistence::persistenceFor(Setting * setting) +{ + SettingPersistence * sp = m_persistences.value(setting); + if (!sp) + switch (setting->type()) { + case Setting::Cdma: + sp = new CdmaPersistence(static_cast(setting), m_config, m_storageMode); + break; + case Setting::Gsm: + sp = new GsmPersistence(static_cast(setting), m_config, m_storageMode); + break; + case Setting::Ipv4: + sp = new Ipv4Persistence(static_cast(setting), m_config, m_storageMode); + break; + case Setting::Ppp: + sp = new PppPersistence(static_cast(setting), m_config, m_storageMode); + break; + case Setting::Pppoe: + sp = new PppoePersistence(static_cast(setting), m_config, m_storageMode); + break; + case Setting::Security8021x: + sp = new Security8021xPersistence(static_cast(setting), m_config, m_storageMode); + break; + case Setting::Serial: + sp = new SerialPersistence(static_cast(setting), m_config, m_storageMode); + break; + case Setting::Vpn: + sp = new VpnPersistence(static_cast(setting), m_config, m_storageMode); + break; + case Setting::Wired: + sp = new WiredPersistence(static_cast(setting), m_config, m_storageMode); + break; + case Setting::Wireless: + sp = new WirelessPersistence(static_cast(setting), m_config, m_storageMode); + break; + case Setting::WirelessSecurity: + sp = new WirelessSecurityPersistence( + static_cast(setting), m_config, m_storageMode + ); + break; + } + if (sp) { + m_persistences.insert(setting, sp); + } + return sp; +} + +void ConnectionPersistence::save() +{ + // save connection settings + KConfigGroup cg(m_config, "connection"); + cg.writeEntry("id", m_connection->name()); + cg.writeEntry("uuid", m_connection->uuid().toString()); + cg.writeEntry("type", Connection::typeAsString(m_connection->type())); + cg.writeEntry("autoconnect", m_connection->autoConnect()); + cg.writeEntry("timestamp", m_connection->timestamp()); + + // save each setting + foreach (Setting * setting, m_connection->settings()) { + SettingPersistence * sp = persistenceFor(setting); + sp->save(); + + } + m_config->sync(); + + // factor out to make a pure Qt version + bool readyForWalletWrite = false; + if (m_connection->hasSecrets() && m_storageMode == ConnectionPersistence::Secure) { + KWallet::Wallet * wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), walletWid(), KWallet::Wallet::Synchronous ); + if( wallet && wallet->isOpen() ) { + if( !wallet->hasFolder( s_walletFolderName ) ) + wallet->createFolder( s_walletFolderName ); + if ( wallet->setFolder( s_walletFolderName ) ) { + readyForWalletWrite = true; + } + } + + // could be merged with above loop for speed but this keeps the + // kde wallet dependencies in one place + if (readyForWalletWrite) { + foreach (Setting * setting, m_connection->settings()) { + SettingPersistence * sp = persistenceFor(setting); + QMap secrets = sp->secrets(); + if (!secrets.isEmpty()) { + wallet->writeMap(walletKeyFor(setting), secrets); + } + } + } + } +} + +void ConnectionPersistence::load() +{ + // load connection settings + KConfigGroup cg(m_config, "connection"); + if (cg.exists()) { // don't bother to try if the KConfigGroup doesn't exist, save opening the wallet too + m_connection->setName(cg.readEntry("id")); + m_connection->setAutoConnect(cg.readEntry("autoconnect", false)); + m_connection->setTimestamp(cg.readEntry("timestamp", QDateTime())); + + // load each setting + foreach (Setting * setting, m_connection->settings()) { + SettingPersistence * sp = persistenceFor(setting); + sp->load(); + } + } +} + +QString ConnectionPersistence::walletKeyFor(const Setting * setting) const +{ + return m_connection->uuid() + ';' + setting->name(); +} + +void ConnectionPersistence::loadSecrets() +{ + KConfigGroup cg(m_config, "connection"); + if (cg.exists()) { + bool haveResult = true; + EnumError::type errorCode = EnumError::NoError; + + if (m_storageMode != ConnectionPersistence::Secure) { + + foreach (Setting * setting, m_connection->settings()) { + setting->setSecretsAvailable(true); + } + + } else if (!m_connection->hasSecrets() || + m_connection->secretsAvailable()) { + + } else if (KWallet::Wallet::isEnabled()) { + + kDebug() << "opening wallet..."; + KWallet::Wallet * wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), + walletWid(), KWallet::Wallet::Asynchronous); + if (wallet) { + haveResult = false; + disconnect(wallet, SIGNAL(walletOpened(bool)), this, 0); + connect(wallet, SIGNAL(walletOpened(bool)), this, SLOT(walletOpenedForRead(bool))); + } else { + errorCode = EnumError::WalletNotFound; + } + } else { + errorCode = EnumError::WalletDisabled; + } + + if (haveResult) { + emit loadSecretsResult(errorCode); + } + } + return; +} + +void ConnectionPersistence::walletOpenedForRead(bool success) +{ + if (success) { + KWallet::Wallet * wallet = static_cast(sender()); + if (wallet->isOpen() && wallet->hasFolder(s_walletFolderName) && wallet->setFolder(s_walletFolderName)) { + kDebug() << "Reading all entries for connection"; + QMap > entries; + QString key = m_connection->uuid() + QLatin1String("*"); + + if (wallet->readMapList(key, entries) == 0) { + foreach (Setting * setting, m_connection->settings()) { + QString settingKey = walletKeyFor(setting); + + if (entries.contains(settingKey)) { + QMap settingSecrets = entries.value(settingKey); + kDebug() << settingSecrets; + persistenceFor(setting)->restoreSecrets(settingSecrets); + } + } + kDebug() << "Check connection:"; + kDebug() << "secretsAvailable:" << m_connection->secretsAvailable(); + + emit loadSecretsResult(EnumError::NoError); + } else { + kDebug() << "Wallet::readEntryList for :" << key << " failed"; + emit loadSecretsResult(EnumError::MissingContents); + } + } + } else { + emit loadSecretsResult(EnumError::WalletOpenRefused); + } +} + +// vim: sw=4 sts=4 et tw=100 Index: libs/internals/vpninterfaceconnection.cpp =================================================================== --- libs/internals/vpninterfaceconnection.cpp (revision 0) +++ libs/internals/vpninterfaceconnection.cpp (revision 1010672) @@ -0,0 +1,36 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#include "vpninterfaceconnection.h" + +using namespace Knm; + +VpnInterfaceConnection::VpnInterfaceConnection(const QUuid & connectionUuid, const QString & connectionName, const QString & deviceUni, QObject * parent) +: InterfaceConnection( connectionUuid, connectionName, Knm::Activatable::VpnInterfaceConnection, deviceUni, parent) +{ + +} + +VpnInterfaceConnection::~VpnInterfaceConnection() +{ + +} + +// vim: sw=4 sts=4 et tw=100 Index: libs/internals/wpasecretidentifier.h =================================================================== --- libs/internals/wpasecretidentifier.h (revision 0) +++ libs/internals/wpasecretidentifier.h (revision 1010672) @@ -0,0 +1,35 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#include +#include "../knm_export.h" + +#ifndef WPASECRETIDENTIFIER_H +#define WPASECRETIDENTIFIER_H + +class KNM_EXPORT WpaSecretIdentifier +{ +public: + enum WpaSecretType {Invalid, Passphrase, PreSharedKey}; + + static WpaSecretIdentifier::WpaSecretType identify(const QString & secret); +}; + +#endif //WPASECRETIDENTIFIER_H Index: libs/internals/secretstoragehelper.cpp =================================================================== --- libs/internals/secretstoragehelper.cpp (revision 0) +++ libs/internals/secretstoragehelper.cpp (revision 1010672) @@ -0,0 +1,71 @@ +/* +Copyright 2008 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "secretstoragehelper.h" + +#include +#include + +QString SecretStorageHelper::s_walletFolderName = QLatin1String("NetworkManager"); +WId SecretStorageHelper::s_walletWId = 0; + +SecretStorageHelper::SecretStorageHelper( const QString &connectionName, const QString &settingGroup) : m_connectionName(connectionName), m_settingGroup(settingGroup) +{ +} + +QString SecretStorageHelper::keyForEntry(const QString & entry) const +{ + return m_connectionName + ';' + m_settingGroup + ';' + entry; +} + +void SecretStorageHelper::readSecret(const QString &key, QString &secret ) +{ + kDebug() << key << secret; + KWallet::Wallet * wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), walletWid(), KWallet::Wallet::Synchronous ); + if( wallet && wallet->isOpen() ) { + if( !wallet->hasFolder( s_walletFolderName ) ) + wallet->createFolder( s_walletFolderName ); + + if ( wallet->setFolder( s_walletFolderName ) ) { + if (wallet->readPassword(keyForEntry(key), secret) == 0 ) { + kDebug() << "Got secret '" << keyForEntry(key) << "' : '" << secret << "' in folder " << s_walletFolderName; + return; + } + } + } + kDebug() << "Failed to get secret '" << keyForEntry(key) << "' in folder " << s_walletFolderName; + secret = QString(); +} + +void SecretStorageHelper::writeSecret(const QString &key, const QString &secret ) +{ + kDebug() << key << secret; + KWallet::Wallet * wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), walletWid(), KWallet::Wallet::Synchronous ); + if( wallet && wallet->isOpen() ) { + if( !wallet->hasFolder( s_walletFolderName ) ) + wallet->createFolder( s_walletFolderName ); + + if ( wallet->setFolder( s_walletFolderName ) ) { + wallet->writePassword(keyForEntry(key), secret); + } + } +} + +// vim: sw=4 sts=4 et tw=100 Property changes on: libs/internals/secretstoragehelper.cpp ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/wirelessnetwork.h =================================================================== --- libs/internals/wirelessnetwork.h (revision 0) +++ libs/internals/wirelessnetwork.h (revision 1010672) @@ -0,0 +1,51 @@ +/* +Copyright 2008 Frederik Gladhorn + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef WIRELESSNETWORK_H +#define WIRELESSNETWORK_H + +#include "activatable.h" +#include "wirelessobject.h" + +#include +#include + +#include "knminternals_export.h" + +namespace Knm { + +class KNMINTERNALS_EXPORT WirelessNetwork : public Activatable, public WirelessObject +{ +Q_OBJECT +Q_PROPERTY(QString ssid READ ssid) +Q_PROPERTY(int strength READ strength) +Q_PROPERTY(uint wpaFlags READ wpaFlags) +Q_PROPERTY(uint rsnFlags READ rsnFlags) +public: + WirelessNetwork(const QString & ssid, int strength, Solid::Control::WirelessNetworkInterface::Capabilities interfaceCapabilities, Solid::Control::AccessPoint::Capabilities apCapabilities, Solid::Control::AccessPoint::WpaFlags wpaFlags, Solid::Control::AccessPoint::WpaFlags rsnFlags, Solid::Control::WirelessNetworkInterface::OperationMode mode, const QString & deviceUni, QObject * parent); + virtual ~WirelessNetwork(); +signals: + void strengthChanged(int); +public Q_SLOTS: + void setStrength(int); +}; +} // namespace + +#endif // WIRELESSNETWORK_H Index: libs/internals/tooltips.cpp =================================================================== --- libs/internals/tooltips.cpp (revision 0) +++ libs/internals/tooltips.cpp (revision 1010672) @@ -0,0 +1,115 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#include "tooltips.h" + +#include + +#include +#include + +class ToolTipsPrivate +{ +public: + ToolTipsPrivate(); + ~ToolTipsPrivate(); +public: + QHash tipKeysToLabels; + QHash tipKeysToToolTips; +}; + +K_GLOBAL_STATIC(ToolTipsPrivate, myToolTipsPrivate) + +ToolTipsPrivate::ToolTipsPrivate() +{ + /* first the tooltips for the tooltips */ + tipKeysToToolTips[QLatin1String("interface:type")] = i18nc("@info:tooltip", "Interface type"); + tipKeysToToolTips[QLatin1String("interface:name")] = i18nc("@info:tooltip", "System device name"); + tipKeysToToolTips[QLatin1String("interface:driver")] = i18nc("@info:tooltip", "System driver name"); + tipKeysToToolTips[QLatin1String("interface:status")] = i18nc("@info:tooltip", "Network interface status"); + tipKeysToToolTips[QLatin1String("interface:hardwareaddress")] = i18nc("@info:tooltip", "Hardware address of a network interface"); + tipKeysToToolTips[QLatin1String("interface:bitrate")] = i18nc("@info:tooltip", "Network interface current bit rate"); + tipKeysToToolTips[QLatin1String("interface:designspeed")] = i18nc("@info:tooltip", "Maximum speed of the network interface"); + tipKeysToToolTips[QLatin1String("ipv4:address")] = i18nc("@info:tooltip", "IPv4 network address"); + tipKeysToToolTips[QLatin1String("ipv4:nameservers")] = i18nc("@info:tooltip", "Network name servers"); + tipKeysToToolTips[QLatin1String("ipv4:domains")] = i18nc("@info:tooltip", "Network domains"); + tipKeysToToolTips[QLatin1String("ipv4:routes")] = i18nc("@info:tooltip", "Network routes"); + //tipKeysToToolTips[QLatin1String("wired:carrier")] = + tipKeysToToolTips[QLatin1String("wireless:strength")] = i18nc("@info:tooltip", "Signal strength of the wifi network"); + tipKeysToToolTips[QLatin1String("wireless:ssid")] = i18nc("@info:tooltip", "Name of the wireless network in use"); + tipKeysToToolTips[QLatin1String("wireless:mode")] = i18nc("@info:tooltip", "Operation mode of wireless network"); + tipKeysToToolTips[QLatin1String("wireless:accesspoint")] = i18nc("@info:tooltip", "Hardware address of the active access point"); + tipKeysToToolTips[QLatin1String("wireless:frequency")] = i18nc("@info:tooltip", "The radio channel frequency that the access point is operating on"); + tipKeysToToolTips[QLatin1String("wireless:security")] = i18nc("@info:tooltip", "Subjective network security level description"); + tipKeysToToolTips[QLatin1String("wireless:wpaflags")] = i18nc("@info:tooltip", "Flags describing the access point's capabilities according to WPA (Wifi Protected Access)"); + tipKeysToToolTips[QLatin1String("wireless:rsnflags")] = i18nc("@info:tooltip", "Flags describing the access point's capabilities according to RSN (Robust Secure Network)"); + + /* now the labels */ + tipKeysToLabels[QLatin1String("interface:type")] = i18nc(" interface type", "Type"); + tipKeysToLabels[QLatin1String("interface:name")] = i18nc(" network device name eg eth0", "Interface"); + tipKeysToLabels[QLatin1String("interface:driver")] = i18nc(" system driver name", "Driver"); + tipKeysToLabels[QLatin1String("interface:status")] = i18nc(" network interface status", "Status"); + tipKeysToLabels[QLatin1String("interface:hardwareaddress")] = i18nc(" this is the hardware address of a network interface", + "Hardware address (Wired)"); + tipKeysToLabels[QLatin1String("interface:bitrate")] = i18nc(" network connection bit rate","Bit rate"); + tipKeysToLabels[QLatin1String("interface:designspeed")] = i18nc(" The network device's maximum speed", + "Max speed"); + tipKeysToLabels[QLatin1String("ipv4:address")] = i18nc(" IPv4 address", "IP address"); + tipKeysToLabels[QLatin1String("ipv4:nameservers")] = i18nc(" network name servers", "Name servers"); + tipKeysToLabels[QLatin1String("ipv4:domains")] = i18nc(" network domains", "Domains"); + tipKeysToLabels[QLatin1String("ipv4:routes")] = i18nc(" network routes", "Routes"); + //tipKeysToLabels[QLatin1String("wired:carrier")] = + tipKeysToLabels[QLatin1String("wireless:strength")] = i18nc(" The signal strength of the wifi network", + "Strength"); + tipKeysToLabels[QLatin1String("wireless:ssid")] = i18nc(" SSID is a friendly name that identifies a 802.11 WLAN.", + "SSID"); + tipKeysToLabels[QLatin1String("wireless:mode")] = i18nc(" the operation mode of wi-fi network","Mode"); + tipKeysToLabels[QLatin1String("wireless:accesspoint")] = i18nc(" Active access point MAC address", + "Access point"); + tipKeysToLabels[QLatin1String("wireless:frequency")] = i18nc(" the frequency of the radio channel that the access point is operating on", + "Frequency"); + tipKeysToLabels[QLatin1String("wireless:security")] = i18nc(" network security level, e.g. high, low", "Security"); + tipKeysToLabels[QLatin1String("wireless:wpaflags")] = i18nc(" Flags describing the access point's capabilities according to WPA (Wifi Protected Access)", + "WPA flags"); + tipKeysToLabels[QLatin1String("wireless:rsnflags")] = i18nc("Flags describing the access point's capabilities according to RSN (Robust Secure Network)", + "RSN(WPA2) flags"); +} + +ToolTipsPrivate::~ToolTipsPrivate() +{ + +} + +QStringList Knm::ToolTips::allKeys() +{ + return myToolTipsPrivate->tipKeysToLabels.keys(); +} + +QString Knm::ToolTips::labelForKey(const QString & key) +{ + return myToolTipsPrivate->tipKeysToLabels.value(key); +} + +QString Knm::ToolTips::toolTipForKey(const QString & key) +{ + return myToolTipsPrivate->tipKeysToToolTips.value(key); +} + +// vim: sw=4 sts=4 et tw=100 Index: libs/internals/setting.cpp =================================================================== --- libs/internals/setting.cpp (revision 0) +++ libs/internals/setting.cpp (revision 1010672) @@ -0,0 +1,140 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#include "setting.h" + +#include +#include +#include +#include +// Removed in NM0.7rc1 +// #include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace Knm; + +QString Setting::typeAsString(Setting::Type type) +{ + QString typeString; + switch (type) { + case Cdma: + typeString = QLatin1String(NM_SETTING_CDMA_SETTING_NAME); + break; + case Gsm: + typeString = QLatin1String(NM_SETTING_GSM_SETTING_NAME); + break; + case Ipv4: + typeString = QLatin1String(NM_SETTING_IP4_CONFIG_SETTING_NAME); + break; + case Ppp: + typeString = QLatin1String(NM_SETTING_PPP_SETTING_NAME); + break; + case Pppoe: + typeString = QLatin1String(NM_SETTING_PPPOE_SETTING_NAME); + break; + case Security8021x: + typeString = QLatin1String(NM_SETTING_802_1X_SETTING_NAME); + break; + case Serial: + typeString = QLatin1String(NM_SETTING_SERIAL_SETTING_NAME); + break; + case Vpn: + typeString = QLatin1String(NM_SETTING_VPN_SETTING_NAME); + break; + case Wired: + typeString = QLatin1String(NM_SETTING_WIRED_SETTING_NAME); + break; + case Wireless: + typeString = QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME); + break; + case WirelessSecurity: + typeString = QLatin1String(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); + break; + default: + break; + } + return typeString; +} + +Setting::Type Setting::typeFromString(const QString & typeString) +{ + Setting::Type type = Wired; + if (typeString == QLatin1String(NM_SETTING_CDMA_SETTING_NAME)) { + type = Cdma; + } else if (typeString == QLatin1String(NM_SETTING_GSM_SETTING_NAME)) { + type = Gsm; + } else if (typeString == QLatin1String(NM_SETTING_IP4_CONFIG_SETTING_NAME)) { + type = Ipv4; + } else if (typeString == QLatin1String(NM_SETTING_PPP_SETTING_NAME)) { + type = Ppp; + } else if (typeString == QLatin1String(NM_SETTING_PPPOE_SETTING_NAME)) { + type = Pppoe; + } else if (typeString == QLatin1String(NM_SETTING_SERIAL_SETTING_NAME)) { + type = Serial; + } else if (typeString == QLatin1String(NM_SETTING_802_1X_SETTING_NAME)) { + type = Security8021x; + } else if (typeString == QLatin1String(NM_SETTING_VPN_SETTING_NAME)) { + type = Vpn; + } else if (typeString == QLatin1String(NM_SETTING_WIRED_SETTING_NAME)) { + type = Wired; + } else if (typeString == QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME)) { + type = Wireless; + } else if (typeString == QLatin1String(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME)) { + type = WirelessSecurity; + } + return type; +} + +Setting::Setting(Setting::Type type) + : m_type(type), m_secretsAvailable(false) +{ + +} + +Setting::~Setting() +{ + +} + +Setting::Type Setting::type() const +{ + return m_type; +} + +bool Setting::secretsAvailable() const +{ + return m_secretsAvailable; +} + +void Setting::setSecretsAvailable(bool available) +{ + m_secretsAvailable = available; +} + +// vim: sw=4 sts=4 et tw=100 Index: libs/internals/unconfiguredinterface.h =================================================================== --- libs/internals/unconfiguredinterface.h (revision 0) +++ libs/internals/unconfiguredinterface.h (revision 1010672) @@ -0,0 +1,41 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#ifndef KNM_INTERNALS_UNCONFIGUREDINTERFACE_H +#define KNM_INTERNALS_UNCONFIGUREDINTERFACE_H + + +#include "activatable.h" + +#include "knminternals_export.h" + +namespace Knm { + +class KNMINTERNALS_EXPORT UnconfiguredInterface : public Activatable +{ +Q_OBJECT +public: + UnconfiguredInterface(const QString & deviceUni, QObject * parent); + virtual ~UnconfiguredInterface(); +}; + +} + +#endif // KNM_INTERNALS_UNCONFIGUREDINTERFACE_H Index: libs/internals/settings/ppp.cpp =================================================================== --- libs/internals/settings/ppp.cpp (revision 0) +++ libs/internals/settings/ppp.cpp (revision 1010672) @@ -0,0 +1,23 @@ +// This file is generated by kconfig_compiler from ppp.kcfg. +// All changes you do to this file will be lost. + +#include "ppp.h" + +using namespace Knm; + +PppSetting::PppSetting() : Setting(Setting::Ppp), mNoauth(false), mRefuseeap(false), mRefusepap(false), mRefusechap(false), mRefusemschap(false), mRefusemschapv2(false), mNobsdcomp(false), mNodeflate(false), mNovjcomp(false), mRequiremppe(false), mRequiremppe128(false), mMppestateful(false), mCrtscts(false), mBaud(0), mMru(0), mMtu(0), mLcpechofailure(0), mLcpechointerval(0) +{ +} + +PppSetting::~PppSetting() +{ +} + +QString PppSetting::name() const +{ + return QLatin1String("ppp"); +} +bool PppSetting::hasSecrets() const +{ + return false; +} Index: libs/internals/settings/802-1x.cpp =================================================================== --- libs/internals/settings/802-1x.cpp (revision 0) +++ libs/internals/settings/802-1x.cpp (revision 1010672) @@ -0,0 +1,36 @@ +// This file is generated by kconfig_compiler from 802-1x.kcfg. +// All changes you do to this file will be lost. + +#include "802-1x.h" + +using namespace Knm; + +Security8021xSetting::Security8021xSetting() : Setting(Setting::Security8021x), + mPhase1peapver(0), mPhase2auth(0), mPhase2autheap(0), mEnabled(false) +{ +} + +Security8021xSetting::~Security8021xSetting() +{ +} + +QString Security8021xSetting::name() const +{ + return QLatin1String("802-1x"); +} +bool Security8021xSetting::hasSecrets() const +{ + return true; +} + + +QByteArray Security8021xSetting::getBytes(const QString & fileName) +{ + QByteArray bytes; + QFile file(fileName); + + if (file.open(QIODevice::ReadOnly)) { + bytes = file.readAll(); + } + return bytes; +} Index: libs/internals/settings/802-3-ethernetpersistence.h =================================================================== --- libs/internals/settings/802-3-ethernetpersistence.h (revision 0) +++ libs/internals/settings/802-3-ethernetpersistence.h (revision 1010672) @@ -0,0 +1,27 @@ +// This file is generated by kconfig_compiler from 802-3-ethernet.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_WIREDPERSISTENCE_H +#define KNM_WIREDPERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +namespace Knm { + +class WiredSetting; + +class KNMINTERNALS_EXPORT WiredPersistence : public SettingPersistence +{ + public: + WiredPersistence( WiredSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~WiredPersistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; +}; +} + +#endif + Index: libs/internals/settings/vpn.cpp =================================================================== --- libs/internals/settings/vpn.cpp (revision 0) +++ libs/internals/settings/vpn.cpp (revision 1010672) @@ -0,0 +1,23 @@ +// This file is generated by kconfig_compiler from vpn.kcfg. +// All changes you do to this file will be lost. + +#include "vpn.h" + +using namespace Knm; + +VpnSetting::VpnSetting() : Setting(Setting::Vpn) +{ +} + +VpnSetting::~VpnSetting() +{ +} + +QString VpnSetting::name() const +{ + return QLatin1String("vpn"); +} +bool VpnSetting::hasSecrets() const +{ + return true; +} Index: libs/internals/settings/cdma.cpp =================================================================== --- libs/internals/settings/cdma.cpp (revision 0) +++ libs/internals/settings/cdma.cpp (revision 1010672) @@ -0,0 +1,23 @@ +// This file is generated by kconfig_compiler from cdma.kcfg. +// All changes you do to this file will be lost. + +#include "cdma.h" + +using namespace Knm; + +CdmaSetting::CdmaSetting() : Setting(Setting::Cdma) +{ +} + +CdmaSetting::~CdmaSetting() +{ +} + +QString CdmaSetting::name() const +{ + return QLatin1String("cdma"); +} +bool CdmaSetting::hasSecrets() const +{ + return true; +} Index: libs/internals/settings/802-1xpersistence.cpp =================================================================== --- libs/internals/settings/802-1xpersistence.cpp (revision 0) +++ libs/internals/settings/802-1xpersistence.cpp (revision 1010672) @@ -0,0 +1,220 @@ +// This file is generated by kconfig_compiler from 802-1x.kcfg. +// All changes you do to this file will be lost. + +#include "802-1xpersistence.h" + +#include "802-1x.h" + +using namespace Knm; + +Security8021xPersistence::Security8021xPersistence(Security8021xSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +Security8021xPersistence::~Security8021xPersistence() +{ +} + +void Security8021xPersistence::load() +{ + if (m_config->exists()) { + Security8021xSetting * setting = static_cast(m_setting); + setting->setEnabled(true); + setting->setEap(m_config->readEntry("eap", QStringList())); + setting->setIdentity(m_config->readEntry("identity", "")); + setting->setAnonymousidentity(m_config->readEntry("anonymousidentity", "")); + setting->setCacert(m_config->readEntry("cacert", QByteArray())); + setting->setCapath(m_config->readEntry("capath", "")); + setting->setClientcert(m_config->readEntry("clientcert", QByteArray())); + setting->setClientcertpath(m_config->readEntry("clientcertpath", "")); + { + QString contents = m_config->readEntry("phase1peapver", "automatic"); + if (contents == "automatic") + setting->setPhase1peapver(Security8021xSetting::EnumPhase1peapver::automatic); + if (contents == "zero") + setting->setPhase1peapver(Security8021xSetting::EnumPhase1peapver::zero); + else if (contents == "one") + setting->setPhase1peapver(Security8021xSetting::EnumPhase1peapver::one); + + } + setting->setPhase1peaplabel(m_config->readEntry("phase1peaplabel", "")); + setting->setPhase1fastprovisioning(m_config->readEntry("phase1fastprovisioning", "")); + { + QString contents = m_config->readEntry("phase2auth", "none"); + if (contents == "none") + setting->setPhase2auth(Security8021xSetting::EnumPhase2auth::none); + else if (contents == "pap") + setting->setPhase2auth(Security8021xSetting::EnumPhase2auth::pap); + else if (contents == "mschap") + setting->setPhase2auth(Security8021xSetting::EnumPhase2auth::mschap); + else if (contents == "mschapv2") + setting->setPhase2auth(Security8021xSetting::EnumPhase2auth::mschapv2); + else if (contents == "chap") + setting->setPhase2auth(Security8021xSetting::EnumPhase2auth::chap); + else if (contents == "md5") + setting->setPhase2auth(Security8021xSetting::EnumPhase2auth::md5); + else if (contents == "gtc") + setting->setPhase2auth(Security8021xSetting::EnumPhase2auth::gtc); + else if (contents == "otp") + setting->setPhase2auth(Security8021xSetting::EnumPhase2auth::otp); + + } + { + QString contents = m_config->readEntry("phase2autheap", "none"); + if (contents == "none") + setting->setPhase2autheap(Security8021xSetting::EnumPhase2autheap::none); + else if (contents == "md5") + setting->setPhase2autheap(Security8021xSetting::EnumPhase2autheap::md5); + else if (contents == "gtc") + setting->setPhase2autheap(Security8021xSetting::EnumPhase2autheap::gtc); + else if (contents == "otp") + setting->setPhase2autheap(Security8021xSetting::EnumPhase2autheap::otp); + else if (contents == "mschapv2") + setting->setPhase2autheap(Security8021xSetting::EnumPhase2autheap::mschapv2); + else if (contents == "tls") + setting->setPhase2autheap(Security8021xSetting::EnumPhase2autheap::tls); + + } + setting->setPhase2cacert(m_config->readEntry("phase2cacert", QByteArray())); + setting->setPhase2capath(m_config->readEntry("phase2capath", "")); + setting->setPhase2clientcert(m_config->readEntry("phase2clientcert", QByteArray())); + setting->setPhase2clientcertpath(m_config->readEntry("phase2clientcertpath", "")); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setPassword(m_config->readEntry("password", "")); + } + setting->setPrivatekey(m_config->readEntry("privatekey", QByteArray())); + setting->setPrivatekeypath(m_config->readEntry("privatekeypath", "")); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setPrivatekeypassword(m_config->readEntry("privatekeypassword", "")); + } + setting->setPhase2privatekey(m_config->readEntry("phase2privatekey", QByteArray())); + setting->setPhase2privatekeypath(m_config->readEntry("phase2privatekeypath", "")); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setPhase2privatekeypassword(m_config->readEntry("phase2privatekeypassword", "")); + } + setting->setPin(m_config->readEntry("pin", "")); + setting->setPsk(m_config->readEntry("psk", "")); + setting->setUseSystemCaCerts(m_config->readEntry("UseSystemCaCerts", false)); + } +} + +void Security8021xPersistence::save() +{ + Security8021xSetting * setting = static_cast(m_setting); + if (setting->enabled() ) { + m_config->writeEntry("eap", setting->eap()); + m_config->writeEntry("identity", setting->identity()); + m_config->writeEntry("anonymousidentity", setting->anonymousidentity()); + m_config->writeEntry("cacert", setting->cacert()); + m_config->writeEntry("capath", setting->capath()); + m_config->writeEntry("clientcert", setting->clientcert()); + m_config->writeEntry("clientcertpath", setting->clientcertpath()); + switch (setting->phase1peapver()) { + case Security8021xSetting::EnumPhase1peapver::automatic: + m_config->writeEntry("phase1peapver", "automatic"); + break; + case Security8021xSetting::EnumPhase1peapver::zero: + m_config->writeEntry("phase1peapver", "zero"); + break; + case Security8021xSetting::EnumPhase1peapver::one: + m_config->writeEntry("phase1peapver", "one"); + break; + } + m_config->writeEntry("phase1peaplabel", setting->phase1peaplabel()); + m_config->writeEntry("phase1fastprovisioning", setting->phase1fastprovisioning()); + switch (setting->phase2auth()) { + case Security8021xSetting::EnumPhase2auth::none: + m_config->writeEntry("phase2auth", "none"); + break; + case Security8021xSetting::EnumPhase2auth::pap: + m_config->writeEntry("phase2auth", "pap"); + break; + case Security8021xSetting::EnumPhase2auth::mschap: + m_config->writeEntry("phase2auth", "mschap"); + break; + case Security8021xSetting::EnumPhase2auth::mschapv2: + m_config->writeEntry("phase2auth", "mschapv2"); + break; + case Security8021xSetting::EnumPhase2auth::chap: + m_config->writeEntry("phase2auth", "chap"); + break; + case Security8021xSetting::EnumPhase2auth::md5: + m_config->writeEntry("phase2auth", "md5"); + break; + case Security8021xSetting::EnumPhase2auth::gtc: + m_config->writeEntry("phase2auth", "gtc"); + break; + case Security8021xSetting::EnumPhase2auth::otp: + m_config->writeEntry("phase2auth", "otp"); + break; + } + switch (setting->phase2autheap()) { + case Security8021xSetting::EnumPhase2autheap::none: + m_config->writeEntry("phase2autheap", "none"); + break; + case Security8021xSetting::EnumPhase2autheap::md5: + m_config->writeEntry("phase2autheap", "md5"); + break; + case Security8021xSetting::EnumPhase2autheap::gtc: + m_config->writeEntry("phase2autheap", "gtc"); + break; + case Security8021xSetting::EnumPhase2autheap::otp: + m_config->writeEntry("phase2autheap", "otp"); + break; + case Security8021xSetting::EnumPhase2autheap::mschapv2: + m_config->writeEntry("phase2autheap", "mschapv2"); + break; + case Security8021xSetting::EnumPhase2autheap::tls: + m_config->writeEntry("phase2autheap", "tls"); + break; + } + m_config->writeEntry("phase2cacert", setting->phase2cacert()); + m_config->writeEntry("phase2capath", setting->phase2capath()); + m_config->writeEntry("phase2clientcert", setting->phase2clientcert()); + m_config->writeEntry("phase2clientcertpath", setting->phase2clientcertpath()); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("password", setting->password()); + } + m_config->writeEntry("privatekey", setting->privatekey()); + m_config->writeEntry("privatekeypath", setting->privatekeypath()); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("privatekeypassword", setting->privatekeypassword()); + } + m_config->writeEntry("phase2privatekey", setting->phase2privatekey()); + m_config->writeEntry("phase2privatekeypath", setting->phase2privatekeypath()); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("phase2privatekeypassword", setting->phase2privatekeypassword()); + } + m_config->writeEntry("pin", setting->pin()); + m_config->writeEntry("psk", setting->psk()); + m_config->writeEntry("UseSystemCaCerts", setting->useSystemCaCerts()); + } else + m_config->deleteGroup(); +} + +QMap Security8021xPersistence::secrets() const +{ + Security8021xSetting * setting = static_cast(m_setting); + QMap map; + map.insert(QLatin1String("password"), setting->password()); + map.insert(QLatin1String("privatekeypassword"), setting->privatekeypassword()); + map.insert(QLatin1String("phase2privatekeypassword"), setting->phase2privatekeypassword()); + return map; +} + +void Security8021xPersistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + Security8021xSetting * setting = static_cast(m_setting); + setting->setPassword(secrets.value("password")); + setting->setPrivatekeypassword(secrets.value("privatekeypassword")); + setting->setPhase2privatekeypassword(secrets.value("phase2privatekeypassword")); + setting->setSecretsAvailable(true); + } +} Index: libs/internals/settings/ppppersistence.cpp =================================================================== --- libs/internals/settings/ppppersistence.cpp (revision 0) +++ libs/internals/settings/ppppersistence.cpp (revision 1010672) @@ -0,0 +1,75 @@ +// This file is generated by kconfig_compiler from ppp.kcfg. +// All changes you do to this file will be lost. + +#include "ppppersistence.h" + +#include "ppp.h" + +using namespace Knm; + +PppPersistence::PppPersistence(PppSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +PppPersistence::~PppPersistence() +{ +} + +void PppPersistence::load() +{ + PppSetting * setting = static_cast(m_setting); + setting->setNoauth(m_config->readEntry("noauth", false)); + setting->setRefuseeap(m_config->readEntry("refuseeap", false)); + setting->setRefusepap(m_config->readEntry("refusepap", false)); + setting->setRefusechap(m_config->readEntry("refusechap", false)); + setting->setRefusemschap(m_config->readEntry("refusemschap", false)); + setting->setRefusemschapv2(m_config->readEntry("refusemschapv2", false)); + setting->setNobsdcomp(m_config->readEntry("nobsdcomp", false)); + setting->setNodeflate(m_config->readEntry("nodeflate", false)); + setting->setNovjcomp(m_config->readEntry("novjcomp", false)); + setting->setRequiremppe(m_config->readEntry("requiremppe", false)); + setting->setRequiremppe128(m_config->readEntry("requiremppe128", false)); + setting->setMppestateful(m_config->readEntry("mppestateful", false)); + setting->setCrtscts(m_config->readEntry("crtscts", false)); + setting->setBaud(m_config->readEntry("baud", 0)); + setting->setMru(m_config->readEntry("mru", 0)); + setting->setMtu(m_config->readEntry("mtu", 0)); + setting->setLcpechofailure(m_config->readEntry("lcpechofailure", 0)); + setting->setLcpechointerval(m_config->readEntry("lcpechointerval", 0)); +} + +void PppPersistence::save() +{ + PppSetting * setting = static_cast(m_setting); + m_config->writeEntry("noauth", setting->noauth()); + m_config->writeEntry("refuseeap", setting->refuseeap()); + m_config->writeEntry("refusepap", setting->refusepap()); + m_config->writeEntry("refusechap", setting->refusechap()); + m_config->writeEntry("refusemschap", setting->refusemschap()); + m_config->writeEntry("refusemschapv2", setting->refusemschapv2()); + m_config->writeEntry("nobsdcomp", setting->nobsdcomp()); + m_config->writeEntry("nodeflate", setting->nodeflate()); + m_config->writeEntry("novjcomp", setting->novjcomp()); + m_config->writeEntry("requiremppe", setting->requiremppe()); + m_config->writeEntry("requiremppe128", setting->requiremppe128()); + m_config->writeEntry("mppestateful", setting->mppestateful()); + m_config->writeEntry("crtscts", setting->crtscts()); + m_config->writeEntry("baud", setting->baud()); + m_config->writeEntry("mru", setting->mru()); + m_config->writeEntry("mtu", setting->mtu()); + m_config->writeEntry("lcpechofailure", setting->lcpechofailure()); + m_config->writeEntry("lcpechointerval", setting->lcpechointerval()); +} + +QMap PppPersistence::secrets() const +{ + QMap map; + return map; +} + +void PppPersistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + Q_UNUSED(secrets); + } +} Index: libs/internals/settings/wephash.h =================================================================== --- libs/internals/settings/wephash.h (revision 0) +++ libs/internals/settings/wephash.h (revision 1010672) @@ -0,0 +1,29 @@ +/* This file is part of the KDE project + Copyright (C) 2008 Christopher Blauvelt + + Based on code from Dan Williams + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ + +#ifndef WEP_HASH_H +#define WEP_HASH_H + +class QByteArray; + +QByteArray wep128PassphraseHash(QByteArray input); + +#endif Property changes on: libs/internals/settings/wephash.h ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/settings/pbkdf2.cpp =================================================================== --- libs/internals/settings/pbkdf2.cpp (revision 0) +++ libs/internals/settings/pbkdf2.cpp (revision 1010672) @@ -0,0 +1,692 @@ +/* + * SHA1 hash implementation and interface functions + * Copyright (c) 2003-2005, Jouni Malinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Alternatively, this software may be distributed under the terms of BSD + * license. + * + * See README and COPYING for more details. + */ + +#include +#include + +#include "pbkdf2.h" + +#include "config-knmstorage.h" + +/* Define types for stupid code. Userspace should + * be using u_*_t rather than kernel-space u* types. + */ +typedef u_int8_t u8; +typedef u_int16_t u16; +typedef u_int32_t u32; +typedef u_int64_t u64; + +void sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac); +void sha1_transform(u8 *state, const u8 data[64]); + +void sha1_mac(const u8 *key, size_t key_len, const u8 *data, size_t data_len, + u8 *mac) +{ + const u8 *addr[3]; + size_t len[3]; + addr[0] = key; + len[0] = key_len; + addr[1] = data; + len[1] = data_len; + addr[2] = key; + len[2] = key_len; + sha1_vector(3, addr, len, mac); +} + + +/* HMAC code is based on RFC 2104 */ +void hmac_sha1_vector(const u8 *key, size_t key_len, size_t num_elem, + const u8 *addr[], const size_t *len, u8 *mac) +{ + unsigned char k_pad[64]; /* padding - key XORd with ipad/opad */ + unsigned char tk[20]; + const u8 *_addr[6]; + size_t _len[6], i; + + if (num_elem > 5) { + /* + * Fixed limit on the number of fragments to avoid having to + * allocate memory (which could fail). + */ + return; + } + + /* if key is longer than 64 bytes reset it to key = SHA1(key) */ + if (key_len > 64) { + sha1_vector(1, &key, &key_len, tk); + key = tk; + key_len = 20; + } + + /* the HMAC_SHA1 transform looks like: + * + * SHA1(K XOR opad, SHA1(K XOR ipad, text)) + * + * where K is an n byte key + * ipad is the byte 0x36 repeated 64 times + * opad is the byte 0x5c repeated 64 times + * and text is the data being protected */ + + /* start out by storing key in ipad */ + memset(k_pad, 0, sizeof(k_pad)); + memcpy(k_pad, key, key_len); + /* XOR key with ipad values */ + for (i = 0; i < 64; i++) + k_pad[i] ^= 0x36; + + /* perform inner SHA1 */ + _addr[0] = k_pad; + _len[0] = 64; + for (i = 0; i < num_elem; i++) { + _addr[i + 1] = addr[i]; + _len[i + 1] = len[i]; + } + sha1_vector(1 + num_elem, _addr, _len, mac); + + memset(k_pad, 0, sizeof(k_pad)); + memcpy(k_pad, key, key_len); + /* XOR key with opad values */ + for (i = 0; i < 64; i++) + k_pad[i] ^= 0x5c; + + /* perform outer SHA1 */ + _addr[0] = k_pad; + _len[0] = 64; + _addr[1] = mac; + _len[1] = SHA1_MAC_LEN; + sha1_vector(2, _addr, _len, mac); +} + + +void hmac_sha1(const u8 *key, size_t key_len, const u8 *data, size_t data_len, + u8 *mac) +{ + hmac_sha1_vector(key, key_len, 1, &data, &data_len, mac); +} + + +void sha1_prf(const u8 *key, size_t key_len, const char *label, + const u8 *data, size_t data_len, u8 *buf, size_t buf_len) +{ + u8 zero = 0, counter = 0; + size_t pos, plen; + u8 hash[SHA1_MAC_LEN]; + size_t label_len = strlen(label); + const unsigned char *addr[4]; + size_t len[4]; + + addr[0] = (u8 *) label; + len[0] = label_len; + addr[1] = &zero; + len[1] = 1; + addr[2] = data; + len[2] = data_len; + addr[3] = &counter; + len[3] = 1; + + pos = 0; + while (pos < buf_len) { + plen = buf_len - pos; + if (plen >= SHA1_MAC_LEN) { + hmac_sha1_vector(key, key_len, 4, addr, len, + &buf[pos]); + pos += SHA1_MAC_LEN; + } else { + hmac_sha1_vector(key, key_len, 4, addr, len, + hash); + memcpy(&buf[pos], hash, plen); + break; + } + counter++; + } +} + + +static void pbkdf2_sha1_f(const char *passphrase, const char *ssid, + size_t ssid_len, int iterations, int count, + u8 *digest) +{ + unsigned char tmp[SHA1_MAC_LEN], tmp2[SHA1_MAC_LEN]; + int i, j; + unsigned char count_buf[4]; + const u8 *addr[2]; + size_t len[2]; + size_t passphrase_len = strlen(passphrase); + + addr[0] = (u8 *) ssid; + len[0] = ssid_len; + addr[1] = count_buf; + len[1] = 4; + + /* F(P, S, c, i) = U1 xor U2 xor ... Uc + * U1 = PRF(P, S || i) + * U2 = PRF(P, U1) + * Uc = PRF(P, Uc-1) + */ + + count_buf[0] = (count >> 24) & 0xff; + count_buf[1] = (count >> 16) & 0xff; + count_buf[2] = (count >> 8) & 0xff; + count_buf[3] = count & 0xff; + hmac_sha1_vector((u8 *) passphrase, passphrase_len, 2, addr, len, tmp); + memcpy(digest, tmp, SHA1_MAC_LEN); + + for (i = 1; i < iterations; i++) { + hmac_sha1((u8 *) passphrase, passphrase_len, tmp, SHA1_MAC_LEN, + tmp2); + memcpy(tmp, tmp2, SHA1_MAC_LEN); + for (j = 0; j < SHA1_MAC_LEN; j++) + digest[j] ^= tmp2[j]; + } +} + + +void pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, + int iterations, u8 *buf, size_t buflen) +{ + int count = 0; + unsigned char *pos = buf; + size_t left = buflen; + size_t plen; + unsigned char digest[SHA1_MAC_LEN]; + + while (left > 0) { + count++; + pbkdf2_sha1_f(passphrase, ssid, ssid_len, iterations, count, + digest); + plen = left > SHA1_MAC_LEN ? SHA1_MAC_LEN : left; + memcpy(pos, digest, plen); + pos += plen; + left -= plen; + } +} + + +#ifndef EAP_TLS_FUNCS + +typedef struct { + u32 state[5]; + u32 count[2]; + unsigned char buffer[64]; +} SHA1_CTX; + +static void SHA1Init(SHA1_CTX *context); +static void SHA1Update(SHA1_CTX *context, const void *data, u32 len); +static void SHA1Final(unsigned char digest[20], SHA1_CTX* context); +static void SHA1Transform(u32 state[5], const unsigned char buffer[64]); + + +/** + * sha1_vector - SHA-1 hash for data vector + * @num_elem: Number of elements in the data vector + * @addr: Pointers to the data areas + * @len: Lengths of the data blocks + * @mac: Buffer for the hash + */ +void sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len, + u8 *mac) +{ + SHA1_CTX ctx; + size_t i; + + SHA1Init(&ctx); + for (i = 0; i < num_elem; i++) + SHA1Update(&ctx, addr[i], len[i]); + SHA1Final(mac, &ctx); +} + + +/** + * sha1_transform - Perform one SHA-1 transform step + * @state: SHA-1 state + * @data: Input data for the SHA-1 transform + * + * This function is used to implement random number generation specified in + * NIST FIPS Publication 186-2 for EAP-SIM. This PRF uses a function that is + * similar to SHA-1, but has different message padding and as such, access to + * just part of the SHA-1 is needed. + */ +void sha1_transform(u8 *state, const u8 data[64]) +{ + SHA1Transform((u32 *) state, data); +} + + +/* ===== start - public domain SHA1 implementation ===== */ + +/* +SHA-1 in C +By Steve Reid +100% Public Domain + +----------------- +Modified 7/98 +By James H. Brown +Still 100% Public Domain + +Corrected a problem which generated improper hash values on 16 bit machines +Routine SHA1Update changed from + void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int +len) +to + void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned +long len) + +The 'len' parameter was declared an int which works fine on 32 bit machines. +However, on 16 bit machines an int is too small for the shifts being done +against +it. This caused the hash function to generate incorrect values if len was +greater than 8191 (8K - 1) due to the 'len << 3' on line 3 of SHA1Update(). + +Since the file IO in main() reads 16K at a time, any file 8K or larger would +be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million +"a"s). + +I also changed the declaration of variables i & j in SHA1Update to +unsigned long from unsigned int for the same reason. + +These changes should make no difference to any 32 bit implementations since +an +int and a long are the same size in those environments. + +-- +I also corrected a few compiler warnings generated by Borland C. +1. Added #include for exit() prototype +2. Removed unused variable 'j' in SHA1Final +3. Changed exit(0) to return(0) at end of main. + +ALL changes I made can be located by searching for comments containing 'JHB' +----------------- +Modified 8/98 +By Steve Reid +Still 100% public domain + +1- Removed #include and used return() instead of exit() +2- Fixed overwriting of finalcount in SHA1Final() (discovered by Chris Hall) +3- Changed email address from steve@edmweb.com to sreid@sea-to-sky.net + +----------------- +Modified 4/01 +By Saul Kravitz +Still 100% PD +Modified to run on Compaq Alpha hardware. + +----------------- +Modified 4/01 +By Jouni Malinen +Minor changes to match the coding style used in Dynamics. + +Modified September 24, 2004 +By Jouni Malinen +Fixed alignment issue in SHA1Transform when SHA1HANDSOFF is defined. + +*/ + +/* +Test Vectors (from FIPS PUB 180-1) +"abc" + A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D +"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" + 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 +A million repetitions of "a" + 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F +*/ + +#define SHA1HANDSOFF + +#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) + +/* blk0() and blk() perform the initial expand. */ +/* I got the idea of expanding during the round function from SSLeay */ +#ifndef WORDS_BIGENDIAN +#define blk0(i) (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | \ + (rol(block->l[i], 8) & 0x00FF00FF)) +#else +#define blk0(i) block->l[i] +#endif +#define blk(i) (block->l[i & 15] = rol(block->l[(i + 13) & 15] ^ \ + block->l[(i + 8) & 15] ^ block->l[(i + 2) & 15] ^ block->l[i & 15], 1)) + +/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ +#define R0(v,w,x,y,z,i) \ + z += ((w & (x ^ y)) ^ y) + blk0(i) + 0x5A827999 + rol(v, 5); \ + w = rol(w, 30); +#define R1(v,w,x,y,z,i) \ + z += ((w & (x ^ y)) ^ y) + blk(i) + 0x5A827999 + rol(v, 5); \ + w = rol(w, 30); +#define R2(v,w,x,y,z,i) \ + z += (w ^ x ^ y) + blk(i) + 0x6ED9EBA1 + rol(v, 5); w = rol(w, 30); +#define R3(v,w,x,y,z,i) \ + z += (((w | x) & y) | (w & x)) + blk(i) + 0x8F1BBCDC + rol(v, 5); \ + w = rol(w, 30); +#define R4(v,w,x,y,z,i) \ + z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \ + w=rol(w, 30); + + +#ifdef VERBOSE /* SAK */ +void SHAPrintContext(SHA1_CTX *context, char *msg) +{ + printf("%s (%d,%d) %x %x %x %x %x\n", + msg, + context->count[0], context->count[1], + context->state[0], + context->state[1], + context->state[2], + context->state[3], + context->state[4]); +} +#endif + +/* Hash a single 512-bit block. This is the core of the algorithm. */ + +void SHA1Transform(u32 state[5], const unsigned char buffer[64]) +{ + u32 a, b, c, d, e; + typedef union { + unsigned char c[64]; + u32 l[16]; + } CHAR64LONG16; + CHAR64LONG16* block; +#ifdef SHA1HANDSOFF + u32 workspace[16]; + block = (CHAR64LONG16 *) workspace; + memcpy(block, buffer, 64); +#else + block = (CHAR64LONG16 *) buffer; +#endif + /* Copy context->state[] to working vars */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + /* 4 rounds of 20 operations each. Loop unrolled. */ + R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); + R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); + R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); + R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); + R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); + R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); + R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); + R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); + R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); + R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); + R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); + R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); + R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); + R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); + R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); + R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); + R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); + R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); + R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); + R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); + /* Add the working vars back into context.state[] */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + /* Wipe variables */ + a = b = c = d = e = 0; +#ifdef SHA1HANDSOFF + memset(block, 0, 64); +#endif +} + + +/* SHA1Init - Initialize new context */ + +static void SHA1Init(SHA1_CTX* context) +{ + /* SHA1 initialization constants */ + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; + context->count[0] = context->count[1] = 0; +} + + +/* Run your data through this. */ + +static void SHA1Update(SHA1_CTX* context, const void *_data, u32 len) +{ + u32 i, j; + const unsigned char *data = (const unsigned char*) _data; + +#ifdef VERBOSE + SHAPrintContext(context, "before"); +#endif + j = (context->count[0] >> 3) & 63; + if ((context->count[0] += len << 3) < (len << 3)) + context->count[1]++; + context->count[1] += (len >> 29); + if ((j + len) > 63) { + memcpy(&context->buffer[j], data, (i = 64-j)); + SHA1Transform(context->state, context->buffer); + for ( ; i + 63 < len; i += 64) { + SHA1Transform(context->state, &data[i]); + } + j = 0; + } + else i = 0; + memcpy(&context->buffer[j], &data[i], len - i); +#ifdef VERBOSE + SHAPrintContext(context, "after "); +#endif +} + + +/* Add padding and return the message digest. */ + +static void SHA1Final(unsigned char digest[20], SHA1_CTX* context) +{ + u32 i; + unsigned char finalcount[8]; + + for (i = 0; i < 8; i++) { + finalcount[i] = (unsigned char) + ((context->count[(i >= 4 ? 0 : 1)] >> + ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ + } + SHA1Update(context, (unsigned char *) "\200", 1); + while ((context->count[0] & 504) != 448) { + SHA1Update(context, (unsigned char *) "\0", 1); + } + SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() + */ + for (i = 0; i < 20; i++) { + digest[i] = (unsigned char) + ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & + 255); + } + /* Wipe variables */ + i = 0; + memset(context->buffer, 0, 64); + memset(context->state, 0, 20); + memset(context->count, 0, 8); + memset(finalcount, 0, 8); +} + +/* ===== end - public domain SHA1 implementation ===== */ + +#endif /* EAP_TLS_FUNCS */ + + +#ifdef TEST_MAIN + +static u8 key0[] = +{ + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b +}; +static u8 data0[] = "Hi There"; +static u8 prf0[] = +{ + 0xbc, 0xd4, 0xc6, 0x50, 0xb3, 0x0b, 0x96, 0x84, + 0x95, 0x18, 0x29, 0xe0, 0xd7, 0x5f, 0x9d, 0x54, + 0xb8, 0x62, 0x17, 0x5e, 0xd9, 0xf0, 0x06, 0x06, + 0xe1, 0x7d, 0x8d, 0xa3, 0x54, 0x02, 0xff, 0xee, + 0x75, 0xdf, 0x78, 0xc3, 0xd3, 0x1e, 0x0f, 0x88, + 0x9f, 0x01, 0x21, 0x20, 0xc0, 0x86, 0x2b, 0xeb, + 0x67, 0x75, 0x3e, 0x74, 0x39, 0xae, 0x24, 0x2e, + 0xdb, 0x83, 0x73, 0x69, 0x83, 0x56, 0xcf, 0x5a +}; + +static u8 key1[] = "Jefe"; +static u8 data1[] = "what do ya want for nothing?"; +static u8 prf1[] = +{ + 0x51, 0xf4, 0xde, 0x5b, 0x33, 0xf2, 0x49, 0xad, + 0xf8, 0x1a, 0xeb, 0x71, 0x3a, 0x3c, 0x20, 0xf4, + 0xfe, 0x63, 0x14, 0x46, 0xfa, 0xbd, 0xfa, 0x58, + 0x24, 0x47, 0x59, 0xae, 0x58, 0xef, 0x90, 0x09, + 0xa9, 0x9a, 0xbf, 0x4e, 0xac, 0x2c, 0xa5, 0xfa, + 0x87, 0xe6, 0x92, 0xc4, 0x40, 0xeb, 0x40, 0x02, + 0x3e, 0x7b, 0xab, 0xb2, 0x06, 0xd6, 0x1d, 0xe7, + 0xb9, 0x2f, 0x41, 0x52, 0x90, 0x92, 0xb8, 0xfc +}; + + +static u8 key2[] = +{ + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa +}; +static u8 data2[] = +{ + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd +}; +static u8 prf2[] = +{ + 0xe1, 0xac, 0x54, 0x6e, 0xc4, 0xcb, 0x63, 0x6f, + 0x99, 0x76, 0x48, 0x7b, 0xe5, 0xc8, 0x6b, 0xe1, + 0x7a, 0x02, 0x52, 0xca, 0x5d, 0x8d, 0x8d, 0xf1, + 0x2c, 0xfb, 0x04, 0x73, 0x52, 0x52, 0x49, 0xce, + 0x9d, 0xd8, 0xd1, 0x77, 0xea, 0xd7, 0x10, 0xbc, + 0x9b, 0x59, 0x05, 0x47, 0x23, 0x91, 0x07, 0xae, + 0xf7, 0xb4, 0xab, 0xd4, 0x3d, 0x87, 0xf0, 0xa6, + 0x8f, 0x1c, 0xbd, 0x9e, 0x2b, 0x6f, 0x76, 0x07 +}; + + +struct passphrase_test { + char *passphrase; + char *ssid; + char psk[32]; +}; + +static struct passphrase_test passphrase_tests[] = +{ + { + "password", + "IEEE", + { + 0xf4, 0x2c, 0x6f, 0xc5, 0x2d, 0xf0, 0xeb, 0xef, + 0x9e, 0xbb, 0x4b, 0x90, 0xb3, 0x8a, 0x5f, 0x90, + 0x2e, 0x83, 0xfe, 0x1b, 0x13, 0x5a, 0x70, 0xe2, + 0x3a, 0xed, 0x76, 0x2e, 0x97, 0x10, 0xa1, 0x2e + } + }, + { + "ThisIsAPassword", + "ThisIsASSID", + { + 0x0d, 0xc0, 0xd6, 0xeb, 0x90, 0x55, 0x5e, 0xd6, + 0x41, 0x97, 0x56, 0xb9, 0xa1, 0x5e, 0xc3, 0xe3, + 0x20, 0x9b, 0x63, 0xdf, 0x70, 0x7d, 0xd5, 0x08, + 0xd1, 0x45, 0x81, 0xf8, 0x98, 0x27, 0x21, 0xaf + } + }, + { + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ", + { + 0xbe, 0xcb, 0x93, 0x86, 0x6b, 0xb8, 0xc3, 0x83, + 0x2c, 0xb7, 0x77, 0xc2, 0xf5, 0x59, 0x80, 0x7c, + 0x8c, 0x59, 0xaf, 0xcb, 0x6e, 0xae, 0x73, 0x48, + 0x85, 0x00, 0x13, 0x00, 0xa9, 0x81, 0xcc, 0x62 + } + }, +}; + +#define NUM_PASSPHRASE_TESTS \ +(sizeof(passphrase_tests) / sizeof(passphrase_tests[0])) + + +int main(int argc, char *argv[]) +{ + u8 res[512]; + int ret = 0, i; + + printf("PRF-SHA1 test cases:\n"); + + sha1_prf(key0, sizeof(key0), "prefix", data0, sizeof(data0) - 1, + res, sizeof(prf0)); + if (memcmp(res, prf0, sizeof(prf0)) == 0) + printf("Test case 0 - OK\n"); + else { + printf("Test case 0 - FAILED!\n"); + ret++; + } + + sha1_prf(key1, sizeof(key1) - 1, "prefix", data1, sizeof(data1) - 1, + res, sizeof(prf1)); + if (memcmp(res, prf1, sizeof(prf1)) == 0) + printf("Test case 1 - OK\n"); + else { + printf("Test case 1 - FAILED!\n"); + ret++; + } + + sha1_prf(key2, sizeof(key2), "prefix", data2, sizeof(data2), + res, sizeof(prf2)); + if (memcmp(res, prf2, sizeof(prf2)) == 0) + printf("Test case 2 - OK\n"); + else { + printf("Test case 2 - FAILED!\n"); + ret++; + } + + ret += test_eap_fast(); + + printf("PBKDF2-SHA1 Passphrase test cases:\n"); + for (i = 0; i < NUM_PASSPHRASE_TESTS; i++) { + u8 psk[32]; + struct passphrase_test *test = &passphrase_tests[i]; + pbkdf2_sha1(test->passphrase, + test->ssid, strlen(test->ssid), + 4096, psk, 32); + if (memcmp(psk, test->psk, 32) == 0) + printf("Test case %d - OK\n", i); + else { + printf("Test case %d - FAILED!\n", i); + ret++; + } + } + + return ret; +} +#endif /* TEST_MAIN */ Property changes on: libs/internals/settings/pbkdf2.cpp ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/settings/vpnpersistence.cpp =================================================================== --- libs/internals/settings/vpnpersistence.cpp (revision 0) +++ libs/internals/settings/vpnpersistence.cpp (revision 1010672) @@ -0,0 +1,104 @@ +// This file is generated by kconfig_compiler from vpn.kcfg. +// All changes you do to this file will be lost. + +#include "vpnpersistence.h" + +#include "vpn.h" + +using namespace Knm; + +VpnPersistence::VpnPersistence(VpnSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +VpnPersistence::~VpnPersistence() +{ +} + +void VpnPersistence::load() +{ + VpnSetting * setting = static_cast(m_setting); + setting->setServiceType(m_config->readEntry("ServiceType", "")); + setting->setData(stringMapFromStringList(m_config->readEntry("Data", QStringList()))); + setting->setUserName(m_config->readEntry("UserName", "")); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + // the map is flattened to a list of key,value,key,value + setting->setVpnSecrets(variantMapFromStringList(m_config->readEntry("VpnSecrets", QStringList()))); + } + setting->setPluginName(m_config->readEntry("PluginName", "")); +} + +void VpnPersistence::save() +{ + VpnSetting * setting = static_cast(m_setting); + m_config->writeEntry("ServiceType", setting->serviceType()); + m_config->writeEntry("Data", stringMapToStringList(setting->data())); + m_config->writeEntry("UserName", setting->userName()); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("VpnSecrets", variantMapToStringList(setting->vpnSecrets())); + } + m_config->writeEntry("PluginName", setting->pluginName()); +} + +QVariantMap VpnPersistence::variantMapFromStringList(const QStringList & list) +{ + QVariantMap secretsMap; + if (list.count() % 2 == 0) { + for ( int i = 0; i < list.count(); i += 2 ) { + secretsMap.insert( list[i], list[i+1] ); + } + } + return secretsMap; +} + +QStringList VpnPersistence::variantMapToStringList(const QVariantMap & map) +{ + QStringList rawSecrets; + QMapIterator i(map); + while (i.hasNext()) { + i.next(); + rawSecrets << i.key() << i.value().toString(); + } + return rawSecrets; +} + +QStringMap VpnPersistence::stringMapFromStringList(const QStringList & list) +{ + QStringMap map; + if (list.count() % 2 == 0) { + for ( int i = 0; i < list.count(); i += 2 ) { + map.insert( list[i], list[i+1] ); + } + } + return map; +} + +QStringList VpnPersistence::stringMapToStringList(const QStringMap & map) +{ + QStringList rawSecrets; + QStringMapIterator i(map); + while (i.hasNext()) { + i.next(); + rawSecrets << i.key() << i.value(); + } + return rawSecrets; +} + +QMap VpnPersistence::secrets() const +{ + VpnSetting * setting = static_cast(m_setting); + QMap map; + map.insert(QLatin1String("VpnSecrets"), variantMapToStringList(setting->vpnSecrets()).join(QLatin1String("%SEP%"))); + return map; +} + +void VpnPersistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + VpnSetting * setting = static_cast(m_setting); + setting->setVpnSecrets(variantMapFromStringList(secrets.value("VpnSecrets").split("%SEP%"))); + setting->setSecretsAvailable(true); + } +} Index: libs/internals/settings/cdmapersistence.h =================================================================== --- libs/internals/settings/cdmapersistence.h (revision 0) +++ libs/internals/settings/cdmapersistence.h (revision 1010672) @@ -0,0 +1,27 @@ +// This file is generated by kconfig_compiler from cdma.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_CDMAPERSISTENCE_H +#define KNM_CDMAPERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +namespace Knm { + +class CdmaSetting; + +class KNMINTERNALS_EXPORT CdmaPersistence : public SettingPersistence +{ + public: + CdmaPersistence( CdmaSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~CdmaPersistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; +}; +} + +#endif + Index: libs/internals/settings/ipv4.cpp =================================================================== --- libs/internals/settings/ipv4.cpp (revision 0) +++ libs/internals/settings/ipv4.cpp (revision 1010672) @@ -0,0 +1,25 @@ +// This file is generated by kconfig_compiler from ipv4.kcfg. +// All changes you do to this file will be lost. + +#include "ipv4.h" + +using namespace Knm; + +Ipv4Setting::Ipv4Setting() : Setting(Setting::Ipv4), + mMethod(Ipv4Setting::EnumMethod::Automatic), + mIgnoredhcpdns(false) +{ +} + +Ipv4Setting::~Ipv4Setting() +{ +} + +QString Ipv4Setting::name() const +{ + return QLatin1String("ipv4"); +} +bool Ipv4Setting::hasSecrets() const +{ + return false; +} Index: libs/internals/settings/serial.h =================================================================== --- libs/internals/settings/serial.h (revision 0) +++ libs/internals/settings/serial.h (revision 1010672) @@ -0,0 +1,124 @@ +// This file is generated by kconfig_compiler from serial.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_SERIALSETTING_H +#define KNM_SERIALSETTING_H + +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" +namespace Knm { + +class KNMINTERNALS_EXPORT SerialSetting : public Setting +{ + public: + class EnumParity + { + public: + enum type { None, Even, Odd, COUNT }; + }; + + SerialSetting( ); + ~SerialSetting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set Baud + */ + void setBaud( uint v ) + { + mBaud = v; + } + + /** + Get Baud + */ + uint baud() const + { + return mBaud; + } + + /** + Set Data bits + */ + void setBits( uint v ) + { + mBits = v; + } + + /** + Get Data bits + */ + uint bits() const + { + return mBits; + } + + /** + Set Parity + */ + void setParity( const QString & v ) + { + mParity = v; + } + + /** + Get Parity + */ + QString parity() const + { + return mParity; + } + + /** + Set Stop bits + */ + void setStopbits( uint v ) + { + mStopbits = v; + } + + /** + Get Stop bits + */ + uint stopbits() const + { + return mStopbits; + } + + /** + Set Send delay + */ + void setSenddelay( quint64 v ) + { + mSenddelay = v; + } + + /** + Get Send delay + */ + quint64 senddelay() const + { + return mSenddelay; + } + + protected: + + // serial + uint mBaud; + uint mBits; + QString mParity; + uint mStopbits; + quint64 mSenddelay; + + private: +}; + +} + +#endif + Index: libs/internals/settings/802-3-ethernet.cpp =================================================================== --- libs/internals/settings/802-3-ethernet.cpp (revision 0) +++ libs/internals/settings/802-3-ethernet.cpp (revision 1010672) @@ -0,0 +1,28 @@ +// This file is generated by kconfig_compiler from 802-3-ethernet.kcfg. +// All changes you do to this file will be lost. + +#include "802-3-ethernet.h" + +using namespace Knm; + +WiredSetting::WiredSetting() : Setting(Setting::Wired), + mPort(WiredSetting::EnumPort::mii), + mSpeed(0), + mDuplex(WiredSetting::EnumDuplex::full), + mAutonegotiate(true), + mMtu(0) +{ +} + +WiredSetting::~WiredSetting() +{ +} + +QString WiredSetting::name() const +{ + return QLatin1String("802-3-ethernet"); +} +bool WiredSetting::hasSecrets() const +{ + return false; +} Index: libs/internals/settings/gsm.cpp =================================================================== --- libs/internals/settings/gsm.cpp (revision 0) +++ libs/internals/settings/gsm.cpp (revision 1010672) @@ -0,0 +1,23 @@ +// This file is generated by kconfig_compiler from gsm.kcfg. +// All changes you do to this file will be lost. + +#include "gsm.h" + +using namespace Knm; + +GsmSetting::GsmSetting() : Setting(Setting::Gsm) +{ +} + +GsmSetting::~GsmSetting() +{ +} + +QString GsmSetting::name() const +{ + return QLatin1String("gsm"); +} +bool GsmSetting::hasSecrets() const +{ + return true; +} Index: libs/internals/settings/pppoe.h =================================================================== --- libs/internals/settings/pppoe.h (revision 0) +++ libs/internals/settings/pppoe.h (revision 1010672) @@ -0,0 +1,85 @@ +// This file is generated by kconfig_compiler from pppoe.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_PPPOESETTING_H +#define KNM_PPPOESETTING_H + +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" +namespace Knm { + +class KNMINTERNALS_EXPORT PppoeSetting : public Setting +{ + public: + + PppoeSetting( ); + ~PppoeSetting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set Service + */ + void setService( const QString & v ) + { + mService = v; + } + + /** + Get Service + */ + QString service() const + { + return mService; + } + + /** + Set Username + */ + void setUsername( const QString & v ) + { + mUsername = v; + } + + /** + Get Username + */ + QString username() const + { + return mUsername; + } + + /** + Set Password + */ + void setPassword( const QString & v ) + { + mPassword = v; + } + + /** + Get Password + */ + QString password() const + { + return mPassword; + } + + protected: + + // pppoe + QString mService; + QString mUsername; + QString mPassword; + + private: +}; + +} + +#endif + Index: libs/internals/settings/802-11-wireless.h =================================================================== --- libs/internals/settings/802-11-wireless.h (revision 0) +++ libs/internals/settings/802-11-wireless.h (revision 1010672) @@ -0,0 +1,231 @@ +// This file is generated by kconfig_compiler from 802-11-wireless.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_WIRELESSSETTING_H +#define KNM_WIRELESSSETTING_H + +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" +namespace Knm { + +class KNMINTERNALS_EXPORT WirelessSetting : public Setting +{ + public: + class EnumMode + { + public: + enum type { infrastructure, adhoc, COUNT }; + }; + class EnumBand + { + public: + enum type { a, bg, COUNT }; + }; + + WirelessSetting( ); + ~WirelessSetting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set SSID + */ + void setSsid( const QByteArray & v ) + { + mSsid = v; + } + + /** + Get SSID + */ + QByteArray ssid() const + { + return mSsid; + } + + /** + Set Mode + */ + void setMode( int v ) + { + mMode = v; + } + + /** + Get Mode + */ + int mode() const + { + return mMode; + } + + /** + Set Band + */ + void setBand( int v ) + { + mBand = v; + } + + /** + Get Band + */ + int band() const + { + return mBand; + } + + /** + Set Channel + */ + void setChannel( uint v ) + { + mChannel = v; + } + + /** + Get Channel + */ + uint channel() const + { + return mChannel; + } + + /** + Set BSSID + */ + void setBssid( const QByteArray & v ) + { + mBssid = v; + } + + /** + Get BSSID + */ + QByteArray bssid() const + { + return mBssid; + } + + /** + Set Data rate + */ + void setRate( uint v ) + { + mRate = v; + } + + /** + Get Data rate + */ + uint rate() const + { + return mRate; + } + + /** + Set Transmit power + */ + void setTxpower( uint v ) + { + mTxpower = v; + } + + /** + Get Transmit power + */ + uint txpower() const + { + return mTxpower; + } + + /** + Set MAC Address + */ + void setMacaddress( const QByteArray & v ) + { + mMacaddress = v; + } + + /** + Get MAC Address + */ + QByteArray macaddress() const + { + return mMacaddress; + } + + /** + Set MTU + */ + void setMtu( uint v ) + { + mMtu = v; + } + + /** + Get MTU + */ + uint mtu() const + { + return mMtu; + } + + /** + Set Seen BSSIDs + */ + void setSeenbssids( const QStringList & v ) + { + mSeenbssids = v; + } + + /** + Get Seen BSSIDs + */ + QStringList seenbssids() const + { + return mSeenbssids; + } + + /** + Set security + */ + void setSecurity( const QString & v ) + { + mSecurity = v; + } + + /** + Get security + */ + QString security() const + { + return mSecurity; + } + + protected: + + // 802-11-wireless + QByteArray mSsid; + int mMode; + int mBand; + uint mChannel; + QByteArray mBssid; + uint mRate; + uint mTxpower; + QByteArray mMacaddress; + uint mMtu; + QStringList mSeenbssids; + QString mSecurity; + + private: +}; + +} + +#endif + Index: libs/internals/settings/802-11-wireless-security.cpp =================================================================== --- libs/internals/settings/802-11-wireless-security.cpp (revision 0) +++ libs/internals/settings/802-11-wireless-security.cpp (revision 1010672) @@ -0,0 +1,24 @@ +// This file is generated by kconfig_compiler from 802-11-wireless-security.kcfg. +// All changes you do to this file will be lost. + +#include "802-11-wireless-security.h" + +using namespace Knm; + +WirelessSecuritySetting::WirelessSecuritySetting() : Setting(Setting::WirelessSecurity) + , mSecurityType(WirelessSecuritySetting::EnumSecurityType::None), mKeymgmt(0), mWeptxkeyindex(0), mAuthalg(0) +{ +} + +WirelessSecuritySetting::~WirelessSecuritySetting() +{ +} + +QString WirelessSecuritySetting::name() const +{ + return QLatin1String("802-11-wireless-security"); +} +bool WirelessSecuritySetting::hasSecrets() const +{ + return true; +} Index: libs/internals/settings/serialpersistence.h =================================================================== --- libs/internals/settings/serialpersistence.h (revision 0) +++ libs/internals/settings/serialpersistence.h (revision 1010672) @@ -0,0 +1,27 @@ +// This file is generated by kconfig_compiler from serial.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_SERIALPERSISTENCE_H +#define KNM_SERIALPERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +namespace Knm { + +class SerialSetting; + +class KNMINTERNALS_EXPORT SerialPersistence : public SettingPersistence +{ + public: + SerialPersistence( SerialSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~SerialPersistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; +}; +} + +#endif + Index: libs/internals/settings/802-3-ethernetpersistence.cpp =================================================================== --- libs/internals/settings/802-3-ethernetpersistence.cpp (revision 0) +++ libs/internals/settings/802-3-ethernetpersistence.cpp (revision 1010672) @@ -0,0 +1,89 @@ +// This file is generated by kconfig_compiler from 802-3-ethernet.kcfg. +// All changes you do to this file will be lost. + +#include "802-3-ethernetpersistence.h" + +#include "802-3-ethernet.h" + +using namespace Knm; + +WiredPersistence::WiredPersistence(WiredSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +WiredPersistence::~WiredPersistence() +{ +} + +void WiredPersistence::load() +{ + WiredSetting * setting = static_cast(m_setting); + { + QString contents = m_config->readEntry("port", "tp"); + if (contents == "tp") + setting->setPort(WiredSetting::EnumPort::tp); + else if (contents == "aui") + setting->setPort(WiredSetting::EnumPort::aui); + else if (contents == "bnc") + setting->setPort(WiredSetting::EnumPort::bnc); + else if (contents == "mii") + setting->setPort(WiredSetting::EnumPort::mii); + + } + setting->setSpeed(m_config->readEntry("speed", 0)); + { + QString contents = m_config->readEntry("duplex", "full"); + if (contents == "half") + setting->setDuplex(WiredSetting::EnumDuplex::half); + else if (contents == "full") + setting->setDuplex(WiredSetting::EnumDuplex::full); + + } + setting->setAutonegotiate(m_config->readEntry("autonegotiate", true)); + setting->setMacaddress(m_config->readEntry("macaddress", QByteArray())); + setting->setMtu(m_config->readEntry("mtu", 0)); +} + +void WiredPersistence::save() +{ + WiredSetting * setting = static_cast(m_setting); + switch (setting->port()) { + case WiredSetting::EnumPort::tp: + m_config->writeEntry("port", "tp"); + break; + case WiredSetting::EnumPort::aui: + m_config->writeEntry("port", "aui"); + break; + case WiredSetting::EnumPort::bnc: + m_config->writeEntry("port", "bnc"); + break; + case WiredSetting::EnumPort::mii: + m_config->writeEntry("port", "mii"); + break; + } + m_config->writeEntry("speed", setting->speed()); + switch (setting->duplex()) { + case WiredSetting::EnumDuplex::half: + m_config->writeEntry("duplex", "half"); + break; + case WiredSetting::EnumDuplex::full: + m_config->writeEntry("duplex", "full"); + break; + } + m_config->writeEntry("autonegotiate", setting->autonegotiate()); + m_config->writeEntry("macaddress", setting->macaddress()); + m_config->writeEntry("mtu", setting->mtu()); +} + +QMap WiredPersistence::secrets() const +{ + QMap map; + return map; +} + +void WiredPersistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + Q_UNUSED(secrets); + } +} Index: libs/internals/settings/ipv4persistence.h =================================================================== --- libs/internals/settings/ipv4persistence.h (revision 0) +++ libs/internals/settings/ipv4persistence.h (revision 1010672) @@ -0,0 +1,27 @@ +// This file is generated by kconfig_compiler from ipv4.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_IPV4PERSISTENCE_H +#define KNM_IPV4PERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +namespace Knm { + +class Ipv4Setting; + +class KNMINTERNALS_EXPORT Ipv4Persistence : public SettingPersistence +{ + public: + Ipv4Persistence( Ipv4Setting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~Ipv4Persistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; +}; +} + +#endif + Index: libs/internals/settings/pppoepersistence.h =================================================================== --- libs/internals/settings/pppoepersistence.h (revision 0) +++ libs/internals/settings/pppoepersistence.h (revision 1010672) @@ -0,0 +1,27 @@ +// This file is generated by kconfig_compiler from pppoe.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_PPPOEPERSISTENCE_H +#define KNM_PPPOEPERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +namespace Knm { + +class PppoeSetting; + +class KNMINTERNALS_EXPORT PppoePersistence : public SettingPersistence +{ + public: + PppoePersistence( PppoeSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~PppoePersistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; +}; +} + +#endif + Index: libs/internals/settings/802-11-wirelesspersistence.h =================================================================== --- libs/internals/settings/802-11-wirelesspersistence.h (revision 0) +++ libs/internals/settings/802-11-wirelesspersistence.h (revision 1010672) @@ -0,0 +1,27 @@ +// This file is generated by kconfig_compiler from 802-11-wireless.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_WIRELESSPERSISTENCE_H +#define KNM_WIRELESSPERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +namespace Knm { + +class WirelessSetting; + +class KNMINTERNALS_EXPORT WirelessPersistence : public SettingPersistence +{ + public: + WirelessPersistence( WirelessSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~WirelessPersistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; +}; +} + +#endif + Index: libs/internals/settings/wephash.cpp =================================================================== --- libs/internals/settings/wephash.cpp (revision 0) +++ libs/internals/settings/wephash.cpp (revision 1010672) @@ -0,0 +1,45 @@ +/* This file is part of the KDE project + Copyright (C) 2008 Christopher Blauvelt + + Based on code from Dan Williams + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ + +#include +#include + +#include "wephash.h" + +QByteArray wep128PassphraseHash(QByteArray input) +{ + QByteArray md5_data, digest; + + if (input.isEmpty()) { + return QByteArray(); + } + + md5_data.reserve(65); + digest.reserve(16); + + // Get at least 64 bytes + for (int i = 0; i < 64; i++) + md5_data[i] = input[i % input.length()]; + + digest = QCryptographicHash::hash(md5_data, QCryptographicHash::Md5); + //convert to hex and only pass the first 26 chars for 128-bit encryption + return digest.toHex().left(26); +} \ No newline at end of file Property changes on: libs/internals/settings/wephash.cpp ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/settings/gsmpersistence.h =================================================================== --- libs/internals/settings/gsmpersistence.h (revision 0) +++ libs/internals/settings/gsmpersistence.h (revision 1010672) @@ -0,0 +1,27 @@ +// This file is generated by kconfig_compiler from gsm.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_GSMPERSISTENCE_H +#define KNM_GSMPERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +namespace Knm { + +class GsmSetting; + +class KNMINTERNALS_EXPORT GsmPersistence : public SettingPersistence +{ + public: + GsmPersistence( GsmSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~GsmPersistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; +}; +} + +#endif + Index: libs/internals/settings/802-11-wireless-securitypersistence.h =================================================================== --- libs/internals/settings/802-11-wireless-securitypersistence.h (revision 0) +++ libs/internals/settings/802-11-wireless-securitypersistence.h (revision 1010672) @@ -0,0 +1,27 @@ +// This file is generated by kconfig_compiler from 802-11-wireless-security.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_WIRELESSSECURITYPERSISTENCE_H +#define KNM_WIRELESSSECURITYPERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +namespace Knm { + +class WirelessSecuritySetting; + +class KNMINTERNALS_EXPORT WirelessSecurityPersistence : public SettingPersistence +{ + public: + WirelessSecurityPersistence( WirelessSecuritySetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~WirelessSecurityPersistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; +}; +} + +#endif + Index: libs/internals/settings/802-1x.h =================================================================== --- libs/internals/settings/802-1x.h (revision 0) +++ libs/internals/settings/802-1x.h (revision 1010672) @@ -0,0 +1,565 @@ +// This file is generated by kconfig_compiler from 802-1x.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_SECURITY8021XSETTING_H +#define KNM_SECURITY8021XSETTING_H + +#include +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" +namespace Knm { + +class KNMINTERNALS_EXPORT Security8021xSetting : public Setting +{ + public: + class EnumPhase1peapver + { + public: + enum type { automatic, zero, one, COUNT }; + }; + class EnumPhase1peaplabel + { + public: + enum type { automatic, zero, one, COUNT }; + }; + class EnumPhase2auth + { + public: + enum type { none, pap, mschap, mschapv2, chap, md5, gtc, otp, COUNT }; + }; + class EnumPhase2autheap + { + public: + enum type { none, md5, gtc, otp, mschapv2, tls, COUNT }; + }; + + Security8021xSetting( ); + ~Security8021xSetting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set EAP + */ + void setEap( const QStringList & v ) + { + mEap = v; + } + + /** + Get EAP + */ + QStringList eap() const + { + return mEap; + } + + /** + Set Identity + */ + void setIdentity( const QString & v ) + { + mIdentity = v; + } + + /** + Get Identity + */ + QString identity() const + { + return mIdentity; + } + + /** + Set Anonymous identity + */ + void setAnonymousidentity( const QString & v ) + { + mAnonymousidentity = v; + } + + /** + Get Anonymous identity + */ + QString anonymousidentity() const + { + return mAnonymousidentity; + } + + /** + Set CA Cert + */ + void setCacert( const QByteArray & v ) + { + mCacert = v; + } + + /** + Get CA Cert + */ + QByteArray cacert() const + { + return mCacert; + } + + /** + Set CA Path + */ + void setCapath( const QString & v ) + { + mCapath = v; + + setCacert( getBytes(v)); + } + + /** + Get CA Path + */ + QString capath() const + { + return mCapath; + } + + /** + Set Client Cert + */ + void setClientcert( const QByteArray & v ) + { + mClientcert = v; + } + + /** + Get Client Cert + */ + QByteArray clientcert() const + { + return mClientcert; + } + + /** + Set Client Cert Path + */ + void setClientcertpath( const QString & v ) + { + mClientcertpath = v; + setClientcert( getBytes(v)); + } + + /** + Get Client Cert Path + */ + QString clientcertpath() const + { + return mClientcertpath; + } + + /** + Set Phase 1 PEAP version + */ + void setPhase1peapver( int v ) + { + mPhase1peapver = v; + } + + /** + Get Phase 1 PEAP version + */ + int phase1peapver() const + { + return mPhase1peapver; + } + + /** + Set Phase 1 PEAP label + */ + void setPhase1peaplabel( const QString & v ) + { + mPhase1peaplabel = v; + } + + /** + Get Phase 1 PEAP label + */ + QString phase1peaplabel() const + { + return mPhase1peaplabel; + } + + /** + Set Phase 1 fast provisioning + */ + void setPhase1fastprovisioning( const QString & v ) + { + mPhase1fastprovisioning = v; + } + + /** + Get Phase 1 fast provisioning + */ + QString phase1fastprovisioning() const + { + return mPhase1fastprovisioning; + } + + /** + Set Phase 2 auth + */ + void setPhase2auth( int v ) + { + mPhase2auth = v; + } + + /** + Get Phase 2 auth + */ + int phase2auth() const + { + return mPhase2auth; + } + + /** + Set Phase 2 auth eap + */ + void setPhase2autheap( int v ) + { + mPhase2autheap = v; + } + + /** + Get Phase 2 auth eap + */ + int phase2autheap() const + { + return mPhase2autheap; + } + + /** + Set Phase 2 CA Cert + */ + void setPhase2cacert( const QByteArray & v ) + { + mPhase2cacert = v; + } + + /** + Get Phase 2 CA Cert + */ + QByteArray phase2cacert() const + { + return mPhase2cacert; + } + + /** + Set Phase 2 CA Path + */ + void setPhase2capath( const QString & v ) + { + mPhase2capath = v; + setPhase2cacert( getBytes(v)); + } + + /** + Get Phase 2 CA Path + */ + QString phase2capath() const + { + return mPhase2capath; + } + + /** + Set Phase 2 client cert + */ + void setPhase2clientcert( const QByteArray & v ) + { + mPhase2clientcert = v; + } + + /** + Get Phase 2 client cert + */ + QByteArray phase2clientcert() const + { + return mPhase2clientcert; + } + + /** + Set Phase 2 client cert path + */ + void setPhase2clientcertpath( const QString & v ) + { + mPhase2clientcertpath = v; + setPhase2clientcert( getBytes(v)); + } + + /** + Get Phase 2 client cert path + */ + QString phase2clientcertpath() const + { + return mPhase2clientcertpath; + } + + /** + Set Password + */ + void setPassword( const QString & v ) + { + mPassword = v; + } + + /** + Get Password + */ + QString password() const + { + return mPassword; + } + + /** + Set Private key + */ + void setPrivatekey( const QByteArray & v ) + { + mPrivatekey = v; + } + + /** + Get Private key + */ + QByteArray privatekey() const + { + return mPrivatekey; + } + + /** + Set Private key Path + */ + void setPrivatekeypath( const QString & v ) + { + mPrivatekeypath = v; + setPrivatekey( getBytes(v)); + } + + /** + Get Private key Path + */ + QString privatekeypath() const + { + return mPrivatekeypath; + } + + /** + Set Private key password + */ + void setPrivatekeypassword( const QString & v ) + { + mPrivatekeypassword = v; + } + + /** + Get Private key password + */ + QString privatekeypassword() const + { + return mPrivatekeypassword; + } + + /** + Set Phase 2 private key + */ + void setPhase2privatekey( const QByteArray & v ) + { + mPhase2privatekey = v; + } + + /** + Get Phase 2 private key + */ + QByteArray phase2privatekey() const + { + return mPhase2privatekey; + } + + /** + Set Phase 2 Private key Path + */ + void setPhase2privatekeypath( const QString & v ) + { + mPhase2privatekeypath = v; + setPhase2privatekey( getBytes(v)); + } + + /** + Get Phase 2 Private key Path + */ + QString phase2privatekeypath() const + { + return mPhase2privatekeypath; + } + + /** + Set Phase 2 private key password + */ + void setPhase2privatekeypassword( const QString & v ) + { + mPhase2privatekeypassword = v; + } + + /** + Get Phase 2 private key password + */ + QString phase2privatekeypassword() const + { + return mPhase2privatekeypassword; + } + + /** + Set PIN + */ + void setPin( const QString & v ) + { + mPin = v; + } + + /** + Get PIN + */ + QString pin() const + { + return mPin; + } + + /** + Set PSK + */ + void setPsk( const QString & v ) + { + mPsk = v; + } + + /** + Get PSK + */ + QString psk() const + { + return mPsk; + } + + /** + Set Use System CA Certs + */ + void setUseSystemCaCerts( bool v ) + { + mUseSystemCaCerts = v; + } + + /** + Get Use System CA Certs + */ + bool useSystemCaCerts() const + { + return mUseSystemCaCerts; + } + + /** + Set Connection uses 802.1x + */ + void setEnabled( bool v ) + { + mEnabled = v; + } + + /** + Get Connection uses 802.1x + */ + bool enabled() const + { + return mEnabled; + } + + enum EapMethod + { + ttls = 1, + peap = 2, + tls = 4, + leap = 8 + }; + Q_DECLARE_FLAGS(EapMethods, EapMethod) + + void setEapFlags( const EapMethods& methods ) + { + QStringList eap; + if (methods.testFlag(ttls)) + eap.append("ttls"); + if (methods.testFlag(tls)) + eap.append("tls"); + if (methods.testFlag(peap)) + eap.append("peap"); + if (methods.testFlag(peap)) + eap.append("leap"); +kDebug() << eap; + setEap(eap); + } + + EapMethods eapFlags() const + { + QStringList eaps = eap(); + EapMethods eapFlags; + if (eaps.contains("ttls")) + eapFlags = eapFlags | ttls; + if (eaps.contains("tls")) + eapFlags = eapFlags | tls; + if (eaps.contains("peap")) + eapFlags = eapFlags | peap; + if (eaps.contains("peap")) + eapFlags = eapFlags | leap; + return eapFlags; + } + + + + protected: + + // 802-1x + QStringList mEap; + QString mIdentity; + QString mAnonymousidentity; + QByteArray mCacert; + QString mCapath; + QByteArray mClientcert; + QString mClientcertpath; + int mPhase1peapver; + QString mPhase1peaplabel; + QString mPhase1fastprovisioning; + int mPhase2auth; + int mPhase2autheap; + QByteArray mPhase2cacert; + QString mPhase2capath; + QByteArray mPhase2clientcert; + QString mPhase2clientcertpath; + QString mPassword; + QByteArray mPrivatekey; + QString mPrivatekeypath; + QString mPrivatekeypassword; + QByteArray mPhase2privatekey; + QString mPhase2privatekeypath; + QString mPhase2privatekeypassword; + QString mPin; + QString mPsk; + bool mUseSystemCaCerts; + bool mEnabled; + + private: + QByteArray getBytes(const QString & fileName); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(Security8021xSetting::EapMethods) + +} + +#endif + Index: libs/internals/settings/ppp.h =================================================================== --- libs/internals/settings/ppp.h (revision 0) +++ libs/internals/settings/ppp.h (revision 1010672) @@ -0,0 +1,340 @@ +// This file is generated by kconfig_compiler from ppp.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_PPPSETTING_H +#define KNM_PPPSETTING_H + +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" +namespace Knm { + +class KNMINTERNALS_EXPORT PppSetting : public Setting +{ + public: + + PppSetting( ); + ~PppSetting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set No Auth + */ + void setNoauth( bool v ) + { + mNoauth = v; + } + + /** + Get No Auth + */ + bool noauth() const + { + return mNoauth; + } + + /** + Set Refuse EAP + */ + void setRefuseeap( bool v ) + { + mRefuseeap = v; + } + + /** + Get Refuse EAP + */ + bool refuseeap() const + { + return mRefuseeap; + } + + /** + Set Refuse PAP + */ + void setRefusepap( bool v ) + { + mRefusepap = v; + } + + /** + Get Refuse PAP + */ + bool refusepap() const + { + return mRefusepap; + } + + /** + Set Refuse CHAP + */ + void setRefusechap( bool v ) + { + mRefusechap = v; + } + + /** + Get Refuse CHAP + */ + bool refusechap() const + { + return mRefusechap; + } + + /** + Set Refuse MS CHAP + */ + void setRefusemschap( bool v ) + { + mRefusemschap = v; + } + + /** + Get Refuse MS CHAP + */ + bool refusemschap() const + { + return mRefusemschap; + } + + /** + Set Refuse MS CHAP V2 + */ + void setRefusemschapv2( bool v ) + { + mRefusemschapv2 = v; + } + + /** + Get Refuse MS CHAP V2 + */ + bool refusemschapv2() const + { + return mRefusemschapv2; + } + + /** + Set No BSD comp. + */ + void setNobsdcomp( bool v ) + { + mNobsdcomp = v; + } + + /** + Get No BSD comp. + */ + bool nobsdcomp() const + { + return mNobsdcomp; + } + + /** + Set No deflate + */ + void setNodeflate( bool v ) + { + mNodeflate = v; + } + + /** + Get No deflate + */ + bool nodeflate() const + { + return mNodeflate; + } + + /** + Set No VJ comp. + */ + void setNovjcomp( bool v ) + { + mNovjcomp = v; + } + + /** + Get No VJ comp. + */ + bool novjcomp() const + { + return mNovjcomp; + } + + /** + Set Require MPPE + */ + void setRequiremppe( bool v ) + { + mRequiremppe = v; + } + + /** + Get Require MPPE + */ + bool requiremppe() const + { + return mRequiremppe; + } + + /** + Set Require MPPE 128 + */ + void setRequiremppe128( bool v ) + { + mRequiremppe128 = v; + } + + /** + Get Require MPPE 128 + */ + bool requiremppe128() const + { + return mRequiremppe128; + } + + /** + Set MPPE Stateful + */ + void setMppestateful( bool v ) + { + mMppestateful = v; + } + + /** + Get MPPE Stateful + */ + bool mppestateful() const + { + return mMppestateful; + } + + /** + Set CRTSCTS + */ + void setCrtscts( bool v ) + { + mCrtscts = v; + } + + /** + Get CRTSCTS + */ + bool crtscts() const + { + return mCrtscts; + } + + /** + Set Baud + */ + void setBaud( uint v ) + { + mBaud = v; + } + + /** + Get Baud + */ + uint baud() const + { + return mBaud; + } + + /** + Set MRU + */ + void setMru( uint v ) + { + mMru = v; + } + + /** + Get MRU + */ + uint mru() const + { + return mMru; + } + + /** + Set MTU + */ + void setMtu( uint v ) + { + mMtu = v; + } + + /** + Get MTU + */ + uint mtu() const + { + return mMtu; + } + + /** + Set LCP echo Failure + */ + void setLcpechofailure( uint v ) + { + mLcpechofailure = v; + } + + /** + Get LCP echo Failure + */ + uint lcpechofailure() const + { + return mLcpechofailure; + } + + /** + Set LCP echo interval + */ + void setLcpechointerval( uint v ) + { + mLcpechointerval = v; + } + + /** + Get LCP echo interval + */ + uint lcpechointerval() const + { + return mLcpechointerval; + } + + protected: + + // ppp + bool mNoauth; + bool mRefuseeap; + bool mRefusepap; + bool mRefusechap; + bool mRefusemschap; + bool mRefusemschapv2; + bool mNobsdcomp; + bool mNodeflate; + bool mNovjcomp; + bool mRequiremppe; + bool mRequiremppe128; + bool mMppestateful; + bool mCrtscts; + uint mBaud; + uint mMru; + uint mMtu; + uint mLcpechofailure; + uint mLcpechointerval; + + private: +}; + +} + +#endif + Index: libs/internals/settings/vpn.h =================================================================== --- libs/internals/settings/vpn.h (revision 0) +++ libs/internals/settings/vpn.h (revision 1010672) @@ -0,0 +1,120 @@ +// This file is generated by kconfig_compiler from vpn.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_VPNSETTING_H +#define KNM_VPNSETTING_H + +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" +#include "../types.h" +namespace Knm { + +class KNMINTERNALS_EXPORT VpnSetting : public Setting +{ + public: + + VpnSetting( ); + ~VpnSetting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set Service Type + */ + void setServiceType( const QString & v ) + { + mServiceType = v; + } + + /** + Get Service Type + */ + QString serviceType() const + { + return mServiceType; + } + + /** + Set Data bits + */ + void setData( const QStringMap & v ) + { + mData = v; + } + + /** + Get Data bits + */ + QStringMap data() const + { + return mData; + } + + /** + Set Username + */ + void setUserName( const QString & v ) + { + mUserName = v; + } + + /** + Get Username + */ + QString userName() const + { + return mUserName; + } + + /** + Set Vpnsecrets + */ + void setVpnSecrets( const QVariantMap & v ) + { + mVpnSecrets = v; + } + + /** + Get Vpnsecrets + */ + QVariantMap vpnSecrets() const + { + return mVpnSecrets; + } + + /** + Set VPN Plugin Name + */ + void setPluginName( const QString & v ) + { + mPluginName = v; + } + + /** + Get VPN Plugin Name + */ + QString pluginName() const + { + return mPluginName; + } + + protected: + + // vpn + QString mServiceType; + QStringMap mData; + QString mUserName; + QVariantMap mVpnSecrets; + QString mPluginName; + + private: +}; + +} + +#endif + Index: libs/internals/settings/802-1xpersistence.h =================================================================== --- libs/internals/settings/802-1xpersistence.h (revision 0) +++ libs/internals/settings/802-1xpersistence.h (revision 1010672) @@ -0,0 +1,27 @@ +// This file is generated by kconfig_compiler from 802-1x.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_SECURITY8021XPERSISTENCE_H +#define KNM_SECURITY8021XPERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +namespace Knm { + +class Security8021xSetting; + +class KNMINTERNALS_EXPORT Security8021xPersistence : public SettingPersistence +{ + public: + Security8021xPersistence( Security8021xSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~Security8021xPersistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; +}; +} + +#endif + Index: libs/internals/settings/cdma.h =================================================================== --- libs/internals/settings/cdma.h (revision 0) +++ libs/internals/settings/cdma.h (revision 1010672) @@ -0,0 +1,85 @@ +// This file is generated by kconfig_compiler from cdma.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_CDMASETTING_H +#define KNM_CDMASETTING_H + +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" +namespace Knm { + +class KNMINTERNALS_EXPORT CdmaSetting : public Setting +{ + public: + + CdmaSetting( ); + ~CdmaSetting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set Number + */ + void setNumber( const QString & v ) + { + mNumber = v; + } + + /** + Get Number + */ + QString number() const + { + return mNumber; + } + + /** + Set Username + */ + void setUsername( const QString & v ) + { + mUsername = v; + } + + /** + Get Username + */ + QString username() const + { + return mUsername; + } + + /** + Set Password + */ + void setPassword( const QString & v ) + { + mPassword = v; + } + + /** + Get Password + */ + QString password() const + { + return mPassword; + } + + protected: + + // cdma + QString mNumber; + QString mUsername; + QString mPassword; + + private: +}; + +} + +#endif + Index: libs/internals/settings/cdmapersistence.cpp =================================================================== --- libs/internals/settings/cdmapersistence.cpp (revision 0) +++ libs/internals/settings/cdmapersistence.cpp (revision 1010672) @@ -0,0 +1,55 @@ +// This file is generated by kconfig_compiler from cdma.kcfg. +// All changes you do to this file will be lost. + +#include "cdmapersistence.h" + +#include "cdma.h" + +using namespace Knm; + +CdmaPersistence::CdmaPersistence(CdmaSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +CdmaPersistence::~CdmaPersistence() +{ +} + +void CdmaPersistence::load() +{ + CdmaSetting * setting = static_cast(m_setting); + setting->setNumber(m_config->readEntry("number", "")); + setting->setUsername(m_config->readEntry("username", "")); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setPassword(m_config->readEntry("password", "")); + } +} + +void CdmaPersistence::save() +{ + CdmaSetting * setting = static_cast(m_setting); + m_config->writeEntry("number", setting->number()); + m_config->writeEntry("username", setting->username()); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("password", setting->password()); + } +} + +QMap CdmaPersistence::secrets() const +{ + CdmaSetting * setting = static_cast(m_setting); + QMap map; + map.insert(QLatin1String("password"), setting->password()); + return map; +} + +void CdmaPersistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + CdmaSetting * setting = static_cast(m_setting); + setting->setPassword(secrets.value("password")); + setting->setSecretsAvailable(true); + } +} Index: libs/internals/settings/ppppersistence.h =================================================================== --- libs/internals/settings/ppppersistence.h (revision 0) +++ libs/internals/settings/ppppersistence.h (revision 1010672) @@ -0,0 +1,27 @@ +// This file is generated by kconfig_compiler from ppp.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_PPPPERSISTENCE_H +#define KNM_PPPPERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +namespace Knm { + +class PppSetting; + +class KNMINTERNALS_EXPORT PppPersistence : public SettingPersistence +{ + public: + PppPersistence( PppSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~PppPersistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; +}; +} + +#endif + Index: libs/internals/settings/pbkdf2.h =================================================================== --- libs/internals/settings/pbkdf2.h (revision 0) +++ libs/internals/settings/pbkdf2.h (revision 1010672) @@ -0,0 +1,34 @@ +/* + * SHA1 hash implementation and interface functions + * Copyright (c) 2003-2005, Jouni Malinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Alternatively, this software may be distributed under the terms of BSD + * license. + * + * See README and COPYING for more details. + */ + +#ifndef SHA1_H +#define SHA1_H + +#include + + +#define SHA1_MAC_LEN 20 + +void sha1_mac(const u_int8_t *key, size_t key_len, const u_int8_t *data, size_t data_len, + u_int8_t *mac); +void hmac_sha1_vector(const u_int8_t *key, size_t key_len, size_t num_elem, + const u_int8_t *addr[], const size_t *len, u_int8_t *mac); +void hmac_sha1(const u_int8_t *key, size_t key_len, const u_int8_t *data, size_t data_len, + u_int8_t *mac); +void sha1_prf(const u_int8_t *key, size_t key_len, const char *label, + const u_int8_t *data, size_t data_len, u_int8_t *buf, size_t buf_len); +void pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, + int iterations, u_int8_t *buf, size_t buflen); + +#endif /* SHA1_H */ Property changes on: libs/internals/settings/pbkdf2.h ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/settings/vpnpersistence.h =================================================================== --- libs/internals/settings/vpnpersistence.h (revision 0) +++ libs/internals/settings/vpnpersistence.h (revision 1010672) @@ -0,0 +1,33 @@ +// This file is generated by kconfig_compiler from vpn.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_VPNPERSISTENCE_H +#define KNM_VPNPERSISTENCE_H + +#include +#include +#include "settingpersistence.h" +#include "knminternals_export.h" +#include "../types.h" + +namespace Knm { + +class VpnSetting; + +class KNMINTERNALS_EXPORT VpnPersistence : public SettingPersistence +{ + public: + VpnPersistence( VpnSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode = ConnectionPersistence::Secure); + ~VpnPersistence(); + void load(); + void save(); + QMap secrets() const; + void restoreSecrets(QMap) const; + static QStringList variantMapToStringList(const QVariantMap &); + static QVariantMap variantMapFromStringList(const QStringList &); + static QStringList stringMapToStringList(const QStringMap &); + static QStringMap stringMapFromStringList(const QStringList &); +}; +} + +#endif + Index: libs/internals/settings/serial.cpp =================================================================== --- libs/internals/settings/serial.cpp (revision 0) +++ libs/internals/settings/serial.cpp (revision 1010672) @@ -0,0 +1,23 @@ +// This file is generated by kconfig_compiler from serial.kcfg. +// All changes you do to this file will be lost. + +#include "serial.h" + +using namespace Knm; + +SerialSetting::SerialSetting() : Setting(Setting::Serial), mBaud(0), mBits(0), mStopbits(0), mSenddelay(0) +{ +} + +SerialSetting::~SerialSetting() +{ +} + +QString SerialSetting::name() const +{ + return QLatin1String("serial"); +} +bool SerialSetting::hasSecrets() const +{ + return false; +} Index: libs/internals/settings/802-11-wireless.cpp =================================================================== --- libs/internals/settings/802-11-wireless.cpp (revision 0) +++ libs/internals/settings/802-11-wireless.cpp (revision 1010672) @@ -0,0 +1,24 @@ +// This file is generated by kconfig_compiler from 802-11-wireless.kcfg. +// All changes you do to this file will be lost. + +#include "802-11-wireless.h" + +using namespace Knm; + +WirelessSetting::WirelessSetting() : Setting(Setting::Wireless), + mMode(0), mBand(WirelessSetting::EnumBand::bg), mChannel(0), mRate(0), mTxpower(0), mMtu(0) +{ +} + +WirelessSetting::~WirelessSetting() +{ +} + +QString WirelessSetting::name() const +{ + return QLatin1String("802-11-wireless"); +} +bool WirelessSetting::hasSecrets() const +{ + return false; +} Index: libs/internals/settings/pppoe.cpp =================================================================== --- libs/internals/settings/pppoe.cpp (revision 0) +++ libs/internals/settings/pppoe.cpp (revision 1010672) @@ -0,0 +1,23 @@ +// This file is generated by kconfig_compiler from pppoe.kcfg. +// All changes you do to this file will be lost. + +#include "pppoe.h" + +using namespace Knm; + +PppoeSetting::PppoeSetting() : Setting(Setting::Pppoe) +{ +} + +PppoeSetting::~PppoeSetting() +{ +} + +QString PppoeSetting::name() const +{ + return QLatin1String("pppoe"); +} +bool PppoeSetting::hasSecrets() const +{ + return true; +} Index: libs/internals/settings/serialpersistence.cpp =================================================================== --- libs/internals/settings/serialpersistence.cpp (revision 0) +++ libs/internals/settings/serialpersistence.cpp (revision 1010672) @@ -0,0 +1,49 @@ +// This file is generated by kconfig_compiler from serial.kcfg. +// All changes you do to this file will be lost. + +#include "serialpersistence.h" + +#include "serial.h" + +using namespace Knm; + +SerialPersistence::SerialPersistence(SerialSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +SerialPersistence::~SerialPersistence() +{ +} + +void SerialPersistence::load() +{ + SerialSetting * setting = static_cast(m_setting); + setting->setBaud(m_config->readEntry("baud", 0)); + setting->setBits(m_config->readEntry("bits", 8)); + setting->setParity(m_config->readEntry("parity", "None")); + setting->setStopbits(m_config->readEntry("stopbits", 1)); + setting->setSenddelay(m_config->readEntry("senddelay", 0)); +} + +void SerialPersistence::save() +{ + SerialSetting * setting = static_cast(m_setting); + m_config->writeEntry("baud", setting->baud()); + m_config->writeEntry("bits", setting->bits()); + m_config->writeEntry("parity", setting->parity()); + m_config->writeEntry("stopbits", setting->stopbits()); + m_config->writeEntry("senddelay", setting->senddelay()); +} + +QMap SerialPersistence::secrets() const +{ + QMap map; + return map; +} + +void SerialPersistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + Q_UNUSED(secrets); + } +} Index: libs/internals/settings/ipv4persistence.cpp =================================================================== --- libs/internals/settings/ipv4persistence.cpp (revision 0) +++ libs/internals/settings/ipv4persistence.cpp (revision 1010672) @@ -0,0 +1,141 @@ +// This file is generated by kconfig_compiler from ipv4.kcfg. +// All changes you do to this file will be lost. + +#include "ipv4persistence.h" + +#include "ipv4.h" + +using namespace Knm; + +Ipv4Persistence::Ipv4Persistence(Ipv4Setting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +Ipv4Persistence::~Ipv4Persistence() +{ +} + +void Ipv4Persistence::load() +{ + Ipv4Setting * setting = static_cast(m_setting); + { + QString contents = m_config->readEntry("method", "Automatic"); + if (contents == "Automatic") + setting->setMethod(Ipv4Setting::EnumMethod::Automatic); + else if (contents == "LinkLocal") + setting->setMethod(Ipv4Setting::EnumMethod::LinkLocal); + else if (contents == "Manual") + setting->setMethod(Ipv4Setting::EnumMethod::Manual); + else if (contents == "Shared") + setting->setMethod(Ipv4Setting::EnumMethod::Shared); + + } + + // dns + QList dnsServers; + QStringList rawDnsServers = m_config->readEntry("dns", QStringList()); + foreach (QString server, rawDnsServers) { + dnsServers.append(QHostAddress(server)); + } + setting->setDns(dnsServers); + + setting->setDnssearch(m_config->readEntry("dnssearch", QStringList())); + + // addresses + QList addresses; + QStringList rawAddresses = m_config->readEntry("addresses", QStringList()); + foreach (QString rawAddress, rawAddresses) { + QStringList parts = rawAddress.split(';'); + if (parts.count() != 3) { // sanity check + continue; + } + QHostAddress ip(parts[0]); + QHostAddress gateway(parts[2]); + Solid::Control::IPv4Address addr(ip.toIPv4Address(), parts[1].toUInt(), gateway.toIPv4Address()); + addresses.append(addr); + } + setting->setAddresses(addresses); + + // routes + QList routes; + QStringList rawRoutes = m_config->readEntry("routes", QStringList()); + foreach (QString rawRoute, rawRoutes) { + QStringList parts = rawRoute.split(';'); + if (parts.count() != 4) { // sanity check + continue; + } + QHostAddress address(parts[0]); + quint32 prefix = parts[1].toUInt(); + QHostAddress nextHop(parts[2]); + quint32 metric = parts[3].toUInt(); + Solid::Control::IPv4Route route(address.toIPv4Address(), prefix, nextHop.toIPv4Address(), metric); + routes.append(route); + } + setting->setRoutes(routes); + setting->setIgnoredhcpdns(m_config->readEntry("ignoredhcpdns", false)); +} + +void Ipv4Persistence::save() +{ + Ipv4Setting * setting = static_cast(m_setting); + switch (setting->method()) { + case Ipv4Setting::EnumMethod::Automatic: + m_config->writeEntry("method", "Automatic"); + break; + case Ipv4Setting::EnumMethod::LinkLocal: + m_config->writeEntry("method", "LinkLocal"); + break; + case Ipv4Setting::EnumMethod::Manual: + m_config->writeEntry("method", "Manual"); + break; + case Ipv4Setting::EnumMethod::Shared: + m_config->writeEntry("method", "Shared"); + break; + } + + QStringList rawDns; + foreach (QHostAddress dns, setting->dns()) { + rawDns.append(dns.toString()); + } + if (!rawDns.isEmpty()) + m_config->writeEntry("dns", rawDns); + + if (!setting->dnssearch().isEmpty()) + m_config->writeEntry("dnssearch", setting->dnssearch()); + + QStringList rawAddresses; + foreach (Solid::Control::IPv4Address addr, setting->addresses()) { + QStringList rawAddress; + rawAddress << QHostAddress(addr.address()).toString() + << QString::number(addr.netMask()) + << QHostAddress(addr.gateway()).toString(); + rawAddresses << rawAddress.join(";"); + } + m_config->writeEntry("addresses", rawAddresses); + + QStringList rawRoutes; + foreach (Solid::Control::IPv4Route route, setting->routes()) { + QStringList rawRoute; + rawRoute << QHostAddress(route.route()).toString() + << QString::number(route.prefix()) + << QHostAddress(route.nextHop()).toString() + << QString::number(route.metric()); + rawRoutes << rawRoute; + } + m_config->writeEntry("routes", rawRoutes); + + m_config->writeEntry("ignoredhcpdns", setting->ignoredhcpdns()); +} + +QMap Ipv4Persistence::secrets() const +{ + QMap map; + return map; +} + +void Ipv4Persistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + Q_UNUSED(secrets); + } +} Index: libs/internals/settings/ipv4.h =================================================================== --- libs/internals/settings/ipv4.h (revision 0) +++ libs/internals/settings/ipv4.h (revision 1010672) @@ -0,0 +1,140 @@ +// This file is generated by kconfig_compiler from ipv4.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_IPV4SETTING_H +#define KNM_IPV4SETTING_H + +#include +#include +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" + +Q_DECLARE_METATYPE(Solid::Control::IPv4Address) +Q_DECLARE_METATYPE(Solid::Control::IPv4Route) + +namespace Knm { + +class KNMINTERNALS_EXPORT Ipv4Setting : public Setting +{ + public: + class EnumMethod + { + public: + enum type { Automatic, LinkLocal, Manual, Shared, COUNT }; + }; + + Ipv4Setting( ); + ~Ipv4Setting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set Method + */ + void setMethod( int v ) + { + mMethod = v; + } + + /** + Get Method + */ + int method() const + { + return mMethod; + } + + /** + Set DNS Servers + */ + void setDns( const QList & v ) + { + mDns = v; + } + + /** + Get DNS Servers + */ + QList dns() const + { + return mDns; + } + + /** + Set Search Domains + */ + void setDnssearch( const QStringList & v ) + { + mDnssearch = v; + } + + /** + Get Search Domains + */ + QStringList dnssearch() const + { + return mDnssearch; + } + + /** + Set IP Addresses + */ + void setAddresses( const QList & v ) + { + mAddresses = v; + } + + /** + Get IP Addresses + */ + QList addresses() const + { + return mAddresses; + } + + /** + Set Ignore DHCP DNS + */ + void setIgnoredhcpdns( bool v ) + { + mIgnoredhcpdns = v; + } + + /** + Get Ignore DHCP DNS + */ + bool ignoredhcpdns() const + { + return mIgnoredhcpdns; + } + + QList routes() const + { + return mRoutes; + } + + void setRoutes(QList routes) + { + mRoutes = routes; + } + + protected: + + // ipv4 + int mMethod; + QList mDns; + QStringList mDnssearch; + QList mAddresses; + QList mRoutes; + bool mIgnoredhcpdns; + private: +}; + +} + +#endif + Index: libs/internals/settings/802-11-wirelesspersistence.cpp =================================================================== --- libs/internals/settings/802-11-wirelesspersistence.cpp (revision 0) +++ libs/internals/settings/802-11-wirelesspersistence.cpp (revision 1010672) @@ -0,0 +1,90 @@ +// This file is generated by kconfig_compiler from 802-11-wireless.kcfg. +// All changes you do to this file will be lost. + +#include "802-11-wirelesspersistence.h" + +#include "802-11-wireless.h" + +using namespace Knm; + +WirelessPersistence::WirelessPersistence(WirelessSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +WirelessPersistence::~WirelessPersistence() +{ +} + +void WirelessPersistence::load() +{ + WirelessSetting * setting = static_cast(m_setting); + setting->setSsid(m_config->readEntry("ssid", QByteArray())); + { + QString contents = m_config->readEntry("mode", "infrastructure"); + if (contents == "infrastructure") + setting->setMode(WirelessSetting::EnumMode::infrastructure); + else if (contents == "adhoc") + setting->setMode(WirelessSetting::EnumMode::adhoc); + + } + { + QString contents = m_config->readEntry("band", "bg"); + if (contents == "a") + setting->setBand(WirelessSetting::EnumBand::a); + else if (contents == "bg") + setting->setBand(WirelessSetting::EnumBand::bg); + + } + setting->setChannel(m_config->readEntry("channel", 0)); + setting->setBssid(m_config->readEntry("bssid", QByteArray())); + setting->setRate(m_config->readEntry("rate", 0)); + setting->setTxpower(m_config->readEntry("txpower", 0)); + setting->setMacaddress(m_config->readEntry("macaddress", QByteArray())); + setting->setMtu(m_config->readEntry("mtu", 0)); + setting->setSeenbssids(m_config->readEntry("seenbssids", QStringList())); + setting->setSecurity(m_config->readEntry("security", "")); +} + +void WirelessPersistence::save() +{ + WirelessSetting * setting = static_cast(m_setting); + m_config->writeEntry("ssid", setting->ssid()); + switch (setting->mode()) { + case WirelessSetting::EnumMode::infrastructure: + m_config->writeEntry("mode", "infrastructure"); + break; + case WirelessSetting::EnumMode::adhoc: + m_config->writeEntry("mode", "adhoc"); + break; + } + switch (setting->band()) { + case WirelessSetting::EnumBand::a: + m_config->writeEntry("band", "a"); + break; + case WirelessSetting::EnumBand::bg: + m_config->writeEntry("band", "bg"); + break; + } + m_config->writeEntry("channel", setting->channel()); + m_config->writeEntry("bssid", setting->bssid()); + m_config->writeEntry("rate", setting->rate()); + m_config->writeEntry("txpower", setting->txpower()); + m_config->writeEntry("macaddress", setting->macaddress()); + m_config->writeEntry("mtu", setting->mtu()); + m_config->writeEntry("seenbssids", setting->seenbssids()); +kDebug() << setting->security(); + m_config->writeEntry("security", setting->security()); +} + +QMap WirelessPersistence::secrets() const +{ + QMap map; + return map; +} + +void WirelessPersistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + Q_UNUSED(secrets); + } +} Index: libs/internals/settings/pppoepersistence.cpp =================================================================== --- libs/internals/settings/pppoepersistence.cpp (revision 0) +++ libs/internals/settings/pppoepersistence.cpp (revision 1010672) @@ -0,0 +1,55 @@ +// This file is generated by kconfig_compiler from pppoe.kcfg. +// All changes you do to this file will be lost. + +#include "pppoepersistence.h" + +#include "pppoe.h" + +using namespace Knm; + +PppoePersistence::PppoePersistence(PppoeSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +PppoePersistence::~PppoePersistence() +{ +} + +void PppoePersistence::load() +{ + PppoeSetting * setting = static_cast(m_setting); + setting->setService(m_config->readEntry("service", "")); + setting->setUsername(m_config->readEntry("username", "")); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setPassword(m_config->readEntry("password", "")); + } +} + +void PppoePersistence::save() +{ + PppoeSetting * setting = static_cast(m_setting); + m_config->writeEntry("service", setting->service()); + m_config->writeEntry("username", setting->username()); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("password", setting->password()); + } +} + +QMap PppoePersistence::secrets() const +{ + PppoeSetting * setting = static_cast(m_setting); + QMap map; + map.insert(QLatin1String("password"), setting->password()); + return map; +} + +void PppoePersistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + PppoeSetting * setting = static_cast(m_setting); + setting->setPassword(secrets.value("password")); + setting->setSecretsAvailable(true); + } +} Index: libs/internals/settings/802-3-ethernet.h =================================================================== --- libs/internals/settings/802-3-ethernet.h (revision 0) +++ libs/internals/settings/802-3-ethernet.h (revision 1010672) @@ -0,0 +1,146 @@ +// This file is generated by kconfig_compiler from 802-3-ethernet.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_WIREDSETTING_H +#define KNM_WIREDSETTING_H + +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" +namespace Knm { + +class KNMINTERNALS_EXPORT WiredSetting : public Setting +{ + public: + class EnumPort + { + public: + enum type { tp, aui, bnc, mii, COUNT }; + }; + class EnumDuplex + { + public: + enum type { half, full, COUNT }; + }; + + WiredSetting( ); + ~WiredSetting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set Port + */ + void setPort( int v ) + { + mPort = v; + } + + /** + Get Port + */ + int port() const + { + return mPort; + } + + /** + Set Speed + */ + void setSpeed( uint v ) + { + mSpeed = v; + } + + /** + Get Speed + */ + uint speed() const + { + return mSpeed; + } + + /** + Set Duplex + */ + void setDuplex( int v ) + { + mDuplex = v; + } + + /** + Get Duplex + */ + int duplex() const + { + return mDuplex; + } + + /** + Set Auto negotiate + */ + void setAutonegotiate( bool v ) + { + mAutonegotiate = v; + } + + /** + Get Auto negotiate + */ + bool autonegotiate() const + { + return mAutonegotiate; + } + + /** + Set MAC Address + */ + void setMacaddress( const QByteArray & v ) + { + mMacaddress = v; + } + + /** + Get MAC Address + */ + QByteArray macaddress() const + { + return mMacaddress; + } + + /** + Set MTU + */ + void setMtu( uint v ) + { + mMtu = v; + } + + /** + Get MTU + */ + uint mtu() const + { + return mMtu; + } + + protected: + + // 802-3-ethernet + int mPort; + uint mSpeed; + int mDuplex; + bool mAutonegotiate; + QByteArray mMacaddress; + uint mMtu; + + private: +}; + +} + +#endif + Index: libs/internals/settings/gsmpersistence.cpp =================================================================== --- libs/internals/settings/gsmpersistence.cpp (revision 0) +++ libs/internals/settings/gsmpersistence.cpp (revision 1010672) @@ -0,0 +1,83 @@ +// This file is generated by kconfig_compiler from gsm.kcfg. +// All changes you do to this file will be lost. + +#include "gsmpersistence.h" + +#include "gsm.h" + +using namespace Knm; + +GsmPersistence::GsmPersistence(GsmSetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +GsmPersistence::~GsmPersistence() +{ +} + +void GsmPersistence::load() +{ + GsmSetting * setting = static_cast(m_setting); + setting->setNumber(m_config->readEntry("number", "*99#")); + setting->setUsername(m_config->readEntry("username", "")); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setPassword(m_config->readEntry("password", "")); + } + setting->setApn(m_config->readEntry("apn", "")); + setting->setNetworkid(m_config->readEntry("networkid", "")); + setting->setNetworktype(m_config->readEntry("networktype", 0)); + setting->setBand(m_config->readEntry("band", 0)); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setPin(m_config->readEntry("pin", "")); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setPuk(m_config->readEntry("puk", "")); + } +} + +void GsmPersistence::save() +{ + GsmSetting * setting = static_cast(m_setting); + m_config->writeEntry("number", setting->number()); + m_config->writeEntry("username", setting->username()); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("password", setting->password()); + } + m_config->writeEntry("apn", setting->apn()); + m_config->writeEntry("networkid", setting->networkid()); + m_config->writeEntry("networktype", setting->networktype()); + m_config->writeEntry("band", setting->band()); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("pin", setting->pin()); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("puk", setting->puk()); + } +} + +QMap GsmPersistence::secrets() const +{ + GsmSetting * setting = static_cast(m_setting); + QMap map; + map.insert(QLatin1String("password"), setting->password()); + map.insert(QLatin1String("pin"), setting->pin()); + map.insert(QLatin1String("puk"), setting->puk()); + return map; +} + +void GsmPersistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + GsmSetting * setting = static_cast(m_setting); + setting->setPassword(secrets.value("password")); + setting->setPin(secrets.value("pin")); + setting->setPuk(secrets.value("puk")); + setting->setSecretsAvailable(true); + } +} Index: libs/internals/settings/gsm.h =================================================================== --- libs/internals/settings/gsm.h (revision 0) +++ libs/internals/settings/gsm.h (revision 1010672) @@ -0,0 +1,187 @@ +// This file is generated by kconfig_compiler from gsm.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_GSMSETTING_H +#define KNM_GSMSETTING_H + +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" +namespace Knm { + +class KNMINTERNALS_EXPORT GsmSetting : public Setting +{ + public: + + GsmSetting( ); + ~GsmSetting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set Number + */ + void setNumber( const QString & v ) + { + mNumber = v; + } + + /** + Get Number + */ + QString number() const + { + return mNumber; + } + + /** + Set Username + */ + void setUsername( const QString & v ) + { + mUsername = v; + } + + /** + Get Username + */ + QString username() const + { + return mUsername; + } + + /** + Set Password + */ + void setPassword( const QString & v ) + { + mPassword = v; + } + + /** + Get Password + */ + QString password() const + { + return mPassword; + } + + /** + Set APN + */ + void setApn( const QString & v ) + { + mApn = v; + } + + /** + Get APN + */ + QString apn() const + { + return mApn; + } + + /** + Set Network ID + */ + void setNetworkid( const QString & v ) + { + mNetworkid = v; + } + + /** + Get Network ID + */ + QString networkid() const + { + return mNetworkid; + } + + /** + Set Network Type + */ + void setNetworktype( int v ) + { + mNetworktype = v; + } + + /** + Get Network Type + */ + int networktype() const + { + return mNetworktype; + } + + /** + Set Band + */ + void setBand( int v ) + { + mBand = v; + } + + /** + Get Band + */ + int band() const + { + return mBand; + } + + /** + Set PIN + */ + void setPin( const QString & v ) + { + mPin = v; + } + + /** + Get PIN + */ + QString pin() const + { + return mPin; + } + + /** + Set PUK + */ + void setPuk( const QString & v ) + { + mPuk = v; + } + + /** + Get PUK + */ + QString puk() const + { + return mPuk; + } + + protected: + + // gsm + QString mNumber; + QString mUsername; + QString mPassword; + QString mApn; + QString mNetworkid; + int mNetworktype; + int mBand; + QString mPin; + QString mPuk; + + private: +}; + +} + +#endif + Index: libs/internals/settings/802-11-wireless-security.h =================================================================== --- libs/internals/settings/802-11-wireless-security.h (revision 0) +++ libs/internals/settings/802-11-wireless-security.h (revision 1010672) @@ -0,0 +1,304 @@ +// This file is generated by kconfig_compiler from 802-11-wireless-security.kcfg. +// All changes you do to this file will be lost. +#ifndef KNM_WIRELESSSECURITYSETTING_H +#define KNM_WIRELESSSECURITYSETTING_H + +#include +#include +#include +#include "setting.h" +#include "knminternals_export.h" +namespace Knm { + +class KNMINTERNALS_EXPORT WirelessSecuritySetting : public Setting +{ + public: + class EnumSecurityType + { + public: + enum type { None, StaticWep, Leap, DynamicWep, WpaPsk, WpaEap, Wpa2Psk, Wpa2Eap, COUNT }; + }; + class EnumKeymgmt + { + public: + enum type { None, Ieee8021x, WPANone, WPAPSK, WPAEAP, COUNT }; + }; + class EnumAuthalg + { + public: + enum type { none, open, shared, leap, COUNT }; + }; + + WirelessSecuritySetting( ); + ~WirelessSecuritySetting(); + + QString name() const; + + bool hasSecrets() const; + + /** + Set Security type + */ + void setSecurityType( int v ) + { + mSecurityType = v; + } + + /** + Get Security type + */ + int securityType() const + { + return mSecurityType; + } + + /** + Set Key management + */ + void setKeymgmt( int v ) + { + mKeymgmt = v; + } + + /** + Get Key management + */ + int keymgmt() const + { + return mKeymgmt; + } + + /** + Set WEP TX key index + */ + void setWeptxkeyindex( uint v ) + { + mWeptxkeyindex = v; + } + + /** + Get WEP TX key index + */ + uint weptxkeyindex() const + { + return mWeptxkeyindex; + } + + /** + Set Authentication algorithm + */ + void setAuthalg( int v ) + { + mAuthalg = v; + } + + /** + Get Authentication algorithm + */ + int authalg() const + { + return mAuthalg; + } + + /** + Set Protocols + */ + void setProto( const QStringList & v ) + { + mProto = v; + } + + /** + Get Protocols + */ + QStringList proto() const + { + return mProto; + } + + /** + Set Pairwise + */ + void setPairwise( const QStringList & v ) + { + mPairwise = v; + } + + /** + Get Pairwise + */ + QStringList pairwise() const + { + return mPairwise; + } + + /** + Set Group + */ + void setGroup( const QStringList & v ) + { + mGroup = v; + } + + /** + Get Group + */ + QStringList group() const + { + return mGroup; + } + + /** + Set LEAP Username + */ + void setLeapusername( const QString & v ) + { + mLeapusername = v; + } + + /** + Get LEAP Username + */ + QString leapusername() const + { + return mLeapusername; + } + + /** + Set WEP key 0 + */ + void setWepkey0( const QString & v ) + { + mWepkey0 = v; + } + + /** + Get WEP key 0 + */ + QString wepkey0() const + { + return mWepkey0; + } + + /** + Set WEP key 1 + */ + void setWepkey1( const QString & v ) + { + mWepkey1 = v; + } + + /** + Get WEP key 1 + */ + QString wepkey1() const + { + return mWepkey1; + } + + /** + Set WEP key 2 + */ + void setWepkey2( const QString & v ) + { + mWepkey2 = v; + } + + /** + Get WEP key 2 + */ + QString wepkey2() const + { + return mWepkey2; + } + + /** + Set WEP key 3 + */ + void setWepkey3( const QString & v ) + { + mWepkey3 = v; + } + + /** + Get WEP key 3 + */ + QString wepkey3() const + { + return mWepkey3; + } + + /** + Set PSK + */ + void setPsk( const QString & v ) + { + mPsk = v; + } + + /** + Get PSK + */ + QString psk() const + { + return mPsk; + } + + /** + Set LEAP Password + */ + void setLeappassword( const QString & v ) + { + mLeappassword = v; + } + + /** + Get LEAP Password + */ + QString leappassword() const + { + return mLeappassword; + } + + /** + Set WEP Passphrase + */ + void setWeppassphrase( const QString & v ) + { + mWeppassphrase = v; + } + + /** + Get WEP Passphrase + */ + QString weppassphrase() const + { + return mWeppassphrase; + } + + protected: + + // 802-11-wireless-security + int mSecurityType; + int mKeymgmt; + uint mWeptxkeyindex; + int mAuthalg; + QStringList mProto; + QStringList mPairwise; + QStringList mGroup; + QString mLeapusername; + QString mWepkey0; + QString mWepkey1; + QString mWepkey2; + QString mWepkey3; + QString mPsk; + QString mLeappassword; + QString mWeppassphrase; + + private: +}; + +} + +#endif + Index: libs/internals/settings/802-11-wireless-securitypersistence.cpp =================================================================== --- libs/internals/settings/802-11-wireless-securitypersistence.cpp (revision 0) +++ libs/internals/settings/802-11-wireless-securitypersistence.cpp (revision 1010672) @@ -0,0 +1,229 @@ +// This file is generated by kconfig_compiler from 802-11-wireless-security.kcfg. +// All changes you do to this file will be lost. + +#include "802-11-wireless-securitypersistence.h" + +#include "802-11-wireless-security.h" + +using namespace Knm; + +WirelessSecurityPersistence::WirelessSecurityPersistence(WirelessSecuritySetting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) : SettingPersistence(setting, config, mode) +{ +} + +WirelessSecurityPersistence::~WirelessSecurityPersistence() +{ +} + +void WirelessSecurityPersistence::load() +{ + WirelessSecuritySetting * setting = static_cast(m_setting); + { + if (m_config->exists()) { // this persistence saves nothing if there is no security, so the + // group won't exist. not indenting the code inside this test to keep the diff clean ;) + QString contents = m_config->readEntry("securityType", "None"); + if (contents == "None") + setting->setSecurityType(WirelessSecuritySetting::EnumSecurityType::None); + else if (contents == "StaticWep") + setting->setSecurityType(WirelessSecuritySetting::EnumSecurityType::StaticWep); + else if (contents == "Leap") + setting->setSecurityType(WirelessSecuritySetting::EnumSecurityType::Leap); + else if (contents == "DynamicWep") + setting->setSecurityType(WirelessSecuritySetting::EnumSecurityType::DynamicWep); + else if (contents == "WpaPsk") + setting->setSecurityType(WirelessSecuritySetting::EnumSecurityType::WpaPsk); + else if (contents == "WpaEap") + setting->setSecurityType(WirelessSecuritySetting::EnumSecurityType::WpaEap); + else if (contents == "Wpa2Psk") + setting->setSecurityType(WirelessSecuritySetting::EnumSecurityType::Wpa2Psk); + else if (contents == "Wpa2Eap") + setting->setSecurityType(WirelessSecuritySetting::EnumSecurityType::Wpa2Eap); + + } + { + QString contents = m_config->readEntry("keymgmt", "None"); + if (contents == "None") + setting->setKeymgmt(WirelessSecuritySetting::EnumKeymgmt::None); + else if (contents == "Ieee8021x") + setting->setKeymgmt(WirelessSecuritySetting::EnumKeymgmt::Ieee8021x); + else if (contents == "WPANone") + setting->setKeymgmt(WirelessSecuritySetting::EnumKeymgmt::WPANone); + else if (contents == "WPAPSK") + setting->setKeymgmt(WirelessSecuritySetting::EnumKeymgmt::WPAPSK); + else if (contents == "WPAEAP") + setting->setKeymgmt(WirelessSecuritySetting::EnumKeymgmt::WPAEAP); + + } + setting->setWeptxkeyindex(m_config->readEntry("weptxkeyindex", 0)); + { + QString contents = m_config->readEntry("authalg", "none"); + if (contents == "none") + setting->setAuthalg(WirelessSecuritySetting::EnumAuthalg::none); + else if (contents == "open") + setting->setAuthalg(WirelessSecuritySetting::EnumAuthalg::open); + else if (contents == "shared") + setting->setAuthalg(WirelessSecuritySetting::EnumAuthalg::shared); + else if (contents == "leap") + setting->setAuthalg(WirelessSecuritySetting::EnumAuthalg::leap); + + } + setting->setProto(m_config->readEntry("proto", QStringList())); + setting->setPairwise(m_config->readEntry("pairwise", QStringList())); + setting->setGroup(m_config->readEntry("group", QStringList())); + setting->setLeapusername(m_config->readEntry("leapusername", "")); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setWepkey0(m_config->readEntry("wepkey0", "")); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setWepkey1(m_config->readEntry("wepkey1", "")); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setWepkey2(m_config->readEntry("wepkey2", "")); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setWepkey3(m_config->readEntry("wepkey3", "")); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setPsk(m_config->readEntry("psk", "")); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setLeappassword(m_config->readEntry("leappassword", "")); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + setting->setWeppassphrase(m_config->readEntry("weppassphrase", "")); + } + } +} + +void WirelessSecurityPersistence::save() +{ + WirelessSecuritySetting * setting = static_cast(m_setting); + switch (setting->securityType()) { + case WirelessSecuritySetting::EnumSecurityType::None: + return; // don't save anything if no encryption + break; + case WirelessSecuritySetting::EnumSecurityType::StaticWep: + m_config->writeEntry("securityType", "StaticWep"); + break; + case WirelessSecuritySetting::EnumSecurityType::Leap: + m_config->writeEntry("securityType", "Leap"); + break; + case WirelessSecuritySetting::EnumSecurityType::DynamicWep: + m_config->writeEntry("securityType", "DynamicWep"); + break; + case WirelessSecuritySetting::EnumSecurityType::WpaPsk: + m_config->writeEntry("securityType", "WpaPsk"); + break; + case WirelessSecuritySetting::EnumSecurityType::WpaEap: + m_config->writeEntry("securityType", "WpaEap"); + break; + case WirelessSecuritySetting::EnumSecurityType::Wpa2Psk: + m_config->writeEntry("securityType", "Wpa2Psk"); + break; + case WirelessSecuritySetting::EnumSecurityType::Wpa2Eap: + m_config->writeEntry("securityType", "Wpa2Eap"); + break; + } + switch (setting->keymgmt()) { + case WirelessSecuritySetting::EnumKeymgmt::None: + m_config->writeEntry("keymgmt", "None"); + break; + case WirelessSecuritySetting::EnumKeymgmt::Ieee8021x: + m_config->writeEntry("keymgmt", "Ieee8021x"); + break; + case WirelessSecuritySetting::EnumKeymgmt::WPANone: + m_config->writeEntry("keymgmt", "WPANone"); + break; + case WirelessSecuritySetting::EnumKeymgmt::WPAPSK: + m_config->writeEntry("keymgmt", "WPAPSK"); + break; + case WirelessSecuritySetting::EnumKeymgmt::WPAEAP: + m_config->writeEntry("keymgmt", "WPAEAP"); + break; + } + m_config->writeEntry("weptxkeyindex", setting->weptxkeyindex()); + switch (setting->authalg()) { + case WirelessSecuritySetting::EnumAuthalg::none: + m_config->writeEntry("authalg", "none"); + break; + case WirelessSecuritySetting::EnumAuthalg::open: + m_config->writeEntry("authalg", "open"); + break; + case WirelessSecuritySetting::EnumAuthalg::shared: + m_config->writeEntry("authalg", "shared"); + break; + case WirelessSecuritySetting::EnumAuthalg::leap: + m_config->writeEntry("authalg", "leap"); + break; + } + m_config->writeEntry("proto", setting->proto()); + m_config->writeEntry("pairwise", setting->pairwise()); + m_config->writeEntry("group", setting->group()); + m_config->writeEntry("leapusername", setting->leapusername()); + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("wepkey0", setting->wepkey0()); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("wepkey1", setting->wepkey1()); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("wepkey2", setting->wepkey2()); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("wepkey3", setting->wepkey3()); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("psk", setting->psk()); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("leappassword", setting->leappassword()); + } + // SECRET + if (m_storageMode != ConnectionPersistence::Secure) { + m_config->writeEntry("weppassphrase", setting->weppassphrase()); + } +} + +QMap WirelessSecurityPersistence::secrets() const +{ + WirelessSecuritySetting * setting = static_cast(m_setting); + QMap map; + if (setting->securityType() != WirelessSecuritySetting::EnumSecurityType::None) { // don't save anything if security is disabled + map.insert(QLatin1String("wepkey0"), setting->wepkey0()); + map.insert(QLatin1String("wepkey1"), setting->wepkey1()); + map.insert(QLatin1String("wepkey2"), setting->wepkey2()); + map.insert(QLatin1String("wepkey3"), setting->wepkey3()); + map.insert(QLatin1String("psk"), setting->psk()); + map.insert(QLatin1String("leappassword"), setting->leappassword()); + map.insert(QLatin1String("weppassphrase"), setting->weppassphrase()); + } + return map; +} + +void WirelessSecurityPersistence::restoreSecrets(QMap secrets) const +{ + if (m_storageMode == ConnectionPersistence::Secure) { + WirelessSecuritySetting * setting = static_cast(m_setting); + setting->setWepkey0(secrets.value("wepkey0")); + setting->setWepkey1(secrets.value("wepkey1")); + setting->setWepkey2(secrets.value("wepkey2")); + setting->setWepkey3(secrets.value("wepkey3")); + setting->setPsk(secrets.value("psk")); + setting->setLeappassword(secrets.value("leappassword")); + setting->setWeppassphrase(secrets.value("weppassphrase")); + setting->setSecretsAvailable(true); + } +} Index: libs/internals/settingpersistence.cpp =================================================================== --- libs/internals/settingpersistence.cpp (revision 0) +++ libs/internals/settingpersistence.cpp (revision 1010672) @@ -0,0 +1,38 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#include "settingpersistence.h" + +#include + +using namespace Knm; + +SettingPersistence::SettingPersistence(Setting * setting, KSharedConfig::Ptr config, ConnectionPersistence::SecretStorageMode mode) + : m_setting(setting), m_config(new KConfigGroup(config, setting->name())), m_storageMode(mode) +{ + +} + +SettingPersistence::~SettingPersistence() +{ + delete m_config; +} + +// vim: sw=4 sts=4 et tw=100 Index: libs/internals/update_clean_settings =================================================================== --- libs/internals/update_clean_settings (revision 0) +++ libs/internals/update_clean_settings (revision 1010672) @@ -0,0 +1 @@ +make knm_compiler && for i in schemas/*.kcfg; do j=`basename $i .kcfg`; if [ -e schemas/$j.kcfgc ]; then /space/kde/builds/trunk/playground/base/plasma/applets/networkmanager/libs/internals/knm_compiler schemas/$j.kcfg schemas/$j.kcfgc -d origsettings; fi; done Index: libs/internals/wirelessobject.cpp =================================================================== --- libs/internals/wirelessobject.cpp (revision 0) +++ libs/internals/wirelessobject.cpp (revision 1010672) @@ -0,0 +1,81 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#include "wirelessobject.h" + +Knm::WirelessObject::WirelessObject(const QString & ssid, int strength, Solid::Control::WirelessNetworkInterface::Capabilities interfaceCapabilities, Solid::Control::AccessPoint::Capabilities apCapabilities, Solid::Control::AccessPoint::WpaFlags wpaFlags, Solid::Control::AccessPoint::WpaFlags rsnFlags, Solid::Control::WirelessNetworkInterface::OperationMode mode) +: m_ssid(ssid), + m_strength(strength), + m_interfaceCapabilities(interfaceCapabilities), + m_apCapabilities(apCapabilities), + m_wpaFlags(wpaFlags), + m_rsnFlags(rsnFlags), + m_operationMode(mode) +{ + +} + +Knm::WirelessObject::~WirelessObject() +{ + +} + +QString Knm::WirelessObject::ssid() const +{ + return m_ssid; +} + +int Knm::WirelessObject::strength() const +{ + return m_strength; +} + +void Knm::WirelessObject::setStrength(int strength) +{ + m_strength = strength; +} + +Solid::Control::WirelessNetworkInterface::Capabilities Knm::WirelessObject::interfaceCapabilities() const +{ + return m_interfaceCapabilities; +} + +Solid::Control::AccessPoint::Capabilities Knm::WirelessObject::apCapabilities() const +{ + return m_apCapabilities; +} + + +Solid::Control::AccessPoint::WpaFlags Knm::WirelessObject::wpaFlags() const +{ + return m_wpaFlags; +} + +Solid::Control::AccessPoint::WpaFlags Knm::WirelessObject::rsnFlags() const +{ + return m_rsnFlags; +} + +Solid::Control::WirelessNetworkInterface::OperationMode Knm::WirelessObject::operationMode() const +{ + return m_operationMode; +} + +// vim: sw=4 sts=4 et tw=100 Index: libs/internals/activatable.h =================================================================== --- libs/internals/activatable.h (revision 0) +++ libs/internals/activatable.h (revision 1010672) @@ -0,0 +1,66 @@ +/* +Copyright 2008 Frederik Gladhorn +Copyright 2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef KNM_INTERNALS_ACTIVATABLE_H +#define KNM_INTERNALS_ACTIVATABLE_H + +#include "knminternals_export.h" + +#include +#include + +namespace Knm { + +class KNMINTERNALS_EXPORT Activatable : public QObject +{ +Q_OBJECT +Q_PROPERTY(QString deviceUni READ deviceUni) +Q_PROPERTY(QString type READ activatableType) +public: + enum ActivatableType { + InterfaceConnection, + WirelessInterfaceConnection, + WirelessNetwork, + UnconfiguredInterface, + VpnInterfaceConnection + }; + + virtual ~Activatable(); + + ActivatableType activatableType() const; + void setDeviceUni(const QString& deviceUni); + QString deviceUni() const; +public Q_SLOTS: + void activate(); +Q_SIGNALS: + void activated(); + void changed(); +protected: + Activatable(ActivatableType type, const QString &deviceUni, QObject * parent); + +private: + ActivatableType m_type; + QString m_deviceUni; +}; + +} // namespace + +#endif Index: libs/internals/interfaceconnection.h =================================================================== --- libs/internals/interfaceconnection.h (revision 0) +++ libs/internals/interfaceconnection.h (revision 1010672) @@ -0,0 +1,85 @@ +/* +Copyright 2008 Frederik Gladhorn +Copyright 2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef KNM_EXTERNALS_INTERFACECONNECTION_H +#define KNM_EXTERNALS_INTERFACECONNECTION_H + +#include "activatable.h" + +#include +#include + +#include "knminternals_export.h" + +#include "connection.h" + +namespace Knm { + +class KNMINTERNALS_EXPORT InterfaceConnection : public Activatable +{ +Q_OBJECT +Q_PROPERTY(uint type READ connectionType) +Q_PROPERTY(QString uuid READ connectionUuid) +Q_PROPERTY(QString name READ connectionName) +Q_PROPERTY(uint activationState READ activationState) +Q_PROPERTY(bool hasDefaultRoute READ hasDefaultRoute WRITE setHasDefaultRoute) + +public: + enum ActivationState { Unknown, Activating, Activated }; + InterfaceConnection(const QUuid & connectionUuid, const QString & connectionName, const QString & deviceUni, QObject * parent); + virtual ~InterfaceConnection(); + + void setConnectionType(Knm::Connection::Type type); + Knm::Connection::Type connectionType() const; + + QUuid connectionUuid() const; + + void setConnectionName(const QString& name); + QString connectionName() const; + + void setActivationState(ActivationState state); + ActivationState activationState() const; + + /** + * Indicates if this InterfaceConnection provides the default route + * Only valid if Activated + */ + void setHasDefaultRoute(bool hasDefault); + bool hasDefaultRoute() const; + void disconnect(); + +Q_SIGNALS: + void activationStateChanged(Knm::InterfaceConnection::ActivationState); + void hasDefaultRouteChanged(bool); + void deactivated(); +protected: + InterfaceConnection(const QUuid & connectionUuid, const QString & connectionName, ActivatableType type, const QString & deviceUni, QObject * parent); + +private: + Knm::Connection::Type m_type; + QUuid m_uuid; + QString m_name; + ActivationState m_state; + bool m_hasDefaultRoute; +}; +} // namespace + +#endif Index: libs/internals/configxml.cpp =================================================================== --- libs/internals/configxml.cpp (revision 0) +++ libs/internals/configxml.cpp (revision 1010672) @@ -0,0 +1,651 @@ +/* + * Copyright 2007 Aaron Seigo + * Copyright 2008 Will Stephenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "configxml.h" + +#include +#include +#include +#include +#include + +#include +#include + +#include "secretstoragehelper.h" + +class ItemSecret : public KCoreConfigSkeleton::ItemString +{ +/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ +public: + ItemSecret(const QString & _group, const QString & _key, + QString & _reference, bool readSecrets, SecretStorageHelper * secretStorage) + : KCoreConfigSkeleton::ItemString(_group, _key, _reference, QLatin1String("")), + m_readSecrets(readSecrets), + m_secretStorage(secretStorage) + { + } + virtual void readConfig(KConfig * config) + { + if (!m_readSecrets) { + //KCoreConfigSkeleton::ItemString::readConfig(config); + QString secret; + m_secretStorage->readSecret(name(), secret); + kDebug() << "got secret: " << secret; + } + } + virtual void writeConfig(KConfig * config) + { + KCoreConfigSkeleton::ItemString::writeConfig(config); + kDebug() << "wrote secret: " << KCoreConfigSkeleton::ItemString::property(); + m_secretStorage->writeSecret(name(), KCoreConfigSkeleton::ItemString::property().toString()); + } +private: + bool m_readSecrets; + SecretStorageHelper * m_secretStorage; +}; + +class ConfigXml::Private +{ + public: + Private(bool theReadSecrets, SecretStorageHelper * helper) : readSecrets(theReadSecrets), secretStorageHelper(helper) + { + } + ~Private() + { + qDeleteAll(bools); + qDeleteAll(strings); + qDeleteAll(stringlists); + qDeleteAll(colors); + qDeleteAll(fonts); + qDeleteAll(ints); + qDeleteAll(uints); + qDeleteAll(urls); + qDeleteAll(dateTimes); + qDeleteAll(doubles); + qDeleteAll(intlists); + qDeleteAll(longlongs); + qDeleteAll(points); + qDeleteAll(rects); + qDeleteAll(sizes); + qDeleteAll(ulonglongs); + qDeleteAll(urllists); + qDeleteAll(bytearrays); + delete secretStorageHelper; + } + + bool* newBool() + { + bool* v = new bool; + bools.append(v); + return v; + } + + QString* newString() + { + QString* v = new QString; + strings.append(v); + return v; + } + + QStringList* newStringList() + { + QStringList* v = new QStringList; + stringlists.append(v); + return v; + } + + QColor* newColor() + { + QColor* v = new QColor; + colors.append(v); + return v; + } + + QFont* newFont() + { + QFont* v = new QFont; + fonts.append(v); + return v; + } + + qint32* newInt() + { + qint32* v = new qint32; + ints.append(v); + return v; + } + + quint32* newUint() + { + quint32* v = new quint32; + uints.append(v); + return v; + } + + KUrl* newUrl() + { + KUrl* v = new KUrl; + urls.append(v); + return v; + } + + QDateTime* newDateTime() + { + QDateTime* v = new QDateTime; + dateTimes.append(v); + return v; + } + + double* newDouble() + { + double* v = new double; + doubles.append(v); + return v; + } + + QList* newIntList() + { + QList* v = new QList; + intlists.append(v); + return v; + } + + qint64* newLongLong() + { + qint64* v = new qint64; + longlongs.append(v); + return v; + } + + QPoint* newPoint() + { + QPoint* v = new QPoint; + points.append(v); + return v; + } + + QRect* newRect() + { + QRect* v = new QRect; + rects.append(v); + return v; + } + + QSize* newSize() + { + QSize* v = new QSize; + sizes.append(v); + return v; + } + + quint64* newULongLong() + { + quint64* v = new quint64; + ulonglongs.append(v); + return v; + } + + KUrl::List* newUrlList() + { + KUrl::List* v = new KUrl::List; + urllists.append(v); + return v; + } + + QByteArray* newByteArray() + { + QByteArray* v = new QByteArray; + bytearrays.append(v); + return v; + } + + void parse(ConfigXml *configXml, QIODevice *xml); + + QList bools; + QList strings; + QList stringlists; + QList colors; + QList fonts; + QList ints; + QList uints; + QList urls; + QList dateTimes; + QList doubles; + QList*> intlists; + QList longlongs; + QList points; + QList rects; + QList sizes; + QList ulonglongs; + QList urllists; + QMap keysToNames; + QList bytearrays; + bool readSecrets; + SecretStorageHelper * secretStorageHelper; +}; + +ItemByteArray::ItemByteArray(const QString & _group, const QString & _key, + QByteArray & reference, const QByteArray & defaultValue) +: KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) +{ +} + +void ItemByteArray::readConfig(KConfig * config) +{ + KConfigGroup cg(config, mGroup ); + + mReference = cg.readEntry( mKey, mDefault ); + mLoadedValue = mReference; + + readImmutability( cg ); +} + +void ItemByteArray::setProperty(const QVariant & p) +{ + //at this point this is probably a string in dotted format + // we don't know if NM expects this or some other series of bytes + if (p.toString() != QLatin1String(":::::")) { + mReference = p.toByteArray(); + } +} + +bool ItemByteArray::isEqual(const QVariant &p) const +{ + return mReference == p.toByteArray(); +} + +QVariant ItemByteArray::property() const +{ + return QVariant(mReference); +} + +class ConfigXmlHandler : public QXmlDefaultHandler +{ +public: + ConfigXmlHandler(ConfigXml* config, ConfigXml::Private* d, bool readSecrets, SecretStorageHelper * storage); + bool startElement(const QString &namespaceURI, const QString & localName, const QString &qName, const QXmlAttributes &atts); + bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName); + bool characters(const QString &ch); + +private: + void addItem(); + void resetState(); + + ConfigXml* m_config; + ConfigXml::Private* d; + bool m_readSecrets; + SecretStorageHelper * m_secretStorage; + int m_min; + int m_max; + QString m_name; + QString m_key; + QString m_type; + QString m_label; + QString m_default; + QString m_cdata; + QString m_whatsThis; + KConfigSkeleton::ItemEnum::Choice m_choice; + QList m_enumChoices; + bool m_haveMin; + bool m_haveMax; + bool m_inChoice; + bool m_secret; +}; + +void ConfigXml::Private::parse(ConfigXml *configXml, QIODevice *xml) +{ + QXmlInputSource source(xml); + QXmlSimpleReader reader; + ConfigXmlHandler handler(configXml, this, readSecrets, secretStorageHelper ); + reader.setContentHandler(&handler); + reader.parse(&source, false); +} + +ConfigXmlHandler::ConfigXmlHandler(ConfigXml* config, ConfigXml::Private* d, bool readSecrets, SecretStorageHelper * storage) + : QXmlDefaultHandler(), + m_config(config), + d(d), + m_readSecrets(readSecrets), + m_secretStorage(storage) +{ + resetState(); +} + +bool ConfigXmlHandler::startElement(const QString &namespaceURI, const QString &localName, + const QString &qName, const QXmlAttributes &attrs) +{ + Q_UNUSED(namespaceURI) + Q_UNUSED(qName) + +// kDebug() << "ConfigXmlHandler::startElement(" << localName << qName; + int numAttrs = attrs.count(); + QString tag = localName.toLower(); + if (tag == "group") { + for (int i = 0; i < numAttrs; ++i) { + QString name = attrs.localName(i).toLower(); + if (name == "name") { + kDebug() << "set group to " << attrs.value(i); + m_config->setCurrentGroup(attrs.value(i)); + } + } + } else if (tag == "entry") { + for (int i = 0; i < numAttrs; ++i) { + QString name = attrs.localName(i).toLower(); + if (name == "name") { + m_name = attrs.value(i); + } else if (name == "type") { + m_type = attrs.value(i).toLower(); + } else if (name == "key") { + m_key = attrs.value(i); + } else if (name == "secret") { + m_secret = (attrs.value(i).toLower() == "true"); + kDebug() << "Found a secret: " << m_name << (m_secret ? "TRUE" : "FALSE"); + } + } + } else if (tag == "choice") { + m_choice.name.clear(); + m_choice.label.clear(); + m_choice.whatsThis.clear(); + for (int i = 0; i < numAttrs; ++i) { + QString name = attrs.localName(i).toLower(); + if (name == "name") { + m_choice.name = attrs.value(i); + } + } + m_inChoice = true; + } + + return true; +} + +bool ConfigXmlHandler::characters(const QString &ch) +{ + m_cdata.append(ch); + return true; +} + +bool ConfigXmlHandler::endElement(const QString &namespaceURI, const QString &localName, const QString &qName) +{ + Q_UNUSED(namespaceURI) + Q_UNUSED(qName) + +// kDebug() << "ConfigXmlHandler::endElement(" << localName << qName; + QString tag = localName.toLower(); + if (tag == "entry") { + addItem(); + resetState(); + } else if (tag == "label") { + if (m_inChoice) { + m_choice.label = m_cdata; + } else { + m_label = m_cdata; + } + } else if (tag == "whatsthis") { + if (m_inChoice) { + m_choice.whatsThis = m_cdata; + } else { + m_whatsThis = m_cdata; + } + } else if (tag == "default") { + m_default = m_cdata; + } else if (tag == "min") { + m_min = m_cdata.toInt(&m_haveMin); + } else if (tag == "max") { + m_max = m_cdata.toInt(&m_haveMax); + } else if (tag == "choice") { + m_enumChoices.append(m_choice); + m_inChoice = false; + } + + m_cdata.clear(); + return true; +} + +void ConfigXmlHandler::addItem() +{ + kDebug() << m_name; + if (m_name.isEmpty()) { + return; + } + + KConfigSkeletonItem* item = 0; + + if (m_type == "bool") { + bool defaultValue = m_default.toLower() == "true"; + item = m_config->addItemBool(m_name, *d->newBool(), defaultValue, m_key); + } else if (m_type == "color") { + item = m_config->addItemColor(m_name, *d->newColor(), QColor(m_default), m_key); + } else if (m_type == "datetime") { + item = m_config->addItemDateTime(m_name, *d->newDateTime(), + QDateTime::fromString(m_default), m_key); + } else if (m_type == "enum") { + QString keyToUse = (m_key.isEmpty() ? m_name : m_key ); + KConfigSkeleton::ItemEnum* enumItem = + new KConfigSkeleton::ItemEnum(m_config->currentGroup(), + m_key, *d->newInt(), + m_enumChoices, + m_default.toUInt()); + enumItem->setName(m_name); + m_config->addItem(enumItem, keyToUse); + item = enumItem; + } else if (m_type == "font") { + item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key); + } else if (m_type == "int") { + KConfigSkeleton::ItemInt* intItem = m_config->addItemInt(m_name, + *d->newInt(), + m_default.toInt(), + m_key); + if (m_haveMin) { + intItem->setMinValue(m_min); + } + if (m_haveMax) { + intItem->setMaxValue(m_max); + } + item = intItem; + } else if (m_type == "password") { + item = m_config->addItemPassword(m_name, *d->newString(), m_default, m_key); + } else if (m_type == "path") { + item = m_config->addItemPath(m_name, *d->newString(), m_default, m_key); + } else if (m_type == "string") { + if (m_secret) { + kDebug() << "Adding a secret item:" << m_name; + QString keyToUse = (m_key.isEmpty() ? m_name : m_key ); + ItemSecret * item = new ItemSecret(m_config->currentGroup(), keyToUse, *d->newString(), + m_readSecrets, m_secretStorage); + m_config->addItem( item, keyToUse ); + } else { + kDebug() << "Adding a normal string" << m_name; + item = m_config->addItemString(m_name, *d->newString(), m_default, m_key); + } + } else if (m_type == "stringlist") { + //FIXME: the split() is naive and will break on lists with ,'s in them + item = m_config->addItemStringList(m_name, *d->newStringList(), m_default.split(","), m_key); + } else if (m_type == "uint") { + KConfigSkeleton::ItemUInt* uintItem = m_config->addItemUInt(m_name, + *d->newUint(), + m_default.toUInt(), + m_key); + if (m_haveMin) { + uintItem->setMinValue(m_min); + } + if (m_haveMax) { + uintItem->setMaxValue(m_max); + } + item = uintItem; + } else if (m_type == "url") { + KConfigSkeleton::ItemUrl* urlItem = + new KConfigSkeleton::ItemUrl(m_config->currentGroup(), + m_key, *d->newUrl(), + m_default); + urlItem->setName(m_name); + m_config->addItem(urlItem, m_name); + item = urlItem; + } else if (m_type == "double") { + KConfigSkeleton::ItemDouble* doubleItem = m_config->addItemDouble(m_name, + *d->newDouble(), m_default.toDouble(), m_key); + if (m_haveMin) { + doubleItem->setMinValue(m_min); + } + if (m_haveMax) { + doubleItem->setMaxValue(m_max); + } + item = doubleItem; + } else if (m_type == "intlist") { + QStringList tmpList = m_default.split(","); + QList defaultList; + foreach (const QString &tmp, tmpList) { + defaultList.append(tmp.toInt()); + } + item = m_config->addItemIntList(m_name, *d->newIntList(), defaultList, m_key); + } else if (m_type == "longlong") { + KConfigSkeleton::ItemLongLong* longlongItem = m_config->addItemLongLong(m_name, + *d->newLongLong(), m_default.toLongLong(), m_key); + if (m_haveMin) { + longlongItem->setMinValue(m_min); + } + if (m_haveMax) { + longlongItem->setMaxValue(m_max); + } + item = longlongItem; + /* No addItemPathList in KConfigSkeleton ? + } else if (m_type == "PathList") { + //FIXME: the split() is naive and will break on lists with ,'s in them + item = m_config->addItemPathList(m_name, *d->newStringList(), m_default.split(","), m_key); */ + } else if (m_type == "point") { + QPoint defaultPoint; + QStringList tmpList = m_default.split(","); + while (tmpList.size() >= 2) { + defaultPoint.setX(tmpList[0].toInt()); + defaultPoint.setY(tmpList[1].toInt()); + } + item = m_config->addItemPoint(m_name, *d->newPoint(), defaultPoint, m_key); + } else if (m_type == "rect") { + QRect defaultRect; + QStringList tmpList = m_default.split(","); + while (tmpList.size() >= 4) { + defaultRect.setCoords(tmpList[0].toInt(), tmpList[1].toInt(), + tmpList[2].toInt(), tmpList[3].toInt()); + } + item = m_config->addItemRect(m_name, *d->newRect(), defaultRect, m_key); + } else if (m_type == "size") { + QSize defaultSize; + QStringList tmpList = m_default.split(","); + while (tmpList.size() >= 2) { + defaultSize.setWidth(tmpList[0].toInt()); + defaultSize.setHeight(tmpList[1].toInt()); + } + item = m_config->addItemSize(m_name, *d->newSize(), defaultSize, m_key); + } else if (m_type == "ulonglong") { + KConfigSkeleton::ItemULongLong* ulonglongItem = m_config->addItemULongLong(m_name, + *d->newULongLong(), m_default.toULongLong(), m_key); + if (m_haveMin) { + ulonglongItem->setMinValue(m_min); + } + if (m_haveMax) { + ulonglongItem->setMaxValue(m_max); + } + item = ulonglongItem; + /* No addItemUrlList in KConfigSkeleton ? + } else if (m_type == "urllist") { + //FIXME: the split() is naive and will break on lists with ,'s in them + QStringList tmpList = m_default.split(","); + KUrl::List defaultList; + foreach (QString tmp, tmpList) { + defaultList.append(KUrl(tmp)); + } + item = m_config->addItemUrlList(m_name, *d->newUrlList(), defaultList, m_key);*/ + } else if (m_type == "bytearray") { + QString keyToUse = (m_key.isEmpty() ? m_name : m_key ); + item = new ItemByteArray( m_config->currentGroup(), keyToUse, *d->newByteArray(), QByteArray()); + kDebug() << "Adding bytearray with name: " << item->name() << "m_name:" << m_name << "m_key:" << m_key; + m_config->addItem(item, keyToUse); + } + + + if (item) { + item->setLabel(m_label); + item->setWhatsThis(m_whatsThis); + d->keysToNames.insert(item->group() + item->key(), item->name()); + } +} + +void ConfigXmlHandler::resetState() +{ + m_haveMin = false; + m_min = 0; + m_haveMax = false; + m_max = 0; + m_name.clear(); + m_type.clear(); + m_label.clear(); + m_default.clear(); + m_key.clear(); + m_whatsThis.clear(); + m_enumChoices.clear(); + m_inChoice = false; + m_secret = false; +} + +ConfigXml::ConfigXml(const QString &configFile, QIODevice *xml, bool readSecrets, SecretStorageHelper *helper, QObject *parent) + : KConfigSkeleton(configFile, parent), + d(new Private(readSecrets, helper)) +{ +#if 0 + QXmlInputSource source(xml); + QXmlSimpleReader reader; + ConfigXmlHandler handler(this, d, helper); + reader.setContentHandler(&handler); + reader.parse(&source, false); +#endif + d->parse(this, xml); +} + +ConfigXml::ConfigXml(KSharedConfigPtr config, QIODevice *xml, bool readSecrets, SecretStorageHelper *helper, QObject *parent) + : KConfigSkeleton(config, parent), + d(new Private(readSecrets, helper)) +{ + d->parse(this, xml); +} + +//FIXME: obviously this is broken and should be using the group as the root, +// but KConfigSkeleton does not currently support this. it will eventually though, +// at which point this can be addressed properly +ConfigXml::ConfigXml(const KConfigGroup *config, QIODevice *xml, bool readSecrets, SecretStorageHelper *helper, QObject *parent) + : KConfigSkeleton(KSharedConfig::openConfig(config->config()->name()), parent), + d(new Private(readSecrets, helper)) +{ + d->parse(this, xml); +} + +ConfigXml::~ConfigXml() +{ + delete d; +} + +KConfigSkeletonItem* ConfigXml::findItem(const QString &group, const QString &key) +{ + return KConfigSkeleton::findItem(d->keysToNames[group + key]); +} + +bool ConfigXml::hasGroup(const QString &group) const +{ + return d->keysToNames.contains(group); +} Property changes on: libs/internals/configxml.cpp ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/update_settings_and_apply_patch =================================================================== --- libs/internals/update_settings_and_apply_patch (revision 0) +++ libs/internals/update_settings_and_apply_patch (revision 1010672) @@ -0,0 +1 @@ +make knm_compiler && for i in schemas/*.kcfg; do j=`basename $i .kcfg`; if [ -e schemas/$j.kcfgc ]; then /space/kde/builds/trunk/playground/base/plasma/applets/networkmanager/libs/internals/knm_compiler schemas/$j.kcfg schemas/$j.kcfgc -d settings; fi; done && patch -p0 < settings_hand_edits.diff Index: libs/internals/wirelesssecurityidentifier.cpp =================================================================== --- libs/internals/wirelesssecurityidentifier.cpp (revision 0) +++ libs/internals/wirelesssecurityidentifier.cpp (revision 1010672) @@ -0,0 +1,273 @@ +/* +Copyright 2009 Will Stephenson + + possible() incorporates code from nm-utils.c by + Ray Strode + Dan Williams + Tambet Ingo + (C) Copyright 2005 - 2008 Red Hat, Inc. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#include + +#include "wirelesssecurityidentifier.h" + +bool Knm::WirelessSecurity::interfaceSupportsApCiphers(Solid::Control::WirelessNetworkInterface::Capabilities interfaceCaps, Solid::Control::AccessPoint::WpaFlags apCiphers, Knm::WirelessSecurity::Type type ) +{ + bool havePair = false; + bool haveGroup = true; + if ( type == WirelessSecurity::StaticWep ) { + havePair = true; + } else { + if ( interfaceCaps.testFlag(Solid::Control::WirelessNetworkInterface::Wep40) && apCiphers.testFlag(Solid::Control::AccessPoint::PairWep40)) { + havePair = true; + } + if ( interfaceCaps.testFlag(Solid::Control::WirelessNetworkInterface::Wep104) && apCiphers.testFlag(Solid::Control::AccessPoint::PairWep104)) { + havePair = true; + } + if ( interfaceCaps.testFlag(Solid::Control::WirelessNetworkInterface::Tkip) && apCiphers.testFlag(Solid::Control::AccessPoint::PairTkip)) { + havePair = true; + } + if ( interfaceCaps.testFlag(Solid::Control::WirelessNetworkInterface::Ccmp) && apCiphers.testFlag(Solid::Control::AccessPoint::PairCcmp)) { + havePair = true; + } + } + + if ( interfaceCaps.testFlag(Solid::Control::WirelessNetworkInterface::Wep40) && apCiphers.testFlag(Solid::Control::AccessPoint::GroupWep40)) { + haveGroup = true; + } + if ( interfaceCaps.testFlag(Solid::Control::WirelessNetworkInterface::Wep104) && apCiphers.testFlag(Solid::Control::AccessPoint::GroupWep104)) { + haveGroup = true; + } + if (type != StaticWep) { + if ( interfaceCaps.testFlag(Solid::Control::WirelessNetworkInterface::Tkip) && apCiphers.testFlag(Solid::Control::AccessPoint::GroupTkip)) { + haveGroup = true; + } + if ( interfaceCaps.testFlag(Solid::Control::WirelessNetworkInterface::Ccmp) && apCiphers.testFlag(Solid::Control::AccessPoint::GroupCcmp)) { + haveGroup = true; + } + } + + return havePair && haveGroup; +} + +bool Knm::WirelessSecurity::possible(Knm::WirelessSecurity::Type type, Solid::Control::WirelessNetworkInterface::Capabilities interfaceCaps, bool haveAp, bool adhoc, Solid::Control::AccessPoint::Capabilities apCaps, Solid::Control::AccessPoint::WpaFlags apWpa, Solid::Control::AccessPoint::WpaFlags apRsn) +{ + bool good = TRUE; + + if (!haveAp) { + if (type == Knm::WirelessSecurity::None) + return true; + if ((type == Knm::WirelessSecurity::StaticWep) + || ((type == Knm::WirelessSecurity::DynamicWep) && !adhoc) + || ((type == Knm::WirelessSecurity::Leap) && !adhoc)) { + if (interfaceCaps & (Solid::Control::WirelessNetworkInterface::Wep40 | Solid::Control::WirelessNetworkInterface::Wep104)) + return true; + } + } + + switch (type) { + case Knm::WirelessSecurity::None: + Q_ASSERT (haveAp); + if (apCaps & Solid::Control::AccessPoint::Privacy) + return false; + if (apWpa || apRsn) + return false; + break; + case Knm::WirelessSecurity::Leap: /* require PRIVACY bit for LEAP? */ + if (adhoc) + return false; + /* Fall through */ + case Knm::WirelessSecurity::StaticWep: + Q_ASSERT (haveAp); + if (!(apCaps & Solid::Control::AccessPoint::Privacy)) + return false; + if (apWpa || apRsn) { + if (!interfaceSupportsApCiphers (interfaceCaps, apWpa, StaticWep)) + if (!interfaceSupportsApCiphers (interfaceCaps, apRsn, StaticWep)) + return false; + } + break; + case Knm::WirelessSecurity::DynamicWep: + if (adhoc) + return false; + Q_ASSERT (haveAp); + if (apRsn || !(apCaps & Solid::Control::AccessPoint::Privacy)) + return false; + /* Some APs broadcast minimal WPA-enabled beacons that must be handled */ + if (apWpa) { + if (!(apWpa & Solid::Control::AccessPoint::KeyMgmt8021x)) + return false; + if (!interfaceSupportsApCiphers (interfaceCaps, apWpa, DynamicWep)) + return false; + } + break; + case Knm::WirelessSecurity::WpaPsk: + if (!(interfaceCaps & Solid::Control::WirelessNetworkInterface::Wpa)) + return false; + if (haveAp) { + /* Ad-Hoc WPA APs won't necessarily have the PSK flag set */ + if ((apWpa & Solid::Control::AccessPoint::KeyMgmtPsk) || adhoc) { + if ( (apWpa & Solid::Control::AccessPoint::PairTkip) + && (interfaceCaps & Solid::Control::WirelessNetworkInterface::Tkip)) + return true; + if ( (apWpa & Solid::Control::AccessPoint::PairCcmp) + && (interfaceCaps & Solid::Control::WirelessNetworkInterface::Ccmp)) + return true; + } + return false; + } + break; + case Knm::WirelessSecurity::Wpa2Psk: + if (!(interfaceCaps & Solid::Control::WirelessNetworkInterface::Rsn)) + return false; + if (haveAp) { + /* Ad-Hoc WPA APs won't necessarily have the PSK flag set */ + if ((apRsn & Solid::Control::AccessPoint::KeyMgmtPsk) || adhoc) { + if ( (apRsn & Solid::Control::AccessPoint::PairTkip) + && (interfaceCaps & Solid::Control::WirelessNetworkInterface::Tkip)) + return true; + if ( (apRsn & Solid::Control::AccessPoint::PairCcmp) + && (interfaceCaps & Solid::Control::WirelessNetworkInterface::Ccmp)) + return true; + } + return false; + } + break; + case Knm::WirelessSecurity::WpaEap: + if (adhoc) + return false; + if (!(interfaceCaps & Solid::Control::WirelessNetworkInterface::Wpa)) + return false; + if (haveAp) { + if (!(apWpa & Solid::Control::AccessPoint::KeyMgmt8021x)) + return false; + /* Ensure at least one WPA cipher is supported */ + if (!interfaceSupportsApCiphers (interfaceCaps, apWpa, WpaEap)) + return false; + } + break; + case Knm::WirelessSecurity::Wpa2Eap: + if (adhoc) + return false; + if (!(interfaceCaps & Solid::Control::WirelessNetworkInterface::Rsn)) + return false; + if (haveAp) { + if (!(apRsn & Solid::Control::AccessPoint::KeyMgmt8021x)) + return false; + /* Ensure at least one WPA cipher is supported */ + if (!interfaceSupportsApCiphers (interfaceCaps, apRsn, Wpa2Eap)) + return false; + } + break; + default: + good = false; + break; + } + + return good; +} + +Knm::WirelessSecurity::Type Knm::WirelessSecurity::best(Solid::Control::WirelessNetworkInterface::Capabilities interfaceCaps, bool haveAp, bool adHoc, Solid::Control::AccessPoint::Capabilities apCaps, Solid::Control::AccessPoint::WpaFlags apWpa, Solid::Control::AccessPoint::WpaFlags apRsn) +{ + QList types; + + types << Knm::WirelessSecurity::Wpa2Eap << Knm::WirelessSecurity::WpaEap << Knm::WirelessSecurity::Wpa2Psk << Knm::WirelessSecurity::WpaPsk << Knm::WirelessSecurity::DynamicWep << Knm::WirelessSecurity::Leap << Knm::WirelessSecurity::StaticWep << Knm::WirelessSecurity::None; + + foreach (Knm::WirelessSecurity::Type type, types) { + if (possible(type, interfaceCaps, haveAp, adHoc, apCaps, apWpa, apRsn)) { + return type; + } + } + return Knm::WirelessSecurity::Unknown; +} + +QString Knm::WirelessSecurity::shortToolTip(Knm::WirelessSecurity::Type type) +{ + QString tip; + switch (type) { + case None: + tip = i18nc("@info:tooltip no security", "Insecure"); + break; + case StaticWep: + tip = i18nc("@info:tooltip WEP security", "WEP"); + break; + case Leap: + tip = i18nc("@info:tooltip LEAP security", "LEAP"); + break; + case DynamicWep: + tip = i18nc("@info:tooltip Dynamic WEP security", "Dynamic WEP"); + break; + case WpaPsk: + tip = i18nc("@info:tooltip WPA-PSK security", "WPA-PSK"); + break; + case WpaEap: + tip = i18nc("@info:tooltip WPA-EAP security", "WPA-EAP"); + break; + case Wpa2Psk: + tip = i18nc("@info:tooltip WPA2-PSK security", "WPA2-PSK"); + break; + case Wpa2Eap: + tip = i18nc("@info:tooltip WPA2-EAP security", "WPA2-EAP"); + break; + default: + case Unknown: + tip = i18nc("@info:tooltip unknown security", "Unknown security type"); + break; + } + return tip; +} + +QString Knm::WirelessSecurity::iconName(Knm::WirelessSecurity::Type type) +{ + QString icon; + switch (type) { + case None: + icon = QLatin1String("security-low"); + break; + case StaticWep: + icon = QLatin1String("security-medium"); + break; + case Leap: + icon = QLatin1String("security-medium"); + break; + case DynamicWep: + icon = QLatin1String("security-medium"); + break; + case WpaPsk: + icon = QLatin1String("security-high"); + break; + case WpaEap: + icon = QLatin1String("security-high"); + break; + case Wpa2Psk: + icon = QLatin1String("security-high"); + break; + case Wpa2Eap: + icon = QLatin1String("security-high"); + break; + default: + case Unknown: + icon = QLatin1String("security-low"); + break; + } + return icon; +} + +// vim: sw=4 sts=4 et tw=100 Index: libs/internals/org.kde.networkmanagement.wirelessinterfaceconnection.xml =================================================================== --- libs/internals/org.kde.networkmanagement.wirelessinterfaceconnection.xml (revision 0) +++ libs/internals/org.kde.networkmanagement.wirelessinterfaceconnection.xml (revision 1010672) @@ -0,0 +1,9 @@ + + + + + + + + + Index: libs/internals/CMakeLists.txt =================================================================== --- libs/internals/CMakeLists.txt (revision 0) +++ libs/internals/CMakeLists.txt (revision 1010672) @@ -0,0 +1,101 @@ +add_definitions(-DKDE_DEFAULT_DEBUG_AREA=51010) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) + +## next target: internals layer library + +set(knminternals_SRCS + connection.cpp + #connectiondbus.cpp + connectionpersistence.cpp + + setting.cpp + #settingdbus.cpp + settingpersistence.cpp + + #settings/pbkdf2.cpp + #settings/wephash.cpp + + settings/802-11-wireless-security.cpp + #settings/802-11-wireless-securitydbus.cpp + settings/802-11-wireless-securitypersistence.cpp + + settings/802-11-wireless.cpp + #settings/802-11-wirelessdbus.cpp + settings/802-11-wirelesspersistence.cpp + + settings/802-3-ethernet.cpp + #settings/802-3-ethernetdbus.cpp + settings/802-3-ethernetpersistence.cpp + + settings/802-1x.cpp + #settings/802-1xdbus.cpp + settings/802-1xpersistence.cpp + + settings/gsm.cpp + #settings/gsmdbus.cpp + settings/gsmpersistence.cpp + + settings/cdma.cpp + #settings/cdmadbus.cpp + settings/cdmapersistence.cpp + + settings/ipv4.cpp + #settings/ipv4dbus.cpp + settings/ipv4persistence.cpp + + settings/ppp.cpp + #settings/pppdbus.cpp + settings/ppppersistence.cpp + + settings/pppoe.cpp + #settings/pppoedbus.cpp + settings/pppoepersistence.cpp + + settings/serial.cpp + #settings/serialdbus.cpp + settings/serialpersistence.cpp + + settings/vpn.cpp + #settings/vpndbus.cpp + settings/vpnpersistence.cpp + + activatable.cpp + interfaceconnection.cpp + wirelessinterfaceconnection.cpp + wirelessobject.cpp + wirelessnetwork.cpp + unconfiguredinterface.cpp + vpninterfaceconnection.cpp + + # helper class for recognising the type of WPA secrets + wpasecretidentifier.cpp + + # helper class for identifying wireless security + wirelesssecurityidentifier.cpp + + # helper functions for storing tooltip keys and UI strings + tooltips.cpp + ) + +kde4_add_kcfg_files(knminternals_SRCS knmserviceprefs.kcfgc) + +kde4_add_library(knminternals SHARED ${knminternals_SRCS}) + +target_link_libraries(knminternals ${KDE4_KDEUI_LIBS} ${QT_QTXML_LIBRARY} solidcontrol ${QT_QTNETWORK_LIBRARY}) + +set_target_properties(knminternals PROPERTIES + VERSION ${GENERIC_LIB_VERSION} + SOVERSION ${GENERIC_LIB_SOVERSION} + ) +install(TARGETS knminternals ${INSTALL_TARGETS_DEFAULT_ARGS}) + +set(kconfig_compiler_SRCS kconfig_compiler.cpp) + +kde4_add_executable(knm_compiler NOGUI RUN_UNINSTALLED ${kconfig_compiler_SRCS}) + +target_link_libraries(knm_compiler ${QT_QTCORE_LIBRARY} ${QT_QTXML_LIBRARY} ) + Index: libs/internals/wirelessinterfaceconnection.cpp =================================================================== --- libs/internals/wirelessinterfaceconnection.cpp (revision 0) +++ libs/internals/wirelessinterfaceconnection.cpp (revision 1010672) @@ -0,0 +1,41 @@ +/* +Copyright 2008 Frederik Gladhorn +Copyright 2009 Will Stephenson + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "wirelessinterfaceconnection.h" + +using namespace Knm; + +WirelessInterfaceConnection::WirelessInterfaceConnection(const QString & ssid, int strength, Solid::Control::WirelessNetworkInterface::Capabilities interfaceCapabilities, Solid::Control::AccessPoint::Capabilities apCapabilities, Solid::Control::AccessPoint::WpaFlags wpaFlags, Solid::Control::AccessPoint::WpaFlags rsnFlags, Solid::Control::WirelessNetworkInterface::OperationMode mode, const QUuid & connectionUuid, const QString & connectionName, const QString & deviceUni, QObject * parent) +: InterfaceConnection(connectionUuid, connectionName, Activatable::WirelessInterfaceConnection, deviceUni, parent), WirelessObject(ssid, strength, interfaceCapabilities, apCapabilities, wpaFlags, rsnFlags, mode) +{ +} + +WirelessInterfaceConnection::~WirelessInterfaceConnection() +{ +} + +void WirelessInterfaceConnection::setStrength(int strength) +{ + if (strength != m_strength) { + WirelessObject::setStrength(strength); + emit strengthChanged(strength); + } +} Index: libs/internals/wpasecretidentifier.cpp =================================================================== --- libs/internals/wpasecretidentifier.cpp (revision 0) +++ libs/internals/wpasecretidentifier.cpp (revision 1010672) @@ -0,0 +1,57 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#include "wpasecretidentifier.h" + +WpaSecretIdentifier::WpaSecretType WpaSecretIdentifier::identify(const QString & secret) +{ + bool secretIsPsk = true; + bool secretIsPassphrase = true; + QByteArray secretBytes = secret.toAscii(); + for (int i = 0; i < secretBytes.size(); ++i) { + char current = secretBytes.at(i); + if (!(current >= (char)0x20 && current <= (char)0x7e)) { + secretIsPassphrase = false; + } + if (! ( current >= (char)0x30 && current <= (char)0x39) + || ( current >= (char)0x41 && current <= (char)0x46) + || ( current >= (char)0x61 && current <= (char)0x66)) { + secretIsPsk = false; + } + } + if (secretBytes.size() < 8 || secretBytes.size() > 63) { + secretIsPassphrase = false; + } + if (secretBytes.size() != 64) { + secretIsPsk = false; + } + + WpaSecretType type = Invalid; + + if (secretIsPsk) { + type = PreSharedKey; + } else if (secretIsPassphrase) { + type = Passphrase; + } + + return type; +} + +// vim: sw=4 sts=4 et tw=100 Index: libs/internals/knmserviceprefs.kcfgc =================================================================== --- libs/internals/knmserviceprefs.kcfgc (revision 0) +++ libs/internals/knmserviceprefs.kcfgc (revision 1010672) @@ -0,0 +1,6 @@ +File=knmserviceprefs.kcfg +ClassName=KNetworkManagerServicePrefs +Singleton=true +Mutators=true +Visibility=KNMINTERNALS_EXPORT +IncludeFiles=\"knminternals_export.h\" Property changes on: libs/internals/knmserviceprefs.kcfgc ___________________________________________________________________ Added: svn:mergeinfo Index: libs/internals/connection.h =================================================================== --- libs/internals/connection.h (revision 0) +++ libs/internals/connection.h (revision 1010672) @@ -0,0 +1,118 @@ +/* +Copyright 2009 Will Stephenson + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) version 3, or any +later version accepted by the membership of KDE e.V. (or its +successor approved by the membership of KDE e.V.), which shall +act as a proxy defined in Section 6 of version 3 of the license. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library. If not, see . +*/ + +#ifndef KNM_INTERNALS_CONNECTION_H +#define KNM_INTERNALS_CONNECTION_H + +#include +#include +#include +#include + +#include "setting.h" + +#include "knminternals_export.h" + +namespace Knm +{ + +class KNMINTERNALS_EXPORT Connection +{ +public: + enum Type { Wired = 1, Wireless, Gsm, Cdma, Vpn, Pppoe }; + static QString typeAsString(Connection::Type); + static Connection::Type typeFromString(const QString & type); + + /** + * Create a connection with a new Uuid + */ + Connection(const QString & name, Connection::Type type); + /** + * Create a connection with a given Uuid + */ + explicit Connection(const QUuid& uuid, Connection::Type type); + virtual ~Connection(); + + QString name() const; + QUuid uuid() const; + Connection::Type type() const; + void setType(Connection::Type); + bool autoConnect() const; + QDateTime timestamp() const; + + QString origin() const; + void setOrigin(const QString &); + + /** + * Access all settings + */ + QList settings() const; + /** + * Access a specific setting + * @param the type of setting to retrieve + * @return 0 if this Connection does not contain the given Setting type + */ + Setting * setting(Setting::Type type) const; + + void setName(const QString &); + void setUuid(const QUuid &); + void setAutoConnect(bool); + void setTimestamp(const QDateTime&); + /** + * Syntactic sugar for setTimestamp(QDateTime::currentDateTime()) + */ + void updateTimestamp(); + + /** + * Check if any of the settings in this connection have secrets + */ + bool hasSecrets() const; + + /** + * Check if this connection's secrets are currently loaded (secrets may be lazy loaded) + * If not, use @ref ConnectionPersistence::loadSecrets() + * Connections which have no secrets always return true + */ + bool secretsAvailable() const; + +private: + /** + * Set up internal structure, including all settings specific to this connection type + */ + void init(); + + /** + * Add a setting to this connection. The connection will delete the Setting + * @return false if the setting can not use the given Setting type or if it already contains a + * Setting of this type. + */ + void addSetting(Setting*); + + QString m_name; + QUuid m_uuid; + Connection::Type m_type; + bool m_autoConnect; + QDateTime m_timestamp; + QString m_origin; + QList m_settings; +}; +} // namespace Knm + +#endif // CONNECTION_H Index: libs/internals/wirelessnetwork.cpp =================================================================== --- libs/internals/wirelessnetwork.cpp (revision 0) +++ libs/internals/wirelessnetwork.cpp (revision 1010672) @@ -0,0 +1,41 @@ +/* +Copyright 2008 Frederik Gladhorn + +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) version 3 or any later version +accepted by the membership of KDE e.V. (or its successor approved +by the membership of KDE e.V.), which shall act as a proxy +defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "wirelessnetwork.h" + +using namespace Knm; + +WirelessNetwork::WirelessNetwork(const QString & ssid, int strength, Solid::Control::WirelessNetworkInterface::Capabilities interfaceCapabilities, Solid::Control::AccessPoint::Capabilities apCapabilities, Solid::Control::AccessPoint::WpaFlags wpaFlags, Solid::Control::AccessPoint::WpaFlags rsnFlags, Solid::Control::WirelessNetworkInterface::OperationMode mode, const QString & deviceUni, QObject * parent) +: Activatable(Activatable::WirelessNetwork, deviceUni, parent), WirelessObject(ssid, strength, interfaceCapabilities, apCapabilities, wpaFlags, rsnFlags, mode) +{ +} + +WirelessNetwork::~WirelessNetwork() +{ + +} + +void WirelessNetwork::setStrength(int strength) +{ + if (strength != m_strength) { + WirelessObject::setStrength(strength); + emit strengthChanged(strength); + } +} Index: libs/internals/settings_hand_edits.diff =================================================================== --- libs/internals/settings_hand_edits.diff (revision 0) +++ libs/internals/settings_hand_edits.diff (revision 1010672) @@ -0,0 +1,1611 @@ +diff -ur origsettings//802-11-wireless.cpp settings/802-11-wireless.cpp +--- origsettings//802-11-wireless.cpp 2009-08-11 17:28:56.000000000 +0200 ++++ settings/802-11-wireless.cpp 2009-08-11 14:51:38.000000000 +0200 +@@ -5,7 +5,8 @@ + + using namespace Knm; + +-WirelessSetting::WirelessSetting() : Setting(Setting::Wireless) ++WirelessSetting::WirelessSetting() : Setting(Setting::Wireless), ++ mMode(0), mBand(WirelessSetting::EnumBand::bg), mChannel(0), mRate(0), mTxpower(0), mMtu(0) + { + } + +diff -ur origsettings//802-11-wirelessdbus.cpp settings/802-11-wirelessdbus.cpp +--- origsettings//802-11-wirelessdbus.cpp 2009-08-11 17:28:56.000000000 +0200 ++++ settings/802-11-wirelessdbus.cpp 2009-08-11 14:51:38.000000000 +0200 +@@ -64,6 +64,8 @@ + map.insert("mode", "adhoc"); + break; + } ++ // leave out band, NM seems to work automatically without it ++#if 0 + switch (setting->band()) { + case Knm::WirelessSetting::EnumBand::a: + map.insert("band", "a"); +@@ -72,14 +74,24 @@ + map.insert("band", "bg"); + break; + } +- map.insert("channel", setting->channel()); +- map.insert("bssid", setting->bssid()); +- map.insert("rate", setting->rate()); +- map.insert(QLatin1String(NM_SETTING_WIRELESS_TX_POWER), setting->txpower()); +- map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS), setting->macaddress()); +- map.insert("mtu", setting->mtu()); +- map.insert(QLatin1String(NM_SETTING_WIRELESS_SEEN_BSSIDS), setting->seenbssids()); +- map.insert("security", setting->security()); ++#endif ++ //map.insert("channel", setting->channel()); ++ if (!setting->bssid().isEmpty()) { ++ map.insert("bssid", setting->bssid()); ++ } ++ //map.insert("rate", setting->rate()); ++ //map.insert(QLatin1String(NM_SETTING_WIRELESS_TX_POWER), setting->txpower()); ++ if (!setting->macaddress().isEmpty()) { ++ map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS), setting->macaddress()); ++ } ++ if (setting->mtu() > 0 ) ++ map.insert("mtu", setting->mtu()); ++ if (!setting->seenbssids().isEmpty()) { ++ map.insert(QLatin1String(NM_SETTING_WIRELESS_SEEN_BSSIDS), setting->seenbssids()); ++ } ++ if (!setting->security().isEmpty()) { ++ map.insert("security", setting->security()); ++ } + return map; + } + +diff -ur origsettings//802-11-wirelessdbus.h settings/802-11-wirelessdbus.h +--- origsettings//802-11-wirelessdbus.h 2009-08-11 17:28:56.000000000 +0200 ++++ settings/802-11-wirelessdbus.h 2009-08-11 14:51:38.000000000 +0200 +@@ -3,7 +3,7 @@ + #ifndef WIRELESSDBUS_H + #define WIRELESSDBUS_H + +-#include ++#include + + #include + #include +diff -ur origsettings//802-11-wirelesspersistence.cpp settings/802-11-wirelesspersistence.cpp +--- origsettings//802-11-wirelesspersistence.cpp 2009-08-11 17:28:56.000000000 +0200 ++++ settings/802-11-wirelesspersistence.cpp 2009-08-11 14:51:38.000000000 +0200 +@@ -20,7 +20,7 @@ + WirelessSetting * setting = static_cast(m_setting); + setting->setSsid(m_config->readEntry("ssid", QByteArray())); + { +- QString contents = m_config->readEntry("mode", 0); ++ QString contents = m_config->readEntry("mode", "infrastructure"); + if (contents == "infrastructure") + setting->setMode(WirelessSetting::EnumMode::infrastructure); + else if (contents == "adhoc") +@@ -28,7 +28,7 @@ + + } + { +- QString contents = m_config->readEntry("band", 1); ++ QString contents = m_config->readEntry("band", "bg"); + if (contents == "a") + setting->setBand(WirelessSetting::EnumBand::a); + else if (contents == "bg") +@@ -72,6 +72,7 @@ + m_config->writeEntry("macaddress", setting->macaddress()); + m_config->writeEntry("mtu", setting->mtu()); + m_config->writeEntry("seenbssids", setting->seenbssids()); ++kDebug() << setting->security(); + m_config->writeEntry("security", setting->security()); + } + +diff -ur origsettings//802-11-wireless-security.cpp settings/802-11-wireless-security.cpp +--- origsettings//802-11-wireless-security.cpp 2009-08-11 17:28:56.000000000 +0200 ++++ settings/802-11-wireless-security.cpp 2009-08-11 14:51:38.000000000 +0200 +@@ -6,6 +6,7 @@ + using namespace Knm; + + WirelessSecuritySetting::WirelessSecuritySetting() : Setting(Setting::WirelessSecurity) ++ , mSecurityType(WirelessSecuritySetting::EnumSecurityType::None), mKeymgmt(0), mWeptxkeyindex(0), mAuthalg(0) + { + } + +diff -ur origsettings//802-11-wireless-securitydbus.cpp settings/802-11-wireless-securitydbus.cpp +--- origsettings//802-11-wireless-securitydbus.cpp 2009-08-11 17:28:56.000000000 +0200 ++++ settings/802-11-wireless-securitydbus.cpp 2009-08-11 14:55:45.000000000 +0200 +@@ -3,9 +3,15 @@ + + #include "802-11-wireless-securitydbus.h" + ++#include ++ ++#include "config-nm07backend.h" + #include "802-11-wireless-security.h" ++#include "pbkdf2.h" ++#include "wephash.h" + +-WirelessSecurityDbus::WirelessSecurityDbus(Knm::WirelessSecuritySetting * setting) : SettingDbus(setting) ++WirelessSecurityDbus::WirelessSecurityDbus(Knm::WirelessSecuritySetting * setting, const QString & essid) : SettingDbus(setting), ++ m_essid(essid) + { + } + +@@ -67,6 +73,7 @@ + { + QVariantMap map; + Knm::WirelessSecuritySetting * setting = static_cast(m_setting); ++ if (setting->securityType() != Knm::WirelessSecuritySetting::EnumSecurityType::None) { // don't return anything if there is no security + switch (setting->keymgmt()) { + case Knm::WirelessSecuritySetting::EnumKeymgmt::None: + map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "none"); +@@ -84,13 +91,18 @@ + map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-eap"); + break; + } +- map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), setting->weptxkeyindex()); ++ // only insert WEP key index if we are using WEP ++ if (setting->securityType() == Knm::WirelessSecuritySetting::EnumSecurityType::StaticWep ++ || setting->securityType() == Knm::WirelessSecuritySetting::EnumSecurityType::DynamicWep) { ++ map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), setting->weptxkeyindex()); ++ } + switch (setting->authalg()) { +- case Knm::WirelessSecuritySetting::EnumAuthalg::none: +- map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "none"); +- break; +- case Knm::WirelessSecuritySetting::EnumAuthalg::open: +- map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "open"); ++ case Knm::WirelessSecuritySetting::EnumAuthalg::none: ++ // the none auth alg is internal ++ break; ++ case Knm::WirelessSecuritySetting::EnumAuthalg::open: ++ // the default ++ // map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "open"); + break; + case Knm::WirelessSecuritySetting::EnumAuthalg::shared: + map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "shared"); +@@ -99,10 +111,19 @@ + map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "leap"); + break; + } +- map.insert("proto", setting->proto()); +- map.insert("pairwise", setting->pairwise()); +- map.insert("group", setting->group()); +- map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), setting->leapusername()); ++ if (!setting->proto().isEmpty()) { ++ map.insert("proto", setting->proto()); ++ } ++ if (!setting->pairwise().isEmpty()) { ++ map.insert("pairwise", setting->pairwise()); ++ } ++ if (!setting->group().isEmpty()) { ++ map.insert("group", setting->group()); ++ } ++ if (!setting->leapusername().isEmpty()) { ++ map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), setting->leapusername()); ++ } ++ } // end of if not setting->clear() + return map; + } + +@@ -110,12 +131,78 @@ + { + QVariantMap map; + Knm::WirelessSecuritySetting * setting = static_cast(m_setting); +- map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), setting->wepkey0()); +- map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), setting->wepkey1()); +- map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), setting->wepkey2()); +- map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), setting->wepkey3()); +- map.insert("psk", setting->psk()); +- map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), setting->leappassword()); ++ if (setting->securityType() != Knm::WirelessSecuritySetting::EnumSecurityType::None) { // don't return anything if there is no security ++ if (!setting->weppassphrase().isEmpty()) { ++ QString key = hashWepPassphrase(setting->weppassphrase()); ++ switch (setting->weptxkeyindex()) { ++ case 0: ++ setting->setWepkey0(key); ++ break; ++ case 1: ++ setting->setWepkey1(key); ++ break; ++ case 2: ++ setting->setWepkey2(key); ++ break; ++ case 3: ++ setting->setWepkey3(key); ++ break; ++ } ++ } ++ if (!setting->wepkey0().isEmpty()) { ++ map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), setting->wepkey0()); ++ } ++ if (!setting->wepkey1().isEmpty()) { ++ map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), setting->wepkey1()); ++ } ++ if (!setting->wepkey2().isEmpty()) { ++ map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), setting->wepkey2()); ++ } ++ if (!setting->wepkey3().isEmpty()) { ++ map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), setting->wepkey3()); ++ } ++ if (!setting->psk().isEmpty()) { ++ WpaSecretIdentifier::WpaSecretType secretType = WpaSecretIdentifier::identify(setting->psk()); ++ if (secretType == WpaSecretIdentifier::Passphrase) { ++ map.insert("psk", hashWpaPsk(setting->psk())); ++ } else if (secretType == WpaSecretIdentifier::PreSharedKey) { ++ map.insert("psk", setting->psk()); ++ } ++ } ++ if (!setting->leappassword().isEmpty()) { ++ map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), setting->leappassword()); ++ } ++ } // end of if not clear + return map; + } + ++QString WirelessSecurityDbus::hashWpaPsk(const QString & plainText) ++{ ++ QString result; ++//#ifdef NM_0_7_1 ++#if 0 ++ kDebug() << "Built for NetworkManager that can hash WPA keys itself; passing through plaintext"; ++ result = plainText.toLocal8Bit(); ++ kDebug() << " plaintext out:" << result; ++#else ++#define WPA_PMK_LEN 32 ++ //kDebug() << "Hashing PSK. essid:" << m_essid << "psk:" << plainText; ++ QByteArray buffer(WPA_PMK_LEN * 2, 0); ++ pbkdf2_sha1(plainText.toLatin1(), m_essid.toLatin1(), m_essid.size(), 4096, (quint8*)buffer.data(), WPA_PMK_LEN); ++ result = buffer.toHex().left(WPA_PMK_LEN*2); ++ //kDebug() << " hexadecimal key out:" << result; ++#endif ++ return result; ++ ++} ++ ++QString WirelessSecurityDbus::hashWepPassphrase(const QString & plainText) ++{ ++ //kDebug() << "Hashing wep passphrase, essid: " << essid << " passphrase: " << passphrase; ++ QString hexHash = wep128PassphraseHash(plainText.toAscii()); ++ //kDebug() <<