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

« back to all changes in this revision

Viewing changes to libnm-glib/nm-device-bt.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:
32
32
#include "nm-device-private.h"
33
33
#include "nm-object-private.h"
34
34
 
35
 
#include "nm-device-bt-bindings.h"
36
 
 
37
35
G_DEFINE_TYPE (NMDeviceBt, nm_device_bt, NM_TYPE_DEVICE)
38
36
 
39
37
#define NM_DEVICE_BT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BT, NMDeviceBtPrivate))
44
42
        char *hw_address;
45
43
        char *name;
46
44
        guint32 bt_capabilities;
47
 
        gboolean bt_capabilities_valid;
48
45
 
49
46
        gboolean disposed;
50
47
} NMDeviceBtPrivate;
95
92
const char *
96
93
nm_device_bt_get_hw_address (NMDeviceBt *device)
97
94
{
98
 
        NMDeviceBtPrivate *priv;
99
 
 
100
95
        g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL);
101
96
 
102
 
        priv = NM_DEVICE_BT_GET_PRIVATE (device);
103
 
        if (!priv->hw_address) {
104
 
                priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device),
105
 
                                                                   NM_DBUS_INTERFACE_DEVICE_BLUETOOTH,
106
 
                                                                   DBUS_PROP_HW_ADDRESS,
107
 
                                                                   NULL);
108
 
        }
109
 
 
110
 
        return priv->hw_address;
 
97
        _nm_object_ensure_inited (NM_OBJECT (device));
 
98
        return NM_DEVICE_BT_GET_PRIVATE (device)->hw_address;
111
99
}
112
100
 
113
101
/**
121
109
const char *
122
110
nm_device_bt_get_name (NMDeviceBt *device)
123
111
{
124
 
        NMDeviceBtPrivate *priv;
125
 
 
126
112
        g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL);
127
113
 
128
 
        priv = NM_DEVICE_BT_GET_PRIVATE (device);
129
 
        if (!priv->name) {
130
 
                priv->name = _nm_object_get_string_property (NM_OBJECT (device),
131
 
                                                             NM_DBUS_INTERFACE_DEVICE_BLUETOOTH,
132
 
                                                             DBUS_PROP_NAME,
133
 
                                                             NULL);
134
 
        }
135
 
 
136
 
        return priv->name;
 
114
        _nm_object_ensure_inited (NM_OBJECT (device));
 
115
        return NM_DEVICE_BT_GET_PRIVATE (device)->name;
137
116
}
138
117
 
139
118
/**
147
126
NMBluetoothCapabilities
148
127
nm_device_bt_get_capabilities (NMDeviceBt *device)
149
128
{
150
 
        NMDeviceBtPrivate *priv;
151
 
 
152
129
        g_return_val_if_fail (NM_IS_DEVICE_BT (device), NM_BT_CAPABILITY_NONE);
153
130
 
154
 
        priv = NM_DEVICE_BT_GET_PRIVATE (device);
155
 
        if (!priv->bt_capabilities_valid) {
156
 
                priv->bt_capabilities = _nm_object_get_uint_property (NM_OBJECT (device),
157
 
                                                                      NM_DBUS_INTERFACE_DEVICE_BLUETOOTH,
158
 
                                                                      DBUS_PROP_BT_CAPABILITIES,
159
 
                                                                      NULL);
160
 
                priv->bt_capabilities_valid = TRUE;
161
 
        }
162
 
 
163
 
        return priv->bt_capabilities;
 
131
        _nm_object_ensure_inited (NM_OBJECT (device));
 
132
        return NM_DEVICE_BT_GET_PRIVATE (device)->bt_capabilities;
164
133
}
165
134
 
166
135
static NMBluetoothCapabilities
232
201
}
233
202
 
234
203
static void
235
 
register_for_property_changed (NMDeviceBt *device)
 
204
register_properties (NMDeviceBt *device)
236
205
{
237
206
        NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
238
 
        const NMPropertiesChangedInfo property_changed_info[] = {
239
 
                { NM_DEVICE_BT_HW_ADDRESS,   _nm_object_demarshal_generic, &priv->hw_address },
240
 
                { NM_DEVICE_BT_NAME,         _nm_object_demarshal_generic, &priv->name },
241
 
                { NM_DEVICE_BT_CAPABILITIES, _nm_object_demarshal_generic, &priv->bt_capabilities },
 
207
        const NMPropertiesInfo property_info[] = {
 
208
                { NM_DEVICE_BT_HW_ADDRESS,   &priv->hw_address },
 
209
                { NM_DEVICE_BT_NAME,         &priv->name },
 
210
                { NM_DEVICE_BT_CAPABILITIES, &priv->bt_capabilities },
242
211
                { NULL },
243
212
        };
244
213
 
245
 
        _nm_object_handle_properties_changed (NM_OBJECT (device),
246
 
                                             priv->proxy,
247
 
                                             property_changed_info);
 
214
        _nm_object_register_properties (NM_OBJECT (device),
 
215
                                        priv->proxy,
 
216
                                        property_info);
248
217
}
249
218
 
250
 
static GObject*
251
 
constructor (GType type,
252
 
                         guint n_construct_params,
253
 
                         GObjectConstructParam *construct_params)
 
219
static void
 
220
constructed (GObject *object)
254
221
{
255
 
        GObject *object;
256
 
 
257
 
        object = G_OBJECT_CLASS (nm_device_bt_parent_class)->constructor (type,
258
 
                                                                          n_construct_params,
259
 
                                                                          construct_params);
260
 
        if (object) {
261
 
                        NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object);
262
 
 
263
 
                priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
264
 
                                                         NM_DBUS_SERVICE,
265
 
                                                         nm_object_get_path (NM_OBJECT (object)),
266
 
                                                         NM_DBUS_INTERFACE_DEVICE_BLUETOOTH);
267
 
 
268
 
                register_for_property_changed (NM_DEVICE_BT (object));
269
 
        }
270
 
 
271
 
        return object;
 
222
        NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object);
 
223
 
 
224
        G_OBJECT_CLASS (nm_device_bt_parent_class)->constructed (object);
 
225
 
 
226
        priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
 
227
                                                 NM_DBUS_SERVICE,
 
228
                                                 nm_object_get_path (NM_OBJECT (object)),
 
229
                                                 NM_DBUS_INTERFACE_DEVICE_BLUETOOTH);
 
230
 
 
231
        register_properties (NM_DEVICE_BT (object));
272
232
}
273
233
 
274
234
static void
331
291
        g_type_class_add_private (bt_class, sizeof (NMDeviceBtPrivate));
332
292
 
333
293
        /* virtual methods */
334
 
        object_class->constructor = constructor;
 
294
        object_class->constructed = constructed;
335
295
        object_class->dispose = dispose;
336
296
        object_class->finalize = finalize;
337
297
        object_class->get_property = get_property;