Send response and result to requester application 04/227004/4
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 9 Mar 2020 04:02:06 +0000 (13:02 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 9 Mar 2020 05:34:23 +0000 (14:34 +0900)
Change-Id: I7860eaee2dc6fe3253fed0d4b6324e83797fe521
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
receiver/src/ft.cpp
receiver/src/message.cpp

index 764d552..c8d83eb 100644 (file)
@@ -82,6 +82,12 @@ static struct sap_info_s priv_data = { 0 };
 static struct sticker_info sticker_data;
 static struct sync_request pending_sync_request;
 
+enum {
+    SYNC_START_RSP_SUCCESS = 1000,
+    SYNC_START_RSP_NO_STICKER = 1001,
+    SYNC_START_RSP_EXIST_STICKER = 1002
+};
+
 gboolean file_on_progress = 0;
 static string incoming_file_name;
 static int t_id = 0;
@@ -406,6 +412,22 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
         string result = string(json_result ? json_result : "");
         int result_code = json_object_get_int_member(root_obj, "resultCode");
         LOGD("result : %s, resultCode : %d", result.c_str(), result_code);
+
+        string response_to_app;
+        switch (result_code) {
+        case SYNC_START_RSP_SUCCESS:
+        case SYNC_START_RSP_EXIST_STICKER:
+            response_to_app = "success";
+            break;
+        case SYNC_START_RSP_NO_STICKER:
+            response_to_app = "no_sticker";
+            break;
+        default:
+            response_to_app = "unknown_error";
+            break;
+        }
+
+        send_message("sync_start_response", response_to_app.c_str());
     } else if (msg_id == STICKER_SEND_START_REQ) {
         LOGD("msg : %s", msg_id.c_str());
         total_file_count = 0;
@@ -502,6 +524,8 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
         if (_send_json_data(j_object) == FALSE)
             LOGE("Failed to send message");
 
+        send_message("sync_stop_result", reason.c_str());
+
         json_object_unref(j_object);
     } else
         LOGW("unknown msg id : %s", msg_id.c_str());
index 4513000..f67b29e 100644 (file)
@@ -62,6 +62,8 @@ bool send_message(const char *cmd, const char *data)
     int ret;
     bool found = false;
 
+    LOGD("command: %s, data: %s", cmd, data);
+
     message_port_check_remote_port(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, &found);
     if (!found) {
         LOGW("Can't find remote port");
@@ -78,7 +80,7 @@ bool send_message(const char *cmd, const char *data)
     }
     else
     {
-        LOGI("send message done");
+        LOGI("Succeed to send message.");
         result = true;
     }