Remove trivial unnecessary build dependency
[apps/core/preloaded/lockscreen.git] / src / camera_ctrl.c
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <Ecore.h>
18
19 #include "log.h"
20 #include "camera_ctrl.h"
21 #include "camera.h"
22 #include "camera_view.h"
23 #include "main_view.h"
24
25 static Ecore_Event_Handler *handler;
26 static Evas_Object *main_view;
27
28 static void _camera_clicked(void *data, Evas_Object *obj, void *event)
29 {
30         lockscreen_camera_activate();
31 }
32
33 static void _camera_view_update()
34 {
35         Evas_Object *cam_view;
36
37         if (lockscreen_camera_is_on()) {
38                 cam_view = lockscreen_camera_view_create(main_view);
39                 evas_object_smart_callback_add(cam_view, SIGNAL_CAMERA_SELECTED, _camera_clicked, NULL);
40                 lockscreen_main_view_part_content_set(main_view, PART_CAMERA, cam_view);
41         }
42         else {
43                 cam_view = lockscreen_main_view_part_content_unset(main_view, PART_CAMERA);
44                 evas_object_del(cam_view);
45         }
46 }
47
48 static Eina_Bool _cam_status_changed(void *data, int event, void *event_info)
49 {
50         _camera_view_update();
51         return EINA_TRUE;
52 }
53
54 int lockscreen_camera_ctrl_init(Evas_Object *view)
55 {
56         if (lockscreen_camera_init()) {
57                 ERR("lockscreen_camera_init failed");
58                 return 1;
59         }
60
61         handler = ecore_event_handler_add(LOCKSCREEN_EVENT_CAMERA_STATUS_CHANGED, _cam_status_changed, NULL);
62         if (!handler)
63                 FAT("ecore_event_handler_add failed on LOCKSCREEN_EVENT_BATTERY_CHANGED event");
64         main_view = view;
65         _camera_view_update();
66
67         return 0;
68 }
69
70 void lockscreen_camera_ctrl_fini(void)
71 {
72         Evas_Object *cam_view = lockscreen_main_view_part_content_get(main_view, PART_CAMERA);
73         if (cam_view) evas_object_smart_callback_del(cam_view, SIGNAL_CAMERA_SELECTED, _camera_clicked);
74         ecore_event_handler_del(handler);
75         lockscreen_camera_shutdown();
76 }