From e67386207a9fd8cbac33b656086987dab3fddfea Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 7 May 2020 19:12:50 +0900 Subject: [PATCH] Fix issue auto synchronization does not work Change-Id: I344a1a4e209a4b902cc97d90e80dba565d34624c --- receiver/src/ft.cpp | 84 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 29450fa..98870c8 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -415,24 +415,67 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty return result; } +static bool process_request_queue() +{ + if (ReqQueue.empty()) + return false; + + StickerRequest request = ReqQueue.front(); + + if (request.req_type == REQUEST_TYPE_FEATURE_REQ) { + LOGD("[Request feature exchange]"); + request_sticker_feature(); + ReqQueue.pop(); + } + else if (request.req_type == REQUEST_TYPE_SYNC) { + LOGD("[Request to sync sticker] mode: %s, category: %s, type : %s", request.mode.c_str(), + request.category.c_str(), + request.type.c_str()); + + if (request_sticker_data(request.mode.c_str(), request.category.c_str(), request.type.c_str())) + ReqQueue.pop(); + } + else if (request.req_type == REQUEST_TYPE_SHOW_NOTIFICATION) { + LOGD("[Request to show notification]"); + request_show_sync_notification(); + ReqQueue.pop(); + } + + return true; +} + void request_all_sticker_data(const char *mode, const char *type) { + StickerRequest pending_request; + pending_request.req_type = REQUEST_TYPE_SYNC; + pending_request.mode = string(mode); + pending_request.type = string(type); + #ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE int feature_flag = 0; if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0) { - if (feature_flag & VCONFKEY_STICKER_FEATURE_AREMOJI) - request_sticker_data(mode, "arsticker", type); + if (feature_flag & VCONFKEY_STICKER_FEATURE_AREMOJI) { + pending_request.category = string("arsticker"); + ReqQueue.push(pending_request); + } - if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) - request_sticker_data(mode, "bitmoji", type); + if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) { + pending_request.category = string("bitmoji"); + ReqQueue.push(pending_request); + } } else LOGW("Failed to get value of VCONFKEY_STICKER_SUPPORTED_FEATURE"); #else - request_sticker_data(mode, "arsticker", type); - request_sticker_data(mode, "bitmoji", type); + pending_request.category = string("arsticker"); + ReqQueue.push(pending_request); + pending_request.category = string("bitmoji"); + ReqQueue.push(pending_request); #endif + + if (priv_data.socket) + process_request_queue(); } void request_sticker_feature() @@ -578,35 +621,6 @@ void conn_terminated(sap_peer_agent_h peer_agent, service_app_exit(); } -static bool process_request_queue() -{ - if (ReqQueue.empty()) - return false; - - StickerRequest request = ReqQueue.front(); - - if (request.req_type == REQUEST_TYPE_FEATURE_REQ) { - LOGD("[Request feature exchange]"); - request_sticker_feature(); - ReqQueue.pop(); - } - else if (request.req_type == REQUEST_TYPE_SYNC) { - LOGD("[Request to sync sticker] mode: %s, category: %s, type : %s", request.mode.c_str(), - request.category.c_str(), - request.type.c_str()); - - if (request_sticker_data(request.mode.c_str(), request.category.c_str(), request.type.c_str())) - ReqQueue.pop(); - } - else if (request.req_type == REQUEST_TYPE_SHOW_NOTIFICATION) { - LOGD("[Request to show notification]"); - request_show_sync_notification(); - ReqQueue.pop(); - } - - return true; -} - static void quit() { job_progress = FALSE; -- 2.7.4