Tizen 2.0 Release
[apps/home/settings.git] / setting-network / src / setting-network-connection-create.c
1 /*
2  * setting
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Flora License, Version 1.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://floralicense.org/license/
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include <setting-network-connection-create.h>
18 #define MAX_PDP_APN_LEN_MAX 100
19 #define MAX_PDP_AUTH_USERNAME_LEN_MAX 32
20 #define MAX_PDP_AUTH_PASSWORD_LEN_MAX 32
21 #define MAX_HOME_URL_LEN_MAX 512
22 #define MAX_PROXY_LEN_MAX 64
23
24 static int setting_network_connection_create(void *cb);
25 static int setting_network_connection_destroy(void *cb);
26 static int setting_network_connection_update(void *cb);
27 static int setting_network_connection_cleanup(void *cb);
28
29 setting_view setting_view_network_connection_create = {
30         .create = setting_network_connection_create,
31         .destroy = setting_network_connection_destroy,
32         .update = setting_network_connection_update,
33         .cleanup = setting_network_connection_cleanup,
34 };
35
36 SettingNetworkUG *g_networkUG = NULL;
37 #define SUPPORT_EXPANDABLE_AUTHTYPE 1
38 #define URL_HEAD "http://"
39 /* ***************************************************
40  *
41  *basic func
42  *
43  ***************************************************/
44
45 static void
46 __network_connection_gl_mouse_up(void *data, Evas *e, Evas_Object *obj,
47                                  void *event)
48 {
49         ret_if(!data);
50         SETTING_TRACE_BEGIN;
51         SettingNetworkUG *ad = (SettingNetworkUG *) data;
52
53         if (ad->data_acs_name) {
54                 setting_hide_input_pannel_cb(ad->data_acs_name->eo_check);
55         }
56         if (ad->data_user_name) {
57                 setting_hide_input_pannel_cb(ad->data_user_name->eo_check);
58         }
59         if (ad->data_pwd) {
60                 setting_hide_input_pannel_cb(ad->data_pwd->eo_check);
61         }
62         if (ad->data_pxy_addr) {
63                 setting_hide_input_pannel_cb(ad->data_pxy_addr->eo_check);
64         }
65         if (ad->data_pxy_port) {
66                 setting_hide_input_pannel_cb(ad->data_pxy_port->eo_check);
67         }
68         if (ad->data_hm_url) {
69                 setting_hide_input_pannel_cb(ad->data_hm_url->eo_check);
70         }
71
72 }
73
74 void __sub_list_rd_change(void *data, Evas_Object *obj, void *event_info)
75 {
76         SETTING_TRACE_BEGIN;
77         retm_if(data == NULL, "Data parameter is NULL");
78         Setting_GenGroupItem_Data *list_item =
79             (Setting_GenGroupItem_Data *) data;
80         list_item->chk_status = elm_radio_value_get(obj);       /*  for update */
81
82         Elm_Object_Item *subItem = list_item->item;
83         Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subItem);
84
85         Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subItem);    /* subItem data */
86         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
87
88         ret_if(NULL == data_subItem || NULL == data_parentItem);
89
90         data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
91         elm_object_item_data_set(data_parentItem->item, data_parentItem);
92         elm_genlist_item_update(data_parentItem->item);
93         setting_network_edit_connection_display_auth_type
94             (data_parentItem->userdata, list_item->chk_status);
95 }
96
97 void __sub_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
98 {
99         SETTING_TRACE_BEGIN;
100         /* error check */
101         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
102         Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
103         Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
104         elm_genlist_item_selected_set(subitem, 0);
105         Setting_GenGroupItem_Data *data_subItem =
106             elm_object_item_data_get(subitem);
107         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
108         ret_if(NULL == data_subItem || NULL == data_parentItem);
109
110         elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
111
112         data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
113         elm_object_item_data_set(data_parentItem->item, data_parentItem);
114         elm_genlist_item_update(data_parentItem->item);
115         setting_network_edit_connection_display_auth_type(data,
116                                                           data_subItem->chk_status);
117 }
118
119 static void __setting_network_connection_exp_cb(void *data, Evas_Object *obj,
120                                                 void *event_info)
121 {
122         ret_if(NULL == data || NULL == event_info);
123         SETTING_TRACE_BEGIN;
124         SettingNetworkUG *ad = (SettingNetworkUG *) data;
125         Elm_Object_Item *parentItem = event_info;       /* parent item */
126         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
127         Evas_Object *scroller = elm_object_item_widget_get(parentItem);
128
129         Evas_Object *rgd;
130         if (data_parentItem == ad->data_auth_type) {
131                 rgd = elm_radio_add(scroller);
132                 elm_radio_value_set(rgd, -1);
133
134                 setting_create_Gendial_exp_sub_field(scroller,
135                                                      &itc_1icon_1text_sub,
136                                                      __sub_list_sel_cb, ad,
137                                                      parentItem,
138                                                      SWALLOW_Type_1RADIO, rgd,
139                                                      CONNECTION_CELLULAR_AUTH_TYPE_PAP,
140                                                      "IDS_ST_MBODY_PAP",
141                                                      __sub_list_rd_change);
142
143                 setting_create_Gendial_exp_sub_field(scroller,
144                                                      &itc_1icon_1text_sub,
145                                                      __sub_list_sel_cb, ad,
146                                                      parentItem,
147                                                      SWALLOW_Type_1RADIO, rgd,
148                                                      CONNECTION_CELLULAR_AUTH_TYPE_CHAP,
149                                                      "IDS_ST_POP_CHAP",
150                                                      __sub_list_rd_change);
151
152                 setting_create_Gendial_exp_sub_field(scroller,
153                                                      &itc_1icon_1text_sub,
154                                                      __sub_list_sel_cb, ad,
155                                                      parentItem,
156                                                      SWALLOW_Type_1RADIO, rgd,
157                                                      CONNECTION_CELLULAR_AUTH_TYPE_NONE,
158                                                      "IDS_COM_BODY_NONE",
159                                                      __sub_list_rd_change);
160
161                 elm_radio_value_set(rgd, ad->chkType);
162         }
163 }
164
165 static void __genlist_disable_set(Evas_Object *genlist, bool disabled)
166 {
167         SETTING_TRACE_BEGIN;
168         ret_if (!genlist);
169         Elm_Object_Item *item = elm_genlist_first_item_get(genlist);
170         for(;item != elm_genlist_last_item_get(genlist);
171             item = elm_genlist_item_next_get(item))
172         {
173                 elm_object_item_disabled_set(item, disabled);
174
175                 Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *)elm_object_item_data_get(item);
176                 if (item_data == NULL) {
177                         //SETTING_TRACE("item_data is null");
178                         continue;
179                 }
180                 if (item_data->swallow_type == SWALLOW_Type_LAYOUT_ENTRY) {
181                         elm_entry_context_menu_disabled_set(item_data->eo_check, disabled);
182                 }
183                 //elm_object_item_signal_emit(item, "elm,state,enabled", "elm");
184         }
185         elm_object_item_disabled_set(item, disabled);//the last one item
186         Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *)elm_object_item_data_get(item);
187         if (item_data == NULL) {
188                 SETTING_TRACE("item_data is null");
189                 return;
190         }
191         if (item_data->swallow_type == SWALLOW_Type_LAYOUT_ENTRY) {
192                 elm_entry_context_menu_disabled_set(item_data->eo_check, disabled);
193         }
194 }
195 static Eina_Bool __connection_idler(void *data)
196 {
197         SETTING_TRACE_BEGIN;
198         retv_if (!data, FALSE);
199         SettingNetworkUG *ad = data;
200         __genlist_disable_set(ad->scl_edit, TRUE);
201         setting_network_connection_hide_input_pannel(ad);
202         return FALSE;
203 }
204 void __get_connection_info(void *cb)
205 {
206         SETTING_TRACE_BEGIN;
207         ret_if(cb == NULL);
208         SettingNetworkUG *ad = (SettingNetworkUG *) cb;
209         //int ret;
210         G_FREE(ad->ed_acs_name_desc);
211         G_FREE(ad->ed_user_name_desc);
212         G_FREE(ad->ed_pwd_desc);
213
214         G_FREE(ad->ed_pxy_addr_desc);
215         G_FREE(ad->ed_pxy_port_desc);
216
217         G_FREE(ad->ed_hm_url_desc);
218         ad->ed_auth_type_desc = NULL;
219         ad->chkType = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
220
221         SETTING_TRACE("ad->con_name:%s", ad->con_name);
222         int ServiceType = CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION;
223         if (0 == safeStrCmp(ad->con_name,"IDS_ST_BODY_INTERNET_CONNECTION"))
224         {
225                 ServiceType = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
226         }
227         else if (0 == safeStrCmp(ad->con_name,STR_SETTING_MMS_CONNECTIONS))
228         {
229                 ServiceType = CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
230         }
231         const char *con_name_utf8 = elm_entry_markup_to_utf8(ad->con_name);
232
233
234         //match with the correct profile
235         connection_profile_iterator_h profile_iter = NULL;
236         connection_profile_h profile_h = NULL;
237         char *profile_name = NULL;
238         char *apn = NULL;
239         connection_profile_type_e profile_type = CONNECTION_PROFILE_TYPE_CELLULAR;
240         connection_cellular_service_type_e service_type = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
241         int err = connection_get_profile_iterator(ad->connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
242         if (err != CONNECTION_ERROR_NONE) {
243                 SETTING_TRACE_ERROR("Fail to get profile iterator [%d]", err);
244                 FREE(con_name_utf8);
245                 return;
246         }
247
248         int cnt = 0;
249         bool found = FALSE;
250         while (connection_profile_iterator_has_next(profile_iter)) {
251                 //reset and release..
252                 G_FREE(apn);
253                 G_FREE(profile_name);
254
255                 if (cnt >= MAX_PROFILE_NUM || connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE)
256                 {
257                         break;
258                 }
259
260                 connection_profile_get_type(profile_h, &profile_type);
261                 connection_profile_get_cellular_service_type(profile_h, &service_type);
262                 connection_profile_get_cellular_apn(profile_h, &apn);
263                 connection_profile_get_name(profile_h, &profile_name);
264                 SETTING_TRACE("Record[%d] apn[%s], profile_name[%s], profile_type[%d], service_type[%d]",
265                               cnt, apn, profile_name, profile_type, service_type);
266                 if(CONNECTION_PROFILE_TYPE_CELLULAR != profile_type)
267                         continue;
268
269                 if (CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION != service_type)
270                 {
271                         //match with ServiceType
272                         if (ServiceType == service_type)
273                         {
274                                 ad->sel_profile_h = profile_h;
275                                 found = TRUE;
276                                 break;
277                         }
278                 }
279                 else //the customer's profiles
280                 {
281                         if (0 == safeStrCmp(con_name_utf8, apn))
282                         {
283                                 ad->sel_profile_h = profile_h;
284                                 found = TRUE;
285                                 break;
286                         }
287                 }
288                 cnt++;
289         }
290         FREE(con_name_utf8);
291         if (found)//found sucessfully
292         {
293                 SETTING_TRACE("found the following record:");
294                 SETTING_TRACE("\tapn:%s", apn);
295                 SETTING_TRACE("\tprofile_name:%s", profile_name);
296                 SETTING_TRACE("\tservice_type:%d", service_type);
297                 SETTING_TRACE("\tprofile_type:%d", profile_type);
298                 /* load access name */
299                 //ad->ed_acs_name_desc = ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.Apn;
300                 connection_profile_get_cellular_apn(ad->sel_profile_h, &(ad->ed_acs_name_desc));
301                 /*ad->ed_user_name_desc =
302                     ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.AuthInfo.UserName;
303                 ad->chkType =
304                     ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.AuthInfo.AuthType;
305                 ad->ed_pwd_desc =
306                     ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.AuthInfo.Password;*/
307                 connection_cellular_auth_type_e auth_type = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
308                 connection_profile_get_cellular_auth_info(ad->sel_profile_h, &auth_type, &(ad->ed_user_name_desc), &(ad->ed_pwd_desc));
309                 ad->chkType = auth_type;
310
311                 switch (ad->chkType) {
312                 case CONNECTION_CELLULAR_AUTH_TYPE_PAP:
313                         ad->ed_auth_type_desc = _("IDS_ST_MBODY_PAP");
314                         break;
315                 case CONNECTION_CELLULAR_AUTH_TYPE_CHAP:
316                         ad->ed_auth_type_desc = _("IDS_ST_POP_CHAP");
317                         break;
318                 case CONNECTION_CELLULAR_AUTH_TYPE_NONE:
319                         ad->ed_auth_type_desc = _("IDS_COM_BODY_NONE");
320                         break;
321                 default:
322                         ad->chkType = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
323                         ad->ed_auth_type_desc = _("IDS_COM_BODY_NONE");
324                         break;
325                 }
326
327
328                 char *full_addr = NULL;
329                 char *addr = NULL;
330                 char *port = NULL;
331                 //Fix the Port 'NULL' issue when enter connection view repeatly..
332                 connection_profile_get_proxy_address(ad->sel_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, &full_addr);
333                 char ProxyAddr[MAX_PROXY_LEN_MAX+1] = {0,};
334                 safeCopyStr(ProxyAddr, full_addr, MAX_PROXY_LEN_MAX);
335                 G_FREE(full_addr);
336
337                 SETTING_TRACE("ProxyAddr:%s", ProxyAddr);
338                 //several real format after removing "http://":
339                 //      ":80", "1.1.1.1:80","1.1.1.1: ", "127.0.0.1/", "127.0.0.1"
340                 full_addr = ProxyAddr;
341                 int url_head_len = strlen(URL_HEAD);
342                 if (0 == safeStrNCmp(full_addr, URL_HEAD, url_head_len))
343                 {
344                         full_addr += url_head_len;
345                 }
346                 addr = strsep(&full_addr, ":");
347                 if (NULL == full_addr)//format like "http://127.0.0.1/" or "http://127.0.0.1"
348                 {
349                         SETTING_TRACE("NULL == full_addr");
350                         addr = strsep(&addr, "/");
351                 }
352                 if (is_ip_string(addr))
353                 {
354                         port = strsep(&full_addr, "/");
355                 }
356                 else //invalid format,let addr and port to be NULL.
357                 {
358                         addr = NULL;
359                 }
360                 SETTING_TRACE("addr:%s", addr);
361                 SETTING_TRACE("port:%s", port);
362                 ad->ed_pxy_addr_desc = g_strdup(addr);
363                 ad->ed_pxy_port_desc = g_strdup(port);
364                 //if (ad->con_type == NET_SERVICE_MMS) {        /* Message Connection */
365                 if (!safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS)) {   /* Message Connection */
366                         //ad->ed_hm_url_desc = ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.HomeURL;
367                         connection_profile_get_cellular_home_url(ad->sel_profile_h, &(ad->ed_hm_url_desc));
368                 }
369         } else {
370                 SETTING_TRACE("Didn't find any record, to let add a new one:");
371                 ad->sel_profile_h = NULL;
372                 ad->ed_auth_type_desc = _("IDS_COM_BODY_NONE");
373                 ad->chkType = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
374         }
375
376         //release the memory..
377         G_FREE(apn);
378         G_FREE(profile_name);
379         return;
380 }
381 void __update_genlist_info(void *cb)
382 {
383         SETTING_TRACE_BEGIN;
384         ret_if(cb == NULL);
385         SettingNetworkUG *ad = (SettingNetworkUG *) cb;
386         if (ad->data_acs_name)
387         {
388                 ad->data_acs_name->sub_desc = g_strdup(ad->ed_acs_name_desc);
389         }
390
391         if (ad->data_auth_type)
392         {
393                 ad->data_auth_type->sub_desc = g_strdup(ad->ed_auth_type_desc);
394                 if (ad->sel_profile_h) {
395                         //int authType = ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.AuthInfo.AuthType;
396                         connection_cellular_auth_type_e authType = 0;
397                         char *user_name;
398                         char *pwd;
399                         connection_profile_get_cellular_auth_info(ad->sel_profile_h, &authType, &user_name, &pwd);
400                         ad->chkType = !ad->chkType;
401                         setting_network_edit_connection_display_auth_type(ad, authType);
402                 }
403         }
404         if (ad->data_user_name)
405         {
406                 ad->data_user_name->sub_desc = g_strdup(ad->ed_user_name_desc);
407         }
408         if (ad->data_pwd)
409         {
410                 ad->data_pwd->sub_desc = g_strdup(ad->ed_pwd_desc);
411         }
412
413         if (ad->data_pxy_addr)
414         {
415                 ad->data_pxy_addr->sub_desc = g_strdup(ad->ed_pxy_addr_desc);
416         }
417         if (ad->data_pxy_port)
418         {
419                 ad->data_pxy_port->sub_desc = g_strdup(ad->ed_pxy_port_desc);
420         }
421         if (ad->data_hm_url)
422         {
423                 ad->data_hm_url->sub_desc = g_strdup(ad->ed_hm_url_desc);
424         }
425         elm_genlist_realized_items_update(ad->scl_edit);
426         return;
427 }
428
429 static int setting_network_connection_create(void *cb)
430 {
431         SETTING_TRACE_BEGIN;
432         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
433
434         SettingNetworkUG *ad = (SettingNetworkUG *) cb;
435
436         setting_retvm_if(!ad->con_name, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "!ad->con_name")
437
438         Evas_Object *scroller = elm_genlist_add(ad->win_main_layout);
439         elm_object_style_set(scroller, "dialogue");
440         retvm_if(scroller == NULL, SETTING_DRAW_ERR_FAIL_SCROLLER,
441                  "Cannot set scroller object  as contento of layout");
442         elm_genlist_clear(scroller);    /* first to clear list */
443
444         /* connection intializes */
445         ad->data_hm_url = NULL;
446         ad->data_pwd = NULL;
447         ad->data_user_name = NULL;
448         ad->data_pxy_addr = NULL;
449         ad->data_acs_name = NULL;
450         ad->data_auth_type = NULL;
451
452         ad->navi_it = setting_push_layout_navi_bar(_(ad->con_name),
453                                      _("IDS_COM_BODY_BACK"),
454                                      _(KeyStr_Edit),
455                                      NULL,//_(KeyStr_Reset_Def),
456                                      setting_network_edit_connection_click_softkey_back_cb,
457                                      setting_network_edit_connection_click_softkey_eidt_cb,
458                                      NULL,
459                                      ad, scroller, ad->navi_bar, NULL);
460
461         retv_if(!ad->navi_it, SETTING_RETURN_FAIL);
462         ad->has_form_changed  = FALSE;
463
464         setting_enable_expandable_genlist(scroller, ad,
465                                           __setting_network_connection_exp_cb,
466                                           NULL);
467         evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_UP,
468                                        __network_connection_gl_mouse_up, ad);
469         __get_connection_info(ad);
470         Elm_Object_Item *item;
471
472         /* item = elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); */
473         item =
474             elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
475                                     ELM_GENLIST_ITEM_NONE, NULL, NULL);
476         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
477         ad->data_acs_name =
478             setting_create_Gendial_field_def(scroller,
479                                              &itc_1icon, NULL,
480                                              NULL, SWALLOW_Type_LAYOUT_ENTRY,
481                                              NULL, NULL, 0,
482                                              "IDS_ST_BODY_ACCESS_NAME",
483                                              (char *)ad->ed_acs_name_desc,
484                                              setting_network_connection_entry_changed_cb);
485         if (ad->data_acs_name) {
486                 ad->data_acs_name->userdata = ad;
487                 ad->data_acs_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
488                 if (ad->data_acs_name->limit_filter_data) {
489                         ad->data_acs_name->limit_filter_data->max_byte_count = MAX_PDP_APN_LEN_MAX - 1;
490                         ad->data_acs_name->win_main = ad->win_get;
491                 }
492
493         } else {
494                 SETTING_TRACE_ERROR("ad->data_acs_name is NULL");
495         }
496
497         item =
498             elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
499                                     ELM_GENLIST_ITEM_GROUP, NULL, NULL);
500         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
501
502         ad->data_auth_type =
503             setting_create_Gendial_exp_parent_field(scroller,
504                                                     &itc_2text_3_parent,
505                                                     NULL, NULL,
506                                                     SWALLOW_Type_INVALID,
507                                                     "IDS_ST_BODY_AUTH_TYPE",
508                                                     (char *)ad->ed_auth_type_desc);
509         /* ad->data_auth_type->int_slp_setting_binded = INT_SLP_SETTING_INVALID; */
510         if (ad->data_auth_type) {
511                 ad->data_auth_type->userdata = ad;
512         } else {
513                 SETTING_TRACE_ERROR("ad->data_auth_type is NULL");
514         }
515
516         ad->item_above_user_name = item =
517             elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
518                                     ELM_GENLIST_ITEM_NONE, NULL, NULL);
519         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
520
521         ad->is_show_user = 0;
522         if (CONNECTION_CELLULAR_AUTH_TYPE_NONE != ad->chkType) {
523                 ad->data_user_name =
524                     setting_create_Gendial_field_def(scroller,
525                                                      &itc_1icon,
526                                                      NULL, NULL,
527                                                      SWALLOW_Type_LAYOUT_ENTRY,
528                                                      NULL, NULL, 0,
529                                                      "IDS_COM_BODY_USER_NAME",
530                                                      (char *)
531                                                      ad->ed_user_name_desc,
532                                                      setting_network_connection_entry_changed_cb);
533                 if (ad->data_user_name) {
534                         ad->data_user_name->userdata = ad;
535                         ad->data_user_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
536                         if (ad->data_user_name->limit_filter_data) {
537                                 ad->data_user_name->limit_filter_data->max_byte_count = MAX_PDP_AUTH_USERNAME_LEN_MAX - 1;
538                                 ad->data_user_name->win_main = ad->win_get;
539                         }
540                 } else {
541                         SETTING_TRACE_ERROR("ad->data_user_name is NULL");
542                 }
543
544                 ad->data_pwd =
545                     setting_create_Gendial_field_def(scroller,
546                                                      &itc_1icon,
547                                                      NULL, NULL,
548                                                      SWALLOW_Type_LAYOUT_ENTRY,
549                                                      NULL, NULL, 0,
550                                                      "IDS_COM_BODY_PASSWORD",
551                                                      (char *)ad->ed_pwd_desc,
552                                                      setting_network_connection_entry_changed_cb);
553                 if (ad->data_pwd) {
554                         ad->data_pwd->userdata = ad;
555                         ad->is_show_user = 1;
556                         ad->data_pwd->isPasswordFlag = TRUE;
557                         ad->data_pwd->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
558                         if (ad->data_pwd->limit_filter_data) {
559                                 ad->data_pwd->limit_filter_data->max_byte_count = MAX_PDP_AUTH_PASSWORD_LEN_MAX - 1;
560                                 ad->data_pwd->win_main = ad->win_get;
561                         }
562                 } else {
563                         SETTING_TRACE_ERROR("ad->data_pwd is NULL");
564                 }
565
566                 ad->item_above_proxy_add = item =
567                     elm_genlist_item_append(scroller, &itc_seperator,
568                                             NULL, NULL, ELM_GENLIST_ITEM_NONE,
569                                             NULL, NULL);
570                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
571         }
572
573         ad->data_pxy_addr =
574             setting_create_Gendial_field_def(scroller,
575                                              &itc_1icon, NULL,
576                                              NULL, SWALLOW_Type_LAYOUT_ENTRY,
577                                              NULL, NULL, 0,
578                                              "IDS_ST_BODY_CONNECTIONSETTINGS_PROXY_ADDRESS",
579                                              (char *)ad->ed_pxy_addr_desc,
580                                              setting_network_connection_entry_changed_cb);
581         if (ad->data_pxy_addr) {
582                 ad->data_pxy_addr->userdata = ad;
583                 ad->data_pxy_addr->input_type = ELM_INPUT_PANEL_LAYOUT_IP;
584         } else {
585                 SETTING_TRACE_ERROR("ad->data_pxy_addr is NULL");
586         }
587
588         ad->data_pxy_port =
589             setting_create_Gendial_field_def(scroller,
590                                              &itc_1icon, NULL,
591                                              NULL, SWALLOW_Type_LAYOUT_ENTRY,
592                                              NULL, NULL, 0,
593                                              "IDS_ST_BODY_PROXY_PORT",
594                                              (char *)ad->ed_pxy_port_desc,
595                                              setting_network_connection_entry_changed_cb);
596         if (ad->data_pxy_port) {
597                 ad->data_pxy_port->userdata = ad;
598                 ad->data_pxy_port->input_type = ELM_INPUT_PANEL_LAYOUT_NUMBERONLY;
599         } else {
600                 SETTING_TRACE_ERROR("ad->data_pxy_port is NULL");
601         }
602
603         if (!safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS)) {   /*  mms Connection */
604                 ad->data_hm_url =
605                     setting_create_Gendial_field_def(scroller,
606                                                      &itc_1icon,
607                                                      NULL, NULL,
608                                                      SWALLOW_Type_LAYOUT_ENTRY,
609                                                      NULL, NULL, 0,
610                                                      "IDS_ST_BODY_HOME_URL",
611                                                      (char *)ad->ed_hm_url_desc,
612                                                      setting_network_connection_entry_changed_cb);
613                 if (ad->data_hm_url) {
614                         ad->data_hm_url->userdata = ad;
615                         ad->data_hm_url->input_type = ELM_INPUT_PANEL_LAYOUT_URL;
616                         ad->data_hm_url->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
617                         if (ad->data_hm_url->limit_filter_data) {
618                                 ad->data_hm_url->limit_filter_data->max_byte_count = MAX_HOME_URL_LEN_MAX - 1;
619                                 ad->data_hm_url->win_main = ad->win_get;
620                         }
621                 } else {
622                         SETTING_TRACE_ERROR("ad->data_hm_url is NULL");
623                 }
624                 /* ad->is_show_url = 1; */
625         }
626
627         item = elm_genlist_item_append(scroller, &itc_bottom_seperator, NULL, NULL,
628                                     ELM_GENLIST_ITEM_NONE, NULL, NULL);
629         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
630
631         setting_view_network_connection_create.is_create = 1;
632         ad->scl_edit = scroller;
633         __genlist_disable_set(ad->scl_edit, TRUE);
634         ecore_idler_add(__connection_idler, ad);
635         return SETTING_RETURN_SUCCESS;
636 }
637
638 static int setting_network_connection_destroy(void *cb)
639 {
640         SETTING_TRACE_BEGIN;
641         /* error check */
642         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
643
644         SettingNetworkUG *ad = (SettingNetworkUG *) cb;
645         ad->navi_it = NULL;
646         ad->bottom_btn = NULL;
647         ad->back_btn = NULL;
648         //manager separatly,
649         if (ad->l_button)
650         {
651                 evas_object_del(ad->l_button);
652                 ad->l_button = NULL;
653         }
654         /*if (ad->m_button)
655         {
656                 evas_object_del(ad->m_button);
657                 ad->m_button = NULL;
658         }*/
659         if (ad->r_button)
660         {
661                 evas_object_del(ad->r_button);
662                 ad->r_button = NULL;
663         }
664         FREE(ad->con_name);
665         G_FREE(ad->ed_acs_name_desc);
666         G_FREE(ad->ed_user_name_desc);
667         G_FREE(ad->ed_pwd_desc);
668
669         G_FREE(ad->ed_pxy_addr_desc);
670         G_FREE(ad->ed_pxy_port_desc);
671
672         G_FREE(ad->ed_hm_url_desc);
673         //if (ad->prof_list)
674         //{
675         //      connection_profile_destroy(ad->prof_list);
676         //      ad->prof_list = NULL;
677         //}
678
679         elm_naviframe_item_pop(ad->navi_bar);
680         setting_view_network_connection_create.is_create = 0;
681         return SETTING_RETURN_SUCCESS;
682 }
683
684 static int setting_network_connection_update(void *cb)
685 {
686         SETTING_TRACE_BEGIN;
687         return SETTING_RETURN_SUCCESS;
688 }
689
690 static int setting_network_connection_cleanup(void *cb)
691 {
692         return setting_network_connection_destroy(cb);
693 }
694
695 /* ***************************************************
696  *
697  *general func
698  *
699  ***************************************************/
700
701 static int __save_connection(void *data)
702 {
703         SETTING_TRACE_BEGIN;
704         /* error check */
705         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
706
707         SettingNetworkUG *ad = (SettingNetworkUG *) data;
708         const char *acs_name = NULL;
709         const char *usr_name = NULL;
710         const char *pwd = NULL;
711         const char *addr = NULL;
712         const char *port = NULL;
713         const char *home = NULL;
714
715         if (ad->data_acs_name)
716                 acs_name = elm_entry_markup_to_utf8(ad->data_acs_name->sub_desc);
717         if (ad->data_user_name)
718                 usr_name = elm_entry_markup_to_utf8(ad->data_user_name->sub_desc);
719         if (ad->data_pwd)
720                 pwd = elm_entry_markup_to_utf8(ad->data_pwd->sub_desc);
721         if (ad->data_pxy_addr)
722                 addr = elm_entry_markup_to_utf8(ad->data_pxy_addr->sub_desc);
723         if (ad->data_pxy_port)
724                 port = elm_entry_markup_to_utf8(ad->data_pxy_port->sub_desc);
725
726         if (!acs_name)
727                 acs_name = strdup("");
728         if (!usr_name)
729                 usr_name = strdup("");
730         if (!pwd)
731                 pwd = strdup("");
732         if (!addr)
733                 addr = strdup("");
734         if (!port)
735                 port = strdup("");
736         SETTING_TRACE("acs_name:%s", acs_name);
737         SETTING_TRACE("usr_name:%s", usr_name);
738         SETTING_TRACE("pwd:%s", pwd);
739
740         SETTING_TRACE("addr:%s", addr);
741         SETTING_TRACE("port:%s", port);
742         SETTING_TRACE("home:%s", home);
743
744         char sz_text[MAX_PROXY_LEN_MAX + 1] = { 0, };
745         int type;
746         int ret = SETTING_RETURN_SUCCESS;
747         int err;
748
749         if (!safeStrCmp(acs_name, "")) {
750                 setting_create_simple_popup(ad, ad->win_get,
751                                             NULL, _(Insert_Access_Name_desc));
752                 FREE(acs_name);
753                 FREE(usr_name);
754                 FREE(pwd);
755                 FREE(addr);
756                 FREE(port);
757                 return SETTING_DNET_RETURN_NULL_ACCESS_NAME;
758         }
759         //if (test_update_cellular_info(profile) == -1)
760         bool add_flag = FALSE;//add a new profile
761         connection_profile_h con_info = NULL;
762         if (ad->sel_profile_h) {
763                 con_info = ad->sel_profile_h;
764                 if(0 != safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS)
765                    && 0 != safeStrCmp(ad->con_name, "IDS_ST_BODY_INTERNET_CONNECTION"))
766                 {
767                         //need to change con_name
768                         FREE(ad->con_name);
769                         ad->con_name = strdup(acs_name);
770                 }
771                 SETTING_TRACE("ad->con_name:%s", ad->con_name);
772
773         } else {
774                 SETTING_TRACE("ad->con_name:%s", ad->con_name);
775                 if(!safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS))
776                 {
777                         connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, _(ad->con_name), &con_info);
778                         connection_profile_set_cellular_service_type(con_info,CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
779                 }
780                 else if(!safeStrCmp(ad->con_name, "IDS_ST_BODY_INTERNET_CONNECTION"))
781                 {
782                         connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, _(ad->con_name), &con_info);
783                         connection_profile_set_cellular_service_type(con_info,CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
784                 }
785                 else
786                 {
787                         //need to change con_name
788                         FREE(ad->con_name);
789                         ad->con_name = strdup(acs_name);
790                         connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, _(ad->con_name), &con_info);
791                         connection_profile_set_cellular_service_type(con_info,CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION);
792                 }
793
794                 SETTING_TRACE("ad->con_name:%s", ad->con_name);
795                 add_flag = TRUE;
796         }
797
798         /* save access name */
799         connection_profile_set_cellular_apn(con_info, acs_name);
800         FREE(acs_name);
801
802         /* save auth type */
803         /* type = elm_radio_value_get(ad->chk_type); */
804         type = ad->chkType;
805         /* save user name */
806         if (!safeStrCmp(usr_name, "")
807             && CONNECTION_CELLULAR_AUTH_TYPE_NONE != type) {
808                 setting_create_simple_popup(ad, ad->win_get,
809                                             NULL, _(Insert_User_Name_Desc));
810                 FREE(usr_name);
811                 FREE(pwd);
812                 FREE(addr);
813                 FREE(port);
814                 return SETTING_DNET_RETURN_NULL_USER_NAME;
815         }
816
817         /* save password */
818         if (!safeStrCmp(pwd, "")
819             && CONNECTION_CELLULAR_AUTH_TYPE_NONE != type) {
820                 setting_create_simple_popup(ad, ad->win_get,
821                                             NULL, _("IDS_ST_BODY_ENTER_PASSWORD"));
822                 FREE(usr_name);
823                 FREE(pwd);
824                 FREE(addr);
825                 FREE(port);
826                 return SETTING_DNET_RETURN_NULL_PASSWORD;
827         }
828
829         connection_profile_set_cellular_auth_info(con_info, type, usr_name, pwd);
830
831         /* save proxy addr */
832         SETTING_TRACE("addr:port[%s:%s]", addr, port);
833         if (!safeStrCmp(addr, "")) {
834                 /* check proxy port */
835                 if (!safeStrCmp(port, ""))
836                 {
837                         //it is the normal case.
838                 }
839                 else //like ":80",it's forbiden
840                 {
841                         setting_create_simple_popup(ad, ad->win_get,
842                                                     NULL, _("Incorrect proxy address, please add correct adress or clear the port field."));
843                         FREE(usr_name);
844                         FREE(pwd);
845                         FREE(addr);
846                         FREE(port);
847                         return SETTING_DNET_RETURN_INVALID_PROXY_ADDR;
848                 }
849         } else if (!is_ip_string(addr)) {
850                 setting_create_simple_popup(ad, ad->win_get,
851                                             NULL, _("IDS_ST_HEADER_INCORRECT_PROXY_ADDRESS"));
852                 FREE(usr_name);
853                 FREE(pwd);
854                 FREE(addr);
855                 FREE(port);
856                 return SETTING_DNET_RETURN_INVALID_PROXY_ADDR;
857         }
858
859         ret = snprintf(sz_text, sizeof(sz_text), "%s:%s", addr, port);
860         retv_if(ret < 0, SETTING_DNET_RETURN_ERR);
861         connection_profile_set_proxy_address(con_info, CONNECTION_ADDRESS_FAMILY_IPV4, sz_text);
862
863         /* save home url(message connection only) */
864         if (!safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS)) {   /* Message Connection */
865                 home = elm_entry_markup_to_utf8(ad->data_hm_url->sub_desc);
866                 if (home == (char *)NULL) {
867                         connection_profile_set_cellular_home_url(con_info, URL_HEAD);
868                 } else {
869                         if (!safeStrCmp(home, "")) {
870                                 FREE(home);
871                                 home = strdup(URL_HEAD);
872                                 ret = SETTING_DNET_RETURN_NULL_HOMEURL;
873                         }
874                         connection_profile_set_cellular_home_url(con_info, home);
875                 }
876         } else if (!safeStrCmp(ad->con_name, "IDS_ST_BODY_INTERNET_CONNECTION")) {
877                 if (add_flag)
878                 {
879                         //For internet, it needs call following api to set the default profile.
880                         connection_set_default_cellular_service_profile(ad->connection, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET, con_info);
881                 }
882         }
883
884         FREE(usr_name);
885         FREE(pwd);
886         FREE(addr);
887         FREE(port);
888         FREE(home);
889         //SETTING_TRACE("ad->con_type:%d", ad->con_type);
890         /* save connection */
891         if (add_flag) {
892                 //con_info->profile_type = NET_DEVICE_CELLULAR;
893                 //con_info->ProfileState = NET_STATE_TYPE_UNKNOWN;
894                 //con_info->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_GPRS;
895                 err = connection_add_profile(ad->connection, con_info);
896                 if (err != CONNECTION_ERROR_NONE) {
897                         SETTING_TRACE_ERROR
898                             ("%s*** [ERR] connection_add_profile. err=%d ***%s",
899                              SETTING_FONT_RED, err, SETTING_FONT_BLACK);
900                         ret = SETTING_DNET_RETURN_ERR;
901                         setting_create_simple_popup(ad, ad->win_get,
902                                                     NULL, _("IDS_COM_POP_FAILED"));
903                         return ret;
904                 }
905                 connection_profile_destroy(con_info);
906         } else {
907
908                 err = connection_update_profile(ad->connection, con_info);
909                 if (err != CONNECTION_ERROR_NONE) {
910                         SETTING_TRACE_ERROR
911                             ("%s*** [ERR] net_modify_profile. err=%d ***%s",
912                              SETTING_FONT_RED, err, SETTING_FONT_BLACK);
913                         ret = SETTING_DNET_RETURN_ERR;
914                         setting_create_simple_popup(ad, ad->win_get,
915                                                     NULL, _("IDS_COM_POP_FAILED"));
916                 }
917         }
918         return ret;
919 }
920
921 /* ***************************************************
922  *
923  *call back func
924  *
925  ***************************************************/
926 static void
927 setting_network_edit_connection_click_softkey_eidt_cb(void *data,
928                                                       Evas_Object *obj,
929                                                       void *event_info)
930 {
931         SETTING_TRACE_BEGIN;
932         /* error check */
933         retm_if(data == NULL, "Data parameter is NULL");
934
935         SettingNetworkUG *ad = (SettingNetworkUG *) data;
936         //setting_enable_evas_object(ad->scl_edit);
937         __genlist_disable_set(ad->scl_edit, FALSE);
938         /*  create buttons */
939         if (!ad->l_button) //go into first time
940         {
941                 ad->l_button = setting_create_button(ad->navi_bar, _("IDS_COM_SK_DONE"),
942                                                          "naviframe/title/icon/edit",
943                                                          setting_network_edit_connection_click_softkey_save_cb,
944                                                          ad);
945         }
946
947         if (!ad->r_button) //go into first time
948         {
949                 ad->r_button = setting_create_button(ad->navi_bar, _("IDS_COM_SK_CANCEL"),
950                                                          NAVI_BACK_BUTTON_STYLE,
951                                                          setting_network_edit_connection_click_softkey_cancel_cb,
952                                                          ad);
953         }
954         /*if (!ad->m_button) //go into first time
955         {
956                 ad->m_button = setting_create_button(ad->navi_bar, NULL,
957                                                          BTN_STYLE_DEF,
958                                                          NULL, ad);
959         }*/
960         if (ad->l_button) {
961                 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_LEFT, ad->l_button);
962                 evas_object_show(ad->l_button);
963         }
964         if (ad->r_button) {
965                 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_RIGHT, ad->r_button);
966                 ad->has_form_changed = TRUE;//intialize
967                 setting_network_connection_check_entry_empty(ad);
968                 ad->has_form_changed = FALSE;//restore
969         }
970         /*if (ad->m_button) {
971                 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_MORE, ad->m_button);
972                 evas_object_show(ad->r_button);
973         }*/
974
975         //remove '<-' button
976         ad->back_btn = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_PREV);
977         elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_PREV, NULL);
978         evas_object_hide(ad->back_btn);
979
980         //remove other buttons
981         ad->bottom_btn = elm_object_item_part_content_unset(ad->navi_it, "toolbar_button1");
982         elm_object_item_part_content_set(ad->navi_it, "toolbar_button1", NULL);
983         evas_object_hide(ad->bottom_btn);
984 }
985
986
987 static void
988 setting_network_edit_connection_click_softkey_save_cb(void *data,
989                                                       Evas_Object *obj,
990                                                       void *event_info)
991 {
992         SETTING_TRACE_BEGIN;
993         /* error check */
994         retm_if(data == NULL, "Data parameter is NULL");
995
996         SettingNetworkUG *ad = (SettingNetworkUG *) data;
997         /* elm_box_unpack_all(ad->bx_blk); */
998         /* elm_dialoguegroup_remove_all(ad->dg_blk); */
999
1000         int ret = __save_connection(ad);
1001         /* need special handle */
1002         if (SETTING_DNET_RETURN_NULL_ACCESS_NAME == ret
1003             || SETTING_DNET_RETURN_NULL_USER_NAME == ret
1004             || SETTING_DNET_RETURN_NULL_PASSWORD == ret
1005             || SETTING_DNET_RETURN_INVALID_PROXY_ADDR == ret
1006             || SETTING_DNET_RETURN_ERR == ret) {
1007                 return;
1008         }
1009         if (ret != SETTING_RETURN_SUCCESS) {
1010                 SETTING_TRACE_ERROR
1011                     ("%s*** [ERR] __save_connection ***%s",
1012                      SETTING_FONT_RED, SETTING_FONT_BLACK);
1013         }
1014
1015         setting_create_popup_without_btn(ad, ad->win_get, NULL, _(KeyStr_Saved), NULL, POPUP_INTERVAL, FALSE, FALSE);
1016         //re-fetch connection info..
1017         __get_connection_info(ad);
1018
1019         //UI update
1020         elm_object_item_text_set(ad->navi_it, _(ad->con_name));
1021         setting_network_edit_connection_click_softkey_cancel_cb(ad, ad->r_button, NULL);
1022 }
1023
1024 static void
1025 setting_network_edit_connection_click_softkey_back_cb(void *data,
1026                                                         Evas_Object *obj,
1027                                                         void *event_info)
1028 {
1029         SETTING_TRACE_BEGIN;
1030         /* error check */
1031         retm_if(data == NULL, "Data parameter is NULL");
1032
1033         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1034         /* elm_box_unpack_all(ad->bx_blk); */
1035         /* elm_dialoguegroup_remove_all(ad->dg_blk); */
1036         setting_view_change(&setting_view_network_connection_create,
1037                             &setting_view_network_con, ad);
1038 }
1039 static void
1040 setting_network_edit_connection_click_softkey_cancel_cb(void *data,
1041                                                         Evas_Object *obj,
1042                                                         void *event_info)
1043 {
1044         SETTING_TRACE_BEGIN;
1045         /* error check */
1046         retm_if(data == NULL, "Data parameter is NULL");
1047
1048         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1049         ad->l_button = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_LEFT);
1050         elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_LEFT, NULL);
1051         evas_object_hide(ad->l_button);
1052 /*
1053         ad->m_button = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_MORE);
1054         elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_MORE, NULL);
1055         evas_object_hide(ad->m_button);*/
1056
1057         ad->r_button = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_RIGHT);
1058         elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_RIGHT, NULL);
1059         evas_object_hide(ad->r_button);
1060         //setting_disable_evas_object(ad->r_button);
1061         setting_undo_dim_evas_object(ad->r_button, TRUE);
1062
1063         elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_PREV, ad->back_btn);
1064         elm_object_item_part_content_set(ad->navi_it, "toolbar_button1", ad->bottom_btn);
1065         evas_object_show(ad->back_btn);
1066         evas_object_show(ad->bottom_btn);
1067
1068         __get_connection_info(ad);
1069         __update_genlist_info(ad);
1070         if(ad->data_auth_type) elm_genlist_item_expanded_set(ad->data_auth_type->item, FALSE);
1071         ecore_idler_add(__connection_idler, ad);
1072 }
1073 static void _gl_Gendial_sel(void *data, Evas_Object *obj, void *event_info)
1074 {
1075         /* SETTING_TRACE_BEGIN; */
1076         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1077         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1078         elm_genlist_item_selected_set(item, 0);
1079         return;
1080 }
1081
1082 static void setting_network_connection_check_entry_empty(SettingNetworkUG *ad)
1083 {
1084         SETTING_TRACE_BEGIN;
1085         if (!ad->has_form_changed)
1086         {
1087                 SETTING_TRACE_DEBUG("ad->has_form_changed == FALSE!");
1088                 return;
1089         }
1090         bool isFoundEmptyEntry = FALSE;
1091
1092         do {
1093                 if (ad->data_acs_name && isEmptyStr(ad->data_acs_name->sub_desc)) {
1094                         SETTING_TRACE("entry_str:%s", ad->data_acs_name->sub_desc);
1095                         isFoundEmptyEntry = TRUE;
1096                         break;
1097                 }
1098                 if (ad->data_user_name && isEmptyStr(ad->data_user_name->sub_desc)) {
1099                         SETTING_TRACE("entry_str:%s", ad->data_user_name->sub_desc);
1100                         isFoundEmptyEntry = TRUE;
1101                         break;
1102                 }
1103                 if (ad->data_pwd && isEmptyStr(ad->data_pwd->sub_desc)) {
1104                         SETTING_TRACE("entry_str:%s", ad->data_pwd->sub_desc);
1105                         isFoundEmptyEntry = TRUE;
1106                         break;
1107                 }
1108                 if (ad->data_hm_url && isEmptyStr(ad->data_hm_url->sub_desc)) {
1109                         SETTING_TRACE("entry_str:%s", ad->data_hm_url->sub_desc);
1110                         isFoundEmptyEntry = TRUE;
1111                         break;
1112                 }
1113         } while (0);
1114         Evas_Object *done_btn = elm_object_item_part_content_get(ad->navi_it, NAVI_BTN_STYLE_LEFT);
1115         if (isFoundEmptyEntry) {
1116                 if (!evas_object_pass_events_get(done_btn)) {//it had not yet been disabled
1117                         setting_disable_evas_object(done_btn);
1118                         setting_dim_evas_object(done_btn, TRUE);
1119                 }
1120                 else
1121                 {
1122                     //do nothing..if invoke setting_dim_evas_object many times, the done button will be dimer until it cannot be see.
1123                     //refer to the API of setting_dim_evas_object(). The API is supplied by Setting itself, winset doesn't support until now as I now.
1124                 }
1125         } else {
1126                 setting_enable_evas_object(done_btn);
1127                 setting_undo_dim_evas_object(done_btn, TRUE);
1128         }
1129 }
1130
1131 static void
1132 setting_network_edit_connection_display_auth_type(SettingNetworkUG *ad,
1133                                                   int auth_type)
1134 {
1135         SETTING_TRACE_BEGIN;
1136         retm_if(ad == NULL, "Data parameter is NULL");
1137         if (ad->chkType == auth_type) return;
1138
1139         ad->chkType = auth_type;        /* for update genlist */
1140         if (CONNECTION_CELLULAR_AUTH_TYPE_NONE != auth_type) {  /* to show */
1141                 SETTING_TRACE("ad->is_show_user:%d", ad->is_show_user);
1142                 if (ad->is_show_user == 0) {    /* do only when hiden */
1143                         SETTING_TRACE("to create");
1144
1145                         ad->data_user_name =
1146                             (Setting_GenGroupItem_Data *) calloc(1,
1147                                                                  sizeof
1148                                                                  (Setting_GenGroupItem_Data));
1149                         setting_retm_if(ad->data_user_name == NULL, "calloc failed");
1150                         ad->data_user_name->keyStr =
1151                             (char *)g_strdup("IDS_COM_BODY_USER_NAME");
1152                         ad->data_user_name->sub_desc =
1153                             (char *)g_strdup(ad->ed_user_name_desc);
1154                         ad->data_user_name->swallow_type =
1155                             SWALLOW_Type_LAYOUT_ENTRY;
1156                         ad->data_user_name->userdata = ad;
1157                         ad->data_user_name->chk_change_cb =
1158                             setting_network_connection_entry_changed_cb;
1159                         ad->data_user_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
1160                         if (ad->data_user_name->limit_filter_data) {
1161                                 ad->data_user_name->limit_filter_data->max_byte_count = MAX_PDP_AUTH_USERNAME_LEN_MAX - 1;
1162                                 ad->data_user_name->win_main = ad->win_get;
1163                         }
1164                         ad->data_user_name->item =
1165                             elm_genlist_item_insert_after(ad->scl_edit,
1166                                                           &itc_1icon,
1167                                                           ad->data_user_name,
1168                                                           NULL,
1169                                                           ad->item_above_user_name,
1170                                                           ELM_GENLIST_ITEM_NONE,
1171                                                           _gl_Gendial_sel, ad);
1172
1173                         ad->data_pwd =
1174                             (Setting_GenGroupItem_Data *) calloc(1,
1175                                                                  sizeof
1176                                                                  (Setting_GenGroupItem_Data));
1177
1178                         setting_retm_if(ad->data_pwd == NULL, "calloc failed");
1179                         ad->data_pwd->keyStr =
1180                             (char *)g_strdup("IDS_COM_BODY_PASSWORD");
1181                         ad->data_pwd->sub_desc =
1182                             (char *)g_strdup(ad->ed_pwd_desc);
1183                         ad->data_pwd->swallow_type = SWALLOW_Type_LAYOUT_ENTRY;
1184                         ad->data_pwd->userdata = ad;
1185                         ad->data_pwd->chk_change_cb =
1186                             setting_network_connection_entry_changed_cb;
1187                         ad->data_pwd->isPasswordFlag = TRUE;
1188                         /* ad->data_pwd->chk_change_cb = chk_change_cb; */
1189                         ad->data_pwd->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
1190                         if (ad->data_pwd->limit_filter_data) {
1191                                 ad->data_pwd->limit_filter_data->max_byte_count = MAX_PDP_AUTH_PASSWORD_LEN_MAX - 1;
1192                                 ad->data_pwd->win_main = ad->win_get;
1193                         }
1194                         ad->data_pwd->item =
1195                             elm_genlist_item_insert_after(ad->scl_edit,
1196                                                           &itc_1icon,
1197                                                           ad->data_pwd, NULL,
1198                                                           ad->
1199                                                           data_user_name->item,
1200                                                           ELM_GENLIST_ITEM_NONE,
1201                                                           _gl_Gendial_sel, ad);
1202
1203                         ad->item_above_proxy_add =
1204                             elm_genlist_item_insert_after(ad->scl_edit,
1205                                                           &itc_seperator,
1206                                                           NULL, NULL,
1207                                                           ad->data_pwd->item,
1208                                                           ELM_GENLIST_ITEM_NONE,
1209                                                           NULL, NULL);
1210                         elm_genlist_item_select_mode_set
1211                             (ad->item_above_proxy_add, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1212
1213                         ad->has_form_changed  = TRUE;
1214                         setting_network_connection_check_entry_empty(ad);
1215                         /* ad->is_show_user = 1; */
1216                 }
1217                 ad->is_show_user = 1;
1218         } else {                /* to hide */
1219
1220                 SETTING_TRACE("ad->is_show_user:%d", ad->is_show_user);
1221                 if (ad->is_show_user == 1) {    /* do only when shown */
1222                         SETTING_TRACE("to destroy");
1223                         if (ad->data_user_name) {
1224                                 elm_object_item_del(ad->data_user_name->item);
1225                                 ad->data_user_name = NULL;
1226                         }
1227                         if (ad->data_pwd) {
1228                                 elm_object_item_del(ad->data_pwd->item);
1229                                 ad->data_pwd = NULL;
1230                         }
1231                         if (ad->item_above_proxy_add) {
1232                                 elm_object_item_del(ad->item_above_proxy_add);
1233                                 ad->item_above_proxy_add = NULL;
1234                         }
1235
1236                 }
1237                 ad->has_form_changed  = TRUE;
1238                 setting_network_connection_check_entry_empty(ad);
1239                 ad->is_show_user = 0;
1240
1241         }
1242 }
1243
1244 static void
1245 setting_network_connection_entry_changed_cb(void *data, Evas_Object *obj,
1246                                             void *event_info)
1247 {
1248         SETTING_TRACE_BEGIN;
1249         retm_if(data == NULL, "Data parameter is NULL");
1250         Setting_GenGroupItem_Data *list_item =
1251             (Setting_GenGroupItem_Data *) data;
1252         SettingNetworkUG *ad = list_item->userdata;
1253         const char *entry_str = elm_entry_entry_get(obj);
1254         list_item->sub_desc = (char *)g_strdup(entry_str);
1255         //SETTING_TRACE("list_item->sub_desc:%s", list_item->sub_desc);
1256         ad->has_form_changed  = TRUE;
1257         setting_network_connection_check_entry_empty(ad);
1258 }
1259 static void
1260 setting_network_connection_hide_input_pannel(void *data)
1261 {
1262         SETTING_TRACE_BEGIN;
1263         retm_if(data == NULL, "Data parameter is NULL");
1264         SettingNetworkUG *ad = data;
1265         if (ad->data_acs_name) {
1266                 setting_hide_input_pannel_cb(ad->data_acs_name->eo_check);
1267         }
1268         if (ad->data_user_name) {
1269                 setting_hide_input_pannel_cb(ad->data_user_name->eo_check);
1270         }
1271         if (ad->data_pwd) {
1272                 setting_hide_input_pannel_cb(ad->data_pwd->eo_check);
1273         }
1274         if (ad->data_pxy_addr) {
1275                 setting_hide_input_pannel_cb(ad->data_pxy_addr->eo_check);
1276         }
1277         if (ad->data_pxy_port) {
1278                 setting_hide_input_pannel_cb(ad->data_pxy_port->eo_check);
1279         }
1280         if (ad->data_hm_url) {
1281                 setting_hide_input_pannel_cb(ad->data_hm_url->eo_check);
1282         }
1283 }
1284