diff options
Diffstat (limited to 'daemon/notifications/activenoti.c')
-rwxr-xr-x[-rw-r--r--] | daemon/notifications/activenoti.c | 1488 |
1 files changed, 878 insertions, 610 deletions
diff --git a/daemon/notifications/activenoti.c b/daemon/notifications/activenoti.c index dc9ff3d..64ef6df 100644..100755 --- a/daemon/notifications/activenoti.c +++ b/daemon/notifications/activenoti.c @@ -17,24 +17,35 @@ #include <Elementary.h> +#include <glib.h> + #include <appcore-common.h> #include <vconf.h> #include <app_control.h> #include <notification.h> #include <feedback.h> #include <system_settings.h> -#ifdef HAVE_X -#include <utilX.h> -#endif +#include <notification_internal.h> +#include <notification_setting_internal.h> +#include <notification_text_domain.h> +#include <player.h> +#include <tzsh.h> +#include <tzsh_quickpanel_service.h> +#include <E_DBus.h> + #include "quickpanel-ui.h" +#include "common_uic.h" #include "common.h" +#include "media.h" +#include "noti_node.h" #include "noti.h" #include "noti_win.h" #include "noti_util.h" +#include "animated_icon.h" + #ifdef QP_EMERGENCY_MODE_ENABLE #include "emergency_mode.h" #endif -#include "animated_icon.h" #define QP_ACTIVENOTI_DURATION 3 #define QP_ACTIVENOTI_DETAIL_DURATION 6 @@ -42,13 +53,12 @@ #define ACTIVENOTI_MSG_LEN 100 #define DEFAULT_ICON RESDIR"/quickpanel_icon_default.png" -#define E_DATA_ICON "E_DATA_ICON" -#define E_DATA_BADGE "E_DATA_BADGE" -#define E_DATA_NOTI "E_DATA_NOTI" -#define E_DATA_BTN_IMAGE "E_DATA_BTN_IMAGE" -#define E_DATA_BG_IMAGE "E_DATA_BG_IMAGE" -#define DELAY_TIMER_VALUE 0.480 +#define DELAY_TIMER_VALUE 0.480 #define DEL_TIMER_VALUE 8.0 +#define SHOW_MIN_TIMER_VALUE 1.0 +#define RELEASE_TIME 8.0 + +#define NOTI_START_Y ELM_SCALE_SIZE(36) static struct info { Evas_Object *activenoti; @@ -57,6 +67,12 @@ static struct info { Evas_Object *gesture; Ecore_Timer *delay_timer; Ecore_Timer *close_timer; + Ecore_Timer *show_min_timer; + + Eina_List *auto_remove_list; + Eina_List *non_auto_remove_list; + notification_h current_noti; + } s_info = { .activenoti = NULL, .layout = NULL, @@ -64,19 +80,37 @@ static struct info { .gesture = NULL, .delay_timer = NULL, .close_timer = NULL, + .show_min_timer = NULL, + .auto_remove_list = NULL, + .non_auto_remove_list = NULL, + .current_noti = NULL, }; +struct noti_info { + notification_h noti; + Ecore_Timer *timer; +}; + +static inline char *_get_text(notification_h noti, notification_text_type_e text_type); static int _activenoti_init(void *data); static int _activenoti_fini(void *data); static int _activenoti_enter_hib(void *data); static int _activenoti_leave_hib(void *data); static void _activenoti_reflesh(void *data); -static void _activenoti_create_activenoti(void *data); +static void _activenoti_qp_opened(void *data); + +static void _activenoti_update_activenoti(); +static void _activenoti_create_activenoti(); static void _activenoti_win_rotated(void *data, int need_hide); -static void _activenoti_hide(void *data, int delay); -static void _activenoti_destroy_activenoti(); +static void _activenoti_destroy_activenoti(); +static void _media_feedback_sound(notification_h noti); +static notification_h _activenoti_get_in_list(); +static bool _activenoti_remove_in_list(notification_h noti); +static void _activenoti_delete_current_noti(void); +static bool _activenoti_has_pending_noti(void); +static void _activenoti_hide(void *data, int delay); QP_Module activenoti = { .name = "activenoti", @@ -85,9 +119,19 @@ QP_Module activenoti = { .hib_enter = _activenoti_enter_hib, .hib_leave = _activenoti_leave_hib, .lang_changed = NULL, + .qp_opened = _activenoti_qp_opened, + .qp_closed = NULL, .refresh = _activenoti_reflesh }; +static void _app_control_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + if (data) { + DBG("_app_control_del_cb %p", data); + app_control_destroy(data); + } +} + static inline int _is_text_exist(const char *text) { if (text != NULL) { @@ -95,18 +139,19 @@ static inline int _is_text_exist(const char *text) return 1; } } - return 0; } -static int _is_sound_playable(void) { +static int _is_sound_playable(void) +{ int status = 0, ret = 0; ret = vconf_get_int(VCONFKEY_CAMERA_STATE, &status); - if (ret == 0 && status == VCONFKEY_CAMERA_STATE_RECORDING) { + if (ret == VCONF_OK && status == VCONFKEY_CAMERA_STATE_RECORDING) { ERR("camcorder is working, don't play notification sound %d %d", ret, status); return 0; } + return 1; } @@ -114,7 +159,6 @@ static int _is_security_lockscreen_launched(void) { int ret = 0; int is_idle_lock = 0; - int lock_type = 0; ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &is_idle_lock); retif(ret != 0, 0,"failed to get VCONFKEY_IDLE_LOCK_STATE %d %d", ret, is_idle_lock); @@ -122,43 +166,84 @@ static int _is_security_lockscreen_launched(void) if (is_idle_lock == VCONFKEY_IDLE_LOCK ) { DBG("Lock screen is launched"); return 1; //don't show on lock screen - /* - ret = vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type); - retif(ret != 0, 0,"failed to get VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT %d %d", ret, lock_type); - if (lock_type != SETTING_SCREEN_LOCK_TYPE_NONE && lock_type != SETTING_SCREEN_LOCK_TYPE_SWIPE) { - return 1; - } - */ } return 0; } -static Evas_Event_Flags __flick_end_cb(void *data, void *event_info) +static Eina_Bool _activenoti_hide_timer_cb(void *data) { DBG(""); - Elm_Gesture_Line_Info *line_info = (Elm_Gesture_Line_Info *) event_info; + + s_info.delay_timer = NULL; + + _activenoti_hide(data, 0); + return ECORE_CALLBACK_CANCEL; +} + +static void _activenoti_hide(void *data, int delay) +{ + DBG("delay : %d", delay); + if (delay == 1) { + if (s_info.delay_timer == NULL) { + s_info.delay_timer = ecore_timer_add(DELAY_TIMER_VALUE, _activenoti_hide_timer_cb, NULL); + if (!s_info.delay_timer) { + ERR("Failed to create a new timer for hide activenoti"); + } + } + } else { + _activenoti_delete_current_noti(); + + if (s_info.delay_timer != NULL) { + ecore_timer_del(s_info.delay_timer); + s_info.delay_timer = NULL; + } + + if (s_info.close_timer != NULL) { + ecore_timer_del(s_info.close_timer); + s_info.close_timer = NULL; + } + + if (s_info.activenoti) { + if (_activenoti_has_pending_noti()) { + _activenoti_update_activenoti(); + } else { + DBG("pending noti is null. called evas_object_hide"); + evas_object_hide(s_info.activenoti); + } + } + } + DBG(""); +} + +static Evas_Event_Flags __flick_end_cb(void *data, void *event_info) +{ + Elm_Gesture_Line_Info *line_info = (Elm_Gesture_Line_Info *)event_info; DBG("line_info->momentum.my : %d", line_info->momentum.my); /* Flick Up */ - if (line_info->momentum.my < 0) - { - _activenoti_hide(NULL,0); + if (line_info->momentum.my < 0) { + DBG("HIDE ACTIVE NOTI"); + if (_activenoti_has_pending_noti() == false) { + _activenoti_hide(NULL, 0); + } else { + _activenoti_delete_current_noti(); + _activenoti_update_activenoti(); + } + } else { + DBG("HOLD ACTIVE NOTI"); } - return EVAS_EVENT_FLAG_ON_HOLD; } - static Evas_Object *_gesture_create(Evas_Object *layout) { Evas_Object *gesture_layer = NULL; - INFO("gesture create"); - gesture_layer = elm_gesture_layer_add(layout); retif(!gesture_layer, NULL,); + elm_gesture_layer_attach(gesture_layer, layout); evas_object_show(gesture_layer); @@ -169,17 +254,69 @@ static Evas_Object *_gesture_create(Evas_Object *layout) static int _check_sound_off(notification_h noti) { + notification_system_setting_h system_setting = NULL; + notification_setting_h setting = NULL; char *pkgname = NULL; + bool do_not_disturb = false; + bool do_not_disturb_except = false; + int err = NOTIFICATION_ERROR_NONE; + int ret = 0; - notification_get_pkgname(noti, &pkgname); + retif(noti == NULL, 0, "Invalid parameter!"); - //to do + err = notification_system_setting_load_system_setting(&system_setting); + if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) { + DBG("notification_system_setting_load_system_setting failed [%d]\n", err); + goto out; + } - return 0; -} + err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb); + if (err != NOTIFICATION_ERROR_NONE) { + DBG("notification_system_setting_get_do_not_disturb failed [%d]", err); + goto out; + } + + DBG("do_not_disturb [%d]\n", do_not_disturb); + + if (do_not_disturb) { + err = notification_get_pkgname(noti, &pkgname); + if (err != NOTIFICATION_ERROR_NONE || pkgname == NULL) { + DBG("notification_get_pkgname failed [%d]", err); + goto out; + } + + err = notification_setting_get_setting_by_package_name(pkgname, &setting); + if (err != NOTIFICATION_ERROR_NONE || setting == NULL) { + DBG("notification_setting_get_setting_by_package_name failed [%d]", err); + goto out; + } + + notification_setting_get_do_not_disturb_except(setting, &do_not_disturb_except); + if (err != NOTIFICATION_ERROR_NONE) { + DBG("notification_setting_get_do_not_disturb_except failed [%d]", err); + goto out; + } + + if (do_not_disturb_except) { + ret = 0; + } else { + ret = 1; + } + } + +out: + if (system_setting) { + notification_system_setting_free_system_setting(system_setting); + } + + if (setting) { + notification_setting_free_notification(setting); + } + return ret; +} -static void _gesture_destroy() +static void _gesture_destroy(void) { if (s_info.gesture) { evas_object_del(s_info.gesture); @@ -191,207 +328,430 @@ static void _gesture_destroy() static inline void _activenoti_only_noti_del(notification_h noti) { + retif(noti == NULL, ,"Invalid parameter!"); int applist = NOTIFICATION_DISPLAY_APP_ALL; - retif(noti == NULL, ,"noti is null"); - notification_get_display_applist(noti, &applist); -#ifdef HAVE_X - if (applist & NOTIFICATION_DISPLAY_APP_HEADS_UP) -#endif - { + if (applist & NOTIFICATION_DISPLAY_APP_ACTIVE) { if (!(applist & NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY)) { char *pkgname = NULL; int priv_id = 0; notification_get_pkgname(noti, &pkgname); notification_get_id(noti, NULL, &priv_id); - notification_delete_by_priv_id(pkgname, - NOTIFICATION_TYPE_NONE, - priv_id); + notification_delete_by_priv_id(pkgname, NOTIFICATION_TYPE_NONE, priv_id); } } } - -static Eina_Bool _activenoti_hide_timer_cb(void *data) +static Eina_Bool _activenoti_close_timer_cb(void *data) { - _activenoti_hide(NULL,0); + DBG("%d", _activenoti_has_pending_noti()); + s_info.close_timer = NULL; - if (s_info.delay_timer != NULL) { - ecore_timer_del(s_info.delay_timer); - s_info.delay_timer = NULL; - } + _activenoti_hide(data, 0); return ECORE_CALLBACK_CANCEL; } +static void _activenoti_delete_current_noti(void) +{ + if (!s_info.current_noti) { + DBG("There is no displaying notification"); + return; + } + DBG(""); + notification_free(s_info.current_noti); + s_info.current_noti = NULL; +} -static void _activenoti_hide(void *data, int delay) +static Evas_Object *_activenoti_create_badge(Evas_Object *parent, notification_h noti) { - if (delay == 1) { - if (s_info.delay_timer == NULL) { - s_info.delay_timer = ecore_timer_add(DELAY_TIMER_VALUE, _activenoti_hide_timer_cb, NULL); - } - } else { - if (s_info.delay_timer != NULL) { - ecore_timer_del(s_info.delay_timer); - s_info.delay_timer = NULL; - } + DBG(""); + retif(noti == NULL || parent == NULL, NULL, "Invalid parameter!"); - if (s_info.close_timer != NULL) { - ecore_timer_del(s_info.close_timer); - s_info.close_timer = NULL; - } + char *icon_path = NULL; + Evas_Object *icon = NULL; + int ret = NOTIFICATION_ERROR_NONE; - if (s_info.activenoti) { - evas_object_hide(s_info.activenoti); - } + ret = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &icon_path); + if (ret != NOTIFICATION_ERROR_NONE || icon_path == NULL) { + DBG("notification_get_image failed [%d]", ret);; + return NULL; + } + + DBG("NOTIFICATION_IMAGE_TYPE_ICON_SUB : %s", icon_path); + + icon = elm_image_add(parent); + if (icon == NULL) { + // free(icon_path); + DBG("icon error"); + return NULL; + } + + elm_image_resizable_set(icon, EINA_FALSE, EINA_TRUE); + + ret = elm_image_file_set(icon, icon_path, NULL); + //free(icon_path); + + if (ret == EINA_FALSE) { + evas_object_del(icon); + return NULL; } + + return icon; } +static void _image_press_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + DBG(""); + app_control_h app_control = data; + + if (app_control) { + int ret = APP_CONTROL_ERROR_NONE; + ret = app_control_send_launch_request(app_control, NULL, NULL); + DBG("app_control_send_launch_request return [%d]", ret); + } + _activenoti_hide(NULL, 1); +} -static void _activenoti_detail_show_cb(void *data, Evas *e, - Evas_Object *obj, - void *event_info) +static Eina_Bool _delete_timer_cb(void *data) { DBG(""); + struct noti_info *noti = data; + + s_info.auto_remove_list = eina_list_remove(s_info.auto_remove_list, noti); + notification_free(noti->noti); + free(noti); + + return ECORE_CALLBACK_CANCEL; } -static Evas_Object *_activenoti_create_badge(Evas_Object *parent, - notification_h noti) +static int _compare_noti_time(notification_h noti1, notification_h noti2) { - char *pkgname = NULL; - char *icon_path = NULL; - char *icon_default = NULL; - Evas_Object *icon = NULL; - int ret = NOTIFICATION_ERROR_NONE; + time_t noti_time1 = 0; + time_t noti_time2 = 0; + int ret; - retif(noti == NULL || parent == NULL, NULL, "Invalid parameter!"); + ret = notification_get_time(noti1, ¬i_time1); + if (ret != NOTIFICATION_ERROR_NONE || noti_time1 == 0) { + notification_get_insert_time(noti1, ¬i_time1); + } - ret = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &icon_path); + ret = notification_get_time(noti2, ¬i_time2); + if (ret != NOTIFICATION_ERROR_NONE || noti_time2 == 0) { + notification_get_insert_time(noti2, ¬i_time2); + } - if (ret == NOTIFICATION_ERROR_NONE && icon_path != NULL) { - DBG("icon_path : %s", icon_path); - icon = elm_image_add(parent); - elm_image_resizable_set(icon, EINA_TRUE, EINA_TRUE); - if ( elm_image_file_set(icon, icon_path, NULL) == EINA_FALSE) { - ERR("fail to set file[%s]", icon_path); - evas_object_del(icon); - icon = NULL; - free(icon_path); - return NULL; - } - } else { - /* - notification_get_pkgname(noti, &pkgname); - if (pkgname != NULL) { - INFO("pkgname : %s", pkgname); - icon_default = quickpanel_common_ui_get_pkginfo_icon(pkgname); - if (icon_default != NULL) { - elm_image_file_set(icon, icon_default, NULL); - free(icon_default); - } else { - return NULL; + DBG("not_time1 : %d noti_time2 : %d", noti_time1, noti_time2); + + return (int)(noti_time1 - noti_time2); +} + +static int _compare_time_cb(const void *data1, const void *data2) +{ + struct noti_info *info1 = (struct noti_info *)data1; + struct noti_info *info2 = (struct noti_info *)data2; + + return _compare_noti_time(info1->noti, info2->noti); +} + +static void _activenoti_remove_list(void) +{ + struct noti_info *info; + char *tmp; + + EINA_LIST_FREE(s_info.auto_remove_list, info) { + /** + * For debugging + */ + tmp = _get_text(info->noti, NOTIFICATION_TEXT_TYPE_TITLE); + DBG("auto remove %s", tmp); + free(tmp); + + free(info->noti); + free(info->timer); + } + + EINA_LIST_FREE(s_info.non_auto_remove_list, info) { + /** + * For debugging + */ + tmp = _get_text(info->noti, NOTIFICATION_TEXT_TYPE_TITLE); + DBG("nont auto remove %s", tmp); + free(tmp); + + free(info->noti); + } +} + +static bool _activenoti_add_in_list(notification_h noti) +{ + DBG(""); + bool auto_remove; + struct noti_info *info; + int ret; + time_t noti_time = 0; + + ret = notification_get_auto_remove( noti, &auto_remove); + if (ret != NOTIFICATION_ERROR_NONE) { + DBG("notification_get_auto_remove return [%d]", ret); + return false; + } + + info = malloc(sizeof(*info)); + if (!info) { + DBG("malloc error, can't make noti_info"); + return false; + } + + ret = notification_clone(noti, &info->noti); + if (ret != NOTIFICATION_ERROR_NONE || !info->noti) { + free(info); + ERR("failed to create a cloned notification"); + return false; + } + + if (auto_remove == true) { + ret = notification_get_time(info->noti, ¬i_time); + if (ret!=NOTIFICATION_ERROR_NONE || noti_time == 0) { + ret = notification_get_insert_time(info->noti, ¬i_time); + if (ret != NOTIFICATION_ERROR_NONE || noti_time == 0) { + DBG("notification_get_insert_time failed. time is 0 ret %d", ret); } + } + + noti_time -= time(NULL); + + if (noti_time > 8.0f) { + DBG("remove noti"); + info->timer = NULL; + _delete_timer_cb(info); } else { - return NULL; + info->timer = ecore_timer_add(8.0f - noti_time, _delete_timer_cb, info); + DBG("timer add"); + if(!info->timer) { + DBG("ecore_timer_add failed"); + } + /** + * @todo + * Revise this. + * Do we need to replace this with eina_list_prepend? + */ + s_info.auto_remove_list = eina_list_sorted_insert(s_info.auto_remove_list, _compare_time_cb, info); } - */ - return NULL; + } else { + info->timer = NULL; + s_info.non_auto_remove_list = eina_list_sorted_insert(s_info.non_auto_remove_list, _compare_time_cb, info); } - free(icon_path); - return icon; + return 1; } -static void _image_press_cb(void *data, Evas_Object *obj, - const char *emission, const char *source) +static bool _activenoti_has_pending_noti(void) +{ + + return s_info.non_auto_remove_list || s_info.auto_remove_list; +} + +static bool _activenoti_remove_in_list(notification_h noti) { DBG(""); - app_control_h app_control = data; - int ret = APP_CONTROL_ERROR_NONE; + bool auto_remove; + int ret; + Eina_List *l; + Eina_List *n; + struct noti_info *info; + + ret = notification_get_auto_remove(noti, &auto_remove); + if (ret != NOTIFICATION_ERROR_NONE) { + DBG("notification_get_auto_remove return [%d]", ret); + return false; + } + + if (auto_remove) { + DBG("remove in auto remove list"); + EINA_LIST_FOREACH_SAFE(s_info.auto_remove_list, l, n, info) { + if (info->noti != noti) { + int priv_id_from_list; + int priv_id_from_arg; + + notification_get_id(info->noti, NULL, &priv_id_from_list); + notification_get_id(noti, NULL, &priv_id_from_arg); + if (priv_id_from_list != priv_id_from_arg) { + continue; + } + } + s_info.auto_remove_list = eina_list_remove(s_info.auto_remove_list, info); + ecore_timer_del(info->timer); + notification_free(info->noti); + free(info); + break; + } + } else { + DBG("remove in non auto remove list"); + EINA_LIST_FOREACH_SAFE(s_info.non_auto_remove_list, l, n, info) { + if (info->noti != noti) { + int priv_id_from_list; + int priv_id_from_arg; + + notification_get_id(info->noti, NULL, &priv_id_from_list); + notification_get_id(noti, NULL, &priv_id_from_arg); + + if (priv_id_from_list != priv_id_from_arg) { + continue; + } + } + s_info.non_auto_remove_list = eina_list_remove(s_info.non_auto_remove_list, info); + notification_free(info->noti); + free(info); + break; + } + } + return 1; +} + +static notification_h _activenoti_get_in_list(notification_h cur_noti) +{ DBG(""); - if (app_control) { - char *app_id = NULL; - ret = app_control_get_app_id(app_control, &app_id); - - DBG("app_id : %s",app_id); - if (ret == APP_CONTROL_ERROR_NONE && app_id != NULL) { - ret = app_control_send_launch_request(app_control, NULL, NULL); - DBG("ret [%s]", ret); - free(app_id); + notification_h noti = NULL; + struct noti_info *info; + bool auto_remove = true; + int ret; + + if (cur_noti != NULL) { + ret = notification_get_auto_remove(cur_noti, &auto_remove); + if (ret != NOTIFICATION_ERROR_NONE) { + DBG("notification_get_auto_remove return [%d]", ret); + return NULL; } + } - } else { - ERR("app_control is NULL"); + info = eina_list_nth(s_info.non_auto_remove_list, 0); + if (info) { + if (!auto_remove) { + ret = _compare_noti_time(cur_noti, info->noti); + + if (ret > 0) { + return NULL; + } + } + s_info.non_auto_remove_list = eina_list_remove(s_info.non_auto_remove_list, info); + // ..... + noti = info->noti; + free(info); + return noti; } - _activenoti_hide(NULL, 1); -} + if (auto_remove == false) { + return noti; + } + + info = eina_list_nth(s_info.auto_remove_list, 0); + if (info) { + s_info.auto_remove_list = eina_list_remove(s_info.auto_remove_list, info); + // ..... + noti = info->noti; + ecore_timer_del(info->timer); + free(info); + return noti; + } + return noti; +} static Evas_Object *_activenoti_create_icon(Evas_Object *parent, notification_h noti) { - char *pkgname = NULL; - char *icon_path = NULL; - char *thumb_path = NULL; - char *icon_default = NULL; - Evas_Object *icon = NULL; - retif(noti == NULL || parent == NULL, NULL, "Invalid parameter!"); + DBG(""); + retif(noti == NULL || parent == NULL , NULL, "Invalid parameter!"); - notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, &icon_path); - notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, &thumb_path); + char *icon_path; + char *tmp; + Evas_Object *icon; + int ret; + app_control_h app_control; - icon = elm_image_add(parent); - elm_image_resizable_set(icon, EINA_TRUE, EINA_TRUE); + retif(noti == NULL || parent == NULL, NULL, "Invalid parameter!"); + + tmp = NULL; + ret = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, &tmp); + if (ret == NOTIFICATION_ERROR_NONE && tmp != NULL) { + icon_path = strdup(tmp); + if (!icon_path) { + ERR("strdup: %s", tmp); + } - if (icon_path == NULL - || (icon_path != NULL && elm_image_file_set(icon, icon_path, NULL) == EINA_FALSE)) { - DBG("icon_path : %s", icon_path); + app_control = NULL; + ret = notification_get_event_handler(noti, NOTIFICATION_EVENT_TYPE_CLICK_ON_ICON, &app_control); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Failed to get handler"); + } - if (thumb_path == NULL - || (thumb_path != NULL && elm_image_file_set(icon, thumb_path, NULL) == EINA_FALSE)) { - DBG("thumb_path : %s", thumb_path); + DBG("icon_path : %s app_control = %p", icon_path, app_control); + } else { + tmp = NULL; + ret = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, &tmp); + if (ret == NOTIFICATION_ERROR_NONE && tmp != NULL) { + icon_path = strdup(tmp); + if (!icon_path) { + ERR("strdup: %s", tmp); + } - int ret = notification_get_pkgname(noti, &pkgname); - if (ret == NOTIFICATION_ERROR_NONE && pkgname != NULL) { - DBG("pkgname : %s", icon_default); + app_control = NULL; + ret = notification_get_event_handler(noti, NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL, &app_control); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Failed to get handler"); + } - icon_default = quickpanel_common_ui_get_pkginfo_icon(pkgname); - DBG("icon_default : %s", icon_default); + DBG("thumb_path : %s app_control = %p", icon_path, app_control); + } else { + char *pkgname; - if (icon_default == NULL - || ( icon_default != NULL && elm_image_file_set(icon, icon_default, NULL) == EINA_FALSE)) { - DBG("DEFAULT_ICON : %s", DEFAULT_ICON); + icon_path = NULL; + pkgname = NULL; + ret = notification_get_pkgname(noti, &pkgname); + if (ret == NOTIFICATION_ERROR_NONE && pkgname != NULL) { + icon_path = quickpanel_common_ui_get_pkginfo_icon(pkgname); + DBG("default_pkgicon_path : %s", icon_path); + } - if( elm_image_file_set(icon, DEFAULT_ICON, NULL) == EINA_FALSE) { - evas_object_del(icon); - icon = NULL; - } - } - } else { - if ( elm_image_file_set(icon, DEFAULT_ICON, NULL) == EINA_FALSE) { - evas_object_del(icon); - icon = NULL; - } + if (!icon_path) { + icon_path = strdup(DEFAULT_ICON); + DBG("default_path : %s", icon_path); } + + app_control = NULL; } } - if (icon != NULL) { - elm_object_signal_callback_add(parent, "image_press" , "", _image_press_cb, noti); + icon = elm_image_add(parent); + if (!icon) { + ERR("Failed to create an image object"); + free(icon_path); + if (app_control) { + app_control_destroy(app_control); + } + return NULL; } + ret = elm_image_file_set(icon, icon_path, NULL); free(icon_path); - free(thumb_path); - free(pkgname); - free(icon_default); + if (ret == EINA_FALSE) { + evas_object_del(icon); + if (app_control) { + app_control_destroy(app_control); + } + return NULL; + } + elm_image_resizable_set(icon, EINA_FALSE, EINA_TRUE); + + elm_object_signal_callback_add(icon, "image_press" , "", _image_press_cb, app_control); + evas_object_event_callback_add(icon, EVAS_CALLBACK_DEL, _app_control_del_cb, app_control); return icon; } @@ -401,6 +761,7 @@ static inline char *_get_text(notification_h noti, notification_text_type_e text time_t time = 0; char *text = NULL; char buf[ACTIVENOTI_MSG_LEN] = {0,}; + if (notification_get_time_from_text(noti, text_type, &time) == NOTIFICATION_ERROR_NONE) { if ((int)time > 0) { quickpanel_noti_util_get_time(time, buf, sizeof(buf)); @@ -416,7 +777,6 @@ static inline char *_get_text(notification_h noti, notification_text_type_e text return elm_entry_utf8_to_markup(text); } - return NULL; } @@ -450,80 +810,58 @@ static inline void _check_and_add_to_buffer(Eina_Strbuf *str_buf, char *text, in } } -static char *_activenoti_get_label_layout_default(notification_h noti, int is_screenreader, char **subtitle, char **title, char **content) +static void _activenoti_set_text(notification_h noti, int is_screenreader) { - int len = 0; char *domain = NULL; char *dir = NULL; - const char *tmp = NULL; - char buf[ACTIVENOTI_MSG_LEN] = { 0, }; - - retif(noti == NULL, NULL, "Invalid parameter!"); + char *tmp; + int ret; - notification_get_text_domain(noti, &domain, &dir); - if (domain != NULL && dir != NULL) { - bindtextdomain(domain, dir); + if (!noti) { + ERR("Invalid parameter"); + return; } - if ( title != NULL ) { - *title = _get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE); + ret = notification_get_text_domain(noti, &domain, &dir); + if (ret == NOTIFICATION_ERROR_NONE && domain != NULL && dir != NULL) { + bindtextdomain(domain, dir); } - if ( content != NULL ) { - *content = _get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT); + tmp = _get_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1); + if (tmp != NULL) { + elm_object_part_text_set(s_info.layout, "subtitle_text", tmp); + free(tmp); + elm_object_signal_emit(s_info.layout, "sub_show", "subtitle_text"); + } else { + elm_object_signal_emit(s_info.layout, "sub_hide", "subtitle_text"); } - if ( subtitle != NULL ) { - *subtitle = _get_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1); + tmp = _get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE); + if (tmp != NULL) { + elm_object_part_text_set(s_info.layout, "title_text", tmp); + free(tmp); + } else { + elm_object_part_text_set(s_info.layout, "title_text", ""); } - if (is_screenreader == 1) { - if (title == NULL && content == NULL) { - len = 0; - } else { - Eina_Strbuf *strbuf = eina_strbuf_new(); - if (strbuf != NULL) { - eina_strbuf_append(strbuf, _("IDS_QP_BUTTON_NOTIFICATION")); - eina_strbuf_append_char(strbuf, '\n'); - _check_and_add_to_buffer(strbuf, title, 1); - _check_and_add_to_buffer(strbuf, content, 1); - - if (eina_strbuf_length_get(strbuf) > 0) { - len = snprintf(buf, sizeof(buf) - 1, "%s", eina_strbuf_string_get(strbuf)); - } - eina_strbuf_free(strbuf); - } - } - - if (len > 0) { - return strdup(buf); - } + tmp = _get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT); + if (tmp != NULL) { + elm_object_part_text_set(s_info.layout, "content_text", tmp); + free(tmp); + } else { + elm_object_part_text_set(s_info.layout, "content_text", ""); } - - return NULL; -} - - -static char *_activenoti_get_text(notification_h noti, int is_screenreader, char **subtitle, char **title, char **content) -{ - char *result = NULL; - result = _activenoti_get_label_layout_default(noti, is_screenreader, subtitle, title, content); - - return result; } -static void _noti_hide_cb(void *data, Evas_Object *obj, - const char *emission, const char *source) +static void _handle_press_cb(void *data, Evas_Object *obj, const char *emission, const char *source) { + DBG(""); _activenoti_hide(data, 0); } -static void _noti_press_cb(void *data, Evas_Object *obj, - const char *emission, const char *source) +static void _noti_press_cb(void *data, Evas_Object *obj, const char *emission, const char *source) { DBG(""); - - notification_h noti = (notification_h) data; int ret = APP_CONTROL_ERROR_NONE; char *caller_pkgname = NULL; bundle *responding_service_handle = NULL; @@ -531,9 +869,12 @@ static void _noti_press_cb(void *data, Evas_Object *obj, bundle *multi_service_handle = NULL; int flags = 0, group_id = 0, priv_id = 0, count = 0, flag_launch = 0; notification_type_e type = NOTIFICATION_TYPE_NONE; + notification_h noti = NULL; - retif(noti == NULL, , "Invalid parameter!"); + retif(s_info.activenoti == NULL, , "Invalid parameter!"); + retif(s_info.current_noti == NULL, , "Invalid parameter!"); + noti = s_info.current_noti; notification_get_pkgname(noti, &caller_pkgname); notification_get_id(noti, &group_id, &priv_id); notification_get_property(noti, &flags); @@ -545,9 +886,20 @@ static void _noti_press_cb(void *data, Evas_Object *obj, flag_launch = 1; } - notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, &responding_service_handle); - notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &single_service_handle); - notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, &multi_service_handle); + ret = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, &responding_service_handle); + if (ret != NOTIFICATION_ERROR_NONE || responding_service_handle == NULL) { + DBG("NOTIFICATION_EXECUTE_TYPE_RESPONDING failed [%d]", ret); + } + + ret = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &single_service_handle); + if (ret != NOTIFICATION_ERROR_NONE || single_service_handle == NULL) { + DBG("NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH failed [%d]", ret); + } + + ret = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, &multi_service_handle); + if (ret != NOTIFICATION_ERROR_NONE || multi_service_handle == NULL) { + DBG("NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH failed [%d]", ret); + } if (responding_service_handle != NULL) { DBG("responding_service_handle : %s", responding_service_handle); @@ -563,13 +915,10 @@ static void _noti_press_cb(void *data, Evas_Object *obj, } if (single_service_handle != NULL && multi_service_handle == NULL) { - DBG(""); ret = quickpanel_uic_launch_app(NULL, single_service_handle); } else if (single_service_handle == NULL && multi_service_handle != NULL) { - DBG(""); ret = quickpanel_uic_launch_app(NULL, multi_service_handle); } else if (single_service_handle != NULL && multi_service_handle != NULL) { - DBG(""); if (count <= 1) { ret = quickpanel_uic_launch_app(NULL, single_service_handle); } else { @@ -585,128 +934,96 @@ static void _noti_press_cb(void *data, Evas_Object *obj, } - -static void _button_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - DBG(""); - app_control_h app_control = data; - Evas_Object *btn_img; - - msgif(app_control == NULL, , "Invalid parameter!"); - - btn_img = evas_object_data_get(obj, E_DATA_BTN_IMAGE); - - if (btn_img) { - evas_object_del(btn_img); - btn_img = NULL; - } - - if (app_control) { - app_control_destroy(app_control); - } -} - - static void _button_press_cb(void *data, Evas_Object *obj, const char *emission, const char *source) { app_control_h app_control = data; int ret = APP_CONTROL_ERROR_NONE; - if (app_control) { - char *app_id = NULL; - ret = app_control_get_app_id(app_control, &app_id); - - DBG("app_id : %s",app_id); - if (ret == APP_CONTROL_ERROR_NONE && app_id != NULL) { - ret = app_control_send_launch_request(app_control, NULL, NULL); - DBG("ret [%s]", ret); - free(app_id); - } - - } else { - ERR("app_control is NULL"); - } + ret = app_control_send_launch_request(app_control, NULL, NULL); + DBG("app_control_send_launch_request return [%s]", ret); _activenoti_hide(NULL, 1); } - static Evas_Object *_get_btn_img(Evas_Object *parent, notification_h noti, int btn_num) { - char *btn_path = NULL; - Evas_Object *btn_img = NULL; retif(noti == NULL || parent == NULL, NULL, "Invalid parameter!"); -#ifdef HAVE_X - notification_get_image(noti, btn_num + NOTIFICATION_IMAGE_TYPE_BUTTON_1, &btn_path); -#endif + char *btn_path = NULL; + Evas_Object *btn_img = NULL; + int ret; - if (btn_path == NULL ){ + ret = notification_get_image(noti, btn_num + NOTIFICATION_IMAGE_TYPE_BUTTON_1, &btn_path); + if (ret != NOTIFICATION_ERROR_NONE || btn_path == NULL) { + DBG("notification_get_image return [%d]", ret); return NULL; } btn_img = elm_image_add(parent); + if (!btn_img) { + //free(btn_path); + return NULL; + } + evas_object_size_hint_weight_set(btn_img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(btn_img, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_image_resizable_set(btn_img, EINA_TRUE, EINA_TRUE); - if (btn_img) { - elm_image_resizable_set(btn_img, EINA_TRUE, EINA_TRUE); - if( elm_image_file_set(btn_img, btn_path, NULL) == EINA_FALSE) { - evas_object_del(btn_img); - btn_img = NULL; - return NULL; - } - } else { + ret = elm_image_file_set(btn_img, btn_path, NULL); + //free(btn_path); + if (ret == EINA_FALSE) { + evas_object_del(btn_img); return NULL; } - free(btn_path); - return btn_img; } - static Evas_Object *_get_bg_img(Evas_Object *parent, notification_h noti) { char *bg_path = NULL; Evas_Object *bg_img = NULL; - retif(noti == NULL || parent == NULL, NULL, "Invalid parameter!"); + int ret; - notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &bg_path); + if (!parent || !noti) { + ERR("Invalid parameters %p %p", parent, noti); + return NULL; + } - if (bg_path == NULL ){ + ret = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &bg_path); + if (ret != NOTIFICATION_ERROR_NONE || bg_path == NULL) { + DBG("bg_path is null ret = %d", ret); return NULL; } bg_img = elm_image_add(parent); + if (!bg_img) { + return NULL; + } + evas_object_size_hint_weight_set(bg_img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(bg_img, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_image_resizable_set(bg_img, EINA_TRUE, EINA_TRUE); - if (bg_img) { - elm_image_resizable_set(bg_img, EINA_TRUE, EINA_TRUE); - if( elm_image_file_set(bg_img, bg_path, NULL) == EINA_FALSE) { - evas_object_del(bg_img); - bg_img = NULL; - return NULL; - } - } else { + ret = elm_image_file_set(bg_img, bg_path, NULL); + if (ret == EINA_FALSE) { + evas_object_del(bg_img); return NULL; } - free(bg_path); - return bg_img; } - static int _activenoti_create_button(Evas_Object *obj, notification_h noti) { - int btn_cnt= 0; - int ret = APP_CONTROL_ERROR_NONE; - app_control_h app_control = NULL; + int btn_cnt; + int ret; + app_control_h app_control; - retif(obj == NULL, 0, "obj is NULL!"); - retif(noti == NULL, 0, "noti is NULL!"); + if (!obj || !noti) { + ERR("Invalid parameters"); + return 0; + } if (s_info.btnbox) { //if exist, delete and create evas_object_del(s_info.btnbox); @@ -727,23 +1044,29 @@ static int _activenoti_create_button(Evas_Object *obj, notification_h noti) evas_object_show(box); s_info.btnbox = box; - for( btn_cnt = 0 ; btn_cnt <= 2 ; btn_cnt++) { - retif(ret != APP_CONTROL_ERROR_NONE, 0, "noapp_control_createti is failed!"); -#ifdef HAVE_X + for (btn_cnt = 0; btn_cnt < 3; btn_cnt++) { + app_control = NULL; ret = notification_get_event_handler(noti, btn_cnt + NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, &app_control); -#endif + DBG("appcontrol %p", app_control); if(ret != NOTIFICATION_ERROR_NONE || app_control == NULL) { INFO("no more button, button count is %d", btn_cnt); INFO("ret is %d", ret); + + /** + * @note + * In this case, + * The app_control is not used and no one cares it. + * So we have to release it from here if it is allocated. + */ + if (app_control) { + app_control_destroy(app_control); + } + if (btn_cnt == 0) { // noti doesn't have button - if (app_control) { - app_control_destroy(app_control); - } evas_object_del(s_info.btnbox); s_info.btnbox = NULL; return 0; } - break; } else { Evas_Object *bt_layout; char *btn_text; @@ -752,10 +1075,8 @@ static int _activenoti_create_button(Evas_Object *obj, notification_h noti) bt_layout = elm_layout_add(s_info.btnbox); if(bt_layout == NULL) { ERR("bt_layout is null"); - if (app_control) { - app_control_destroy(app_control); - } evas_object_del(s_info.btnbox); + app_control_destroy(app_control); s_info.btnbox = NULL; return 0; } @@ -764,255 +1085,225 @@ static int _activenoti_create_button(Evas_Object *obj, notification_h noti) evas_object_size_hint_weight_set (bt_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(bt_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - image = _get_btn_img(bt_layout , noti, btn_cnt); + image = _get_btn_img(bt_layout, noti, btn_cnt); if (image != NULL) { elm_object_part_content_set(bt_layout, "content.button.image", image); - evas_object_data_set(bt_layout, E_DATA_BTN_IMAGE, image); } - -#ifdef HAVE_X + btn_text = _get_text(noti, btn_cnt + NOTIFICATION_TEXT_TYPE_BUTTON_1); -#endif if (btn_text != NULL) { - DBG("btn_text :%s", btn_text); elm_object_part_text_set(bt_layout, "content.button.text", btn_text); free(btn_text); } - elm_object_signal_callback_add(bt_layout, "button_clicked" , "", _button_press_cb, app_control); - evas_object_event_callback_add(bt_layout, EVAS_CALLBACK_DEL, _button_del_cb, app_control); + evas_object_event_callback_add(bt_layout, EVAS_CALLBACK_DEL, _app_control_del_cb, app_control); + evas_object_show(bt_layout); elm_box_pack_end(s_info.btnbox,bt_layout); } } + elm_object_part_content_set(obj, "button.swallow", s_info.btnbox); return btn_cnt; } -static void _activenoti_update_activenoti(void *data) +static void _activenoti_create_activenoti(void) { DBG(""); Eina_Bool ret = EINA_FALSE; - notification_h noti = (notification_h) data; - Evas_Object *icon = NULL; - Evas_Object *badge = NULL; - - Evas_Object *textblock = NULL; - char *title = NULL; - char *subtitle = NULL; - char *content = NULL; - int btn_cnt = 0; - - retif(noti == NULL, , "Invalid parameter!"); + Evas_Object *base = NULL; + int w, h; - if (s_info.activenoti == NULL) { - ERR("Active notification doesn't exist"); + if (s_info.activenoti != NULL) { + ERR("Instant notification exists"); return; } - btn_cnt = _activenoti_create_button(s_info.layout, noti); - - if (btn_cnt == 0) { //no button - elm_object_signal_emit(s_info.layout, "btn_hide", "button.space"); - } else { - elm_object_signal_emit(s_info.layout, "btn_show", "button.space"); - } + s_info.activenoti = quickpanel_noti_win_add(NULL); + retif(s_info.activenoti == NULL, , "Failed to add elm activenoti."); - icon = elm_object_part_content_get(s_info.layout, "icon_big"); - if(icon != NULL) { - evas_object_del(icon); - icon = NULL; + s_info.layout = elm_layout_add(s_info.activenoti); + if (!s_info.layout) { + ERR("Failed to get detailview."); + _activenoti_destroy_activenoti(); + return; } - icon = _activenoti_create_icon(s_info.layout, noti); - if (icon != NULL) { - elm_object_part_content_set(s_info.layout, "icon_big", icon); + ret = elm_layout_file_set(s_info.layout, ACTIVENOTI_EDJ, "headsup/base"); + retif(ret == EINA_FALSE, , "failed to load layout"); - badge = elm_object_part_content_get(s_info.layout, "icon_badge"); - if(badge != NULL) { - evas_object_del(badge); - badge = NULL; - } + elm_object_signal_callback_add(s_info.layout, "noti_press" , "", _noti_press_cb, NULL); + elm_object_signal_callback_add(s_info.layout, "del" , "", _handle_press_cb, NULL); - badge = _activenoti_create_badge(s_info.layout, noti); - if (badge != NULL) { - elm_object_part_content_set(s_info.layout, "icon_badge", badge); - } else { - INFO("badge is NULL"); - } - } else { - INFO("icon is NULL"); - } - _activenoti_get_text(noti, 0, &subtitle, &title, &content); + evas_object_geometry_get(s_info.activenoti, NULL, NULL, &w, &h); + DBG("evas_object_geometry_get x %d y %d", w, h); - if (title != NULL) { - Eina_Strbuf *bufferT = eina_strbuf_new(); - eina_strbuf_append(bufferT, title); - eina_strbuf_append(bufferT, "<b/>"); - elm_object_part_text_set(s_info.layout, "title_text", eina_strbuf_string_get(bufferT)); - free(title); - eina_strbuf_free(bufferT); - } + elm_win_resize_object_add(s_info.activenoti, s_info.layout); + evas_object_show(s_info.layout); - if (subtitle != NULL) { - Eina_Strbuf *bufferST = eina_strbuf_new(); - eina_strbuf_append(bufferST, subtitle); - elm_object_part_text_set(s_info.layout, "subtitle_text", eina_strbuf_string_get(bufferST)); - free(subtitle); - eina_strbuf_free(bufferST); - elm_object_signal_emit(s_info.layout, "sub_show", "subtitle_text"); - } else { - elm_object_signal_emit(s_info.layout, "sub_hide", "subtitle_text"); + /* create base rectangle */ + base = evas_object_rectangle_add(evas_object_evas_get(s_info.layout)); + if (!base) { + ERR("Failed to get detailview."); + _activenoti_destroy_activenoti(); + return; } - if (content != NULL) { - Eina_Strbuf *bufferC = eina_strbuf_new(); - eina_strbuf_append(bufferC, content); - elm_object_part_text_set(s_info.layout, "content_text", eina_strbuf_string_get(bufferC)); - free(content); - eina_strbuf_free(bufferC); - } + evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_color_set(base, 0, 165, 198, 255); + elm_object_part_content_set(s_info.layout, "background", base); - if (s_info.close_timer != NULL) { - ecore_timer_del(s_info.close_timer); - s_info.close_timer = NULL; - } + quickpanel_noti_win_content_set(s_info.activenoti, s_info.layout); - s_info.close_timer = ecore_timer_add(DEL_TIMER_VALUE, _activenoti_hide_timer_cb, NULL); - evas_object_show(s_info.activenoti); + s_info.gesture = _gesture_create(s_info.layout); - SERR("activenoti noti is updated"); + _activenoti_win_rotated(quickpanel_get_app_data(), 0); } -static void _activenoti_create_activenoti(void *data) +static void _activenoti_update_activenoti(void) { - DBG(""); + ERR(""); Eina_Bool ret = EINA_FALSE; - notification_h noti = (notification_h) data; + notification_h noti; Evas_Object *icon = NULL; Evas_Object *badge = NULL; Evas_Object *bg_img = NULL; - - - Evas_Object *textblock = NULL; - char *title = NULL; - char *subtitle = NULL; - char *content = NULL; - int *is_activenoti_executed = NULL; int btn_cnt = 0; + bool auto_remove = true; + bool current_auto_remove = true; - retif(noti == NULL, , "Invalid parameter!"); + if (s_info.activenoti == NULL) { + ERR("Active notification doesn't exist"); + return; + } - if (s_info.activenoti != NULL) { - ERR("Instant notification exists"); + if (s_info.layout == NULL) { + ERR("Active notification doesn't exist"); return; } - s_info.activenoti = quickpanel_noti_win_add(NULL); - retif(s_info.activenoti == NULL, , "Failed to add elm activenoti."); - evas_object_data_set(s_info.activenoti, E_DATA_NOTI, noti); + if (s_info.delay_timer != NULL) { + ERR("s_info.delay_timer"); + ecore_timer_del(s_info.delay_timer); + s_info.delay_timer = NULL; + } - s_info.layout = elm_layout_add(s_info.activenoti); - if (!s_info.layout) { - ERR("Failed to get detailview."); - _activenoti_hide(s_info.activenoti, 0); + if (s_info.close_timer != NULL) { + ERR("s_info.close_timer"); + ecore_timer_del(s_info.close_timer); + s_info.close_timer = NULL; + } + + noti = _activenoti_get_in_list(s_info.current_noti); + if (noti == NULL) { + DBG("noti is null"); return; } - ret = elm_layout_file_set(s_info.layout, ACTIVENOTI_EDJ, "headsup/base"); - retif(ret == EINA_FALSE, , "failed to load layout"); - evas_object_show(s_info.layout); + if (s_info.current_noti) { + ret = notification_get_auto_remove(s_info.current_noti, ¤t_auto_remove); + if (ret != NOTIFICATION_ERROR_NONE) { + DBG("notification_get_auto_remove return [%s] from current_noti", ret); + return; + } + if (!current_auto_remove) { + DBG("!auto_remove"); + ret = notification_get_auto_remove(noti, &auto_remove); + if (ret != NOTIFICATION_ERROR_NONE) { + DBG("notification_get_auto_remove return [%s] from new noti", ret); + return; + } + + if (auto_remove) { + DBG("auto_remove"); + _activenoti_add_in_list(noti); // timer + return; // check!!! + } else { + DBG("!auto_remove"); + _activenoti_add_in_list(s_info.current_noti); + } + } + } else { + ret = notification_get_auto_remove(noti, ¤t_auto_remove); + if (ret != NOTIFICATION_ERROR_NONE) { + DBG("notification_get_auto_remove return [%s] from current_noti", ret); + return; + } + } + + s_info.current_noti = noti; + + if (current_auto_remove == true) { + time_t noti_time = 0; + ret = notification_get_time(s_info.current_noti, ¬i_time); + if (ret != NOTIFICATION_ERROR_NONE || noti_time == 0) { + notification_get_insert_time(s_info.current_noti, ¬i_time); + } + noti_time = time(NULL) - noti_time; + s_info.close_timer = ecore_timer_add(DEL_TIMER_VALUE - noti_time, _activenoti_close_timer_cb, NULL); + } - elm_object_signal_callback_add(s_info.layout, "noti_press" , "", _noti_press_cb, noti); - elm_object_signal_callback_add(s_info.layout, "del" , "", _noti_hide_cb, noti); + bg_img = elm_object_part_content_unset(s_info.layout, "bg_img"); + DBG("bg_img %p", bg_img); + if(bg_img != NULL) { + evas_object_del(bg_img); + bg_img = NULL; + } - bg_img = _get_bg_img(s_info.layout , noti); + bg_img = _get_bg_img(s_info.layout , s_info.current_noti); if (bg_img != NULL) { elm_object_part_content_set(s_info.layout, "bg_img", bg_img); - evas_object_data_set(s_info.activenoti, E_DATA_BG_IMAGE, bg_img); } - btn_cnt = _activenoti_create_button(s_info.layout, noti); - + btn_cnt = _activenoti_create_button(s_info.layout, s_info.current_noti); if (btn_cnt == 0) { //no button elm_object_signal_emit(s_info.layout, "btn_hide", "button.space"); + } else { + elm_object_signal_emit(s_info.layout, "btn_show", "button.space"); } - quickpanel_noti_win_content_set(s_info.activenoti, s_info.layout, btn_cnt); + icon = elm_object_part_content_unset(s_info.layout, "icon_big"); + DBG("icon %p", icon); + if(icon != NULL) { + evas_object_del(icon); + icon = NULL; + } - icon = _activenoti_create_icon(s_info.layout, noti); + icon = _activenoti_create_icon(s_info.layout, s_info.current_noti); if (icon != NULL) { elm_object_part_content_set(s_info.layout, "icon_big", icon); - evas_object_data_set(s_info.activenoti, E_DATA_ICON, icon); - badge = _activenoti_create_badge(s_info.layout, noti); + badge = elm_object_part_content_unset(s_info.layout, "icon_badge"); + DBG("badget %p", badge); + if(badge != NULL) { + evas_object_del(badge); + } + + badge = _activenoti_create_badge(s_info.layout, s_info.current_noti); if (badge != NULL) { elm_object_part_content_set(s_info.layout, "icon_badge", badge); - evas_object_data_set(s_info.activenoti, E_DATA_BADGE, icon); } else { INFO("badge is NULL"); } + DBG(""); } else { INFO("icon is NULL"); } - _activenoti_get_text(noti, 0, &subtitle, &title, &content); - - if (title != NULL) { - Eina_Strbuf *bufferT = eina_strbuf_new(); - eina_strbuf_append(bufferT, title); - elm_object_part_text_set(s_info.layout, "title_text", eina_strbuf_string_get(bufferT)); - free(title); - eina_strbuf_free(bufferT); - } - - - if (subtitle != NULL) { - Eina_Strbuf *bufferST = eina_strbuf_new(); - eina_strbuf_append(bufferST, subtitle); - elm_object_part_text_set(s_info.layout, "subtitle_text", eina_strbuf_string_get(bufferST)); - free(subtitle); - eina_strbuf_free(bufferST); - elm_object_signal_emit(s_info.layout, "subtext_show", "subtitle_text"); - } - - if (content != NULL) { - Eina_Strbuf *bufferC = eina_strbuf_new(); - eina_strbuf_append(bufferC, content); - elm_object_part_text_set(s_info.layout, "content_text", eina_strbuf_string_get(bufferC)); - free(content); - eina_strbuf_free(bufferC); - } - - SERR("activenoti noti is created"); - - s_info.gesture = _gesture_create(s_info.layout); - _activenoti_win_rotated(data, 0); - - if (s_info.close_timer != NULL) { - ecore_timer_del(s_info.close_timer); - s_info.close_timer = NULL; - } - s_info.close_timer = ecore_timer_add(DEL_TIMER_VALUE, _activenoti_hide_timer_cb, NULL); + _activenoti_set_text(noti, 0); evas_object_show(s_info.activenoti); - SERR("show activenoti noti"); + + SERR("activenoti noti is updated"); } -static void _activenoti_destroy_activenoti() +static void _activenoti_destroy_activenoti(void) { - Evas_Object *bg; - Evas_Object *icon; - Evas_Object *badge; - notification_h noti; - retif(!s_info.activenoti,,"s_info->activenoti is null"); _gesture_destroy(); - DBG("_activenoti_destroy_activenoti"); - if (s_info.delay_timer != NULL) { ecore_timer_del(s_info.delay_timer); s_info.delay_timer = NULL; @@ -1023,21 +1314,6 @@ static void _activenoti_destroy_activenoti() s_info.close_timer = NULL; } - bg = evas_object_data_del(s_info.activenoti, E_DATA_BG_IMAGE); - if (bg) { - evas_object_del(bg); - } - - icon = evas_object_data_del(s_info.activenoti, E_DATA_ICON); - if (icon) { - evas_object_del(icon); - } - - badge = evas_object_data_del(s_info.activenoti, E_DATA_BADGE); - if (badge) { - evas_object_del(badge); - } - if (s_info.btnbox) { evas_object_del(s_info.btnbox); s_info.btnbox = NULL; @@ -1048,21 +1324,16 @@ static void _activenoti_destroy_activenoti() s_info.layout = NULL; } - noti = evas_object_data_del(s_info.activenoti, E_DATA_NOTI); - if (noti) { - _activenoti_only_noti_del(noti); - notification_free(noti); - } if (s_info.activenoti) { - evas_object_hide(s_info.activenoti); + evas_object_del(s_info.activenoti); s_info.activenoti = NULL; } } static void _activenoti_win_rotated(void *data, int need_hide) { - int angle = 0; retif(data == NULL, ,"data is NULL"); + int angle = 0; struct appdata *ad = data; if (s_info.activenoti != NULL) { @@ -1079,83 +1350,80 @@ static void _activenoti_win_rotated(void *data, int need_hide) static void _media_feedback_sound(notification_h noti) { + retif(noti == NULL, ,"op_list is NULL"); int ret = 0, priv_id = 0; const char *nsound_path = NULL; notification_sound_type_e nsound_type = NOTIFICATION_SOUND_TYPE_NONE; char *default_msg_tone = NULL; - retif(noti == NULL, ,"op_list is NULL"); notification_get_id(noti, NULL, &priv_id); notification_get_sound(noti, &nsound_type, &nsound_path); SDBG("notification sound: %d, %s", nsound_type, nsound_path); switch (nsound_type) { - case NOTIFICATION_SOUND_TYPE_USER_DATA: - /* - * if user data file isn't playable, play the default ringtone - */ - if (nsound_path != NULL) { - if (quickpanel_media_playable_check(nsound_path) == EINA_TRUE) { - ret = quickpanel_media_player_play(SOUND_TYPE_NOTIFICATION, nsound_path); - if (quickpanel_media_player_is_drm_error(ret) == 1) { - ERR("failed to play notification sound due to DRM problem"); -#ifdef HAVE_X - ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, &default_msg_tone); - msgif(ret != SYSTEM_SETTINGS_ERROR_NONE, "ailed to get key(%s) : %d", SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, ret); -#endif - - - if (default_msg_tone != NULL) { - SDBG("setting sound[%s]", default_msg_tone); - ret = quickpanel_media_player_play(SOUND_TYPE_NOTIFICATION, default_msg_tone); - free(default_msg_tone); - } - } - if (ret == PLAYER_ERROR_NONE) { - quickpanel_media_player_id_set(priv_id); - } else { - ERR("failed to play notification sound"); + case NOTIFICATION_SOUND_TYPE_USER_DATA: + /* + * if user data file isn't playable, play the default ringtone + */ + if (nsound_path != NULL) { + if (quickpanel_media_playable_check(nsound_path) == EINA_TRUE) { + ret = quickpanel_media_player_play(SOUND_TYPE_NOTIFICATION, nsound_path); + if (quickpanel_media_player_is_drm_error(ret) == 1) { + ERR("failed to play notification sound due to DRM problem"); + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, &default_msg_tone); + msgif(ret != SYSTEM_SETTINGS_ERROR_NONE, "ailed to get key(%s) : %d", SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, ret); + + + if (default_msg_tone != NULL) { + SDBG("setting sound[%s]", default_msg_tone); + ret = quickpanel_media_player_play(SOUND_TYPE_NOTIFICATION, default_msg_tone); + free(default_msg_tone); } - break; - } else { - ERR("playable false, So unlock tone"); - feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_UNLOCK); } - } else { - ERR("sound path null"); - } - - break; - case NOTIFICATION_SOUND_TYPE_DEFAULT: -#ifdef HAVE_X - ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, &default_msg_tone); - msgif(ret != SYSTEM_SETTINGS_ERROR_NONE, "ailed to get key(%s) : %d", SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, ret); -#endif - if (default_msg_tone != NULL) { - SDBG("Reminded setting sound[%s]", default_msg_tone); - ret = quickpanel_media_player_play(SOUND_TYPE_NOTIFICATION, default_msg_tone); - free(default_msg_tone); if (ret == PLAYER_ERROR_NONE) { quickpanel_media_player_id_set(priv_id); } else { - ERR("failed to play notification sound(default)"); + ERR("failed to play notification sound"); } + break; + } else { + ERR("playable false, So unlock tone"); + feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_UNLOCK); } - break; - case NOTIFICATION_SOUND_TYPE_MAX: - case NOTIFICATION_SOUND_TYPE_NONE: - ERR("None type: No sound"); - break; + } else { + ERR("sound path null"); + } - default: - ERR("UnKnown type[%d]", (int)nsound_type); - break; + break; + case NOTIFICATION_SOUND_TYPE_DEFAULT: + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, &default_msg_tone); + msgif(ret != SYSTEM_SETTINGS_ERROR_NONE, "ailed to get key(%s) : %d", SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, ret); + + if (default_msg_tone != NULL) { + SDBG("Reminded setting sound[%s]", default_msg_tone); + ret = quickpanel_media_player_play(SOUND_TYPE_NOTIFICATION, default_msg_tone); + free(default_msg_tone); + if (ret == PLAYER_ERROR_NONE) { + quickpanel_media_player_id_set(priv_id); + } else { + ERR("failed to play notification sound(default)"); + } + } + break; + case NOTIFICATION_SOUND_TYPE_MAX: + case NOTIFICATION_SOUND_TYPE_NONE: + ERR("None type: No sound"); + break; + + default: + ERR("UnKnown type[%d]", (int)nsound_type); + break; } } static void _media_feedback_vibration(notification_h noti) { - retif(noti == NULL, ,"op_list is NULL"); + retif(noti == NULL, , "Invalid parameter!"); /* Play Vibration */ notification_vibration_type_e nvibration_type = NOTIFICATION_VIBRATION_TYPE_NONE; @@ -1164,59 +1432,55 @@ static void _media_feedback_vibration(notification_h noti) notification_get_vibration(noti, &nvibration_type, &nvibration_path); DBG("notification vibration: %d, %s", nvibration_type, nvibration_path); switch (nvibration_type) { - case NOTIFICATION_VIBRATION_TYPE_USER_DATA: - case NOTIFICATION_VIBRATION_TYPE_DEFAULT: - feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE); - break; - case NOTIFICATION_VIBRATION_TYPE_MAX: - case NOTIFICATION_VIBRATION_TYPE_NONE: - break; + case NOTIFICATION_VIBRATION_TYPE_USER_DATA: + case NOTIFICATION_VIBRATION_TYPE_DEFAULT: + feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE); + break; + case NOTIFICATION_VIBRATION_TYPE_MAX: + case NOTIFICATION_VIBRATION_TYPE_NONE: + break; } } static void _activenoti_noti_detailed_changed_cb(void *data, notification_type_e type, notification_op *op_list, int num_op) { + DBG(""); + retif(op_list == NULL, ,"op_list is NULL"); + notification_h noti = NULL; - notification_h noti_from_master = NULL; int flags = 0; int applist = NOTIFICATION_DISPLAY_APP_ALL; - int ret = 0; int op_type = 0; int priv_id = 0; - DBG("_quickpanel_activenoti_noti_changed_cb"); + notification_op_get_data(op_list, NOTIFICATION_OP_DATA_TYPE, &op_type); + notification_op_get_data(op_list, NOTIFICATION_OP_DATA_PRIV_ID, &priv_id); + notification_op_get_data(op_list, NOTIFICATION_OP_DATA_NOTI, ¬i); - retif(op_list == NULL, ,"op_list is NULL"); + DBG("op_type:%d", op_type); + DBG("op_priv_id:%d", priv_id); + DBG("noti:%p", noti); - if (num_op == 1) { - notification_op_get_data(op_list, NOTIFICATION_OP_DATA_TYPE, &op_type); - notification_op_get_data(op_list, NOTIFICATION_OP_DATA_PRIV_ID, &priv_id); - notification_op_get_data(op_list, NOTIFICATION_OP_DATA_NOTI, ¬i_from_master); - DBG("op_type:%d", op_type); - DBG("op_priv_id:%d", priv_id); - DBG("noti:%p", noti_from_master); + if( op_type == NOTIFICATION_OP_DELETE) { + DBG("NOTIFICATION_OP_DELETE"); + int priv_id_current = 0; - if (op_type != NOTIFICATION_OP_INSERT && - op_type != NOTIFICATION_OP_UPDATE) { - return; - } - if (noti_from_master == NULL) { - ERR("failed to get a notification from master"); - return; - } - if (notification_clone(noti_from_master, ¬i) != NOTIFICATION_ERROR_NONE) { - ERR("failed to create a cloned notification"); - return; - } -#ifdef QP_EMERGENCY_MODE_ENABLE - if (quickpanel_emergency_mode_is_on()) { - if (quickpanel_emergency_mode_notification_filter(noti, 1)) { - DBG("notification filtered"); - notification_free(noti); + if (s_info.current_noti) { + notification_get_id(s_info.current_noti, NULL, &priv_id_current); + if (s_info.current_noti == noti || priv_id_current == priv_id) { + _activenoti_hide(NULL, 0); return; } } -#endif + + _activenoti_remove_in_list(noti); + + return; + } else if (op_type == NOTIFICATION_OP_DELETE_ALL) { + if(s_info.current_noti) { + _activenoti_hide(NULL, 0); + } + _activenoti_remove_list(); } retif(noti == NULL, ,"noti is NULL"); @@ -1224,54 +1488,45 @@ static void _activenoti_noti_detailed_changed_cb(void *data, notification_type_e if (op_type == NOTIFICATION_OP_INSERT || op_type == NOTIFICATION_OP_UPDATE) { if (_is_sound_playable() == 1) { if (_check_sound_off(noti) == 0) { - DBG("try to play notification sound"); + DBG("try to play notification sound %x", pthread_self()); _media_feedback_sound(noti); + if (quickpanel_media_is_vib_enabled() == 1 + || quickpanel_media_is_sound_enabled() == 1) { + _media_feedback_vibration(noti); + } } - if (quickpanel_media_is_vib_enabled() == 1 - || quickpanel_media_is_sound_enabled() == 1) { - _media_feedback_vibration(noti); - } + } } notification_get_display_applist(noti, &applist); + DBG("applist : %x" ,applist); /* Check activenoti flag */ notification_get_property(noti, &flags); - DBG("applist : %x" ,applist); - -#ifdef HAVE_X - if (applist & NOTIFICATION_DISPLAY_APP_HEADS_UP) -#endif - { - if (_is_security_lockscreen_launched()) { - notification_free(noti); + if (applist & NOTIFICATION_DISPLAY_APP_ACTIVE) { + if (_is_security_lockscreen_launched() || _check_sound_off(noti) == 1 ) { INFO("lock screen is launched"); return; } - if (quickpanel_uic_is_opened()) { + if (quickpanel_uic_is_opened() && (applist & NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY) ) { ERR("quickpanel is opened, activenoti will be not displayed"); - notification_free(noti); - INFO("quickpanel has opened"); return; } /* wait if s_info.activenoti is not NULL */ - if (s_info.activenoti == NULL) { - _activenoti_create_activenoti(noti); - } else { - INFO("s_info.activenoti is not NULL"); - _activenoti_update_activenoti(noti); - } + _activenoti_add_in_list(noti); + _activenoti_create_activenoti(); if (s_info.activenoti == NULL) { ERR("Fail to create activenoti"); _activenoti_only_noti_del(noti); - notification_free(noti); return; } + + _activenoti_update_activenoti(); } } @@ -1301,7 +1556,7 @@ static int _activenoti_init(void *data) static int _activenoti_fini(void *data) { - struct appdata *ad = (struct appdata *)data; + // struct appdata *ad = (struct appdata *)data; _activenoti_destroy_activenoti(); @@ -1326,3 +1581,16 @@ static void _activenoti_reflesh(void *data) _activenoti_win_rotated(data, 1); } } + +static void _activenoti_qp_opened(void *data) +{ + DBG(""); + struct appdata *ad = data; + retif(ad == NULL, , "Invalid parameter!"); + + if (_activenoti_has_pending_noti()) { + _activenoti_remove_list(); + } + _activenoti_hide(NULL, 0); +} + |