Add api to set/get checkbox 12/293912/9
authorSukhyungKang <shine.kang@samsung.com>
Thu, 8 Jun 2023 04:49:06 +0000 (13:49 +0900)
committerSukhyungKang <shine.kang@samsung.com>
Mon, 12 Jun 2023 22:42:34 +0000 (07:42 +0900)
Change-Id: I5337c49a7c10ea23ac5d7ea460154cb31b755bb9
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
notification/include/notification_internal.h
notification/include/notification_private.h
notification/include/notification_type_internal.h
notification/src/notification.c
notification/src/notification_db_query.h
notification/src/notification_internal.c
notification/src/notification_ipc.c
notification/src/notification_noti.c
notification/test-app/main.c
scripts/505.notification_upgrade.sh

index b2996ea..01080cc 100644 (file)
@@ -1497,8 +1497,11 @@ 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);
+int notification_set_check_box(notification_h noti, bool flag, bool checked);
+int notification_get_check_box(notification_h noti, bool *flag, bool *checked);
+
+int notification_set_check_box_checked(notification_h noti, bool checked);
+int notification_get_check_box_checked(notification_h noti, bool *checked);
 
 
 /**
index ef0d80e..4b72183 100644 (file)
@@ -106,6 +106,9 @@ struct _notification {
        bool is_translation;
        int extension_image_size;
 
+       bool check_box;                         /* check box flag */
+       bool check_box_value;           /* check box value */
+
        uid_t uid;
 };
 
@@ -178,6 +181,8 @@ typedef enum notification_data_type {
        NOTIFICATION_DATA_TYPE_EVENT_FLAG,
        NOTIFICATION_DATA_TYPE_TRANSLATION,
        NOTIFICATION_DATA_TYPE_EXTENSION_IMAGE_SIZE,
+       NOTIFICATION_DATA_TYPE_CHECK_BOX,
+       NOTIFICATION_DATA_TYPE_CHECK_BOX_VALUE,
        NOTIFICATION_DATA_TYPE_UID,
 } notification_data_type_e;
 
