Add API for get/set notification ongoing value type and time 42/87142/5
authorseungha.son <seungha.son@samsung.com>
Tue, 6 Sep 2016 08:06:53 +0000 (17:06 +0900)
committerseungha.son <seungha.son@samsung.com>
Wed, 7 Sep 2016 07:20:23 +0000 (16:20 +0900)
 - Add notification ongoing value type for display time infomation.
   User gets/sets notification ongoing value type and time.

Signed-off-by: seungha.son <seungha.son@samsung.com>
Change-Id: Id12bf068c9a11815a7f4f6e94dd383755e073b2e

include/notification_internal.h
include/notification_private.h
src/notification.c
src/notification_db.c
src/notification_internal.c
src/notification_ipc.c
src/notification_noti.c

index 5df7184..a12d443 100644 (file)
@@ -28,6 +28,15 @@ extern "C" {
 #endif
 
 /**
+ * @brief Enumeration for notification ongoing value type
+ * @since_tizen 3.0
+ */
+typedef enum _notification_ongoing_value_type {
+       NOTIFICATION_ONGOING_VALUE_TYPE_PERCENT = 0,
+       NOTIFICATION_ONGOING_VALUE_TYPE_TIME,
+} notification_ongoing_value_type_e;
+
+/**
  * @addtogroup NOTIFICATION_INTERNAL
  * @{
  */
@@ -724,7 +733,6 @@ int notification_unregister_detailed_changed_cb(
 int notification_unregister_detailed_changed_cb_for_uid(
                void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
                void *user_data, uid_t uid);
-
 /**
  * @brief Sets the default button to display highlight on the notification.
  * @since_tizen 3.0
@@ -802,6 +810,155 @@ int notification_set_default_button(notification_h noti, notification_button_ind
 int notification_get_default_button(notification_h noti, notification_button_index_e *index);
 
 /**
+ * @brief Gets the notification ongoing value type.
+ * @since_tizen 3.0
+ * @param[in] noti     The notification handle
+ * @param[out] type    The notification ongoing value type
+ * @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_ongoing_value_type_e
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+       notification_h noti = NULL;
+       notification_ongoing_value_type_e type;
+       int noti_err = NOTIFICATION_ERROR_NONE;
+
+       noti = notification_create(NOTIFICATION_TYPE_NOTI);
+       if (noti == NULL) {
+               return;
+       }
+
+       noti_err  = notification_get_ongoing_value_type(noti, &type);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               notification_free(noti);
+               return;
+       }
+}
+ * @endcode
+ */
+int notification_get_ongoing_value_type(notification_h noti, notification_ongoing_value_type_e *type);
+
+/**
+ * @brief Sets the notification ongoing value type.
+ * @since_tizen 3.0
+ * @param[in] noti     The notification handle
+ * @param[in] type     The notification ongoing value type
+ * @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_ongoing_value_type_e
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+       notification_h noti = NULL;
+       notification_ongoing_value_type_e type;
+       int noti_err = NOTIFICATION_ERROR_NONE;
+
+       noti = notification_create(NOTIFICATION_TYPE_NOTI);
+       if (noti == NULL) {
+               return;
+       }
+
+       type = NOTIFICATION_ONGOING_VALUE_TYPE_TIME;
+
+       noti_err  = notification_set_ongoing_value_type(noti, type);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               notification_free(noti);
+               return;
+       }
+}
+ * @endcode
+ */
+int notification_set_ongoing_value_type(notification_h noti, notification_ongoing_value_type_e type);
+
+/**
+ * @brief Gets the notification ongoing time when ongoint type value is set NOTIFICATION_ONGOING_VALUE_TYPE_TIME.
+ * @since_tizen 3.0
+ * @param[in] noti     The notification handle
+ * @param[out] current The ongoing current time
+ * @param[out] duration        The ongoing duration 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_ongoing_value_type_e
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+       notification_h noti = NULL;
+       int noti_err = NOTIFICATION_ERROR_NONE;
+       int current;
+       int duration;
+
+       noti = notification_create(NOTIFICATION_TYPE_NOTI);
+       if (noti == NULL) {
+               return;
+       }
+
+       noti_err  = notification_get_ongoing_time(noti, &current, &duration);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               notification_free(noti);
+               return;
+       }
+}
+ * @endcode
+ */
+EXPORT_API 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.
+ * @since_tizen 3.0
+ * @param[in] noti     The notification handle
+ * @param[in] current  The ongoing current time
+ * @param[in] duration The ongoing duration 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_ongoing_value_type_e
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+       notification_h noti = NULL;
+       int noti_err = NOTIFICATION_ERROR_NONE;
+       int current;
+       int duration;
+
+       noti = notification_create(NOTIFICATION_TYPE_NOTI);
+       if (noti == NULL) {
+               return;
+       }
+
+       current = 0;
+       duration = 30;
+
+       noti_err  = notification_set_ongoing_time(noti, current, duration)
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               notification_free(noti);
+               return;
+       }
+}
+ * @endcode
+ */
+EXPORT_API int nofication_set_ongoing_time(notification_h noti, int current, int duration);
+
+/**
  * @brief This function translate localized texts
  * @param[in] noti The notification handle that is created by notification_create()
  * @return #NOTIFICATION_ERROR_NONE if success, other value if failure
@@ -825,4 +982,3 @@ notification_h notification_create_from_package_template(const char *pkgname,
 }
 #endif
 #endif
-
index a2e6ece..ee908b6 100644 (file)
@@ -88,6 +88,9 @@ struct _notification {
        char *temp_content;
        char *tag;
        bool ongoing_flag;
+       int ongoing_value_type;
+       int ongoing_current;            /* Ongoing current time */
+       int ongoing_duration;           /* Ongoing duration time */
        bool auto_remove;
        notification_button_index_e default_button_index;
        uid_t uid;
