From 6c57c184172a34a771ba188b05d0ba5e1d9a0b27 Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Wed, 7 Sep 2016 17:36:49 +0900 Subject: Add notification hide event type and get/set hide time API Signed-off-by: seungha.son Change-Id: Ie7ac962016cd0d0cfe23d28e01e05347d5c369da --- include/notification_internal.h | 78 +++++++++++++++++++++++++++++++++++++++-- include/notification_private.h | 2 ++ src/notification.c | 2 ++ src/notification_db.c | 2 ++ src/notification_internal.c | 20 +++++++++++ src/notification_ipc.c | 2 ++ src/notification_noti.c | 11 +++--- 7 files changed, 111 insertions(+), 6 deletions(-) diff --git a/include/notification_internal.h b/include/notification_internal.h index a12d443..e90cd7d 100644 --- a/include/notification_internal.h +++ b/include/notification_internal.h @@ -36,6 +36,11 @@ typedef enum _notification_ongoing_value_type { NOTIFICATION_ONGOING_VALUE_TYPE_TIME, } notification_ongoing_value_type_e; +typedef enum _notification_event_type_extension { + NOTIFICATION_EVENT_TYPE_HIDDEN_BY_USER = 100, + NOTIFICATION_EVENT_TYPE_HIDDEN_BY_TIMEOUT = 101, +} notification_event_type_extension_e; + /** * @addtogroup NOTIFICATION_INTERNAL * @{ @@ -916,7 +921,7 @@ int notification_set_ongoing_value_type(notification_h noti, notification_ongoin } * @endcode */ -EXPORT_API int nofication_get_ongoing_time(notification_h noti, int *current, int *duration); +int nofication_get_ongoing_time(notification_h noti, int *current, int *duration); /** * @brief Sets the notification ongoing time when ongoint type value is set NOTIFICATION_ONGOING_VALUE_TYPE_TIME. @@ -956,7 +961,76 @@ EXPORT_API int nofication_get_ongoing_time(notification_h noti, int *current, in } * @endcode */ -EXPORT_API int nofication_set_ongoing_time(notification_h noti, int current, int duration); +int nofication_set_ongoing_time(notification_h noti, int current, int duration); + +/** + * @brief Gets the time that notification is hidden. + * @since_tizen 3.0 + * @param[in] noti The notification handle + * @param[out] timeout The timeout time + * @return #NOTIFICATION_ERROR_NONE on success, + * otherwise any other value on failure + * @retval #NOTIFICATION_ERROR_NONE Success + * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter + * @pre Notification handle should be created by notification_create(). + * @see #notification_event_type_extension_e + * @par Sample code: + * @code +#include +... +{ + notification_h noti = NULL; + int noti_err = NOTIFICATION_ERROR_NONE; + int timeout; + + noti = notification_create(NOTIFICATION_TYPE_NOTI); + if (noti == NULL) { + return; + } + + noti_err = notification_get_hide_timeout(noti, &timeout) + if (noti_err != NOTIFICATION_ERROR_NONE) { + notification_free(noti); + return; + } +} + * @endcode + */ +int nofication_get_hide_timeout(notification_h noti, int *timeout); + +/** + * @brief Sets the time that notification is hidden. + * @since_tizen 3.0 + * @param[in] noti The notification handle + * @param[in] timeout The timeout time + * @return #NOTIFICATION_ERROR_NONE on success, + * otherwise any other value on failure + * @retval #NOTIFICATION_ERROR_NONE Success + * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter + * @pre Notification handle should be created by notification_create(). + * @see #notification_event_type_extension_e + * @par Sample code: + * @code +#include +... +{ + notification_h noti = NULL; + int noti_err = NOTIFICATION_ERROR_NONE; + + noti = notification_create(NOTIFICATION_TYPE_NOTI); + if (noti == NULL) { + return; + } + + noti_err = notification_set_hide_timeout(noti, 10) + if (noti_err != NOTIFICATION_ERROR_NONE) { + notification_free(noti); + return; + } +} + * @endcode + */ +int nofication_set_hide_timeout(notification_h noti, int timeout); /** * @brief This function translate localized texts diff --git a/include/notification_private.h b/include/notification_private.h index ee908b6..f895b9b 100644 --- a/include/notification_private.h +++ b/include/notification_private.h @@ -93,6 +93,7 @@ struct _notification { int ongoing_duration; /* Ongoing duration time */ bool auto_remove; notification_button_index_e default_button_index; + int timeout; uid_t uid; }; @@ -150,6 +151,7 @@ typedef enum notification_data_type { NOTIFICATION_DATA_TYPE_ONGOING_DURATION, NOTIFICATION_DATA_TYPE_AUTO_REMOVE, NOTIFICATION_DATA_TYPE_DEFAULT_BUTTON, + NOTIFICATION_DATA_TYPE_TIMEOUT, NOTIFICATION_DATA_TYPE_UID, } notification_data_type_e; diff --git a/src/notification.c b/src/notification.c index 03c94d6..c012d5b 100755 --- a/src/notification.c +++ b/src/notification.c @@ -1430,6 +1430,7 @@ static notification_h _notification_create(notification_type_e type) noti->ongoing_flag = false; noti->default_button_index = 0; noti->type = NOTIFICATION_ONGOING_VALUE_TYPE_PERCENT; + noti->timeout = 0; if (getuid() >= REGULAR_UID_MIN) { noti->caller_pkgname = notification_get_pkgname_by_pid(); @@ -1644,6 +1645,7 @@ EXPORT_API int notification_clone(notification_h noti, notification_h *clone) new_noti->ongoing_duration = noti->ongoing_duration; new_noti->auto_remove = noti->auto_remove; new_noti->default_button_index = noti->default_button_index; + new_noti->timeout = noti->timeout; new_noti->uid = noti->uid; diff --git a/src/notification_db.c b/src/notification_db.c index f331934..58b5151 100755 --- a/src/notification_db.c +++ b/src/notification_db.c @@ -84,6 +84,7 @@ create table if not exists noti_list ( \ ongoing_duration INTEGER default 0, \ auto_remove INTEGER default 1, \ default_button_index INTEGER default 0, \ + timeout INTEGER default 0, \ uid INTEGER \ ); \ create table if not exists noti_group_data ( \ @@ -197,6 +198,7 @@ create table if not exists noti_list ( \ ongoing_duration INTEGER default 0, \ auto_remove INTEGER default 1, \ default_button_index INTEGER default 0, \ + timeout INTEGER default 0, \ uid INTEGER, \ template_name TEXT, \ UNIQUE (caller_pkgname, template_name) \ diff --git a/src/notification_internal.c b/src/notification_internal.c index 8a463d1..e3b2719 100755 --- a/src/notification_internal.c +++ b/src/notification_internal.c @@ -1375,3 +1375,23 @@ EXPORT_API int notification_set_ongoing_time(notification_h noti, int current, i return NOTIFICATION_ERROR_NONE; } + +EXPORT_API int nofication_get_hide_timeout(notification_h noti, int *timeout) +{ + if (noti == NULL || timeout == NULL) + return NOTIFICATION_ERROR_INVALID_PARAMETER; + + *timeout = noti->timeout; + + return NOTIFICATION_ERROR_NONE; +} + +EXPORT_API int nofication_set_hide_timeout(notification_h noti, int timeout) +{ + if (noti == NULL) + return NOTIFICATION_ERROR_INVALID_PARAMETER; + + noti->timeout = timeout; + + return NOTIFICATION_ERROR_NONE; +} diff --git a/src/notification_ipc.c b/src/notification_ipc.c index 8b445b2..546f9a1 100755 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -1669,6 +1669,7 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_ONGOING_DURATION, g_variant_new_int32(noti->ongoing_duration)); g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_AUTO_REMOVE, g_variant_new_int32(noti->auto_remove)); g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_DEFAULT_BUTTON, g_variant_new_int32(noti->default_button_index)); + g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_TIMEOUT, g_variant_new_int32(noti->timeout)); g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_UID, g_variant_new_int32(noti->uid)); result_body = g_variant_builder_end(&builder); @@ -1820,6 +1821,7 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti, _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_ONGOING_DURATION, "i", ¬i->ongoing_duration); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_AUTO_REMOVE, "i", ¬i->auto_remove); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_DEFAULT_BUTTON, "i", ¬i->default_button_index); + _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TIMEOUT, "i", ¬i->timeout); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_UID, "i", ¬i->uid); noti->caller_pkgname = _dup_string(caller_pkgname); diff --git a/src/notification_noti.c b/src/notification_noti.c index 7fa4d19..133c26d 100755 --- a/src/notification_noti.c +++ b/src/notification_noti.c @@ -263,7 +263,7 @@ static int _insertion_query_create(notification_h noti, char **query) "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, uid) values (" + "auto_remove, default_button_index, timeout, uid) values (" "%d, " "%d, " "'%s', '%s', " @@ -282,7 +282,7 @@ static int _insertion_query_create(notification_h noti, char **query) "%d, '%s', %d, '%s', %d, %d, %d, %d," "%d, %d, %d, " "$progress_size, $progress_percentage, " - "%d, %d, %d, %d, %d, %d, %d)", + "%d, %d, %d, %d, %d, %d, %d, %d)", noti->type, noti->layout, NOTIFICATION_CHECK_STR(noti->caller_pkgname), @@ -321,6 +321,7 @@ static int _insertion_query_create(notification_h noti, char **query) noti->ongoing_duration, noti->auto_remove, noti->default_button_index, + noti->timeout, noti->uid); /* Free decoded data */ @@ -458,7 +459,7 @@ static int _update_query_create(notification_h noti, char **query) "display_applist = %d, " "progress_size = $progress_size, progress_percentage = $progress_percentage, " "ongoing_flag = %d, ongoing_value_type = %d, ongoing_current = %d, ongoing_duration = %d, " - "auto_remove = %d, default_button_index = %d " + "auto_remove = %d, default_button_index = %d, timeout = %d " "where priv_id = %d ", noti->type, noti->layout, @@ -492,7 +493,8 @@ static int _update_query_create(notification_h noti, char **query) noti->flags_for_property, flag_simmode, noti->display_applist, noti->ongoing_flag, noti->ongoing_value_type, noti->ongoing_current, noti->ongoing_duration, - noti->auto_remove, noti->default_button_index, noti->priv_id); + noti->auto_remove, noti->default_button_index, + noti->timeout, noti->priv_id); /* Free decoded data */ if (args) @@ -592,6 +594,7 @@ static void _notification_noti_populate_from_stmt(sqlite3_stmt *stmt, notificati noti->ongoing_duration = sqlite3_column_int(stmt, col++); noti->auto_remove = sqlite3_column_int(stmt, col++); noti->default_button_index = sqlite3_column_int(stmt, col++); + noti->timeout = sqlite3_column_int(stmt, col++); noti->app_icon_path = NULL; noti->app_name = NULL; -- cgit v1.2.3