Add API for app_enable/disable 10/182710/1
authorjusung son <jusung07.son@samsung.com>
Mon, 25 Jun 2018 11:16:43 +0000 (20:16 +0900)
committerjusung son <jusung07.son@samsung.com>
Wed, 27 Jun 2018 08:33:42 +0000 (08:33 +0000)
 - notification_setting_db_update_pkg_disabled

Change-Id: Ie1352f65cd4216661cafa8a81c78cbbeb6321f04
Signed-off-by: jusung son <jusung07.son@samsung.com>
(cherry picked from commit 37aaad297caa4aa3116a63a3149628ae7dbc1179)

include/notification_setting_service.h [changed mode: 0644->0755]
src/notification_setting_service.c

old mode 100644 (file)
new mode 100755 (executable)
index d948808..f5a1947
@@ -45,6 +45,8 @@ int notification_get_dnd_and_allow_to_notify(const char *app_id, int *do_not_dis
 int notification_system_setting_load_dnd_allow_exception(dnd_allow_exception_h *dnd_allow_exception, int *count, uid_t uid);
 int notification_system_setting_update_dnd_allow_exception(int type, int value, uid_t uid);
 int notification_setting_db_update_app_disabled(const char *app_id, bool value, uid_t uid);
+int notification_setting_db_update_pkg_disabled(const char *pkg_id, bool value, uid_t uid);
+
 #ifdef __cplusplus
 }
 #endif
index 644568691b43110f17f41b8c27ad4d9508283307..46a1730fccbea52cc850c45c0980da85b47eddda 100644 (file)
@@ -854,6 +854,7 @@ int notification_setting_db_update_app_disabled(const char *app_id, bool value,
        sqlite3 *db = NULL;
        char *query = NULL;
        int ret = NOTIFICATION_ERROR_NONE;
+       int num_changes = 0;
 
        if (app_id == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
@@ -862,7 +863,7 @@ int notification_setting_db_update_app_disabled(const char *app_id, bool value,
        if (!db)
                return get_last_result();
 
-       query = sqlite3_mprintf("UPDATE %s SET app_disabled= %d "
+       query = sqlite3_mprintf("UPDATE %s SET app_disabled= %d " \
                                "WHERE app_id = %Q AND uid = %d",
                                NOTIFICATION_SETTING_DB_TABLE, value,
                                app_id, uid);
@@ -872,7 +873,50 @@ int notification_setting_db_update_app_disabled(const char *app_id, bool value,
                goto out;
        }
 
-       ret = notification_db_exec(db, query, NULL);
+       ret = notification_db_exec(db, query, &num_changes);
+       if (ret == NOTIFICATION_ERROR_NONE && num_changes <= 0)
+               ret = NOTIFICATION_ERROR_NOT_EXIST_ID;
+
+out:
+       if (query)
+               sqlite3_free(query);
+
+       if (db)
+               notification_db_close(&db);
+
+       return ret;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+EXPORT_API
+int notification_setting_db_update_pkg_disabled(const char *pkg_id, bool value, uid_t uid)
+{
+       sqlite3 *db = NULL;
+       char *query = NULL;
+       int ret = NOTIFICATION_ERROR_NONE;
+       int num_changes = 0;
+
+       if (pkg_id == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       db = notification_db_open(DBPATH);
+       if (!db)
+               return get_last_result();
+
+       query = sqlite3_mprintf("UPDATE %s SET app_disabled= %d " \
+                               "WHERE package_name = %Q AND uid = %d",
+                               NOTIFICATION_SETTING_DB_TABLE, value,
+                               pkg_id, uid);
+       if (query == NULL) {
+               NOTIFICATION_ERR("Failed to alloc memory"); /* LCOV_EXCL_LINE */
+               ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+               goto out;
+       }
+
+       ret = notification_db_exec(db, query, &num_changes);
+       if (ret == NOTIFICATION_ERROR_NONE && num_changes <= 0)
+               ret = NOTIFICATION_ERROR_NOT_EXIST_ID;
 
 out:
        if (query)
@@ -884,3 +928,4 @@ out:
        return ret;
 }
 /* LCOV_EXCL_STOP */
+