4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
25 #include <appcore-efl.h>
27 #include <bundle_internal.h>
30 #include "syspopup-app.h"
37 #define LOG_TAG "SYSPOPUP-APP"
39 #define _E(fmt, arg...) LOGE(fmt,##arg)
40 #define _D(fmt, arg...) LOGD(fmt,##arg)
42 int myterm(bundle *b, void *data)
48 int mytimeout(bundle *b, void* data)
50 _D("mytimeout called");
54 syspopup_handler handler = {
55 .def_term_fn = myterm,
56 .def_timeout_fn = mytimeout
59 static void __win_del(void *data, Evas_Object * obj, void *event)
61 _D("__win_del called");
65 static Evas_Object *__create_win(const char *name)
71 eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
73 elm_win_title_set(eo, name);
74 elm_win_borderless_set(eo, EINA_TRUE);
76 elm_win_alpha_set(eo, EINA_TRUE);
78 evas_object_smart_callback_add(eo, "delete,request",
80 ecore_x_window_size_get(ecore_x_window_root_first_get(),
82 evas_object_resize(eo, w, h);
88 static int __app_create(void *data)
90 struct appdata *ad = data;
94 _D("__app_create called");
97 win = __create_win(PACKAGE);
101 /* evas_object_show(win);*/
103 /* init internationalization */
104 r = appcore_set_i18n(PACKAGE, LOCALEDIR);
108 /* appcore_set_rotation_cb(rotate, ad);*/
110 appcore_measure_start();
114 static int __app_terminate(void *data)
116 struct appdata *ad = data;
118 _D("__app_terminate called");
121 evas_object_del(ad->win);
126 static int __app_pause(void *data)
128 struct appdata *ad = data;
130 _D("__app_pause called");
135 static int __app_resume(void *data)
137 struct appdata *ad = data;
139 _D("__app_resume called");
144 static void __prt_recvd_bundle(const char *key, const char *value, void *d)
146 _D("recvd - key: %s, value: %s\n", key, value);
149 static void __response_cb(void *data, Evas_Object * obj, void *event_info)
151 _D("__response_cb called");
153 if ((int)event_info != 5)
154 evas_object_del(obj);
158 static void _block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
160 _D("_block_clicked_cb called");
161 evas_object_del(obj);
164 static int __app_reset(bundle *b, void *data)
166 struct appdata *ad = data;
171 _D("__app_reset called");
173 ad->b = bundle_dup(b);
175 bundle_iterate(b, __prt_recvd_bundle, NULL);
177 if (syspopup_has_popup(b)) {
180 popup = elm_popup_add(ad->win);
182 ret = syspopup_create(b, &handler, ad->win, ad);
183 evas_object_show(ad->win);
186 val = bundle_get_val(b, "_SYSPOPUP_TITLE_");
188 snprintf(ad->title, TITLE_BUF_LEN, "%s",
191 snprintf(ad->title, TITLE_BUF_LEN, "%s",
195 val = bundle_get_val(b, "_SYSPOPUP_CONTENT_");
197 snprintf(ad->content, CONTENT_BUF_LEN,
200 snprintf(ad->content, CONTENT_BUF_LEN,
201 "%s", "Unknown Content");
204 elm_object_style_set(popup, "char_wrap_style");
205 evas_object_size_hint_weight_set(popup,
208 evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb, NULL);
209 elm_object_part_text_set(popup, "title,text", ad->title);
210 elm_object_text_set(popup, ad->content);
211 evas_object_smart_callback_add(popup,
216 evas_object_show(popup);
224 int main(int argc, char *argv[])
227 struct appcore_ops ops = {
228 .create = __app_create,
229 .terminate = __app_terminate,
230 .pause = __app_pause,
231 .resume = __app_resume,
232 .reset = __app_reset,
235 //unsetenv("ELM_SCALE");
237 /* appcore measure time example */
238 _D("from AUL to %s(): %d msec\n", __func__,
239 appcore_measure_time_from("APP_START_TIME"));
241 memset(&ad, 0x0, sizeof(struct appdata));
244 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);