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
|
#include "nm-device-802-11-wireless.h"
#include "nm-device-private.h"
#include "nm-utils.h"
#include "nm-device-802-11-wireless-bindings.h"
G_DEFINE_TYPE (NMDevice80211Wireless, nm_device_802_11_wireless, NM_TYPE_DEVICE)
static void
nm_device_802_11_wireless_init (NMDevice80211Wireless *device)
{
}
static void
nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *device_class)
{
}
NMDevice80211Wireless *
nm_device_802_11_wireless_new (DBusGConnection *connection, const char *path)
{
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
return (NMDevice80211Wireless *) g_object_new (NM_TYPE_DEVICE_802_11_WIRELESS,
"name", NM_DBUS_SERVICE,
"path", path,
"interface", NM_DBUS_INTERFACE_DEVICE_WIRELESS,
"connection", connection,
NULL);
}
char *
nm_device_802_11_wireless_get_hw_address (NMDevice80211Wireless *device)
{
GValue value = {0,};
char *address = NULL;
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), NULL);
if (nm_dbus_get_property (DBUS_G_PROXY (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
"HwAddress",
&value))
address = g_strdup (g_value_get_string (&value));
return address;
}
int
nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *device)
{
GValue value = {0,};
int mode = 0;
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), 0);
if (nm_dbus_get_property (DBUS_G_PROXY (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
"Mode",
&value))
mode = g_value_get_int (&value);
return mode;
}
int
nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *device)
{
GValue value = {0,};
int bitrate = 0;
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), 0);
if (nm_dbus_get_property (DBUS_G_PROXY (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
"Bitrate",
&value))
bitrate = g_value_get_int (&value);
return bitrate;
}
NMAccessPoint *
nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device)
{
GValue value = {0,};
NMAccessPoint *ap = NULL;
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), NULL);
if (nm_dbus_get_property (DBUS_G_PROXY (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
"ActiveNetwork",
&value)) {
DBusGConnection *connection = NULL;
g_object_get (device, "connection", &connection, NULL);
ap = nm_access_point_new (connection, g_value_get_string (&value));
}
return ap;
}
GSList *
nm_device_802_11_wireless_get_networks (NMDevice80211Wireless *device)
{
GSList *list = NULL;
GPtrArray *array = NULL;
GError *err = NULL;
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), NULL);
if (!org_freedesktop_NetworkManager_Device_Wireless_get_active_networks (DBUS_G_PROXY (device), &array, &err)) {
g_warning ("Error in get_networks: %s", err->message);
g_error_free (err);
} else {
DBusGConnection *connection = NULL;
int i;
g_object_get (device, "connection", &connection, NULL);
for (i = 0; i < array->len; i++) {
NMAccessPoint *ap = nm_access_point_new (connection, g_ptr_array_index (array, i));
list = g_slist_prepend (list, ap);
}
list = g_slist_reverse (list);
g_ptr_array_free (array, TRUE);
}
return list;
}
void
nm_device_802_11_wireless_activate (NMDevice80211Wireless *device,
NMAccessPoint *ap,
gboolean user_requested)
{
GError *err = NULL;
g_return_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device));
g_return_if_fail (NM_IS_ACCESS_POINT (ap));
if (!org_freedesktop_NetworkManager_Device_Wireless_activate (DBUS_G_PROXY (device),
dbus_g_proxy_get_path (DBUS_G_PROXY (ap)),
user_requested,
&err)) {
g_warning ("Error in wireless_activate: %s", err->message);
g_error_free (err);
}
}
|