1.Limit the max length of Network connection profile
[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;
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;
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;
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;
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 = ad->data_acs_name->sub_desc;
651         if (ad->data_user_name)
652                 usr_name = ad->data_user_name->sub_desc;
653         if (ad->data_pwd)
654                 pwd = ad->data_pwd->sub_desc;
655         if (ad->data_pxy_addr)
656                 addr = ad->data_pxy_addr->sub_desc;
657         if (ad->data_pxy_port)
658                 port = ad->data_pxy_port->sub_desc;
659
660         if (!acs_name)
661                 acs_name = "";
662         if (!usr_name)
663                 usr_name = "";
664         if (!pwd)
665                 pwd = "";
666         if (!addr)
667                 addr = "";
668         if (!port)
669                 port = "";
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                 return SETTING_DNET_RETURN_NULL_ACCESS_NAME;
694         } else {
695                 safeCopyStr(con_info->ProfileInfo.Pdp.Apn, acs_name,
696                             NET_PDP_APN_LEN_MAX);
697         }
698
699         /* save auth type */
700         /* type = elm_radio_value_get(ad->chk_type); */
701         type = ad->chkType;
702
703         switch (type) {
704         case NET_PDP_AUTH_PAP:  /*  Normal */
705
706                 con_info->ProfileInfo.Pdp.AuthInfo.AuthType =
707                     NET_PDP_AUTH_PAP;
708
709                 break;
710
711         case NET_PDP_AUTH_CHAP: /*  Secure */
712
713                 con_info->ProfileInfo.Pdp.AuthInfo.AuthType =
714                     NET_PDP_AUTH_CHAP;
715
716                 break;
717
718         case NET_PDP_AUTH_NONE: /*  None */
719
720                 con_info->ProfileInfo.Pdp.AuthInfo.AuthType =
721                     NET_PDP_AUTH_NONE;
722
723                 break;
724         default:
725                 /* do nothing*/
726                 break;
727         }
728         /* save user name */
729         if (!safeStrCmp(usr_name, "")
730             && NET_PDP_AUTH_NONE != type) {
731                 setting_create_simple_popup(ad, ad->win_get,
732                                             NULL, _(Insert_User_Name_Desc));
733                 return SETTING_DNET_RETURN_NULL_USER_NAME;
734         } else {
735                 safeCopyStr(con_info->ProfileInfo.Pdp.AuthInfo.UserName,
736                             usr_name, NET_PDP_AUTH_USERNAME_LEN_MAX - 1);
737         }
738         /* save password */
739         if (!safeStrCmp(pwd, "")
740             && NET_PDP_AUTH_NONE != type) {
741                 setting_create_simple_popup(ad, ad->win_get,
742                                             NULL, _("IDS_ST_BODY_ENTER_PASSWORD"));
743                 return SETTING_DNET_RETURN_NULL_PASSWORD;
744         } else {
745                 safeCopyStr(con_info->ProfileInfo.Pdp.AuthInfo.Password, pwd,
746                             NET_PDP_AUTH_PASSWORD_LEN_MAX - 1);
747         }
748
749         /* save proxy addr */
750         if (!safeStrCmp(addr, "")) {
751                 /* addr = "0.0.0.0"; */
752                 ret = SETTING_DNET_RETURN_NULL_PROXY_ADDR;
753         } else if (!is_ip_string(addr)) {
754                 setting_create_simple_popup(ad, ad->win_get,
755                                             NULL, _("IDS_ST_HEADER_INCORRECT_PROXY_ADDRESS"));
756                 return SETTING_DNET_RETURN_INVALID_PROXY_ADDR;
757         }
758         /* check proxy port */
759         if (!safeStrCmp(port, "")) {
760                 /* port =  "80"; */
761                 ret = SETTING_DNET_RETURN_NULL_PROXY_PORT;
762         }
763
764         ret = snprintf(sz_text, sizeof(sz_text), "%s:%s", addr, port);
765         retv_if(ret < 0, SETTING_DNET_RETURN_ERR);
766         safeCopyStr(con_info->ProfileInfo.Pdp.net_info.ProxyAddr, sz_text,
767                     NET_PROXY_LEN_MAX);
768
769         /* save home url(message connection only) */
770         if (ad->con_type == NET_SERVICE_MMS) {  /* Message Connection */
771                 home = ad->data_hm_url->sub_desc;
772                 if (home == (char *)NULL) {
773                         safeCopyStr(con_info->ProfileInfo.Pdp.HomeURL,
774                                     URL_HEAD, NET_HOME_URL_LEN_MAX);
775                 } else {
776                         if (!safeStrCmp(home, "")) {
777                                 home = URL_HEAD;
778                                 ret = SETTING_DNET_RETURN_NULL_HOMEURL;
779                         }
780
781                         safeCopyStr(con_info->ProfileInfo.Pdp.HomeURL, home,
782                                     NET_HOME_URL_LEN_MAX);
783                 }
784         }
785
786         SETTING_TRACE("ad->con_type:%d", ad->con_type);
787         /* save connection */
788         if (ad->prof_sel_idx == SETTING_ADD_PROFILE_INDEX) {
789                 /* add connection */
790                 if (ad->con_type == NET_SERVICE_INTERNET) {     /* Internet Connection */
791                         safeCopyStr(con_info->ProfileName,
792                                     "IDS_ST_BODY_INTERNET_CONNECTION",
793                                     strlen("IDS_ST_BODY_INTERNET_CONNECTION"));
794                         //con_info->ProfileInfo.Pdp.ServiceCategoryId = 1;
795                 } else {
796                         safeCopyStr(con_info->ProfileName, STR_SETTING_MMS_CONNECTIONS,
797                                     strlen(STR_SETTING_MMS_CONNECTIONS));
798                         //con_info->ProfileInfo.Pdp.ServiceCategoryId = 2;
799                 }
800                 /** Specifies a protocol type */
801
802                 /** network information */
803                 con_info->ProfileInfo.Pdp.ServiceType = ad->con_type;
804
805                 con_info->profile_type = NET_DEVICE_CELLULAR;
806                 con_info->ProfileState = NET_STATE_TYPE_UNKNOWN;
807                 con_info->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_GPRS;
808                 err = net_add_profile(ad->con_type, con_info);
809                 if (err != NET_ERR_NONE) {
810                         SETTING_TRACE_ERROR
811                             ("%s*** [ERR] net_add_profile. err=%d ***%s",
812                              SETTING_FONT_RED, err, SETTING_FONT_BLACK);
813                         ret = SETTING_DNET_RETURN_ERR;
814                         setting_create_simple_popup(ad, ad->win_get,
815                                                     NULL, _("IDS_COM_POP_FAILED"));
816                         return ret;
817                 }
818                 FREE(con_info);
819         } else {
820                 err = net_modify_profile(con_info->ProfileName, con_info);
821                 if (err != NET_ERR_NONE) {
822                         SETTING_TRACE_ERROR
823                             ("%s*** [ERR] net_modify_profile. err=%d ***%s",
824                              SETTING_FONT_RED, err, SETTING_FONT_BLACK);
825                         ret = SETTING_DNET_RETURN_ERR;
826                         setting_create_simple_popup(ad, ad->win_get,
827                                                     NULL, _("IDS_COM_POP_FAILED"));
828                 }
829         }
830         return ret;
831 }
832
833 /* ***************************************************
834  *
835  *call back func
836  *
837  ***************************************************/
838  #define BTN_STYLE_DEF "naviframe/title/default"
839 static void
840 setting_network_edit_connection_click_softkey_eidt_cb(void *data,
841                                                       Evas_Object *obj,
842                                                       void *event_info)
843 {
844         SETTING_TRACE_BEGIN;
845         /* error check */
846         retm_if(data == NULL, "Data parameter is NULL");
847
848         SettingNetworkUG *ad = (SettingNetworkUG *) data;
849         //setting_enable_evas_object(ad->scl_edit);
850         __genlist_disable_set(ad->scl_edit, FALSE);
851         /*  create buttons */
852         if (!ad->l_button) //go into first time
853         {
854                 ad->l_button = setting_create_button(ad->navi_bar, _("IDS_COM_SK_DONE"),
855                                                          BTN_STYLE_DEF,
856                                                          setting_network_edit_connection_click_softkey_save_cb,
857                                                          ad);
858         }
859
860         if (!ad->r_button) //go into first time
861         {
862                 ad->r_button = setting_create_button(ad->navi_bar, _("IDS_COM_SK_CANCEL"),
863                                                          BTN_STYLE_DEF,
864                                                          setting_network_edit_connection_click_softkey_cancel_cb,
865                                                          ad);
866         }
867         if (!ad->m_button) //go into first time
868         {
869                 ad->m_button = setting_create_button(ad->navi_bar, NULL,
870                                                          BTN_STYLE_DEF,
871                                                          NULL, ad);
872         }
873         if (ad->l_button) {
874                 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_LEFT, ad->l_button);
875                 evas_object_show(ad->l_button);
876         }
877         if (ad->r_button) {
878                 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_RIGHT, ad->r_button);
879                 ad->has_form_changed = TRUE;//intialize
880                 setting_network_connection_check_entry_empty(ad);
881                 ad->has_form_changed = FALSE;//restore
882         }
883         if (ad->m_button) {
884                 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_MORE, ad->m_button);
885                 evas_object_show(ad->r_button);
886         }
887
888         //remove '<-' button
889         ad->back_btn = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_PREV);
890         elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_PREV, NULL);
891         evas_object_hide(ad->back_btn);
892
893         //remove other buttons on controlbar
894         ad->controlbar = elm_object_item_part_content_unset(ad->navi_it, NAVI_CONTROLBAR_PART);
895         elm_object_item_part_content_set(ad->navi_it, NAVI_CONTROLBAR_PART, NULL);
896         evas_object_hide(ad->controlbar);
897 }
898 static void
899 setting_network_edit_connection_click_softkey_reset_cb(void *data,
900                                                       Evas_Object *obj,
901                                                       void *event_info)
902 {
903         SETTING_TRACE_BEGIN;
904         /* error check */
905         retm_if(data == NULL, "Data parameter is NULL");
906
907         SettingNetworkUG *ad = (SettingNetworkUG *) data;
908         net_profile_info_t *con_info = NULL;
909         int err = -1;
910         if (ad->prof_sel_idx != SETTING_ADD_PROFILE_INDEX) {
911                 con_info = &(ad->prof_list[ad->prof_sel_idx]);
912         } else {
913                 con_info = (net_profile_info_t *)calloc(1, sizeof(net_profile_info_t));
914                 setting_retm_if(!con_info, "Failed to alloc for net_profile_info_t");
915         }
916
917         const char *access_name = _("Connection");
918         int auth_type = NET_PDP_AUTH_NONE;
919         safeCopyStr(con_info->ProfileInfo.Pdp.Apn, access_name, NET_PDP_APN_LEN_MAX);
920         con_info->ProfileInfo.Pdp.AuthInfo.AuthType = auth_type;
921
922         safeCopyStr(con_info->ProfileInfo.Pdp.net_info.ProxyAddr, "0.0.0.0:80",
923                     NET_PROXY_LEN_MAX);
924         safeCopyStr(con_info->ProfileInfo.Pdp.HomeURL,
925                     URL_HEAD, NET_HOME_URL_LEN_MAX);
926
927         SETTING_TRACE("ad->con_type:%d", ad->con_type);
928         /* save connection */
929         if (ad->prof_sel_idx == SETTING_ADD_PROFILE_INDEX)
930         {
931                 /* add connection */
932                 if (ad->con_type == NET_SERVICE_INTERNET)
933                 {       /* Internet Connection */
934                         safeCopyStr(con_info->ProfileName,
935                                     "IDS_ST_BODY_INTERNET_CONNECTION",
936                                     strlen("IDS_ST_BODY_INTERNET_CONNECTION"));
937                         //con_info->ProfileInfo.Pdp.ServiceCategoryId = 1;
938                 }
939                 else
940                 {
941                         safeCopyStr(con_info->ProfileName, STR_SETTING_MMS_CONNECTIONS,
942                                     strlen(STR_SETTING_MMS_CONNECTIONS));
943                         //con_info->ProfileInfo.Pdp.ServiceCategoryId = 2;
944                 }
945                 /** Specifies a protocol type */
946
947                 /** network information */
948                 con_info->ProfileInfo.Pdp.ServiceType = ad->con_type;
949
950                 con_info->profile_type = NET_DEVICE_CELLULAR;
951                 con_info->ProfileState = NET_STATE_TYPE_UNKNOWN;
952                 con_info->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_GPRS;
953
954                 err = net_add_profile(ad->con_type, con_info);
955                 if (err != NET_ERR_NONE)
956                 {
957                         SETTING_TRACE_DEBUG
958                             ("%s*** [ERR] net_add_profile. err=%d ***%s",
959                              SETTING_FONT_RED, err, SETTING_FONT_BLACK);
960                         setting_create_simple_popup(ad, ad->win_get,
961                                                     NULL, _(Invok_API_Failed_Desc));
962                 }
963                 FREE(con_info);
964         }
965         else
966         {
967                 err = net_modify_profile(con_info->ProfileName, con_info);
968                 if (err != NET_ERR_NONE)
969                 {
970                         SETTING_TRACE_DEBUG
971                             ("%s*** [ERR] net_modify_profile. err=%d ***%s",
972                              SETTING_FONT_RED, err, SETTING_FONT_BLACK);
973                 }
974         }
975
976         if (err == NET_ERR_NONE) //update genlist when it operaters sucessfully
977         {
978                 if (!ad->prof_list) __get_connection_info(ad);//maybe new added
979                 ad->ed_acs_name_desc = access_name;
980                 ad->ed_user_name_desc = NULL;
981                 ad->ed_pwd_desc = NULL;
982                 ad->ed_pxy_addr_desc = g_strdup("0.0.0.0");
983                 ad->ed_pxy_port_desc = g_strdup("80");
984                 ad->ed_hm_url_desc = URL_HEAD;
985                 ad->chkType = NET_PDP_AUTH_NONE;
986                 ad->ed_auth_type_desc = _("IDS_COM_BODY_NONE");
987                 __update_genlist_info(ad);
988         }
989         else
990         {
991                 elm_genlist_realized_items_update(ad->scl_edit);//refresh genlist
992         }
993         ecore_idler_add(__connection_idler, ad);
994 }
995
996 static void
997 setting_network_edit_connection_click_softkey_save_cb(void *data,
998                                                       Evas_Object *obj,
999                                                       void *event_info)
1000 {
1001         SETTING_TRACE_BEGIN;
1002         /* error check */
1003         retm_if(data == NULL, "Data parameter is NULL");
1004
1005         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1006         /* elm_box_unpack_all(ad->bx_blk); */
1007         /* elm_dialoguegroup_remove_all(ad->dg_blk); */
1008
1009         int ret = setting_network_edit_connection_save_connection(ad);
1010         /* need special handle */
1011         if (SETTING_DNET_RETURN_NULL_ACCESS_NAME == ret
1012             || SETTING_DNET_RETURN_NULL_USER_NAME == ret
1013             || SETTING_DNET_RETURN_NULL_PASSWORD == ret
1014             || SETTING_DNET_RETURN_INVALID_PROXY_ADDR == ret
1015             || SETTING_DNET_RETURN_ERR == ret) {
1016                 return;
1017         }
1018         if (ret != SETTING_RETURN_SUCCESS) {
1019                 SETTING_TRACE_ERROR
1020                     ("%s*** [ERR] setting_network_edit_connection_save_connection ***%s",
1021                      SETTING_FONT_RED, SETTING_FONT_BLACK);
1022         }
1023
1024         setting_create_popup_without_btn(ad, ad->win_get, NULL, _(KeyStr_Saved), NULL, POPUP_INTERVAL, FALSE, FALSE);
1025         //re-fetch connection info..
1026         FREE(ad->prof_list);
1027         __get_connection_info(ad);
1028
1029         setting_network_edit_connection_click_softkey_cancel_cb(ad, ad->r_button, NULL);
1030 }
1031
1032 static void
1033 setting_network_edit_connection_click_softkey_back_cb(void *data,
1034                                                         Evas_Object *obj,
1035                                                         void *event_info)
1036 {
1037         SETTING_TRACE_BEGIN;
1038         /* error check */
1039         retm_if(data == NULL, "Data parameter is NULL");
1040
1041         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1042         /* elm_box_unpack_all(ad->bx_blk); */
1043         /* elm_dialoguegroup_remove_all(ad->dg_blk); */
1044         setting_view_change(&setting_view_network_connection_create,
1045                             &setting_view_network_main, ad);
1046 }
1047 static void
1048 setting_network_edit_connection_click_softkey_cancel_cb(void *data,
1049                                                         Evas_Object *obj,
1050                                                         void *event_info)
1051 {
1052         SETTING_TRACE_BEGIN;
1053         /* error check */
1054         retm_if(data == NULL, "Data parameter is NULL");
1055
1056         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1057         ad->l_button = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_LEFT);
1058         elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_LEFT, NULL);
1059         evas_object_hide(ad->l_button);
1060
1061         ad->m_button = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_MORE);
1062         elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_MORE, NULL);
1063         evas_object_hide(ad->m_button);
1064
1065         ad->r_button = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_RIGHT);
1066         elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_RIGHT, NULL);
1067         evas_object_hide(ad->r_button);
1068         //setting_disable_evas_object(ad->r_button);
1069         setting_undo_dim_evas_object(ad->r_button, TRUE);
1070
1071         elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_PREV, ad->back_btn);
1072         elm_object_item_part_content_set(ad->navi_it, NAVI_CONTROLBAR_PART, ad->controlbar);
1073         evas_object_show(ad->back_btn);
1074         evas_object_show(ad->controlbar);
1075
1076         __get_connection_info(ad);
1077         __update_genlist_info(ad);
1078         if(ad->data_auth_type) elm_genlist_item_expanded_set(ad->data_auth_type->item, FALSE);
1079         ecore_idler_add(__connection_idler, ad);
1080 }
1081 static void _gl_Gendial_sel(void *data, Evas_Object *obj, void *event_info)
1082 {
1083         /* SETTING_TRACE_BEGIN; */
1084         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1085         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1086         elm_genlist_item_selected_set(item, 0);
1087         return;
1088 }
1089
1090 static void setting_network_connection_check_entry_empty(SettingNetworkUG *ad)
1091 {
1092         SETTING_TRACE_BEGIN;
1093         if (!ad->has_form_changed)
1094         {
1095                 SETTING_TRACE_DEBUG("ad->has_form_changed == FALSE!");
1096                 return;
1097         }
1098         bool isFoundEmptyEntry = FALSE;
1099
1100         do {
1101                 if (ad->data_acs_name && isEmptyStr(ad->data_acs_name->sub_desc)) {
1102                         SETTING_TRACE("entry_str:%s", ad->data_acs_name->sub_desc);
1103                         isFoundEmptyEntry = TRUE;
1104                         break;
1105                 }
1106                 if (ad->data_user_name && isEmptyStr(ad->data_user_name->sub_desc)) {
1107                         SETTING_TRACE("entry_str:%s", ad->data_user_name->sub_desc);
1108                         isFoundEmptyEntry = TRUE;
1109                         break;
1110                 }
1111                 if (ad->data_pwd && isEmptyStr(ad->data_pwd->sub_desc)) {
1112                         SETTING_TRACE("entry_str:%s", ad->data_pwd->sub_desc);
1113                         isFoundEmptyEntry = TRUE;
1114                         break;
1115                 }
1116                 if (ad->data_hm_url && isEmptyStr(ad->data_hm_url->sub_desc)) {
1117                         SETTING_TRACE("entry_str:%s", ad->data_hm_url->sub_desc);
1118                         isFoundEmptyEntry = TRUE;
1119                         break;
1120                 }
1121         } while (0);
1122         Evas_Object *done_btn = elm_object_item_part_content_get(ad->navi_it, NAVI_BTN_STYLE_LEFT);
1123         if (isFoundEmptyEntry) {
1124                 if (!evas_object_pass_events_get(done_btn)) {//it had not yet been disabled
1125                         setting_disable_evas_object(done_btn);
1126                         setting_dim_evas_object(done_btn, TRUE);
1127                 }
1128                 else
1129                 {
1130                     //do nothing..if invoke setting_dim_evas_object many times, the done button will be dimer until it cannot be see.
1131                     //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.
1132                 }
1133         } else {
1134                 setting_enable_evas_object(done_btn);
1135                 setting_undo_dim_evas_object(done_btn, TRUE);
1136         }
1137 }
1138
1139 static void
1140 setting_network_edit_connection_display_auth_type(SettingNetworkUG *ad,
1141                                                   int auth_type)
1142 {
1143         SETTING_TRACE_BEGIN;
1144         retm_if(ad == NULL, "Data parameter is NULL");
1145         if (ad->chkType == auth_type) return;
1146
1147         ad->chkType = auth_type;        /* for update genlist */
1148         if (NET_PDP_AUTH_NONE != auth_type) {   /* to show */
1149                 SETTING_TRACE("ad->is_show_user:%d", ad->is_show_user);
1150                 if (ad->is_show_user == 0) {    /* do only when hiden */
1151                         SETTING_TRACE("to create");
1152
1153                         ad->data_user_name =
1154                             (Setting_GenGroupItem_Data *) calloc(1,
1155                                                                  sizeof
1156                                                                  (Setting_GenGroupItem_Data));
1157                         setting_retm_if(ad->data_user_name == NULL, "calloc failed");
1158                         ad->data_user_name->keyStr =
1159                             (char *)g_strdup("IDS_COM_BODY_USER_NAME");
1160                         ad->data_user_name->sub_desc =
1161                             (char *)g_strdup(ad->ed_user_name_desc);
1162                         ad->data_user_name->swallow_type =
1163                             SWALLOW_Type_LAYOUT_ENTRY;
1164                         ad->data_user_name->userdata = ad;
1165                         ad->data_user_name->chk_change_cb =
1166                             setting_network_connection_entry_changed_cb;
1167                         ad->data_user_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
1168                         if (ad->data_user_name->limit_filter_data) {
1169                                 ad->data_user_name->limit_filter_data->max_byte_count = NET_PDP_AUTH_USERNAME_LEN_MAX;
1170                                 ad->data_user_name->win_main = ad->win_get;
1171                         }
1172                         ad->data_user_name->item =
1173                             elm_genlist_item_insert_after(ad->scl_edit,
1174                                                           &itc_1icon,
1175                                                           ad->data_user_name,
1176                                                           NULL,
1177                                                           ad->item_above_user_name,
1178                                                           ELM_GENLIST_ITEM_NONE,
1179                                                           _gl_Gendial_sel, ad);
1180
1181                         ad->data_pwd =
1182                             (Setting_GenGroupItem_Data *) calloc(1,
1183                                                                  sizeof
1184                                                                  (Setting_GenGroupItem_Data));
1185
1186                         setting_retm_if(ad->data_pwd == NULL, "calloc failed");
1187                         ad->data_pwd->keyStr =
1188                             (char *)g_strdup("IDS_COM_BODY_PASSWORD");
1189                         ad->data_pwd->sub_desc =
1190                             (char *)g_strdup(ad->ed_pwd_desc);
1191                         ad->data_pwd->swallow_type = SWALLOW_Type_LAYOUT_ENTRY;
1192                         ad->data_pwd->userdata = ad;
1193                         ad->data_pwd->chk_change_cb =
1194                             setting_network_connection_entry_changed_cb;
1195                         ad->data_pwd->isPasswordFlag = TRUE;
1196                         /* ad->data_pwd->chk_change_cb = chk_change_cb; */
1197                         ad->data_pwd->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
1198                         if (ad->data_pwd->limit_filter_data) {
1199                                 ad->data_pwd->limit_filter_data->max_byte_count = NET_PDP_AUTH_PASSWORD_LEN_MAX;
1200                                 ad->data_pwd->win_main = ad->win_get;
1201                         }
1202                         ad->data_pwd->item =
1203                             elm_genlist_item_insert_after(ad->scl_edit,
1204                                                           &itc_1icon,
1205                                                           ad->data_pwd, NULL,
1206                                                           ad->
1207                                                           data_user_name->item,
1208                                                           ELM_GENLIST_ITEM_NONE,
1209                                                           _gl_Gendial_sel, ad);
1210
1211                         ad->item_above_proxy_add =
1212                             elm_genlist_item_insert_after(ad->scl_edit,
1213                                                           &itc_seperator,
1214                                                           NULL, NULL,
1215                                                           ad->data_pwd->item,
1216                                                           ELM_GENLIST_ITEM_NONE,
1217                                                           NULL, NULL);
1218                         elm_genlist_item_select_mode_set
1219                             (ad->item_above_proxy_add, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1220
1221                         ad->has_form_changed  = TRUE;
1222                         setting_network_connection_check_entry_empty(ad);
1223                         /* ad->is_show_user = 1; */
1224                 }
1225                 ad->is_show_user = 1;
1226         } else {                /* to hide */
1227
1228                 SETTING_TRACE("ad->is_show_user:%d", ad->is_show_user);
1229                 if (ad->is_show_user == 1) {    /* do only when shown */
1230                         SETTING_TRACE("to destroy");
1231                         if (ad->data_user_name) {
1232                                 elm_object_item_del(ad->data_user_name->item);
1233                                 ad->data_user_name = NULL;
1234                         }
1235                         if (ad->data_pwd) {
1236                                 elm_object_item_del(ad->data_pwd->item);
1237                                 ad->data_pwd = NULL;
1238                         }
1239                         if (ad->item_above_proxy_add) {
1240                                 elm_object_item_del(ad->item_above_proxy_add);
1241                                 ad->item_above_proxy_add = NULL;
1242                         }
1243
1244                 }
1245                 ad->has_form_changed  = TRUE;
1246                 setting_network_connection_check_entry_empty(ad);
1247                 ad->is_show_user = 0;
1248
1249         }
1250 }
1251
1252 static void
1253 setting_network_connection_entry_changed_cb(void *data, Evas_Object *obj,
1254                                             void *event_info)
1255 {
1256         SETTING_TRACE_BEGIN;
1257         retm_if(data == NULL, "Data parameter is NULL");
1258         Setting_GenGroupItem_Data *list_item =
1259             (Setting_GenGroupItem_Data *) data;
1260         SettingNetworkUG *ad = list_item->userdata;
1261         const char *entry_str = elm_entry_entry_get(obj);
1262         list_item->sub_desc = (char *)g_strdup(entry_str);
1263         ad->has_form_changed  = TRUE;
1264         setting_network_connection_check_entry_empty(ad);
1265 }
1266 static void
1267 setting_network_connection_hide_input_pannel(void *data)
1268 {
1269         SETTING_TRACE_BEGIN;
1270         retm_if(data == NULL, "Data parameter is NULL");
1271         SettingNetworkUG *ad = data;
1272         if (ad->data_acs_name) {
1273                 setting_hide_input_pannel_cb(ad->data_acs_name->eo_check);
1274         }
1275         if (ad->data_user_name) {
1276                 setting_hide_input_pannel_cb(ad->data_user_name->eo_check);
1277         }
1278         if (ad->data_pwd) {
1279                 setting_hide_input_pannel_cb(ad->data_pwd->eo_check);
1280         }
1281         if (ad->data_pxy_addr) {
1282                 setting_hide_input_pannel_cb(ad->data_pxy_addr->eo_check);
1283         }
1284         if (ad->data_pxy_port) {
1285                 setting_hide_input_pannel_cb(ad->data_pxy_port->eo_check);
1286         }
1287         if (ad->data_hm_url) {
1288                 setting_hide_input_pannel_cb(ad->data_hm_url->eo_check);
1289         }
1290 }
1291