4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <setting-network-connection-create.h>
23 static int setting_network_connection_create(void *cb);
24 static int setting_network_connection_destroy(void *cb);
25 static int setting_network_connection_update(void *cb);
26 static int setting_network_connection_cleanup(void *cb);
28 setting_view setting_view_network_connection_create = {
29 .create = setting_network_connection_create,
30 .destroy = setting_network_connection_destroy,
31 .update = setting_network_connection_update,
32 .cleanup = setting_network_connection_cleanup,
35 SettingNetworkUG *g_networkUG = NULL;
36 #define SUPPORT_EXPANDABLE_AUTHTYPE 1
37 #define URL_HEAD "http://"
38 /* ***************************************************
42 ***************************************************/
45 __network_connection_gl_mouse_up(void *data, Evas *e, Evas_Object *obj,
50 SettingNetworkUG *ad = (SettingNetworkUG *) data;
52 if (ad->data_acs_name) {
53 setting_hide_input_pannel_cb(ad->data_acs_name->eo_check);
55 if (ad->data_user_name) {
56 setting_hide_input_pannel_cb(ad->data_user_name->eo_check);
59 setting_hide_input_pannel_cb(ad->data_pwd->eo_check);
61 if (ad->data_pxy_addr) {
62 setting_hide_input_pannel_cb(ad->data_pxy_addr->eo_check);
64 if (ad->data_pxy_port) {
65 setting_hide_input_pannel_cb(ad->data_pxy_port->eo_check);
67 if (ad->data_hm_url) {
68 setting_hide_input_pannel_cb(ad->data_hm_url->eo_check);
73 void __sub_list_rd_change(void *data, Evas_Object *obj, void *event_info)
76 retm_if(data == NULL, "Data parameter is NULL");
77 Setting_GenGroupItem_Data *list_item =
78 (Setting_GenGroupItem_Data *) data;
79 list_item->chk_status = elm_radio_value_get(obj); /* for update */
81 Elm_Object_Item *subItem = list_item->item;
82 Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subItem);
84 Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subItem); /* subItem data */
85 Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */
87 ret_if(NULL == data_subItem || NULL == data_parentItem);
89 data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
90 elm_object_item_data_set(data_parentItem->item, data_parentItem);
91 elm_genlist_item_update(data_parentItem->item);
92 setting_network_edit_connection_display_auth_type
93 (data_parentItem->userdata, list_item->chk_status);
96 void __sub_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
100 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
101 Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
102 Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
103 elm_genlist_item_selected_set(subitem, 0);
104 Setting_GenGroupItem_Data *data_subItem =
105 elm_object_item_data_get(subitem);
106 Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */
107 ret_if(NULL == data_subItem || NULL == data_parentItem);
109 elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
111 data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
112 elm_object_item_data_set(data_parentItem->item, data_parentItem);
113 elm_genlist_item_update(data_parentItem->item);
114 setting_network_edit_connection_display_auth_type(data,
115 data_subItem->chk_status);
118 static void __setting_network_connection_exp_cb(void *data, Evas_Object *obj,
121 ret_if(NULL == data || NULL == event_info);
123 SettingNetworkUG *ad = (SettingNetworkUG *) data;
124 Elm_Object_Item *parentItem = event_info; /* parent item */
125 Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */
126 Evas_Object *scroller = elm_object_item_widget_get(parentItem);
129 if (data_parentItem == ad->data_auth_type) {
130 rgd = elm_radio_add(scroller);
131 elm_radio_value_set(rgd, -1);
133 setting_create_Gendial_exp_sub_field(scroller,
134 &itc_1icon_1text_sub,
135 __sub_list_sel_cb, ad,
137 SWALLOW_Type_1RADIO, rgd,
140 __sub_list_rd_change);
142 setting_create_Gendial_exp_sub_field(scroller,
143 &itc_1icon_1text_sub,
144 __sub_list_sel_cb, ad,
146 SWALLOW_Type_1RADIO, rgd,
149 __sub_list_rd_change);
151 setting_create_Gendial_exp_sub_field(scroller,
152 &itc_1icon_1text_sub,
153 __sub_list_sel_cb, ad,
155 SWALLOW_Type_1RADIO, rgd,
158 __sub_list_rd_change);
160 elm_radio_value_set(rgd, ad->chkType);
164 static void __genlist_disable_set(Evas_Object *genlist, bool disabled)
168 Elm_Object_Item *item = elm_genlist_first_item_get(genlist);
169 for(;item != elm_genlist_last_item_get(genlist);
170 item = elm_genlist_item_next_get(item))
172 elm_object_item_disabled_set(item, disabled);
174 Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *)elm_object_item_data_get(item);
175 if (item_data == NULL) {
176 SETTING_TRACE("item_data is null");
179 if (item_data->swallow_type == SWALLOW_Type_LAYOUT_ENTRY) {
180 elm_entry_context_menu_disabled_set(item_data->eo_check, disabled);
182 //elm_object_item_signal_emit(item, "elm,state,enabled", "elm");
184 elm_object_item_disabled_set(item, disabled);//the last one item
185 Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *)elm_object_item_data_get(item);
186 if (item_data == NULL) {
187 SETTING_TRACE("item_data is null");
190 if (item_data->swallow_type == SWALLOW_Type_LAYOUT_ENTRY) {
191 elm_entry_context_menu_disabled_set(item_data->eo_check, disabled);
194 static Eina_Bool __connection_idler(void *data)
197 retv_if (!data, FALSE);
198 SettingNetworkUG *ad = data;
199 __genlist_disable_set(ad->scl_edit, TRUE);
200 setting_network_connection_hide_input_pannel(ad);
203 void __get_connection_info(void *cb)
207 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
209 ad->ed_acs_name_desc = NULL;
210 ad->ed_user_name_desc = NULL;
211 ad->ed_pwd_desc = NULL;
212 G_FREE(ad->ed_pxy_addr_desc);
213 G_FREE(ad->ed_pxy_port_desc);
214 ad->ed_hm_url_desc = NULL;
215 ad->chkType = NET_PDP_AUTH_NONE;
216 ad->ed_auth_type_desc = NULL;
218 if (NULL == ad->prof_list)
220 int err = net_get_profile_list(NET_DEVICE_CELLULAR, &(ad->prof_list), &(ad->prof_count));
221 if (err != NET_ERR_NONE) {
223 ("%s*** [ERR] Internet net_get_app_profile_id. err=%d ***%s",
224 SETTING_FONT_RED, err, SETTING_FONT_BLACK);
228 //SETTING_TRACE("NET_ERR_UNKNOWN_METHOD:%d", NET_ERR_UNKNOWN_METHOD);
230 ad->prof_sel_idx = SETTING_ADD_PROFILE_INDEX;//need add new configuration
234 for(ci = 0;ci < ad->prof_count;ci++){
235 SETTING_TRACE_DEBUG("profList[%d].ProfileName:%s", ci,ad->prof_list[ci].ProfileName);
236 SETTING_TRACE_DEBUG("profList[%d].profile_type:%d", ci, ad->prof_list[ci].profile_type);
237 if(NET_DEVICE_CELLULAR == ad->prof_list[ci].profile_type) {
238 if (ad->con_type == ad->prof_list[ci].ProfileInfo.Pdp.ServiceType)
240 ad->prof_sel_idx = ci;
246 SETTING_TRACE("ad->prof_sel_idx:%d", ad->prof_sel_idx);
247 char ProxyAddr[NET_PROXY_LEN_MAX+1] = {0,};
248 if (SETTING_ADD_PROFILE_INDEX != ad->prof_sel_idx)//found sucessfully
250 /* load access name */
251 ad->ed_acs_name_desc = ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.Apn;
252 ad->ed_user_name_desc =
253 ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.AuthInfo.UserName;
255 ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.AuthInfo.AuthType;
257 ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.AuthInfo.Password;
259 switch (ad->chkType) {
260 case NET_PDP_AUTH_PAP:
261 ad->ed_auth_type_desc = _("IDS_ST_MBODY_PAP");
263 case NET_PDP_AUTH_CHAP:
264 ad->ed_auth_type_desc = _("IDS_ST_POP_CHAP");
266 case NET_PDP_AUTH_NONE:
267 ad->ed_auth_type_desc = _("IDS_COM_BODY_NONE");
270 ad->chkType = NET_PDP_AUTH_NONE;
271 ad->ed_auth_type_desc = _("IDS_COM_BODY_NONE");
276 char *full_addr = NULL;
279 //Fix the Port 'NULL' issue when enter connection view repeatly..
280 full_addr = safeCopyStr(ProxyAddr, ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.net_info.ProxyAddr, NET_PROXY_LEN_MAX);
281 int url_head_len = strlen(URL_HEAD);
282 if (0 == safeStrNCmp(full_addr, URL_HEAD, url_head_len))
284 full_addr += url_head_len;
286 addr = strsep(&full_addr, ":");
287 if (NULL == full_addr)//format like "http://127.0.0.1/" or "http://127.0.0.1"
289 SETTING_TRACE("NULL == full_addr");
290 addr = strsep(&addr, "/");
292 if (is_ip_string(addr))
294 port = strsep(&full_addr, "/");
296 else //invalid format,let addr and port to be NULL.
301 ad->ed_pxy_addr_desc = g_strdup(addr);
302 ad->ed_pxy_port_desc = g_strdup(port);
304 if (ad->con_type == NET_SERVICE_MMS) { /* Message Connection */
306 ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.HomeURL;
309 ad->ed_auth_type_desc = _("IDS_COM_BODY_NONE");
310 ad->chkType = NET_PDP_AUTH_NONE;
314 void __update_genlist_info(void *cb)
318 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
319 if (ad->data_acs_name)
321 ad->data_acs_name->sub_desc = g_strdup(ad->ed_acs_name_desc);
324 if (ad->data_auth_type)
326 ad->data_auth_type->sub_desc = g_strdup(ad->ed_auth_type_desc);
328 int authType = ad->prof_list[ad->prof_sel_idx].ProfileInfo.Pdp.AuthInfo.AuthType;
329 ad->chkType = !ad->chkType;
330 setting_network_edit_connection_display_auth_type(ad, authType);
333 if (ad->data_user_name)
335 ad->data_user_name->sub_desc = g_strdup(ad->ed_user_name_desc);
339 ad->data_pwd->sub_desc = g_strdup(ad->ed_pwd_desc);
342 if (ad->data_pxy_addr)
344 ad->data_pxy_addr->sub_desc = g_strdup(ad->ed_pxy_addr_desc);
346 if (ad->data_pxy_port)
348 ad->data_pxy_port->sub_desc = g_strdup(ad->ed_pxy_port_desc);
352 ad->data_hm_url->sub_desc = g_strdup(ad->ed_hm_url_desc);
354 elm_genlist_realized_items_update(ad->scl_edit);
358 static int setting_network_connection_create(void *cb)
361 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
363 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
365 setting_retvm_if(NET_SERVICE_MMS != ad->con_type && NET_SERVICE_INTERNET != ad->con_type,
366 SETTING_GENERAL_ERR_WRONG_PARAMETER,
367 "Invalid connection type[%d]", ad->con_type)
369 const char *title = NULL;
370 if (ad->con_type == NET_SERVICE_INTERNET)
371 { /* Internet Connection & MMS Connection Head Title should be different. */
372 title = _("IDS_ST_BODY_INTERNET_CONNECTION");
376 title = _(STR_SETTING_MMS_CONNECTIONS);
379 Evas_Object *scroller = elm_genlist_add(ad->win_main_layout);
380 elm_object_style_set(scroller, "dialogue");
381 retvm_if(scroller == NULL, SETTING_DRAW_ERR_FAIL_SCROLLER,
382 "Cannot set scroller object as contento of layout");
383 elm_genlist_clear(scroller); /* first to clear list */
385 /* Enabling illume notification property for window */
386 elm_win_conformant_set(ad->win_main_layout, 1);
387 Evas_Object *conformant = elm_conformant_add(ad->win_main_layout);
388 elm_object_style_set(conformant, "internal_layout"); /* By Kollus. 2011-01-04 */
389 evas_object_show(conformant);
390 elm_object_content_set(conformant, scroller);
391 ad->conformant = conformant;
392 /* connection intializes */
393 ad->data_hm_url = NULL;
395 ad->data_user_name = NULL;
396 ad->data_pxy_addr = NULL;
397 ad->data_acs_name = NULL;
398 ad->data_auth_type = NULL;
400 ad->navi_it = setting_push_layout_navi_bar((char *)title,
401 _("IDS_COM_BODY_BACK"),
403 NULL,//_(KeyStr_Reset_Def),
404 setting_network_edit_connection_click_softkey_back_cb,
405 setting_network_edit_connection_click_softkey_eidt_cb,
406 setting_network_edit_connection_click_softkey_reset_cb,
407 ad, conformant, ad->navi_bar, &ad->controlbar);
409 retv_if(!ad->navi_it, SETTING_RETURN_FAIL);
410 ad->has_form_changed = FALSE;
412 setting_enable_expandable_genlist(scroller, ad,
413 __setting_network_connection_exp_cb,
415 evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_UP,
416 __network_connection_gl_mouse_up, ad);
417 __get_connection_info(ad);
418 Elm_Object_Item *item;
420 /* item = elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); */
422 elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
423 ELM_GENLIST_ITEM_NONE, NULL, NULL);
424 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
426 setting_create_Gendial_field_def(scroller,
428 NULL, SWALLOW_Type_LAYOUT_ENTRY,
430 "IDS_ST_BODY_ACCESS_NAME",
431 (char *)ad->ed_acs_name_desc,
432 setting_network_connection_entry_changed_cb);
433 if (ad->data_acs_name) {
434 ad->data_acs_name->userdata = ad;
435 ad->data_acs_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
436 if (ad->data_acs_name->limit_filter_data) {
437 ad->data_acs_name->limit_filter_data->max_byte_count = NET_PDP_APN_LEN_MAX - 1;
438 ad->data_acs_name->win_main = ad->win_get;
442 SETTING_TRACE_ERROR("ad->data_acs_name is NULL");
446 elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
447 ELM_GENLIST_ITEM_GROUP, NULL, NULL);
448 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
451 setting_create_Gendial_exp_parent_field(scroller,
454 SWALLOW_Type_INVALID,
455 "IDS_ST_BODY_AUTH_TYPE",
456 (char *)ad->ed_auth_type_desc);
457 /* ad->data_auth_type->int_slp_setting_binded = INT_SLP_SETTING_INVALID; */
458 if (ad->data_auth_type) {
459 ad->data_auth_type->userdata = ad;
461 SETTING_TRACE_ERROR("ad->data_auth_type is NULL");
464 ad->item_above_user_name = item =
465 elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
466 ELM_GENLIST_ITEM_NONE, NULL, NULL);
467 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
469 ad->is_show_user = 0;
470 if (NET_PDP_AUTH_NONE != ad->chkType) {
472 setting_create_Gendial_field_def(scroller,
475 SWALLOW_Type_LAYOUT_ENTRY,
477 "IDS_COM_BODY_USER_NAME",
479 ad->ed_user_name_desc,
480 setting_network_connection_entry_changed_cb);
481 if (ad->data_user_name) {
482 ad->data_user_name->userdata = ad;
483 ad->data_user_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
484 if (ad->data_user_name->limit_filter_data) {
485 ad->data_user_name->limit_filter_data->max_byte_count = NET_PDP_AUTH_USERNAME_LEN_MAX - 1;
486 ad->data_user_name->win_main = ad->win_get;
489 SETTING_TRACE_ERROR("ad->data_user_name is NULL");
493 setting_create_Gendial_field_def(scroller,
496 SWALLOW_Type_LAYOUT_ENTRY,
498 "IDS_COM_BODY_PASSWORD",
499 (char *)ad->ed_pwd_desc,
500 setting_network_connection_entry_changed_cb);
502 ad->data_pwd->userdata = ad;
503 ad->is_show_user = 1;
504 ad->data_pwd->isPasswordFlag = TRUE;
505 ad->data_pwd->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
506 if (ad->data_pwd->limit_filter_data) {
507 ad->data_pwd->limit_filter_data->max_byte_count = NET_PDP_AUTH_PASSWORD_LEN_MAX - 1;
508 ad->data_pwd->win_main = ad->win_get;
511 SETTING_TRACE_ERROR("ad->data_pwd is NULL");
514 ad->item_above_proxy_add = item =
515 elm_genlist_item_append(scroller, &itc_seperator,
516 NULL, NULL, ELM_GENLIST_ITEM_NONE,
518 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
522 setting_create_Gendial_field_def(scroller,
524 NULL, SWALLOW_Type_LAYOUT_ENTRY,
526 "IDS_ST_BODY_CONNECTIONSETTINGS_PROXY_ADDRESS",
527 (char *)ad->ed_pxy_addr_desc,
528 setting_network_connection_entry_changed_cb);
529 if (ad->data_pxy_addr) {
530 ad->data_pxy_addr->userdata = ad;
531 ad->data_pxy_addr->input_type = ELM_INPUT_PANEL_LAYOUT_IP;
533 SETTING_TRACE_ERROR("ad->data_pxy_addr is NULL");
537 setting_create_Gendial_field_def(scroller,
539 NULL, SWALLOW_Type_LAYOUT_ENTRY,
541 "IDS_ST_BODY_PROXY_PORT",
542 (char *)ad->ed_pxy_port_desc,
543 setting_network_connection_entry_changed_cb);
544 if (ad->data_pxy_port) {
545 ad->data_pxy_port->userdata = ad;
546 ad->data_pxy_port->input_type = ELM_INPUT_PANEL_LAYOUT_NUMBERONLY;
548 SETTING_TRACE_ERROR("ad->data_pxy_port is NULL");
551 if (ad->con_type == NET_SERVICE_MMS) { /* mms Connection */
553 setting_create_Gendial_field_def(scroller,
556 SWALLOW_Type_LAYOUT_ENTRY,
558 "IDS_ST_BODY_HOME_URL",
559 (char *)ad->ed_hm_url_desc,
560 setting_network_connection_entry_changed_cb);
561 if (ad->data_hm_url) {
562 ad->data_hm_url->userdata = ad;
563 ad->data_hm_url->input_type = ELM_INPUT_PANEL_LAYOUT_URL;
564 ad->data_hm_url->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
565 if (ad->data_hm_url->limit_filter_data) {
566 ad->data_hm_url->limit_filter_data->max_byte_count = NET_HOME_URL_LEN_MAX - 1;
567 ad->data_hm_url->win_main = ad->win_get;
570 SETTING_TRACE_ERROR("ad->data_hm_url is NULL");
572 /* ad->is_show_url = 1; */
575 item = elm_genlist_item_append(scroller, &itc_bottom_seperator, NULL, NULL,
576 ELM_GENLIST_ITEM_NONE, NULL, NULL);
577 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
579 setting_view_network_connection_create.is_create = 1;
580 ad->scl_edit = scroller;
581 __genlist_disable_set(ad->scl_edit, TRUE);
582 ecore_idler_add(__connection_idler, ad);
583 return SETTING_RETURN_SUCCESS;
586 static int setting_network_connection_destroy(void *cb)
590 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
592 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
594 ad->controlbar = NULL;
599 evas_object_del(ad->l_button);
604 evas_object_del(ad->m_button);
609 evas_object_del(ad->r_button);
613 elm_naviframe_item_pop(ad->navi_bar);
614 setting_view_network_connection_create.is_create = 0;
615 return SETTING_RETURN_SUCCESS;
618 static int setting_network_connection_update(void *cb)
621 return SETTING_RETURN_SUCCESS;
624 static int setting_network_connection_cleanup(void *cb)
626 return setting_network_connection_destroy(cb);
629 /* ***************************************************
633 ***************************************************/
635 static int setting_network_edit_connection_save_connection(void *data)
639 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
641 SettingNetworkUG *ad = (SettingNetworkUG *) data;
642 const char *acs_name = NULL;
643 const char *usr_name = NULL;
644 const char *pwd = NULL;
645 const char *addr = NULL;
646 const char *port = NULL;
647 const char *home = NULL;
649 if (ad->data_acs_name)
650 acs_name = elm_entry_markup_to_utf8(ad->data_acs_name->sub_desc);
651 if (ad->data_user_name)
652 usr_name = elm_entry_markup_to_utf8(ad->data_user_name->sub_desc);
654 pwd = elm_entry_markup_to_utf8(ad->data_pwd->sub_desc);
655 if (ad->data_pxy_addr)
656 addr = elm_entry_markup_to_utf8(ad->data_pxy_addr->sub_desc);
657 if (ad->data_pxy_port)
658 port = elm_entry_markup_to_utf8(ad->data_pxy_port->sub_desc);
661 acs_name = strdup("");
663 usr_name = strdup("");
670 SETTING_TRACE("acs_name:%s", acs_name);
671 SETTING_TRACE("usr_name:%s", usr_name);
672 SETTING_TRACE("pwd:%s", pwd);
674 SETTING_TRACE("addr:%s", addr);
675 SETTING_TRACE("port:%s", port);
676 SETTING_TRACE("home:%s", home);
678 char sz_text[NET_PROXY_LEN_MAX + 1] = { 0, };
680 int ret = SETTING_RETURN_SUCCESS;
683 net_profile_info_t *con_info = NULL;
684 if (ad->prof_sel_idx != SETTING_ADD_PROFILE_INDEX) {
685 con_info = &(ad->prof_list[ad->prof_sel_idx]);
687 con_info = (net_profile_info_t *)calloc(1, sizeof(net_profile_info_t));
689 /* save access name */
690 if (!safeStrCmp(acs_name, "")) {
691 setting_create_simple_popup(ad, ad->win_get,
692 NULL, _(Insert_Access_Name_desc));
698 return SETTING_DNET_RETURN_NULL_ACCESS_NAME;
700 safeCopyStr(con_info->ProfileInfo.Pdp.Apn, acs_name,
701 NET_PDP_APN_LEN_MAX);
705 /* type = elm_radio_value_get(ad->chk_type); */
709 case NET_PDP_AUTH_PAP: /* Normal */
711 con_info->ProfileInfo.Pdp.AuthInfo.AuthType =
716 case NET_PDP_AUTH_CHAP: /* Secure */
718 con_info->ProfileInfo.Pdp.AuthInfo.AuthType =
723 case NET_PDP_AUTH_NONE: /* None */
725 con_info->ProfileInfo.Pdp.AuthInfo.AuthType =
734 if (!safeStrCmp(usr_name, "")
735 && NET_PDP_AUTH_NONE != type) {
736 setting_create_simple_popup(ad, ad->win_get,
737 NULL, _(Insert_User_Name_Desc));
743 return SETTING_DNET_RETURN_NULL_USER_NAME;
745 safeCopyStr(con_info->ProfileInfo.Pdp.AuthInfo.UserName,
746 usr_name, NET_PDP_AUTH_USERNAME_LEN_MAX - 1);
749 if (!safeStrCmp(pwd, "")
750 && NET_PDP_AUTH_NONE != type) {
751 setting_create_simple_popup(ad, ad->win_get,
752 NULL, _("IDS_ST_BODY_ENTER_PASSWORD"));
758 return SETTING_DNET_RETURN_NULL_PASSWORD;
760 safeCopyStr(con_info->ProfileInfo.Pdp.AuthInfo.Password, pwd,
761 NET_PDP_AUTH_PASSWORD_LEN_MAX - 1);
764 /* save proxy addr */
765 if (!safeStrCmp(addr, "")) {
766 /* addr = "0.0.0.0"; */
767 ret = SETTING_DNET_RETURN_NULL_PROXY_ADDR;
768 } else if (!is_ip_string(addr)) {
769 setting_create_simple_popup(ad, ad->win_get,
770 NULL, _("IDS_ST_HEADER_INCORRECT_PROXY_ADDRESS"));
776 return SETTING_DNET_RETURN_INVALID_PROXY_ADDR;
778 /* check proxy port */
779 if (!safeStrCmp(port, "")) {
781 ret = SETTING_DNET_RETURN_NULL_PROXY_PORT;
784 ret = snprintf(sz_text, sizeof(sz_text), "%s:%s", addr, port);
785 retv_if(ret < 0, SETTING_DNET_RETURN_ERR);
786 safeCopyStr(con_info->ProfileInfo.Pdp.net_info.ProxyAddr, sz_text,
789 /* save home url(message connection only) */
790 if (ad->con_type == NET_SERVICE_MMS) { /* Message Connection */
791 home = elm_entry_markup_to_utf8(ad->data_hm_url->sub_desc);
792 if (home == (char *)NULL) {
793 safeCopyStr(con_info->ProfileInfo.Pdp.HomeURL,
794 URL_HEAD, NET_HOME_URL_LEN_MAX);
796 if (!safeStrCmp(home, "")) {
797 home = strdup(URL_HEAD);
798 ret = SETTING_DNET_RETURN_NULL_HOMEURL;
801 safeCopyStr(con_info->ProfileInfo.Pdp.HomeURL, home,
802 NET_HOME_URL_LEN_MAX);
811 SETTING_TRACE("ad->con_type:%d", ad->con_type);
812 /* save connection */
813 if (ad->prof_sel_idx == SETTING_ADD_PROFILE_INDEX) {
815 if (ad->con_type == NET_SERVICE_INTERNET) { /* Internet Connection */
816 safeCopyStr(con_info->ProfileName,
817 "IDS_ST_BODY_INTERNET_CONNECTION",
818 strlen("IDS_ST_BODY_INTERNET_CONNECTION"));
819 //con_info->ProfileInfo.Pdp.ServiceCategoryId = 1;
821 safeCopyStr(con_info->ProfileName, STR_SETTING_MMS_CONNECTIONS,
822 strlen(STR_SETTING_MMS_CONNECTIONS));
823 //con_info->ProfileInfo.Pdp.ServiceCategoryId = 2;
825 /** Specifies a protocol type */
827 /** network information */
828 con_info->ProfileInfo.Pdp.ServiceType = ad->con_type;
830 con_info->profile_type = NET_DEVICE_CELLULAR;
831 con_info->ProfileState = NET_STATE_TYPE_UNKNOWN;
832 con_info->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_GPRS;
833 err = net_add_profile(ad->con_type, con_info);
834 if (err != NET_ERR_NONE) {
836 ("%s*** [ERR] net_add_profile. err=%d ***%s",
837 SETTING_FONT_RED, err, SETTING_FONT_BLACK);
838 ret = SETTING_DNET_RETURN_ERR;
839 setting_create_simple_popup(ad, ad->win_get,
840 NULL, _("IDS_COM_POP_FAILED"));
845 err = net_modify_profile(con_info->ProfileName, con_info);
846 if (err != NET_ERR_NONE) {
848 ("%s*** [ERR] net_modify_profile. err=%d ***%s",
849 SETTING_FONT_RED, err, SETTING_FONT_BLACK);
850 ret = SETTING_DNET_RETURN_ERR;
851 setting_create_simple_popup(ad, ad->win_get,
852 NULL, _("IDS_COM_POP_FAILED"));
858 /* ***************************************************
862 ***************************************************/
863 #define BTN_STYLE_DEF "naviframe/title/default"
865 setting_network_edit_connection_click_softkey_eidt_cb(void *data,
871 retm_if(data == NULL, "Data parameter is NULL");
873 SettingNetworkUG *ad = (SettingNetworkUG *) data;
874 //setting_enable_evas_object(ad->scl_edit);
875 __genlist_disable_set(ad->scl_edit, FALSE);
877 if (!ad->l_button) //go into first time
879 ad->l_button = setting_create_button(ad->navi_bar, _("IDS_COM_SK_DONE"),
881 setting_network_edit_connection_click_softkey_save_cb,
885 if (!ad->r_button) //go into first time
887 ad->r_button = setting_create_button(ad->navi_bar, _("IDS_COM_SK_CANCEL"),
889 setting_network_edit_connection_click_softkey_cancel_cb,
892 if (!ad->m_button) //go into first time
894 ad->m_button = setting_create_button(ad->navi_bar, NULL,
899 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_LEFT, ad->l_button);
900 evas_object_show(ad->l_button);
903 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_RIGHT, ad->r_button);
904 ad->has_form_changed = TRUE;//intialize
905 setting_network_connection_check_entry_empty(ad);
906 ad->has_form_changed = FALSE;//restore
909 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_MORE, ad->m_button);
910 evas_object_show(ad->r_button);
914 ad->back_btn = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_PREV);
915 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_PREV, NULL);
916 evas_object_hide(ad->back_btn);
918 //remove other buttons on controlbar
919 ad->controlbar = elm_object_item_part_content_unset(ad->navi_it, NAVI_CONTROLBAR_PART);
920 elm_object_item_part_content_set(ad->navi_it, NAVI_CONTROLBAR_PART, NULL);
921 evas_object_hide(ad->controlbar);
924 setting_network_edit_connection_click_softkey_reset_cb(void *data,
930 retm_if(data == NULL, "Data parameter is NULL");
932 SettingNetworkUG *ad = (SettingNetworkUG *) data;
933 net_profile_info_t *con_info = NULL;
935 if (ad->prof_sel_idx != SETTING_ADD_PROFILE_INDEX) {
936 con_info = &(ad->prof_list[ad->prof_sel_idx]);
938 con_info = (net_profile_info_t *)calloc(1, sizeof(net_profile_info_t));
939 setting_retm_if(!con_info, "Failed to alloc for net_profile_info_t");
942 const char *access_name = _("Connection");
943 int auth_type = NET_PDP_AUTH_NONE;
944 safeCopyStr(con_info->ProfileInfo.Pdp.Apn, access_name, NET_PDP_APN_LEN_MAX);
945 con_info->ProfileInfo.Pdp.AuthInfo.AuthType = auth_type;
947 safeCopyStr(con_info->ProfileInfo.Pdp.net_info.ProxyAddr, "0.0.0.0:80",
949 safeCopyStr(con_info->ProfileInfo.Pdp.HomeURL,
950 URL_HEAD, NET_HOME_URL_LEN_MAX);
952 SETTING_TRACE("ad->con_type:%d", ad->con_type);
953 /* save connection */
954 if (ad->prof_sel_idx == SETTING_ADD_PROFILE_INDEX)
957 if (ad->con_type == NET_SERVICE_INTERNET)
958 { /* Internet Connection */
959 safeCopyStr(con_info->ProfileName,
960 "IDS_ST_BODY_INTERNET_CONNECTION",
961 strlen("IDS_ST_BODY_INTERNET_CONNECTION"));
962 //con_info->ProfileInfo.Pdp.ServiceCategoryId = 1;
966 safeCopyStr(con_info->ProfileName, STR_SETTING_MMS_CONNECTIONS,
967 strlen(STR_SETTING_MMS_CONNECTIONS));
968 //con_info->ProfileInfo.Pdp.ServiceCategoryId = 2;
970 /** Specifies a protocol type */
972 /** network information */
973 con_info->ProfileInfo.Pdp.ServiceType = ad->con_type;
975 con_info->profile_type = NET_DEVICE_CELLULAR;
976 con_info->ProfileState = NET_STATE_TYPE_UNKNOWN;
977 con_info->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_GPRS;
979 err = net_add_profile(ad->con_type, con_info);
980 if (err != NET_ERR_NONE)
983 ("%s*** [ERR] net_add_profile. err=%d ***%s",
984 SETTING_FONT_RED, err, SETTING_FONT_BLACK);
985 setting_create_simple_popup(ad, ad->win_get,
986 NULL, _(Invok_API_Failed_Desc));
992 err = net_modify_profile(con_info->ProfileName, con_info);
993 if (err != NET_ERR_NONE)
996 ("%s*** [ERR] net_modify_profile. err=%d ***%s",
997 SETTING_FONT_RED, err, SETTING_FONT_BLACK);
1001 if (err == NET_ERR_NONE) //update genlist when it operaters sucessfully
1003 if (!ad->prof_list) __get_connection_info(ad);//maybe new added
1004 ad->ed_acs_name_desc = access_name;
1005 ad->ed_user_name_desc = NULL;
1006 ad->ed_pwd_desc = NULL;
1007 ad->ed_pxy_addr_desc = g_strdup("0.0.0.0");
1008 ad->ed_pxy_port_desc = g_strdup("80");
1009 ad->ed_hm_url_desc = URL_HEAD;
1010 ad->chkType = NET_PDP_AUTH_NONE;
1011 ad->ed_auth_type_desc = _("IDS_COM_BODY_NONE");
1012 __update_genlist_info(ad);
1016 elm_genlist_realized_items_update(ad->scl_edit);//refresh genlist
1018 ecore_idler_add(__connection_idler, ad);
1022 setting_network_edit_connection_click_softkey_save_cb(void *data,
1026 SETTING_TRACE_BEGIN;
1028 retm_if(data == NULL, "Data parameter is NULL");
1030 SettingNetworkUG *ad = (SettingNetworkUG *) data;
1031 /* elm_box_unpack_all(ad->bx_blk); */
1032 /* elm_dialoguegroup_remove_all(ad->dg_blk); */
1034 int ret = setting_network_edit_connection_save_connection(ad);
1035 /* need special handle */
1036 if (SETTING_DNET_RETURN_NULL_ACCESS_NAME == ret
1037 || SETTING_DNET_RETURN_NULL_USER_NAME == ret
1038 || SETTING_DNET_RETURN_NULL_PASSWORD == ret
1039 || SETTING_DNET_RETURN_INVALID_PROXY_ADDR == ret
1040 || SETTING_DNET_RETURN_ERR == ret) {
1043 if (ret != SETTING_RETURN_SUCCESS) {
1045 ("%s*** [ERR] setting_network_edit_connection_save_connection ***%s",
1046 SETTING_FONT_RED, SETTING_FONT_BLACK);
1049 setting_create_popup_without_btn(ad, ad->win_get, NULL, _(KeyStr_Saved), NULL, POPUP_INTERVAL, FALSE, FALSE);
1050 //re-fetch connection info..
1051 FREE(ad->prof_list);
1052 __get_connection_info(ad);
1054 setting_network_edit_connection_click_softkey_cancel_cb(ad, ad->r_button, NULL);
1058 setting_network_edit_connection_click_softkey_back_cb(void *data,
1062 SETTING_TRACE_BEGIN;
1064 retm_if(data == NULL, "Data parameter is NULL");
1066 SettingNetworkUG *ad = (SettingNetworkUG *) data;
1067 /* elm_box_unpack_all(ad->bx_blk); */
1068 /* elm_dialoguegroup_remove_all(ad->dg_blk); */
1069 setting_view_change(&setting_view_network_connection_create,
1070 &setting_view_network_main, ad);
1073 setting_network_edit_connection_click_softkey_cancel_cb(void *data,
1077 SETTING_TRACE_BEGIN;
1079 retm_if(data == NULL, "Data parameter is NULL");
1081 SettingNetworkUG *ad = (SettingNetworkUG *) data;
1082 ad->l_button = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_LEFT);
1083 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_LEFT, NULL);
1084 evas_object_hide(ad->l_button);
1086 ad->m_button = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_MORE);
1087 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_MORE, NULL);
1088 evas_object_hide(ad->m_button);
1090 ad->r_button = elm_object_item_part_content_unset(ad->navi_it, NAVI_BTN_STYLE_RIGHT);
1091 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_RIGHT, NULL);
1092 evas_object_hide(ad->r_button);
1093 //setting_disable_evas_object(ad->r_button);
1094 setting_undo_dim_evas_object(ad->r_button, TRUE);
1096 elm_object_item_part_content_set(ad->navi_it, NAVI_BTN_STYLE_PREV, ad->back_btn);
1097 elm_object_item_part_content_set(ad->navi_it, NAVI_CONTROLBAR_PART, ad->controlbar);
1098 evas_object_show(ad->back_btn);
1099 evas_object_show(ad->controlbar);
1101 __get_connection_info(ad);
1102 __update_genlist_info(ad);
1103 if(ad->data_auth_type) elm_genlist_item_expanded_set(ad->data_auth_type->item, FALSE);
1104 ecore_idler_add(__connection_idler, ad);
1106 static void _gl_Gendial_sel(void *data, Evas_Object *obj, void *event_info)
1108 /* SETTING_TRACE_BEGIN; */
1109 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1110 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1111 elm_genlist_item_selected_set(item, 0);
1115 static void setting_network_connection_check_entry_empty(SettingNetworkUG *ad)
1117 SETTING_TRACE_BEGIN;
1118 if (!ad->has_form_changed)
1120 SETTING_TRACE_DEBUG("ad->has_form_changed == FALSE!");
1123 bool isFoundEmptyEntry = FALSE;
1126 if (ad->data_acs_name && isEmptyStr(ad->data_acs_name->sub_desc)) {
1127 SETTING_TRACE("entry_str:%s", ad->data_acs_name->sub_desc);
1128 isFoundEmptyEntry = TRUE;
1131 if (ad->data_user_name && isEmptyStr(ad->data_user_name->sub_desc)) {
1132 SETTING_TRACE("entry_str:%s", ad->data_user_name->sub_desc);
1133 isFoundEmptyEntry = TRUE;
1136 if (ad->data_pwd && isEmptyStr(ad->data_pwd->sub_desc)) {
1137 SETTING_TRACE("entry_str:%s", ad->data_pwd->sub_desc);
1138 isFoundEmptyEntry = TRUE;
1141 if (ad->data_hm_url && isEmptyStr(ad->data_hm_url->sub_desc)) {
1142 SETTING_TRACE("entry_str:%s", ad->data_hm_url->sub_desc);
1143 isFoundEmptyEntry = TRUE;
1147 Evas_Object *done_btn = elm_object_item_part_content_get(ad->navi_it, NAVI_BTN_STYLE_LEFT);
1148 if (isFoundEmptyEntry) {
1149 if (!evas_object_pass_events_get(done_btn)) {//it had not yet been disabled
1150 setting_disable_evas_object(done_btn);
1151 setting_dim_evas_object(done_btn, TRUE);
1155 //do nothing..if invoke setting_dim_evas_object many times, the done button will be dimer until it cannot be see.
1156 //refer to the API of setting_dim_evas_object(). The API is supplied by Setting itself, winset doesn't support until now as I now.
1159 setting_enable_evas_object(done_btn);
1160 setting_undo_dim_evas_object(done_btn, TRUE);
1165 setting_network_edit_connection_display_auth_type(SettingNetworkUG *ad,
1168 SETTING_TRACE_BEGIN;
1169 retm_if(ad == NULL, "Data parameter is NULL");
1170 if (ad->chkType == auth_type) return;
1172 ad->chkType = auth_type; /* for update genlist */
1173 if (NET_PDP_AUTH_NONE != auth_type) { /* to show */
1174 SETTING_TRACE("ad->is_show_user:%d", ad->is_show_user);
1175 if (ad->is_show_user == 0) { /* do only when hiden */
1176 SETTING_TRACE("to create");
1178 ad->data_user_name =
1179 (Setting_GenGroupItem_Data *) calloc(1,
1181 (Setting_GenGroupItem_Data));
1182 setting_retm_if(ad->data_user_name == NULL, "calloc failed");
1183 ad->data_user_name->keyStr =
1184 (char *)g_strdup("IDS_COM_BODY_USER_NAME");
1185 ad->data_user_name->sub_desc =
1186 (char *)g_strdup(ad->ed_user_name_desc);
1187 ad->data_user_name->swallow_type =
1188 SWALLOW_Type_LAYOUT_ENTRY;
1189 ad->data_user_name->userdata = ad;
1190 ad->data_user_name->chk_change_cb =
1191 setting_network_connection_entry_changed_cb;
1192 ad->data_user_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
1193 if (ad->data_user_name->limit_filter_data) {
1194 ad->data_user_name->limit_filter_data->max_byte_count = NET_PDP_AUTH_USERNAME_LEN_MAX - 1;
1195 ad->data_user_name->win_main = ad->win_get;
1197 ad->data_user_name->item =
1198 elm_genlist_item_insert_after(ad->scl_edit,
1202 ad->item_above_user_name,
1203 ELM_GENLIST_ITEM_NONE,
1204 _gl_Gendial_sel, ad);
1207 (Setting_GenGroupItem_Data *) calloc(1,
1209 (Setting_GenGroupItem_Data));
1211 setting_retm_if(ad->data_pwd == NULL, "calloc failed");
1212 ad->data_pwd->keyStr =
1213 (char *)g_strdup("IDS_COM_BODY_PASSWORD");
1214 ad->data_pwd->sub_desc =
1215 (char *)g_strdup(ad->ed_pwd_desc);
1216 ad->data_pwd->swallow_type = SWALLOW_Type_LAYOUT_ENTRY;
1217 ad->data_pwd->userdata = ad;
1218 ad->data_pwd->chk_change_cb =
1219 setting_network_connection_entry_changed_cb;
1220 ad->data_pwd->isPasswordFlag = TRUE;
1221 /* ad->data_pwd->chk_change_cb = chk_change_cb; */
1222 ad->data_pwd->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
1223 if (ad->data_pwd->limit_filter_data) {
1224 ad->data_pwd->limit_filter_data->max_byte_count = NET_PDP_AUTH_PASSWORD_LEN_MAX - 1;
1225 ad->data_pwd->win_main = ad->win_get;
1227 ad->data_pwd->item =
1228 elm_genlist_item_insert_after(ad->scl_edit,
1232 data_user_name->item,
1233 ELM_GENLIST_ITEM_NONE,
1234 _gl_Gendial_sel, ad);
1236 ad->item_above_proxy_add =
1237 elm_genlist_item_insert_after(ad->scl_edit,
1241 ELM_GENLIST_ITEM_NONE,
1243 elm_genlist_item_select_mode_set
1244 (ad->item_above_proxy_add, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1246 ad->has_form_changed = TRUE;
1247 setting_network_connection_check_entry_empty(ad);
1248 /* ad->is_show_user = 1; */
1250 ad->is_show_user = 1;
1251 } else { /* to hide */
1253 SETTING_TRACE("ad->is_show_user:%d", ad->is_show_user);
1254 if (ad->is_show_user == 1) { /* do only when shown */
1255 SETTING_TRACE("to destroy");
1256 if (ad->data_user_name) {
1257 elm_object_item_del(ad->data_user_name->item);
1258 ad->data_user_name = NULL;
1261 elm_object_item_del(ad->data_pwd->item);
1262 ad->data_pwd = NULL;
1264 if (ad->item_above_proxy_add) {
1265 elm_object_item_del(ad->item_above_proxy_add);
1266 ad->item_above_proxy_add = NULL;
1270 ad->has_form_changed = TRUE;
1271 setting_network_connection_check_entry_empty(ad);
1272 ad->is_show_user = 0;
1278 setting_network_connection_entry_changed_cb(void *data, Evas_Object *obj,
1281 SETTING_TRACE_BEGIN;
1282 retm_if(data == NULL, "Data parameter is NULL");
1283 Setting_GenGroupItem_Data *list_item =
1284 (Setting_GenGroupItem_Data *) data;
1285 SettingNetworkUG *ad = list_item->userdata;
1286 const char *entry_str = elm_entry_entry_get(obj);
1287 list_item->sub_desc = (char *)g_strdup(entry_str);
1288 ad->has_form_changed = TRUE;
1289 setting_network_connection_check_entry_empty(ad);
1292 setting_network_connection_hide_input_pannel(void *data)
1294 SETTING_TRACE_BEGIN;
1295 retm_if(data == NULL, "Data parameter is NULL");
1296 SettingNetworkUG *ad = data;
1297 if (ad->data_acs_name) {
1298 setting_hide_input_pannel_cb(ad->data_acs_name->eo_check);
1300 if (ad->data_user_name) {
1301 setting_hide_input_pannel_cb(ad->data_user_name->eo_check);
1304 setting_hide_input_pannel_cb(ad->data_pwd->eo_check);
1306 if (ad->data_pxy_addr) {
1307 setting_hide_input_pannel_cb(ad->data_pxy_addr->eo_check);
1309 if (ad->data_pxy_port) {
1310 setting_hide_input_pannel_cb(ad->data_pxy_port->eo_check);
1312 if (ad->data_hm_url) {
1313 setting_hide_input_pannel_cb(ad->data_hm_url->eo_check);