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;
22 _gl_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
26 snprintf(buf, 1023, "%s", "Notification");
31 void _initialize_noti()
33 is_called_myself = false;
35 g_noti_data.g_noti_genlist = NULL;
36 g_noti_data.is_enable_noti = 0;
37 g_noti_data.temp_ad = NULL;
39 register_vconf_changing(VCONF_WMS_NOTIFICATION_KEY, noti_enabling_vconf_changed_cb, NULL);
42 void _noti_gl_enabling_noti_cb(void *data, Evas_Object *obj, void *event_info)
44 DBG("Setting - _noti_gl_enabling_noti_cb() is called!");
46 Elm_Object_Item *it = (Elm_Object_Item *)event_info;
50 DBG("%s", "_noti_gl_enabling_noti_cb - ad or check is null");
54 is_called_myself = true;
56 g_noti_data.is_enable_noti = (g_noti_data.is_enable_noti) ? 0 : 1;
58 vconf_set_int(VCONF_WMS_NOTIFICATION_KEY, g_noti_data.is_enable_noti);
60 elm_genlist_item_selected_set(it, EINA_FALSE);
62 if (g_noti_data.g_noti_genlist) {
63 elm_genlist_realized_items_update(g_noti_data.g_noti_genlist);
67 Eina_Bool _clear_noti_cb(void *data, Elm_Object_Item *it)
69 DBG("Setting - _clear_noti_cb() is called!");
71 is_called_myself = false;
73 g_noti_data.g_noti_genlist = NULL;
74 g_noti_data.is_enable_noti = 0;
75 g_noti_data.temp_ad = NULL;
77 unregister_vconf_changing(VCONF_WMS_NOTIFICATION_KEY, noti_enabling_vconf_changed_cb);
82 char *_gl_noti_title_get(void *data, Evas_Object *obj, const char *part)
84 char buf[1024] = {0,};
85 Noti_Item_Data *id = data;
86 int index = id->index;
88 if (!strcmp(part, "elm.text")) {
89 snprintf(buf, sizeof(buf) - 1, "%s", _(noti_menu_its[index % 1].name));
90 } else if (!strcmp(part, "elm.text.1")) {
91 vconf_get_int(VCONF_WMS_NOTIFICATION_KEY, &g_noti_data.is_enable_noti);
92 snprintf(buf, sizeof(buf) - 1, "%s", (g_noti_data.is_enable_noti) ? _("IDS_EMAIL_BODY_ENABLED_M_STATUS")
93 : _("IDS_ST_MBODY_DISABLED_ABB"));
98 Evas_Object *_gl_noti_check_get(void *data, Evas_Object *obj, const char *part)
100 Evas_Object *check = NULL;
101 Noti_Item_Data *id = data;
102 int index = id->index;
104 if (!strcmp(part, "elm.icon")) {
105 check = elm_check_add(obj);
106 elm_object_style_set(check, "list");
107 vconf_get_int(VCONF_WMS_NOTIFICATION_KEY, &g_noti_data.is_enable_noti);
108 elm_check_state_set(check, (g_noti_data.is_enable_noti) ? EINA_TRUE : EINA_FALSE);
109 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
110 evas_object_propagate_events_set(check, EINA_FALSE);
111 evas_object_repeat_events_set(check, EINA_TRUE);
117 static void _noti_gl_del(void *data, Evas_Object *obj)
119 Noti_Item_Data *id = data;
124 Evas_Object *_create_noti_list(void *data)
126 DBG("Setting - _create_noti_list() is called!");
130 DBG("%s", "_create_noti_list - appdata is null");
133 Evas_Object *genlist = NULL;
134 struct _noti_menu_item *menu_its = NULL;
137 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
138 itc->item_style = "2text.1icon.1";
139 itc->func.text_get = _gl_noti_title_get;
140 itc->func.content_get = _gl_noti_check_get;
141 itc->func.del = _noti_gl_del;
143 Evas_Object *layout = elm_layout_add(ad->nf);
144 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
145 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
147 genlist = elm_genlist_add(layout);
148 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
150 menu_its = noti_menu_its;
153 Elm_Genlist_Item_Class *title_item = elm_genlist_item_class_new();
154 title_item ->func.text_get = _gl_menu_title_text_get;
155 title_item->item_style = "title";
156 title_item->func.del = _noti_gl_del;
158 elm_genlist_item_append(genlist, title_item, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
160 elm_genlist_item_class_free(title_item);
163 device_info_h *device_info = NULL;
166 capability_manager_create_device_info(&device_info);
167 capability_manager_get_device_features(device_info, &b);
168 val = bundle_get_val(b, "smartrelay");
169 capability_manager_destroy_device_info(device_info);
172 for (idx = 0; idx < NOTIFICATION_ITEM_COUNT; idx++) {
173 Noti_Item_Data *id = calloc(sizeof(Noti_Item_Data), 1);
176 id->item = elm_genlist_item_append(
177 genlist, /* genlist object */
178 itc, /* item class */
181 ELM_GENLIST_ITEM_NONE,
182 menu_its[idx].func, /* call back */
187 Elm_Genlist_Item_Class *padding = elm_genlist_item_class_new();
188 padding->item_style = "padding";
189 padding->func.del = _noti_gl_del;
191 elm_genlist_item_append(genlist, padding, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
192 elm_genlist_item_class_free(padding);
195 g_noti_data.g_noti_genlist = genlist;
197 elm_object_part_content_set(layout, "elm.genlist", genlist);
202 void noti_enabling_vconf_changed_cb(keynode_t *key, void *data)
204 DBG("Setting - noti_enabling_vconf_changed_cb() is called!");
206 if (is_called_myself) {
207 DBG("Setting - is_called_myself!! Return!!");
208 is_called_myself = false;
212 g_noti_data.is_enable_noti = vconf_keynode_get_int(key);
214 DBG("Setting - Noti value: %d", g_noti_data.is_enable_noti);
216 if (g_noti_data.g_noti_genlist) {
217 elm_genlist_realized_items_update(g_noti_data.g_noti_genlist);