int size = 0;
int err = EMAIL_ERROR_NONE;
- if (account == NULL || account->user_email_address == NULL || account->incoming_server_user_name == NULL || account->incoming_server_address == NULL||
+ if (account == NULL || account->user_email_address == NULL ||
+ account->incoming_server_user_name == NULL || account->incoming_server_address == NULL||
account->outgoing_server_user_name == NULL || account->outgoing_server_address == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
return EMAIL_ERROR_INVALID_PARAM;
return err;
}
-EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, int input_on_server, int *output_handle)
+EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_id_array,
+ int input_mailbox_id_count, int input_on_server,
+ int *output_handle)
{
- EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id_array[%p] input_mailbox_id_count[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id_array, input_mailbox_id_array, input_mailbox_id_count, input_on_server, output_handle);
+ EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id_array[%p] "
+ "input_mailbox_id_count[%d] input_on_server[%d] "
+ "output_handle[%p]", input_mailbox_id_array, input_mailbox_id_array,
+ input_mailbox_id_count, input_on_server, output_handle);
+
int err = EMAIL_ERROR_NONE;
char *multi_user_name = NULL;
email_account_server_t account_server_type;
}
/* check account bind type and branch off */
- if (em_get_account_server_type_by_account_id(multi_user_name, input_account_id, &account_server_type, false, &err) == false) {
+ if (em_get_account_server_type_by_account_id(multi_user_name,
+ input_account_id,
+ &account_server_type,
+ false,
+ &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
task_parameter.mailbox_id_count = input_mailbox_id_count;
task_parameter.on_server = input_on_server;
- if ((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, &task_parameter)) != EMAIL_ERROR_NONE) {
+ if ((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX,
+ &task_parameter)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("execute_proxy_task failed [%d]", err);
goto FINISH_OFF;
}
EXPORT_API int email_sync_header_for_all_account(int *handle)
{
EM_DEBUG_API_BEGIN ("handle[%p]", handle);
- char* mailbox_stream = NULL;
char *multi_user_name = NULL;
int err = EMAIL_ERROR_NONE;
HIPC_API hAPI = NULL;
if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
- EM_SAFE_FREE(mailbox_stream);
+ EM_SAFE_FREE(multi_user_name);
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
{
EM_DEBUG_API_BEGIN ("mail_id[%d] nth[%d] handle[%p]", mail_id, nth, handle);
- char* mailbox_stream = NULL;
int err = EMAIL_ERROR_NONE;
emstorage_mail_tbl_t* mail_table_data = NULL;
int account_id = 0;
/* Execute API */
if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
- EM_SAFE_FREE(mailbox_stream);
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
return err;
}
-EXPORT_API int email_search_mail_on_server(int input_account_id, int input_mailbox_id, email_search_filter_t *input_search_filter_list, int input_search_filter_count, int *output_handle)
+EXPORT_API int email_search_mail_on_server(int input_account_id,
+ int input_mailbox_id,
+ email_search_filter_t *input_search_filter_list,
+ int input_search_filter_count,
+ int *output_handle)
{
- EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id[%d] input_search_filter_list[%p] input_search_filter_count[%d] output_handle[%p]", input_account_id, input_mailbox_id, input_search_filter_list, input_search_filter_count, output_handle);
+ EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id[%d] input_search_filter_list[%p] "
+ "input_search_filter_count[%d] output_handle[%p]",
+ input_account_id, input_mailbox_id, input_search_filter_list,
+ input_search_filter_count, output_handle);
int err = EMAIL_ERROR_NONE;
int return_value = 0;
memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
- if ( em_get_account_server_type_by_account_id(multi_user_name, input_account_id, &account_server_type, true, &err) == false ) {
+ if (em_get_account_server_type_by_account_id(multi_user_name,
+ input_account_id,
+ &account_server_type,
+ true,
+ &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
goto FINISH_OFF;
}
- if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+ if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
int as_handle = 0;
- if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+ if (em_get_handle_for_activesync(&as_handle, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
goto FINISH_OFF;
}
return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER, &as_noti_data);
- if ( return_value == false ) {
+ if (return_value == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if(output_handle)
+ if (output_handle)
*output_handle = as_handle;
}
else
EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_account_id, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_account_id, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
goto FINISH_OFF;
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_mailbox_id, sizeof(int))){
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_mailbox_id, sizeof(int))){
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
goto FINISH_OFF;
}
- stream_for_search_filter_list = em_convert_search_filter_to_byte_stream(input_search_filter_list, input_search_filter_count, &stream_size_for_search_filter_list);
+ stream_for_search_filter_list = em_convert_search_filter_to_byte_stream(input_search_filter_list,
+ input_search_filter_count,
+ &stream_size_for_search_filter_list);
EM_PROXY_IF_NULL_RETURN_VALUE(stream_for_search_filter_list, hAPI, EMAIL_ERROR_NULL_VALUE);
- if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, stream_for_search_filter_list, stream_size_for_search_filter_list)) { /*prevent 18950*/
+ if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN,
+ stream_for_search_filter_list,
+ stream_size_for_search_filter_list)) { /*prevent 18950*/
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
goto FINISH_OFF;
}
- if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
- if ( em_get_account_server_type_by_account_id(multi_user_name, input_account_id, &account_server_type, true, &err) == false ) {
+ if (em_get_account_server_type_by_account_id(multi_user_name,
+ input_account_id,
+ &account_server_type,
+ true,
+ &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
goto FINISH_OFF;
}
- if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+ if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
int as_handle = 0;
- if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+ if (em_get_handle_for_activesync(&as_handle, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
goto FINISH_OFF;
}
as_noti_data.clear_result_of_search_mail_on_server.account_id = input_account_id;
as_noti_data.clear_result_of_search_mail_on_server.multi_user_name = multi_user_name;
- return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER, &as_noti_data);
-
- if ( return_value == false ) {
+ return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER,
+ &as_noti_data);
+ if (return_value == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
FINISH_OFF:
- if(hAPI) {
+ if (hAPI) {
emipc_destroy_email_api(hAPI);
hAPI = NULL;
}
}
if (input_mail_data->smime_type == EMAIL_SMIME_SIGNED) {
- emcore_init_openssl_library();
+ emcore_init_openssl_library();
if (!emcore_verify_signature(input_attachment_data[count].attachment_path, input_mail_data->file_path_mime_entity, verify, &err))
EM_DEBUG_EXCEPTION("emcore_verify_signature failed : [%d]", err);
- emcore_clean_openssl_library();
+ emcore_clean_openssl_library();
} else if(input_mail_data->smime_type == EMAIL_PGP_SIGNED) {
if ((err = emcore_pgp_get_verify_signature(input_attachment_data[count].attachment_path, input_mail_data->file_path_mime_entity, input_mail_data->digest_type, verify)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_pgp_get_verify_siganture failed : [%d]", err);
c++;
}
- EM_DEBUG_LOG("original fmt : [%s]", fmt);
- EM_DEBUG_LOG("converted_fmt : [%s]", converted_fmt);
+ EM_DEBUG_LOG_DEV("original fmt : [%s]", fmt);
+ EM_DEBUG_LOG_DEV("converted_fmt : [%s]", converted_fmt);
ret = true;
case EMAIL_SEARCH_FILTER_TYPE_TO :
case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET :
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED :
result_stream = append_string_to_stream(result_stream, &stream_size, input_search_filter_list[i].search_filter_key_value.string_type_key_value);
break;
case EMAIL_SEARCH_FILTER_TYPE_TO :
case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET :
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED :
fetch_string_from_stream(input_stream, &stream_offset, &(local_search_filter[i].search_filter_key_value.string_type_key_value));
break;
return NULL;
}
- void *p = calloc(1,len);
- if (!p)
+ void *p = NULL;
+ p = malloc(len);
+ if (!p) {
EM_DEBUG_PERROR("malloc failed");
+ return NULL;
+ }
+ memset(p, 0x00, len);
return p;
}
EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, /* string type */ /**< Messages with specified message ID */
EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY = 50, /* integer type */ /**< Messages that have a header with the specified priority */
EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME = 60, /* string type */ /**< Messages that contain the specified string in attachment name */
+ EMAIL_SEARCH_FILTER_TYPE_CHARSET = 61, /* string type */ /**< Messages of encoded type */
+ EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED = 62, /* string type */ /**< Messages that extend and user defined string */
} email_search_filter_type;
typedef enum {
error_code_from_account_svc = account_delete_from_db_by_id(account_to_be_deleted->account_svc_id);
EM_DEBUG_LOG("account_delete_from_db_by_id returns [%d]", error_code_from_account_svc);
- emcore_unset_join_zone(join_zone);
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
}
if (account_to_be_deleted) {
if(error_code != ACCOUNT_ERROR_NONE) {
EM_DEBUG_EXCEPTION("account_create failed [%d]", error_code);
err = error_code;
- emcore_unset_join_zone(join_zone);
+ if (join_zone) emcore_unset_join_zone(join_zone);
goto FINISH_OFF;
}
if (account_handle)
account_destroy(account_handle);
- emcore_unset_join_zone(join_zone);
+ if (join_zone) emcore_unset_join_zone(join_zone);
}
}
}
snprintf(uid_str, sizeof(uid_str), "%ld", event_data->server_mail_id);
- if (!emstorage_get_maildata_by_servermailid(event_data->multi_user_name, event_data->mailbox_id, uid_str, &mail, true, &err) || !mail) {
+ if (!emstorage_get_maildata_by_servermailid(event_data->multi_user_name,
+ uid_str,
+ event_data->mailbox_id,
+ &mail,
+ true,
+ &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_data_by_servermailid failed : [%d]", err);
}
else {
FINISH_OFF:
if (!event_pushed) {
- EM_SAFE_FREE(ad_event->multi_user_name);
- EM_SAFE_FREE(ad_event);
+ if (ad_event) {
+ EM_SAFE_FREE(ad_event->multi_user_name);
+ free(ad_event);
+ }
}
EM_DEBUG_FUNC_END();
goto FINISH_OFF;
}
- EM_DEBUG_EXCEPTION("emcore_load_PFX_file - certificate passed : %s", certificate);
+ EM_DEBUG_LOG("emcore_load_PFX_file - certificate passed : %s", certificate);
/* Create instance */
err = certsvc_instance_new(&cert_instance);
new_event->event_param_data_3 = EM_SAFE_STRDUP(sync_failed_event_data->event_param_data_3);
new_event->event_param_data_4 = sync_failed_event_data->event_param_data_4;
new_event->event_param_data_5 = sync_failed_event_data->event_param_data_5;
+ new_event->multi_user_name = EM_SAFE_STRDUP(sync_failed_event_data->multi_user_name);
*event_data = new_event;
emcore_free_event(sync_failed_event_data);
EM_SAFE_FREE(sync_failed_event_data);
- sync_failed_event_data = NULL;
}
INTERNAL_FUNC int emcore_insert_event_for_sending_mails(email_event_t *event_data, int *handle, int *err_code)
case EMAIL_SEARCH_FILTER_TYPE_TO :
case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET :
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED :
EM_SAFE_FREE(search_filter[i].search_filter_key_value.string_type_key_value);
break;
default:
/*Figure out TEXT or ATTACHMENT(INLINE) ?*/
int result = false;
if (disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) {
- if (content_id &&
- (emcore_search_string_from_file(cnt_info->text.html, content_id, NULL, &result) == EMAIL_ERROR_NONE && result)) {
+ if (content_id && (emcore_search_string_from_file(cnt_info->text.html,
+ content_id,
+ NULL,
+ &result) == EMAIL_ERROR_NONE && result)) {
content_disposition_type = INLINE_ATTACHMENT;
EM_DEBUG_LOG("INLINE_ATTACHMENT");
- } else {
- content_disposition_type = ATTACHMENT;
- EM_DEBUG_LOG("ATTACHMENT");
- }
+ } else {
+ content_disposition_type = ATTACHMENT;
+ EM_DEBUG_LOG("ATTACHMENT");
+ }
} else if ((content_id || content_location) && (ctype_name || disposition_filename)) {
if (cnt_info->attachment_only) {
content_disposition_type = ATTACHMENT;
EM_DEBUG_LOG("INLINE_ATTACHMENT");
}
} else {
- if (content_id &&
- (emcore_search_string_from_file(cnt_info->text.html, content_id, NULL, &result) == EMAIL_ERROR_NONE && result)) {
+ if (content_id && (emcore_search_string_from_file(cnt_info->text.html,
+ content_id,
+ NULL,
+ &result) == EMAIL_ERROR_NONE && result)) {
content_disposition_type = INLINE_ATTACHMENT;
EM_DEBUG_LOG("INLINE_ATTACHMENT");
} else if (content_id || content_location) {
}
}
} else {
- if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
- (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
+ if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
+ (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 ||
+ g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
EM_DEBUG_LOG("TEXT");
} else {
content_disposition_type = ATTACHMENT;
return err;
}
-INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(char *multi_user_name, int input_account_id, int input_mailbox_id, int input_from_server, int *err_code)
+INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(char *multi_user_name,
+ int input_account_id,
+ int input_mailbox_id,
+ int input_mailbox_type,
+ int input_from_server,
+ int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("input_account_id[%d] input_mailbox_id[%d] input_from_server[%d] err_code[%p]", input_account_id, input_mailbox_id, input_from_server, err_code);
+ EM_DEBUG_FUNC_BEGIN("input_account_id[%d] input_mailbox_id[%d] input_from_server[%d] err_code[%p]",
+ input_account_id, input_mailbox_id, input_from_server, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
int mail_id_count = 0;
char conditional_clause[QUERY_SIZE] = { 0, };
- if (!input_mailbox_id) {
+ if (input_mailbox_id <= 0 && input_mailbox_type <= 0) {
err = EMAIL_ERROR_INVALID_PARAM;
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
goto FINISH_OFF;
}
/* Delete all mails in specific mailbox */
+ SNPRINTF(conditional_clause, QUERY_SIZE, " where ");
+
+ if (input_mailbox_id <= 0 && input_mailbox_type > 0) {
+ SNPRINTF(conditional_clause + strlen(conditional_clause), QUERY_SIZE,
+ "mailbox_type = %d ", input_mailbox_type);
+ } else if (input_mailbox_id > 0 && input_mailbox_type <= 0) {
+ SNPRINTF(conditional_clause + strlen(conditional_clause), QUERY_SIZE,
+ "mailbox_id = %d ", input_mailbox_id);
+ } else {
+ SNPRINTF(conditional_clause + strlen(conditional_clause), QUERY_SIZE,
+ "mailbox_type = %d and mailbox_id = %d ", input_mailbox_type, input_mailbox_id);
+ }
- SNPRINTF(conditional_clause, QUERY_SIZE, " where mailbox_id = %d ", input_mailbox_id);
+ EM_DEBUG_LOG("command : [%s]", conditional_clause);
- emstorage_query_mail_id_list(multi_user_name, conditional_clause, false, &mail_id_array, &mail_id_count);
+ err = emstorage_query_mail_id_list(multi_user_name, conditional_clause, false, &mail_id_array, &mail_id_count);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_query_mail_id_list failed : [%d]", err);
+ goto FINISH_OFF;
+ }
EM_DEBUG_LOG("emstorage_query_mail_id_list returns [%d]", mail_id_count);
if (mail_id_count > 0) {
- if (!emcore_delete_mail(multi_user_name, input_account_id, mail_id_array, mail_id_count, input_from_server, EMAIL_DELETED_BY_COMMAND, false, &err)) {
+ if (!emcore_delete_mail(multi_user_name,
+ input_account_id,
+ mail_id_array,
+ mail_id_count,
+ input_from_server,
+ EMAIL_DELETED_BY_COMMAND,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err);
goto FINISH_OFF;
}
ret = true;
FINISH_OFF:
+
EM_SAFE_FREE(mail_id_array);
if (err_code != NULL)
/* Updating Thread informations */
for(i = 0; i < num; i++) {
if (result_mail_list[i].thread_id != 0) {
- if (!emstorage_update_latest_thread_mail(multi_user_name, account_id, result_mail_list[i].mailbox_id, result_mail_list[i].thread_id, NULL, 0, 0, NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ account_id,
+ result_mail_list[i].mailbox_id,
+ result_mail_list[i].mailbox_type,
+ result_mail_list[i].thread_id,
+ NULL,
+ 0,
+ 0,
+ NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG("emstorage_get_thread_id_of_thread_mails is failed.");
/* Original mailbox replace thread id */
- if (!emstorage_update_latest_thread_mail(multi_user_name, account_id, mail_list[i].mailbox_id, mail_list[i].thread_id, NULL, 0, 0, NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ account_id,
+ mail_list[i].mailbox_id,
+ mail_list[i].mailbox_type,
+ mail_list[i].thread_id,
+ NULL,
+ 0,
+ 0,
+ NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
goto FINISH_OFF;
}
/* Destination mailbox replace thread id */
if (p_thread_id == -1) {
- if (!emstorage_update_latest_thread_mail(multi_user_name, account_id, p_mail_data->mailbox_id, p_mail_data->mail_id, NULL, p_mail_data->mail_id, 1, NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ account_id,
+ p_mail_data->mailbox_id,
+ p_mail_data->mailbox_type,
+ p_mail_data->mail_id,
+ NULL,
+ p_mail_data->mail_id,
+ 1,
+ NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
goto FINISH_OFF;
}
} else {
- if (!emstorage_update_latest_thread_mail(multi_user_name, account_id, p_mail_data->mailbox_id, dest_prev_thread_id_list[i], NULL, 0, 0, NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ account_id,
+ p_mail_data->mailbox_id,
+ p_mail_data->mailbox_type,
+ dest_prev_thread_id_list[i],
+ NULL,
+ 0,
+ 0,
+ NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_FUNC_END();
}
-#if 0
-static char *make_time_string_to_time_t(time_t time)
-{
- char *time_string = NULL;
- struct tm *struct_time = NULL;
-
- if (!time) {
- EM_DEBUG_EXCEPTION("Invalid paramter");
- return NULL;
- }
-
- time_string = em_malloc(MAX_DATETIME_STRING_LENGTH);
- if (time_string == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- return NULL;
- }
-
- struct_time = localtime(&time);
- SNPRINTF(time_string, MAX_DATETIME_STRING_LENGTH, "%d/%d/%d", struct_time->tm_mon + 1, struct_time->tm_mday, struct_time->tm_year + 1900);
-
- EM_DEBUG_LOG("time string = [%s]", time_string);
- return time_string;
-}
-
-static SEARCHOR *make_all_search_program(email_search_filter_t *search_filter, int search_filter_count, int current_index, int *output_current_index)
-{
- EM_DEBUG_FUNC_BEGIN("search_filter : [%p], search_filter_count : [%d], current_index : [%d]", search_filter, search_filter_count, current_index);
-
- int i = 0;
- char *time_string = NULL;
- char temp_criteria[STRING_LENGTH_FOR_DISPLAY] = {0,};
-
- SEARCHOR *p_search_or_program = NULL;
- SEARCHPGM *child_search_pgm = NULL;
-
- for (i = current_index; i < search_filter_count; i++) {
-
- memset(temp_criteria, 0x00 ,sizeof(temp_criteria));
-
- switch (search_filter[i].search_filter_type) {
- case EMAIL_SEARCH_FILTER_TYPE_ALL:
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- goto FINISH_OFF;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "ANSWERED ");
- else
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNANSWERED ");
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_BCC :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BCC %s ", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :
- EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
- time_string = make_time_string_to_time_t(search_filter[i].search_filter_key_value.time_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BEFORE %s ", time_string);
- EM_SAFE_FREE(time_string);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_BODY :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BODY \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_CC :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "CC \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "DELETED ");
- else
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNDELETED ");
-
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "FLAGGED ");
- else
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNFLAGGED ");
-
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FROM :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "FROM \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_KEYWORD :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "KEYWORD \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW:
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD:
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON :
- EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "RECENT ");
-
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SEEN ");
- else
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNSEEN ");
-
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE :
- EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
- time_string = make_time_string_to_time_t(search_filter[i].search_filter_key_value.time_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SINCE %s ", time_string);
- EM_SAFE_FREE(time_string);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_SUBJECT :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SUBJECT \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_TEXT :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TEXT \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_TO :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TO \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "HEADER x-priority %d ", search_filter[i].search_filter_key_value.integer_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO :
- case EMAIL_SEARCH_FILTER_TYPE_UID :
- case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER :
- case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER :
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- default :
- EM_DEBUG_EXCEPTION("Invalid list_filter_item_type [%d]", search_filter);
- break;
- }
-
- while (true) {
- if (!p_search_or_program) {
- p_search_or_program = (SEARCHOR *)em_malloc(sizeof(SEARCHOR));
- } else {
- if (!p_search_or_program->first) {
- p_search_or_program->first = mail_criteria(temp_criteria);
- break;
- }
- else if (!p_search_or_program->second) {
- p_search_or_program->second = mail_criteria(temp_criteria);
- break;
- }
- else {
- child_search_pgm = mail_newsearchpgm();
- child_search_pgm->or = p_search_or_program;
-
- p_search_or_program = NULL;
- p_search_or_program = (SEARCHOR *)em_malloc(sizeof(SEARCHOR));
- p_search_or_program->first = child_search_pgm;
- }
- }
- }
- }
-
-FINISH_OFF:
-
- if (output_current_index)
- *output_current_index = i;
-
- EM_SAFE_FREE(time_string);
-
- EM_DEBUG_FUNC_END();
-
- return p_search_or_program;
-}
-
-static int make_criteria_to_search_filter(email_search_filter_t *search_filter, int search_filter_count, SEARCHPGM **output_search_program)
-{
- EM_DEBUG_FUNC_BEGIN("search_filter : [%p], search_filter_count : [%d]", search_filter, search_filter_count);
-
- int i = 0;
- int err = EMAIL_ERROR_NONE;
- char *criteria = NULL;
- char *temp_criteria = NULL;
- char *time_string = NULL;
- int current_index = 0;
- int draft = 0;
- int undraft = 0;
- unsigned long larger_size = 0;
- unsigned long smaller_size = 0;
-
- SEARCHOR *or_search_program = NULL;
- SEARCHPGM *p_search_program = NULL;
-
- if (search_filter == NULL || search_filter_count < 0) {
- EM_DEBUG_EXCEPTION("Invalid paramter");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- criteria = (char *)em_malloc(STRING_LENGTH_FOR_DISPLAY * search_filter_count);
- if (criteria == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- temp_criteria = (char *)em_malloc(STRING_LENGTH_FOR_DISPLAY);
- if (temp_criteria == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- for (i = 0; i < search_filter_count; i++) {
- EM_DEBUG_LOG("search_filter_type [%d]", search_filter[i].search_filter_type);
- memset(temp_criteria, 0x00, STRING_LENGTH_FOR_DISPLAY);
-
- switch (search_filter[i].search_filter_type) {
- case EMAIL_SEARCH_FILTER_TYPE_ALL:
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "ALL ");
- if (!search_filter[i].search_filter_key_value.integer_type_key_value) {
- or_search_program = make_all_search_program(search_filter, search_filter_count, i + 1, ¤t_index);
- i = current_index;
- }
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "ANSWERED ");
- else
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNANSWERED ");
-
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_BCC :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BCC \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :
- EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
- time_string = make_time_string_to_time_t(search_filter[i].search_filter_key_value.time_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BEFORE %s ", time_string);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- EM_SAFE_FREE(time_string);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_BODY :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BODY \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_CC :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "CC \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "DELETED ");
- else
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNDELETED ");
-
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "FLAGGED ");
- else
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNFLAGGED ");
-
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FROM :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "FROM \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_KEYWORD :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "KEYWORD \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW:
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "NEW ");
-
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD:
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "OLD ");
-
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON :
- EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
- time_string = make_time_string_to_time_t(search_filter[i].search_filter_key_value.time_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "ON %s ", time_string);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- EM_SAFE_FREE(time_string);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "RECENT ");
-
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SEEN ");
- else
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNSEEN ");
-
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE :
- EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
- time_string = make_time_string_to_time_t(search_filter[i].search_filter_key_value.time_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SINCE %s ", time_string);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- EM_SAFE_FREE(time_string);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_SUBJECT :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SUBJECT \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_TEXT :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TEXT \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_TO :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TO \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "HEADER x-priority %d ", search_filter[i].search_filter_key_value.integer_type_key_value);
- strncat(criteria, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- larger_size = search_filter[i].search_filter_key_value.integer_type_key_value;
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- smaller_size = search_filter[i].search_filter_key_value.integer_type_key_value;
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- if (search_filter[i].search_filter_key_value.integer_type_key_value)
- draft = search_filter[i].search_filter_key_value.integer_type_key_value;
- else
- undraft = search_filter[i].search_filter_key_value.integer_type_key_value;
-
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO :
- case EMAIL_SEARCH_FILTER_TYPE_UID :
- EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
- break;
-
- case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
- EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- break;
-
- default :
- EM_DEBUG_EXCEPTION("Invalid list_filter_item_type [%d]", search_filter);
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
- EM_SAFE_FREE(time_string); /*prevent 26258*/
- }
-
- EM_DEBUG_LOG("criteria[%s]", criteria);
-
- p_search_program = mail_criteria(criteria);
- p_search_program->or = or_search_program;
- p_search_program->larger = larger_size;
- p_search_program->smaller = smaller_size;
- p_search_program->draft = draft;
- p_search_program->undraft = undraft;
-
-FINISH_OFF:
-
- EM_SAFE_FREE(temp_criteria);
- EM_SAFE_FREE(time_string);
- EM_SAFE_FREE(criteria);
-
- if (output_search_program != NULL)
- *output_search_program = p_search_program;
-
- EM_DEBUG_FUNC_END();
- return err;
-}
-#endif
-
static int get_search_filter_string(email_search_filter_t *search_filter, int search_filter_count, char **output_filter_string)
{
EM_DEBUG_FUNC_BEGIN("search_filter : [%p], search_filter_count : [%d]", search_filter, search_filter_count);
case EMAIL_SEARCH_FILTER_TYPE_BCC :
EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BCC \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BCC \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
break;
case EMAIL_SEARCH_FILTER_TYPE_BODY :
EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BODY \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BODY \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
break;
case EMAIL_SEARCH_FILTER_TYPE_CC :
EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "CC \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "CC \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
break;
case EMAIL_SEARCH_FILTER_TYPE_FROM :
EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "FROM \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "FROM \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
break;
case EMAIL_SEARCH_FILTER_TYPE_KEYWORD :
EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "KEYWORD \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "KEYWORD \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+
strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
break;
case EMAIL_SEARCH_FILTER_TYPE_SUBJECT :
EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SUBJECT \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SUBJECT \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
break;
case EMAIL_SEARCH_FILTER_TYPE_TEXT :
EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TEXT \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TEXT \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
break;
case EMAIL_SEARCH_FILTER_TYPE_TO :
EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
- SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TO \"%s\" ", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TO \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
break;
case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "X-GM-RAW \"has:attachment filename:%s\"",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET:
+ EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "charset %s", search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED:
+ EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "%s", search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
break;
case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO :
return err;
}
-int emcore_search_mail_and_uids(MAILSTREAM *stream, email_search_filter_t *input_search_filter, int input_search_filter_count, emcore_uid_list** output_uid_list, int *output_uid_count)
+int emcore_search_mail_and_uids(MAILSTREAM *stream, email_search_filter_t *input_search_filter,
+ int input_search_filter_count, emcore_uid_list** output_uid_list,
+ int *output_uid_count)
{
- EM_DEBUG_FUNC_BEGIN("stream[%p] input_search_filter[%p] input_search_filter_count[%d] output_uid_list[%p] output_uid_count[%p]", stream, input_search_filter_count, output_uid_list, output_uid_count);
+ EM_DEBUG_FUNC_BEGIN("stream[%p] input_search_filter[%p] input_search_filter_count[%d] "
+ "output_uid_list[%p] output_uid_count[%p]",
+ stream, input_search_filter_count, output_uid_list, output_uid_count);
int err = EMAIL_ERROR_NONE;
memset(tag, 0x00, sizeof(tag));
memset(command, 0x00, sizeof(command));
- if ((err = get_search_filter_string(input_search_filter, input_search_filter_count, &search_filter_string)) != EMAIL_ERROR_NONE) {
+ if ((err = get_search_filter_string(input_search_filter,
+ input_search_filter_count,
+ &search_filter_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("get_search_filter_string failed [%d]", err);
goto FINISH_OFF;
}
SNPRINTF(tag, sizeof(tag), "%08lx", 0xffffffff & (stream->gensym++));
SNPRINTF(command, MAX_PREVIEW_TEXT_LENGTH, "%s UID SEARCH %s\015\012", tag, search_filter_string);
- /*
- SNPRINTF(command, sizeof(command), "%s UID SEARCH BEFORE %s SINCE %s OR OR SUBJECT \"%s\" FROM \"%s\" BODY \"%s\"\015\012", tag, before_date_string, since_date_string, input_keyword, input_keyword, input_keyword);
- */
EM_DEBUG_LOG_SEC("COMMAND [%s] ", command);
#ifdef FEATURE_CORE_DEBUG
EM_DEBUG_LOG("uid_count [%d] ", uid_count);
if (uid_count > 0) {
- if ((err = emcore_make_uid_range_string(uid_list_for_listing, uid_count, &uid_range_string)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_make_uid_range_string(uid_list_for_listing,
+ uid_count,
+ &uid_range_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_make_uid_range_string failed [%d]", err);
goto FINISH_OFF;
}
}
-INTERNAL_FUNC int emcore_search_on_server(char *multi_user_name, int account_id, int mailbox_id, email_search_filter_t *input_search_filter, int input_search_filter_count, int handle_to_be_published)
+INTERNAL_FUNC int emcore_search_on_server(char *multi_user_name, int account_id, int mailbox_id,
+ email_search_filter_t *input_search_filter,
+ int input_search_filter_count,
+ int cancellable,
+ int event_handle)
{
EM_DEBUG_FUNC_BEGIN_SEC("account_id : [%d], mailbox_id : [%d]", account_id, mailbox_id);
int mail_id = 0;
int thread_id = 0;
int uid_count = 0;
- //char temp_uid_string[20] = {0,};
char *uid_range = NULL;
+ char mailbox_id_param_string[10] = {0,};
emcore_uid_list *uid_list = NULL;
emcore_uid_list *uid_elem = NULL;
emstorage_mailbox_tbl_t *search_mailbox = NULL;
emstorage_mail_tbl_t *new_mail_tbl_data = NULL;
-// SEARCHPGM *search_program = NULL;
MAILSTREAM *stream = NULL;
- //MESSAGECACHE *mail_cache_element = NULL;
ENVELOPE *env = NULL;
- emstorage_mailbox_tbl_t* local_mailbox = NULL;
- char mailbox_id_param_string[10] = {0,};
if (account_id < 0 || mailbox_id == 0) {
EM_DEBUG_EXCEPTION("Invalid parameter");
goto FINISH_OFF;
}
- /*
- if ((err = make_criteria_to_search_filter(input_search_filter, input_search_filter_count, &search_program)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("make_criteria_to_search_filter failed [%d]", err);
- goto FINISH_OFF;
- }
- */
-
- if ( (err = emstorage_get_mailbox_by_id(multi_user_name, mailbox_id, &local_mailbox)) != EMAIL_ERROR_NONE || !local_mailbox) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
- goto FINISH_OFF;
- }
-
- SNPRINTF(mailbox_id_param_string, 10, "%d", local_mailbox->mailbox_id);
-
- if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_START, account_id, mailbox_id_param_string, handle_to_be_published, 0))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEARCH_ON_SERVER_START] failed >>>>");
-
- if (!emnetwork_check_network_status(&err)) {
- EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
- if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, 0, err))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_FAIL] Failed");
- goto FINISH_OFF;
- }
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, mailbox_id, (void **)&stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed");
- if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>");
goto FINISH_OFF;
}
- /*
- if (!mail_search_full(stream, NIL, search_program, 0)) {
- EM_DEBUG_EXCEPTION("mail_search failed");
- if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>");
- goto FINISH_OFF;
- }
- */
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- if ((err = emcore_search_mail_and_uids(stream, input_search_filter, input_search_filter_count, &uid_list, &uid_count)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_search_mail_and_uids(stream,
+ input_search_filter,
+ input_search_filter_count,
+ &uid_list,
+ &uid_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_search_mail_and_uids failed [%d]", err);
goto FINISH_OFF;
}
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+
uid_elem = uid_list;
if (uid_count > 0) {
}
while (uid_elem) {
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+
EM_DEBUG_LOG("msgno : [%4lu]", uid_elem->msgno);
#ifdef __FEATURE_HEADER_OPTIMIZATION__
env = mail_fetchstructure_full(stream, uid_elem->msgno, NULL, FT_PEEK, 0);
if (env)
EM_DEBUG_LOG("message_id[%s]", env->message_id);
- if (!emcore_make_mail_tbl_data_from_envelope(multi_user_name, account_id, stream, env, uid_elem, &new_mail_tbl_data, &err) || !new_mail_tbl_data) {
+ if (!emcore_make_mail_tbl_data_from_envelope(multi_user_name,
+ account_id,
+ stream,
+ env,
+ uid_elem,
+ &new_mail_tbl_data,
+ &err) || !new_mail_tbl_data) {
EM_DEBUG_EXCEPTION("emcore_make_mail_tbl_data_from_envelope failed [%d]", err);
- if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>");
goto FINISH_OFF;
}
if (search_mailbox == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
err = EMAIL_ERROR_OUT_OF_MEMORY;
- if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>");
goto FINISH_OFF;
}
search_mailbox->mailbox_name = EM_SAFE_STRDUP(EMAIL_SEARCH_RESULT_MAILBOX_NAME);
search_mailbox->mailbox_type = EMAIL_MAILBOX_TYPE_SEARCH_RESULT;
- if ((err = emcore_add_mail_to_mailbox(multi_user_name, search_mailbox, new_mail_tbl_data, &mail_id, &thread_id)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_add_mail_to_mailbox(multi_user_name,
+ search_mailbox,
+ new_mail_tbl_data,
+ &mail_id,
+ &thread_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox failed [%d]", err);
- if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>");
goto FINISH_OFF;
}
memset(mailbox_id_param_string, 0, 10);
SNPRINTF(mailbox_id_param_string, 10, "%d", search_mailbox->mailbox_id);
+
+ if (!emcore_initiate_pbd(multi_user_name,
+ stream,
+ account_id,
+ mail_id,
+ uid_elem->uid,
+ search_mailbox->mailbox_id,
+ search_mailbox->mailbox_name,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emcore_initiate_pbd failed : [%d]", err);
+ }
+
if (!emcore_notify_storage_event(NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id)) {
EM_DEBUG_EXCEPTION("emcore_notify_storage_event [NOTI_MAIL_ADD] failed");
}
i++;
}
- if (err == EMAIL_ERROR_NONE && !emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FINISH, account_id, NULL, handle_to_be_published, 0))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_SEARCH_ON_SERVER_FINISH] Failed >>>>>");
-
FINISH_OFF:
if (stream)
if (uid_list)
emcore_free_uids(uid_list, NULL);
-/*
- if (search_program)
- mail_free_searchpgm(&search_program);
-*/
+
if (search_mailbox != NULL)
emstorage_free_mailbox(&search_mailbox, 1, NULL);
if (new_mail_tbl_data)
emstorage_free_mail(&new_mail_tbl_data, 1, NULL);
- if (local_mailbox)
- emstorage_free_mailbox(&local_mailbox, 1, NULL);
-
EM_DEBUG_FUNC_END();
return err;
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
static void emcore_free_email_partial_buffer(email_partial_buffer **partial_buffer, int item_count);
static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply, int input_download_size, int item_count);
-static int emcore_initiate_pbd(char *multi_user_name, MAILSTREAM *stream, int account_id, int mail_id, char *uid, int mailbox_id, int *err_code);
#endif
#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
return ret;
}
-static int emcore_get_uids_to_download(char *multi_user_name, MAILSTREAM *stream, email_account_t *account, emstorage_mailbox_tbl_t *input_mailbox_tbl, int limit_count, emcore_uid_list** uid_list, int *uids, int retrieve_mode , int *err_code)
+static int emcore_get_uids_to_download(char *multi_user_name,
+ MAILSTREAM *stream,
+ email_account_t *account,
+ emstorage_mailbox_tbl_t *input_mailbox_tbl,
+ int limit_count,
+ emcore_uid_list** uid_list,
+ int *uids,
+ int retrieve_mode,
+ int *err_code)
{
EM_PROFILE_BEGIN(emCoreGetUidsDownload);
- EM_DEBUG_FUNC_BEGIN("account[%p], input_mailbox_tbl[%p], limit_count[%d], uid_list[%p], err_code[%p]", account, input_mailbox_tbl, limit_count, uid_list, err_code);
+ EM_DEBUG_FUNC_BEGIN("account[%p], input_mailbox_tbl[%p], limit_count[%d], uid_list[%p], err_code[%p]",
+ account, input_mailbox_tbl, limit_count, uid_list, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
else { /* EMAIL_SERVER_TYPE_IMAP4 */
EM_DEBUG_LOG("nmsgs[%d]", ((MAILSTREAM *)stream)->nmsgs);
if ((limit_count < ((MAILSTREAM *)stream)->nmsgs)) {
- if ((err = emcore_get_uids_order_by_datetime_from_imap_server(stream, limit_count, uid_list)) != EMAIL_ERROR_NONE ) {
+ if ((err = emcore_get_uids_order_by_datetime_from_imap_server(stream,
+ limit_count,
+ uid_list)) != EMAIL_ERROR_NONE ) {
EM_DEBUG_EXCEPTION("emcore_get_uids_order_by_datetime_from_imap_server failed [%d]", err);
if (err != EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER)
goto FINISH_OFF;
}
}
- if (!emstorage_get_downloaded_list(multi_user_name, input_mailbox_tbl->account_id,
- (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) ? 0 : input_mailbox_tbl->mailbox_id,
- &downloaded_uids,
- &downloaded_uid_count,
- true,
- &err)) {
+ if (!emstorage_get_downloaded_list(multi_user_name,
+ input_mailbox_tbl->account_id,
+ (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) ?
+ 0 : input_mailbox_tbl->mailbox_id,
+ &downloaded_uids,
+ &downloaded_uid_count,
+ true,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_downloaded_list failed [%d]", err);
goto FINISH_OFF;
}
uid_elem = *uid_list;
uid_count = 0;
- if(!uid_elem) { /* If there is no mail in the input_mailbox_tbl, remove all mails in the input_mailbox_tbl */
+ if (!uid_elem) { /* If there is no mail in the input_mailbox_tbl, remove all mails in the input_mailbox_tbl */
for (i = 0; i < downloaded_uid_count; i++) {
downloaded_uids[i].sync_status = EMAIL_SYNC_STATUS_NOT_EXIST_ON_SERVER;
}
while (uid_elem) {
next_uid_elem = uid_elem->next;
- if ((account->retrieval_mode & EMAIL_IMAP4_RETRIEVAL_MODE_NEW) && (uid_elem->flag.seen != 0)) { /* already seen */
+ if ((account->retrieval_mode & EMAIL_IMAP4_RETRIEVAL_MODE_NEW) && (uid_elem->flag.seen != 0)) {
+ /* already seen */
EM_SAFE_FREE (uid_elem->uid);
EM_SAFE_FREE (uid_elem->internaldate);
EM_SAFE_FREE (uid_elem);
if (downloaded_uids[i - 1].mailbox_id != input_mailbox_tbl->mailbox_id) {
uid_count--;
} else {
- /* The mail exists on server and local storage, so it should not be downloaded, just check seen flag */
+ /* The mail exists on server and local storage,
+ so it should not be downloaded, just check seen flag */
if (downloaded_uids[i - 1].flags_seen_field != uid_elem->flag.seen ||
downloaded_uids[i - 1].flags_flagged_field != uid_elem->flag.flagged) {
if(downloaded_uids[i - 1].flags_seen_field != uid_elem->flag.seen) {
}
}
- //EM_DEBUG_LOG("Is uid[%s] datetime[%s] going to be downloaded ? [%d]", uid_elem->uid, uid_elem->internaldate, to_be_downloaded);
-
if (to_be_downloaded) {
- if (retrieve_mode == EMAIL_SYNC_OLDEST_MAILS_FIRST){
+ if (retrieve_mode == EMAIL_SYNC_OLDEST_MAILS_FIRST) {
uid_elem->next = head_uid_elem;
head_uid_elem = uid_elem;
- }
- else{ /* if retrieve_mode is EMAIL_SYNC_LATEST_MAILS_FIRST, add uid elem to end so that latest mails are in front of list */
- if (head_uid_elem == NULL){
+ } else {
+ /* if retrieve_mode is EMAIL_SYNC_LATEST_MAILS_FIRST,
+ add uid elem to end so that latest mails are in front of list */
+ if (head_uid_elem == NULL) {
uid_elem->next = head_uid_elem;
head_uid_elem = uid_elem;
end = head_uid_elem;
- }
- else{
+ } else {
end->next = uid_elem;
uid_elem->next = NULL;
end = uid_elem;
}
}
uid_to_be_downloaded_count++;
-
- }
- else {
+ } else {
EM_SAFE_FREE (uid_elem->uid);
EM_SAFE_FREE (uid_elem);
}
-
uid_count++;
}
-
uid_elem = next_uid_elem;
}
EM_PROFILE_BEGIN(emCoreGetUidsDownloadForLoop);
for (i = 0; i < downloaded_uid_count; i++) {
- /* EM_DEBUG_LOG("input_mailbox_tbl[%s] sync_status[%d]", input_mailbox_tbl->name, downloaded_uids[i].sync_status); */
if ((downloaded_uids[i].sync_status == EMAIL_SYNC_STATUS_NOT_EXIST_ON_SERVER) &&
- (EM_SAFE_STRCMP(downloaded_uids[i].mailbox_name, EMAIL_SEARCH_RESULT_MAILBOX_NAME) != 0)) { /* deleted on server */
- if (!emstorage_get_maildata_by_servermailid(multi_user_name, input_mailbox_tbl->mailbox_id, downloaded_uids[i].server_uid, &mail, true, &err)){
- EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid for uid[%s] Failed [%d] \n ", downloaded_uids[i].server_uid, err);
+ (EM_SAFE_STRCMP(downloaded_uids[i].mailbox_name, EMAIL_SEARCH_RESULT_MAILBOX_NAME) != 0)) {
+ /* deleted on server */
+ if (!emstorage_get_maildata_by_servermailid(multi_user_name,
+ downloaded_uids[i].server_uid,
+ input_mailbox_tbl->mailbox_id,
+ &mail,
+ true,
+ &err)){
+ EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid for uid[%s] Failed [%d] \n ",
+ downloaded_uids[i].server_uid, err);
if (err == EMAIL_ERROR_MAIL_NOT_FOUND){
continue;
}
}
if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
- ret = emcore_delete_mails_from_local_storage(multi_user_name, input_mailbox_tbl->account_id, &(mail->mail_id), 1, EMAIL_DELETED_FROM_SERVER, false, &err);
+ ret = emcore_delete_mails_from_local_storage(multi_user_name,
+ input_mailbox_tbl->account_id,
+ &(mail->mail_id),
+ 1,
+ EMAIL_DELETED_FROM_SERVER,
+ false,
+ &err);
/* Update badge count */
emcore_display_unread_in_badge(multi_user_name);
if (!ret) {
}
/* insert received mail UID to read mail uid table */
-static int emcore_add_read_mail_uid(char *multi_user_name, emstorage_mailbox_tbl_t *input_maibox_data, char *server_mailbox_name, int mail_id, char *uid, int rfc822_size, int rule_id, int *err_code)
+static int emcore_add_read_mail_uid(char *multi_user_name,
+ emstorage_mailbox_tbl_t *input_maibox_data,
+ char *server_mailbox_name,
+ int mail_id,
+ char *uid,
+ int rfc822_size,
+ int rule_id,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("input_maibox_data[%p], server_mailbox_name[%s], uid[%s], rfc822_size[%d], rule_id[%d], err_code[%p]", input_maibox_data, server_mailbox_name, uid, rfc822_size, rule_id, err_code);
}
read_mail_uid.account_id = input_maibox_data->account_id;
-
if (!(input_maibox_data->mailbox_id) || !(server_mailbox_name)) {
- if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, input_maibox_data->account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl, false, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name,
+ input_maibox_data->account_id,
+ EMAIL_MAILBOX_TYPE_INBOX,
+ &mailbox_tbl,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
}
#endif
-INTERNAL_FUNC int emcore_add_mail_to_mailbox(char *multi_user_name, emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, int *output_mail_id, int *output_thread_id)
+INTERNAL_FUNC int emcore_add_mail_to_mailbox(char *multi_user_name,
+ emstorage_mailbox_tbl_t *input_maibox_data,
+ emstorage_mail_tbl_t *input_new_mail_tbl_data,
+ int *output_mail_id,
+ int *output_thread_id)
{
- EM_DEBUG_FUNC_BEGIN("input_maibox_data[%p], input_new_mail_tbl_data[%p], uid_elem[%p], output_mail_id[%p], output_thread_id[%p]", mail_stream, input_maibox_data, input_new_mail_tbl_data, output_mail_id, output_thread_id);
+ EM_DEBUG_FUNC_BEGIN("input_maibox_data[%p], input_new_mail_tbl_data[%p], "
+ "uid_elem[%p], output_mail_id[%p], output_thread_id[%p]", mail_stream, input_maibox_data,
+ input_new_mail_tbl_data, output_mail_id, output_thread_id);
int err = EMAIL_ERROR_NONE;
int thread_id = -1;
goto FINISH_OFF;
}
- if (emstorage_get_thread_id_of_thread_mails(multi_user_name, input_new_mail_tbl_data, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMAIL_ERROR_NONE)
+ err = emstorage_get_thread_id_of_thread_mails(multi_user_name,
+ input_new_mail_tbl_data,
+ &thread_id,
+ &latest_mail_id_in_thread,
+ &thread_item_count);
+ if (err != EMAIL_ERROR_NONE)
EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed.");
if (thread_id == -1){
input_new_mail_tbl_data->thread_id = input_new_mail_tbl_data->mail_id;
input_new_mail_tbl_data->thread_item_count = thread_item_count = 1;
- }
- else {
+ } else {
input_new_mail_tbl_data->thread_id = thread_id;
thread_item_count++;
}
- EM_DEBUG_LOG("MULTI USER NAME: [%s]", multi_user_name);
- input_new_mail_tbl_data->user_name = EM_SAFE_STRDUP(multi_user_name);
+ EM_DEBUG_LOG("MULTI USER NAME: [%s]", multi_user_name);
+ input_new_mail_tbl_data->user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emstorage_add_mail(multi_user_name, input_new_mail_tbl_data, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]", err);
}
if (thread_item_count > 1) {
- if (!emstorage_update_latest_thread_mail(multi_user_name, input_new_mail_tbl_data->account_id, input_new_mail_tbl_data->mailbox_id, input_new_mail_tbl_data->thread_id, NULL, -1, -1, NOTI_THREAD_ID_CHANGED_BY_ADD, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ input_new_mail_tbl_data->account_id,
+ input_new_mail_tbl_data->mailbox_id,
+ input_new_mail_tbl_data->mailbox_type,
+ input_new_mail_tbl_data->thread_id,
+ NULL,
+ -1,
+ -1,
+ NOTI_THREAD_ID_CHANGED_BY_ADD,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
- if (!emstorage_update_latest_thread_mail(multi_user_name, input_new_mail_tbl_data->account_id, input_new_mail_tbl_data->mailbox_id, input_new_mail_tbl_data->thread_id, NULL, 0, 0, NOTI_THREAD_ID_CHANGED_BY_ADD, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ input_new_mail_tbl_data->account_id,
+ input_new_mail_tbl_data->mailbox_id,
+ input_new_mail_tbl_data->mailbox_type,
+ input_new_mail_tbl_data->thread_id,
+ NULL,
+ 0,
+ 0,
+ NOTI_THREAD_ID_CHANGED_BY_ADD,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
- if (emstorage_get_thread_id_of_thread_mails(multi_user_name, input_new_mail_tbl_data, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMAIL_ERROR_NONE)
+ if (emstorage_get_thread_id_of_thread_mails(multi_user_name,
+ input_new_mail_tbl_data,
+ &thread_id,
+ &latest_mail_id_in_thread,
+ &thread_item_count) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed.");
if (output_thread_id)
if (output_mail_id != NULL)
*output_mail_id = input_new_mail_tbl_data->mail_id;
- if (!emcore_add_read_mail_uid(multi_user_name, input_maibox_data, input_maibox_data->mailbox_name, input_new_mail_tbl_data->mail_id, input_new_mail_tbl_data->server_mail_id, input_new_mail_tbl_data->mail_size, 0, &err)) {
+ if (!emcore_add_read_mail_uid(multi_user_name,
+ input_maibox_data,
+ input_maibox_data->mailbox_name,
+ input_new_mail_tbl_data->mail_id,
+ input_new_mail_tbl_data->server_mail_id,
+ input_new_mail_tbl_data->mail_size,
+ 0,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_add_read_mail_uid failed [%d]", err);
emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
int *err_code)
{
EM_PROFILE_BEGIN(emCoreSyncHeader);
- EM_DEBUG_FUNC_BEGIN("input_mailbox_tbl[%p], input_uid_list [%p], err_code[%p]", input_mailbox_tbl, input_uid_list, err_code);
+ EM_DEBUG_FUNC_BEGIN("input_mailbox_tbl[%p], input_uid_list [%p], err_code[%p]",
+ input_mailbox_tbl, input_uid_list, err_code);
+
if (!stream) {
EM_DEBUG_EXCEPTION ("NULL stream");
if (err_code)
int ret = false;
int err = EMAIL_ERROR_NONE, err_2 = EMAIL_ERROR_NONE;
int download_limit_count;
- email_account_t *account_ref = NULL;
+ email_session_t *session = NULL;
+ email_account_t *account_ref = NULL;
emstorage_rule_tbl_t *rule = NULL;
- emcore_uid_list *uid_list = NULL;
- emcore_uid_list *uid_elem = NULL;
+ emcore_uid_list *uid_list = NULL;
+ emcore_uid_list *uid_elem = NULL;
emstorage_mail_tbl_t *new_mail_tbl_data = NULL;
emstorage_mailbox_tbl_t *destination_mailbox = NULL;
goto FINISH_OFF;
}
-
if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && input_mailbox_tbl->local_yn == 1) {
/* mailbox recovery starts */
if (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) {
}
}
else {
- EM_DEBUG_EXCEPTION("because mailbox_name[%s] mailbox_type[%d] of account[%d] is a local box, it cant be synced",
- input_mailbox_tbl->mailbox_name, input_mailbox_tbl->mailbox_type, account_id);
+ EM_DEBUG_EXCEPTION("because mailbox_name[%s] mailbox_type[%d] of account[%d] is "
+ "a local box, it cant be synced",
+ input_mailbox_tbl->mailbox_name, input_mailbox_tbl->mailbox_type, account_id);
err = EMAIL_ERROR_INVALID_MAILBOX;
goto FINISH_OFF;
}
}
#endif /* __FEATURE_SUPPORT_SYNC_STATE_ON_NOTI_BAR__ */
- if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, input_mailbox_tbl->mailbox_id, (void **)stream, &err) || !*stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name,
+ account_id,
+ input_mailbox_tbl->mailbox_id,
+ (void **)stream,
+ &err) || !*stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err);
goto FINISH_OFF;
}
if (cancellable)
FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- /* save total mail count on server to DB */
- if (!emstorage_update_mailbox_total_count(multi_user_name, account_id, input_mailbox_tbl->mailbox_id, ((MAILSTREAM *)*stream)->nmsgs, 1, &err)){
- EM_DEBUG_EXCEPTION("emstorage_update_mailbox_total_count failed [%d]", err);
- goto FINISH_OFF;
- }
-
- /* if (((MAILSTREAM *)stream)->nmsgs > 0) */
- {
- email_option_t *opt_ref = &account_ref->options;
- EM_DEBUG_LOG_SEC("block_address = %d, block_subject = %d", opt_ref->block_address, opt_ref->block_subject);
- if (opt_ref->block_address || opt_ref->block_subject) {
- int is_completed = false;
- int type = 0;
+ /* check the connection broken */
+ EM_DEBUG_LOG("((MAILSTREAM *)stream)->nmsgs [%ld]", ((MAILSTREAM *)*stream)->nmsgs);
- if (!opt_ref->block_address)
- type = EMAIL_FILTER_SUBJECT;
- else if (!opt_ref->block_subject)
- type = EMAIL_FILTER_FROM;
-
- if (!emstorage_get_rule(multi_user_name, ALL_ACCOUNT, type, 0, &rule_count, &is_completed, &rule, true, &err) || !rule) {
- if ( err != EMAIL_ERROR_FILTER_NOT_FOUND )
- EM_DEBUG_EXCEPTION ("emstorage_get_rule error [%d]", err);
- }
+ unsigned long nmsgs_count = ((MAILSTREAM *)*stream)->nmsgs;
+ if (!nmsgs_count) {
+ EM_DEBUG_LOG("MAILSTREAM");
+ if (!emcore_get_current_session(&session)) {
+ EM_DEBUG_EXCEPTION("emcore_get_current_session failed");
+ err = EMAIL_ERROR_SESSION_NOT_FOUND;
+ goto FINISH_OFF;
}
- download_limit_count = input_mailbox_tbl->mail_slot_size;
- if (!emcore_get_uids_to_download(multi_user_name, *stream, account_ref, input_mailbox_tbl, download_limit_count, &uid_list,
- &total, EMAIL_SYNC_LATEST_MAILS_FIRST, &err)){
- EM_DEBUG_EXCEPTION("emcore_get_uids_to_download failed [%d]", err);
+ if (session->error == EMAIL_ERROR_CONNECTION_BROKEN) {
+ EM_DEBUG_EXCEPTION("session error : [%d]", session->error);
+ err = session->error;
goto FINISH_OFF;
}
+ }
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+ /* save total mail count on server to DB */
+ if (!emstorage_update_mailbox_total_count(multi_user_name,
+ account_id,
+ input_mailbox_tbl->mailbox_id,
+ ((MAILSTREAM *)*stream)->nmsgs,
+ 1,
+ &err)){
+ EM_DEBUG_EXCEPTION("emstorage_update_mailbox_total_count failed [%d]", err);
+ goto FINISH_OFF;
+ }
- if (input_uid_list && *input_uid_list){
- emcore_free_uids(*input_uid_list, NULL);
- *input_uid_list = uid_list;
+ email_option_t *opt_ref = &account_ref->options;
+ EM_DEBUG_LOG_SEC("block_address = %d, block_subject = %d", opt_ref->block_address, opt_ref->block_subject);
+
+ if (opt_ref->block_address || opt_ref->block_subject) {
+ int is_completed = false;
+ int type = 0;
+
+ if (!opt_ref->block_address)
+ type = EMAIL_FILTER_SUBJECT;
+ else if (!opt_ref->block_subject)
+ type = EMAIL_FILTER_FROM;
+
+ if (!emstorage_get_rule(multi_user_name,
+ ALL_ACCOUNT,
+ type,
+ 0,
+ &rule_count,
+ &is_completed,
+ &rule,
+ true,
+ &err) || !rule) {
+ if ( err != EMAIL_ERROR_FILTER_NOT_FOUND )
+ EM_DEBUG_EXCEPTION ("emstorage_get_rule error [%d]", err);
}
- uid_elem = uid_list;
- i = 0;
- EM_PROFILE_BEGIN(emCoreSyncHeaderwhileloop);
+ }
+
+ download_limit_count = input_mailbox_tbl->mail_slot_size;
+ if (!emcore_get_uids_to_download(multi_user_name,
+ *stream,
+ account_ref,
+ input_mailbox_tbl,
+ download_limit_count,
+ &uid_list,
+ &total,
+ EMAIL_SYNC_LATEST_MAILS_FIRST,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emcore_get_uids_to_download failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+
+ if (input_uid_list && *input_uid_list){
+ emcore_free_uids(*input_uid_list, NULL);
+ *input_uid_list = uid_list;
+ }
+ uid_elem = uid_list;
+ i = 0;
+ EM_PROFILE_BEGIN(emCoreSyncHeaderwhileloop);
#ifdef __FEATURE_HEADER_OPTIMIZATION__
- /* g.shyamakshi@samsung.com : Bulk fetch of headers only if the receiving server type is IMAP */
+ /* g.shyamakshi@samsung.com : Bulk fetch of headers only if the receiving server type is IMAP */
- EM_DEBUG_LOG("((MAILSTREAM *)stream)->nmsgs [%d]", ((MAILSTREAM *)*stream)->nmsgs);
- EM_DEBUG_LOG("uid_list [%p]", uid_list);
+ EM_DEBUG_LOG("uid_list [%p]", uid_list);
- if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && uid_list != NULL) {
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && uid_list != NULL) {
- if ((err = emcore_make_uid_range_string(uid_list, total, &uid_range)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_make_uid_range_string failed [%d]", err);
- goto FINISH_OFF;
- }
+ if ((err = emcore_make_uid_range_string(uid_list, total, &uid_range)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_make_uid_range_string failed [%d]", err);
+ goto FINISH_OFF;
+ }
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- uid_elem = uid_list;
- if (*stream && uid_elem){
- EM_DEBUG_LOG("msgno : %d", uid_elem->msgno);
- ((MAILSTREAM *)*stream)->nmsgs = uid_elem->msgno;
- }
- else{
- EM_DEBUG_LOG("Uid List Null");
- }
- EM_DEBUG_LOG("Calling ... mail_fetch_fast. uid_range [%s]", uid_range);
- mail_fetch_fast(*stream, uid_range, FT_UID | FT_PEEK | FT_NEEDENV);
- EM_SAFE_FREE(uid_range);
+ uid_elem = uid_list;
+ if (*stream && uid_elem){
+ EM_DEBUG_LOG("msgno : %d", uid_elem->msgno);
+ ((MAILSTREAM *)*stream)->nmsgs = uid_elem->msgno;
+ }
+ else{
+ EM_DEBUG_LOG("Uid List Null");
}
+ EM_DEBUG_LOG("Calling ... mail_fetch_fast. uid_range [%s]", uid_range);
+ mail_fetch_fast(*stream, uid_range, FT_UID | FT_PEEK | FT_NEEDENV);
+ EM_SAFE_FREE(uid_range);
+ }
#endif
- /* h.gahlaut@samsung.com : Clear the event queue of partial body download thread before starting fetching new headers */
+ /* h.gahlaut@samsung.com : Clear the event queue of partial body download thread before starting fetching new headers */
#ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
- if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4){
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4){
#endif /* __FEATURE_PARTIAL_BODY_FOR_POP3__ */
- /* Partial body download feature is only for IMAP accounts */
- if (false == emcore_clear_partial_body_thd_event_que(&err))
- EM_DEBUG_LOG("emcore_clear_partial_body_thd_event_que failed [%d]", err);
+ /* Partial body download feature is only for IMAP accounts */
+ if (false == emcore_clear_partial_body_thd_event_que(&err))
+ EM_DEBUG_LOG("emcore_clear_partial_body_thd_event_que failed [%d]", err);
#ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
- }
+ }
#endif /* __FEATURE_PARTIAL_BODY_FOR_POP3__ */
- while (uid_elem) {
- EM_PROFILE_BEGIN(emCoreSyncHeaderEachMail);
- EM_DEBUG_LOG("mail_fetchstructure_full : uid_elem->msgno[%d]", uid_elem->msgno);
+ while (uid_elem) {
+ EM_PROFILE_BEGIN(emCoreSyncHeaderEachMail);
+ EM_DEBUG_LOG("mail_fetchstructure_full : uid_elem->msgno[%d]", uid_elem->msgno);
- env = NULL;
+ env = NULL;
- if (uid_elem->msgno > ((MAILSTREAM *)*stream)->nmsgs) {
- EM_DEBUG_LOG ("WARN: msgno[%d] can't be greater than nmsgs[%d].",
- uid_elem->msgno, ((MAILSTREAM *)*stream)->nmsgs);
- }
- else{
+ if (uid_elem->msgno > ((MAILSTREAM *)*stream)->nmsgs) {
+ EM_DEBUG_LOG ("WARN: msgno[%d] can't be greater than nmsgs[%d].",
+ uid_elem->msgno, ((MAILSTREAM *)*stream)->nmsgs);
+ }
+ else{
#ifdef __FEATURE_HEADER_OPTIMIZATION__
- if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) /* Fetch env from cache in case of IMAP */
- env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK, 0);
- else /* Fetch header from network in case of POP */
- env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK, 1);
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) /* Fetch env from cache in case of IMAP */
+ env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK, 0);
+ else /* Fetch header from network in case of POP */
+ env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK, 1);
#else
- env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK);
+ env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK);
#endif
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+ }
- if (env != NULL) {
- int searched_mail_id = 0;
- int blocked = false;
- int priority_sender = false;
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- if (!emcore_make_mail_tbl_data_from_envelope (multi_user_name, account_id, *stream, env, uid_elem,
- &new_mail_tbl_data, &err) || !new_mail_tbl_data) {
- EM_DEBUG_EXCEPTION("emcore_make_mail_tbl_data_from_envelope failed [%d]", err);
- goto CONTINUE_NEXT;
- }
+ if (env != NULL) {
+ int searched_mail_id = 0;
+ int blocked = false;
+ int priority_sender = false;
- /* Check message_id for duplicated mail in sentbox */
- if ((input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX) &&
- (emstorage_check_and_update_server_uid_by_message_id(multi_user_name,
- new_mail_tbl_data->account_id,
- input_mailbox_tbl->mailbox_type,
- new_mail_tbl_data->message_id,
- new_mail_tbl_data->server_mail_id,
- &searched_mail_id) == EMAIL_ERROR_NONE)) {
- EM_DEBUG_LOG("Existed the duplicated mail : message_id[%s]", new_mail_tbl_data->message_id);
-
- if (!emcore_add_read_mail_uid(multi_user_name, input_mailbox_tbl,
- input_mailbox_tbl->mailbox_name, searched_mail_id,
- new_mail_tbl_data->server_mail_id, new_mail_tbl_data->mail_size,
- 0, &err)) {
- EM_DEBUG_EXCEPTION("emcore_add_read_mail_uid failed : [%d]", err);
- goto CONTINUE_NEXT;
- }
-
- if (!emstorage_change_mail_field(multi_user_name, searched_mail_id, UPDATE_DATETIME,
- new_mail_tbl_data, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed : [%d]", err);
- goto CONTINUE_NEXT;
- }
+ if (!emcore_make_mail_tbl_data_from_envelope (multi_user_name, account_id, *stream, env, uid_elem,
+ &new_mail_tbl_data, &err) || !new_mail_tbl_data) {
+ EM_DEBUG_EXCEPTION("emcore_make_mail_tbl_data_from_envelope failed [%d]", err);
+ goto CONTINUE_NEXT;
+ }
+ /* Check message_id for duplicated mail in sentbox */
+ if ((input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX) &&
+ (emstorage_check_and_update_server_uid_by_message_id(multi_user_name,
+ new_mail_tbl_data->account_id,
+ input_mailbox_tbl->mailbox_type,
+ new_mail_tbl_data->message_id,
+ new_mail_tbl_data->server_mail_id,
+ &searched_mail_id) == EMAIL_ERROR_NONE)) {
+ EM_DEBUG_LOG("Existed the duplicated mail : message_id[%s]", new_mail_tbl_data->message_id);
+
+ if (!emcore_add_read_mail_uid(multi_user_name, input_mailbox_tbl,
+ input_mailbox_tbl->mailbox_name, searched_mail_id,
+ new_mail_tbl_data->server_mail_id, new_mail_tbl_data->mail_size,
+ 0, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_add_read_mail_uid failed : [%d]", err);
goto CONTINUE_NEXT;
}
-
- if (rule && !emcore_check_rule(new_mail_tbl_data->full_address_from, new_mail_tbl_data->subject, rule, rule_count, &priority_sender, &blocked, &err)) {
- EM_DEBUG_EXCEPTION("emcore_check_rule failed [%d]", err);
+
+ if (!emstorage_change_mail_field(multi_user_name, searched_mail_id, UPDATE_DATETIME,
+ new_mail_tbl_data, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed : [%d]", err);
+ goto CONTINUE_NEXT;
}
- if (destination_mailbox) /* cleanup before reusing */
- emstorage_free_mailbox(&destination_mailbox, 1, NULL);
+ goto CONTINUE_NEXT;
+ }
- if (priority_sender) {
- new_mail_tbl_data->tag_id = PRIORITY_SENDER_TAG_ID;
- vip_total ++;
- }
+ if (rule && !emcore_check_rule(new_mail_tbl_data->full_address_from,
+ new_mail_tbl_data->subject,
+ rule,
+ rule_count,
+ &priority_sender,
+ &blocked,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emcore_check_rule failed [%d]", err);
+ }
- if (blocked && (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)) {
- if (input_mailbox_tbl->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX) {
- EM_DEBUG_LOG("This mail would be added to spambox");
- if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name,
- account_id,
- EMAIL_MAILBOX_TYPE_SPAMBOX,
- &destination_mailbox,
- false,
- &err)) {
- EM_DEBUG_LOG("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
- }
- }
- else
- blocked = 0;
- }
+ if (destination_mailbox) /* cleanup before reusing */
+ emstorage_free_mailbox(&destination_mailbox, 1, NULL);
- /* Set the noti waited */
- new_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_NOTI_WAITED;
+ if (priority_sender) {
+ new_mail_tbl_data->tag_id = PRIORITY_SENDER_TAG_ID;
+ vip_total ++;
+ }
- if (destination_mailbox) {
- if (destination_mailbox->local_yn == 0 || account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
- if ((err = emcore_move_mail_on_server_by_server_mail_id((void*)*stream, new_mail_tbl_data->server_mail_id, destination_mailbox->mailbox_name)) != EMAIL_ERROR_NONE){
- EM_DEBUG_EXCEPTION("emcore_move_mail_on_server_by_server_mail_id falied [%d]", err);
- goto CONTINUE_NEXT;
- }
+ if (blocked && (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)) {
+ if (input_mailbox_tbl->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX) {
+ EM_DEBUG_LOG("This mail would be added to spambox");
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name,
+ account_id,
+ EMAIL_MAILBOX_TYPE_SPAMBOX,
+ &destination_mailbox,
+ false,
+ &err)) {
+ EM_DEBUG_LOG("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
}
- else { /* local mailbox */
- if ((err = emcore_add_mail_to_mailbox(multi_user_name,
- destination_mailbox,
- new_mail_tbl_data,
- &mail_id,
- &thread_id)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox falied [%d]", err);
- goto CONTINUE_NEXT;
- }
+ }
+ else
+ blocked = 0;
+ }
+ /* Set the noti waited */
+ new_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_NOTI_WAITED;
+
+ if (destination_mailbox) {
+ if (destination_mailbox->local_yn == 0 ||
+ account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
+ err = emcore_move_mail_on_server_by_server_mail_id((void*)*stream,
+ new_mail_tbl_data->server_mail_id,
+ destination_mailbox->mailbox_name);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_move_mail_on_server_by_server_mail_id falied [%d]", err);
+ goto CONTINUE_NEXT;
}
- SNPRINTF(mailbox_id_param_string, 10, "%d", destination_mailbox->mailbox_id);
- } else {
- /* add mails to specified mail box */
- EM_DEBUG_LOG_SEC("mail[%d] moved to input_mailbox_tbl [%s]", mail_id, input_mailbox_tbl->mailbox_name);
- if ( (err = emcore_add_mail_to_mailbox(multi_user_name,
- input_mailbox_tbl,
- new_mail_tbl_data,
- &mail_id,
- &thread_id)) != EMAIL_ERROR_NONE) {
+ } else { /* local mailbox */
+ if ((err = emcore_add_mail_to_mailbox(multi_user_name,
+ destination_mailbox,
+ new_mail_tbl_data,
+ &mail_id,
+ &thread_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox falied [%d]", err);
goto CONTINUE_NEXT;
}
+ }
+ SNPRINTF(mailbox_id_param_string, 10, "%d", destination_mailbox->mailbox_id);
+ } else {
+ /* add mails to specified mail box */
+ EM_DEBUG_LOG_SEC("mail[%d] moved to input_mailbox_tbl [%s]", mail_id, input_mailbox_tbl->mailbox_name);
+ if ((err = emcore_add_mail_to_mailbox(multi_user_name,
+ input_mailbox_tbl,
+ new_mail_tbl_data,
+ &mail_id,
+ &thread_id)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox falied [%d]", err);
+ goto CONTINUE_NEXT;
+ }
+
#ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
- if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
#endif /* __FEATURE_PARTIAL_BODY_FOR_POP3__ */
- if (account_ref->auto_download_size != 0) {
- if (false == emcore_initiate_pbd (multi_user_name,
- *stream,
- account_id,
- mail_id,
- uid_elem->uid,
- input_mailbox_tbl->mailbox_id,
- &err))
- EM_DEBUG_LOG("Partial body download initiation failed [%d]", err);
- }
-#ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
+ if (account_ref->auto_download_size != 0) {
+ if (false == emcore_initiate_pbd(multi_user_name,
+ *stream,
+ account_id,
+ mail_id,
+ uid_elem->uid,
+ input_mailbox_tbl->mailbox_id,
+ input_mailbox_tbl->mailbox_name,
+ &err))
+ EM_DEBUG_LOG("Partial body download initiation failed [%d]", err);
}
+#ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
+ }
#endif /* __FEATURE_PARTIAL_BODY_FOR_POP3__ */
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
- if (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) {
- if (!emcore_insert_auto_download_job(multi_user_name,
- account_id,
- input_mailbox_tbl->mailbox_id,
- mail_id,
- /*account_ref->wifi_auto_download*/ 1,
- uid_elem->uid,
- &err))
- EM_DEBUG_LOG("emcore_insert_auto_download_job failed [%d]", err);
- }
+ if (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) {
+ if (!emcore_insert_auto_download_job(multi_user_name,
+ account_id,
+ input_mailbox_tbl->mailbox_id,
+ mail_id,
+ /*account_ref->wifi_auto_download*/ 1,
+ uid_elem->uid,
+ &err))
+ EM_DEBUG_LOG("emcore_insert_auto_download_job failed [%d]", err);
+ }
#endif
/*
- if (!uid_elem->flag.seen && input_mailbox_tbl->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX)
- emcore_add_notification_for_unread_mail(new_mail_tbl_data);
+ if (!uid_elem->flag.seen && input_mailbox_tbl->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX)
+ emcore_add_notification_for_unread_mail(new_mail_tbl_data);
*/
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- if (!uid_elem->flag.seen) {
- unread++;
- if (priority_sender) {
- vip_unread++;
- }
+ if (!uid_elem->flag.seen) {
+ unread++;
+ if (priority_sender) {
+ vip_unread++;
}
-
- percentage = ((i+1) * 100) / total ;
- EM_DEBUG_LOG("Header Percentage Completed [%d] : [%d/%d] mail_id [%d]", percentage, i+1,
- total, mail_id);
- SNPRINTF(mailbox_id_param_string, 10, "%d", input_mailbox_tbl->mailbox_id);
}
- if (!emcore_notify_storage_event (NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id))
- EM_DEBUG_EXCEPTION ("emcore_notify_storage_event [NOTI_MAIL_ADD] failed");
+ percentage = ((i+1) * 100) / total ;
+ EM_DEBUG_LOG("Header Percentage Completed [%d] : [%d/%d] mail_id [%d]", percentage, i+1,
+ total, mail_id);
+ SNPRINTF(mailbox_id_param_string, 10, "%d", input_mailbox_tbl->mailbox_id);
+ }
-#ifdef __FEATURE_BLOCKING_MODE__
- /* Check the blocking mode */
- int blocking_mode = false;
-
- blocking_mode = emcore_get_blocking_mode_status();
- if (!blocking_mode) {
- if ((err = emcore_check_blocking_mode (multi_user_name, new_mail_tbl_data->email_address_sender,
- &blocking_mode)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION ("emcore_check_blocking_mode failed : [%d]", err);
- }
+ if (!emcore_notify_storage_event (NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id))
+ EM_DEBUG_EXCEPTION ("emcore_notify_storage_event [NOTI_MAIL_ADD] failed");
- if (blocking_mode)
- emcore_set_blocking_mode_status (blocking_mode);
+#ifdef __FEATURE_BLOCKING_MODE__
+ /* Check the blocking mode */
+ int blocking_mode = false;
+
+ blocking_mode = emcore_get_blocking_mode_status();
+ if (!blocking_mode) {
+ if ((err = emcore_check_blocking_mode (multi_user_name, new_mail_tbl_data->email_address_sender,
+ &blocking_mode)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION ("emcore_check_blocking_mode failed : [%d]", err);
}
+
+ if (blocking_mode)
+ emcore_set_blocking_mode_status (blocking_mode);
+ }
#endif /* __FEATURE_BLOCKING_MODE__ */
- /* Set contact log */
- switch (input_mailbox_tbl->mailbox_type) {
- case EMAIL_MAILBOX_TYPE_INBOX :
- if ((err = emcore_set_received_contacts_log(multi_user_name, new_mail_tbl_data)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_set_received_contacts_log failed : [%d]", err);
- }
- break;
- case EMAIL_MAILBOX_TYPE_SENTBOX:
- case EMAIL_MAILBOX_TYPE_OUTBOX:
- if ((err = emcore_set_sent_contacts_log(multi_user_name, new_mail_tbl_data)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_set_sent_contacts_log failed : [%d]", err);
- }
- break;
- default:
- EM_DEBUG_LOG("Mailbox type : [%d]", input_mailbox_tbl->mailbox_type);
- break;
+ /* Set contact log */
+ switch (input_mailbox_tbl->mailbox_type) {
+ case EMAIL_MAILBOX_TYPE_INBOX :
+ if ((err = emcore_set_received_contacts_log(multi_user_name, new_mail_tbl_data)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_received_contacts_log failed : [%d]", err);
}
+ break;
+ case EMAIL_MAILBOX_TYPE_SENTBOX:
+ case EMAIL_MAILBOX_TYPE_OUTBOX:
+ if ((err = emcore_set_sent_contacts_log(multi_user_name, new_mail_tbl_data)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_sent_contacts_log failed : [%d]", err);
+ }
+ break;
+ default:
+ EM_DEBUG_LOG("Mailbox type : [%d]", input_mailbox_tbl->mailbox_type);
+ break;
+ }
- /* Release for envelope is not required and it may cause crash. Don't free the memory for envelope here. */
- /* Envelope data will be freed by garbage collector in mail_close_full */
+ /* Release for envelope is not required and it may cause crash. Don't free the memory for envelope here. */
+ /* Envelope data will be freed by garbage collector in mail_close_full */
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- }
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+ }
CONTINUE_NEXT:
- if (new_mail_tbl_data){
- emstorage_free_mail(&new_mail_tbl_data, 1, NULL);
- new_mail_tbl_data = NULL;
- }
- uid_elem = uid_elem->next;
- i++;
- EM_PROFILE_END(emCoreSyncHeaderEachMail);
+ if (new_mail_tbl_data){
+ emstorage_free_mail(&new_mail_tbl_data, 1, NULL);
+ new_mail_tbl_data = NULL;
}
- EM_PROFILE_END(emCoreSyncHeaderwhileloop);
+ uid_elem = uid_elem->next;
+ i++;
+ EM_PROFILE_END(emCoreSyncHeaderEachMail);
}
+ EM_PROFILE_END(emCoreSyncHeaderwhileloop);
ret = true;
+
FINISH_OFF:
if (mail_count != NULL)
if (!net_sout(pop3local->netstream, cmd, (int)EM_SAFE_STRLEN(cmd))) {
EM_DEBUG_EXCEPTION("net_sout failed...");
-
err = EMAIL_ERROR_CONNECTION_BROKEN;
goto FINISH_OFF;
}
#endif
if (!net_sout(imaplocal->netstream, cmd, (int)EM_SAFE_STRLEN(cmd))) {
EM_DEBUG_EXCEPTION("net_sout failed...");
-
err = EMAIL_ERROR_CONNECTION_BROKEN;
goto FINISH_OFF;
}
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
-static int emcore_initiate_pbd(char *multi_user_name, MAILSTREAM *stream, int account_id, int mail_id, char *uid, int input_maibox_id, int *err_code)
+INTERNAL_FUNC int emcore_initiate_pbd(char *multi_user_name, MAILSTREAM *stream, int account_id,
+ int mail_id, char *uid, int input_maibox_id,
+ char *input_mailbox_name, int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_id[%d], uid[%p], input_maibox_id[%d]", account_id, mail_id, uid, input_maibox_id);
+ EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_id[%d], uid[%p], input_maibox_id[%d], input_mailbox_name[%s]",
+ account_id, mail_id, uid, input_maibox_id, input_mailbox_name);
int ret = false;
int err = EMAIL_ERROR_NONE;
email_account_t *account_ref = NULL;
- emstorage_mailbox_tbl_t* mailbox = NULL;
if (account_id < FIRST_ACCOUNT_ID || mail_id < 0 || NULL == uid || 0 == input_maibox_id){
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
}
account_ref = emcore_get_account_reference(multi_user_name, account_id, false);
+ if (account_ref == NULL) {
+ EM_DEBUG_EXCEPTION("emcore_get_account_reference failed");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
- email_event_partial_body_thd pbd_event;
+ if (account_ref->auto_download_size == 0) {
+ EM_DEBUG_LOG("Header only download");
+ ret = true;
+ goto FINISH_OFF;
+ }
+ email_event_partial_body_thd pbd_event;
memset(&pbd_event, 0x00, sizeof(email_event_partial_body_thd));
pbd_event.account_id = account_id;
else
pbd_event.activity_type = ACTIVITY_PARTIAL_BODY_DOWNLOAD_IMAP4;
- if ( (err = emstorage_get_mailbox_by_id(multi_user_name, input_maibox_id, &mailbox)) != EMAIL_ERROR_NONE || !mailbox) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
- goto FINISH_OFF;
- }
-
- pbd_event.mailbox_id = input_maibox_id;
pbd_event.mail_id = mail_id;
pbd_event.server_mail_id = strtoul(uid, NULL, 0);
- pbd_event.mailbox_name = EM_SAFE_STRDUP(mailbox->mailbox_name);
+ pbd_event.mailbox_id = input_maibox_id;
+ pbd_event.mailbox_name = EM_SAFE_STRDUP(input_mailbox_name);
pbd_event.multi_user_name = EM_SAFE_STRDUP(multi_user_name);
EM_DEBUG_LOG("input_mailbox_name name [%d]", pbd_event.mailbox_id);
EM_DEBUG_LOG("uid [%s]", uid);
- EM_DEBUG_LOG("pbd_event.account_id[%d], pbd_event.mail_id[%d], pbd_event.server_mail_id [%d]", pbd_event.account_id, pbd_event.mail_id , pbd_event.server_mail_id);
+ EM_DEBUG_LOG("pbd_event.account_id[%d], pbd_event.mail_id[%d], pbd_event.server_mail_id [%d]",
+ pbd_event.account_id, pbd_event.mail_id , pbd_event.server_mail_id);
if (!emcore_insert_pbd_activity(&pbd_event, &pbd_event.activity_id, &err)){
EM_DEBUG_EXCEPTION("Inserting Partial Body Download activity failed with error[%d]", err);
FINISH_OFF:
- if (mailbox) {
- emstorage_free_mailbox(&mailbox, 1, &err);
- }
-
if (account_ref) {
emcore_free_account(account_ref);
EM_SAFE_FREE(account_ref);
int *output_attachment_count,
int *output_inline_attachment_count)
{
- EM_DEBUG_FUNC_BEGIN("cnt_info : [%p], account_id : [%d], mail_id : [%d], mailbox_id : [%d]", cnt_info, account_id, mail_id, mailbox_id);
+ EM_DEBUG_FUNC_BEGIN("cnt_info : [%p], account_id : [%d], mail_id : [%d], mailbox_id : [%d]",
+ cnt_info, account_id, mail_id, mailbox_id);
int err = EMAIL_ERROR_NONE;
if (!cnt_info || !account_id || !mail_id || !mailbox_id) {
IMAPLOCAL *imaplocal = NULL;
IMAPPARSEDREPLY *reply_from_server = NULL;
emstorage_mail_tbl_t *mail = NULL;
+ emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
email_partial_buffer *imap_response = NULL;
BODY *body = NULL;
struct _m_content_info *cnt_info = NULL;
/* Check the body download status and body size */
SNPRINTF(uid_string, sizeof(uid_string), "%ld", imap_response[i].uid_no);
- if (!emstorage_get_maildata_by_servermailid(pbd_event[temp_count].multi_user_name, pbd_event[temp_count].mailbox_id, uid_string, &mail, true, &err) || !mail) {
+ if (!emstorage_get_maildata_by_servermailid(pbd_event[temp_count].multi_user_name,
+ uid_string,
+ pbd_event[temp_count].mailbox_id,
+ &mail,
+ false,
+ &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_data_by_servermailid failed : [%d]", err);
if (err == EMAIL_ERROR_MAIL_NOT_FOUND || !mail)
goto FINISH_OFF;
}
+ if (mailbox_tbl) {
+ emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+ mailbox_tbl = NULL;
+ }
+
if (mail->body_download_status & EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED) {
EM_DEBUG_LOG("Downloaded mail");
continue;
}
}
- if (!emstorage_create_dir(pbd_event[temp_count].multi_user_name, pbd_event[temp_count].account_id, mail->mail_id, 0, &err))
+ if (!emstorage_create_dir(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ 0,
+ &err))
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
if (!emstorage_get_save_name(pbd_event[temp_count].multi_user_name,
while (temp_file) {
if (temp_file->type == INLINE_ATTACHMENT && temp_file->save_status == 1) {
inline_download_count++;
- memset(path_buf, 0x00, sizeof(path_buf));
- memset(move_buf, 0x00, sizeof(move_buf));
-
- if (!emstorage_create_dir(pbd_event[temp_count].multi_user_name, pbd_event[temp_count].account_id, mail->mail_id, 0, &err))
+ memset(path_buf, 0x00, sizeof(path_buf));
+ memset(move_buf, 0x00, sizeof(move_buf));
+
+ if (!emstorage_create_dir(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ 0,
+ &err))
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
if (!emstorage_get_save_name(pbd_event[temp_count].multi_user_name,
attachment_tbl.content_id = temp_file->content_id;
EM_DEBUG_LOG("mime_type : [%s]", temp_file->attachment_mime_type);
- if (!emstorage_add_attachment(pbd_event[temp_count].multi_user_name, &attachment_tbl, false, false, &err))
+ if (!emstorage_add_attachment(pbd_event[temp_count].multi_user_name,
+ &attachment_tbl,
+ false,
+ false,
+ &err))
EM_DEBUG_EXCEPTION("emstorage_add_attachment failed - %d", err);
}
}
}
}
- mail->body_download_status = (mail->body_download_status & ~0x00000003) | (( (total_mail_size - total_attachment_size <= input_download_size) && (inline_download_count == inline_attachment_num))?
- EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED: EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED);
+ mail->body_download_status = (mail->body_download_status & ~0x00000003) |
+ (((total_mail_size - total_attachment_size <= input_download_size) &&
+ (inline_download_count == inline_attachment_num)) ?
+ EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED :
+ EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED);
- EM_DEBUG_LOG("inline_download_count[%d] inline_attachment_num[%d]", inline_download_count, inline_attachment_num);
- EM_DEBUG_LOG("total_mail_size[%d] total_attachment_size[%d] input_download_size[%d]", total_mail_size, total_attachment_size, input_download_size);
+ EM_DEBUG_LOG("inline_download_count[%d] inline_attachment_num[%d]",
+ inline_download_count, inline_attachment_num);
+ EM_DEBUG_LOG("total_mail_size[%d] total_attachment_size[%d] input_download_size[%d]",
+ total_mail_size, total_attachment_size, input_download_size);
EM_DEBUG_LOG("mail_id [%d] body_download_status [%d]", mail->mail_id, mail->body_download_status);
/* Get preview text */
EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file() failed[%d]", err);
/* Update body contents */
- if (!emstorage_change_mail_field(pbd_event[temp_count].multi_user_name, mail->mail_id, UPDATE_PARTIAL_BODY_DOWNLOAD, mail, true, &err)) {
+ if (!emstorage_change_mail_field(pbd_event[temp_count].multi_user_name,
+ mail->mail_id,
+ UPDATE_PARTIAL_BODY_DOWNLOAD,
+ mail,
+ true,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed - %d", err);
goto FINISH_OFF;
}
#ifdef __FEATURE_BODY_SEARCH__
/* strip html content and save into mail_text_tbl */
char *stripped_text = NULL;
- if (!emcore_strip_mail_body_from_file(pbd_event[temp_count].multi_user_name, mail, &stripped_text, &err) || stripped_text == NULL) {
+ if (!emcore_strip_mail_body_from_file(pbd_event[temp_count].multi_user_name,
+ mail,
+ &stripped_text,
+ &err) || stripped_text == NULL) {
EM_DEBUG_EXCEPTION("emcore_strip_mail_body_from_file failed [%d]", err);
}
- if (!emstorage_get_mail_text_by_id(pbd_event[temp_count].multi_user_name, mail->mail_id, &mail_text, true, &err) || !mail_text) {
+ if (!emstorage_get_mail_text_by_id(pbd_event[temp_count].multi_user_name,
+ mail->mail_id,
+ &mail_text,
+ true,
+ &err) || !mail_text) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_text_by_id failed [%d]", err);
goto FINISH_OFF;
}
EM_SAFE_FREE(mail_text->body_text);
mail_text->body_text = stripped_text;
- if (!emstorage_change_mail_text_field(pbd_event[temp_count].multi_user_name, mail->mail_id, mail_text, false, &err)) {
+ if (!emstorage_change_mail_text_field(pbd_event[temp_count].multi_user_name,
+ mail->mail_id,
+ mail_text,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_text_field failed [%d]", err);
goto FINISH_OFF;
}
if (mail)
emstorage_free_mail(&mail, 1, NULL);
- if (false == emcore_delete_pbd_activity(pbd_event[temp_count].multi_user_name, pbd_event[temp_count].account_id, pbd_event[temp_count].mail_id, pbd_event[temp_count].activity_id, &err)){
+ if (false == emcore_delete_pbd_activity(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ pbd_event[temp_count].mail_id,
+ pbd_event[temp_count].activity_id,
+ &err)){
EM_DEBUG_EXCEPTION("emcore_delete_pbd_activity failed [%d]", err);
goto FINISH_OFF;
}
if (mail)
emstorage_free_mail(&mail, 1, NULL);
+ if (mailbox_tbl)
+ emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+
if (mail_text)
emstorage_free_mail_text(&mail_text, 1, NULL);
return ret;
}
-
-
INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, email_event_partial_body_thd *pbd_event, int item_count, int *error)
{
EM_DEBUG_FUNC_BEGIN("stream [%p], pbd_event [%p], item_count [%d], error [%p]", stream, pbd_event, item_count, error);
goto FINISH_OFF;
}
- auto_download_size = (pbd_account_tbl->auto_download_size<4096)?4096:pbd_account_tbl->auto_download_size;
+ auto_download_size = (pbd_account_tbl->auto_download_size < 4096) ? 4096 : pbd_account_tbl->auto_download_size;
switch (pbd_account_tbl->incoming_server_type){
case EMAIL_SERVER_TYPE_IMAP4:
EM_DEBUG_LOG("Delete the mailbox in server : success");
}
- if (!emcore_delete_all_mails_of_mailbox(multi_user_name, target_mailbox_array[i].account_id, target_mailbox_array[i].mailbox_id, false, &err)) {
- EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err);
- goto FINISH_OFF;
+ if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
+ target_mailbox_array[i].account_id,
+ target_mailbox_array[i].mailbox_id,
+ 0,
+ false,
+ &err)) {
+ if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
+ EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err);
+ goto FINISH_OFF;
+ }
}
if (!emstorage_delete_mailbox(multi_user_name, target_mailbox_array[i].account_id, -1, target_mailbox_array[i].mailbox_id, true, &err)) {
goto FINISH_OFF;
}
- if (!emcore_delete_all_mails_of_mailbox(multi_user_name, mailbox->account_id, mailbox->mailbox_id, 0, /*NULL, */ &err)) {
- EM_DEBUG_EXCEPTION(" emcore_delete_all_mails_of_mailbox failed - %d", err);
-
- goto FINISH_OFF;
+ if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
+ mailbox->account_id,
+ mailbox->mailbox_id,
+ 0,
+ 0, /*NULL, */
+ &err)) {
+ if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
+ EM_DEBUG_EXCEPTION(" emcore_delete_all_mails_of_mailbox failed - %d", err);
+ goto FINISH_OFF;
+ }
}
if (!emstorage_delete_mailbox(multi_user_name, mailbox->account_id, -1, mailbox->mailbox_id, true, &err)) {
extern long smtp_send(SENDSTREAM *stream, char *command, char *args);
#endif /* __FEATURE_KEEP_CONNECTION__ */
-INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (char *multi_user_name, email_account_t *account,
- int input_mailbox_id, void **result_stream, /*either MAILSTREAM or SENDSTREAM*/
- int *err_code)
+INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (char *multi_user_name,
+ email_account_t *account,
+ int input_mailbox_id,
+ /*either MAILSTREAM or SENDSTREAM*/ void **result_stream,
+ int *err_code)
{
EM_PROFILE_BEGIN(emCoreMailboxOpen);
EM_DEBUG_FUNC_BEGIN("account[%p], input_mailbox_id[%d], mail_stream[%p], err_code[%p]", account, input_mailbox_id,
EM_DEBUG_LOG("Stream reuse desired");
#endif
+ /* set current network error as EMAIL_ERROR_NONE before network operation */
session->error = EMAIL_ERROR_NONE;
- emcore_set_network_error (EMAIL_ERROR_NONE); /* set current network error as EMAIL_ERROR_NONE before network operation */
-
+ emcore_set_network_error(EMAIL_ERROR_NONE);
+
if (input_mailbox_id == EMAIL_CONNECT_FOR_SENDING) {
mailbox_name = EM_SAFE_STRDUP(ENCODED_PATH_SMTP);
- }
- else if (input_mailbox_id == 0) {
+ } else if (input_mailbox_id == 0) {
mailbox_name = NULL;
- }
- else {
+ } else {
if ((error = emstorage_get_mailbox_by_id (multi_user_name, input_mailbox_id, &mailbox)) != EMAIL_ERROR_NONE || !mailbox) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", error);
goto FINISH_OFF;
if (is_connection_for == _SERVICE_THREAD_TYPE_RECEIVING) {
/* open pop3/imap server */
- if (!emcore_get_long_encoded_path_with_account_info (multi_user_name, account, mailbox_name, '/', &mbox_path, &error)) {
+ if (!emcore_get_long_encoded_path_with_account_info(multi_user_name,
+ account,
+ mailbox_name,
+ '/',
+ &mbox_path,
+ &error)) {
EM_DEBUG_EXCEPTION("emcore_get_long_encoded_path failed - %d", error);
session->error = error;
goto FINISH_OFF;
session->auth = 0; /* ref_account->receiving_auth ? 1 : 0 */
- if (!(*result_stream = mail_open (*result_stream, mbox_path, IMAP_2004_LOG))) {
- EM_DEBUG_EXCEPTION("mail_open failed. session->error[%d], session->network[%d]", session->error, session->network);
- *result_stream = mail_close (*result_stream);
+ if (!(*result_stream = mail_open(*result_stream, mbox_path, IMAP_2004_LOG))) {
+ EM_DEBUG_EXCEPTION("mail_open failed. session->error[%d], session->network[%d]",
+ session->error, session->network);
+ *result_stream = mail_close(*result_stream);
+
+ if (account->account_id > 0 && (session->network == EMAIL_ERROR_XOAUTH_BAD_REQUEST ||
+ session->network == EMAIL_ERROR_XOAUTH_INVALID_UNAUTHORIZED)) {
+ error = emcore_refresh_xoauth2_access_token (multi_user_name, account->account_id);
- if(account->account_id > 0 && (session->network == EMAIL_ERROR_XOAUTH_BAD_REQUEST || session->network == EMAIL_ERROR_XOAUTH_INVALID_UNAUTHORIZED)) {
- if((error = emcore_refresh_xoauth2_access_token (multi_user_name, account->account_id)) != EMAIL_ERROR_NONE) {
+ if (error != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_refresh_xoauth2_access_token failed. [%d]", error);
- }
- else {
+ } else {
while (*result_stream == NULL && connection_retry_count < 3) {
sleep(3); /* wait for updating access token */
- if (!(*result_stream = mail_open (*result_stream, mbox_path, IMAP_2004_LOG))) {
- EM_DEBUG_LOG("mail_open failed. session->error[%d], session->network[%d]", session->error, session->network);
+ if (!(*result_stream = mail_open(*result_stream, mbox_path, IMAP_2004_LOG))) {
+ EM_DEBUG_LOG("mail_open failed. session->error[%d], session->network[%d]",
+ session->error, session->network);
}
connection_retry_count++;
EM_DEBUG_LOG ("connection_retry_count [%d]", connection_retry_count);
}
}
- } else if ((session->error == EMAIL_ERROR_TLS_SSL_FAILURE || session->error == EMAIL_ERROR_CANNOT_NEGOTIATE_TLS)) {
+ } else if ((session->error == EMAIL_ERROR_TLS_SSL_FAILURE ||
+ session->error == EMAIL_ERROR_CANNOT_NEGOTIATE_TLS)) {
char *replaced_mbox_path = NULL;
replaced_mbox_path = em_replace_string(mbox_path, "}", "/force_tls_v1_0}");
- if (replaced_mbox_path != NULL && !(*result_stream = mail_open (*result_stream, replaced_mbox_path, IMAP_2004_LOG))) {
- EM_DEBUG_EXCEPTION("retry --> mail_open failed. session->error[%d], session->network[%d]", session->error, session->network);
- *result_stream = mail_close (*result_stream);
+ if (replaced_mbox_path != NULL &&
+ !(*result_stream = mail_open(*result_stream, replaced_mbox_path, IMAP_2004_LOG))) {
+ EM_DEBUG_EXCEPTION("retry --> mail_open failed. session->error[%d], session->network[%d]",
+ session->error, session->network);
+ *result_stream = mail_close(*result_stream);
}
EM_SAFE_FREE(replaced_mbox_path);
goto FINISH_OFF;
}
}
- }
- else {
+ } else {
/* open smtp server */
char *host_list[2] = {NULL, NULL};
}
#endif
if (!*result_stream) {
- if (!emcore_get_long_encoded_path_with_account_info (multi_user_name, account, mailbox_name, 0, &mbox_path, &error)) {
+ if (!emcore_get_long_encoded_path_with_account_info(multi_user_name,
+ account,
+ mailbox_name,
+ 0,
+ &mbox_path,
+ &error)) {
EM_DEBUG_EXCEPTION(" emcore_get_long_encoded_path failed - %d", error);
session->error = error;
goto FINISH_OFF;
if (!(*result_stream = smtp_open (host_list, 1))) {
EM_DEBUG_EXCEPTION_SEC("smtp_open error : outgoing_server_secure_connection[%d] "
- "session->error[%d] session->network[%d]",
- account->outgoing_server_secure_connection, session->error, session->network);
+ "session->error[%d] session->network[%d]",
+ account->outgoing_server_secure_connection,
+ session->error, session->network);
if (account->account_id > 0 && (session->network == EMAIL_ERROR_XOAUTH_BAD_REQUEST ||
- session->network == EMAIL_ERROR_XOAUTH_INVALID_UNAUTHORIZED)) {
- *result_stream = smtp_close (*result_stream);
- if((error = emcore_refresh_xoauth2_access_token (multi_user_name, account->account_id)) != EMAIL_ERROR_NONE) {
+ session->network == EMAIL_ERROR_XOAUTH_INVALID_UNAUTHORIZED)) {
+ *result_stream = smtp_close(*result_stream);
+
+ error = emcore_refresh_xoauth2_access_token(multi_user_name, account->account_id);
+ if (error != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION ("emcore_refresh_xoauth2_access_token failed. [%d]", error);
if ((session->error == EMAIL_ERROR_UNKNOWN) || (session->error == EMAIL_ERROR_NONE))
session->error = EMAIL_ERROR_CONNECTION_FAILURE;
}
sleep(2); /* wait for updating access token */
-
- if (!(*result_stream = smtp_open (host_list, 1))) {
+ if (!(*result_stream = smtp_open(host_list, 1))) {
if (session->network != EMAIL_ERROR_NONE)
session->error = session->network;
if ((session->error == EMAIL_ERROR_UNKNOWN) || (session->error == EMAIL_ERROR_NONE))
error = session->error;
goto FINISH_OFF;
}
- }
- else {
+ } else {
error = EMAIL_ERROR_CONNECTION_FAILURE;
goto FINISH_OFF;
}
if (err_code)
*err_code = error;
+
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
}
case EMAIL_SEARCH_FILTER_TYPE_TO :\r
case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :\r
case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :\r
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET :\r
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED :\r
dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.search_filter_list[i].search_filter_key_value.string_type_key_value), DBUS_TYPE_INVALID);\r
break;\r
\r
signed_message = PKCS7_sign(NULL, NULL, other_certs, bio_mime_entity, flags);
if (!signed_message) {
- EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
digest = emcore_get_digest_algorithm(digest_type);
if (!PKCS7_sign_add_signer(signed_message, cert, private_key, digest, flags)) {
- EM_DEBUG_EXCEPTION("PKCS7_sign_add_signer failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_sign_add_signer failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
if (!PKCS7_final(signed_message, bio_mime_entity, flags)) {
- EM_DEBUG_EXCEPTION("PKCS7_final failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_final failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
if (!i2d_PKCS7_bio_stream(smime_attachment, signed_message, bio_mime_entity, flags)) {
- EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
encrypt_message = PKCS7_encrypt(recipient_certs, bio_mime_entity, cipher, flags);
if (encrypt_message == NULL) {
- EM_DEBUG_EXCEPTION("PKCS7_encrypt failed [%ld]", ERR_get_error());
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_encrypt failed [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
if (!i2d_PKCS7_bio_stream(smime_attachment, encrypt_message, bio_mime_entity, flags)) {
- EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
/* 3. signing */
signed_message = PKCS7_sign(NULL, NULL, other_certs, bio_mime_entity, flags);
if (!signed_message) {
- EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
/* 5. Apply a digest algorithm */
if (!PKCS7_sign_add_signer(signed_message, cert, private_key, digest, flags)) {
- EM_DEBUG_EXCEPTION("PKCS7_sign_add_signer failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_sign_add_signer failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
goto FINISH_OFF;
}
- if (!SMIME_write_PKCS7(bio_signed_message, signed_message, bio_mime_entity, flags | SMIME_OLDMIME | SMIME_CRLFEOL)) {
- EM_DEBUG_EXCEPTION("SMIME_write_PKCS7 error");
+ if (!SMIME_write_PKCS7(bio_signed_message, signed_message, bio_mime_entity,
+ flags | SMIME_OLDMIME | SMIME_CRLFEOL)) {
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("SMIME_write_PKCS7 error : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
encrypt_message = PKCS7_encrypt(recipient_certs, bio_signed_message, cipher, flags);
if (encrypt_message == NULL) {
- EM_DEBUG_EXCEPTION("PKCS7_encrypt failed [%ld]", ERR_get_error());
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_encrypt failed [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
/* 4. Write the encrypt message in file */
if (!i2d_PKCS7_bio_stream(smime_attachment, encrypt_message, bio_mime_entity, flags)) {
- EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
}
if (!PKCS7_decrypt(p7_encrypt_message, private_key, cert, out_buf, 0)) {
- EM_DEBUG_EXCEPTION("Decrpyt failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("Decrpyt failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_DECRYPT_FAILED;
goto FINISH_OFF;
}
#include "email-debug-log.h"
#include "email-core-gmime.h"
#include "email-core-container.h"
+#include "email-network.h"
#undef min
if (body->encoding == ENCQUOTEDPRINTABLE || body->encoding == ENCBASE64)
fprintf(fp, CRLF_STRING);
- fprintf(fp, CRLF_STRING);
-
FINISH_OFF: /* prevent 34226 */
/* cleanup local vars */
rfc822_write_body_header(&p, &part->body);
- fprintf(fp, "--%s"CRLF_STRING, bndry);
+ fprintf(fp, CRLF_STRING"--%s"CRLF_STRING, bndry);
if (body->subtype && (body->subtype[0] == 'S' || body->subtype[0] == 's')) {
if ((error = emcore_write_body (body, root_body, fp)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_write_body failed : [%d]", error);
return false;
}
- fprintf(fp, "--%s"CRLF_STRING, bndry);
+ fprintf(fp, CRLF_STRING"--%s"CRLF_STRING, bndry);
}
- fprintf(fp, "%s"CRLF_STRING, buf);
-
+ fprintf(fp, "%s", buf);
emcore_write_rfc822_body(&part->body, root_body, fp, err_code);
+
} while ((part = part->next));
- fprintf(fp, "--%s--"CRLF_STRING, bndry);
+ fprintf(fp, CRLF_STRING"--%s--"CRLF_STRING, bndry);
break;
default:
EM_DEBUG_LOG_DEV("body->type is not TYPEMULTIPART");
+ fprintf(fp, CRLF_STRING);
if ((error = emcore_write_body (body, root_body, fp)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_write_body failed : [%d]", error);
return false;
rfc822_output_header(&buf, env, body, NIL, NIL); /* Excluding BCC */
EM_DEBUG_LOG("header_buffer [%d]", strlen(header_buffer));
-
{
gchar **tokens = g_strsplit(header_buffer, "CHARSET=X-UNKNOWN", 2);
}
}
- SNPRINTF(header_buffer + EM_SAFE_STRLEN(header_buffer), header_buffer_lenth-(EM_SAFE_STRLEN(header_buffer)), CRLF_STRING);
-
+// SNPRINTF(header_buffer + EM_SAFE_STRLEN(header_buffer), header_buffer_lenth-(EM_SAFE_STRLEN(header_buffer)), CRLF_STRING);
if (data && EM_SAFE_STRLEN(*data) > 0) {
fname = EM_SAFE_STRDUP(*data);
file_exist = 1;
EM_DEBUG_LOG("thread_item_count [%d]", thread_item_count);
if (thread_item_count > 1) {
- if (!emstorage_update_latest_thread_mail(multi_user_name, mail_data->account_id, mail_data->mailbox_id, converted_mail_tbl->thread_id, &updated_thread_id, 0, 0, NOTI_THREAD_ID_CHANGED_BY_ADD, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ mail_data->account_id,
+ mail_data->mailbox_id,
+ mail_data->mailbox_type,
+ converted_mail_tbl->thread_id,
+ &updated_thread_id,
+ 0,
+ 0,
+ NOTI_THREAD_ID_CHANGED_BY_ADD,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
dst_mailbox_id = local_mailbox->mailbox_id;
emstorage_free_mailbox(&local_mailbox, 1, NULL);
+ if (!emnetwork_check_network_status(&err)) {
+ EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
+ goto FINISH_OFF;
+ }
send_stream = emcore_get_smtp_stream (multi_user_name, account_id, &err);
if (!send_stream) {
EM_DEBUG_EXCEPTION("emcore_sync_header failed");
}
mail_close (local_stream);
- if (!emstorage_get_maildata_by_servermailid(multi_user_name, local_mailbox->mailbox_id, "0", &temp_mail, false, &err)) {
+ if (!emstorage_get_maildata_by_servermailid(multi_user_name,
+ "0",
+ local_mailbox->mailbox_id,
+ &temp_mail,
+ false,
+ &err)) {
if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid failed : [%d]", err);
goto FINISH_OFF;
int err2 = EMAIL_ERROR_NONE;
int status = EMAIL_SEND_FAIL;
int *mail_ids = NULL;
- DB_STMT handle;
+ DB_STMT handle = NULL;
int i = 0;
int total = 0;
int attachment_tbl_count = 0;
/*don't delete the comment. several threads including event thread call this func */
/* FINISH_OFF_IF_CANCELED; */
+ if (!emnetwork_check_network_status(&err)) {
+ EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
opt = &(ref_account->options);
if (!emstorage_get_mailbox_by_name(multi_user_name, account_id, -1, input_mailbox_name, &local_mailbox, false, &err)) {
recipients++;
}
-
if (send_err) {
EM_DEBUG_EXCEPTION("One or more recipients failed...");
err = EMAIL_ERROR_INVALID_ADDRESS;
}
while (total) {
-#if 0
/* Cancel the sending event */
if (!emcore_check_send_mail_thread_status()) {
EM_DEBUG_EXCEPTION(" emcore_check_send_mail_thread_status failed...");
err = EMAIL_ERROR_CANCELLED;
goto FINISH_OFF;
}
-#endif
+
if (total < allocSize)
dataSize = total;
else
emcore_encode_rfc2047_address(envelope->cc, &error);
emcore_encode_rfc2047_address(envelope->bcc, &error);
- if (input_mail_tbl_data->subject)
+ if (input_mail_tbl_data->subject) {
envelope->subject = emcore_encode_rfc2047_text(input_mail_tbl_data->subject, &error);
+ }
char rfc822_date_string[DATE_STR_LENGTH] = { 0, };
rfc822_date(rfc822_date_string);
trigger_at_time = current_time + input_alarm_interval_in_second;
- if ((err = emcore_add_alarm(multi_user_name, trigger_at_time, EMAIL_ALARM_CLASS_AUTO_RESEND, 0, emcore_auto_resend_cb, (void *)multi_user_name)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_add_alarm(multi_user_name, trigger_at_time, EMAIL_ALARM_CLASS_AUTO_RESEND, 0, emcore_auto_resend_cb, NULL)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]",err);
goto FINISH_OFF;
}
}
FINISH_OFF:
- emcore_finalize_async_task_handler(task, err);
- EM_SAFE_FREE(decoded_task_parameter);
+ emcore_finalize_async_task_handler(task, err);
EM_DEBUG_FUNC_END("err [%d]", err);
return NULL;
free(return_err);
}
- EM_SAFE_FREE(decoded_task_parameter);
-
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
if(tn)
tpl_free(tn);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_SAFE_FREE(result_data);
+
+ if (task_parameter) {
+ EM_SAFE_FREE(task_parameter->multi_user_name);
+ EM_SAFE_FREE(task_parameter->mail_id_array);
+ free(task_parameter);
+ }
+ }
+
EM_DEBUG_FUNC_END("err [%d]", err);
- return EMAIL_ERROR_NONE;
+ return err;
}
-INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(char *input_byte_stream, int input_stream_size, void **output_task_parameter_struct)
+INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(char *input_byte_stream,
+ int input_stream_size,
+ void **output_task_parameter_struct)
{
- EM_DEBUG_FUNC_BEGIN("input_byte_stream [%p] input_stream_size [%d] output_task_parameter_struct [%p]", input_byte_stream, input_stream_size, output_task_parameter_struct);
+ EM_DEBUG_FUNC_BEGIN("input_byte_stream [%p] input_stream_size [%d] output_task_parameter_struct [%p]",
+ input_byte_stream, input_stream_size, output_task_parameter_struct);
int err = EMAIL_ERROR_NONE;
tpl_node *tn = NULL;
tpl_bin tb_mail_id_array;
}
task_parameter = em_malloc(sizeof(task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE));
-
if(task_parameter == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
err = EMAIL_ERROR_OUT_OF_MEMORY;
tpl_unpack(tn, 0);
if(task_parameter->mail_id_count <= 0 || tb_mail_id_array.addr == NULL) {
- EM_DEBUG_LOG("No mail id list. mail_id_count[%d] addr[%p]", task_parameter->mail_id_count, tb_mail_id_array.addr);
+ EM_DEBUG_LOG("No mail id list. mail_id_count[%d] addr[%p]",
+ task_parameter->mail_id_count, tb_mail_id_array.addr);
}
else {
task_parameter->mail_id_array = tb_mail_id_array.addr;
}
if(tb_value.addr) {
- if ((err = emcore_get_mail_attribute_value_type(task_parameter->attribute_type, &attribute_value_type)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_get_mail_attribute_value_type(task_parameter->attribute_type,
+ &attribute_value_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_mail_attribute_value_type failed [%d]", err);
goto FINISH_OFF;
}
FINISH_OFF:
- if(tn)
+ if (tn)
tpl_free(tn);
+ if (err != EMAIL_ERROR_NONE) {
+ if (task_parameter) {
+ EM_SAFE_FREE(task_parameter->multi_user_name);
+ EM_SAFE_FREE(task_parameter->mail_id_array);
+ free(task_parameter);
+ }
+ }
+
EM_DEBUG_FUNC_END("err [%d]", err);
- return EMAIL_ERROR_NONE;
+ return err;
}
INTERNAL_FUNC void *task_handler_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(void *input_param)
SNPRINTF(p, long_enc_path_len, "{%s:%d/%s/user=%d%s%s",
account->incoming_server_address,
account->incoming_server_port_number,
- account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap",
- account->account_id,
- TOKEN_FOR_MULTI_USER,
+ account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap",
+ account->account_id,
+ TOKEN_FOR_MULTI_USER,
multi_user_name);
} else {
SNPRINTF(p, long_enc_path_len, "{%s:%d/%s/user=%d",
account->incoming_server_address,
account->incoming_server_port_number,
- account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap",
+ account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap",
account->account_id);
}
if (account->outgoing_server_need_authentication > 0) {
if (multi_user_name) {
- SNPRINTF(p + EM_SAFE_STRLEN(p), long_enc_path_len-(EM_SAFE_STRLEN(p)), "/user=%d%s%s",
- account->account_id,
- TOKEN_FOR_MULTI_USER,
+ SNPRINTF(p + EM_SAFE_STRLEN(p), long_enc_path_len-(EM_SAFE_STRLEN(p)), "/user=%d%s%s",
+ account->account_id,
+ TOKEN_FOR_MULTI_USER,
multi_user_name);
} else {
- SNPRINTF(p + EM_SAFE_STRLEN(p), long_enc_path_len-(EM_SAFE_STRLEN(p)), "/user=%d",
+ SNPRINTF(p + EM_SAFE_STRLEN(p), long_enc_path_len-(EM_SAFE_STRLEN(p)), "/user=%d",
account->account_id);
}
int total_mail_count = 0;
int unseen = 0;
- if (!emcore_get_mail_count_by_query((char *)data, ALL_ACCOUNT,
- EMAIL_MAILBOX_TYPE_INBOX, 0,
- &total_mail_count, &total_unread_count,
+ if (!emcore_get_mail_count_by_query((char *)data, ALL_ACCOUNT,
+ EMAIL_MAILBOX_TYPE_INBOX, 0,
+ &total_mail_count, &total_unread_count,
&err)) {
EM_DEBUG_EXCEPTION("emcore_get_mail_count_by_query failed");
goto FINISH_OFF;
EM_DEBUG_FUNC_BEGIN();
int storage_status = 0, nError = 0;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
#endif
#ifdef STORAGE_STATUS
mailbox = g_strdup(mailbox_path);
- token_list = g_strsplit_set(mailbox, "/", -1);
+ token_list = g_strsplit_set(mailbox, "/\\", -1);
if(token_list == NULL) {
EM_DEBUG_LOG("g_strsplit_set failed.");
} else {
prefix_path = strdup("");
}
-
+
if (input_html_path) { /*prevent 26249*/
/* get preview text from html file */
char result_buffer[MAX_PREVIEW_TEXT_LENGTH] = { 0, };
if (time_info == NULL) {
EM_DEBUG_EXCEPTION("localtime failed");
err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
+ goto FINISH_OFF;
}
EM_DEBUG_LOG("input time and date: %s", asctime(time_info));
if (time_info == NULL) {
EM_DEBUG_EXCEPTION("localtime failed");
err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
+ goto FINISH_OFF;
}
EM_DEBUG_LOG("input time and date: %s", asctime(time_info));
int ret = false;
int err = EMAIL_ERROR_NONE;
-
+
if (!emcore_get_mail_contact_info_with_update(multi_user_name, contact_info, full_address, 0, &err))
EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info_with_update failed [%d]", err);
else
}
int emcore_set_contacts_log (char *multi_user_name,
- int account_id,
- char *email_address,
- char *subject,
- time_t date_time,
+ int account_id,
+ char *email_address,
+ char *subject,
+ time_t date_time,
email_action_t action)
{
/* arg shall be destroyed in emcore_set_contacts_log_internal */
rfc822_parse_adrlist(&addr, address_array[i], NULL);
for (p_addr = addr ; p_addr ;p_addr = p_addr->next) {
SNPRINTF(email_address, MAX_EMAIL_ADDRESS_LENGTH, "%s@%s", addr->mailbox, addr->host);
- if ((err = emcore_set_contacts_log(multi_user_name,
- input_mail_data->account_id,
- email_address,
- input_mail_data->subject,
- input_mail_data->date_time,
+ if ((err = emcore_set_contacts_log(multi_user_name,
+ input_mail_data->account_id,
+ email_address,
+ input_mail_data->subject,
+ input_mail_data->date_time,
EMAIL_ACTION_SEND_MAIL)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_set_contacts_log failed : [%d]", err);
goto FINISH_OFF;
EM_DEBUG_FUNC_BEGIN("input_mail_data : [%p]", input_mail_data);
int err = EMAIL_ERROR_NONE;
- if ((err = emcore_set_contacts_log(multi_user_name,
- input_mail_data->account_id,
- input_mail_data->email_address_sender,
- input_mail_data->subject,
- input_mail_data->date_time,
+ if ((err = emcore_set_contacts_log(multi_user_name,
+ input_mail_data->account_id,
+ input_mail_data->email_address_sender,
+ input_mail_data->subject,
+ input_mail_data->date_time,
EMAIL_ACTION_SYNC_HEADER)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_set_contacts_log failed [%d]", err);
}
gboolean emcore_delete_contacts_log_internal(void* arg)
{
EM_DEBUG_FUNC_BEGIN();
-
+
contacts_delete_data *data = (contacts_delete_data *)arg;
int contacts_error = CONTACTS_ERROR_NONE;
g_main_context_invoke (NULL, emcore_delete_contacts_log_internal, (void*) data);
- return EMAIL_ERROR_NONE;
+ return EMAIL_ERROR_NONE;
}
INTERNAL_FUNC int emcore_get_mail_display_name (char *multi_user_name, char *email_address, char **contact_display_name)
GVariant *result = NULL;
int ret = EMAIL_ERROR_NONE;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
#endif
GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
goto FINISH_OFF;
}
- result = g_dbus_proxy_call_sync (bproxy,
- "GetDisplayName",
- g_variant_new ("(ss)", email_address, multi_user_name),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
+ result = g_dbus_proxy_call_sync (bproxy,
+ "GetDisplayName",
+ g_variant_new ("(ss)", email_address, multi_user_name),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
&gerror);
if (!result) {
- EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'GetDisplayName' error [%s]",
+ EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'GetDisplayName' error [%s]",
gerror->message);
ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
goto FINISH_OFF;
}
-INTERNAL_FUNC int emcore_get_mail_display_name_internal (char *multi_user_name,
- char *email_address,
+INTERNAL_FUNC int emcore_get_mail_display_name_internal (char *multi_user_name,
+ char *email_address,
char **contact_display_name)
{
EM_DEBUG_FUNC_BEGIN_SEC("contact_name_value[%s], contact_display_name[%p]", email_address, contact_display_name);
if (EM_SAFE_STRLEN(multi_user_name) > 0) {
if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
- return err;
+ return err;
}
}
if (EM_SAFE_STRLEN(multi_user_name) > 0) {
if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
- return err;
+ return err;
}
}
GVariant *result = NULL;
int ret = EMAIL_ERROR_NONE;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
#endif
GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
goto FINISH_OFF;
}
- result = g_dbus_proxy_call_sync (bproxy,
- "CheckBlockingMode",
- g_variant_new ("(ss)", sender_address, multi_user_name),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
+ result = g_dbus_proxy_call_sync (bproxy,
+ "CheckBlockingMode",
+ g_variant_new ("(ss)", sender_address, multi_user_name),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
&gerror);
if (!result) {
- EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'CheckBlockingMode' error [%s]",
+ EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'CheckBlockingMode' error [%s]",
gerror->message);
ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
goto FINISH_OFF;
int err = EMAIL_ERROR_NONE;
int ret = false;
- if(network_status == 0) {
+ if (network_status == 0) {
EM_DEBUG_LOG("VCONFKEY_NETWORK_STATUS is 0");
- if ( (err = _get_flight_mode(&flight_mode)) != EMAIL_ERROR_NONE) {
+ if ((err = _get_flight_mode(&flight_mode)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("_get_flight_mode failed : [%d]", err);
goto FINISH_OFF;
}
goto FINISH_OFF;
}
- if ( (err = emnetwork_get_wifi_status(&wifi_status)) != EMAIL_ERROR_NONE) {
+ if ((err = emnetwork_get_wifi_status(&wifi_status)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emnetwork_get_wifi_status failed [%d]", err);
goto FINISH_OFF;
}
#include "email-core-signal.h"
#include "email-core-event.h"
#include "email-core-container.h"
+#include "email-core-gmime.h"
#include "email-core-key-manager.h"
#define SETTING_MEMORY_TEMP_FILE_PATH "/tmp/email_tmp_file"
pthread_t current_thread_id = THREAD_SELF();
sqlite3 *result_db_handle = NULL;
- ENTER_CRITICAL_SECTION(_db_handle_lock);
- for (i = 0; i < MAX_DB_CLIENT; i++) {
- if (pthread_equal(current_thread_id, _db_handle_list[i].thread_id))
- {
- if (_db_handle_list[i].user_name) {
- if (EM_SAFE_STRCASECMP(_db_handle_list[i].user_name, multi_user_name ? multi_user_name : "root"))
- continue;
- }
- EM_DEBUG_LOG_DEV("found db handle at [%d]", i);
- result_db_handle = _db_handle_list[i].db_handle;
- break;
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ ENTER_CRITICAL_SECTION(_db_handle_lock);
+ for (i = 0; i < MAX_DB_CLIENT; i++) {
+ if (EM_SAFE_STRCASECMP(_db_handle_list[i].user_name, multi_user_name) != 0)
+ continue;
+
+ if (pthread_equal(current_thread_id, _db_handle_list[i].thread_id)) {
+ EM_DEBUG_LOG_DEV("found db handle at [%d]", i);
+ result_db_handle = _db_handle_list[i].db_handle;
+ break;
+ }
+ }
+ LEAVE_CRITICAL_SECTION(_db_handle_lock);
+ } else {
+ ENTER_CRITICAL_SECTION(_db_handle_lock);
+ for (i = 0; i < MAX_DB_CLIENT; i++) {
+ if (EM_SAFE_STRLEN(_db_handle_list[i].user_name) > 0)
+ continue;
+
+ if (pthread_equal(current_thread_id, _db_handle_list[i].thread_id)) {
+ EM_DEBUG_LOG_DEV("found db handle at [%d]", i);
+ result_db_handle = _db_handle_list[i].db_handle;
+ break;
+ }
}
+ LEAVE_CRITICAL_SECTION(_db_handle_lock);
}
- LEAVE_CRITICAL_SECTION(_db_handle_lock);
if (!result_db_handle)
EM_DEBUG_LOG("no db_handle for [%d] found", current_thread_id);
_db_handle_list[i].thread_id = current_thread_id;
_db_handle_list[i].db_handle = db_handle;
/* Only distinguished container and host */
- _db_handle_list[i].user_name = strdup(multi_user_name ? multi_user_name : "root");
+ _db_handle_list[i].user_name = EM_SAFE_STRDUP(multi_user_name);
EM_DEBUG_LOG("current_thread_id [%d], index [%d]", current_thread_id, i);
error_code = EMAIL_ERROR_NONE;
break;
/* pData : a parameter which is registered when busy handler is registerd */
/* count : retry count */
-#define EMAIL_STORAGE_MAX_RETRY_COUNT 20
-
-static int _callback_sqlite_busy_handler(void *pData, int retry)
-{
- if (retry < EMAIL_STORAGE_MAX_RETRY_COUNT) {
- EM_DEBUG_LOG("Busy handler called!!: [%d]", retry);
- sqlite3_sleep(200);
+static int _callback_sqlite_busy_handler(void *pData, int count)
+{
+ if (10 - count > 0) {
+ struct timespec time = {
+ .tv_sec = 0,
+ .tv_nsec = (count + 1) * 100 * 1000 * 1000
+ };
+ EM_DEBUG_LOG("Busy handler called!!: PID[%d] / CNT [%d]", getpid(), count);
+ nanosleep(&time, NULL);
return 1;
+ } else {
+ EM_DEBUG_EXCEPTION("Busy handler will be returned SQLITE_BUSY error PID[%d] / CNT[%d]", getpid(), count);
+ return 0;
}
-
- EM_DEBUG_EXCEPTION("Invalid Busy handler called:: [%d]", retry);
- return 0;
}
static int _callback_collation_utf7_sort(void *data, int length_text_a, const void *text_a,
goto FINISH_OFF;
}
- EM_DEBUG_LOG_DEV(">>>>> Register DB Handle to busy handler: *sqlite_handle[%p]", *sqlite_handle);
/* register busy handler */
+ EM_DEBUG_LOG_DEV(">>>>> Register DB Handle to busy handler: *sqlite_handle[%p]", *sqlite_handle);
rc = sqlite3_busy_handler(*sqlite_handle, _callback_sqlite_busy_handler, NULL); /* Busy Handler registration, NULL is a parameter which will be passed to handler */
if (SQLITE_OK != rc) {
EM_DEBUG_EXCEPTION("sqlite3_busy_handler fail:%d -%s", rc, sqlite3_errmsg(*sqlite_handle));
return ret;
}
-INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(char *multi_user_name, int mailbox_id, char *server_mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(char *multi_user_name,
+ char *server_mail_id,
+ int mailbox_id,
+ emstorage_mail_tbl_t **mail,
+ int transaction,
+ int *err_code)
{
- EM_DEBUG_FUNC_BEGIN_SEC("mailbox_id [%d], server_mail_id[%s], mail[%p], transaction[%d], err_code[%p]", mailbox_id, server_mail_id, mail, transaction, err_code);
+ EM_DEBUG_FUNC_BEGIN_SEC("mailbox_id [%d], server_mail_id[%s], mail[%p], transaction[%d], err_code[%p]",
+ mailbox_id, server_mail_id, mail, transaction, err_code);
int ret = false, error = EMAIL_ERROR_NONE, result_count;
char conditional_clause[QUERY_SIZE] = {0, };
goto FINISH_OFF;
}
- if (mailbox_id == 0)
- SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE UPPER(server_mail_id) =UPPER('%s')", server_mail_id);
- else
- SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE UPPER(server_mail_id) =UPPER('%s') AND mailbox_id = %d", server_mail_id, mailbox_id);
+ SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE UPPER(server_mail_id) = UPPER('%s')", server_mail_id);
+ if (mailbox_id > 0)
+ SNPRINTF(conditional_clause + strlen(conditional_clause), QUERY_SIZE, " AND mailbox_id = %d", mailbox_id);
+
EM_DEBUG_LOG("conditional_clause [%s]", conditional_clause);
- if (!emstorage_query_mail_tbl(multi_user_name, conditional_clause, transaction, &p_data_tbl, &result_count, &error)) {
+ if (!emstorage_query_mail_tbl(multi_user_name,
+ conditional_clause,
+ transaction,
+ &p_data_tbl,
+ &result_count,
+ &error)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl failed [%d]", error);
goto FINISH_OFF;
}
ret = true;
FINISH_OFF:
+
if (ret == true)
*mail = p_data_tbl;
EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string);
- if( (ret = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, "", true, false, output_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
+ if ((ret = emstorage_query_mailbox_tbl(multi_user_name,
+ conditional_clause_string,
+ "", true, false, output_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", ret);
goto FINISH_OFF;
}
}
-INTERNAL_FUNC int emstorage_update_mailbox_total_count(char *multi_user_name, int account_id, int input_mailbox_id, int total_count_on_server, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_mailbox_total_count(char *multi_user_name,
+ int account_id,
+ int input_mailbox_id,
+ int total_count_on_server,
+ int transaction,
+ int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], total_count_on_server[%d], transaction[%d], err_code[%p]", account_id, input_mailbox_id, total_count_on_server, transaction, err_code);
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], total_count_on_server[%d], "
+ "transaction[%d], err_code[%p]",
+ account_id, input_mailbox_id, total_count_on_server, transaction, err_code);
+
int ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
if (account_id <= 0 || input_mailbox_id <= 0) {
EM_DEBUG_EXCEPTION("account_id[%d], input_mailbox_id[%d]", account_id, input_mailbox_id);
-
if (err_code != NULL)
*err_code = EMAIL_ERROR_INVALID_PARAM;
EM_DEBUG_FUNC_END("ret [%d]", ret);
return false;
}
+
sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
ret = true;
FINISH_OFF:
+
EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
#define STRIPPED_SUBJECT_BUFFER_SIZE 4086
-INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(char *multi_user_name, emstorage_mail_tbl_t *mail_tbl, int *thread_id, int *result_latest_mail_id_in_thread, int *thread_item_count)
+INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(char *multi_user_name,
+ emstorage_mail_tbl_t *mail_tbl,
+ int *thread_id,
+ int *result_latest_mail_id_in_thread,
+ int *thread_item_count)
{
- EM_DEBUG_FUNC_BEGIN("mail_tbl [%p], thread_id [%p], result_latest_mail_id_in_thread [%p], thread_item_count [%p]", mail_tbl, thread_id, result_latest_mail_id_in_thread, thread_item_count);
+ EM_DEBUG_FUNC_BEGIN("mail_tbl [%p], thread_id [%p], "
+ "result_latest_mail_id_in_thread [%p], thread_item_count [%p]",
+ mail_tbl, thread_id, result_latest_mail_id_in_thread, thread_item_count);
EM_PROFILE_BEGIN(profile_emstorage_get_thread_id_of_thread_mails);
+
int rc = 0, query_size = 0, query_size_account = 0;
int account_id = 0;
int err_code = EMAIL_ERROR_NONE;
goto FINISH_OFF;
}
- if (em_find_pos_stripped_subject_for_thread_view(subject, stripped_subject, STRIPPED_SUBJECT_BUFFER_SIZE) != EMAIL_ERROR_NONE) {
+ if (em_find_pos_stripped_subject_for_thread_view(subject,
+ stripped_subject,
+ STRIPPED_SUBJECT_BUFFER_SIZE) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_find_pos_stripped_subject_for_thread_view is failed");
err_code = EMAIL_ERROR_UNKNOWN;
result_thread_id = -1;
goto FINISH_OFF;
}
- EM_DEBUG_LOG_SEC("em_find_pos_stripped_subject_for_thread_view returns[len = %d] = %s", EM_SAFE_STRLEN(stripped_subject), stripped_subject);
+ EM_DEBUG_LOG_SEC("em_find_pos_stripped_subject_for_thread_view returns[len = %d] = %s",
+ EM_SAFE_STRLEN(stripped_subject), stripped_subject);
if (account_id > 0) {
query_size_account = 3 + EM_SAFE_STRLEN(sql_format_account);
return ret;
}
-INTERNAL_FUNC int emstorage_update_latest_thread_mail(char *multi_user_name, int account_id, int mailbox_id, int thread_id, int *updated_thread_id, int latest_mail_id, int thread_item_count, int noti_type, int transaction, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_id [%d], thread_id[%d], updated_thread_id[%p], latest_mail_id [%d], thread_item_count[%d], err_code[%p]", account_id, mailbox_id, thread_id, updated_thread_id, latest_mail_id, thread_item_count, err_code);
+INTERNAL_FUNC int emstorage_update_latest_thread_mail(char *multi_user_name,
+ int account_id,
+ int mailbox_id,
+ int mailbox_type,
+ int thread_id,
+ int *updated_thread_id,
+ int latest_mail_id,
+ int thread_item_count,
+ int noti_type,
+ int transaction,
+ int *err_code)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_id [%d], thread_id[%d], updated_thread_id[%p], "
+ "latest_mail_id [%d], thread_item_count[%d], err_code[%p]",
+ account_id, mailbox_id, thread_id, updated_thread_id,
+ latest_mail_id, thread_item_count, err_code);
int rc = -1, ret = false;
int err = EMAIL_ERROR_NONE;
EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, err);
- if (thread_item_count < 0)
- {
+ if (thread_item_count < 0) {
memset(sql_query_string, 0, QUERY_SIZE);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET thread_item_count = 0 WHERE account_id = %d AND thread_id = %d", account_id, thread_id);
EM_DEBUG_LOG_SEC("query[%s]", sql_query_string);
*output_task_list = task_item_from_tbl;
*output_task_count = count;
} else {
- for (i = 0; i < count; i++) {
- EM_SAFE_FREE(task_item_from_tbl[i].task_parameter);
+ if (task_item_from_tbl) {
+ for (i = 0; i < count; i++)
+ EM_SAFE_FREE(task_item_from_tbl[i].task_parameter);
+
+ free(task_item_from_tbl);
}
- EM_SAFE_FREE(task_item_from_tbl);
}
if (hStmt != NULL) {
INTERNAL_FUNC int emstorage_get_searched_mail_list(char *multi_user_name, int account_id, int mailbox_id, int thread_id, int search_type, const char *search_value, int start_index, int limit_count, email_sort_type_t sorting, int transaction, email_mail_list_item_t **mail_list, int *result_count, int *err_code);
-INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(char *multi_user_name, int mailbox_id, char *server_mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(char *multi_user_name,
+ char *server_mail_id,
+ int mailbox_id,
+ emstorage_mail_tbl_t **mail,
+ int transaction,
+ int *err_code);
INTERNAL_FUNC int emstorage_get_unread_mailid(char *multi_user_name, int account_id, int vip_mode, int **mail_ids, int *mail_number, int *err_code);
INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(char *multi_user_name, int mail_id, int *thread_id, int *err_code);
-INTERNAL_FUNC int emstorage_update_latest_thread_mail(char *multi_user_name, int account_id, int mailbox_id, int thread_id, int *updated_thread_id, int latest_mail_id, int thread_item_count, int noti_type, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_update_latest_thread_mail(char *multi_user_name,
+ int account_id,
+ int mailbox_id,
+ int mailbox_type,
+ int thread_id,
+ int *updated_thread_id,
+ int latest_mail_id,
+ int thread_item_count,
+ int noti_type,
+ int transaction,
+ int *err_code);
INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(char *multi_user_name, int account_id, int mailbox_id, char *mail_subject, int *thread_id, int *thread_item_count);
* @return This function returns true on success or false on failure.
*/
INTERNAL_FUNC int emcore_delete_all_mails_of_acount(char *multi_user_name, int input_account_id);
-INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(char *multi_user_name, int input_account_id, int input_mailbox_id, int input_from_server, int *err_code);
+INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(char *multi_user_name,
+ int input_account_id,
+ int input_mailbox_id,
+ int input_mailbox_type,
+ int input_from_server,
+ int *err_code);
INTERNAL_FUNC void emcore_free_mail_data_list(email_mail_data_t **mail_list, int count);
INTERNAL_FUNC void emcore_free_mail_data(email_mail_data_t *mail);
* @param[in] mailbox_id Specifies the id of mailbox
* @param[in] input_search_filter Specifies the filter list for searching field
* @param[in] input_search_filter_count Specifies the filter count
+ * @param[in] cancellable Specifies the cancellable
* @param[in] handle Specifies the handle for searching mails
* @remarks N/A
* @return EMAIL_ERROR_NONE on success or an error code (refer to EMAIL_ERROR_XXX) on failure
*/
-INTERNAL_FUNC int emcore_search_on_server(char *multi_user_name, int account_id, int mailbox_id, email_search_filter_t *input_search_filter, int input_search_filter_count, int handle_to_be_published);
+INTERNAL_FUNC int emcore_search_on_server(char *multi_user_name,
+ int account_id,
+ int mailbox_id,
+ email_search_filter_t *input_search_filter,
+ int input_search_filter_count,
+ int cancellable,
+ int event_handle);
#ifdef __cplusplus
}
#endif /* __cplusplus */
int *output_inline_attachment_count);
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
-INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, email_event_partial_body_thd *pbd_event, int count, int *error);
+INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream,
+ email_event_partial_body_thd *pbd_event,
+ int count,
+ int *error);
+
+INTERNAL_FUNC int emcore_initiate_pbd(char *multi_user_name, MAILSTREAM *stream,
+ int account_id, int mail_id, char *uid,
+ int input_mailbox_id, char *input_mailbox_name,
+ int *err_code);
#endif /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ */
email_event_t *event_data = NULL;
event_data = em_malloc(sizeof(email_event_t));
-
- if(!event_data) { /*prevent 53094*/
+ if (!event_data) { /*prevent 53094*/
EM_DEBUG_EXCEPTION("em_malloc failed");
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
case EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT: {
email_account_t *account = (email_account_t *)event_data->event_param_data_1;
- event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(event_data->multi_user_name, event_data->account_id, account, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(event_data->multi_user_name,
+ event_data->account_id,
+ account,
+ handle_to_be_published,
+ &err);
}
break;
}
}
- if ((event_data->type == EMAIL_EVENT_SYNC_HEADER || event_data->type == EMAIL_EVENT_SYNC_IMAP_MAILBOX) && (err != EMAIL_ERROR_NONE)) {
+ if ((event_data->type == EMAIL_EVENT_SYNC_HEADER || event_data->type == EMAIL_EVENT_SYNC_IMAP_MAILBOX) &&
+ (err != EMAIL_ERROR_NONE)) {
EM_DEBUG_LOG("retry syncing");
+ if (event_data->type == EMAIL_EVENT_SYNC_IMAP_MAILBOX && err == EMAIL_ERROR_INVALID_ACCOUNT) {
+ EM_DEBUG_LOG("Unsupported account");
+ goto FINISH_OFF;
+ }
+
/* for the retry syncing */
if (sync_failed_event_data) {
emcore_free_event(sync_failed_event_data);
EM_SAFE_FREE(sync_failed_event_data);
- sync_failed_event_data = NULL;
}
sync_failed_event_data = em_malloc(sizeof(email_event_t));
if (sync_failed_event_data == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
}
if (event_data->type == EMAIL_EVENT_SYNC_IMAP_MAILBOX && sync_failed_event_data) {
sync_failed_event_data->account_id = event_data->account_id;
sync_failed_event_data->status = EMAIL_EVENT_STATUS_WAIT;
sync_failed_event_data->event_param_data_3 = EM_SAFE_STRDUP(event_data->event_param_data_3);
+ sync_failed_event_data->multi_user_name = EM_SAFE_STRDUP(event_data->multi_user_name);
}
if (event_data->type == EMAIL_EVENT_SYNC_HEADER && sync_failed_event_data) {
sync_failed_event_data->status = EMAIL_EVENT_STATUS_WAIT;
sync_failed_event_data->event_param_data_5 = event_data->event_param_data_5;
sync_failed_event_data->event_param_data_4 = event_data->event_param_data_4;
+ sync_failed_event_data->multi_user_name = EM_SAFE_STRDUP(event_data->multi_user_name);
}
}
-
- /* free internals in event */
- emcore_free_event(event_data); /*detected by valgrind*/
+FINISH_OFF:
+ if (!emcore_notify_response_to_api(event_data->type, handle_to_be_published, err))
+ EM_DEBUG_EXCEPTION("emcore_notify_response_to_api failed");
if (account_tbl) {
emstorage_free_account(&account_tbl, 1, NULL);
account_tbl = NULL;
}
- if (!emcore_notify_response_to_api(event_data->type, handle_to_be_published, err))
- EM_DEBUG_EXCEPTION("emcore_notify_response_to_api failed");
-
/* free event itself */
ENTER_RECURSIVE_CRITICAL_SECTION(_event_queue_lock);
started_event = g_queue_pop_head(g_event_que);
EM_DEBUG_EXCEPTION("Failed to g_queue_pop_head");
}
else {
+ /* freed event_data : event_data is started event */
emcore_return_handle(started_event->handle);
+ emcore_free_event(started_event); /*detected by valgrind*/
EM_SAFE_FREE(started_event);
}
}
EM_DEBUG_FUNC_BEGIN("input_account_id [%d] input_mailbox_id [%d], input_from_server [%d], error [%p]", input_account_id, input_mailbox_id, input_from_server, error);
int err = EMAIL_ERROR_NONE;
- if (!emcore_delete_all_mails_of_mailbox(multi_user_name, input_account_id, input_mailbox_id, input_from_server, &err))
+ if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
+ input_account_id,
+ input_mailbox_id,
+ 0,
+ input_from_server,
+ &err))
EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err);
if (error)
return true;
}
-static int event_handler_EMAIL_EVENT_SEARCH_ON_SERVER(char *multi_user_name, int account_id, int mailbox_id, email_search_filter_t *input_search_filter, int input_search_filter_count, int handle_to_be_published)
+static int event_handler_EMAIL_EVENT_SEARCH_ON_SERVER(char *multi_user_name, int account_id, int mailbox_id,
+ email_search_filter_t *input_search_filter,
+ int input_search_filter_count, int handle_to_be_published)
{
- EM_DEBUG_FUNC_BEGIN("account_id : [%d], mailbox_id : [%d], input_search_filter : [%p], input_search_filter_count : [%d], handle_to_be_published [%d]", account_id, mailbox_id, input_search_filter, input_search_filter_count, handle_to_be_published);
+ EM_DEBUG_FUNC_BEGIN("account_id : [%d], mailbox_id : [%d], input_search_filter : [%p], "
+ "input_search_filter_count : [%d], handle_to_be_published [%d]",
+ account_id, mailbox_id, input_search_filter,
+ input_search_filter_count, handle_to_be_published);
+
int err = EMAIL_ERROR_NONE;
-
- if (err == EMAIL_ERROR_NONE) {
- if ((err = emcore_search_on_server(multi_user_name, account_id, mailbox_id, input_search_filter, input_search_filter_count, handle_to_be_published)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_search_on_server failed [%d]", err);
- }
+ char mailbox_id_param_string[10] = {0,};
+ emstorage_mailbox_tbl_t *local_mailbox = NULL;
+
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name,
+ mailbox_id,
+ &local_mailbox)) != EMAIL_ERROR_NONE || !local_mailbox) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
+ goto FINISH_OFF;
}
+ SNPRINTF(mailbox_id_param_string, 10, "%d", local_mailbox->mailbox_id);
+
+ if (!emnetwork_check_network_status(&err)) {
+ EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
+ if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, 0, err))
+ EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_FAIL] Failed");
+ goto FINISH_OFF;
+ }
+
+ if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_START,
+ account_id,
+ mailbox_id_param_string,
+ handle_to_be_published,
+ 0))
+ EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEARCH_ON_SERVER_START] failed >>>>");
+
+ if ((err = emcore_search_on_server(multi_user_name,
+ account_id,
+ mailbox_id,
+ input_search_filter,
+ input_search_filter_count,
+ true,
+ handle_to_be_published)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_search_on_server failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+
+ if (err != EMAIL_ERROR_NONE) {
+ if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL,
+ account_id,
+ mailbox_id_param_string,
+ handle_to_be_published,
+ 0))
+ EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEARCH_ON_SERVER_FAILED] failed >>>>");
+ } else {
+ if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FINISH,
+ account_id,
+ NULL,
+ handle_to_be_published,
+ 0))
+ EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_SEARCH_ON_SERVER_FINISH] Failed >>>>>");
+ }
+
+ if (local_mailbox)
+ emstorage_free_mailbox(&local_mailbox, 1, NULL);
+
EM_DEBUG_FUNC_END();
return err;
}
#include "email-internal-types.h"
#include "email-daemon.h"
+#include "email-network.h"
#include "email-core-event.h"
#include "email-daemon-account.h"
#include "email-debug-log.h"
goto FINISH_OFF;
}
+ if (!emnetwork_check_network_status(&err)) {
+ EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
#ifdef __FEATURE_MOVE_TO_OUTBOX_FIRST__
if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &local_mailbox, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
+
dst_mailbox_id = local_mailbox->mailbox_id;
- if ( mail_table_data->mailbox_id != dst_mailbox_id ) {
+ if (mail_table_data->mailbox_id != dst_mailbox_id) {
/* mail is moved to 'OUTBOX' first of all. */
if (!emcore_move_mail(multi_user_name, &mail_id, 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, &err)) {
EM_DEBUG_EXCEPTION("emcore_mail_move falied [%d]", err);
}
#endif /* __FEATURE_MOVE_TO_OUTBOX_FIRST__ */
- if(!emcore_notify_network_event(NOTI_SEND_START, account_id, NULL, mail_id, 0))
+ if (!emcore_notify_network_event(NOTI_SEND_START, account_id, NULL, mail_id, 0))
EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_SEND_START] Failed >>>> ");
/* set EMAIL_MAIL_STATUS_SEND_WAIT status */
return SUCCESS;
}
-INTERNAL_FUNC int emdaemon_delete_mail(char *multi_user_name, int mailbox_id, int mail_ids[], int mail_ids_count, int from_server, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_delete_mail(char *multi_user_name,
+ int account_id,
+ int mail_ids[],
+ int mail_ids_count,
+ int from_server,
+ int *handle,
+ int* err_code)
{
- EM_DEBUG_FUNC_BEGIN("mailbox_id[%d], mail_ids[%p], mail_ids_count[%d], from_server[%d], handle[%p], err_code[%p]", mailbox_id, mail_ids, mail_ids_count, from_server, handle, err_code);
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_ids[%p], mail_ids_count[%d], from_server[%d], handle[%p], err_code[%p]",
+ account_id, mail_ids, mail_ids_count, from_server, handle, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
int thread_error = 0;
email_account_t *ref_account = NULL;
email_event_t *event_data = NULL;
- emstorage_mailbox_tbl_t *mailbox_tbl_data = NULL;
thread_t delete_thread;
/* mailbox can be NULL for deleting thread mail. */
goto FINISH_OFF;
}
- if ( (err = emstorage_get_mailbox_by_id(multi_user_name, mailbox_id, &mailbox_tbl_data)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%err]", err);
- goto FINISH_OFF;
- }
-
if ((p = em_malloc(sizeof(int) * mail_ids_count)) == NULL) {
EM_DEBUG_EXCEPTION("em_malloc for p failed...");
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(multi_user_name, mailbox_tbl_data->account_id, false);
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed.");
err = EMAIL_ERROR_INVALID_ACCOUNT;
}
event_data->type = EMAIL_EVENT_DELETE_MAIL;
- event_data->account_id = mailbox_tbl_data->account_id;
+ event_data->account_id = account_id;
event_data->event_param_data_3 = (char*)p;
event_data->event_param_data_4 = mail_ids_count;
event_data->event_param_data_5 = from_server;
FINISH_OFF:
- if (mailbox_tbl_data)
- emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL);
-
if (ref_account) {
emcore_free_account(ref_account);
EM_SAFE_FREE(ref_account);
goto FINISH_OFF;
}
- if(!emcore_delete_all_mails_of_mailbox(multi_user_name, mailbox_tbl->account_id, input_mailbox_id, EMAIL_DELETE_LOCALLY, &err)) {
+ if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
+ mailbox_tbl->account_id,
+ input_mailbox_id,
+ 0,
+ EMAIL_DELETE_LOCALLY,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err);
goto FINISH_OFF;
}
return ret;
}
-INTERNAL_FUNC int emdaemon_set_flags_field(char *multi_user_name, int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int onserver, int* err_code)
+INTERNAL_FUNC int emdaemon_set_flags_field(char *multi_user_name, int account_id, int mail_ids[],
+ int num, email_flags_field_type field_type, int value,
+ int onserver, int* err_code)
{
- EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num[%d], field_type [%d], value[%d], err_code[%p]", mail_ids, num, field_type, value, err_code); /*prevent 27460*/
+ EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num[%d], field_type [%d], value[%d], err_code[%p]",
+ mail_ids, num, field_type, value, err_code); /*prevent 27460*/
int ret = false, err = EMAIL_ERROR_NONE;
emstorage_account_tbl_t *account_tbl = NULL;
goto FINISH_OFF;
}
- if (!emstorage_get_account_by_id(multi_user_name, account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_tbl, false, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name,
+ account_id,
+ EMAIL_ACC_GET_OPT_DEFAULT,
+ &account_tbl,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id falled [%d]", err);
goto FINISH_OFF;
}
goto FINISH_OFF;
}
- if( onserver && account_tbl->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 ) {
+ if (onserver && account_tbl->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
mail_id_array = em_malloc(sizeof(int) * num);
-
if (mail_id_array == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed...");
err = EMAIL_ERROR_OUT_OF_MEMORY;
if (err_code)
*err_code = err;
+
EM_DEBUG_FUNC_END();
return ret;
}
-
-INTERNAL_FUNC int emdaemon_update_mail(char *multi_user_name, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas)
+INTERNAL_FUNC int emdaemon_update_mail(char *multi_user_name, email_mail_data_t *input_mail_data,
+ email_attachment_data_t *input_attachment_data_list, int input_attachment_count,
+ email_meeting_request_t *input_meeting_request, int input_from_eas)
{
- EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count [%d], input_meeting_req [%p], input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
+ EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], "
+ "input_attachment_count [%d], input_meeting_req [%p], "
+ "input_from_eas[%d]", input_mail_data, input_attachment_data_list,
+ input_attachment_count, input_meeting_request, input_from_eas);
+
int err = EMAIL_ERROR_NONE;
/*email_event_t *event_data = NULL;*/
email_account_t *ref_account = NULL;
int ret = false;
int err = EMAIL_ERROR_NONE;
int account_id = 0;
- int mailbox_id, *mail_id_list = NULL, result_count = 0, i;
+ int *mail_id_list = NULL, result_count = 0, i;
email_mail_list_item_t *mail_list = NULL;
- if (!emstorage_get_mail_list(multi_user_name, 0, 0, NULL, thread_id, -1, -1, 0, NULL, EMAIL_SORT_MAILBOX_ID_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) {
+ if (!emstorage_get_mail_list(multi_user_name,
+ 0,
+ 0,
+ NULL,
+ thread_id,
+ -1,
+ -1,
+ 0,
+ NULL,
+ EMAIL_SORT_MAILBOX_ID_HIGH,
+ true,
+ &mail_list,
+ &result_count,
+ &err) || !mail_list || !result_count) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err);
goto FINISH_OFF;
}
mail_id_list = em_malloc(sizeof(int) * result_count);
-
if (mail_id_list == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed...");
err = EMAIL_ERROR_OUT_OF_MEMORY;
}
account_id = mail_list[0].account_id;
- mailbox_id = mail_list[0].mailbox_id;
// should remove requiring of mailbox information from this function.
// email-service should find mailboxes itself by its mail id.
- if (!emdaemon_delete_mail(multi_user_name, mailbox_id, mail_id_list, result_count, false, handle, &err)) {
+ if (!emdaemon_delete_mail(multi_user_name, account_id, mail_id_list, result_count, false, handle, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_delete_mail failed [%d]", err);
goto FINISH_OFF;
}
extern int g_local_activity_run;
#endif
-INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(char *multi_user_name, int account_id, char* mailbox, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(char *multi_user_name,
+ int account_id,
+ char* mailbox,
+ int *handle,
+ int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d] mailbox[%p] err_code[%p]", account_id, mailbox, err_code);
event_data->event_param_data_3 = EM_SAFE_STRDUP(mailbox);
event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
- if (!emcore_insert_event(event_data, (int*)handle, &err)) {
+ if (!emcore_insert_event(event_data, handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
goto FINISH_OFF;
}
/**
* Delete a mail or multiple mails.
*
- * @param[in] mailbox_id Specifies the mailbox.
+ * @param[in] account_id Specifies the account.
* @param[in] mail_id Specifies the arrary of mail id.
* @param[in] num Specifies the number of mail id.
* @param[in] from_server Specifies whether mails are deleted from server.
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_mail(char *multi_user_name, int mailbox_id, int mail_id[], int num, int from_server, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_delete_mail(char *multi_user_name, int account_id, int mail_id[], int num, int from_server, int *handle, int* err_code);
/**
* Delete all mail from a mailbox.
int *mail_ids = NULL;
int nAPPID = emipc_get_app_id(a_hAPI);
char *multi_user_name = NULL;
+ emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 3, sizeof(int), &from_server);
EM_DEBUG_LOG("from_server [%d]", from_server);
- emdaemon_delete_mail(multi_user_name, mailbox_id, mail_ids, num, from_server, NULL, &err);
+ err = emstorage_get_mailbox_by_id(multi_user_name, mailbox_id, &mailbox_tbl);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ emdaemon_delete_mail(multi_user_name, mailbox_tbl->account_id, mail_ids, num, from_server, NULL, &err);
FINISH_OFF:
+
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
- EM_SAFE_FREE(mail_ids);
+ if (mailbox_tbl)
+ emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+ EM_SAFE_FREE(mail_ids);
EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_FUNC_END();
}
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
- /*need to check: why err value is changed? */
+ /* need to check: why err value is changed? */
if(emdaemon_get_imap_mailbox_list(multi_user_name, account_id, "", &handle, &err))
err = EMAIL_ERROR_NONE;
}
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, stream_for_search_filter_list);
- em_convert_byte_stream_to_search_filter(stream_for_search_filter_list, &search_filter_list, &search_filter_count);
+ em_convert_byte_stream_to_search_filter(stream_for_search_filter_list,
+ &search_filter_list,
+ &search_filter_count);
EM_SAFE_FREE(stream_for_search_filter_list);
}
- if(!emdaemon_search_mail_on_server(multi_user_name, account_id ,mailbox_id, search_filter_list, search_filter_count, &job_handle, &err))
+ if (!emdaemon_search_mail_on_server(multi_user_name, account_id ,mailbox_id,
+ search_filter_list,
+ search_filter_count,
+ &job_handle,
+ &err))
EM_DEBUG_LOG("success");
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &job_handle, sizeof(int)))
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &job_handle, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
if (!emipc_execute_stub_api(a_hAPI))
void stb_clear_result_of_search_mail_on_server(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
- int err = EMAIL_ERROR_NONE;
- int account_id = 0;
- emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
+
+ int err = EMAIL_ERROR_NONE;
+ int account_id = 0;
+ int handle = 0;
+ int *mail_id_list = NULL;
+ int mail_id_count = 0;
int nAPPID = emipc_get_app_id(a_hAPI);
+
+ char conditional_clause[QUERY_SIZE] = {0, };
char *multi_user_name = NULL;
+ emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
EM_DEBUG_LOG("account_id [%d]", account_id);
- if (!emstorage_get_mailbox_by_name(multi_user_name, account_id, -1, EMAIL_SEARCH_RESULT_MAILBOX_NAME, &mailbox_tbl, false, &err)) {
- EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_by_name failed [%d]", err);
+ if (!emstorage_get_mailbox_by_name(multi_user_name,
+ account_id,
+ -1,
+ EMAIL_SEARCH_RESULT_MAILBOX_NAME,
+ &mailbox_tbl,
+ false,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_delete_mail_by_mailbox(multi_user_name, mailbox_tbl, true, &err))
- EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
+ /* Create the conditional_clause */
+ SNPRINTF(conditional_clause, QUERY_SIZE, " where mailbox_type = %d ", mailbox_tbl->mailbox_type);
-FINISH_OFF:
+ /* Get mail ids */
+ err = emstorage_query_mail_id_list(multi_user_name,
+ conditional_clause,
+ false,
+ &mail_id_list,
+ &mail_id_count);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_query_mail_id_list failed : [%d]", err);
+ if (err == EMAIL_ERROR_MAIL_NOT_FOUND) err = EMAIL_ERROR_NONE;
+ goto FINISH_OFF;
+ }
- if (mailbox_tbl) {
- emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+ /* Remove the searched mails */
+ if (!emdaemon_delete_mail(multi_user_name,
+ account_id,
+ mail_id_list,
+ mail_id_count,
+ EMAIL_DELETE_LOCALLY,
+ &handle,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emdaemon_delete_mail failed : [%d]", err);
+ goto FINISH_OFF;
}
+/*
+ if (!emstorage_delete_mail_by_mailbox(multi_user_name, mailbox_tbl, true, &err))
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
+*/
+FINISH_OFF:
if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+ if (mailbox_tbl)
+ emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+
+ EM_SAFE_FREE(mail_id_list);
EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_FUNC_END();
}
err = emcore_get_task_information(&task_information, &task_information_count);
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_LOG("emipc_add_parameter failed ");
/* email_task_information_t */
- if(task_information_count) {
+ if (task_information_count) {
task_information_stream = em_convert_task_information_to_byte_stream(task_information, task_information_count, &stream_length);
if((stream_length > 0) && !emipc_add_dynamic_parameter(a_hAPI, ePARAMETER_OUT, task_information_stream, stream_length)) {
goto FINISH_OFF;
}
- if (g_list_length(zone_name_list) == 1) {
+ if (g_list_length(zone_name_list) <= 1) {
if ((err = emcore_get_account_reference_list(NULL, &account_list, &account_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_LOG("emcore_get_account_reference_list failed [%d]", err);
}
EXPORT_API long emipc_get_api_id(HIPC_API api)
{
EM_DEBUG_FUNC_BEGIN();
- emipc_email_api_info *api_info = (emipc_email_api_info*)api;
+ emipc_email_api_info *api_info = (emipc_email_api_info *)api;
EM_DEBUG_FUNC_END("api_id [%d]", api_info->api_id);
return api_info->api_id;
}
{
EM_DEBUG_FUNC_BEGIN();
emipc_email_api_info *api_info = (emipc_email_api_info *)api;
+ EM_DEBUG_FUNC_END("app_id [%d]", api_info->app_id);
return api_info->app_id;
}
}
parameters = emipc_get_api_parameters(input_api_handle, input_parameter_direction);
-
if (parameters == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
return EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
}
local_buffer = emipc_get_param_of_param_list(parameters, input_parameter_index);
-
if (local_buffer == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
return EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
void *buf = NULL;
parameters = emipc_get_api_parameters(api_handle, direction);
-
if (parameters == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
return NULL;
}
buf = emipc_get_param_of_param_list(parameters, param_index);
-
if (!buf) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
return NULL;
EM_DEBUG_FUNC_BEGIN();
emipc_param_list *parameters = emipc_get_api_parameters(api, direction);
if (parameters) {
- EM_DEBUG_FUNC_END("Suceeded");
+ EM_DEBUG_LOG("Suceeded");
return emipc_get_param_len_of_param_list(parameters, parameter_index);
}
EM_DEBUG_FUNC_END("Failed");
EM_DEBUG_FUNC_BEGIN();
emipc_param_list *parameters = emipc_get_api_parameters(api, direction);
if (parameters) {
- EM_DEBUG_FUNC_END("Suceeded");
+ EM_DEBUG_LOG("Suceeded");
return emipc_get_param_len_of_param_list(parameters, parameter_index);
}
EM_DEBUG_FUNC_END("Failed");
{
EM_DEBUG_FUNC_BEGIN("index [%d]", index);
if (index < 0 || index >= param_list->param_count) {
- EM_DEBUG_EXCEPTION("Index value is not valid");
+// EM_DEBUG_EXCEPTION("Index value is not valid");
return NULL;
}
return emipc_get_data(param_list->params[index]);
{
EM_DEBUG_FUNC_BEGIN();
if (index < 0 || index >= param_list->param_count) {
- EM_DEBUG_EXCEPTION("Index valud is not valid");
+// EM_DEBUG_EXCEPTION("Index value is not valid");
return 0;
}
return emipc_get_length(param_list->params[index]);
email_search_filter_t search_filter[10];
int handle = 0;
time_t current_time = 0;
- char search_key_value_string[MAX_EMAIL_ADDRESS_LENGTH];
+ char search_key_value_string[256];
testapp_print("input account id : ");
if (0 >= scanf("%d",&account_id))
testapp_print(
" EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO = 1, ( integer type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_UID = 2, ( integer type ) \n"
- " EMAIL_SEARCH_FILTER_TYPE_ALL = 3, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_ALL = 3, ( integer type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_BCC = 7, ( string type ) \n"
- " EMAIL_SEARCH_FILTER_TYPE_BODY = 8, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_BODY = 8, ( string type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_CC = 9, ( string type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_FROM = 10, ( string type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_KEYWORD = 11, ( string type ) \n"
- " EMAIL_SEARCH_FILTER_TYPE_TEXT = 12, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_TEXT = 12, ( string type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_SUBJECT = 13, ( string type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_TO = 15, ( string type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER = 16, ( integet type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON = 21, ( time type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE = 22, ( time type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED = 26, ( integer type ) \n"
- " EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW = 27, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW = 27, ( integer type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED = 28, ( integer type ) \n"
- " EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD = 29, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD = 29, ( integer type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT = 30, ( integer type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED = 32, ( integer type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT = 34, ( integer type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN = 36, ( integer type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, ( string type ) \n"
- " EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY = 50, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY = 50, ( integer type ) \n"
" EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME = 60, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_CHARSET = 61, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED = 62, ( string type ) \n"
" END = 0 \n");
testapp_print("input search filter type : ");
case EMAIL_SEARCH_FILTER_TYPE_TO :
case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET :
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED :
testapp_print("input search filter key value : ");
- if (0 >= scanf("%s", search_key_value_string))
+ int readn = read(0, search_key_value_string, 256);
+ if (readn < 0)
testapp_print("Invalid input. ");
- search_filter[search_filter_count].search_filter_key_value.string_type_key_value = strdup(search_key_value_string);
+
+ search_filter[search_filter_count].search_filter_key_value.string_type_key_value = strndup(search_key_value_string, readn - 1);
break;
case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :