Support display_type 14/227714/4
authorInHong Han <inhong1.han@samsung.com>
Fri, 13 Mar 2020 00:52:19 +0000 (09:52 +0900)
committerInHong Han <inhong1.han@samsung.com>
Wed, 18 Mar 2020 05:03:25 +0000 (14:03 +0900)
Change-Id: I84a9ee0230c8d0da38236edde726eb74abcd66a8

client/sticker_data.c
client/sticker_data_main.h
client/sticker_dbus.c
client/sticker_defs.h
include/sticker_data.h
include/sticker_provider.h
server/stickerd_data_manager.c
server/stickerd_db_manager.c
server/stickerd_db_manager.h
sticker-parser/sticker-parser.c

index decbfe3..b76e7a8 100644 (file)
@@ -208,6 +208,8 @@ EXPORT_API int sticker_data_clone(sticker_data_h origin_handle, sticker_data_h *
     if (origin_handle->date)
         handle->date = strdup(origin_handle->date);
 
+    handle->disp_type = origin_handle->disp_type;
+
     *target_handle = handle;
 
     return STICKER_ERROR_NONE;
@@ -444,3 +446,27 @@ EXPORT_API int sticker_data_get_date(sticker_data_h data_handle, char **date)
 
     return STICKER_ERROR_NONE;
 }
+
+EXPORT_API int sticker_data_set_display_type(sticker_data_h data_handle, sticker_data_display_type_e type)
+{
+    CHECK_STICKER_FEATURE();
+
+    if (!data_handle || !type || type < STICKER_DATA_DISP_EMOJI || type > STICKER_DATA_DISP_WALLPAPER)
+        return STICKER_ERROR_INVALID_PARAMETER;
+
+    data_handle->disp_type = type;
+
+    return STICKER_ERROR_NONE;
+}
+
+EXPORT_API int sticker_data_get_display_type(sticker_data_h data_handle, sticker_data_display_type_e *type)
+{
+    CHECK_STICKER_FEATURE();
+
+    if (!data_handle || !type)
+        return STICKER_ERROR_INVALID_PARAMETER;
+
+    *type = data_handle->disp_type;
+
+    return STICKER_ERROR_NONE;
+}
\ No newline at end of file
index 058de9c..463216e 100644 (file)
@@ -39,6 +39,7 @@ struct sticker_data_s{
     char *group;
     char *description;
     char *date;
+    sticker_data_display_type_e disp_type;
 };
 
 #ifdef __cplusplus
index debfc5f..7bf48bf 100644 (file)
@@ -110,6 +110,9 @@ static void _get_sticker_info_from_gvariant(GVariant *body, sticker_data_h stick
             case STICKER_DATA_TYPE_DATE:
             sticker_data->date = g_variant_dup_string(value, NULL);
             break;
+            case STICKER_DATA_TYPE_DISP_TYPE:
+            sticker_data->disp_type = g_variant_get_int32(value);
+            break;
             default:
             break;
         }
@@ -585,6 +588,7 @@ int sticker_dbus_insert_sticker_info(GDBusConnection *gdbus_connection, sticker_
     if (sticker_data->description)
         g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_DESCRIPTION, g_variant_new_string((const gchar *)sticker_data->description));
     g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_GROUP, g_variant_new_string((const gchar *)sticker_data->group));
+    g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_DISP_TYPE, g_variant_new_int32(sticker_data->disp_type));
 
     keyword_builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
     g_list_foreach(sticker_data->keyword, (GFunc) _set_keyword_builder, keyword_builder);
index ce56260..01cae60 100644 (file)
@@ -66,6 +66,7 @@ typedef enum {
     STICKER_DATA_TYPE_GROUP,
     STICKER_DATA_TYPE_KEYWORD,
     STICKER_DATA_TYPE_DATE,
+    STICKER_DATA_TYPE_DISP_TYPE,
 } STICKER_DAT_TYPE;
 
 #ifdef __cplusplus
index 16c8753..fc1f8c3 100644 (file)
@@ -44,6 +44,16 @@ typedef enum {
 } sticker_data_uri_type_e;
 
 /**
+ * @brief Enumeration for sticker display type.
+ *
+ * @since_tizen 5.5
+ */
+typedef enum {
+    STICKER_DATA_DISP_EMOJI = 1, /**< Emoji type */
+    STICKER_DATA_DISP_WALLPAPER, /**< Wallpaper type */
+} sticker_data_display_type_e;
+
+/**
  * @brief The sticker data handle.
  * @since_tizen 5.5
  */
