summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSukhyungKang <shine.kang@samsung.com>2022-07-21 08:33:33 +0900
committerSukhyungKang <shine.kang@samsung.com>2023-05-09 16:34:28 +0900
commit70748d854d62f9024cfb343ed3d8e0cdd8787a22 (patch)
tree5dd399469db735b1fd713cae7f09c7599f0dd352
parent7eafa40028945618969df23c4b51aee7fb560eb0 (diff)
downloadnotification-70748d854d62f9024cfb343ed3d8e0cdd8787a22.tar.gz
notification-70748d854d62f9024cfb343ed3d8e0cdd8787a22.tar.bz2
notification-70748d854d62f9024cfb343ed3d8e0cdd8787a22.zip
Add event for do not show again for test
Change-Id: I4113169894c842499bf80f30a890607b429e37d6 Signed-off-by: SukhyungKang <shine.kang@samsung.com>
-rw-r--r--notification/include/notification_internal.h4
-rw-r--r--notification/include/notification_type_internal.h1
-rw-r--r--notification/src/notification_internal.c73
3 files changed, 76 insertions, 2 deletions
diff --git a/notification/include/notification_internal.h b/notification/include/notification_internal.h
index 9199eb5..b2996ea 100644
--- a/notification/include/notification_internal.h
+++ b/notification/include/notification_internal.h
@@ -1497,6 +1497,10 @@ int notification_set_indirect_request(notification_h noti, pid_t pid, uid_t uid)
int notification_delete_by_display_applist(int display_applist);
int notification_delete_by_display_applist_for_uid(int display_applist, uid_t uid);
+int notification_set_do_not_show_again(notification_h noti, bool flag);
+int notification_get_do_not_show_again(notification_h noti, bool* flag);
+
+
/**
* @}
*/
diff --git a/notification/include/notification_type_internal.h b/notification/include/notification_type_internal.h
index cd93858..b08a516 100644
--- a/notification/include/notification_type_internal.h
+++ b/notification/include/notification_type_internal.h
@@ -72,6 +72,7 @@ typedef enum _notification_event_type_extension {
NOTIFICATION_EVENT_TYPE_HIDDEN_BY_EXTERNAL = 102, /**< Hidden by external */
NOTIFICATION_EVENT_TYPE_PRESSED = 200, /**< Pressed by user */
NOTIFICATION_EVENT_TYPE_DELETED = 201, /**< Deleted by user */
+ NOTIFICATION_EVENT_TYPE_DO_NOT_SHOW_AGAIN = 300, /**< Do not show again */
} notification_event_type_extension_e;
/**
diff --git a/notification/src/notification_internal.c b/notification/src/notification_internal.c
index f4b3fc1..f4c36f1 100644
--- a/notification/src/notification_internal.c
+++ b/notification/src/notification_internal.c
@@ -1722,7 +1722,8 @@ EXPORT_API int notification_send_event(notification_h noti, int event_type)
(event_type >= NOTIFICATION_EVENT_TYPE_HIDDEN_BY_USER
&& event_type <= NOTIFICATION_EVENT_TYPE_HIDDEN_BY_EXTERNAL) ||
(event_type >= NOTIFICATION_EVENT_TYPE_PRESSED
- && event_type <= NOTIFICATION_EVENT_TYPE_DELETED)))
+ && event_type <= NOTIFICATION_EVENT_TYPE_DELETED) ||
+ (event_type == NOTIFICATION_EVENT_TYPE_DO_NOT_SHOW_AGAIN)))
return NOTIFICATION_ERROR_INVALID_PARAMETER;
ret = notification_get_event_flag(noti, &event_flag);
@@ -1746,7 +1747,8 @@ EXPORT_API int notification_send_event_by_priv_id(int priv_id, int event_type)
(event_type >= NOTIFICATION_EVENT_TYPE_HIDDEN_BY_USER
&& event_type <= NOTIFICATION_EVENT_TYPE_HIDDEN_BY_EXTERNAL) ||
(event_type >= NOTIFICATION_EVENT_TYPE_PRESSED
- && event_type <= NOTIFICATION_EVENT_TYPE_DELETED)))
+ && event_type <= NOTIFICATION_EVENT_TYPE_DELETED) ||
+ (event_type == NOTIFICATION_EVENT_TYPE_DO_NOT_SHOW_AGAIN)))
return NOTIFICATION_ERROR_INVALID_PARAMETER;
ret = notification_ipc_send_event(NULL, event_type, priv_id);
@@ -2132,3 +2134,70 @@ EXPORT_API int notification_delete_by_display_applist(int display_applist)
{
return notification_delete_by_display_applist_for_uid(display_applist, getuid());
}
+
+EXPORT_API int notification_set_do_not_show_again(notification_h noti,
+ bool flag)
+{
+ int err;
+ int ret = NOTIFICATION_ERROR_NONE;
+ char key[KEY_LEN];
+ char *del = NULL;
+
+ if (noti == NULL) {
+ ERR("Invalid parameter");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (noti->args == NULL)
+ noti->args = bundle_create();
+
+ snprintf(key, sizeof(key), "%s%d", EXTENSION_EVENT_KEY,
+ NOTIFICATION_EVENT_TYPE_DO_NOT_SHOW_AGAIN);
+ bundle_get_str(noti->args, key, &del);
+ if (del != NULL) {
+ bundle_del(noti->args, key);
+ del = NULL;
+ }
+
+ if (flag)
+ err = bundle_add_str(noti->args, key, "true");
+ else
+ err = bundle_add_str(noti->args, key, "false");
+
+ if (err != BUNDLE_ERROR_NONE) {
+ ERR("Failed to add str to bundle [%d]", err);
+ return NOTIFICATION_ERROR_IO_ERROR;
+ }
+
+ return ret;
+}
+
+EXPORT_API int notification_get_do_not_show_again(notification_h noti,
+ bool* flag)
+{
+ int err;
+ int ret = NOTIFICATION_ERROR_NONE;
+ char *ret_str = NULL;
+ char key[KEY_LEN];
+
+ if (noti == NULL) {
+ ERR("Invalid parameter");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(key, sizeof(key), "%s%d", EXTENSION_EVENT_KEY,
+ NOTIFICATION_EVENT_TYPE_DO_NOT_SHOW_AGAIN);
+
+ bundle_get_str(noti->args, key, &ret_str);
+ if (ret_str == NULL) {
+ ERR("No key");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (strncmp("true", ret_str, 4) == 0)
+ *flag = true;
+ else
+ *flag = false;
+
+ return ret;
+}