tizen 2.3 release
[apps/home/settings.git] / setting-network / include / setting-network.h
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 #ifndef __SETTING_NETWORK_H__
22 #define __SETTING_NETWORK_H__
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <glib.h>
27 #include <Elementary.h>
28 #include <Ecore_IMF.h>
29 #include <string.h>
30
31 #include <glib-object.h>
32 #include <net_connection.h>
33
34
35 #include <setting-common-draw-widget.h>
36 #include <setting-common-view.h>
37 #include <setting-debug.h>
38
39 #include <TapiUtility.h>
40 #include <ITapiNetwork.h>
41 #include <ITapiSim.h>
42
43 #include <Ecore_IMF.h>
44
45 //#include <tethering.h>
46
47 #define TIME_TO_TURN_OFF_3G 2
48
49 //for new metwork mode
50 #define Keystr_NetBrand_Auto "IDS_CST_OPT_GSM_WCDMA_HAUTO_CONNECT"//"GSM/WCDMA (auto connect)"
51 #define Keystr_NetBrand_Auto_WCDMA_GSM "IDS_CST_OPT_GSM_WCDMA_HAUTO_CONNECT"//"GSM/WCDMA (auto connect)"
52
53 #define Keystr_NetBrand_WCDMA "IDS_ST_MBODY_WCDMA_ONLY"
54 #define Keystr_NetBrand_LTE_WCDMA "LTE/3G"
55
56 #define Keystr_NetBrand_GSM "IDS_ST_MBODY_GSM_ONLY"
57 //**************************************************//
58 #define KeyStr_UserID "IDS_ST_BODY_USER_ID"
59
60 #define SUPPORT_CON_RESET
61 //#define NET_CON_RESET_DBUS_PARA  "--system --print-reply --dest=com.tcore.ps / com.tcore.ps.master.ResetProfile"
62 #define NET_CON_RESET_DBUS_PARA  "--system --print-reply --dest=com.tcore.ps / com.tcore.ps.master.ResetProfile int32:0"
63
64 #define Data_packet_Sub_desc "IDS_ST_BODY_ENABLE_DATA_ACCESS_OVER_MOBILE_NETWORK"
65 #define Data_packet_Popup_desc "IDS_ST_POP_MOBILE_DATA_ENABLED_CONNECTING_TO_MOBILE_NETWORKS_MAY_INCUR_EXTRA_CHARGES_DEPENDING_ON_YOUR_DATA_PLAN_CONTINUE_Q"
66 #define SETTING_NETWORK_DATA_ROMING_DESC "IDS_COM_BODY_CONNECT_TO_DATA_SERVICES_WHEN_ROAMING"
67 #define SETTING_NETWORK_DATA_ROMING_OFF_DESC "IDS_ST_BODY_WHEN_DATA_ROAMING_IS_DISABLED_APPLICATIONS_THAT_USE_THE_DATA_CONNECTION_MAY_NOT_WORK"
68
69 #define SETTING_NETWORK_USE_PACKET_DATA_OFF_DESC "IDS_ST_BODY_USING_MOBILE_DATA_MAY_RESULT_IN_ADDITIONAL_CHARGES_CONTINUE_Q"
70 #define SETTING_NETWORK_USE_PACKET_DATA_ON_DESC "IDS_COM_BODY_ALLOW_DATA_ROAMING_Q_YOU_MAY_INCUR_SIGNIFICANT_ROAMING_CHARGES_E"
71
72 #define SETTING_NETWORK_SEARCH_3G_ON_DESC "IDS_ST_POP_UNABLE_TO_SEARCH_NETWORKS_DURING_DATA_SERVICE_ACTIVATED_DO_YOU_WANT_TO_DISCONNECT_THE_DATA_SERVICE_AND_SEARCH_AVAILABLE_NETWORK_Q"
73 #define SETTING_NETWORK_CHANGE_3G_ON_DESC "IDS_ST_POP_UNABLE_TO_CHANGE_NETWORKS_WHILE_DATA_SERVICE_IN_USE_STOP_USING_CURRENT_DATA_SERVICE_AND_SELECT_ANOTHER_AVAILABLE_NETWORK_Q"
74
75 #define SETTING_NETWORK_SEARCHING_NETWORK "IDS_ST_POP_SEARCHING_NETWORK_ING"
76 #define SETTING_NETWORK_USE_PACKET_DATA_OFF_NO_DATA_DESC _("IDS_ST_POP_MOBILE_DATA_HAS_BEEN_DISABLED_MSG")
77 #define CONNECTION_DSC "IDS_ST_BODY_CONNECTIONS"
78 #define KeyStr_Reset_Def "IDS_ST_BODY_RESET_TO_DEFAULT"
79 #define KeyStr_Edit "IDS_ST_BODY_EDIT"
80 #define KeyStr_Saved "IDS_ST_BODY_SAVED"
81 #define keyStr_Searched "IDS_SSEARCH_POP_SEARCHED"
82 #define keyStr_Failed_Searched "IDS_ST_POP_NETWORK_SEARCH_FAILED"
83 #define keyStr_Failed_Select_Network "IDS_COM_BODY_YOUR_SIM_CARD_DOES_NOT_ALLOW_A_CONNECTION_TO_THIS_NETWORK"
84 #define keyStr_Failed_Get_PreferNetwork "Get preferred network failed"
85 #define keyStr_Forbidden_Network _("IDS_ST_BODY_FORBIDDEN_NETWORK")
86 #define keyStr_OK _("IDS_ST_BUTTON_OK_ABB")
87 #define keyStr_CANCEL   _("IDS_ST_BUTTON_CANCEL_ABB2")
88
89 #define KeyStr_No_Profile _("IDS_ST_BODY_EMPTY")
90 #define keyStr_No_Other_Network "IDS_ST_BODY_THERE_ARE_NO_NETWORKS_NEARBY"
91
92 #define Insert_Profile_Name_desc "Please input Profile name !"  //IDS_ST_BODY_ACCESS_NAME
93 #define Insert_Access_Name_desc "Please input Access name !"    //IDS_ST_BODY_ACCESS_NAME
94 #define Insert_User_Name_Desc "Please input User ID !"                  //IDS_COM_BODY_USER_NAME
95 #define Invok_API_Failed_Desc "Failed to invoke API"
96 #define SETTING_NETWORK_NOT_ALLOWED_WITH_TETHERING "Unable to change APN when tethering is enabled"
97 #define SETTING_NETWORK_DOT "IDS_WIFI_BODY_DOT"
98 #define SETTING_NETWORK_CONTINUE "IDS_COM_OPT_CONTINUE_Q"
99
100 //in the feture
101 #define NotifyStr_PDP_OFF "PDP will be disabled to find network nearby"
102 #define Keystr_UNKNOWN_NETWORK _("IDS_ST_OPT_UNTITLED_NETWORK")
103
104 //#define WHITELIST_DIR_PATH    "/opt/usr/data/setting/lteon_netlist.xml"
105 #define WHITELIST_DIR_PATH      "/opt/system/csc/usr/network/lteon_netlist.xml"
106
107
108 #define SETTING_ADD_PROFILE_INDEX -1
109 #define Invoking_TAPI_Timeout  8
110 #define COUNTRY_CODE_LEN        3
111 #define NETWORK_CODE_LEN        3
112 #define PRE_NETWORK_NAME_MAX 256
113
114 #define SETTING_NETWORK_POP_RESPONSE_ACTION_CANCEL  10  /*  the popupresponse action ID */
115 #define SETTING_NETWORK_SUBS_ID_NET_LEN 7
116 typedef enum {
117         SETTING_NETWORK_PREFERRED_NETWORK_NONE,
118         SETTING_NETWORK_PREFERRED_NETWORK_NEW,
119         SETTING_NETWORK_PREFERRED_NETWORK_EDIT,
120         SETTING_NETWORK_PREFERRED_NETWORK_LIST,
121         SETTING_NETWORK_PREFERRED_NETWORK_DELETE,
122
123 } setting_network_preferred_network_operation_type_t;
124
125 typedef struct _SettingNetworkUG SettingNetworkUG;
126
127 struct gl_network_data {
128         int index;
129         char name[PRE_NETWORK_NAME_MAX];
130 };
131
132 typedef enum {
133         ERROR_STATE = 0,
134         MAIN_ONLY = 1,
135         CONNECTIONS_MAIN = 2,
136         CREATE_CONNECTIONS_MAIN = 3,
137         CREATE_CONLIST_CONNECTIONS_MAIN = 4
138 } setting_network_view_type_t;
139
140 #define MAX_PROFILE_NUM 100
141 /**
142  * Setting Network UG context
143  * all UG function has void* as an agument. this is casted back to SettingNetworkUG
144  * and the functions access app context.
145  */
146 struct _SettingNetworkUG {
147         ui_gadget_h ug;
148         TapiHandle *handle;
149         connection_h connection;
150         connection_profile_h sel_profile_h;
151         setting_view *profile_topper_view;
152
153         //xmlDocPtr whitelist_doc;
154         //xmlNodePtr whitelist_root_node;
155         void *whitelist_doc;
156         void *whitelist_root_node;
157
158 #if SUPPORT_TETHERING
159         tethering_h th_main;
160         tethering_h th_connections;
161         tethering_h th_conlists;
162         tethering_h th_concreate;
163 #endif
164         int profile_service_type;
165
166         /* add more variables here (move your appdata to here) */
167         Evas *evas;
168         Evas_Object *win_main_layout;
169         Evas_Object *win_get;
170         Evas_Object *navi_bar;
171
172         Evas_Object *popup_concreate;
173         Evas_Object *popup_conlist;
174         Evas_Object *popup_conreset;
175         Evas_Object *popup;
176         Evas_Object *popup_chk;
177
178         Evas_Object *popup_data_on;
179         Evas_Object *popup_data_off;
180
181         //connection,
182         Elm_Object_Item *navi_it;
183         Elm_Object_Item *navi_it_con_list;
184         Elm_Object_Item *navi_it_profile_del_list;
185         Evas_Object *bottom_btn;
186         //Evas_Object *conformant;
187         Evas_Object *back_btn;
188         Evas_Object *l_button;
189         Evas_Object *r_button;
190         //Evas_Object *m_button;
191
192         bool has_form_changed;
193         Evas_Object *genlist;
194         Evas_Object *genlist_sel_network;
195         Evas_Object *connections_gl;  /* genlist in connections view */
196         Evas_Object *con_list_gl;  /* genlist in connections view */
197         int cur_profile_num;
198
199         Evas_Object *network_ug_pop;
200         Evas_Object *network_select_registering_pop;
201         Evas_Object *controllbar;
202
203         char *view_type_string;
204
205         Evas_Object *ly_main;
206         //Evas_Object *ly_search; // select network - view
207         unsigned int subs_id_net[SETTING_NETWORK_SUBS_ID_NET_LEN];
208
209         Evas_Point        point_down;
210
211         Setting_GenGroupItem_Data* data_auto_network_item;
212         Setting_GenGroupItem_Data* data_search_network_item;
213
214         bool b_searching_network;
215         bool b_set_auto_network;
216         bool b_set_manul_network;
217         bool b_trigged_by_searching;
218         bool b_trigged_by_modechanging;
219         bool b_restore_3g_status;
220         bool b_restore_roaming_status;
221
222         Setting_GenGroupItem_Data *data_sel_net;
223 #ifdef NETWORK_MODE
224         Setting_GenGroupItem_Data *data_net_mode;
225 #endif
226         Setting_GenGroupItem_Data *data_connection;
227         Setting_GenGroupItem_Data *data_use_packet;
228         Setting_GenGroupItem_Data *data_roaming;
229         Setting_GenGroupItem_Data *data_srv_type;
230         Setting_GenGroupItem_Data *internet_conn;
231         Setting_GenGroupItem_Data *mms_conn;
232         Setting_GenGroupItem_Data *selected_profile;
233
234         Setting_GenGroupItem_Data *lte_wcdma_gsm;
235         Setting_GenGroupItem_Data *wcdma_gsm;
236         Setting_GenGroupItem_Data *wcdma_only;
237         Setting_GenGroupItem_Data *gsm_only;
238
239         Evas_Object *chk_sel;
240         Evas_Object *chk_mode;
241         Evas_Object *pop_gsm;
242         Evas_Object *chk_3gcon;
243
244         int sel_net;            /**< like vconf key:VCONFKEY_SETAPPL_SELECT_NETWORK_INT */
245         int sel_act;            /**< like vconf key:VCONFKEY_SETAPPL_SELECT_OLD_NT_ACT */
246         char *sel_network;
247 #ifdef NETWORK_MODE
248         int net_mode;           /* like vconf key */
249 #endif
250
251         TelNetworkPlmnList_t plmn_info;
252
253         int is_show_user;
254         char *con_name;
255         char *access_name;
256
257         Evas_Object *chk_type;
258
259         char *ed_profile_name_desc;
260         char *ed_acs_name_desc;
261         char *ed_auth_type_desc;
262         char *ed_user_name_desc;
263         char *ed_pwd_desc;
264         char *ed_pxy_addr_desc;
265         char *ed_pxy_port_desc;
266         char *ed_hm_url_desc;
267         int chkType;
268         int srvType;
269         bool is_editable;
270         Elm_Object_Item *item_above_user_name;
271         Elm_Object_Item *item_above_proxy_add;
272         Setting_GenGroupItem_Data *data_user_name;
273         Setting_GenGroupItem_Data *data_pwd;
274         Setting_GenGroupItem_Data *data_acs_name;
275         Setting_GenGroupItem_Data *data_profile_name;
276         Setting_GenGroupItem_Data *data_pxy_addr;
277         Setting_GenGroupItem_Data *data_pxy_port;
278         Setting_GenGroupItem_Data *data_hm_url;
279         Setting_GenGroupItem_Data *data_auth_type;
280         Setting_GenGroupItem_Data *data_type_nor;
281         Setting_GenGroupItem_Data *data_type_sec;
282         Setting_GenGroupItem_Data *data_type_none;
283
284         Evas_Object *scl_edit;
285
286         /* Preferred network common */
287         TelNetworkPreferredPlmnList_t pref_list;
288         int sel_pref_idx;
289         setting_network_preferred_network_operation_type_t op_type;
290
291         Ecore_Idler *add_view_timer;
292         char search_text[MAX_SEARCH_STR_LEN + 1];
293         Evas_Object *nw_search_bar;
294
295         Evas_Object *scl_pref;
296         Evas_Object *chk_new_type;
297         Setting_GenGroupItem_Data *data_edit_mcc;
298         Setting_GenGroupItem_Data *data_edit_mnc;
299         Setting_GenGroupItem_Data *data_new_mcc;
300         Setting_GenGroupItem_Data *data_new_mnc;
301         Evas_Object *chk_edit_type;
302         Evas_Object *scl_pref_del;
303         Evas_Object *gl_sel_all;
304         Evas_Object *gl_profile_del;
305         Eina_List* profile_list;
306         Eina_List* profile_del_list;
307
308         Evas_Object *popup_label;
309         int deleted_number;
310         Eina_List *checked_data_list;
311         Eina_List *item_check_list;
312
313         /* Preferred network network list for genlist */
314         Evas_Object *gl_network;
315         Elm_Genlist_Item_Class itc;
316         struct gl_network_data *cur_sel_mem;
317         int cur_sel_index;
318
319         Setting_GenGroupItem_Data *data_cl_select_all;
320         Evas_Object *sub_clear_layout;
321         Evas_Object *selInfoPop;
322         Evas_Object *selInfoPop_layout;
323         Evas_Object *rdg;
324
325         setting_view *view_to_load;
326         Ecore_Timer *timer;
327
328         char *apn_internet;
329         char *apn_MMS;
330         Ecore_Idler *add_apn_idler;
331         Ecore_Idler *add_apn_timer;
332
333         int is_update;
334
335         int viewtype;
336
337         //dual sim
338         int sim_type;
339 };
340
341
342 extern setting_view setting_view_network_main;
343 extern setting_view setting_view_network_select_network;
344 extern setting_view setting_view_network_main_help;
345 extern setting_view setting_view_network_con;
346 extern setting_view setting_view_network_con_list;
347 extern setting_view setting_view_network_connection_create;
348 extern setting_view setting_view_network_3gcon;
349
350 extern setting_view setting_view_network_preferred_network;
351 extern setting_view setting_view_network_preferred_network_new;
352 extern setting_view setting_view_network_preferred_network_list;
353 extern setting_view setting_view_network_preferred_network_edit;
354 extern setting_view setting_view_network_preferred_network_delete;
355 extern setting_view setting_view_network_profile_delete;
356
357 const char *setting_network_get_act_str(TelNetworkSystemType_t type);
358 void setting_network_update_sel_network(void *data);
359 bool setting_network_equal_profile(connection_profile_h pf1, connection_profile_h pf2);
360 void setting_network_reget_profile_list(void *cb);
361 void setting_tapi_get_preferred_plmn_cb(TapiHandle *handle, int result, void *data, void *user_data);
362 void setting_tapi_set_preferred_plmn_cb(TapiHandle *handle, int result, void *data, void *user_data);
363
364 void setting_tapi_cancel_manual_search_cb(TapiHandle *handle, int result, void *data, void *user_data);
365 void setting_tapi_search_network_cb(TapiHandle *handle, int result, void *data, void *user_data);
366
367 void setting_tapi_get_serving_network_cb(TapiHandle *handle, int result, void *data, void *user_data);
368 void setting_tapi_get_plmn_mode_cb(TapiHandle *handle, int result, void *data, void *user_data);
369 void setting_tapi_set_plmn_mode_cb(TapiHandle *handle, int result, void *data, void *user_data);
370
371 void setting_tapi_get_band_cb(TapiHandle *handle, int result, void *data, void *user_data);
372 void setting_tapi_set_band_cb(TapiHandle *handle, int result, void *data, void *user_data);
373
374 void setting_network_select_network_chk_changed(void *data, Evas_Object *obj, void *event_info);
375 void setting_network_Gendial_select_plmn_cb(void *data, Evas_Object *obj, void *event_info);
376 void setting_network_popup_delete(void *data);
377 int is_lte_on_feature(void *data);
378 char* __get_profile_name(int conType, void *data);
379
380 void    setting_network_searching_network( Setting_GenGroupItem_Data *list_item );
381
382
383 #endif                          /* __SETTING_NETWORK_H__ */