index b08a516..58a603f 100644 (file)
@@ -72,7 +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_CHECK_BOX = 300, /**< Do not show again */
 } notification_event_type_extension_e;
 
 /**
index 04b0063..5db51a1 100644 (file)
@@ -1509,6 +1509,9 @@ static notification_h _notification_create(notification_type_e type)
                goto out;
        }
 
+       noti->check_box = false;
+       noti->check_box_value = false;
+
        if (getuid() < REGULAR_UID_MIN) {
                noti->pkg_id = strdup(noti->caller_app_id);
                if (noti->pkg_id == NULL)
@@ -1762,6 +1765,9 @@ EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
 
        new_noti->uid = noti->uid;
 
+       new_noti->check_box = noti->check_box;
+       new_noti->check_box_value = noti->check_box_value;
+
        *clone = new_noti;
 
        return NOTIFICATION_ERROR_NONE;
index dd6a65a..9b0fd96 100644 (file)
@@ -89,7 +89,9 @@
        "  text_input_max_length INTEGER DEFAULT 0,\n" \
        "  event_flag INTEGER DEFAULT 0,\n" \
        "  extension_image_size INTEGER DEFAULT 0,\n" \
-       "  uid INTEGER );\n" \
+       "  uid INTEGER,\n" \
+       "  check_box INTEGER DEFAULT 0,\n" \
+       "  check_box_value INTEGER DEFAULT 0 );\n" \
        "CREATE TABLE IF NOT EXISTS noti_group_data (\n" \
        "  caller_app_id TEXT NOT NULL,\n" \
        "  group_id INTEGER DEFAULT 0,\n" \
        "  event_flag INTEGER DEFAULT 0,\n" \
        "  extension_image_size INTEGER DEFAULT 0,\n" \
        "  uid INTEGER,\n" \
+       "  check_box INTEGER DEFAULT 0,\n" \
+       "  check_box_value INTEGER DEFAULT 0,\n" \
        "  template_name TEXT,\n" \
        "  UNIQUE (caller_app_id, template_name));\n"
 
        "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"
+       "extension_image_size, uid, check_box, check_box_value"
 
 #define NOTI_LIST_DB_ATTRIBUTES_INSERT \
        "type, layout, pkg_id, caller_app_id, launch_app_id, app_label, " \
        "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"
+       "extension_image_size, uid, check_box, check_box_value"
 
 #define NOTI_LIST_INSERT_VALUES \
        "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " \
        "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " \
        "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " \
-       "?, ?, ?, ?, ?, ? "
+       "?, ?, ?, ?, ?, ?, ?, ? "
 
 #define NOTI_LIST_DB_ATTRIBUTES_UPDATE \
        "type = ?, layout = ?, launch_app_id = ?, app_label = ?, " \
        "ongoing_current = ?, ongoing_duration = ?, " \
        "auto_remove = ?, default_button_index = ?, " \
        "hide_timeout = ?, delete_timeout = ?, " \
-       "text_input_max_length = ?, event_flag = ?, extension_image_size = ? "
+       "text_input_max_length = ?, event_flag = ?, extension_image_size = ?, " \
+       "check_box = ?, check_box_value = ? "
 
 #define NOTIFICATION_SETTING_DB_ATTRIBUTES \
        "package_name, app_id, allow_to_notify, do_not_disturb_except, "\
index f4c36f1..8c2e359 100644 (file)
@@ -1723,7 +1723,7 @@ EXPORT_API int notification_send_event(notification_h noti, int event_type)
                && 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_DO_NOT_SHOW_AGAIN)))
+               (event_type == NOTIFICATION_EVENT_TYPE_CHECK_BOX)))
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
        ret = notification_get_event_flag(noti, &event_flag);
@@ -1748,7 +1748,7 @@ EXPORT_API int notification_send_event_by_priv_id(int priv_id, int event_type)
                && 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_DO_NOT_SHOW_AGAIN)))
+               (event_type == NOTIFICATION_EVENT_TYPE_CHECK_BOX)))
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
        ret = notification_ipc_send_event(NULL, event_type, priv_id);
@@ -2135,69 +2135,59 @@ 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)
+EXPORT_API int notification_set_check_box(notification_h noti,
+               bool flag, bool checked)
 {
-       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;
-       }
+       noti->check_box = flag;
+       noti->check_box_value = checked;
 
-       if (flag)
-               err = bundle_add_str(noti->args, key, "true");
-       else
-               err = bundle_add_str(noti->args, key, "false");
+       return NOTIFICATION_ERROR_NONE;
+}
 
-       if (err != BUNDLE_ERROR_NONE) {
-               ERR("Failed to add str to bundle [%d]", err);
-               return NOTIFICATION_ERROR_IO_ERROR;
+EXPORT_API int notification_get_check_box(notification_h noti,
+               bool *flag, bool *checked)
+{
+       if (noti == NULL || flag == NULL || checked == NULL) {
+               ERR("Invalid parameter");
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
        }
 
-       return ret;
+       *flag = noti->check_box;
+       *checked = noti->check_box_value;
+
+       return NOTIFICATION_ERROR_NONE;
 }
 
-EXPORT_API int notification_get_do_not_show_again(notification_h noti,
-               bool* flag)
+EXPORT_API int notification_set_check_box_checked(notification_h noti,
+               bool checked)
 {
-       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);
+       noti->check_box_value = checked;
 
-       bundle_get_str(noti->args, key, &ret_str);
-       if (ret_str == NULL) {
-               ERR("No key");
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_check_box_checked(notification_h noti,
+               bool *checked)
+{
+       if (noti == NULL || checked == NULL) {
+               ERR("Invalid parameter");
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
        }
 
-       if (strncmp("true", ret_str, 4) == 0)
-               *flag = true;
+       if (noti->check_box)
+               *checked = noti->check_box_value;
        else
-               *flag = false;
+               *checked = false;
 
-       return ret;
+       return NOTIFICATION_ERROR_NONE;
 }
index 2c2a5cf..c97dcd9 100644 (file)
@@ -2210,6 +2210,8 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not
        g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_EVENT_FLAG, g_variant_new_int32(noti->event_flag));
        g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_TRANSLATION, g_variant_new_int32(noti->is_translation));
        g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_EXTENSION_IMAGE_SIZE, g_variant_new_int32(noti->extension_image_size));
+       g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_CHECK_BOX, g_variant_new_int32(noti->check_box));
+       g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_CHECK_BOX_VALUE, g_variant_new_int32(noti->check_box_value));
        g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_UID, g_variant_new_int32(noti->uid));
 
        result_body = g_variant_builder_end(&builder);
@@ -2382,6 +2384,8 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti,
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_EVENT_FLAG, "i", &noti->event_flag);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TRANSLATION, "i", &noti->is_translation);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_EXTENSION_IMAGE_SIZE, "i", &noti->extension_image_size);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_CHECK_BOX, "i", &noti->check_box);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_CHECK_BOX_VALUE, "i", &noti->check_box_value);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_UID, "i", &noti->uid);
 
        if (noti->pkg_id)
index df0455e..f91eded 100644 (file)
@@ -139,6 +139,8 @@ static void __notification_noti_populate_from_stmt(sqlite3_stmt *stmt, notificat
        noti->event_flag = sqlite3_column_int(stmt, col++);
        noti->extension_image_size = sqlite3_column_int(stmt, col++);
        noti->uid = sqlite3_column_int(stmt, col++);
+       noti->check_box = sqlite3_column_int(stmt, col++);
+       noti->check_box_value = sqlite3_column_int(stmt, col++);
 
        noti->app_icon_path = NULL;
        noti->temp_title = NULL;
@@ -403,6 +405,8 @@ static int _create_insertion_query(sqlite3 *db, notification_h noti, sqlite3_stm
        __BIND_INT(db, stmt, idx++, noti->event_flag, ret, out);
        __BIND_INT(db, stmt, idx++, noti->extension_image_size, ret, out);
        __BIND_INT(db, stmt, idx++, noti->uid, ret, out);
+       __BIND_INT(db, stmt, idx++, noti->check_box, ret, out);
+       __BIND_INT(db, stmt, idx++, noti->check_box_value, ret, out);
 
 out:
        __free_encoded_data(b_image_path);
index f410beb..cd48ee5 100644 (file)
@@ -215,6 +215,9 @@ static int testapp_add_a_notification_to_bob()
        noti_err  = notification_set_ongoing_flag(noti_handle, true);
        noti_err  = notification_set_auto_remove(noti_handle, false);
 
+       noti_err  = notification_set_check_box(noti_handle, true, false);
+       noti_err  = notification_set_check_box_checked(noti_handle, true);
+
        noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_INDICATOR | NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER);
 
        noti_err  = notification_post_for_uid(noti_handle, 5002);
@@ -257,6 +260,9 @@ static int testapp_add_a_notification()
        noti_err  = notification_set_ongoing_flag(noti_handle, true);
        noti_err  = notification_set_auto_remove(noti_handle, false);
 
+       noti_err  = notification_set_check_box(noti_handle, true, false);
+       noti_err  = notification_set_check_box_checked(noti_handle, true);
+
        noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_INDICATOR | NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER);
 
        noti_err  = notification_post(noti_handle);
@@ -575,6 +581,8 @@ static int testapp_test_get_list()
        int type;
        bool ongoing_flag;
        bool auto_remove;
+       bool check_box;
+       bool checked;
 
        noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, &noti_list_handle);
 
@@ -592,7 +600,11 @@ static int testapp_test_get_list()
                notification_get_ongoing_flag(noti_handle, &ongoing_flag);
                notification_get_auto_remove(noti_handle, &auto_remove);
 
-               testapp_print("priv_id[%d] type[%d] ongoing_flag[%d] auto_remove[%d]\n", priv_id, type, ongoing_flag, auto_remove);
+               notification_get_check_box(noti_handle, &check_box, &checked);
+               notification_get_check_box_checked(noti_handle, &checked);
+
+               testapp_print("priv_id[%d] type[%d] ongoing_flag[%d] auto_remove[%d] check_box[%d] checked[%d]\n",
+                               priv_id, type, ongoing_flag, auto_remove, check_box, checked);
                noti_list_cursor_handle = notification_list_get_next(noti_list_cursor_handle);
        }
 
index b113738..95ed350 100644 (file)
@@ -1,8 +1,8 @@
 #!/bin/sh
 
-#------------------------------------------#
-# notification patch for upgrade (4.0 -> 5.x) #
-#------------------------------------------#
+#----------------------------------------------------#
+# notification patch for upgrade (7.0 -> 8.0) #
+#----------------------------------------------------#
 
 # Macro
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
@@ -13,9 +13,11 @@ DB_NOTIFICATION=$DB_DIR/.notification.db
 CheckListTable() {
   ADDED_COLUMN=`sqlite3 $DB_NOTIFICATION 'PRAGMA table_info(noti_list)' | grep b_event_handler_click_on_button_7`
 
+  CHECKBOX_COLUMN=`sqlite3 $DB_NOTIFICATION 'PRAGMA table_info(noti_list)' | grep check_box`
+
   echo "## Check list table"
 
-  if [ -z "${ADDED_COLUMN}" ]; then
+  if [ -z "${ADDED_COLUMN}" ] || [ -z "${CHECKBOX_COLUMN}"]; then
     echo "column empty"
     return 1
   else
@@ -27,9 +29,11 @@ CheckListTable() {
 CheckTemplateTable() {
   ADDED_COLUMN=`sqlite3 $DB_NOTIFICATION 'PRAGMA table_info(noti_template)' | grep template_name`
 
+  CHECKBOX_COLUMN=`sqlite3 $DB_NOTIFICATION 'PRAGMA table_info(noti_template)' | grep check_box`
+
   echo "## Check template table"
 
-  if [ -z "${ADDED_COLUMN}" ]; then
+  if [ -z "${ADDED_COLUMN}" ] || [ -z "${CHECKBOX_COLUMN}"]; then
     echo "column empty"
     return 1
   else
@@ -109,7 +113,9 @@ CREATE TABLE noti_list_temp (
        text_input_max_length INTEGER default 0,
        event_flag INTEGER default 0,
        extension_image_size INTEGER default 0,
-       uid INTEGER
+       uid INTEGER,
+       check_box INTEGER DEFAULT 0,
+       check_box_value INTEGER DEFAULT 0
 );
 INSERT INTO noti_list_temp (type, layout, pkg_id, caller_app_id, launch_app_id, image_path, priv_image_path, group_id, internal_group_id, priv_id, title_key, b_text, b_key, tag, 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, b_event_handler_click_on_text_input_button, sound_type, sound_path, priv_sound_path, vibration_type, vibration_path, priv_vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, flags_for_property, flag_simmode, 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) \
 SELECT type, layout, pkg_id, caller_app_id, launch_app_id, image_path, priv_image_path, group_id, internal_group_id, priv_id, title_key, b_text, b_key, tag, 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, b_event_handler_click_on_text_input_button, sound_type, sound_path, priv_sound_path, vibration_type, vibration_path, priv_vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, flags_for_property, flag_simmode, 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;
@@ -190,6 +196,8 @@ CREATE TABLE noti_template_temp (
        event_flag INTEGER default 0,
        extension_image_size INTEGER default 0,
        uid INTEGER,
+       check_box INTEGER DEFAULT 0,
+       check_box_value INTEGER DEFAULT 0,
        template_name TEXT,
        UNIQUE (caller_app_id, template_name)
 );