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