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 "time_format.h"
20 #include "main_view.h"
25 static Ecore_Event_Handler *handler, *display_handler;
26 static Ecore_Timer *update_timer;
27 static Evas_Object *main_view;
29 static void _time_update(void)
31 lockscreen_main_view_time_set(main_view, lockscreen_time_format_locale_get(),
32 lockscreen_time_format_timezone_get(), lockscreen_time_format_use_24h(), time(NULL));
35 static Eina_Bool _timer_cb(void *data)
38 ecore_timer_interval_set(update_timer, 60.0);
39 return ECORE_CALLBACK_RENEW;
42 static void _time_spawn_align(void)
48 localtime_r(&tt, &st);
50 ecore_timer_interval_set(update_timer, 60 - st.tm_sec);
53 static Eina_Bool _time_changed(void *data, int event, void *event_info)
60 static Eina_Bool _display_status_changed(void *data, int event, void *event_info)
62 if (lockscreen_display_is_off()) {
63 if (update_timer) ecore_timer_freeze(update_timer);
72 int lockscreen_time_format_ctrl_init(Evas_Object *view)
74 if (lockscreen_display_init()) {
75 FAT("lockscreen_display_init failed");
79 if (lockscreen_time_format_init()) {
80 lockscreen_display_shutdown();
81 FAT("lockscreen_time_format_init failed");
85 handler = ecore_event_handler_add(LOCKSCREEN_EVENT_TIME_FORMAT_CHANGED, _time_changed, NULL);
87 FAT("ecore_event_handler_add failed on LOCKSCREEN_DATA_MODEL_EVENT_TIME_FORMAT_CHANGED event");
88 display_handler = ecore_event_handler_add(LOCKSCREEN_EVENT_DISPLAY_STATUS_CHANGED, _display_status_changed, NULL);
90 FAT("ecore_event_handler_add failed on LOCKSCREEN_DATA_MODEL_EVENT_LCD_STATUS_CHANGED event");
92 update_timer = ecore_timer_add(60.0, _timer_cb, NULL);
99 void lockscreen_time_ctrl_shutdown(void)
101 ecore_timer_del(update_timer);
102 ecore_event_handler_del(handler);
103 ecore_event_handler_del(display_handler);
104 lockscreen_display_shutdown();
105 lockscreen_time_format_shutdown();
108 void lockscreen_time_format_ctrl_time_update(void)