2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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.
22 #include "indicator.h"
23 #include "indicator_ui.h"
25 #include "indicator_icon_util.h"
27 #define ICON_PRIORITY INDICATOR_PRIORITY_NON_FIXED_2
28 #define MODULE_NAME "alarm"
30 static int register_alarm_module(void *data);
31 static int unregister_alarm_module(void);
32 static int hib_enter_alarm_module(void);
33 static int hib_leave_alarm_module(void *data);
35 Indicator_Icon_Object useralarm = {
36 .type = INDICATOR_IMG_ICON,
38 .priority = ICON_PRIORITY,
39 .always_top = EINA_FALSE,
40 .exist_in_view = EINA_FALSE,
43 .obj_exist = EINA_FALSE,
45 .init = register_alarm_module,
46 .fini = unregister_alarm_module,
47 .hib_enter = hib_enter_alarm_module,
48 .hib_leave = hib_leave_alarm_module
51 static char *icon_path[] = {
52 "Alarm/B03_Alarm.png",
56 static void show_image_icon(void *data)
58 useralarm.img_obj.data = icon_path[0];
59 indicator_util_icon_show(&useralarm);
62 static void hide_image_icon(void)
64 indicator_util_icon_hide(&useralarm);
67 static void indicator_alarm_change_cb(keynode_t *node, void *data)
72 retif(data == NULL, , "Invalid parameter!");
74 ret = vconf_get_int(VCONFKEY_ALARM_STATE, &status);
77 INFO("ALARM COUNT: %d", status);
78 show_image_icon(data);
81 INFO("ALARM COUNT: %d", status);
85 ERR("Failed to get alarm count!");
89 static int register_alarm_module(void *data)
93 retif(data == NULL, FAIL, "Invalid parameter!");
95 ret = vconf_notify_key_changed(VCONFKEY_ALARM_STATE,
96 indicator_alarm_change_cb, data);
98 ERR("Failed to register callback!");
100 indicator_alarm_change_cb(NULL, data);
105 static int unregister_alarm_module(void)
109 ret = vconf_ignore_key_changed(VCONFKEY_ALARM_STATE,
110 indicator_alarm_change_cb);
112 ERR("Failed to unregister callback!");
119 static int hib_enter_alarm_module(void)
123 ret = vconf_ignore_key_changed(VCONFKEY_ALARM_STATE,
124 indicator_alarm_change_cb);
126 ERR("Failed to unregister callback!");
131 static int hib_leave_alarm_module(void *data)
135 retif(data == NULL, FAIL, "Invalid parameter!");
137 ret = vconf_notify_key_changed(VCONFKEY_ALARM_STATE,
138 indicator_alarm_change_cb, data);
139 retif(ret != OK, FAIL, "Failed to register callback!");
141 indicator_alarm_change_cb(NULL, data);