2 * Copyright (c) 2009-2015 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 #include <Elementary.h>
21 #include <device/led.h>
24 #include <tzsh_quickpanel_service.h>
27 #include "quickpanel-ui.h"
29 #include "setting_utils.h"
30 #include "setting_module_api.h"
32 #define E_DATA_POPUP_MODULE_ITEM "mobule_item"
33 #define BUTTON_LABEL _("IDS_ST_BUTTON2_TORCH_ABB")
34 #define BUTTON_ICON_NORMAL "quick_icon_torch.png"
36 static void _status_update(QP_Module_Setting *module, int light_status, int flag_extra_2);
38 static const char *_label_get(void)
43 static void _on_vconf_assetive_light_changed(keynode_t *node, void *user_data)
45 Eina_Bool mode = EINA_FALSE;
54 quickpanel_setting_module_icon_state_set(user_data, mode);
55 _status_update(user_data, mode, FLAG_VALUE_VOID);
58 static int _init(void *data)
60 vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, _on_vconf_assetive_light_changed, data);
65 static void _set_assetive_light_mode(Eina_Bool mode)
68 int ret = device_flash_get_max_brightness(&max_brightness);
71 ERR("TORCH LIGHT CHANGE: ret != 0 -> %d", ret);
74 ERR("TORCH LIGHT OK[%d]", max_brightness);
79 if(mode == EINA_TRUE) {
80 ret_set = device_flash_set_brightness(max_brightness);
82 ERR("Failed to set brightness(%d)[%d]", max_brightness, ret_set);
84 if (vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, 1) < 0) {
85 ERR("Failed to set tourch light vconf key");
89 ret_set = device_flash_set_brightness(0);
91 ERR("Failed to set brightness(0)[%d]", ret_set);
93 if (vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, 0) < 0) {
94 ERR("Failed to set tourch light vconf key");
100 static void _view_update(Evas_Object *view, int state, int flag_extra_1, int flag_extra_2)
102 Evas_Object *image = NULL;
103 const char *icon_path = NULL;
105 quickpanel_setting_icon_state_set(view, state);
106 icon_path = BUTTON_ICON_NORMAL;
107 image = quickpanel_setting_icon_image_new(view, icon_path);
108 quickpanel_setting_icon_content_set(view, image);
109 quickpanel_setting_icon_text_set(view, BUTTON_LABEL, state);
112 static void _status_update(QP_Module_Setting *module, int light_status, int flag_extra_2)
115 retif(module == NULL, , "Invalid parameter!");
118 ret = device_flash_get_brightness(&brightness);
120 ERR("Failed to get brightness[%d]", ret);
123 if (brightness > 0) {
124 quickpanel_setting_module_icon_state_set(module, ICON_VIEW_STATE_ON);
126 quickpanel_setting_module_icon_state_set(module, ICON_VIEW_STATE_OFF);
129 quickpanel_setting_module_icon_view_update(module,
130 quickpanel_setting_module_icon_state_get(module), FLAG_VALUE_VOID);
133 static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
135 QP_Module_Setting *module = (QP_Module_Setting *)data;
136 retif(module == NULL, , "Invalid parameter!");
138 if (quickpanel_setting_module_icon_state_get(module) == ICON_VIEW_STATE_ON) {
139 _set_assetive_light_mode(FLAG_TURN_OFF);
141 _set_assetive_light_mode(FLAG_TURN_ON);
144 _status_update(module, FLAG_VALUE_VOID, FLAG_VALUE_VOID);
147 static void _lang_changed(void *data)
149 QP_Module_Setting *module = (QP_Module_Setting *) data;
150 retif(module == NULL, , "Invalid parameter!");
152 quickpanel_setting_module_icon_view_update_text(module);
155 static void _refresh(void *data)
157 QP_Module_Setting *module = (QP_Module_Setting *)data;
158 retif(module == NULL, , "Invalid parameter!");
160 quickpanel_setting_module_icon_view_update_text(module);
163 static int _fini(void *data)
168 QP_Module_Setting assistive_light =
170 .name = "assisitvelight",
173 .lang_changed = _lang_changed,
176 .label_get = _label_get,
177 .supported_get = NULL,
178 .view_update = _view_update,
179 .status_update = _status_update,
180 .handler_longpress = NULL,
181 .handler_press = _mouse_clicked_cb,