~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to solid/networkmanager/tests/listdevices.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is part of the KDE project
 
2
    Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
 
3
 
 
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.
 
7
 
 
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.
 
12
 
 
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.
 
17
 
 
18
*/
 
19
 
 
20
#include <QApplication>
 
21
#include <QStringList>
 
22
 
 
23
#include <kdebug.h>
 
24
#include <solid/control/ifaces/networkinterface.h>
 
25
 
 
26
#include "nmobject.h"
 
27
 
 
28
#include "NetworkManager-network.h"
 
29
#include "NetworkManager-networkinterface.h"
 
30
#include "NetworkManager-networkmanager.h"
 
31
#include "NetworkManager-dbushelper.h"
 
32
 
 
33
int main(int argc, char ** argv)
 
34
{
 
35
//#if 1
 
36
    QApplication app(argc, argv);
 
37
#if 0
 
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();
 
47
 
 
48
    foreach (QString netPath, networks)
 
49
    {
 
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);
 
54
    }
 
55
#endif
 
56
#if 1
 
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");
 
63
   */
 
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;
 
72
    bool error;
 
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);
 
78
    return app.exec();
 
79
#else
 
80
    //    QApplication app(argc, argv);
 
81
    NMObject obj(argc, argv);
 
82
 //   obj.showDevices();
 
83
    NMNetworkManager mgr(0, QStringList());
 
84
    mgr.networkInterfaces();
 
85
    return obj.exec();
 
86
#endif
 
87
}