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