~ubuntu-branches/ubuntu/precise/network-manager/precise

« back to all changes in this revision

Viewing changes to libnm-glib/nm-device.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-02-09 16:45:41 UTC
  • mfrom: (1.1.53)
  • Revision ID: package-import@ubuntu.com-20120209164541-4h90zknlsfdb7x35
Tags: 0.9.2.0+git201202091925.c721477-0ubuntu1
* upstream snapshot 2012-02-09 19:25:59 (GMT)
  + c721477d11d4fe144111d6d2eec8f93f2e9186c9
* debian/patches/avoid-periodic-disk-wakeups.patch: refreshed.
* debian/patches/nl3-default-ip6-route.patch: refreshed.
* debian/libnm-glib4.symbols: add symbols:
  + nm_active_connection_get_master@Base
  + nm_client_new_async@Base
  + nm_client_new_finish@Base
  + nm_remote_settings_new_async@Base
  + nm_remote_settings_new_finish@Base
  + nm_device_get_state_reason@Base
* debian/libnm-util2.symbols: add symbols:
  + nm_setting_802_1x_get_pac_file@Base
  + nm_setting_infiniband_get_transport_mode@Base

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * Boston, MA 02110-1301 USA.
19
19
 *
20
20
 * Copyright (C) 2007 - 2008 Novell, Inc.
21
 
 * Copyright (C) 2007 - 2011 Red Hat, Inc.
 
21
 * Copyright (C) 2007 - 2012 Red Hat, Inc.
22
22
 */
23
23
 
24
24
#include <string.h>
38
38
#include "nm-object-cache.h"
39
39
#include "nm-marshal.h"
40
40
#include "nm-dbus-glib-types.h"
41
 
 
42
 
#include "nm-device-bindings.h"
43
 
 
44
 
G_DEFINE_TYPE (NMDevice, nm_device, NM_TYPE_OBJECT)
 
41
#include "nm-glib-compat.h"
 
42
 
 
43
static GType nm_device_type_for_path (DBusGConnection *connection,
 
44
                                      const char *path);
 
45
static void nm_device_type_for_path_async (DBusGConnection *connection,
 
46
                                           const char *path,
 
47
                                           NMObjectTypeCallbackFunc callback,
 
48
                                           gpointer user_data);
 
49
 
 
50
G_DEFINE_TYPE_WITH_CODE (NMDevice, nm_device, NM_TYPE_OBJECT,
 
51
                         _nm_object_register_type_func (g_define_type_id, nm_device_type_for_path,
 
52
                                                        nm_device_type_for_path_async);
 
53
                         )
 
54
 
 
55
#define DBUS_G_TYPE_UINT_STRUCT (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID))
45
56
 
46
57
#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
47
58
 
58
69
        gboolean managed;
59
70
        gboolean firmware_missing;
60
71
        NMIP4Config *ip4_config;
61
 
        gboolean got_ip4_config;
62
72
        NMDHCP4Config *dhcp4_config;
63
 
        gboolean got_dhcp4_config;
64
73
        NMIP6Config *ip6_config;
65
 
        gboolean got_ip6_config;
66
74
        NMDHCP6Config *dhcp6_config;
67
 
        gboolean got_dhcp6_config;
68
75
        NMDeviceState state;
 
76
        NMDeviceStateReason reason;
69
77
 
70
78
        NMActiveConnection *active_connection;
71
 
        gboolean got_active_connection;
72
79
 
73
80
        GUdevClient *client;
74
81
        char *product;
87
94
        PROP_DHCP4_CONFIG,
88
95
        PROP_IP6_CONFIG,
89
96
        PROP_STATE,
 
97
        PROP_STATE_REASON,
90
98
        PROP_PRODUCT,
91
99
        PROP_VENDOR,
92
100
        PROP_DHCP6_CONFIG,
112
120
        NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
113
121
 
114
122
        priv->state = NM_DEVICE_STATE_UNKNOWN;
115
 
}
116
 
 
117
 
static gboolean
118
 
demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
119
 
{
120
 
        NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
121
 
        const char *path;
122
 
        NMIP4Config *config = NULL;
123
 
        DBusGConnection *connection;
124
 
 
125
 
        if (value) {
126
 
                if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
127
 
                        return FALSE;
128
 
 
129
 
                path = g_value_get_boxed (value);
130
 
                if (path) {
131
 
                        config = NM_IP4_CONFIG (_nm_object_cache_get (path));
132
 
                        if (!config) {
133
 
                                connection = nm_object_get_connection (object);
134
 
                                config = NM_IP4_CONFIG (nm_ip4_config_new (connection, path));
135
 
                        }
136
 
                }
137
 
        }
138
 
 
139
 
        priv->got_ip4_config = TRUE;
140
 
 
141
 
        if (priv->ip4_config) {
142
 
                g_object_unref (priv->ip4_config);
143
 
                priv->ip4_config = NULL;
144
 
        }
145
 
 
146
 
        if (config)
147
 
                priv->ip4_config = config;
148
 
 
149
 
        _nm_object_queue_notify (object, NM_DEVICE_IP4_CONFIG);
150
 
        return TRUE;
151
 
}
152
 
 
153
 
static gboolean
154
 
demarshal_dhcp4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
155
 
{
156
 
        NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
157
 
        const char *path;
158
 
        NMDHCP4Config *config = NULL;
159
 
        DBusGConnection *connection;
160
 
 
161
 
        if (value) {
162
 
                if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
163
 
                        return FALSE;
164
 
 
165
 
                path = g_value_get_boxed (value);
166
 
                if (path) {
167
 
                        config = NM_DHCP4_CONFIG (_nm_object_cache_get (path));
168
 
                        if (!config) {
169
 
                                connection = nm_object_get_connection (object);
170
 
                                config = NM_DHCP4_CONFIG (nm_dhcp4_config_new (connection, path));
171
 
                        }
172
 
                }
173
 
        }
174
 
 
175
 
        priv->got_dhcp4_config = TRUE;
176
 
 
177
 
        if (priv->dhcp4_config) {
178
 
                g_object_unref (priv->dhcp4_config);
179
 
                priv->dhcp4_config = NULL;
180
 
        }
181
 
 
182
 
        if (config)
183
 
                priv->dhcp4_config = config;
184
 
 
185
 
        _nm_object_queue_notify (object, NM_DEVICE_DHCP4_CONFIG);
186
 
        return TRUE;
187
 
}
188
 
 
189
 
