util: Use reserved paths to icons 31/68931/4 submit/tizen/20160510.143641
authorKamil Lipiszko <k.lipiszko@samsung.com>
Tue, 10 May 2016 11:26:15 +0000 (13:26 +0200)
committerKamil Lipiszko <k.lipiszko@samsung.com>
Tue, 10 May 2016 12:46:48 +0000 (14:46 +0200)
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
src/modules/information/noti.c
src/util.c

index 0c7c810822261f66982e87d3437c8b4dd890f8c9..072c71b5f19e395f7025e02e96db496f5b3bcbe6 100644 (file)
@@ -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);
index 2bd1e8cdefa29f47ba70a9c94dd8f3a632739761..86fad0ceb9706e170afa8a66cafbe11c2532663e 100644 (file)
@@ -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);
index 220fb4a3367a3d759924a581d542800cbde9145f..c1f48906b57406eaec30401591a7649b107afc08 100644 (file)
 #define DIR_PREFIX     "Theme_%02d_"
 #define LABEL_STRING   "<color=#%02x%02x%02x%02x>%s</color>"
 
+#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)
 {