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)
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,
}
}
- rec_file_cnt++;
+ rec_file_cnt_in_group++;
} else {
switch (result) {
case (SAP_FT_TRANSFER_FAIL_CHANNEL_IO): {
}
} 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) {
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) {
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 {
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);
bundle_free(b);
return result;
-}
\ No newline at end of file
+}