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"
31 /*#include <quickpanel.h> */
46 int myterm(bundle *b, void *data)
49 char b_str[QP_BUF_LEN];
53 struct appdata *ad = data;
54 struct quickpanel* qp;
56 val = bundle_get_val(b,"_INTERNAL_SYSPOPUP_NAME_");
57 printf("[SYSTEM POPUP] Popup Name : %s\n", val);
59 qp = malloc(sizeof(struct quickpanel));
60 memset(qp,0,sizeof(struct quickpanel));
62 //qp->type = QP_TYPE_SYSPOPUP;
63 qp->type = quickpanel_get_type_id("org.tizen.syspopup-app", NULL, 0);
64 qp->priv_id = QP_PRIVID;
65 qp->title = ad->title;
66 qp->content = ad->content;
68 qp->group_id = qp->priv_id;
70 ret = quickpanel_insert(qp);
72 printf("[SYSTEM POPUP] Error!! Cannot insert to quickpanel!\n");
79 int mytimeout(bundle *b, void* data)
82 char b_str[QP_BUF_LEN];
86 struct appdata *ad = data;
87 struct quickpanel* qp;
89 val = bundle_get_val(b,"_INTERNAL_SYSPOPUP_NAME_");
90 printf("[SYSTEM POPUP] Popup Name : %s\n", val);
92 qp = malloc(sizeof(struct quickpanel));
93 memset(qp,0,sizeof(struct quickpanel));
95 //qp->type = QP_TYPE_SYSPOPUP;
96 qp->type = quickpanel_get_type_id("org.tizen.syspopup-app", NULL, 0);
97 qp->priv_id = QP_PRIVID;
98 qp->title = ad->title;
99 qp->content = ad->content;
101 qp->group_id = qp->priv_id;
103 ret = quickpanel_insert(qp);
105 printf("[SYSTEM POPUP] Error!! Cannot insert to quickpanel!\n");
112 syspopup_handler handler = {
113 .def_term_fn = myterm,
114 .def_timeout_fn = mytimeout
117 static void __win_del(void *data, Evas_Object * obj, void *event)
123 static Evas_Object *__create_win(const char *name)
129 eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
131 elm_win_title_set(eo, name);
132 elm_win_borderless_set(eo, EINA_TRUE);
134 elm_win_alpha_set(eo, EINA_TRUE);
136 evas_object_smart_callback_add(eo, "delete,request",
138 ecore_x_window_size_get(ecore_x_window_root_first_get(),
140 evas_object_resize(eo, w, h);
146 static int __app_create(void *data)
148 struct appdata *ad = data;
153 win = __create_win(PACKAGE);
157 /* evas_object_show(win);*/
159 /* init internationalization */
160 r = appcore_set_i18n(PACKAGE, LOCALEDIR);
164 appcore_measure_start();
168 static int __app_terminate(void *data)
170 struct appdata *ad = data;
172 printf("[SYSPOPUP] %s, %d\n", __func__, __LINE__);
175 evas_object_del(ad->win);
180 static int __app_pause(void *data)
182 struct appdata *ad = data;
187 static int __app_resume(void *data)
189 struct appdata *ad = data;
194 static void __prt_recvd_bundle(const char *key, const char *value, void *d)
196 printf("recvd - key: %s, value: %s\n", key, value);
199 static void __response_cb(void *data, Evas_Object * obj, void *event_info)
201 if ((int)event_info != 5)
202 evas_object_del(obj);
206 static void _block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
208 evas_object_del(obj);
211 static int __app_reset(bundle *b, void *data)
213 struct appdata *ad = data;
218 ad->b = bundle_dup(b);
220 bundle_iterate(b, __prt_recvd_bundle, NULL);
222 if (syspopup_has_popup(b)) {
225 popup = elm_popup_add(ad->win);
227 ret = syspopup_create(b, &handler, ad->win, ad);
228 evas_object_show(ad->win);
231 val = bundle_get_val(b,
232 "_INTERNAL_SYSPOPUP_NAME_");
234 val = bundle_get_val(b, "_SYSPOPUP_TITLE_");
236 snprintf(ad->title, TITLE_BUF_LEN, "%s",
239 snprintf(ad->title, TITLE_BUF_LEN, "%s",
243 val = bundle_get_val(b, "_SYSPOPUP_CONTENT_");
245 snprintf(ad->content, CONTENT_BUF_LEN,
248 snprintf(ad->content, CONTENT_BUF_LEN,
249 "%s", "Unknown Content");
252 elm_object_style_set(popup, "char_wrap_style");
253 evas_object_size_hint_weight_set(popup,
256 evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb, NULL);
257 elm_object_part_text_set(popup, "title,text", ad->title);
258 elm_object_text_set(popup, ad->content);
259 evas_object_smart_callback_add(popup,
264 evas_object_show(popup);
272 int main(int argc, char *argv[])
275 struct appcore_ops ops = {
276 .create = __app_create,
277 .terminate = __app_terminate,
278 .pause = __app_pause,
279 .resume = __app_resume,
280 .reset = __app_reset,
283 // unsetenv("ELM_SCALE");
285 /* appcore measure time example */
286 printf("from AUL to %s(): %d msec\n", __func__,
287 appcore_measure_time_from("APP_START_TIME"));
289 memset(&ad, 0x0, sizeof(struct appdata));
292 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);