static gboolean
190
 
demarshal_ip6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
191
 
{
192
 
        NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
193
 
        const char *path;
194
 
        NMIP6Config *config = NULL;
195
 
        DBusGConnection *connection;
196
 
 
197
 
        if (value) {
198
 
                if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
199
 
                        return FALSE;
200
 
 
201
 
                path = g_value_get_boxed (value);
202
 
                if (path) {
203
 
                        config = NM_IP6_CONFIG (_nm_object_cache_get (path));
204
 
                        if (!config) {
205
 
                                connection = nm_object_get_connection (object);
206
 
                                config = NM_IP6_CONFIG (nm_ip6_config_new (connection, path));
207
 
                        }
208
 
                }
209
 
        }
210
 
 
211
 
        priv->got_ip6_config = TRUE;
212
 
 
213
 
        if (priv->ip6_config) {
214
 
                g_object_unref (priv->ip6_config);
215
 
                priv->ip6_config = NULL;
216
 
        }
217
 
 
218
 
        if (config)
219
 
                priv->ip6_config = config;
220
 
 
221
 
        _nm_object_queue_notify (object, NM_DEVICE_IP6_CONFIG);
222
 
        return TRUE;
223
 
}
224
 
 
225
 
static gboolean
226
 
demarshal_dhcp6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
227
 
{
228
 
        NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
229
 
        const char *path;
230
 
        NMDHCP6Config *config = NULL;
231
 
        DBusGConnection *connection;
232
 
 
233
 
        if (value) {
234
 
                if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
235
 
                        return FALSE;
236
 
 
237
 
                path = g_value_get_boxed (value);
238
 
                if (path) {
239
 
                        config = NM_DHCP6_CONFIG (_nm_object_cache_get (path));
240
 
                        if (!config) {
241
 
                                connection = nm_object_get_connection (object);
242
 
                                config = NM_DHCP6_CONFIG (nm_dhcp6_config_new (connection, path));
243
 
                        }
244
 
                }
245
 
        }
246
 
 
247
 
        priv->got_dhcp6_config = TRUE;
248
 
 
249
 
        if (priv->dhcp6_config) {
250
 
                g_object_unref (priv->dhcp6_config);
251
 
                priv->dhcp6_config = NULL;
252
 
        }
253
 
 
254
 
        if (config)
255
 
                priv->dhcp6_config = config;
256
 
 
257
 
        _nm_object_queue_notify (object, NM_DEVICE_DHCP6_CONFIG);
258
 
        return TRUE;
259
 
}
260
 
 
261
 
static gboolean
262
 