@@ -304,6 +314,33 @@ int sticker_data_get_description(sticker_data_h data_handle, char **description)
 int sticker_data_get_date(sticker_data_h data_handle, char **date);
 
 /**
+ * @brief Sets the display type of the sticker.
+ * @since_tizen 5.5
+ * @param[in] data_handle The sticker data handle
+ * @param[in] type The display type to be saved
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STICKER_ERROR_NONE Successful
+ * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see sticker_data_get_display_type()
+ */
+int sticker_data_set_display_type(sticker_data_h data_handle, sticker_data_display_type_e type);
+
+/**
+ * @brief Gets the display type from sticker data handle.
+ * @details If the display type is empty, the result will be a zero.
+ * @since_tizen 5.5
+ * @param[in] data_handle The sticker data handle
+ * @param[out] type The display type of the sticker
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STICKER_ERROR_NONE Successful
+ * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see sticker_data_set_display_type()
+ */
+int sticker_data_get_display_type(sticker_data_h data_handle, sticker_data_display_type_e *type);
+
+/**
  * @}
  */
 
index 8ab7758..6ea0234 100644 (file)
@@ -97,7 +97,7 @@ int sticker_provider_destroy(sticker_provider_h provider_handle);
 /**
  * @brief Inserts a sticker data to the sticker database.
  * @since_tizen 5.5
- * @remarks All data except thumbnail and description must be set in the @a data_handle to insert the sticker data.
+ * @remarks All data except thumbnail, description, display_type must be set in the @a data_handle to insert the sticker data.
  *          If the uri type is #STICKER_DATA_URI_LOCAL_PATH, the sticker file is copied to a sticker directory.
  *          It is recommended to delete your sticker file after inserting a sticker data.
  * @param[in] provider_handle The sticker provider handle
@@ -116,7 +116,7 @@ int sticker_provider_insert_data(sticker_provider_h provider_handle, sticker_dat
  * @brief Inserts a sticker data using json file.
  * @details @a json_path must be a relative path like '/data/message_sticker.json'.
  * @since_tizen 5.5
- * @remarks All data except thumbnail and description must be set in the json file to insert the sticker data.
+ * @remarks All data except thumbnail, description, display_type must be set in the json file to insert the sticker data.
  *          @a json_path must have a non-null value and must be an existing file. If not, the error as invalid parameter will be returned.
  *          If the uri type is #STICKER_DATA_URI_LOCAL_PATH, the sticker file is copied to a sticker directory.
  *          It is recommended to delete your sticker files after inserting a sticker data.
@@ -143,7 +143,8 @@ int sticker_provider_insert_data(sticker_provider_h provider_handle, sticker_dat
             "keyword" : ["heart eyes", "love", "cute"],
             "group" : "face",
             "thumbnail" : "/res/face/thumbnail/heart_eyes.png",
-            "description" : "Smiling face with heart eyes emoji."
+            "description" : "Smiling face with heart eyes emoji.",
+            "display_type" : 1
         },
         {
             "type" : 2,
@@ -151,7 +152,8 @@ int sticker_provider_insert_data(sticker_provider_h provider_handle, sticker_dat
             "keyword" : ["smile", "high five"],
             "group" : "face",
             "thumbnail" : "",
-            "description" : "Smiling face with high five emoji."
+            "description" : "Smiling face with high five emoji.",
+            "display_type" : null
         },
             .....
         {
index f0dc8d2..07f667a 100644 (file)
@@ -531,6 +531,8 @@ int stickerd_insert_sticker_info(GVariant *parameters, GVariant **reply_body)
             case STICKER_DATA_TYPE_GROUP:
             sticker_info->group = (char *) g_variant_get_string(value, NULL);
             break;
+            case STICKER_DATA_TYPE_DISP_TYPE:
+            sticker_info->display_type = g_variant_get_int32(value);
             default:
             break;
         }
@@ -701,6 +703,8 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_
 
             sticker_info->description = _get_string_from_object(info_object, "description");
 
+            sticker_info->display_type = _get_int_from_object(info_object, "display_type");
+
             JsonArray *keyword_arr = json_object_get_array_member(info_object, "keyword");
             int keyword_arr_len = json_array_get_length(keyword_arr);
             if (keyword_arr_len < 1)
@@ -986,6 +990,7 @@ int stickerd_get_sticker_info(GVariant *parameters, GVariant **reply_body)
     g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_DESCRIPTION, g_variant_new_string((const gchar *)sticker_info->description));
     g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_GROUP, g_variant_new_string((const gchar *)sticker_info->group));
     g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_DATE, g_variant_new_string((const gchar *)sticker_info->date));
+    g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_DISP_TYPE, g_variant_new_int32(sticker_info->display_type));
 
     keyword_builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
     g_list_foreach(sticker_info->keyword, (GFunc) _set_keyword_builder, keyword_builder);
index ab68092..e0d1a1b 100644 (file)
  * Table Information
  *
  * sticker_info
- * +-----------------+--------+------+------+-----------+-------------+------------+------+
- * | INT             | TEXT   | INT  | TEXT | TEXT      | TEXT        | TEXT       | TEXT |
- * +-----------------+--------+------+------+-----------+-------------+------------+------+
- * | sticker_info_id | app_id | type | uri  | thumbnail | description | group_name | date |
- * +-----------------+--------+------+------+-----------+-------------+------------+------+
+ * +-----------------+--------+------+------+-----------+-------------+------------+------+--------------+
+ * | INT             | TEXT   | INT  | TEXT | TEXT      | TEXT        | TEXT       | TEXT | INT          |
+ * +-----------------+--------+------+------+-----------+-------------+------------+------+--------------+
+ * | sticker_info_id | app_id | type | uri  | thumbnail | description | group_name | date | display_type |
+ * +-----------------+--------+------+------+-----------+-------------+------------+------+--------------+
  *
  * sticker_keyword_info
  * +------------+-----------------+---------+
  */
 
 #define STICKER_DB_PATH tzplatform_mkpath(TZ_SYS_DB, ".sticker_info.db")
