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
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
#include "nm-gsm-device.h"
#include "nm-device-private.h"
#include "nm-object-private.h"
G_DEFINE_TYPE (NMGsmDevice, nm_gsm_device, NM_TYPE_SERIAL_DEVICE)
#define NM_GSM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_GSM_DEVICE, NMGsmDevicePrivate))
typedef struct {
DBusGProxy *proxy;
gboolean disposed;
} NMGsmDevicePrivate;
static void
nm_gsm_device_init (NMGsmDevice *device)
{
}
static void
register_for_property_changed (NMGsmDevice *device)
{
NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (device);
const NMPropertiesChangedInfo property_changed_info[] = {
{ NULL },
};
_nm_object_handle_properties_changed (NM_OBJECT (device),
priv->proxy,
property_changed_info);
}
static GObject*
constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params)
{
GObject *object;
NMGsmDevicePrivate *priv;
object = G_OBJECT_CLASS (nm_gsm_device_parent_class)->constructor (type,
n_construct_params,
construct_params);
if (!object)
return NULL;
priv = NM_GSM_DEVICE_GET_PRIVATE (object);
priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
NM_DBUS_SERVICE,
nm_object_get_path (NM_OBJECT (object)),
NM_DBUS_INTERFACE_GSM_DEVICE);
register_for_property_changed (NM_GSM_DEVICE (object));
return object;
}
static void
dispose (GObject *object)
{
NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (object);
if (priv->disposed) {
G_OBJECT_CLASS (nm_gsm_device_parent_class)->dispose (object);
return;
}
priv->disposed = TRUE;
g_object_unref (priv->proxy);
G_OBJECT_CLASS (nm_gsm_device_parent_class)->dispose (object);
}
static void
nm_gsm_device_class_init (NMGsmDeviceClass *device_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (device_class);
g_type_class_add_private (device_class, sizeof (NMGsmDevicePrivate));
/* virtual methods */
object_class->constructor = constructor;
object_class->dispose = dispose;
}
/**
* nm_gsm_device_new:
* @connection: the #DBusGConnection
* @path: the DBus object path of the device
*
* Creates a new #NMGsmDevice.
*
* Returns: a new device
**/
NMGsmDevice *
nm_gsm_device_new (DBusGConnection *connection, const char *path)
{
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
return (NMGsmDevice *) g_object_new (NM_TYPE_GSM_DEVICE,
NM_OBJECT_DBUS_CONNECTION, connection,
NM_OBJECT_DBUS_PATH, path,
NULL);
}
|