demarshal_active_connection (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
263
 
{
264
 
        NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
265
 
        const char *path;
266
 
        NMActiveConnection *active = NULL;
267
 
        DBusGConnection *connection;
268
 
 
269
 
        if (value) {
270
 
                if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
271
 
                        return FALSE;
272
 
 
273
 
                path = g_value_get_boxed (value);
274
 
                if (path) {
275
 
                        active = NM_ACTIVE_CONNECTION (_nm_object_cache_get (path));
276
 
                        if (!active) {
277
 
                                connection = nm_object_get_connection (object);
278
 
                                active = NM_ACTIVE_CONNECTION (nm_active_connection_new (connection, path));
279
 
                        }
280
 
                }
281
 
        }
282
 
 
283
 
        priv->got_active_connection = TRUE;
284
 
 
285
 
        if (priv->active_connection) {
286
 
                g_object_unref (priv->active_connection);
287
 
                priv->active_connection = NULL;
288
 
        }
289
 
 
290
 
        if (active)
291
 
                priv->active_connection = active;
292
 
 
293
 
        _nm_object_queue_notify (object, NM_DEVICE_ACTIVE_CONNECTION);
 
123
        priv->reason = NM_DEVICE_STATE_REASON_NONE;
 
124
}
 
125
 
 
126
static gboolean
 
127
demarshal_state_reason (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
 
128
{
 
129
        NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
 
130
 
 
131
        if (!G_VALUE_HOLDS (value, DBUS_G_TYPE_UINT_STRUCT))
 
132
                return FALSE;
 
133
 
 
134
        dbus_g_type_struct_get (value,
 
135
                                0, &priv->state,
 
136
                                1, &priv->reason,
 
137
                                G_MAXUINT);
 
138
 
 
139
        _nm_object_queue_notify (object, NM_DEVICE_STATE_REASON);
294
140
        return TRUE;
295
141
}
296
142
 
297
143
static void
298
 
register_for_property_changed (NMDevice *device)
 
144
register_properties (NMDevice *device)
299
145
{
300
146
        NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
301
 
        const NMPropertiesChangedInfo property_changed_info[] = {
302
 
                { NM_DEVICE_UDI,              _nm_object_demarshal_generic, &priv->udi },
303
 
                { NM_DEVICE_INTERFACE,        _nm_object_demarshal_generic, &priv->iface },
304
 
                { NM_DEVICE_IP_INTERFACE,     _nm_object_demarshal_generic, &priv->ip_iface },
305
 
                { NM_DEVICE_DRIVER,           _nm_object_demarshal_generic, &priv->driver },
306
 
                { NM_DEVICE_CAPABILITIES,     _nm_object_demarshal_generic, &priv->capabilities },
307
 
                { NM_DEVICE_MANAGED,          _nm_object_demarshal_generic, &priv->managed },
308
 
                { NM_DEVICE_FIRMWARE_MISSING, _nm_object_demarshal_generic, &priv->firmware_missing },
309
 
                { NM_DEVICE_IP4_CONFIG,       demarshal_ip4_config,         &priv->ip4_config },
310
 
                { NM_DEVICE_DHCP4_CONFIG,     demarshal_dhcp4_config,       &priv->dhcp4_config },
311
 
                { NM_DEVICE_IP6_CONFIG,       demarshal_ip6_config,         &priv->ip6_config },
312
 
                { NM_DEVICE_DHCP6_CONFIG,     demarshal_dhcp6_config,       &priv->dhcp6_config },
313
 
                { NM_DEVICE_ACTIVE_CONNECTION,demarshal_active_connection,  &priv->active_connection },
 
147
        const NMPropertiesInfo property_info[] = {
 
148
                { NM_DEVICE_UDI,               &priv->udi },
 
149
                { NM_DEVICE_INTERFACE,         &priv->iface },
 
150
                { NM_DEVICE_IP_INTERFACE,      &priv->ip_iface },
 
151
                { NM_DEVICE_DRIVER,            &priv->driver },
 
152
                { NM_DEVICE_CAPABILITIES,      &priv->capabilities },
 
153
                { NM_DEVICE_MANAGED,           &priv->managed },
 
154
                { NM_DEVICE_FIRMWARE_MISSING,  &priv->firmware_missing },
 
155
                { NM_DEVICE_IP4_CONFIG,        &priv->ip4_config, NULL, NM_TYPE_IP4_CONFIG },
 
156
                { NM_DEVICE_DHCP4_CONFIG,      &priv->dhcp4_config, NULL, NM_TYPE_DHCP4_CONFIG },
 
157
                { NM_DEVICE_IP6_CONFIG,        &priv->ip6_config, NULL, NM_TYPE_IP6_CONFIG },
 
158
                { NM_DEVICE_DHCP6_CONFIG,      &priv->dhcp6_config, NULL, NM_TYPE_DHCP6_CONFIG },
 
159
                { NM_DEVICE_STATE,             &priv->state },
 
160
                { NM_DEVICE_STATE_REASON,      &priv->state, demarshal_state_reason },
 
161
                { NM_DEVICE_ACTIVE_CONNECTION, &priv->active_connection, NULL, NM_TYPE_ACTIVE_CONNECTION },
 
162
 
 
163
                /* The D-Bus interface has this property, but we don't; register
 
164
                 * it so that handle_property_changed() doesn't complain.
 
165
                 */
 
166
                { "ip4-address", NULL },
 
167
 
314
168
                { NULL },
315
169
        };
316
170
 
317
 
        _nm_object_handle_properties_changed (NM_OBJECT (device),
318
 
                                             priv->proxy,
319
 
                                             property_changed_info);
 
171
        _nm_object_register_properties (NM_OBJECT (device),
 
172
                                        priv->proxy,
 
173
                                        property_info);
320
174
}
321
175
 
322
176
static void
327
181
                      gpointer user_data)
328
182
{
329
183
        NMDevice *self = NM_DEVICE (user_data);
330
 
        NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
331
184
 
332
 
        if (priv->state != new_state) {
333
 
                priv->state = new_state;
 
185
        if (old_state != new_state)
334
186
                g_signal_emit (self, signals[STATE_CHANGED], 0, new_state, old_state, reason);
335
 
                _nm_object_queue_notify (NM_OBJECT (self), "state");
336
 
        }
337
 
}
338
 
 
339
 
static void
340
 
get_all_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
341
 
{
342
 
        NMObject *self = NM_OBJECT (user_data);
343
 
        GHashTable *props = NULL;
344
 
        GError *error = NULL;
345
 
 
346
 
        if (!dbus_g_proxy_end_call (proxy, call, &error,
347
 
                                    DBUS_TYPE_G_MAP_OF_VARIANT, &props,
348
 
                                    G_TYPE_INVALID)) {
349
 
                if (!(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_NO_REPLY)) {
350
 
                        g_warning ("%s: couldn't retrieve device properties: (%d) %s.",
351
 
                                   __func__,
352
 
                                   error ? error->code : -1,
353
 
                                   (error && error->message) ? error->message : "(unknown)");
354
 
                }
355
 
                g_clear_error (&error);
356
 
                g_object_unref (proxy);
357
 
                return;
358
 
        }
359
 
        g_object_unref (proxy);
360
 
 
361
 
        /* Hack: libnm-glib's NMDevice doesn't have ip4-address property. Remove
362
 
         * it from the hash to prevent warnings.
363
 
         */
364
 
        g_hash_table_remove (props, "Ip4Address");
365
 
 
366
 
        _nm_object_process_properties_changed (NM_OBJECT (self), props);
367
 
        g_hash_table_destroy (props);
368
 
 
369
 
}
370
 
 
371
 
static void
372
 
initialize_properties (NMObject *object)
373
 
{
374
 
        DBusGProxy *props_proxy;
375
 
 
376
 
        /* D-Bus properties proxy */
377
 
        props_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (object),
378
 
                                                 NM_DBUS_SERVICE,
379
 
                                                 nm_object_get_path (object),
380
 
                                                 "org.freedesktop.DBus.Properties");
381
 
        g_assert (props_proxy);
382
 
 
383
 
        /* Get properties */
384
 
        dbus_g_proxy_begin_call (props_proxy, "GetAll",
385
 
                                 get_all_cb,
386
 
                                 object,
387
 
                                 NULL,
388
 
                                 G_TYPE_STRING, NM_DBUS_INTERFACE_DEVICE,
389
 
                                 G_TYPE_INVALID);
390
 
 
391
 
}
392
 
 
393
 
static GObject*
394
 
constructor (GType type,
395
 
                         guint n_construct_params,
396
 
                         GObjectConstructParam *construct_params)
397
 
{
398
 
        NMObject *object;
 
187
}
 
188
 
 
189
static void
 
190
constructed (GObject *object)
 
191
{
399
192
        NMDevicePrivate *priv;
400
193
 
401
 
        object = (NMObject *) G_OBJECT_CLASS (nm_device_parent_class)->constructor (type,
402
 
                                                                                                                                                                n_construct_params,
403
 
                                                                                                                                                                construct_params);
404
 
        if (!object)
405
 
                return NULL;
 
194
        G_OBJECT_CLASS (nm_device_parent_class)->constructed (object);
406
195
 
407
196
        priv = NM_DEVICE_GET_PRIVATE (object);
408
197
 
409
 
        priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (object),
 
198
        priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
410
199
                                                                                         NM_DBUS_SERVICE,
411
 
                                                                                         nm_object_get_path (object),
 
200
                                                                                         nm_object_get_path (NM_OBJECT (object)),
412
201
                                                                                         NM_DBUS_INTERFACE_DEVICE);
413
202
 
414
 
        register_for_property_changed (NM_DEVICE (object));
415
 
 
416
 
        /* Get initial properties, so that we have all properties set even if
417
 
         * no PropertiesChanged signal is received.
418
 
         * It has to be called after register_for_property_changed().
419
 
         */
420
 
        initialize_properties (object);
 
203
        register_properties (NM_DEVICE (object));
421
204
 
422
205
        dbus_g_object_register_marshaller (_nm_marshal_VOID__UINT_UINT_UINT,
423
206
                                                                           G_TYPE_NONE,
433
216
                                                                 G_CALLBACK (device_state_changed),
434
217
                                                                 NM_DEVICE (object),
435
218
                                                                 NULL);
436
 
 
437
 
        return G_OBJECT (object);
438
219
}
439
220
 
