Apply screen reader for unlocking lockscreen.
[apps/home/lockscreen.git] / src / lockscreen.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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
18 #include <app.h>
19 #include <vconf.h>
20 #include <Ecore_X.h>
21 #include <system_info.h>
22
23 #include "lockscreen.h"
24 #include "util.h"
25
26 #define QP_EMUL_STR      "Emulator"
27
28 static void win_del(void *data, Evas_Object * obj, void *event)
29 {
30         elm_exit();
31 }
32
33 static Evas_Object *create_win(const char *name)
34 {
35         if (name == NULL)
36                 return NULL;
37
38         Evas_Object *eo;
39         int w, h;
40
41         eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
42         if (!eo) {
43                 LOGE("[%s:%d] eo is NULL", __func__, __LINE__);
44                 return NULL;
45         }
46
47         elm_win_title_set(eo, name);
48         elm_win_borderless_set(eo, EINA_TRUE);
49         evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
50         ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
51         evas_object_resize(eo, w, h);
52         elm_win_alpha_set(eo, EINA_TRUE);
53
54         return eo;
55 }
56
57 static void resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
58 {
59         Evas_Coord w;
60         Evas_Coord h;
61
62         evas_object_geometry_get(obj, NULL, NULL, &w, &h);
63 }
64
65 static int _check_emul()
66 {
67         int is_emul = 0;
68         char *info = NULL;
69
70         if (system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &info) == 0) {
71                 if (info == NULL) return 0;
72                 if (!strncmp(QP_EMUL_STR, info, strlen(info))) {
73                         is_emul = 1;
74                 }
75         }
76
77         if (info != NULL) free(info);
78
79         return is_emul;
80 }
81
82 static bool app_create(void *data)
83 {
84         struct appdata *ad = data;
85         LOGD("[ == %s == ]", __func__);
86         if (ad == NULL)
87                 return false;
88
89         ad->win = NULL;
90         ad->ly_main = NULL;
91         ad->ao_bg = NULL;
92         ad->info = NULL;
93         ad->event_bg = NULL;
94         ad->slider = NULL;
95         ad->bDrag = 0;
96
97         Evas_Object *win = NULL;
98
99         ecore_x_window_size_get(ecore_x_window_root_first_get(), &ad->win_w, &ad->win_h);
100         LOGD("[%s:%d] win_w : %d, win_h : %d", __func__, __LINE__, ad->win_w, ad->win_h);
101
102         win = create_win(PACKAGE);
103         if (win == NULL)
104                 return false;
105         ad->win = win;
106         elm_win_conformant_set(ad->win, EINA_TRUE);
107         evas_object_resize(win, ad->win_w, ad->win_h);
108         evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, resize_cb, NULL);
109
110         int ret = _app_create(ad);
111         if(ret == -1)
112                 return false;
113
114         return true;
115 }
116
117 static void app_service(service_h service, void *data)
118 {
119         struct appdata *ad = data;
120         LOGD("[ == %s == ]", __func__);
121         if (ad == NULL)
122                 return;
123
124         if (ad->win)
125                 elm_win_activate(ad->win);
126
127         _app_reset(ad);
128 }
129
130 static void app_terminate(void *data)
131 {
132         struct appdata *ad = data;
133         LOGD("[ == %s == ]", __func__);
134         if (ad == NULL)
135                 return;
136
137         if (ad->ly_main)
138                 evas_object_del(ad->ly_main);
139
140         if (ad->win)
141                 evas_object_del(ad->win);
142 }
143
144 static void app_pause(void *data)
145 {
146         struct appdata *ad = data;
147         LOGD("[ == %s == ]", __func__);
148         if (ad == NULL)
149                 return;
150 }
151
152 static void app_resume(void *data)
153 {
154         struct appdata *ad = data;
155         LOGD("[ == %s == ]", __func__);
156         if (ad == NULL)
157                 return;
158 }
159
160 static void device_orientation(app_device_orientation_e orientation, void * data)
161 {
162         struct appdata *ad = data;
163         LOGD("[ == %s == ]", __func__);
164         if (ad == NULL || ad->win == NULL)
165                 return;
166 }
167
168 int main(int argc, char *argv[])
169 {
170         struct appdata ad;
171
172         app_event_callback_s event_callback;
173
174         event_callback.create = app_create;
175         event_callback.terminate = app_terminate;
176         event_callback.pause = app_pause;
177         event_callback.resume = app_resume;
178         event_callback.service = app_service;
179         event_callback.low_memory = NULL;
180         event_callback.low_battery = NULL;
181         event_callback.device_orientation = device_orientation;
182         event_callback.language_changed = NULL;
183         event_callback.region_format_changed = NULL;
184
185         memset(&ad, 0x0, sizeof(struct appdata));
186
187         if(!_check_emul()) {
188                 setenv("ELM_ENGINE", "gl", 1);
189         }
190
191         return app_efl_main(&argc, &argv, &event_callback, &ad);
192 }