From 98cc6afb8e303a432d8bf80e532a3537f7c02e9e Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 4 Aug 2020 18:05:47 +0900 Subject: [PATCH] Send request to sync after receiving sticker feature Change-Id: I9a719deff45a0dc5c42642fbdc35f1d820cf4a0c Signed-off-by: Jihoon Kim --- receiver/inc/ft.h | 1 + receiver/inc/sticker_request.h | 3 ++- receiver/src/ft.cpp | 48 +++++++++++++++++++++++++++++------------- receiver/src/main.cpp | 3 ++- 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index 6c91c66..afab92e 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -33,6 +33,7 @@ gboolean is_init_sap(); void request_all_sticker_data(const char *mode, const char *type); bool request_sticker_data(const char *mode, const char *category, const char *type); +void request_auto_sync(); void request_sticker_feature(); void send_disconnect_message(); void request_show_sync_notification(); diff --git a/receiver/inc/sticker_request.h b/receiver/inc/sticker_request.h index 9fa6f2e..1aca41d 100644 --- a/receiver/inc/sticker_request.h +++ b/receiver/inc/sticker_request.h @@ -24,7 +24,8 @@ using namespace std; typedef enum { REQUEST_TYPE_SYNC, REQUEST_TYPE_FEATURE_REQ, - REQUEST_TYPE_SHOW_NOTIFICATION + REQUEST_TYPE_SHOW_NOTIFICATION, + REQUEST_TYPE_AUTOSYNC } request_type; struct StickerRequest { diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 670d30c..dd20ce5 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -422,28 +422,46 @@ static bool process_request_queue() 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()); + switch (request.req_type) { + case REQUEST_TYPE_FEATURE_REQ: + LOGD("[Request feature exchange]"); + request_sticker_feature(); + ReqQueue.pop(); + break; + case 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(); - if (request_sticker_data(request.mode.c_str(), request.category.c_str(), request.type.c_str())) + break; + case REQUEST_TYPE_SHOW_NOTIFICATION: + LOGD("[Request to show notification]"); + request_show_sync_notification(); ReqQueue.pop(); - } - else if (request.req_type == REQUEST_TYPE_SHOW_NOTIFICATION) { - LOGD("[Request to show notification]"); - request_show_sync_notification(); - ReqQueue.pop(); + break; + case REQUEST_TYPE_AUTOSYNC: + LOGD("[Request to sync automatically]"); + ReqQueue.pop(); + request_all_sticker_data("auto", "input"); + break; + default: + break; } return true; } +void request_auto_sync() +{ + LOGD("Add request to sync automatically"); + StickerRequest pending_request; + pending_request.req_type = REQUEST_TYPE_AUTOSYNC; + ReqQueue.push(pending_request); +} + void request_all_sticker_data(const char *mode, const char *type) { StickerRequest pending_request; diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index f5d8120..b874611 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -185,7 +185,8 @@ static void app_control(app_control_h app_control, void *data) if (check_battery_condition()) { LOGD("Starting auto synchronization"); initialize_sap(); - request_all_sticker_data("auto", "input"); + request_sticker_feature(); + request_auto_sync(); } } else { -- 2.7.4