summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyuho Jo <kyuho.jo@samsung.com>2015-05-06 15:49:09 +0900
committerKyuho Jo <kyuho.jo@samsung.com>2015-05-07 11:12:00 +0900
commita8fff04a1c3373dafe4cd0ab3f709cd842f20a6a (patch)
treedf73e6ee780008766efb8f740bcd972f63d42c70
parent6064205f3031e16007a3b7025b0d397b85c742a5 (diff)
downloadnotification-a8fff04a1c3373dafe4cd0ab3f709cd842f20a6a.tar.gz
notification-a8fff04a1c3373dafe4cd0ab3f709cd842f20a6a.tar.bz2
notification-a8fff04a1c3373dafe4cd0ab3f709cd842f20a6a.zip
1. Move internal API set for notification_list to notification_list.h
2. New API set for notification system setting 3. Correct abnormal file access permsssions Change-Id: I9a00c7bedadcd2e350875246197f22c7488cdd13 Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
-rw-r--r--CMakeLists.txt1
-rw-r--r--[-rwxr-xr-x]include/notification.h117
-rw-r--r--[-rwxr-xr-x]include/notification_debug.h0
-rw-r--r--[-rwxr-xr-x]include/notification_internal.h0
-rw-r--r--[-rwxr-xr-x]include/notification_ipc.h2
-rw-r--r--include/notification_list.h115
-rw-r--r--[-rwxr-xr-x]include/notification_private.h22
-rw-r--r--[-rwxr-xr-x]include/notification_setting.h0
-rw-r--r--[-rwxr-xr-x]include/notification_setting_internal.h132
-rw-r--r--[-rwxr-xr-x]include/notification_setting_service.h1
-rw-r--r--[-rwxr-xr-x]include/notification_text_domain.h2
-rw-r--r--[-rwxr-xr-x]include/notification_type.h0
-rw-r--r--[-rwxr-xr-x]packaging/notification.spec10
-rw-r--r--[-rwxr-xr-x]src/notification.c0
-rw-r--r--[-rwxr-xr-x]src/notification_ipc.c43
-rw-r--r--[-rwxr-xr-x]src/notification_noti.c0
-rw-r--r--[-rwxr-xr-x]src/notification_setting.c251
-rw-r--r--[-rwxr-xr-x]src/notification_status.c0
-rwxr-xr-xtest-app/main.c48
19 files changed, 537 insertions, 207 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c28f8e..9569af9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,7 @@ SET(HEADERS-DEVEL
./include/notification_list.h
./include/notification_status.h
./include/notification_setting.h
+ ./include/notification_setting_internal.h
)
diff --git a/include/notification.h b/include/notification.h
index 92ee0db..02a4fb0 100755..100644
--- a/include/notification.h
+++ b/include/notification.h
@@ -1235,123 +1235,6 @@ 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, &noti_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, &noti_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);
-
-/**
- * @}
- */
-
-/**
* @addtogroup NOTIFICATION_MODULE
* @{
*/
diff --git a/include/notification_debug.h b/include/notification_debug.h
index e507471..e507471 100755..100644
--- a/include/notification_debug.h
+++ b/include/notification_debug.h
diff --git a/include/notification_internal.h b/include/notification_internal.h
index 0de1b98..0de1b98 100755..100644
--- a/include/notification_internal.h
+++ b/include/notification_internal.h
diff --git a/include/notification_ipc.h b/include/notification_ipc.h
index 204d135..26e0650 100755..100644
--- a/include/notification_ipc.h
+++ b/include/notification_ipc.h
@@ -24,6 +24,7 @@
#include <notification.h>
#include <notification_setting.h>
+#include <notification_setting_internal.h>
#define NOTIFICATION_ADDR "/tmp/.notification.service"
#define NOTIFICATION_DEL_PACKET_UNIT 10
@@ -55,6 +56,7 @@ int notification_ipc_add_deffered_task(void (*deferred_task_cb)(void *data), voi
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);
diff --git a/include/notification_list.h b/include/notification_list.h
index 2985af8..8584968 100644
--- a/include/notification_list.h
+++ b/include/notification_list.h
@@ -45,8 +45,113 @@ extern "C" {
*/
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, &noti_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, &noti_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.
@@ -77,8 +182,7 @@ typedef struct _notification_list *notification_list_h;
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
@@ -108,7 +212,6 @@ notification_list_h notification_list_get_head(notification_list_h list);
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.
@@ -139,7 +242,6 @@ notification_list_h notification_list_get_tail(notification_list_h list);
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.
@@ -170,7 +272,6 @@ notification_list_h notification_list_get_prev(notification_list_h list);
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.
@@ -203,7 +304,6 @@ notification_list_h notification_list_get_next(notification_list_h list);
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.
@@ -239,7 +339,6 @@ notification_list_h notification_list_append(notification_list_h list,
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.
diff --git a/include/notification_private.h b/include/notification_private.h
index 21b5e8c..f5ddf9c 100755..100644
--- a/include/notification_private.h
+++ b/include/notification_private.h
@@ -26,6 +26,23 @@
#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;
@@ -81,6 +98,11 @@ struct _notification {
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);
diff --git a/include/notification_setting.h b/include/notification_setting.h
index a06fef6..a06fef6 100755..100644
--- a/include/notification_setting.h
+++ b/include/notification_setting.h
diff --git a/include/notification_setting_internal.h b/include/notification_setting_internal.h
index bee4d1d..5a14225 100755..100644
--- a/include/notification_setting_internal.h
+++ b/include/notification_setting_internal.h
@@ -1,59 +1,73 @@
-/*
- * libnotification
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@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 INCLUDE_NOTIFICATION_SETTING_INTERNAL_H_
-#define INCLUDE_NOTIFICATION_SETTING_INTERNAL_H_
-
-#include <stdbool.h>
-#include "notification.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-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);
-
-
-/* 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 /* INCLUDE_NOTIFICATION_SETTING_INTERNAL_H_ */
+/*
+ * 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__ */
diff --git a/include/notification_setting_service.h b/include/notification_setting_service.h
index a27af00..f8b0fd4 100755..100644
--- a/include/notification_setting_service.h
+++ b/include/notification_setting_service.h
@@ -32,6 +32,7 @@ int notification_setting_db_set(const char *pkgname, const char *property, const
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
}
diff --git a/include/notification_text_domain.h b/include/notification_text_domain.h
index 4ae429e..f41a42e 100755..100644
--- a/include/notification_text_domain.h
+++ b/include/notification_text_domain.h
@@ -27,7 +27,6 @@ extern "C" {
#endif
/**
- * @internal
* @brief Sets the text domain to localize the notification.
* @since_tizen 2.3
* @param[in] noti The notification handle
@@ -63,7 +62,6 @@ int notification_set_text_domain(notification_h noti,
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.
diff --git a/include/notification_type.h b/include/notification_type.h
index 6e94002..6e94002 100755..100644
--- a/include/notification_type.h
+++ b/include/notification_type.h
diff --git a/packaging/notification.spec b/packaging/notification.spec
index 43e44da..db9eb43 100755..100644
--- a/packaging/notification.spec
+++ b/packaging/notification.spec
@@ -1,6 +1,6 @@
Name: notification
Summary: notification library
-Version: 0.2.29
+Version: 0.2.30
Release: 1
Group: TBD
License: Apache
@@ -179,12 +179,19 @@ then
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);
'
@@ -218,6 +225,7 @@ vconftool set -t string memory/private/libstatus/message "" -i -g 5000 -f $SMAC
%{_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
diff --git a/src/notification.c b/src/notification.c
index 3097938..3097938 100755..100644
--- a/src/notification.c
+++ b/src/notification.c
diff --git a/src/notification_ipc.c b/src/notification_ipc.c
index 741af31..5c51b23 100755..100644
--- a/src/notification_ipc.c
+++ b/src/notification_ipc.c
@@ -1461,7 +1461,7 @@ int notification_ipc_update_setting(notification_setting_h setting)
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);
@@ -1487,6 +1487,47 @@ int notification_ipc_update_setting(notification_setting_h setting)
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;
diff --git a/src/notification_noti.c b/src/notification_noti.c
index 075ea10..075ea10 100755..100644
--- a/src/notification_noti.c
+++ b/src/notification_noti.c
diff --git a/src/notification_setting.c b/src/notification_setting.c
index 436a991..a98d1fb 100755..100644
--- a/src/notification_setting.c
+++ b/src/notification_setting.c
@@ -33,21 +33,6 @@
#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)
{
@@ -228,7 +213,7 @@ EXPORT_API int notification_setting_get_setting_by_package_name(const char *pack
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;
}
@@ -445,7 +430,7 @@ EXPORT_API int notification_setting_update_setting(notification_setting_h settin
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;
}
@@ -464,8 +449,11 @@ EXPORT_API int notification_setting_free_notification(notification_setting_h set
}
SAFE_FREE(setting->package_name);
+
+
/* add codes to free all properties */
+ SAFE_FREE(setting);
out:
return err;
@@ -510,8 +498,235 @@ EXPORT_API int notification_setting_db_update(const char *package_name, int allo
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"
diff --git a/src/notification_status.c b/src/notification_status.c
index 919f018..919f018 100755..100644
--- a/src/notification_status.c
+++ b/src/notification_status.c
diff --git a/test-app/main.c b/test-app/main.c
index 073ee0e..0ebe371 100755
--- a/test-app/main.c
+++ b/test-app/main.c
@@ -158,6 +158,7 @@ void testapp_show_menu (testapp_menu_type_e menu)
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:
@@ -494,7 +495,7 @@ static int testapp_test_get_setting_list()
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)
@@ -517,6 +518,47 @@ static int testapp_test_update_setting()
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)
@@ -532,6 +574,10 @@ 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;