2 * Copyright (c) 2016 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 "main_ctrl.h"
19 #include "main_view.h"
21 #include "battery_ctrl.h"
22 #include "background.h"
23 #include "camera_ctrl.h"
24 #include "time_format_ctrl.h"
28 #include "events_ctrl.h"
30 #include <Elementary.h>
33 static Evas_Object *win;
34 static Evas_Object *view;
36 static void _view_unlocked(void *data, Evas_Object *obj, void *event)
41 static void _swipe_finished(void *data, Evas_Object *obj, void *event)
43 /* When swipe finished play unlock animation and exit */
44 evas_object_smart_callback_add(obj, SIGNAL_UNLOCK_ANIMATION_FINISHED, _view_unlocked, NULL);
45 lockscreen_main_view_unlock(obj);
48 static Eina_Bool _lockscreen_main_ctrl_win_event_cb(void *data, Evas_Object *obj, Evas_Object *source, Evas_Callback_Type type, void *event_info)
50 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_TRUE;
51 Evas_Event_Key_Down *ev = event_info;
53 if (!strcmp(ev->key, "XF86PowerOff") || !strcmp(ev->key, "XF86Menu")) {
54 lockscreen_time_format_ctrl_time_update();
56 else if (!strcmp(ev->key, "XF86Back")) {
57 util_feedback_tap_play();
63 static void _lockcscreen_main_ctrl_win_touch_start_cb(void *data, Evas_Object *obj, void *event_info)
65 lockscreen_display_timer_freeze();
68 static void _lockcscreen_main_ctrl_win_touch_end_cb(void *data, Evas_Object *obj, void *event_info)
70 lockscreen_display_timer_renew();
73 int lockscreen_main_ctrl_init(void)
75 win = lockscreen_window_create();
77 FAT("elm_win_add failed.");
79 view = lockscreen_main_view_create(win);
81 FAT("lockscreen_main_view_create failed.");
83 if (lockscreen_background_init()) {
84 FAT("lockscreen_background_init failed. Background changes will not be available");
86 if (!lockscreen_main_view_background_set(view, LOCKSCREEN_BACKGROUND_TYPE_DEFAULT, lockscreen_background_file_get()))
87 FAT("lockscreen_main_view_background_image_set failed");
90 if (lockscreen_display_init()) {
91 FAT("lockscreen_display_init failed. Display on/off changes will not be available.");
93 evas_object_smart_callback_add(win, SIGNAL_TOUCH_STARTED, _lockcscreen_main_ctrl_win_touch_start_cb, NULL);
94 evas_object_smart_callback_add(win, SIGNAL_TOUCH_ENDED, _lockcscreen_main_ctrl_win_touch_end_cb, NULL);
97 lockscreen_window_content_set(view);
98 evas_object_smart_callback_add(view, SIGNAL_SWIPE_GESTURE_FINISHED, _swipe_finished, NULL);
99 elm_object_event_callback_add(win, _lockscreen_main_ctrl_win_event_cb, NULL);
101 // init subcontrollers
102 if (lock_battery_ctrl_init(view))
103 FAT("lock_battery_ctrl_init failed. Battery information will not be available");
105 if (lockscreen_camera_ctrl_init(view))
106 FAT("lockscreen_camera_ctrl_init failed. Camera quickshot will not be available");
108 if (lockscreen_time_format_ctrl_init(view))
109 FAT("lockscreen_time_format_ctrl_init failed. Time format changes will not be available");
111 if (lockscreen_sim_ctrl_init(view))
112 FAT("lockscreen_sim_ctrl_init failed. Sim PLMN updates will not be available");
114 if (lockscreen_events_ctrl_init(view))
115 FAT("lockscreen_events_ctrl_init failed. Lockscreen events will not be displayed");
120 void lockscreen_main_ctrl_shutdown(void)
122 lockscreen_background_shutdown();
123 evas_object_del(win);