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
|
/*
* Copyright (c) 2000-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* PROPRIETARY/CONFIDENTIAL
*
* This software is the confidential and proprietary information of
* SAMSUNG ELECTRONICS ("Confidential Information").
* You shall not disclose such Confidential Information and shall
* use it only in accordance with the terms of the license agreement
* you entered into with SAMSUNG ELECTRONICS.
* SAMSUNG make no representations or warranties about the suitability
* of the software, either express or implied, including but not
* limited to the implied warranties of merchantability, fitness for
* a particular purpose, or non-infringement.
* SAMSUNG shall not be liable for any damages suffered by licensee as
* a result of using, modifying or distributing this software or its derivatives.
*/
#include <nfc.h>
#include <vconf.h>
#include "nsa-main.h"
#include "nsa-view.h"
#include "nsa-debug.h"
#include "nsa-util.h"
#include "nsa-ui-widget.h"
#include "nsa-popup.h"
static void __back_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
appdata *ad = data;
NSA_DEBUG_ERR("back click cb : view depth is %d", ad->current_view);
elm_naviframe_item_pop(ad->navi_frame);
if (ad->current_view == V_TAP_N_PAY && ad->op_type != NSA_OP_TAP_N_PAY) {
Evas_Object *circle_obj;
/* release Tap & Pay view */
if (ad->payment_wallet_list != NULL) {
int i;
NSA_DEBUG_ERR("wallet count is %d", ad->payment_wallet_cnt);
for (i = 0; i < ad->payment_wallet_cnt; i++) {
wallet_info_t *winfo = NULL;
winfo = g_array_index(ad->payment_wallet_list, wallet_info_t *, i);
NSA_MEM_FREE(winfo->appid);
NSA_MEM_FREE(winfo);
}
g_array_free(ad->payment_wallet_list, FALSE);
ad->payment_wallet_list = NULL;
}
ad->payment_wallet_cnt = 0;
ad->radio_main = NULL;
ad->current_view = V_MAIN;
eext_rotary_object_event_activated_set(ad->main_circle_obj, EINA_TRUE);
} else {
/* release Main view and exit application */
NSA_MEM_FREE(ad->payment_handler);
ui_app_exit();
}
}
bool _nsa_main_app_create(void *user_data)
{
appdata *ad = user_data;
NSA_DEBUG("_nsa_main_app_create start");
retv_if(ad == NULL, false);
bindtextdomain("setting-nfc-efl", "/usr/apps/org.tizen.nfc-setting-app/res/locale");
textdomain("setting-nfc-efl");
if (nfc_manager_initialize() != NFC_ERROR_NONE)
NSA_DEBUG_ERR("nfc_manager_initialize failed");
NSA_DEBUG("_nsa_main_app_create end");
return true;
}
void _nsa_main_app_terminate(void *user_data)
{
appdata *ad = user_data;
NSA_DEBUG("_nsa_main_app_terminate start");
ret_if(ad == NULL);
if (nfc_manager_deinitialize() != NFC_ERROR_NONE)
NSA_DEBUG_ERR("nfc_manager_deinitialize failed");
NSA_DEBUG("_nsa_main_app_terminate end");
}
static void __parse_service(app_control_h service, void *user_data)
{
appdata *ad = user_data;
char *operation = NULL;
char *app_id = NULL;
char *ex_data = NULL;
ret_if(ad == NULL);
app_control_get_operation(service, &operation);
app_control_get_app_id(service, &app_id);
app_control_get_extra_data(service, APP_CONTROL_DATA_TYPE, &ex_data);
NSA_DEBUG("operation [%s] >>>>> ", GET_SAFE_STRING(operation));
NSA_DEBUG("app_id [%s] >>>>> ", GET_SAFE_STRING(app_id));
NSA_DEBUG("extra data [%s] >>>>> ", GET_SAFE_STRING(ex_data));
ad->op_type = NSA_OP_NFC;
if (!ex_data) {
NSA_DEBUG_ERR("extra data is NULL");
goto end;
}
if (strncmp(operation, APP_CONTROL_OPERATION_SETTING_NFC,
strlen(APP_CONTROL_OPERATION_SETTING_NFC)) == 0) {
/* launched by app-control */
if (strncmp(ex_data, "nfc", strlen("nfc")) == 0) {
ad->op_type = NSA_OP_NFC;
} else if (strncmp(ex_data, "tap_n_pay", strlen("tap_n_pay")) == 0) {
ad->op_type = NSA_OP_TAP_N_PAY;
}
}
end:
NSA_MEM_FREE(operation);
NSA_MEM_FREE(app_id);
NSA_MEM_FREE(ex_data);
return;
}
void _nsa_main_app_service(app_control_h service, void *user_data)
{
appdata *ad = user_data;
NSA_DEBUG("_nsa_main_app_service start");
ret_if(ad == NULL);
/* create window */
ad->main_win = nsa_create_main_win(APPNAME);
ret_if(ad->main_win == NULL);
/* create conformant */
ad->conform = nsa_create_conformant(ad->main_win);
ret_if(ad->conform == NULL);
/* create circle surface */
ad->circle_surface = eext_circle_surface_conformant_add(ad->conform);
ret_if(ad->circle_surface == NULL);
/* create bg */
ad->main_bg = nsa_create_bg(ad->conform);
ret_if(ad->main_bg == NULL);
/* create base layout */
ad->main_layout = nsa_create_main_layout(ad->conform);
ret_if(ad->main_layout == NULL);
/* create naviframe */
ad->navi_frame = elm_naviframe_add(ad->main_layout);
ret_if(ad->navi_frame == NULL);
elm_object_part_content_set(ad->main_layout, "elm.swallow.content", ad->navi_frame);
eext_object_event_callback_add(ad->navi_frame, EEXT_CALLBACK_BACK, __back_clicked_cb, ad);
/* parse service data */
__parse_service(service, ad);
/* launch nss */
if (ad->op_type == NSA_OP_TAP_N_PAY){
_nsa_view_tap_n_pay_create(ad);
} else {
_nsa_view_main_create(ad);
}
elm_win_activate(ad->main_win);
NSA_DEBUG("_nsa_main_app_service end");
}
int main(int argc, char* argv[])
{
appdata ad;
ui_app_lifecycle_callback_s event_callback = {0,};
NSA_DEBUG("app start");
event_callback.create = _nsa_main_app_create;
event_callback.terminate = _nsa_main_app_terminate;
event_callback.app_control = _nsa_main_app_service;
NSA_DEBUG("app end");
memset(&ad, 0x0, sizeof(appdata));
return ui_app_main(argc, argv, &event_callback, &ad);
}
|