summaryrefslogtreecommitdiff
path: root/src/ui-callback.c
blob: 6c80883934834332b53b07c783a84ae8c2ca0a5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
 *  pwlock
 *
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.tizenopensource.org/license
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#include <Ecore_X.h>
#include <ui-gadget.h>
#include <vconf.h>

#include "pwlock.h"
#include "util.h"
#include "ui-callback.h"

void pwlock_greeting_next_cb(void *data, Evas_Object *obj, void *e) {
	_DBG("%s,%d", __func__, __LINE__);
	struct appdata *ad = data;

	if (!ad)
		return;

	if (ad->is_no_sim == 1) {
		do_state_directly(_ST_NOSIM, ad);
	} else {
		do_state_directly(_ST_TIME, ad);
	}
}

void pwlock_nosim_skip_cb(void *data, Evas_Object * obj, void *e) {
	_DBG("%s,%d", __func__, __LINE__);
	struct appdata *ad = data;

	if (!ad)
		return;

	do_state_directly(_ST_TIME, ad);
}

void pwlock_tutorial_prev_cb(void *data, Evas_Object *obj, void *e) {
	_DBG("%s,%d", __func__, __LINE__);
	struct appdata *ad = data;

	if (!ad)
		return;

	do_state_directly(_ST_CONNECTION, ad);
}

void pwlock_tutorial_next_cb(void *data, Evas_Object *obj, void *e) {
	_DBG("%s,%d", __func__, __LINE__);
	struct appdata *ad = data;

	if (!ad)
		return;


	do_state_directly(_ST_EXIT, ad);
}

void pwlock_ug_connection_layout_cb(ui_gadget_h ug, enum ug_mode mode,
		void *priv) {
	struct appdata *ad = (struct appdata *) priv;
	Evas_Object *base;
	_DBG("%s begin", __func__);
	if (!ug || !priv)
		return;

	base = (Evas_Object *) ug_get_layout(ug);
	if (!base) {
		_DBG("base layout null!\n");
		return;
	}

	_DBG("%s,%d", __func__, __LINE__);
	ad->ug_btn_evt_state = UG_BUTTON_STATE_NONE;
	switch (mode) {
	case UG_MODE_FULLVIEW:
		evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
				EVAS_HINT_EXPAND);
		elm_win_resize_object_add(ug_get_window(), base);
		evas_object_show(base);
		break;
	default:
		break;
	}
	_DBG("%s end", __func__);
}

void pwlock_ug_connection_result_cb(ui_gadget_h ug, service_h service,
		void *priv) {
	_DBG("function=%s", __func__);
	struct appdata *ad = NULL;

	if (!ug || !priv || !service) {
		return;
	}
	char *retv = NULL;
	ad = (struct appdata *) priv;
	_DBG("ad->state=%d", ad->state);

	service_get_extra_data(service, "result", &retv);

	if (retv && !strcmp(retv, "lbutton_click")) {
		ad->ug_btn_evt_state = UG_BUTTON_STATE_PREV_CLICKED;
	}
	if (retv && !strcmp(retv, "rbutton_click")) {
		ad->ug_btn_evt_state = UG_BUTTON_STATE_NEXT_CLICKED;
	}
}

void pwlock_ug_connection_destroy_cb(ui_gadget_h ug, void *priv) {
	_DBG("%s, %d begin", __func__, __LINE__);

	struct appdata *ad = NULL;

	if (!ug || !priv) {
		return;
	}
	ad = (struct appdata *) priv;

	_DBG("ad->ug_btn_evt_state=%d", ad->ug_btn_evt_state);

	switch (ad->ug_btn_evt_state) {
	case UG_BUTTON_STATE_NEXT_CLICKED:
		do_state_directly(_ST_FINISH, ad);
		ug_destroy(ug);
		break;
	case UG_BUTTON_STATE_PREV_CLICKED:
		do_state_directly(_ST_TIME, ad);
		ug_destroy(ug);
		break;
	case UG_BUTTON_STATE_NONE:
		break;
	}
	//ad->ug_btn_evt_state = UG_BUTTON_STATE_NONE;
}

void pwlock_popup_exit_ok_cb(void *data, Evas_Object * e, void *ei)
{
	int i = (int)ei;
	struct appdata *ad = (struct appdata *)data;

	_DBG("popup exit rsp: %d\n", i);

	if (NULL == ad) {
		return;
	}

	if (ad->popup) {
		evas_object_del(ad->popup);
		ad->popup = NULL;
	}
	if (ad->current_ug) {
		ug_destroy(ad->current_ug);
	}
	if (ad->msg) {
		free(ad->msg);
		ad->msg = NULL;
	}

	vconf_set_bool(VCONFKEY_PWLOCK_FIRST_BOOT, 0);

	ad->state = _ST_EXIT;
	do_state(ad);
}

void pwlock_popup_exit_cancel_cb(void *data, Evas_Object * e, void *ei)
{
	int i = (int)ei;
	struct appdata *ad = (struct appdata *)data;

	_DBG("popup rsp: %d\n", i);

	if (NULL == ad) {
		return;
	}

	if (ad->popup) {
		evas_object_del(ad->popup);
		ad->popup = NULL;
	}
	if (ad->msg) {
		free(ad->msg);
		ad->msg = NULL;
	}
}

void pwlock_finish_prev_cb(void *data, Evas_Object *obj, void *e) 
{
	_DBG("%s,%d", __func__, __LINE__);
	struct appdata *ad = data;

	if (!ad)
		return;

	// temp use ug_btn_evt_state variable
	ad->ug_btn_evt_state = UG_BUTTON_STATE_PREV_CLICKED;
	ad->state = _ST_CONNECTION;
	do_state(ad);
}

void pwlock_finish_cb(void *data, Evas_Object *obj, void *e) {
	_DBG("%s,%d", __func__, __LINE__);
	struct appdata *ad = data;

	if (!ad)
		return;

	vconf_set_bool(VCONFKEY_PWLOCK_FIRST_BOOT, 0);

	do_state_directly(_ST_EXIT, ad);
}