2 * Copyright (c) 2000 - 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.
17 #include <app_control.h>
21 #include "lock_pwd_util.h"
22 #include "lock_pwd_control_panel.h"
24 #define EMG_CALL_LABEL_STYLE_START "<style=far_shadow,bottom><shadow_color=#00000033><font_size=28><align=left><color=#FFFFFF><wrap=none>"
25 #define EMG_CALL_LABEL_STYLE_END "</wrap></color></align></font_size></shadow_color></style>"
26 #define EMG_BTN_WIDTH 280
28 static struct _s_lock_pwd_control_panel {
29 Evas_Object *control_panel_layout;
30 Evas_Object *emg_call_btn;
31 Evas_Object *cancel_btn;
32 } s_lock_pwd_control_panel = {
33 .control_panel_layout = NULL,
40 static void _emg_call_btn_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
43 app_control_h service;
44 Evas_Object *lock_pwd_win = NULL;
46 lock_pwd_win = lock_pwd_util_win_get();
47 ret_if(!lock_pwd_win);
49 app_control_create(&service);
52 lock_mgr_sound_play(LOCK_SOUND_TAP);
54 if (APP_CONTROL_ERROR_NONE != app_control_set_operation(service, APP_CONTROL_OPERATION_DEFAULT)) {
55 _E("Failed to set operation for app control handle");
59 //@TODO: need to check appid
60 if (APP_CONTROL_ERROR_NONE != app_control_set_app_id(service, "dialer-efl")) {
61 _E("Failed to launch dialer-efl");
65 app_control_add_extra_data(service, "emergency_dialer", "emergency");
67 if (APP_CONTROL_ERROR_NONE != app_control_send_launch_request(service, NULL, NULL)) {
68 _E("Failed to send launch request");
71 app_control_destroy(service);
76 _E("Failed to launch emergency call");
78 if (service) app_control_destroy(service);
83 static void _sliding_label_mode_set(Evas_Object *label)
85 Evas_Object *label_edje = NULL;
86 Evas_Object *tb = NULL;
91 elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_NONE);
93 label_edje = elm_layout_edje_get(label);
96 tb = (Evas_Object *)edje_object_part_object_get(label_edje, "elm.text");
99 evas_object_textblock_size_native_get(tb, &tb_w, NULL);
100 _D("tb width(%d), label width(%f)", tb_w, ELM_SCALE_SIZE(EMG_BTN_WIDTH));
102 if ((tb_w > 0) && (tb_w > ELM_SCALE_SIZE(EMG_BTN_WIDTH))) {
103 elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO);
106 elm_label_slide_go(label);
110 static Evas_Object *_sliding_label_create(Evas_Object *parent, const char *text)
112 char buf[BUF_SIZE_512] = { 0, };
113 char *markup_txt = NULL;
114 Evas_Object *label = NULL;
116 retv_if(!parent, NULL);
118 label = elm_label_add(parent);
119 retv_if(!label, NULL);
121 markup_txt = elm_entry_utf8_to_markup(text);
122 snprintf(buf, sizeof(buf), "%s%s%s", EMG_CALL_LABEL_STYLE_START, markup_txt, EMG_CALL_LABEL_STYLE_END);
125 elm_object_style_set(label, "slide_short");
126 elm_label_wrap_width_set(label, EMG_BTN_WIDTH);
127 elm_label_slide_duration_set(label, 2);
128 elm_object_text_set(label, buf);
129 evas_object_show(label);
131 _sliding_label_mode_set(label);
138 static Evas_Object *_emg_call_btn_create(Evas_Object *parent)
140 Evas_Object *btn = NULL;
142 retv_if(!parent, NULL);
144 btn = _sliding_label_create(parent, _("IDS_LCKSCN_BODY_EMERGENCY_CALL"));
147 elm_object_signal_callback_add(parent, "emg_button", "clicked", _emg_call_btn_clicked_cb, NULL);
149 s_lock_pwd_control_panel.emg_call_btn = btn;
155 void lock_pwd_control_panel_emg_btn_text_update(void)
157 char buf[BUF_SIZE_512] = { 0, };
158 char *markup_txt = NULL;
160 ret_if(!s_lock_pwd_control_panel.emg_call_btn);
162 markup_txt = elm_entry_utf8_to_markup(_("IDS_LCKSCN_BODY_EMERGENCY_CALL"));
163 snprintf(buf, sizeof(buf), "%s%s%s", EMG_CALL_LABEL_STYLE_START, markup_txt, EMG_CALL_LABEL_STYLE_END);
166 elm_object_text_set(s_lock_pwd_control_panel.emg_call_btn, buf);
171 void lock_pwd_control_panel_cancel_btn_enable_set(Eina_Bool enable)
173 ret_if(!s_lock_pwd_control_panel.control_panel_layout);
176 elm_object_signal_emit(s_lock_pwd_control_panel.control_panel_layout, "button3,enable", "prog");
178 elm_object_signal_emit(s_lock_pwd_control_panel.control_panel_layout, "button3,disable", "prog");
184 static void _cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
187 lock_mgr_sound_play(LOCK_SOUND_TAP);
189 if (!lock_mgr_lockscreen_launch()) {
190 _E("Failed to launch lockscreen");
193 lock_pwd_util_view_init();
198 static Evas_Object *_cancel_btn_create(Evas_Object *parent)
200 Evas_Object *btn = NULL;
202 retv_if(!parent, NULL);
204 btn = elm_button_add(parent);
207 elm_theme_extension_add(NULL, LOCK_PWD_BTN_EDJE_FILE);
209 elm_object_style_set(btn, "right_button");
210 elm_object_domain_translatable_text_set(btn, PACKAGE, "IDS_COM_BUTTON_CANCEL");
211 evas_object_smart_callback_add(btn, "clicked", (Evas_Smart_Cb)_cancel_btn_clicked_cb, NULL);
213 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
215 evas_object_show(btn);
217 s_lock_pwd_control_panel.cancel_btn = btn;
224 Evas_Object *lock_pwd_control_panel_create(Evas_Object *parent)
226 Evas_Object *control_panel_layout = NULL;
227 Evas_Object *cancel_btn = NULL;
228 Evas_Object *emg_call_btn = NULL;
230 retv_if(!parent, NULL);
232 control_panel_layout = elm_layout_add(parent);
233 retv_if(!control_panel_layout, NULL);
235 if (!elm_layout_file_set(control_panel_layout, LOCK_PWD_EDJE_FILE, "lock-control-panel")) {
236 _E("Failed to set edje file : %s", LOCK_PWD_EDJE_FILE);
239 s_lock_pwd_control_panel.control_panel_layout = control_panel_layout;
241 evas_object_size_hint_weight_set(control_panel_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
242 evas_object_size_hint_align_set(control_panel_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
244 /* create emg call button */
245 emg_call_btn = _emg_call_btn_create(control_panel_layout);
247 _E("Failed to create operator button");
249 elm_object_part_content_set(control_panel_layout, "button1", emg_call_btn);
252 /* create cancel button */
253 cancel_btn = _cancel_btn_create(control_panel_layout);
255 _E("Failed to create cancel button");
257 elm_object_part_content_set(control_panel_layout, "button3", cancel_btn);
260 evas_object_show(control_panel_layout);
262 return control_panel_layout;
265 _E("Failed to create password control panel");
267 if (control_panel_layout) {
268 evas_object_del(control_panel_layout);
269 s_lock_pwd_control_panel.control_panel_layout = NULL;
275 void lock_pwd_control_panel_del(void)
277 if (s_lock_pwd_control_panel.cancel_btn) {
278 evas_object_smart_callback_del(s_lock_pwd_control_panel.cancel_btn, "clicked", (Evas_Smart_Cb)_cancel_btn_clicked_cb);
279 evas_object_del(s_lock_pwd_control_panel.cancel_btn);
280 s_lock_pwd_control_panel.cancel_btn = NULL;
283 if (s_lock_pwd_control_panel.emg_call_btn) {
284 elm_object_signal_callback_del(s_lock_pwd_control_panel.control_panel_layout, "emg_button", "clicked", _emg_call_btn_clicked_cb);
285 evas_object_del(s_lock_pwd_control_panel.emg_call_btn);
286 s_lock_pwd_control_panel.emg_call_btn = NULL;
289 if (s_lock_pwd_control_panel.control_panel_layout) {
290 evas_object_del(s_lock_pwd_control_panel.control_panel_layout);
291 s_lock_pwd_control_panel.control_panel_layout = NULL;
295 void lock_pwd_control_panel_pause(void)
297 if (s_lock_pwd_control_panel.emg_call_btn) {
298 elm_label_slide_mode_set(s_lock_pwd_control_panel.emg_call_btn, ELM_LABEL_SLIDE_MODE_NONE);
299 elm_label_slide_go(s_lock_pwd_control_panel.emg_call_btn);
303 void lock_pwd_control_panel_resume(void)
305 if (s_lock_pwd_control_panel.emg_call_btn) {
306 elm_label_slide_mode_set(s_lock_pwd_control_panel.emg_call_btn, ELM_LABEL_SLIDE_MODE_AUTO);
307 elm_label_slide_go(s_lock_pwd_control_panel.emg_call_btn);