@@ -142,6 +145,9 @@ typedef enum notification_data_type {
        NOTIFICATION_DATA_TYPE_TEMP_CONTENT,
        NOTIFICATION_DATA_TYPE_TAG,
        NOTIFICATION_DATA_TYPE_ONGOING_FLAG,
+       NOTIFICATION_DATA_TYPE_ONGOING_VALUE_TYPE,
+       NOTIFICATION_DATA_TYPE_ONGOING_CURRENT,
+       NOTIFICATION_DATA_TYPE_ONGOING_DURATION,
        NOTIFICATION_DATA_TYPE_AUTO_REMOVE,
        NOTIFICATION_DATA_TYPE_DEFAULT_BUTTON,
        NOTIFICATION_DATA_TYPE_UID,
index 3ab618e..03c94d6 100755 (executable)
@@ -1429,6 +1429,7 @@ static notification_h _notification_create(notification_type_e type)
        noti->auto_remove = true;
        noti->ongoing_flag = false;
        noti->default_button_index = 0;
+       noti->type = NOTIFICATION_ONGOING_VALUE_TYPE_PERCENT;
 
        if (getuid() >= REGULAR_UID_MIN) {
                noti->caller_pkgname = notification_get_pkgname_by_pid();
@@ -1638,8 +1639,12 @@ EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
        new_noti->progress_percentage = noti->progress_percentage;
 
        new_noti->ongoing_flag = noti->ongoing_flag;
+       new_noti->ongoing_value_type = noti->ongoing_value_type;
+       new_noti->ongoing_current = noti->ongoing_current;
+       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->uid = noti->uid;
 
        new_noti->app_icon_path = NULL;
index b4cfaf0..f331934 100755 (executable)
@@ -79,6 +79,9 @@ create        table if not exists noti_list ( \
                        progress_size DOUBLE default 0, \
                        progress_percentage DOUBLE default 0, \
                        ongoing_flag INTEGER default 0, \
+                       ongoing_value_type INTEGER default 0, \
+                       ongoing_current INTEGER default 0, \
+                       ongoing_duration INTEGER default 0, \
                        auto_remove INTEGER default 1, \
                        default_button_index INTEGER default 0, \
                        uid INTEGER \
@@ -189,6 +192,9 @@ create      table if not exists noti_list ( \
                        progress_size DOUBLE default 0, \
                        progress_percentage DOUBLE default 0, \
                        ongoing_flag INTEGER default 0, \
+                       ongoing_value_type INTEGER default 0, \
+                       ongoing_current INTEGER default 0, \
+                       ongoing_duration INTEGER default 0, \
                        auto_remove INTEGER default 1, \
                        default_button_index INTEGER default 0, \
                        uid INTEGER, \
index dbf3820..8a463d1 100755 (executable)
@@ -1311,7 +1311,7 @@ EXPORT_API notification_h notification_create_from_package_template(const char *
        return noti;
 }
 
-int notification_set_default_button(notification_h noti, notification_button_index_e index)
+EXPORT_API int notification_set_default_button(notification_h noti, notification_button_index_e index)
 {
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
@@ -1324,7 +1324,7 @@ int notification_set_default_button(notification_h noti, notification_button_ind
        return NOTIFICATION_ERROR_NONE;
 }
 
-int notification_get_default_button(notification_h noti, notification_button_index_e *index)
+EXPORT_API int notification_get_default_button(notification_h noti, notification_button_index_e *index)
 {
        if (noti == NULL || index == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
@@ -1333,3 +1333,45 @@ int notification_get_default_button(notification_h noti, notification_button_ind
 
        return NOTIFICATION_ERROR_NONE;
 }
+
+EXPORT_API int notification_get_ongoing_value_type(notification_h noti, notification_ongoing_value_type_e *type)
+{
+       if (noti == NULL || type == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *type = noti->ongoing_value_type;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_set_ongoing_value_type(notification_h noti, notification_ongoing_value_type_e type)
+{
+       if (type < NOTIFICATION_ONGOING_VALUE_TYPE_PERCENT && type > NOTIFICATION_ONGOING_VALUE_TYPE_TIME)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->ongoing_value_type = type;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int nofication_get_ongoing_time(notification_h noti, int *current, int *duration)
+{
+       if (noti == NULL || current == NULL || duration == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *current = noti->ongoing_current;
+       *duration = noti->ongoing_duration;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_set_ongoing_time(notification_h noti, int current, int duration)
+{
+       if (noti == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->ongoing_current = current;
+       noti->ongoing_duration = duration;
+
+       return NOTIFICATION_ERROR_NONE;
+}
index 0453d57..8b445b2 100755 (executable)
@@ -1664,6 +1664,9 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not
                g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_TAG, g_variant_new_string((const gchar *)noti->tag));
 
        g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_ONGOING_FLAG, g_variant_new_int32(noti->ongoing_flag));
+       g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_ONGOING_VALUE_TYPE, g_variant_new_int32(noti->ongoing_value_type));
+       g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_ONGOING_CURRENT, g_variant_new_int32(noti->ongoing_current));
+       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_UID, g_variant_new_int32(noti->uid));
@@ -1812,6 +1815,9 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti,
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TEMP_CONTENT, "&s", &temp_content);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TAG, "&s", &tag);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_ONGOING_FLAG, "i", &noti->ongoing_flag);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_ONGOING_VALUE_TYPE, "i", &noti->ongoing_value_type);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_ONGOING_CURRENT, "i", &noti->ongoing_current);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_ONGOING_DURATION, "i", &noti->ongoing_duration);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_AUTO_REMOVE, "i", &noti->auto_remove);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_DEFAULT_BUTTON, "i", &noti->default_button_index);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_UID, "i", &noti->uid);
index 1443822..7fa4d19 100755 (executable)
@@ -261,7 +261,9 @@ static int _insertion_query_create(notification_h noti, char **query)
                "b_event_handler_click_on_icon, b_event_handler_click_on_thumbnail, "
                "sound_type, sound_path, vibration_type, 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, auto_remove, default_button_index, uid) values ("