440
221
static void
488
269
              GParamSpec *pspec)
489
270
{
490
271
        NMDevice *device = NM_DEVICE (object);
 
272
        NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
491
273
 
492
274
        switch (prop_id) {
493
275
        case PROP_DEVICE_TYPE:
529
311
        case PROP_STATE:
530
312
                g_value_set_uint (value, nm_device_get_state (device));
531
313
                break;
 
314
        case PROP_STATE_REASON:
 
315
                g_value_set_boxed (value,
 
316
                                   dbus_g_type_specialized_construct (DBUS_G_TYPE_UINT_STRUCT));
 
317
                dbus_g_type_struct_set (value,
 
318
                                        0, priv->state,
 
319
                                        1, priv->reason,
 
320
                                        G_MAXUINT);
 
321
                break;
532
322
        case PROP_ACTIVE_CONNECTION:
533
323
                g_value_set_object (value, nm_device_get_active_connection (device));
534
324
                break;
572
362
        g_type_class_add_private (device_class, sizeof (NMDevicePrivate));
573
363
 
574
364
        /* virtual methods */
575
 
        object_class->constructor = constructor;
 
365
        object_class->constructed = constructed;
576
366
        object_class->get_property = get_property;
577
367
        object_class->set_property = set_property;
578
368
        object_class->dispose = dispose;
756
546
                                                  G_PARAM_READABLE));
757
547
 
758
548
        /**
 
549
         * NMDevice:state-reason:
 
550
         *
 
551
         * The state and reason of the device.
 
552
         **/
 
553
        g_object_class_install_property
 
554
                (object_class, PROP_STATE_REASON,
 
555
                 g_param_spec_boxed (NM_DEVICE_STATE_REASON,
 
556
                                     "StateReason",
 
557
                                     "StateReason",
 
558
                                     DBUS_G_TYPE_UINT_STRUCT,
 
559
                                     G_PARAM_READABLE));
 
560
 
 
561
        /**
759
562
         * NMDevice:active-connection:
760
563
         *
761
564
         * The #NMActiveConnection object that "owns" this device during activation.
814
617
                                    G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
815
618
}
816
619
 
817
 
/**
818
 
 * nm_device_new:
819
 
 * @connection: the #DBusGConnection
820
 
 * @path: the DBus object path of the device
821
 
 *
822
 
 * Creates a new #NMDevice.
823
 
 *
824
 
 * Returns: (transfer full): a new device
825
 
 **/
826
 
GObject *
827
 
nm_device_new (DBusGConnection *connection, const char *path)
 
620
static GType
 
621
nm_device_gtype_from_dtype (NMDeviceType dtype)
 
622
{
 
623
        switch (dtype) {
 
624
        case NM_DEVICE_TYPE_ETHERNET:
 
625
                return NM_TYPE_DEVICE_ETHERNET;
 
626
        case NM_DEVICE_TYPE_WIFI:
 
627
                return NM_TYPE_DEVICE_WIFI;
 
628
        case NM_DEVICE_TYPE_MODEM:
 
629
                return NM_TYPE_DEVICE_MODEM;
 
630
        case NM_DEVICE_TYPE_BT:
 
631
                return NM_TYPE_DEVICE_BT;
 
632
        case NM_DEVICE_TYPE_WIMAX:
 
633
                return NM_TYPE_DEVICE_WIMAX;
 
634
        case NM_DEVICE_TYPE_INFINIBAND:
 
635
                return NM_TYPE_DEVICE_INFINIBAND;
 
636
        default:
 
637
                g_warning ("Unknown device type %d", dtype);
 
638
                return G_TYPE_INVALID;
 
639
        }
 
640
}
 
641
 
 
642
static GType
 
643
nm_device_type_for_path (DBusGConnection *connection,
 
644
                         const char *path)
