1. Move internal API set for notification_list to notification_list.h
authorKyuho Jo <kyuho.jo@samsung.com>
Wed, 6 May 2015 06:49:09 +0000 (15:49 +0900)
committerKyuho Jo <kyuho.jo@samsung.com>
Thu, 7 May 2015 02:12:00 +0000 (11:12 +0900)
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>
19 files changed:
CMakeLists.txt
include/notification.h [changed mode: 0755->0644]
include/notification_debug.h [changed mode: 0755->0644]
include/notification_internal.h [changed mode: 0755->0644]
include/notification_ipc.h [changed mode: 0755->0644]
include/notification_list.h
include/notification_private.h [changed mode: 0755->0644]
include/notification_setting.h [changed mode: 0755->0644]
include/notification_setting_internal.h [changed mode: 0755->0644]
include/notification_setting_service.h [changed mode: 0755->0644]
include/notification_text_domain.h [changed mode: 0755->0644]
include/notification_type.h [changed mode: 0755->0644]
packaging/notification.spec [changed mode: 0755->0644]
src/notification.c [changed mode: 0755->0644]
src/notification_ipc.c [changed mode: 0755->0644]
src/notification_noti.c [changed mode: 0755->0644]
src/notification_setting.c [changed mode: 0755->0644]
src/notification_status.c [changed mode: 0755->0644]
test-app/main.c

index 4c28f8ec1e4d6974bdf0b15b7c316e91a74e4daa..9569af95944df9d717f2e060a22a3a3219ae5a16 100644 (file)
@@ -33,6 +33,7 @@ SET(HEADERS-DEVEL
        ./include/notification_list.h
        ./include/notification_status.h
        ./include/notification_setting.h
+       ./include/notification_setting_internal.h
    )
 
 
old mode 100755 (executable)
new mode 100644 (file)
index 92ee0db..02a4fb0
@@ -1230,123 +1230,6 @@ int notification_clone(notification_h noti, notification_h *clone);
  */
 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);
-
 /**
  * @}
  */
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 204d135..26e0650
@@ -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);
 
index 2985af881187d9b85a5698e67330a2ffbaa8752c..8584968796ba234e37a7e22ef62760a730f427d0 100644 (file)
@@ -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.
old mode 100755 (executable)
new mode 100644 (file)
index 21b5e8c..f5ddf9c
 #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);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index bee4d1d..5a14225
@@ -1,59 +1,73 @@
-/*\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__ */
old mode 100755 (executable)
new mode 100644 (file)
index a27af00..f8b0fd4
@@ -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
 }
old mode 100755 (executable)
new mode 100644 (file)
index 4ae429e..f41a42e
@@ -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.
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 43e44da..db9eb43
@@ -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
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 741af31..5c51b23
@@ -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;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 436a991..a98d1fb
 #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"
 
old mode 100755 (executable)
new mode 100644 (file)
index 073ee0ec23f572c1f0ff774309820d133e0778bc..0ebe37171adec5604b45e2f06233df4602e301c7 100755 (executable)
@@ -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;