Implement function to support notification dnd changed callback 60/90760/4 accepted/tizen/3.0/ivi/20161011.055300 accepted/tizen/3.0/mobile/20161015.033859 accepted/tizen/3.0/tv/20161016.005123 accepted/tizen/3.0/wearable/20161015.083511 accepted/tizen/common/20161005.165600 accepted/tizen/ivi/20161006.075655 accepted/tizen/mobile/20161006.075609 accepted/tizen/tv/20161006.075628 accepted/tizen/wearable/20161006.075643 submit/tizen/20161005.072822 submit/tizen_3.0_ivi/20161010.000005 submit/tizen_3.0_mobile/20161015.000005 submit/tizen_3.0_tv/20161015.000004 submit/tizen_3.0_wearable/20161015.000004
authorseungha.son <seungha.son@samsung.com>
Tue, 4 Oct 2016 07:20:31 +0000 (16:20 +0900)
committerseungha.son <seungha.son@samsung.com>
Wed, 5 Oct 2016 09:06:35 +0000 (18:06 +0900)
Signed-off-by: seungha.son <seungha.son@samsung.com>
Change-Id: Ibdc5dc51f4418f16b58451af11e26e2804431fa9

include/notification_setting_internal.h
include/notification_setting_service.h
src/notification_setting_service.c

index f289ba3..9320bb7 100644 (file)
@@ -1268,7 +1268,8 @@ int notification_system_setting_set_dnd_allow_exceptions(notification_system_set
 
 /*
  * @internal
- * @brief Registers a callback for 'Do not disturb' mode setting schedule is start or end.
+ * @brief Registers a callback for turn on/off 'Do not disturb' mode by user_data
+ *        or 'Do not disturb' mode setting schedule is start or end.
  * @since_tizen 3.0
  * @privlevel public
  * @privilege %http://tizen.org/privilege/notification
@@ -1311,7 +1312,8 @@ int notification_register_system_setting_dnd_changed_cb_for_uid(dnd_changed_cb c
 
 /*
  * @internal
- * @brief Unregisters a callback for 'Do not disturb' mode setting schedule is start or end.
+ * @brief Unregisters a callback for turn on/off 'Do not disturb' mode by user_data
+ *        or 'Do not disturb' mode setting schedule is start or end.
  * @since_tizen 3.0
  * @privlevel public
  * @privilege %http://tizen.org/privilege/notification
index 592cff0..84a44f1 100644 (file)
@@ -39,6 +39,7 @@ int notification_setting_db_update_do_not_disturb(int do_not_disturb, uid_t uid)
 int noti_setting_service_get_setting_by_package_name(const char *package_name, notification_setting_h *setting, uid_t uid);
 int noti_setting_get_setting_array(notification_setting_h *setting_array, int *count, uid_t uid);
 int noti_system_setting_load_system_setting(notification_system_setting_h *system_setting, uid_t uid);
+int noti_system_setting_get_do_not_disturb(int *do_not_disturb, uid_t uid);
 int notification_system_setting_get_dnd_schedule_enabled_uid(uid_t **uids, int *count);
 int notification_get_dnd_and_allow_to_notify(const char *pkgname, int *do_not_disturb, int *do_not_disturb_except, int *allow_to_notify, uid_t uid);
 int notification_system_setting_load_dnd_allow_exception(dnd_allow_exception_h *dnd_allow_exception, int *count, uid_t uid);
index cdd5415..a4a3b50 100644 (file)
@@ -788,3 +788,54 @@ out:
 
        return ret;
 }
+
+EXPORT_API int noti_system_setting_get_do_not_disturb(int *do_not_disturb, uid_t uid)
+{
+       int ret = NOTIFICATION_ERROR_NONE;
+       int row_count = 0;
+       int col_count = 0;
+       int col_index = 0;
+       char *query = NULL;
+       char **query_result = NULL;
+       sqlite3 *db = NULL;
+
+       db = notification_db_open(DBPATH);
+       if (db == NULL)
+               return get_last_result();
+
+       query = sqlite3_mprintf("SELECT do_not_disturb FROM %s WHERE uid = %d",
+                               NOTIFICATION_SYSTEM_SETTING_DB_TABLE, uid);
+
+       if (query == NULL) {
+               NOTIFICATION_ERR("fail to alloc query");
+               ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+               goto out;
+       }
+
+       ret = sqlite3_get_table(db, query, &query_result, &row_count, &col_count, NULL);
+       if (ret != SQLITE_OK && ret != -1) {
+               NOTIFICATION_ERR("NOTIFICATION_ERROR_FROM_DB failed [%d][%s]", ret, query);
+               ret = NOTIFICATION_ERROR_FROM_DB;
+               goto out;
+       }
+
+       col_index = col_count;
+       if (row_count == 0) {
+               NOTIFICATION_ERR("No system setting found");
+               ret = NOTIFICATION_ERROR_INVALID_PARAMETER;
+       } else {
+               if (_get_table_field_data_int(query_result, (int *)do_not_disturb, col_index++) == false)
+                       ret = NOTIFICATION_ERROR_FROM_DB;
+       }
+
+out:
+       if (query_result)
+               sqlite3_free_table(query_result);
+       if (query)
+               sqlite3_free(query);
+       if (db)
+               notification_db_close(&db);
+
+       return ret;
+}
+