828
645
{
829
646
        DBusGProxy *proxy;
830
647
        GError *err = NULL;
831
648
        GValue value = {0,};
832
 
        GType dtype = 0;
833
 
        NMDevice *device = NULL;
834
649
        NMDeviceType nm_dtype;
835
650
 
836
 
        g_return_val_if_fail (connection != NULL, NULL);
837
 
        g_return_val_if_fail (path != NULL, NULL);
838
 
 
839
651
        proxy = dbus_g_proxy_new_for_name (connection,
840
652
                                                                           NM_DBUS_SERVICE,
841
653
                                                                           path,
842
654
                                                                           "org.freedesktop.DBus.Properties");
843
655
        if (!proxy) {
844
656
                g_warning ("%s: couldn't create D-Bus object proxy.", __func__);
845
 
                return NULL;
 
657
                return G_TYPE_INVALID;
846
658
        }
847
659
 
848
660
        if (!dbus_g_proxy_call (proxy,
851
663
                                                    G_TYPE_STRING, "DeviceType",
852
664
                                                    G_TYPE_INVALID,
853
665
                                                    G_TYPE_VALUE, &value, G_TYPE_INVALID)) {
 
666
                g_object_unref (proxy);
854
667
                g_warning ("Error in get_property: %s\n", err->message);
855
668
                g_error_free (err);
856
 
                goto out;
857
669
        }
 
670
        g_object_unref (proxy);
858
671
 
859
672
        nm_dtype = g_value_get_uint (&value);
860
 
        switch (nm_dtype) {
861
 
        case NM_DEVICE_TYPE_ETHERNET:
862
 
                dtype = NM_TYPE_DEVICE_ETHERNET;
863
 
                break;
864
 
        case NM_DEVICE_TYPE_WIFI:
865
 
                dtype = NM_TYPE_DEVICE_WIFI;
866
 
                break;
867
 
        case NM_DEVICE_TYPE_MODEM:
868
 
                dtype = NM_TYPE_DEVICE_MODEM;
869
 
                break;
870
 
        case NM_DEVICE_TYPE_BT:
871
 
                dtype = NM_TYPE_DEVICE_BT;
872
 
                break;
873
 
        case NM_DEVICE_TYPE_WIMAX:
874
 
                dtype = NM_TYPE_DEVICE_WIMAX;
875
 
                break;
876
 
        case NM_DEVICE_TYPE_INFINIBAND:
877
 
                dtype = NM_TYPE_DEVICE_INFINIBAND;
878
 
                break;
879
 
        default:
880
 
                g_warning ("Unknown device type %d", g_value_get_uint (&value));
881
 
                break;
882
 
        }
883
 
 
884
 
        if (dtype) {
885
 
                device = (NMDevice *) g_object_new (dtype,
886
 
                                                                                        NM_OBJECT_DBUS_CONNECTION, connection,
887
 
                                                                                        NM_OBJECT_DBUS_PATH, path,
888
 
                                                                                        NM_DEVICE_DEVICE_TYPE, nm_dtype,
889
 
                                                                                        NULL);
890
 
        }
891
 
 
892
 
out:
893
 
        g_object_unref (proxy);
 
673
        return nm_device_gtype_from_dtype (nm_dtype);
 
674
}
 
675
 
 
676
/**
 
677
 * nm_device_new:
 
678
 * @connection: the #DBusGConnection
 
679
 * @path: the DBus object path of the device
 
680
 *
 
681
 * Creates a new #NMDevice.
 
682
 *
 
683
 * Returns: (transfer full): a new device
 
684
 **/
 
685
GObject *
 
686
nm_device_new (DBusGConnection *connection, const char *path)
 
687
{
 
688
        GType dtype;
 
689
        NMDevice *device = NULL;
 
690
 
 
691
        g_return_val_if_fail (connection != NULL, NULL);
 
692
        g_return_val_if_fail (path != NULL, NULL);
 
693
 
 
694
        dtype = nm_device_type_for_path (connection, path);
 
695
        if (dtype == G_TYPE_INVALID)
 
696
                return NULL;
 
697
 
 
698
        device = (NMDevice *) g_object_new (dtype,
 
699
                                            NM_OBJECT_DBUS_CONNECTION, connection,
 
700
                                            NM_OBJECT_DBUS_PATH, path,
 
701
                                            NULL);
 
702
        _nm_object_ensure_inited (NM_OBJECT (device));
894
703
        return G_OBJECT (device);
895
704
}
896
705
 
 
706
typedef struct {
 
707
        DBusGConnection *connection;
 
708
        NMObjectTypeCallbackFunc callback;
 
709
        gpointer user_data;
 
710
} NMDeviceAsyncData;
 
711
 
 
712
static void
 
713
async_got_type (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 
714
{
 
715
        NMDeviceAsyncData *async_data = user_data;
 
716
        GValue value = G_VALUE_INIT;
 
717
        const char *path = dbus_g_proxy_get_path (proxy);
 
718
        GError *error = NULL;
 
719
        GType type;
 
720
 
 
721
        if (dbus_g_proxy_end_call (proxy, call, &error,
 
722
                                   G_TYPE_VALUE, &value,
 
723
                                   G_TYPE_INVALID)) {
 
724
                NMDeviceType dtype;
 
725
 
 
726
                dtype = g_value_get_uint (&value);
 
727
                type = nm_device_gtype_from_dtype (dtype);
 
728
        } else {
 
729
                g_warning ("%s: could not read properties for %s: %s", __func__, path, error->message);
 
730
                g_error_free (error);
 
731
                type = G_TYPE_INVALID;
 
732
        }
 
733
 
 
734
        async_data->callback (type, async_data->user_data);
 
735
        g_object_unref (proxy);
 
736
        g_slice_free (NMDeviceAsyncData, async_data);
 
737
}
 
738
 
 
739
static void
 
740
nm_device_type_for_path_async (DBusGConnection *connection,
 
741
                               const char *path,
 
742
                               NMObjectTypeCallbackFunc callback,
 
743
                               gpointer user_data)
 
744
{
 
745
        NMDeviceAsyncData *async_data;
 
746
        DBusGProxy *proxy;
 
747
 
 
748
        async_data = g_slice_new (NMDeviceAsyncData);
 
749
        async_data->connection = connection;
 
750
        async_data->callback = callback;
 
751
        async_data->user_data = user_data;
 
752
 
 
753
        proxy = dbus_g_proxy_new_for_name (connection, NM_DBUS_SERVICE, path,
 
754
                                           "org.freedesktop.DBus.Properties");
 
755
        dbus_g_proxy_begin_call (proxy, "Get",
 
756
                                 async_got_type, async_data, NULL,
 
757
                                 G_TYPE_STRING, NM_DBUS_INTERFACE_DEVICE,
 
758
                                 G_TYPE_STRING, "DeviceType",
 
759
                                 G_TYPE_INVALID);
 
760
}
 
761
 
897
762
/**
898
763
 * nm_device_get_iface:
899
764
 * @device: a #NMDevice
906
771
const char *
907
772
nm_device_get_iface (NMDevice *device)
908
773
{
909
 
        NMDevicePrivate *priv;
910
 
 
911
774
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
912
775
 
913
 
        priv = NM_DEVICE_GET_PRIVATE (device);
914
 
        if (!priv->iface) {
915
 
                priv->iface = _nm_object_get_string_property (NM_OBJECT (device),
916
 
                                                             NM_DBUS_INTERFACE_DEVICE,
917
 
                                                             "Interface",
918
 
                                                             NULL);
919
 
        }
920
 
 
921
 
        return priv->iface;
 
776
        _nm_object_ensure_inited (NM_OBJECT (device));
 
777
        return NM_DEVICE_GET_PRIVATE (device)->iface;
922
778
}
923
779
 
924
780
/**
934
790
const char *
935
791
nm_device_get_ip_iface (NMDevice *device)
936
792
{
937
 
        NMDevicePrivate *priv;
938
 
 
939
793
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
940
794
 
941
 
        priv = NM_DEVICE_GET_PRIVATE (device);
942
 
        if (!priv->ip_iface) {
943
 
                priv->ip_iface = _nm_object_get_string_property (NM_OBJECT (device),
944
 
                                                                 NM_DBUS_INTERFACE_DEVICE,
945
 
                                                                 "IpInterface",
946
 
                                                                 NULL);
947
 
        }
948
 
 
949
 
        return priv->ip_iface;
 
795
        _nm_object_ensure_inited (NM_OBJECT (device));
 
796
        return NM_DEVICE_GET_PRIVATE (device)->ip_iface;
950
797
}
951
798
 
952
799
/**
960
807
NMDeviceType
961
808
nm_device_get_device_type (NMDevice *self)
962
809
{
 
810
        NMDevicePrivate *priv;
 
811
 
963
812
        g_return_val_if_fail (NM_IS_DEVICE (self), NM_DEVICE_TYPE_UNKNOWN);
964
813
 
965
 
        return NM_DEVICE_GET_PRIVATE (self)->device_type;
 
814
        priv = NM_DEVICE_GET_PRIVATE (self);
 
815
 
 
816
        /* Fill this in if it wasn't set at construct time */
 
817
        if (priv->device_type == NM_DEVICE_TYPE_UNKNOWN) {
 
818
                if (NM_IS_DEVICE_ETHERNET (self))
 
819
                        priv->device_type = NM_DEVICE_TYPE_ETHERNET;
 
820
                else if (NM_IS_DEVICE_WIFI (self))
 
821
                        priv->device_type = NM_DEVICE_TYPE_WIFI;
 
822
                else if (NM_IS_DEVICE_MODEM (self))
 
823
                        priv->device_type = NM_DEVICE_TYPE_MODEM;
 
824
                else if (NM_IS_DEVICE_BT (self))
 
825
                        priv->device_type = NM_DEVICE_TYPE_BT;
 
826
                else if (NM_IS_DEVICE_WIMAX (self))
 
827
                        priv->device_type = NM_DEVICE_TYPE_WIMAX;
 
828
                else if (NM_IS_DEVICE_INFINIBAND (self))
 
829
                        priv->device_type = NM_DEVICE_TYPE_INFINIBAND;
 
830
                else
 
831
                        g_warn_if_reached ();
 
832
        }
 
833
 
 
834
        return priv->device_type;
966
835
}
967
836
 
