diff options
Diffstat (limited to 'meta/recipes-connectivity/connman/connman-gnome/0002-Update-for-ConnMan-0.79-API-changes.patch')
-rw-r--r-- | meta/recipes-connectivity/connman/connman-gnome/0002-Update-for-ConnMan-0.79-API-changes.patch | 865 |
1 files changed, 865 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/connman/connman-gnome/0002-Update-for-ConnMan-0.79-API-changes.patch b/meta/recipes-connectivity/connman/connman-gnome/0002-Update-for-ConnMan-0.79-API-changes.patch new file mode 100644 index 0000000000..fe87b5b71d --- /dev/null +++ b/meta/recipes-connectivity/connman/connman-gnome/0002-Update-for-ConnMan-0.79-API-changes.patch | |||
@@ -0,0 +1,865 @@ | |||
1 | From 8b8fd038474def8452354105b40738a402f28d19 Mon Sep 17 00:00:00 2001 | ||
2 | Message-Id: <8b8fd038474def8452354105b40738a402f28d19.1334369310.git.paul.eggleton@linux.intel.com> | ||
3 | In-Reply-To: <cover.1334369310.git.paul.eggleton@linux.intel.com> | ||
4 | References: <cover.1334369310.git.paul.eggleton@linux.intel.com> | ||
5 | From: Paul Eggleton <paul.eggleton@linux.intel.com> | ||
6 | Date: Thu, 12 Apr 2012 00:35:00 +0100 | ||
7 | Subject: [PATCH 2/6] Update for ConnMan 0.79 API changes | ||
8 | |||
9 | * Use Manager.GetServices method instead of Manager.Services property | ||
10 | * Use Manager.GetTechnologies / Technology.Powered instead of | ||
11 | Manager.EnabledTechnologies method | ||
12 | * Use Technology.Powered property instead of Manager.EnableTechnology | ||
13 | and Manager.DisableTechnology methods | ||
14 | * Use Technology.Scan method instead of Manager.RequestScan method | ||
15 | * Listen for ServicesAdded, ServicesRemoved, TechnologyAdded and | ||
16 | TechnologyRemoved signals instead of monitoring the old Services | ||
17 | and EnabledTechnologies properties | ||
18 | |||
19 | Also remove unused code relating to the old API. | ||
20 | |||
21 | Upstream-Status: Submitted | ||
22 | |||
23 | Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> | ||
24 | --- | ||
25 | common/connman-client.c | 90 ++----------- | ||
26 | common/connman-client.h | 12 +- | ||
27 | common/connman-dbus.c | 359 +++++++++++++++++++++++++++-------------------- | ||
28 | common/connman-dbus.h | 1 + | ||
29 | common/connman-dbus.xml | 17 +-- | ||
30 | common/marshal.list | 2 + | ||
31 | properties/cellular.c | 6 +- | ||
32 | properties/ethernet.c | 8 +- | ||
33 | properties/main.c | 14 +-- | ||
34 | properties/wifi.c | 8 +- | ||
35 | 10 files changed, 245 insertions(+), 272 deletions(-) | ||
36 | |||
37 | diff --git a/common/connman-client.c b/common/connman-client.c | ||
38 | index 407aea0..9d755c4 100644 | ||
39 | --- a/common/connman-client.c | ||
40 | +++ b/common/connman-client.c | ||
41 | @@ -112,9 +112,7 @@ static void connman_client_init(ConnmanClient *client) | ||
42 | G_TYPE_STRING, /* address */ | ||
43 | G_TYPE_STRING, /* netmask */ | ||
44 | G_TYPE_STRING, /* gateway */ | ||
45 | - G_TYPE_BOOLEAN, /* ethernet enabled */ | ||
46 | - G_TYPE_BOOLEAN, /* wifi enabled */ | ||
47 | - G_TYPE_BOOLEAN, /* cellular enabled */ | ||
48 | + G_TYPE_BOOLEAN, /* powered */ | ||
49 | G_TYPE_BOOLEAN);/* offline */ | ||
50 | |||
51 | g_object_set_data(G_OBJECT(priv->store), | ||
52 | @@ -288,7 +286,7 @@ void connman_client_set_powered(ConnmanClient *client, const gchar *device, | ||
53 | DBusGProxy *proxy; | ||
54 | GValue value = { 0 }; | ||
55 | |||
56 | - DBG("client %p", client); | ||
57 | + DBG("client %p device %s", client, device); | ||
58 | |||
59 | if (device == NULL) | ||
60 | return; | ||
61 | @@ -300,64 +298,34 @@ void connman_client_set_powered(ConnmanClient *client, const gchar *device, | ||
62 | g_value_init(&value, G_TYPE_BOOLEAN); | ||
63 | g_value_set_boolean(&value, powered); | ||
64 | |||
65 | - connman_set_property(proxy, "Powered", &value, NULL); | ||
66 | - | ||
67 | - g_object_unref(proxy); | ||
68 | -} | ||
69 | - | ||
70 | -static gboolean device_scan(GtkTreeModel *model, GtkTreePath *path, | ||
71 | - GtkTreeIter *iter, gpointer user_data) | ||
72 | -{ | ||
73 | - DBusGProxy *proxy; | ||
74 | - | ||
75 | - gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, -1); | ||
76 | - | ||
77 | - if (proxy == NULL) | ||
78 | - return FALSE; | ||
79 | - | ||
80 | - if (g_str_equal(dbus_g_proxy_get_interface(proxy), | ||
81 | - CONNMAN_SERVICE_INTERFACE) == FALSE) | ||
82 | - return FALSE; | ||
83 | - | ||
84 | - connman_propose_scan(proxy, NULL); | ||
85 | + GError *error = NULL; | ||
86 | + gboolean ret = connman_set_property(proxy, "Powered", &value, &error); | ||
87 | + if( error ) | ||
88 | + fprintf (stderr, "error: %s\n", error->message); | ||
89 | |||
90 | g_object_unref(proxy); | ||
91 | - | ||
92 | - return FALSE; | ||
93 | } | ||
94 | |||
95 | -void connman_client_propose_scan(ConnmanClient *client, const gchar *device) | ||
96 | +void connman_client_scan(ConnmanClient *client, const gchar *device, | ||
97 | + connman_scan_reply callback, gpointer user_data) | ||
98 | { | ||
99 | ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
100 | DBusGProxy *proxy; | ||
101 | |||
102 | - DBG("client %p", client); | ||
103 | + DBG("client %p device %s", client, device); | ||
104 | |||
105 | - if (device == NULL) { | ||
106 | - gtk_tree_model_foreach(GTK_TREE_MODEL(priv->store), | ||
107 | - device_scan, NULL); | ||
108 | + if (device == NULL) | ||
109 | return; | ||
110 | - } | ||
111 | |||
112 | proxy = connman_dbus_get_proxy(priv->store, device); | ||
113 | if (proxy == NULL) | ||
114 | return; | ||
115 | |||
116 | - connman_propose_scan(proxy, NULL); | ||
117 | + connman_scan_async(proxy, callback, user_data); | ||
118 | |||
119 | g_object_unref(proxy); | ||
120 | } | ||
121 | |||
122 | -void connman_client_request_scan(ConnmanClient *client, char *scantype, | ||
123 | - connman_request_scan_reply callback, gpointer userdata) | ||
124 | -{ | ||
125 | - ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
126 | - | ||
127 | - DBG("client %p", client); | ||
128 | - | ||
129 | - connman_request_scan_async(priv->manager, scantype, callback, userdata); | ||
130 | -} | ||
131 | - | ||
132 | gboolean connman_client_get_offline_status(ConnmanClient *client) | ||
133 | { | ||
134 | GHashTable *hash; | ||
135 | @@ -600,39 +568,3 @@ void connman_client_remove(ConnmanClient *client, const gchar *network) | ||
136 | |||
137 | g_object_unref(proxy); | ||
138 | } | ||
139 | - | ||
140 | -void connman_client_enable_technology(ConnmanClient *client, const char *network, | ||
141 | - const gchar *technology) | ||
142 | -{ | ||
143 | - ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
144 | - DBusGProxy *proxy; | ||
145 | - | ||
146 | - if (network== NULL) | ||
147 | - return; | ||
148 | - | ||
149 | - proxy = connman_dbus_get_proxy(priv->store, network); | ||
150 | - if (proxy == NULL) | ||
151 | - return; | ||
152 | - | ||
153 | - connman_enable_technology(proxy, technology, NULL); | ||
154 | - | ||
155 | - g_object_unref(proxy); | ||
156 | -} | ||
157 | - | ||
158 | -void connman_client_disable_technology(ConnmanClient *client, const char *network, | ||
159 | - const gchar *technology) | ||
160 | -{ | ||
161 | - ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client); | ||
162 | - DBusGProxy *proxy; | ||
163 | - | ||
164 | - if (network == NULL) | ||
165 | - return; | ||
166 | - | ||
167 | - proxy = connman_dbus_get_proxy(priv->store, network); | ||
168 | - if (proxy == NULL) | ||
169 | - return; | ||
170 | - | ||
171 | - connman_disable_technology(proxy, technology, NULL); | ||
172 | - | ||
173 | - g_object_unref(proxy); | ||
174 | -} | ||
175 | diff --git a/common/connman-client.h b/common/connman-client.h | ||
176 | index 15fa098..6fe772c 100644 | ||
177 | --- a/common/connman-client.h | ||
178 | +++ b/common/connman-client.h | ||
179 | @@ -69,7 +69,8 @@ void connman_client_set_powered(ConnmanClient *client, const gchar *device, | ||
180 | gboolean powered); | ||
181 | gboolean connman_client_set_ipv4(ConnmanClient *client, const gchar *device, | ||
182 | struct ipv4_config *ipv4_config); | ||
183 | -void connman_client_propose_scan(ConnmanClient *client, const gchar *device); | ||
184 | +void connman_client_scan(ConnmanClient *client, const gchar *device, | ||
185 | + connman_scan_reply callback, gpointer user_data); | ||
186 | |||
187 | void connman_client_connect(ConnmanClient *client, const gchar *network); | ||
188 | void connman_client_disconnect(ConnmanClient *client, const gchar *network); | ||
189 | @@ -89,8 +90,6 @@ void connman_client_set_callback(ConnmanClient *client, | ||
190 | |||
191 | void connman_client_remove(ConnmanClient *client, const gchar *network); | ||
192 | |||
193 | -void connman_client_request_scan(ConnmanClient *client, char *scantype, | ||
194 | - connman_request_scan_reply callback, gpointer userdata); | ||
195 | gboolean connman_client_get_offline_status(ConnmanClient *client); | ||
196 | void connman_client_set_offlinemode(ConnmanClient *client, gboolean status); | ||
197 | |||
198 | @@ -114,11 +113,8 @@ enum { | ||
199 | CONNMAN_COLUMN_ADDRESS, /* G_TYPE_STRING */ | ||
200 | CONNMAN_COLUMN_NETMASK, /* G_TYPE_STRING */ | ||
201 | CONNMAN_COLUMN_GATEWAY, /* G_TYPE_STRING */ | ||
202 | - | ||
203 | - CONNMAN_COLUMN_ETHERNET_ENABLED,/* G_TYPE_STRING */ | ||
204 | - CONNMAN_COLUMN_WIFI_ENABLED, /* G_TYPE_STRING */ | ||
205 | - CONNMAN_COLUMN_CELLULAR_ENABLED,/* G_TYPE_STRING */ | ||
206 | - CONNMAN_COLUMN_OFFLINEMODE, /* G_TYPE_STRING */ | ||
207 | + CONNMAN_COLUMN_POWERED, /* G_TYPE_BOOLEAN */ | ||
208 | + CONNMAN_COLUMN_OFFLINEMODE, /* G_TYPE_BOOLEAN */ | ||
209 | |||
210 | _CONNMAN_NUM_COLUMNS | ||
211 | }; | ||
212 | diff --git a/common/connman-dbus.c b/common/connman-dbus.c | ||
213 | index 6669749..4eb77b6 100644 | ||
214 | --- a/common/connman-dbus.c | ||
215 | +++ b/common/connman-dbus.c | ||
216 | @@ -28,6 +28,8 @@ | ||
217 | #include "connman-dbus.h" | ||
218 | #include "connman-dbus-glue.h" | ||
219 | |||
220 | +#include "marshal.h" | ||
221 | + | ||
222 | #ifdef DEBUG | ||
223 | #define DBG(fmt, arg...) printf("%s:%s() " fmt "\n", __FILE__, __FUNCTION__ , ## arg) | ||
224 | #else | ||
225 | @@ -164,22 +166,6 @@ gboolean connman_dbus_get_iter(GtkTreeStore *store, const gchar *path, | ||
226 | return get_iter_from_path(store, iter, path); | ||
227 | } | ||
228 | |||
229 | -static void iterate_list(const GValue *value, gpointer user_data) | ||
230 | -{ | ||
231 | - GSList **list = user_data; | ||
232 | - gchar *path = g_value_dup_boxed(value); | ||
233 | - | ||
234 | - if (path == NULL) | ||
235 | - return; | ||
236 | - | ||
237 | - *list = g_slist_append(*list, path); | ||
238 | -} | ||
239 | - | ||
240 | -static gint compare_path(gconstpointer a, gconstpointer b) | ||
241 | -{ | ||
242 | - return g_strcmp0(a, b); | ||
243 | -} | ||
244 | - | ||
245 | static guint get_type(const GValue *value) | ||
246 | { | ||
247 | const char *type = value ? g_value_get_string(value) : NULL; | ||
248 | @@ -217,95 +203,76 @@ static const gchar *type2icon(guint type) | ||
249 | return NULL; | ||
250 | } | ||
251 | |||
252 | -static void enabled_technologies_changed(GtkTreeStore *store, GValue *value) | ||
253 | +static void tech_changed(DBusGProxy *proxy, const char *property, | ||
254 | + GValue *value, gpointer user_data) | ||
255 | { | ||
256 | + GtkTreeStore *store = user_data; | ||
257 | + const char *path = dbus_g_proxy_get_path(proxy); | ||
258 | GtkTreeIter iter; | ||
259 | - gboolean ethernet_enabled_prev, ethernet_enabled = FALSE; | ||
260 | - gboolean wifi_enabled_prev, wifi_enabled = FALSE; | ||
261 | - gboolean cellular_enabled_prev, cellular_enabled = FALSE; | ||
262 | - gchar **tech = g_value_get_boxed (value); | ||
263 | - guint i; | ||
264 | |||
265 | - if (value == NULL) | ||
266 | - return; | ||
267 | - | ||
268 | - for (i = 0; i < g_strv_length(tech); i++) { | ||
269 | - DBG("technology: %s", *(tech+i)); | ||
270 | - if (g_str_equal("ethernet", *(tech + i))) | ||
271 | - ethernet_enabled = TRUE; | ||
272 | - else if (g_str_equal ("wifi", *(tech + i))) | ||
273 | - wifi_enabled = TRUE; | ||
274 | - else if (g_str_equal ("cellular", *(tech + i))) | ||
275 | - cellular_enabled = TRUE; | ||
276 | - } | ||
277 | + DBG("store %p proxy %p property %s", store, proxy, property); | ||
278 | |||
279 | - get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_ETHERNET); | ||
280 | - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, | ||
281 | - CONNMAN_COLUMN_ETHERNET_ENABLED, ðernet_enabled_prev, -1); | ||
282 | - if (ethernet_enabled_prev != ethernet_enabled) | ||
283 | - gtk_tree_store_set(store, &iter, | ||
284 | - CONNMAN_COLUMN_ETHERNET_ENABLED, ethernet_enabled, -1); | ||
285 | + if (property == NULL || value == NULL) | ||
286 | + return; | ||
287 | |||
288 | - get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_WIFI); | ||
289 | - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, | ||
290 | - CONNMAN_COLUMN_WIFI_ENABLED, &wifi_enabled_prev, -1); | ||
291 | - if (wifi_enabled_prev != wifi_enabled) | ||
292 | - gtk_tree_store_set(store, &iter, | ||
293 | - CONNMAN_COLUMN_WIFI_ENABLED, wifi_enabled, -1); | ||
294 | + if (get_iter_from_path(store, &iter, path) == FALSE) | ||
295 | + return; | ||
296 | |||
297 | - get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_CELLULAR); | ||
298 | - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, | ||
299 | - CONNMAN_COLUMN_CELLULAR_ENABLED, &cellular_enabled_prev, -1); | ||
300 | - if (cellular_enabled_prev != cellular_enabled) | ||
301 | + if (g_str_equal(property, "Powered") == TRUE) { | ||
302 | + gboolean powered = g_value_get_boolean(value); | ||
303 | gtk_tree_store_set(store, &iter, | ||
304 | - CONNMAN_COLUMN_CELLULAR_ENABLED, cellular_enabled, -1); | ||
305 | + CONNMAN_COLUMN_POWERED, powered, -1); | ||
306 | + } | ||
307 | } | ||
308 | |||
309 | -static void enabled_technologies_properties(GtkTreeStore *store, DBusGProxy *proxy, GValue *value) | ||
310 | +static void tech_properties(DBusGProxy *proxy, GHashTable *hash, | ||
311 | + GError *error, gpointer user_data) | ||
312 | { | ||
313 | + GtkTreeStore *store = user_data; | ||
314 | GtkTreeIter iter; | ||
315 | - gboolean ethernet_enabled = FALSE; | ||
316 | - gboolean wifi_enabled = FALSE; | ||
317 | - gboolean cellular_enabled = FALSE; | ||
318 | - gchar **tech = g_value_get_boxed (value); | ||
319 | - guint i; | ||
320 | - | ||
321 | - for (i = 0; i < g_strv_length (tech); i++) { | ||
322 | - DBG("technology: %s", *(tech+i)); | ||
323 | - if (g_str_equal("ethernet", *(tech + i))) | ||
324 | - ethernet_enabled = TRUE; | ||
325 | - else if (g_str_equal ("wifi", *(tech + i))) | ||
326 | - wifi_enabled = TRUE; | ||
327 | - else if (g_str_equal ("cellular", *(tech + i))) | ||
328 | - cellular_enabled = TRUE; | ||
329 | - } | ||
330 | + gboolean powered = FALSE; | ||
331 | + GValue *propval = 0; | ||
332 | + const char *techtype = 0; | ||
333 | |||
334 | - if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_ETHERNET) == FALSE) | ||
335 | - gtk_tree_store_append(store, &iter, NULL); | ||
336 | + propval = g_hash_table_lookup(hash, "Type"); | ||
337 | + techtype = propval ? g_value_get_string(propval) : NULL; | ||
338 | |||
339 | - gtk_tree_store_set(store, &iter, | ||
340 | - CONNMAN_COLUMN_PROXY, proxy, | ||
341 | - CONNMAN_COLUMN_ETHERNET_ENABLED, ethernet_enabled, | ||
342 | - CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_ETHERNET, | ||
343 | - -1); | ||
344 | + propval = g_hash_table_lookup(hash, "Powered"); | ||
345 | + powered = propval ? g_value_get_boolean(propval) : FALSE; | ||
346 | |||
347 | - if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_WIFI) == FALSE) | ||
348 | - gtk_tree_store_append(store, &iter, NULL); | ||
349 | + if (g_str_equal("ethernet", techtype)) | ||
350 | + { | ||
351 | + if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_ETHERNET) == FALSE) | ||
352 | + gtk_tree_store_append(store, &iter, NULL); | ||
353 | |||
354 | - gtk_tree_store_set(store, &iter, | ||
355 | - CONNMAN_COLUMN_PROXY, proxy, | ||
356 | - CONNMAN_COLUMN_WIFI_ENABLED, wifi_enabled, | ||
357 | - CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_WIFI, | ||
358 | - -1); | ||
359 | + gtk_tree_store_set(store, &iter, | ||
360 | + CONNMAN_COLUMN_PROXY, proxy, | ||
361 | + CONNMAN_COLUMN_POWERED, powered, | ||
362 | + CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_ETHERNET, | ||
363 | + -1); | ||
364 | + } | ||
365 | + else if (g_str_equal ("wifi", techtype)) | ||
366 | + { | ||
367 | + if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_WIFI) == FALSE) | ||
368 | + gtk_tree_store_append(store, &iter, NULL); | ||
369 | |||
370 | - if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_CELLULAR) == FALSE) | ||
371 | - gtk_tree_store_append(store, &iter, NULL); | ||
372 | + gtk_tree_store_set(store, &iter, | ||
373 | + CONNMAN_COLUMN_PROXY, proxy, | ||
374 | + CONNMAN_COLUMN_POWERED, powered, | ||
375 | + CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_WIFI, | ||
376 | + -1); | ||
377 | + } | ||
378 | + else if (g_str_equal ("3g", techtype)) | ||
379 | + { | ||
380 | + if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_CELLULAR) == FALSE) | ||
381 | + gtk_tree_store_append(store, &iter, NULL); | ||
382 | |||
383 | - gtk_tree_store_set(store, &iter, | ||
384 | - CONNMAN_COLUMN_PROXY, proxy, | ||
385 | - CONNMAN_COLUMN_CELLULAR_ENABLED, cellular_enabled, | ||
386 | - CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_CELLULAR, | ||
387 | - -1); | ||
388 | + gtk_tree_store_set(store, &iter, | ||
389 | + CONNMAN_COLUMN_PROXY, proxy, | ||
390 | + CONNMAN_COLUMN_POWERED, powered, | ||
391 | + CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_CELLULAR, | ||
392 | + -1); | ||
393 | + } | ||
394 | } | ||
395 | |||
396 | static void offline_mode_changed(GtkTreeStore *store, GValue *value) | ||
397 | @@ -319,6 +286,39 @@ static void offline_mode_changed(GtkTreeStore *store, GValue *value) | ||
398 | -1); | ||
399 | } | ||
400 | |||
401 | +static void tech_added(DBusGProxy *proxy, DBusGObjectPath *path, | ||
402 | + GHashTable *hash, gpointer user_data) | ||
403 | +{ | ||
404 | + GtkTreeStore *store = user_data; | ||
405 | + GtkTreeIter iter; | ||
406 | + DBG("store %p proxy %p hash %p", store, proxy, hash); | ||
407 | + | ||
408 | + if (!get_iter_from_path(store, &iter, path)) { | ||
409 | + DBusGProxy *tech_proxy = dbus_g_proxy_new_for_name(connection, | ||
410 | + CONNMAN_SERVICE, path, | ||
411 | + CONNMAN_TECHNOLOGY_INTERFACE); | ||
412 | + if (tech_proxy == NULL) | ||
413 | + return; | ||
414 | + | ||
415 | + tech_properties(tech_proxy, hash, NULL, user_data); | ||
416 | + | ||
417 | + dbus_g_proxy_add_signal(tech_proxy, "PropertyChanged", | ||
418 | + G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); | ||
419 | + dbus_g_proxy_connect_signal(tech_proxy, "PropertyChanged", | ||
420 | + G_CALLBACK(tech_changed), store, NULL); | ||
421 | + } | ||
422 | +} | ||
423 | + | ||
424 | +static void tech_removed(DBusGProxy *proxy, DBusGObjectPath *path, | ||
425 | + gpointer user_data) | ||
426 | +{ | ||
427 | + GtkTreeStore *store = user_data; | ||
428 | + GtkTreeIter iter; | ||
429 | + | ||
430 | + if (get_iter_from_path(store, &iter, path)) | ||
431 | + gtk_tree_store_remove(store, &iter); | ||
432 | +} | ||
433 | + | ||
434 | static void offline_mode_properties(GtkTreeStore *store, DBusGProxy *proxy, GValue *value) | ||
435 | { | ||
436 | GtkTreeIter iter; | ||
437 | @@ -401,59 +401,8 @@ static void service_changed(DBusGProxy *proxy, const char *property, | ||
438 | } | ||
439 | } | ||
440 | |||
441 | -static void property_update(GtkTreeStore *store, const GValue *value, | ||
442 | - connman_get_properties_reply callback) | ||
443 | -{ | ||
444 | - GSList *list, *link, *old_list, *new_list = NULL; | ||
445 | - | ||
446 | - DBG("store %p", store); | ||
447 | - | ||
448 | - old_list = g_object_get_data(G_OBJECT(store), "Services"); | ||
449 | - | ||
450 | - dbus_g_type_collection_value_iterate(value, iterate_list, &new_list); | ||
451 | - | ||
452 | - g_object_set_data(G_OBJECT(store), "Services", new_list); | ||
453 | - | ||
454 | - for (list = new_list; list; list = list->next) { | ||
455 | - gchar *path = list->data; | ||
456 | - DBusGProxy *proxy; | ||
457 | - | ||
458 | - DBG("new path %s", path); | ||
459 | - | ||
460 | - link = g_slist_find_custom(old_list, path, compare_path); | ||
461 | - if (link != NULL) { | ||
462 | - g_free(link->data); | ||
463 | - old_list = g_slist_delete_link(old_list, link); | ||
464 | - } | ||
465 | - | ||
466 | - proxy = dbus_g_proxy_new_for_name(connection, | ||
467 | - CONNMAN_SERVICE, path, | ||
468 | - CONNMAN_SERVICE_INTERFACE); | ||
469 | - if (proxy == NULL) | ||
470 | - continue; | ||
471 | - | ||
472 | - DBG("getting %s properties", "Services"); | ||
473 | - | ||
474 | - connman_get_properties_async(proxy, callback, store); | ||
475 | - } | ||
476 | - | ||
477 | - for (list = old_list; list; list = list->next) { | ||
478 | - gchar *path = list->data; | ||
479 | - GtkTreeIter iter; | ||
480 | - | ||
481 | - DBG("old path %s", path); | ||
482 | - | ||
483 | - if (get_iter_from_path(store, &iter, path) == TRUE) | ||
484 | - gtk_tree_store_remove(store, &iter); | ||
485 | - | ||
486 | - g_free(path); | ||
487 | - } | ||
488 | - | ||
489 | - g_slist_free(old_list); | ||
490 | -} | ||
491 | - | ||
492 | static void service_properties(DBusGProxy *proxy, GHashTable *hash, | ||
493 | - GError *error, gpointer user_data) | ||
494 | + gpointer user_data) | ||
495 | { | ||
496 | GtkTreeStore *store = user_data; | ||
497 | GValue *value; | ||
498 | @@ -468,7 +417,7 @@ static void service_properties(DBusGProxy *proxy, GHashTable *hash, | ||
499 | |||
500 | DBG("store %p proxy %p hash %p", store, proxy, hash); | ||
501 | |||
502 | - if (error != NULL || hash == NULL) | ||
503 | + if (hash == NULL) | ||
504 | goto done; | ||
505 | |||
506 | value = g_hash_table_lookup(hash, "Name"); | ||
507 | @@ -572,11 +521,7 @@ static void manager_changed(DBusGProxy *proxy, const char *property, | ||
508 | if (property == NULL || value == NULL) | ||
509 | return; | ||
510 | |||
511 | - if (g_str_equal(property, "Services") == TRUE) | ||
512 | - property_update(store, value, service_properties); | ||
513 | - else if (g_str_equal(property, "EnabledTechnologies") == TRUE) | ||
514 | - enabled_technologies_changed(store, value); | ||
515 | - else if (g_str_equal(property, "OfflineMode") == TRUE) | ||
516 | + if (g_str_equal(property, "OfflineMode") == TRUE) | ||
517 | offline_mode_changed(store, value); | ||
518 | } | ||
519 | |||
520 | @@ -591,23 +536,89 @@ static void manager_properties(DBusGProxy *proxy, GHashTable *hash, | ||
521 | if (error != NULL || hash == NULL) | ||
522 | return; | ||
523 | |||
524 | - value = g_hash_table_lookup(hash, "Services"); | ||
525 | - if (value != NULL) | ||
526 | - property_update(store, value, service_properties); | ||
527 | - | ||
528 | - value = g_hash_table_lookup(hash, "EnabledTechnologies"); | ||
529 | - if (value != NULL) | ||
530 | - enabled_technologies_properties(store, proxy, value); | ||
531 | - | ||
532 | value = g_hash_table_lookup(hash, "OfflineMode"); | ||
533 | if (value != NULL) | ||
534 | offline_mode_properties(store, proxy, value); | ||
535 | } | ||
536 | |||
537 | +static void manager_services(DBusGProxy *proxy, GPtrArray *array, | ||
538 | + GError *error, gpointer user_data) | ||
539 | +{ | ||
540 | + int i; | ||
541 | + | ||
542 | + DBG("proxy %p array %p", proxy, array); | ||
543 | + | ||
544 | + if (error != NULL || array == NULL) | ||
545 | + return; | ||
546 | + | ||
547 | + for (i = 0; i < array->len; i++) | ||
548 | + { | ||
549 | + GValueArray *item = g_ptr_array_index(array, i); | ||
550 | + | ||
551 | + DBusGObjectPath *path = (DBusGObjectPath *)g_value_get_boxed(g_value_array_get_nth(item, 0)); | ||
552 | + DBusGProxy *service_proxy = dbus_g_proxy_new_for_name(connection, | ||
553 | + CONNMAN_SERVICE, path, | ||
554 | + CONNMAN_SERVICE_INTERFACE); | ||
555 | + if (service_proxy == NULL) | ||
556 | + continue; | ||
557 | + | ||
558 | + GHashTable *props = (GHashTable *)g_value_get_boxed(g_value_array_get_nth(item, 1)); | ||
559 | + service_properties(service_proxy, props, user_data); | ||
560 | + } | ||
561 | +} | ||
562 | + | ||
563 | +static void manager_technologies(DBusGProxy *proxy, GPtrArray *array, | ||
564 | + GError *error, gpointer user_data) | ||
565 | +{ | ||
566 | + int i; | ||
567 | + | ||
568 | + DBG("proxy %p array %p", proxy, array); | ||
569 | + | ||
570 | + if (error != NULL || array == NULL) | ||
571 | + return; | ||
572 | + | ||
573 | + for (i = 0; i < array->len; i++) | ||
574 | + { | ||
575 | + GValueArray *item = g_ptr_array_index(array, i); | ||
576 | + | ||
577 | + DBusGObjectPath *path = (DBusGObjectPath *)g_value_get_boxed(g_value_array_get_nth(item, 0)); | ||
578 | + GHashTable *props = (GHashTable *)g_value_get_boxed(g_value_array_get_nth(item, 1)); | ||
579 | + | ||
580 | + tech_added(proxy, path, props, user_data); | ||
581 | + } | ||
582 | +} | ||
583 | + | ||
584 | +static void services_added(DBusGProxy *proxy, GPtrArray *array, | ||
585 | + gpointer user_data) | ||
586 | +{ | ||
587 | + DBG("proxy %p array %p", proxy, array); | ||
588 | + | ||
589 | + manager_services(proxy, array, NULL, user_data); | ||
590 | +} | ||
591 | + | ||
592 | +static void services_removed(DBusGProxy *proxy, GPtrArray *array, | ||
593 | + gpointer user_data) | ||
594 | +{ | ||
595 | + GtkTreeStore *store = user_data; | ||
596 | + GtkTreeIter iter; | ||
597 | + int i; | ||
598 | + | ||
599 | + DBG("store %p proxy %p array %p", store, proxy, array); | ||
600 | + | ||
601 | + for (i = 0; i < array->len; i++) | ||
602 | + { | ||
603 | + DBusGObjectPath *path = (DBusGObjectPath *)g_ptr_array_index(array, i); | ||
604 | + | ||
605 | + if (get_iter_from_path(store, &iter, path)) | ||
606 | + gtk_tree_store_remove(store, &iter); | ||
607 | + } | ||
608 | +} | ||
609 | + | ||
610 | DBusGProxy *connman_dbus_create_manager(DBusGConnection *conn, | ||
611 | GtkTreeStore *store) | ||
612 | { | ||
613 | DBusGProxy *proxy; | ||
614 | + GType otype; | ||
615 | |||
616 | connection = dbus_g_connection_ref(conn); | ||
617 | |||
618 | @@ -620,11 +631,49 @@ DBusGProxy *connman_dbus_create_manager(DBusGConnection *conn, | ||
619 | G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); | ||
620 | dbus_g_proxy_connect_signal(proxy, "PropertyChanged", | ||
621 | G_CALLBACK(manager_changed), store, NULL); | ||
622 | - | ||
623 | + | ||
624 | + otype = dbus_g_type_get_struct("GValueArray", DBUS_TYPE_G_OBJECT_PATH, DBUS_TYPE_G_DICTIONARY, G_TYPE_INVALID); | ||
625 | + otype = dbus_g_type_get_collection("GPtrArray", otype); | ||
626 | + dbus_g_object_register_marshaller(marshal_VOID__BOXED, G_TYPE_NONE, otype, G_TYPE_INVALID); | ||
627 | + | ||
628 | + dbus_g_proxy_add_signal(proxy, "ServicesAdded", | ||
629 | + otype, G_TYPE_INVALID); | ||
630 | + dbus_g_proxy_connect_signal(proxy, "ServicesAdded", | ||
631 | + G_CALLBACK(services_added), store, NULL); | ||
632 | + | ||
633 | + otype = DBUS_TYPE_G_OBJECT_PATH_ARRAY; | ||
634 | + dbus_g_object_register_marshaller(marshal_VOID__BOXED, G_TYPE_NONE, otype, G_TYPE_INVALID); | ||
635 | + | ||
636 | + dbus_g_proxy_add_signal(proxy, "ServicesRemoved", | ||
637 | + otype, G_TYPE_INVALID); | ||
638 | + dbus_g_proxy_connect_signal(proxy, "ServicesRemoved", | ||
639 | + G_CALLBACK(services_removed), store, NULL); | ||
640 | + | ||
641 | + dbus_g_object_register_marshaller(marshal_VOID__STRING_BOXED, G_TYPE_NONE, DBUS_TYPE_G_OBJECT_PATH, DBUS_TYPE_G_DICTIONARY, G_TYPE_INVALID); | ||
642 | + dbus_g_proxy_add_signal(proxy, "TechnologyAdded", | ||
643 | + DBUS_TYPE_G_OBJECT_PATH, DBUS_TYPE_G_DICTIONARY, G_TYPE_INVALID); | ||
644 | + dbus_g_proxy_connect_signal(proxy, "TechnologyAdded", | ||
645 | + G_CALLBACK(tech_added), store, NULL); | ||
646 | + | ||
647 | + dbus_g_object_register_marshaller(marshal_VOID__STRING, G_TYPE_NONE, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); | ||
648 | + dbus_g_proxy_add_signal(proxy, "TechnologyRemoved", | ||
649 | + DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); | ||
650 | + dbus_g_proxy_connect_signal(proxy, "TechnologyRemoved", | ||
651 | + G_CALLBACK(tech_removed), store, NULL); | ||
652 | + | ||
653 | + | ||
654 | DBG("getting manager properties"); | ||
655 | |||
656 | connman_get_properties_async(proxy, manager_properties, store); | ||
657 | |||
658 | + DBG("getting technologies"); | ||
659 | + | ||
660 | + connman_get_technologies_async(proxy, manager_technologies, store); | ||
661 | + | ||
662 | + DBG("getting services"); | ||
663 | + | ||
664 | + connman_get_services_async(proxy, manager_services, store); | ||
665 | + | ||
666 | return proxy; | ||
667 | } | ||
668 | |||
669 | diff --git a/common/connman-dbus.h b/common/connman-dbus.h | ||
670 | index cfca50e..c1b5091 100644 | ||
671 | --- a/common/connman-dbus.h | ||
672 | +++ b/common/connman-dbus.h | ||
673 | @@ -32,6 +32,7 @@ | ||
674 | |||
675 | #define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile" | ||
676 | #define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service" | ||
677 | +#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology" | ||
678 | |||
679 | DBusGProxy *connman_dbus_create_manager(DBusGConnection *connection, | ||
680 | GtkTreeStore *store); | ||
681 | diff --git a/common/connman-dbus.xml b/common/connman-dbus.xml | ||
682 | index e20cb3b..56b9582 100644 | ||
683 | --- a/common/connman-dbus.xml | ||
684 | +++ b/common/connman-dbus.xml | ||
685 | @@ -5,26 +5,23 @@ | ||
686 | <method name="GetProperties"> | ||
687 | <arg type="a{sv}" direction="out"/> | ||
688 | </method> | ||
689 | + <method name="GetServices"> | ||
690 | + <arg type="a(oa{sv})" direction="out"/> | ||
691 | + </method> | ||
692 | + <method name="GetTechnologies"> | ||
693 | + <arg type="a(oa{sv})" direction="out"/> | ||
694 | + </method> | ||
695 | <method name="SetProperty"> | ||
696 | <arg type="s"/> | ||
697 | <arg type="v"/> | ||
698 | </method> | ||
699 | - <method name="ProposeScan"> | ||
700 | - </method> | ||
701 | <method name="Connect"> | ||
702 | </method> | ||
703 | <method name="Disconnect"> | ||
704 | </method> | ||
705 | <method name="Remove"> | ||
706 | </method> | ||
707 | - <method name="RequestScan"> | ||
708 | - <arg type="s"/> | ||
709 | - </method> | ||
710 | - <method name="EnableTechnology"> | ||
711 | - <arg type="s"/> | ||
712 | - </method> | ||
713 | - <method name="DisableTechnology"> | ||
714 | - <arg type="s"/> | ||
715 | + <method name="Scan"> | ||
716 | </method> | ||
717 | </interface> | ||
718 | </node> | ||
719 | diff --git a/common/marshal.list b/common/marshal.list | ||
720 | index e72aa4b..8b174d0 100644 | ||
721 | --- a/common/marshal.list | ||
722 | +++ b/common/marshal.list | ||
723 | @@ -1 +1,3 @@ | ||
724 | VOID:STRING,BOXED | ||
725 | +VOID:BOXED | ||
726 | +VOID:STRING | ||
727 | diff --git a/properties/cellular.c b/properties/cellular.c | ||
728 | index 7bbfb89..4d27e0e 100644 | ||
729 | --- a/properties/cellular.c | ||
730 | +++ b/properties/cellular.c | ||
731 | @@ -59,9 +59,9 @@ static void switch_callback(GtkWidget *editable, gpointer user_data) | ||
732 | const gchar *label = gtk_button_get_label(GTK_BUTTON(data->cellular_button)); | ||
733 | |||
734 | if (g_str_equal(label, "Disable")) | ||
735 | - connman_client_disable_technology(data->client, data->device, "cellular"); | ||
736 | + connman_client_set_powered(data->client, data->device, FALSE); | ||
737 | else | ||
738 | - connman_client_enable_technology(data->client, data->device, "cellular"); | ||
739 | + connman_client_set_powered(data->client, data->device, TRUE); | ||
740 | } | ||
741 | |||
742 | void add_cellular_switch_button(GtkWidget *mainbox, GtkTreeIter *iter, | ||
743 | @@ -75,7 +75,7 @@ void add_cellular_switch_button(GtkWidget *mainbox, GtkTreeIter *iter, | ||
744 | gboolean cellular_enabled; | ||
745 | |||
746 | gtk_tree_model_get(data->model, iter, | ||
747 | - CONNMAN_COLUMN_CELLULAR_ENABLED, &cellular_enabled, | ||
748 | + CONNMAN_COLUMN_POWERED, &cellular_enabled, | ||
749 | -1); | ||
750 | |||
751 | vbox = gtk_vbox_new(TRUE, 0); | ||
752 | diff --git a/properties/ethernet.c b/properties/ethernet.c | ||
753 | index d7f91d9..31db7a0 100644 | ||
754 | --- a/properties/ethernet.c | ||
755 | +++ b/properties/ethernet.c | ||
756 | @@ -59,9 +59,9 @@ static void switch_callback(GtkWidget *editable, gpointer user_data) | ||
757 | struct config_data *data = user_data; | ||
758 | const gchar *label = gtk_button_get_label(GTK_BUTTON(data->ethernet_button)); | ||
759 | if (g_str_equal(label, "Disable")) | ||
760 | - connman_client_disable_technology(data->client, data->device, "ethernet"); | ||
761 | - else if (g_str_equal(label, "Enable")) | ||
762 | - connman_client_enable_technology(data->client, data->device, "ethernet"); | ||
763 | + connman_client_set_powered(data->client, data->device, FALSE); | ||
764 | + else | ||
765 | + connman_client_set_powered(data->client, data->device, TRUE); | ||
766 | } | ||
767 | |||
768 | void add_ethernet_switch_button(GtkWidget *mainbox, GtkTreeIter *iter, | ||
769 | @@ -75,7 +75,7 @@ void add_ethernet_switch_button(GtkWidget *mainbox, GtkTreeIter *iter, | ||
770 | gboolean ethernet_enabled; | ||
771 | |||
772 | gtk_tree_model_get(data->model, iter, | ||
773 | - CONNMAN_COLUMN_ETHERNET_ENABLED, ðernet_enabled, | ||
774 | + CONNMAN_COLUMN_POWERED, ðernet_enabled, | ||
775 | -1); | ||
776 | |||
777 | vbox = gtk_vbox_new(TRUE, 0); | ||
778 | diff --git a/properties/main.c b/properties/main.c | ||
779 | index 088684a..e266f03 100644 | ||
780 | --- a/properties/main.c | ||
781 | +++ b/properties/main.c | ||
782 | @@ -40,18 +40,14 @@ static void status_update(GtkTreeModel *model, GtkTreePath *path, | ||
783 | struct config_data *data = user_data; | ||
784 | guint type; | ||
785 | const char *name = NULL, *_name = NULL, *state = NULL; | ||
786 | - gboolean ethernet_enabled; | ||
787 | - gboolean wifi_enabled; | ||
788 | - gboolean cellular_enabled; | ||
789 | + gboolean powered; | ||
790 | gboolean offline_mode; | ||
791 | |||
792 | gtk_tree_model_get(model, iter, | ||
793 | CONNMAN_COLUMN_STATE, &state, | ||
794 | CONNMAN_COLUMN_NAME, &name, | ||
795 | CONNMAN_COLUMN_TYPE, &type, | ||
796 | - CONNMAN_COLUMN_ETHERNET_ENABLED, ðernet_enabled, | ||
797 | - CONNMAN_COLUMN_WIFI_ENABLED, &wifi_enabled, | ||
798 | - CONNMAN_COLUMN_CELLULAR_ENABLED, &cellular_enabled, | ||
799 | + CONNMAN_COLUMN_POWERED, &powered, | ||
800 | CONNMAN_COLUMN_OFFLINEMODE, &offline_mode, | ||
801 | -1); | ||
802 | |||
803 | @@ -103,14 +99,14 @@ static void status_update(GtkTreeModel *model, GtkTreePath *path, | ||
804 | } else if (type == CONNMAN_TYPE_LABEL_ETHERNET) { | ||
805 | if (!data->ethernet_button) | ||
806 | return; | ||
807 | - if (ethernet_enabled) | ||
808 | + if (powered) | ||
809 | gtk_button_set_label(GTK_BUTTON(data->ethernet_button), _("Disable")); | ||
810 | else | ||
811 | gtk_button_set_label(GTK_BUTTON(data->ethernet_button), _("Enable")); | ||
812 | } else if (type == CONNMAN_TYPE_LABEL_WIFI) { | ||
813 | if (!data->wifi_button) | ||
814 | return; | ||
815 | - if (wifi_enabled) { | ||
816 | + if (powered) { | ||
817 | gtk_button_set_label(GTK_BUTTON(data->wifi_button), _("Disable")); | ||
818 | gtk_widget_set_sensitive(data->scan_button, 1); | ||
819 | } else { | ||
820 | @@ -120,7 +116,7 @@ static void status_update(GtkTreeModel *model, GtkTreePath *path, | ||
821 | } else if (type == CONNMAN_TYPE_LABEL_CELLULAR) { | ||
822 | if (!data->cellular_button) | ||
823 | return; | ||
824 | - if (cellular_enabled) | ||
825 | + if (powered) | ||
826 | gtk_button_set_label(GTK_BUTTON(data->cellular_button), _("Disable")); | ||
827 | else | ||
828 | gtk_button_set_label(GTK_BUTTON(data->cellular_button), _("Enable")); | ||
829 | diff --git a/properties/wifi.c b/properties/wifi.c | ||
830 | index 85922a3..038d35a 100644 | ||
831 | --- a/properties/wifi.c | ||
832 | +++ b/properties/wifi.c | ||
833 | @@ -96,9 +96,9 @@ static void switch_callback(GtkWidget *editable, gpointer user_data) | ||
834 | const gchar *label = gtk_button_get_label(GTK_BUTTON(data->wifi_button)); | ||
835 | |||
836 | if (g_str_equal(label, "Disable")) | ||
837 | - connman_client_disable_technology(data->client, data->device, "wifi"); | ||
838 | + connman_client_set_powered(data->client, data->device, FALSE); | ||
839 | else | ||
840 | - connman_client_enable_technology(data->client, data->device, "wifi"); | ||
841 | + connman_client_set_powered(data->client, data->device, TRUE); | ||
842 | } | ||
843 | |||
844 | static void scan_reply_cb(DBusGProxy *proxy, GError *error, | ||
845 | @@ -115,7 +115,7 @@ static void scan_callback(GtkWidget *button, gpointer user_data) | ||
846 | { | ||
847 | struct config_data *data = user_data; | ||
848 | gtk_widget_set_sensitive(button, 0); | ||
849 | - connman_client_request_scan(data->client, "", scan_reply_cb, button); | ||
850 | + connman_client_scan(data->client, data->device, scan_reply_cb, button); | ||
851 | } | ||
852 | |||
853 | void add_wifi_switch_button(GtkWidget *mainbox, GtkTreeIter *iter, | ||
854 | @@ -129,7 +129,7 @@ void add_wifi_switch_button(GtkWidget *mainbox, GtkTreeIter *iter, | ||
855 | gboolean wifi_enabled; | ||
856 | |||
857 | gtk_tree_model_get(data->model, iter, | ||
858 | - CONNMAN_COLUMN_WIFI_ENABLED, &wifi_enabled, | ||
859 | + CONNMAN_COLUMN_POWERED, &wifi_enabled, | ||
860 | -1); | ||
861 | |||
862 | vbox = gtk_vbox_new(TRUE, 0); | ||
863 | -- | ||
864 | 1.7.5.4 | ||
865 | |||