Add event for do not show again for test 57/278457/7
authorSukhyungKang <shine.kang@samsung.com>
Wed, 20 Jul 2022 23:33:33 +0000 (08:33 +0900)
committerSukhyungKang <shine.kang@samsung.com>
Tue, 9 May 2023 07:34:28 +0000 (16:34 +0900)
Change-Id: I4113169894c842499bf80f30a890607b429e37d6
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
notification/include/notification_internal.h
notification/include/notification_type_internal.h
notification/src/notification_internal.c

index 9199eb5..b2996ea 100644 (file)
@@ -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);
+
+
 /**
  * @}
  */
index cd93858..b08a516 100644 (file)
@@ -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;
 
 /**
index f4b3fc1..f4c36f1 100644 (file)
@@ -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;
+}