static gboolean job_progress = FALSE;
static int sync_complete_flags = 0;
+void push_sticker_request(request_type req_type, const char *mode, const char *category, const char *type)
+{
+ StickerRequest pending_request;
+
+ pending_request.req_type = req_type;
+
+ if (mode != NULL)
+ pending_request.mode = string(mode);
+
+ if (category != NULL)
+ pending_request.category = string(category);
+
+ if (type != NULL)
+ pending_request.type = string(type);
+
+ ReqQueue.push(pending_request);
+ STLOGI("Push sticker request: req_type[%d], mode[%s], category[%s], type[%s]",
+ pending_request.req_type, pending_request.mode.c_str(), pending_request.category.c_str(), pending_request.type.c_str());
+}
+
static void sticker_service_quit();
static void save_last_sync_info()
if (!priv_data.socket) {
job_progress = TRUE;
- StickerRequest pending_request;
- pending_request.req_type = REQUEST_TYPE_SYNC;
- pending_request.mode = string(mode ? mode : "manual");
- pending_request.category = string(category ? category : "arsticker");
- pending_request.type = string(type ? type : "input");
-
- ReqQueue.push(pending_request);
- STLOGI("Push sync request");
return false;
}
if (_send_json_data(j_object) == FALSE) {
STLOGE("Failed to send STICKER_SYNC_START_REQ");
+
result = false;
}
else {
switch (request.req_type) {
case REQUEST_TYPE_FEATURE_REQ:
STLOGD("[Request feature exchange]");
- request_sticker_feature();
+
+ if (true == 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(),
request.category.c_str(),
request.type.c_str());
- request_sticker_data(request.mode.c_str(), request.category.c_str(), request.type.c_str());
+ if (true == request_sticker_data(request.mode.c_str(), request.category.c_str(), request.type.c_str()))
+ ReqQueue.pop();
+
break;
case REQUEST_TYPE_SHOW_NOTIFICATION:
STLOGD("[Request to show notification]");
- request_show_sync_notification();
- ReqQueue.pop();
+
+ if (true == request_show_sync_notification())
+ ReqQueue.pop();
+
break;
case REQUEST_TYPE_AUTOSYNC:
STLOGD("[Request to sync automatically]");
return true;
}
-void request_auto_sync()
-{
- STLOGD("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;
- 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) {
- pending_request.category = string("arsticker");
- ReqQueue.push(pending_request);
+ push_sticker_request(REQUEST_TYPE_SYNC, mode, "arsticker", type);
}
if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) {
- pending_request.category = string("bitmoji");
- ReqQueue.push(pending_request);
+ push_sticker_request(REQUEST_TYPE_SYNC, mode, "bitmoji", type);
}
}
else
STLOGW("Failed to get value of VCONFKEY_STICKER_SUPPORTED_FEATURE");
#else
- pending_request.category = string("arsticker");
- ReqQueue.push(pending_request);
- pending_request.category = string("bitmoji");
- ReqQueue.push(pending_request);
+ push_sticker_request(REQUEST_TYPE_SYNC, mode, "arsticker", type);
+ push_sticker_request(REQUEST_TYPE_SYNC, mode, "bitmoji", type);
#endif
if (priv_data.socket)
process_request_queue();
}
-void request_sticker_feature()
+bool request_sticker_feature()
{
+ bool result = false;
JsonObject *j_object = NULL;
if (!priv_data.socket) {
job_progress = TRUE;
- StickerRequest pending_request;
- pending_request.req_type = REQUEST_TYPE_FEATURE_REQ;
- ReqQueue.push(pending_request);
- STLOGI("Push sync feature request");
- return;
+ return false;
}
j_object = json_object_new();
if (j_object == NULL) {
STLOGE("json object create error");
- return;
+ return false;
}
json_object_set_string_member(j_object, "msgId", STICKER_SYNC_FEATURE_REQ);
if (_send_json_data(j_object) == FALSE) {
STLOGE("Failed to send STICKER_SYNC_FEATURE_REQ");
+ result = false;
}
else {
job_progress = TRUE;
+ result = true;
}
json_object_unref(j_object);
if (_create_thumbnail_directory() != 0)
STLOGE("Failed to create thumbnail directory");
+
+ return result;
}
void send_disconnect_message()
json_object_unref(j_object);
}
-void request_show_sync_notification()
+bool request_show_sync_notification()
{
+ bool result = false;
JsonObject *j_object = NULL;
if (!priv_data.socket) {
job_progress = TRUE;
- StickerRequest pending_request;
- pending_request.req_type = REQUEST_TYPE_SHOW_NOTIFICATION;
- ReqQueue.push(pending_request);
- STLOGI("Push show notification request");
- return;
+ return false;
}
j_object = json_object_new();
if (j_object == NULL) {
STLOGE("json object create error");
- return;
+ return false;
}
json_object_set_string_member(j_object, "msgId", STICKER_REQUEST_NOTI_REQ);
if (_send_json_data(j_object) == FALSE) {
STLOGE("Failed to send STICKER_REQUEST_NOTI_REQ");
+ result = false;
} else {
job_progress = TRUE;
+ result = true;
}
json_object_unref(j_object);
+ return result;
}
void reject_file()
#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) */
#else
STLOGW("No vconf supported feature");
#endif
-
- pop_sticker_request(REQUEST_TYPE_FEATURE_REQ);
-
if (!process_request_queue()) {
sticker_service_quit();
}
save_last_sync_info();
sticker_service_quit();
}
-
- pop_sticker_request(REQUEST_TYPE_SYNC);
}
} else if (msg_id == STICKER_SEND_START_REQ) {
STLOGD("msg : %s", msg_id.c_str());
if (timediff > MAX_WAIT_TIME) {
STLOGD("Starting manual synchronization");
initialize_sap();
- request_show_sync_notification();
+ if (false == request_show_sync_notification())
+ push_sticker_request(REQUEST_TYPE_SHOW_NOTIFICATION, NULL, NULL, NULL);
result = false;
} else {
if (timediff > SYNC_INTERVAL)
}
else if (strcmp(request, "oobe") == 0) {
initialize_sap();
- request_sticker_feature();
+
+ if (false == request_sticker_feature())
+ push_sticker_request(REQUEST_TYPE_FEATURE_REQ, NULL, NULL, NULL);
}
else {
STLOGW("Unknown command : %s", request);
if (preference_set_int(LAST_SYNC_STATUS, LAST_SYNC_STATUS_SYNC_NEEDED) != PREFERENCE_ERROR_NONE)
STLOGE("Failed to set sync status as NEEDED");
initialize_sap();
- request_sticker_feature();
- request_auto_sync();
+
+ if (false == request_sticker_feature())
+ push_sticker_request(REQUEST_TYPE_FEATURE_REQ, NULL, NULL, NULL);
+
+ push_sticker_request(REQUEST_TYPE_AUTOSYNC, NULL, NULL, NULL);
}
else {
STLOGI("The status of battery is low");
if (last_sync_status == LAST_SYNC_STATUS_SYNC_NEEDED) {
STLOGD("Last sync status is NEEDED(code: %d). Retrying to sync.", last_sync_status);
initialize_sap();
- request_sticker_feature();
- request_auto_sync();
+
+ if (false == request_sticker_feature())
+ push_sticker_request(REQUEST_TYPE_FEATURE_REQ, NULL, NULL, NULL);
+
+ push_sticker_request(REQUEST_TYPE_AUTOSYNC, NULL, NULL, NULL);
} else {
STLOGD("Last sync status is SUCCESS(code: %d). Don't have to retrying sync", last_sync_status);
service_app_exit();
if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0 && feature_flag == 0) {
STLOGD("Request to get sticker feature");
initialize_sap();
- request_sticker_feature();
+
+ if (false == request_sticker_feature())
+ push_sticker_request(REQUEST_TYPE_FEATURE_REQ, NULL, NULL, NULL);
}
else {
if (!is_init_sap())