4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include <setting-ledindicator.h>
22 #include <setting-cfg.h>
25 #define UG_MODULE_API __attribute__ ((visibility("default")))
28 static void setting_ledindicator_ug_cb_resize(void *data, Evas *e,
29 Evas_Object *obj, void *event_info)
31 SettingLedIndicatorUG *ad = (SettingLedIndicatorUG *) data;
32 setting_view_update(&setting_view_ledindicator_main, ad);
35 static void *setting_ledindicator_ug_on_create(ui_gadget_h ug,
36 enum ug_mode mode, app_control_h service,
40 setting_retvm_if((!priv), NULL, "!priv");
41 SettingLedIndicatorUG *ledindicatorUG = priv;
42 ledindicatorUG->ug = ug;
43 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
45 ledindicatorUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
46 ledindicatorUG->win_get = (Evas_Object *) ug_get_window();
48 evas_object_show(ledindicatorUG->win_main_layout);
49 ledindicatorUG->evas = evas_object_evas_get(ledindicatorUG->win_main_layout);
51 setting_retvm_if(ledindicatorUG->win_main_layout == NULL, NULL,
52 "cannot get main window ");
55 ledindicatorUG->bg = elm_bg_add(ledindicatorUG->win_get);
56 elm_object_style_set(ledindicatorUG->bg, "dialogue_field");
57 evas_object_size_hint_weight_set(ledindicatorUG->bg, EVAS_HINT_EXPAND,
61 setting_view_create(&setting_view_ledindicator_main, (void *)ledindicatorUG);
62 evas_object_event_callback_add(ledindicatorUG->win_main_layout,
64 setting_ledindicator_ug_cb_resize, ledindicatorUG);
66 return ledindicatorUG->ly_main;
69 static void setting_ledindicator_ug_on_start(ui_gadget_h ug, app_control_h service,
74 static void setting_ledindicator_ug_on_pause(ui_gadget_h ug, app_control_h service,
79 static void setting_ledindicator_ug_on_resume(ui_gadget_h ug, app_control_h service,
84 static void setting_ledindicator_ug_on_destroy(ui_gadget_h ug, app_control_h service,
88 setting_retm_if((!priv), "!priv");
89 SettingLedIndicatorUG *ledindicatorUG = priv;
90 evas_object_event_callback_del(ledindicatorUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_ledindicator_ug_cb_resize); //fix flash issue for gallery
91 ledindicatorUG->ug = ug;
92 if (ledindicatorUG->bg) {
93 evas_object_del(ledindicatorUG->bg);
95 ledindicatorUG->bg = NULL;
97 // called when this shared gadget is terminated. similar with app_exit
98 setting_view_destroy(&setting_view_ledindicator_main, ledindicatorUG);
100 if (NULL != ug_get_layout(ledindicatorUG->ug)) {
101 evas_object_hide((Evas_Object *) ug_get_layout(ledindicatorUG->ug));
102 evas_object_del((Evas_Object *) ug_get_layout(ledindicatorUG->ug));
106 static void setting_ledindicator_ug_on_message(ui_gadget_h ug, app_control_h msg,
107 app_control_h service, void *priv)
112 static void setting_ledindicator_ug_on_event(ui_gadget_h ug,
113 enum ug_event event, app_control_h service,
117 setting_retm_if((!priv), "!priv");
118 SettingLedIndicatorUG *ad = priv;
120 case UG_EVENT_LOW_MEMORY:
122 case UG_EVENT_LOW_BATTERY:
124 case UG_EVENT_LANG_CHANGE:
125 setting_navi_items_update(ad->navi_bar);
127 case UG_EVENT_ROTATE_PORTRAIT:
129 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
131 case UG_EVENT_ROTATE_LANDSCAPE:
133 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
135 case UG_EVENT_REGION_CHANGE:
142 static void setting_ledindicator_ug_on_key_event(ui_gadget_h ug,
143 enum ug_key_event event,
144 app_control_h service, void *priv)
147 SettingLedIndicatorUG *ad = (SettingLedIndicatorUG *) priv;
150 case UG_KEY_EVENT_END:
152 if (elm_naviframe_top_item_get(ad->navi_bar) ==
153 elm_naviframe_bottom_item_get(ad->
158 setting_view_cb_at_endKey(ad);
167 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
170 SettingLedIndicatorUG *ledindicatorUG = calloc(1, sizeof(SettingLedIndicatorUG));
171 setting_retvm_if(!ledindicatorUG, -1, "Create SettingLedIndicatorUG obj failed");
173 ops->create = setting_ledindicator_ug_on_create;
174 ops->start = setting_ledindicator_ug_on_start;
175 ops->pause = setting_ledindicator_ug_on_pause;
176 ops->resume = setting_ledindicator_ug_on_resume;
177 ops->destroy = setting_ledindicator_ug_on_destroy;
178 ops->message = setting_ledindicator_ug_on_message;
179 ops->event = setting_ledindicator_ug_on_event;
180 ops->key_event = setting_ledindicator_ug_on_key_event;
181 ops->priv = ledindicatorUG;
182 ops->opt = UG_OPT_INDICATOR_ENABLE;
186 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
189 struct SettingLedIndicatorUG *ledindicatorUG;
190 setting_retm_if(!ops, "ops == NULL");
192 ledindicatorUG = ops->priv;
193 if (ledindicatorUG) {
194 FREE(ledindicatorUG);
198 static Setting_Cfg_Node_T s_cfg_node_array[] = {
199 {"IDS_ST_MBODY_CHARGING", NULL, "viewtype:frontpage", 0, 0, 0, Cfg_Item_View_Node_Toggle, NULL, NULL, NULL, NULL},
200 {"IDS_ST_BODY_LEDOT_LOW_BATTERY", NULL, "viewtype:frontpage", 0, 0, 0, Cfg_Item_View_Node_Toggle, NULL, NULL, NULL, NULL},
201 {"IDS_ST_BODY_NOTIFICATIONS", NULL, "viewtype:frontpage", 0, 0, 0, Cfg_Item_View_Node_Toggle, NULL, NULL, NULL, NULL},
202 {"IDS_ST_BODY_VOICE_RECORDING", NULL, "viewtype:frontpage", 0, 0, 0, Cfg_Item_View_Node_Toggle, NULL, NULL, NULL, NULL},
205 UG_MODULE_API int setting_plugin_search_init(app_control_h service, void *priv, char** applocale)
208 SETTING_TRACE(">> setting-ledindicator-efl DB search code");
209 setting_retvm_if(!priv || !applocale,SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "pplist/applocale is NULL");
211 *applocale = strdup("setting:/usr/apps/org.tizen.setting/res/locale");
213 Eina_List **pplist = (Eina_List**)priv;
215 int size = sizeof(s_cfg_node_array)/sizeof(s_cfg_node_array[0]);
216 for(i=0;i<size;i++) {
217 Setting_Cfg_Node_T * node = setting_plugin_search_item_subindex_add(s_cfg_node_array[i].key_name, s_cfg_node_array[i].ug_args, IMG_LEDIndicator,s_cfg_node_array[i].item_type, s_cfg_node_array[i].data, "LED");
218 *pplist = eina_list_append(*pplist, node);
224 * @brief get toggle state for "charging"
226 * @param stat store the toggle state
227 * @param data application context
229 * @return 0 for success
232 int get_ledindicator_ug_charging_state(Cfg_Item_State* stat, void* data)
237 int ret = vconf_get_bool(VCONFKEY_SETAPPL_LED_INDICATOR_CHARGING, &value);
242 *stat = Cfg_Item_Off;
248 * @brief set toggle state for "charging"
250 * @param stat the toggle state will be set
251 * @param data application context
253 * @return 0 for success
256 int set_ledindicator_ug_charging_state(Cfg_Item_State stat, void* item, void* data)
261 if (stat == Cfg_Item_On){
263 }else if (stat == Cfg_Item_Off){
268 int ret = vconf_set_bool(VCONFKEY_SETAPPL_LED_INDICATOR_CHARGING, value);
273 * @brief get toggle state for "low battery"
275 * @param stat store the toggle state
276 * @param data application context
278 * @return 0 for success
281 int get_ledindicator_ug_low_battery_state(Cfg_Item_State* stat, void* data)
286 int ret = vconf_get_bool(VCONFKEY_SETAPPL_LED_INDICATOR_LOW_BATT, &value);
291 *stat = Cfg_Item_Off;
297 * @brief set toggle state for "low_battery"
299 * @param stat the toggle state will be set
300 * @param data application context
302 * @return 0 for success
305 int set_ledindicator_ug_low_battery_state(Cfg_Item_State stat, void* item, void* data)
310 if (stat == Cfg_Item_On){
312 }else if (stat == Cfg_Item_Off){
317 int ret = vconf_set_bool(VCONFKEY_SETAPPL_LED_INDICATOR_LOW_BATT, value);
322 * @brief get toggle state for "notifications"
324 * @param stat store the toggle state
325 * @param data application context
327 * @return 0 for success
330 int get_ledindicator_ug_notifications_state(Cfg_Item_State* stat, void* data)
335 int ret = vconf_get_bool(VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS, &value);
340 *stat = Cfg_Item_Off;
346 * @brief set toggle state for "notifications"
348 * @param stat the toggle state will be set
349 * @param data application context
351 * @return 0 for success
354 int set_ledindicator_ug_notifications_state(Cfg_Item_State stat, void* item, void* data)
359 if (stat == Cfg_Item_On){
361 }else if (stat == Cfg_Item_Off){
366 int ret = vconf_set_bool(VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS, value);
371 * @brief get toggle state for "voice recording"
373 * @param stat store the toggle state
374 * @param data application context
376 * @return 0 for success
379 int get_ledindicator_ug_voice_recording_state(Cfg_Item_State* stat, void* data)
384 int ret = vconf_get_bool(VCONFKEY_SETAPPL_LED_INDICATOR_VOICE_REC, &value);
389 *stat = Cfg_Item_Off;
395 * @brief set toggle state for "notifications"
397 * @param stat the toggle state will be set
398 * @param data application context
400 * @return 0 for success
403 int set_ledindicator_ug_voice_recording_state(Cfg_Item_State stat, void* item, void* data)
408 if (stat == Cfg_Item_On){
410 }else if (stat == Cfg_Item_Off){
415 int ret = vconf_set_bool(VCONFKEY_SETAPPL_LED_INDICATOR_VOICE_REC, value);
421 * @brief function table for searchable menu item "charging"
423 * @see the struct cfg_func_table defination
426 cfg_func_table opt_tab_charging = {
427 .get_item_state = get_ledindicator_ug_charging_state,
428 .set_item_state = set_ledindicator_ug_charging_state,
429 .set_item_update_ui = NULL,
433 * @brief function table for searchable menu item "low battery"
435 * @see the struct cfg_func_table defination
439 cfg_func_table opt_tab_low_batt = {
440 .get_item_state = get_ledindicator_ug_low_battery_state,
441 .set_item_state = set_ledindicator_ug_low_battery_state,
442 .set_item_update_ui = NULL,
446 * @brief function table for searchable menu item "notifications"
448 * @see the struct cfg_func_table defination
452 cfg_func_table opt_tab_noti = {
453 .get_item_state = get_ledindicator_ug_notifications_state,
454 .set_item_state = set_ledindicator_ug_notifications_state,
455 .set_item_update_ui = NULL,
459 * @brief function table for searchable menu item "voice recording"
461 * @see the struct cfg_func_table defination
465 cfg_func_table opt_tab_voice_rec = {
466 .get_item_state = get_ledindicator_ug_voice_recording_state,
467 .set_item_state = set_ledindicator_ug_voice_recording_state,
468 .set_item_update_ui = NULL,
473 * @brief get the operation function table for searchable menu items
475 * @param str_id key string for searchable menu items
476 * @param tfunc_obj application context
478 * @return 0 for success
480 UG_MODULE_API int setting_plugin_search_query_ops(char* str_id, void** tfunc_obj)
483 SETTING_TRACE(">> get tfunc operation via plugin-model 1");
484 if (str_id && !safeStrCmp(str_id, _("IDS_ST_MBODY_CHARGING"))) {
485 *tfunc_obj = (void*)&opt_tab_charging;
486 }else if(str_id && !safeStrCmp(str_id, _("IDS_ST_BODY_LEDOT_LOW_BATTERY"))){
487 *tfunc_obj = (void*)&opt_tab_low_batt;
488 }else if(str_id && !safeStrCmp(str_id, _("IDS_ST_BODY_NOTIFICATIONS"))){
489 *tfunc_obj = (void*)&opt_tab_noti;
490 }else if(str_id && !safeStrCmp(str_id, _("IDS_ST_BODY_VOICE_RECORDING"))){
491 *tfunc_obj = (void*)&opt_tab_voice_rec;
493 SETTING_TRACE(">> get tfunc operation via plugin-model 2");