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
|
/***************************************************************************
*
* knetworkmanager-nminfo_dbus.cpp - A NetworkManager frontend for KDE
*
* Copyright (C) 2005, 2006 Novell, Inc.
*
* Author: Timo Hoenig <[email protected]>, <[email protected]>
* Valentine Sinitsyn <[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 <stdlib.h>
#include <kdebug.h>
#include <NetworkManager.h>
#include <tqdbusobjectpath.h>
#include <tqdbusconnection.h>
#include "knetworkmanager.h"
#include "knetworkmanager-nmsettings.h"
#include "knetworkmanager-connection_setting.h"
#include "knetworkmanager-connection_store.h"
#include "knetworkmanager-connection.h"
#if !defined(NM_CHECK_VERSION)
#define NM_CHECK_VERSION(x,y,z) 0
#endif
class NMSettingsPrivate
{
public:
NMSettingsPrivate()
: obj_path_index(0)
{
}
~NMSettingsPrivate()
{
}
int obj_path_index;
};
NMSettings* NMSettings::_instance = NULL;
NMSettings* NMSettings::getInstance()
{
// return singleton instance
if (_instance)
return _instance;
return (_instance = new NMSettings());
}
NMSettings::NMSettings()
{
d = new NMSettingsPrivate();
TQT_DBusConnection conn = TQT_DBusConnection::systemBus();
kdDebug() << "NMSettings::NMSettings" << endl;
#if NM_CHECK_VERSION(0,8,992)
if (!conn.requestName("org.freedesktop.NetworkManagerUserSettings"))
kdError() << "req name failed for " << "org.freedesktop.NetworkManagerUserSettings" << endl;
#else
// request the name for the settings interface
if (!conn.requestName(NM_DBUS_SERVICE_USER_SETTINGS))
kdError() << "req name failed for " << NM_DBUS_SERVICE_USER_SETTINGS << endl;
#endif
// request the name for the connections here too
if (!conn.requestName(NM_DBUS_IFACE_SETTINGS_CONNECTION))
kdError() << "req name failed for " << NM_DBUS_IFACE_SETTINGS_CONNECTION << endl;
// request the name for the connections here too
if (!conn.requestName(NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS))
kdError() << "req name failed for " << NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS << endl;
// register on the DBus
if (!conn.registerObject(objectPath(), this))
kdError() << "registerobjectpath failed" << endl;
ConnectionStore* cstore = ConnectionStore::getInstance();
// we need to get informed about new connections...
connect(cstore, TQT_SIGNAL(signalConnectionAdded(ConnectionSettings::Connection*)), this, TQT_SLOT(slotNewConnection(ConnectionSettings::Connection*)));
}
NMSettings::~NMSettings()
{
delete d;
TQT_DBusConnection conn = TQT_DBusConnection::systemBus();
conn.unregisterObject(NM_DBUS_PATH_SETTINGS);
}
bool NMSettings::handleSignalSend(const TQT_DBusMessage& reply)
{
TQT_DBusConnection::systemBus().send(reply);
return true;
}
TQString NMSettings::objectPath() const
{
return TQString(NM_DBUS_PATH_SETTINGS);
}
bool NMSettings::ListConnections(TQValueList<TQT_DBusObjectPath>& connections, TQT_DBusError& /*error*/)
{
// return connections
ConnectionStore* cstore = ConnectionStore::getInstance();
TQValueList<ConnectionSettings::Connection*> conns = cstore->getConnections();
for (TQValueList<ConnectionSettings::Connection*>::Iterator it = conns.begin(); it != conns.end(); ++it)
{
ConnectionSettings::Connection* conn = (*it);
connections.append(conn->getObjectPath());
}
return true;
}
void NMSettings::handleMethodReply(const TQT_DBusMessage& reply)
{
TQT_DBusConnection::systemBus().send(reply);
}
TQT_DBusObjectPath
NMSettings::getObjPathForConnection()
{
// just increase the number for this connection
TQT_DBusObjectPath obj_path(NM_DBUS_PATH_SETTINGS_CONNECTION"/");
obj_path += TQString::number(d->obj_path_index++);
return obj_path;
}
void
NMSettings::slotNewConnection(ConnectionSettings::Connection* conn)
{
emitNewConnection(conn->getObjectPath());
}
#include "knetworkmanager-nmsettings.moc"
|