summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2016-02-19 21:34:27 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-02-19 21:34:27 -0500
commit2258646cfdd74a30434525eb0289c475190f0a07 (patch)
tree57343154578d1221a67a61b955c47d84c1bc4060
parent40616fb2037f767b33a01aac18e2613b036a572a (diff)
wip
-rw-r--r--src/gadgets/core.c95
-rw-r--r--src/gadgets/gadget.h2
-rw-r--r--src/gadgets/wireless/connman.c189
-rw-r--r--src/gadgets/wireless/wireless.c455
-rw-r--r--src/gadgets/wireless/wireless.h13
5 files changed, 721 insertions, 33 deletions
diff --git a/src/gadgets/core.c b/src/gadgets/core.c
index 60dd8ac..9c22666 100644
--- a/src/gadgets/core.c
+++ b/src/gadgets/core.c
@@ -56,6 +56,14 @@ struct Z_Gadget_Config
56 Z_Gadget_Site *site; 56 Z_Gadget_Site *site;
57 E_Menu *menu; 57 E_Menu *menu;
58 58
59 struct
60 {
61 Evas_Object *popup;
62 Evas_Smart_Cb allow;
63 Evas_Smart_Cb deny;
64 void *data;
65 } allow_deny;
66
59 double x, y; //fixed % positioning 67 double x, y; //fixed % positioning
60 double w, h; //fixed % sizing 68 double w, h; //fixed % sizing
61 Evas_Point offset; //offset from mouse down 69 Evas_Point offset; //offset from mouse down
@@ -184,6 +192,15 @@ _gadget_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
184} 192}
185 193
186static void 194static void
195_gadget_util_allow_deny_cleanup(Z_Gadget_Config *zgc)
196{
197 zgc->allow_deny.allow = zgc->allow_deny.deny = NULL;
198 zgc->allow_deny.data = NULL;
199 evas_object_hide(zgc->allow_deny.popup);
200 E_FREE_FUNC(zgc->allow_deny.popup, evas_object_del);
201}
202
203static void
187_gadget_object_free(E_Object *eobj) 204_gadget_object_free(E_Object *eobj)
188{ 205{
189 Z_Gadget_Config *zgc; 206 Z_Gadget_Config *zgc;
@@ -198,6 +215,7 @@ _gadget_object_free(E_Object *eobj)
198 E_FREE_FUNC(zgc->gadget, evas_object_del); 215 E_FREE_FUNC(zgc->gadget, evas_object_del);
199 E_FREE_FUNC(zgc->cfg_object, evas_object_del); 216 E_FREE_FUNC(zgc->cfg_object, evas_object_del);
200 E_FREE_FUNC(zgc->style.obj, evas_object_del); 217 E_FREE_FUNC(zgc->style.obj, evas_object_del);
218 _gadget_util_allow_deny_cleanup(zgc);
201 E_FREE(zgc->e_obj_inherit); 219 E_FREE(zgc->e_obj_inherit);
202} 220}
203 221
@@ -1616,6 +1634,83 @@ z_gadget_util_ctxpopup_place(Evas_Object *g, Evas_Object *ctx)
1616 evas_object_move(ctx, x, y); 1634 evas_object_move(ctx, x, y);
1617} 1635}
1618 1636
1637static void
1638_gadget_util_allow(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1639{
1640 Z_Gadget_Config *zgc = data;
1641
1642 zgc->allow_deny.allow(zgc->allow_deny.data, zgc->gadget, NULL);
1643 _gadget_util_allow_deny_cleanup(zgc);
1644}
1645
1646static void
1647_gadget_util_deny(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1648{
1649 Z_Gadget_Config *zgc = data;
1650
1651 zgc->allow_deny.deny(zgc->allow_deny.data, zgc->gadget, NULL);
1652 _gadget_util_allow_deny_cleanup(zgc);
1653}
1654
1655Z_API void
1656z_gadget_util_allow_deny_ctxpopup(Evas_Object *g, const char *text, Evas_Smart_Cb allow_cb, Evas_Smart_Cb deny_cb, const void *data)
1657{
1658 Evas_Object *ctx, *tb, *lbl, *bt;
1659 Z_Gadget_Config *zgc;
1660
1661 EINA_SAFETY_ON_NULL_RETURN(g);
1662 zgc = evas_object_data_get(g, "__z_gadget");
1663 EINA_SAFETY_ON_NULL_RETURN(zgc);
1664
1665 /* FIXME */
1666 EINA_SAFETY_ON_TRUE_RETURN(!!zgc->allow_deny.popup);
1667
1668 EINA_SAFETY_ON_NULL_RETURN(allow_cb);
1669 EINA_SAFETY_ON_NULL_RETURN(deny_cb);
1670 EINA_SAFETY_ON_NULL_RETURN(text);
1671
1672 zgc->allow_deny.allow = allow_cb;
1673 zgc->allow_deny.deny = deny_cb;
1674 zgc->allow_deny.data = (void*)data;
1675
1676 ctx = elm_ctxpopup_add(e_comp->elm);
1677 elm_object_style_set(ctx, "noblock");
1678
1679 tb = elm_table_add(ctx);
1680 E_EXPAND(tb);
1681 E_FILL(tb);
1682 evas_object_show(tb);
1683 lbl = elm_label_add(ctx);
1684 E_FILL(lbl);
1685 elm_object_text_set(lbl, text);
1686 evas_object_show(lbl);
1687 elm_table_pack(tb, lbl, 0, 0, 2, 2);
1688
1689 bt = elm_button_add(ctx);
1690 evas_object_show(bt);
1691 E_EXPAND(bt);
1692 E_FILL(bt);
1693 elm_object_text_set(bt, "Deny");
1694 evas_object_smart_callback_add(bt, "clicked", _gadget_util_deny, zgc);
1695 elm_table_pack(tb, bt, 0, 2, 1, 1);
1696
1697 bt = elm_button_add(ctx);
1698 evas_object_show(bt);
1699 E_EXPAND(bt);
1700 E_FILL(bt);
1701 elm_object_text_set(bt, "Allow");
1702 evas_object_smart_callback_add(bt, "clicked", _gadget_util_allow, zgc);
1703 elm_table_pack(tb, bt, 1, 2, 1, 1);
1704
1705 elm_object_content_set(ctx, tb);
1706
1707 z_gadget_util_ctxpopup_place(g, ctx);
1708 zgc->allow_deny.popup = e_comp_object_util_add(ctx, E_COMP_OBJECT_TYPE_NONE);
1709 evas_object_smart_callback_call(g, "gadget_popup", zgc->allow_deny.popup);
1710 evas_object_layer_set(zgc->allow_deny.popup, E_LAYER_POPUP);
1711 evas_object_show(zgc->allow_deny.popup);
1712}
1713
1619/* FIXME */ 1714/* FIXME */
1620static void 1715static void
1621gadget_save(void) 1716gadget_save(void)
diff --git a/src/gadgets/gadget.h b/src/gadgets/gadget.h
index 12a2842..29d70eb 100644
--- a/src/gadgets/gadget.h
+++ b/src/gadgets/gadget.h
@@ -61,7 +61,7 @@ Z_API Eina_Iterator *z_gadget_type_iterator_get(void);
61 61
62Z_API Evas_Object *z_gadget_util_layout_style_init(Evas_Object *g, Evas_Object *style); 62Z_API Evas_Object *z_gadget_util_layout_style_init(Evas_Object *g, Evas_Object *style);
63Z_API void z_gadget_util_ctxpopup_place(Evas_Object *g, Evas_Object *ctx); 63Z_API void z_gadget_util_ctxpopup_place(Evas_Object *g, Evas_Object *ctx);
64 64Z_API void z_gadget_util_allow_deny_ctxpopup(Evas_Object *g, const char *text, Evas_Smart_Cb allow_cb, Evas_Smart_Cb deny_cb, const void *data);
65 65
66Z_API Evas_Object *z_gadget_editor_add(Evas_Object *parent, Evas_Object *site); 66Z_API Evas_Object *z_gadget_editor_add(Evas_Object *parent, Evas_Object *site);
67#endif 67#endif
diff --git a/src/gadgets/wireless/connman.c b/src/gadgets/wireless/connman.c
index 1d46354..e17867b 100644
--- a/src/gadgets/wireless/connman.c
+++ b/src/gadgets/wireless/connman.c
@@ -11,6 +11,9 @@
11#define CONNMAN_AGENT_IFACE "net.connman.Agent" 11#define CONNMAN_AGENT_IFACE "net.connman.Agent"
12#define CONNMAN_AGENT_PATH "/org/enlightenment/connman/agent" 12#define CONNMAN_AGENT_PATH "/org/enlightenment/connman/agent"
13 13
14#define CONNMAN_SERVICE_TYPE_ITER(i) \
15 for ((i) = 0; (i) < CONNMAN_SERVICE_TYPE_LAST; (i)++)
16
14#define MILLI_PER_SEC 1000 17#define MILLI_PER_SEC 1000
15#define CONNMAN_CONNECTION_TIMEOUT 60 * MILLI_PER_SEC 18#define CONNMAN_CONNECTION_TIMEOUT 60 * MILLI_PER_SEC
16 19
@@ -97,6 +100,12 @@ typedef struct
97 Wireless_Network_IPv6_Privacy privacy; 100 Wireless_Network_IPv6_Privacy privacy;
98 } v6; 101 } v6;
99 } ip; 102 } ip;
103
104 /* Proxy */
105 unsigned int proxy_type;
106 Eina_Stringshare *proxy_url;
107 Eina_Array *proxy_servers;
108 Eina_Array *proxy_excludes;
100 Eina_Bool ipv6 : 1; 109 Eina_Bool ipv6 : 1;
101} Connman_Service; 110} Connman_Service;
102 111
@@ -185,7 +194,7 @@ _connman_update_technologies(void)
185 Eina_Bool avail[CONNMAN_SERVICE_TYPE_LAST]; 194 Eina_Bool avail[CONNMAN_SERVICE_TYPE_LAST];
186 int i; 195 int i;
187 196
188 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 197 CONNMAN_SERVICE_TYPE_ITER(i)
189 avail[i] = connman_technology[i].type > -1; 198 avail[i] = connman_technology[i].type > -1;
190 wireless_service_type_available_set(avail); 199 wireless_service_type_available_set(avail);
191} 200}
@@ -196,7 +205,7 @@ _connman_update_enabled_technologies(void)
196 Eina_Bool enabled[CONNMAN_SERVICE_TYPE_LAST]; 205 Eina_Bool enabled[CONNMAN_SERVICE_TYPE_LAST];
197 int i; 206 int i;
198 207
199 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 208 CONNMAN_SERVICE_TYPE_ITER(i)
200 enabled[i] = connman_technology[i].powered; 209 enabled[i] = connman_technology[i].powered;
201 wireless_service_type_enabled_set(enabled); 210 wireless_service_type_enabled_set(enabled);
202} 211}
@@ -375,6 +384,18 @@ _connman_service_free(Connman_Service *cs)
375 else 384 else
376 eina_stringshare_del(cs->ip.v4.netmask); 385 eina_stringshare_del(cs->ip.v4.netmask);
377 386
387 eina_stringshare_del(cs->proxy_url);
388
389 if (cs->proxy_servers)
390 while (eina_array_count(cs->proxy_servers))
391 eina_stringshare_del(eina_array_pop(cs->proxy_servers));
392 eina_array_free(cs->proxy_servers);
393
394 if (cs->proxy_excludes)
395 while (eina_array_count(cs->proxy_excludes))
396 eina_stringshare_del(eina_array_pop(cs->proxy_excludes));
397 eina_array_free(cs->proxy_excludes);
398
378 eina_stringshare_del(cs->name); 399 eina_stringshare_del(cs->name);
379 eina_stringshare_del(cs->path); 400 eina_stringshare_del(cs->path);
380 eldbus_signal_handler_del(cs->handler); 401 eldbus_signal_handler_del(cs->handler);
@@ -461,6 +482,8 @@ _connman_service_parse_prop_changed(Connman_Service *cs, const char *prop_name,
461 cs->method = WIRELESS_NETWORK_IPV4_METHOD_DHCP; 482 cs->method = WIRELESS_NETWORK_IPV4_METHOD_DHCP;
462 else if (!strcmp(val, "manual")) 483 else if (!strcmp(val, "manual"))
463 cs->method = WIRELESS_NETWORK_IPV4_METHOD_MANUAL; 484 cs->method = WIRELESS_NETWORK_IPV4_METHOD_MANUAL;
485 else if (!strcmp(val, "fixed"))
486 cs->method = WIRELESS_NETWORK_IPV4_METHOD_FIXED;
464 } 487 }
465 else if (!strcmp(name, "Address")) 488 else if (!strcmp(name, "Address"))
466 { 489 {
@@ -479,6 +502,67 @@ _connman_service_parse_prop_changed(Connman_Service *cs, const char *prop_name,
479 } 502 }
480 } 503 }
481 } 504 }
505 else if (!strcmp(prop_name, "Proxy"))
506 {
507 Eldbus_Message_Iter *array, *dict;
508
509 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value, "a{sv}", &array));
510 while (eldbus_message_iter_get_and_next(array, 'e', &dict))
511 {
512 Eldbus_Message_Iter *var;
513 const char *name, *val;
514
515 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(dict, "sv", &name, &var));
516 if (!strcmp(name, "Method"))
517 {
518 cs->proxy_type = WIRELESS_PROXY_TYPE_DIRECT;
519 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
520 if (!strcmp(val, "manual"))
521 cs->proxy_type = WIRELESS_PROXY_TYPE_MANUAL;
522 else if (!strcmp(val, "auto"))
523 cs->proxy_type = WIRELESS_PROXY_TYPE_AUTO;
524 }
525 else if (!strcmp(name, "URL"))
526 {
527 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
528 eina_stringshare_replace(&cs->proxy_url, val);
529 }
530 else if (!strcmp(name, "Servers"))
531 {
532 Eldbus_Message_Iter *itr_array;
533 const char *s;
534
535 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value, "as",
536 &itr_array));
537 if (cs->proxy_servers)
538 {
539 while (eina_array_count(cs->proxy_servers))
540 eina_stringshare_del(eina_array_pop(cs->proxy_servers));
541 }
542 else
543 cs->proxy_servers = eina_array_new(1);
544 while (eldbus_message_iter_get_and_next(itr_array, 's', &s))
545 eina_array_push(cs->proxy_servers, eina_stringshare_add(s));
546 }
547 else if (!strcmp(name, "Excludes"))
548 {
549 Eldbus_Message_Iter *itr_array;
550 const char *s;
551
552 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value, "as",
553 &itr_array));
554 if (cs->proxy_excludes)
555 {
556 while (eina_array_count(cs->proxy_excludes))
557 eina_stringshare_del(eina_array_pop(cs->proxy_excludes));
558 }
559 else
560 cs->proxy_excludes = eina_array_new(1);
561 while (eldbus_message_iter_get_and_next(itr_array, 's', &s))
562 eina_array_push(cs->proxy_excludes, eina_stringshare_add(s));
563 }
564 }
565 }
482} 566}
483 567
484static void 568static void
@@ -583,7 +667,7 @@ _connman_technology_event_property(void *data, const Eldbus_Message *msg)
583 Connman_Technology *ct = NULL; 667 Connman_Technology *ct = NULL;
584 int i; 668 int i;
585 669
586 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 670 CONNMAN_SERVICE_TYPE_ITER(i)
587 if (data == connman_technology[i].proxy) 671 if (data == connman_technology[i].proxy)
588 { 672 {
589 ct = &connman_technology[i]; 673 ct = &connman_technology[i];
@@ -660,7 +744,7 @@ _connman_manager_getservices(void *data EINA_UNUSED, const Eldbus_Message *msg,
660 Eina_Bool update[CONNMAN_SERVICE_TYPE_LAST] = {0}; 744 Eina_Bool update[CONNMAN_SERVICE_TYPE_LAST] = {0};
661 745
662 pending_getservices = NULL; 746 pending_getservices = NULL;
663 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 747 CONNMAN_SERVICE_TYPE_ITER(i)
664 eina_hash_free_buckets(connman_services[i]); 748 eina_hash_free_buckets(connman_services[i]);
665 if (eldbus_message_error_get(msg, &name, &text)) 749 if (eldbus_message_error_get(msg, &name, &text))
666 { 750 {
@@ -686,7 +770,7 @@ _connman_manager_getservices(void *data EINA_UNUSED, const Eldbus_Message *msg,
686 cs = _connman_service_new(path, inner_array); 770 cs = _connman_service_new(path, inner_array);
687 update[cs->type] = 1; 771 update[cs->type] = 1;
688 } 772 }
689 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 773 CONNMAN_SERVICE_TYPE_ITER(i)
690 if (update[i]) _connman_update_networks(i); 774 if (update[i]) _connman_update_networks(i);
691} 775}
692 776
@@ -726,7 +810,7 @@ _connman_manager_gettechnologies(void *data EINA_UNUSED, const Eldbus_Message *m
726 810
727 if (!eldbus_message_iter_arguments_get(s, "oa{sv}", &path, &inner_array)) 811 if (!eldbus_message_iter_arguments_get(s, "oa{sv}", &path, &inner_array))
728 continue; 812 continue;
729 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 813 CONNMAN_SERVICE_TYPE_ITER(i)
730 { 814 {
731 if (strcmp(path, paths[i])) continue; 815 if (strcmp(path, paths[i])) continue;
732 ct = &connman_technology[i]; 816 ct = &connman_technology[i];
@@ -779,7 +863,7 @@ _connman_manager_event_services(void *data EINA_UNUSED, const Eldbus_Message *ms
779 863
780 while (eldbus_message_iter_get_and_next(removed, 'o', &path)) 864 while (eldbus_message_iter_get_and_next(removed, 'o', &path))
781 { 865 {
782 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 866 CONNMAN_SERVICE_TYPE_ITER(i)
783 { 867 {
784 if (!eina_hash_del_by_key(connman_services[i], path)) continue; 868 if (!eina_hash_del_by_key(connman_services[i], path)) continue;
785 DBG("Removed service: %s", path); 869 DBG("Removed service: %s", path);
@@ -797,7 +881,7 @@ _connman_manager_event_services(void *data EINA_UNUSED, const Eldbus_Message *ms
797 if (!eldbus_message_iter_arguments_get(s, "oa{sv}", &path, &array)) 881 if (!eldbus_message_iter_arguments_get(s, "oa{sv}", &path, &array))
798 continue; 882 continue;
799 883
800 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 884 CONNMAN_SERVICE_TYPE_ITER(i)
801 { 885 {
802 cs = eina_hash_find(connman_services[i], path); 886 cs = eina_hash_find(connman_services[i], path);
803 if (!cs) continue; 887 if (!cs) continue;
@@ -812,7 +896,7 @@ _connman_manager_event_services(void *data EINA_UNUSED, const Eldbus_Message *ms
812 update[cs->type] = 1; 896 update[cs->type] = 1;
813 } 897 }
814 } 898 }
815 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 899 CONNMAN_SERVICE_TYPE_ITER(i)
816 if (update[i]) _connman_update_networks(i); 900 if (update[i]) _connman_update_networks(i);
817} 901}
818 902
@@ -849,10 +933,28 @@ _connman_agent_report_error(const Eldbus_Service_Interface *iface EINA_UNUSED,
849} 933}
850 934
851static Eldbus_Message * 935static Eldbus_Message *
852_connman_agent_request_browser(const Eldbus_Service_Interface *iface EINA_UNUSED, 936_connman_agent_request_browser(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
853 const Eldbus_Message *msg EINA_UNUSED)
854{ 937{
855#warning FIXME 938 const char *path, *url;
939 int i;
940 Connman_Service *cs;
941 Wireless_Network *wn;
942
943 if (!eldbus_message_arguments_get(msg, "ss", &path, &url))
944 {
945 ERR("Could not parse message %p", msg);
946 return NULL;
947 }
948
949 CONNMAN_SERVICE_TYPE_ITER(i)
950 {
951 cs = eina_hash_find(connman_services[i], path);
952 if (cs) break;
953 }
954 if (!cs) return NULL;
955 wn = eina_hash_find(connman_services_map[i], &cs);
956 EINA_SAFETY_ON_NULL_RETURN_VAL(wn, NULL);
957 wireless_authenticate_external(wn, url);
856 return NULL; 958 return NULL;
857} 959}
858 960
@@ -1084,7 +1186,7 @@ _connman_start(void)
1084 Eldbus_Object *obj; 1186 Eldbus_Object *obj;
1085 int i; 1187 int i;
1086 1188
1087 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 1189 CONNMAN_SERVICE_TYPE_ITER(i)
1088 connman_services[i] = eina_hash_string_superfast_new((Eina_Free_Cb)_connman_service_free); 1190 connman_services[i] = eina_hash_string_superfast_new((Eina_Free_Cb)_connman_service_free);
1089 1191
1090 obj = eldbus_object_get(dbus_conn, CONNMAN_BUS_NAME, "/"); 1192 obj = eldbus_object_get(dbus_conn, CONNMAN_BUS_NAME, "/");
@@ -1115,7 +1217,7 @@ _connman_end(Eina_Bool killed)
1115 if (!proxy_manager) return; 1217 if (!proxy_manager) return;
1116 eldbus_proxy_call(proxy_manager, "UnregisterAgent", NULL, NULL, -1, "o", CONNMAN_AGENT_PATH); 1218 eldbus_proxy_call(proxy_manager, "UnregisterAgent", NULL, NULL, -1, "o", CONNMAN_AGENT_PATH);
1117 1219
1118 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 1220 CONNMAN_SERVICE_TYPE_ITER(i)
1119 { 1221 {
1120 E_FREE_FUNC(connman_services[i], eina_hash_free); 1222 E_FREE_FUNC(connman_services[i], eina_hash_free);
1121 if (!connman_technology[i].proxy) continue; 1223 if (!connman_technology[i].proxy) continue;
@@ -1147,7 +1249,7 @@ connman_init(void)
1147 int i; 1249 int i;
1148 1250
1149 if (_connman_log_dom > -1) return; 1251 if (_connman_log_dom > -1) return;
1150 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 1252 CONNMAN_SERVICE_TYPE_ITER(i)
1151 connman_technology[i].type = -1; 1253 connman_technology[i].type = -1;
1152 eldbus_name_owner_changed_callback_add(dbus_conn, CONNMAN_BUS_NAME, 1254 eldbus_name_owner_changed_callback_add(dbus_conn, CONNMAN_BUS_NAME,
1153 _connman_name_owner_changed, 1255 _connman_name_owner_changed,
@@ -1159,7 +1261,7 @@ EINTERN void
1159connman_shutdown(void) 1261connman_shutdown(void)
1160{ 1262{
1161 int i; 1263 int i;
1162 for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++) 1264 CONNMAN_SERVICE_TYPE_ITER(i)
1163 { 1265 {
1164 E_FREE_FUNC(connman_services_map[i], eina_hash_free); 1266 E_FREE_FUNC(connman_services_map[i], eina_hash_free);
1165 E_FREE(connman_current_connection[i]); 1267 E_FREE(connman_current_connection[i]);
@@ -1187,3 +1289,58 @@ connman_technology_enabled_set(Wireless_Service_Type type, Eina_Bool state)
1187 1289
1188 eldbus_proxy_send(connman_technology[type].proxy, msg, NULL, NULL, -1); 1290 eldbus_proxy_send(connman_technology[type].proxy, msg, NULL, NULL, -1);
1189} 1291}
1292
1293static void
1294_connman_service_edit_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
1295{
1296 const char *name, *text;
1297 if (eldbus_message_error_get(msg, &name, &text))
1298 {
1299 ERR("Could not set properties. %s: %s", name, text);
1300 }
1301}
1302
1303EINTERN void
1304connman_service_edit(const char *path, Wireless_Connection *wc)
1305{
1306 int i;
1307 Eldbus_Proxy *proxy;
1308 Eldbus_Message *msg;
1309 Eldbus_Message_Iter *iter, *variant, *array;
1310 Connman_Service *cs = NULL;
1311 const char *prop[] =
1312 {
1313 "IPv4.Configuration",
1314 "IPv6.Configuration",
1315 };
1316 const char *method[] =
1317 {
1318 "off",
1319 "manual",
1320 "dhcp",
1321 "fixed",
1322 };
1323
1324 CONNMAN_SERVICE_TYPE_ITER(i)
1325 {
1326 cs = eina_hash_find(connman_services[i], path);
1327 if (cs) break;
1328 }
1329 EINA_SAFETY_ON_NULL_RETURN(cs);
1330
1331 msg = eldbus_proxy_method_call_new(cs->proxy, "SetProperty");
1332 iter = eldbus_message_iter_get(msg);
1333 eldbus_message_iter_basic_append(iter, 's', prop[cs->ipv6]);
1334 variant = eldbus_message_iter_container_new(iter, 'v', "a{sv}");
1335 eldbus_message_iter_arguments_append(variant, "a{sv}", &array);
1336 _connman_agent_auth_dict_append_basic(array, "Method", method[wc->method]);
1337 _connman_agent_auth_dict_append_basic(array, "Address", wc->address);
1338 _connman_agent_auth_dict_append_basic(array, "Gateway", wc->gateway);
1339 if (wc->ipv6){}//FIXME
1340 else
1341 _connman_agent_auth_dict_append_basic(array, "Netmask", wc->ip.v4.netmask);
1342 eldbus_message_iter_container_close(variant, array);
1343 eldbus_message_iter_container_close(iter, variant);
1344
1345 eldbus_proxy_send(cs->proxy, msg, _connman_service_edit_cb, NULL, -1);
1346}
diff --git a/src/gadgets/wireless/wireless.c b/src/gadgets/wireless/wireless.c
index 1036a92..aa427f3 100644
--- a/src/gadgets/wireless/wireless.c
+++ b/src/gadgets/wireless/wireless.c
@@ -8,6 +8,21 @@ static const char *wireless_theme_groups[] =
8 [WIRELESS_SERVICE_TYPE_CELLULAR] = "e/modules/wireless/cellular", 8 [WIRELESS_SERVICE_TYPE_CELLULAR] = "e/modules/wireless/cellular",
9}; 9};
10 10
11static const char *wireless_ipv4_methods[] =
12{
13 "Disabled",
14 "Manual",
15 "DHCP",
16 "Fixed",
17};
18
19static const char *wireless_proxy_methods[] =
20{
21 "Direct",
22 "Manual",
23 "Auto",
24};
25
11typedef struct Instance 26typedef struct Instance
12{ 27{
13 Z_Gadget_Site_Orient orient; 28 Z_Gadget_Site_Orient orient;
@@ -47,6 +62,12 @@ static Eina_List *instances;
47static Eina_List *wireless_auth_pending; 62static Eina_List *wireless_auth_pending;
48static Wireless_Auth_Popup *wireless_auth_popup; 63static Wireless_Auth_Popup *wireless_auth_popup;
49 64
65static Eina_List *wireless_edit_proxy_entries;
66static Eina_List *wireless_edit_entries;
67static Evas_Object *wireless_edit_popup;
68static Wireless_Connection *wireless_edit[2];
69
70static Eina_Bool auth_popup;
50 71
51#undef DBG 72#undef DBG
52#undef INF 73#undef INF
@@ -181,6 +202,354 @@ _wireless_popup_key(void *d EINA_UNUSED, Ecore_Event_Key *ev)
181} 202}
182 203
183static void 204static void
205_wireless_edit_entries_update(void)
206{
207 Eina_List *l;
208 Evas_Object *ent;
209
210 if (wireless_edit[1]->ipv6){}//FIXME
211 else
212 {
213 switch (wireless_edit[1]->method)
214 {
215 case WIRELESS_NETWORK_IPV4_METHOD_MANUAL:
216 EINA_LIST_FOREACH(wireless_edit_entries, l, ent)
217 elm_object_disabled_set(ent, 0);
218 break;
219 case WIRELESS_NETWORK_IPV4_METHOD_OFF:
220 case WIRELESS_NETWORK_IPV4_METHOD_DHCP:
221 case WIRELESS_NETWORK_IPV4_METHOD_FIXED:
222 EINA_LIST_FOREACH(wireless_edit_entries, l, ent)
223 elm_object_disabled_set(ent, 1);
224 break;
225 }
226 }
227}
228
229static void
230_wireless_edit_proxy_entries_update(void)
231{
232 Eina_List *l;
233 Evas_Object *ent;
234
235 switch (wireless_edit[1]->proxy_type)
236 {
237 case WIRELESS_PROXY_TYPE_MANUAL:
238 case WIRELESS_PROXY_TYPE_AUTO:
239 EINA_LIST_FOREACH(wireless_edit_proxy_entries, l, ent)
240 elm_object_disabled_set(ent, 0);
241 break;
242 case WIRELESS_PROXY_TYPE_DIRECT:
243 EINA_LIST_FOREACH(wireless_edit_proxy_entries, l, ent)
244 elm_object_disabled_set(ent, 1);
245 break;
246 }
247}
248
249static void
250_wireless_gadget_edit_proxy_method(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
251{
252 wireless_edit[1]->proxy_type = (intptr_t)elm_object_item_data_get(event_info);
253 _wireless_edit_proxy_entries_update();
254}
255
256static void
257_wireless_gadget_edit_method(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
258{
259 wireless_edit[1]->method = (intptr_t)elm_object_item_data_get(event_info);
260 _wireless_edit_entries_update();
261}
262
263/* FIXME combine with other row fn */
264static Evas_Object *
265_wireless_edit_table_entry_row(Evas_Object *tb, const char *name, Evas_Smart_Cb cb, void *data, int *row)
266{
267 Evas_Object *fr, *entry;
268
269 fr = elm_frame_add(tb);
270 evas_object_show(fr);
271 E_EXPAND(fr);
272 E_FILL(fr);
273 elm_object_text_set(fr, name);
274 elm_table_pack(tb, fr, 0, *row, 2, 2);
275 *row += 2;
276
277 entry = elm_entry_add(tb);
278 evas_object_show(entry);
279 elm_entry_single_line_set(entry, 1);
280 evas_object_data_set(entry, "table", tb);
281 evas_object_smart_callback_add(entry, "activated", cb, data);
282 elm_object_content_set(fr, entry);
283 return entry;
284}
285
286static void
287_wireless_edit_entry_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
288{
289 Eina_Stringshare **str = data;
290
291 eina_stringshare_replace(str, elm_entry_entry_get(obj));
292}
293
294static void
295_wireless_edit_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
296{
297 int i;
298
299 wireless_edit_entries = eina_list_free(wireless_edit_entries);
300 wireless_edit_proxy_entries = eina_list_free(wireless_edit_proxy_entries);
301 eina_stringshare_del(wireless_edit[0]->wn->path);
302 free(wireless_edit[0]->wn);
303 for (i = 0; i <= 1; i++)
304 {
305 eina_stringshare_del(wireless_edit[i]->address);
306 eina_stringshare_del(wireless_edit[i]->gateway);
307 if (wireless_edit[i]->ipv6)
308 eina_stringshare_del(wireless_edit[i]->ip.v6.prefixlength);
309 else
310 eina_stringshare_del(wireless_edit[i]->ip.v4.netmask);
311 eina_stringshare_del(wireless_edit[i]->proxy_url);
312 if (wireless_edit[i]->proxy_excludes)
313 while (eina_array_count(wireless_edit[i]->proxy_excludes))
314 eina_stringshare_del(eina_array_pop(wireless_edit[i]->proxy_excludes));
315 eina_array_free(wireless_edit[i]->proxy_excludes);
316 if (wireless_edit[i]->proxy_servers)
317 while (eina_array_count(wireless_edit[i]->proxy_servers))
318 eina_stringshare_del(eina_array_pop(wireless_edit[i]->proxy_servers));
319 eina_array_free(wireless_edit[i]->proxy_servers);
320 E_FREE(wireless_edit[i]);
321 }
322 wireless_edit_popup = NULL;
323}
324
325static void
326_wireless_edit_send()
327{
328 EINTERN void connman_service_edit(const char *path, Wireless_Connection *wc);
329 connman_service_edit(wireless_edit[1]->wn->path, wireless_edit[1]);
330}
331
332static Eina_Bool
333_wireless_edit_key(void *d EINA_UNUSED, Ecore_Event_Key *ev)
334{
335 if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")))
336 {
337 _wireless_edit_send();
338 return EINA_FALSE;
339 }
340 return strcmp(ev->key, "Escape");
341}
342
343static Evas_Object *
344_wireless_edit_method(Evas_Object *popup, Evas_Object *box, Wireless_Connection *wc)
345{
346 Evas_Object *tb, *fr, *hoversel, *entry, *ent;
347 int i, row = 0;
348
349 tb = elm_table_add(popup);
350 E_FILL(tb);
351 evas_object_show(tb);
352 elm_box_pack_end(box, tb);
353
354 fr = elm_frame_add(tb);
355 E_EXPAND(fr);
356 E_FILL(fr);
357 evas_object_show(fr);
358 elm_object_text_set(fr, "Method");
359 elm_table_pack(tb, fr, 0, row++, 2, 1);
360
361 hoversel = elm_hoversel_add(tb);
362 elm_hoversel_hover_parent_set(hoversel, popup);
363 elm_hoversel_auto_update_set(hoversel, 1);
364 evas_object_show(hoversel);
365 elm_object_content_set(fr, hoversel);
366 evas_object_smart_callback_add(hoversel, "selected", _wireless_gadget_edit_method, NULL);
367 if (wc->ipv6){}//FIXME
368 else
369 {
370 elm_object_text_set(hoversel, wireless_ipv4_methods[wc->method]);
371 for (i = 0; i <= WIRELESS_NETWORK_IPV4_METHOD_FIXED; i++)
372 {
373 if ((int)wc->method != i)
374 elm_hoversel_item_add(hoversel, wireless_ipv4_methods[i], NULL, ELM_ICON_NONE, NULL, (intptr_t*)(long)i);
375 }
376 }
377
378 ent = entry = _wireless_edit_table_entry_row(tb, "Address", NULL, NULL, &row);
379 wireless_edit_entries = eina_list_append(wireless_edit_entries, ent);
380 elm_entry_entry_set(ent, wc->address);
381 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->address);
382 if (wc->ipv6)
383 {
384 ent = _wireless_edit_table_entry_row(tb, "PrefixLength", NULL, NULL, &row);
385 elm_entry_entry_set(ent, wc->ip.v6.prefixlength);
386 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->ip.v6.prefixlength);
387 }
388 else
389 {
390 ent = _wireless_edit_table_entry_row(tb, "Netmask", NULL, NULL, &row);
391 elm_entry_entry_set(ent, wc->ip.v4.netmask);
392 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->ip.v4.netmask);
393 }
394 wireless_edit_entries = eina_list_append(wireless_edit_entries, ent);
395 ent = _wireless_edit_table_entry_row(tb, "Gateway", NULL, NULL, &row);
396 elm_entry_entry_set(ent, wc->gateway);
397 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->gateway);
398 wireless_edit_entries = eina_list_append(wireless_edit_entries, ent);
399 _wireless_edit_entries_update();
400 return entry;
401}
402static void
403_wireless_edit_proxy(Evas_Object *popup, Evas_Object *box, Wireless_Connection *wc)
404{
405 Evas_Object *tb, *fr, *hoversel, *ent;
406 int i, row = 0;
407
408 tb = elm_table_add(popup);
409 E_FILL(tb);
410 evas_object_show(tb);
411 elm_box_pack_end(box, tb);
412
413 fr = elm_frame_add(tb);
414 E_EXPAND(fr);
415 E_FILL(fr);
416 evas_object_show(fr);
417 elm_object_text_set(fr, "Proxy Type");
418 elm_table_pack(tb, fr, 0, row++, 2, 1);
419
420 hoversel = elm_hoversel_add(tb);
421 elm_hoversel_hover_parent_set(hoversel, popup);
422 elm_hoversel_auto_update_set(hoversel, 1);
423 evas_object_show(hoversel);
424 elm_object_content_set(fr, hoversel);
425 evas_object_smart_callback_add(hoversel, "selected", _wireless_gadget_edit_proxy_method, NULL);
426 if (wc->ipv6){}//FIXME
427 else
428 {
429 elm_object_text_set(hoversel, wireless_proxy_methods[wc->proxy_type]);
430 for (i = 0; i <= WIRELESS_PROXY_TYPE_AUTO; i++)
431 {
432 if ((int)wc->proxy_type != i)
433 elm_hoversel_item_add(hoversel, wireless_proxy_methods[i], NULL, ELM_ICON_NONE, NULL, (intptr_t*)(long)i);
434 }
435 }
436
437 ent = _wireless_edit_table_entry_row(tb, "Proxy Address", NULL, NULL, &row);
438 wireless_edit_proxy_entries = eina_list_append(wireless_edit_proxy_entries, ent);
439 elm_entry_entry_set(ent, wc->proxy_url);
440 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->address);
441 if (wc->ipv6)
442 {
443 ent = _wireless_edit_table_entry_row(tb, "PrefixLength", NULL, NULL, &row);
444 elm_entry_entry_set(ent, wc->ip.v6.prefixlength);
445 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->ip.v6.prefixlength);
446 }
447 else
448 {
449 ent = _wireless_edit_table_entry_row(tb, "Netmask", NULL, NULL, &row);
450 elm_entry_entry_set(ent, wc->ip.v4.netmask);
451 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->ip.v4.netmask);
452 }
453 wireless_edit_proxy_entries = eina_list_append(wireless_edit_proxy_entries, ent);
454 ent = _wireless_edit_table_entry_row(tb, "Gateway", NULL, NULL, &row);
455 elm_entry_entry_set(ent, wc->gateway);
456 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->gateway);
457 wireless_edit_proxy_entries = eina_list_append(wireless_edit_proxy_entries, ent);
458 _wireless_edit_proxy_entries_update();
459}
460
461static void
462_wireless_gadget_edit(Instance *inst, int type)
463{
464 Evas_Object *popup, *lbl, *entry, *bt, *box;
465 int i;
466 char buf[1024] = {0};
467 Wireless_Connection *wc = wireless_current[type];
468 Wireless_Network *wn;
469
470 if (!wc) return;//FIXME: possible?
471 wireless_edit[0] = E_NEW(Wireless_Connection, 1);
472 wireless_edit[1] = E_NEW(Wireless_Connection, 1);
473 wn = E_NEW(Wireless_Network, 1);
474 wn->path = eina_stringshare_ref(wc->wn->path);
475 for (i = 0; i <= 1; i++)
476 {
477 Eina_Array *arrays[] =
478 { wc->proxy_servers, wc->proxy_excludes, NULL };
479 Eina_Array **arrays2[] =
480 { &wireless_edit[i]->proxy_servers, &wireless_edit[i]->proxy_excludes, NULL };
481 unsigned int ii;
482
483 wireless_edit[i]->wn = wn;
484 wireless_edit[i]->method = wc->method;
485 wireless_edit[i]->address = eina_stringshare_ref(wc->address);
486 wireless_edit[i]->gateway = eina_stringshare_ref(wc->gateway);
487 wireless_edit[i]->ipv6 = wc->ipv6;
488 if (wc->ipv6)
489 {
490 wireless_edit[i]->ip.v6.prefixlength = eina_stringshare_ref(wc->ip.v6.prefixlength);
491 wireless_edit[i]->ip.v6.privacy = wc->ip.v6.privacy;
492 }
493 else
494 wireless_edit[i]->ip.v4.netmask = eina_stringshare_ref(wc->ip.v4.netmask);
495 wireless_edit[i]->proxy_type = wc->proxy_type;
496 wireless_edit[i]->proxy_url = eina_stringshare_ref(wc->proxy_url);
497 /* fuuuuck thiiiiiiis */
498 for (ii = 0; ii < EINA_C_ARRAY_LENGTH(arrays); ii++)
499 {
500 unsigned int iii;
501 Eina_Stringshare *str;
502 Eina_Array_Iterator itr;
503
504 if (!arrays[ii]) continue;
505 *arrays2[ii] = eina_array_new(eina_array_count(arrays[ii]));
506 EINA_ARRAY_ITER_NEXT(arrays[ii], iii, str, itr)
507 eina_array_push(*arrays2[ii], eina_stringshare_ref(str));
508 }
509 }
510
511 popup = elm_popup_add(e_comp->elm);
512 evas_object_layer_set(popup, E_LAYER_MENU);
513 elm_popup_allow_events_set(popup, 1);
514 elm_popup_scrollable_set(popup, 1);
515
516 box = elm_box_add(popup);
517 E_EXPAND(box);
518 E_FILL(box);
519 evas_object_show(box);
520 elm_object_content_set(popup, box);
521
522 lbl = elm_label_add(popup);
523 elm_object_style_set(lbl, "marker");
524 evas_object_show(lbl);
525 if (type == WIRELESS_SERVICE_TYPE_ETHERNET)
526 strncpy(buf, "Edit Connection Details: Ethernet", sizeof(buf) - 1);
527 else
528 snprintf(buf, sizeof(buf), "Edit Connection Details: <hilight>%s</hilight>", wc->wn->name);
529 elm_object_text_set(lbl, buf);
530 elm_box_pack_end(box, lbl);
531
532 entry = _wireless_edit_method(popup, box, wc);
533 //_wireless_edit_proxy(popup, box, wc);
534
535 bt = elm_button_add(box);
536 E_EXPAND(bt);
537 E_FILL(bt);
538 evas_object_show(bt);
539 elm_object_text_set(bt, "Okay");
540 evas_object_smart_callback_add(bt, "clicked", _wireless_edit_send, NULL);
541 elm_box_pack_end(box, bt);
542
543 wireless_edit_popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE);
544 evas_object_resize(wireless_edit_popup, e_zone_current_get()->w / 3, e_zone_current_get()->h / 2);
545 e_comp_object_util_center(wireless_edit_popup);
546 evas_object_show(wireless_edit_popup);
547 e_comp_object_util_autoclose(wireless_edit_popup, NULL, _wireless_edit_key, NULL);
548 evas_object_event_callback_add(wireless_edit_popup, EVAS_CALLBACK_DEL, _wireless_edit_del, NULL);
549 elm_object_focus_set(entry, 1);
550}
551
552static void
184_wireless_gadget_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info) 553_wireless_gadget_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info)
185{ 554{
186 Evas_Event_Mouse_Down *ev = event_info; 555 Evas_Event_Mouse_Down *ev = event_info;
@@ -196,10 +565,12 @@ _wireless_gadget_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, v
196 "Cellular", 565 "Cellular",
197 }; 566 };
198 567
199 if (ev->button != 1) return; 568 if (auth_popup) return;
200 for (type = 0; type < WIRELESS_SERVICE_TYPE_LAST; type++) 569 for (type = 0; type < WIRELESS_SERVICE_TYPE_LAST; type++)
201 if (obj == inst->icon[type]) 570 if (obj == inst->icon[type])
202 break; 571 break;
572 if (ev->button == 3) _wireless_gadget_edit(inst, type);
573 if (ev->button != 1) return;
203 if (inst->popup.popup) 574 if (inst->popup.popup)
204 { 575 {
205 evas_object_hide(inst->popup.popup); 576 evas_object_hide(inst->popup.popup);
@@ -236,9 +607,9 @@ _wireless_gadget_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, v
236 elm_box_pack_end(box, toggle); 607 elm_box_pack_end(box, toggle);
237 elm_object_content_set(ctx, box); 608 elm_object_content_set(ctx, box);
238 z_gadget_util_ctxpopup_place(inst->box, ctx); 609 z_gadget_util_ctxpopup_place(inst->box, ctx);
239 evas_object_smart_callback_call(inst->box, "gadget_popup", ctx);
240 inst->popup.popup = e_comp_object_util_add(ctx, E_COMP_OBJECT_TYPE_NONE); 610 inst->popup.popup = e_comp_object_util_add(ctx, E_COMP_OBJECT_TYPE_NONE);
241 evas_object_layer_set(inst->popup.popup, E_LAYER_MENU); 611 evas_object_smart_callback_call(inst->box, "gadget_popup", inst->popup.popup);
612 evas_object_layer_set(inst->popup.popup, E_LAYER_POPUP);
242 e_comp_object_util_autoclose(inst->popup.popup, NULL, _wireless_popup_key, NULL); 613 e_comp_object_util_autoclose(inst->popup.popup, NULL, _wireless_popup_key, NULL);
243 614
244 zone = e_zone_current_get(); 615 zone = e_zone_current_get();
@@ -585,11 +956,11 @@ _wireless_auth_send(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
585 if (!arr) arr = eina_array_new(2); 956 if (!arr) arr = eina_array_new(2);
586 txt = elm_object_text_get(o); 957 txt = elm_object_text_get(o);
587 eina_array_push(arr, txt); 958 eina_array_push(arr, txt);
588 o = elm_table_child_get(tb, 1, row); 959 o = elm_object_content_get(o);
589 /* skip checkboxes */ 960 /* skip checkboxes */
590 if (!strncmp(txt, "Pass", 4)) row++; 961 if (!strncmp(txt, "Pass", 4)) row++;
591 eina_array_push(arr, elm_object_text_get(o)); 962 eina_array_push(arr, elm_object_text_get(o));
592 row++; 963 row += 2;
593 } while (1); 964 } while (1);
594 p->cb(p->data, arr); 965 p->cb(p->data, arr);
595 p->sent = 1; 966 p->sent = 1;
@@ -599,23 +970,23 @@ _wireless_auth_send(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
599static Evas_Object * 970static Evas_Object *
600_wireless_auth_table_row(Evas_Object *tb, const char *name, Wireless_Auth_Popup *p, int *row) 971_wireless_auth_table_row(Evas_Object *tb, const char *name, Wireless_Auth_Popup *p, int *row)
601{ 972{
602 Evas_Object *lbl, *entry, *ck; 973 Evas_Object *fr, *entry, *ck;
603 char buf[1024]; 974 char buf[1024];
604 975
605 lbl = elm_label_add(tb); 976 fr = elm_frame_add(tb);
606 evas_object_show(lbl); 977 evas_object_show(fr);
607 E_ALIGN(lbl, 0, -1); 978 E_EXPAND(fr);
608 elm_object_text_set(lbl, name); 979 E_FILL(fr);
609 elm_table_pack(tb, lbl, 0, *row, 1, 1); 980 elm_object_text_set(fr, name);
981 elm_table_pack(tb, fr, 0, *row, 2, 2);
982 *row += 2;
610 983
611 entry = elm_entry_add(tb); 984 entry = elm_entry_add(tb);
612 evas_object_show(entry); 985 evas_object_show(entry);
613 E_ALIGN(entry, -1, -1);
614 E_EXPAND(entry);
615 elm_entry_single_line_set(entry, 1); 986 elm_entry_single_line_set(entry, 1);
616 evas_object_data_set(entry, "table", tb); 987 evas_object_data_set(entry, "table", tb);
617 evas_object_smart_callback_add(entry, "activated", _wireless_auth_send, p); 988 evas_object_smart_callback_add(entry, "activated", _wireless_auth_send, p);
618 elm_table_pack(tb, entry, 1, *row, 1, 1); 989 elm_object_content_set(fr, entry);
619 if (strncmp(name, "Pass", 4)) return NULL; 990 if (strncmp(name, "Pass", 4)) return NULL;
620 elm_entry_password_set(entry, 1); 991 elm_entry_password_set(entry, 1);
621 992
@@ -624,7 +995,7 @@ _wireless_auth_table_row(Evas_Object *tb, const char *name, Wireless_Auth_Popup
624 E_ALIGN(ck, 0, -1); 995 E_ALIGN(ck, 0, -1);
625 snprintf(buf, sizeof(buf), "Show %s", name); 996 snprintf(buf, sizeof(buf), "Show %s", name);
626 elm_object_text_set(ck, buf); 997 elm_object_text_set(ck, buf);
627 elm_table_pack(tb, ck, 0, ++(*row), 2, 1); 998 elm_table_pack(tb, ck, 0, (*row)++, 2, 1);
628 return entry; 999 return entry;
629} 1000}
630 1001
@@ -669,7 +1040,6 @@ wireless_authenticate(const Eina_Array *fields, Wireless_Auth_Cb cb, void *data)
669 1040
670 o = _wireless_auth_table_row(tb, f, p, &row); 1041 o = _wireless_auth_table_row(tb, f, p, &row);
671 if (!entry) entry = o; 1042 if (!entry) entry = o;
672 row++;
673 } 1043 }
674 popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE); 1044 popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE);
675 p->popup = popup; 1045 p->popup = popup;
@@ -694,3 +1064,56 @@ wireless_authenticate_cancel(void)
694 evas_object_hide(wireless_auth_popup->popup); 1064 evas_object_hide(wireless_auth_popup->popup);
695 evas_object_del(wireless_auth_popup->popup); 1065 evas_object_del(wireless_auth_popup->popup);
696} 1066}
1067
1068static void
1069_wireless_auth_external_deny(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1070{
1071 /* FIXME */
1072 free(data);
1073 auth_popup = 0;
1074}
1075
1076static void
1077_wireless_auth_external_allow(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1078{
1079 char *sb, *uri = data;
1080 const char *bindir;
1081 size_t size = PATH_MAX, len;
1082
1083 bindir = e_prefix_bin_get();
1084 len = strlen(bindir);
1085 sb = malloc(size);
1086 snprintf(sb, size, "%s/enlightenment_open", bindir);
1087 sb = e_util_string_append_quoted(sb, &size, &len, uri);
1088 DBG("launched command: %s", sb);
1089 ecore_exe_run(sb, NULL);
1090 free(sb);
1091 free(uri);
1092 auth_popup = 0;
1093}
1094
1095EINTERN void
1096wireless_authenticate_external(Wireless_Network *wn, const char *url)
1097{
1098 char buf[1024];
1099 Eina_List *l;
1100 Instance *inst;
1101
1102 EINA_LIST_FOREACH(instances, l, inst)
1103 if (inst->popup.popup)
1104 {
1105 evas_object_hide(inst->popup.popup);
1106 evas_object_del(inst->popup.popup);
1107 }
1108 if (wn->type == WIRELESS_SERVICE_TYPE_ETHERNET)
1109 snprintf(buf, sizeof(buf), "Ethernet connection wants to open a url:<br>%s", url);
1110 else
1111 snprintf(buf, sizeof(buf), "Network '%s' wants to open a url:<br>%s", wn->name, url);
1112 EINA_LIST_FOREACH(instances, l, inst)
1113 {
1114 if (!inst->icon[wn->type]) continue;
1115 z_gadget_util_allow_deny_ctxpopup(inst->box, buf, _wireless_auth_external_allow, _wireless_auth_external_deny, strdup(url));
1116 auth_popup = 1;
1117 break;
1118 }
1119}
diff --git a/src/gadgets/wireless/wireless.h b/src/gadgets/wireless/wireless.h
index 55a80d6..4916fed 100644
--- a/src/gadgets/wireless/wireless.h
+++ b/src/gadgets/wireless/wireless.h
@@ -37,6 +37,7 @@ typedef enum
37 WIRELESS_NETWORK_IPV4_METHOD_OFF, 37 WIRELESS_NETWORK_IPV4_METHOD_OFF,
38 WIRELESS_NETWORK_IPV4_METHOD_MANUAL, 38 WIRELESS_NETWORK_IPV4_METHOD_MANUAL,
39 WIRELESS_NETWORK_IPV4_METHOD_DHCP, 39 WIRELESS_NETWORK_IPV4_METHOD_DHCP,
40 WIRELESS_NETWORK_IPV4_METHOD_FIXED,
40} Wireless_Network_IPv4_Method; 41} Wireless_Network_IPv4_Method;
41 42
42typedef enum 43typedef enum
@@ -54,6 +55,13 @@ typedef enum
54 WIRELESS_NETWORK_IPV6_PRIVACY_PREFERRED, 55 WIRELESS_NETWORK_IPV6_PRIVACY_PREFERRED,
55} Wireless_Network_IPv6_Privacy; 56} Wireless_Network_IPv6_Privacy;
56 57
58typedef enum
59{
60 WIRELESS_PROXY_TYPE_DIRECT,
61 WIRELESS_PROXY_TYPE_MANUAL,
62 WIRELESS_PROXY_TYPE_AUTO,
63} Wireless_Proxy_Type;
64
57typedef struct Wireless_Network Wireless_Network; 65typedef struct Wireless_Network Wireless_Network;
58 66
59typedef Eina_Bool (*Wireless_Network_Connect_Cb)(Wireless_Network *); 67typedef Eina_Bool (*Wireless_Network_Connect_Cb)(Wireless_Network *);
@@ -88,6 +96,10 @@ typedef struct Wireless_Connection
88 Wireless_Network_IPv6_Privacy privacy; 96 Wireless_Network_IPv6_Privacy privacy;
89 } v6; 97 } v6;
90 } ip; 98 } ip;
99 Wireless_Proxy_Type proxy_type;
100 Eina_Stringshare *proxy_url;
101 Eina_Array *proxy_servers;
102 Eina_Array *proxy_excludes;
91 Eina_Bool ipv6 : 1; 103 Eina_Bool ipv6 : 1;
92} Wireless_Connection; 104} Wireless_Connection;
93 105
@@ -102,4 +114,5 @@ EINTERN Eina_Array *wireless_wifi_networks_set(Eina_Array *networks);
102EINTERN void wireless_airplane_mode_set(Eina_Bool enabled); 114EINTERN void wireless_airplane_mode_set(Eina_Bool enabled);
103EINTERN void wireless_authenticate(const Eina_Array *fields, Wireless_Auth_Cb cb, void *data); 115EINTERN void wireless_authenticate(const Eina_Array *fields, Wireless_Auth_Cb cb, void *data);
104EINTERN void wireless_authenticate_cancel(void); 116EINTERN void wireless_authenticate_cancel(void);
117EINTERN void wireless_authenticate_external(Wireless_Network *wn, const char *url);
105#endif 118#endif