Base code merged to SPIN 2.4
[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-mobileap-efl"
29 #endif
30
31 #if !defined(LOCALEDIR)
32 #define LOCALEDIR "/usr/apps/ug-setting-mobileap-efl/res/locale"
33 #endif
34
35 #if !defined(EDJDIR)
36 #define EDJDIR "/usr/apps/ug-setting-mobileap-efl/res/edje/ug-setting-mobileap-efl"
37 #endif
38
39 #if !defined(PREFIX)
40 #define PREFIX "/usr/ug"
41 #endif
42
43 #define TETHERING_EDJ "tethering.edj"
44 #define POPUP_EDJ_PATH EDJDIR"/"TETHERING_EDJ
45
46 #include <sys/time.h>
47 #include <glib.h>
48 #include <Elementary.h>
49 #include <vconf.h>
50 #include <ui-gadget-module.h>
51 #include <wifi.h>
52 #include <net_connection.h>
53 #include <tethering.h>
54 #include <dlog.h>
55 #include <notification.h>
56
57 #define MH_TEXT_DOMAIN                          PACKAGE
58 #define MH_LOCALEDIR                            LOCALEDIR
59
60
61 #define VCONF_MOBILE_AP_PREV_WIFI_STATUS        "db/private/libug-setting-mobileap-efl/prev_wifi_status"
62 #define VCONF_MOBILE_AP_WIFI_POPUP_CHECKBOX_STATUS "file/private/libug-setting-mobileap-efl/wifi_popup_check_box_status"
63 #define VCONF_MOBILE_AP_BT_POPUP_CHECKBOX_STATUS "file/private/libug-setting-mobileap-efl/bt_popup_check_box_status"
64 #define VCONF_MOBILE_AP_USB_POPUP_CHECKBOX_STATUS "file/private/libug-setting-mobileap-efl/usb_popup_check_box_status"
65 #define VCONF_MOBILE_AP_CONNECT_USB_POPUP_STATUS "memory/private/libug-setting-mobileap-efl/trying_usb_tethering"
66 #define COLOR_TABLE "/usr/apps/ug-setting-mobileap-efl/shared/res/tables/ug-setting-mobileap-efl_ChangeableColorInfo.xml"
67 #define FONT_TABLE "/usr/apps/ug-setting-mobileap-efl/shared/res/tables/ug-setting-mobileap-efl_fontInfoTable.xml"
68
69 #define VCONF_KEY_MOBILEAP_SYSPOPUP_RESPONSE "memory/private/libug-setting-mobileap-efl/mobileap_syspopup_user_response"
70
71 #ifdef LOG_TAG
72 #undef LOG_TAG
73 #endif
74
75 #define LOG_TAG                         "UG_SETTING_MOBILEAP_EFL"
76
77 #define DBG(fmt, args...)               LOGD(fmt, ##args)
78 #define INFO(fmt, args...)              LOGI(fmt, ##args)
79 #define ERR(fmt, args...)               LOGE(fmt, ##args)
80 #define SDBG(fmt, args...)              SECURE_LOGD(fmt, ##args)
81 #define SERR(fmt, args...)              SECURE_LOGE(fmt, ##args)
82
83 #define __MOBILE_AP_FUNC_ENTER__        DBG("Entering: +\n")
84 #define __MOBILE_AP_FUNC_EXIT__         DBG("Exit: -\n")
85
86 #define TETHERING_IMAGES_EDJ            "tethering_images.edj"
87 #define WIFI_ICON                       "A01-5_device_WIFI.png"
88 #define BT_ICON                         "A01-5_device_bluetooth.png"
89 #define USB_ICON                        "A01-5_device_USB_icon.png"
90
91 #define DEVICE_NAME_LENGTH_MAX          32
92 #define WIFI_PASSPHRASE_LENGTH_MIN      8
93 #define WIFI_PASSPHRASE_LENGTH_MAX      63
94 #define MH_LABEL_LENGTH_MAX             1024
95
96 #define _EDJ(obj)                       elm_layout_edje_get(obj)
97
98 #define TETHERING_WIFI_MAX_CONNECTED_STA        10
99 #define TETHERING_BT_MAX_CONNECTED_STA          4
100 #define MAX_CONNECTED_STA 15
101
102 /* This is from tethering_private.h */
103 #define TETHERING_TYPE_MAX              4       /**< All, USB, Wi-Fi, BT */
104
105 typedef enum {
106         MH_POPUP_NONE,
107         MH_POPUP_WIFI_ON_CHECKBOX,
108         MH_POPUP_BT_ON_CHECKBOX,
109         MH_POPUP_USB_ON_CHECKBOX,
110         MH_POPUP_WIFI_AP_OFF,
111         MH_POPUP_NO_SIM,
112         MH_POPUP_FLIGHT_MODE,
113         MH_POPUP_MOBILE_DATA_OFF,
114         MH_POPUP_CANCEL_MOBILE_DATA_ON,
115         MH_POPUP_NETWORK_OUT_OF_RANGE,
116         MH_POPUP_WIFI_OFF,
117         MH_POPUP_TETH_ENABLING_FAILED,
118         MH_POPUP_SPECIAL_LETTER_WARN,
119         MH_POPUP_MAX
120 } mh_popup_type_e;
121
122 typedef enum {
123         MH_STATE_NONE,
124         MH_STATE_PROCESS,
125         MH_STATE_MAX
126 } mh_state_e;
127
128 typedef struct ap_app_main {
129         Evas_Object             *genlist;
130         Evas_Object             *back_btn;
131         Evas_Object             *check_popup_ly;
132
133 #if 0 /* not used */
134         Elm_Genlist_Item_Class  *sp_itc;
135         Elm_Genlist_Item_Class  *sp2_itc;
136 #endif
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         Elm_Genlist_Item_Class  *device_itc;
143         Elm_Genlist_Item_Class  *device0_itc;
144         Elm_Genlist_Item_Class  *popup_descp_itc;
145         Elm_Genlist_Item_Class  *popup_check_itc;
146
147         Elm_Object_Item         *sp_item[4];
148         Elm_Object_Item         *help_sp_item;
149         Elm_Object_Item         *wifi_item;
150         Elm_Object_Item         *setup_item;
151         Elm_Object_Item         *bt_item;
152         Elm_Object_Item         *usb_item;
153         Elm_Object_Item         *device_item;
154         Elm_Object_Item         *help_item;
155         Elm_Object_Item         *popup_descp_item;
156         Elm_Object_Item         *popup_check_item;
157
158 #ifdef TETHERING_DATA_USAGE_SUPPORT
159         Elm_Genlist_Item_Class  *usage_itc;
160         Elm_Object_Item         *usage_item;
161 #endif
162
163         int             hotspot_mode;
164         int             wifi_state;
165         int             bt_state;
166         int             usb_state;
167 } mh_main_view_t;
168
169 typedef struct {
170         Elm_Object_Item         *navi_it;
171         Evas_Object                     *genlist;
172         Evas_Object                     *rename_genlist;
173         Evas_Object             *hide_btn;
174         Evas_Object             *security_btn;
175         Evas_Object             *pw_entry;
176         Evas_Object             *popup_passphrase;
177         Evas_Object             *save_button;
178         Evas_Object             *cancel_button;
179
180 #if 0 /* not used */
181         Elm_Genlist_Item_Class          *sp_itc;
182         Elm_Genlist_Item_Class          *sp2_itc;
183 #endif
184         Elm_Genlist_Item_Class          *hide_itc;
185         Elm_Genlist_Item_Class          *security_itc;
186         Elm_Genlist_Item_Class          *pw_itc;
187         Elm_Genlist_Item_Class          *name_itc;
188         Elm_Genlist_Item_Class          *rename_entry_itc;
189         Elm_Genlist_Item_Class          *rename_descp_itc;
190
191         Elm_Object_Item         *sp_item[2];
192         Elm_Object_Item         *hide_item;
193         Elm_Object_Item         *security_item;
194         Elm_Object_Item         *pw_item;
195         Elm_Object_Item         *name_item;
196         Elm_Object_Item         *pw_guide_item;
197         Elm_Object_Item         *rename_entry_item;
198         Elm_Object_Item         *rename_descp_item;
199
200         bool    visibility;
201         bool    visibility_new;
202         tethering_wifi_security_type_e  security_type;
203         tethering_wifi_security_type_e  security_type_new;
204
205         char    device_name[DEVICE_NAME_LENGTH_MAX + 1];
206         char    wifi_passphrase[WIFI_PASSPHRASE_LENGTH_MAX + 1];
207         char    wifi_passphrase_new[WIFI_PASSPHRASE_LENGTH_MAX + 1];
208 } mh_wifi_setting_view_t;
209
210 typedef struct {
211         bool    is_updated;
212         unsigned long long      pdp_total_sent;
213         unsigned long long      pdp_total_receive;
214 } mh_data_usage_t;
215
216 typedef struct {
217         Elm_Object_Item *navi_it;
218         Evas_Object *genlist;
219
220         Elm_Genlist_Item_Class *dev_itc[TETHERING_TYPE_MAX];
221         Elm_Object_Item *dev_item;
222         Elm_Object_Item         *station_items[MAX_CONNECTED_STA];
223         int no_of_clients;
224 } mh_conn_client_view_t;
225
226 typedef struct {
227         void    *gadget;
228         GSList  *client_list;
229         bool    is_foreground;
230
231         tethering_h             handle;
232         connection_h    conn_handle;
233         tethering_type_e        type;
234
235         Evas_Object             *win;
236         Evas_Object             *layout;
237         Evas_Object             *bg;
238         Evas_Object             *naviframe;
239         Evas_Object             *popup_checkbox;
240         Evas_Object             *popup;
241         Evas_Object             *rename_entry;
242         Ecore_Timer             *update_statistics_handle;
243         Ecore_Timer             *update_conn_time_handle;
244         Evas_Object             *ctxpopup;
245         Evas_Object             *rename_popup;
246         Evas_Object             *rename_button;
247         Elm_Object_Item         *navi_item;
248
249         int             ps_recheck_timer_id;
250         int             is_wifi_teth_enabling;
251         int             is_usb_teth_enabling;
252         int             is_bt_teth_enabling;
253
254         mh_main_view_t  main;
255         mh_wifi_setting_view_t  setup;
256         mh_data_usage_t         data_statistics;
257         mh_conn_client_view_t connected_device;
258 } mh_appdata_t;
259
260 typedef struct {
261         mh_appdata_t    *ad;
262         ui_gadget_h             ug;
263 } mh_ugdata_t;
264
265 #ifdef __cplusplus
266 }
267 #endif
268 #endif /* __MOBILE_HOTSPOT_H__ */