Add interface to update sticker display type 99/227799/3
authorInHong Han <inhong1.han@samsung.com>
Mon, 16 Mar 2020 10:29:11 +0000 (19:29 +0900)
committerInHong Han <inhong1.han@samsung.com>
Wed, 18 Mar 2020 05:05:32 +0000 (05:05 +0000)
Change-Id: I34f96920bc8acb6aab9c76395732dfa084297e8c

client/sticker_dbus.c
server/stickerd_data_manager.c
server/stickerd_data_manager.h
server/stickerd_db_manager.c

index cef8b8c..242e978 100644 (file)
@@ -702,6 +702,13 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_
             LOGE("failed to update sticker group");
     }
 
+    if (sticker_data->disp_type != 0 && sticker_data->disp_type != origin_data->disp_type) {
+        LOGD("origin_disp_type : %d, new_disp_type : %d", origin_data->disp_type, sticker_data->disp_type);
+        ret = _send_sync_message(gdbus_connection, g_variant_new("(ii)", sticker_data->sticker_info_id, sticker_data->disp_type), &reply, "update_sticker_disp_type");
+        if (ret != STICKER_CLIENT_ERROR_NONE)
+            LOGE("failed to update sticker display type");
+    }
+
     if (sticker_data->keyword) {
         GVariantBuilder *keyword_builder;
         keyword_builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
index 9b344d4..414fc12 100644 (file)
@@ -143,6 +143,8 @@ static void _stickerd_client_dbus_method_call_handler(GDBusConnection *conn, con
         ret = stickerd_get_sticker_info_by_display_type(parameters, &reply_body);
     } else if (g_strcmp0(method_name, "get_group_list_by_disp_type") == 0) {
         ret = stickerd_get_group_list_by_disp_type(parameters, &reply_body);
+    } else if (g_strcmp0(method_name, "update_sticker_disp_type") == 0) {
+        ret = stickerd_update_sticker_disp_type(parameters, &reply_body);
     }
 
     if (ret == STICKERD_SERVER_ERROR_NONE) {
@@ -294,6 +296,11 @@ int stickerd_register_dbus_interface(void)
             "          <arg type='i' name='disp_type' direction='in'/>"
             "          <arg type='a(s)' name='group_list' direction='out'/>"
             "        </method>"
+
+            "        <method name='update_sticker_disp_type'>"
+            "          <arg type='i' name='record_id' direction='in'/>"
+            "          <arg type='i' name='disp_type' direction='in'/>"
+            "        </method>"
             "  </interface>"
             "  </node>";
 
@@ -1432,4 +1439,27 @@ int stickerd_get_group_list_by_disp_type(GVariant *parameters, GVariant **reply_
     }
 
     return ret;
+}
+
+int stickerd_update_sticker_disp_type(GVariant *parameters, GVariant **reply_body)
+{
+    int ret;
+    int record_id;
+    int disp_type;
+
+    *reply_body = g_variant_new("()");
+    if (*reply_body == NULL) {
+        LOGE("Failed to create reply_body");
+        return STICKERD_SERVER_ERROR_OPERATION_FAILED;
+    }
+
+    g_variant_get(parameters, "(ii)", &record_id, &disp_type);
+
+    ret = stickerd_db_update_sticker_info(record_id, STICKER_DB_STICKER_DISP_TYPE, &disp_type);
+    if (ret != STICKERD_SERVER_ERROR_NONE) {
+        LOGE("Failed to update sticker disp_type");
+        return STICKERD_SERVER_ERROR_OPERATION_FAILED;
+    }
+
+    return ret;
 }
\ No newline at end of file
index 0c4c979..e8e3a9e 100644 (file)
@@ -45,6 +45,7 @@ int stickerd_get_sticker_info_by_group(GVariant *parameters, GVariant **reply_bo
 int stickerd_get_sticker_info_by_keyword(GVariant *parameters, GVariant **reply_body);
 int stickerd_get_sticker_info_by_display_type(GVariant *parameters, GVariant **reply_body);
 int stickerd_get_group_list_by_disp_type(GVariant *parameters, GVariant **reply_body);
+int stickerd_update_sticker_disp_type(GVariant *parameters, GVariant **reply_body);
 
 #ifdef __cplusplus
 }
index bc172e2..3b54fb4 100644 (file)
@@ -69,6 +69,7 @@
 #define STICKER_DB_UPDATE_STICKER_THUMBNAIL "UPDATE sticker_info SET thumbnail = ?, date = DateTime('now','localtime') WHERE sticker_info_id = ?"
 #define STICKER_DB_UPDATE_STICKER_DESCRIPTION "UPDATE sticker_info SET description = ?, date = DateTime('now','localtime') WHERE sticker_info_id = ?"
 #define STICKER_DB_UPDATE_STICKER_GROUP "UPDATE sticker_info SET group_name = ?, date = DateTime('now','localtime') WHERE sticker_info_id = ?"
+#define STICKER_DB_UPDATE_STICKER_DISP_TYPE "UPDATE sticker_info SET display_type = ?, date = DateTime('now','localtime') WHERE sticker_info_id = ?"
 
 #define STICKER_DB_GET_LATEST_RECORD_ID "SELECT sticker_info_id FROM sticker_info ORDER BY sticker_info_id DESC LIMIT 1"
 #define STICKER_DB_GET_STICKER_INFO_BY_RECORD_ID "SELECT * FROM sticker_info WHERE sticker_info_id = ?"
@@ -116,6 +117,9 @@ static const char *_db_get_query(sticker_info_db_type sticker_type, command_type
             case STICKER_DB_STICKER_KEYWORD:
             query = STICKER_DB_DELETE_STICKER_KEYWORD_INFO;
             break;
+            case STICKER_DB_STICKER_DISP_TYPE:
+            query = STICKER_DB_UPDATE_STICKER_DISP_TYPE;
+            break;
             default :
             query = "";
             break;
@@ -438,7 +442,7 @@ int stickerd_db_update_sticker_info(int record_id, sticker_info_db_type type, vo
         goto cleanup;
     }
 
-    if (type == STICKER_DB_STICKER_TYPE) {
+    if (type == STICKER_DB_STICKER_TYPE || type == STICKER_DB_STICKER_DISP_TYPE) {
         sqlite3_bind_int(stmt, 1, *(int *)data);
     } else if (type == STICKER_DB_STICKER_KEYWORD) {
         sqlite3_bind_int(stmt, 1, record_id);