quickpanel open problem in lockscreen
[apps/home/draglock.git] / src / draglock.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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.tizenopensource.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 #include <stdio.h>
18 #include <app.h>
19 #include <Ecore_X.h>
20 #include <utilX.h>
21 #include "draglock.h"
22 #include "draglock-ui.h"
23 #include "draglock-util.h"
24
25 static void device_orientation(app_device_orientation_e orientation,
26                 void *user_data) {
27         struct appdata *ad = (struct appdata *) user_data;
28
29         if (ad == NULL || ad->win == NULL)
30                 return;
31 }
32
33 static bool app_create(void *user_data) {
34         struct appdata *ad = (struct appdata *) user_data;
35         Evas_Object *win;
36         Evas_Object *bg;
37         char *name;
38
39         DRAGLOCK_DBG("launching draglock");
40
41         if (ad == NULL) {
42                 return FALSE;
43         }
44
45         ecore_x_window_size_get(ecore_x_window_root_first_get(), &ad->win_w,
46                         &ad->win_h);
47         DRAGLOCK_DBG("window size(%d,%d)", ad->win_w, ad->win_h);
48
49         draglock_init_svi(&ad->sound_handle);
50         draglock_play_sound(ad->sound_handle, 0);
51
52         /* create window */
53         app_get_name(&name);
54
55         win = draglock_util_add_window(name);
56         if (win == NULL)
57                 return FALSE;
58         ad->win = win;
59
60         ecore_x_icccm_name_class_set(elm_win_xwindow_get(ad->win),"LOCK_SCREEN", "LOCK_SCREEN");
61
62         utilx_set_window_effect_state(ecore_x_display_get(),elm_win_xwindow_get(ad->win), 0);
63
64         evas_object_show(win);
65
66         ad->scale = elm_scale_get();
67
68         bg = draglock_util_add_bg(win);
69
70         draglock_ui_create(ad);
71
72         free(name);
73
74         return TRUE;
75 }
76
77 static void app_terminate(void *user_data) {
78         struct appdata *ad = (struct appdata *) user_data;
79
80         if (ad == NULL) {
81                 return;
82         }
83
84         draglock_play_sound(ad->sound_handle, 1);
85         draglock_fini_svi(ad->sound_handle);
86
87         draglock_ui_destroy(ad);
88
89         if (ad->win)
90                 evas_object_del(ad->win);
91 }
92
93 static void app_pause(void *user_data) {
94         struct appdata *ad = (struct appdata *) user_data;
95         (void) ad;
96 }
97
98 static void app_resume(void *user_data) {
99         struct appdata *ad = (struct appdata *) user_data;
100         (void) ad;
101 }
102
103 static void app_service(service_h service, void *user_data) {
104         struct appdata *ad = (struct appdata *) user_data;
105
106         if (ad == NULL) {
107                 return;
108         }
109
110         if (ad->win)
111                 elm_win_activate(ad->win);
112 }
113
114 int main(int argc, char *argv[]) {
115         struct appdata ad;
116
117         app_event_callback_s event_callback;
118
119         event_callback.create = app_create;
120         event_callback.terminate = app_terminate;
121         event_callback.pause = app_pause;
122         event_callback.resume = app_resume;
123         event_callback.service = app_service;
124         event_callback.low_memory = NULL;
125         event_callback.low_battery = NULL;
126         event_callback.device_orientation = device_orientation;
127         event_callback.language_changed = NULL;
128         event_callback.region_format_changed = NULL;
129
130         memset(&ad, 0x0, sizeof(struct appdata));
131
132         return app_efl_main(&argc, &argv, &event_callback, &ad);
133 }