summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Houston <stephen@localhost.localdomain>2017-11-27 13:05:11 -0600
committerStephen Houston <stephen@localhost.localdomain>2017-11-27 13:05:11 -0600
commit96d040dbe6b41dd4db46a8dfb84d3849936e625e (patch)
tree554fcc6d6875ddf275e2bced6e81d6b0b46c7c2e
parent104bfeaafc1109e41b31d04c1cd6d6c19b101bb6 (diff)
Networkmanager: Allow editing of a network's connection settings.
-rw-r--r--TODO4
-rw-r--r--src/networkmanager.c804
-rw-r--r--src/wireless.c31
3 files changed, 797 insertions, 42 deletions
diff --git a/TODO b/TODO
index 64644b7..406565f 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,8 @@
1NetworkManager Support: 1NetworkManager Support:
2--Untested--
3Dns config editing
4Proxy config editing
5--Issues--
2Doesn't update the icon correctly when activing connections on separate devices 6Doesn't update the icon correctly when activing connections on separate devices
3Random crashes 7Random crashes
4 8
diff --git a/src/networkmanager.c b/src/networkmanager.c
index 3c666ac..dc8bcf9 100644
--- a/src/networkmanager.c
+++ b/src/networkmanager.c
@@ -3,6 +3,10 @@
3#define NETWORKMANAGER_BUS_NAME "org.freedesktop.NetworkManager" 3#define NETWORKMANAGER_BUS_NAME "org.freedesktop.NetworkManager"
4#define NETWORKMANAGER_BUS_PATH "/org/freedesktop/NetworkManager" 4#define NETWORKMANAGER_BUS_PATH "/org/freedesktop/NetworkManager"
5#define NETWORKMANAGER_BUS_INTERFACE NETWORKMANAGER_BUS_NAME 5#define NETWORKMANAGER_BUS_INTERFACE NETWORKMANAGER_BUS_NAME
6#define NETWORKMANAGER_AGENT_MANAGER NETWORKMANAGER_BUS_NAME ".AgentManager"
7#define NETWORKMANAGER_AGENT_MANAGER_PATH NETWORKMANAGER_BUS_PATH "/AgentManager"
8#define NETWORKMANAGER_AGENT_NAME "org.wireless.nm.agent"
9#define NETWORKMANAGER_AGENT_PATH "/org/wireless/nm/agent"
6 10
7#define NETWORKMANAGER_SERVICE_TYPE_ITER(i) \ 11#define NETWORKMANAGER_SERVICE_TYPE_ITER(i) \
8 for ((i) = 0; (i) < NETWORKMANAGER_SERVICE_TYPE_LAST; (i)++) 12 for ((i) = 0; (i) < NETWORKMANAGER_SERVICE_TYPE_LAST; (i)++)
@@ -47,7 +51,6 @@ typedef enum
47 51
48typedef struct 52typedef struct
49{ 53{
50 EINA_INLIST;
51 Eldbus_Proxy *proxy; 54 Eldbus_Proxy *proxy;
52 Eldbus_Proxy *device_proxy; 55 Eldbus_Proxy *device_proxy;
53 56
@@ -132,7 +135,7 @@ typedef struct NetworkManager_Field
132 135
133static int _networkmanager_log_dom = -1; 136static int _networkmanager_log_dom = -1;
134 137
135static Eina_Inlist *networkmanager_services_list[NETWORKMANAGER_SERVICE_TYPE_LAST]; 138static Eina_List *networkmanager_services_list[NETWORKMANAGER_SERVICE_TYPE_LAST];
136static NetworkManager_Service *networkmanager_current_service[NETWORKMANAGER_SERVICE_TYPE_LAST]; 139static NetworkManager_Service *networkmanager_current_service[NETWORKMANAGER_SERVICE_TYPE_LAST];
137static Wireless_Connection *networkmanager_current_connection[NETWORKMANAGER_SERVICE_TYPE_LAST]; 140static Wireless_Connection *networkmanager_current_connection[NETWORKMANAGER_SERVICE_TYPE_LAST];
138static NetworkManager_Technology networkmanager_technology[NETWORKMANAGER_SERVICE_TYPE_LAST]; 141static NetworkManager_Technology networkmanager_technology[NETWORKMANAGER_SERVICE_TYPE_LAST];
@@ -146,7 +149,7 @@ static Eina_List *sig_handlers;
146static const char *active_connection; 149static const char *active_connection;
147Eldbus_Connection *dbus_conn; 150Eldbus_Connection *dbus_conn;
148 151
149//static NetworkManager_Service *_networkmanager_service_find_path(const char *path); 152static NetworkManager_Service *_networkmanager_service_find_path(const char *path);
150static void _networkmanager_services_free(); 153static void _networkmanager_services_free();
151 154
152static void 155static void
@@ -166,54 +169,767 @@ _networkmanager_service_is_connected(const NetworkManager_Service *ns)
166} 169}
167 170
168void 171void
169networkmanager_technology_enabled_set(Wireless_Service_Type type EINA_UNUSED, Eina_Bool state EINA_UNUSED) 172networkmanager_technology_enabled_set(Wireless_Service_Type type, Eina_Bool state)
170{ 173{
174 EINA_SAFETY_ON_NULL_RETURN(proxy_manager);
175 if (type == 1)
176 eldbus_proxy_property_set(proxy_manager, "WirelessEnabled", "b", (void*)(intptr_t)state, NULL, NULL);
177}
178
179static void
180_networkmanager_service_edit_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
181{
182 const char *name, *text;
183
184 if (eldbus_message_error_get(msg, &name, &text))
185 {
186 ERR("Could not set properties. %s: %s", name, text);
187 }
188}
189
190static void
191_networkmanager_edit_getsettings_append_bool(Eldbus_Message_Iter *entry, const char *setting, int value)
192{
193 Eldbus_Message_Iter *oarray;
194
195 eldbus_message_iter_arguments_append(entry, "s", setting);
196 oarray = eldbus_message_iter_container_new(entry, 'v', "b");
197 eldbus_message_iter_arguments_append(oarray, "b", value);
198 eldbus_message_iter_container_close(entry, oarray);
199}
200
201static void
202_networkmanager_edit_getsettings_append_byte_array(Eldbus_Message_Iter *entry, const char *setting, Eldbus_Message_Iter *value)
203{
204 Eldbus_Message_Iter *oarray, *oarray2;
205 const unsigned char *arr;
206 int size;
207
208 eldbus_message_iter_fixed_array_get(value, 'y', &arr, &size);
209 eldbus_message_iter_arguments_append(entry, "s", setting);
210 oarray = eldbus_message_iter_container_new(entry, 'v', "ay");
211 oarray2 = eldbus_message_iter_container_new(oarray, 'a', "y");
212 eldbus_message_iter_fixed_array_append(oarray2, 'y', arr, size);
213 eldbus_message_iter_container_close(oarray, oarray2);
214 eldbus_message_iter_container_close(entry, oarray);
215}
216
217static void
218_networkmanager_edit_getsettings_append_string(Eldbus_Message_Iter *entry, const char *setting, const char *value)
219{
220 Eldbus_Message_Iter *oarray;
221
222 eldbus_message_iter_arguments_append(entry, "s", setting);
223 oarray = eldbus_message_iter_container_new(entry, 'v', "s");
224 eldbus_message_iter_arguments_append(oarray, "s", value);
225 eldbus_message_iter_container_close(entry, oarray);
226}
227
228static void
229_networkmanager_edit_getsettings_append_string_array(Eldbus_Message_Iter *entry, const char *setting, Eldbus_Message_Iter *value)
230{
231 Eldbus_Message_Iter *oarray, *oarray2;
232 const char *string;
233
234 eldbus_message_iter_arguments_append(entry, "s", setting);
235 oarray = eldbus_message_iter_container_new(entry, 'v', "as");
236 oarray2 = eldbus_message_iter_container_new(oarray, 'a', "s");
237 while (eldbus_message_iter_get_and_next(value, 's', &string))
238 eldbus_message_iter_arguments_append(oarray2, "s", string);
239 eldbus_message_iter_container_close(oarray, oarray2);
240 eldbus_message_iter_container_close(entry, oarray);
241}
242
243static void
244_networkmanager_edit_getsettings_append_time(Eldbus_Message_Iter *entry, const char *setting, time_t value)
245{
246 Eldbus_Message_Iter *oarray;
247
248 eldbus_message_iter_arguments_append(entry, "s", setting);
249 oarray = eldbus_message_iter_container_new(entry, 'v', "t");
250 eldbus_message_iter_arguments_append(oarray, "t", value);
251 eldbus_message_iter_container_close(entry, oarray);
252}
253
254static void
255_networkmanager_edit_getsettings_append_int(Eldbus_Message_Iter *entry, const char *setting, int value)
256{
257 Eldbus_Message_Iter *oarray;
258
259 eldbus_message_iter_arguments_append(entry, "s", setting);
260 oarray = eldbus_message_iter_container_new(entry, 'v', "i");
261 eldbus_message_iter_arguments_append(oarray, "i", value);
262 eldbus_message_iter_container_close(entry, oarray);
263}
264
265static void
266_networkmanager_edit_getsettings_append_long_long(Eldbus_Message_Iter *entry, const char *setting, long long value)
267{
268 Eldbus_Message_Iter *oarray;
269
270 eldbus_message_iter_arguments_append(entry, "s", setting);
271 oarray = eldbus_message_iter_container_new(entry, 'v', "x");
272 eldbus_message_iter_arguments_append(oarray, "x", value);
273 eldbus_message_iter_container_close(entry, oarray);
274}
275
276static void
277_networkmanager_edit_getsettings_append_uint(Eldbus_Message_Iter *entry, const char *setting, unsigned int value)
278{
279 Eldbus_Message_Iter *oarray;
280
281 eldbus_message_iter_arguments_append(entry, "s", setting);
282 oarray = eldbus_message_iter_container_new(entry, 'v', "u");
283 eldbus_message_iter_arguments_append(oarray, "u", value);
284 eldbus_message_iter_container_close(entry, oarray);
285}
286
287static void
288_networkmanager_edit_getsettings_append_uint_array(Eldbus_Message_Iter *entry, const char *setting, Eldbus_Message_Iter *value)
289{
290 Eldbus_Message_Iter *oarray, *oarray2;
291 unsigned int num;
292
293 eldbus_message_iter_arguments_append(entry, "s", setting);
294 oarray = eldbus_message_iter_container_new(entry, 'v', "au");
295 oarray2 = eldbus_message_iter_container_new(oarray, 'a', "u");
296 while (eldbus_message_iter_get_and_next(value, 'u', &num))
297 eldbus_message_iter_arguments_append(oarray2, "u", num);
298 eldbus_message_iter_container_close(oarray, oarray2);
299 eldbus_message_iter_container_close(entry, oarray);
300}
301
302static void
303_networkmanager_edit_getsettings_append_array_uint_array(Eldbus_Message_Iter *entry, const char *setting, Eldbus_Message_Iter *value)
304{
305 Eldbus_Message_Iter *oarray, *oarray2, *oarray3, *value2;
306 unsigned int num;
307
308 eldbus_message_iter_arguments_append(entry, "s", setting);
309 oarray = eldbus_message_iter_container_new(entry, 'v', "aau");
310 oarray2 = eldbus_message_iter_container_new(oarray, 'a', "ay");
311 while (eldbus_message_iter_get_and_next(value, 'e', &value2))
312 {
313 oarray3 = eldbus_message_iter_container_new(oarray2, 'a', "u");
314 while (eldbus_message_iter_get_and_next(value2, 'u', &num))
315 eldbus_message_iter_arguments_append(oarray3, "u", num);
316 eldbus_message_iter_container_close(oarray2, oarray3);
317 }
318 eldbus_message_iter_container_close(oarray, oarray2);
319 eldbus_message_iter_container_close(entry, oarray);
320}
321
322static void
323_networkmanager_edit_getsettings_append_array_byte_array(Eldbus_Message_Iter *entry, const char *setting, Eldbus_Message_Iter *value)
324{
325 Eldbus_Message_Iter *oarray, *oarray2, *oarray3, *value2, *value3;
326 const unsigned char *arr;
327 int size;
328
329 eldbus_message_iter_arguments_append(entry, "s", setting);
330 oarray = eldbus_message_iter_container_new(entry, 'v', "aay");
331 oarray2 = eldbus_message_iter_container_new(oarray, 'a', "ay");
332 while (eldbus_message_iter_get_and_next(value, 'e', &value2))
333 {
334 oarray3 = eldbus_message_iter_container_new(oarray2, 'a', "y");
335 while (eldbus_message_iter_get_and_next(value2, 'e', &value3))
336 {
337 eldbus_message_iter_fixed_array_get(value3, 'y', &arr, &size);
338 eldbus_message_iter_fixed_array_append(oarray2, 'y', arr, size);
339 }
340 eldbus_message_iter_container_close(oarray2, oarray3);
341 }
342 eldbus_message_iter_container_close(oarray, oarray2);
343 eldbus_message_iter_container_close(entry, oarray);
344}
345
346static void
347_networkmanager_edit_getsettings_append_vardict_array(Eldbus_Message_Iter *entry, const char *setting, Eldbus_Message_Iter *value)
348{
349 Eldbus_Message_Iter *oarray, *oarray2, *oarray3, *oarray4, *entry2;
350 Eldbus_Message_Iter *arr, *arr2, *variant;
351 const char *name, *sig, *string;
352 unsigned int num;
353
354 eldbus_message_iter_arguments_append(entry, "s", setting);
355 oarray = eldbus_message_iter_container_new(entry, 'v', "aa{sv}");
356 oarray2 = eldbus_message_iter_container_new(oarray, 'a', "a{sv}");
357 oarray3 = eldbus_message_iter_container_new(oarray2, 'a', "{sv}");
358 if (!eldbus_message_iter_arguments_get(value, "a{sv}", &arr))
359 {
360 DBG("Could not get vardict array");
361 eldbus_message_iter_container_close(oarray2, oarray3);
362 eldbus_message_iter_container_close(oarray, oarray2);
363 eldbus_message_iter_container_close(entry, oarray);
364 return;
365 }
366 while (eldbus_message_iter_get_and_next(arr, 'e', &arr2))
367 {
368 if (!eldbus_message_iter_arguments_get(arr2, "sv", &name, &variant))
369 {
370 DBG("Could not get vardict array %p", arr2);
371 continue;
372 }
373 entry2 = eldbus_message_iter_container_new(oarray3, 'e', NULL);
374 eldbus_message_iter_arguments_append(entry2, "s", name);
375 sig = eldbus_message_iter_signature_get(variant);
376 if (eina_streq(sig, "u"))
377 {
378 eldbus_message_iter_arguments_get(variant, "u", &num);
379 oarray4 = eldbus_message_iter_container_new(entry2, 'v', "u");
380 eldbus_message_iter_arguments_append(oarray4, "u", num);
381 }
382 else if (eina_streq(sig, "s"))
383 {
384 eldbus_message_iter_arguments_get(variant, "s", &string);
385 oarray4 = eldbus_message_iter_container_new(entry2, 'v', "s");
386 eldbus_message_iter_arguments_append(oarray4, "s", string);
387 }
388 eldbus_message_iter_container_close(entry2, oarray4);
389 eldbus_message_iter_container_close(oarray3, entry2);
390 }
391 eldbus_message_iter_container_close(oarray2, oarray3);
392 eldbus_message_iter_container_close(oarray, oarray2);
393 eldbus_message_iter_container_close(entry, oarray);
394}
395
396static void
397_networkmanager_edit_getsettings(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
398{
399 const char *main_setting, *setting, *name, *text;
400 Eldbus_Message_Iter *it, *array, *array2, *array3, *array4, *variant;
401 Eldbus_Message_Iter *oiter, *moarray, *moarray2, *moarray3, *entry;
402 Eldbus_Message *omsg;
403
404 NetworkManager_Service *ns = data;
405
406 pending_technologies = eina_list_remove(pending_technologies, pending);
407
408 it = eldbus_message_iter_get(msg);
409 if (eldbus_message_error_get(msg, &name, &text))
410 {
411 ERR("Could not get connection settings %s: %s", name, text);
412 return;
413 }
414 if (!eldbus_message_iter_arguments_get(it, "a{sa{sv}}", &array))
415 {
416 ERR("Could not get connection settings %p", msg);
417 return;
418 }
419 omsg = eldbus_proxy_method_call_new(ns->proxy, "Update");
420 oiter = eldbus_message_iter_get(omsg);
421 moarray = eldbus_message_iter_container_new(oiter, 'a', "{sa{sv}}");
422 while (eldbus_message_iter_get_and_next(array, 'e', &array2))
423 {
424 if (!eldbus_message_iter_arguments_get(array2, "sa{sv}", &main_setting, &array3))
425 {
426 ERR("Could not get technology settings array %p", msg);
427 return;
428 }
429 moarray2 = eldbus_message_iter_container_new(moarray, 'e', NULL);
430 eldbus_message_iter_arguments_append(moarray2, "s", main_setting);
431 moarray3 = eldbus_message_iter_container_new(moarray2, 'a', "{sv}");
432 while (eldbus_message_iter_get_and_next(array3, 'e', &array4))
433 {
434 const char *signature;
435 if (!eldbus_message_iter_arguments_get(array4, "sv", &setting, &variant))
436 {
437 ERR("Could not get technology settings array %p", msg);
438 return;
439 }
440 if (eina_streq(setting, "addresses") || eina_streq(setting, "routes")
441 || eina_streq(setting, "gateway"))
442 {
443 /*addresses and routes Settings are deprectaed in favor of address-data and route-data
444 we set gateway at the time we find ipv4/ipv6 configs*/
445 continue;
446 }
447 signature = eldbus_message_iter_signature_get(variant);
448 entry = eldbus_message_iter_container_new(moarray3, 'e', NULL);
449 if (eina_streq(main_setting, "ipv4") && eina_streq(setting, "address-data"))
450 {
451 Eldbus_Message_Iter *value;
452
453 if (!ns->ipv6 && ns->address)
454 {
455 if (!eldbus_message_iter_arguments_get(variant, "aa{sv}", &value))
456 {
457 ERR("Could not parse settings array %p", msg);
458 continue;
459 }
460 Eldbus_Message_Iter *oarray, *oarray2, *oarray3, *oarray4, *entry2;
461
462 eldbus_message_iter_arguments_append(entry, "s", setting);
463 oarray = eldbus_message_iter_container_new(entry, 'v', "aa{sv}");
464 oarray2 = eldbus_message_iter_container_new(oarray, 'a', "a{sv}");
465 oarray3 = eldbus_message_iter_container_new(oarray2, 'a', "{sv}");
466 if (ns->address)
467 {
468 entry2 = eldbus_message_iter_container_new(oarray3, 'e', NULL);
469 eldbus_message_iter_arguments_append(entry2, "s", "address");
470 oarray4 = eldbus_message_iter_container_new(entry2, 'v', "s");
471 eldbus_message_iter_arguments_append(oarray4, "s", ns->address);
472 eldbus_message_iter_container_close(entry2, oarray4);
473 eldbus_message_iter_container_close(oarray3, entry2);
474 }
475 if (ns->ip.v4.netmask)
476 {
477 unsigned int num, i = 0;
478 entry2 = eldbus_message_iter_container_new(oarray3, 'e', NULL);
479 eldbus_message_iter_arguments_append(entry2, "s", "prefix");
480 oarray4 = eldbus_message_iter_container_new(entry2, 'v', "u");
481 inet_pton(AF_INET, ns->ip.v4.netmask, &num);
482 while (num > 0)
483 {
484 num = num >> 1;
485 i++;
486 }
487 eldbus_message_iter_arguments_append(oarray4, "u", i);
488 eldbus_message_iter_container_close(entry2, oarray4);
489 eldbus_message_iter_container_close(oarray3, entry2);
490 }
491 eldbus_message_iter_container_close(oarray2, oarray3);
492 eldbus_message_iter_container_close(oarray, oarray2);
493 eldbus_message_iter_container_close(entry, oarray);
494 if (ns->gateway)
495 {
496 Eldbus_Message_Iter *gentry;
497 eldbus_message_iter_container_close(moarray3, entry);
498 entry = NULL;
499 gentry = eldbus_message_iter_container_new(moarray3, 'e', NULL);
500 _networkmanager_edit_getsettings_append_string(gentry, "gateway", ns->gateway);
501 eldbus_message_iter_container_close(moarray3, gentry);
502 }
503 }
504 else
505 {
506 if (!eldbus_message_iter_arguments_get(variant, "aa{sv}", &value))
507 {
508 ERR("Could not parse settings array %p", msg);
509 continue;
510 }
511 _networkmanager_edit_getsettings_append_vardict_array(entry, setting, value);
512 }
513 }
514 else if (eina_streq(main_setting, "ipv4") && eina_streq(setting, "dns"))
515 {
516 Eldbus_Message_Iter *value;
517
518 if (!eldbus_message_iter_arguments_get(variant, "au", &value))
519 {
520 ERR("Could not parse settings array %p", msg);
521 continue;
522 }
523 _networkmanager_edit_getsettings_append_uint_array(entry, setting, value);
524 }
525 else if (eina_streq(main_setting, "ipv4") && eina_streq(setting, "method"))
526 {
527 const char *value;
528
529 if (!ns->ipv6)
530 {
531 if (ns->method == WIRELESS_NETWORK_IPV4_METHOD_OFF)
532 value = "disabled";
533 else if (ns->method == WIRELESS_NETWORK_IPV4_METHOD_DHCP)
534 value = "auto";
535 else if (ns->method == WIRELESS_NETWORK_IPV4_METHOD_MANUAL)
536 value = "manual";
537 else if (ns->method == WIRELESS_NETWORK_IPV4_METHOD_FIXED)
538 value = "link-local";
539 else
540 value = "auto";
541 _networkmanager_edit_getsettings_append_string(entry, setting, value);
542 }
543 else
544 {
545 if (!eldbus_message_iter_arguments_get(variant, "s", &value))
546 {
547 ERR("Could not parse settings array %p", msg);
548 continue;
549 }
550 _networkmanager_edit_getsettings_append_string(entry, setting, value);
551 }
552 }
553 else if (eina_streq(main_setting, "ipv6") && eina_streq(setting, "address-data"))
554 {
555 Eldbus_Message_Iter *value;
556
557 if (ns->ipv6 && ns->address)
558 {
559 if (!eldbus_message_iter_arguments_get(variant, "aa{sv}", &value))
560 {
561 ERR("Could not parse settings array %p", msg);
562 continue;
563 }
564 Eldbus_Message_Iter *oarray, *oarray2, *oarray3, *oarray4, *entry2;
565
566 eldbus_message_iter_arguments_append(entry, "s", setting);
567 oarray = eldbus_message_iter_container_new(entry, 'v', "aa{sv}");
568 oarray2 = eldbus_message_iter_container_new(oarray, 'a', "a{sv}");
569 oarray3 = eldbus_message_iter_container_new(oarray2, 'a', "{sv}");
570 if (ns->address)
571 {
572 entry2 = eldbus_message_iter_container_new(oarray3, 'e', NULL);
573 eldbus_message_iter_arguments_append(entry2, "s", "address");
574 oarray4 = eldbus_message_iter_container_new(entry2, 'v', "s");
575 eldbus_message_iter_arguments_append(oarray4, "s", ns->address);
576 eldbus_message_iter_container_close(entry2, oarray4);
577 eldbus_message_iter_container_close(oarray3, entry2);
578 }
579 if (ns->ip.v6.prefixlength)
580 {
581 unsigned int pref;
582 entry2 = eldbus_message_iter_container_new(oarray3, 'e', NULL);
583 eldbus_message_iter_arguments_append(entry2, "s", "prefix");
584 oarray4 = eldbus_message_iter_container_new(entry2, 'v', "u");
585 pref = strtoul(ns->ip.v6.prefixlength, NULL, 0);
586 eldbus_message_iter_arguments_append(oarray4, "u", pref);
587 eldbus_message_iter_container_close(entry2, oarray4);
588 eldbus_message_iter_container_close(oarray3, entry2);
589 }
590 eldbus_message_iter_container_close(oarray2, oarray3);
591 eldbus_message_iter_container_close(oarray, oarray2);
592 eldbus_message_iter_container_close(entry, oarray);
593 if (ns->gateway)
594 {
595 Eldbus_Message_Iter *gentry;
596 eldbus_message_iter_container_close(moarray3, entry);
597 entry = NULL;
598 gentry = eldbus_message_iter_container_new(moarray3, 'e', NULL);
599 _networkmanager_edit_getsettings_append_string(gentry, "gateway", ns->gateway);
600 eldbus_message_iter_container_close(moarray3, gentry);
601 }
602 }
603 else
604 {
605 if (!eldbus_message_iter_arguments_get(variant, "aa{sv}", &value))
606 {
607 ERR("Could not parse settings array %p", msg);
608 continue;
609 }
610 _networkmanager_edit_getsettings_append_vardict_array(entry, setting, value);
611 }
612 }
613 else if (eina_streq(main_setting, "ipv6") && eina_streq(setting, "ip6-privacy"))
614 {
615 int value;
616
617 if (ns->ipv6)
618 {
619 if (ns->ip.v6.privacy == WIRELESS_NETWORK_IPV6_PRIVACY_DISABLED)
620 value = 0;
621 else if (ns->ip.v6.privacy == WIRELESS_NETWORK_IPV6_PRIVACY_ENABLED)
622 value = 1;
623 else if (ns->ip.v6.privacy == WIRELESS_NETWORK_IPV6_PRIVACY_PREFERRED)
624 value = 2;
625 else
626 value = -1;
627 _networkmanager_edit_getsettings_append_int(entry, setting, value);
628 }
629 else
630 {
631 if (!eldbus_message_iter_arguments_get(variant, "i", &value))
632 {
633 ERR("Could not parse settings array %p", msg);
634 continue;
635 }
636 _networkmanager_edit_getsettings_append_int(entry, setting, value);
637 }
638 }
639 else if (eina_streq(main_setting, "ipv6") && eina_streq(setting, "method"))
640 {
641 const char *value;
642
643 if (ns->ipv6)
644 {
645 if (ns->method == WIRELESS_NETWORK_IPV6_METHOD_OFF)
646 value = "disabled";
647 else if (ns->method == WIRELESS_NETWORK_IPV6_METHOD_AUTO)
648 value = "auto";
649 else if (ns->method == WIRELESS_NETWORK_IPV6_METHOD_MANUAL)
650 value = "manual";
651 else if (ns->method == WIRELESS_NETWORK_IPV6_METHOD_6TO4)
652 value = "6to4";
653 else if (ns->method == WIRELESS_NETWORK_IPV4_METHOD_FIXED)
654 value = "link-local";
655 else
656 value = "auto";
657 _networkmanager_edit_getsettings_append_string(entry, setting, value);
658 }
659 else
660 {
661 if (!eldbus_message_iter_arguments_get(variant, "s", &value))
662 {
663 ERR("Could not parse settings array %p", msg);
664 continue;
665 }
666 _networkmanager_edit_getsettings_append_string(entry, setting, value);
667 }
668 }
669 else if (eina_streq(main_setting, "proxy"))
670 {
671 int value;
672
673 if (ns->proxy_type)
674 {
675 if (ns->proxy_type == WIRELESS_PROXY_TYPE_MANUAL)
676 value = 0;
677 else
678 value = 1;
679 _networkmanager_edit_getsettings_append_int(entry, "method", value);
680 }
681 if (ns->proxy_url)
682 {
683 Eldbus_Message_Iter *pentry;
684 eldbus_message_iter_container_close(moarray3, entry);
685 entry = NULL;
686 pentry = eldbus_message_iter_container_new(moarray3, 'e', NULL);
687 _networkmanager_edit_getsettings_append_string(pentry, "pac-url", ns->proxy_url);
688 eldbus_message_iter_container_close(moarray3, pentry);
689 }
690 }
691 else if (eina_streq(signature, "aau"))
692 {
693 Eldbus_Message_Iter *value;
694
695 if (!eldbus_message_iter_arguments_get(variant, "aau", &value))
696 {
697 ERR("Could not parse settings array %p", msg);
698 continue;
699 }
700 _networkmanager_edit_getsettings_append_array_uint_array(entry, setting, value);
701 }
702 else if (eina_streq(signature, "aay"))
703 {
704 Eldbus_Message_Iter *value;
705
706 if (!eldbus_message_iter_arguments_get(variant, "aay", &value))
707 {
708 ERR("Could not parse settings array %p", msg);
709 continue;
710 }
711 _networkmanager_edit_getsettings_append_array_byte_array(entry, setting, value);
712 }
713 else if (eina_streq(signature, "as"))
714 {
715 Eldbus_Message_Iter *value;
716
717 if (!eldbus_message_iter_arguments_get(variant, "as", &value))
718 {
719 ERR("Could not parse settings array %p", msg);
720 continue;
721 }
722 _networkmanager_edit_getsettings_append_string_array(entry, setting, value);
723 }
724 else if (eina_streq(signature, "ay"))
725 {
726 Eldbus_Message_Iter *value;
727
728 if (!eldbus_message_iter_arguments_get(variant, "ay", &value))
729 {
730 ERR("Could not parse settings array %p", msg);
731 continue;
732 }
733 _networkmanager_edit_getsettings_append_byte_array(entry, setting, value);
734 }
735 else if (eina_streq(signature, "au"))
736 {
737 Eldbus_Message_Iter *value;
738
739 if (!eldbus_message_iter_arguments_get(variant, "au", &value))
740 {
741 ERR("Could not parse settings array %p", msg);
742 continue;
743 }
744 _networkmanager_edit_getsettings_append_uint_array(entry, setting, value);
745 }
746 else if (eina_streq(signature, "aa{sv}"))
747 {
748 Eldbus_Message_Iter *value;
749
750 if (!eldbus_message_iter_arguments_get(variant, "aa{sv}", &value))
751 {
752 ERR("Could not parse settings array %p", msg);
753 continue;
754 }
755 _networkmanager_edit_getsettings_append_vardict_array(entry, setting, value);
756 }
757 else if (eina_streq(signature, "b"))
758 {
759 int value;
760
761 if (!eldbus_message_iter_arguments_get(variant, "b", &value))
762 {
763 ERR("Could not parse settings array %p", msg);
764 continue;
765 }
766 _networkmanager_edit_getsettings_append_bool(entry, setting, value);
767 }
768 else if (eina_streq(signature, "i"))
769 {
770 int value;
771
772 if (!eldbus_message_iter_arguments_get(variant, "i", &value))
773 {
774 ERR("Could not parse settings array %p", msg);
775 continue;
776 }
777 _networkmanager_edit_getsettings_append_int(entry, setting, value);
778 }
779 else if (eina_streq(signature, "s"))
780 {
781 const char *value;
782
783 if (!eldbus_message_iter_arguments_get(variant, "s", &value))
784 {
785 ERR("Could not parse settings array %p", msg);
786 continue;
787 }
788 _networkmanager_edit_getsettings_append_string(entry, setting, value);
789 }
790 else if (eina_streq(signature, "t"))
791 {
792 time_t value;
793
794 if (!eldbus_message_iter_arguments_get(variant, "t", &value))
795 {
796 ERR("Could not parse settings array %p", msg);
797 continue;
798 }
799 _networkmanager_edit_getsettings_append_time(entry, setting, value);
800 }
801 else if (eina_streq(signature, "u"))
802 {
803 unsigned int value;
804
805 if (!eldbus_message_iter_arguments_get(variant, "u", &value))
806 {
807 ERR("Could not parse settings array %p", msg);
808 continue;
809 }
810 _networkmanager_edit_getsettings_append_uint(entry, setting, value);
811 }
812 else if (eina_streq(signature, "x"))
813 {
814 long long value;
815
816 if (!eldbus_message_iter_arguments_get(variant, "x", &value))
817 {
818 ERR("Could not parse settings array %p", msg);
819 continue;
820 }
821 _networkmanager_edit_getsettings_append_long_long(entry, setting, value);
822 }
823 if (entry)
824 eldbus_message_iter_container_close(moarray3, entry);
825 }
826 eldbus_message_iter_container_close(moarray2, moarray3);
827 eldbus_message_iter_container_close(moarray, moarray2);
828 }
829 eldbus_message_iter_container_close(oiter, moarray);
830 eldbus_proxy_send(ns->proxy, omsg, _networkmanager_service_edit_cb, NULL, ELDBUS_TIMEOUT_INFINITE);
171} 831}
172 832
173void 833void
174networkmanager_service_edit(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED) 834networkmanager_service_edit(const char *path, Wireless_Connection *wc)
175{ 835{
836 NetworkManager_Service *ns;
837 Eldbus_Object *obj;
838 Eldbus_Proxy *proxy;
839 Eldbus_Pending *pend;
840
841 ns = _networkmanager_service_find_path(path);
842 EINA_SAFETY_ON_NULL_RETURN(ns);
843
844 eina_stringshare_replace(&ns->address, wc->address);
845 eina_stringshare_replace(&ns->gateway, wc->gateway);
846 ns->method = wc->method;
847 if (wc->ipv6)
848 {
849 ns->ipv6 = EINA_TRUE;
850 ns->ip.v6.privacy = wc->ip.v6.privacy;
851 eina_stringshare_replace(&ns->ip.v6.prefixlength, wc->ip.v6.prefixlength);
852 }
853 else
854 {
855 ns->ipv6 = EINA_FALSE;
856 eina_stringshare_replace(&ns->ip.v4.netmask, wc->ip.v4.netmask);
857 }
858
859 obj = eldbus_object_get(dbus_conn, NETWORKMANAGER_BUS_NAME, ns->path);
860 proxy = eldbus_proxy_get(obj, NETWORKMANAGER_BUS_INTERFACE ".Settings.Connection");
861 pend = eldbus_proxy_call(proxy, "GetSettings",
862 _networkmanager_edit_getsettings, ns, -1, "");
863 pending_technologies = eina_list_append(pending_technologies, pend);
176} 864}
177 865
178void 866void
179networkmanager_service_edit_proxy(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED) 867networkmanager_service_edit_proxy(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED)
180{ 868{
869 NetworkManager_Service *ns;
870 Eldbus_Object *obj;
871 Eldbus_Proxy *proxy;
872 Eldbus_Pending *pend;
873
874 ns = _networkmanager_service_find_path(path);
875 EINA_SAFETY_ON_NULL_RETURN(ns);
876
877 eina_stringshare_replace(&ns->proxy_url, wc->proxy_url);
878 ns->proxy_type = wc->proxy_type;
879
880 obj = eldbus_object_get(dbus_conn, NETWORKMANAGER_BUS_NAME, ns->path);
881 proxy = eldbus_proxy_get(obj, NETWORKMANAGER_BUS_INTERFACE ".Settings.Connection");
882 pend = eldbus_proxy_call(proxy, "GetSettings",
883 _networkmanager_edit_getsettings, ns, -1, "");
884 pending_technologies = eina_list_append(pending_technologies, pend);
181} 885}
182 886
183void 887void
184networkmanager_service_edit_domains(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED) 888networkmanager_service_edit_domains(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED)
185{ 889{
890
186} 891}
187 892
188void 893void
189networkmanager_service_edit_nameservers(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED) 894networkmanager_service_edit_nameservers(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED)
190{ 895{
896
191} 897}
192 898
193void 899void
194networkmanager_service_edit_timeservers(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED) 900networkmanager_service_edit_timeservers(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED)
195{ 901{
902 DBG("NetworkManager does not have time servers configuration");
196} 903}
197 904
198void 905void
199networkmanager_service_remove(const char *path EINA_UNUSED) 906networkmanager_service_remove(const char *path)
200{ 907{
908 Eldbus_Object *obj;
909 Eldbus_Proxy *proxy;
910
911 obj = eldbus_object_get(dbus_conn, NETWORKMANAGER_BUS_NAME, path);
912 proxy = eldbus_proxy_get(obj, NETWORKMANAGER_BUS_INTERFACE ".Settings.Connection");
913 eldbus_proxy_call(proxy, "Delete", NULL, NULL, -1, "");
201} 914}
202 915
203void 916void
204networkmanager_airplane_mode_set(Eina_Bool set EINA_UNUSED) 917networkmanager_airplane_mode_set(Eina_Bool set)
205{ 918{
919 EINA_SAFETY_ON_NULL_RETURN(proxy_manager);
920 eldbus_proxy_call(proxy_manager, "Enable", NULL, NULL, -1, "b", set);
206} 921}
207 922
208/*static NetworkManager_Service * 923static NetworkManager_Service *
209_networkmanager_service_find_path(const char *path) 924_networkmanager_service_find_path(const char *path)
210{ 925{
211 NetworkManager_Service *ns, *nss = NULL; 926 NetworkManager_Service *ns, *nss = NULL;
927 Eina_List *l;
212 int i; 928 int i;
213 929
214 NETWORKMANAGER_SERVICE_TYPE_ITER(i) 930 NETWORKMANAGER_SERVICE_TYPE_ITER(i)
215 { 931 {
216 EINA_INLIST_FOREACH(networkmanager_services_list[i], ns) 932 EINA_LIST_FOREACH(networkmanager_services_list[i], l, ns)
217 { 933 {
218 if (eina_streq(ns->path, path)) 934 if (eina_streq(ns->path, path))
219 { 935 {
@@ -223,17 +939,18 @@ _networkmanager_service_find_path(const char *path)
223 } 939 }
224 } 940 }
225 return nss; 941 return nss;
226}*/ 942}
227 943
228static NetworkManager_Service * 944static NetworkManager_Service *
229_networkmanager_service_find_wn(Wireless_Network *wn) 945_networkmanager_service_find_wn(Wireless_Network *wn)
230{ 946{
231 NetworkManager_Service *ns, *nss = NULL; 947 NetworkManager_Service *ns, *nss = NULL;
948 Eina_List *l;
232 int i; 949 int i;
233 950
234 NETWORKMANAGER_SERVICE_TYPE_ITER(i) 951 NETWORKMANAGER_SERVICE_TYPE_ITER(i)
235 { 952 {
236 EINA_INLIST_FOREACH(networkmanager_services_list[i], ns) 953 EINA_LIST_FOREACH(networkmanager_services_list[i], l, ns)
237 { 954 {
238 if (ns->wn) 955 if (ns->wn)
239 { 956 {
@@ -290,10 +1007,18 @@ _networkmanager_service_connect(Wireless_Network *wn)
290 { 1007 {
291 if (ns->access_point) 1008 if (ns->access_point)
292 { 1009 {
293 pend = eldbus_proxy_call(proxy_manager, "ActivateConnection", 1010 Eldbus_Message *msg;
1011 Eldbus_Message_Iter *iter, *array;
1012
1013 msg = eldbus_proxy_method_call_new(proxy_manager, "AddAndActivateConnection");
1014 iter = eldbus_message_iter_get(msg);
1015 eldbus_message_iter_arguments_append(iter, "a{sa{sv}}", &array);
1016 eldbus_message_iter_container_close(iter, array);
1017 eldbus_message_iter_basic_append(iter, 'o', device_path);
1018 eldbus_message_iter_basic_append(iter, 'o', ns->path);
1019 pend = eldbus_proxy_send(proxy_manager, msg,
294 _networkmanager_service_connect_cb, ns, 1020 _networkmanager_service_connect_cb, ns,
295 NETWORKMANAGER_CONNECTION_TIMEOUT, "ooo", 1021 NETWORKMANAGER_CONNECTION_TIMEOUT);
296 "/", device_path, "/");
297 } 1022 }
298 else 1023 else
299 { 1024 {
@@ -384,9 +1109,10 @@ _networkmanager_update_networks(NetworkManager_Service_Type type)
384 Eina_Array *arr; 1109 Eina_Array *arr;
385 NetworkManager_Service *ns; 1110 NetworkManager_Service *ns;
386 NetworkManager_Service *services[NETWORKMANAGER_SERVICE_TYPE_LAST] = {NULL}; 1111 NetworkManager_Service *services[NETWORKMANAGER_SERVICE_TYPE_LAST] = {NULL};
1112 Eina_List *l;
387 1113
388 arr = eina_array_new(eina_inlist_count(networkmanager_services_list[type])); 1114 arr = eina_array_new(eina_list_count(networkmanager_services_list[type]));
389 EINA_INLIST_FOREACH(networkmanager_services_list[type], ns) 1115 EINA_LIST_FOREACH(networkmanager_services_list[type], l, ns)
390 { 1116 {
391 if (ns->wn) free(ns->wn); 1117 if (ns->wn) free(ns->wn);
392 _networkmanager_service_convert(ns); 1118 _networkmanager_service_convert(ns);
@@ -553,7 +1279,7 @@ _networkmanager_manager_getsetting_prop_ipv6(void *data, const void *msg, Eldbus
553 else if (eina_streq(setting, "ip6-privacy")) 1279 else if (eina_streq(setting, "ip6-privacy"))
554 { 1280 {
555 int privacy; 1281 int privacy;
556 if (!eldbus_message_iter_arguments_get(it, "u", &privacy)) 1282 if (!eldbus_message_iter_arguments_get(it, "i", &privacy))
557 { 1283 {
558 ERR("Could not get technology ipv6 privacy %p", msg); 1284 ERR("Could not get technology ipv6 privacy %p", msg);
559 return; 1285 return;
@@ -571,7 +1297,7 @@ _networkmanager_manager_getsetting_prop_ipv6(void *data, const void *msg, Eldbus
571 { 1297 {
572 const char *name, *address; 1298 const char *name, *address;
573 size_t prefix; 1299 size_t prefix;
574 char buf[4096]; 1300 char buf[33];
575 Eldbus_Message_Iter *array, *array2, *array3, *variant; 1301 Eldbus_Message_Iter *array, *array2, *array3, *variant;
576 if (!eldbus_message_iter_arguments_get(it, "aa{sv}", &array)) 1302 if (!eldbus_message_iter_arguments_get(it, "aa{sv}", &array))
577 { 1303 {
@@ -663,7 +1389,7 @@ _networkmanager_manager_getsetting_prop_ipv4(void *data, const void *msg, Eldbus
663 { 1389 {
664 const char *name, *address; 1390 const char *name, *address;
665 size_t prefix = 0; 1391 size_t prefix = 0;
666 char buf[4096]; 1392 char buf[33];
667 struct in_addr tmp_addr; 1393 struct in_addr tmp_addr;
668 Eldbus_Message_Iter *array, *array2, *array3, *variant; 1394 Eldbus_Message_Iter *array, *array2, *array3, *variant;
669 if (!eldbus_message_iter_arguments_get(it, "aa{sv}", &array)) 1395 if (!eldbus_message_iter_arguments_get(it, "aa{sv}", &array))
@@ -896,8 +1622,7 @@ _networkmanager_service_free(NetworkManager_Service *ns)
896 if (!ns) return; 1622 if (!ns) return;
897 1623
898 _networkmanager_service_free_common(ns); 1624 _networkmanager_service_free_common(ns);
899 networkmanager_services_list[ns->type] = eina_inlist_remove(networkmanager_services_list[ns->type], 1625 networkmanager_services_list[ns->type] = eina_list_remove(networkmanager_services_list[ns->type], ns);
900 EINA_INLIST_GET(ns));
901 free(ns); 1626 free(ns);
902 ns = NULL; 1627 ns = NULL;
903} 1628}
@@ -976,6 +1701,7 @@ _networkmanager_service_ap_new(int type, const char *path, Eldbus_Message_Iter *
976{ 1701{
977 NetworkManager_Service *ns, *nss; 1702 NetworkManager_Service *ns, *nss;
978 Eldbus_Object *obj; 1703 Eldbus_Object *obj;
1704 Eina_List *l;
979 1705
980 ns = calloc(1, sizeof(NetworkManager_Service)); 1706 ns = calloc(1, sizeof(NetworkManager_Service));
981 ns->path = eina_stringshare_add(path); 1707 ns->path = eina_stringshare_add(path);
@@ -1003,7 +1729,7 @@ _networkmanager_service_ap_new(int type, const char *path, Eldbus_Message_Iter *
1003 _networkmanager_service_free_nolist(ns); 1729 _networkmanager_service_free_nolist(ns);
1004 return NULL; 1730 return NULL;
1005 } 1731 }
1006 EINA_INLIST_FOREACH(networkmanager_services_list[ns->type], nss) 1732 EINA_LIST_FOREACH(networkmanager_services_list[ns->type], l, nss)
1007 { 1733 {
1008 if (nss->access_point) 1734 if (nss->access_point)
1009 { 1735 {
@@ -1041,8 +1767,7 @@ _networkmanager_service_ap_new(int type, const char *path, Eldbus_Message_Iter *
1041 } 1767 }
1042 } 1768 }
1043 } 1769 }
1044 networkmanager_services_list[ns->type] = eina_inlist_append(networkmanager_services_list[ns->type], 1770 networkmanager_services_list[ns->type] = eina_list_append(networkmanager_services_list[ns->type], ns);
1045 EINA_INLIST_GET(ns));
1046 DBG("Added service: %p %s || proxy %p", ns, path, ns->proxy); 1771 DBG("Added service: %p %s || proxy %p", ns, path, ns->proxy);
1047 return ns; 1772 return ns;
1048} 1773}
@@ -1052,6 +1777,7 @@ _networkmanager_service_new(int type, int state, const char *path, Eldbus_Messag
1052{ 1777{
1053 NetworkManager_Service *ns, *nss; 1778 NetworkManager_Service *ns, *nss;
1054 Eldbus_Object *obj; 1779 Eldbus_Object *obj;
1780 Eina_List *l;
1055 1781
1056 ns = calloc(1, sizeof(NetworkManager_Service)); 1782 ns = calloc(1, sizeof(NetworkManager_Service));
1057 ns->path = eina_stringshare_add(path); 1783 ns->path = eina_stringshare_add(path);
@@ -1085,7 +1811,7 @@ _networkmanager_service_new(int type, int state, const char *path, Eldbus_Messag
1085 _networkmanager_service_free_nolist(ns); 1811 _networkmanager_service_free_nolist(ns);
1086 return NULL; 1812 return NULL;
1087 } 1813 }
1088 EINA_INLIST_FOREACH(networkmanager_services_list[ns->type], nss) 1814 EINA_LIST_FOREACH(networkmanager_services_list[ns->type], l, nss)
1089 { 1815 {
1090 if (!ns->conn_ssid) continue; 1816 if (!ns->conn_ssid) continue;
1091 if (nss->access_point) 1817 if (nss->access_point)
@@ -1103,8 +1829,7 @@ _networkmanager_service_new(int type, int state, const char *path, Eldbus_Messag
1103 } 1829 }
1104 } 1830 }
1105 } 1831 }
1106 networkmanager_services_list[ns->type] = eina_inlist_append(networkmanager_services_list[ns->type], 1832 networkmanager_services_list[ns->type] = eina_list_append(networkmanager_services_list[ns->type], ns);
1107 EINA_INLIST_GET(ns));
1108 DBG("Added service: %p %s || proxy %p", ns, path, ns->proxy); 1833 DBG("Added service: %p %s || proxy %p", ns, path, ns->proxy);
1109 return ns; 1834 return ns;
1110} 1835}
@@ -1242,6 +1967,7 @@ _networkmanager_manager_gettechnologies_prop_state(void *data, const Eldbus_Mess
1242 Eldbus_Message_Iter *it, *variant; 1967 Eldbus_Message_Iter *it, *variant;
1243 NetworkManager_Technology *nt = data; 1968 NetworkManager_Technology *nt = data;
1244 NetworkManager_Service *ns; 1969 NetworkManager_Service *ns;
1970 Eina_List *l;
1245 int state; 1971 int state;
1246 1972
1247 pending_technologies = eina_list_remove(pending_technologies, pending); 1973 pending_technologies = eina_list_remove(pending_technologies, pending);
@@ -1272,7 +1998,7 @@ _networkmanager_manager_gettechnologies_prop_state(void *data, const Eldbus_Mess
1272 nt->connected = EINA_FALSE; 1998 nt->connected = EINA_FALSE;
1273 _networkmanager_update_technologies(); 1999 _networkmanager_update_technologies();
1274 _networkmanager_update_enabled_technologies(); 2000 _networkmanager_update_enabled_technologies();
1275 EINA_INLIST_FOREACH(networkmanager_services_list[nt->type], ns) 2001 EINA_LIST_FOREACH(networkmanager_services_list[nt->type], l, ns)
1276 _networkmanager_service_state(ns, state); 2002 _networkmanager_service_state(ns, state);
1277} 2003}
1278 2004
@@ -1282,6 +2008,7 @@ _networkmanager_manager_technology_event_property(void *data, const Eldbus_Messa
1282 NetworkManager_Technology *nt = data; 2008 NetworkManager_Technology *nt = data;
1283 NetworkManager_Service *ns; 2009 NetworkManager_Service *ns;
1284 Eldbus_Message_Iter *it; 2010 Eldbus_Message_Iter *it;
2011 Eina_List *l;
1285 int state; 2012 int state;
1286 2013
1287 if (pending_getproperties_manager) return; 2014 if (pending_getproperties_manager) return;
@@ -1302,7 +2029,7 @@ _networkmanager_manager_technology_event_property(void *data, const Eldbus_Messa
1302 nt->connected = EINA_FALSE; 2029 nt->connected = EINA_FALSE;
1303 _networkmanager_update_technologies(); 2030 _networkmanager_update_technologies();
1304 _networkmanager_update_enabled_technologies(); 2031 _networkmanager_update_enabled_technologies();
1305 EINA_INLIST_FOREACH(networkmanager_services_list[nt->type], ns) 2032 EINA_LIST_FOREACH(networkmanager_services_list[nt->type], l, ns)
1306 _networkmanager_service_state(ns, state); 2033 _networkmanager_service_state(ns, state);
1307} 2034}
1308 2035
@@ -1389,6 +2116,7 @@ _networkmanager_manager_getactive_conn(void *data EINA_UNUSED, const Eldbus_Mess
1389 const char *name, *text, *conn_path; 2116 const char *name, *text, *conn_path;
1390 Eldbus_Message_Iter *it, *variant; 2117 Eldbus_Message_Iter *it, *variant;
1391 NetworkManager_Service *ns; 2118 NetworkManager_Service *ns;
2119 Eina_List *l;
1392 int i; 2120 int i;
1393 2121
1394 pending_technologies = eina_list_remove(pending_technologies, pending); 2122 pending_technologies = eina_list_remove(pending_technologies, pending);
@@ -1411,7 +2139,7 @@ _networkmanager_manager_getactive_conn(void *data EINA_UNUSED, const Eldbus_Mess
1411 eina_stringshare_replace(&active_connection, conn_path); 2139 eina_stringshare_replace(&active_connection, conn_path);
1412 NETWORKMANAGER_SERVICE_TYPE_ITER(i) 2140 NETWORKMANAGER_SERVICE_TYPE_ITER(i)
1413 { 2141 {
1414 EINA_INLIST_FOREACH(networkmanager_services_list[i], ns) 2142 EINA_LIST_FOREACH(networkmanager_services_list[i], l, ns)
1415 { 2143 {
1416 if (ns->access_point) continue; 2144 if (ns->access_point) continue;
1417 ns->is_active_connection = EINA_FALSE; 2145 ns->is_active_connection = EINA_FALSE;
@@ -1433,6 +2161,7 @@ _networkmanager_manager_getactive(void *data EINA_UNUSED, const Eldbus_Message *
1433 Eldbus_Proxy *prox; 2161 Eldbus_Proxy *prox;
1434 Eldbus_Pending *pend; 2162 Eldbus_Pending *pend;
1435 Eldbus_Message_Iter *variant; 2163 Eldbus_Message_Iter *variant;
2164 Eina_List *l;
1436 const char *name, *text, *conn_path; 2165 const char *name, *text, *conn_path;
1437 int i; 2166 int i;
1438 NetworkManager_Service *ns; 2167 NetworkManager_Service *ns;
@@ -1459,7 +2188,7 @@ _networkmanager_manager_getactive(void *data EINA_UNUSED, const Eldbus_Message *
1459 eina_stringshare_replace(&active_connection, conn_path); 2188 eina_stringshare_replace(&active_connection, conn_path);
1460 NETWORKMANAGER_SERVICE_TYPE_ITER(i) 2189 NETWORKMANAGER_SERVICE_TYPE_ITER(i)
1461 { 2190 {
1462 EINA_INLIST_FOREACH(networkmanager_services_list[i], ns) 2191 EINA_LIST_FOREACH(networkmanager_services_list[i], l, ns)
1463 { 2192 {
1464 if (ns->access_point) continue; 2193 if (ns->access_point) continue;
1465 if (ns->is_active_connection) 2194 if (ns->is_active_connection)
@@ -1563,6 +2292,7 @@ _networkmanager_manager_update_prop(void *data EINA_UNUSED, const void *msg, Eld
1563 Eldbus_Object *obj; 2292 Eldbus_Object *obj;
1564 Eldbus_Pending *pend; 2293 Eldbus_Pending *pend;
1565 Eldbus_Proxy *prox; 2294 Eldbus_Proxy *prox;
2295 Eina_List *l;
1566 const char *conn_path; 2296 const char *conn_path;
1567 int i; 2297 int i;
1568 NetworkManager_Service *ns; 2298 NetworkManager_Service *ns;
@@ -1578,7 +2308,7 @@ _networkmanager_manager_update_prop(void *data EINA_UNUSED, const void *msg, Eld
1578 eina_stringshare_replace(&active_connection, conn_path); 2308 eina_stringshare_replace(&active_connection, conn_path);
1579 NETWORKMANAGER_SERVICE_TYPE_ITER(i) 2309 NETWORKMANAGER_SERVICE_TYPE_ITER(i)
1580 { 2310 {
1581 EINA_INLIST_FOREACH(networkmanager_services_list[i], ns) 2311 EINA_LIST_FOREACH(networkmanager_services_list[i], l, ns)
1582 { 2312 {
1583 if (ns->access_point) continue; 2313 if (ns->access_point) continue;
1584 if (ns->is_active_connection) 2314 if (ns->is_active_connection)
@@ -1621,8 +2351,11 @@ _networkmanager_services_free(void)
1621 2351
1622 NETWORKMANAGER_SERVICE_TYPE_ITER(i) 2352 NETWORKMANAGER_SERVICE_TYPE_ITER(i)
1623 { 2353 {
1624 EINA_INLIST_FOREACH(networkmanager_services_list[i], ns) 2354 if (eina_list_count(networkmanager_services_list[i]))
1625 _networkmanager_service_free(ns); 2355 {
2356 EINA_LIST_FREE(networkmanager_services_list[i], ns)
2357 _networkmanager_service_free(ns);
2358 }
1626 } 2359 }
1627} 2360}
1628 2361
@@ -1655,6 +2388,7 @@ _networkmanager_start(void)
1655 sig_handlers = eina_list_append(sig_handlers, 2388 sig_handlers = eina_list_append(sig_handlers,
1656 eldbus_proxy_signal_handler_add(proxy_manager, "PropertiesChanged", 2389 eldbus_proxy_signal_handler_add(proxy_manager, "PropertiesChanged",
1657 _networkmanager_manager_event_property, NULL)); 2390 _networkmanager_manager_event_property, NULL));
2391
1658} 2392}
1659 2393
1660static void 2394static void
@@ -1670,7 +2404,6 @@ _networkmanager_end(void)
1670 eldbus_pending_cancel(pend); 2404 eldbus_pending_cancel(pend);
1671 pend = NULL; 2405 pend = NULL;
1672 } 2406 }
1673 _networkmanager_services_free();
1674 NETWORKMANAGER_SERVICE_TYPE_ITER(i) 2407 NETWORKMANAGER_SERVICE_TYPE_ITER(i)
1675 { 2408 {
1676 if (networkmanager_technology[i].handler) 2409 if (networkmanager_technology[i].handler)
@@ -1719,6 +2452,7 @@ networkmanager_shutdown(void)
1719{ 2452{
1720 int i; 2453 int i;
1721 2454
2455 _networkmanager_services_free();
1722 NETWORKMANAGER_SERVICE_TYPE_ITER(i) 2456 NETWORKMANAGER_SERVICE_TYPE_ITER(i)
1723 { 2457 {
1724 free(networkmanager_current_connection[i]); 2458 free(networkmanager_current_connection[i]);
diff --git a/src/wireless.c b/src/wireless.c
index 19d92f3..78a8adb 100644
--- a/src/wireless.c
+++ b/src/wireless.c
@@ -656,8 +656,8 @@ _wireless_edit_send()
656static void 656static void
657_wireless_edit_send_button() 657_wireless_edit_send_button()
658{ 658{
659 evas_object_del(wireless_edit_popup);
660 _wireless_edit_send(); 659 _wireless_edit_send();
660 evas_object_del(wireless_edit_popup);
661} 661}
662 662
663static void 663static void
@@ -1003,18 +1003,35 @@ _wireless_gadget_edit(int type)
1003 1003
1004 wireless_edit[i]->wn = wn; 1004 wireless_edit[i]->wn = wn;
1005 wireless_edit[i]->method = wc->method; 1005 wireless_edit[i]->method = wc->method;
1006 wireless_edit[i]->address = eina_stringshare_ref(wc->address); 1006 if (wc->address)
1007 wireless_edit[i]->gateway = eina_stringshare_ref(wc->gateway); 1007 wireless_edit[i]->address = eina_stringshare_ref(wc->address);
1008 else
1009 wireless_edit[i]->address = NULL;
1010 if (wc->gateway)
1011 wireless_edit[i]->gateway = eina_stringshare_ref(wc->gateway);
1012 else
1013 wireless_edit[i]->gateway = NULL;
1008 wireless_edit[i]->ipv6 = wc->ipv6; 1014 wireless_edit[i]->ipv6 = wc->ipv6;
1009 if (wc->ipv6) 1015 if (wc->ipv6)
1010 { 1016 {
1011 wireless_edit[i]->ip.v6.prefixlength = eina_stringshare_ref(wc->ip.v6.prefixlength); 1017 if (wc->ip.v6.prefixlength)
1018 wireless_edit[i]->ip.v6.prefixlength = eina_stringshare_ref(wc->ip.v6.prefixlength);
1019 else
1020 wireless_edit[i]->ip.v6.prefixlength = NULL;
1012 wireless_edit[i]->ip.v6.privacy = wc->ip.v6.privacy; 1021 wireless_edit[i]->ip.v6.privacy = wc->ip.v6.privacy;
1013 } 1022 }
1014 else 1023 else
1015 wireless_edit[i]->ip.v4.netmask = eina_stringshare_ref(wc->ip.v4.netmask); 1024 {
1025 if (wc->ip.v4.netmask)
1026 wireless_edit[i]->ip.v4.netmask = eina_stringshare_ref(wc->ip.v4.netmask);
1027 else
1028 wireless_edit[i]->ip.v4.netmask = NULL;
1029 }
1016 wireless_edit[i]->proxy_type = wc->proxy_type; 1030 wireless_edit[i]->proxy_type = wc->proxy_type;
1017 wireless_edit[i]->proxy_url = eina_stringshare_ref(wc->proxy_url); 1031 if (wc->proxy_url)
1032 wireless_edit[i]->proxy_url = eina_stringshare_ref(wc->proxy_url);
1033 else
1034 wireless_edit[i]->proxy_url = NULL;
1018 /* fuuuuck thiiiiiiis */ 1035 /* fuuuuck thiiiiiiis */
1019 for (ii = 0; ii < EINA_C_ARRAY_LENGTH(arrays); ii++) 1036 for (ii = 0; ii < EINA_C_ARRAY_LENGTH(arrays); ii++)
1020 { 1037 {
@@ -1318,10 +1335,10 @@ wireless_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
1318 } 1335 }
1319 1336
1320 evas_object_del(wireless_popup.popup); 1337 evas_object_del(wireless_popup.popup);
1338 _connection_shutdown();
1321 free(inst); 1339 free(inst);
1322 free(wireless_config); 1340 free(wireless_config);
1323 1341
1324 _connection_shutdown();
1325 eldbus_connection_unref(dbus_conn); 1342 eldbus_connection_unref(dbus_conn);
1326 eina_log_domain_unregister(_wireless_gadget_log_dom); 1343 eina_log_domain_unregister(_wireless_gadget_log_dom);
1327 _wireless_gadget_log_dom = -1; 1344 _wireless_gadget_log_dom = -1;