2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <appcore-common.h>
22 #include <app_service.h>
24 #include <notification.h>
26 #include "quickpanel-ui.h"
27 #include "quickpanel_def.h"
29 #include "noti_node.h"
30 #include "noti_gridbox.h"
32 #include "noti_listbox.h"
33 #include "noti_list_item.h"
34 #include "noti_section.h"
36 #include "list_util.h"
37 #ifdef QP_SERVICE_NOTI_LED_ENABLE
41 #ifndef VCONFKEY_QUICKPANEL_STARTED
42 #define VCONFKEY_QUICKPANEL_STARTED "memory/private/"PACKAGE_NAME"/started"
43 #endif /* VCONFKEY_QUICKPANEL_STARTED */
45 #define QP_NOTI_ONGOING_DBUS_PATH "/dbus/signal"
46 #define QP_NOTI_ONGOING_DBUS_INTERFACE "notification.ongoing"
48 static noti_node *g_noti_node;
49 static Evas_Object *g_noti_section;
50 static Evas_Object *g_noti_listbox;
51 static Evas_Object *g_noti_gridbox;
53 static int quickpanel_noti_init(void *data);
54 static int quickpanel_noti_fini(void *data);
55 static int quickpanel_noti_suspend(void *data);
56 static int quickpanel_noti_resume(void *data);
57 static void quickpanel_noti_lang_changed(void *data);
58 static void quickpanel_noti_refresh(void *data);
62 .init = quickpanel_noti_init,
63 .fini = quickpanel_noti_fini,
64 .suspend = quickpanel_noti_suspend,
65 .resume = quickpanel_noti_resume,
66 .lang_changed = quickpanel_noti_lang_changed,
69 .refresh = quickpanel_noti_refresh,
73 static notification_h _quickpanel_noti_update_item_progress(const char *pkgname,
77 char *noti_pkgname = NULL;
80 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
82 if (node != NULL && node->noti != NULL) {
83 notification_get_pkgname(node->noti, ¬i_pkgname);
84 notification_get_id(node->noti, NULL, ¬i_priv_id);
85 if (!strcmp(noti_pkgname, pkgname)
86 && priv_id == noti_priv_id) {
88 if (notification_set_progress(node->noti, progress) != NOTIFICATION_ERROR_NONE) {
89 ERR("fail to set progress");
98 static notification_h _quickpanel_noti_update_item_size(const char *pkgname,
102 char *noti_pkgname = NULL;
103 int noti_priv_id = 0;
105 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
107 if (node != NULL && node->noti != NULL) {
108 notification_get_pkgname(node->noti, ¬i_pkgname);
109 notification_get_id(node->noti, NULL, ¬i_priv_id);
110 if (!strcmp(noti_pkgname, pkgname)
111 && priv_id == noti_priv_id) {
112 notification_set_size(node->noti, size);
120 static notification_h _quickpanel_noti_update_item_content(const char *pkgname,
124 char *noti_pkgname = NULL;
125 int noti_priv_id = 0;
127 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
129 if (node != NULL && node->noti != NULL) {
130 notification_get_pkgname(node->noti, ¬i_pkgname);
131 notification_get_id(node->noti, NULL, ¬i_priv_id);
132 if (!strcmp(noti_pkgname, pkgname)
133 && priv_id == noti_priv_id) {
134 notification_set_text(node->noti,
135 NOTIFICATION_TEXT_TYPE_CONTENT,
137 NOTIFICATION_VARIABLE_TYPE_NONE);
145 static void _quickpanel_noti_update_progressbar(void *data,
146 notification_h update_noti)
148 struct appdata *ad = NULL;
149 Elm_Object_Item *found = NULL;
150 noti_node_item *node = NULL;
152 retif(!data, , "data is NULL");
155 retif(!ad->list, , "ad->list is NULL");
159 if (notification_get_id(update_noti, NULL, &priv_id) == NOTIFICATION_ERROR_NONE) {
160 node = noti_node_get(g_noti_node, priv_id);
167 retif(node == NULL, , "fail to find node of priv_id:%d", priv_id);
168 retif(node->view == NULL, , "fail to find %p", node->view);
170 listbox_update_item(g_noti_listbox, node->view);
173 static void _quickpanel_noti_item_progress_update_cb(void *data,
180 notification_h noti = NULL;
182 retif(data == NULL || msg == NULL, , "Invalid parameter!");
184 dbus_error_init(&err);
185 dbus_message_get_args(msg, &err,
186 DBUS_TYPE_STRING, &pkgname,
187 DBUS_TYPE_INT32, &priv_id,
188 DBUS_TYPE_DOUBLE, &progress,
191 if (dbus_error_is_set(&err)) {
192 ERR("dbus err: %s", err.message);
193 dbus_error_free(&err);
197 if (pkgname == NULL) {
198 ERR("pkgname is null");
202 /* check item on the list */
203 noti = _quickpanel_noti_update_item_progress(pkgname,
205 retif(noti == NULL, , "Can not found noti data.");
207 DBG("pkgname[%s], priv_id[%d], progress[%lf]",
208 pkgname, priv_id, progress);
209 if (!quickpanel_is_suspended())
210 _quickpanel_noti_update_progressbar(data, noti);
213 static void _quickpanel_noti_item_size_update_cb(void *data, DBusMessage * msg)
219 notification_h noti = NULL;
221 retif(data == NULL || msg == NULL, , "Invalid parameter!");
223 dbus_error_init(&err);
224 dbus_message_get_args(msg, &err,
225 DBUS_TYPE_STRING, &pkgname,
226 DBUS_TYPE_INT32, &priv_id,
227 DBUS_TYPE_DOUBLE, &size, DBUS_TYPE_INVALID);
228 if (dbus_error_is_set(&err)) {
229 ERR("dbus err: %s", err.message);
230 dbus_error_free(&err);
234 if (pkgname == NULL) {
235 ERR("pkgname is null");
239 /* check item on the list */
240 noti = _quickpanel_noti_update_item_size(pkgname, priv_id, size);
241 retif(noti == NULL, , "Can not found noti data.");
243 DBG("pkgname[%s], priv_id[%d], progress[%lf]",
244 pkgname, priv_id, size);
246 if (!quickpanel_is_suspended())
247 _quickpanel_noti_update_progressbar(data, noti);
250 static void _quickpanel_noti_item_content_update_cb(void *data,
254 char *pkgname = NULL;
256 char *content = NULL;
257 notification_h noti = NULL;
259 retif(data == NULL || msg == NULL, , "Invalid parameter!");
261 dbus_error_init(&err);
262 dbus_message_get_args(msg, &err,
263 DBUS_TYPE_STRING, &pkgname,
264 DBUS_TYPE_INT32, &priv_id,
265 DBUS_TYPE_STRING, &content, DBUS_TYPE_INVALID);
267 if (pkgname == NULL) {
268 ERR("pkgname is null");
271 if (content == NULL) {
272 ERR("content is null");
276 if (dbus_error_is_set(&err)) {
277 ERR("dbus err: %s", err.message);
278 dbus_error_free(&err);
282 DBG("pkgname[%s], priv_id[%d], content[%s]",
283 pkgname, priv_id, content);
285 /* check item on the list */
286 noti = _quickpanel_noti_update_item_content(pkgname, priv_id, content);
287 retif(noti == NULL, , "Can not found noti data.");
289 if (!quickpanel_is_suspended())
290 _quickpanel_noti_update_progressbar(data, noti);
293 static void _quickpanel_do_noti_delete(notification_h noti) {
294 char *pkgname = NULL;
295 char *caller_pkgname = NULL;
296 int flags = 0, priv_id = 0, flag_delete = 0;
297 notification_type_e type = NOTIFICATION_TYPE_NONE;
299 quickpanel_play_feedback();
301 retif(noti == NULL, , "Invalid parameter!");
303 notification_get_pkgname(noti, &caller_pkgname);
304 notification_get_application(noti, &pkgname);
306 pkgname = caller_pkgname;
308 notification_get_id(noti, NULL, &priv_id);
309 notification_get_property(noti, &flags);
310 notification_get_type(noti, &type);
312 if (flags & NOTIFICATION_PROP_PERMANENT_DISPLAY)
317 if (flag_delete == 1 && type == NOTIFICATION_TYPE_NOTI) {
318 notification_delete_by_priv_id(caller_pkgname, NOTIFICATION_TYPE_NOTI,
323 static void _quickpanel_do_noti_press(notification_h noti, int pressed_area) {
325 char *pkgname = NULL;
326 char *caller_pkgname = NULL;
328 bundle *group_args = NULL;
329 bundle *responding_service_handle = NULL;
330 bundle *single_service_handle = NULL;
331 bundle *multi_service_handle = NULL;
332 int flags = 0, group_id = 0, priv_id = 0, count = 0, flag_launch = 0,
334 notification_type_e type = NOTIFICATION_TYPE_NONE;
336 quickpanel_play_feedback();
338 retif(noti == NULL, , "Invalid parameter!");
340 notification_get_pkgname(noti, &caller_pkgname);
341 notification_get_application(noti, &pkgname);
343 pkgname = caller_pkgname;
345 notification_get_id(noti, &group_id, &priv_id);
346 notification_get_property(noti, &flags);
347 notification_get_type(noti, &type);
349 if (flags & NOTIFICATION_PROP_DISABLE_APP_LAUNCH)
354 if (flags & NOTIFICATION_PROP_DISABLE_AUTO_DELETE)
359 notification_get_execute_option(noti,
360 NOTIFICATION_EXECUTE_TYPE_RESPONDING,
361 NULL, &responding_service_handle);
362 notification_get_execute_option(noti,
363 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
364 NULL, &single_service_handle);
365 notification_get_execute_option(noti,
366 NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH,
367 NULL, &multi_service_handle);
369 if (pressed_area == NOTI_PRESS_BUTTON_1 && responding_service_handle != NULL) {
371 quickpanel_close_quickpanel(true);
372 ret = quickpanel_launch_app(NULL, responding_service_handle);
373 quickpanel_launch_app_inform_result(pkgname, ret);
374 } else if (flag_launch == 1) {
375 /* Hide quickpanel */
376 quickpanel_close_quickpanel(true);
378 char *text_count = NULL;
379 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &text_count);
381 if (text_count != NULL) {
382 count = atoi(text_count);
387 if (single_service_handle != NULL && multi_service_handle == NULL) {
389 ret = quickpanel_launch_app(NULL, single_service_handle);
390 quickpanel_launch_app_inform_result(pkgname, ret);
392 if (single_service_handle == NULL && multi_service_handle != NULL) {
394 ret = quickpanel_launch_app(NULL, multi_service_handle);
395 quickpanel_launch_app_inform_result(pkgname, ret);
397 if (single_service_handle != NULL && multi_service_handle != NULL) {
400 ret = quickpanel_launch_app(NULL, single_service_handle);
401 quickpanel_launch_app_inform_result(pkgname, ret);
403 ret = quickpanel_launch_app(NULL, multi_service_handle);
404 quickpanel_launch_app_inform_result(pkgname, ret);
407 if (single_service_handle == NULL && multi_service_handle == NULL) {
409 notification_get_args(noti, &args, &group_args);
411 if (count > 1 && group_args != NULL) {
412 ret = quickpanel_launch_app(pkgname, group_args);
413 quickpanel_launch_app_inform_result(pkgname, ret);
415 ret = quickpanel_launch_app(pkgname, args);
416 quickpanel_launch_app_inform_result(pkgname, ret);
421 if (flag_delete == 1 && type == NOTIFICATION_TYPE_NOTI) {
422 notification_delete_by_priv_id(caller_pkgname,
423 NOTIFICATION_TYPE_NOTI,
428 static void quickpanel_notibox_delete_cb(void *data, Evas_Object * obj) {
430 noti_node_item *item = data;
431 retif(item == NULL, , "Invalid parameter!");
433 notification_h noti = item->noti;
434 retif(noti == NULL, , "Invalid parameter!");
436 _quickpanel_do_noti_delete(noti);
440 static void quickpanel_notibox_button_1_cb(void *data, Evas_Object * obj) {
442 noti_node_item *item = data;
443 retif(item == NULL, , "Invalid parameter!");
445 notification_h noti = item->noti;
446 retif(noti == NULL, , "Invalid parameter!");
448 _quickpanel_do_noti_press(noti, NOTI_PRESS_BUTTON_1);
451 static void quickpanel_notibox_select_cb(void *data, Evas_Object * obj) {
453 noti_node_item *item = data;
454 retif(item == NULL, , "Invalid parameter!");
456 notification_h noti = item->noti;
457 retif(noti == NULL, , "Invalid parameter!");
459 _quickpanel_do_noti_press(noti, NOTI_PRESS_BG);
462 static void quickpanel_noti_listitem_select_cb(void *data, Evas_Object * obj) {
464 noti_node_item *item = data;
465 retif(item == NULL, , "Invalid parameter!");
467 notification_h noti = item->noti;
468 retif(noti == NULL, , "Invalid parameter!");
470 _quickpanel_do_noti_press(noti, NOTI_PRESS_BG);
473 static inline void __ongoing_comp_n_copy(notification_h old, notification_h new)
477 char *pkgname = NULL;
478 char *new_pkgname = NULL;
486 notification_get_id(old, NULL, &priv_id);
487 notification_get_id(new, NULL, &new_priv_id);
489 notification_get_pkgname(old, &pkgname);
490 notification_get_pkgname(new, &new_pkgname);
492 if (!pkgname || !new_pkgname)
495 if (!strcmp(pkgname, new_pkgname) && priv_id == new_priv_id) {
496 double percentage = 0.0;
498 time_t insert_time = 0;
499 time_t new_insert_time = 0;
501 notification_get_progress(old, &percentage);
502 notification_get_size(old, &size);
503 if (notification_set_progress(new, percentage) != NOTIFICATION_ERROR_NONE) {
504 ERR("fail to set progress");
506 if (notification_set_size(new, size) != NOTIFICATION_ERROR_NONE) {
507 ERR("fail to set size");
509 notification_get_insert_time(old, &insert_time);
510 notification_get_insert_time(new, &new_insert_time);
512 if (insert_time == new_insert_time) {
513 char *content = NULL;
514 notification_get_text(old,
515 NOTIFICATION_TEXT_TYPE_CONTENT, &content);
516 notification_set_text(new,
517 NOTIFICATION_TEXT_TYPE_CONTENT, content,
518 NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
523 static void _quickpanel_noti_clear_ongoinglist()
525 if (g_noti_listbox != NULL) {
526 listbox_remove_all_item(g_noti_listbox, EINA_FALSE);
530 static void _quickpanel_noti_clear_notilist(void)
532 if (g_noti_gridbox != NULL) {
533 gridbox_remove_all_item(g_noti_gridbox, EINA_FALSE);
537 static void _quickpanel_noti_clear_list_all(void)
539 _quickpanel_noti_clear_ongoinglist();
540 _quickpanel_noti_clear_notilist();
543 static void _quickpanel_noti_section_add(void)
545 struct appdata *ad = quickpanel_get_app_data();
546 retif(ad == NULL, , "Invalid parameter!");
547 retif(ad->list == NULL, , "Invalid parameter!");
549 if (g_noti_section == NULL) {
550 g_noti_section = noti_section_create(ad->list);
551 if (g_noti_section != NULL) {
552 quickpanel_list_util_sort_insert(ad->list, g_noti_section);
553 DBG("noti section[%p]", g_noti_section);
558 static void _quickpanel_noti_section_remove(void)
560 struct appdata *ad = quickpanel_get_app_data();
561 retif(ad == NULL, , "Invalid parameter!");
562 retif(ad->list == NULL, , "Invalid parameter!");
564 if (g_noti_section != NULL) {
565 quickpanel_list_util_item_unpack_by_type(ad->list, QP_ITEM_TYPE_NOTI_GROUP);
566 noti_section_remove(g_noti_section);
567 g_noti_section = NULL;
571 static void _quickpanel_noti_box_deleted_cb(void *data, Evas_Object *obj) {
574 retif(data == NULL, , "Invalid parameter!");
575 DBG("deleting:%p", data);
577 noti_node_item *item = data;
578 notification_h noti = item->noti;
581 notification_get_id(noti, NULL, &priv_id);
582 noti_node_remove(g_noti_node, priv_id);
586 static void _quickpanel_list_box_deleted_cb(void *data, Evas_Object *obj) {
589 retif(data == NULL, , "Invalid parameter!");
590 DBG("deleting:%p", data);
592 noti_node_item *item = data;
593 notification_h noti = item->noti;
596 notification_get_id(noti, NULL, &priv_id);
597 noti_node_remove(g_noti_node, priv_id);
601 static void _quickpanel_noti_ongoing_add(Evas_Object *list, void *data, int is_prepend)
603 Evas_Object *noti_list_item = NULL;
604 notification_ly_type_e layout = NOTIFICATION_LY_ONGOING_EVENT;
606 retif(list == NULL, , "Invalid parameter!");
607 notification_h noti = data;
610 notification_get_layout(noti, &layout);
611 noti_list_item = noti_list_item_create(g_noti_listbox, layout);
613 if (noti_list_item != NULL) {
614 noti_node_item *item = noti_node_add(g_noti_node, (void*)data, (void*)noti_list_item);
616 noti_list_item_node_set(noti_list_item, item);
617 noti_list_item_set_item_selected_cb(noti_list_item, quickpanel_noti_listitem_select_cb);
618 listbox_add_item(g_noti_listbox, noti_list_item, is_prepend);
621 ERR("fail to insert item to list : %p", data);
624 DBG("noti[%p] data[%p] added listbox[%p]",
625 data, noti_list_item, g_noti_listbox);
628 static void _quickpanel_noti_noti_add(Evas_Object *list, void *data, int is_prepend)
630 notification_h noti = data;
631 notification_ly_type_e layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
632 Evas_Object *noti_box = NULL;
634 retif(list == NULL, , "Invalid parameter!");
636 if (g_noti_section == NULL) {
637 _quickpanel_noti_section_add();
641 notification_get_layout(noti, &layout);
642 Evas_Object *noti_box = noti_box_create(g_noti_gridbox, layout);
644 if (noti_box != NULL) {
645 noti_node_item *item = noti_node_add(g_noti_node, (void*)data, (void*)noti_box);
647 noti_box_node_set(noti_box, item);
648 noti_box_set_item_selected_cb(noti_box, quickpanel_notibox_select_cb);
649 noti_box_set_item_button_1_cb(noti_box, quickpanel_notibox_button_1_cb);
650 noti_box_set_item_deleted_cb(noti_box, quickpanel_notibox_delete_cb);
651 gridbox_add_item(g_noti_gridbox, noti_box, is_prepend);
654 ERR("fail to insert item to list : %p", data);
658 noti_node_get_item_count(g_noti_node, NOTIFICATION_TYPE_NOTI);
660 if (g_noti_section != NULL) {
661 noti_section_update(g_noti_section, noti_count);
664 DBG("noti[%p] view[%p] added gridbox[%p]",
665 data, noti_box, g_noti_gridbox);
668 static void _quickpanel_noti_update_notilist(struct appdata *ad)
670 Evas_Object *list = NULL;
671 notification_h noti = NULL;
672 notification_h noti_save = NULL;
673 notification_list_h get_list = NULL;
674 int applist = NOTIFICATION_DISPLAY_APP_ALL;
678 retif(ad == NULL, , "Invalid parameter!");
681 retif(list == NULL, , "Failed to get noti genlist.");
683 _quickpanel_noti_clear_list_all();
685 notification_get_list(NOTIFICATION_TYPE_ONGOING, -1, &get_list);
686 while (get_list != NULL) {
687 noti = notification_list_get_data(get_list);
688 notification_get_display_applist(noti, &applist);
691 NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY) {
692 notification_clone(noti, ¬i_save);
693 _quickpanel_noti_ongoing_add(list, noti_save, LISTBOX_APPEND);
695 get_list = notification_list_get_next(get_list);
697 notification_free_list(get_list);
699 notification_get_list(NOTIFICATION_TYPE_NOTI , -1, &get_list);
700 while (get_list != NULL) {
701 noti = notification_list_get_data(get_list);
702 notification_get_display_applist(noti, &applist);
705 NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY) {
706 notification_clone(noti, ¬i_save);
707 _quickpanel_noti_noti_add(list, noti_save, GRIDBOX_APPEND);
709 get_list = notification_list_get_next(get_list);
711 notification_free_list(get_list);
713 if (g_noti_gridbox != NULL) {
714 elm_box_recalculate(g_noti_gridbox);
718 static void _quickpanel_noti_delete_volatil_data(void)
720 notification_list_h noti_list = NULL;
721 notification_list_h noti_list_head = NULL;
722 notification_h noti = NULL;
725 notification_get_grouping_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
727 noti_list_head = noti_list;
729 while (noti_list != NULL) {
730 noti = notification_list_get_data(noti_list);
731 notification_get_property(noti, &property);
733 if (property & NOTIFICATION_PROP_VOLATILE_DISPLAY) {
734 notification_set_property(noti,
736 NOTIFICATION_PROP_DISABLE_UPDATE_ON_DELETE);
737 notification_delete(noti);
740 noti_list = notification_list_get_next(noti_list);
743 notification_free_list(noti_list_head);
745 notification_update(NULL);
748 inline static void _print_debuginfo_from_noti(notification_h noti) {
749 retif(noti == NULL, , "Invalid parameter!");
751 char *noti_pkgname = NULL;
752 char *noti_launch_pkgname = NULL;
753 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
755 notification_get_pkgname(noti, ¬i_pkgname);
756 notification_get_application(noti, ¬i_launch_pkgname);
757 notification_get_type(noti, ¬i_type);
759 if (noti_pkgname != NULL) {
760 ERR("pkg:%s", noti_pkgname);
762 if (noti_launch_pkgname != NULL) {
763 ERR("pkgl:%s", noti_launch_pkgname);
766 ERR("type:%d", noti_type);
769 static void _quickpanel_noti_detailed_changed_cb(void *data, notification_type_e type, notification_op *op_list, int num_op)
774 struct appdata *ad = NULL;
775 notification_h noti_new = NULL;
776 notification_h noti_from_master = NULL;
777 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
778 int noti_applist = NOTIFICATION_DISPLAY_APP_ALL;
779 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
781 retif(data == NULL, , "Invalid parameter!");
784 ERR("num_op:%d", num_op);
786 for (i = 0; i < num_op; i++) {
787 notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_TYPE, &op_type);
788 notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_PRIV_ID, &priv_id);
789 notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_NOTI, ¬i_from_master);
791 ERR("noti operation:%d privid:%d", op_type, priv_id);
793 if (op_type == NOTIFICATION_OP_INSERT) {
795 if (noti_from_master == NULL) {
796 ERR("failed to get a notification from master");
799 if (notification_clone(noti_from_master, ¬i_new) != NOTIFICATION_ERROR_NONE) {
800 ERR("failed to create a cloned notification");
804 _print_debuginfo_from_noti(noti_new);
805 #ifdef QP_SERVICE_NOTI_LED_ENABLE
806 quickpanel_service_noti_led_on(noti_new);
809 notification_get_type(noti_new, ¬i_type);
810 notification_get_display_applist(noti_new, ¬i_applist);
811 notification_get_layout(noti_new, ¬i_layout);
813 if (noti_applist & NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY) {
814 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
816 if (noti_type == NOTIFICATION_TYPE_NOTI) {
817 DBG("cb after inserted:%d", priv_id);
819 notification_free(noti_new);
821 if (noti_type == NOTIFICATION_TYPE_NOTI) {
822 _quickpanel_noti_noti_add(ad->list, noti_new, GRIDBOX_PREPEND);
823 } else if (noti_type == NOTIFICATION_TYPE_ONGOING) {
824 _quickpanel_noti_ongoing_add(ad->list, noti_new, LISTBOX_PREPEND);
828 notification_free(noti_new);
830 } else if (op_type == NOTIFICATION_OP_DELETE) {
831 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
833 if (node != NULL && node->noti != NULL) {
834 notification_h noti = node->noti;
835 notification_get_type(noti, ¬i_type);
837 #ifdef QP_SERVICE_NOTI_LED_ENABLE
838 quickpanel_service_noti_led_off(noti);
840 _print_debuginfo_from_noti(noti);
842 if (noti_type == NOTIFICATION_TYPE_NOTI) {
843 gridbox_remove_item(g_noti_gridbox, node->view, 0);
844 } else if (noti_type == NOTIFICATION_TYPE_ONGOING) {
845 listbox_remove_item(g_noti_listbox, node->view, 0);
847 noti_node_remove(g_noti_node, priv_id);
849 } else if (op_type == NOTIFICATION_OP_UPDATE) {
850 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
851 notification_h old_noti = NULL;
853 if (noti_from_master == NULL) {
854 ERR("failed to get a notification from master");
857 if (notification_clone(noti_from_master, ¬i_new) != NOTIFICATION_ERROR_NONE) {
858 ERR("failed to create a cloned notification");
862 #ifdef QP_SERVICE_NOTI_LED_ENABLE
863 quickpanel_service_noti_led_on(noti_new);
865 _print_debuginfo_from_noti(noti_new);
867 if (node != NULL && node->view != NULL && node->noti != NULL) {
868 notification_get_type(noti_new, ¬i_type);
870 if (noti_type == NOTIFICATION_TYPE_NOTI) {
871 gridbox_remove_item(g_noti_gridbox, node->view, 0);
872 _quickpanel_noti_noti_add(ad->list, noti_new, GRIDBOX_PREPEND);
874 gridbox_remove_and_add_item(g_noti_gridbox, node->view,
875 _quickpanel_noti_noti_add
876 ,ad->list, noti_new, GRIDBOX_PREPEND);
878 } else if (noti_type == NOTIFICATION_TYPE_ONGOING) {
879 old_noti = node->noti;
880 node->noti = noti_new;
882 listbox_update_item(g_noti_listbox, node->view);
885 if (old_noti != NULL) {
886 notification_free(old_noti);
889 notification_get_display_applist(noti_new, ¬i_applist);
891 if (noti_applist & NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY) {
892 if (noti_type == NOTIFICATION_TYPE_NOTI) {
893 _quickpanel_noti_noti_add(ad->list, noti_new, GRIDBOX_PREPEND);
894 } else if (noti_type == NOTIFICATION_TYPE_ONGOING) {
895 _quickpanel_noti_ongoing_add(ad->list, noti_new, GRIDBOX_PREPEND);
898 notification_free(noti_new);
901 } else if (op_type == NOTIFICATION_OP_REFRESH) {
902 _quickpanel_noti_update_notilist(ad);
903 } else if (op_type == NOTIFICATION_OP_SERVICE_READY) {
904 _quickpanel_noti_update_notilist(ad);
906 #ifdef QP_SERVICE_NOTI_LED_ENABLE
907 quickpanel_service_noti_init(ad);
908 quickpanel_service_noti_led_on(NULL);
915 if ((noti_count = noti_node_get_item_count(g_noti_node, NOTIFICATION_TYPE_NOTI))
917 _quickpanel_noti_clear_notilist();
918 _quickpanel_noti_section_remove();
920 if (g_noti_section != NULL) {
921 noti_section_update(g_noti_section, noti_count);
925 ERR("current noti count:%d", noti_count);
928 static void _quickpanel_noti_update_desktop_cb(keynode_t *node, void *data)
931 char type[10] = {0,};
932 char package[1024] = {0,};
934 event = vconf_get_str(vconf_keynode_get_name(node));
935 retif(NULL == event, , "invalid event");
939 if (sscanf(event, "%10[^:]:%1023s", type, package) != 2) {
940 DBG("Failed to parse the event format : [%s], [%s]", type, package);
943 if (strncasecmp(type, "delete", strlen(type)) == 0) {
944 notification_delete_all_by_type(package, NOTIFICATION_TYPE_NONE);
951 static void _quickpanel_noti_update_sim_status_cb(keynode_t *node, void *data)
953 struct appdata *ad = data;
955 if (ad != NULL && ad->list != NULL) {
956 _quickpanel_noti_update_notilist(ad);
960 static int _quickpanel_noti_register_event_handler(struct appdata *ad)
963 retif(ad == NULL, QP_FAIL, "Invalid parameter!");
965 /* Add dbus signal */
967 ad->dbus_connection = e_dbus_bus_get(DBUS_BUS_SYSTEM);
968 if (ad->dbus_connection == NULL) {
969 ERR("noti register : failed to get dbus bus");
973 ad->dbus_handler_size =
974 e_dbus_signal_handler_add(ad->dbus_connection, NULL,
975 QP_NOTI_ONGOING_DBUS_PATH,
976 QP_NOTI_ONGOING_DBUS_INTERFACE, "update_progress",
977 _quickpanel_noti_item_progress_update_cb,
979 if (ad->dbus_handler_size == NULL)
980 ERR("fail to add size signal");
982 ad->dbus_handler_progress =
983 e_dbus_signal_handler_add(ad->dbus_connection, NULL,
984 QP_NOTI_ONGOING_DBUS_PATH,
985 QP_NOTI_ONGOING_DBUS_INTERFACE, "update_size",
986 _quickpanel_noti_item_size_update_cb,
988 if (ad->dbus_handler_progress == NULL)
989 ERR("fail to add progress signal");
991 ad->dbus_handler_content =
992 e_dbus_signal_handler_add(ad->dbus_connection, NULL,
993 QP_NOTI_ONGOING_DBUS_PATH,
994 QP_NOTI_ONGOING_DBUS_INTERFACE, "update_content",
995 _quickpanel_noti_item_content_update_cb,
997 if (ad->dbus_handler_content == NULL)
998 ERR("fail to add content signal");
1000 /* Notify vconf key */
1001 ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT,
1002 _quickpanel_noti_update_sim_status_cb,
1005 ERR("Failed to register SIM_SLOT change callback!");
1007 /* Notify vconf key */
1008 ret = vconf_notify_key_changed(VCONFKEY_MENUSCREEN_DESKTOP,
1009 _quickpanel_noti_update_desktop_cb,
1012 ERR("Failed to register DESKTOP change callback!");
1014 /* Register notification changed cb */
1015 notification_register_detailed_changed_cb(_quickpanel_noti_detailed_changed_cb, ad);
1020 static int _quickpanel_noti_unregister_event_handler(struct appdata *ad)
1024 /* Unregister notification changed cb */
1025 notification_unregister_detailed_changed_cb(_quickpanel_noti_detailed_changed_cb, (void *)ad);
1027 /* Ignore vconf key */
1028 ret = vconf_ignore_key_changed(VCONFKEY_MENUSCREEN_DESKTOP,
1029 _quickpanel_noti_update_desktop_cb);
1031 ERR("Failed to ignore DESKTOP change callback!");
1033 ret = vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT,
1034 _quickpanel_noti_update_sim_status_cb);
1036 ERR("Failed to ignore SIM_SLOT change callback!");
1038 /* Delete dbus signal */
1039 if (ad->dbus_handler_size != NULL) {
1040 e_dbus_signal_handler_del(ad->dbus_connection,
1041 ad->dbus_handler_size);
1042 ad->dbus_handler_size = NULL;
1044 if (ad->dbus_handler_progress != NULL) {
1045 e_dbus_signal_handler_del(ad->dbus_connection,
1046 ad->dbus_handler_progress);
1047 ad->dbus_handler_progress = NULL;
1049 if (ad->dbus_handler_content != NULL) {
1050 e_dbus_signal_handler_del(ad->dbus_connection,
1051 ad->dbus_handler_content);
1052 ad->dbus_handler_content = NULL;
1055 if (ad->dbus_connection != NULL) {
1056 e_dbus_connection_close(ad->dbus_connection);
1057 ad->dbus_connection = NULL;
1063 static int _quickpanel_noti_check_first_start(void)
1068 ret = vconf_get_bool(VCONFKEY_QUICKPANEL_STARTED, &status);
1069 if (ret == 0 && status == 0) {
1071 ret = vconf_set_bool(VCONFKEY_QUICKPANEL_STARTED, 1);
1072 INFO("set : %s, result : %d", VCONFKEY_QUICKPANEL_STARTED, ret);
1081 static void _quickpanel_noti_init(void *data)
1083 struct appdata *ad = NULL;
1085 retif(data == NULL, , "Invalid parameter!");
1088 retif(ad->list == NULL, , "Invalid parameter!");
1092 if (g_noti_listbox == NULL) {
1093 g_noti_listbox = listbox_create(ad->list, quickpanel_get_app_data());
1094 listbox_set_item_deleted_cb(g_noti_listbox, _quickpanel_list_box_deleted_cb);
1095 quickpanel_list_util_sort_insert(ad->list, g_noti_listbox);
1098 if (g_noti_gridbox == NULL) {
1099 g_noti_gridbox = gridbox_create(ad->list, quickpanel_get_app_data());
1100 gridbox_set_item_deleted_cb(g_noti_gridbox, _quickpanel_noti_box_deleted_cb);
1101 quickpanel_list_util_sort_insert(ad->list, g_noti_gridbox);
1105 static void _quickpanel_noti_fini(void *data)
1107 struct appdata *ad = NULL;
1109 retif(data == NULL, , "Invalid parameter!");
1112 retif(ad->list == NULL, , "Invalid parameter!");
1116 if (g_noti_listbox != NULL) {
1117 quickpanel_list_util_item_unpack_by_object(ad->list
1119 listbox_remove(g_noti_listbox);
1120 g_noti_listbox = NULL;
1123 if (g_noti_gridbox != NULL) {
1124 quickpanel_list_util_item_unpack_by_object(ad->list
1126 gridbox_remove(g_noti_gridbox);
1127 g_noti_gridbox = NULL;
1131 static void _quickpanel_noti_cleanup(void *data) {
1132 notifiation_clear(NOTIFICATION_TYPE_ONGOING);
1133 _quickpanel_noti_delete_volatil_data();
1136 static int quickpanel_noti_init(void *data)
1138 struct appdata *ad = data;
1141 retif(ad == NULL, QP_FAIL, "Invalid parameter!");
1143 noti_node_create(&g_noti_node);
1145 is_first = _quickpanel_noti_check_first_start();
1147 if (notification_is_service_ready()) {
1148 _quickpanel_noti_cleanup(ad);
1150 notification_add_deffered_task(_quickpanel_noti_cleanup, ad);
1154 _quickpanel_noti_init(ad);
1156 _quickpanel_noti_register_event_handler(ad);
1161 static int quickpanel_noti_fini(void *data)
1163 struct appdata *ad = data;
1164 retif(ad == NULL, QP_FAIL, "Invalid parameter!");
1166 #ifdef QP_SERVICE_NOTI_LED_ENABLE
1167 quickpanel_service_noti_fini(ad);
1168 quickpanel_service_noti_led_off(NULL);
1171 /* Unregister event handler */
1172 _quickpanel_noti_unregister_event_handler(data);
1174 _quickpanel_noti_clear_list_all();
1176 _quickpanel_noti_fini(ad);
1178 if (g_noti_node != NULL) {
1179 noti_node_destroy(&g_noti_node);
1185 static int quickpanel_noti_suspend(void *data)
1187 struct appdata *ad = data;
1188 retif(ad == NULL, QP_FAIL, "Invalid parameter!");
1193 static int quickpanel_noti_resume(void *data)
1195 struct appdata *ad = data;
1196 retif(ad == NULL, QP_FAIL, "Invalid parameter!");
1199 listbox_update(g_noti_listbox);
1205 static void quickpanel_noti_refresh(void *data) {
1206 struct appdata *ad = NULL;
1208 retif(data == NULL, , "Invalid parameter!");
1211 if (g_noti_gridbox != NULL) {
1212 gridbox_rotation(g_noti_gridbox, ad->angle);
1216 static void quickpanel_noti_lang_changed(void *data)
1218 struct appdata *ad = data;
1220 retif(ad == NULL, , "Invalid parameter!");
1222 _quickpanel_noti_update_notilist(ad);