Set sticker feature flag 55/227455/4
authorInHong Han <inhong1.han@samsung.com>
Thu, 12 Mar 2020 05:21:50 +0000 (14:21 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 12 Mar 2020 11:32:36 +0000 (20:32 +0900)
Change-Id: Ibf6b8dd884a450101f3300b3ff5414523aa549ec

receiver/inc/ft.h
receiver/src/ft.cpp
receiver/src/main.cpp

index 271a98f..c6cbb63 100644 (file)
@@ -31,5 +31,6 @@ void deinitialize_sap(void);
 
 void sap_file_transfer_get_receive_filepath(char **filepath);
 void request_sticker_data(const char *mode, const char *category, const char *type);
+void request_sticker_feature();
 
 #endif /* __FT_H__ */
index 53427fb..4e26d73 100644 (file)
@@ -41,6 +41,8 @@
 #define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender"
 #define ACCESSORY_SERVICE_CHANNEL_ID 107
 
+#define STICKER_SYNC_FEATURE_REQ "sticker-sync-feature-req"
+#define STICKER_SYNC_FEATURE_RSP "sticker-sync-feature-rsp"
 #define STICKER_SYNC_START_REQ "sticker-sync-start-req"
 #define STICKER_SYNC_START_RSP "sticker-sync-start-rsp"
 #define STICKER_SEND_START_REQ "sticker-send-start-req"
 
 using namespace std;
 
+typedef enum {
+    REQUEST_TYPE_SYNC,
+    REQUEST_TYPE_FEATURE_REQ
+} request_type;
+
+enum {
+    SYNC_START_RSP_SUCCESS = 1000,
+    SYNC_START_RSP_NO_STICKER = 1001,
+    SYNC_START_RSP_EXIST_STICKER = 1002
+};
+
 struct sap_info_s {
     sap_agent_h agent;
     sap_socket_h socket;
@@ -58,7 +71,8 @@ struct sap_info_s {
     sap_file_transaction_h file_socket;
 };
 
-struct sync_request {
+struct request {
+    request_type req_type;
     string mode;
     string category;
     string type;
@@ -81,13 +95,7 @@ struct sticker_info {
 
 static struct sap_info_s priv_data = { 0 };
 static struct sticker_info sticker_data;
-static struct sync_request pending_sync_request, current_sync_request;
-
-enum {
-    SYNC_START_RSP_SUCCESS = 1000,
-    SYNC_START_RSP_NO_STICKER = 1001,
-    SYNC_START_RSP_EXIST_STICKER = 1002
-};
+static struct request pending_request, current_request;
 
 gboolean file_on_progress = 0;
 static string incoming_file_name;
@@ -298,16 +306,37 @@ void request_sticker_data(const char *mode, const char *category, const char *ty
     json_object_set_string_member(j_object, "type", type);
 
     if (_send_json_data(j_object) == FALSE) {
-        pending_sync_request.mode = string(mode ? mode : "manual");
-        pending_sync_request.category = string(category? category : "arsticker");
-        pending_sync_request.type = string(type ? type : "input");
+        pending_request.req_type = REQUEST_TYPE_SYNC;
+        pending_request.mode = string(mode ? mode : "manual");
+        pending_request.category = string(category? category : "arsticker");
+        pending_request.type = string(type ? type : "input");
 
         LOGI("Push sync request");
     }
     else {
-        current_sync_request.mode = string(mode ? mode : "manual");
-        current_sync_request.category = string(category? category : "arsticker");
-        current_sync_request.type = string(type ? type : "input");
+        current_request.req_type = REQUEST_TYPE_SYNC;
+        current_request.mode = string(mode ? mode : "manual");
+        current_request.category = string(category? category : "arsticker");
+        current_request.type = string(type ? type : "input");
+    }
+
+    json_object_unref(j_object);
+}
+
+void request_sticker_feature()
+{
+    JsonObject *j_object = json_object_new();
+    if (j_object == NULL) {
+        LOGE("json object create error");
+        return;
+    }
+
+    json_object_set_string_member(j_object, "msgId", STICKER_SYNC_FEATURE_REQ);
+    json_object_set_int_member(j_object, "tID", ++t_id);
+
+    if (_send_json_data(j_object) == FALSE) {
+        pending_request.req_type = REQUEST_TYPE_FEATURE_REQ;
+        LOGE("Failed to send STICKER_SYNC_FEATURE_REQ");
     }
 
     json_object_unref(j_object);
@@ -412,7 +441,27 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
 
     json_msgid = json_object_get_string_member(root_obj, "msgId");
     msg_id = string(json_msgid ? json_msgid : "");
-    if (msg_id == STICKER_SYNC_START_RSP) {
+    if (msg_id == STICKER_SYNC_FEATURE_RSP) {
+        LOGD("msg : %s", msg_id.c_str());
+        const char *json_aremoji = json_object_get_string_member(root_obj, "arEmoji");
+        const char *json_bitmoji = json_object_get_string_member(root_obj, "bitmoji");
+        string support_aremoji = string(json_aremoji ? json_aremoji : "");
+        string support_bitmoji = string(json_bitmoji ? json_bitmoji : "");
+        int supported_feature = VCONFKEY_STICKER_FEATURE_NONE;
+
+        if (support_aremoji == "support")
+            supported_feature |= VCONFKEY_STICKER_FEATURE_AREMOJI;
+
+        if (support_bitmoji == "support")
+            supported_feature |= VCONFKEY_STICKER_FEATURE_BITMOJI;
+
+        if (vconf_set_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, supported_feature) == 0)
+            LOGD("Succeed to set supported feature");
+        else
+            LOGW("Fail to set supported feature");
+
+        service_app_exit();
+    } else if (msg_id == STICKER_SYNC_START_RSP) {
         LOGD("msg : %s", msg_id.c_str());
         const char *json_result = json_object_get_string_member(root_obj, "result");
         string result = string(json_result ? json_result : "");
@@ -529,7 +578,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
 
             json_object_set_string_member(j_object, "result", "success");
 
-            if (current_sync_request.mode == string("manual")) {
+            if (current_request.mode == string("manual")) {
                 if (!sync_alarm_exist())
                     sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL);
             }
@@ -542,9 +591,9 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
 
         json_object_unref(j_object);
 
-        current_sync_request.mode.clear();
-        current_sync_request.category.clear();
-        current_sync_request.type.clear();
+        current_request.mode.clear();
+        current_request.category.clear();
+        current_request.type.clear();
     } else
         LOGW("unknown msg id : %s", msg_id.c_str());
 
@@ -617,16 +666,24 @@ _on_service_connection_created(sap_peer_agent_h peer_agent,
         priv->socket = socket;
         LOGI("Connection Established");
 
-        if (!pending_sync_request.mode.empty()) {
-            LOGD("[Request to sync sticker] mode: %s, category: %s, type : %s", pending_sync_request.mode.c_str(),
-                                                                                pending_sync_request.category.c_str(),
-                                                                                pending_sync_request.type.c_str());
+        LOGD("pending_request : %d", pending_request.req_type);
+
+        if (pending_request.req_type == REQUEST_TYPE_FEATURE_REQ) {
+            LOGD("[Request feature exchange]");
+            request_sticker_feature();
+        }
+        else if (pending_request.req_type == REQUEST_TYPE_SYNC) {
+            if (!pending_request.mode.empty()) {
+                LOGD("[Request to sync sticker] mode: %s, category: %s, type : %s", pending_request.mode.c_str(),
+                                                                                    pending_request.category.c_str(),
+                                                                                    pending_request.type.c_str());
 
-            request_sticker_data(pending_sync_request.mode.c_str(), pending_sync_request.category.c_str(), pending_sync_request.type.c_str());
+                request_sticker_data(pending_request.mode.c_str(), pending_request.category.c_str(), pending_request.type.c_str());
 
-            pending_sync_request.mode.clear();
-            pending_sync_request.category.clear();
-            pending_sync_request.type.clear();
+                pending_request.mode.clear();
+                pending_request.category.clear();
+                pending_request.type.clear();
+            }
         }
 
         break;
index 115d278..3799557 100644 (file)
@@ -96,7 +96,7 @@ static void app_control(app_control_h app_control, void *data)
         else if (strcmp(request, "oobe") == 0) {
             LOGI("[OOBE] register sync alarm");
             sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL);
-            service_app_exit();
+            request_sticker_feature();
         }
         else
         {