From bdecd73ce2c99b80f4b75268dbf932564dcfd8f7 Mon Sep 17 00:00:00 2001 From: Kamil Lipiszko Date: Tue, 10 May 2016 13:26:15 +0200 Subject: [PATCH] util: Use reserved paths to icons Indicator should not use absolute paths from other apps. If indicator changes its icons directory, paths from other app will not match anymore. This patch is checking if received path is reserved, if it is replaces reserved path with real path to icon. Related msg-manager change: https://review.tizen.org/gerrit/#/c/68618/1 Change-Id: I3c6e8cac266325c84e0bbea26c4c4e8739dad1bb --- inc/util.h | 1 + src/modules/information/noti.c | 46 +++++++++++++++++------------ src/util.c | 54 ++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 19 deletions(-) diff --git a/inc/util.h b/inc/util.h index 0c7c810..072c71b 100644 --- a/inc/util.h +++ b/inc/util.h @@ -57,6 +57,7 @@ extern char* util_get_timezone_str(void); extern Eina_Bool util_win_prop_angle_get(Ecore_X_Window win, int *curr); extern int util_is_orf(void); extern int util_check_noti_ani(const char* path); +extern char *util_get_real_path(char *special_path); extern void util_start_noti_ani(void* data); extern void util_stop_noti_ani(void* data); extern void util_send_status_message_start(void* data,double duration); diff --git a/src/modules/information/noti.c b/src/modules/information/noti.c index 2bd1e8c..86fad0c 100644 --- a/src/modules/information/noti.c +++ b/src/modules/information/noti.c @@ -165,26 +165,34 @@ static void show_image_icon(struct noti_status *data) notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, &icon_path); if (icon_path == NULL || !ecore_file_exists(icon_path)) { - if (icon_path != NULL && util_check_noti_ani(icon_path)) { + + if (util_check_noti_ani(icon_path)) show_icon_with_path(data, icon_path); - } else { - notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, &icon_path); - - if (icon_path == NULL || !ecore_file_exists(icon_path)) { - char *pkgname = NULL; - char *icon_path_second = NULL; - notification_get_pkgname(noti, &pkgname); - icon_path_second = __indicator_ui_get_pkginfo_icon(pkgname); - - if (icon_path_second == NULL || !ecore_file_exists(icon_path_second)) - data->icon->img_obj.data = NULL; - else - show_icon_with_path(data, icon_path_second); - - if (icon_path_second != NULL) - free(icon_path_second); - } else - show_icon_with_path(data, icon_path); + else { + char *real_path = util_get_real_path(icon_path); + + if (real_path) { + show_icon_with_path(data, real_path); + free(real_path); + } else { + notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, &icon_path); + + if (icon_path == NULL || !ecore_file_exists(icon_path)) { + char *pkgname = NULL; + char *icon_path_second = NULL; + notification_get_pkgname(noti, &pkgname); + icon_path_second = __indicator_ui_get_pkginfo_icon(pkgname); + + if (icon_path_second == NULL || !ecore_file_exists(icon_path_second)) + data->icon->img_obj.data = NULL; + else + show_icon_with_path(data, icon_path_second); + + if (icon_path_second != NULL) + free(icon_path_second); + } else + show_icon_with_path(data, icon_path); + } } } else show_icon_with_path(data, icon_path); diff --git a/src/util.c b/src/util.c index 220fb4a..c1f4890 100644 --- a/src/util.c +++ b/src/util.c @@ -40,6 +40,16 @@ #define DIR_PREFIX "Theme_%02d_" #define LABEL_STRING "%s" +#define MSG_RESERVED "reserved://indicator/" + +#define MSG_NORMAL_STATUS_ICON MSG_RESERVED"icons/notify_message" +#define MSG_FAILED_STATUS_ICON MSG_RESERVED"icons/notify_message_failed" +#define MSG_DELIVER_REPORT_STATUS_ICON MSG_RESERVED"icons/delivery_report_message" +#define MSG_READ_REPORT_STATUS_ICON MSG_RESERVED"icons/read_report_message" +#define MSG_VOICE_MSG_STATUS_ICON MSG_RESERVED"icons/notify_voicemail" +#define MSG_SIM_FULL_STATUS_ICON MSG_RESERVED"icons/sim_card_full" + + typedef struct { wifi_connection_state_changed_cb cb; void *data; @@ -62,11 +72,27 @@ typedef struct { void *data; } runtime_info_handler_t; +typedef struct { + char *path; + char *icon; +} reserved_t; + static Eina_List *wifi_callbacks; static Eina_List *wifi_device_callbacks; static Eina_List *ss_callbacks; static Eina_List *ri_callbacks; static int wifi_init_cnt = 0; + +const reserved_t reserved_paths[] = { + {MSG_NORMAL_STATUS_ICON, "/Notify/B03_notify_message.png"}, + {MSG_FAILED_STATUS_ICON, "/Notify/B03_notify_message_failed.png"}, + {MSG_DELIVER_REPORT_STATUS_ICON, "/Event/B03_event_delivery_report_message.png"}, + {MSG_READ_REPORT_STATUS_ICON, "/Event/B03_event_read_report_message.png"}, + {MSG_VOICE_MSG_STATUS_ICON, "/Event/B03_Event_voicemail.png"}, + {MSG_SIM_FULL_STATUS_ICON, "/SIM card full/B03_sim_card_full.png"} +}; + + char *util_set_label_text_color(const char *txt) { Eina_Strbuf *temp_buf = NULL; @@ -465,7 +491,35 @@ int util_check_noti_ani(const char* path) return 0; } +char *util_get_real_path(char *special_path) +{ + retv_if(!special_path, 0); + + char *real_path = NULL; + + int i; + for (i = 0; i < ARRAY_SIZE(reserved_paths); ++i) { + if(!strcmp(special_path, reserved_paths[i].path)) { + + real_path = calloc( + strlen(util_get_icon_dir()) + + strlen(reserved_paths[i].icon) + + 1, + sizeof(char)); + + if(!real_path) + return NULL; + + snprintf(real_path, + strlen(util_get_icon_dir()) + strlen(reserved_paths[i].icon) + 1, + "%s%s", util_get_icon_dir(), reserved_paths[i].icon); + return real_path; + } + } + + return NULL; +} void util_start_noti_ani(void* data) { -- 2.34.1