From 20bb66aa2c1c8df0a32d52861288a54039688374 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Sat, 10 Oct 2020 13:40:49 +0900 Subject: [PATCH] Support to request sticker sync when BT connects after disconnecting Change-Id: I9d0b876024eab482fbe3ac38c73f4dbcfcab07dd Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 4467722..9a684cb 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -449,16 +449,13 @@ static bool process_request_queue() case REQUEST_TYPE_FEATURE_REQ: STLOGD("[Request feature exchange]"); request_sticker_feature(); - ReqQueue.pop(); break; case REQUEST_TYPE_SYNC: - STLOGD("[Request to sync sticker] mode: %s, category: %s, type : %s", request.mode.c_str(), + STLOGD("[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(); - + request_sticker_data(request.mode.c_str(), request.category.c_str(), request.type.c_str()); break; case REQUEST_TYPE_SHOW_NOTIFICATION: STLOGD("[Request to show notification]"); @@ -662,7 +659,6 @@ static void _on_connection_terminated(sap_peer_agent_h peer_agent, set_sync_progressing(FALSE); send_message("sync_stop_result", "cancel"); - sticker_service_quit(); } static void sticker_service_quit() @@ -745,6 +741,19 @@ static void send_sync_start_response(int result_code) #endif } +static void pop_sticker_request(request_type req_type) +{ + if (ReqQueue.empty()) + return; + + StickerRequest request = ReqQueue.front(); + STLOGD ("request type : %d", request.req_type); + if (request.req_type == req_type) { + STLOGD ("pop sync request"); + ReqQueue.pop(); + } +} + void on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned int payload_length, void *buffer, void *user_data) /* message exchange on_receive callback (sap_agent_data_received_cb) */ @@ -805,6 +814,8 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in STLOGW("No vconf supported feature"); #endif + pop_sticker_request(REQUEST_TYPE_FEATURE_REQ); + if (!process_request_queue()) { sticker_service_quit(); } @@ -865,6 +876,8 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in sticker_service_quit(); } + + pop_sticker_request(REQUEST_TYPE_SYNC); } } else if (msg_id == STICKER_SEND_START_REQ) { STLOGD("msg : %s", msg_id.c_str()); -- 2.7.4