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_1
28 #define MODULE_NAME "silent"
30 static int register_silent_module(void *data);
31 static int unregister_silent_module(void);
32 static int hib_enter_silent_module(void);
33 static int hib_leave_silent_module(void *data);
35 Indicator_Icon_Object silent = {
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_silent_module,
46 .fini = unregister_silent_module,
47 .hib_enter = hib_enter_silent_module,
48 .hib_leave = hib_leave_silent_module
52 PROFILE_SOUND_VIBRATION,
58 static const char *icon_path[PROFILE_NUM] = {
59 [PROFILE_SOUND_VIBRATION] = "Profile/B03_Profile_Sound_Vibration.png",
60 [PROFILE_MUTE] = "Profile/B03_Profile_Mute.png",
61 [PROFILE_VIBRATION] = "Profile/B03_Profile_Vibration.png",
64 static void indicator_silent_change_cb(keynode_t *node, void *data)
69 const char *selected_image = NULL;
71 retif(data == NULL, , "Invalid parameter!");
73 ret = vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_status);
75 vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_status);
78 INFO("CURRENT Sound Status: %d vib_status: %d", sound_status,
81 if (sound_status == TRUE) {
82 if (vib_status == TRUE)
83 /* Sound and Vibration Mode */
85 icon_path[PROFILE_SOUND_VIBRATION];
87 if (vib_status != TRUE)
89 selected_image = icon_path[PROFILE_MUTE];
91 /* Vibration Only Mode */
92 selected_image = icon_path[PROFILE_VIBRATION];
95 if (selected_image != NULL) {
96 silent.img_obj.data = selected_image;
97 indicator_util_icon_show(&silent);
101 /* If path is not set to 'selected_image', Hide All Image */
102 indicator_util_icon_hide(&silent);
106 ERR("Failed to get current profile!");
110 static int register_silent_module(void *data)
114 retif(data == NULL, FAIL, "Invalid parameter!");
116 ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
117 indicator_silent_change_cb, data);
119 ERR("Fail: register VCONFKEY_SETAPPL_SOUND_STATUS_BOOL");
121 ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
122 indicator_silent_change_cb, data);
124 ERR("Fail: register VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL");
126 indicator_silent_change_cb(NULL, data);
131 static int unregister_silent_module(void)
135 ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
136 indicator_silent_change_cb);
138 ERR("Fail: ignore VCONFKEY_SETAPPL_SOUND_STATUS_BOOL");
140 ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
141 indicator_silent_change_cb);
143 ERR("Fail: ignore VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL");
145 indicator_util_icon_hide(&silent);
150 static int hib_enter_silent_module(void)
154 ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
155 indicator_silent_change_cb);
157 ERR("H_Fail: ignore VCONFKEY_SETAPPL_SOUND_STATUS_BOOL");
159 ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
160 indicator_silent_change_cb);
162 ERR("H_Fail: ignore VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL");
167 static int hib_leave_silent_module(void *data)
171 retif(data == NULL, FAIL, "Invalid parameter!");
173 ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
174 indicator_silent_change_cb, data);
176 ERR("H_Fail: register VCONFKEY_SETAPPL_SOUND_STATUS_BOOL");
178 ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
179 indicator_silent_change_cb, data);
181 ERR("H_Fail: register VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL");
183 indicator_silent_change_cb(NULL, data);