968
837
/**
978
847
const char *
979
848
nm_device_get_udi (NMDevice *device)
980
849
{
981
 
        NMDevicePrivate *priv;
982
 
 
983
850
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
984
851
 
985
 
        priv = NM_DEVICE_GET_PRIVATE (device);
986
 
        if (!priv->udi) {
987
 
                priv->udi = _nm_object_get_string_property (NM_OBJECT (device),
988
 
                                                           NM_DBUS_INTERFACE_DEVICE,
989
 
                                                           "Udi",
990
 
                                                           NULL);
991
 
        }
992
 
 
993
 
        return priv->udi;
 
852
        _nm_object_ensure_inited (NM_OBJECT (device));
 
853
        return NM_DEVICE_GET_PRIVATE (device)->udi;
994
854
}
995
855
 
996
856
/**
1005
865
const char *
1006
866
nm_device_get_driver (NMDevice *device)
1007
867
{
1008
 
        NMDevicePrivate *priv;
1009
 
 
1010
868
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
1011
869
 
1012
 
        priv = NM_DEVICE_GET_PRIVATE (device);
1013
 
        if (!priv->driver) {
1014
 
                priv->driver = _nm_object_get_string_property (NM_OBJECT (device),
1015
 
                                                              NM_DBUS_INTERFACE_DEVICE,
1016
 
                                                              "Driver",
1017
 
                                                              NULL);
1018
 
        }
1019
 
 
1020
 
        return priv->driver;
 
870
        _nm_object_ensure_inited (NM_OBJECT (device));
 
871
        return NM_DEVICE_GET_PRIVATE (device)->driver;
1021
872
}
1022
873
 
1023
874
/**
1031
882
NMDeviceCapabilities
1032
883
nm_device_get_capabilities (NMDevice *device)
1033
884
{
1034
 
        NMDevicePrivate *priv;
1035
 
 
1036
885
        g_return_val_if_fail (NM_IS_DEVICE (device), 0);
1037
886
 
1038
 
        priv = NM_DEVICE_GET_PRIVATE (device);
1039
 
        if (!priv->capabilities) {
1040
 
                priv->capabilities = _nm_object_get_uint_property (NM_OBJECT (device),
1041
 
                                                                  NM_DBUS_INTERFACE_DEVICE,
1042
 
                                                                  "Capabilities",
1043
 
                                                                  NULL);
1044
 
        }
1045
 
 
1046
 
        return priv->capabilities;
 
887
        _nm_object_ensure_inited (NM_OBJECT (device));
 
888
        return NM_DEVICE_GET_PRIVATE (device)->capabilities;
1047
889
}
1048
890
 
1049
891
/**
1057
899
gboolean
1058
900
nm_device_get_managed (NMDevice *device)
1059
901
{
1060
 
        NMDevicePrivate *priv;
1061
 
 
1062
902
        g_return_val_if_fail (NM_IS_DEVICE (device), 0);
1063
903
 
1064
 
        priv = NM_DEVICE_GET_PRIVATE (device);
1065
 
        if (!priv->managed) {
1066
 
                priv->managed = _nm_object_get_boolean_property (NM_OBJECT (device),
1067
 
                                                                NM_DBUS_INTERFACE_DEVICE,
1068
 
                                                                "Managed",
1069
 
                                                                NULL);
1070
 
        }
1071
 
 
1072
 
        return priv->managed;
 
904
        _nm_object_ensure_inited (NM_OBJECT (device));
 
905
        return NM_DEVICE_GET_PRIVATE (device)->managed;
1073
906
}
1074
907
 
1075
908
/**
1085
918
gboolean
1086
919
nm_device_get_firmware_missing (NMDevice *device)
1087
920
{
1088
 
        NMDevicePrivate *priv;
1089
 
 
1090
921
        g_return_val_if_fail (NM_IS_DEVICE (device), 0);
1091
922
 
1092
 
        priv = NM_DEVICE_GET_PRIVATE (device);
1093
 
        if (!priv->firmware_missing) {
1094
 
                priv->firmware_missing = _nm_object_get_boolean_property (NM_OBJECT (device),
1095
 
                                                                          NM_DBUS_INTERFACE_DEVICE,
1096
 
                                                                          "FirmwareMissing",
1097
 
                                                                          NULL);
1098
 
        }
1099
 
 
1100
 
        return priv->firmware_missing;
 
923
        _nm_object_ensure_inited (NM_OBJECT (device));
 
924
        return NM_DEVICE_GET_PRIVATE (device)->firmware_missing;
1101
925
}
1102
926
 
1103
927
/**
1111
935
NMIP4Config *
1112
936
nm_device_get_ip4_config (NMDevice *device)
1113
937
{
1114
 
        NMDevicePrivate *priv;
1115
 
        char *path;
1116
 
        GValue value = { 0, };
1117
 
        GError *error = NULL;
1118
 
 
1119
938
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
1120
939
 
1121
 
        priv = NM_DEVICE_GET_PRIVATE (device);
1122
 
        if (priv->got_ip4_config == TRUE)
1123
 
                return priv->ip4_config;
1124
 
 
1125
 
        path = _nm_object_get_object_path_property (NM_OBJECT (device),
1126
 
                                                    NM_DBUS_INTERFACE_DEVICE,
1127
 
                                                    "Ip4Config",
1128
 
                                                    &error);
1129
 
        if (error == NULL) {
1130
 
                g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
1131
 
                g_value_take_boxed (&value, path);
1132
 
                demarshal_ip4_config (NM_OBJECT (device), NULL, &value, &priv->ip4_config);
1133
 
                g_value_unset (&value);
1134
 
        }
1135
 
        g_clear_error (&error);
1136
 
 
1137
 
        return priv->ip4_config;
 
940
        _nm_object_ensure_inited (NM_OBJECT (device));
 
941
        return NM_DEVICE_GET_PRIVATE (device)->ip4_config;
1138
942
}
1139
943
 
1140
944
/**
1149
953
NMDHCP4Config *
1150
954
nm_device_get_dhcp4_config (NMDevice *device)
1151
955
{
1152
 
        NMDevicePrivate *priv;
1153
 
        char *path;
1154
 
        GValue value = { 0, };
1155
 
        GError *error = NULL;
1156
 
 
1157
956
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
1158
957
 
1159
 
        priv = NM_DEVICE_GET_PRIVATE (device);
1160
 
        if (priv->got_dhcp4_config == TRUE)
1161
 
                return priv->dhcp4_config;
1162
 
 
1163
 
        path = _nm_object_get_object_path_property (NM_OBJECT (device),
1164
 
                                                    NM_DBUS_INTERFACE_DEVICE,
1165
 
                                                    "Dhcp4Config",
1166
 
                                                    &error);
1167
 
        if (error == NULL) {
1168
 
                g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
1169
 
                g_value_take_boxed (&value, path);
1170
 
                demarshal_dhcp4_config (NM_OBJECT (device), NULL, &value, &priv->dhcp4_config);
1171
 
                g_value_unset (&value);
1172
 
        }
1173
 
        g_clear_error (&error);
1174
 
 
1175
 
        return priv->dhcp4_config;
 
958
        _nm_object_ensure_inited (NM_OBJECT (device));
 
959
        return NM_DEVICE_GET_PRIVATE (device)->dhcp4_config;
1176
960
}
1177
961
 
1178
962
/**
1186
970
NMIP6Config *
1187
971
nm_device_get_ip6_config (NMDevice *device)
1188
972
{
1189
 
        NMDevicePrivate *priv;
1190
 
        char *path;
1191
 
        GValue value = { 0, };
1192
 
        GError *error = NULL;
1193
 
 
1194
973
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
1195
974
 
1196
 
        priv = NM_DEVICE_GET_PRIVATE (device);
1197
 
        if (priv->got_ip6_config == TRUE)
1198
 
                return priv->ip6_config;
1199
 
 
1200
 
        path = _nm_object_get_object_path_property (NM_OBJECT (device),
1201
 
                                                    NM_DBUS_INTERFACE_DEVICE,
1202
 
                                                    "Ip6Config",
1203
 
                                                    &error);
1204
 
        if (error == NULL) {
1205
 
                g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
1206
 
                g_value_take_boxed (&value, path);
1207
 
                demarshal_ip6_config (NM_OBJECT (device), NULL, &value, &priv->ip6_config);
1208
 
                g_value_unset (&value);
1209
 
        }
1210
 
        g_clear_error (&error);
1211
 
 
1212
 
        return priv->ip6_config;
 
975
        _nm_object_ensure_inited (NM_OBJECT (device));
 
976
        return NM_DEVICE_GET_PRIVATE (device)->ip6_config;
1213
977
}
1214
978
 
1215
979
/**
1224
988
NMDHCP6Config *
1225
989
nm_device_get_dhcp6_config (NMDevice *device)
1226
990
{
1227
 
        NMDevicePrivate *priv;
1228
 
        char *path;
1229
 
        GValue value = { 0, };
1230
 
        GError *error = NULL;
1231
 
 
1232
991
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
1233
992
 
1234
 
        priv = NM_DEVICE_GET_PRIVATE (device);
1235
 
        if (priv->got_dhcp6_config == TRUE)
1236
 
                return priv->dhcp6_config;
1237
 
 
1238
 
        path = _nm_object_get_object_path_property (NM_OBJECT (device),
1239
 
                                                    NM_DBUS_INTERFACE_DEVICE,
1240
 
                                                    "Dhcp6Config",
1241
 
                                                    &error);
1242
 
        if (error == NULL) {
1243
 
                g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
1244
 
                g_value_take_boxed (&value, path);
1245
 
                demarshal_dhcp6_config (NM_OBJECT (device), NULL, &value, &priv->dhcp6_config);
1246
 
                g_value_unset (&value);
1247
 
        }
1248
 
        g_clear_error (&error);
1249
 
 
1250
 
        return priv->dhcp6_config;
 
993
        _nm_object_ensure_inited (NM_OBJECT (device));
 
994
        return NM_DEVICE_GET_PRIVATE (device)->dhcp6_config;
1251
995
}
1252
996
 
1253
997
/**
1261
1005
NMDeviceState
1262
1006
nm_device_get_state (NMDevice *device)
1263
1007
{
1264
 
        NMDevicePrivate *priv;
1265
 
 
1266
 
        g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
1267
 
 
1268
 
        priv = NM_DEVICE_GET_PRIVATE (device);
1269
 
        if (priv->state == NM_DEVICE_STATE_UNKNOWN) {
1270
 
                priv->state = _nm_object_get_uint_property (NM_OBJECT (device), 
1271
 
                                                           NM_DBUS_INTERFACE_DEVICE,
1272
 
                                                           "State",
1273
 
                                                           NULL);
1274
 
        }
1275
 
 
1276
 
        return priv->state;
 
1008
        g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
 
1009
 
 
1010
        _nm_object_ensure_inited (NM_OBJECT (device));
 
1011
        return NM_DEVICE_GET_PRIVATE (device)->state;
 
1012
}
 
1013
 
 
1014
/**
 
1015
 * nm_device_get_state_reason:
 
1016
 * @device: a #NMDevice
 
1017
 * @reason: (out) (allow-none): location to store reason (#NMDeviceStateReason), or NULL
 
1018
 *
 
1019
 * Gets the current #NMDevice state (return value) and the reason for entering
 
1020
 * the state (@reason argument).
 
1021
 *
 
1022
 * Returns: the current device state
 
1023
 **/
 
