0731471a9a8467e84ef329105d748555c7a65fbf
[framework/uifw/e17.git] / src / modules / connman / e_mod_main.h
1 #ifndef E_MOD_MAIN_H
2 #define E_MOD_MAIN_H
3
4 #include "config.h"
5 #include <e.h>
6 #include <E_Connman.h>
7 #include <eina_log.h>
8
9 #define MOD_CONF_VERSION 2
10
11 extern int _e_connman_log_dom;
12 #define DBG(...) EINA_LOG_DOM_DBG(_e_connman_log_dom, __VA_ARGS__)
13 #define WRN(...) EINA_LOG_DOM_WARN(_e_connman_log_dom, __VA_ARGS__)
14 #define ERR(...) EINA_LOG_DOM_ERR(_e_connman_log_dom, __VA_ARGS__)
15
16 typedef struct E_Connman_Instance       E_Connman_Instance;
17 typedef struct E_Connman_Module_Context E_Connman_Module_Context;
18 typedef struct E_Connman_Service        E_Connman_Service;
19 typedef struct E_Connman_Technology     E_Connman_Technology;
20
21 struct E_Connman_Instance
22 {
23    E_Connman_Module_Context *ctxt;
24    E_Gadcon_Client          *gcc;
25    E_Gadcon_Popup           *popup;
26    E_Menu                   *menu;
27
28    /* used by popup */
29    int                       offline_mode;
30    const char               *service_path;
31    Eina_Bool                 first_selection;
32
33    struct
34    {
35       Evas_Object *gadget;
36       Evas_Object *list;
37       Evas_Object *offline_mode;
38       Evas_Object *button;
39       Evas_Object *table;
40       struct
41       {
42          Ecore_X_Window       win;
43          Ecore_Event_Handler *mouse_up;
44          Ecore_Event_Handler *key_down;
45       } input;
46    } ui;
47
48    E_Gadcon_Popup *tip;
49    Evas_Object    *o_tip;
50 };
51
52 struct E_Connman_Service
53 {
54                              EINA_INLIST;
55    E_Connman_Module_Context *ctxt;
56    E_Connman_Element        *element;
57    const char               *path;
58    const char               *name;
59    const char               *type;
60    const char               *mode;
61    const char               *state;
62    const char               *error;
63    const char               *security;
64    const char               *ipv4_method;
65    const char               *ipv4_address;
66    const char               *ipv4_netmask;
67    unsigned char             strength;
68    Eina_Bool                 favorite : 1;
69    Eina_Bool                 auto_connect : 1;
70    Eina_Bool                 pass_required : 1;
71 };
72
73 struct E_Connman_Technology
74 {
75                              EINA_INLIST;
76    E_Connman_Module_Context *ctxt;
77    E_Connman_Element        *element;
78    const char               *path;
79    const char               *name;
80    const char               *type;
81    const char               *state;
82 };
83
84 struct E_Connman_Module_Context
85 {
86    Eina_List       *instances;
87    E_Config_Dialog *conf_dialog;
88
89    struct st_connman_actions
90    {
91       E_Action *toggle_offline_mode;
92    } actions;
93
94    struct
95    {
96       Ecore_Event_Handler *manager_in;
97       Ecore_Event_Handler *manager_out;
98       Ecore_Event_Handler *mode_changed;
99    } event;
100
101    struct
102    {
103       Ecore_Poller *default_service_changed;
104       Ecore_Poller *manager_changed;
105    } poller;
106
107    Eina_Bool                has_manager : 1;
108    Eina_Bool                offline_mode;
109    Eina_Bool                offline_mode_pending;
110    const char              *technology;
111    const E_Connman_Service *default_service;
112    Eina_Inlist             *services;
113    Eina_Inlist             *technologies;
114 };
115
116 EAPI extern E_Module_Api e_modapi;
117 EAPI void       *e_modapi_init(E_Module *m);
118 EAPI int         e_modapi_shutdown(E_Module *m);
119 EAPI int         e_modapi_save(E_Module *m);
120
121 const char      *e_connman_theme_path(void);
122 E_Config_Dialog *e_connman_config_dialog_new(E_Container              *con,
123                                              E_Connman_Module_Context *ctxt);
124 void             _connman_toggle_offline_mode(E_Connman_Module_Context *ctxt);
125 Evas_Object     *_connman_service_new_list_item(Evas              *evas,
126                                                 E_Connman_Service *service);
127
128 static inline void
129 _connman_dbus_error_show(const char      *msg,
130                          const DBusError *error)
131 {
132    const char *name;
133
134    if ((!error) || (!dbus_error_is_set(error)))
135      return;
136
137    name = error->name;
138    if (strncmp(name, "org.moblin.connman.Error.",
139                sizeof("org.moblin.connman.Error.") - 1) == 0)
140      name += sizeof("org.moblin.connman.Error.") - 1;
141
142    e_util_dialog_show(_("Connman Server Operation Failed"),
143                       _("Could not execute remote operation:<br>"
144                         "%s<br>"
145                         "Server Error <hilight>%s:</hilight> %s"),
146                       msg, name, error->message);
147 }
148
149 static inline void
150 _connman_operation_error_show(const char *msg)
151 {
152    e_util_dialog_show(_("Connman Operation Failed"),
153                       _("Could not execute local operation:<br>%s"),
154                       msg);
155 }
156
157 static inline E_Connman_Service *
158 _connman_ctxt_find_service_stringshare(const E_Connman_Module_Context *ctxt,
159                                        const char                     *service_path)
160 {
161    E_Connman_Service *itr;
162
163    EINA_INLIST_FOREACH(ctxt->services, itr)
164    if (itr->path == service_path)
165      return itr;
166
167    return NULL;
168 }
169
170 static inline E_Connman_Technology *
171 _connman_ctxt_technology_find_stringshare(const E_Connman_Module_Context *ctxt,
172                                           const char                     *path)
173 {
174    E_Connman_Technology *t;
175
176    EINA_INLIST_FOREACH(ctxt->technologies, t)
177    if (t->path == path)
178      return t;
179
180    return NULL;
181 }
182
183 #endif