2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (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"
38 #ifndef VCONFKEY_QUICKPANEL_STARTED
39 #define VCONFKEY_QUICKPANEL_STARTED "memory/private/"PACKAGE_NAME"/started"
40 #endif /* VCONFKEY_QUICKPANEL_STARTED */
42 #define QP_NOTI_ONGOING_DBUS_PATH "/dbus/signal"
43 #define QP_NOTI_ONGOING_DBUS_INTERFACE "notification.ongoing"
45 static noti_node *g_noti_node;
46 static Evas_Object *g_noti_section;
47 static Evas_Object *g_noti_listbox;
48 static Evas_Object *g_noti_gridbox;
49 static Eina_List *g_animated_image_list;
51 static int quickpanel_noti_init(void *data);
52 static int quickpanel_noti_fini(void *data);
53 static int quickpanel_noti_suspend(void *data);
54 static int quickpanel_noti_resume(void *data);
55 static void quickpanel_noti_lang_changed(void *data);
56 static void quickpanel_noti_refresh(void *data);
60 .init = quickpanel_noti_init,
61 .fini = quickpanel_noti_fini,
62 .suspend = quickpanel_noti_suspend,
63 .resume = quickpanel_noti_resume,
64 .lang_changed = quickpanel_noti_lang_changed,
67 .refresh = quickpanel_noti_refresh,
71 static notification_h _quickpanel_noti_update_item_progress(const char *pkgname,
75 char *noti_pkgname = NULL;
78 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
80 if (node != NULL && node->noti != NULL) {
81 notification_get_pkgname(node->noti, ¬i_pkgname);
82 notification_get_id(node->noti, NULL, ¬i_priv_id);
83 if (!strcmp(noti_pkgname, pkgname)
84 && priv_id == noti_priv_id) {
86 if (notification_set_progress(node->noti, progress) != NOTIFICATION_ERROR_NONE) {
87 ERR("fail to set progress");
96 static notification_h _quickpanel_noti_update_item_size(const char *pkgname,
100 char *noti_pkgname = NULL;
101 int noti_priv_id = 0;
103 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
105 if (node != NULL && node->noti != NULL) {
106 notification_get_pkgname(node->noti, ¬i_pkgname);
107 notification_get_id(node->noti, NULL, ¬i_priv_id);
108 if (!strcmp(noti_pkgname, pkgname)
109 && priv_id == noti_priv_id) {
110 notification_set_size(node->noti, size);
118 static notification_h _quickpanel_noti_update_item_content(const char *pkgname,
122 char *noti_pkgname = NULL;
123 int noti_priv_id = 0;
125 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
127 if (node != NULL && node->noti != NULL) {
128 notification_get_pkgname(node->noti, ¬i_pkgname);
129 notification_get_id(node->noti, NULL, ¬i_priv_id);
130 if (!strcmp(noti_pkgname, pkgname)
131 && priv_id == noti_priv_id) {
132 notification_set_text(node->noti,
133 NOTIFICATION_TEXT_TYPE_CONTENT,
135 NOTIFICATION_VARIABLE_TYPE_NONE);
143 static void _quickpanel_noti_update_progressbar(void *data,
144 notification_h update_noti)
146 struct appdata *ad = NULL;
147 Elm_Object_Item *found = NULL;
148 noti_node_item *node = NULL;
150 retif(!data, , "data is NULL");
153 retif(!ad->list, , "ad->list is NULL");
157 if (notification_get_id(update_noti, NULL, &priv_id) == NOTIFICATION_ERROR_NONE) {
158 node = noti_node_get(g_noti_node, priv_id);
165 retif(node == NULL, , "fail to find node of priv_id:%d", priv_id);
166 retif(node->view == NULL, , "fail to find %p", node->view);
168 listbox_update_item(g_noti_listbox, node->view);
171 static void _quickpanel_noti_item_progress_update_cb(void *data,
178 notification_h noti = NULL;
180 retif(data == NULL || msg == NULL, , "Invalid parameter!");
182 dbus_error_init(&err);
183 dbus_message_get_args(msg, &err,
184 DBUS_TYPE_STRING, &pkgname,
185 DBUS_TYPE_INT32, &priv_id,
186 DBUS_TYPE_DOUBLE, &progress,
189 if (dbus_error_is_set(&err)) {
190 ERR("dbus err: %s", err.message);
191 dbus_error_free(&err);
195 if (pkgname == NULL) {
196 ERR("pkgname is null");
200 /* check item on the list */
201 noti = _quickpanel_noti_update_item_progress(pkgname,
203 retif(noti == NULL, , "Can not found noti data.");
205 DBG("pkgname[%s], priv_id[%d], progress[%lf]",
206 pkgname, priv_id, progress);
207 if (!quickpanel_is_suspended())
208 _quickpanel_noti_update_progressbar(data, noti);
211 static void _quickpanel_noti_item_size_update_cb(void *data, DBusMessage * msg)
217 notification_h noti = NULL;
219 retif(data == NULL || msg == NULL, , "Invalid parameter!");
221 dbus_error_init(&err);
222 dbus_message_get_args(msg, &err,
223 DBUS_TYPE_STRING, &pkgname,
224 DBUS_TYPE_INT32, &priv_id,
225 DBUS_TYPE_DOUBLE, &size, DBUS_TYPE_INVALID);
226 if (dbus_error_is_set(&err)) {
227 ERR("dbus err: %s", err.message);
228 dbus_error_free(&err);
232 if (pkgname == NULL) {
233 ERR("pkgname is null");
237 /* check item on the list */
238 noti = _quickpanel_noti_update_item_size(pkgname, priv_id, size);
239 retif(noti == NULL, , "Can not found noti data.");
241 DBG("pkgname[%s], priv_id[%d], progress[%lf]",
242 pkgname, priv_id, size);
244 if (!quickpanel_is_suspended())
245 _quickpanel_noti_update_progressbar(data, noti);
248 static void _quickpanel_noti_item_content_update_cb(void *data,
252 char *pkgname = NULL;
254 char *content = NULL;
255 notification_h noti = NULL;
257 retif(data == NULL || msg == NULL, , "Invalid parameter!");
259 dbus_error_init(&err);
260 dbus_message_get_args(msg, &err,
261 DBUS_TYPE_STRING, &pkgname,
262 DBUS_TYPE_INT32, &priv_id,
263 DBUS_TYPE_STRING, &content, DBUS_TYPE_INVALID);
265 if (pkgname == NULL) {
266 ERR("pkgname is null");
269 if (content == NULL) {
270 ERR("content is null");
274 if (dbus_error_is_set(&err)) {
275 ERR("dbus err: %s", err.message);
276 dbus_error_free(&err);
280 DBG("pkgname[%s], priv_id[%d], content[%s]",
281 pkgname, priv_id, content);
283 /* check item on the list */
284 noti = _quickpanel_noti_update_item_content(pkgname, priv_id, content);
285 retif(noti == NULL, , "Can not found noti data.");
287 if (!quickpanel_is_suspended())
288 _quickpanel_noti_update_progressbar(data, noti);
291 static void _quickpanel_noti_ani_image_control(Eina_Bool on)
293 const Eina_List *l = NULL;
294 const Eina_List *ln = NULL;
295 Evas_Object *entry_obj = NULL;
297 retif(g_animated_image_list == NULL, ,"");
299 EINA_LIST_FOREACH_SAFE(g_animated_image_list, l, ln, entry_obj) {
300 if (entry_obj == NULL) continue;
302 if (on == EINA_TRUE) {
303 if (elm_image_animated_play_get(entry_obj) == EINA_FALSE) {
304 elm_image_animated_play_set(entry_obj, EINA_TRUE);
307 if (elm_image_animated_play_get(entry_obj) == EINA_TRUE) {
308 elm_image_animated_play_set(entry_obj, EINA_FALSE);
314 static void _quickpanel_noti_ani_image_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
316 retif(obj == NULL, , "obj is NULL");
317 retif(g_animated_image_list == NULL, , "list is empty");
319 g_animated_image_list = eina_list_remove(g_animated_image_list, obj);
322 static void _quickpanel_do_noti_delete(notification_h noti) {
323 char *pkgname = NULL;
324 char *caller_pkgname = NULL;
325 int flags = 0, priv_id = 0, flag_delete = 0;
326 notification_type_e type = NOTIFICATION_TYPE_NONE;
328 quickpanel_play_feedback();
330 retif(noti == NULL, , "Invalid parameter!");
332 notification_get_pkgname(noti, &caller_pkgname);
333 notification_get_application(noti, &pkgname);
335 pkgname = caller_pkgname;
337 notification_get_id(noti, NULL, &priv_id);
338 notification_get_property(noti, &flags);
339 notification_get_type(noti, &type);
341 if (flags & NOTIFICATION_PROP_PERMANENT_DISPLAY)
346 if (flag_delete == 1 && type == NOTIFICATION_TYPE_NOTI) {
347 notification_delete_by_priv_id(caller_pkgname, NOTIFICATION_TYPE_NOTI,
352 static void _quickpanel_do_noti_press(notification_h noti, int pressed_area) {
354 char *pkgname = NULL;
355 char *caller_pkgname = NULL;
357 bundle *group_args = NULL;
358 bundle *responding_service_handle = NULL;
359 bundle *single_service_handle = NULL;
360 bundle *multi_service_handle = NULL;
361 int flags = 0, group_id = 0, priv_id = 0, count = 0, flag_launch = 0,
363 notification_type_e type = NOTIFICATION_TYPE_NONE;
365 quickpanel_play_feedback();
367 retif(noti == NULL, , "Invalid parameter!");
369 notification_get_pkgname(noti, &caller_pkgname);
370 notification_get_application(noti, &pkgname);
372 pkgname = caller_pkgname;
374 notification_get_id(noti, &group_id, &priv_id);
375 notification_get_property(noti, &flags);
376 notification_get_type(noti, &type);
378 if (flags & NOTIFICATION_PROP_DISABLE_APP_LAUNCH)
383 if (flags & NOTIFICATION_PROP_DISABLE_AUTO_DELETE)
388 notification_get_execute_option(noti,
389 NOTIFICATION_EXECUTE_TYPE_RESPONDING,
390 NULL, &responding_service_handle);
391 notification_get_execute_option(noti,
392 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
393 NULL, &single_service_handle);
394 notification_get_execute_option(noti,
395 NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH,
396 NULL, &multi_service_handle);
398 if (pressed_area == NOTI_PRESS_BUTTON_1 && responding_service_handle != NULL) {
400 quickpanel_close_quickpanel(true);
401 ret = quickpanel_launch_app(NULL, responding_service_handle);
402 quickpanel_launch_app_inform_result(pkgname, ret);
403 } else if (flag_launch == 1) {
404 /* Hide quickpanel */
405 quickpanel_close_quickpanel(true);
407 char *text_count = NULL;
408 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &text_count);
410 if (text_count != NULL) {
411 count = atoi(text_count);
416 if (single_service_handle != NULL && multi_service_handle == NULL) {
418 ret = quickpanel_launch_app(NULL, single_service_handle);
419 quickpanel_launch_app_inform_result(pkgname, ret);
421 if (single_service_handle == NULL && multi_service_handle != NULL) {
423 ret = quickpanel_launch_app(NULL, multi_service_handle);
424 quickpanel_launch_app_inform_result(pkgname, ret);
426 if (single_service_handle != NULL && multi_service_handle != NULL) {
429 ret = quickpanel_launch_app(NULL, single_service_handle);
430 quickpanel_launch_app_inform_result(pkgname, ret);
432 ret = quickpanel_launch_app(NULL, multi_service_handle);
433 quickpanel_launch_app_inform_result(pkgname, ret);
436 if (single_service_handle == NULL && multi_service_handle == NULL) {
438 notification_get_args(noti, &args, &group_args);
440 if (count > 1 && group_args != NULL) {
441 ret = quickpanel_launch_app(pkgname, group_args);
442 quickpanel_launch_app_inform_result(pkgname, ret);
444 ret = quickpanel_launch_app(pkgname, args);
445 quickpanel_launch_app_inform_result(pkgname, ret);
450 if (flag_delete == 1 && type == NOTIFICATION_TYPE_NOTI) {
451 notification_delete_by_priv_id(caller_pkgname,
452 NOTIFICATION_TYPE_NOTI,
457 static void quickpanel_notibox_delete_cb(void *data, Evas_Object * obj) {
459 noti_node_item *item = data;
460 retif(item == NULL, , "Invalid parameter!");
462 notification_h noti = item->noti;
463 retif(noti == NULL, , "Invalid parameter!");
465 _quickpanel_do_noti_delete(noti);
469 static void quickpanel_notibox_button_1_cb(void *data, Evas_Object * obj) {
471 noti_node_item *item = data;
472 retif(item == NULL, , "Invalid parameter!");
474 notification_h noti = item->noti;
475 retif(noti == NULL, , "Invalid parameter!");
477 _quickpanel_do_noti_press(noti, NOTI_PRESS_BUTTON_1);
480 static void quickpanel_notibox_select_cb(void *data, Evas_Object * obj) {
482 noti_node_item *item = data;
483 retif(item == NULL, , "Invalid parameter!");
485 notification_h noti = item->noti;
486 retif(noti == NULL, , "Invalid parameter!");
488 _quickpanel_do_noti_press(noti, NOTI_PRESS_BG);
491 static void quickpanel_noti_listitem_select_cb(void *data, Evas_Object * obj) {
493 noti_node_item *item = data;
494 retif(item == NULL, , "Invalid parameter!");
496 notification_h noti = item->noti;
497 retif(noti == NULL, , "Invalid parameter!");
499 _quickpanel_do_noti_press(noti, NOTI_PRESS_BG);
502 static inline void __ongoing_comp_n_copy(notification_h old, notification_h new)
506 char *pkgname = NULL;
507 char *new_pkgname = NULL;
515 notification_get_id(old, NULL, &priv_id);
516 notification_get_id(new, NULL, &new_priv_id);
518 notification_get_pkgname(old, &pkgname);
519 notification_get_pkgname(new, &new_pkgname);
521 if (!pkgname || !new_pkgname)
524 if (!strcmp(pkgname, new_pkgname) && priv_id == new_priv_id) {
525 double percentage = 0.0;
527 time_t insert_time = 0;
528 time_t new_insert_time = 0;
530 notification_get_progress(old, &percentage);
531 notification_get_size(old, &size);
532 if (notification_set_progress(new, percentage) != NOTIFICATION_ERROR_NONE) {
533 ERR("fail to set progress");
535 if (notification_set_size(new, size) != NOTIFICATION_ERROR_NONE) {
536 ERR("fail to set size");
538 notification_get_insert_time(old, &insert_time);
539 notification_get_insert_time(new, &new_insert_time);
541 if (insert_time == new_insert_time) {
542 char *content = NULL;
543 notification_get_text(old,
544 NOTIFICATION_TEXT_TYPE_CONTENT, &content);
545 notification_set_text(new,
546 NOTIFICATION_TEXT_TYPE_CONTENT, content,
547 NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
552 static void _quickpanel_noti_clear_ongoinglist()
554 if (g_noti_listbox != NULL) {
555 listbox_remove_all_item(g_noti_listbox, EINA_FALSE);
559 static void _quickpanel_noti_clear_notilist(void)
561 if (g_noti_gridbox != NULL) {
562 gridbox_remove_all_item(g_noti_gridbox, EINA_FALSE);
566 static void _quickpanel_noti_clear_list_all(void)
568 _quickpanel_noti_clear_ongoinglist();
569 _quickpanel_noti_clear_notilist();
572 static void _quickpanel_noti_section_add(void)
574 struct appdata *ad = quickpanel_get_app_data();
575 retif(ad == NULL, , "Invalid parameter!");
576 retif(ad->list == NULL, , "Invalid parameter!");
578 if (g_noti_section == NULL) {
579 g_noti_section = noti_section_create(ad->list);
580 if (g_noti_section != NULL) {
581 quickpanel_list_util_sort_insert(ad->list, g_noti_section);
582 DBG("noti section[%p]", g_noti_section);
587 static void _quickpanel_noti_section_remove(void)
589 struct appdata *ad = quickpanel_get_app_data();
590 retif(ad == NULL, , "Invalid parameter!");
591 retif(ad->list == NULL, , "Invalid parameter!");
593 if (g_noti_section != NULL) {
594 quickpanel_list_util_item_unpack_by_type(ad->list, QP_ITEM_TYPE_NOTI_GROUP);
595 noti_section_remove(g_noti_section);
596 g_noti_section = NULL;
600 static void _quickpanel_noti_box_deleted_cb(void *data, Evas_Object *obj) {
603 retif(data == NULL, , "Invalid parameter!");
604 DBG("deleting:%p", data);
606 noti_node_item *item = data;
607 notification_h noti = item->noti;
610 notification_get_id(noti, NULL, &priv_id);
611 noti_node_remove(g_noti_node, priv_id);
615 static void _quickpanel_list_box_deleted_cb(void *data, Evas_Object *obj) {
618 retif(data == NULL, , "Invalid parameter!");
619 DBG("deleting:%p", data);
621 noti_node_item *item = data;
622 notification_h noti = item->noti;
625 notification_get_id(noti, NULL, &priv_id);
626 noti_node_remove(g_noti_node, priv_id);
630 static void _quickpanel_noti_ongoing_add(Evas_Object *list, void *data, int is_prepend)
632 Evas_Object *noti_list_item = NULL;
633 notification_ly_type_e layout = NOTIFICATION_LY_ONGOING_EVENT;
635 retif(list == NULL, , "Invalid parameter!");
636 notification_h noti = data;
639 notification_get_layout(noti, &layout);
640 noti_list_item = noti_list_item_create(g_noti_listbox, layout);
642 if (noti_list_item != NULL) {
643 noti_node_item *item = noti_node_add(g_noti_node, (void*)data, (void*)noti_list_item);
645 noti_list_item_node_set(noti_list_item, item);
646 noti_list_item_set_item_selected_cb(noti_list_item, quickpanel_noti_listitem_select_cb);
647 listbox_add_item(g_noti_listbox, noti_list_item, is_prepend);
650 ERR("fail to insert item to list : %p", data);
653 DBG("noti[%p] data[%p] added listbox[%p]",
654 data, noti_list_item, g_noti_listbox);
657 static void _quickpanel_noti_noti_add(Evas_Object *list, void *data, int is_prepend)
659 notification_h noti = data;
660 notification_ly_type_e layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
661 Evas_Object *noti_box = NULL;
663 retif(list == NULL, , "Invalid parameter!");
665 if (g_noti_section == NULL) {
666 _quickpanel_noti_section_add();
670 notification_get_layout(noti, &layout);
671 Evas_Object *noti_box = noti_box_create(g_noti_gridbox, layout);
673 if (noti_box != NULL) {
674 noti_node_item *item = noti_node_add(g_noti_node, (void*)data, (void*)noti_box);
676 noti_box_node_set(noti_box, item);
677 noti_box_set_item_selected_cb(noti_box, quickpanel_notibox_select_cb);
678 noti_box_set_item_button_1_cb(noti_box, quickpanel_notibox_button_1_cb);
679 noti_box_set_item_deleted_cb(noti_box, quickpanel_notibox_delete_cb);
680 gridbox_add_item(g_noti_gridbox, noti_box, is_prepend);
683 ERR("fail to insert item to list : %p", data);
687 noti_node_get_item_count(g_noti_node, NOTIFICATION_TYPE_NOTI);
689 if (g_noti_section != NULL) {
690 noti_section_update(g_noti_section, noti_count);
693 DBG("noti[%p] view[%p] added gridbox[%p]",
694 data, noti_box, g_noti_gridbox);
697 static void _quickpanel_noti_update_notilist(struct appdata *ad)
699 Evas_Object *list = NULL;
700 notification_h noti = NULL;
701 notification_h noti_save = NULL;
702 notification_list_h get_list = NULL;
703 int applist = NOTIFICATION_DISPLAY_APP_ALL;
707 retif(ad == NULL, , "Invalid parameter!");
710 retif(list == NULL, , "Failed to get noti genlist.");
712 _quickpanel_noti_clear_list_all();
714 notification_get_list(NOTIFICATION_TYPE_ONGOING, -1, &get_list);
715 while (get_list != NULL) {
716 noti = notification_list_get_data(get_list);
717 notification_get_display_applist(noti, &applist);
720 NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY) {
721 notification_clone(noti, ¬i_save);
722 _quickpanel_noti_ongoing_add(list, noti_save, LISTBOX_APPEND);
724 get_list = notification_list_get_next(get_list);
726 notification_free_list(get_list);
728 notification_get_list(NOTIFICATION_TYPE_NOTI , -1, &get_list);
729 while (get_list != NULL) {
730 noti = notification_list_get_data(get_list);
731 notification_get_display_applist(noti, &applist);
734 NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY) {
735 notification_clone(noti, ¬i_save);
736 _quickpanel_noti_noti_add(list, noti_save, GRIDBOX_APPEND);
738 get_list = notification_list_get_next(get_list);
740 notification_free_list(get_list);
742 if (g_noti_gridbox != NULL) {
743 elm_box_recalculate(g_noti_gridbox);
747 static void _quickpanel_noti_delete_volatil_data(void)
749 notification_list_h noti_list = NULL;
750 notification_list_h noti_list_head = NULL;
751 notification_h noti = NULL;
754 notification_get_grouping_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
756 noti_list_head = noti_list;
758 while (noti_list != NULL) {
759 noti = notification_list_get_data(noti_list);
760 notification_get_property(noti, &property);
762 if (property & NOTIFICATION_PROP_VOLATILE_DISPLAY) {
763 notification_set_property(noti,
765 NOTIFICATION_PROP_DISABLE_UPDATE_ON_DELETE);
766 notification_delete(noti);
769 noti_list = notification_list_get_next(noti_list);
772 notification_free_list(noti_list_head);
774 notification_update(NULL);
777 static void _quickpanel_noti_detailed_changed_cb(void *data, notification_type_e type, notification_op *op_list, int num_op)
782 struct appdata *ad = NULL;
783 notification_h new_noti = NULL;
784 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
785 int noti_applist = NOTIFICATION_DISPLAY_APP_ALL;
786 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
788 retif(data == NULL, , "Invalid parameter!");
791 DBG("test detailed quickpanel:%d", num_op);
793 for (i = 0; i < num_op; i++) {
794 notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_TYPE, &op_type);
795 DBG("op_type:%d", op_type);
796 notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_PRIV_ID, &priv_id);
797 DBG("op_priv_id:%d", priv_id);
799 if (op_type == NOTIFICATION_OP_INSERT) {
800 new_noti = notification_load(NULL, priv_id);
801 if (new_noti == NULL) continue;
803 notification_get_type(new_noti, ¬i_type);
804 notification_get_display_applist(new_noti, ¬i_applist);
805 notification_get_layout(new_noti, ¬i_layout);
807 DBG("layout:%d", noti_layout);
809 if (noti_applist & NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY) {
810 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
812 if (noti_type == NOTIFICATION_TYPE_NOTI) {
813 DBG("cb after inserted:%d", priv_id);
816 if (noti_type == NOTIFICATION_TYPE_NOTI) {
817 _quickpanel_noti_noti_add(ad->list, new_noti, GRIDBOX_PREPEND);
818 } else if (noti_type == NOTIFICATION_TYPE_ONGOING) {
819 _quickpanel_noti_ongoing_add(ad->list, new_noti, LISTBOX_PREPEND);
822 DBG("%d noti added", priv_id);
824 notification_free(new_noti);
827 if (op_type == NOTIFICATION_OP_DELETE) {
828 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
830 if (node != NULL && node->noti != NULL) {
831 notification_h noti = node->noti;
832 notification_get_type(noti, ¬i_type);
834 if (noti_type == NOTIFICATION_TYPE_NOTI) {
835 gridbox_remove_item(g_noti_gridbox, node->view, 0);
836 } else if (noti_type == NOTIFICATION_TYPE_ONGOING) {
837 listbox_remove_item(g_noti_listbox, node->view, 0);
839 noti_node_remove(g_noti_node, priv_id);
841 DBG("%d noti deleted", priv_id);
843 if (op_type == NOTIFICATION_OP_UPDATE) {
844 noti_node_item *node = noti_node_get(g_noti_node, priv_id);
845 notification_h old_noti = NULL;
847 new_noti = notification_load(NULL, priv_id);
848 retif(new_noti == NULL, , "fail to load updated noti");
850 if (node != NULL && node->view != NULL && node->noti != NULL) {
851 notification_get_type(new_noti, ¬i_type);
853 if (noti_type == NOTIFICATION_TYPE_NOTI) {
854 gridbox_remove_item(g_noti_gridbox, node->view, 0);
855 _quickpanel_noti_noti_add(ad->list, new_noti, GRIDBOX_PREPEND);
857 gridbox_remove_and_add_item(g_noti_gridbox, node->view,
858 _quickpanel_noti_noti_add
859 ,ad->list, new_noti, GRIDBOX_PREPEND);
861 } else if (noti_type == NOTIFICATION_TYPE_ONGOING) {
862 old_noti = node->noti;
863 node->noti = new_noti;
865 listbox_update_item(g_noti_listbox, node->view);
868 if (old_noti != NULL) {
869 notification_free(old_noti);
872 notification_get_display_applist(new_noti, ¬i_applist);
874 if (noti_applist & NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY) {
876 if (noti_type == NOTIFICATION_TYPE_NOTI) {
877 _quickpanel_noti_noti_add(ad->list, new_noti, GRIDBOX_PREPEND);
878 } else if (noti_type == NOTIFICATION_TYPE_ONGOING) {
879 _quickpanel_noti_ongoing_add(ad->list, new_noti, GRIDBOX_PREPEND);
884 DBG("%d noti updated", priv_id);
890 if ((noti_count = noti_node_get_item_count(g_noti_node, NOTIFICATION_TYPE_NOTI))
893 _quickpanel_noti_clear_notilist();
894 _quickpanel_noti_section_remove();
896 if (g_noti_section != NULL) {
898 noti_section_update(g_noti_section, noti_count);
903 static void _quickpanel_noti_update_desktop_cb(keynode_t *node, void *data)
906 char type[10] = {0,};
907 char package[1024] = {0,};
909 event = vconf_get_str(vconf_keynode_get_name(node));
910 retif(NULL == event, , "invalid event");
914 if (sscanf(event, "%10[^:]:%1023s", type, package) != 2) {
915 DBG("Failed to parse the event format : [%s], [%s]", type, package);
918 if (strncasecmp(type, "delete", strlen(type)) == 0) {
919 notification_delete_all_by_type(package, NOTIFICATION_TYPE_NONE);
926 static void _quickpanel_noti_update_sim_status_cb(keynode_t *node, void *data)
928 struct appdata *ad = data;
930 if (ad != NULL && ad->list != NULL) {
931 _quickpanel_noti_update_notilist(ad);
935 static int _quickpanel_noti_register_event_handler(struct appdata *ad)
938 retif(ad == NULL, QP_FAIL, "Invalid parameter!");
940 /* Add dbus signal */
942 ad->dbus_connection = e_dbus_bus_get(DBUS_BUS_SYSTEM);
943 if (ad->dbus_connection == NULL) {
944 ERR("noti register : failed to get dbus bus");
948 ad->dbus_handler_size =
949 e_dbus_signal_handler_add(ad->dbus_connection, NULL,
950 QP_NOTI_ONGOING_DBUS_PATH,
951 QP_NOTI_ONGOING_DBUS_INTERFACE, "update_progress",
952 _quickpanel_noti_item_progress_update_cb,
954 if (ad->dbus_handler_size == NULL)
955 ERR("fail to add size signal");
957 ad->dbus_handler_progress =
958 e_dbus_signal_handler_add(ad->dbus_connection, NULL,
959 QP_NOTI_ONGOING_DBUS_PATH,
960 QP_NOTI_ONGOING_DBUS_INTERFACE, "update_size",
961 _quickpanel_noti_item_size_update_cb,
963 if (ad->dbus_handler_progress == NULL)
964 ERR("fail to add progress signal");
966 ad->dbus_handler_content =
967 e_dbus_signal_handler_add(ad->dbus_connection, NULL,
968 QP_NOTI_ONGOING_DBUS_PATH,
969 QP_NOTI_ONGOING_DBUS_INTERFACE, "update_content",
970 _quickpanel_noti_item_content_update_cb,
972 if (ad->dbus_handler_content == NULL)
973 ERR("fail to add content signal");
975 /* Notify vconf key */
976 ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT,
977 _quickpanel_noti_update_sim_status_cb,
980 ERR("Failed to register SIM_SLOT change callback!");
982 /* Notify vconf key */
983 ret = vconf_notify_key_changed(VCONFKEY_MENUSCREEN_DESKTOP,
984 _quickpanel_noti_update_desktop_cb,
987 ERR("Failed to register DESKTOP change callback!");
989 /* Register notification changed cb */
990 notification_register_detailed_changed_cb(_quickpanel_noti_detailed_changed_cb, ad);
995 static int _quickpanel_noti_unregister_event_handler(struct appdata *ad)
999 /* Unregister notification changed cb */
1000 notification_unregister_detailed_changed_cb(_quickpanel_noti_detailed_changed_cb, (void *)ad);
1002 /* Ignore vconf key */
1003 ret = vconf_ignore_key_changed(VCONFKEY_MENUSCREEN_DESKTOP,
1004 _quickpanel_noti_update_desktop_cb);
1006 ERR("Failed to ignore DESKTOP change callback!");
1008 ret = vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SIM_SLOT,
1009 _quickpanel_noti_update_sim_status_cb);
1011 ERR("Failed to ignore SIM_SLOT change callback!");
1013 /* Delete dbus signal */
1014 if (ad->dbus_handler_size != NULL) {
1015 e_dbus_signal_handler_del(ad->dbus_connection,
1016 ad->dbus_handler_size);
1017 ad->dbus_handler_size = NULL;
1019 if (ad->dbus_handler_progress != NULL) {
1020 e_dbus_signal_handler_del(ad->dbus_connection,
1021 ad->dbus_handler_progress);
1022 ad->dbus_handler_progress = NULL;
1024 if (ad->dbus_handler_content != NULL) {
1025 e_dbus_signal_handler_del(ad->dbus_connection,
1026 ad->dbus_handler_content);
1027 ad->dbus_handler_content = NULL;
1030 if (ad->dbus_connection != NULL) {
1031 e_dbus_connection_close(ad->dbus_connection);
1032 ad->dbus_connection = NULL;
1038 static int _quickpanel_noti_check_first_start(void)
1043 ret = vconf_get_bool(VCONFKEY_QUICKPANEL_STARTED, &status);
1045 INFO("fail to get %s", VCONFKEY_QUICKPANEL_STARTED);
1047 ret = vconf_set_bool(VCONFKEY_QUICKPANEL_STARTED, 1);
1048 INFO("set : %s, result : %d", VCONFKEY_QUICKPANEL_STARTED, ret);
1057 static void _quickpanel_noti_init(void *data)
1059 struct appdata *ad = NULL;
1061 retif(data == NULL, , "Invalid parameter!");
1064 retif(ad->list == NULL, , "Invalid parameter!");
1068 if (g_noti_listbox == NULL) {
1069 g_noti_listbox = listbox_create(ad->list, quickpanel_get_app_data());
1070 listbox_set_item_deleted_cb(g_noti_listbox, _quickpanel_list_box_deleted_cb);
1071 quickpanel_list_util_sort_insert(ad->list, g_noti_listbox);
1074 if (g_noti_gridbox == NULL) {
1075 g_noti_gridbox = gridbox_create(ad->list, quickpanel_get_app_data());
1076 gridbox_set_item_deleted_cb(g_noti_gridbox, _quickpanel_noti_box_deleted_cb);
1077 quickpanel_list_util_sort_insert(ad->list, g_noti_gridbox);
1080 /* Update notification list */
1081 _quickpanel_noti_update_notilist(ad);
1084 static void _quickpanel_noti_fini(void *data)
1086 struct appdata *ad = NULL;
1088 retif(data == NULL, , "Invalid parameter!");
1091 retif(ad->list == NULL, , "Invalid parameter!");
1095 if (g_noti_listbox != NULL) {
1096 quickpanel_list_util_item_unpack_by_object(ad->list
1098 listbox_remove(g_noti_listbox);
1099 g_noti_listbox = NULL;
1102 if (g_noti_gridbox != NULL) {
1103 quickpanel_list_util_item_unpack_by_object(ad->list
1105 gridbox_remove(g_noti_gridbox);
1106 g_noti_gridbox = NULL;
1110 static int quickpanel_noti_init(void *data)
1112 struct appdata *ad = data;
1115 retif(ad == NULL, QP_FAIL, "Invalid parameter!");
1117 noti_node_create(&g_noti_node);
1119 is_first = _quickpanel_noti_check_first_start();
1121 /* Remove ongoing and volatile noti data */
1122 notifiation_clear(NOTIFICATION_TYPE_ONGOING);
1123 _quickpanel_noti_delete_volatil_data();
1126 _quickpanel_noti_init(ad);
1128 _quickpanel_noti_register_event_handler(ad);
1133 static int quickpanel_noti_fini(void *data)
1135 struct appdata *ad = data;
1136 retif(ad == NULL, QP_FAIL, "Invalid parameter!");
1138 /* Unregister event handler */
1139 _quickpanel_noti_unregister_event_handler(data);
1141 _quickpanel_noti_clear_list_all();
1143 _quickpanel_noti_fini(ad);
1145 if (g_noti_node != NULL) {
1146 noti_node_destroy(&g_noti_node);
1152 static int quickpanel_noti_suspend(void *data)
1154 struct appdata *ad = data;
1155 retif(ad == NULL, QP_FAIL, "Invalid parameter!");
1158 _quickpanel_noti_ani_image_control(EINA_FALSE);
1164 static int quickpanel_noti_resume(void *data)
1166 struct appdata *ad = data;
1167 retif(ad == NULL, QP_FAIL, "Invalid parameter!");
1170 listbox_update(g_noti_listbox);
1172 _quickpanel_noti_ani_image_control(EINA_TRUE);
1178 static void quickpanel_noti_refresh(void *data) {
1179 struct appdata *ad = NULL;
1181 retif(data == NULL, , "Invalid parameter!");
1184 if (g_noti_gridbox != NULL) {
1185 gridbox_rotation(g_noti_gridbox, ad->angle);
1189 static void quickpanel_noti_lang_changed(void *data)
1191 struct appdata *ad = data;
1193 retif(ad == NULL, , "Invalid parameter!");
1195 _quickpanel_noti_update_notilist(ad);