1024
NMDeviceState
 
1025
nm_device_get_state_reason (NMDevice *device, NMDeviceStateReason *reason)
 
1026
{
 
1027
        g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
 
1028
 
 
1029
        _nm_object_ensure_inited (NM_OBJECT (device));
 
1030
        if (reason)
 
1031
                *reason = NM_DEVICE_GET_PRIVATE (device)->reason;
 
1032
        return NM_DEVICE_GET_PRIVATE (device)->state;
1277
1033
}
1278
1034
 
1279
1035
/**
1288
1044
NMActiveConnection *
1289
1045
nm_device_get_active_connection (NMDevice *device)
1290
1046
{
1291
 
        NMDevicePrivate *priv;
1292
 
        char *path;
1293
 
        GValue value = { 0, };
1294
 
        GError *error = NULL;
1295
 
 
1296
1047
        g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
1297
1048
 
1298
 
        priv = NM_DEVICE_GET_PRIVATE (device);
1299
 
        if (priv->got_active_connection == TRUE)
1300
 
                return priv->active_connection;
1301
 
 
1302
 
        path = _nm_object_get_object_path_property (NM_OBJECT (device),
1303
 
                                                    NM_DBUS_INTERFACE_DEVICE,
1304
 
                                                    "ActiveConnection",
1305
 
                                                    &error);
1306
 
        if (error == NULL) {
1307
 
                g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
1308
 
                g_value_take_boxed (&value, path);
1309
 
                demarshal_active_connection (NM_OBJECT (device), NULL, &value, &priv->active_connection);
1310
 
                g_value_unset (&value);
1311
 
        }
1312
 
        g_clear_error (&error);
1313
 
 
1314
 
        return priv->active_connection;
 
1049
        _nm_object_ensure_inited (NM_OBJECT (device));
 
1050
        return NM_DEVICE_GET_PRIVATE (device)->active_connection;
1315
1051
}
1316
1052
 
1317
1053
/* From hostap, Copyright (c) 2002-2005, Jouni Malinen <jkmaline@cc.hut.fi> */
1518
1254
 
