1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/***************************************************************************
*
* knetworkmanager-device.cpp - A NetworkManager frontend for KDE
*
* Copyright (C) 2005, 2006 Novell, Inc.
*
* Author: Timo Hoenig <[email protected]>, <[email protected]>
* Will Stephenson <[email protected]>, <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
**************************************************************************/
#include <NetworkManager.h>
#include "knetworkmanager.h"
#include "knetworkmanager-nm_proxy.h"
#include "knetworkmanager-device.h"
#include "dbus/deviceproxy.h"
#include "knetworkmanager-hal_device_proxy.h"
#include <kdebug.h>
#include <tqhostaddress.h>
#include <tqdbuserror.h>
#include <tqdbusconnection.h>
#include <tqdbusproxy.h>
class NMDeviceProxy : public DBus::DeviceProxy
{
public:
NMDeviceProxy(const TQString& service, const TQString& path, TQObject* parent = 0, const char* name = 0)
: DeviceProxy(service, path, parent, name)
{
}
TQString getObjectPath() const
{
return m_baseProxy->path();
}
};
class DevicePrivate
{
public:
DevicePrivate(TQString service, TQString obj_path)
: nmDevice(service, obj_path)
, halDevice(NULL)
{}
~DevicePrivate() {}
NMDeviceProxy nmDevice;
HalDeviceProxy* halDevice;
};
TQ_UINT32 Device::getDeviceType() const
{
TQT_DBusError err;
TQ_UINT32 type = d->nmDevice.getDeviceType(err);
kdWarning() << k_funcinfo << err.name() << err.message() << endl;
return type;
}
TQString Device::getInterface() const
{
TQT_DBusError err;
return d->nmDevice.getInterface(err);
}
TQString Device::getUdi() const
{
TQT_DBusError err;
return d->nmDevice.getUdi(err);
}
TQString Device::getDriver() const
{
TQT_DBusError err;
return d->nmDevice.getDriver(err);
}
TQ_UINT32 Device::getCapabilities() const
{
TQT_DBusError err;
return d->nmDevice.getCapabilities(err);
}
TQ_INT32 Device::getIp4Address() const
{
TQT_DBusError err;
return d->nmDevice.getIp4Address(err);
}
NMDeviceState Device::getState() const
{
TQT_DBusError err;
return (NMDeviceState)d->nmDevice.getState(err);
}
TQString Device::getVendor() const
{
// FIXME: ask hal
return "";
}
TQString Device::getProduct() const
{
// FIXME: ask hal
return "";
}
TQString Device::getObjectPath() const
{
return d->nmDevice.getObjectPath();
}
void Device::slotStateChanged(TQ_UINT32 state)
{
emit StateChanged((NMDeviceState)state);
}
void Device::slotDeactivate()
{
// FIXME: the method was removed from NM API, use nm_proxy instead
NMProxy* nm = NMProxy::getInstance();
nm->deactivateDevice(this);
// TQT_DBusError err;
// d->nmDevice.Deactivate(err);
}
Device::Device (const TQString & obj_path)
{
d = new DevicePrivate(NM_DBUS_SERVICE, obj_path);
// create the NM Device Proxy
d->nmDevice.setConnection(TQT_DBusConnection::systemBus());
connect(&(d->nmDevice), TQT_SIGNAL(StateChanged(TQ_UINT32)), this, TQT_SLOT(slotStateChanged(TQ_UINT32)));
// d->halDevice = new HalDeviceProxy();
}
Device::~Device ()
{
// delete d->halDevice;
delete d;
}
#include "knetworkmanager-device.moc"
|