Fix pkgname NULL bug & vibration type ignored bug 92/63292/1
authorHyunho Kang <hhstark.kang@samsung.com>
Wed, 23 Mar 2016 05:36:44 +0000 (14:36 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Wed, 23 Mar 2016 05:39:47 +0000 (14:39 +0900)
- When pkgname is NULL dbus pass invalid utf-8 instead of NULL
- Vibration type is ignored when vibration type is NONE

Change-Id: I52f81a87669d1e387cc752997a2fc976f9c00b4c
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/notification_ipc.c
src/notification_list.c
src/notification_noti.c

index 0453361..c2ce9ac 100755 (executable)
@@ -76,11 +76,13 @@ static void _print_noti(notification_h noti) {
        char *text = NULL;
        char *content = NULL;
        const char *tag = NULL;
+       notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
 
        notification_get_pkgname(noti, &pkgname);
        notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &text);
        notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
        notification_get_tag(noti, &tag);
+       notification_get_vibration(noti, &vib_type, NULL);
 
        NOTIFICATION_DBG("client print_noti  pkgname  = %s ", pkgname );
        NOTIFICATION_DBG("client print_noti  title  = %s ", text );
@@ -88,6 +90,7 @@ static void _print_noti(notification_h noti) {
        NOTIFICATION_DBG("client print_noti  tag  = %s ", tag );
        NOTIFICATION_DBG("client print_noti  priv_id  = %d ", noti->priv_id);
        NOTIFICATION_DBG("client print_noti  vibration_path  = %s ", noti->vibration_path);
+       NOTIFICATION_DBG("client print_noti  vibration_type  = %d ", vib_type);
 }
 
 static inline char *_string_get(char *string)
@@ -816,6 +819,9 @@ int notification_ipc_request_delete_multiple(notification_type_e type, char *pkg
                return result;
        }
 
+       if (!pkgname)
+               pkgname = "";
+
        body = g_variant_new("(si)", pkgname, type);
        result = _send_sync_noti(body, &reply, "del_noti_multiple");
 
@@ -845,6 +851,9 @@ int notification_ipc_request_load_noti_by_tag(notification_h noti, const char *p
                return result;
        }
 
+       if (!pkgname)
+               pkgname = "";
+
        body = g_variant_new("(ss)", pkgname, tag);
        result = _send_sync_noti(body, &reply, "load_noti_by_tag");
 
@@ -879,6 +888,9 @@ int notification_ipc_request_load_noti_by_priv_id(notification_h noti, const cha
                return result;
        }
 
+       if (!pkgname)
+               pkgname = "";
+
        body = g_variant_new("(si)", pkgname, priv_id);
        result = _send_sync_noti(body, &reply, "load_noti_by_priv_id");
 
@@ -913,6 +925,9 @@ int notification_ipc_request_get_count(notification_type_e type,
                return result;
        }
 
+       if (!pkgname)
+               pkgname = "";
+
        body = g_variant_new("(isii)", type, pkgname, group_id, priv_id);
        result = _send_sync_noti(body, &reply, "get_noti_count");
 
@@ -1351,8 +1366,7 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not
        if (noti->sound_path)
                g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_SOUND_PATH, g_variant_new_string((const gchar *)noti->sound_path));
 
-       if (noti->vibration_type != NOTIFICATION_VIBRATION_TYPE_NONE)
-               g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_VIBRATION_TYPE, g_variant_new_int32(noti->vibration_type));
+       g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_VIBRATION_TYPE, g_variant_new_int32(noti->vibration_type));
 
        if (noti->vibration_path)
                g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_VIBRATION_PATH, g_variant_new_string((const gchar *)noti->vibration_path));
index bd80f40..078dc29 100755 (executable)
@@ -254,7 +254,7 @@ EXPORT_API int notification_get_detail_list(const char *pkgname,
        notification_list_h get_list = NULL;
        int ret = 0;
 
-       if (list == NULL)
+       if (list == NULL || pkgname == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
        ret =
index 2130f05..75297e0 100755 (executable)
@@ -1009,7 +1009,7 @@ EXPORT_API int notification_noti_get_by_priv_id(notification_h noti, char *pkgna
                         "flags_for_property, display_applist, progress_size, progress_percentage, ongoing_flag, auto_remove "
                         "from noti_list ";
 
-       if (pkgname != NULL)
+       if (pkgname != NULL && strlen(pkgname) != 0)
                query = sqlite3_mprintf("%s where caller_pkgname = '%s' and priv_id = %d",
                                base_query, pkgname, priv_id);
        else
@@ -1067,7 +1067,7 @@ EXPORT_API int notification_noti_get_by_tag(notification_h noti, char *pkgname,
        if (!db)
                return get_last_result();
 
-       if (pkgname != NULL) {
+       if (pkgname != NULL && strlen(pkgname) != 0) {
                ret = sqlite3_prepare_v2(db, "select "
                         "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, "
                         "tag, b_text, b_key, b_format_args, num_format_args, "
@@ -1590,7 +1590,7 @@ EXPORT_API int notification_noti_get_count(notification_type_e type,
        snprintf(query_base, sizeof(query_base),
                 "select count(*) from noti_list ");
 
-       if (pkgname != NULL) {
+       if (pkgname != NULL && strlen(pkgname) != 0) {
                if (group_id == NOTIFICATION_GROUP_ID_NONE) {
                        if (priv_id == NOTIFICATION_PRIV_ID_NONE) {
                                snprintf(query_where, sizeof(query_where),