1519
1255
static void
1520
1256
deactivate_cb (DBusGProxy *proxy,
1521
 
               GError *error,
 
1257
               DBusGProxyCall *call,
1522
1258
               gpointer user_data)
1523
1259
{
1524
1260
        DeactivateInfo *info = user_data;
 
1261
        GError *error = NULL;
1525
1262
 
 
1263
        dbus_g_proxy_end_call (proxy, call, &error,
 
1264
                               G_TYPE_INVALID);
1526
1265
        if (info->fn)
1527
1266
                info->fn (info->device, error, info->user_data);
1528
1267
        else if (error) {
1532
1271
                           error ? error->code : -1,
1533
1272
                           error && error->message ? error->message : "(unknown)");
1534
1273
        }
 
1274
        g_clear_error (&error);
1535
1275
 
1536
1276
        g_object_unref (info->device);
1537
1277
        g_slice_free (DeactivateInfo, info);
1562
1302
        info->user_data = user_data;
1563
1303
        info->device = g_object_ref (device);
1564
1304
 
1565
 
        org_freedesktop_NetworkManager_Device_disconnect_async (NM_DEVICE_GET_PRIVATE (device)->proxy,
1566
 
                                                                deactivate_cb,
1567
 
                                                                info);
 
1305
        dbus_g_proxy_begin_call (NM_DEVICE_GET_PRIVATE (device)->proxy, "Disconnect",
 
1306
                                 deactivate_cb, info, NULL,
 
1307
                                 G_TYPE_INVALID);
1568
1308
}
1569
1309
 
1570
1310
/**
1602
1342
 * contain any WiFi connections in @connections that allow connection to
1603
1343
 * unencrypted or WEP-enabled SSIDs.  The returned list will not contain
1604
1344
 * Ethernet, Bluetooth, WiFi WPA connections, or any other connection that is
1605
 
 * incompatible with the device.
 
1345
 * incompatible with the device. To get the full list of connections see
 
1346
 * nm_remote_settings_list_connections().
1606
1347
 *
1607
1348
 * Returns: (transfer container) (element-type NetworkManager.Connection): a
1608
1349
 * list of #NMConnection objects that could be activated with the given @device.