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.
23 *@defgroup setting-about
24 *UG creation code for setting-about
35 * - Diagnostics and Usage
39 #include <setting-about.h>
40 #include <setting-about-main.h>
43 #define UG_MODULE_API __attribute__ ((visibility("default")))
47 * Event process when the sizeof UG view changes
54 static void setting_about_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
57 SettingAboutUG *ad = (SettingAboutUG *) data;
58 setting_view_update(&setting_view_about_main, ad);
62 * on_create function of the UG
71 static void *setting_about_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
72 service_h service, void *priv)
75 setting_retvm_if((NULL == priv), NULL, "NULL == priv");
76 SettingAboutUG *aboutUG = priv;
79 aboutUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
80 aboutUG->win_get = (Evas_Object *) ug_get_window();
81 evas_object_show(aboutUG->win_main_layout);
82 aboutUG->evas = evas_object_evas_get(aboutUG->win_main_layout);
84 setting_retvm_if(aboutUG->win_main_layout == NULL, NULL,
85 "cannot get main window ");
87 /* register view node table */
88 setting_view_node_table_intialize();
89 setting_view_node_table_register(&setting_view_about_main, NULL);
91 /* setting_view_node_table_register(&setting_view_about_about_view, &setting_view_about_main); */
93 /* creating a view. */
94 setting_create_Gendial_itc("dialogue/1text", &(aboutUG->itc_1text));
95 setting_create_Gendial_itc("dialogue/2text.3", &(aboutUG->itc_2text_2));
96 setting_create_Gendial_itc("dialogue/title",
97 &(aboutUG->itc_group_item));
98 setting_create_Gendial_itc("dialogue/1icon", &(aboutUG->itc_1icon));
99 setting_create_Gendial_itc("dialogue/2text.3/expandable",
100 &(aboutUG->itc_2text_3_parent));
101 setting_create_Gendial_itc("dialogue/1text.1icon/expandable2",
102 &(aboutUG->itc_1icon_1text_sub));
103 setting_create_Gendial_itc("multiline/1text",
104 &(aboutUG->itc_help_style));
106 aboutUG->itc_seperator.item_style = "dialogue/separator/21/with_line";
107 aboutUG->itc_seperator.func.text_get = NULL;
108 aboutUG->itc_seperator.func.content_get = NULL;
109 aboutUG->itc_seperator.func.state_get = NULL;
110 aboutUG->itc_seperator.func.del = NULL;
111 setting_view_node_set_cur_view(&setting_view_about_main);
112 setting_view_create(&setting_view_about_main, (void *)aboutUG);
113 evas_object_event_callback_add(aboutUG->win_main_layout,
114 EVAS_CALLBACK_RESIZE,
115 setting_about_ug_cb_resize, aboutUG);
117 aboutUG->popup_showed_flag = FALSE;
118 return aboutUG->ly_main;
121 static void setting_about_ug_on_start(ui_gadget_h ug, service_h service,
126 static void setting_about_ug_on_pause(ui_gadget_h ug, service_h service,
130 SettingAboutUG *SettingAboutUG = priv;
131 SettingAboutUG->pause_flag = TRUE;
134 static void setting_about_ug_on_resume(ui_gadget_h ug, service_h service,
138 setting_retm_if((!priv), "!priv");
139 SettingAboutUG *aboutUG = priv;
140 aboutUG->pause_flag = FALSE;
142 char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
144 memset(str, 0x00, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
145 if(aboutUG->item_data_wifi)
147 setting_about_main_get_wifi_mac_address_string(str, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
148 aboutUG->item_data_wifi->sub_desc = (char*)g_strdup(str);
149 elm_object_item_data_set(aboutUG->item_data_wifi->item, aboutUG->item_data_wifi);
150 elm_genlist_item_update(aboutUG->item_data_wifi->item);
152 memset(str, 0x00, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
153 if(aboutUG->item_data_bt)
155 setting_about_main_get_bluetooth_address_string(str, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
156 aboutUG->item_data_bt->sub_desc = (char*)g_strdup(str);
157 elm_object_item_data_set(aboutUG->item_data_bt->item, aboutUG->item_data_bt);
158 elm_genlist_item_update(aboutUG->item_data_bt->item);
163 * on_destroy function of the UG
169 static void setting_about_ug_on_destroy(ui_gadget_h ug, service_h service,
173 setting_retm_if((!priv), "!priv");
174 SettingAboutUG *aboutUG = priv;
176 evas_object_event_callback_del(aboutUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_about_ug_cb_resize); /* fix flash issue for gallery */
179 /* delete the allocated objects. */
180 setting_view_destroy(&setting_view_about_main, aboutUG);
181 if (NULL != ug_get_layout(aboutUG->ug)) {
182 evas_object_hide((Evas_Object *) ug_get_layout(aboutUG->ug));
183 evas_object_del((Evas_Object *) ug_get_layout(aboutUG->ug));
189 static void setting_about_ug_on_message(ui_gadget_h ug, service_h msg,
190 service_h service, void *priv)
195 static void setting_about_ug_on_event(ui_gadget_h ug, enum ug_event event,
196 service_h service, void *priv)
200 case UG_EVENT_LOW_MEMORY:
202 case UG_EVENT_LOW_BATTERY:
204 case UG_EVENT_LANG_CHANGE:
206 case UG_EVENT_ROTATE_PORTRAIT:
208 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
210 case UG_EVENT_ROTATE_LANDSCAPE:
212 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
214 case UG_EVENT_REGION_CHANGE:
221 static void setting_about_ug_on_key_event(ui_gadget_h ug,
222 enum ug_key_event event,
223 service_h service, void *priv)
226 SettingAboutUG *ad = (SettingAboutUG *) priv;
231 case UG_KEY_EVENT_END:
233 if (elm_naviframe_top_item_get(ad->navi_bar) ==
234 elm_naviframe_bottom_item_get(ad->navi_bar)) {
237 /* elm_naviframe_item_pop(ad->navi_bar); */
238 setting_view_cb_at_endKey(ad);
247 static void __about_gl_sel_expand(void *data, Evas_Object *obj,
250 /* SETTING_TRACE_BEGIN; */
251 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
252 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
253 elm_genlist_item_selected_set(item, 0);
254 bool status = !elm_genlist_item_expanded_get(item);
255 elm_genlist_item_expanded_set(item, status);
258 Eina_Bool __insert_item_idler(void *data)
261 retv_if(!data, FALSE);
262 SettingAboutUG *ad = data;
263 if (ad->item_dev_name) //the genlist exists already.
265 SETTING_TRACE("Beging to insert items...");
268 char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
269 setting_get_string_slp_key(STR_SLP_SETTING_SELECT_NUM, sel_num, &err);
271 Setting_GenGroupItem_Data *item_data = NULL;
272 if (ad->my_numbers.count == 1) {
273 item_data = calloc(1, sizeof(Setting_GenGroupItem_Data));
274 setting_retvm_if(!item_data, FALSE, "calloc item_data failed");
275 item_data->keyStr = (char *)g_strdup("IDS_ST_BODY_MY_NUMBER");
276 item_data->sub_desc = (char *)g_strdup(sel_num);
277 item_data->swallow_type = SWALLOW_Type_INVALID;
279 item_data->item = elm_genlist_item_insert_after(ad->genlsit, &(ad->itc_2text_2),
281 ad->item_dev_name->item,
282 ELM_GENLIST_ITEM_NONE,
284 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
286 } else if (ad->my_numbers.count > 1) {
287 setting_enable_expandable_genlist(ad->genlsit, ad,
288 setting_about_main_exp_cb, NULL);
289 item_data = calloc(1, sizeof(Setting_GenGroupItem_Data));
290 setting_retvm_if(!item_data, FALSE, "calloc item_data failed");
291 item_data->keyStr = (char *)g_strdup("IDS_ST_BODY_MY_NUMBER");
292 item_data->sub_desc = (char *)g_strdup(sel_num);
293 item_data->swallow_type = SWALLOW_Type_INVALID;
295 item_data->int_slp_setting_binded = STR_SLP_SETTING_SELECT_NUM;
296 item_data->item = elm_genlist_item_insert_after(ad->genlsit, &(ad->itc_2text_3_parent),
298 ad->item_dev_name->item,
299 ELM_GENLIST_ITEM_TREE,
300 __about_gl_sel_expand, NULL);
307 static void __on_sim_get_msisdn(TapiHandle *handle, int result, void *data, void *user_data)
310 ret_if(!user_data || !data);
311 SettingAboutUG *ad = user_data;
312 TelSimAccessResult_t access_rt = result;
313 //TelSimMsisdnList_t *list = data;
316 SETTING_TRACE("access_rt[%d]", access_rt);
320 memcpy(&(ad->my_numbers), data, sizeof(TelSimMsisdnList_t));
322 TelSimMsisdnList_t r_numbers;
323 /////////r_numbers.count = 3;
325 safeCopyStr(r_numbers.list[0].name, "n1", 30);
326 safeCopyStr(r_numbers.list[1].name, "n2", 30);
327 safeCopyStr(r_numbers.list[2].name, "n3", 30);
328 safeCopyStr(r_numbers.list[0].num, "1111111111", 30);
329 safeCopyStr(r_numbers.list[1].num, "2222222222", 30);
330 safeCopyStr(r_numbers.list[2].num, "3333333333", 30);
331 memcpy(&(ad->my_numbers), &r_numbers, sizeof(TelSimMsisdnList_t));
335 char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
336 setting_get_string_slp_key(STR_SLP_SETTING_SELECT_NUM, sel_num, &err);
338 bool isFound = FALSE;
339 //SETTING_TRACE("ad->my_numbers.count[%d]", ad->my_numbers.count);
341 for (i = 0; i < ad->my_numbers.count && i < SETTING_ABOUT_MY_NUMBERS_LEN; i++) {
342 SETTING_TRACE("index[%d] - name[%s], num[%s]", i, ad->my_numbers.list[i].name, ad->my_numbers.list[i].num);
343 if (0 == safeStrCmp(sel_num, ad->my_numbers.list[i].num)) {
347 if (!isFound && ad->my_numbers.count > 0) {//if not found, set as the first num of returned-list
348 SETTING_TRACE("Selected-num hasn't been found, to let the first one as defalut one");
349 setting_set_string_slp_key(STR_SLP_SETTING_SELECT_NUM, ad->my_numbers.list[0].num, &err);
352 ad->tapi_responsed = TRUE;
354 evas_object_del(ad->popup);
357 //setting_about_generate_genlist((void *)ad);
358 ecore_idler_add(__insert_item_idler, ad);
361 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
364 SettingAboutUG *aboutUG = calloc(1, sizeof(SettingAboutUG));
365 setting_retvm_if(!aboutUG, -1, "Create SettingAboutUG obj failed");
367 ops->create = setting_about_ug_on_create;
368 ops->start = setting_about_ug_on_start;
369 ops->pause = setting_about_ug_on_pause;
370 ops->resume = setting_about_ug_on_resume;
371 ops->destroy = setting_about_ug_on_destroy;
372 ops->message = setting_about_ug_on_message;
373 ops->event = setting_about_ug_on_event;
374 ops->key_event = setting_about_ug_on_key_event;
376 ops->opt = UG_OPT_INDICATOR_ENABLE;
380 setting_get_int_slp_key(INT_SLP_SETTING_SIM_SLOT, &value, &err);
381 if (VCONFKEY_TELEPHONY_SIM_INSERTED == value)//There is a sim card, so do display to user
383 aboutUG->handle = tel_init(NULL);
384 SETTING_TRACE("aboutUG->handle:%p", aboutUG->handle);
385 if (aboutUG->handle) {
386 SETTING_TRACE("tel_init sucessed, and there is at least one sim card, now trying to get misidns");
387 if (tel_get_sim_msisdn(aboutUG->handle, __on_sim_get_msisdn, aboutUG) == TAPI_API_SUCCESS) {
388 SETTING_TRACE("tel_get_sim_msisdn sent");
395 SETTING_TRACE_DEBUG("There is no sim card, so skip getting misidns");
400 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
403 SettingAboutUG *aboutUG;
404 setting_retm_if(!ops, "ops == NULL");
409 && tel_deinit(aboutUG->handle) == TAPI_API_SUCCESS) {
410 SETTING_TRACE("tel_deinit sucessed");
416 /* ***************************************************
420 ****************************************************/
421 void setting_about_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
424 SettingAboutUG *ad = (SettingAboutUG *) priv;
431 base = (Evas_Object *) ug_get_layout(ug);
436 case UG_MODE_FULLVIEW:
437 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
439 elm_win_resize_object_add(ad->win_get, base);
440 evas_object_show(base);
449 static void __setting_about_sub_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
453 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
454 Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
455 Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
456 elm_genlist_item_selected_set(subitem, 0);
457 Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subitem);
458 Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */
459 ret_if(NULL == data_subItem || NULL == data_parentItem);
463 setting_set_string_slp_key(data_parentItem->int_slp_setting_binded, data_subItem->keyStr, &err);
464 setting_retm_if(0 != err, "Set vconf error[%d]",data_parentItem->int_slp_setting_binded);
466 data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
467 elm_object_item_data_set(data_parentItem->item, data_parentItem);
468 elm_genlist_item_update(data_parentItem->item);
469 elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
472 static void __setting_about_sub_list_rd_change(void *data, Evas_Object *obj, void *event_info)
476 retm_if(data == NULL, "Data parameter is NULL");
477 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
479 Elm_Object_Item *subItem = list_item->item;
480 Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subItem);
482 Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subItem); /* subItem data */
483 Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */
484 ret_if(NULL == data_subItem || NULL == data_parentItem);
487 setting_set_string_slp_key(data_parentItem->int_slp_setting_binded, data_subItem->keyStr, &err);
490 data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
491 elm_object_item_data_set(data_parentItem->item, data_parentItem);
492 elm_genlist_item_update(data_parentItem->item);
493 elm_radio_value_set(obj, data_subItem->chk_status);
496 void setting_about_main_exp_cb(void *data, Evas_Object *obj, void *event_info)
499 setting_retm_if(data == NULL, "Data parameter is NULL");
500 setting_retm_if(event_info == NULL, "event_info parameter is NULL");
502 SettingAboutUG *ad = (SettingAboutUG *) data;
503 Elm_Object_Item *parentItem = event_info; /* parent item */
504 Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);
505 Evas_Object *scroller = elm_object_item_widget_get(parentItem);
507 Evas_Object *rgd = elm_radio_add(scroller);
508 elm_radio_value_set(rgd, -1);
511 char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
512 setting_get_string_slp_key(data_parentItem->int_slp_setting_binded, sel_num, &err);
513 SETTING_TRACE("binded: %d, checked: %s, err: %d", data_parentItem->int_slp_setting_binded, sel_num, err);
517 Setting_GenGroupItem_Data *item_data = NULL;
518 for(; i < SETTING_ABOUT_MY_NUMBERS_LEN; i++) {
519 if (ad->my_numbers.list[i].num == NULL) {
523 if (sel_idx == -1 && 0 == safeStrCmp(sel_num, ad->my_numbers.list[i].num)) {
526 item_data = setting_create_Gendial_exp_sub_field(scroller,
527 &(ad->itc_1icon_1text_sub),
528 __setting_about_sub_list_sel_cb, ad, parentItem,
529 SWALLOW_Type_1RADIO, rgd,
531 ad->my_numbers.list[i].num, __setting_about_sub_list_rd_change);
533 item_data->userdata = ad;
535 SETTING_TRACE_ERROR("item_data is NULL");
539 elm_radio_value_set(rgd, sel_idx);
544 * Reset function to 'reset' the settings of the UG, it will be invoked by 'Reset' UG
549 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
552 #if SUPPORT_RUN_SYSTEM_COMMAND
553 return excuteCmd(SETTING_POSTINST_FILE, 1, "about");
555 return vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SETTING_ABOUT_DEFAULT_DEVICE_NAME);