2 * Tizen Zone Setup-Wizard application
4 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
6 * Licensed under the Apache License, Version 2.0 (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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include "krate-setup.h"
22 static void __create_welcome_view(appdata_s *ad);
26 static Eina_Bool __naviframe_pop_cb(void *data, Elm_Object_Item *it)
28 app_control_h svc = (app_control_h) data;
30 _create_notification(svc);
36 static void __welcome_cancel_cb(void *data, Evas_Object *obj, void *event_info)
38 appdata_s *ad = (appdata_s *)data;
40 _create_notification(ad->app_control);
46 static void __welcome_next_cb(void *data, Evas_Object *obj, void *event_info)
48 appdata_s *ad = (appdata_s *)data;
50 if (!strcmp(ad->mode, "create")) {
51 _create_security_view(ad);
53 if (_send_zone_remove_request(ad) != 0)
55 _create_setup_view(ad);
61 static Eina_Bool __home_key_cb(void *data, int type, void *event)
63 app_control_h app_control = (app_control_h) data;
64 Evas_Event_Key_Down *ev = event;
66 if (!strcmp(ev->keyname, "XF86Home")) {
67 _create_notification(app_control);
74 void _create_two_button_layout(Evas_Object *parent, Evas_Object *left_button, Evas_Object *right_button)
78 layout = _create_layout(parent, ud.edj_path, "two_button_layout");
80 elm_object_part_content_set(layout, "prev_button", left_button);
81 elm_object_part_content_set(layout, "next_button", right_button);
82 elm_object_part_content_set(parent, "bottom_layout", layout);
86 static Eina_Bool __progressbar_timer_cb(void *data)
88 appdata_s *ad = (appdata_s *)data;
89 if (ad->request_done) {
91 return ECORE_CALLBACK_CANCEL;
94 return ECORE_CALLBACK_RENEW;
97 void _create_base_window(appdata_s *ad)
102 char edj_path[PATH_MAX] = "\0";
103 char *res_path = NULL;
105 /* Initialize data */
106 ad->request_done = false;
109 res_path = app_get_resource_path();
110 if (res_path == NULL) {
111 dlog_print(DLOG_ERROR, LOG_TAG, "failed get resource path");
114 snprintf(edj_path, PATH_MAX, "%s%s", res_path, "org.tizen.krate-setup-wizard.edj");
116 ud.edj_path = strdup(edj_path);
119 /* Create main UI widget */
120 win = _create_win(PACKAGE);
121 ud.conform = _create_conformant(win);
122 layout = _create_layout(ud.conform, NULL, NULL);
123 elm_object_content_set(ud.conform, layout);
124 ud.nf = elm_naviframe_add(layout);
126 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, __home_key_cb, ad->app_control);
128 __create_welcome_view(ad);
130 elm_object_part_content_set(layout, "elm.swallow.content", ud.nf);
131 eext_object_event_callback_add(ud.nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
133 evas_object_show(win);
137 static void __create_welcome_view(appdata_s *ad)
139 Elm_Object_Item *nf_it;
140 Evas_Object *layout, *welcome_layout;
141 Evas_Object *title, *content;
142 Evas_Object *left_button, *right_button;
144 char *welcome_text[2][4] = {
145 {WELCOME_MESSAGE_TITLE, WELCOME_MESSAGE_CONTENT, CANCEL_BUTTON, NEXT_BUTTON},
146 {DELETE_MESSAGE_TITLE, DELETE_MESSAGE_CONTENT, CANCEL_BUTTON, REMOVE_BUTTON}
150 if (!strcmp(ad->mode, "create"))
151 text = welcome_text[0];
153 text = welcome_text[1];
155 elm_object_signal_emit(ud.conform, "elm,state,indicator,overlap", "elm");
157 layout = _create_layout(ud.nf, ud.edj_path, "base_layout");
158 welcome_layout = _create_layout(layout, ud.edj_path, "welcome_layout");
160 title = _create_textblock(welcome_layout, text[0], SUB_TITLE_STYLE_B);
161 content = _create_textblock(welcome_layout, text[1], SUB_CONTENT_STYLE_B);
163 elm_object_part_content_set(welcome_layout, "message_title", title);
164 elm_object_part_content_set(welcome_layout, "message_content", content);
166 elm_object_part_content_set(layout, "content_layout", welcome_layout);
168 left_button = _create_button(layout, text[2], __welcome_cancel_cb, ad);
169 right_button = _create_button(layout, text[3], __welcome_next_cb, ad);
171 _create_two_button_layout(layout, left_button, right_button);
173 nf_it = elm_naviframe_item_push(ud.nf, NULL, NULL, NULL, layout, NULL);
174 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_TRUE);
175 elm_naviframe_item_pop_cb_set(nf_it, __naviframe_pop_cb, ad->app_control);
180 void _create_setup_view(appdata_s *ad)
182 Elm_Object_Item *nf_it;
183 Evas_Object *setup_layout;
184 Evas_Object *progressbar;
185 Evas_Object *title, *content;
187 char *setup_text[2][2] = {
188 {SETUP_MESSAGE_TITLE, SETUP_MESSAGE_CONTENT},
189 {DELETE_ONGOING_TITLE, DELETE_ONGOING_CONTENT}
193 if (!strcmp(ad->mode, "create"))
194 text = setup_text[0];
196 text = setup_text[1];
198 eext_object_event_callback_del(ud.nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb);
200 setup_layout = _create_layout(ud.nf, ud.edj_path, "setup_layout");
202 title = _create_textblock(setup_layout, text[0], SUB_TITLE_STYLE_W);
203 content = _create_textblock(setup_layout, text[1], SUB_CONTENT_STYLE_W);
205 elm_object_part_content_set(setup_layout, "progressbar_msg", title);
207 progressbar = _create_progressbar(setup_layout, "pending");
208 elm_object_part_content_set(setup_layout, "progressbar", progressbar);
210 elm_object_part_content_set(setup_layout, "content_text", content);
212 nf_it = elm_naviframe_item_push(ud.nf, NULL, NULL, NULL, setup_layout, NULL);
213 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_TRUE);
215 /* set progressbar timer callback */
216 ecore_timer_add(0.1, __progressbar_timer_cb, ad);