Below changes are applied
[apps/native/ug-mobile-ap.git] / include / mobile_hotspot.h
1 /*
2 * ug-mobile-ap
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9
10 * http://www.tizenopensource.org/license
11
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 #ifndef __MOBILE_HOTSPOT_H__
21 #define __MOBILE_HOTSPOT_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #if !defined(PACKAGE)
28 #define PACKAGE "ug-setting-mobile-ap-ug"
29 #endif
30
31 #if !defined(LOCALEDIR)
32 #define LOCALEDIR "/usr/ug/res/locale"
33 #endif
34
35 #if !defined(EDJDIR)
36 #define EDJDIR "/usr/ug/res/edje/ug-setting-mobile-ap-ug"
37 #endif
38
39 #if !defined(PREFIX)
40 #define PREFIX "/usr/ug"
41 #endif
42
43 #include <sys/time.h>
44 #include <glib.h>
45 #include <Elementary.h>
46 #include <vconf.h>
47 #include <ui-gadget-module.h>
48 #include <wifi.h>
49 #include <net_connection.h>
50 #include <sim.h>
51 #include <tethering.h>
52 #include <dlog.h>
53
54 #define MH_TEXT_DOMAIN                          PACKAGE
55 #define MH_LOCALEDIR                            LOCALEDIR
56
57 #ifdef S_
58 #undef S_
59 #endif
60 #define S_(str)                                 dgettext("sys_string", str)
61
62 #ifdef N_
63 #undef N_
64 #endif
65 #define N_(str)                                 gettext_noop(str)
66
67 #ifdef _
68 #undef _
69 #endif
70 #define _(str)                                  dgettext(MH_TEXT_DOMAIN, str)
71
72 #define VCONF_MOBILE_AP_PREV_WIFI_STATUS        "db/private/libug-setting-mobileap-efl/prev_wifi_status"
73
74 #define MOBILE_AP_TAG                                   "mobile_ap"
75 #define DBG(fmt, args...) LOG(LOG_DEBUG, MOBILE_AP_TAG, "[%s()][Ln:%d] "fmt, \
76                                                 __func__, __LINE__, ##args)
77 #define ERR(fmt, args...) LOG(LOG_ERROR, MOBILE_AP_TAG, "[%s()][Ln:%d] "fmt, \
78                                                 __func__, __LINE__, ##args)
79
80 #define __MOBILE_AP_FUNC_ENTER__        DBG("Entering: +\n")
81 #define __MOBILE_AP_FUNC_EXIT__         DBG("Exit: -\n")
82
83 #define TETHERING_IMAGES_EDJ            "tethering_images.edj"
84 #define WIFI_ICON                       "Wifi.png"
85 #define BT_ICON                         "Bluetooth.png"
86 #define USB_ICON                        "USB.png"
87
88 #define DEVICE_NAME_LENGTH_MAX          31
89 #define WIFI_PASSPHRASE_LENGTH_MIN      8
90 #define WIFI_PASSPHRASE_LENGTH_MAX      63
91 #define MH_LABEL_LENGTH_MAX             1024
92
93 #define _EDJ(obj)                       elm_layout_edje_get(obj)
94
95 /* This is from tethering_private.h */
96 #define TETHERING_MAX_CONNECTED_STA     16      /**< Maximum connected station. 8(Wi-Fi) + 7(BT) + 1(USB) */
97 #define TETHERING_TYPE_MAX              4       /**< All, USB, Wi-Fi, BT */
98
99 typedef enum {
100         MH_POPUP_NONE,
101
102         /* Two buttons pop-up */
103         MH_POP_WIFI_OFF_CONF,
104         MH_POP_WIFI_ON_CONF,
105         MH_POP_BT_ON_CONF,
106         MH_POP_USB_ON_CONF,
107         MH_POP_USB_ON_PREVCONN_CONF,
108         MH_POP_ENTER_TO_WIFI_SETUP_CONF,
109
110         /* One button pop-up */
111         MH_POP_INFORMATION,
112         MH_POP_USB_CONNECT,
113         MH_POP_WIFI_PASSWORD_SHORT,
114
115         /* No button & timeout pop-up */
116         MH_POP_INFORMATION_WO_BUTTON,
117
118         MH_POPUP_TYPE_MAX
119 } mh_popup_type_e;
120
121 typedef enum {
122         MH_STATE_NONE,
123         MH_STATE_PROCESS,
124         MH_STATE_MAX
125 } mh_state_e;
126
127 typedef struct ap_app_main {
128         Evas_Object                     *genlist;
129
130         Evas_Object                     *back_btn;
131         Evas_Object                     *wifi_btn;
132         Evas_Object                     *bt_btn;
133         Evas_Object                     *usb_btn;
134
135         Elm_Genlist_Item_Class          *sp_itc;
136         Elm_Genlist_Item_Class          *end_sp_itc;
137         Elm_Genlist_Item_Class          *wifi_itc;
138         Elm_Genlist_Item_Class          *setup_itc;
139         Elm_Genlist_Item_Class          *bt_itc;
140         Elm_Genlist_Item_Class          *usb_itc;
141         Elm_Genlist_Item_Class          *help_itc;
142
143         Elm_Genlist_Item_Class          *device_itc;
144         Elm_Genlist_Item_Class          *device0_itc;
145         Elm_Genlist_Item_Class          *usage_itc;
146         Elm_Genlist_Item_Class          *dev_itc[TETHERING_TYPE_MAX];
147
148         Elm_Object_Item                 *wifi_item;
149         Elm_Object_Item                 *setup_item;
150         Elm_Object_Item                 *bt_item;
151         Elm_Object_Item                 *usb_item;
152         Elm_Object_Item                 *device_item;
153         Elm_Object_Item                 *usage_item;
154         Elm_Object_Item                 *help_item;
155
156         int                             hotspot_mode;
157         int                             wifi_state;
158         int                             bt_state;
159         int                             usb_state;
160         bool                            need_recover_wifi_tethering;
161 } mh_main_view_t;
162
163 typedef struct {
164         Elm_Object_Item                 *navi_it;
165         Evas_Object                     *genlist;
166
167         Evas_Object                     *back_btn;
168         Evas_Object                     *title_back_btn;
169         Evas_Object                     *hide_btn;
170         Evas_Object                     *security_btn;
171         Evas_Object                     *pw_layout;
172         Evas_Object                     *pw_entry;
173
174         Elm_Genlist_Item_Class          *sp_itc;
175         Elm_Genlist_Item_Class          *end_sp_itc;
176         Elm_Genlist_Item_Class          *hide_itc;
177         Elm_Genlist_Item_Class          *security_itc;
178         Elm_Genlist_Item_Class          *pw_itc;
179         Elm_Genlist_Item_Class          *name_itc;
180
181         Elm_Object_Item                 *hide_item;
182         Elm_Object_Item                 *security_item;
183         Elm_Object_Item                 *pw_item;
184         Elm_Object_Item                 *name_item;
185
186         bool                            visibility;
187         tethering_wifi_security_type_e  security_type;
188
189         char                            device_name[DEVICE_NAME_LENGTH_MAX + 1];
190         char                            wifi_passphrase[WIFI_PASSPHRASE_LENGTH_MAX + 1];
191         char                            wifi_passphrase_new[WIFI_PASSPHRASE_LENGTH_MAX + 1];
192 } mh_wifi_setting_view_t;
193
194 typedef struct {
195         int number;
196         tethering_client_h handle[TETHERING_MAX_CONNECTED_STA];
197 } mh_clients_t;
198
199 typedef struct {
200         bool                    is_updated;
201         unsigned long long      pdp_total_sent;
202         unsigned long long      pdp_total_receive;
203 } mh_data_usage_t;
204
205 typedef struct {
206         void                            *gadget;
207         tethering_h                     handle;
208         connection_h                    conn_handle;
209
210         Evas_Object                     *win;
211         Evas_Object                     *layout;
212         Evas_Object                     *bg;
213
214         Evas_Object                     *naviframe;
215         Evas_Object                     *popup;
216
217         Ecore_Timer                     *update_statistics_handle;
218
219         mh_main_view_t                  main;
220         mh_wifi_setting_view_t          setup;
221
222         mh_data_usage_t                 data_statistics;
223         mh_clients_t                    clients;
224
225         int                             popup_type;
226         char                            popup_string[MH_LABEL_LENGTH_MAX];
227 } mh_appdata_t;
228
229 typedef struct {
230         mh_appdata_t            *ad;
231         ui_gadget_h             ug;
232 } mh_ugdata_t;
233
234 #ifdef __cplusplus
235 }
236 #endif
237 #endif /* __MOBILE_HOTSPOT_H__ */