Remove the sim feature and deprecated vconf key
[apps/native/ug-mobile-ap.git] / include / mobile_hotspot.h
1 /*
2 * ug-mobile-ap
3 *
4 * Copyright 2012-2013  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.1 (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://floralicense.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/ug/res/locale"
33 #endif
34
35 #if !defined(EDJDIR)
36 #define EDJDIR "/usr/ug/res/edje/ug-setting-mobileap-efl"
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 <tethering.h>
51 #include <dlog.h>
52
53 #define MH_TEXT_DOMAIN                          PACKAGE
54 #define MH_LOCALEDIR                            LOCALEDIR
55
56 #ifdef S_
57 #undef S_
58 #endif
59 #define S_(str)                                 dgettext("sys_string", str)
60
61 #ifdef N_
62 #undef N_
63 #endif
64 #define N_(str)                                 gettext_noop(str)
65
66 #ifdef _
67 #undef _
68 #endif
69 #define _(str)                                  dgettext(MH_TEXT_DOMAIN, str)
70
71 #define VCONF_MOBILE_AP_PREV_WIFI_STATUS        "db/private/libug-setting-mobileap-efl/prev_wifi_status"
72
73 #define MOBILE_AP_TAG                                   "mobile_ap"
74 #define DBG(fmt, args...) LOG(LOG_DEBUG, MOBILE_AP_TAG, "[%s()][Ln:%d] "fmt, \
75                                                 __func__, __LINE__, ##args)
76 #define ERR(fmt, args...) LOG(LOG_ERROR, MOBILE_AP_TAG, "[%s()][Ln:%d] "fmt, \
77                                                 __func__, __LINE__, ##args)
78
79 #define __MOBILE_AP_FUNC_ENTER__        DBG("Entering: +\n")
80 #define __MOBILE_AP_FUNC_EXIT__         DBG("Exit: -\n")
81
82 #define TETHERING_IMAGES_EDJ            "tethering_images.edj"
83 #define WIFI_ICON                       "Wifi.png"
84 #define BT_ICON                         "Bluetooth.png"
85 #define USB_ICON                        "USB.png"
86
87 #define DEVICE_NAME_LENGTH_MAX          31
88 #define WIFI_PASSPHRASE_LENGTH_MIN      8
89 #define WIFI_PASSPHRASE_LENGTH_MAX      63
90 #define MH_LABEL_LENGTH_MAX             1024
91
92 #define _EDJ(obj)                       elm_layout_edje_get(obj)
93
94 #define TETHERING_WIFI_MAX_CONNECTED_STA        8
95 #define TETHERING_BT_MAX_CONNECTED_STA          7
96 #define TETHERING_USB_MAX_CONNECTED_STA         1
97 #define TETHERING_MAX_CONNECTED_STA \
98         (TETHERING_WIFI_MAX_CONNECTED_STA + TETHERING_BT_MAX_CONNECTED_STA + TETHERING_USB_MAX_CONNECTED_STA)
99
100 /* This is from tethering_private.h */
101 #define TETHERING_TYPE_MAX              4       /**< All, USB, Wi-Fi, BT */
102
103 typedef enum {
104         MH_POPUP_NONE,
105
106         /* Two buttons pop-up */
107         MH_POP_WIFI_OFF_CONF,
108         MH_POP_WIFI_ON_CONF,
109         MH_POP_BT_ON_CONF,
110         MH_POP_USB_ON_CONF,
111         MH_POP_USB_ON_PREVCONN_CONF,
112         MH_POP_ENTER_TO_WIFI_SETUP_CONF,
113
114         /* One button pop-up */
115         MH_POP_INFORMATION,
116         MH_POP_USB_CONNECT,
117
118         /* No button & timeout pop-up */
119         MH_POP_INFORMATION_WO_BUTTON,
120
121         MH_POPUP_TYPE_MAX
122 } mh_popup_type_e;
123
124 typedef enum {
125         MH_STATE_NONE,
126         MH_STATE_PROCESS,
127         MH_STATE_MAX
128 } mh_state_e;
129
130 typedef struct ap_app_main {
131         Evas_Object                     *genlist;
132
133         Evas_Object                     *back_btn;
134         Evas_Object                     *wifi_btn;
135         Evas_Object                     *bt_btn;
136         Evas_Object                     *usb_btn;
137
138         Elm_Genlist_Item_Class          *sp_itc;
139         Elm_Genlist_Item_Class          *end_sp_itc;
140         Elm_Genlist_Item_Class          *wifi_itc;
141         Elm_Genlist_Item_Class          *setup_itc;
142         Elm_Genlist_Item_Class          *bt_itc;
143         Elm_Genlist_Item_Class          *usb_itc;
144         Elm_Genlist_Item_Class          *help_itc;
145
146         Elm_Genlist_Item_Class          *device_itc;
147         Elm_Genlist_Item_Class          *device0_itc;
148         Elm_Genlist_Item_Class          *usage_itc;
149         Elm_Genlist_Item_Class          *dev_itc[TETHERING_TYPE_MAX];
150
151         Elm_Object_Item                 *sp_item[4];
152         Elm_Object_Item                 *wifi_item;
153         Elm_Object_Item                 *setup_item;
154         Elm_Object_Item                 *bt_item;
155         Elm_Object_Item                 *usb_item;
156         Elm_Object_Item                 *device_item;
157         Elm_Object_Item                 *usage_item;
158         Elm_Object_Item                 *help_item;
159
160         int                             hotspot_mode;
161         int                             wifi_state;
162         int                             bt_state;
163         int                             usb_state;
164         bool                            need_recover_wifi_tethering;
165 } mh_main_view_t;
166
167 typedef struct {
168         Elm_Object_Item                 *navi_it;
169         Evas_Object                     *genlist;
170
171         Evas_Object                     *back_btn;
172         Evas_Object                     *title_back_btn;
173         Evas_Object                     *hide_btn;
174         Evas_Object                     *security_btn;
175         Evas_Object                     *pw_entry;
176
177         Elm_Genlist_Item_Class          *sp_itc;
178         Elm_Genlist_Item_Class          *end_sp_itc;
179         Elm_Genlist_Item_Class          *hide_itc;
180         Elm_Genlist_Item_Class          *security_itc;
181         Elm_Genlist_Item_Class          *pw_itc;
182         Elm_Genlist_Item_Class          *name_itc;
183
184         Elm_Object_Item                 *sp_item[2];
185         Elm_Object_Item                 *hide_item;
186         Elm_Object_Item                 *security_item;
187         Elm_Object_Item                 *pw_item;
188         Elm_Object_Item                 *name_item;
189
190         bool                            visibility;
191         tethering_wifi_security_type_e  security_type;
192
193         char                            device_name[DEVICE_NAME_LENGTH_MAX + 1];
194         char                            wifi_passphrase[WIFI_PASSPHRASE_LENGTH_MAX + 1];
195         char                            wifi_passphrase_new[WIFI_PASSPHRASE_LENGTH_MAX + 1];
196 } mh_wifi_setting_view_t;
197
198 typedef struct {
199         int number;
200         tethering_client_h handle[TETHERING_MAX_CONNECTED_STA];
201 } mh_clients_t;
202
203 typedef struct {
204         bool                    is_updated;
205         unsigned long long      pdp_total_sent;
206         unsigned long long      pdp_total_receive;
207 } mh_data_usage_t;
208
209 typedef struct {
210         void                            *gadget;
211         tethering_h                     handle;
212         connection_h                    conn_handle;
213
214         Evas_Object                     *win;
215         Evas_Object                     *layout;
216         Evas_Object                     *bg;
217
218         Evas_Object                     *naviframe;
219         Evas_Object                     *popup;
220
221         Ecore_Timer                     *update_statistics_handle;
222
223         mh_main_view_t                  main;
224         mh_wifi_setting_view_t          setup;
225
226         mh_data_usage_t                 data_statistics;
227         mh_clients_t                    clients;
228
229         enum ug_event                   rotate_state;
230         Ecore_IMF_Input_Panel_State     imf_state;
231 } mh_appdata_t;
232
233 typedef struct {
234         mh_appdata_t            *ad;
235         ui_gadget_h             ug;
236 } mh_ugdata_t;
237
238 #ifdef __cplusplus
239 }
240 #endif
241 #endif /* __MOBILE_HOTSPOT_H__ */