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>
29 #include "syspopup-app.h"
36 #define LOG_TAG "SYSPOPUP-APP"
38 #define _E(fmt, arg...) LOGE(fmt,##arg)
39 #define _D(fmt, arg...) LOGD(fmt,##arg)
54 int myterm(bundle *b, void *data)
57 char b_str[QP_BUF_LEN];
61 struct appdata *ad = data;
62 struct quickpanel* qp;
64 val = bundle_get_val(b,"_INTERNAL_SYSPOPUP_NAME_");
65 printf("[SYSTEM POPUP] Popup Name : %s\n", val);
67 qp = malloc(sizeof(struct quickpanel));
68 memset(qp,0,sizeof(struct quickpanel));
70 //qp->type = QP_TYPE_SYSPOPUP;
71 qp->type = quickpanel_get_type_id("org.tizen.syspopup-app", NULL, 0);
72 qp->priv_id = QP_PRIVID;
73 qp->title = ad->title;
74 qp->content = ad->content;
76 qp->group_id = qp->priv_id;
78 ret = quickpanel_insert(qp);
80 printf("[SYSTEM POPUP] Error!! Cannot insert to quickpanel!\n");
87 int mytimeout(bundle *b, void* data)
90 char b_str[QP_BUF_LEN];
94 struct appdata *ad = data;
95 struct quickpanel* qp;
97 val = bundle_get_val(b,"_INTERNAL_SYSPOPUP_NAME_");
98 printf("[SYSTEM POPUP] Popup Name : %s\n", val);
100 qp = malloc(sizeof(struct quickpanel));
101 memset(qp,0,sizeof(struct quickpanel));
103 //qp->type = QP_TYPE_SYSPOPUP;
104 qp->type = quickpanel_get_type_id("org.tizen.syspopup-app", NULL, 0);
105 qp->priv_id = QP_PRIVID;
106 qp->title = ad->title;
107 qp->content = ad->content;
109 qp->group_id = qp->priv_id;
111 ret = quickpanel_insert(qp);
113 printf("[SYSTEM POPUP] Error!! Cannot insert to quickpanel!\n");
120 syspopup_handler handler = {
121 .def_term_fn = myterm,
122 .def_timeout_fn = mytimeout
125 static void __win_del(void *data, Evas_Object * obj, void *event)
131 static int rotate(enum appcore_rm m, void *data)
133 struct appdata *ad = data;
136 if (ad == NULL || ad->win == NULL)
140 case APPCORE_RM_PORTRAIT_NORMAL:
143 case APPCORE_RM_PORTRAIT_REVERSE:
146 case APPCORE_RM_LANDSCAPE_NORMAL:
149 case APPCORE_RM_LANDSCAPE_REVERSE:
158 elm_win_rotation_with_resize_set(ad->win, r);
164 static Evas_Object *__create_win(const char *name)
170 eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
172 elm_win_title_set(eo, name);
173 elm_win_borderless_set(eo, EINA_TRUE);
175 elm_win_alpha_set(eo, EINA_TRUE);
177 evas_object_smart_callback_add(eo, "delete,request",
179 ecore_x_window_size_get(ecore_x_window_root_first_get(),
181 evas_object_resize(eo, w, h);
187 static int __app_create(void *data)
189 struct appdata *ad = data;
194 win = __create_win(PACKAGE);
198 /* evas_object_show(win);*/
200 /* init internationalization */
201 r = appcore_set_i18n(PACKAGE, LOCALEDIR);
205 /* appcore_set_rotation_cb(rotate, ad);*/
207 appcore_measure_start();
211 static int __app_terminate(void *data)
213 struct appdata *ad = data;
215 _D("__app_terminate called");
218 evas_object_del(ad->win);
223 static int __app_pause(void *data)
225 struct appdata *ad = data;
230 static int __app_resume(void *data)
232 struct appdata *ad = data;
237 static void __prt_recvd_bundle(const char *key, const char *value, void *d)
239 _D("recvd - key: %s, value: %s\n", key, value);
242 static void __response_cb(void *data, Evas_Object * obj, void *event_info)
244 if ((int)event_info != 5)
245 evas_object_del(obj);
249 static void _block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
251 evas_object_del(obj);
254 static int __app_reset(bundle *b, void *data)
256 struct appdata *ad = data;
261 ad->b = bundle_dup(b);
263 bundle_iterate(b, __prt_recvd_bundle, NULL);
265 if (syspopup_has_popup(b)) {
268 popup = elm_popup_add(ad->win);
270 ret = syspopup_create(b, &handler, ad->win, ad);
271 evas_object_show(ad->win);
274 val = bundle_get_val(b, "_SYSPOPUP_TITLE_");
276 snprintf(ad->title, TITLE_BUF_LEN, "%s",
279 snprintf(ad->title, TITLE_BUF_LEN, "%s",
283 val = bundle_get_val(b, "_SYSPOPUP_CONTENT_");
285 snprintf(ad->content, CONTENT_BUF_LEN,
288 snprintf(ad->content, CONTENT_BUF_LEN,
289 "%s", "Unknown Content");
292 elm_object_style_set(popup, "char_wrap_style");
293 evas_object_size_hint_weight_set(popup,
296 evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb, NULL);
297 elm_object_part_text_set(popup, "title,text", ad->title);
298 elm_object_text_set(popup, ad->content);
299 evas_object_smart_callback_add(popup,
304 evas_object_show(popup);
312 int main(int argc, char *argv[])
315 struct appcore_ops ops = {
316 .create = __app_create,
317 .terminate = __app_terminate,
318 .pause = __app_pause,
319 .resume = __app_resume,
320 .reset = __app_reset,
323 memset(&ad, 0x0, sizeof(struct appdata));
326 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);