summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseungha.son <seungha.son@samsung.com>2017-03-21 10:40:36 +0900
committerSon seungha <seungha.son@samsung.com>2017-03-22 01:54:35 -0700
commit9fbe062b58dc473b1e5a5503c417d71cb31cb17d (patch)
tree9d7074cc6774b391b682d8abf3f6b782c5868bee
parent81a451dbf3cd77c78bdf5c9f91a2b3ec600224ab (diff)
downloadnotification-9fbe062b58dc473b1e5a5503c417d71cb31cb17d.tar.gz
notification-9fbe062b58dc473b1e5a5503c417d71cb31cb17d.tar.bz2
notification-9fbe062b58dc473b1e5a5503c417d71cb31cb17d.zip
Add internal API to support C# API
- notification_send_event_by_priv_id - notification_set_extention_data - notification_get_extention_data Signed-off-by: seungha.son <seungha.son@samsung.com> Change-Id: I25e88295a0776c63982849a8a6ca27f3a34df18b
-rwxr-xr-xinclude/notification_internal.h4
-rwxr-xr-xinclude/notification_ipc.h2
-rw-r--r--include/notification_noti.h2
-rwxr-xr-xsrc/notification_internal.c90
-rwxr-xr-xsrc/notification_ipc.c20
-rwxr-xr-xsrc/notification_noti.c10
6 files changed, 110 insertions, 18 deletions
diff --git a/include/notification_internal.h b/include/notification_internal.h
index d72b16d..0f8c078 100755
--- a/include/notification_internal.h
+++ b/include/notification_internal.h
@@ -1213,6 +1213,7 @@ int notification_post_with_event_cb_for_uid(notification_h noti, event_handler_c
* @endcode
*/
int notification_send_event(notification_h noti, int event_type);
+int notification_send_event_by_priv_id(int priv_id, int event_type);
/**
* @brief Gets the event flag.
@@ -1342,6 +1343,9 @@ notification_h notification_create_from_package_template(const char *pkgname,
*/
int notification_get_text_input_max_length(notification_h noti, int *text_input_max_length);
+int notification_set_extention_data(notification_h noti, const char *key, bundle *value);
+int notification_get_extention_data(notification_h noti, const char *key, bundle **value);
+
/**
* @}
*/
diff --git a/include/notification_ipc.h b/include/notification_ipc.h
index 36a83a8..bd90155 100755
--- a/include/notification_ipc.h
+++ b/include/notification_ipc.h
@@ -95,7 +95,7 @@ GVariant *notification_ipc_make_gvariant_from_dnd_allow_exception(
int notification_ipc_make_dnd_allow_exception_from_gvariant(
struct notification_system_setting_dnd_allow_exception *dnd_allow_exception,
GVariant *variant);
-int notification_ipc_send_event(notification_h noti, int event_type);
+int notification_ipc_send_event(notification_h noti, int event_type, int priv_id);
int notification_ipc_check_event_receiver(int priv_id, bool *available);
void notification_ipc_reset_event_handler(int priv_id);
#ifdef __cplusplus
diff --git a/include/notification_noti.h b/include/notification_noti.h
index bdef709..6d0c8f3 100644
--- a/include/notification_noti.h
+++ b/include/notification_noti.h
@@ -38,7 +38,7 @@ int notification_noti_update(notification_h noti);
int notification_noti_delete_all(notification_type_e type, const char *pkgname, int *num_deleted, int **list_deleted_rowid, uid_t uid);
-int notification_noti_get_by_priv_id(notification_h noti, char *pkgname, int priv_id, uid_t uid);
+int notification_noti_get_by_priv_id(notification_h noti, int priv_id);
int notification_noti_get_by_tag(notification_h noti, char *pkgname, char* tag, uid_t uid);
int notification_noti_delete_by_priv_id(const char *pkgname, int priv_id);
diff --git a/src/notification_internal.c b/src/notification_internal.c
index c9fe8a5..c6b2384 100755
--- a/src/notification_internal.c
+++ b/src/notification_internal.c
@@ -31,6 +31,8 @@
#include <tizen.h>
#include <vconf-keys.h>
#include <vconf.h>
+#include <bundle.h>
+#include <bundle_internal.h>
#include <notification.h>
#include <notification_list.h>
@@ -1629,11 +1631,30 @@ EXPORT_API int notification_send_event(notification_h noti, int event_type)
if (ret != NOTIFICATION_ERROR_NONE || event_flag == false)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
- ret = notification_ipc_send_event(noti, event_type);
+ ret = notification_ipc_send_event(noti, event_type, -1);
return ret;
}
+EXPORT_API int notification_send_event_by_priv_id(int priv_id, int event_type)
+{
+ int ret;
+
+ if (priv_id <= 0)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ if (!((event_type >= NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
+ && event_type < NOTIFICATION_EVENT_TYPE_MAX) ||
+ (event_type >= NOTIFICATION_EVENT_TYPE_HIDDEN_BY_USER
+ && event_type <= NOTIFICATION_EVENT_TYPE_HIDDEN_BY_TIMEOUT) ||
+ (event_type >= NOTIFICATION_EVENT_TYPE_PRESSED
+ && event_type <= NOTIFICATION_EVENT_TYPE_DELETED)))
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ ret = notification_ipc_send_event(NULL, event_type, priv_id);
+ return ret;
+}
+
EXPORT_API int notification_get_event_flag(notification_h noti, bool *flag)
{
if (noti == NULL || flag == NULL)
@@ -1662,3 +1683,70 @@ EXPORT_API int notification_check_event_receiver_available(notification_h noti,
return ret;
}
+
+static bundle *_create_bundle_from_bundle_raw(bundle_raw *string)
+{
+ if (string == NULL || string[0] == '\0')
+ return NULL;
+
+ return bundle_decode(string, strlen((char *)string));
+}
+
+EXPORT_API int notification_set_extention_data(notification_h noti, const char *key, bundle *value)
+{
+ int ret;
+ int len = 0;
+ char *del = NULL;
+ bundle_raw *raw = NULL;
+
+ if (noti == NULL || key == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ if (noti->args == NULL)
+ noti->args = bundle_create();
+
+ if (value == NULL) {
+ ret = bundle_del(noti->args, key);
+ if (ret == BUNDLE_ERROR_NONE)
+ return NOTIFICATION_ERROR_NONE;
+ else
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ }
+
+ bundle_get_str(noti->args, key, &del);
+ if (del != NULL) {
+ bundle_del(noti->args, key);
+ del = NULL;
+ }
+
+ bundle_encode(value, &raw, &len);
+ bundle_add_str(noti->args, key, (const char *)raw);
+ bundle_free_encoded_rawdata(&raw);
+
+ return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_extention_data(notification_h noti, const char *key, bundle **value)
+{
+ char *ret_str;
+ bundle *args;
+
+ if (noti == NULL || key == NULL || value == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ if (noti->args == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ args = noti->args;
+
+ bundle_get_str(args, key, &ret_str);
+ if (ret_str == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ *value = _create_bundle_from_bundle_raw((bundle_raw *)ret_str);
+ if (*value == NULL)
+ return NOTIFICATION_ERROR_IO_ERROR;
+
+ return NOTIFICATION_ERROR_NONE;
+}
diff --git a/src/notification_ipc.c b/src/notification_ipc.c
index dbb22e5..f97dd7d 100755
--- a/src/notification_ipc.c
+++ b/src/notification_ipc.c
@@ -1642,7 +1642,7 @@ int notification_ipc_get_noti_block_state(const char *pkgname, int *do_not_distu
return ret;
}
-int notification_ipc_send_event(notification_h noti, int event_type)
+int notification_ipc_send_event(notification_h noti, int event_type, int priv_id)
{
int ret;
GVariant *body = NULL;
@@ -1654,13 +1654,17 @@ int notification_ipc_send_event(notification_h noti, int event_type)
return ret;
}
- body = notification_ipc_make_gvariant_from_noti(noti, false);
- if (body == NULL) {
- NOTIFICATION_ERR("Can't make gvariant to noti");
- return NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
+ if (priv_id > 0) {
+ ret = _send_sync_noti(g_variant_new("(ii)", priv_id, event_type), &reply, "send_noti_event_by_priv_id");
+ } else {
+ body = notification_ipc_make_gvariant_from_noti(noti, false);
+ if (body == NULL) {
+ NOTIFICATION_ERR("Can't make gvariant to noti");
+ return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
- ret = _send_sync_noti(g_variant_new("(vi)", body, event_type), &reply, "send_noti_event");
+ ret = _send_sync_noti(g_variant_new("(vi)", body, event_type), &reply, "send_noti_event");
+ }
if (reply)
g_object_unref(reply);
@@ -1747,7 +1751,7 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not
g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_DISPLAY_APPLIST, g_variant_new_int32(noti->display_applist));
if (noti->args) {
- bundle_encode(noti->args, (bundle_raw **)&args, NULL);
+ bundle_encode(noti->args, (bundle_raw **)&args, &b_encode_len);
g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_ARGS, g_variant_new_string((const gchar *)args));
if (args)
diff --git a/src/notification_noti.c b/src/notification_noti.c
index 45804df..2ee1b97 100755
--- a/src/notification_noti.c
+++ b/src/notification_noti.c
@@ -1038,7 +1038,7 @@ err:
}
/* LCOV_EXCL_START */
-EXPORT_API int notification_noti_get_by_priv_id(notification_h noti, char *pkgname, int priv_id, uid_t uid)
+EXPORT_API int notification_noti_get_by_priv_id(notification_h noti, int priv_id)
{
int ret = 0;
char *query = NULL;
@@ -1066,13 +1066,9 @@ EXPORT_API int notification_noti_get_by_priv_id(notification_h noti, char *pkgna
"flags_for_property, display_applist, progress_size, progress_percentage, ongoing_flag, ongoing_value_type, "
"ongoing_current, ongoing_duration, auto_remove, default_button_index, hide_timeout, delete_timeout, "
"text_input_max_length, event_flag, extension_image_size, uid "
- "from noti_list ";
+ "from noti_list";
- if (pkgname != NULL && strlen(pkgname) != 0)
- query = sqlite3_mprintf("%s where caller_pkgname = '%s' and priv_id = %d and uid = %d",
- base_query, pkgname, priv_id, uid);
- else
- query = sqlite3_mprintf("%s where priv_id = %d and uid = %d", base_query, priv_id, uid);
+ query = sqlite3_mprintf("%s where priv_id = %d", base_query, priv_id);
if (query == NULL) {
ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;