./include/notification_list.h
./include/notification_status.h
./include/notification_setting.h
+ ./include/notification_setting_internal.h
)
*/
int notification_free(notification_h noti);
-/**
- * @}
- */
-
-/**
- * @internal
- * @addtogroup NOTIFICATION_LIST
- * @{
- */
-
-/**
- * @internal
- * @brief Returns the notification list handle.
- * @details If count is equal to @c -1, all notifications are returned.
- * @since_tizen 2.3
- * @privlevel public
- * @privilege %http://tizen.org/privilege/notification
- * @param[in] type The notification type
- * @param[in] count The returned notification data number
- * @param[out] #NOTIFICATION_ERROR_NONE on success, other value on failure
- * @return #NOTIFICATION_ERROR_NONE on success,
- * otherwise any other value on failure
- * @retval #NOTIFICATION_ERROR_NONE Success
- * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
- * @see #notification_list_h
- * @par Sample code:
- * @code
-#include <notification.h>
-...
-{
- notification_list_h noti_list = NULL;
- int noti_err = NOTIFICATION_ERROR_NONE;
-
- noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
- if(noti_err != NOTIFICATION_ERROR_NONE) {
- return;
- }
-}
- * @endcode
- */
-int notification_get_list(notification_type_e type,
- int count,
- notification_list_h * list);
-
-/**
- * @internal
- * @brief Returns the notification detail list handle of grouping data.
- * @details If count is equal to c -1, all notifications are returned.
- * @since_tizen 2.3
- * @privlevel public
- * @privilege %http://tizen.org/privilege/notification
- * @param[in] pkgname The caller application package name
- * @param[in] group_id The group ID
- * @param[in] priv_id The private ID
- * @param[in] count The returned notification data number
- * @param[out] list The notification list handle
- * @return #NOTIFICATION_ERROR_NONE if success,
- * other value if failure
- * @retval #NOTIFICATION_ERROR_NONE Success
- * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
- * @see #notification_list_h
- * @par Sample code:
- * @code
-#include <notification.h>
-...
-{
- notification_list_h noti_list = NULL;
- int noti_err = NOTIFICATION_ERROR_NONE;
-
- noti_err = notification_get_detail_list(pkgname, group_id, priv_id, -1, ¬i_list);
- if(noti_err != NOTIFICATION_ERROR_NONE) {
- return;
- }
-}
- * @endcode
- */
-int notification_get_detail_list(const char *pkgname,
- int group_id,
- int priv_id,
- int count,
- notification_list_h *list);
-
-/**
- * @internal
- * @brief Frees a notification list.
- * @since_tizen 2.3
- * @privlevel public
- * @privilege %http://tizen.org/privilege/notification
- * @param[in] list The notification list handle
- * @return #NOTIFICATION_ERROR_NONE on success,
- * otherwise any other value on failure
- * @retval #NOTIFICATION_ERROR_NONE Success
- * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
- * @pre notification_get_grouping_list() or notification_get_detail_list().
- * @see #notification_list_h
- * @par Sample code:
- * @code
-#include <notification.h>
-...
-{
- notification_list_h noti_list = NULL;
- int noti_err = NOTIFICATION_ERROR_NONE;
-
- ...
-
- noti_err = notification_free_list(noti_list);
- if(noti_err != NOTIFICATION_ERROR_NONE) {
- return;
- }
-}
- * @endcode
- */
-int notification_free_list(notification_list_h list);
-
/**
* @}
*/
#include <notification.h>
#include <notification_setting.h>
+#include <notification_setting_internal.h>
#define NOTIFICATION_ADDR "/tmp/.notification.service"
#define NOTIFICATION_DEL_PACKET_UNIT 10
int notification_ipc_del_deffered_task(void (*deferred_task_cb)(void *data));
int notification_ipc_update_setting(notification_setting_h setting);
+int notification_ipc_update_system_setting(notification_system_setting_h system_setting);
int notification_ipc_noti_setting_property_set(const char *pkgname, const char *property, const char *value);
int notification_ipc_noti_setting_property_get(const char *pkgname, const char *property, char **value);
*/
typedef struct _notification_list *notification_list_h;
+
+/**
+ * @brief Returns the notification list handle.
+ * @details If count is equal to @c -1, all notifications are returned.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/notification
+ * @param[in] type The notification type
+ * @param[in] count The returned notification data number
+ * @param[out] #NOTIFICATION_ERROR_NONE on success, other value on failure
+ * @return #NOTIFICATION_ERROR_NONE on success,
+ * otherwise any other value on failure
+ * @retval #NOTIFICATION_ERROR_NONE Success
+ * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
+ * @see #notification_list_h
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+ notification_list_h noti_list = NULL;
+ int noti_err = NOTIFICATION_ERROR_NONE;
+
+ noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
+ if(noti_err != NOTIFICATION_ERROR_NONE) {
+ return;
+ }
+}
+ * @endcode
+ */
+int notification_get_list(notification_type_e type,
+ int count,
+ notification_list_h * list);
+
+/**
+ * @brief Returns the notification detail list handle of grouping data.
+ * @details If count is equal to c -1, all notifications are returned.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/notification
+ * @param[in] pkgname The caller application package name
+ * @param[in] group_id The group ID
+ * @param[in] priv_id The private ID
+ * @param[in] count The returned notification data number
+ * @param[out] list The notification list handle
+ * @return #NOTIFICATION_ERROR_NONE if success,
+ * other value if failure
+ * @retval #NOTIFICATION_ERROR_NONE Success
+ * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
+ * @see #notification_list_h
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+ notification_list_h noti_list = NULL;
+ int noti_err = NOTIFICATION_ERROR_NONE;
+
+ noti_err = notification_get_detail_list(pkgname, group_id, priv_id, -1, ¬i_list);
+ if(noti_err != NOTIFICATION_ERROR_NONE) {
+ return;
+ }
+}
+ * @endcode
+ */
+int notification_get_detail_list(const char *pkgname,
+ int group_id,
+ int priv_id,
+ int count,
+ notification_list_h *list);
+
+/**
+ * @brief Frees a notification list.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/notification
+ * @param[in] list The notification list handle
+ * @return #NOTIFICATION_ERROR_NONE on success,
+ * otherwise any other value on failure
+ * @retval #NOTIFICATION_ERROR_NONE Success
+ * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
+ * @pre notification_get_grouping_list() or notification_get_detail_list().
+ * @see #notification_list_h
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+ notification_list_h noti_list = NULL;
+ int noti_err = NOTIFICATION_ERROR_NONE;
+
+ ...
+
+ noti_err = notification_free_list(noti_list);
+ if(noti_err != NOTIFICATION_ERROR_NONE) {
+ return;
+ }
+}
+ * @endcode
+ */
+int notification_free_list(notification_list_h list);
+
+
/**
- * @internal
* @brief Gets the head pointer of the notification list.
* @since_tizen 2.3
* @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
notification_list_h notification_list_get_head(notification_list_h list);
/**
- * @internal
- * @brief Gets the tail pointer to the notification list.
+ * @brief Gets the tail pointer to the notification list.
* @since_tizen 2.3
* @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
* @param[in] list Notification list handle
notification_list_h notification_list_get_tail(notification_list_h list);
/**
- * @internal
* @brief Gets the previous pointer of the current notification list.
* @since_tizen 2.3
* @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
notification_list_h notification_list_get_prev(notification_list_h list);
/**
- * @internal
* @brief Gets the next pointer of the current notification list.
* @since_tizen 2.3
* @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
notification_list_h notification_list_get_next(notification_list_h list);
/**
- * @internal
* @brief Gets the notification handle that the list has.
* @since_tizen 2.3
* @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
notification_h notification_list_get_data(notification_list_h list);
/**
- * @internal
* @brief Appends notification data to the notification list.
* @since_tizen 2.3
* @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
notification_h noti);
/**
- * @internal
* @brief Removes notification data from the notification list.
* @since_tizen 2.3
* @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
#define EXPORT_API __attribute__ ((visibility("default")))
#endif
+#define SAFE_STRDUP(s) \
+ ({\
+ char* _s = (char*)s;\
+ (_s)? strdup(_s) : NULL;\
+})
+
+#define SAFE_FREE(s) \
+ ({\
+ if (s) {\
+ free(s);\
+ s = NULL;\
+ }\
+})
+
+#define NOTIFICATION_SETTING_DB_TABLE "notification_setting"
+#define NOTIFICATION_SYSTEM_SETTING_DB_TABLE "notification_system_setting"
+
struct _notification {
notification_type_e type;
notification_ly_type_e layout;
char *tag;
};
+struct notification_system_setting {
+ bool do_not_disturb;
+ int visibility_class;
+};
+
void notification_call_changed_cb(notification_op *op_list, int op_num);
char *notification_get_pkgname_by_pid(void);
-/*\r
- * libnotification\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#ifndef INCLUDE_NOTIFICATION_SETTING_INTERNAL_H_\r
-#define INCLUDE_NOTIFICATION_SETTING_INTERNAL_H_\r
-\r
-#include <stdbool.h>\r
-#include "notification.h"\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-struct notification_setting {\r
- char *package_name;\r
- bool allow_to_notify;\r
- bool do_not_disturb_except;\r
- int visibility_class;\r
-};\r
-\r
-int notification_setting_get_setting_array(notification_setting_h *setting_array, int *count);\r
-int notification_setting_get_setting_by_package_name(const char *package_name, notification_setting_h *setting);\r
-\r
-int notification_setting_get_package_name(notification_setting_h setting, char **value);\r
-int notification_setting_set_package_name(notification_setting_h setting, char *value);\r
-\r
-int notification_setting_get_allow_to_notify(notification_setting_h setting, bool *value);\r
-int notification_setting_set_allow_to_notify(notification_setting_h setting, bool value);\r
-\r
-int notification_setting_get_do_not_disturb_except(notification_setting_h setting, bool *value);\r
-int notification_setting_set_do_not_disturb_except(notification_setting_h setting, bool value);\r
-\r
-\r
-/* OLD IMPLEMENTATION */\r
-int notification_setting_property_set(const char *pkgname, const char *property, const char *value) NOTIFICATION_DEPRECATED_API;\r
-int notification_setting_property_get(const char *pkgname, const char *property, char **value) NOTIFICATION_DEPRECATED_API;\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif /* INCLUDE_NOTIFICATION_SETTING_INTERNAL_H_ */\r
+/*
+ * libnotification
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Kyho Jo <kyuho.jo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NOTIFICATION_SETTING_INTERNAL_H__
+#define __NOTIFICATION_SETTING_INTERNAL_H__
+
+#include <stdbool.h>
+#include "notification.h"
+#include "notification_setting.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Application setting */
+struct notification_setting {
+ char *package_name;
+ bool allow_to_notify;
+ bool do_not_disturb_except;
+ int visibility_class;
+};
+
+int notification_setting_get_setting_array(notification_setting_h *setting_array, int *count);
+int notification_setting_get_setting_by_package_name(const char *package_name, notification_setting_h *setting);
+
+int notification_setting_get_package_name(notification_setting_h setting, char **value);
+int notification_setting_set_package_name(notification_setting_h setting, char *value);
+
+int notification_setting_get_allow_to_notify(notification_setting_h setting, bool *value);
+int notification_setting_set_allow_to_notify(notification_setting_h setting, bool value);
+
+int notification_setting_get_do_not_disturb_except(notification_setting_h setting, bool *value);
+int notification_setting_set_do_not_disturb_except(notification_setting_h setting, bool value);
+
+/* System setting */
+typedef struct notification_system_setting* notification_system_setting_h;
+
+int notification_system_setting_load_system_setting(notification_system_setting_h *system_setting);
+int notification_system_setting_update_system_setting(notification_system_setting_h system_setting);
+int notification_system_setting_free_system_setting(notification_system_setting_h system_setting);
+
+int notification_system_setting_get_do_not_disturb(notification_system_setting_h system_setting, bool *value);
+int notification_system_setting_set_do_not_disturb(notification_system_setting_h system_setting, bool value);
+
+int notification_system_setting_get_visibility_class(notification_system_setting_h system_setting, int *value);
+int notification_system_setting_set_visibility_class(notification_system_setting_h system_setting, int value);
+
+/* OLD IMPLEMENTATION */
+int notification_setting_property_set(const char *pkgname, const char *property, const char *value) NOTIFICATION_DEPRECATED_API;
+int notification_setting_property_get(const char *pkgname, const char *property, char **value) NOTIFICATION_DEPRECATED_API;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __NOTIFICATION_SETTING_INTERNAL_H__ */
int notification_setting_db_get(const char *pkgname, const char *property, char **value);
int notification_setting_db_update(const char *package_name, int allow_to_notify, int do_not_disturb_except, int visibility_class);
+int notification_setting_db_update_system_setting(int do_not_disturb, int visibility_class);
#ifdef __cplusplus
}
#endif
/**
- * @internal
* @brief Sets the text domain to localize the notification.
* @since_tizen 2.3
* @param[in] noti The notification handle
const char *dir);
/**
- * @internal
* @brief Gets the text domain from the notification handle.
* @since_tizen 2.3
* @remarks Do not free returned domain and dir. They are freed when notification_free() or notification_free_list() is called.
Name: notification
Summary: notification library
-Version: 0.2.29
+Version: 0.2.30
Release: 1
Group: TBD
License: Apache
visibility_class INTEGER DEFAULT 0,
UNIQUE (priv_id, package_name)
);
+ CREATE TABLE IF NOT EXISTS notification_system_setting (
+ priv_id INTERGER PRIMARY KEY,
+ do_not_disturb INTEGER DEFAULT 0,
+ visibility_class INTEGER DEFAULT 0,
+ UNIQUE (priv_id, package_name)
+ );
INSERT INTO notification_setting (priv_id, package_name, allow_to_notify, do_not_disturb_except, visibility_class) VALUES (1, "org.tizen.photos", 1, 0, 0);
INSERT INTO notification_setting (priv_id, package_name, allow_to_notify, do_not_disturb_except, visibility_class) VALUES (2, "org.tizen.email", 1, 0, 0);
INSERT INTO notification_setting (priv_id, package_name, allow_to_notify, do_not_disturb_except, visibility_class) VALUES (3, "org.tizen.message", 1, 0, 0);
INSERT INTO notification_setting (priv_id, package_name, allow_to_notify, do_not_disturb_except, visibility_class) VALUES (4, "org.tizen.internet", 1, 0, 0);
INSERT INTO notification_setting (priv_id, package_name, allow_to_notify, do_not_disturb_except, visibility_class) VALUES (5, "org.tizen.games", 1, 0, 0);
+ INSERT INTO notification_system_setting (do_not_disturb, visibility_class) VALUES (0, 0, 0);
CREATE UNIQUE INDEX package_name_idx1 ON notification_setting (package_name);
'
%{_includedir}/notification/notification_list.h
%{_includedir}/notification/notification_status.h
%{_includedir}/notification/notification_setting.h
+%{_includedir}/notification/notification_setting_internal.h
%{_libdir}/pkgconfig/notification.pc
%files service-devel
struct packet *packet;
struct packet *result;
- packet = packet_create("update_noti_setting", "siii", setting->package_name, (int)setting->allow_to_notify, (int)setting->do_not_disturb_except, (int)setting->visibility_class);
+ packet = packet_create("update_noti_setting", "siii", setting->package_name, (int)(setting->allow_to_notify), (int)(setting->do_not_disturb_except), (int)(setting->visibility_class));
result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
packet,
NOTIFICATION_IPC_TIMEOUT);
return status;
}
+int notification_ipc_update_system_setting(notification_system_setting_h system_setting)
+{
+ int status = 0;
+ int ret = 0;
+ struct packet *packet = NULL;
+ struct packet *result = NULL;
+
+ packet = packet_create("update_noti_sys_setting", "ii", (int)(system_setting->do_not_disturb), (int)(system_setting->visibility_class));
+ if (packet == NULL) {
+ NOTIFICATION_ERR("packet_create failed.");
+ goto out;
+ }
+ result = com_core_packet_oneshot_send(NOTIFICATION_ADDR, packet, NOTIFICATION_IPC_TIMEOUT);
+ packet_destroy(packet);
+
+ if (result != NULL) {
+ if (packet_get(result, "ii", &status, &ret) != 2) {
+ NOTIFICATION_ERR("Failed to get a result packet");
+ status = NOTIFICATION_ERROR_IO_ERROR;
+ goto out;
+ }
+
+ } else {
+ NOTIFICATION_ERR("failed to receive answer(delete)");
+ if (notification_ipc_is_master_ready() == 1) {
+ status = NOTIFICATION_ERROR_PERMISSION_DENIED;
+ goto out;
+ }
+ else {
+ status = NOTIFICATION_ERROR_SERVICE_NOT_READY;
+ goto out;
+ }
+ }
+out:
+ if (result) {
+ packet_unref(result);
+ }
+
+ return status;
+}
+
int notification_ipc_noti_setting_property_set(const char *pkgname, const char *property, const char *value)
{
int status = 0;
#include <notification_setting.h>
#include <notification_setting_internal.h>
-#define SAFE_STRDUP(s) \
- ({\
- char* _s = (char*)s;\
- (_s)? strdup(_s) : NULL;\
-})
-
-#define SAFE_FREE(s) \
- ({\
- if (s) {\
- free(s);\
- s = NULL;\
- }\
-})
-
-#define NOTIFICATION_SETTING_DB_TABLE "notification_setting"
static int _get_table_field_data_int(char **table, int *buf, int index)
{
sql_return = sqlite3_get_table(local_db_handle, sql_query, &query_result, &row_count, &column_count, NULL);
if (sql_return != SQLITE_OK && sql_return != -1) {
- NOTIFICATION_ERR("NOTIFICATION_ERROR_FROM_DB failed [%d][%s]", sql_return, sql_query);
+ NOTIFICATION_ERR("sqlite3_get_table failed [%d][%s]", sql_return, sql_query);
err = NOTIFICATION_ERROR_FROM_DB;
goto out;
}
err = notification_ipc_update_setting(setting);
if (err != NOTIFICATION_ERROR_NONE) {
- NOTIFICATION_ERR("notification_ipc_noti_setting_property_set returns[%d]\n", err);
+ NOTIFICATION_ERR("notification_setting_update_setting returns[%d]\n", err);
goto out;
}
}
SAFE_FREE(setting->package_name);
+
+
/* add codes to free all properties */
+ SAFE_FREE(setting);
out:
return err;
return err;
}
+/* system setting --------------------------------*/
+
+EXPORT_API int notification_system_setting_load_system_setting(notification_system_setting_h *system_setting)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+ sqlite3 *local_db_handle = NULL;
+ char *sql_query = NULL;
+ char **query_result = NULL;
+ int sql_return;
+ int row_count = 0;
+ int column_count = 0;
+ int col_index = 0;
+ notification_system_setting_h result_system_setting= NULL;
+
+ if (system_setting == NULL) {
+ NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ sql_return = db_util_open(DBPATH, &local_db_handle, 0);
+
+ if (sql_return != SQLITE_OK || local_db_handle == NULL) {
+ NOTIFICATION_ERR("db_util_open failed [%d]", sql_return);
+ err = NOTIFICATION_ERROR_FROM_DB;
+ goto out;
+ }
+
+ sql_query = sqlite3_mprintf("SELECT do_not_disturb, visibility_class "
+ "FROM %s ", NOTIFICATION_SYSTEM_SETTING_DB_TABLE);
+
+ if (!sql_query) {
+ NOTIFICATION_ERR("fail to alloc query");
+ err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ sql_return = sqlite3_get_table(local_db_handle, sql_query, &query_result, &row_count, &column_count, NULL);
+
+ if (sql_return != SQLITE_OK && sql_return != -1) {
+ NOTIFICATION_ERR("sqlite3_get_table failed [%d][%s]", sql_return, sql_query);
+ err = NOTIFICATION_ERROR_FROM_DB;
+ goto out;
+ }
+
+ if (!row_count) {
+ NOTIFICATION_DBG ("No setting found...");
+ err= NOTIFICATION_ERROR_NOT_EXIST_ID;
+ goto out;
+ }
+
+ NOTIFICATION_DBG ("row_count [%d] column_count [%d]", row_count, column_count);
+
+ row_count = 1;
+
+ if (!(result_system_setting = (struct notification_system_setting*)malloc(sizeof(struct notification_system_setting)))) {
+ NOTIFICATION_ERR("malloc failed...");
+ err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ col_index = column_count;
+
+ _get_table_field_data_int(query_result, (int*)&(result_system_setting->do_not_disturb), col_index++);
+ _get_table_field_data_int(query_result, &(result_system_setting->visibility_class), col_index++);
+
+ *system_setting = result_system_setting;
+
+out:
+ if (query_result)
+ sqlite3_free_table(query_result);
+
+ if (sql_query)
+ sqlite3_free(sql_query);
+
+ if (local_db_handle) {
+ sql_return = db_util_close(local_db_handle);
+ if (sql_return != SQLITE_OK) {
+ NOTIFICATION_WARN("fail to db_util_close - [%d]", sql_return);
+ }
+ }
+
+ return err;
+}
+
+EXPORT_API int notification_system_setting_update_system_setting(notification_system_setting_h system_setting)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (system_setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ err = notification_ipc_update_system_setting(system_setting);
+ if (err != NOTIFICATION_ERROR_NONE) {
+ NOTIFICATION_ERR("notification_ipc_update_system_setting returns[%d]\n", err);
+ goto out;
+ }
+
+out:
+ return err;
+}
+
+EXPORT_API int notification_system_setting_free_system_setting(notification_system_setting_h system_setting)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (system_setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ /* add codes to free all properties */
+
+ SAFE_FREE(system_setting);
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_system_setting_get_do_not_disturb(notification_system_setting_h system_setting, bool *value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (system_setting == NULL || value == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ *value = system_setting->do_not_disturb;
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_system_setting_set_do_not_disturb(notification_system_setting_h system_setting, bool value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (system_setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ system_setting->do_not_disturb = value;
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_system_setting_get_visibility_class(notification_system_setting_h system_setting, int *value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (system_setting == NULL || value == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ *value = system_setting->visibility_class;
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_system_setting_set_visibility_class(notification_system_setting_h system_setting, int value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (system_setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ system_setting->visibility_class = value;
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_setting_db_update_system_setting(int do_not_disturb, int visibility_class)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+ sqlite3 *db = NULL;
+ char *sqlbuf = NULL;
+ int sqlret;
+
+ sqlret = db_util_open(DBPATH, &db, 0);
+ if (sqlret != SQLITE_OK || db == NULL) {
+ NOTIFICATION_ERR("db_util_open failed [%s][%d]", DBPATH, sqlret);
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
+
+ sqlbuf = sqlite3_mprintf("UPDATE %s SET do_not_disturb = %d, visibility_class = %d ",
+ NOTIFICATION_SYSTEM_SETTING_DB_TABLE, do_not_disturb, visibility_class);
+
+ if (!sqlbuf) {
+ NOTIFICATION_ERR("fail to alloc query");
+ err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ goto return_close_db;
+ }
+
+ err = notification_db_exec(db, sqlbuf, NULL);
+
+ return_close_db:
+ if (sqlbuf)
+ sqlite3_free(sqlbuf);
+
+ sqlret = db_util_close(db);
+ if (sqlret != SQLITE_OK) {
+ NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlret);
+ }
+
+ return err;
+}
-/* OLD IMPLEMENTATION */
+/* OLD IMPLEMENTATION ----------------------------*/
#define NOTIFICATION_SETTING_DB "notification_setting"
#define NOTIFICATION_SETTING_DB_PATH "/opt/usr/dbspace/.notification_parser.db"
testapp_print ("==========================================\n");
testapp_print (" 1. Get setting list\n");
testapp_print (" 2. Update setting\n");
+ testapp_print (" 3. Update system setting\n");
testapp_print ("------------------------------------------\n");
break;
default:
testapp_print("[%d] : package_name[%s], allow_to_notify[%d], do_not_disturb_except[%d], visibility_class[%d]\n"
,i, package_name, allow_to_notify, do_not_disturb_except, visibility_class);
free(package_name);
- notification_setting_free_notification(setting_array + i);
+ notification_setting_free_notification(setting_array );
}
if (setting_array)
notification_setting_set_allow_to_notify(setting, 0);
notification_setting_update_setting(setting);
}
+
+ return err;
+}
+
+static int testapp_test_update_system_setting()
+{
+ int err = NOTIFICATION_ERROR_NONE;
+ bool do_not_disturb;
+ int visibility_class;
+ notification_system_setting_h system_setting = NULL;
+
+
+ err = notification_system_setting_load_system_setting(&system_setting);
+
+ if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
+ testapp_print("notification_system_setting_load_system_setting failed [%d]\n", err);
+ goto out;
+ }
+
+ notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb);
+ testapp_print("do_not_disturb [%d]\n", do_not_disturb);
+ do_not_disturb = !do_not_disturb;
+ notification_system_setting_set_do_not_disturb(system_setting, do_not_disturb);
+
+ notification_system_setting_get_visibility_class(system_setting, &visibility_class);
+ testapp_print("visibility_class [%d]\n", visibility_class);
+ visibility_class = !visibility_class;
+ notification_system_setting_set_visibility_class(system_setting, visibility_class);
+
+ err = notification_system_setting_update_system_setting(system_setting);
+
+ if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
+ testapp_print("notification_system_setting_update_system_setting failed [%d]\n", err);
+ goto out;
+ }
+
+out:
+ if (system_setting)
+ notification_system_setting_free_system_setting(system_setting);
+
+ return err;
}
static gboolean testapp_interpret_command_setting_test (int selected_number)
testapp_test_update_setting();
break;
+ case 3:
+ testapp_test_update_system_setting();
+ break;
+
case 0:
go_to_loop = FALSE;
break;