2 * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <Elementary.h>
21 #include <appcore-common.h>
23 #include <app_control.h>
24 #include <notification.h>
27 #include "quickpanel-ui.h"
31 #include "noti_util.h"
32 #ifdef QP_EMERGENCY_MODE_ENABLE
33 #include "emergency_mode.h"
35 #include "animated_icon.h"
37 #define QP_TICKER_DURATION 3
38 #define QP_TICKER_DETAIL_DURATION 6
40 #define TICKER_MSG_LEN 1024
41 #define DEFAULT_ICON ICONDIR "/quickpanel_icon_default.png"
43 #define E_DATA_IS_TICKERNOTI_CONTENT "E_DATA_TN_CONTENT"
44 #define E_DATA_IS_TICKERNOTI_EXECUTED "E_DATA_TN_EXECUTED"
46 #define FORMAT_1LINE "<font_size=29><color=#F4F4F4FF>%s</color></font_size>"
47 #define FORMAT_2LINE "<font_size=26><color=#BABABAFF>%s</color></font_size><br/><font_size=29><color=#F4F4F4FF>%s</color></font_size>"
49 static Evas_Object *g_window = NULL;
50 static Evas_Object *g_ticker = NULL;
51 static Evas_Object *g_scroller = NULL;
52 static Ecore_Timer *g_timer = NULL;
53 static Eina_List *ticker_list = NULL;
55 static int quickpanel_ticker_init(void *data);
56 static int quickpanel_ticker_fini(void *data);
57 static int quickpanel_ticker_enter_hib(void *data);
58 static int quickpanel_ticker_leave_hib(void *data);
59 static void quickpanel_ticker_reflesh(void *data);
60 static void _quickpanel_ticker_destroy_tickernoti(Evas_Object *tickernoti);
61 static void _quickpanel_ticker_create_tickernoti(void *data);
62 static void _quickpanel_ticker_win_rotated(void *data, int need_hide);
66 .init = quickpanel_ticker_init,
67 .fini = quickpanel_ticker_fini,
68 .hib_enter = quickpanel_ticker_enter_hib,
69 .hib_leave = quickpanel_ticker_leave_hib,
71 .refresh = quickpanel_ticker_reflesh
74 static inline int _is_text_exist(const char *text) {
76 if (strlen(text) > 0) {
77 if (strcmp(text, "") != 0) {
86 static int _is_sound_playable(void) {
87 int status = 0, ret = 0;
89 ret = vconf_get_int(VCONFKEY_CAMERA_STATE, &status);
90 if (ret == 0 && status == VCONFKEY_CAMERA_STATE_RECORDING) {
91 ERR("camcorder is working, don't play notification sound %d %d", ret, status);
96 if ((ret = sound_manager_get_current_sound_type(&type))
97 == SOUND_MANAGER_ERROR_CAPTURE_ONLY) {
98 ERR("capturing sound is working, don't play notification sound");
106 static int _is_blocking_mode_on(void) {
108 int is_blocking_mode_on = 0;
110 if ((ret = vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_NOTIFICATIONS, &is_blocking_mode_on)) == 0) {
111 if (ret == 0 && is_blocking_mode_on == 1) {
119 static int _is_security_lockscreen_launched(void) {
121 int is_lock_launched = 0;
123 if ((ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &is_lock_launched)) == 0) {
124 if (is_lock_launched == VCONFKEY_IDLE_LOCK && (ret = vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &is_lock_launched)) == 0) {
125 if (is_lock_launched != SETTING_SCREEN_LOCK_TYPE_NONE && is_lock_launched != SETTING_SCREEN_LOCK_TYPE_SWIPE) {
134 static int _check_is_noti_from_email(char *pkgname) {
135 retif(pkgname == NULL, 0, "Invalid parameter!");
139 if (strcmp(pkgname, VENDOR".email") == 0 || strcmp(pkgname, "/usr/bin/eas-engine") == 0) {
149 static int _check_is_noti_from_message(char *pkgname) {
150 retif(pkgname == NULL, 0, "Invalid parameter!");
152 if (strcmp(pkgname, VENDOR".message-lite") == 0 || strcmp(pkgname, "/usr/bin/msg-server") == 0) {
159 static int _check_is_noti_from_im(char *pkgname) {
160 retif(pkgname == NULL, 0, "Invalid parameter!");
162 if (strcmp(pkgname, "xnq5eh9vop.ChatON") == 0) {
169 static notification_h _get_instant_latest_message_from_list(void) {
171 notification_h noti = NULL;
173 count = eina_list_count(ticker_list);
175 noti = eina_list_nth(ticker_list, count-1);
177 eina_list_free(ticker_list);
185 /*****************************************************************************
187 * (Static) Util functions
189 *****************************************************************************/
191 static int _quickpanel_ticker_check_ticker_off(notification_h noti)
193 char *pkgname = NULL;
197 notification_get_pkgname(noti, &pkgname);
200 return 1; /* Ticker is not displaying. */
202 if (_check_is_noti_from_message(pkgname) == 1)
204 ret = vconf_get_bool(
205 VCONFKEY_SETAPPL_STATE_TICKER_NOTI_MESSAGES_BOOL,
207 if (ret == 0 && boolval == 0)
213 /* Displaying ticker! */
223 static int _quickpanel_ticker_check_displaying_contents_off(notification_h noti)
225 char *pkgname = NULL;
229 notification_get_pkgname(noti, &pkgname);
232 return 0; /* Ticker is not displaying. */
234 if (_check_is_noti_from_message(pkgname) == 1) {
235 ret = vconf_get_bool(
236 VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_MESSASGES,
238 if (ret == 0 && boolval == 0)
240 } else if (_check_is_noti_from_email(pkgname) == 1) {
241 ret = vconf_get_bool(
242 VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_EMAIL,
244 if (ret == 0 && boolval == 0)
246 } else if (_check_is_noti_from_im(pkgname) == 1) {
247 ret = vconf_get_bool(
248 VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_IM,
250 if (ret == 0 && boolval == 0)
254 /* Displaying ticker! */
258 static int _quickpanel_ticker_check_sound_off(notification_h noti)
260 char *pkgname = NULL;
264 notification_get_pkgname(noti, &pkgname);
267 return 0; /* don't play sound */
269 if (_check_is_noti_from_message(pkgname) == 1) {
270 ret = vconf_get_bool(
271 VCONFKEY_TICKER_NOTI_SOUND_MESSAGES,
273 DBG("VCONFKEY_TICKER_NOTI_SOUND_MESSAGES:%d", boolval);
275 if (ret == 0 && boolval == 0)
278 ERR("Failed to get a value of %s(%d)",
279 "VCONFKEY_TICKER_NOTI_SOUND_MESSAGES", ret);
281 } else if (_check_is_noti_from_email(pkgname) == 1) {
282 ret = vconf_get_bool(
283 VCONFKEY_TICKER_NOTI_SOUND_EMAIL,
285 if (ret == 0 && boolval == 0)
288 ERR("Failed to get a value of %s(%d)",
289 "VCONFKEY_TICKER_NOTI_SOUND_EMAIL", ret);
291 } else if (_check_is_noti_from_im(pkgname) == 1) {
292 ret = vconf_get_bool(
293 VCONFKEY_TICKER_NOTI_SOUND_IM,
295 if (ret == 0 && boolval == 0)
298 ERR("Failed to get a value of %s(%d)",
299 "VCONFKEY_TICKER_NOTI_SOUND_IM", ret);
306 static inline void __ticker_only_noti_del(notification_h noti)
308 int applist = NOTIFICATION_DISPLAY_APP_ALL;
310 retif(noti == NULL, ,"noti is null");
312 notification_get_display_applist(noti, &applist);
313 if (applist & NOTIFICATION_DISPLAY_APP_TICKER) {
314 if (!(applist & NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY)) {
315 char *pkgname = NULL;
318 notification_get_pkgname(noti, &pkgname);
319 notification_get_id(noti, NULL, &priv_id);
320 notification_delete_by_priv_id(pkgname,
321 NOTIFICATION_TYPE_NONE,
327 static void _quickpanel_ticker_del(void *data)
330 evas_object_del(g_ticker);
334 static Eina_Bool _quickpanel_ticker_timeout_cb(void *data)
336 DBG("ticker dismissed by timeout callback");
342 //notification_h noti = (notification_h) data;
344 /* If count is 1, self*/
345 if (ticker_list && eina_list_count(ticker_list) > 1) {
347 ecore_timer_del(g_timer);
350 _quickpanel_ticker_del(data);
352 return ECORE_CALLBACK_CANCEL;
355 elm_scroller_last_page_get(g_scroller, &h_last_page, &v_last_page);
356 elm_scroller_current_page_get(g_scroller, &h_page, &v_page);
358 if (v_last_page > v_page) {
359 elm_scroller_page_bring_in(g_scroller, h_page, v_page + 1);
361 return ECORE_CALLBACK_RENEW;
365 ecore_timer_del(g_timer);
368 _quickpanel_ticker_del(data);
370 return ECORE_CALLBACK_CANCEL;
373 static void _quickpanel_ticker_detail_delete_cb(void *data, Evas *e,
377 DBG("ticker dismissed by touching a hide button");
379 notification_h noti = (notification_h) data;
381 _quickpanel_ticker_destroy_tickernoti(g_ticker);
385 ecore_timer_del(g_timer);
389 retif(noti == NULL, , "Invalid parameter!");
391 __ticker_only_noti_del(noti);
392 notification_free(noti);
395 noti = _get_instant_latest_message_from_list();
397 _quickpanel_ticker_create_tickernoti(noti);
402 static void _quickpanel_ticker_detail_show_cb(void *data, Evas *e,
409 static Evas_Object *_quickpanel_ticker_create_icon(Evas_Object *parent,
412 char *pkgname = NULL;
413 char *icon_path = NULL;
414 char *icon_default = NULL;
415 Evas_Object *icon = NULL;
417 retif(noti == NULL || parent == NULL, NULL, "Invalid parameter!");
419 notification_get_pkgname(noti, &pkgname);
420 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, &icon_path);
422 icon = quickpanel_service_animated_icon_get(parent, icon_path);
424 icon = elm_image_add(parent);
425 if (icon_path == NULL
426 || (elm_image_file_set(icon, icon_path, NULL) == EINA_FALSE)) {
427 icon_default = quickpanel_ui_get_pkginfo_icon(pkgname);
428 if (icon_default != NULL) {
429 elm_image_file_set(icon, icon_default, NULL);
430 elm_image_resizable_set(icon, EINA_TRUE, EINA_TRUE);
433 elm_image_file_set(icon, DEFAULT_ICON, NULL);
434 elm_image_resizable_set(icon, EINA_TRUE, EINA_TRUE);
442 static inline char *_get_text(notification_h noti, notification_text_type_e text_type) {
445 char buf[TICKER_MSG_LEN] = {0,};
447 if (notification_get_time_from_text(noti, text_type, &time) == NOTIFICATION_ERROR_NONE) {
449 quickpanel_noti_get_time(time, buf, sizeof(buf));
453 notification_get_text(noti, text_type, &text);
457 return elm_entry_utf8_to_markup(text);
463 static inline void _strbuf_add(Eina_Strbuf *str_buf, char *text, const char *delimiter) {
465 if (strlen(text) > 0) {
466 if (delimiter != NULL) {
467 eina_strbuf_append(str_buf, delimiter);
469 eina_strbuf_append(str_buf, text);
474 static inline void _check_and_add_to_buffer(Eina_Strbuf *str_buf, char *text, int is_check_phonenumber) {
475 char buf_number[QP_UTIL_PHONE_NUMBER_MAX_LEN * 2] = { 0, };
478 if (strlen(text) > 0) {
479 if (quickpanel_util_is_phone_number(text) && is_check_phonenumber) {
480 quickpanel_util_phone_number_tts_make(buf_number, text,
481 (QP_UTIL_PHONE_NUMBER_MAX_LEN * 2) - 1);
482 eina_strbuf_append(str_buf, buf_number);
484 eina_strbuf_append(str_buf, text);
486 eina_strbuf_append_char(str_buf, '\n');
491 static char *_quickpanel_ticker_get_label_layout_default(notification_h noti, int is_screenreader, char **str_line1, char **str_line2)
497 char *title_utf8 = NULL;
498 char *content_utf8 = NULL;
499 char *info1_utf8 = NULL;
500 char *info1_sub_utf8 = NULL;
501 char *info2_utf8 = NULL;
502 char *info2_sub_utf8 = NULL;
503 char *event_count_utf8 = NULL;
504 const char *tmp = NULL;
505 Eina_Strbuf *line1 = NULL;
506 Eina_Strbuf *line2 = NULL;
507 char buf[TICKER_MSG_LEN] = { 0, };
509 retif(noti == NULL, NULL, "Invalid parameter!");
511 notification_get_text_domain(noti, &domain, &dir);
512 if (domain != NULL && dir != NULL)
513 bindtextdomain(domain, dir);
515 title_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE);
516 if (_quickpanel_ticker_check_displaying_contents_off(noti) == 1) {
517 content_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF);
520 content_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT);
522 info1_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1);
523 info1_sub_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1);
524 info2_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2);
525 info2_sub_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_2);
526 //event_count_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT);
528 if (is_screenreader == 0) {
529 line1 = eina_strbuf_new();
530 line2 = eina_strbuf_new();
532 if (line1 != NULL && line2 != NULL) {
533 if (_is_text_exist(title_utf8) && (_is_text_exist(content_utf8)
534 || _is_text_exist(event_count_utf8))) {
535 _strbuf_add(line1, title_utf8, NULL);
536 _strbuf_add(line2, content_utf8, NULL);
537 if (_is_text_exist(content_utf8)) {
538 _strbuf_add(line2, event_count_utf8, " ");
540 _strbuf_add(line2, event_count_utf8, "");
543 } else if (_is_text_exist(info1_utf8) && (_is_text_exist(content_utf8)
544 || _is_text_exist(event_count_utf8))) {
545 _strbuf_add(line1, content_utf8, NULL);
546 _strbuf_add(line1, event_count_utf8, " ");
547 _strbuf_add(line2, info1_utf8, NULL);
548 _strbuf_add(line2, info1_sub_utf8, " ");
550 } else if (_is_text_exist(info1_utf8) && _is_text_exist(info2_utf8)) {
551 _strbuf_add(line1, info1_utf8, NULL);
552 _strbuf_add(line1, info1_sub_utf8, " ");
553 _strbuf_add(line2, info2_utf8, NULL);
554 _strbuf_add(line2, info2_sub_utf8, " ");
556 } else if (_is_text_exist(title_utf8)) {
557 _strbuf_add(line1, title_utf8, NULL);
559 } else if (_is_text_exist(content_utf8)) {
560 _strbuf_add(line1, content_utf8, NULL);
565 tmp = eina_strbuf_string_get(line1);
566 if (str_line1 != NULL && tmp != NULL) {
567 *str_line1 = strdup(tmp);
570 tmp = eina_strbuf_string_get(line2);
571 if (str_line2 != NULL && tmp != NULL) {
572 *str_line2 = strdup(tmp);
575 tmp = eina_strbuf_string_get(line1);
576 if (str_line1 != NULL && tmp != NULL) {
577 *str_line1 = strdup(tmp);
581 eina_strbuf_free(line1);
582 eina_strbuf_free(line2);
584 ERR("failed to allocate string buffer");
587 if (title_utf8 == NULL
588 && event_count_utf8 == NULL
589 && content_utf8 == NULL
590 && info1_utf8 == NULL
591 && info1_sub_utf8 == NULL
592 && info2_utf8 == NULL
593 && info2_sub_utf8 == NULL) {
596 Eina_Strbuf *strbuf = eina_strbuf_new();
597 if (strbuf != NULL) {
598 eina_strbuf_append(strbuf, _("IDS_QP_BUTTON_NOTIFICATION"));
599 eina_strbuf_append_char(strbuf, '\n');
600 _check_and_add_to_buffer(strbuf, title_utf8, 1);
601 _check_and_add_to_buffer(strbuf, event_count_utf8, 0);
602 _check_and_add_to_buffer(strbuf, content_utf8, 1);
603 _check_and_add_to_buffer(strbuf, info1_utf8, 1);
604 _check_and_add_to_buffer(strbuf, info1_sub_utf8, 1);
605 _check_and_add_to_buffer(strbuf, info2_utf8, 1);
606 _check_and_add_to_buffer(strbuf, info2_sub_utf8, 1);
608 if (eina_strbuf_length_get(strbuf) > 0) {
609 len = snprintf(buf, sizeof(buf) - 1, "%s", eina_strbuf_string_get(strbuf));
611 eina_strbuf_free(strbuf);
622 // if (event_count_utf8)
623 // free(event_count_utf8);
629 free(info1_sub_utf8);
635 free(info2_sub_utf8);
643 static char *_quickpanel_ticker_get_label_layout_single(notification_h noti, int is_screenreader, char **str_line1, char **str_line2)
649 char *title_utf8 = NULL;
650 char *content_utf8 = NULL;
651 char *info1_utf8 = NULL;
652 char *info1_sub_utf8 = NULL;
653 char *info2_utf8 = NULL;
654 char *info2_sub_utf8 = NULL;
655 Eina_Strbuf *line1 = NULL;
656 Eina_Strbuf *line2 = NULL;
657 const char *tmp = NULL;
658 char buf[TICKER_MSG_LEN] = { 0, };
660 retif(noti == NULL, NULL, "Invalid parameter!");
662 notification_get_text_domain(noti, &domain, &dir);
663 if (domain != NULL && dir != NULL)
664 bindtextdomain(domain, dir);
666 title_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE);
667 if (_quickpanel_ticker_check_displaying_contents_off(noti) == 1) {
668 content_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF);
671 content_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT);
673 info1_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1);
674 info1_sub_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1);
675 info2_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2);
676 info2_sub_utf8 = _get_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_2);
678 if (is_screenreader == 0) {
679 line1 = eina_strbuf_new();
680 line2 = eina_strbuf_new();
682 if (line1 != NULL && line2 != NULL) {
683 if (_is_text_exist(info1_utf8) && _is_text_exist(content_utf8)) {
684 _strbuf_add(line1, content_utf8, NULL);
685 _strbuf_add(line2, info1_utf8, NULL);
686 _strbuf_add(line2, info1_sub_utf8, " ");
688 } else if (_is_text_exist(title_utf8) && _is_text_exist(content_utf8)) {
689 _strbuf_add(line1, title_utf8, NULL);
690 _strbuf_add(line2, content_utf8, NULL);
692 } else if (_is_text_exist(title_utf8)) {
693 _strbuf_add(line1, title_utf8, NULL);
695 } else if (_is_text_exist(content_utf8)) {
696 _strbuf_add(line1, content_utf8, NULL);
701 tmp = eina_strbuf_string_get(line1);
702 if (str_line1 != NULL && tmp != NULL) {
703 *str_line1 = strdup(tmp);
706 tmp = eina_strbuf_string_get(line2);
707 if (str_line2 != NULL && tmp != NULL) {
708 *str_line2 = strdup(tmp);
711 tmp = eina_strbuf_string_get(line1);
712 if (str_line1 != NULL && tmp != NULL) {
713 *str_line1 = strdup(tmp);
717 eina_strbuf_free(line1);
718 eina_strbuf_free(line2);
720 ERR("failed to allocate string buffer");
723 if (title_utf8 == NULL
724 && content_utf8 == NULL
725 && info1_utf8 == NULL
726 && info1_sub_utf8 == NULL) {
729 Eina_Strbuf *strbuf = eina_strbuf_new();
730 if (strbuf != NULL) {
731 eina_strbuf_append(strbuf, _("IDS_QP_BUTTON_NOTIFICATION"));
732 eina_strbuf_append_char(strbuf, '\n');
733 if (info1_utf8 == NULL) {
734 _check_and_add_to_buffer(strbuf, title_utf8, 1);
735 _check_and_add_to_buffer(strbuf, content_utf8, 1);
737 if (content_utf8 == NULL) {
738 _check_and_add_to_buffer(strbuf, title_utf8, 1);
740 _check_and_add_to_buffer(strbuf, content_utf8, 1);
741 _check_and_add_to_buffer(strbuf, info1_utf8, 1);
742 _check_and_add_to_buffer(strbuf, info1_sub_utf8, 1);
745 if (eina_strbuf_length_get(strbuf) > 0) {
746 len = snprintf(buf, sizeof(buf) - 1, "%s", eina_strbuf_string_get(strbuf));
748 eina_strbuf_free(strbuf);
763 free(info1_sub_utf8);
769 free(info2_sub_utf8);
777 static char *_quickpanel_ticker_get_text(notification_h noti, int is_screenreader, char **line1, char **line2)
780 notification_ly_type_e layout;
782 retif(noti == NULL, NULL, "Invalid parameter!");
784 notification_get_layout(noti, &layout);
786 if (_quickpanel_ticker_check_displaying_contents_off(noti) == 1) {
787 result = _quickpanel_ticker_get_label_layout_default(noti, is_screenreader, line1, line2);
788 } else if (layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE) {
789 result = _quickpanel_ticker_get_label_layout_single(noti, is_screenreader, line1, line2);
791 result = _quickpanel_ticker_get_label_layout_default(noti, is_screenreader, line1, line2);
797 static void _noti_hide_cb(void *data, Evas_Object *obj,
798 const char *emission, const char *source)
803 ecore_timer_del(g_timer);
807 _quickpanel_ticker_del(data);
810 static void _quickpanel_ticker_create_tickernoti(void *data)
812 Eina_Bool ret = EINA_FALSE;
814 notification_h noti = (notification_h) data;
815 Evas_Object *icon = NULL;
816 Evas_Object *detail = NULL;
817 Evas_Object *textblock = NULL;
820 const char *data_win_height = NULL;
822 int *is_ticker_executed = NULL;
823 //double scale = elm_config_scale_get();
825 retif(noti == NULL, , "Invalid parameter!");
827 if (g_ticker != NULL) {
828 ERR("Instant notification exists");
832 g_ticker = noti_win_add(NULL);
833 retif(g_ticker == NULL, , "Failed to add elm tickernoti.");
835 detail = elm_layout_add(g_ticker);
837 ERR("Failed to get detailview.");
838 _quickpanel_ticker_del(g_ticker);
842 ret = elm_layout_file_set(detail, TICKER_EDJ, "quickpanel/tickernoti/normal");
843 retif(ret == EINA_FALSE, , "failed to load layout");
845 elm_layout_theme_set(detail, "tickernoti", "base", "default");
846 elm_object_signal_callback_add(detail, "request,hide", "",
847 _noti_hide_cb, noti);
848 //elm_object_signal_callback_add(detail, "clicked", "",
849 // _quickpanel_ticker_clicked_cb, noti);
850 evas_object_event_callback_add(detail,
851 EVAS_CALLBACK_MOUSE_DOWN, _noti_hide_cb, noti);
853 data_win_height = (char *)elm_layout_data_get(detail, "height");
854 /*if (data_win_height != NULL && elm_config_scale_get() > 0.0)
855 noti_height = (int)(elm_config_scale_get()
856 * atoi(data_win_height));*/
857 evas_object_size_hint_min_set(detail, 1, noti_height);
859 noti_win_content_set(g_ticker, detail);
861 icon = _quickpanel_ticker_create_icon(detail, noti);
863 elm_object_part_content_set(detail, "icon", icon);
865 g_scroller = elm_scroller_add(detail);
866 elm_scroller_policy_set(g_scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
867 elm_scroller_page_size_set(g_scroller, 434, 28);
869 elm_scroller_movement_block_set(g_scroller, ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL|ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL);
871 textblock = elm_layout_add(g_ticker);
873 ERR("Failed to get detailview.");
874 _quickpanel_ticker_del(g_ticker);
878 ret = elm_layout_file_set(textblock, TICKER_EDJ, "quickpanel/tickernoti/text");
879 retif(ret == EINA_FALSE, , "failed to load layout");
881 elm_layout_theme_set(detail, "tickernoti", "base", "default");
883 elm_object_content_set(g_scroller, textblock);
885 elm_object_part_content_set(detail, "text_rect", g_scroller);
887 _quickpanel_ticker_get_text(noti, 0, &line1, &line2);
891 elm_object_part_text_set(textblock, "elm.text", line2);
892 SERR("text [%s]", line2);
896 else if (line2 == NULL) {
897 elm_object_part_text_set(textblock, "elm.text", line1);
898 SERR("text [%s]", line1);
902 Eina_Strbuf *buffer = eina_strbuf_new();
903 eina_strbuf_append(buffer, line1);
904 eina_strbuf_append(buffer, "<br/>");
905 eina_strbuf_append(buffer, line2);
906 elm_object_part_text_set(textblock, "elm.text", eina_strbuf_string_get(buffer));
907 SERR("text [%s]", eina_strbuf_string_get(buffer));
910 eina_strbuf_free(buffer);
913 /* Use style "default" for detailview mode and
914 * "info" for text only mode
916 elm_object_style_set(g_ticker, "default");
917 evas_object_data_set(g_ticker, E_DATA_IS_TICKERNOTI_CONTENT, detail);
918 is_ticker_executed = (int *)malloc(sizeof(int));
919 if (is_ticker_executed != NULL) {
920 *is_ticker_executed = 0;
921 evas_object_data_set(detail, E_DATA_IS_TICKERNOTI_EXECUTED, is_ticker_executed);
924 SERR("ticker noti is created");
926 g_timer = ecore_timer_add(QP_TICKER_DURATION,
927 _quickpanel_ticker_timeout_cb, noti);
929 _quickpanel_ticker_win_rotated(data, 0);
931 evas_object_show(g_ticker);
932 SERR("show ticker noti");
934 evas_object_event_callback_add(g_ticker, EVAS_CALLBACK_SHOW,
935 _quickpanel_ticker_detail_show_cb,
937 evas_object_event_callback_add(g_ticker, EVAS_CALLBACK_DEL,
938 _quickpanel_ticker_detail_delete_cb,
942 static void _quickpanel_ticker_destroy_tickernoti(Evas_Object *tickernoti)
944 int *is_ticker_executed = NULL;
945 Evas_Object *detail = NULL;
947 retif(tickernoti == NULL, , "Invalid parameter!");
949 detail = evas_object_data_get(tickernoti, E_DATA_IS_TICKERNOTI_CONTENT);
951 if (detail != NULL) {
952 is_ticker_executed = evas_object_data_get(detail, E_DATA_IS_TICKERNOTI_EXECUTED);
953 if (is_ticker_executed != NULL) {
954 evas_object_data_del(detail, E_DATA_IS_TICKERNOTI_EXECUTED);
955 free(is_ticker_executed);
957 evas_object_data_del(detail, E_DATA_IS_TICKERNOTI_CONTENT);
961 static void _quickpanel_ticker_win_rotated(void *data, int need_hide) {
963 retif(data == NULL, ,"data is NULL");
964 struct appdata *ad = data;
966 if (g_ticker != NULL) {
967 angle = elm_win_rotation_get(g_ticker);
969 if (((angle == 0 || angle == 180) && (ad->angle == 90 || ad->angle == 270))
970 || ((angle == 90 || angle == 270) && (ad->angle == 0 || ad->angle == 180))) {
971 if (need_hide == 1) {
972 evas_object_hide(g_ticker);
978 static void _quickpanel_noti_media_feedback_sound(notification_h noti) {
979 int ret = 0, priv_id = 0;
980 const char *nsound_path = NULL;
981 notification_sound_type_e nsound_type = NOTIFICATION_SOUND_TYPE_NONE;
982 #ifdef VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR
983 char *default_msg_tone = NULL;
985 retif(noti == NULL, ,"op_list is NULL");
987 notification_get_id(noti, NULL, &priv_id);
988 notification_get_sound(noti, &nsound_type, &nsound_path);
989 SDBG("notification sound: %d, %s", nsound_type, nsound_path);
991 switch (nsound_type) {
992 case NOTIFICATION_SOUND_TYPE_USER_DATA:
994 * if user data file isn't playable, play the default ringtone
996 if (nsound_path != NULL)
998 if (quickpanel_media_playable_check(nsound_path) == EINA_TRUE)
1000 ret = quickpanel_player_play(SOUND_TYPE_NOTIFICATION, nsound_path);
1001 if (quickpanel_player_is_drm_error(ret) == 1)
1003 ERR("failed to play notification sound due to DRM problem");
1004 #ifdef VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR
1005 default_msg_tone = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
1007 if (default_msg_tone != NULL) {
1008 ret = quickpanel_player_play(SOUND_TYPE_NOTIFICATION, default_msg_tone);
1009 free(default_msg_tone);
1013 if (ret == PLAYER_ERROR_NONE)
1015 quickpanel_player_id_set(priv_id);
1018 ERR("failed to play notification sound");
1024 ERR("playable false, So unlock tone");
1025 feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_UNLOCK);
1030 ERR("sound path null");
1031 //feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_UNLOCK);
1035 case NOTIFICATION_SOUND_TYPE_DEFAULT:
1036 #ifdef VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR
1037 default_msg_tone = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
1039 if (default_msg_tone != NULL) {
1040 ret = quickpanel_player_play(SOUND_TYPE_NOTIFICATION, default_msg_tone);
1041 free(default_msg_tone);
1042 if (ret == PLAYER_ERROR_NONE) {
1043 quickpanel_player_id_set(priv_id);
1045 ERR("failed to play notification sound(default)");
1048 feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_UNLOCK);
1051 feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_UNLOCK);
1054 case NOTIFICATION_SOUND_TYPE_MAX:
1055 case NOTIFICATION_SOUND_TYPE_NONE:
1056 ERR("None type: No sound");
1060 ERR("UnKnown type[%d]", (int)nsound_type);
1065 static void _quickpanel_noti_media_feedback_vibration(notification_h noti) {
1066 retif(noti == NULL, ,"op_list is NULL");
1068 /* Play Vibration */
1069 notification_vibration_type_e nvibration_type =
1070 NOTIFICATION_VIBRATION_TYPE_NONE;
1071 const char *nvibration_path = NULL;
1073 notification_get_vibration(noti, &nvibration_type, &nvibration_path);
1074 DBG("notification vibration: %d, %s", nvibration_type, nvibration_path);
1075 switch (nvibration_type) {
1076 case NOTIFICATION_VIBRATION_TYPE_USER_DATA:
1077 case NOTIFICATION_VIBRATION_TYPE_DEFAULT:
1078 feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE);
1080 case NOTIFICATION_VIBRATION_TYPE_MAX:
1081 case NOTIFICATION_VIBRATION_TYPE_NONE:
1086 static void _quickpanel_ticker_noti_detailed_changed_cb(void *data, notification_type_e type, notification_op *op_list, int num_op)
1088 notification_h noti = NULL;
1089 notification_h noti_from_master = NULL;
1091 int applist = NOTIFICATION_DISPLAY_APP_ALL;
1096 DBG("_quickpanel_ticker_noti_changed_cb");
1098 retif(op_list == NULL, ,"op_list is NULL");
1101 notification_op_get_data(op_list, NOTIFICATION_OP_DATA_TYPE, &op_type);
1102 notification_op_get_data(op_list, NOTIFICATION_OP_DATA_PRIV_ID, &priv_id);
1103 notification_op_get_data(op_list, NOTIFICATION_OP_DATA_NOTI, ¬i_from_master);
1104 DBG("op_type:%d", op_type);
1105 DBG("op_priv_id:%d", priv_id);
1106 DBG("noti:%p", noti_from_master);
1108 if (op_type != NOTIFICATION_OP_INSERT &&
1109 op_type != NOTIFICATION_OP_UPDATE) {
1112 if (noti_from_master == NULL) {
1113 ERR("failed to get a notification from master");
1116 if (notification_clone(noti_from_master, ¬i) != NOTIFICATION_ERROR_NONE) {
1117 ERR("failed to create a cloned notification");
1120 #ifdef QP_EMERGENCY_MODE_ENABLE
1121 if (quickpanel_emergency_mode_is_on()) {
1122 if (quickpanel_emergency_mode_notification_filter(noti, 1)) {
1123 DBG("notification filtered");
1124 notification_free(noti);
1131 retif(noti == NULL, ,"noti is NULL");
1133 if (op_type == NOTIFICATION_OP_INSERT || op_type == NOTIFICATION_OP_UPDATE) {
1134 if (_is_blocking_mode_on() == 0) {
1135 if (_is_sound_playable() == 1) {
1136 if (_quickpanel_ticker_check_sound_off(noti) == 0) {
1137 DBG("try to play notification sound");
1138 _quickpanel_noti_media_feedback_sound(noti);
1140 if (quickpanel_is_vib_enabled() == 1
1141 || quickpanel_is_sound_enabled() == 1) {
1142 _quickpanel_noti_media_feedback_vibration(noti);
1148 notification_get_display_applist(noti, &applist);
1149 if (!(applist & NOTIFICATION_DISPLAY_APP_TICKER)) {
1150 DBG("displaying ticker option is off");
1151 notification_free(noti);
1155 /* Check setting's event notification */
1156 ret = _quickpanel_ticker_check_ticker_off(noti);
1158 DBG("Disabled tickernoti ret : %d", ret);
1159 /* delete temporary here only ticker noti display item */
1160 __ticker_only_noti_del(noti);
1161 notification_free(noti);
1166 /* Skip if previous ticker is still shown */
1168 if (g_ticker != NULL) {
1169 DBG("delete ticker noti");
1170 _quickpanel_ticker_del(NULL);
1175 /* Check tickernoti flag */
1176 notification_get_property(noti, &flags);
1178 if (flags & NOTIFICATION_PROP_DISABLE_TICKERNOTI) {
1179 DBG("NOTIFICATION_PROP_DISABLE_TICKERNOTI");
1180 __ticker_only_noti_del(noti);
1181 notification_free(noti);
1182 } else if (applist & NOTIFICATION_DISPLAY_APP_TICKER) {
1183 if (_is_security_lockscreen_launched()) {
1184 ERR("lockscreen or sview launched, creating a ticker canceled");
1185 notification_free(noti);
1189 if (quickpanel_is_opened()) {
1190 ERR("quickpanel is opened, tickernoit will be not displayed");
1191 notification_free(noti);
1195 ticker_list = eina_list_append(ticker_list, noti);
1196 /* wait if g_ticker is not NULL */
1197 if (g_ticker == NULL) {
1198 _quickpanel_ticker_create_tickernoti(noti);
1200 if (g_ticker == NULL) {
1201 ERR("Fail to create tickernoti");
1202 __ticker_only_noti_del(noti);
1203 notification_free(noti);
1209 /*****************************************************************************
1213 *****************************************************************************/
1214 static Eina_Bool _tickernoti_callback_register_idler_cb(void *data)
1216 struct appdata *ad = data;
1217 retif(ad == NULL, EINA_FALSE, "Invalid parameter!");
1219 notification_register_detailed_changed_cb(_quickpanel_ticker_noti_detailed_changed_cb, ad);
1224 static int quickpanel_ticker_init(void *data)
1226 struct appdata *ad = (struct appdata *)data;
1230 /* Register notification changed cb */
1231 ecore_idler_add(_tickernoti_callback_register_idler_cb, ad);
1236 static int quickpanel_ticker_fini(void *data)
1239 ecore_timer_del(g_timer);
1246 static int quickpanel_ticker_enter_hib(void *data)
1251 static int quickpanel_ticker_leave_hib(void *data)
1256 static void quickpanel_ticker_reflesh(void *data)
1258 retif(data == NULL, , "Invalid parameter!");
1260 if (g_ticker != NULL) {
1261 _quickpanel_ticker_win_rotated(data, 1);