-#define STICKER_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_info(sticker_info_id INTEGER PRIMARY KEY AUTOINCREMENT, app_id TEXT NOT NULL, type INTEGER NOT NULL, uri TEXT NOT NULL, thumbnail TEXT, description TEXT, group_name TEXT NOT NULL, date TEXT NOT NULL)"
+#define STICKER_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_info(sticker_info_id INTEGER PRIMARY KEY AUTOINCREMENT, app_id TEXT NOT NULL, type INTEGER NOT NULL, uri TEXT NOT NULL, thumbnail TEXT, description TEXT, group_name TEXT NOT NULL, date TEXT NOT NULL, display_type INTEGER)"
 #define STICKER_KEYWORD_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_keyword_info(keyword_id INTEGER PRIMARY KEY AUTOINCREMENT, sticker_info_id INTEGER, keyword TEXT NOT NULL, FOREIGN KEY (sticker_info_id) REFERENCES sticker_info(sticker_info_id) ON DELETE CASCADE)"
 #define STICKER_WHITELIST_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_whitelist_info(whitelist_id INTEGER PRIMARY KEY AUTOINCREMENT, provider_id TEXT NOT NULL, consumer_id TEXT NOT NULL)"
 
-#define STICKER_DB_INSERT_STICKER_INFO "INSERT INTO sticker_info (app_id, type, uri, thumbnail, description, group_name, date) VALUES (?, ?, ?, ?, ?, ?, DateTime('now','localtime'))"
+#define STICKER_DB_INSERT_STICKER_INFO "INSERT INTO sticker_info (app_id, type, uri, thumbnail, description, group_name, date, display_type) VALUES (?, ?, ?, ?, ?, ?, DateTime('now','localtime'), ?)"
 #define STICKER_DB_INSERT_STICKER_KEYWORD_INFO "INSERT INTO sticker_keyword_info (sticker_info_id, keyword) VALUES (?, ?)"
 
 #define STICKER_DB_DELETE_STICKER_INFO "DELETE FROM sticker_info WHERE sticker_info_id = ?"
