fix bug : P120921-6157
[apps/core/preloaded/settings.git] / setting-about / src / setting-about-main.c
index 50f84e6..3818715 100755 (executable)
@@ -24,7 +24,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <bluetooth-api.h>
+//#include <bluetooth-api.h>
+
+#include <bluetooth.h>
 
 
 #include <app_manager.h>
@@ -139,8 +141,8 @@ static void __device_name_changed_cb(void *data, Evas_Object *obj)
                if (!ad->empty_flag)
                {
                        ad->empty_flag = TRUE;
-                       elm_entry_context_menu_disabled_set(obj, TRUE); //disable the copy&paste&search popup
-                       elm_entry_magnifier_disabled_set(obj, TRUE);
+                       //elm_entry_context_menu_disabled_set(obj, TRUE); //disable the copy&paste&search popup
+                       //elm_entry_magnifier_disabled_set(obj, TRUE);
                        Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
                        if (navi_it)
                        {
@@ -160,8 +162,8 @@ static void __device_name_changed_cb(void *data, Evas_Object *obj)
                if (ad->empty_flag)
                {
                        ad->empty_flag = FALSE;
-                       elm_entry_context_menu_disabled_set(obj, FALSE); //enable the copy&paste&search popup
-                       elm_entry_magnifier_disabled_set(obj, FALSE);
+                       //elm_entry_context_menu_disabled_set(obj, FALSE); //enable the copy&paste&search popup
+                       //elm_entry_magnifier_disabled_set(obj, FALSE);
                        Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
                        if (navi_it)
                        {
@@ -224,29 +226,32 @@ void setting_about_main_get_sw_version(char* szStr, int nSize)
 {
        retm_if(szStr == NULL, "szStr parameter is NULL");
 
-       char *version = NULL;
-       int ret = system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION, &version);
+       // ex) TIZEN
+       char *platform = NULL;
+       int ret = system_info_get_value_string(SYSTEM_INFO_KEY_PLATFORM_NAME, &platform);
        if (ret != SYSTEM_INFO_ERROR_NONE) {
                SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
-               FREE(version);
+               FREE(platform);
                snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
                return;
        }
 
-       char *build_info = NULL;
-       ret = system_info_get_value_string(SYSTEM_INFO_KEY_BUILD_STRING, &build_info);
+       // ex) 2.0.0b
+       char *version = NULL;
+       ret = system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION, &version);
        if (ret != SYSTEM_INFO_ERROR_NONE) {
                SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
+
+               FREE(platform);
                FREE(version);
-               FREE(build_info);
+
                snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
                return;
        }
+       snprintf(szStr, nSize, "%s %s", platform, version);
 
-       snprintf(szStr, nSize, "SLP%s (%s)", version, build_info);
-
+       FREE(platform);
        FREE(version);
-       FREE(build_info);
 }
 
 void setting_about_main_get_wifi_mac_address_string(char *str, int size)
@@ -280,30 +285,16 @@ void setting_about_main_get_battery_string(char *str, int size)
 {
        setting_retm_if(str == NULL, "str parameter is NULL");
 
-       int val = -1;
-       char file[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
-       snprintf(file, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO,
-                "%s/%s/%s", SETTING_ABOUT_POWER_SUPPLY_PATH, "battery", "capacity");
-
-       char buf[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
-       int fd = 0;
-       int r = 0;
-
-       fd = open(file, O_RDONLY);
-       if (fd != -1) {
-               r = read(fd, buf, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
-               if ((r >= 0) && (r < MAX_DISPLAY_STR_LEN_ON_PHONE_INFO)) {
-                       buf[r] = '\0';
-                       val = atoi(buf);
-                       snprintf(str, size, "%d%s", val, "\%");
-               } else {
-                       SETTING_TRACE_ERROR("read file fail");
-                       snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
-               }
+       int bat_level = -1;
 
-               close(fd);
-       } else {
-               SETTING_TRACE_ERROR("open file fail");
+       /* Read battery level from vconf, as system-server sets that key using a 
+         device-specific plugin. Reading directly from /sys fails on different
+         devices */
+       if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &bat_level) == 0) {
+               snprintf(str, size, "%d%s", bat_level, "\%");
+       }
+       else {
+               SETTING_TRACE_ERROR("Reading VCONFKEY_SYSMAN_BATTERY_CAPACITY failed.");
                snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
        }
 }
@@ -312,26 +303,27 @@ void setting_about_main_get_bluetooth_address_string(char *str, int size)
 {
        setting_retm_if(str == NULL, "str parameter is NULL");
 
-       bluetooth_device_address_t local_address;
-       memset(&local_address, 0x0, sizeof(local_address));
        int ret = 0;
 
-       /* for fixing BS of dbus signal */
-       bluetooth_register_callback(NULL, NULL);
+       ret = bt_initialize();
+       setting_retm_if(ret != 0, "bluetooth initialization failed");
 
-       ret = bluetooth_get_local_address(&local_address);
+       char *local_address = NULL;
+       ret = bt_adapter_get_address(&local_address);
 
-       /* for fixing BS of dbus signal */
-       bluetooth_unregister_callback();
+       bt_deinitialize();
 
        if (ret < 0) {
                snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
+               SETTING_TRACE_DEBUG("bt address : %s", str);
        } else {
-               snprintf(str, size, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
-                        local_address.addr[0], local_address.addr[1], local_address.addr[2],
-                        local_address.addr[3], local_address.addr[4], local_address.addr[5]);
+               SETTING_TRACE_DEBUG("bt address : %s", local_address);
+               snprintf(str, size, "%s", local_address);
+       }
+
+       if (local_address) {
+               free(local_address);
        }
-       SETTING_TRACE_DEBUG("bt address : %s", str);
 }
 
 int __stat_get_cpuinfo(float *usr_pct, float *sys_pct)
@@ -509,10 +501,11 @@ static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
        Setting_GenGroupItem_Data *item_dev_name = data;
        SettingAboutUG *ad = item_dev_name->userdata;
        __device_name_changed_cb(item_dev_name, item_dev_name->eo_check);
+#if 0
        //after unfocus,need updating..
        elm_object_item_data_set(item_dev_name->item, item_dev_name);
        elm_genlist_item_update(item_dev_name->item);
-
+#endif
 
        if(ad->navi_item
           && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {