Add a new message to notify disconnection 10/229510/1
authorInHong Han <inhong1.han@samsung.com>
Wed, 1 Apr 2020 11:07:16 +0000 (20:07 +0900)
committerInHong Han <inhong1.han@samsung.com>
Wed, 1 Apr 2020 11:07:16 +0000 (20:07 +0900)
Change-Id: Ia65b927b18b0722f74b555039f8eea70b3cc973a

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

index 0a022a6..c20f0af 100644 (file)
@@ -32,5 +32,6 @@ void deinitialize_sap(void);
 
 bool request_sticker_data(const char *mode, const char *category, const char *type);
 void request_sticker_feature();
+void send_disconnect_message();
 
 #endif /* __FT_H__ */
index bd8ae56..3e78566 100644 (file)
@@ -53,6 +53,7 @@
 #define STICKER_SEND_FACE_DATA "sticker-send-face-data"
 #define STICKER_SEND_STOP_REQ  "sticker-send-stop-req"
 #define STICKER_SEND_STOP_RSP  "sticker-send-stop-rsp"
+#define STICKER_SEND_DISCONNECT_REQ "sticker-send-disconnect-req"
 
 #ifndef VCONFKEY_STICKER_SYNC_COMPLETE_DONE
 #define VCONFKEY_STICKER_SYNC_COMPLETE_DONE 0x1
@@ -413,6 +414,25 @@ void request_sticker_feature()
         LOGE("Failed to create thumbnail directory");
 }
 
+void send_disconnect_message()
+{
+    JsonObject *j_object = NULL;
+    j_object = json_object_new();
+    if (j_object == NULL) {
+        LOGE("json object create error");
+        return;
+    }
+
+    json_object_set_string_member(j_object, "msgId", STICKER_SEND_DISCONNECT_REQ);
+    json_object_set_int_member(j_object, "tID", t_id);
+
+    if (_send_json_data(j_object) == FALSE) {
+        LOGE("Failed to send STICKER_SEND_DISCONNECT_REQ");
+    }
+
+    json_object_unref(j_object);
+}
+
 void reject_file()
 {
     int ret = sap_file_transfer_reject(priv_data.file_socket);
@@ -556,6 +576,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
 #endif
 
         if (!process_request_queue()) {
+            send_disconnect_message();
             service_app_exit();
         }
     } else if (msg_id == STICKER_SYNC_START_RSP) {
@@ -583,6 +604,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
         if (result_code != SYNC_START_RSP_SUCCESS) {
             set_sync_progressing(FALSE);
             if (!process_request_queue()) {
+                send_disconnect_message();
                 service_app_exit();
             }
         }
@@ -706,6 +728,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
 
             sync_success_cnt = 0;
 
+            send_disconnect_message();
             service_app_exit();
         }