bd53fb305af07a28f078545efa418b0d6eb65edd
[apps/core/preloaded/pwlock.git] / src / ui-callback.c
1 /*
2  *  pwlock
3  *
4  * Copyright 2012  Samsung Electronics Co., Ltd
5  *
6  * Licensed under the Flora License, Version 1.1 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://floralicense.org/license/
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include <Ecore_X.h>
21 #include <ui-gadget.h>
22 #include <vconf.h>
23
24 #include "pwlock.h"
25 #include "util.h"
26 #include "ui-callback.h"
27
28 void pwlock_greeting_next_cb(void *data, Evas_Object *obj, void *e) {
29         _DBG("%s,%d", __func__, __LINE__);
30         struct appdata *ad = data;
31
32         if (!ad)
33                 return;
34
35         ad->btn_evt_state = BUTTON_STATE_NEXT_CLICKED;
36
37         if (ad->is_no_sim == 1) {
38                 do_state_directly(_ST_NOSIM, ad);
39         } else {
40                 do_state_directly(_ST_TIME, ad);
41         }
42 }
43
44 void pwlock_nosim_prev_cb(void *data, Evas_Object * obj, void *e) {
45         _DBG("%s,%d", __func__, __LINE__);
46         struct appdata *ad = data;
47
48         if (!ad)
49                 return;
50
51         ad->btn_evt_state = BUTTON_STATE_PREV_CLICKED;
52         do_state_directly(_ST_GREETING, ad);
53 }
54
55 void pwlock_nosim_skip_cb(void *data, Evas_Object * obj, void *e) {
56         _DBG("%s,%d", __func__, __LINE__);
57         struct appdata *ad = data;
58
59         if (!ad)
60                 return;
61
62         ad->btn_evt_state = BUTTON_STATE_NEXT_CLICKED;
63         do_state_directly(_ST_TIME, ad);
64 }
65
66 void pwlock_tutorial_prev_cb(void *data, Evas_Object *obj, void *e) {
67         _DBG("%s,%d", __func__, __LINE__);
68         struct appdata *ad = data;
69
70         if (!ad)
71                 return;
72
73         ad->btn_evt_state = BUTTON_STATE_PREV_CLICKED;
74         do_state_directly(_ST_CONNECTION, ad);
75 }
76
77 void pwlock_tutorial_next_cb(void *data, Evas_Object *obj, void *e) {
78         _DBG("%s,%d", __func__, __LINE__);
79         struct appdata *ad = data;
80
81         if (!ad)
82                 return;
83
84         ad->btn_evt_state = BUTTON_STATE_NEXT_CLICKED;
85         do_state_directly(_ST_EXIT, ad);
86 }
87
88 void pwlock_ug_connection_layout_cb(ui_gadget_h ug, enum ug_mode mode,
89                 void *priv) {
90         struct appdata *ad = (struct appdata *) priv;
91         Evas_Object *base;
92         _DBG("%s begin", __func__);
93         if (!ug || !priv)
94                 return;
95
96         base = (Evas_Object *) ug_get_layout(ug);
97         if (!base) {
98                 _DBG("base layout null!\n");
99                 return;
100         }
101
102         _DBG("%s,%d", __func__, __LINE__);
103         //ad->btn_evt_state = BUTTON_STATE_NONE;
104         switch (mode) {
105         case UG_MODE_FULLVIEW:
106                 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
107                                 EVAS_HINT_EXPAND);
108                 elm_win_resize_object_add(ug_get_window(), base);
109                 //ug_disable_effect(ug);
110                 evas_object_show(base);
111                 ad->wifi_ug_layout = base;
112                 break;
113         default:
114                 break;
115         }
116         _DBG("%s end", __func__);
117 }
118
119 void pwlock_ug_connection_result_cb(ui_gadget_h ug, service_h service,
120                 void *priv) {
121         _DBG("function=%s", __func__);
122         struct appdata *ad = NULL;
123
124         if (!ug || !priv || !service) {
125                 return;
126         }
127         char *retv = NULL;
128         ad = (struct appdata *) priv;
129         _DBG("ad->state=%d", ad->state);
130
131         service_get_extra_data(service, "result", &retv);
132
133         if (retv && !strcmp(retv, "lbutton_click")) {
134                 ad->btn_evt_state = BUTTON_STATE_PREV_CLICKED;
135         }
136         if (retv && !strcmp(retv, "rbutton_click")) {
137                 ad->btn_evt_state = BUTTON_STATE_NEXT_CLICKED;
138         }
139 }
140
141 void pwlock_ug_connection_destroy_cb(ui_gadget_h ug, void *priv) {
142         _DBG("%s, %d begin", __func__, __LINE__);
143
144         struct appdata *ad = NULL;
145
146         if (!ug || !priv) {
147                 return;
148         }
149         ad = (struct appdata *) priv;
150
151         if (ug) {
152                 ug_destroy(ug);
153                 ug = NULL;
154         }
155
156         _DBG("ad->btn_evt_state=%d", ad->btn_evt_state);
157
158         switch (ad->btn_evt_state) {
159         case BUTTON_STATE_NEXT_CLICKED:
160                 do_state_directly(_ST_FINISH, ad);
161                 break;
162         case BUTTON_STATE_PREV_CLICKED:
163                 do_state_directly(_ST_TIME, ad);
164                 break;
165         case BUTTON_STATE_NONE:
166                 break;
167         }
168         //ad->btn_evt_state = BUTTON_STATE_NONE;
169 }
170
171 void pwlock_finish_prev_cb(void *data, Evas_Object *obj, void *e) 
172 {
173         _DBG("%s,%d", __func__, __LINE__);
174         struct appdata *ad = data;
175
176         if (!ad)
177                 return;
178
179         ad->btn_evt_state = BUTTON_STATE_PREV_CLICKED;
180         do_state_directly(_ST_CONNECTION, ad);
181 }
182
183 void pwlock_finish_cb(void *data, Evas_Object *obj, void *e) {
184         _DBG("%s,%d", __func__, __LINE__);
185         struct appdata *ad = data;
186
187         if (!ad)
188                 return;
189
190         vconf_set_bool(VCONFKEY_PWLOCK_FIRST_BOOT, 0);
191
192         ad->btn_evt_state = BUTTON_STATE_NEXT_CLICKED;
193         do_state_directly(_ST_EXIT, ad);
194 }