diff options
author | intae, jeon <intae.jeon@samsung.com> | 2016-04-20 18:01:09 +0900 |
---|---|---|
committer | intae, jeon <intae.jeon@samsung.com> | 2016-04-22 13:44:03 +0900 |
commit | 259d8f41dd1c43d0a8123a723acd82c8d64fc0eb (patch) | |
tree | cfdd65c30dc568629bc590b6e89143f10aa54e77 | |
parent | d1cb945855cd49003d60af265f54d7b0f84b22cc (diff) | |
download | email-service-259d8f41dd1c43d0a8123a723acd82c8d64fc0eb.tar.gz email-service-259d8f41dd1c43d0a8123a723acd82c8d64fc0eb.tar.bz2 email-service-259d8f41dd1c43d0a8123a723acd82c8d64fc0eb.zip |
modify download_attachment and get_task_informationsubmit/tizen/20160427.040237accepted/tizen/wearable/20160427.080453accepted/tizen/tv/20160427.080440accepted/tizen/mobile/20160427.080512accepted/tizen/ivi/20160427.080505accepted/tizen/common/20160427.054044accepted/tizen_tv
Change-Id: I3c72d4f48c237176a0af04de276c3d344417ce7e
Signed-off-by: intae, jeon <intae.jeon@samsung.com>
-rwxr-xr-x | email-common-use/email-convert.c | 2 | ||||
-rwxr-xr-x | email-common-use/include/email-types.h | 4 | ||||
-rwxr-xr-x | email-core/email-core-event.c | 84 | ||||
-rwxr-xr-x | email-core/email-core-gmime.c | 17 | ||||
-rwxr-xr-x | email-core/include/email-core-event.h | 11 | ||||
-rwxr-xr-x | utilities/test-application/testapp-others.c | 2 |
6 files changed, 107 insertions, 13 deletions
diff --git a/email-common-use/email-convert.c b/email-common-use/email-convert.c index a046f3b..57486fa 100755 --- a/email-common-use/email-convert.c +++ b/email-common-use/email-convert.c @@ -1536,7 +1536,7 @@ FINISH_OFF: } -#define EMAIL_JOB_INFORMATION_FMT "A(S(iiii))" +#define EMAIL_JOB_INFORMATION_FMT "A(S(iiiiiii))" INTERNAL_FUNC char* em_convert_task_information_to_byte_stream(email_task_information_t *input_task_information, int input_task_information_count, int *stream_len) { diff --git a/email-common-use/include/email-types.h b/email-common-use/include/email-types.h index dde0b8e..8f59526 100755 --- a/email-common-use/include/email-types.h +++ b/email-common-use/include/email-types.h @@ -1869,6 +1869,10 @@ typedef struct { int account_id; /**< The account ID for task information */ email_event_type_t type; /**< The type for task information */ email_event_status_type_t status; /**< The status for task information */ + void *task_data1; /** in general, mail_id */ + void *task_data2; /** in general, attachment_nth */ + void *task_data3; /** in general, progress */ + } email_task_information_t; typedef enum { diff --git a/email-core/email-core-event.c b/email-core/email-core-event.c index b964385..0b30645 100755 --- a/email-core/email-core-event.c +++ b/email-core/email-core-event.c @@ -527,6 +527,57 @@ FINISH_OFF: return ret; } +/* get a event from event_data queue for download_attachment*/ +INTERNAL_FUNC int emcore_retrieve_event_for_download_attachment(email_event_t **event_data, int *err_code) +{ + EM_DEBUG_FUNC_BEGIN("event_data[%p], err_code[%p]", event_data, err_code); + + int ret = false; + int error = EMAIL_ERROR_NONE; + int q_length = 0; + email_event_t *poped = NULL; + email_event_t *head_event = NULL; + + if (g_event_que) + q_length = g_queue_get_length(g_event_que); + + EM_DEBUG_LOG("Q Length : [%d]", q_length); + + if (!q_length) { + error = EMAIL_ERROR_EVENT_QUEUE_EMPTY; + EM_DEBUG_LOG("QUEUE is empty"); + goto FINISH_OFF; + } + + head_event = (email_event_t *)g_queue_peek_head(g_event_que); + if (!head_event) { + error = EMAIL_ERROR_EVENT_QUEUE_EMPTY; + EM_DEBUG_LOG_DEV("QUEUE is empty"); + + } else if (head_event->status != EMAIL_EVENT_STATUS_STARTED) { + EM_DEBUG_LOG("EVENT STATUS [%d]", head_event->status); + error = EMAIL_ERROR_NO_MORE_DATA; + EM_DEBUG_LOG("get event data err"); + + } else { + *event_data = head_event; + ret = true; + + } + + +FINISH_OFF: + + if (err_code != NULL) + *err_code = error; + + EM_DEBUG_FUNC_END("ret [%d]", ret); + return ret; +} + + + + /* check that event_data loop is continuous */ INTERNAL_FUNC int emcore_event_loop_continue(void) { @@ -1365,12 +1416,33 @@ INTERNAL_FUNC int emcore_get_task_information(email_task_information_t **output_ for (i = 0; i < q_length; i++) { elm = (email_event_t *)g_queue_peek_nth(g_event_que, i); - if (elm && (elm->type != EMAIL_EVENT_NONE && elm->status != EMAIL_EVENT_STATUS_CANCELED)) { - task_information[index].handle = elm->handle; - task_information[index].account_id = elm->account_id; - task_information[index].type = elm->type; - task_information[index].status = elm->status; - index++; + if(elm->type != EMAIL_EVENT_DOWNLOAD_ATTACHMENT) { + if (elm && (elm->type != EMAIL_EVENT_NONE && elm->status != EMAIL_EVENT_STATUS_CANCELED)) { + task_information[index].handle = elm->handle; + task_information[index].account_id = elm->account_id; + task_information[index].type = elm->type; + task_information[index].status = elm->status; + task_information[index].task_data1 = 0; + task_information[index].task_data2 = 0; + task_information[index].task_data3 = 0; + index++; + + } + }else if(elm->type == EMAIL_EVENT_DOWNLOAD_ATTACHMENT) { + if (elm && (elm->type != EMAIL_EVENT_NONE && elm->status != EMAIL_EVENT_STATUS_CANCELED)) { + + task_information[index].task_data1 = (void *)elm->event_param_data_4; /* mail_id */ + task_information[index].task_data2 = (void *)elm->event_param_data_5; /* attachment_nth */ + task_information[index].task_data3 = (void *)elm->event_param_data_8; /* download progress */ + + task_information[index].handle = elm->handle; + task_information[index].account_id = elm->account_id; + task_information[index].type = elm->type; + task_information[index].status = elm->status; + + index++; + } + } } diff --git a/email-core/email-core-gmime.c b/email-core/email-core-gmime.c index 4796e4d..11881da 100755 --- a/email-core/email-core-gmime.c +++ b/email-core/email-core-gmime.c @@ -4418,6 +4418,17 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream, GMimeMessagePart *mime_message_part = NULL; search_section *search_info = NULL; + + EM_DEBUG_LOG("get event data for progress"); + email_event_t *event_data = NULL; + if(!emcore_retrieve_event_for_download_attachment(&event_data, &err)){ + + EM_DEBUG_LOG("fail get event data"); + } + + + + if (!stream || !cnt_info || !message) { EM_DEBUG_EXCEPTION_SEC("stream[%p], section[%s], cnt_info[%p], message[%p]", stream, cnt_info, message); @@ -4833,6 +4844,12 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream, EM_DEBUG_LOG("DOWNLOADING STATUS NOTIFY : received[%d] / total_size[%d] = %d %% Completed", downloaded_size, download_total_size, (int)((float)downloaded_size / (float)download_total_size * 100.0)); + if (event_data) { + event_data->event_param_data_8 = (int)((float)downloaded_size / (float)download_total_size * 100.0); + + } + + if (((last_notified_download_size + download_noti_interval) <= downloaded_size) || (downloaded_size >= download_total_size)) { if (downloaded_size > download_total_size) diff --git a/email-core/include/email-core-event.h b/email-core/include/email-core-event.h index 006107e..51e1076 100755 --- a/email-core/include/email-core-event.h +++ b/email-core/include/email-core-event.h @@ -4,7 +4,7 @@ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com> -* +* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -24,9 +24,9 @@ * File : email-core-event.h * Desc : Mail Engine Event Header * - * Auth : + * Auth : * - * History : + * History : * 2006.08.16 : created *****************************************************************************/ #ifndef __EMAIL_CORE_EVNET_H__ @@ -67,6 +67,7 @@ INTERNAL_FUNC int emcore_event_loop_continue(void); INTERNAL_FUNC int emcore_is_event_queue_empty(void); INTERNAL_FUNC int emcore_is_send_event_queue_empty(void); INTERNAL_FUNC int emcore_retrieve_event(email_event_t **event_data, int *err_code); +INTERNAL_FUNC int emcore_retrieve_event_for_download_attachment(email_event_t **event_data, int *err_code); INTERNAL_FUNC int emcore_return_handle(int handle); INTERNAL_FUNC int emcore_retrieve_send_event(email_event_t **event_data, int *err_code); INTERNAL_FUNC int emcore_return_send_handle(int handle); @@ -78,8 +79,8 @@ INTERNAL_FUNC int emcore_set_pbd_thd_state(int flag); INTERNAL_FUNC void emcore_get_sync_fail_event_data(email_event_t **event_data); /* -NOTE: The event is subject to event thread worker. - Don't be confused with other events +NOTE: The event is subject to event thread worker. + Don't be confused with other events */ #define FINISH_OFF_IF_EVENT_CANCELED(err, handle) \ do {\ diff --git a/utilities/test-application/testapp-others.c b/utilities/test-application/testapp-others.c index a892daa..2db9c83 100755 --- a/utilities/test-application/testapp-others.c +++ b/utilities/test-application/testapp-others.c @@ -118,7 +118,7 @@ static gboolean testapp_test_get_task_information() testapp_print("\n======================================================================\n"); for (i = 0; i < task_information_count; i++) - testapp_print("type[%d], account_id[%d], handle[%d], status[%d]", task_information_array[i].type, task_information_array[i].account_id, task_information_array[i].handle, task_information_array[i].status); + testapp_print("type[%d], account_id[%d], handle[%d], status[%d] nth[%d] progress[%d] mail_id[%d]", task_information_array[i].type, task_information_array[i].account_id, task_information_array[i].handle, task_information_array[i].status,(int)task_information_array[i].task_data2, (int)task_information_array[i].task_data3, task_information_array[i].task_data1 ); testapp_print("\n======================================================================\n"); testapp_print("testapp_test_get_task_information ..........End\n"); |