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