@@ -311,6 +311,7 @@ int stickerd_db_insert_sticker_info(int *record_id, sticker_info_db *sticker_inf
     sqlite3_bind_text(stmt, 4, sticker_info->thumbnail, -1, SQLITE_TRANSIENT);
     sqlite3_bind_text(stmt, 5, sticker_info->description, -1, SQLITE_TRANSIENT);
     sqlite3_bind_text(stmt, 6, sticker_info->group, -1, SQLITE_TRANSIENT);
+    sqlite3_bind_int(stmt, 7, sticker_info->display_type);
 
     ret = sqlite3_step(stmt);
     if (ret != SQLITE_OK && ret != SQLITE_DONE) {
@@ -541,6 +542,8 @@ int stickerd_db_get_sticker_info_by_record_id(int record_id, sticker_info_db *st
     if (tmp_date)
         sticker_info->date = strdup((const char *)tmp_date);
 
+    sticker_info->display_type = sqlite3_column_int(stmt, 8);
+
     sqlite3_finalize(stmt);
     stmt = NULL;
 
index b2ff9bb..9b87f81 100644 (file)
@@ -44,6 +44,7 @@ typedef struct {
     char *group;
     GList *keyword;
     char *date;
+    int  display_type;
 } sticker_info_db;
 
 int stickerd_db_init(void);
index 11e7e91..6910d6b 100644 (file)
@@ -41,7 +41,7 @@
 #define LOG_TAG "STICKER_PARSER"
 
 #define STICKER_DIRECTORY tzplatform_mkpath(TZ_SYS_SHARE, "sticker-data")
-#define STICKER_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_info(sticker_info_id INTEGER PRIMARY KEY AUTOINCREMENT, app_id TEXT NOT NULL, type INTEGER NOT NULL, uri TEXT NOT NULL, thumbnail TEXT, description TEXT, group_name TEXT NOT NULL, date TEXT NOT NULL)"
+#define STICKER_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_info(sticker_info_id INTEGER PRIMARY KEY AUTOINCREMENT, app_id TEXT NOT NULL, type INTEGER NOT NULL, uri TEXT NOT NULL, thumbnail TEXT, description TEXT, group_name TEXT NOT NULL, date TEXT NOT NULL, display_type INTEGER)"
 #define STICKER_KEYWORD_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_keyword_info(keyword_id INTEGER PRIMARY KEY AUTOINCREMENT, sticker_info_id INTEGER, keyword TEXT NOT NULL, FOREIGN KEY (sticker_info_id) REFERENCES sticker_info(sticker_info_id) ON DELETE CASCADE)"
 #define STICKER_WHITELIST_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_whitelist_info(whitelist_id INTEGER PRIMARY KEY AUTOINCREMENT, provider_id TEXT NOT NULL, consumer_id TEXT NOT NULL)"
 #define UIFW_ID           502
@@ -405,7 +405,7 @@ cleanup:
     }
 }
 
-static void __insert_sticker_info(const char *app_id, int type, const char *uri, const char *group, const char *thumbnail, const char *description)
+static void __insert_sticker_info(const char *app_id, int type, const char *uri, const char *group, const char *thumbnail, const char *description, int disp_type)
 {
     int ret;
     sqlite3 *db = NULL;
@@ -417,7 +417,7 @@ static void __insert_sticker_info(const char *app_id, int type, const char *uri,
     if (!db)
         return;
 
-    ret = sqlite3_prepare_v2(db, "INSERT INTO sticker_info (app_id, type, uri, thumbnail, description, group_name, date) VALUES (?, ?, ?, ?, ?, ?, DateTime('now','localtime'))",-1, &stmt, NULL);
+    ret = sqlite3_prepare_v2(db, "INSERT INTO sticker_info (app_id, type, uri, thumbnail, description, group_name, date, display_type) VALUES (?, ?, ?, ?, ?, ?, DateTime('now','localtime'), ?)",-1, &stmt, NULL);
     if (ret == SQLITE_OK) {
         sqlite3_bind_text(stmt, 1, app_id, -1, SQLITE_TRANSIENT);
         sqlite3_bind_int(stmt, 2, type);
@@ -425,6 +425,7 @@ static void __insert_sticker_info(const char *app_id, int type, const char *uri,
         sqlite3_bind_text(stmt, 4, thumbnail, -1, SQLITE_TRANSIENT);
         sqlite3_bind_text(stmt, 5, description, -1, SQLITE_TRANSIENT);
         sqlite3_bind_text(stmt, 6, group, -1, SQLITE_TRANSIENT);
+        sqlite3_bind_int(stmt, 7, disp_type);
 
         ret = sqlite3_step(stmt);
         if (ret != SQLITE_OK && ret != SQLITE_DONE)
@@ -599,6 +600,7 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path
 
             thumbnail = __get_string_from_object(info_object, "thumbnail");
             description = __get_string_from_object(info_object, "description");
+            int disp_type = __get_int_from_object(info_object, "display_type");
 
             JsonArray *keyword_arr = json_object_get_array_member(info_object, "keyword");
             int keyword_arr_len = json_array_get_length(keyword_arr);
@@ -610,7 +612,7 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path
                     char *new_uri = __convert_sticker_uri(uri, appid, app_path);
                     if (!new_uri)
                         goto free_memory;
-                    __insert_sticker_info(appid, type, new_uri, group, thumbnail, description);
+                    __insert_sticker_info(appid, type, new_uri, group, thumbnail, description, disp_type);
 
                     if (new_uri) {
                         free(new_uri);
@@ -636,7 +638,7 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path
                             uri_path = NULL;
                             goto free_memory;
                         }
-                        __insert_sticker_info(appid, type, new_uri, group, thumbnail, description);
+                        __insert_sticker_info(appid, type, new_uri, group, thumbnail, description, disp_type);
 
                         free(new_uri);
                         new_uri = NULL;
@@ -651,7 +653,7 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path
                     }
                 }
             } else {
-                __insert_sticker_info(appid, type, uri, group, thumbnail, description);
+                __insert_sticker_info(appid, type, uri, group, thumbnail, description, disp_type);
             }
 
             for (int j = 0; j < keyword_arr_len; j++) {