tizen 2.4 release
[apps/home/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 #include <notification.h>
23
24 #define MAX_PDP_APN_LEN_MAX 100
25 #define MAX_PDP_AUTH_USERNAME_LEN_MAX 32
26 #define MAX_PDP_AUTH_PASSWORD_LEN_MAX 32
27 #define MAX_HOME_URL_LEN_MAX 512
28 #define MAX_PROXY_LEN_MAX 64
29
30 static int setting_network_connection_create(void *cb);
31 static int setting_network_connection_destroy(void *cb);
32 static int setting_network_connection_update(void *cb);
33 static int setting_network_connection_cleanup(void *cb);
34
35 setting_view setting_view_network_connection_create = {
36         .create = setting_network_connection_create,
37         .destroy = setting_network_connection_destroy,
38         .update = setting_network_connection_update,
39         .cleanup = setting_network_connection_cleanup,
40 };
41
42 SettingNetworkUG *g_networkUG = NULL;
43 #define SUPPORT_EXPANDABLE_AUTHTYPE 1
44 #define URL_HEAD "http://"
45 #define INTERNET "IDS_ST_BODY_CONNECTIONSETTINGS_INTERNET"
46 #define PLUS_MMS "+ MMS"
47 /* ***************************************************
48  *
49  *basic func
50  *
51  ***************************************************/
52
53 void __sub_list_rd_change(void *data, Evas_Object *obj, void *event_info)
54 {
55         SETTING_TRACE_BEGIN;
56         retm_if(data == NULL, "Data parameter is NULL");
57         Setting_GenGroupItem_Data *list_item =
58             (Setting_GenGroupItem_Data *) data;
59         list_item->chk_status = elm_radio_value_get(obj);       /*  for update */
60
61         Elm_Object_Item *subItem = list_item->item;
62         Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subItem);
63
64         Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subItem);    /* subItem data */
65         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
66
67         ret_if(NULL == data_subItem || NULL == data_parentItem);
68
69         data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
70         elm_object_item_data_set(data_parentItem->item, data_parentItem);
71         elm_genlist_item_update(data_parentItem->item);
72
73         SettingNetworkUG *ad = data_parentItem->userdata;
74
75         if (data_parentItem == ad->data_auth_type) {
76                 elm_genlist_item_expanded_set(ad->data_auth_type->item, FALSE);
77                 elm_genlist_item_update(ad->data_auth_type->item);
78
79                 setting_network_connection_display_auth_type(data_parentItem->userdata, list_item->chk_status);
80         } else if (data_parentItem == ad->data_srv_type) {
81                 if (ad->srvType != data_subItem->chk_status)
82                         ad->srvType = data_subItem->chk_status;
83                 if (ad->srvType != CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET) {
84                         if (!ad->data_hm_url) {
85                                 /*need home url */
86                                 ad->data_hm_url =
87                                     setting_create_Gendial_field_def(obj,
88                                                                      &itc_editfield,
89                                                                      NULL, NULL,
90                                                                      SWALLOW_Type_LAYOUT_EDITFIELD,
91                                                                      NULL, NULL, 0,
92                                                                      "IDS_ST_BODY_HOME_URL",
93                                                                      (char *)ad->ed_hm_url_desc,
94                                                                      setting_network_connection_entry_changed_cb);
95                                 if (ad->data_hm_url) {
96                                         ad->data_hm_url->userdata = ad;
97                                         ad->data_hm_url->input_type = ELM_INPUT_PANEL_LAYOUT_URL;
98                                         ad->data_hm_url->isSinglelineFlag = TRUE;
99                                         ad->data_hm_url->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
100                                         if (ad->data_hm_url->limit_filter_data) {
101                                                 ad->data_hm_url->limit_filter_data->max_byte_count = MAX_HOME_URL_LEN_MAX - 1;
102                                                 ad->data_hm_url->win_main = ad->win_get;
103                                         }
104                                 } else {
105                                         SETTING_TRACE_ERROR("ad->data_hm_url is NULL");
106                                 }
107                         }
108                 } else {
109                         /*do need home-url */
110                         if (ad->data_hm_url) {
111                                 elm_object_item_del(ad->data_hm_url->item);
112                                 ad->data_hm_url = NULL;
113                         }
114                 }
115         }
116 }
117
118 void __sub_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
119 {
120         SETTING_TRACE_BEGIN;
121         /* error check */
122         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
123         Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
124         Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
125         elm_genlist_item_selected_set(subitem, 0);
126
127         Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subitem);
128         Setting_GenGroupItem_Data *data_parentItem = (Setting_GenGroupItem_Data *)data;
129         ret_if(NULL == data_subItem || NULL == data_parentItem);
130
131         SettingNetworkUG *ad = data_parentItem->userdata;
132         ret_if(NULL == ad);
133
134         int chk_status = data_subItem->chk_status;
135         elm_radio_value_set(data_subItem->rgd, chk_status);
136
137         data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
138         elm_object_item_data_set(data_parentItem->item, data_parentItem);
139 //      elm_genlist_item_fields_update(data_parentItem->item, "*", ELM_GENLIST_ITEM_FIELD_TEXT);
140
141         if (data_parentItem == ad->data_auth_type)
142         {
143                 elm_genlist_item_expanded_set( ad->data_auth_type->item, FALSE );
144                 elm_genlist_item_update( ad->data_auth_type->item );
145
146                 setting_network_connection_display_auth_type(ad, chk_status);
147
148                 //remove network mode popup
149                 if (ad->popup_auth_type) {
150                         evas_object_del(ad->popup_auth_type);
151                         ad->popup_auth_type = NULL;
152                 }
153         }
154         else if (data_parentItem == ad->data_srv_type)
155         {
156                 if (ad->srvType != data_subItem->chk_status)
157                         ad->srvType = data_subItem->chk_status;
158                 if( ad->srvType != CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET)
159                 {
160                         if (!ad->data_hm_url)
161                         {
162                                 //need home url
163                                 ad->data_hm_url =
164                                     setting_create_Gendial_field_def(obj,
165                                                                      &itc_editfield,
166                                                                      NULL, NULL,
167                                                                      SWALLOW_Type_LAYOUT_EDITFIELD,
168                                                                      NULL, NULL, 0,
169                                                                      "IDS_ST_BODY_HOME_URL",
170                                                                      (char *)ad->ed_hm_url_desc,
171                                                                      setting_network_connection_entry_changed_cb);
172                                 if (ad->data_hm_url) {
173                                         ad->data_hm_url->userdata = ad;
174                                         ad->data_hm_url->input_type = ELM_INPUT_PANEL_LAYOUT_URL;
175                                         ad->data_hm_url->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
176                                         if (ad->data_hm_url->limit_filter_data) {
177                                                 ad->data_hm_url->limit_filter_data->max_byte_count = MAX_HOME_URL_LEN_MAX - 1;
178                                                 ad->data_hm_url->win_main = ad->win_get;
179                                         }
180                                 } else {
181                                         SETTING_TRACE_ERROR("ad->data_hm_url is NULL");
182                                 }
183                         }
184
185                 } else {
186                         /*do need home-url */
187                         if (ad->data_hm_url) {
188                                 elm_object_item_del(ad->data_hm_url->item);
189                                 ad->data_hm_url = NULL;
190                         }
191                 }
192         }
193 }
194
195 void __auth_type_popup_del(void *data, Evas_Object *obj, void *event_info)
196 {
197         SettingNetworkUG *ad = data;
198
199         ret_if(data == NULL);
200
201         evas_object_del(ad->popup_auth_type);
202         ad->popup_auth_type = NULL;
203 }
204
205 static void __create_auth_type_popup(void *data, Evas_Object *obj,
206                                                 void *event_info)
207 {
208         ret_if(NULL == data || NULL == event_info);
209         SETTING_TRACE_BEGIN;
210         SettingNetworkUG *ad = (SettingNetworkUG *) data;
211         Elm_Object_Item *parentItem = event_info;       /* parent item */
212         elm_genlist_item_selected_set(parentItem, 0);
213         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
214
215         /* create popup */
216         if(ad->popup_auth_type) {
217                 evas_object_del(ad->popup_auth_type);
218                 ad->popup_auth_type = NULL;
219         }
220         Evas_Object *scroller = NULL;
221         ad->popup_auth_type = setting_create_popup_with_list(&scroller, ad, ad->win_get,
222                                                                                                              data_parentItem->keyStr,
223                                                                                                                  __auth_type_popup_del,
224                                                                                                                  0, false, false, 0);
225         _P(ad->popup_auth_type);
226
227         Evas_Object *rgd;
228
229         Setting_GenGroupItem_Data *list_item = NULL;
230         if (data_parentItem == ad->data_auth_type) {
231                 rgd = elm_radio_add(scroller);
232                 elm_radio_value_set(rgd, -1);
233
234                 list_item = setting_create_Gendial_field_1radio(scroller,
235                                                      &itc_multiline_1text_1icon,
236                                                      __sub_list_sel_cb, data_parentItem,
237                                                      SWALLOW_Type_1RADIO_RIGHT, rgd,
238                                                      CONNECTION_CELLULAR_AUTH_TYPE_PAP,
239                                                      "IDS_ST_MBODY_PAP",
240                                                      NULL);
241
242                 list_item = setting_create_Gendial_field_1radio(scroller,
243                                                      &itc_multiline_1text_1icon,
244                                                      __sub_list_sel_cb, data_parentItem,
245                                                      SWALLOW_Type_1RADIO_RIGHT, rgd,
246                                                      CONNECTION_CELLULAR_AUTH_TYPE_CHAP,
247                                                      "IDS_ST_POP_CHAP",
248                                                      NULL);
249
250                 list_item = setting_create_Gendial_field_1radio(scroller,
251                                                      &itc_multiline_1text_1icon,
252                                                      __sub_list_sel_cb, data_parentItem,
253                                                      SWALLOW_Type_1RADIO_RIGHT, rgd,
254                                                      CONNECTION_CELLULAR_AUTH_TYPE_NONE,
255                                                      "IDS_ST_BODY_NONE",
256                                                      NULL);
257
258                 elm_radio_value_set(rgd, ad->chkType);
259                 elm_object_signal_emit(rgd, "elm,event,pass,enabled", "elm");
260         }
261         else if (data_parentItem == ad->data_srv_type) {
262                 rgd = elm_radio_add(scroller);
263                 elm_radio_value_set(rgd, -1);
264
265                 list_item = setting_create_Gendial_exp_sub_field(scroller,
266                                                      &itc_1icon_1text_sub,
267                                                      __sub_list_sel_cb, ad,
268                                                      parentItem,
269                                                      SWALLOW_Type_1RADIO_RIGHT, rgd,
270                                                      CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET,
271                                                      "IDS_ST_BODY_INTERNET_CONNECTION",
272                                                      __sub_list_rd_change);
273
274                 list_item = setting_create_Gendial_exp_sub_field(scroller,
275                                                      &itc_1icon_1text_sub,
276                                                      __sub_list_sel_cb, ad,
277                                                      parentItem,
278                                                      SWALLOW_Type_1RADIO_RIGHT, rgd,
279                                                      CONNECTION_CELLULAR_SERVICE_TYPE_MMS,
280                                                      STR_SETTING_MMS_CONNECTIONS,
281                                                      __sub_list_rd_change);
282
283                 int r = 0;
284                 char tmp_str[SETTING_STR_SLP_LEN + 1] = {0,};
285                 r = snprintf(tmp_str, SETTING_STR_SLP_LEN, "%s %s", _(INTERNET), PLUS_MMS);
286                 if(r < 0)
287                         SETTING_TRACE("snprintf failed");
288
289                 list_item = setting_create_Gendial_exp_sub_field(scroller,
290                                                      &itc_1icon_1text_sub,
291                                                      __sub_list_sel_cb, ad,
292                                                      parentItem,
293                                                      SWALLOW_Type_1RADIO_RIGHT, rgd,
294                                                      CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION,
295                                                      tmp_str,
296                                                      __sub_list_rd_change);
297
298                 elm_radio_value_set(rgd, ad->srvType);
299                 elm_object_signal_emit(rgd, "elm,event,pass,enabled", "elm");
300         }
301 }
302
303 static void __setting_network_connection_exp_cb(void *data, Evas_Object *obj,
304                                                 void *event_info)
305 {
306         ret_if(NULL == data || NULL == event_info);
307         SETTING_TRACE_BEGIN;
308         SettingNetworkUG *ad = (SettingNetworkUG *) data;
309         Elm_Object_Item *parentItem = event_info;       /* parent item */
310         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
311         Evas_Object *scroller = elm_object_item_widget_get(parentItem);
312
313         Evas_Object *rgd;
314
315         Setting_GenGroupItem_Data *list_item = NULL;
316         if (data_parentItem == ad->data_auth_type) {
317                 rgd = elm_radio_add(scroller);
318                 //elm_object_style_set(rgd, "list");
319                 elm_radio_value_set(rgd, -1);
320
321                 SETTING_TRACE("CONNECTION_CELLULAR_AUTH_TYPE_NONE : %d: ", CONNECTION_CELLULAR_AUTH_TYPE_NONE);
322                 SETTING_TRACE("CONNECTION_CELLULAR_AUTH_TYPE_PAP : %d: ", CONNECTION_CELLULAR_AUTH_TYPE_PAP);
323                 SETTING_TRACE("CONNECTION_CELLULAR_AUTH_TYPE_CHAP : %d: ", CONNECTION_CELLULAR_AUTH_TYPE_CHAP);
324
325                 list_item = setting_create_Gendial_exp_sub_field(scroller,
326                                                                  &itc_1icon_1text_sub,
327                                                                  __sub_list_sel_cb, ad,
328                                                                  parentItem,
329                                                                  SWALLOW_Type_1RADIO_RIGHT, rgd,
330                                                                  CONNECTION_CELLULAR_AUTH_TYPE_NONE,
331                                                                  IDS_ST_BODY_NONE,
332                                                                  __sub_list_rd_change);
333
334                 list_item = setting_create_Gendial_exp_sub_field(scroller,
335                                                                  &itc_1icon_1text_sub,
336                                                                  __sub_list_sel_cb, ad,
337                                                                  parentItem,
338                                                                  SWALLOW_Type_1RADIO_RIGHT, rgd,
339                                                                  CONNECTION_CELLULAR_AUTH_TYPE_PAP,
340                                                                  IDS_ST_MBODY_PAP,
341                                                                  __sub_list_rd_change);
342
343                 list_item = setting_create_Gendial_exp_sub_field(scroller,
344                                                                  &itc_1icon_1text_sub,
345                                                                  __sub_list_sel_cb, ad,
346                                                                  parentItem,
347                                                                  SWALLOW_Type_1RADIO_RIGHT, rgd,
348                                                                  CONNECTION_CELLULAR_AUTH_TYPE_CHAP,
349                                                                  IDS_ST_POP_CHAP,
350                                                                  __sub_list_rd_change);
351
352                 SETTING_TRACE(" ----------------------------->>> ad->chkType : %d ",ad->chkType);
353
354                 elm_radio_value_set(rgd, ad->chkType);
355         } else if (data_parentItem == ad->data_srv_type) {
356                 rgd = elm_radio_add(scroller);
357                 elm_radio_value_set(rgd, -1);
358
359                 list_item = setting_create_Gendial_exp_sub_field(scroller,
360                                                                  &itc_1icon_1text_sub,
361                                                                  __sub_list_sel_cb, ad,
362                                                                  parentItem,
363                                                                  SWALLOW_Type_1RADIO_RIGHT, rgd,
364                                                                  CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET,
365                                                                  "IDS_ST_BODY_INTERNET_CONNECTION",
366                                                                  __sub_list_rd_change);
367
368                 list_item = setting_create_Gendial_exp_sub_field(scroller,
369                                                                  &itc_1icon_1text_sub,
370                                                                  __sub_list_sel_cb, ad,
371                                                                  parentItem,
372                                                                  SWALLOW_Type_1RADIO_RIGHT, rgd,
373                                                                  CONNECTION_CELLULAR_SERVICE_TYPE_MMS,
374                                                                  STR_SETTING_MMS_CONNECTIONS,
375                                                                  __sub_list_rd_change);
376
377                 int r = 0;
378                 char tmp_str[SETTING_STR_SLP_LEN + 1] = {0,};
379                 r = snprintf(tmp_str, SETTING_STR_SLP_LEN, "%s %s", _(INTERNET), PLUS_MMS);
380                 if (r < 0)
381                         SETTING_TRACE("snprintf failed");
382
383                 list_item = setting_create_Gendial_exp_sub_field(scroller,
384                                                                  &itc_1icon_1text_sub,
385                                                                  __sub_list_sel_cb, ad,
386                                                                  parentItem,
387                                                                  SWALLOW_Type_1RADIO_RIGHT, rgd,
388                                                                  CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION,
389                                                                  tmp_str,
390                                                                  __sub_list_rd_change);
391
392                 elm_radio_value_set(rgd, ad->srvType);
393         }
394 }
395
396 static Eina_Bool __connection_idler(void *data)
397 {
398         SETTING_TRACE_BEGIN;
399         retv_if(!data, FALSE);
400         SettingNetworkUG *ad = data;
401         /*__genlist_disable_set(ad->scl_edit, TRUE); */
402         setting_network_connection_hide_input_pannel(ad);
403         return FALSE;
404 }
405 void __get_connection_info(void *cb)
406 {
407         SETTING_TRACE_BEGIN;
408         ret_if(cb == NULL);
409         SettingNetworkUG *ad = (SettingNetworkUG *) cb;
410         /*int ret; */
411         G_FREE(ad->ed_profile_name_desc);
412         G_FREE(ad->ed_acs_name_desc);
413         G_FREE(ad->ed_user_name_desc);
414         G_FREE(ad->ed_pwd_desc);
415
416         G_FREE(ad->ed_pxy_addr_desc);
417         G_FREE(ad->ed_pxy_port_desc);
418
419         G_FREE(ad->ed_hm_url_desc);
420         ad->ed_auth_type_desc = NULL;
421         ad->chkType = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
422
423         SETTING_TRACE("ad->con_name:%s, ad->profile_service_type:%d",
424                       ad->con_name, ad->profile_service_type);
425
426         int ServiceType = ad->profile_service_type;
427         char *con_name_utf8 = NULL;
428         if (ad->access_name) {
429                 con_name_utf8 = strdup(ad->access_name);
430         } else {
431                 con_name_utf8 = strdup("");
432         }
433         SETTING_TRACE("con_name_utf8:%s", con_name_utf8);
434
435         /*match with the correct profile */
436         connection_profile_iterator_h profile_iter = NULL;
437         connection_profile_h profile_h = NULL;
438         char *profile_name = NULL;
439         char *apn = NULL;
440         char *profile_id = NULL;
441         connection_profile_type_e profile_type = CONNECTION_PROFILE_TYPE_CELLULAR;
442         connection_cellular_service_type_e service_type = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
443         int err = connection_get_profile_iterator(ad->connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
444         if (err != CONNECTION_ERROR_NONE) {
445                 SETTING_TRACE_ERROR("Fail to get profile iterator [%d]", err);
446                 FREE(con_name_utf8);
447                 return;
448         }
449
450         int cnt = 0;
451         bool found = FALSE;
452         while (connection_profile_iterator_has_next(profile_iter)) {
453                 /*reset and release.. */
454                 G_FREE(apn);
455                 G_FREE(profile_id);
456                 G_FREE(profile_name);
457
458                 if (cnt >= MAX_PROFILE_NUM || connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
459                         break;
460                 }
461
462                 connection_profile_get_type(profile_h, &profile_type);
463                 connection_profile_get_cellular_service_type(profile_h, &service_type);
464                 connection_profile_get_cellular_apn(profile_h, &apn);
465                 connection_profile_get_id(profile_h, &profile_id);
466                 connection_profile_get_name(profile_h, &profile_name);
467                 SETTING_TRACE("Record[%d] apn[%s], profile_id[%s], profile_name[%s], profile_type[%d], service_type[%d]",
468                               cnt, apn, profile_id, profile_name, profile_type, service_type);
469                 if (CONNECTION_PROFILE_TYPE_CELLULAR != profile_type)
470                         continue;
471
472 #if 0
473                 if (CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION != service_type) {
474                         /*match with ServiceType */
475                         if (ServiceType == service_type) {
476                                 ad->sel_profile_h = profile_h;
477                                 found = TRUE;
478                                 break;
479                         }
480                 } else { /*the customer's profiles */
481                         if (0 == safeStrCmp(con_name_utf8, apn)) {
482                                 ad->sel_profile_h = profile_h;
483                                 found = TRUE;
484                                 break;
485                         }
486                 }
487 #endif
488                 /*match with ServiceType */
489                 if (ServiceType == service_type) {
490                         if (ServiceType == CONNECTION_CELLULAR_SERVICE_TYPE_MMS) {
491
492                                 /*for MMS,it just have one profile */
493                                 ad->sel_profile_h = profile_h;
494                                 found = TRUE;
495                                 break;
496                         } else {
497                                 if (0 == safeStrCmp(con_name_utf8, profile_id)) {
498                                         ad->sel_profile_h = profile_h;
499                                         found = TRUE;
500                                         break;
501                                 }
502                         }
503                 }
504
505                 cnt++;
506         }
507         FREE(con_name_utf8);
508         ad->is_editable = TRUE;
509         if (found) { /*found sucessfully */
510                 SETTING_TRACE("found the following record:");
511                 SETTING_TRACE("\tapn:%s", apn);
512                 SETTING_TRACE("\tprofile_id:%s", profile_id);
513                 SETTING_TRACE("\tprofile_name:%s", profile_name);
514                 SETTING_TRACE("\tservice_type:%d", service_type);
515                 SETTING_TRACE("\tprofile_type:%d", profile_type);
516                 ad->srvType = service_type;
517                 ad->ed_profile_name_desc = profile_name;
518
519                 connection_profile_is_cellular_editable(ad->sel_profile_h, &(ad->is_editable));
520                 SETTING_TRACE("ad->is_editable:%d", ad->is_editable);
521
522                 /* load access name */
523                 connection_profile_get_cellular_apn(ad->sel_profile_h, &(ad->ed_acs_name_desc));
524                 connection_cellular_auth_type_e auth_type = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
525                 connection_profile_get_cellular_auth_info(ad->sel_profile_h, &auth_type, &(ad->ed_user_name_desc), &(ad->ed_pwd_desc));
526                 SETTING_TRACE(" ----> auth_type: (%d)", auth_type);
527
528                 ad->chkType = auth_type;
529                 /*SETTING_TRACE("-----> radio button state: %d", elm_radio_value_get(ad->chk_type));*/
530                 SETTING_TRACE("----------------------> connection_profile_get_cellular_auth_info: %d", auth_type);
531                 elm_radio_value_set(ad->chk_type, ad->chkType);
532
533                 switch (ad->chkType) {
534                         case CONNECTION_CELLULAR_AUTH_TYPE_NONE:
535                                 ad->ed_auth_type_desc = _("IDS_ST_BODY_NONE");
536                                 break;
537                         case CONNECTION_CELLULAR_AUTH_TYPE_PAP:
538                                 ad->ed_auth_type_desc = _("IDS_ST_MBODY_PAP");
539                                 break;
540                         case CONNECTION_CELLULAR_AUTH_TYPE_CHAP:
541                                 ad->ed_auth_type_desc = _("IDS_ST_POP_CHAP");
542                                 break;
543                         default:
544                                 ad->chkType = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
545                                 ad->ed_auth_type_desc = _("IDS_ST_BODY_NONE");
546                                 break;
547                 }
548
549
550                 char *full_addr = NULL;
551                 char *addr = NULL;
552                 char *port = NULL;
553                 /*Fix the Port 'NULL' issue when enter connection view repeatly.. */
554                 connection_profile_get_proxy_address(ad->sel_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, &full_addr);
555                 SETTING_TRACE("full_addr: %s", full_addr);
556                 char ProxyAddr[MAX_HOME_URL_LEN_MAX + 1] = {0,};
557                 safeCopyStr(ProxyAddr, full_addr, MAX_HOME_URL_LEN_MAX);
558                 G_FREE(full_addr);
559
560                 /*several real format after removing "http://": */
561                 /*      ":80", "1.1.1.1:80","1.1.1.1: ", "127.0.0.1/", "127.0.0.1" */
562                 full_addr = ProxyAddr;
563                 int url_head_len = strlen(URL_HEAD);
564                 if (0 == safeStrNCmp(full_addr, URL_HEAD, url_head_len)) {
565                         full_addr += url_head_len;
566                 }
567                 addr = strsep(&full_addr, ":");
568                 if (NULL == full_addr) { /*format like "http://127.0.0.1/" or "http://127.0.0.1" */
569                         SETTING_TRACE("NULL == full_addr");
570                         addr = strsep(&addr, "/");
571                 }
572
573                 ad->ed_pxy_addr_desc = NULL;
574                 /*proxy address support not only ip but also url, need not check the format */
575                 /*bool is_ip = is_ip_string(addr, &tmp); */
576                 if (!isEmptyStr(addr)) {
577                         ad->ed_pxy_addr_desc = g_strdup(addr);
578                         port = strsep(&full_addr, "/");
579                 } else { /*invalid format,let addr and port to be NULL. */
580                         addr = NULL;
581                 }
582                 SETTING_TRACE("addr:%s", addr);
583                 SETTING_TRACE("port:%s", port);
584                 SETTING_TRACE("ad->ed_pxy_addr_desc:%s", ad->ed_pxy_addr_desc);
585                 /*ad->ed_pxy_addr_desc = g_strdup(addr); */
586                 ad->ed_pxy_port_desc = g_strdup(port);
587                 /*if (ad->con_type == NET_SERVICE_MMS) {        /* Message Connection * / */
588                 if (!safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS)) {   /* Message Connection */
589                         /*ad->ed_hm_url_desc = ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.HomeURL; */
590                         connection_profile_get_cellular_home_url(ad->sel_profile_h, &(ad->ed_hm_url_desc));
591                 }
592         } else {
593                 SETTING_TRACE("Didn't find any record, to let add a new one:");
594                 ad->sel_profile_h = NULL;
595                 ad->ed_auth_type_desc = _("IDS_ST_BODY_NONE");
596                 ad->chkType = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
597                 ad->srvType = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
598         }
599
600         /*release the memory.. */
601         G_FREE(apn);
602         G_FREE(profile_id);
603         /*G_FREE(profile_name); */
604         return;
605 }
606
607 static void __network_max_len_reached(void *data, Evas_Object *obj, void *event_info)
608 {
609         SETTING_TRACE_BEGIN;
610         retm_if(data == NULL, "Data parameter is NULL");
611         retm_if(!elm_object_focus_get(obj), "Entry is not focused");/*notify only when entry is being focused on. */
612
613         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
614         list_item->maxLengthReachFlag = true;
615
616         SETTING_TRACE("list_item->enterKeyPressFlag : %d", list_item->enterKeyPressFlag);
617         SettingNetworkUG *ad = list_item->userdata;
618
619         // popup show
620         ad->popup = setting_create_popup(ad, ad->win_get, NULL,
621                                  "IDS_ST_TPOP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED",
622                                  NULL, 2, TRUE, FALSE, 0);
623 }
624
625 /*
626  * Entry - activated callback (When 'Next' key in SIP touched)
627  */
628 static void setting_network_connection_entry_next_activated_cb(void *data, Evas_Object *obj, void *event_info)
629 {
630         SETTING_TRACE_BEGIN;
631         retm_if(data == NULL, "Data parameter is NULL");
632
633         Setting_GenGroupItem_Data       *list_item = (Setting_GenGroupItem_Data *)data;
634         SettingNetworkUG                        *ad = list_item->userdata;
635
636         Evas_Object             *pObj_NextEntry = NULL;
637
638         if (list_item == ad->data_profile_name) {
639                 /* Profile name -> Access name */
640                 if (ad->data_acs_name)
641                         pObj_NextEntry = ad->data_acs_name->eo_check;
642         } else if (list_item == ad->data_user_name) {
643                 /* User name -> Password */
644                 if (ad->data_pwd)
645                         pObj_NextEntry = ad->data_pwd->eo_check;
646         } else if (list_item == ad->data_pwd) {
647                 /* Password -> Proxy address */
648                 if (ad->data_pxy_addr)
649                         pObj_NextEntry = ad->data_pxy_addr->eo_check;
650         } else if (list_item == ad->data_pxy_addr) {
651                 /* Proxy address -> Proxy port */
652                 if (ad->data_pxy_port)
653                         pObj_NextEntry = ad->data_pxy_port->eo_check;
654         } else if (list_item == ad->data_pxy_port) {
655                 /* Proxy port -> Home URL */
656                 if (ad->data_hm_url)
657                         pObj_NextEntry = ad->data_hm_url->eo_check;
658         } else {
659                 SETTING_TRACE_ERROR("list_item unknown");
660                 return;
661         }
662
663         /* Hide & unfocus keypad */
664         setting_hide_input_pannel_cb(list_item->eo_check);
665
666         /* Focus */
667         if (pObj_NextEntry != NULL) {
668                 elm_object_focus_set(pObj_NextEntry, EINA_TRUE);
669                 elm_entry_cursor_end_set(pObj_NextEntry);
670         }
671
672         return;
673 }
674
675 static void _init_context(void *cb)
676 {
677         SETTING_TRACE_BEGIN;
678         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
679
680         SettingNetworkUG *ad = (SettingNetworkUG *) cb;
681
682         /* connection intializes */
683         ad->data_profile_name = NULL;
684         ad->data_acs_name = NULL;
685         ad->data_auth_type = NULL;
686         ad->data_user_name = NULL;
687         ad->data_pwd = NULL;
688         ad->data_pxy_addr = NULL;
689         ad->data_pxy_port = NULL;
690         ad->data_hm_url = NULL;
691 }
692
693 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
694 static Evas_Object* ctxpopup;
695
696 static void
697 ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
698 {
699         SETTING_TRACE_BEGIN;
700         evas_object_del(ctxpopup);
701         ctxpopup = NULL;
702 }
703
704 static void
705 move_more_ctxpopup(Evas_Object *ctxpopup)
706 {
707         SETTING_TRACE_BEGIN;
708         Evas_Object *win;
709         Evas_Coord w, h;
710         int pos = -1;
711
712         /* We convince the top widget is a window */
713         win = elm_object_top_widget_get(ctxpopup);
714         elm_win_screen_size_get(win, NULL, NULL, &w, &h);
715         pos = elm_win_rotation_get(win);
716
717         switch (pos) {
718                 case 0:
719                 case 180:
720                         evas_object_move(ctxpopup, (w / 2), h);
721                         break;
722                 case 90:
723                         evas_object_move(ctxpopup,  (h / 2), w);
724                         break;
725                 case 270:
726                         evas_object_move(ctxpopup, (h / 2), w);
727                         break;
728         }
729 }
730
731 static void
732 naviframe_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
733 {
734         SETTING_TRACE_BEGIN;
735         Evas_Object *ctxpopup = data;
736         move_more_ctxpopup(ctxpopup);
737 }
738
739 static void
740 more_ctxpopup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
741 {
742         SETTING_TRACE_BEGIN;
743         Evas_Object *nf = data;
744         evas_object_event_callback_del_full(nf, EVAS_CALLBACK_RESIZE, naviframe_resize_cb, ctxpopup);
745 }
746
747 static void
748 win_rotation_changed_cb(void *data, Evas_Object *obj, void *event_info)
749 {
750         SETTING_TRACE_BEGIN;
751         Evas_Object *ctxpopup = data;
752         move_more_ctxpopup(ctxpopup);
753 }
754
755 /* Icon + Text (More button style : Naviframe Toolbar) */
756 static void create_ctxpopup_more_button_cb(void *data, Evas_Object *obj, void *event_info)
757 {
758         SETTING_TRACE_BEGIN;
759         SettingNetworkUG *ad = (SettingNetworkUG *) data;
760         Evas_Object *it_obj;
761         Evas_Object *nf = ad->navi_bar;
762         Evas_Object *win;
763         Elm_Object_Item *it;
764
765         if (ctxpopup != NULL) {
766                 evas_object_del(ctxpopup);
767         }
768
769         ctxpopup = elm_ctxpopup_add(nf);
770         elm_ctxpopup_auto_hide_disabled_set(ctxpopup, EINA_TRUE);
771         elm_object_style_set(ctxpopup, "more/default");
772         eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK, eext_ctxpopup_back_cb, NULL);
773         eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_MORE, eext_ctxpopup_back_cb, NULL);
774         evas_object_smart_callback_add(ctxpopup, "dismissed", ctxpopup_dismissed_cb, NULL);
775         evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, more_ctxpopup_del_cb, nf);
776         evas_object_event_callback_add(nf, EVAS_CALLBACK_RESIZE, naviframe_resize_cb, ctxpopup);
777
778         /* We convince the top widget is a window */
779         win = elm_object_top_widget_get(nf);
780         evas_object_smart_callback_add(win, "rotation,changed", win_rotation_changed_cb, ctxpopup);
781
782         //---------------------------------------------------------------------------------------------
783         elm_ctxpopup_item_append(ctxpopup, _("IDS_ST_BODY_SAVE"), NULL, setting_network_connection_click_softkey_save_cb, ad);
784         elm_ctxpopup_item_append(ctxpopup, _("IDS_ST_BUTTON_CANCEL_ABB"), NULL, setting_network_connection_click_softkey_back_cb, ad);
785         //---------------------------------------------------------------------------------------------
786
787         elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN);
788         move_more_ctxpopup(ctxpopup);
789         evas_object_show(ctxpopup);
790 }
791 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
792
793
794 static int setting_network_connection_create(void *cb)
795 {
796         SETTING_TRACE_BEGIN;
797         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
798
799         SettingNetworkUG *ad = (SettingNetworkUG *) cb;
800         setting_retvm_if(!ad->con_name, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "!ad->con_name")
801
802         Evas_Object *scroller = elm_genlist_add(ad->win_main_layout);
803         retvm_if(scroller == NULL, SETTING_DRAW_ERR_FAIL_SCROLLER,
804                  "Cannot set scroller object  as contento of layout");
805         elm_genlist_realization_mode_set(scroller, EINA_TRUE);
806         elm_genlist_mode_set(scroller, ELM_LIST_COMPRESS);
807         elm_genlist_clear(scroller);    /* first to clear list */
808         evas_object_smart_callback_add(scroller, "realized", __gl_realized_cb, NULL);
809
810         ad->con_create_gl = scroller;
811
812         _init_context(ad);
813
814         const char *title = NULL;
815         switch (ad->profile_service_type) {
816                 case CONNECTION_CELLULAR_SERVICE_TYPE_MMS:
817                         title = "IDS_ST_BODY_MMS_CONNECTIONS";
818                         break;
819                 case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET:
820                         title = "IDS_ST_BODY_INTERNET_CONNECTION";
821                         break;
822                 default:
823                         title = ad->con_name;
824                         break;
825         }
826
827         ad->navi_it = setting_push_layout_navi_bar(_(title),
828                                                    NULL, /* ARROW STYLE */
829                                                    _("IDS_ST_BODY_SAVE"),
830                                                    _("IDS_ST_BUTTON_CANCEL_ABB"),
831                                                    setting_network_connection_click_softkey_back_cb,
832                                                    setting_network_connection_click_softkey_save_cb,
833                                                    setting_network_connection_click_softkey_cancel_cb, /* setting_network_connection_click_softkey_back_cb, */
834                                                    ad, scroller, ad->navi_bar, NULL);
835
836         elm_naviframe_item_pop_cb_set(ad->navi_it, setting_network_connection_click_softkey_back_cb, ad);
837         evas_object_data_set(ad->navi_bar, "sip.naviframe.title_obj", "*");
838
839
840         // Add ctx popup handler
841         Evas_Object* btn = elm_button_add(ad->navi_bar);
842         elm_object_style_set(btn, "naviframe/more/default");
843         evas_object_smart_callback_add(btn, "clicked", create_ctxpopup_more_button_cb, ad);
844         elm_object_item_part_content_set(ad->navi_it, "toolbar_more_btn", btn);
845
846         retv_if(!ad->navi_it, SETTING_RETURN_FAIL);
847         ad->has_form_changed  = FALSE;
848
849         setting_enable_expandable_genlist(scroller, ad,
850                                           __setting_network_connection_exp_cb,
851                                           NULL);
852         __get_connection_info(ad);
853         Elm_Object_Item *item;
854
855         item =
856             elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
857                                     ELM_GENLIST_ITEM_NONE, NULL, NULL);
858         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
859
860         bool new_flag = FALSE;
861         if (!safeStrCmp(STR_SETTING_NEW_CONNECTIONS, ad->con_name)) { /*new a profile,need to select the "Service type" */
862                 new_flag = TRUE;
863                 ad->data_srv_type =
864                     setting_create_Gendial_exp_parent_field(scroller,
865                                                             &itc_2text_3_parent,
866                                                             NULL, NULL,
867                                                             SWALLOW_Type_INVALID,
868                                                             _("IDS_MSGF_BODY_SERVICE_TYPE"),
869                                                             _("IDS_ST_BODY_INTERNET_CONNECTION"));
870                 /* ad->data_auth_type->int_slp_setting_binded = INT_SLP_SETTING_INVALID; */
871                 if (ad->data_srv_type) {
872                         ad->data_srv_type->userdata = ad;
873                         __BACK_POINTER_SET(ad->data_srv_type);
874                 } else {
875                         SETTING_TRACE_ERROR("ad->data_auth_type is NULL");
876                 }
877         }
878
879         ad->ed_profile_name_desc = elm_entry_utf8_to_markup(ad->ed_profile_name_desc);
880         ad->ed_acs_name_desc = elm_entry_utf8_to_markup(ad->ed_acs_name_desc);
881         SETTING_TRACE("name :%s", ad->ed_profile_name_desc);
882         SETTING_TRACE("apn :%s", ad->ed_acs_name_desc);
883
884         /* [UI] Profile name */
885         if (!isEmptyStr(ad->ed_profile_name_desc)) {
886                 /* Display */
887                 ad->data_profile_name =
888                     setting_create_Gendial_field_def(scroller,
889                                                            &itc_multiline_2text,
890                                                            NULL,
891                                                            ad,
892                                                            SWALLOW_Type_INVALID,
893                                                            NULL,
894                                                            NULL,
895                                                            0, /* chk_status*/
896                                                            "IDS_ST_BODY_PROFILE_NAME",
897                                                            (char *)ad->ed_profile_name_desc, /* sub_desk*/
898                                                            NULL);
899         } else {
900                 /* Editor */
901                 ad->data_profile_name =
902                     setting_create_Gendial_field_entry_with_return_key(scroller,
903                                                                        &itc_editfield, NULL,
904                                                                        ad, SWALLOW_Type_LAYOUT_EDITFIELD,
905                                                                        NULL, NULL, 0,
906                                                                        "IDS_ST_BODY_PROFILE_NAME",
907                                                                        (char *)ad->ed_profile_name_desc,
908                                                                        setting_network_connection_entry_changed_cb,
909                                                                        __network_max_len_reached,
910                                                                        ELM_INPUT_PANEL_LAYOUT_NORMAL,
911                                                                        FALSE, FALSE,
912                                                                        64, 64, NULL, NULL, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT, setting_network_connection_entry_next_activated_cb, NULL);
913         }
914
915         if (ad->data_profile_name) {
916                 __BACK_POINTER_SET(ad->data_profile_name);
917                 ad->data_profile_name->userdata = ad;
918                 ad->data_profile_name->win_main = ad->win_get;
919                 ad->data_profile_name->isSinglelineFlag = TRUE;
920                 /*there is no CAPI to set profile name,so disable it: */
921                 /*setting_disable_genlist_item(ad->data_profile_name->item); */
922                 if (!isEmptyStr(ad->ed_profile_name_desc)) { /*not create(first time) */
923                         elm_genlist_item_select_mode_set(ad->data_profile_name->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
924
925                         /*setting_disable_genlist_item(ad->data_profile_name->item); */
926                 }
927         } else {
928                 SETTING_TRACE_ERROR("ad->data_acs_name is NULL");
929         }
930
931         /* [UI] Access point name */
932         ad->data_acs_name =
933             setting_create_Gendial_field_entry_with_return_key(scroller,
934                                                                &itc_editfield, NULL,
935                                                                ad, SWALLOW_Type_LAYOUT_EDITFIELD,
936                                                                NULL, NULL, 0,
937                                                                "IDS_DLNA_BODY_ACCESS_POINT_NAME",
938                                                                (char *)ad->ed_acs_name_desc,
939                                                                setting_network_connection_entry_changed_cb,
940                                                                __network_max_len_reached,
941                                                                ELM_INPUT_PANEL_LAYOUT_NORMAL,
942                                                                FALSE, FALSE,
943                                                                64, 64, NULL, NULL, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE, NULL, NULL);
944         if (ad->data_acs_name) {
945                 __BACK_POINTER_SET(ad->data_acs_name);
946                 ad->data_acs_name->userdata = ad;
947                 ad->data_acs_name->isSinglelineFlag = TRUE;
948                 ad->data_acs_name->win_main = ad->win_get;
949         } else {
950                 SETTING_TRACE_ERROR("ad->data_acs_name is NULL");
951         }
952
953         item =
954             elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
955                                     ELM_GENLIST_ITEM_NONE, NULL, NULL);
956         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
957
958         ad->data_auth_type =
959             setting_create_Gendial_field_def(scroller,
960                                                     &itc_2text_3_parent,
961                                                     __create_auth_type_popup, ad,
962                                                     SWALLOW_Type_INVALID,
963                                                     NULL, NULL, 0,
964                                                     "IDS_ST_BODY_AUTH_TYPE",
965                                                     (char *)ad->ed_auth_type_desc, NULL);
966         /* ad->data_auth_type->int_slp_setting_binded = INT_SLP_SETTING_INVALID; */
967         if (ad->data_auth_type) {
968                 ad->data_auth_type->userdata = ad;
969                 __BACK_POINTER_SET(ad->data_auth_type);
970         } else {
971                 SETTING_TRACE_ERROR("ad->data_auth_type is NULL");
972         }
973
974         ad->item_above_user_name = item =
975                                        elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
976                                                                ELM_GENLIST_ITEM_NONE, NULL, NULL);
977         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
978
979         ad->is_show_user = 0;
980         if (CONNECTION_CELLULAR_AUTH_TYPE_NONE != ad->chkType) {
981                 /* [UI] User ID */
982                 ad->data_user_name =
983                     setting_create_Gendial_field_entry_with_return_key(scroller,
984                                                                        &itc_editfield,
985                                                                        NULL, ad,
986                                                                        SWALLOW_Type_LAYOUT_EDITFIELD,
987                                                                        NULL, NULL, 0,
988                                                                        KeyStr_UserID,
989                                                                        (char *)
990                                                                        ad->ed_user_name_desc,
991                                                                        setting_network_connection_entry_changed_cb,
992                                                                        __network_max_len_reached,
993                                                                        ELM_INPUT_PANEL_LAYOUT_NORMAL,
994                                                                        FALSE, FALSE,
995                                                                        MAX_PDP_AUTH_USERNAME_LEN_MAX, MAX_PDP_AUTH_USERNAME_LEN_MAX,
996                                                                        NULL, NULL, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT, setting_network_connection_entry_next_activated_cb, NULL);
997                 if (ad->data_user_name) {
998                         __BACK_POINTER_SET(ad->data_user_name);
999                         ad->data_user_name->userdata = ad;
1000                         ad->data_user_name->isSinglelineFlag = TRUE;
1001                         ad->data_user_name->win_main = ad->win_get;
1002                 } else {
1003                         SETTING_TRACE_ERROR("ad->data_user_name is NULL");
1004                 }
1005
1006                 /* [UI] Password */
1007                 ad->data_pwd =
1008                     setting_create_Gendial_field_entry_with_return_key(scroller,
1009                                                                        &itc_editfield,
1010                                                                        NULL, ad,
1011                                                                        SWALLOW_Type_LAYOUT_EDITFIELD,
1012                                                                        NULL, NULL, 0,
1013                                                                        "IDS_ST_BODY_PASSWORD",
1014                                                                        (char *)ad->ed_pwd_desc,
1015                                                                        setting_network_connection_entry_changed_cb,
1016                                                                        __network_max_len_reached,
1017                                                                        ELM_INPUT_PANEL_LAYOUT_NORMAL,
1018                                                                        TRUE, FALSE,
1019                                                                        MAX_PDP_AUTH_USERNAME_LEN_MAX, MAX_PDP_AUTH_USERNAME_LEN_MAX,
1020                                                                        NULL, NULL, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT, setting_network_connection_entry_next_activated_cb, NULL);
1021                 if (ad->data_pwd) {
1022                         __BACK_POINTER_SET(ad->data_pwd);
1023                         ad->data_pwd->userdata = ad;
1024                         ad->data_pwd->win_main = ad->win_get;
1025                         ad->data_pwd->isSinglelineFlag = TRUE;
1026                         ad->is_show_user = 1;
1027                 } else {
1028                         SETTING_TRACE_ERROR("ad->data_pwd is NULL");
1029                 }
1030
1031                 ad->item_above_proxy_add = item =
1032                                                elm_genlist_item_append(scroller, &itc_seperator,
1033                                                                        NULL, NULL, ELM_GENLIST_ITEM_NONE,
1034                                                                        NULL, NULL);
1035                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1036         }
1037
1038         /* [UI] Proxy address */
1039         ad->data_pxy_addr =
1040             setting_create_Gendial_field_entry_with_return_key(scroller,
1041                                                                &itc_editfield, NULL,
1042                                                                ad, SWALLOW_Type_LAYOUT_EDITFIELD,
1043                                                                NULL, NULL, 0,
1044                                                                "IDS_ST_BODY_CONNECTIONSETTINGS_PROXY_ADDRESS",
1045                                                                (char *)ad->ed_pxy_addr_desc,
1046                                                                setting_network_connection_entry_changed_cb,
1047                                                                __network_max_len_reached,
1048                                                                ELM_INPUT_PANEL_LAYOUT_URL,
1049                                                                FALSE, FALSE,
1050                                                                512, 512, NULL, NULL, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT, setting_network_connection_entry_next_activated_cb, NULL);
1051         if (ad->data_pxy_addr) {
1052                 __BACK_POINTER_SET(ad->data_pxy_addr);
1053                 ad->data_pxy_addr->userdata = ad;
1054                 ad->data_pxy_addr->isSinglelineFlag = TRUE;
1055                 ad->data_pxy_addr->win_main = ad->win_get;
1056         } else {
1057                 SETTING_TRACE_ERROR("ad->data_pxy_addr is NULL");
1058         }
1059
1060         /* Set SIP key on Next or Done if Home URL existed or not below. */
1061         Elm_Input_Panel_Return_Key_Type type = ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1062         setting_call_back_func cbFunc = NULL;
1063
1064         if (!safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS)) {
1065                 type = ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
1066                 cbFunc = setting_network_connection_entry_next_activated_cb;
1067                 //SETTING_TRACE_ERROR("Enter here hwy ---> ad->con_name : %s ", ad->con_name);
1068         }
1069
1070         /* [UI] Proxy port */
1071         ad->data_pxy_port =
1072             setting_create_Gendial_field_entry_with_return_key(scroller,
1073                                                                &itc_editfield, NULL,
1074                                                                ad, SWALLOW_Type_LAYOUT_EDITFIELD,
1075                                                                NULL, NULL, 0,
1076                                                                "IDS_ST_BODY_PROXY_PORT",
1077                                                                (char *)ad->ed_pxy_port_desc,
1078                                                                setting_network_connection_entry_changed_cb,
1079                                                                __network_max_len_reached,
1080                                                                ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
1081                                                                FALSE, FALSE,
1082                                                                0,
1083                                                                5, "0123456789", NULL, type, cbFunc, NULL);
1084         if (ad->data_pxy_port) {
1085                 ad->data_pxy_port->userdata = ad;
1086                 ad->data_pxy_port->isSinglelineFlag = TRUE;
1087                 __BACK_POINTER_SET(ad->data_pxy_port);
1088                 ad->data_pxy_port->win_main = ad->win_get;
1089         } else {
1090                 SETTING_TRACE_ERROR("ad->data_pxy_port is NULL");
1091         }
1092
1093
1094         // if current view is "MMS connection"
1095         if (!safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS)) {   /*  mms Connection */
1096
1097                 #if 0
1098                 if (ad->data_pxy_port) {
1099                         ad->data_pxy_port->return_key_type = ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
1100                         //SETTING_TRACE_ERROR("ad->data_pxy_port->return_key_type = ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT");
1101                 }
1102                 #endif
1103                 /* [UI] Home URL */
1104                 ad->data_hm_url =
1105                     setting_create_Gendial_field_entry_with_return_key(scroller,
1106                                                                        &itc_editfield,
1107                                                                        NULL, ad,
1108                                                                        SWALLOW_Type_LAYOUT_EDITFIELD,
1109                                                                        NULL, NULL, 0,
1110                                                                        "IDS_ST_BODY_HOME_URL",
1111                                                                        (char *)ad->ed_hm_url_desc,
1112                                                                        setting_network_connection_entry_changed_cb,
1113                                                                        __network_max_len_reached,
1114                                                                        ELM_INPUT_PANEL_LAYOUT_URL,
1115                                                                        FALSE, FALSE,
1116                                                                        0, 521, NULL, NULL,
1117                                                                        ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE, NULL, NULL);
1118                 if (ad->data_hm_url) {
1119                         __BACK_POINTER_SET(ad->data_hm_url);
1120                         ad->data_hm_url->userdata = ad;
1121                         ad->data_hm_url->isSinglelineFlag = TRUE;
1122                         ad->data_hm_url->win_main = ad->win_get;
1123                         ad->data_hm_url->return_key_type = ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1124                 } else {
1125                         SETTING_TRACE_ERROR("ad->data_hm_url is NULL");
1126                 }
1127                 /* ad->is_show_url = 1; */
1128         }
1129
1130         setting_view_network_connection_create.is_create = 1;
1131         ad->scl_edit = scroller;
1132         /*__genlist_disable_set(ad->scl_edit, TRUE); */
1133         /*ad->is_editable = FALSE; for test */
1134         SETTING_TRACE("==> ad->is_editable:%d", ad->is_editable);
1135         if (!ad->is_editable) {
1136                 /*SETTING_TRACE("xxxx....."); */
1137                 if (ad->data_srv_type) setting_disable_genlist_item(ad->data_srv_type->item);
1138                 if (ad->data_profile_name) setting_disable_genlist_item(ad->data_profile_name->item);
1139                 if (ad->data_acs_name) setting_disable_genlist_item(ad->data_acs_name->item);
1140                 if (ad->data_auth_type) setting_disable_genlist_item(ad->data_auth_type->item);
1141
1142
1143                 if (ad->data_user_name) setting_disable_genlist_item(ad->data_user_name->item);
1144                 if (ad->data_pwd) setting_disable_genlist_item(ad->data_pwd->item);
1145                 if (ad->data_pxy_addr) setting_disable_genlist_item(ad->data_pxy_addr->item);
1146                 if (ad->data_pxy_port) setting_disable_genlist_item(ad->data_pxy_port->item);
1147                 if (ad->data_hm_url) setting_disable_genlist_item(ad->data_hm_url->item);
1148         }
1149         ecore_idler_add(__connection_idler, ad);
1150
1151         return SETTING_RETURN_SUCCESS;
1152 }
1153
1154 static int setting_network_connection_destroy(void *cb)
1155 {
1156         SETTING_TRACE_BEGIN;
1157         /* error check */
1158         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1159
1160         SettingNetworkUG *ad = (SettingNetworkUG *) cb;
1161
1162         evas_object_data_set(ad->navi_bar, "sip.naviframe.title_obj", NULL);
1163         ad->navi_it = NULL;
1164         ad->bottom_btn = NULL;
1165         ad->back_btn = NULL;
1166         /*manager separatly, */
1167         if (ad->l_button) {
1168                 evas_object_del(ad->l_button);
1169                 ad->l_button = NULL;
1170         }
1171         /*if (ad->m_button)
1172         {
1173                 evas_object_del(ad->m_button);
1174                 ad->m_button = NULL;
1175         }*/
1176         if (ad->r_button) {
1177                 evas_object_del(ad->r_button);
1178                 ad->r_button = NULL;
1179         }
1180         /*FREE(ad->con_name); */
1181         G_FREE(ad->ed_profile_name_desc);
1182         G_FREE(ad->ed_acs_name_desc);
1183         G_FREE(ad->ed_user_name_desc);
1184         G_FREE(ad->ed_pwd_desc);
1185
1186         G_FREE(ad->ed_pxy_addr_desc);
1187         G_FREE(ad->ed_pxy_port_desc);
1188
1189         G_FREE(ad->ed_hm_url_desc);
1190
1191         elm_naviframe_item_pop(ad->navi_bar);
1192
1193         setting_view_network_connection_create.is_create = 0;
1194         return SETTING_RETURN_SUCCESS;
1195 }
1196
1197 static int setting_network_connection_update(void *cb)
1198 {
1199         SETTING_TRACE_BEGIN;
1200         return SETTING_RETURN_SUCCESS;
1201 }
1202
1203 static int setting_network_connection_cleanup(void *cb)
1204 {
1205         return setting_network_connection_destroy(cb);
1206 }
1207
1208 /* ***************************************************
1209  *
1210  *general func
1211  *
1212  ***************************************************/
1213 bool need_check_default_profile(void *data, connection_cellular_service_type_e inputtype)
1214 {
1215         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1216         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1217         SETTING_TRACE("inputtype:%d", inputtype);
1218         connection_profile_iterator_h profile_iter = NULL;
1219         connection_profile_h profile_h = NULL;
1220         int rv = connection_get_profile_iterator(ad->connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
1221         if (rv != CONNECTION_ERROR_NONE) {
1222                 SETTING_TRACE_ERROR("Fail to get profile iterator [%d]", rv);
1223                 return SETTING_RETURN_FAIL;
1224         }
1225
1226         int cnt = 0;
1227         connection_profile_type_e profile_type = CONNECTION_PROFILE_TYPE_CELLULAR;
1228         connection_cellular_service_type_e service_type = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
1229         while (connection_profile_iterator_has_next(profile_iter)) {
1230                 if (cnt >= MAX_PROFILE_NUM) {
1231                         break;
1232                 }
1233                 cnt++;
1234                 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
1235                         SETTING_TRACE_ERROR("Fail to get profile handle");
1236                         break;
1237                 }
1238
1239                 if (connection_profile_get_type(profile_h, &profile_type) != CONNECTION_ERROR_NONE) {
1240                         SETTING_TRACE_ERROR("Fail to get profile type");
1241                         continue;
1242                 }
1243                 if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) {
1244                         SETTING_TRACE_ERROR("Fail to get service type");
1245                         continue;
1246                 }
1247                 if (CONNECTION_PROFILE_TYPE_CELLULAR == profile_type && inputtype == service_type) {
1248                         char *apn = NULL;
1249                         connection_profile_get_cellular_apn(profile_h, &apn);
1250                         SETTING_TRACE("Matched:%s", apn);
1251                         FREE(apn);
1252                         return FALSE;
1253                 }
1254         }
1255         return TRUE;
1256 }
1257
1258 /**
1259  * popup - timeout and 'ok' callback
1260  */
1261 static void __setting_network_connection_popup_rsp_cb(void *data, Evas_Object *obj, void *event_info)
1262 {
1263
1264         SETTING_TRACE_BEGIN;
1265         setting_retm_if(obj == NULL, "obj parameter is NULL");
1266         setting_retm_if(data == NULL, "Data parameter is NULL");
1267         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1268
1269         // remove ctxpopup
1270         if (ctxpopup != NULL) {
1271                 evas_object_del(ctxpopup);
1272                 ctxpopup = NULL;
1273         }
1274 }
1275
1276
1277
1278 static int __save_connection(void *data)
1279 {
1280         SETTING_TRACE_BEGIN;
1281         /* error check */
1282         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1283
1284         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1285         const char *profile_name = NULL;
1286         const char *acs_name = NULL;
1287         const char *usr_name = NULL;
1288         const char *pwd = NULL;
1289         const char *addr = NULL;
1290         const char *port = NULL;
1291         const char *home = NULL;
1292
1293         if (ad->data_profile_name)
1294                 profile_name = elm_entry_markup_to_utf8(ad->data_profile_name->sub_desc);
1295         if (ad->data_acs_name)
1296                 acs_name = elm_entry_markup_to_utf8(ad->data_acs_name->sub_desc);
1297         if (ad->data_user_name)
1298                 usr_name = elm_entry_markup_to_utf8(ad->data_user_name->sub_desc);
1299         if (ad->data_pwd)
1300                 pwd = elm_entry_markup_to_utf8(ad->data_pwd->sub_desc);
1301         if (ad->data_pxy_addr)
1302                 addr = elm_entry_markup_to_utf8(ad->data_pxy_addr->sub_desc);
1303         if (ad->data_pxy_port)
1304                 port = elm_entry_markup_to_utf8(ad->data_pxy_port->sub_desc);
1305
1306         if (!profile_name)
1307                 profile_name = strdup("");
1308         if (!acs_name)
1309                 acs_name = strdup("");
1310         if (!usr_name)
1311                 usr_name = strdup("");
1312         if (!pwd)
1313                 pwd = strdup("");
1314         if (!addr)
1315                 addr = strdup("");
1316         if (!port)
1317                 port = strdup("");
1318         SETTING_TRACE("acs_name:%s", acs_name);
1319         SETTING_TRACE("usr_name:%s", usr_name);
1320         SETTING_TRACE("pwd:%s", pwd);
1321
1322         SETTING_TRACE("addr:%s", addr);
1323         SETTING_TRACE("port:%s", port);
1324         SETTING_TRACE("home:%s", home);
1325
1326         char sz_text[MAX_HOME_URL_LEN_MAX + 1] = { 0, };
1327         int type;
1328         int ret = SETTING_RETURN_SUCCESS;
1329         int err;
1330
1331         if (!safeStrCmp(profile_name, "")) {
1332
1333                 char name[MAX_DISPLAY_NAME_LEN_ON_UI + 1] = {0, };
1334                 snprintf(name, sizeof(name), _("IDS_ST_POP_ENTER_PS"), _("IDS_ST_BODY_PROFILE_NAME"));
1335
1336
1337                 setting_create_popup(ad, ad->win_get, NULL, _(name), __setting_network_connection_popup_rsp_cb, 2/*SECONDS*/, false, false, 0);
1338                 FREE(acs_name);
1339                 FREE(profile_name);
1340                 FREE(usr_name);
1341                 FREE(pwd);
1342                 FREE(addr);
1343                 FREE(port);
1344                 return SETTING_DNET_RETURN_NULL_ACCESS_NAME;
1345         }
1346
1347         if (!safeStrCmp(acs_name, "")) {
1348
1349                 char name[MAX_DISPLAY_NAME_LEN_ON_UI + 1] = {0, };
1350                 snprintf(name, sizeof(name), _("IDS_ST_POP_ENTER_PS"), _("IDS_DLNA_BODY_ACCESS_POINT_NAME"));
1351                 setting_create_popup(ad, ad->win_get, NULL, _(name), __setting_network_connection_popup_rsp_cb, 2/*SECONDS*/, false, false, 0);
1352                 FREE(acs_name);
1353                 FREE(profile_name);
1354                 FREE(usr_name);
1355                 FREE(pwd);
1356                 FREE(addr);
1357                 FREE(port);
1358                 return SETTING_DNET_RETURN_NULL_ACCESS_NAME;
1359         }
1360         /*if (test_update_cellular_info(profile) == -1) */
1361         bool add_flag = FALSE;/*add a new profile */
1362         connection_profile_h con_info = NULL;
1363         connection_profile_h con_info_2 = NULL;/*for MMS */
1364         if (ad->sel_profile_h) {
1365                 con_info = ad->sel_profile_h;
1366                 if (0 != safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS)
1367                     && 0 != safeStrCmp(ad->con_name, "IDS_ST_BODY_INTERNET_CONNECTION")) {
1368                         /*need to change con_name */
1369                         /*FREE(ad->con_name); */
1370                         /*ad->con_name = strdup(acs_name); */
1371                 }
1372         } else {
1373                 if (!safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS)) {
1374                         (void)connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, _(profile_name), &con_info);
1375                         (void)connection_profile_set_cellular_service_type(con_info, CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
1376                 } else if (!safeStrCmp(ad->con_name, "IDS_ST_BODY_INTERNET_CONNECTION")) {
1377                         (void)connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, _(profile_name), &con_info);
1378                         (void)connection_profile_set_cellular_service_type(con_info, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
1379                 } else {
1380                         /*need to change con_name */
1381                         /*FREE(ad->con_name); */
1382                         /*ad->con_name = strdup(acs_name); */
1383                         (void)connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, _(profile_name), &con_info);
1384                         if (CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET == ad->srvType) {
1385                                 /*Internet */
1386                                 (void)connection_profile_set_cellular_service_type(con_info, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
1387                         } else if (CONNECTION_CELLULAR_SERVICE_TYPE_MMS == ad->srvType) {
1388                                 /*MMS */
1389                                 (void)connection_profile_set_cellular_service_type(con_info, CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
1390                         } else { /*MMS + Internet(Together) */
1391                                 (void)connection_profile_set_cellular_service_type(con_info, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
1392                                 (void)connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, _(profile_name), &con_info_2);
1393                                 (void)connection_profile_set_cellular_service_type(con_info_2, CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
1394                                 SETTING_TRACE("con_info_2:%p", con_info_2);
1395                         }
1396                 }
1397
1398                 add_flag = TRUE;
1399         }
1400
1401         SETTING_TRACE("ad->con_name:%s", ad->con_name);
1402         SETTING_TRACE("profile_name:%s", profile_name);
1403         FREE(profile_name);
1404         /* save access name */
1405         SETTING_TRACE("acs_name:%s", acs_name);
1406
1407         (void) connection_profile_set_cellular_apn(con_info, acs_name);
1408         if (con_info_2)(void)connection_profile_set_cellular_apn(con_info_2, acs_name);
1409         FREE(acs_name);
1410
1411         /* save auth type */
1412         type = ad->chkType;
1413         SETTING_TRACE("-----> auth type: %d", type);
1414         SETTING_TRACE("-----> radio button state: %d", elm_radio_value_get(ad->chk_type));
1415
1416 #ifdef OLD_AUTH_CONCEPT
1417         /* save user name */
1418         if (!safeStrCmp(usr_name, "")
1419             && CONNECTION_CELLULAR_AUTH_TYPE_NONE != type) {
1420                 setting_create_popup(ad, ad->win_get,
1421                                             NULL, _(Insert_User_Name_Desc), __setting_network_connection_popup_rsp_cb, 2/*SECONDS*/, false, false, 0);
1422                 FREE(usr_name);
1423                 FREE(pwd);
1424                 FREE(addr);
1425                 FREE(port);
1426                 return SETTING_DNET_RETURN_NULL_USER_NAME;
1427         }
1428
1429         /* save password */
1430         if (!safeStrCmp(pwd, "")
1431             && CONNECTION_CELLULAR_AUTH_TYPE_NONE != type) {
1432                 setting_create_popup(ad, ad->win_get,
1433                                             NULL, _(""), __setting_network_connection_popup_rsp_cb,2/*SECONDS*/, false, false, 0);/*this code is not used now, so remove the ID which is not used in po file*/
1434                 FREE(usr_name);
1435                 FREE(pwd);
1436                 FREE(addr);
1437                 FREE(port);
1438                 return SETTING_DNET_RETURN_NULL_PASSWORD;
1439         }
1440 #endif
1441         (void)connection_profile_set_cellular_auth_info(con_info, type, usr_name, pwd);
1442         if (con_info_2)(void)connection_profile_set_cellular_auth_info(con_info_2, type, usr_name, pwd);
1443
1444         /* save proxy addr */
1445         SETTING_TRACE("addr:port[%s:%s]", addr, port);
1446         char *output_addr = NULL;
1447         if (isEmptyStr(addr)) {
1448                 /* check proxy port */
1449                 if (!isEmptyStr(port)) {
1450                         setting_create_popup(ad, ad->win_get,
1451                                                     NULL, _("IDS_COM_BODY_ENTER_PROXY_EMPTY"), __setting_network_connection_popup_rsp_cb, 2/*SECONDS*/, false, false, 0);
1452                         FREE(usr_name);
1453                         FREE(pwd);
1454                         FREE(addr);
1455                         FREE(port);
1456                         return SETTING_DNET_RETURN_INVALID_PROXY_ADDR;
1457                 }
1458         } else {
1459                 output_addr = g_strdup(addr);
1460                 if (isEmptyStr(port)) {
1461                         snprintf(sz_text, sizeof(sz_text), "%s", output_addr);
1462                 } else {
1463                         snprintf(sz_text, sizeof(sz_text), "%s:%s", output_addr, port);
1464                 }
1465         }
1466
1467         G_FREE(output_addr);
1468         SETTING_TRACE("sz_text:%s", sz_text);
1469         if (!isEmptyStr(sz_text)) {
1470                 connection_profile_set_proxy_address(con_info, CONNECTION_ADDRESS_FAMILY_IPV4, sz_text);
1471                 if (con_info_2) {
1472                         connection_profile_set_proxy_address(con_info_2, CONNECTION_ADDRESS_FAMILY_IPV4, sz_text);
1473                 }
1474         } else {
1475                 connection_profile_set_proxy_address(con_info, CONNECTION_ADDRESS_FAMILY_IPV4, NULL);
1476                 if (con_info_2) {
1477                         connection_profile_set_proxy_address(con_info_2, CONNECTION_ADDRESS_FAMILY_IPV4, NULL);
1478                 }
1479         }
1480         /* save home url(message connection only) */
1481         if (!safeStrCmp(ad->con_name, STR_SETTING_MMS_CONNECTIONS)
1482             || (!safeStrCmp(ad->con_name, STR_SETTING_NEW_CONNECTIONS)
1483                 && CONNECTION_CELLULAR_SERVICE_TYPE_MMS == ad->srvType)) {      /* Message Connection */
1484                 home = elm_entry_markup_to_utf8(ad->data_hm_url->sub_desc);
1485                 if (home == (char *)NULL) {
1486                         (void)connection_profile_set_cellular_home_url(con_info, URL_HEAD);
1487                 } else {
1488                         if (!safeStrCmp(home, "")) {
1489                                 FREE(home);
1490                                 home = strdup(URL_HEAD);
1491                                 ret = SETTING_DNET_RETURN_NULL_HOMEURL;
1492                         }
1493                         (void)connection_profile_set_cellular_home_url(con_info, home);
1494                 }
1495         }
1496         FREE(home);
1497         if (con_info_2) { /*creating both internet + MMS */
1498                 home = elm_entry_markup_to_utf8(ad->data_hm_url->sub_desc);
1499                 if (home == (char *)NULL) {
1500                         (void)connection_profile_set_cellular_home_url(con_info_2, URL_HEAD);
1501                 } else {
1502                         if (!safeStrCmp(home, "")) {
1503                                 FREE(home);
1504                                 home = strdup(URL_HEAD);
1505                                 ret = SETTING_DNET_RETURN_NULL_HOMEURL;
1506                         }
1507                         (void)connection_profile_set_cellular_home_url(con_info_2, home);
1508                 }
1509         }
1510
1511         FREE(usr_name);
1512         FREE(pwd);
1513         FREE(addr);
1514         FREE(port);
1515         FREE(home);
1516         /*SETTING_TRACE("ad->con_type:%d", ad->con_type); */
1517         /* save connection */
1518         if (add_flag) {
1519                 SETTING_TRACE("con_info is %p, con_info_2:%p", con_info, con_info_2);
1520
1521                 /*Add a new profile */
1522                 connection_cellular_service_type_e type = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
1523                 (void)connection_profile_get_cellular_service_type(con_info, &type);
1524
1525                 err = connection_add_profile(ad->connection, con_info);
1526                 if (err != CONNECTION_ERROR_NONE) {
1527                         SETTING_TRACE_ERROR("*** [ERR] connection_add_profile. err=%d ***", err);
1528                         ret = SETTING_DNET_RETURN_ERR;
1529                         setting_create_popup(ad, ad->win_get, NULL, _("IDS_CST_POP_FAILED"), NULL, 0, false, false, 0);
1530                         return ret;
1531                 }
1532                 connection_profile_h tmp_profile = NULL;
1533                 (void)connection_get_default_cellular_service_profile(ad->connection, type, &tmp_profile);
1534                 /*
1535                 => if there is already default profile, after_profile will be handle of default profile.
1536                 => there is no default profile, after_profile will be handle of the profile which we have added just before.
1537                 */
1538                 if (setting_network_equal_profile(con_info, tmp_profile)) {
1539                         SETTING_TRACE_ERROR("Going to set profile")
1540                         (void)connection_set_default_cellular_service_profile(ad->connection, type, tmp_profile);
1541                 } else {
1542                         /*nothing to do */
1543                 }
1544
1545                 (void)connection_destroy(tmp_profile);
1546
1547                 (void)connection_profile_destroy(con_info);
1548
1549
1550
1551                 if (con_info_2) { /*just for MMS + internet */
1552                         connection_cellular_service_type_e type = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
1553                         (void)connection_profile_get_cellular_service_type(con_info_2, &type);
1554                         /*Add a new profile */
1555                         err = connection_add_profile(ad->connection, con_info_2);
1556                         if (err != CONNECTION_ERROR_NONE) {
1557                                 SETTING_TRACE_ERROR("*** [ERR] connection_add_profile. err=%d ***", err);
1558                                 ret = SETTING_DNET_RETURN_ERR;
1559                                 setting_create_popup(ad, ad->win_get, NULL, _("IDS_CST_POP_FAILED"), NULL, 0, false, false, 0);
1560                                 return ret;
1561                         }
1562                         connection_profile_h tmp_profile = NULL;
1563                         (void)connection_get_default_cellular_service_profile(ad->connection, type, &tmp_profile);
1564                         /*
1565                         => if there is already default profile, after_profile will be handle of default profile.
1566                         => there is no default profile, after_profile will be handle of the profile which we have added just before.
1567                         */
1568                         if (setting_network_equal_profile(con_info_2, tmp_profile)) {
1569                                 SETTING_TRACE_ERROR("Going to set profile")
1570                                 (void)connection_set_default_cellular_service_profile(ad->connection, type, tmp_profile);
1571                         } else {
1572                                 /*nothing to do */
1573                         }
1574
1575                         (void)connection_destroy(tmp_profile);
1576                         (void)connection_profile_destroy(con_info_2);
1577                 }
1578         } else {
1579
1580                 err = connection_update_profile(ad->connection, con_info);
1581                 if (err != CONNECTION_ERROR_NONE) {
1582                         SETTING_TRACE_ERROR
1583                         ("%s*** [ERR] net_modify_profile. err=%d ***%s",
1584                          SETTING_FONT_RED, err, SETTING_FONT_BLACK);
1585                         ret = SETTING_DNET_RETURN_ERR;
1586                         setting_create_popup(ad, ad->win_get,
1587                                                     NULL, _("IDS_CST_POP_FAILED"), NULL, 0, false, false, 0);
1588                 }
1589         }
1590         return ret;
1591 }
1592
1593 /* ***************************************************
1594  *
1595  *call back func
1596  *
1597  ***************************************************/
1598 #if 0
1599 static void
1600 setting_network_connection_click_softkey_done_cb(void *data,
1601                                                  Evas_Object *obj,
1602                                                  void *event_info)
1603 {
1604         SETTING_TRACE_BEGIN;
1605         /* error check */
1606         retm_if(data == NULL, "Data parameter is NULL");
1607
1608         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1609         if (ad->data_profile_name) {
1610                 setting_hide_input_pannel_cb(ad->data_profile_name->eo_check);
1611         }
1612
1613         if (ad->data_acs_name) {
1614                 setting_hide_input_pannel_cb(ad->data_acs_name->eo_check);
1615         }
1616         if (ad->data_user_name) {
1617                 setting_hide_input_pannel_cb(ad->data_user_name->eo_check);
1618         }
1619         if (ad->data_pwd) {
1620                 setting_hide_input_pannel_cb(ad->data_pwd->eo_check);
1621         }
1622         if (ad->data_pxy_addr) {
1623                 setting_hide_input_pannel_cb(ad->data_pxy_addr->eo_check);
1624         }
1625         if (ad->data_pxy_port) {
1626                 setting_hide_input_pannel_cb(ad->data_pxy_port->eo_check);
1627         }
1628         if (ad->data_hm_url) {
1629                 setting_hide_input_pannel_cb(ad->data_hm_url->eo_check);
1630         }
1631 }
1632 #endif
1633
1634 static void __save_response_cb(void *data, Evas_Object *obj,
1635                                void *event_info)
1636 {
1637         SETTING_TRACE_BEGIN;
1638         retm_if(data == NULL, "Data parameter is NULL");
1639
1640         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1641         if (obj) {
1642                 evas_object_del(obj);
1643                 obj = NULL;
1644         }
1645         /*re-fetch connection info.. */
1646         /*__get_connection_info(ad); */
1647         SETTING_TRACE("ad->con_name:%s", ad->con_name);
1648
1649         ad->apn_MMS = __get_profile_name(CONNECTION_CELLULAR_SERVICE_TYPE_MMS, ad);
1650
1651         elm_naviframe_item_pop(ad->navi_bar);   /* Call automatically setting_network_connection_click_softkey_back_cb() by registering elm_naviframe_item_pop_cb_set() */
1652 }
1653
1654 /**
1655  * [UI-CALLBACK] 'Save' button handler
1656  */
1657 static void
1658 setting_network_connection_click_softkey_save_cb(void *data,
1659                                                  Evas_Object *obj,
1660                                                  void *event_info)
1661 {
1662         SETTING_TRACE_BEGIN;
1663         /* error check */
1664         retm_if(data == NULL, "Data parameter is NULL");
1665
1666         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1667
1668         int ret = __save_connection(ad);
1669         /* need special handle */
1670         if (SETTING_DNET_RETURN_NULL_ACCESS_NAME == ret
1671             || SETTING_DNET_RETURN_NULL_USER_NAME == ret
1672             || SETTING_DNET_RETURN_NULL_PASSWORD == ret
1673             || SETTING_DNET_RETURN_INVALID_PROXY_ADDR == ret
1674             || SETTING_DNET_RETURN_ERR == ret) {
1675                 return;
1676         }
1677         if (ret != SETTING_RETURN_SUCCESS) {
1678                 SETTING_TRACE_ERROR
1679                 ("%s*** [ERR] __save_connection ***%s",
1680                  SETTING_FONT_RED, SETTING_FONT_BLACK);
1681         }
1682
1683         elm_object_tree_focus_allow_set(ad->con_create_gl, EINA_FALSE);
1684
1685         setting_create_popup(ad, ad->win_get, NULL, KeyStr_Saved, __save_response_cb, 1, FALSE, FALSE, 0);
1686
1687         if (ctxpopup != NULL) {
1688                 evas_object_del(ctxpopup);
1689                 ctxpopup = NULL;
1690         }
1691 }
1692
1693
1694 static Eina_Bool
1695 setting_network_connection_click_softkey_back_cb(void *data, Elm_Object_Item *it)
1696 {
1697         SETTING_TRACE_BEGIN;
1698         /* error check */
1699         retvm_if(data == NULL, EINA_TRUE, "Data parameter is NULL");
1700
1701         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1702
1703         elm_object_tree_focus_allow_set(ad->con_create_gl, EINA_FALSE);
1704
1705         SETTING_TRACE("ad->con_name:%s", ad->con_name);
1706         if (!safeStrCmp(STR_SETTING_NEW_CONNECTIONS, ad->con_name)
1707             || ad->profile_topper_view == &setting_view_network_con) { /*new a profile,need to select the "Service type" */
1708                 /*not normal view change,need do specially */
1709                 setting_view_cleanup(&setting_view_network_connection_create, ad);
1710                 setting_view_update(&setting_view_network_con, ad);
1711         } else {
1712                 setting_view_change(&setting_view_network_connection_create, &setting_view_network_con_list, ad);
1713         }
1714
1715         if (ctxpopup != NULL) {
1716                 evas_object_del(ctxpopup);
1717                 ctxpopup = NULL;
1718         }
1719
1720         return EINA_TRUE;
1721 }
1722
1723 static void
1724 setting_network_connection_click_softkey_cancel_cb(void *data,
1725                                                    Evas_Object *obj,
1726                                                    void *event_info)
1727 {
1728         SETTING_TRACE_BEGIN;
1729         /* error check */
1730         retm_if(data == NULL, "Data parameter is NULL");
1731
1732         SettingNetworkUG *ad = (SettingNetworkUG *) data;
1733
1734         elm_naviframe_item_pop(ad->navi_bar);   /* Call automatically setting_network_connection_click_softkey_back_cb() by registering elm_naviframe_item_pop_cb_set() */
1735 }
1736
1737 static void setting_network_connection_check_entry_empty(SettingNetworkUG *ad)
1738 {
1739         SETTING_TRACE_BEGIN;
1740         if (!ad->has_form_changed) {
1741                 SETTING_TRACE_DEBUG("ad->has_form_changed == FALSE!");
1742                 return;
1743         }
1744         bool isFoundEmptyEntry = FALSE;
1745
1746         do {
1747                 if (ad->data_profile_name && isEmptyStr(ad->data_profile_name->sub_desc)) {
1748                         /*SETTING_TRACE("entry_str:%s", ad->data_profile_name->sub_desc); */
1749                         isFoundEmptyEntry = TRUE;
1750                         break;
1751                 }
1752                 if (ad->data_acs_name && isEmptyStr(ad->data_acs_name->sub_desc)) {
1753                         /*SETTING_TRACE("entry_str:%s", ad->data_acs_name->sub_desc); */
1754                         isFoundEmptyEntry = TRUE;
1755                         break;
1756                 }
1757                 if (ad->data_user_name && isEmptyStr(ad->data_user_name->sub_desc)) {
1758                         /*SETTING_TRACE("entry_str:%s", ad->data_user_name->sub_desc); */
1759                         isFoundEmptyEntry = TRUE;
1760                         break;
1761                 }
1762                 if (ad->data_pwd && isEmptyStr(ad->data_pwd->sub_desc)) {
1763                         /*SETTING_TRACE("entry_str:%s", ad->data_pwd->sub_desc); */
1764                         isFoundEmptyEntry = TRUE;
1765                         break;
1766                 }
1767                 if (ad->data_hm_url && isEmptyStr(ad->data_hm_url->sub_desc)) {
1768                         /*SETTING_TRACE("entry_str:%s", ad->data_hm_url->sub_desc); */
1769                         isFoundEmptyEntry = TRUE;
1770                         break;
1771                 }
1772         } while (0);
1773         Evas_Object *done_btn = elm_object_item_part_content_get(ad->navi_it, NAVI_BTN_STYLE_LEFT);
1774         if (isFoundEmptyEntry) {
1775                 if (!evas_object_pass_events_get(done_btn)) {/*it had not yet been disabled */
1776                         setting_disable_evas_object(done_btn);
1777                         setting_dim_evas_object(done_btn, TRUE);
1778                 } else {
1779                         /*do nothing..if invoke setting_dim_evas_object many times, the done button will be dimer until it cannot be see. */
1780                         /*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. */
1781                 }
1782         } else {
1783                 setting_enable_evas_object(done_btn);
1784                 setting_undo_dim_evas_object(done_btn, TRUE);
1785         }
1786 }
1787
1788 static void
1789 setting_network_connection_display_auth_type(SettingNetworkUG *ad,
1790                                              int auth_type)
1791 {
1792         SETTING_TRACE_BEGIN;
1793         retm_if(ad == NULL, "Data parameter is NULL");
1794         if (ad->chkType == auth_type) return;
1795
1796         ad->chkType = auth_type;        /* for update genlist */
1797         if (CONNECTION_CELLULAR_AUTH_TYPE_NONE != auth_type) {  /* to show */
1798                 SETTING_TRACE("ad->is_show_user:%d", ad->is_show_user);
1799                 if (ad->is_show_user == 0) {    /* do only when hiden */
1800                         SETTING_TRACE("to create");
1801
1802                         ad->data_user_name =
1803                             (Setting_GenGroupItem_Data *) calloc(1,
1804                                                                  sizeof
1805                                                                  (Setting_GenGroupItem_Data));
1806                         setting_retm_if(ad->data_user_name == NULL, "calloc failed");
1807                         ad->data_user_name->keyStr =
1808                             (char *)g_strdup(KeyStr_UserID);
1809                         ad->data_user_name->sub_desc =
1810                             (char *)g_strdup(ad->ed_user_name_desc);
1811                         ad->data_user_name->swallow_type =
1812                             SWALLOW_Type_LAYOUT_EDITFIELD;
1813                         ad->data_user_name->isSinglelineFlag = TRUE;
1814                         ad->data_user_name->userdata = ad;
1815
1816                         ad->data_user_name->return_key_type = ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
1817                         ad->data_user_name->activated_cb = setting_network_connection_entry_next_activated_cb;
1818
1819                         ad->data_user_name->maxlength_reached_cb = __network_max_len_reached;
1820                         ad->data_user_name->disable_auto_cap = EINA_TRUE;
1821
1822                         __BACK_POINTER_SET(ad->data_user_name);
1823
1824                         ad->data_user_name->chk_change_cb =
1825                             setting_network_connection_entry_changed_cb;
1826                         ad->data_user_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
1827                         if (ad->data_user_name->limit_filter_data) {
1828                                 ad->data_user_name->limit_filter_data->max_byte_count = MAX_PDP_AUTH_USERNAME_LEN_MAX;
1829                                 ad->data_user_name->win_main = ad->win_get;
1830                         }
1831                         ad->data_user_name->item =
1832                             elm_genlist_item_insert_after(ad->scl_edit,
1833                                                           &itc_editfield,
1834                                                           ad->data_user_name,
1835                                                           NULL,
1836                                                           ad->item_above_user_name,
1837                                                           ELM_GENLIST_ITEM_NONE,
1838                                                           NULL, ad);
1839
1840                         ad->data_pwd =
1841                             (Setting_GenGroupItem_Data *) calloc(1,
1842                                                                  sizeof
1843                                                                  (Setting_GenGroupItem_Data));
1844
1845                         setting_retm_if(ad->data_pwd == NULL, "calloc failed");
1846                         ad->data_pwd->keyStr =
1847                             (char *)g_strdup("IDS_ST_BODY_PASSWORD");
1848                         ad->data_pwd->sub_desc =
1849                             (char *)g_strdup(ad->ed_pwd_desc);
1850                         ad->data_pwd->swallow_type = SWALLOW_Type_LAYOUT_EDITFIELD;
1851                         ad->data_pwd->userdata = ad;
1852                         ad->data_pwd->chk_change_cb =
1853                             setting_network_connection_entry_changed_cb;
1854                         ad->data_pwd->isPasswordFlag = TRUE;
1855                         ad->data_pwd->isSinglelineFlag = TRUE;
1856
1857                         ad->data_pwd->return_key_type = ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
1858                         ad->data_pwd->activated_cb = setting_network_connection_entry_next_activated_cb;
1859
1860                         ad->data_pwd->maxlength_reached_cb = __network_max_len_reached;
1861                         ad->data_pwd->disable_auto_cap = EINA_TRUE;
1862
1863                         __BACK_POINTER_SET(ad->data_pwd);
1864
1865                         /* ad->data_pwd->chk_change_cb = chk_change_cb; */
1866                         ad->data_pwd->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
1867                         if (ad->data_pwd->limit_filter_data) {
1868                                 ad->data_pwd->limit_filter_data->max_byte_count = MAX_PDP_AUTH_PASSWORD_LEN_MAX;
1869                                 ad->data_pwd->win_main = ad->win_get;
1870                         }
1871                         ad->data_pwd->item =
1872                             elm_genlist_item_insert_after(ad->scl_edit,
1873                                                           &itc_editfield,
1874                                                           ad->data_pwd, NULL,
1875                                                           ad->data_user_name->item,
1876                                                           ELM_GENLIST_ITEM_NONE,
1877                                                           NULL, ad);
1878
1879                         ad->item_above_proxy_add =
1880                             elm_genlist_item_insert_after(ad->scl_edit,
1881                                                           &itc_seperator,
1882                                                           NULL, NULL,
1883                                                           ad->data_pwd->item,
1884                                                           ELM_GENLIST_ITEM_NONE,
1885                                                           NULL, NULL);
1886                         elm_genlist_item_select_mode_set
1887                         (ad->item_above_proxy_add, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1888
1889                         ad->has_form_changed  = TRUE;
1890                         setting_network_connection_check_entry_empty(ad);
1891                         elm_genlist_item_select_mode_set(ad->data_user_name->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1892                         elm_genlist_item_select_mode_set(ad->data_pwd->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1893                         /* ad->is_show_user = 1; */
1894                 }
1895                 ad->is_show_user = 1;
1896         } else {                /* to hide */
1897
1898                 SETTING_TRACE("ad->is_show_user:%d", ad->is_show_user);
1899                 if (ad->is_show_user == 1) {    /* do only when shown */
1900                         SETTING_TRACE("to destroy");
1901                         if (ad->data_user_name) {
1902                                 elm_object_item_del(ad->data_user_name->item);
1903                                 ad->data_user_name = NULL;
1904                         }
1905                         if (ad->data_pwd) {
1906                                 elm_object_item_del(ad->data_pwd->item);
1907                                 ad->data_pwd = NULL;
1908                         }
1909                         if (ad->item_above_proxy_add) {
1910                                 elm_object_item_del(ad->item_above_proxy_add);
1911                                 ad->item_above_proxy_add = NULL;
1912                         }
1913
1914                 }
1915                 ad->has_form_changed  = TRUE;
1916                 setting_network_connection_check_entry_empty(ad);
1917                 ad->is_show_user = 0;
1918
1919         }
1920 }
1921
1922 static void
1923 setting_network_connection_entry_changed_cb(void *data, Evas_Object *obj,
1924                                             void *event_info)
1925 {
1926         SETTING_TRACE_BEGIN;
1927         retm_if(data == NULL, "Data parameter is NULL");
1928         Setting_GenGroupItem_Data *list_item =
1929             (Setting_GenGroupItem_Data *) data;
1930         SettingNetworkUG *ad = list_item->userdata;
1931         const char *entry_str = elm_entry_entry_get(obj);
1932
1933         if (list_item->maxLengthReachFlag && list_item->enterKeyPressFlag == false) {
1934                 #if 0
1935                 int ret = notification_status_message_post(_("IDS_ST_TPOP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED"));
1936                 if (ret != NOTIFICATION_ERROR_NONE)
1937                         SETTING_TRACE_ERROR("notification_status_message_post() failed(%d)", ret);
1938                 ad->popup = setting_create_popup(ad, ad->win_get, NULL,
1939                                          "IDS_ST_TPOP_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED",
1940                                          NULL, 2, TRUE, FALSE, 0);
1941                 elm_object_focus_set(list_item->eo_check, EINA_FALSE);
1942                 #endif
1943         }
1944         list_item->maxLengthReachFlag = FALSE;
1945         list_item->enterKeyPressFlag = FALSE;
1946         /*G_FREE(list_item->sub_desc);//release first */
1947         list_item->sub_desc = (char *)g_strdup(entry_str);
1948         ad->has_form_changed  = TRUE;
1949         setting_network_connection_check_entry_empty(ad);
1950 }
1951 static void
1952 setting_network_connection_hide_input_pannel(void *data)
1953 {
1954         SETTING_TRACE_BEGIN;
1955         retm_if(data == NULL, "Data parameter is NULL");
1956         SettingNetworkUG *ad = data;
1957         if (ad->data_profile_name && ad->data_profile_name->eo_check) {
1958                 setting_hide_input_pannel_cb(ad->data_profile_name->eo_check);
1959         }
1960         if (ad->data_acs_name && ad->data_acs_name->eo_check) {
1961                 setting_hide_input_pannel_cb(ad->data_acs_name->eo_check);
1962         }
1963         if (ad->data_user_name && ad->data_user_name->eo_check) {
1964                 setting_hide_input_pannel_cb(ad->data_user_name->eo_check);
1965         }
1966         if (ad->data_pwd && ad->data_pwd->eo_check) {
1967                 setting_hide_input_pannel_cb(ad->data_pwd->eo_check);
1968         }
1969         if (ad->data_pxy_addr && ad->data_pxy_addr->eo_check) {
1970                 setting_hide_input_pannel_cb(ad->data_pxy_addr->eo_check);
1971         }
1972         if (ad->data_pxy_port && ad->data_pxy_port->eo_check) {
1973                 setting_hide_input_pannel_cb(ad->data_pxy_port->eo_check);
1974         }
1975         if (ad->data_hm_url && ad->data_hm_url->eo_check) {
1976                 setting_hide_input_pannel_cb(ad->data_hm_url->eo_check);
1977         }
1978 }
1979