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.
20 #include "camera_ctrl.h"
22 #include "camera_view.h"
23 #include "main_view.h"
25 static Ecore_Event_Handler *handler;
26 static Evas_Object *main_view;
28 static void _camera_clicked(void *data, Evas_Object *obj, void *event)
30 lockscreen_camera_activate();
33 static void _camera_view_update()
35 Evas_Object *cam_view;
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);
43 cam_view = lockscreen_main_view_part_content_unset(main_view, PART_CAMERA);
44 evas_object_del(cam_view);
48 static Eina_Bool _cam_status_changed(void *data, int event, void *event_info)
50 _camera_view_update();
54 int lockscreen_camera_ctrl_init(Evas_Object *view)
56 if (lockscreen_camera_init()) {
57 ERR("lockscreen_camera_init failed");
61 handler = ecore_event_handler_add(LOCKSCREEN_EVENT_CAMERA_STATUS_CHANGED, _cam_status_changed, NULL);
63 FAT("ecore_event_handler_add failed on LOCKSCREEN_EVENT_BATTERY_CHANGED event");
65 _camera_view_update();
70 void lockscreen_camera_ctrl_fini(void)
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();