update for beta release
[framework/uifw/e17.git] / src / modules / wizard / page_110.c
1 /* Setup if we need connman? */
2 #include "e.h"
3 #include "e_mod_main.h"
4 #ifdef HAVE_ECONNMAN
5 #define E_CONNMAN_I_KNOW_THIS_API_IS_SUBJECT_TO_CHANGE 1
6 #include <connman0_7x/E_Connman.h>
7 #endif
8
9 static Ecore_Event_Handler *handler = NULL;
10 static Ecore_Timer *connman_timeout = NULL;
11
12 static void
13 _recommend_connman(E_Wizard_Page *pg)
14 {
15    Evas_Object *o, *of, *ob;
16    
17    o = e_widget_list_add(pg->evas, 1, 0);
18    e_wizard_title_set(_("Network Management"));
19
20    of = e_widget_framelist_add(pg->evas, 
21                                _("Connman network service not found"), 0);
22    
23    ob = e_widget_label_add
24       (pg->evas, _("Install Connman for network management support"));
25    e_widget_framelist_object_append(of, ob);
26    evas_object_show(ob);
27    
28    e_widget_list_object_append(o, of, 0, 0, 0.5);
29    evas_object_show(ob);
30    evas_object_show(of);
31    
32    e_wizard_page_show(o);
33 //   pg->data = o;
34    
35    e_wizard_button_next_enable_set(1);
36 }
37
38 #ifdef HAVE_ECONNMAN
39 static Eina_Bool
40 _connman_in(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
41 {
42    if (handler)
43      {
44         ecore_event_handler_del(handler);
45         handler = NULL;
46      }
47    if (connman_timeout)
48      {
49         ecore_timer_del(connman_timeout);
50         connman_timeout = NULL;
51      }
52    e_wizard_button_next_enable_set(1);
53    e_wizard_next();
54    return EINA_TRUE;
55 }
56
57 static Eina_Bool
58 _connman_timeout(void *data)
59 {
60    E_Wizard_Page *pg = data;
61    E_Config_Module *em;
62    Eina_List *l;
63    
64    EINA_LIST_FOREACH(e_config->modules, l, em)
65      {
66         if (!em->name) continue;
67         if (!strcmp(em->name, "connman"))
68           {
69              e_config->modules = eina_list_remove_list
70                 (e_config->modules, l);
71              if (em->name) eina_stringshare_del(em->name);
72              free(em);
73              break;
74           }
75      }
76    e_config_save_queue();
77    connman_timeout = NULL;
78    if (handler)
79      {
80         ecore_event_handler_del(handler);
81         handler = NULL;
82      }
83    _recommend_connman(pg);
84    return EINA_FALSE;
85 }
86 #endif
87
88 EAPI int
89 wizard_page_init(E_Wizard_Page *pg __UNUSED__)
90 {
91    return 1;
92 }
93
94 EAPI int
95 wizard_page_shutdown(E_Wizard_Page *pg __UNUSED__)
96 {
97    return 1;
98 }
99
100 EAPI int
101 wizard_page_show(E_Wizard_Page *pg)
102 {
103    int have_connman = 0;
104    E_DBus_Connection *c;
105    
106    c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
107    if (c)
108      {
109 #ifdef HAVE_ECONNMAN             
110         if (e_connman_system_init(c))
111           {
112              handler = ecore_event_handler_add
113                 (E_CONNMAN_EVENT_MANAGER_IN, _connman_in, NULL);
114              if (connman_timeout) ecore_timer_del(connman_timeout);
115              connman_timeout = ecore_timer_add(2.0, _connman_timeout, pg);
116              have_connman = 1;
117              e_wizard_button_next_enable_set(0);
118           }
119 #endif             
120      }
121    if (!have_connman)
122      {
123         E_Config_Module *em;
124         Eina_List *l;
125         
126         EINA_LIST_FOREACH(e_config->modules, l, em)
127           {
128              if (!em->name) continue;
129              if (!strcmp(em->name, "connman"))
130                {
131                   e_config->modules = eina_list_remove_list
132                      (e_config->modules, l);
133                   if (em->name) eina_stringshare_del(em->name);
134                   free(em);
135                   break;
136                }
137           }
138         e_config_save_queue();
139         _recommend_connman(pg);
140      }
141    e_wizard_title_set(_("Checking to see if Connman exists"));
142    return 1; /* 1 == show ui, and wait for user, 0 == just continue */
143 }
144
145 EAPI int
146 wizard_page_hide(E_Wizard_Page *pg __UNUSED__)
147 {
148    if (handler)
149      {
150         ecore_event_handler_del(handler);
151         handler = NULL;
152      }
153    if (connman_timeout)
154      {
155         ecore_timer_del(connman_timeout);
156         connman_timeout = NULL;
157      }
158 //   if (pg->data) evas_object_del(pg->data);
159    return 1;
160 }
161
162 EAPI int
163 wizard_page_apply(E_Wizard_Page *pg __UNUSED__)
164 {
165    return 1;
166 }