1
/* This file is part of the KDE project
2
Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License version 2 as published by the Free Software Foundation.
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public License
14
along with this library; see the file COPYING.LIB. If not, write to
15
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
Boston, MA 02110-1301, USA.
20
#include <QApplication>
21
#include <QStringList>
24
#include <solid/control/ifaces/networkinterface.h>
28
#include "NetworkManager-network.h"
29
#include "NetworkManager-networkinterface.h"
30
#include "NetworkManager-networkmanager.h"
31
#include "NetworkManager-dbushelper.h"
33
int main(int argc, char ** argv)
36
QApplication app(argc, argv);
38
NMNetworkManager mgr(0, QStringList());
39
mgr.networkInterfaces();
40
mgr.isNetworkingEnabled();
41
NMNetworkInterface * ethernetIface = qobject_cast<NMNetworkInterface *>(mgr.createNetworkInterface("/org/freedesktop/NetworkManager/Devices/eth0"));
42
NMNetworkInterface * wifiIface = qobject_cast<NMNetworkInterface *>(mgr.createNetworkInterface("/org/freedesktop/NetworkManager/Devices/eth1"));
43
Solid::Control::Ifaces::NetworkInterface * solidIface;
44
const QMetaObject * parentMo = wifiIface->metaObject()->superClass();
45
kDebug() << parentMo->className();
46
QStringList networks = wifiIface->networks();
48
foreach (QString netPath, networks)
50
kDebug() << "Creating network: " << netPath;
51
NMNetwork * network = qobject_cast<NMNetwork *>(wifiIface->createNetwork(netPath));
52
if (netPath == "/org/freedesktop/NetworkManager/Devices/eth1/Networks/testnet")
53
network->setActivated(true);
57
/* Solid::Control::Ifaces::AuthenticationWep auth;
58
auth.setMethod(Solid::Control::Ifaces::AuthenticationWep::WepSharedKey);
59
auth.setKeyLength(104);
60
auth.setType(Solid::Control::Ifaces::AuthenticationWep::WepPassphrase);
61
QMap<QString,QString> secrets;
62
secrets.insert("key", "testpassphrase");
64
Solid::Control::AuthenticationWpaPersonal auth;
65
auth.setVersion(Solid::Control::AuthenticationWpa::Wpa1);
66
auth.setProtocol(Solid::Control::AuthenticationWpa::WpaTkip);
67
auth.setKeyManagement(Solid::Control::AuthenticationWpa::WpaPsk);
68
QMap<QString,QString> secrets;
69
secrets.insert("key", "testpassphrase");
70
auth.setSecrets(secrets);
71
QList<QVariant> inArgs, outArgs;
73
outArgs = NMDBusHelper::serialize(&auth, "nursery", inArgs, &error);
74
kDebug() << "Serialized arguments:" << outArgs;
75
kDebug() << "Error?" << error;
76
//kDebug() << "Interface: " << netIface->uni() << ", " << netIface->signalStrength();
77
//mgr.setWirelessEnabled(true);
80
// QApplication app(argc, argv);
81
NMObject obj(argc, argv);
83
NMNetworkManager mgr(0, QStringList());
84
mgr.networkInterfaces();