+               "progress_size, progress_percentage, "
+               "ongoing_flag, ongoing_value_type, ongoing_current, ongoing_duration, "
+               "auto_remove, default_button_index, uid) values ("
                "%d, "
                "%d, "
                "'%s', '%s', "
@@ -279,7 +281,8 @@ static int _insertion_query_create(notification_h noti, char **query)
                "'%s', '%s', "
                "%d, '%s', %d, '%s', %d, %d, %d, %d,"
                "%d, %d, %d, "
-               "$progress_size, $progress_percentage, %d, %d, %d, %d)",
+               "$progress_size, $progress_percentage, "
+               "%d, %d, %d, %d, %d, %d, %d)",
                noti->type,
                noti->layout,
                NOTIFICATION_CHECK_STR(noti->caller_pkgname),
@@ -313,6 +316,9 @@ static int _insertion_query_create(notification_h noti, char **query)
                noti->led_off_ms,
                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->uid);
@@ -451,7 +457,8 @@ static int _update_query_create(notification_h noti, char **query)
                "flags_for_property = %d, flag_simmode = %d, "
                "display_applist = %d, "
                "progress_size = $progress_size, progress_percentage = $progress_percentage, "
-               "ongoing_flag = %d, auto_remove = %d, default_button_index = %d "
+               "ongoing_flag = %d, ongoing_value_type = %d, ongoing_current = %d, ongoing_duration = %d, "
+               "auto_remove = %d, default_button_index = %d "
                "where priv_id = %d ",
                noti->type,
                noti->layout,
@@ -483,8 +490,9 @@ static int _update_query_create(notification_h noti, char **query)
                noti->led_on_ms,
                noti->led_off_ms,
                noti->flags_for_property, flag_simmode, noti->display_applist,
-               noti->ongoing_flag, noti->auto_remove, noti->default_button_index,
-               noti->priv_id);
+               noti->ongoing_flag, noti->ongoing_value_type,
+               noti->ongoing_current, noti->ongoing_duration,
+               noti->auto_remove, noti->default_button_index, noti->priv_id);
 
        /* Free decoded data */
        if (args)
@@ -579,6 +587,9 @@ static void _notification_noti_populate_from_stmt(sqlite3_stmt *stmt, notificati
        noti->progress_percentage = sqlite3_column_double(stmt, col++);
 
        noti->ongoing_flag = sqlite3_column_int(stmt, col++);
+       noti->ongoing_value_type = sqlite3_column_int(stmt, col++);
+       noti->ongoing_current = sqlite3_column_int(stmt, col++);
+       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++);