2 * setting-notification.c
4 * Created on: Feb 14, 2014
8 #include "setting-notification.h"
11 static struct _noti_menu_item noti_menu_its[] = {
12 { "IDS_ST_BUTTON_NOTIFICATIONS", 1, _noti_gl_enabling_noti_cb },
16 static struct _noti_data g_noti_data;
17 static bool is_called_myself;
20 void _initialize_noti()
22 is_called_myself = false;
24 g_noti_data.g_noti_genlist = NULL;
25 g_noti_data.is_enable_noti = 0;
26 g_noti_data.temp_ad = NULL;
28 register_vconf_changing(VCONF_WMS_NOTIFICATION_KEY, noti_enabling_vconf_changed_cb, NULL);
31 void _noti_gl_enabling_noti_cb(void *data, Evas_Object *obj, void *event_info)
33 DBG("Setting - _noti_gl_enabling_noti_cb() is called!");
35 Elm_Object_Item *it = (Elm_Object_Item *)event_info;
39 DBG("%s", "_noti_gl_enabling_noti_cb - ad or check is null");
43 is_called_myself = true;
45 g_noti_data.is_enable_noti = (g_noti_data.is_enable_noti) ? 0 : 1;
47 vconf_set_int(VCONF_WMS_NOTIFICATION_KEY, g_noti_data.is_enable_noti);
49 elm_genlist_item_selected_set(it, EINA_FALSE);
51 if (g_noti_data.g_noti_genlist) {
52 elm_genlist_realized_items_update(g_noti_data.g_noti_genlist);
56 Eina_Bool _clear_noti_cb(void *data, Elm_Object_Item *it)
58 DBG("Setting - _clear_noti_cb() is called!");
60 is_called_myself = false;
62 g_noti_data.g_noti_genlist = NULL;
63 g_noti_data.is_enable_noti = 0;
64 g_noti_data.temp_ad = NULL;
66 unregister_vconf_changing(VCONF_WMS_NOTIFICATION_KEY, noti_enabling_vconf_changed_cb);
71 char *_gl_noti_title_get(void *data, Evas_Object *obj, const char *part)
73 char buf[1024] = {0,};
74 Noti_Item_Data *id = data;
75 int index = id->index;
77 if (!strcmp(part, "elm.text")) {
78 snprintf(buf, sizeof(buf) - 1, "%s", _(noti_menu_its[index % 1].name));
79 } else if (!strcmp(part, "elm.text.1")) {
80 vconf_get_int(VCONF_WMS_NOTIFICATION_KEY, &g_noti_data.is_enable_noti);
81 snprintf(buf, sizeof(buf) - 1, "%s", (g_noti_data.is_enable_noti) ? _("IDS_EMAIL_BODY_ENABLED_M_STATUS")
82 : _("IDS_ST_MBODY_DISABLED_ABB"));
87 Evas_Object *_gl_noti_check_get(void *data, Evas_Object *obj, const char *part)
89 Evas_Object *check = NULL;
90 Noti_Item_Data *id = data;
91 int index = id->index;
93 if (!strcmp(part, "elm.icon")) {
94 check = elm_check_add(obj);
95 elm_object_style_set(check, "list");
96 vconf_get_int(VCONF_WMS_NOTIFICATION_KEY, &g_noti_data.is_enable_noti);
97 elm_check_state_set(check, (g_noti_data.is_enable_noti) ? EINA_TRUE : EINA_FALSE);
98 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
99 evas_object_propagate_events_set(check, EINA_FALSE);
100 evas_object_repeat_events_set(check, EINA_TRUE);
106 static void _noti_gl_del(void *data, Evas_Object *obj)
108 Noti_Item_Data *id = data;
113 Evas_Object *_create_noti_list(void *data)
115 DBG("Setting - _create_noti_list() is called!");
119 DBG("%s", "_create_noti_list - appdata is null");
122 Evas_Object *genlist = NULL;
123 struct _noti_menu_item *menu_its = NULL;
126 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
127 itc->item_style = "2text.1icon.1";
128 itc->func.text_get = _gl_noti_title_get;
129 itc->func.content_get = _gl_noti_check_get;
130 itc->func.del = _noti_gl_del;
132 Evas_Object *layout = elm_layout_add(ad->nf);
133 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
134 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
136 genlist = elm_genlist_add(layout);
137 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
139 menu_its = noti_menu_its;
142 device_info_h *device_info = NULL;
145 capability_manager_create_device_info(&device_info);
146 capability_manager_get_device_features(device_info, &b);
147 val = bundle_get_val(b, "smartrelay");
148 capability_manager_destroy_device_info(device_info);
151 for (idx = 0; idx < NOTIFICATION_ITEM_COUNT; idx++) {
152 Noti_Item_Data *id = calloc(sizeof(Noti_Item_Data), 1);
155 id->item = elm_genlist_item_append(
156 genlist, /* genlist object */
157 itc, /* item class */
160 ELM_GENLIST_ITEM_NONE,
161 menu_its[idx].func, /* call back */
165 elm_genlist_item_class_free(itc);
167 g_noti_data.g_noti_genlist = genlist;
169 elm_object_part_content_set(layout, "elm.genlist", genlist);
174 void noti_enabling_vconf_changed_cb(keynode_t *key, void *data)
176 DBG("Setting - noti_enabling_vconf_changed_cb() is called!");
178 if (is_called_myself) {
179 DBG("Setting - is_called_myself!! Return!!");
180 is_called_myself = false;
184 g_noti_data.is_enable_noti = vconf_keynode_get_int(key);
186 DBG("Setting - Noti value: %d", g_noti_data.is_enable_noti);
188 if (g_noti_data.g_noti_genlist) {
189 elm_genlist_realized_items_update(g_noti_data.g_noti_genlist);