Change the sync progress method from total to each group 30/227630/7
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 13 Mar 2020 08:01:02 +0000 (17:01 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 25 Mar 2020 04:35:27 +0000 (13:35 +0900)
Change-Id: I11bf1a405cd8e69cb9b62e416c7ac45fca9b3c6e
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
receiver/src/ft.cpp
receiver/src/message.cpp

index e2b703d..e6f085b 100644 (file)
@@ -76,8 +76,8 @@ static StickerRequest current_request;
 gboolean file_on_progress = 0;
 static string incoming_file_name;
 static int t_id = 0;
-static int rec_file_cnt = 0;
-static int total_file_count = 0;
+static int rec_file_cnt_in_group = 0;
+static int total_file_count_in_group = 0;
 static int sync_success_cnt = 0;
 
 static gboolean _send_json_data(JsonObject *obj)
@@ -129,15 +129,11 @@ cleanup:
 
 static void notify_sync_progress(unsigned int file_progress)
 {
-    if (total_file_count == 0)
+    if (total_file_count_in_group == 0)
         return;
 
-    double total_progress = (((double)rec_file_cnt / (double)total_file_count) + (1.0/(double)total_file_count*file_progress/100))*100;
-
-    LOGI("(%2d / %2d), file progress : %3u%%, total progress : %3u%%", rec_file_cnt, total_file_count, file_progress, (unsigned int)total_progress);
-    char progress_str[32];
-    snprintf(progress_str, sizeof(progress_str), "%u", (unsigned int)total_progress);
-    send_message("sync_progress", progress_str);
+    LOGI("(%2d / %2d), file progress : %3u%%", rec_file_cnt_in_group+1, total_file_count_in_group, file_progress);
+    send_message("sync_progress", NULL);
 }
 
 static void _on_send_completed(sap_file_transaction_h file_transaction,
@@ -167,7 +163,7 @@ static void _on_send_completed(sap_file_transaction_h file_transaction,
             }
         }
 
-        rec_file_cnt++;
+        rec_file_cnt_in_group++;
     } else {
         switch (result) {
             case (SAP_FT_TRANSFER_FAIL_CHANNEL_IO): {
@@ -506,8 +502,8 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
         }
     } else if (msg_id == STICKER_SEND_START_REQ) {
         LOGD("msg : %s", msg_id.c_str());
-        total_file_count = 0;
-        rec_file_cnt = 0;
+        total_file_count_in_group = 0;
+        rec_file_cnt_in_group = 0;
         t_id = json_object_get_int_member(root_obj, "tID");
         JsonArray *file_list = json_object_get_array_member(root_obj, "list");
         if (file_list) {
@@ -520,7 +516,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
 
                 if (file_len > 0) {
                     LOGD("Add file : %s, len : %d", file_name.c_str(), file_len);
-                    total_file_count++;
+                    total_file_count_in_group++;
                 } else {
                     LOGD("Delete file : %s, len : %d", file_name.c_str(), file_len);
                     if (create_sticker_provider_handle() == STICKER_ERROR_NONE) {
@@ -573,7 +569,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
         json_object_set_string_member(j_object, "msgId", STICKER_SEND_STOP_RSP);
         json_object_set_int_member(j_object, "tID", t_id);
 
-        if (reason == "complete" && rec_file_cnt != file_len) {
+        if (reason == "complete" && rec_file_cnt_in_group != file_len) {
             json_object_set_string_member(j_object, "result", "failure");
         }
         else {
index f67b29e..8dde6a6 100644 (file)
@@ -72,7 +72,8 @@ bool send_message(const char *cmd, const char *data)
 
     bundle *b = bundle_create();
     bundle_add_str(b, "command", cmd);
-    bundle_add_str(b, "data", data);
+    if (data)
+        bundle_add_str(b, "data", data);
     ret = message_port_send_message(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, b);
     if (ret != MESSAGE_PORT_ERROR_NONE) {
         LOGW("message port send message error. err : %d", ret);
@@ -87,4 +88,4 @@ bool send_message(const char *cmd, const char *data)
     bundle_free(b);
 
     return result;
-}
\ No newline at end of file
+}