2. notification_set_event_handler/notification_get_event_handler are implemented.
Change-Id: I63ae26521a3bee757551b581316267fdf322ef86
Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
SET(MAJOR_VER 0)
SET(VERSION ${MAJOR_VER}.1.0)
-# ADD_SUBDIRECTORY(test-app)
+ADD_SUBDIRECTORY(test-app)
SET(SRCS
./src/notification.c
#define __NOTIFICATION_IPC_H__
#include <notification.h>
+#include <notification_setting.h>
#define NOTIFICATION_ADDR "/tmp/.notification.service"
#define NOTIFICATION_DEL_PACKET_UNIT 10
int notification_ipc_add_deffered_task(void (*deferred_task_cb)(void *data), void *user_data);
int notification_ipc_del_deffered_task(void (*deferred_task_cb)(void *data));
+int notification_ipc_update_setting(notification_setting_h 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);
bundle *b_service_single_launch;
bundle *b_service_multi_launch;
+ bundle *b_event_handler[NOTIFICATION_EVENT_TYPE_MAX];
+
char *domain; /* Text domain for localization */
char *dir; /* Text dir for localization */
void notification_call_changed_cb(notification_op *op_list, int op_num);
+char *notification_get_pkgname_by_pid(void);
+
#endif /* __NOTIFICATION_PRIVATE_H__ */
#ifndef __NOTIFICATION_SETTING_H__
#define __NOTIFICATION_SETTING_H__
-#include <notification.h>
-
-typedef struct _notification_setting_h notification_setting_h;
+#include <stdbool.h>
+#include "notification.h"
#ifdef __cplusplus
extern "C" {
#endif
-typedef enum _notification_setting_property {
- NOTIFICATION_SETTING_PROPERTY_ALLOW_TO_NOTIFY = 1,
- NOTIFICATION_SETTING_PROPERTY_DO_NOT_DISTURB = 2,
- NOTIFICATION_SETTING_PROPERTY_VISIBILITY_CLASS = 3,
-} notification_setting_property_e;
+typedef struct notification_setting* notification_setting_h;
+int notification_setting_get_setting(notification_setting_h *setting);
+int notification_setting_get_visibility_class(notification_setting_h setting, int *value);
+int notification_setting_set_visibility_class(notification_setting_h setting, int value);
-/**
- * @internal
- * @brief This function sets notification property for designated package.
- * @since_tizen 2.3
- * @privlevel public
- * @privilege http://tizen.org/privilege/core/notification
- * @param[in] pkgname The name of designated package
- * @param[in] property name
- * @param[in] property value
- * @return #NOTIFICATION_ERROR_NONE if success, other value if failure
- * @see #notification_error_e
- */
-int notification_setting_property_set(const char *pkgname, const char *property, const char *value);
+int notification_setting_update_setting(notification_setting_h setting);
-/**
- * @internal
- * @brief This function gets notification property for designated package.
- * @since_tizen 2.3
- * @privlevel public
- * @privilege http://tizen.org/privilege/core/notification
- * @param[in] pkgname The name of designated package
- * @param[in] property name
- * @param[in] pointer which can save the getting value
- * @return #NOTIFICATION_ERROR_NONE if success, other value if failure
- * @see #notification
- */
-int notification_setting_property_get(const char *pkgname, const char *property, char **value);
+int notification_setting_free_notification(notification_setting_h setting);
#ifdef __cplusplus
}
--- /dev/null
+/*\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
int notification_setting_db_set(const char *pkgname, const char *property, const char *value);
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);
+
#ifdef __cplusplus
}
#endif
* @since_tizen 2.4
*/
typedef enum _notification_event_type {
- NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1 = 1, /** < Event type : Click on button 1 */
- NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2 = 2, /** < Event type : Click on button 2 */
- NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3 = 3, /** < Event type : Click on button 3 */
- NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_4 = 4, /** < Event type : Click on button 4 */
- NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_5 = 5, /** < Event type : Click on button 5 */
- NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_6 = 6, /** < Event type : Click on button 6 */
- NOTIFICATION_EVENT_TYPE_CLICK_ON_ICON = 5, /** < Event type : Click on icon */
- NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL = 6, /** < Event type : Click on thumbnail */
+ NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1 = 0, /** < Event type : Click on button 1 */
+ NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2 = 1, /** < Event type : Click on button 2 */
+ NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3 = 2, /** < Event type : Click on button 3 */
+ NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_4 = 3, /** < Event type : Click on button 4 */
+ NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_5 = 4, /** < Event type : Click on button 5 */
+ NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_6 = 5, /** < Event type : Click on button 6 */
+ NOTIFICATION_EVENT_TYPE_CLICK_ON_ICON = 6, /** < Event type : Click on icon */
+ NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL = 7, /** < Event type : Click on thumbnail */
+ NOTIFICATION_EVENT_TYPE_MAX,
} notification_event_type_e;
/**
Name: notification
Summary: notification library
-Version: 0.2.27
+Version: 0.2.28
Release: 1
Group: TBD
License: Apache
b_service_responding TEXT,
b_service_single_launch TEXT,
b_service_multi_launch TEXT,
+ b_event_handler_click_on_button_1 TEXT,
+ b_event_handler_click_on_button_2 TEXT,
+ b_event_handler_click_on_button_3 TEXT,
+ b_event_handler_click_on_button_4 TEXT,
+ b_event_handler_click_on_button_5 TEXT,
+ b_event_handler_click_on_button_6 TEXT,
+ b_event_handler_click_on_icon TEXT,
+ b_event_handler_click_on_thumbnail TEXT,
sound_type INTEGER default 0,
sound_path TEXT,
vibration_type INTEGER default 0,
rowid INTEGER PRIMARY KEY AUTOINCREMENT,
UNIQUE (caller_pkgname, group_id)
);
- create table if not exists ongoing_list (
+ create table if not exists ongoing_list (
caller_pkgname TEXT NOT NULL,
launch_pkgname TEXT,
icon_path TEXT,
flag INTEGER default 0,
progress_size DOUBLE default 0,
progress_percentage DOUBLE default 0,
- rowid INTEGER PRIMARY KEY AUTOINCREMENT,
- UNIQUE (caller_pkgname, priv_id)
+ rowid INTEGER PRIMARY KEY AUTOINCREMENT,
+ UNIQUE (caller_pkgname, priv_id)
);
+ CREATE TABLE IF NOT EXISTS notification_setting (
+ priv_id INTERGER PRIMARY KEY,
+ package_name TEXT NOT NULL,
+ allow_to_notify INTEGER DEFAULT 1,
+ do_not_disturb_except 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);
+
+ CREATE UNIQUE INDEX package_name_idx1 ON notification_setting (package_name);
'
fi
#define NOTI_TEXT_RESULT_LEN 2048
#define NOTI_PKGNAME_LEN 512
-static char *_notification_get_pkgname_by_pid(void)
+char *notification_get_pkgname_by_pid(void)
{
char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
int pid = 0, ret = AUL_R_OK;
EXPORT_API int notification_set_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler)
{
- return NOTIFICATION_ERROR_INVALID_OPERATION;
+ int err = NOTIFICATION_ERROR_NONE;
+ bundle *app_control_bundle = NULL;
+
+ if (noti == NULL) {
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
+ || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
+ NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ if ((err = app_control_to_bundle(event_handler, &app_control_bundle)) != APP_CONTROL_ERROR_NONE) {
+ NOTIFICATION_ERR("app_control_to_bundle failed [%d]", err);
+ goto out;
+ }
+
+ if (noti->b_event_handler[event_type] != NULL) {
+ bundle_free(noti->b_event_handler[event_type]);
+ }
+
+ noti->b_event_handler[event_type] = app_control_bundle;
+
+out:
+ return err;
}
EXPORT_API int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler)
{
- return NOTIFICATION_ERROR_INVALID_OPERATION;
+ int err = NOTIFICATION_ERROR_NONE;
+ bundle *b = NULL;
+ app_control_h app_control_new = NULL;
+
+ if (noti == NULL) {
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
+ goto out;
+ }
+ if (event_handler == NULL) {
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
+ goto out;
+ }
+ if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
+ || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
+ NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ b = noti->b_event_handler[event_type];
+
+ if (b == NULL) {
+ NOTIFICATION_DBG("No event handler\n");
+ err = NOTIFICATION_ERROR_NOT_EXIST_ID;
+ goto out;
+ }
+
+ err = app_control_create(&app_control_new);
+ if (err != APP_CONTROL_ERROR_NONE || app_control_new == NULL) {
+ NOTIFICATION_ERR("app_control_create failed [%d]", err);
+ err = NOTIFICATION_ERROR_IO_ERROR;
+ goto out;
+ }
+
+ err = app_control_import_from_bundle(app_control_new, b);
+ if (err == APP_CONTROL_ERROR_NONE) {
+ *event_handler = app_control_new;
+ }
+ else {
+ app_control_destroy(app_control_new);
+ NOTIFICATION_ERR("Failed to import app control from bundle [%d]", err);
+ err = NOTIFICATION_ERROR_IO_ERROR;
+ goto out;
+ }
+
+out:
+ if (event_handler)
+ *event_handler = app_control_new;
+
+ return err;
}
EXPORT_API int notification_set_execute_option(notification_h noti,
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- caller_pkgname = _notification_get_pkgname_by_pid();
+ caller_pkgname = notification_get_pkgname_by_pid();
ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
}
if (pkgname == NULL) {
- caller_pkgname = _notification_get_pkgname_by_pid();
+ caller_pkgname = notification_get_pkgname_by_pid();
} else {
caller_pkgname = strdup(pkgname);
}
}
if (pkgname == NULL) {
- caller_pkgname = _notification_get_pkgname_by_pid();
+ caller_pkgname = notification_get_pkgname_by_pid();
} else {
caller_pkgname = strdup(pkgname);
}
}
if (noti == NULL) {
- caller_pkgname = _notification_get_pkgname_by_pid();
+ caller_pkgname = notification_get_pkgname_by_pid();
} else {
caller_pkgname = strdup(noti->caller_pkgname);
}
}
if (noti == NULL) {
- caller_pkgname = _notification_get_pkgname_by_pid();
+ caller_pkgname = notification_get_pkgname_by_pid();
} else {
caller_pkgname = strdup(noti->caller_pkgname);
}
}
if (noti == NULL) {
- caller_pkgname = _notification_get_pkgname_by_pid();
+ caller_pkgname = notification_get_pkgname_by_pid();
} else {
caller_pkgname = strdup(noti->caller_pkgname);
}
else if (type == NOTIFICATION_TYPE_ONGOING)
noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
- noti->caller_pkgname = _notification_get_pkgname_by_pid();
+ noti->caller_pkgname = notification_get_pkgname_by_pid();
noti->group_id = NOTIFICATION_GROUP_ID_NONE;
noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
return NULL;
}
- caller_pkgname = _notification_get_pkgname_by_pid();
+ caller_pkgname = notification_get_pkgname_by_pid();
if (!caller_pkgname) {
NOTIFICATION_ERR("Failed to get a package name");
set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
{
+ int i = 0;
notification_h new_noti = NULL;
if (noti == NULL || clone == NULL) {
if(noti->caller_pkgname != NULL) {
new_noti->caller_pkgname = strdup(noti->caller_pkgname);
} else {
- new_noti->caller_pkgname = _notification_get_pkgname_by_pid();
+ new_noti->caller_pkgname = notification_get_pkgname_by_pid();
}
if(noti->launch_pkgname != NULL) {
new_noti->launch_pkgname = strdup(noti->launch_pkgname);
new_noti->b_service_multi_launch = NULL;
}
+ for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
+ if(noti->b_event_handler[i] != NULL) {
+ new_noti->b_event_handler[i] = bundle_dup(noti->b_event_handler[i]);
+ } else {
+ new_noti->b_event_handler[i] = NULL;
+ }
+ }
+
new_noti->sound_type = noti->sound_type;
if(noti->sound_path != NULL) {
new_noti->sound_path = strdup(noti->sound_path);
EXPORT_API int notification_free(notification_h noti)
{
+ int i = 0;
if (noti == NULL) {
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
bundle_free(noti->b_service_multi_launch);
}
+ for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
+ if(noti->b_event_handler[i] != NULL) {
+ bundle_free(noti->b_event_handler[i]);
+ }
+ }
+
if (noti->sound_path) {
free(noti->sound_path);
}
char *caller_pkgname = NULL;
if (pkgname == NULL) {
- caller_pkgname = _notification_get_pkgname_by_pid();
+ caller_pkgname = notification_get_pkgname_by_pid();
} else {
caller_pkgname = strdup(pkgname);
}
char *caller_pkgname = NULL;
if (pkgname == NULL) {
- caller_pkgname = _notification_get_pkgname_by_pid();
+ caller_pkgname = notification_get_pkgname_by_pid();
} else {
caller_pkgname = strdup(pkgname);
}
#include <notification_type.h>
#include <notification_private.h>
#include <notification_debug.h>
+#include <notification_setting_internal.h>
#define NOTIFICATION_IPC_TIMEOUT 0.0
*/
EXPORT_API int notification_ipc_make_noti_from_packet(notification_h noti, const struct packet *packet)
{
+ int i = 0;
int ret = 0;
int type;
int layout;
unsigned char *b_service_responding = NULL;
unsigned char *b_service_single_launch = NULL;
unsigned char *b_service_multi_launch = NULL;
+ unsigned char *b_event_handler[NOTIFICATION_EVENT_TYPE_MAX] = { NULL, };
char *domain = NULL;
char *dir = NULL;
unsigned char *b_text = NULL;
}
ret = packet_get(packet,
- "iiiiisssssssssssssisisisiiiiiiiiddsssss",
+ "iiiiisssssssssssssssssssssisisisiiiiiiiiddsssss",
&type,
&layout,
&group_id,
&b_service_responding,
&b_service_single_launch,
&b_service_multi_launch,
+ &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1],
+ &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2],
+ &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3],
+ &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_4],
+ &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_5],
+ &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_6],
+ &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_ICON],
+ &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL],
&domain,
&dir,
&b_text,
&temp_content,
&tag);
- if (ret != 39) {
+ if (ret != 47) {
NOTIFICATION_ERR("failed to create a noti from packet");
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
noti->b_service_responding = _create_bundle_from_string(b_service_responding);
noti->b_service_single_launch = _create_bundle_from_string(b_service_single_launch);
noti->b_service_multi_launch = _create_bundle_from_string(b_service_multi_launch);
+ for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
+ noti->b_event_handler[i] = _create_bundle_from_string(b_event_handler[i]);
+ }
noti->domain = _dup_string(domain);
noti->dir = _dup_string(dir);
noti->b_text = _create_bundle_from_string(b_text);
EXPORT_API struct packet *notification_ipc_make_packet_from_noti(notification_h noti, const char *command, int packet_type)
{
+ int i = 0;
int b_encode_len = 0;
struct packet *result = NULL;
char *args = NULL;
char *b_service_responding = NULL;
char *b_service_single_launch = NULL;
char *b_service_multi_launch = NULL;
+ char *b_event_handler[NOTIFICATION_EVENT_TYPE_MAX] = { NULL , };
char *b_text = NULL;
char *b_key = NULL;
char *b_format_args = NULL;
(bundle_raw **) & b_service_multi_launch, &b_encode_len);
}
+ for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
+ if (noti->b_event_handler[i]) {
+ bundle_encode(noti->b_event_handler[i],
+ (bundle_raw **) & b_event_handler[i], &b_encode_len);
+ }
+ }
+
if (noti->b_text) {
bundle_encode(noti->b_text, (bundle_raw **) & b_text, &b_encode_len);
}
}
result = func_to_create_packet(command,
- "iiiiisssssssssssssisisisiiiiiiiiddsssss",
+ "iiiiisssssssssssssssssssssisisisiiiiiiiiddsssss",
noti->type,
noti->layout,
noti->group_id,
NOTIFICATION_CHECK_STR(b_service_responding),
NOTIFICATION_CHECK_STR(b_service_single_launch),
NOTIFICATION_CHECK_STR(b_service_multi_launch),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_4]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_5]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_6]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_ICON]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL]),
NOTIFICATION_CHECK_STR(noti->domain),
NOTIFICATION_CHECK_STR(noti->dir),
NOTIFICATION_CHECK_STR(b_text),
free(b_service_multi_launch);
}
+ for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
+ if (b_event_handler[i]) {
+ free(b_event_handler[i]);
+ }
+ }
+
if (b_text) {
free(b_text);
}
EXPORT_API struct packet *notification_ipc_make_reply_packet_from_noti(notification_h noti, struct packet *packet)
{
+ int i = 0;
int b_encode_len = 0;
struct packet *result = NULL;
char *args = NULL;
char *b_service_responding = NULL;
char *b_service_single_launch = NULL;
char *b_service_multi_launch = NULL;
+ char *b_event_handler[NOTIFICATION_EVENT_TYPE_MAX] = { NULL , };
char *b_text = NULL;
char *b_key = NULL;
char *b_format_args = NULL;
(bundle_raw **) & b_service_multi_launch, &b_encode_len);
}
+ for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
+ if (noti->b_event_handler[i]) {
+ bundle_encode(noti->b_event_handler[i],
+ (bundle_raw **) & b_event_handler[i], &b_encode_len);
+ }
+ }
+
if (noti->b_text) {
bundle_encode(noti->b_text, (bundle_raw **) & b_text, &b_encode_len);
}
}
result = packet_create_reply(packet,
- "iiiiisssssssssssssisisisiiiiiiiiddsssss",
+ "iiiiisssssssssssssssssssssisisisiiiiiiiiddsssss",
noti->type,
noti->layout,
noti->group_id,
NOTIFICATION_CHECK_STR(b_service_responding),
NOTIFICATION_CHECK_STR(b_service_single_launch),
NOTIFICATION_CHECK_STR(b_service_multi_launch),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_4]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_5]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_6]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_ICON]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL]),
NOTIFICATION_CHECK_STR(noti->domain),
NOTIFICATION_CHECK_STR(noti->dir),
NOTIFICATION_CHECK_STR(b_text),
free(b_service_multi_launch);
}
+ for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
+ if (b_event_handler[i]) {
+ free(b_event_handler[i]);
+ }
+ }
+
if (b_text) {
free(b_text);
}
return status;
}
+
+int notification_ipc_update_setting(notification_setting_h setting)
+{
+ int status = 0;
+ int ret = 0;
+ 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);
+ 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");
+ packet_unref(result);
+ return NOTIFICATION_ERROR_IO_ERROR;
+ }
+ packet_unref(result);
+ } else {
+ NOTIFICATION_ERR("failed to receive answer(delete)");
+ if (notification_ipc_is_master_ready() == 1) {
+ return NOTIFICATION_ERROR_PERMISSION_DENIED;
+ }
+ else {
+ return NOTIFICATION_ERROR_SERVICE_NOT_READY;
+ }
+ }
+
+ return status;
+}
+
int notification_ipc_noti_setting_property_set(const char *pkgname, const char *property, const char *value)
{
int status = 0;
#include <notification_private.h>
#define NOTI_BURST_DELETE_UNIT 10
-static Eina_List *toast_list;
-static Eina_List *toast_popup;
static void __free_and_set(void **target_ptr, void *new_ptr) {
if (target_ptr != NULL) {
static int _insertion_query_create(notification_h noti, char **query)
{
+ int i = 0;
int b_encode_len = 0;
char *args = NULL;
char *group_args = NULL;
char *b_service_responding = NULL;
char *b_service_single_launch = NULL;
char *b_service_multi_launch = NULL;
+ char *b_event_handler[NOTIFICATION_EVENT_TYPE_MAX] = { NULL , };
char *b_text = NULL;
char *b_key = NULL;
char *b_format_args = NULL;
(bundle_raw **) & b_service_multi_launch, &b_encode_len);
}
+ for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
+ if (noti->b_event_handler[i]) {
+ bundle_encode(noti->b_event_handler[i],
+ (bundle_raw **) & b_event_handler[i], &b_encode_len);
+ }
+ }
+
if (noti->b_text) {
bundle_encode(noti->b_text, (bundle_raw **) & b_text, &b_encode_len);
}
"args, group_args, "
"b_execute_option, "
"b_service_responding, b_service_single_launch, b_service_multi_launch, "
+ "b_event_handler_click_on_button_1, b_event_handler_click_on_button_2, b_event_handler_click_on_button_3, "
+ "b_event_handler_click_on_button_4, b_event_handler_click_on_button_5, b_event_handler_click_on_button_6, "
+ "b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
"sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
"flags_for_property, flag_simmode, display_applist, "
"progress_size, progress_percentage) values ("
"'%s', '%s', "
"'%s', "
"'%s', '%s', '%s', "
+ "'%s', '%s', '%s', "
+ "'%s', '%s', '%s', "
+ "'%s', '%s', "
"%d, '%s', %d, '%s', %d, %d, %d, %d,"
"%d, %d, %d, "
"$progress_size, $progress_percentage)",
NOTIFICATION_CHECK_STR(b_service_responding),
NOTIFICATION_CHECK_STR(b_service_single_launch),
NOTIFICATION_CHECK_STR(b_service_multi_launch),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_4]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_5]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_6]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_ICON]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL]),
noti->sound_type, NOTIFICATION_CHECK_STR(noti->sound_path),
noti->vibration_type,
NOTIFICATION_CHECK_STR(noti->vibration_path),
static int _update_query_create(notification_h noti, char **query)
{
+ int i = 0;
int b_encode_len = 0;
char *args = NULL;
char *group_args = NULL;
char *b_service_responding = NULL;
char *b_service_single_launch = NULL;
char *b_service_multi_launch = NULL;
+ char *b_event_handler[NOTIFICATION_EVENT_TYPE_MAX] = { NULL , };
char *b_text = NULL;
char *b_key = NULL;
char *b_format_args = NULL;
(bundle_raw **) & b_service_multi_launch, &b_encode_len);
}
+ for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
+ if (noti->b_event_handler[i]) {
+ bundle_encode(noti->b_event_handler[i],
+ (bundle_raw **) & b_event_handler[i], &b_encode_len);
+ }
+ }
+
if (noti->b_text) {
bundle_encode(noti->b_text, (bundle_raw **) & b_text, &b_encode_len);
}
"b_service_responding = '%s', "
"b_service_single_launch = '%s', "
"b_service_multi_launch = '%s', "
+ "b_event_handler_click_on_button_1 = '%s', "
+ "b_event_handler_click_on_button_2= '%s', "
+ "b_event_handler_click_on_button_3= '%s', "
+ "b_event_handler_click_on_button_4= '%s', "
+ "b_event_handler_click_on_button_5= '%s', "
+ "b_event_handler_click_on_button_6= '%s', "
+ "b_event_handler_click_on_icon= '%s', "
+ "b_event_handler_click_on_thumbnail= '%s', "
"sound_type = %d, sound_path = '%s', "
"vibration_type = %d, vibration_path = '%s', "
"led_operation = %d, led_argb = %d, "
NOTIFICATION_CHECK_STR(b_service_responding),
NOTIFICATION_CHECK_STR(b_service_single_launch),
NOTIFICATION_CHECK_STR(b_service_multi_launch),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_4]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_5]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_6]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_ICON]),
+ NOTIFICATION_CHECK_STR(b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL]),
noti->sound_type, NOTIFICATION_CHECK_STR(noti->sound_path),
noti->vibration_type,
NOTIFICATION_CHECK_STR(noti->vibration_path),
static void _notification_noti_populate_from_stmt(sqlite3_stmt * stmt, notification_h noti) {
int col = 0;
+ int i = 0;
if (stmt == NULL || noti == NULL) {
return ;
noti->b_service_multi_launch =
notification_db_column_bundle(stmt, col++);
+ for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
+ noti->b_event_handler[i] = notification_db_column_bundle(stmt, col++);
+ }
+
noti->sound_type = sqlite3_column_int(stmt, col++);
__free_and_set((void **)&(noti->sound_path), notification_db_column_text(stmt, col++));
noti->vibration_type = sqlite3_column_int(stmt, col++);
"tag, b_text, b_key, b_format_args, num_format_args, "
"text_domain, text_dir, time, insert_time, args, group_args, "
"b_execute_option, b_service_responding, b_service_single_launch, b_service_multi_launch, "
+ "b_event_handler_click_on_button_1, b_event_handler_click_on_button_2, b_event_handler_click_on_button_3, "
+ "b_event_handler_click_on_button_4, b_event_handler_click_on_button_5, b_event_handler_click_on_button_6, "
+ "b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
"sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
"flags_for_property, display_applist, progress_size, progress_percentage "
"from noti_list ";
"tag, b_text, b_key, b_format_args, num_format_args, "
"text_domain, text_dir, time, insert_time, args, group_args, "
"b_execute_option, b_service_responding, b_service_single_launch, b_service_multi_launch, "
+ "b_event_handler_click_on_button_1, b_event_handler_click_on_button_2, b_event_handler_click_on_button_3, "
+ "b_event_handler_click_on_button_4, b_event_handler_click_on_button_5, b_event_handler_click_on_button_6, "
+ "b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
"sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
"flags_for_property, display_applist, progress_size, progress_percentage "
"from noti_list where caller_pkgname = ? and tag = ?", -1, &stmt, NULL);
"tag, b_text, b_key, b_format_args, num_format_args, "
"text_domain, text_dir, time, insert_time, args, group_args, "
"b_execute_option, b_service_responding, b_service_single_launch, b_service_multi_launch, "
+ "b_event_handler_click_on_button_1, b_event_handler_click_on_button_2, b_event_handler_click_on_button_3, "
+ "b_event_handler_click_on_button_4, b_event_handler_click_on_button_5, b_event_handler_click_on_button_6, "
+ "b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
"sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
"flags_for_property, display_applist, progress_size, progress_percentage "
"from noti_list where tag = ?", -1, &stmt, NULL);
"tag, b_text, b_key, b_format_args, num_format_args, "
"text_domain, text_dir, time, insert_time, args, group_args, "
"b_execute_option, b_service_responding, b_service_single_launch, b_service_multi_launch, "
+ "b_event_handler_click_on_button_1, b_event_handler_click_on_button_2, b_event_handler_click_on_button_3, "
+ "b_event_handler_click_on_button_4, b_event_handler_click_on_button_5, b_event_handler_click_on_button_6, "
+ "b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
"sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
"flags_for_property, display_applist, progress_size, progress_percentage "
"from noti_list ");
"tag, b_text, b_key, b_format_args, num_format_args, "
"text_domain, text_dir, time, insert_time, args, group_args, "
"b_execute_option, b_service_responding, b_service_single_launch, b_service_multi_launch, "
+ "b_event_handler_click_on_button_1, b_event_handler_click_on_button_2, b_event_handler_click_on_button_3, "
+ "b_event_handler_click_on_button_4, b_event_handler_click_on_button_5, b_event_handler_click_on_button_6, "
+ "b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
"sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
"flags_for_property, display_applist, progress_size, progress_percentage "
"from noti_list ");
return ret;
}
-
-static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Eina_List *list = NULL;
- char *msg = NULL;
- int count = 0;
-
- evas_object_del(toast_popup);
- toast_popup = NULL;
- evas_object_del((Evas_Object *)data);
-
- count = eina_list_count(toast_list);
-
- if (count == 1){
- msg = (char *)eina_list_data_get(toast_list);
- free(msg);
-
- eina_list_free(toast_list);
- toast_list = NULL;
- } else if (count > 1) {
- msg = (char *)eina_list_data_get(toast_list);
- toast_list = eina_list_remove(toast_list, msg);
- free(msg);
- _post_toast_message((char *)eina_list_data_get(toast_list));
- }
-}
-
-int _post_toast_message(char *message)
-{
- int let = 0;
- Evas_Object *toast_window;
- Evas *e;
- Ecore_Evas *ee;
- double scale = elm_config_scale_get();
-
-
- toast_window = elm_win_add(NULL, "toast", ELM_WIN_BASIC);
-
- elm_win_alpha_set(toast_window, EINA_TRUE);
- elm_win_title_set(toast_window, "toast");
-
- elm_win_indicator_mode_set(toast_window, ELM_WIN_INDICATOR_SHOW);
- elm_win_indicator_type_set(toast_window,ELM_WIN_INDICATOR_TYPE_1);
-
- //elm_win_autodel_set(toast_win, EINA_TRUE);
- if (elm_win_wm_rotation_supported_get(toast_window)) {
- int rots[4] = { 0, 90, 180, 270 };
- elm_win_wm_rotation_available_rotations_set(toast_window, (const int*)(&rots), 4);
- }
-
- e = evas_object_evas_get(toast_window);
- ee = ecore_evas_ecore_evas_get(e);
- ecore_evas_name_class_set(ee, "TOAST_POPUP", "SYSTEM_POPUP");
-
- evas_object_resize(toast_window, (480 * scale), (650 * scale));
- ecore_x_window_shape_input_rectangle_set(elm_win_xwindow_get(toast_window), 0, 0, (480 * scale), (650 * scale));
-
- toast_popup = elm_popup_add(toast_window);
-
- elm_object_style_set(toast_popup, "toast");
- evas_object_size_hint_weight_set(toast_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- elm_object_text_set(toast_popup,message);
-
- if (eina_list_count(toast_list) != 1) {
- elm_popup_timeout_set(toast_popup, 1.0);
- }
- else {
- elm_popup_timeout_set(toast_popup, 3.0);
- }
- evas_object_smart_callback_add(toast_popup, "timeout", popup_timeout_cb, (void *)toast_window);
-
- elm_win_prop_focus_skip_set(toast_window, EINA_TRUE);
-
- evas_object_show(toast_window);
- evas_object_show(toast_popup);
-
- return 0;
-}
-
-EXPORT_API int notification_noti_post_toast_message(const char *message)
-{
- int let = 0;
- char *msg = NULL;
- int count = 0;
-
- msg = (char *)calloc(strlen(message) + 1, sizeof(char));
- strcpy(msg, message);
-
-/*
- if (eina_list_count(toast_list) == 10) {
- toast_list = eina_list_last(toast_list);
- eina_list_data_set(toast_list, msg);
- toast_list = eina_list_nth_list(toast_list, 0);
- }
- else {
-*/
-
- count = eina_list_count(toast_list);
- if (count == 0) {
- toast_list = eina_list_append(toast_list, msg);
- let = _post_toast_message(msg);
- }
- else if (count == 1) {
- if (strcmp(msg, (char *)eina_list_nth(toast_list, count - 1)) == 0) {
- elm_popup_timeout_set(toast_popup, 3.0);
- }
- else {
- toast_list = eina_list_append(toast_list, msg);
- elm_popup_timeout_set(toast_popup, 1.0);
- }
- }
- else if (count >= 2) {
- if (strcmp(msg, (char *)eina_list_nth(toast_list, count - 1)) == 0) {
- free(msg);
- return 0;
- }
- else {
- toast_list = eina_list_append(toast_list, msg);
- }
- }
-
- return 0;
-}
#include <notification_ipc.h>
#include <notification_private.h>
#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)
+{
+ if ((table == NULL) || (buf == NULL) || (index < 0)) {
+ NOTIFICATION_ERR("table[%p], buf[%p], index[%d]", table, buf, index);
+ return false;
+ }
+
+ if (table[index] != NULL) {
+ *buf = atoi(table[index]);
+ return true;
+ }
+
+ *buf = 0;
+ return false;
+}
+
+static int _get_table_field_data_string(char **table, char **buf, int ucs2, int index)
+{
+ int ret = false;
+
+ if ((table == NULL) || (buf == NULL) || (index < 0)) {
+ NOTIFICATION_ERR("table[%p], buf[%p], index[%d]", table, buf, index);
+ return false;
+ }
+
+ char *pTemp = table[index];
+ int sLen = 0;
+ if (pTemp == NULL)
+ *buf = NULL;
+ else {
+ sLen = strlen(pTemp);
+ if(sLen) {
+ *buf = (char *) malloc(sLen + 1);
+ if (*buf == NULL) {
+ NOTIFICATION_ERR("malloc is failed");
+ goto out;
+ }
+ memset(*buf, 0, sLen + 1);
+ strncpy(*buf, pTemp, sLen);
+ }
+ else
+ *buf = NULL;
+ }
+
+ ret = true;
+out:
+
+ return ret;
+}
+
+
+
+EXPORT_API int notification_setting_get_setting_array(notification_setting_h *setting_array, int *count)
+{
+ 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 i = 0;
+ int col_index = 0;
+ notification_setting_h result_setting_array= NULL;
+
+ if (setting_array == NULL || count == 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 package_name, allow_to_notify, do_not_disturb_except, visibility_class "
+ "FROM %s "
+ "ORDER BY package_name", NOTIFICATION_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("NOTIFICATION_ERROR_FROM_DB 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);
+ if (!(result_setting_array = (struct notification_setting*)malloc(sizeof(struct notification_setting) * row_count))) {
+ NOTIFICATION_ERR("malloc failed...");
+ err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ col_index = column_count;
+
+ for (i = 0; i < row_count; i++) {
+ _get_table_field_data_string(query_result, &(result_setting_array[i].package_name), 1, col_index++);
+ _get_table_field_data_int(query_result, (int*)&(result_setting_array[i].allow_to_notify), col_index++);
+ _get_table_field_data_int(query_result, (int*)&(result_setting_array[i].do_not_disturb_except), col_index++);
+ _get_table_field_data_int(query_result, &(result_setting_array[i].visibility_class), col_index++);
+ }
+
+ *setting_array = result_setting_array;
+ *count = row_count;
+
+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_setting_get_setting_by_package_name(const char *package_name, notification_setting_h *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 i = 0;
+ int col_index = 0;
+ notification_setting_h result_setting_array= NULL;
+
+ if (package_name == NULL || 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 package_name, allow_to_notify, do_not_disturb_except, visibility_class "
+ "FROM %s "
+ "WHERE package_name = %Q ", NOTIFICATION_SETTING_DB_TABLE, package_name);
+
+ 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("NOTIFICATION_ERROR_FROM_DB 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_setting_array = (struct notification_setting*)malloc(sizeof(struct notification_setting) * row_count))) {
+ NOTIFICATION_ERR("malloc failed...");
+ err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ col_index = column_count;
+
+ _get_table_field_data_string(query_result, &(result_setting_array[i].package_name), 1, col_index++);
+ _get_table_field_data_int(query_result, (int*)&(result_setting_array[i].allow_to_notify), col_index++);
+ _get_table_field_data_int(query_result, (int*)&(result_setting_array[i].do_not_disturb_except), col_index++);
+ _get_table_field_data_int(query_result, &(result_setting_array[i].visibility_class), col_index++);
+
+ *setting = result_setting_array;
+
+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_setting_get_setting(notification_setting_h *setting)
+{
+ char *package_name = NULL;
+
+ package_name = notification_get_pkgname_by_pid();
+
+ if (package_name == NULL)
+ return NOTIFICATION_ERROR_NOT_EXIST_ID;
+
+ return notification_setting_get_setting_by_package_name(package_name, setting);
+}
+
+EXPORT_API int notification_setting_get_package_name(notification_setting_h setting, char **value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (setting == NULL || value == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ if (setting->package_name == NULL) {
+ NOTIFICATION_ERR("setting->package_name is null\n");
+ err = NOTIFICATION_ERROR_NOT_EXIST_ID;
+ goto out;
+ }
+
+ *value = SAFE_STRDUP(setting->package_name);
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_setting_set_package_name(notification_setting_h setting, char *value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (setting == NULL || value == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ if (setting->package_name != NULL) {
+ free(setting->package_name);
+ }
+
+ setting->package_name = SAFE_STRDUP(value);
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_setting_get_allow_to_notify(notification_setting_h setting, bool *value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (setting == NULL || value == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ *value = setting->allow_to_notify;
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_setting_set_allow_to_notify(notification_setting_h setting, bool value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ setting->allow_to_notify = value;
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_setting_get_do_not_disturb_except(notification_setting_h setting, bool *value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (setting == NULL || value == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ *value = setting->do_not_disturb_except;
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_setting_set_do_not_disturb_except(notification_setting_h setting, bool value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ setting->do_not_disturb_except = value;
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_setting_get_visibility_class(notification_setting_h setting, int *value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (setting == NULL || value == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ *value = setting->visibility_class;
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_setting_set_visibility_class(notification_setting_h setting, int value)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ setting->visibility_class = value;
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_setting_update_setting(notification_setting_h setting)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ 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);
+ goto out;
+ }
+
+out:
+ return err;
+}
+
+EXPORT_API int notification_setting_free_notification(notification_setting_h setting)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+
+ if (setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter\n");
+ err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ SAFE_FREE(setting->package_name);
+ /* add codes to free all properties */
+
+out:
+
+ return err;
+}
+
+EXPORT_API int notification_setting_db_update(const char *package_name, int allow_to_notify, int do_not_disturb_except, int visibility_class)
+{
+ int err = NOTIFICATION_ERROR_NONE;
+ sqlite3 *db = NULL;
+ char *sqlbuf = NULL;
+ int sqlret;
+
+ if (package_name == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ 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 allow_to_notify = %d, do_not_disturb_except = %d, visibility_class = %d " \
+ "WHERE package_name = %Q",
+ NOTIFICATION_SETTING_DB_TABLE, allow_to_notify, do_not_disturb_except, visibility_class, package_name);
+ 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 */
#define NOTIFICATION_SETTING_DB "notification_setting"
#define NOTIFICATION_SETTING_DB_PATH "/opt/usr/dbspace/.notification_parser.db"
-typedef struct _notification_setting_h notification_setting_h;
-
struct _notification_setting_h {
char *appid;
char *notification;
};
static struct prop_table g_prop_table[] = {
- {
- .property = "OPT_NOTIFICATION",
- .column = "notification",
- .default_value = "ON",
- },
- {
- .property = "OPT_SOUNDS",
- .column = "sounds",
- .default_value = "ON",
- },
- {
- .property = "OPT_CONTENTS",
- .column = "contents",
- .default_value = "ON",
- },
- {
- .property = "OPT_BADGE",
- .column = "badge",
- .default_value = "ON",
- },
- {
- .property = NULL,
- .column = NULL,
- .default_value = NULL,
- }
+ {
+ .property = "OPT_NOTIFICATION",
+ .column = "notification",
+ .default_value = "ON",
+ },
+ {
+ .property = "OPT_SOUNDS",
+ .column = "sounds",
+ .default_value = "ON",
+ },
+ {
+ .property = "OPT_CONTENTS",
+ .column = "contents",
+ .default_value = "ON",
+ },
+ {
+ .property = "OPT_BADGE",
+ .column = "badge",
+ .default_value = "ON",
+ },
+ {
+ .property = NULL,
+ .column = NULL,
+ .default_value = NULL,
+ }
};
static const char *_get_prop_column(const char *property)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
sqlbuf = sqlite3_mprintf("SELECT count(*) FROM %s WHERE " \
- "appid = %Q",
- NOTIFICATION_SETTING_DB, pkgname);
+ "appid = %Q",
+ NOTIFICATION_SETTING_DB, pkgname);
if (!sqlbuf) {
NOTIFICATION_ERR("fail to alloc sql query");
else
result = NOTIFICATION_ERROR_NOT_EXIST_ID;
-free_and_return:
+ free_and_return:
if (sqlbuf)
sqlite3_free(sqlbuf);
result = notification_db_exec(db, sqlbuf, NULL);
-return_close_db:
+ return_close_db:
if (sqlbuf)
sqlite3_free(sqlbuf);
}
}
-return_close_db:
+ return_close_db:
if (sqlbuf)
sqlite3_free(sqlbuf);
return NOTIFICATION_ERROR_NONE;
}
+
#include <errno.h>
#include <vconf.h>
#include <E_DBus.h>
+#include <Ecore.h>
+#include <Elementary.h>
+#include <Eina.h>
#include <notification.h>
#include <notification_db.h>
#define INTERFACE_NAME "org.tizen.system.notification.status_message"
#define MEMBER_NAME "status_message"
+static Eina_List *toast_list;
+static Eina_List *toast_popup;
+
struct _message_cb_data {
notification_status_message_cb callback;
void *data;
static struct _message_cb_data md;
+int _post_toast_message(char *message);
+
+static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ char *msg = NULL;
+ int count = 0;
+
+ evas_object_del(toast_popup);
+ toast_popup = NULL;
+ evas_object_del((Evas_Object *)data);
+
+ count = eina_list_count(toast_list);
+
+ if (count == 1){
+ msg = (char *)eina_list_data_get(toast_list);
+ free(msg);
+
+ eina_list_free(toast_list);
+ toast_list = NULL;
+ } else if (count > 1) {
+ msg = (char *)eina_list_data_get(toast_list);
+ toast_list = eina_list_remove(toast_list, msg);
+ free(msg);
+ _post_toast_message((char *)eina_list_data_get(toast_list));
+ }
+}
+
+int _post_toast_message(char *message)
+{
+ Evas_Object *toast_window;
+ Evas *e;
+ Ecore_Evas *ee;
+ double scale = elm_config_scale_get();
+
+
+ toast_window = elm_win_add(NULL, "toast", ELM_WIN_BASIC);
+
+ elm_win_alpha_set(toast_window, EINA_TRUE);
+ elm_win_title_set(toast_window, "toast");
+
+ elm_win_indicator_mode_set(toast_window, ELM_WIN_INDICATOR_SHOW);
+ elm_win_indicator_type_set(toast_window,ELM_WIN_INDICATOR_TYPE_1);
+
+ //elm_win_autodel_set(toast_win, EINA_TRUE);
+ if (elm_win_wm_rotation_supported_get(toast_window)) {
+ int rots[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(toast_window, (const int*)(&rots), 4);
+ }
+
+ e = evas_object_evas_get(toast_window);
+ ee = ecore_evas_ecore_evas_get(e);
+ ecore_evas_name_class_set(ee, "TOAST_POPUP", "SYSTEM_POPUP");
+
+ evas_object_resize(toast_window, (480 * scale), (650 * scale));
+ ecore_x_window_shape_input_rectangle_set(elm_win_xwindow_get(toast_window), 0, 0, (480 * scale), (650 * scale));
+
+ toast_popup = elm_popup_add(toast_window);
+
+ elm_object_style_set(toast_popup, "toast");
+ evas_object_size_hint_weight_set(toast_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ elm_object_text_set(toast_popup,message);
+
+ if (eina_list_count(toast_list) != 1) {
+ elm_popup_timeout_set(toast_popup, 1.0);
+ }
+ else {
+ elm_popup_timeout_set(toast_popup, 3.0);
+ }
+ evas_object_smart_callback_add(toast_popup, "timeout", popup_timeout_cb, (void *)toast_window);
+
+ elm_win_prop_focus_skip_set(toast_window, EINA_TRUE);
+
+ evas_object_show(toast_window);
+ evas_object_show(toast_popup);
+
+ return 0;
+}
+
+int notification_noti_post_toast_message(const char *message)
+{
+ int let = 0;
+ char *msg = NULL;
+ int count = 0;
+
+ msg = (char *)calloc(strlen(message) + 1, sizeof(char));
+ strcpy(msg, message);
+
+ count = eina_list_count(toast_list);
+ if (count == 0) {
+ toast_list = eina_list_append(toast_list, msg);
+ let = _post_toast_message(msg);
+ }
+ else if (count == 1) {
+ if (strcmp(msg, (char *)eina_list_nth(toast_list, count - 1)) == 0) {
+ elm_popup_timeout_set(toast_popup, 3.0);
+ }
+ else {
+ toast_list = eina_list_append(toast_list, msg);
+ elm_popup_timeout_set(toast_popup, 1.0);
+ }
+ }
+ else if (count >= 2) {
+ if (strcmp(msg, (char *)eina_list_nth(toast_list, count - 1)) == 0) {
+ free(msg);
+ return 0;
+ }
+ else {
+ toast_list = eina_list_append(toast_list, msg);
+ }
+ }
+
+ return 0;
+}
+
static void __notification_status_message_dbus_callback(void *data, DBusMessage *msg)
{
int ret = 0;
SET(VISIBILITY "-DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\"")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections -fPIC")
##########################################################
# Define Test App
/* notification header */
#include <notification.h>
#include <notification_status.h>
+#include <notification_setting.h>
+#include <notification_setting_internal.h>
/*-----------------------------------------------------------------------------------------*/
/* types */
typedef enum testapp_menu_type {
TESTAPP_MENU_TYPE_MAIN_MENU = 1,
TESTAPP_MENU_TYPE_BASIC_TEST_MENU = 2,
+ TESTAPP_MENU_TYPE_SETTING_TEST_MENU = 3
} testapp_menu_type_e;
/*-----------------------------------------------------------------------------------------*/
testapp_print (" Notification test application \n");
testapp_print ("==========================================\n");
testapp_print ("1. Basic Test\n");
+ testapp_print ("2. Setting Test\n");
testapp_print ("0. Exit \n");
testapp_print ("------------------------------------------\n");
break;
testapp_print (" 2. Post simple notifications repeatedly\n");
testapp_print (" 3. Post a notification on indicator\n");
testapp_print (" 4. Post status status message\n");
+ testapp_print (" 5. Delete all notification\n");
+ testapp_print (" 6. Post a heads notification with a button\n");
+ testapp_print ("------------------------------------------\n");
+ break;
+ case TESTAPP_MENU_TYPE_SETTING_TEST_MENU:
+ testapp_print ("==========================================\n");
+ testapp_print (" Setting test menu \n");
+ testapp_print ("==========================================\n");
+ testapp_print (" 1. Get setting list\n");
+ testapp_print (" 2. Update setting\n");
testapp_print ("------------------------------------------\n");
break;
default:
goto FINISH_OFF;
}
-FINISH_OFF:
+ FINISH_OFF:
if (noti_handle)
notification_free(noti_handle);
}
-FINISH_OFF:
+ FINISH_OFF:
return err;
}
}
}
-
-FINISH_OFF:
+ FINISH_OFF:
return err;
}
goto FINISH_OFF;
}
-FINISH_OFF:
+ FINISH_OFF:
if (noti_handle)
notification_free(noti_handle);
return noti_err;
}
+static int testapp_test_delete_all_notifications()
+{
+ int noti_err = NOTIFICATION_ERROR_NONE;
+
+ noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
+
+ testapp_print("notification_delete_all returns[%d]", noti_err);
+
+ return noti_err;
+}
+
+static int testapp_test_post_heads_up_notification_with_button()
+{
+ notification_h noti_handle = NULL;
+ int noti_err = NOTIFICATION_ERROR_NONE;
+ int app_control_err = APP_CONTROL_ERROR_NONE;
+ int priv_id = 0;
+ int group_id = 0;
+ char *app_id = NULL;
+ app_control_h app_control = NULL;
+ time_t result = time(NULL);
+ char tag[100] = { 0, };
+
+ noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
+
+ if (noti_handle == NULL) {
+ testapp_print("notification_create failed");
+ goto FINISH_OFF;
+ }
+
+ noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "CONTENT", NOTIFICATION_VARIABLE_TYPE_NONE);
+
+ noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_HEADS_UP | NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
+
+ snprintf(tag, 100, "%d", result);
+
+ noti_err = notification_set_tag(noti_handle, tag);
+
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ testapp_print("notification_set_display_applist failed[%d]\n", noti_err);
+ goto FINISH_OFF;
+ }
+
+ app_control_err = app_control_create(&app_control);
+ if (app_control_err != APP_CONTROL_ERROR_NONE ) {
+ testapp_print("app_control_create failed[%d]\n", app_control_err);
+ goto FINISH_OFF;
+ }
+
+ app_control_err = app_control_set_app_id(app_control, "org.tizen.quickpanel");
+ if (app_control_err != APP_CONTROL_ERROR_NONE ) {
+ testapp_print("app_control_set_app_id failed[%d]\n", app_control_err);
+ goto FINISH_OFF;
+ }
+ noti_err = notification_set_event_handler(noti_handle, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, app_control);
+
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ testapp_print("notification_set_event_handler failed[%d]", noti_err);
+ goto FINISH_OFF;
+ }
+
+ noti_err = notification_post(noti_handle);
+
+ app_control_destroy(app_control);
+ app_control = NULL;
+
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ testapp_print("notification_post failed[%d]", noti_err);
+ goto FINISH_OFF;
+ }
+
+ noti_err = notification_get_id(noti_handle, &group_id, &priv_id);
+
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ testapp_print("notification_get_id failed[%d]", noti_err);
+ goto FINISH_OFF;
+ }
+
+ /*
+ if (noti_handle)
+ notification_free(noti_handle);
+ noti_handle = NULL;
+ */
+
+ noti_handle = notification_load(NULL, priv_id);
+
+ if (noti_handle == NULL) {
+ testapp_print("notification_load failed");
+ goto FINISH_OFF;
+ }
+
+ noti_err = notification_get_event_handler(noti_handle, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, &app_control);
+
+ if (noti_err != NOTIFICATION_ERROR_NONE ||app_control == NULL) {
+ testapp_print("notification_get_event_handler failed[%d]", noti_err);
+ goto FINISH_OFF;
+ }
+
+ app_control_get_app_id(app_control, &app_id);
+
+ if (app_id) {
+ testapp_print("result app_id [%s]", app_id);
+ free(app_id);
+ }
+
+FINISH_OFF:
+
+ if (app_control)
+ app_control_destroy(app_control);
+
+ if (noti_handle)
+ notification_free(noti_handle);
+
+ return noti_err;
+}
static gboolean testapp_interpret_command_basic_test (int selected_number)
{
- gboolean go_to_loop = TRUE;
+ gboolean go_to_loop = TRUE;
- switch (selected_number) {
- case 1:
- testapp_test_post_notification();
- break;
+ switch (selected_number) {
+ case 1:
+ testapp_test_post_notification();
+ break;
- case 2:
- testapp_test_post_notifications();
- break;
+ case 2:
+ testapp_test_post_notifications();
+ break;
- case 3:
- testapp_test_post_notification_on_indicator();
- break;
+ case 3:
+ testapp_test_post_notification_on_indicator();
+ break;
- case 4:
- testapp_test_post_status_message();
- break;
+ case 4:
+ testapp_test_post_status_message();
+ break;
- case 0:
- go_to_loop = FALSE;
- break;
+ case 5:
+ testapp_test_delete_all_notifications();
+ break;
- default:
- break;
- }
+ case 6:
+ testapp_test_post_heads_up_notification_with_button();
+ break;
- return go_to_loop;
+ case 0:
+ go_to_loop = FALSE;
+ break;
+
+ default:
+ break;
+ }
+
+ return go_to_loop;
}
void testapp_notification_main ()
{
- gboolean go_to_loop = TRUE;
- int menu_number = 0;
+ gboolean go_to_loop = TRUE;
+ int menu_number = 0;
- while (go_to_loop) {
- testapp_show_menu (TESTAPP_MENU_TYPE_BASIC_TEST_MENU);
- testapp_show_prompt (TESTAPP_MENU_TYPE_BASIC_TEST_MENU);
+ while (go_to_loop) {
+ testapp_show_menu (TESTAPP_MENU_TYPE_BASIC_TEST_MENU);
+ testapp_show_prompt (TESTAPP_MENU_TYPE_BASIC_TEST_MENU);
- if (0 >= scanf("%d", &menu_number))
- testapp_print("Invalid input");
+ if (0 >= scanf("%d", &menu_number))
+ testapp_print("Invalid input");
- go_to_loop = testapp_interpret_command_basic_test(menu_number);
- }
+ go_to_loop = testapp_interpret_command_basic_test(menu_number);
+ }
}
/* Basic Test } ---------------------------------------------------------------*/
+/* Setting Test } ---------------------------------------------------------------*/
+
+static int testapp_test_get_setting_list()
+{
+ int err = NOTIFICATION_ERROR_NONE;
+ int i = 0;
+ int count = 0;
+ char *package_name = NULL;
+ bool allow_to_notify = false;
+ bool do_not_disturb_except = false;
+ bool visibility_class = false;
+ notification_setting_h setting_array = NULL;
+
+ notification_setting_get_setting_array(&setting_array, &count);
+
+ testapp_print("count [%d]\n", count);
+
+ for (i = 0; i < count; i++) {
+ notification_setting_get_package_name(setting_array + i, &package_name);
+ notification_setting_get_allow_to_notify(setting_array + i, &allow_to_notify);
+ notification_setting_get_do_not_disturb_except(setting_array + i, &do_not_disturb_except);
+ notification_setting_get_visibility_class(setting_array + i, &visibility_class);
+
+ 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);
+ }
+
+ if (setting_array)
+ free(setting_array);
+
+ return err;
+}
+
+static int testapp_test_update_setting()
+{
+ int err = NOTIFICATION_ERROR_NONE;
+ notification_setting_h setting = NULL;
+
+ err = notification_setting_get_setting_by_package_name("org.tizen.internet", &setting);
+
+ if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
+ testapp_print("notification_setting_get_setting_by_package_name failed [%d]", err);
+ }
+ else {
+ notification_setting_set_allow_to_notify(setting, 0);
+ notification_setting_update_setting(setting);
+ }
+}
+
+static gboolean testapp_interpret_command_setting_test (int selected_number)
+{
+ gboolean go_to_loop = TRUE;
+
+ switch (selected_number) {
+ case 1:
+ testapp_test_get_setting_list();
+ break;
+
+ case 2:
+ testapp_test_update_setting();
+ break;
+
+ case 0:
+ go_to_loop = FALSE;
+ break;
+
+ default:
+ break;
+ }
+
+ return go_to_loop;
+
+}
+
+void testapp_setting_main()
+{
+ gboolean go_to_loop = TRUE;
+ int menu_number = 0;
+
+ while (go_to_loop) {
+ testapp_show_menu (TESTAPP_MENU_TYPE_SETTING_TEST_MENU);
+ testapp_show_prompt (TESTAPP_MENU_TYPE_SETTING_TEST_MENU);
+
+ if (0 >= scanf("%d", &menu_number))
+ testapp_print("Invalid input");
+
+ go_to_loop = testapp_interpret_command_setting_test(menu_number);
+ }
+}
+/* Setting Test } ---------------------------------------------------------------*/
/* Main { ---------------------------------------------------------------------*/
static gboolean testapp_interpret_command (int menu_number)
testapp_notification_main();
break;
+ case 2:
+ testapp_setting_main();
+ break;
+
case 0:
go_to_loop = FALSE;
break;
void testapp_show_prompt (testapp_menu_type_e menu)
{
- switch (menu) {
- case TESTAPP_MENU_TYPE_MAIN_MENU:
- testapp_print ("[MAIN]# ");
- break;
-
- case TESTAPP_MENU_TYPE_BASIC_TEST_MENU:
- testapp_print ("[BASIC_TEST]# ");
- break;
- }
+ switch (menu) {
+ case TESTAPP_MENU_TYPE_MAIN_MENU:
+ testapp_print ("[MAIN]# ");
+ break;
+
+ case TESTAPP_MENU_TYPE_BASIC_TEST_MENU:
+ testapp_print ("[BASIC_TEST]# ");
+ break;
+
+ case TESTAPP_MENU_TYPE_SETTING_TEST_MENU:
+ testapp_print ("[SETTING_TEST]# ");
+ break;
+ }
}
int main (int argc, char *argv[])