2 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * setting-notification.c
20 * Created on: Feb 14, 2014
24 #include "setting-notification.h"
27 static struct _noti_menu_item noti_menu_its[] = {
28 { "IDS_ST_BUTTON_NOTIFICATIONS", 1, _noti_gl_enabling_noti_cb },
32 static struct _noti_data g_noti_data;
33 static bool is_called_myself;
36 void _initialize_noti()
38 is_called_myself = false;
40 g_noti_data.g_noti_genlist = NULL;
41 g_noti_data.is_enable_noti = 0;
42 g_noti_data.temp_ad = NULL;
44 register_vconf_changing(VCONF_WMS_NOTIFICATION_KEY, noti_enabling_vconf_changed_cb, NULL);
47 void _noti_gl_enabling_noti_cb(void *data, Evas_Object *obj, void *event_info)
49 DBG("Setting - _noti_gl_enabling_noti_cb() is called!");
51 Elm_Object_Item* it = (Elm_Object_Item *)event_info;
56 DBG("%s", "_noti_gl_enabling_noti_cb - ad or check is null");
60 is_called_myself = true;
62 g_noti_data.is_enable_noti = (g_noti_data.is_enable_noti) ? 0 : 1;
64 vconf_set_int(VCONF_WMS_NOTIFICATION_KEY, g_noti_data.is_enable_noti);
66 elm_genlist_item_selected_set(it, EINA_FALSE);
68 if(g_noti_data.g_noti_genlist)
70 elm_genlist_realized_items_update(g_noti_data.g_noti_genlist);
74 Eina_Bool _clear_noti_cb(void *data, Elm_Object_Item *it)
76 DBG("Setting - _clear_noti_cb() is called!");
78 is_called_myself = false;
80 g_noti_data.g_noti_genlist = NULL;
81 g_noti_data.is_enable_noti = 0;
82 g_noti_data.temp_ad = NULL;
84 unregister_vconf_changing(VCONF_WMS_NOTIFICATION_KEY, noti_enabling_vconf_changed_cb);
89 char * _gl_noti_title_get(void *data, Evas_Object *obj, const char *part)
91 char buf[1024] = {0,};
92 Noti_Item_Data *id = data;
93 int index = id->index;
95 if( !strcmp(part, "elm.text.1") )
97 snprintf(buf, sizeof(buf)-1, "%s", _(noti_menu_its[index % 1].name));
99 else if( !strcmp(part, "elm.text.2") )
101 vconf_get_int(VCONF_WMS_NOTIFICATION_KEY, &g_noti_data.is_enable_noti);
102 snprintf(buf, sizeof(buf)-1, "%s", (g_noti_data.is_enable_noti) ? _("IDS_EMAIL_BODY_ENABLED_M_STATUS")
103 : _("IDS_ST_MBODY_DISABLED_ABB"));
108 Evas_Object * _gl_noti_check_get(void *data, Evas_Object *obj, const char *part)
110 Evas_Object *check = NULL;
111 Noti_Item_Data *id = data;
112 int index = id->index;
114 if( !strcmp(part, "elm.icon") )
116 check = elm_check_add(obj);
117 elm_object_style_set(check, "list");
118 vconf_get_int(VCONF_WMS_NOTIFICATION_KEY, &g_noti_data.is_enable_noti);
119 elm_check_state_set(check, (g_noti_data.is_enable_noti) ? EINA_TRUE : EINA_FALSE);
120 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
121 evas_object_propagate_events_set(check, EINA_FALSE);
122 evas_object_repeat_events_set(check, EINA_TRUE);
128 static void _noti_gl_del(void *data, Evas_Object *obj)
130 Noti_Item_Data *id = data;
135 Evas_Object* _create_noti_list(void* data)
137 DBG("Setting - _create_noti_list() is called!");
142 DBG("%s", "_create_noti_list - appdata is null");
145 Evas_Object *genlist = NULL;
146 struct _noti_menu_item *menu_its = NULL;
149 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
150 itc->item_style = "2text.1icon.1";
151 itc->func.text_get = _gl_noti_title_get;
152 itc->func.content_get = _gl_noti_check_get;
153 itc->func.del = _noti_gl_del;
155 Evas_Object * layout = elm_layout_add(ad->nf);
156 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
157 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
159 genlist = elm_genlist_add(layout);
160 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
162 menu_its = noti_menu_its;
165 device_info_h* device_info = NULL;
168 capability_manager_create_device_info(&device_info);
169 capability_manager_get_device_features(device_info, &b);
170 val = bundle_get_val(b, "smartrelay");
171 capability_manager_destroy_device_info(device_info);
174 for (idx = 0; idx < NOTIFICATION_ITEM_COUNT; idx++)
176 Noti_Item_Data *id = calloc(sizeof(Noti_Item_Data), 1);
178 id->item = elm_genlist_item_append(
179 genlist, // genlist object
183 ELM_GENLIST_ITEM_NONE,
184 menu_its[ idx ].func, // call back
187 elm_genlist_item_class_free(itc);
189 g_noti_data.g_noti_genlist = genlist;
191 elm_object_part_content_set(layout, "elm.genlist", genlist);
196 void noti_enabling_vconf_changed_cb(keynode_t *key, void * data)
198 DBG("Setting - noti_enabling_vconf_changed_cb() is called!");
202 DBG("Setting - is_called_myself!! Return!!");
203 is_called_myself = false;
207 g_noti_data.is_enable_noti = vconf_keynode_get_int(key);
209 DBG("Setting - Noti value: %d", g_noti_data.is_enable_noti);
211 if(g_noti_data.g_noti_genlist)
213 elm_genlist_realized_items_update(g_noti_data.g_noti_genlist);