sync with private git
authoryoungsub ko <ys4610.ko@samsung.com>
Mon, 29 Apr 2013 10:34:26 +0000 (19:34 +0900)
committeryoungsub ko <ys4610.ko@samsung.com>
Mon, 29 Apr 2013 10:34:26 +0000 (19:34 +0900)
include/notification.h
include/notification_internal.h
include/notification_type.h
packaging/notification.spec
src/notification.c
src/notification_noti.c

index 399d084..219221d 100755 (executable)
@@ -590,6 +590,71 @@ notification_error_e notification_get_vibration(notification_h noti,
                                                const char **path);
 
 /**
+ * @brief This function set led notification.
+ * @details
+ * @remarks
+ * @param[in] noti notification handle
+ * @param[in] operation led notification operation
+ * @param[in] led_argb notification led color
+ * @return NOTIFICATION_ERROR_NONE if success, other value if failure
+ * @retval NOTIFICATION_ERROR_NONE - success
+ * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide parameter
+ * @pre
+ * @post
+ * @see
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+       notification_h noti = NULL;
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+       noti_err  = notification_set_led(noti, NOTIFICATION_LED_TYPE_DEFAULT, NULL);
+       if(noti_err != NOTIFICATION_ERROR_NONE) {
+               return;
+       }
+}
+ * @endcode
+ */
+notification_error_e notification_set_led(notification_h noti,
+                                               notification_led_op_e operation,
+                                               int led_argb);
+
+/**
+  * @brief This function get notification led.
+  * @details
+  * @remarks
+  * @param[in] noti notification handle
+  * @param[out] operation led notification operation
+  * @param[out] led_argb notification led color
+  * @return NOTIFICATION_ERROR_NONE if success, other value if failure
+  * @retval NOTIFICATION_ERROR_NONE - success
+  * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide parameter
+  * @pre
+  * @post
+  * @see
+  * @par Sample code:
+  * @code
+#include <notification.h>
+...
+ {
+       notification_h noti = NULL;
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+       notification_led_type_e type = NOTIFICATION_LED_TYPE_NONE;
+
+       noti_err  = notification_get_led(noti, &type, NULL);
+       if(noti_err != NOTIFICATION_ERROR_NONE) {
+               return;
+       }
+}
+  * @endcode
+  */
+notification_error_e notification_get_led(notification_h noti,
+                                               notification_led_op_e *operation,
+                                               int *led_argb);
+
+/**
  * @brief This function will be deprecated.
  * @see notification_set_execute_option()
  *
index 0cd9220..00f51e8 100755 (executable)
@@ -58,6 +58,8 @@ struct _notification {
        char *sound_path;
        notification_vibration_type_e vibration_type;
        char *vibration_path;
+       notification_led_op_e led_operation;
+       int led_argb;
 
        time_t time;            /* time set by application */
        time_t insert_time;     /* insert time */
