Allow sending minicontrol icons via notifications. 73/81473/3
authorRadoslaw Czerski <r.czerski@samsung.com>
Wed, 10 Aug 2016 14:49:31 +0000 (16:49 +0200)
committerRadoslaw Czerski <r.czerski@samsung.com>
Wed, 10 Aug 2016 14:49:31 +0000 (16:49 +0200)
Change-Id: I8188646e21f4baf4ca0659eac153e606dc87ee31
Signed-off-by: Radoslaw Czerski <r.czerski@samsung.com>
inc/util.h
src/modules/information/noti.c
src/util.c

index aa3a134b96d3fefdf012e258f0863e26608d7a0f..0efab0868a4159448abcf18eeb98092c41973571 100644 (file)
@@ -279,6 +279,16 @@ extern void util_file_monitor_remove(Ecore_File_Monitor *file_monitor);
  */
 extern char *util_safe_str(const char *str, const char *str_search);
 
+/**
+ * @brief Checks if @a str starts with @a prefix
+ *
+ * @param[in] prefix prefix candidate
+ * @param[in] str string to examine
+ *
+ * @return true if @a prefix is a prefix of @a str, false otherwise
+ */
+bool util_string_prefix_check(const char *prefix, const char *str);
+
 #ifdef _SUPPORT_SCREEN_READER
 extern Evas_Object *util_access_object_register(Evas_Object *object, Evas_Object *layout);
 extern void util_access_object_unregister(Evas_Object *object);
index 1130218b3ffe660ac0359fafd86654297d8e1e36..a69ce50b4ac58f78a2138c097ace50b8306c5ee8 100644 (file)
@@ -55,6 +55,21 @@ icon_s noti = {
        .fini = unregister_noti_module
 };
 
+typedef struct {
+       char *name;
+       int priority;
+} minictrl_prop;
+
+static minictrl_prop noti_minictrl_app_list[] = {
+               {"call", 1},
+               {"call_mute", 2},
+               {"call_speaker", 3},
+               {"music", 4},
+               {"video", 5},
+               {"voice_recorder", 6},
+               /* {"3rd_party", 7} TODO This will be handled later*/
+};
+
 struct noti_status {
        notification_h noti;
        icon_s *icon;
@@ -186,6 +201,40 @@ static void show_image_icon_all(void)
 }
 
 
+static int noti_icon_priority_get(const char *tag)
+{
+       int i;
+       int minictrl_len = strlen("minicontrol_");
+       for (i = 0; i < ARRAY_SIZE(noti_minictrl_app_list); i++){
+               if (!strcmp(tag + minictrl_len, noti_minictrl_app_list[i].name)) {
+                       _D("Sufix is is:%s", noti_minictrl_app_list[i].name);
+                       return noti_minictrl_app_list[i].priority;
+               }
+       }
+       return 0;
+}
+
+
+static void _noti_minicontrol_set(struct noti_status *noti_data)
+{
+       const char *tag = NULL;
+       int ret;
+
+       ret = notification_get_tag(noti_data->noti, &tag);
+       retm_if(ret != NOTIFICATION_ERROR_NONE,
+                       "notification_get_tag failed[%d]:%s", ret, get_error_message(ret));
+
+       if (util_string_prefix_check("minicontrol", tag)){
+               int p = noti_icon_priority_get(tag);
+               if(p) {
+                       _D("The icon is for minicontrol area.");
+                       noti_data->icon->priority = p;
+                       noti_data->icon->area = INDICATOR_ICON_AREA_MINICTRL;
+               }
+       }
+}
+
+
 static void _icon_add(struct noti_status *noti_data, const char *name, void *data)
 {
        retm_if(noti_data == NULL || data == NULL, "Invalid parameter!");
@@ -204,6 +253,8 @@ static void _icon_add(struct noti_status *noti_data, const char *name, void *dat
                obj->exist_in_view = EINA_FALSE;
 
                noti_data->icon = obj;
+
+               _noti_minicontrol_set(noti_data);
        }
 
        return;
@@ -310,11 +361,12 @@ static void _insert_noti_by_privid(notification_h noti, void *data)
 
        if (!_is_exist_by_privid(prev_id_str)) {
                status = calloc(1, sizeof(struct noti_status));
-               _icon_add(status, prev_id_str, data);
 
                ret = notification_clone(noti, &status->noti);
-               retm_if(ret != NOTIFICATION_ERROR_NONE, "notification_clone failed[%d]:%s", ret , get_error_message(ret));
+               retm_if(ret != NOTIFICATION_ERROR_NONE,
+                               "notification_clone failed[%d]:%s", ret , get_error_message(ret));
 
+               _icon_add(status, prev_id_str, data);
                insert_icon_list(status);
                status_list = eina_list_append(status_list, status);
                show_image_icon(status);
@@ -350,10 +402,9 @@ static void _update_noti_by_privid(notification_h noti)
        ret = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, &indicator_path);
        retm_if(ret != NOTIFICATION_ERROR_NONE, "notification_get_image failed[%d]:%s", ret , get_error_message(ret));
 
-       if (!indicator_path) {
+       if (!indicator_path)
                _E("The icon path is NULL");
                return;
-       }
 
        if (ecore_file_exists(indicator_path) ||
                        util_check_noti_ani(indicator_path) ||
@@ -377,11 +428,11 @@ static void _update_noti_by_privid(notification_h noti)
                }
        } else
                _E("The path is invalid:%s", icon_path);
-
        if (icon_path) {
                free(icon_path);
                icon_path = NULL;
        }
+
        return;
 }
 
index 446c802cdaff9cd66b5b0356640d2942fc08a227..b8c403590c11b7965151ba4af4d46f775c6f35bc 100644 (file)
@@ -637,6 +637,16 @@ char *util_safe_str(const char *str, const char *str_search)
 
 
 
+bool util_string_prefix_check(const char *prefix, const char *str)
+{
+    size_t lenpre = strlen(prefix);
+    size_t lenstr = strlen(str);
+
+    return lenstr < lenpre ? false : !strncmp(prefix, str, lenpre);
+}
+
+
+
 int util_dynamic_state_get(void)
 {
        int val = 0;