Send request to sync after receiving sticker feature 97/240197/3
authorJihoon Kim <jihoon48.kim@samsung.com>
Tue, 4 Aug 2020 09:05:47 +0000 (18:05 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 4 Aug 2020 09:56:49 +0000 (18:56 +0900)
Change-Id: I9a719deff45a0dc5c42642fbdc35f1d820cf4a0c
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
receiver/inc/ft.h
receiver/inc/sticker_request.h
receiver/src/ft.cpp
receiver/src/main.cpp

index 6c91c66..afab92e 100644 (file)
@@ -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();
index 9fa6f2e..1aca41d 100644 (file)
@@ -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 {
index 670d30c..dd20ce5 100644 (file)
@@ -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;
index f5d8120..b874611 100644 (file)
@@ -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 {