index 2e72df9..ab431ad 100755 (executable)
@@ -38,7 +38,7 @@ extern "C" {
  */
 
 /**
- * @breief Enumeration for notification operation code
+ * @brief Enumeration for notification operation code
  */
 typedef enum _notification_op_type {
        NOTIFICATION_OP_NONE = 0,
@@ -50,7 +50,7 @@ typedef enum _notification_op_type {
 } notification_op_type_e;
 
 /**
- * @breief Enumeration for notification operation data code
+ * @brief Enumeration for notification operation data code
  */
 typedef enum _notification_op_data_type {
        NOTIFICATION_OP_DATA_MIN = 0,
@@ -62,7 +62,7 @@ typedef enum _notification_op_data_type {
 } notification_op_data_type_e;
 
 /**
- * @breief Enumeration for notification layout type
+ * @brief Enumeration for notification layout type
  */
 typedef enum _notification_ly_type {
        NOTIFICATION_LY_NONE = 0,
@@ -75,7 +75,7 @@ typedef enum _notification_ly_type {
 } notification_ly_type_e;
 
 /**
- * @breief Enumeration for notification sound type.
+ * @brief Enumeration for notification sound type.
  */
 typedef enum _notification_sound_type {
        NOTIFICATION_SOUND_TYPE_NONE = -1,
@@ -89,7 +89,7 @@ typedef enum _notification_sound_type {
 } notification_sound_type_e;
 
 /**
- * @breief Enumeration for notification vibration type.
+ * @brief Enumeration for notification vibration type.
  */
 typedef enum _notification_vibration_type {
        NOTIFICATION_VIBRATION_TYPE_NONE = -1,
@@ -101,7 +101,19 @@ typedef enum _notification_vibration_type {
 } notification_vibration_type_e;
 
 /**
- * @breief Will be deprecated.
+ * @brief Enumeration for notification led operation.
+ */
+typedef enum _notification_led_op {
+       NOTIFICATION_LED_OP_OFF = -1,
+                                       /**< Default value. Disable led */
+       NOTIFICATION_LED_OP_ON = 0,/**< turn on led with default color */
+       NOTIFICATION_LED_OP_ON_CUSTOM_COLOR,
+                                       /**< turn on led with custom color */
+       NOTIFICATION_LED_OP_MAX,/**< Max flag */
+} notification_led_op_e;
+
+/**
+ * @brief Will be deprecated.
  */
 typedef enum _notification_count_display_type {
        NOTIFICATION_COUNT_DISPLAY_TYPE_NONE = -1,
@@ -112,7 +124,7 @@ typedef enum _notification_count_display_type {
 } notification_count_display_type_e;
 
 /**
- * @breief Enumeration for notification count position in the text.
+ * @brief Enumeration for notification count position in the text.
  */
 typedef enum _notifcation_count_pos_type {
        NOTIFICATION_COUNT_POS_NONE = -1,
@@ -127,7 +139,7 @@ typedef enum _notifcation_count_pos_type {
 } notification_count_pos_type_e;
 
 /**
- * @breief Enumeration for notification variable parameter type
+ * @brief Enumeration for notification variable parameter type
  */
 typedef enum _notification_variable_type {
        NOTIFICATION_VARIABLE_TYPE_NONE = -1,
@@ -145,7 +157,7 @@ typedef enum _notification_variable_type {
 } notification_variable_type_e;
 
 /**
- * @breief Enumeration for notification text type.
+ * @brief Enumeration for notification text type.
  */
 typedef enum _notification_text_type {
        NOTIFICATION_TEXT_TYPE_NONE = -1,
@@ -181,7 +193,7 @@ typedef enum _notification_text_type {
 } notification_text_type_e;
 
 /**
- * @breief Enumeration for image text type.
+ * @brief Enumeration for image text type.
  */
 typedef enum _notification_image_type {
        NOTIFICATION_IMAGE_TYPE_NONE = -1,
@@ -223,7 +235,7 @@ typedef enum _notification_image_type {
 }notification_button_type_e;*/
 
 /**
- * @breief Enumeration for application execution type.
+ * @brief Enumeration for application execution type.
  */
 typedef enum _notification_execute_type {
        NOTIFICATION_EXECUTE_TYPE_NONE = -1,
@@ -238,7 +250,7 @@ typedef enum _notification_execute_type {
 } notification_execute_type_e;
 
 /**
- * @breief Enumeration for notification type.
+ * @brief Enumeration for notification type.
  */
 typedef enum _notification_type {
        NOTIFICATION_TYPE_NONE = -1,
@@ -252,7 +264,7 @@ typedef enum _notification_type {
 } notification_type_e;
 
 /**
- * @breief Enumeration for Group ID.
+ * @brief Enumeration for Group ID.
  */
 enum _notification_group_id {
        NOTIFICATION_GROUP_ID_NONE = -1,/**< Not Grouping */
@@ -261,7 +273,7 @@ enum _notification_group_id {
 };
 
 /**
- * @breief Enumeration for Private ID.
+ * @brief Enumeration for Private ID.
  */
 enum _notification_priv_id {
        NOTIFICATION_PRIV_ID_NONE = -1,
@@ -269,7 +281,7 @@ enum _notification_priv_id {
 };
 
 /**
- * @breief Enumeration for notification property
+ * @brief Enumeration for notification property
  */
 enum _notification_property {
        NOTIFICATION_PROP_DISPLAY_ONLY_SIMMODE = 0x00000001,
@@ -290,7 +302,7 @@ enum _notification_property {
 };
 
 /**
- * @breief Enumeration for display application list
+ * @brief Enumeration for display application list
  */
 enum _notificaton_display_applist {
        NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY = 0x00000001,/**< Notification Tray(Quickpanel) */
index 0346947..e341e32 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       notification
 Summary:    notification library
-Version:    0.1.8
+Version:    0.2.0
 Release:    1
 Group:      TBD
 License:    Apache-2.0
@@ -86,6 +86,8 @@ then
                        sound_path TEXT,
                        vibration_type INTEGER default 0,
                        vibration_path TEXT,
+                       led_operation INTEGER default 0,
+                       led_argb INTEGER default 0,
                        flags_for_property INTEGER default 0,
                        flag_simmode INTEGER default 0,
                        display_applist INTEGER,
index 827b515..65702d0 100755 (executable)
@@ -1661,6 +1661,53 @@ EXPORT_API notification_error_e notification_get_vibration(notification_h noti,
        return NOTIFICATION_ERROR_NONE;
 }
 
+EXPORT_API notification_error_e notification_set_led(notification_h noti,
+                                                          notification_led_op_e operation,
+                                                          int led_argb)
+{
+       /* Check noti is valid data */
+       if (noti == NULL) {
+               return NOTIFICATION_ERROR_INVALID_DATA;
+       }
+
+       /* Check operation is valid */
+       if (operation < NOTIFICATION_LED_OP_OFF
+           || operation >= NOTIFICATION_LED_OP_MAX) {
+               return NOTIFICATION_ERROR_INVALID_DATA;
+       }
+
+       /* Save led operation */
+       noti->led_operation = operation;
+
+       /* Save led argb if operation is turning on LED with custom color */
+       if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR) {
+               noti->led_argb = led_argb;
+       }
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API notification_error_e notification_get_led(notification_h noti,
+                                                          notification_led_op_e *operation,
+                                                          int *led_argb)
+{
+       /* check noti and operation is valid data */
+       if (noti == NULL || operation == NULL) {
+               return NOTIFICATION_ERROR_INVALID_DATA;
+       }
+
+       /* Set led operation */
+       *operation = noti->led_operation;
+
+       /* Save led argb if operation is turning on LED with custom color */
+       if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
+           && led_argb != NULL) {
+               *led_argb = noti->led_argb;
+       }
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
 EXPORT_API notification_error_e notification_set_application(notification_h noti,
                                                             const char *pkgname)
 {
@@ -2669,6 +2716,9 @@ static notification_h _notification_create(notification_type_e type) {
        noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
        noti->vibration_path = NULL;
 
+       noti->led_operation = NOTIFICATION_LED_OP_OFF;
+       noti->led_argb = 0;
+
        noti->domain = NULL;
        noti->dir = NULL;
 
@@ -2807,6 +2857,8 @@ EXPORT_API notification_error_e notification_clone(notification_h noti, notifica
        } else {
                new_noti->vibration_path = NULL;
        }
+       new_noti->led_operation = noti->led_operation;
+       new_noti->led_argb = noti->led_argb;
 
        if(noti->domain != NULL) {
                new_noti->domain = strdup(noti->domain);
index 395f82a..b90a716 100755 (executable)
@@ -31,7 +31,7 @@
 #include <notification_debug.h>
 #include <notification_internal.h>
 
-static int _notification_noti_bind_query(sqlite3_stmt * stmt, const char *name,
+static int _notification_noti_bind_query_text(sqlite3_stmt * stmt, const char *name,
                                         const char *str)
 {
        int ret = 0;
@@ -55,6 +55,29 @@ static int _notification_noti_bind_query(sqlite3_stmt * stmt, const char *name,
        return NOTIFICATION_ERROR_NONE;
 }
 
+static int _notification_noti_bind_query_double(sqlite3_stmt * stmt, const char *name,
+                                        double val)
+{
+       int ret = 0;
+       int index = 0;
+
+       index = sqlite3_bind_parameter_index(stmt, name);
+       if (index == 0) {
+               NOTIFICATION_ERR("Insert : invalid column name");
+               return NOTIFICATION_ERROR_FROM_DB;
+       }
+
+       ret =
+           sqlite3_bind_double(stmt, index, val);
+       if (ret != SQLITE_OK) {
+               NOTIFICATION_ERR("Insert double : %f",
+                               val);
+               return NOTIFICATION_ERROR_FROM_DB;
+       }
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
 static int _notification_noti_check_priv_id(notification_h noti, sqlite3 * db)
 {
        sqlite3_stmt *stmt = NULL;
@@ -253,7 +276,7 @@ static int _notification_noti_get_internal_group_id(notification_h noti,
        /* Bind query */
        if (ret_title != NULL) {
                ret =
-                   _notification_noti_bind_query(stmt, "$title_key",
+                   _notification_noti_bind_query_text(stmt, "$title_key",
                                                  NOTIFICATION_CHECK_STR
                                                  (ret_title));
                if (ret != NOTIFICATION_ERROR_NONE) {
@@ -357,7 +380,7 @@ static int _notification_noti_make_query(notification_h noti, char *query,
                 "args, group_args, "
                 "b_execute_option, "
                 "b_service_responding, b_service_single_launch, b_service_multi_launch, "
-                "sound_type, sound_path, vibration_type, vibration_path, "
+                "sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb,"
                 "flags_for_property, flag_simmode, display_applist, "
                 "progress_size, progress_percentage) values ("
                 "%d, "
@@ -372,9 +395,9 @@ static int _notification_noti_make_query(notification_h noti, char *query,
                 "'%s', '%s', "
                 "'%s', "
                 "'%s', '%s', '%s', "
-                "%d, '%s', %d, '%s', "
+                "%d, '%s', %d, '%s', %d, %d,"
                 "%d, %d, %d, "
-                "%f, %f)",
+                "$progress_size, $progress_percentage)",
                 noti->type,
                 noti->layout,
                 NOTIFICATION_CHECK_STR(noti->caller_pkgname),
@@ -394,8 +417,9 @@ static int _notification_noti_make_query(notification_h noti, char *query,
                 noti->sound_type, NOTIFICATION_CHECK_STR(noti->sound_path),
                 noti->vibration_type,
                 NOTIFICATION_CHECK_STR(noti->vibration_path),
-                noti->flags_for_property, flag_simmode, noti->display_applist,
-                noti->progress_size, noti->progress_percentage);
+                noti->led_operation,
+                noti->led_argb,
+                noti->flags_for_property, flag_simmode, noti->display_applist);
 
        /* Free decoded data */
        if (args) {
@@ -515,9 +539,10 @@ static int _notification_noti_make_update_query(notification_h noti, char *query
                 "b_service_multi_launch = '%s', "
                 "sound_type = %d, sound_path = '%s', "
                 "vibration_type = %d, vibration_path = '%s', "
+                "led_operation = %d, led_argb = %d, "
                 "flags_for_property = %d, flag_simmode = %d, "
                 "display_applist = %d, "
-                "progress_size = %f, progress_percentage = %f "
+                "progress_size = $progress_size, progress_percentage = $progress_percentage "
                 "where priv_id = %d ",
                 noti->type,
                 noti->layout,
@@ -536,8 +561,9 @@ static int _notification_noti_make_update_query(notification_h noti, char *query
                 noti->sound_type, NOTIFICATION_CHECK_STR(noti->sound_path),
                 noti->vibration_type,
                 NOTIFICATION_CHECK_STR(noti->vibration_path),
+                noti->led_operation,
+                noti->led_argb,
                 noti->flags_for_property, flag_simmode, noti->display_applist,
-                noti->progress_size, noti->progress_percentage,
                 noti->priv_id);
 
        /* Free decoded data */
@@ -617,6 +643,8 @@ static void _notification_noti_populate_from_stmt(sqlite3_stmt * stmt, notificat
        noti->sound_path = notification_db_column_text(stmt, col++);
        noti->vibration_type = sqlite3_column_int(stmt, col++);
        noti->vibration_path = notification_db_column_text(stmt, col++);
+       noti->led_operation = sqlite3_column_int(stmt, col++);
+       noti->led_argb = sqlite3_column_int(stmt, col++);
 
        noti->flags_for_property = sqlite3_column_int(stmt, col++);
        noti->display_applist = sqlite3_column_int(stmt, col++);
@@ -767,11 +795,27 @@ int notification_noti_insert(notification_h noti)
        }
 
        /* Bind query */
-       ret = _notification_noti_bind_query(stmt, "$title_key", title_key);
+       ret = _notification_noti_bind_query_text(stmt, "$title_key", title_key);
        if (ret != NOTIFICATION_ERROR_NONE) {
                NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
                goto err;
        }
+       ret = _notification_noti_bind_query_double(stmt, "$progress_size",noti->progress_size);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
+               if (stmt) {
+                       sqlite3_finalize(stmt);
+               }
+               return ret;
+       }
+       ret = _notification_noti_bind_query_double(stmt, "$progress_percentage",noti->progress_percentage);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
+               if (stmt) {
+                       sqlite3_finalize(stmt);
+               }
+               return ret;
+       }
 
        ret = sqlite3_step(stmt);
        if (ret == SQLITE_OK || ret == SQLITE_DONE) {
@@ -817,7 +861,7 @@ int notification_noti_get_by_priv_id(notification_h noti, char *pkgname, int pri
                         "b_text, b_key, 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, "
-                        "sound_type, sound_path, vibration_type, vibration_path, "
+                        "sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb,"
                         "flags_for_property, display_applist, progress_size, progress_percentage "
                         "from noti_list ";
 
@@ -889,6 +933,23 @@ int notification_noti_update(notification_h noti)
                goto err;
        }
 
+       ret = _notification_noti_bind_query_double(stmt, "$progress_size",noti->progress_size);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
+               if (stmt) {
+                       sqlite3_finalize(stmt);
+               }
+               return ret;
+       }
+       ret = _notification_noti_bind_query_double(stmt, "$progress_percentage",noti->progress_percentage);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
+               if (stmt) {
+                       sqlite3_finalize(stmt);
+               }
+               return ret;
+       }
+
        ret = sqlite3_step(stmt);
        if (ret == SQLITE_OK || ret == SQLITE_DONE) {
                ret = NOTIFICATION_ERROR_NONE;
@@ -1327,7 +1388,7 @@ notification_error_e notification_noti_get_grouping_list(notification_type_e typ
                 "b_text, b_key, 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, "
-                "sound_type, sound_path, vibration_type, vibration_path, "
+                "sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb,"
                 "flags_for_property, display_applist, progress_size, progress_percentage "
                 "from noti_list ");
 
@@ -1430,7 +1491,7 @@ notification_error_e notification_noti_get_detail_list(const char *pkgname,
                 "b_text, b_key, 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, "
-                "sound_type, sound_path, vibration_type, vibration_path, "
+                "sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb,"
                 "flags_for_property, display_applist, progress_size, progress_percentage "
                 "from noti_list ");