2 * Copyright (c) 2010 Samsung Electronics, Inc.
5 * This software is a confidential and proprietary information
6 * of Samsung Electronics, Inc. ("Confidential Information"). You
7 * shall not disclose such Confidential Information and shall use
8 * it only in accordance with the terms of the license agreement
9 * you entered into with Samsung Electronics.
11 #include <bluetooth.h>
12 #include <vconf-keys.h>
15 #include "setting_data_vconf.h"
16 #include "setting_indicator_util.h"
18 void indicator_vconf_changed_cb(keynode_t *node, void *data)
23 ERR("appdata is null!!");
27 Evas_Object *layout = NULL;
29 layout = elm_object_item_part_content_get(elm_genlist_first_item_get(ad->main_genlist), "elm.icon");
30 indicator_view_update(layout);
33 void _indicator_set_BT_icon(keynode_t *node, void *data)
35 Evas_Object *layout = data;
36 int isBTOn = 0, sap_connected = 0, headset_connected = 0;
38 if(vconf_get_int(VCONFKEY_BT_STATUS, &isBTOn) != 0) {
39 DBG("vconf_get_int() failed");
43 elm_object_signal_emit(layout, "hideHeadset", "img.headset");
46 vconf_get_bool(VCONFKEY_WMS_WMANAGER_CONNECTED, &sap_connected);
47 DBG("SAP conntected : %d", sap_connected);
48 if (sap_connected == 0) {
49 elm_object_signal_emit(layout, "showUnconnctedBTicon", "img.bluetooth");
51 elm_object_signal_emit(layout, "showConnectedBTicon", "img.bluetooth");
53 vconf_get_int(VCONFKEY_BT_DEVICE, &headset_connected);
54 DBG("Heaadset connected : %x", headset_connected);
55 if (headset_connected & VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED) {
56 elm_object_signal_emit(layout, "showHeadset", "img.headset");
58 elm_object_signal_emit(layout, "hideHeadset", "img.headset");
61 elm_object_signal_emit(layout, "hideBTicon", "img.bluetooth");
62 elm_object_signal_emit(layout, "hideHeadset", "img.headset");
66 void _indicator_set_battery_icon(keynode_t *node, void *data)
68 int battery_level = 100;
69 int is_battery_display = -1;
70 char buf[1024] = {0,};
72 Evas_Object *icon = NULL;
75 Evas_Object *layout = data;
77 icon = elm_object_part_content_get(layout, "sw.battery");
79 icon = elm_layout_add(layout);
80 elm_layout_file_set(icon, EDJE_PATH, "setting/indicator/battery_icon");
81 evas_object_size_hint_weight_set (icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
82 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
83 elm_object_part_content_set(layout, "sw.battery", icon);
86 vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &battery_level);
87 vconf_get_bool(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, &is_battery_display);
88 if(is_battery_display) {
89 char *level = _get_strnum_from_icu(battery_level);
90 DBG("%s %d", level, strlen(level));
91 if(strlen(level) > 6) {
92 snprintf(buf, sizeof(buf)-1, "%d%%", battery_level);
94 snprintf(buf, sizeof(buf)-1, "%s%%", level);
96 elm_object_part_text_set(layout, "txt.battery", buf);
99 elm_object_part_text_set(layout, "txt.battery", "");
103 vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &is_charged);
104 DBG("battery_level: %d, isCharging: %d", battery_level, is_charged);
105 if(is_charged == 1) {
106 snprintf(buf, sizeof(buf)-1, "change_charging_level_");
107 } else if(is_charged == 0) {
108 snprintf(buf, sizeof(buf)-1, "change_level_");
109 } else if(is_charged == -1) {
110 DBG("Battery charging has problem");
111 elm_object_part_text_set(layout, "txt.battery", "");
112 snprintf(buf, sizeof(buf)-1, "change_level_");
116 snprintf(buf2, sizeof(buf2)-1, "%02d", battery_level);
117 strncat(buf, buf2, sizeof(buf)-1);
118 DBG("battery file : %s", buf);
119 elm_object_signal_emit(icon, buf, "img.battery");
120 elm_object_signal_emit(layout, "showBattery", "sw.battery");
123 void indicator_view_update(Evas_Object *layout)
126 _indicator_set_BT_icon(NULL, layout);
129 _indicator_set_battery_icon(NULL, layout);
132 void indicator_set_vconf_changed_cb(void *data)
134 register_vconf_changing(VCONFKEY_WMS_WMANAGER_CONNECTED, indicator_vconf_changed_cb, data);
135 register_vconf_changing(VCONFKEY_SYSMAN_BATTERY_CAPACITY, indicator_vconf_changed_cb, data);
136 register_vconf_changing(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, indicator_vconf_changed_cb, data);
137 register_vconf_changing(VCONFKEY_BT_DEVICE, indicator_vconf_changed_cb, data);
140 void indicator_unset_vconf_changed_cb()
142 unregister_vconf_changing(VCONFKEY_WMS_WMANAGER_CONNECTED, indicator_vconf_changed_cb);
143 unregister_vconf_changing(VCONFKEY_SYSMAN_BATTERY_CAPACITY, indicator_vconf_changed_cb);
144 unregister_vconf_changing(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, indicator_vconf_changed_cb);
145 unregister_vconf_changing(VCONFKEY_BT_DEVICE, indicator_vconf_changed_cb);