/*
- * Copyright 2012 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.tizenopensource.org/license
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+ * setting
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
+ *
+ * Contact: MyoungJune Park <mj2004.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+/**
+ *@defgroup setting-about
+ *UG creation code for setting-about
+ *
+ * - Device Info
+ * - Name
+ * - My number
+ * - Get info from SIM card and display it.
+ * - if there's no phone number, it shows 'unavailable'.
+ * - Model
+ * - Version
+ * - Bluetooth
+ * - Wi-Fi
+ * - Battery
+ * - CPU usage
+ * - Software update
+ * - Certificates
+ */
#include <setting-about.h>
+#include <setting-about-main.h>
+
#ifndef UG_MODULE_API
#define UG_MODULE_API __attribute__ ((visibility("default")))
#endif
/**
- * Event process when the sizeof UG view changes
- */
+* Event process when the sizeof UG view changes
+*
+* @param data
+* @param e
+* @param obj
+* @param event_info
+*/
static void setting_about_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
void *event_info)
{
}
/**
- * on_create function of the UG
- */
-static void *setting_about_ug_on_create(struct ui_gadget *ug, enum ug_mode mode,
- bundle *data, void *priv)
+* on_create function of the UG
+*
+* @param ug
+* @param mode
+* @param data
+* @param priv
+*
+* @return
+*/
+static void *setting_about_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
+ service_h service, void *priv)
{
SETTING_TRACE_BEGIN;
- setting_retvm_if((NULL == ug
- || NULL == priv), NULL, "NULL == ug || NULL == priv");
+ setting_retvm_if((NULL == priv), NULL, "NULL == priv");
SettingAboutUG *aboutUG = priv;
aboutUG->ug = ug;
setting_retvm_if(aboutUG->win_main_layout == NULL, NULL,
"cannot get main window ");
+ setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
+
/* register view node table */
setting_view_node_table_intialize();
setting_view_node_table_register(&setting_view_about_main, NULL);
-
- setting_view_node_table_register(&setting_view_about_licences,
- &setting_view_about_main);
+
/* setting_view_node_table_register(&setting_view_about_about_view, &setting_view_about_main); */
/* creating a view. */
setting_create_Gendial_itc("dialogue/1text", &(aboutUG->itc_1text));
- setting_create_Gendial_itc("dialogue/2text.3", &(aboutUG->itc_2text_2));
- setting_create_Gendial_itc("dialogue/title",
- &(aboutUG->itc_group_item));
- setting_create_Gendial_itc("dialogue/1icon", &(aboutUG->itc_1icon));
- setting_create_Gendial_itc("dialogue/2text.3/expandable",
- &(aboutUG->itc_2text_3_parent));
- setting_create_Gendial_itc("dialogue/1text.1icon/expandable2",
- &(aboutUG->itc_1icon_1text_sub));
- setting_create_Gendial_itc("multiline/1text",
- &(aboutUG->itc_help_style));
-
- aboutUG->itc_seperator.item_style = "dialogue/separator/21/with_line";
+ setting_create_Gendial_itc("dialogue/multiline/2text", &(aboutUG->itc_2text_2));
+ setting_create_Gendial_itc("dialogue/title", &(aboutUG->itc_group_item));
+ setting_create_Gendial_itc("dialogue/2text.3/expandable", &(aboutUG->itc_2text_3_parent));
+ setting_create_Gendial_itc("dialogue/1text.1icon/expandable2", &(aboutUG->itc_1icon_1text_sub));
+ setting_create_Gendial_itc("multiline/1text", &(aboutUG->itc_help_style));
+
+ aboutUG->itc_seperator.item_style = "dialogue/separator";
aboutUG->itc_seperator.func.text_get = NULL;
aboutUG->itc_seperator.func.content_get = NULL;
aboutUG->itc_seperator.func.state_get = NULL;
aboutUG->itc_seperator.func.del = NULL;
+
setting_view_node_set_cur_view(&setting_view_about_main);
setting_view_create(&setting_view_about_main, (void *)aboutUG);
- evas_object_event_callback_add(aboutUG->win_main_layout,
- EVAS_CALLBACK_RESIZE,
- setting_about_ug_cb_resize, aboutUG);
+ evas_object_event_callback_add(aboutUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_about_ug_cb_resize, aboutUG);
aboutUG->popup_showed_flag = FALSE;
return aboutUG->ly_main;
}
-static void setting_about_ug_on_start(struct ui_gadget *ug, bundle *data,
+static void setting_about_ug_on_start(ui_gadget_h ug, service_h service,
void *priv)
{
}
-static void setting_about_ug_on_pause(struct ui_gadget *ug, bundle *data,
+static void setting_about_ug_on_pause(ui_gadget_h ug, service_h service,
void *priv)
{
+ SETTING_TRACE_BEGIN;
+ SettingAboutUG *SettingAboutUG = priv;
+ SettingAboutUG->pause_flag = TRUE;
}
-static void setting_about_ug_on_resume(struct ui_gadget *ug, bundle *data,
+static void setting_about_ug_on_resume(ui_gadget_h ug, service_h service,
void *priv)
{
+ SETTING_TRACE_BEGIN;
+ setting_retm_if((!priv), "!priv");
+ SettingAboutUG *aboutUG = priv;
+ aboutUG->pause_flag = FALSE;
+
+ char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
+
+ memset(str, 0x00, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
+ if(aboutUG->item_data_wifi)
+ {
+ setting_about_main_get_wifi_mac_address_string(str, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
+ aboutUG->item_data_wifi->sub_desc = (char*)g_strdup(str);
+ elm_object_item_data_set(aboutUG->item_data_wifi->item, aboutUG->item_data_wifi);
+ elm_genlist_item_update(aboutUG->item_data_wifi->item);
+ }
+ memset(str, 0x00, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
+ if(aboutUG->item_data_bt)
+ {
+ setting_about_main_get_bluetooth_address_string(str, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
+ aboutUG->item_data_bt->sub_desc = (char*)g_strdup(str);
+ elm_object_item_data_set(aboutUG->item_data_bt->item, aboutUG->item_data_bt);
+ elm_genlist_item_update(aboutUG->item_data_bt->item);
+ }
}
/**
- * on_destroy function of the UG
- */
-static void setting_about_ug_on_destroy(struct ui_gadget *ug, bundle *data,
+* on_destroy function of the UG
+*
+* @param ug
+* @param data
+* @param priv
+*/
+static void setting_about_ug_on_destroy(ui_gadget_h ug, service_h service,
void *priv)
{
SETTING_TRACE_BEGIN;
- setting_retm_if((!ug || !priv), "!ug || !priv");
+ setting_retm_if((!priv), "!priv");
SettingAboutUG *aboutUG = priv;
evas_object_event_callback_del(aboutUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_about_ug_cb_resize); /* fix flash issue for gallery */
aboutUG->ug = ug;
+
/* delete the allocated objects. */
- setting_view_destroy(&setting_view_about_licences,
- aboutUG);
setting_view_destroy(&setting_view_about_main, aboutUG);
if (NULL != ug_get_layout(aboutUG->ug)) {
evas_object_hide((Evas_Object *) ug_get_layout(aboutUG->ug));
SETTING_TRACE_END;
}
-static void setting_about_ug_on_message(struct ui_gadget *ug, bundle *msg,
- bundle *data, void *priv)
+static void setting_about_ug_on_message(ui_gadget_h ug, service_h msg,
+ service_h service, void *priv)
{
SETTING_TRACE_BEGIN;
}
-static void setting_about_ug_on_event(struct ui_gadget *ug, enum ug_event event,
- bundle *data, void *priv)
+static void setting_about_ug_on_event(ui_gadget_h ug, enum ug_event event,
+ service_h service, void *priv)
{
SETTING_TRACE_BEGIN;
switch (event) {
}
}
-static void setting_about_ug_on_key_event(struct ui_gadget *ug,
+static void setting_about_ug_on_key_event(ui_gadget_h ug,
enum ug_key_event event,
- bundle *data, void *priv)
+ service_h service, void *priv)
{
SETTING_TRACE_BEGIN;
SettingAboutUG *ad = (SettingAboutUG *) priv;
}
}
+static void __about_gl_sel_expand(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ /* SETTING_TRACE_BEGIN; */
+ retm_if(event_info == NULL, "Invalid argument: event info is NULL");
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+ elm_genlist_item_selected_set(item, 0);
+ bool status = !elm_genlist_item_expanded_get(item);
+ elm_genlist_item_expanded_set(item, status);
+}
+
+/**
+ * @see __on_sim_get_msisdn (caller)
+ */
+Eina_Bool __insert_item_idler(void *data)
+{
+ SETTING_TRACE_BEGIN;
+ retv_if(!data, FALSE);
+ SettingAboutUG *ad = data;
+ if (ad->item_dev_name) //the genlist exists already.
+ {
+ SETTING_TRACE("Beging to insert items...");
+ // [UI] My number
+ int err;
+ char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
+ setting_get_string_slp_key(STR_SLP_SETTING_SELECT_NUM, sel_num, &err);
+
+ Setting_GenGroupItem_Data *item_data = NULL;
+ if (ad->my_numbers.count == 1) {
+ item_data = calloc(1, sizeof(Setting_GenGroupItem_Data));
+ setting_retvm_if(!item_data, FALSE, "calloc item_data failed");
+ item_data->keyStr = (char *)g_strdup("IDS_ST_BODY_MY_NUMBER");
+ item_data->sub_desc = (char *)g_strdup(sel_num);
+ item_data->swallow_type = SWALLOW_Type_INVALID;
+
+ item_data->item = elm_genlist_item_insert_after(ad->genlsit, &(ad->itc_2text_2),
+ item_data, NULL,
+ ad->item_dev_name->item,
+ ELM_GENLIST_ITEM_NONE,
+ NULL, NULL);
+ elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ } else if (ad->my_numbers.count > 1) {
+ setting_enable_expandable_genlist(ad->genlsit, ad,
+ setting_about_main_exp_cb, NULL);
+ item_data = calloc(1, sizeof(Setting_GenGroupItem_Data));
+ setting_retvm_if(!item_data, FALSE, "calloc item_data failed");
+ item_data->keyStr = (char *)g_strdup("IDS_ST_BODY_MY_NUMBER");
+ item_data->sub_desc = (char *)g_strdup(sel_num);
+ item_data->swallow_type = SWALLOW_Type_INVALID;
+
+ item_data->int_slp_setting_binded = STR_SLP_SETTING_SELECT_NUM;
+ item_data->item = elm_genlist_item_insert_after(ad->genlsit, &(ad->itc_2text_3_parent),
+ item_data, NULL,
+ ad->item_dev_name->item,
+ ELM_GENLIST_ITEM_TREE,
+ __about_gl_sel_expand, NULL);
+ }
+ }
+
+ return FALSE;
+}
+
+/**
+ * called at initialization of About UG
+ * @see tel_get_sim_msisdn
+ */
+static void __on_sim_get_msisdn(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ SETTING_TRACE_BEGIN;
+ ret_if(!user_data || !data);
+ SettingAboutUG *ad = user_data;
+ TelSimAccessResult_t access_rt = result;
+ //TelSimMsisdnList_t *list = data;
+ int i =0;
+
+ SETTING_TRACE("access_rt[%d]", access_rt);
+
+ //#define TEST
+ #ifndef TEST
+ memcpy(&(ad->my_numbers), data, sizeof(TelSimMsisdnList_t));
+ #else
+ TelSimMsisdnList_t r_numbers;
+ r_numbers.count = 3;
+ safeCopyStr(r_numbers.list[0].name, "n1", 30);
+ safeCopyStr(r_numbers.list[1].name, "n2", 30);
+ safeCopyStr(r_numbers.list[2].name, "n3", 30);
+ safeCopyStr(r_numbers.list[0].num, "1111111111", 30);
+ safeCopyStr(r_numbers.list[1].num, "2222222222", 30);
+ safeCopyStr(r_numbers.list[2].num, "3333333333", 30);
+ memcpy(&(ad->my_numbers), &r_numbers, sizeof(TelSimMsisdnList_t));
+ #endif
+
+ int err;
+ char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
+ setting_get_string_slp_key(STR_SLP_SETTING_SELECT_NUM, sel_num, &err);
+
+ bool isFound = FALSE;
+ SETTING_TRACE("ad->my_numbers.count[%d]", ad->my_numbers.count);
+
+ for (i = 0; i < ad->my_numbers.count && i < SETTING_ABOUT_MY_NUMBERS_LEN; i++) {
+ SETTING_TRACE("index[%d] - name[%s], num[%s]", i, ad->my_numbers.list[i].name, ad->my_numbers.list[i].num);
+ if (0 == safeStrCmp(sel_num, ad->my_numbers.list[i].num)) {
+ isFound = TRUE;
+ }
+ }
+ if (!isFound && ad->my_numbers.count > 0) {//if not found, set as the first num of returned-list
+ SETTING_TRACE("Selected-num hasn't been found, to let the first one as defalut one");
+ setting_set_string_slp_key(STR_SLP_SETTING_SELECT_NUM, ad->my_numbers.list[0].num, &err);
+ }
+
+ ad->tapi_responsed = TRUE;
+ if (ad->popup) {
+ evas_object_del(ad->popup);
+ ad->popup = NULL;
+ }
+ setting_about_generate_genlist((void *)ad);
+}
+
UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
{
SETTING_TRACE_BEGIN;
ops->priv = aboutUG;
ops->opt = UG_OPT_INDICATOR_ENABLE;
+ // init aboutUG
+
+ int err = 0;
+ int value;
+ setting_get_int_slp_key(INT_SLP_SETTING_SIM_SLOT, &value, &err);
+ if (VCONFKEY_TELEPHONY_SIM_INSERTED == value)//There is a sim card, so do display to user
+ {
+ aboutUG->handle = tel_init(NULL);
+
+
+ SETTING_TRACE("aboutUG->handle:%p", aboutUG->handle);
+ if (aboutUG->handle) {
+ SETTING_TRACE("tel_init sucessed, and there is at least one sim card, now trying to get misidns");
+ if (tel_get_sim_msisdn(aboutUG->handle, __on_sim_get_msisdn, aboutUG) == TAPI_API_SUCCESS) {
+ SETTING_TRACE("tel_get_sim_msisdn sent");
+ }
+ }
+ }
+ else
+ {
+ SETTING_TRACE_DEBUG("There is no sim card, so skip getting misidns");
+ }
return 0;
}
UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
{
SETTING_TRACE_BEGIN;
- struct SettingAboutUG *aboutUG;
+ SettingAboutUG *aboutUG;
setting_retm_if(!ops, "ops == NULL");
aboutUG = ops->priv;
if (aboutUG) {
+ if (aboutUG->handle
+ && tel_deinit(aboutUG->handle) == TAPI_API_SUCCESS) {
+ SETTING_TRACE("tel_deinit sucessed");
+ }
FREE(aboutUG);
}
}
**general func
**
****************************************************/
-void setting_about_layout_ug_cb(struct ui_gadget *ug, enum ug_mode mode,
+void setting_about_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
void *priv)
{
SettingAboutUG *ad = (SettingAboutUG *) priv;
Evas_Object *base;
- if (!ug || !priv)
+ if (!priv)
return;
SETTING_TRACE_BEGIN;
case UG_MODE_FULLVIEW:
evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
- elm_win_resize_object_add(ad->win_get, base);
+ //elm_win_resize_object_add(ad->win_get, base);
evas_object_show(base);
break;
default:
SETTING_TRACE_END;
}
+static void __setting_about_sub_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ SETTING_TRACE_BEGIN;
+ /* error check */
+ retm_if(event_info == NULL, "Invalid argument: event info is NULL");
+ Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
+ Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
+ elm_genlist_item_selected_set(subitem, 0);
+ Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subitem);
+ Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */
+ ret_if(NULL == data_subItem || NULL == data_parentItem);
+
+
+ int err;
+ setting_set_string_slp_key(data_parentItem->int_slp_setting_binded, data_subItem->keyStr, &err);
+ setting_retm_if(0 != err, "Set vconf error[%d]",data_parentItem->int_slp_setting_binded);
+
+ data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
+ elm_object_item_data_set(data_parentItem->item, data_parentItem);
+ elm_genlist_item_update(data_parentItem->item);
+ elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
+}
+
+static void __setting_about_sub_list_rd_change(void *data, Evas_Object *obj, void *event_info)
+
+{
+ SETTING_TRACE_BEGIN;
+ retm_if(data == NULL, "Data parameter is NULL");
+ Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
+
+ Elm_Object_Item *subItem = list_item->item;
+ Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subItem);
+
+ Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subItem); /* subItem data */
+ Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */
+ ret_if(NULL == data_subItem || NULL == data_parentItem);
+
+ int err;
+ setting_set_string_slp_key(data_parentItem->int_slp_setting_binded, data_subItem->keyStr, &err);
+
+ ret_if(0 != err);
+ data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
+ elm_object_item_data_set(data_parentItem->item, data_parentItem);
+ elm_genlist_item_update(data_parentItem->item);
+ elm_radio_value_set(obj, data_subItem->chk_status);
+}
+
+void setting_about_main_exp_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ SETTING_TRACE_BEGIN;
+ setting_retm_if(data == NULL, "Data parameter is NULL");
+ setting_retm_if(event_info == NULL, "event_info parameter is NULL");
+
+ SettingAboutUG *ad = (SettingAboutUG *) data;
+ Elm_Object_Item *parentItem = event_info; /* parent item */
+ Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);
+ Evas_Object *scroller = elm_object_item_widget_get(parentItem);
+
+ Evas_Object *rgd = elm_radio_add(scroller);
+ elm_radio_value_set(rgd, -1);
+
+ int err;
+ char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
+ setting_get_string_slp_key(data_parentItem->int_slp_setting_binded, sel_num, &err);
+ SETTING_TRACE("binded: %d, checked: %s, err: %d", data_parentItem->int_slp_setting_binded, sel_num, err);
+
+ int i = 0;
+ int sel_idx = -1;
+ Setting_GenGroupItem_Data *item_data = NULL;
+
+ for(; i < ad->my_numbers.count; i++) {
+ if (ad->my_numbers.list[i].num == NULL) {
+ break;
+ }
+
+ if (sel_idx == -1 && 0 == safeStrCmp(sel_num, ad->my_numbers.list[i].num)) {
+ sel_idx = i;
+ }
+ item_data = setting_create_Gendial_exp_sub_field(scroller,
+ &(ad->itc_1icon_1text_sub),
+ __setting_about_sub_list_sel_cb, ad, parentItem,
+ SWALLOW_Type_1RADIO, rgd,
+ i,
+ ad->my_numbers.list[i].num, __setting_about_sub_list_rd_change);
+ if (item_data) {
+ item_data->userdata = ad;
+ } else {
+ SETTING_TRACE_ERROR("item_data is NULL");
+ }
+ }
+
+ elm_radio_value_set(rgd, sel_idx);
+}
+
+
/**
* Reset function to 'reset' the settings of the UG, it will be invoked by 'Reset' UG
*
* @param[in] data
* @param[in] priv
*/
-UG_MODULE_API int setting_plugin_reset(bundle *data, void *priv)
+UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
{
SETTING_TRACE_BEGIN;
#if SUPPORT_RUN_SYSTEM_COMMAND
- return excuteCmd(SETTING_POSTINST_FILE, 1, "about");
+ return excuteCmd(SETTING_POSTINST_FILE, 1, "about");
#else
- return vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, "Tizen");
+ return vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SETTING_ABOUT_DEFAULT_DEVICE_NAME);
#endif
}