}
-EXPORT_API int email_validate_account(int account_id, unsigned* handle)
+EXPORT_API int email_validate_account(int account_id, int *handle)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p]", account_id, handle);
}
-EXPORT_API int email_add_account_with_validation(email_account_t* account, unsigned* handle)
+EXPORT_API int email_add_account_with_validation(email_account_t* account, int *handle)
{
EM_DEBUG_FUNC_BEGIN("account[%p]", account);
char* local_account_stream = NULL;
#include "email-ipc.h"
#include "email-debug-log.h"
#include "email-core-utils.h"
+#include "email-core-smtp.h"
#include "email-core-mime.h"
+#include "email-convert.h"
+#include "email-utilities.h"
EXPORT_API int email_show_user_message(int id, email_action_t action, int error_code)
{
return err;
}
-EXPORT_API int email_open_eml_file(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
+EXPORT_API int email_parse_mime_file(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
{
EM_DEBUG_FUNC_BEGIN("eml_file_path : [%s], output_mail_data : [%p], output_attachment_data : [%p]", eml_file_path, output_mail_data, output_attachment_data);
int err = EMAIL_ERROR_NONE;
EM_IF_NULL_RETURN_VALUE(eml_file_path, EMAIL_ERROR_INVALID_PARAM);
- if (!emcore_load_eml_file_to_mail(eml_file_path, output_mail_data, output_attachment_data, output_attachment_count, &err) || !*output_mail_data)
- EM_DEBUG_EXCEPTION("emcore_load_eml_file_to_mail_data failed [%d]", err);
+ if (!emcore_parse_mime_file_to_mail(eml_file_path, output_mail_data, output_attachment_data, output_attachment_count, &err) || !*output_mail_data)
+ EM_DEBUG_EXCEPTION("emcore_parse_mime_file_to_mail failed [%d]", err);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
-EXPORT_API int email_delete_eml_data(email_mail_data_t *input_mail_data)
+EXPORT_API int email_write_mime_file(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data, int input_attachment_count, char **output_file_path)
+{
+ EM_DEBUG_FUNC_BEGIN("input_mail_data : [%p], input_attachment_data : [%p], input_attachment_count : [%d]", input_mail_data, input_attachment_data, input_attachment_count);
+
+ int err = EMAIL_ERROR_NONE;
+ int size = 0;
+ char *p_output_file_path = NULL;
+ char *mail_data_stream = NULL;
+ char *attachment_data_list_stream = NULL;
+ HIPC_API hAPI = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(input_mail_data, EMAIL_ERROR_INVALID_PARAM);
+
+ hAPI = emipc_create_email_api(_EMAIL_API_WRITE_MIME_FILE);
+ if (!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMAIL_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, &size);
+ if (!mail_data_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed");
+ err = EMAIL_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_dynamic_parameter failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ attachment_data_list_stream = em_convert_attachment_data_to_byte_stream(input_attachment_data, input_attachment_count, &size);
+ if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_dynamic_parameter failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ if (*output_file_path && (size = strlen(*output_file_path)) > 0) {
+ EM_DEBUG_LOG("output_file_path : [%s] size : [%d]", *output_file_path, size);
+ size = size + 1;
+ } else {
+ size = 0;
+ }
+
+ if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, *output_file_path, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_dynamic_parameter failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ size = emipc_get_parameter_length(hAPI, ePARAMETER_OUT, 0);
+ if (size > 0) {
+ p_output_file_path = (char *)em_malloc(size);
+ if (p_output_file_path == NULL) {
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ if ((err = emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, size, p_output_file_path)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_parameter failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ }
+
+ *output_file_path = p_output_file_path;
+
+FINISH_OFF:
+
+ if (err != EMAIL_ERROR_NONE)
+ EM_SAFE_FREE(p_output_file_path);
+
+ EM_DEBUG_FUNC_END("err : [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_delete_parsed_data(email_mail_data_t *input_mail_data)
{
EM_DEBUG_FUNC_BEGIN("mail_data : [%p]", input_mail_data);
int err = EMAIL_ERROR_NONE;
EM_IF_NULL_RETURN_VALUE(input_mail_data, EMAIL_ERROR_INVALID_PARAM);
- if (!emcore_delete_eml_data(input_mail_data, &err))
- EM_DEBUG_EXCEPTION("emcore_load_eml_file_to_mail_data failed [%d]", err);
+ if (!emcore_delete_parsed_data(input_mail_data, &err))
+ EM_DEBUG_EXCEPTION("emcore_delete_parsed_data failed [%d]", err);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
/* email_mail_data_t */
- mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, 1, &size);
+ mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, &size);
if(!mail_data_stream) {
EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed");
}
/* email_mail_data_t */
- mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, 1, &size);
+ mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, &size);
if(!mail_data_stream) {
EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed");
goto FINISH_OFF;
}
- EM_SAFE_STRNCPY(temp_thread_info->from , mail_table_data->full_address_from, STRING_LENGTH_FOR_DISPLAY);
- EM_SAFE_STRNCPY(temp_thread_info->from_email_address , mail_table_data->email_address_sender, MAX_EMAIL_ADDRESS_LENGTH);
- EM_SAFE_STRNCPY(temp_thread_info->recipients , mail_table_data->email_address_recipient, STRING_LENGTH_FOR_DISPLAY);
- EM_SAFE_STRNCPY(temp_thread_info->subject , mail_table_data->subject, STRING_LENGTH_FOR_DISPLAY);
- EM_SAFE_STRNCPY(temp_thread_info->previewBodyText , mail_table_data->preview_text, MAX_PREVIEW_TEXT_LENGTH);
- temp_thread_info->mail_id = mail_table_data->mail_id;
- temp_thread_info->mailbox_id = mail_table_data->mailbox_id;
- temp_thread_info->account_id = mail_table_data->account_id;
- temp_thread_info->date_time = mail_table_data->date_time;
- temp_thread_info->is_text_downloaded = mail_table_data->body_download_status;
- temp_thread_info->flags_seen_field = mail_table_data->flags_seen_field;
- temp_thread_info->priority = mail_table_data->priority;
- temp_thread_info->save_status = mail_table_data->save_status;
- temp_thread_info->is_locked = mail_table_data->lock_status;
- temp_thread_info->is_report_mail = mail_table_data->report_status;
- temp_thread_info->has_attachment = mail_table_data->attachment_count;
- temp_thread_info->has_drm_attachment = mail_table_data->DRM_status;
- temp_thread_info->thread_id = mail_table_data->thread_id;
- temp_thread_info->thread_item_count = mail_table_data->thread_item_count;
- temp_thread_info->is_meeting_request = mail_table_data->meeting_request_status;
+ EM_SAFE_STRNCPY(temp_thread_info->full_address_from , mail_table_data->full_address_from, STRING_LENGTH_FOR_DISPLAY);
+ EM_SAFE_STRNCPY(temp_thread_info->email_address_sender , mail_table_data->email_address_sender, MAX_EMAIL_ADDRESS_LENGTH);
+ EM_SAFE_STRNCPY(temp_thread_info->email_address_recipient , mail_table_data->email_address_recipient, STRING_LENGTH_FOR_DISPLAY);
+ EM_SAFE_STRNCPY(temp_thread_info->subject , mail_table_data->subject, STRING_LENGTH_FOR_DISPLAY);
+ EM_SAFE_STRNCPY(temp_thread_info->preview_text , mail_table_data->preview_text, MAX_PREVIEW_TEXT_LENGTH);
+ temp_thread_info->mail_id = mail_table_data->mail_id;
+ temp_thread_info->mailbox_id = mail_table_data->mailbox_id;
+ temp_thread_info->account_id = mail_table_data->account_id;
+ temp_thread_info->date_time = mail_table_data->date_time;
+ temp_thread_info->body_download_status = mail_table_data->body_download_status;
+ temp_thread_info->flags_seen_field = mail_table_data->flags_seen_field;
+ temp_thread_info->priority = mail_table_data->priority;
+ temp_thread_info->save_status = mail_table_data->save_status;
+ temp_thread_info->lock_status = mail_table_data->lock_status;
+ temp_thread_info->report_status = mail_table_data->report_status;
+ temp_thread_info->attachment_count = mail_table_data->attachment_count;
+ temp_thread_info->DRM_status = mail_table_data->DRM_status;
+ temp_thread_info->thread_id = mail_table_data->thread_id;
+ temp_thread_info->thread_item_count = mail_table_data->thread_item_count;
+ temp_thread_info->meeting_request_status = mail_table_data->meeting_request_status;
*thread_info = temp_thread_info;
EXPORT_API int email_get_structure(const char*encoded_string, void **struct_var, email_convert_struct_type_e type)
{
EM_DEBUG_FUNC_BEGIN("encoded_string[%s], struct_var[%p], type[%d]", encoded_string, struct_var, type);
-
- int err = EMAIL_ERROR_NONE;
- void * temp_struct = NULL;
-
- EM_IF_NULL_RETURN_VALUE(encoded_string, EMAIL_ERROR_INVALID_PARAM);
- EM_IF_NULL_RETURN_VALUE(struct_var, EMAIL_ERROR_INVALID_PARAM);
-
- if ( (err = emcore_convert_string_to_structure((char*)encoded_string, &temp_struct, type)) != EMAIL_ERROR_NONE ) {
- EM_DEBUG_EXCEPTION("emcore_convert_string_to_structure failed[%d]", err);
- goto FINISH_OFF;
- }
-
- if ( struct_var )
- *struct_var = temp_struct;
-
-FINISH_OFF:
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
+ EM_DEBUG_FUNC_END("err [%d]", EMAIL_ERROR_NOT_IMPLEMENTED);
+ return EMAIL_ERROR_NOT_IMPLEMENTED;
}
EXPORT_API int email_get_meeting_request(int mail_id, email_meeting_request_t **meeting_req)
return err;
}
-EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, unsigned *output_handle)
+EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, int *output_handle)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], input_on_server[%d], output_handle[%p]", input_mailbox_id, input_on_server, output_handle);
int err = EMAIL_ERROR_NONE;
/* API - Create a mailbox */
-EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle)
+EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle)
{
EM_DEBUG_FUNC_BEGIN();
}
FINISH_OFF:
+ EM_SAFE_FREE(local_mailbox_stream);
+
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
-EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias, int input_on_server, unsigned *output_handle)
+EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias, int input_on_server, int *output_handle)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_mailbox_name [%p], input_mailbox_alias [%p], input_on_server [%d], output_handle [%p]", input_mailbox_id, input_mailbox_name, input_mailbox_alias, input_on_server, output_handle);
/* API - Delete a mailbox */
-EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle)
+EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, int *output_handle)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_on_server, output_handle);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
+}
+
+EXPORT_API int email_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox)
+{
+ EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_is_local_mailbox [%d]", input_mailbox_id, input_is_local_mailbox);
+ int err = EMAIL_ERROR_NONE;
+
+ EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_LOCAL_MAILBOX);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
+ }
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_is_local_mailbox, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
+ }
+ 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);
+ }
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ EM_DEBUG_LOG("error VALUE [%d]", err);
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
}
EXPORT_API int email_get_sync_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count)
EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM) ;
- if(mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS)
+ if(mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_USER_DEFINED)
return EMAIL_ERROR_INVALID_PARAM;
if (!emstorage_get_mailbox_by_mailbox_type(account_id, mailbox_type, &local_mailbox, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
-EXPORT_API int email_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle)
+EXPORT_API int email_send_mail(int mail_id, int *handle)
{
- EM_DEBUG_FUNC_BEGIN("mail_id[%d], sending_option[%p], handle[%p]", mail_id, sending_option, handle);
+ EM_DEBUG_FUNC_BEGIN("mail_id[%d], handle[%p]", mail_id, handle);
char* pSendingOption = NULL;
- int size = 0;
int err = EMAIL_ERROR_NONE;
emstorage_mail_tbl_t* mail_table_data = NULL;
+ email_account_server_t account_server_type;
+ HIPC_API hAPI = NULL;
+ ASNotiData as_noti_data;
if(mail_id <= 0) {
EM_DEBUG_EXCEPTION("mail_id is not valid");
EM_DEBUG_LOG("mail_table_data->account_id[%d], mail_table_data->mailbox_name[%s]", mail_table_data->account_id, mail_table_data->mailbox_name);
- email_account_server_t account_server_type;
- HIPC_API hAPI = NULL;
- ASNotiData as_noti_data;
memset(&as_noti_data, 0x00, sizeof(ASNotiData));
/* check account bind type and branch off */
}
/* noti to active sync */
- as_noti_data.send_mail.handle = as_handle;
+ as_noti_data.send_mail.handle = as_handle;
as_noti_data.send_mail.account_id = mail_table_data->account_id;
- as_noti_data.send_mail.mail_id = mail_id;
-
- memcpy(&as_noti_data.send_mail.options, sending_option, sizeof(email_option_t));
+ as_noti_data.send_mail.mail_id = mail_id;
if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- /* sending options */
- pSendingOption = em_convert_option_to_byte_stream(sending_option, &size);
-
- if ( NULL == pSendingOption) {
- EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
- }
-
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pSendingOption, size)){
- EM_DEBUG_EXCEPTION("email_send_mail--Add Param Sending_Option failed ");
- EM_SAFE_FREE(pSendingOption);
- EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
- }
-
if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("email_send_mail--emipc_execute_proxy_api failed ");
EM_SAFE_FREE(pSendingOption);
return err;
}
-EXPORT_API int email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle)
+EXPORT_API int email_send_saved(int account_id, int *handle)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], sending_option[%p], handle[%p]", account_id, sending_option, handle);
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p]", account_id, handle);
char* pOptionStream = NULL;
int err = EMAIL_ERROR_NONE;
- int size = 0;
EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM);
- EM_IF_NULL_RETURN_VALUE(sending_option, EMAIL_ERROR_INVALID_PARAM);
EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM);
HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SEND_SAVED);
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- /* Sending Option */
- pOptionStream = em_convert_option_to_byte_stream(sending_option, &size);
-
- EM_PROXY_IF_NULL_RETURN_VALUE(pOptionStream, hAPI, EMAIL_ERROR_NULL_VALUE);
-
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pOptionStream, size)) {
- EM_DEBUG_EXCEPTION("Add Param sending option failed");
- EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
- }
-
/* Execute API */
if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
return err;
}
-EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle)
+EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, int *handle)
{
EM_DEBUG_FUNC_BEGIN("input_account_id[%d], input_mailbox_id[%d] handle[%p]", input_account_id, input_mailbox_id, handle);
int err = EMAIL_ERROR_NONE;
}
-EXPORT_API int email_sync_header_for_all_account(unsigned* handle)
+EXPORT_API int email_sync_header_for_all_account(int *handle)
{
EM_DEBUG_FUNC_BEGIN("handle[%p]", handle);
char* mailbox_stream = NULL;
return err;
}
-EXPORT_API int email_download_body(int mail_id, int with_attachment, unsigned* handle)
+EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d],with_attachment[%d]", mail_id, with_attachment);
int err = EMAIL_ERROR_NONE;
/* API - Downloads the Email Attachment Information [ INTERNAL ] */
-EXPORT_API int email_download_attachment(int mail_id, int nth, unsigned* handle)
+EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], nth[%d], handle[%p]", mail_id, nth, handle);
char* mailbox_stream = NULL;
return err;
}
-EXPORT_API int email_sync_imap_mailbox_list(int account_id, unsigned* handle)
+EXPORT_API int email_sync_imap_mailbox_list(int account_id, int *handle)
{
EM_DEBUG_FUNC_BEGIN();
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, unsigned *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_FUNC_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);
EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
{
- EM_DEBUG_FUNC_BEGIN("mail_id : [%s]", mail_id);
+ EM_DEBUG_FUNC_BEGIN("mail_id : [%d]", mail_id);
int err = EMAIL_ERROR_NONE;
email_mail_data_t *p_output_mail_data = NULL;
emstorage_account_tbl_t *p_account = NULL;
return err;
}
-EXPORT_API int email_verify_signature(char *certificate_path, int mail_id, int *verify)
+EXPORT_API int email_verify_signature(int mail_id, int *verify)
{
- EM_DEBUG_FUNC_BEGIN("Certificate path : [%s]", certificate_path);
+ EM_DEBUG_FUNC_BEGIN("mail_id : [%d]", mail_id);
int result_from_ipc = 0;
int err = EMAIL_ERROR_NONE;
int p_verify = 0;
-
- if (!certificate_path) {
- EM_DEBUG_EXCEPTION("Invalid parameter");
- return EMAIL_ERROR_INVALID_PARAM;
- }
+
+ EM_IF_NULL_RETURN_VALUE(mail_id, EMAIL_ERROR_INVALID_PARAM);
HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_VERIFY_SIGNATURE);
if (hAPI == NULL) {
goto FINISH_OFF;
}
- if (!emipc_add_parameter(hAPI, ePARAMETER_IN, certificate_path, strlen(certificate_path)+1)) {
- EM_DEBUG_EXCEPTION("emipc_add_parameter certificate_path[%s] failed", certificate_path);
- err = EMAIL_ERROR_NULL_VALUE;
- goto FINISH_OFF;
- }
-
if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &mail_id, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter pass_phrase[%d] failed", mail_id);
err = EMAIL_ERROR_NULL_VALUE;
/**
* @open
- * @fn email_validate_account(int account_id, unsigned* handle)
+ * @fn email_validate_account(int account_id, int *handle)
* @brief Validate account.This function is getting invoked after adding one account to validate it.If account is not validated then user should retry once again to add the account .
*
* @param[in] account_id Specifies the account Id to validate.
* @see none
* @remarks N/A
*/
-EXPORT_API int email_validate_account(int account_id, unsigned* handle);
+EXPORT_API int email_validate_account(int account_id, int *handle);
/**
* @open
- * @fn email_add_account_with_validation(email_account_t* account, unsigned* handle)
+ * @fn email_add_account_with_validation(email_account_t* account, int *handle)
* @brief Add an account when the account is validated. This function is getting invoked when user want to validate an account. If account is not validated then user should retry once again to add the account.<br>
* Validation is executed without saving an account to DB
*
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-EXPORT_API int email_add_account_with_validation(email_account_t* account, unsigned* handle);
+EXPORT_API int email_add_account_with_validation(email_account_t* account, int *handle);
/**
*/
EXPORT_API int email_show_user_message(int id, email_action_t action, int error_code);
-EXPORT_API int email_open_eml_file(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count);
+EXPORT_API int email_parse_mime_file(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count);
-EXPORT_API int email_delete_eml_data(email_mail_data_t *input_mail_data);
+EXPORT_API int email_write_mime_file(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data, int input_attachment_count, char **output_file_path);
+
+EXPORT_API int email_delete_parsed_data(email_mail_data_t *input_mail_data);
EXPORT_API int email_get_mime_entity(char *mime_path, char **mime_entity);
#ifdef __cplusplus
* @open
* @fn email_init_storage(void)
- * @brief Create all table for email. Exposed to External Application- core team.Creates all Email DB tables [ EXTERNAL]
+ * @brief Create all tables for email.
*
* @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure
* @exception none
/**
* @open
- * @fn email_add_read_receipt(int input_read_mail_id, unsigned *output_handle)
+ * @fn email_add_read_receipt(int input_read_mail_id, int *output_handle)
* @brief Add a read receipt mail. This function is invoked when user receives a mail with read report enable and wants to send a read report for the same.
*
* @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
EXPORT_API int email_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server);
-EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, unsigned *output_handle);
+EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, int *output_handle);
#ifdef __cplusplus
}
* email_mailbox_t *mailbox_list = NULL;
* int count = 0;
* int mailbox_type;
- * unsigned handle = 0;
+ * int handle = 0;
* char *pMaiboxName;
* char *pParentMailbox;
*
/**
* @open
- * @fn int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle)
+ * @fn int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle)
* @brief Create a new mailbox or mailbox.This function is invoked when user wants to create a new mailbox for the specified account.
* If On_server is true then it will create the mailbox on server as well as in local also.
*
* @see email_mailbox_t
* @remarks N/A
*/
-EXPORT_API int email_add_mailbox(email_mailbox_t *new_mailbox, int on_server, unsigned* handle);
+EXPORT_API int email_add_mailbox(email_mailbox_t *new_mailbox, int on_server, int *handle);
/**
* @fn int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias)
* @see email_mailbox_t, email_mailbox_type_e
* @remarks N/A
*/
-EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias, int input_on_server, unsigned *output_handle);
+EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias, int input_on_server, int *output_handle);
/**
* @open
- * @fn int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle)
+ * @fn int email_delete_mailbox(int input_mailbox_id, int input_on_server, int *output_handle)
* @brief Delete a mailbox or mailbox.This function deletes the existing mailbox for specified account based on the option on_server.
* If the on_server is true then it deletes mailbox from server as well as locally.
*
* @see email_mailbox_t
* @remarks N/A
*/
-EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle);
+EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, int *output_handle);
/**
* @fn int email_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type)
EXPORT_API int email_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type);
/**
+ * @fn int email_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox)
+ * @brief Change the attribute 'local' of email_mailbox_t. This function is invoked when user wants to change the attribute 'local'.
+ *
+ * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
+ * @param[in] input_mailbox_id Specifies the id of the mailbox.
+ * @param[in] input_is_local_mailbox Specifies the value of the attribute 'local' of email_mailbox_t.
+ * @exception see email-errors.h
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox);
+
+/**
* @open
* @fn email_get_mailbox_list(int account_id, int mailbox_sync_type, email_mailbox_t** mailbox_list, int* count)
*
* // Send a mail
* email_attachment_data_t attachment;
- * email_option_t option;
* int account_id = 1;
* int mailbox_id = 0;
* int attachment_id = 0;
*
* printf("Enter mail id\n");
* scanf("%d",&mail_id);
- * option.keep_local_copy = 1;
*
- * if(EMAIL_ERROR_NONE == email_send_mail(mail_id, &option, &handle))
+ * if(EMAIL_ERROR_NONE == email_send_mail(mail_id, &handle))
* //success
* else
* //failure
*
* // Download header of new emails from mail server
- * unsigned handle = 0;
+ * int handle = 0;
*
* mailbox.account_id = account_id;
* printf("Enter mailbox id\n");
/**
* @open
- * @fn email_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle)
+ * @fn email_send_mail(int mail_id, int *handle)
* @brief Send a mail.This function is invoked when user wants to send a composed mail.
*
* @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
* @param[in] mail_id Specifies the mail ID.
- * @param[in] sending_option Specifies the sending option.
* @param[out] handle Specifies the sending handle.
* @exception none
* @see email_mailbox_t and email_option_t
* @remarks N/A
*/
-EXPORT_API int email_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle);
+EXPORT_API int email_send_mail(int mail_id, int *handle);
/**
* @open
- * @fn email_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle)
+ * @fn email_sync_header(int input_account_id, int input_mailbox_id, int *handle)
* @brief Download header of new emails from mail server.This function is invoked when user wants to download only header of new mails.
*
* @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
* @see email_mailbox_t
* @remarks N/A
*/
-EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle);
+EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, int *handle);
/**
* @open
- * @fn email_sync_header_for_all_account(unsigned* handle)
+ * @fn email_sync_header_for_all_account(int *handle)
* @brief Download header of new emails from mail server for all emails.This function is invoked when user wants to download header of new mails for all accounts.
*
* @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
* @see none
* @remarks N/A
*/
-EXPORT_API int email_sync_header_for_all_account(unsigned* handle);
+EXPORT_API int email_sync_header_for_all_account(int *handle);
/**
* @open
- * @fn email_download_body(int mail_id, int with_attachment, unsigned* handle)
+ * @fn email_download_body(int mail_id, int with_attachment, int *handle)
* @brief Download email body from server.This function is invoked when user wants to download email body with/without attachment based on the option with_attachment
* from the server.
*
* @see email_mailbox_t
* @remarks N/A
*/
-EXPORT_API int email_download_body(int mail_id, int with_attachment, unsigned* handle);
+EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle);
/**
* @open
- * @fn email_download_attachment(int mail_id, const char* nth, unsigned* handle);
+ * @fn email_download_attachment(int mail_id, const char* nth, int *handle);
* @brief Download a email nth-attachment from server.This function is invoked if user wants to download only specific attachment of a mail whose body is already downloaded.
*
* @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
* @see email_mailbox_t
* @remarks N/A
*/
-EXPORT_API int email_download_attachment(int mail_id, int nth, unsigned* handle);
+EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle);
/**
/**
* @open
- * @fn email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle)
+ * @fn email_send_saved(int account_id, int *handle)
* @brief Send all mails to been saved in Offline-mode.This function is invoked when user wants to send an email and after saving it.
* This will save the email in draft mailbox and then sends.
*
* @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
* @param[in] account_id Specifies the account ID.
- * @param[in] sending_option Specifies the sending option.
* @param[out] handle Specifies the handle for stopping sending.
* @exception none
* @see email_option_t
* @remarks N/A
*/
-EXPORT_API int email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle);
+EXPORT_API int email_send_saved(int account_id, int *handle);
/**
* @open
- * @fn email_sync_imap_mailbox_list(int account_id, unsigned* handle)
+ * @fn email_sync_imap_mailbox_list(int account_id, int *handle)
* @brief fetch all the mailbox names from server and store the non-existing mailboxes in DB.This function is invoked when user wants to download all server mailboxes from IMAP server
*
* @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
* @see none
* @remarks N/A
*/
-EXPORT_API int email_sync_imap_mailbox_list(int account_id, unsigned* handle);
+EXPORT_API int email_sync_imap_mailbox_list(int account_id, int *handle);
/**
* @open
- * @fn 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, unsigned *output_handle)
+ * @fn 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)
* @brief Search the mails on server.
*
* @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
* @endcode
* @remarks N/A
*/
-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, unsigned *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);
EXPORT_API int email_clear_result_of_search_mail_on_server(int input_account_id);
EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count);
-EXPORT_API int email_verify_signature(char *certificate_path, int mail_id, int *verify);
+EXPORT_API int email_verify_signature(int mail_id, int *verify);
EXPORT_API int email_verify_certificate(char *certificate_path, int *verify);
#define fATTACHMENT 0x40
#define fFORWARD 0x80
-INTERNAL_FUNC int em_convert_mail_flag_to_int(email_mail_flag_t flag, int *i_flag, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("i_flag[%p], err_code[%p]", i_flag, err_code);
-
- if (!i_flag) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return false;
-
- }
-
- *i_flag =
- (flag.seen ? fSEEN : 0) |
- (flag.deleted ? fDELETED : 0) |
- (flag.flagged ? fFLAGGED : 0) |
- (flag.answered ? fANSWERED : 0) |
- (flag.recent ? fOLD : 0) |
- (flag.draft ? fDRAFT : 0) |
- (flag.has_attachment ? fATTACHMENT : 0) |
- (flag.forwarded ? fFORWARD : 0) ;
-
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-INTERNAL_FUNC int em_convert_mail_int_to_flag(int i_flag, email_mail_flag_t* flag, int* err_code)
-{
- EM_DEBUG_FUNC_BEGIN("i_flag[0x%02x], flag[%p], err_code[%p]", i_flag, flag, err_code);
-
- if (!flag) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return false;
- }
-
- flag->seen = (i_flag & fSEEN ? 1 : 0);
- flag->deleted = (i_flag & fDELETED ? 1 : 0);
- flag->flagged = (i_flag & fFLAGGED ? 1 : 0);
- flag->answered = (i_flag & fANSWERED ? 1 : 0);
- flag->recent = (i_flag & fOLD ? 1 : 0);
- flag->draft = (i_flag & fDRAFT ? 1 : 0);
- flag->has_attachment = (i_flag & fATTACHMENT ? 1 : 0);
- flag->forwarded = (i_flag & fFORWARD ? 1 : 0);
-
- EM_DEBUG_FUNC_END("FLAGS : seen[%d], deleted[%d], flagged[%d], answered[%d], recent[%d], draft[%d], has_attachment[%d], forwarded[%d]",
- flag->seen, flag->deleted, flag->flagged, flag->answered, flag->recent, flag->draft, flag->has_attachment, flag->forwarded);
-
- return true;
-}
-
INTERNAL_FUNC int em_convert_mail_tbl_to_mail_status(emstorage_mail_tbl_t *mail_tbl_data, int *result_mail_status, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_tbl_data[%p], result_mail_status [%p], err_code[%p]", mail_tbl_data, result_mail_status, err_code);
int ret = false, error_code = EMAIL_ERROR_NONE;
- int has_attachment = 0;
+ int attachment_count = 0;
if(!mail_tbl_data || !result_mail_status) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
goto FINISH_OFF;
}
- has_attachment = (mail_tbl_data->attachment_count > mail_tbl_data->inline_content_count) ? 1 : 0;
+ attachment_count = (mail_tbl_data->attachment_count > mail_tbl_data->inline_content_count) ? 1 : 0;
*result_mail_status = (mail_tbl_data->flags_seen_field ? fSEEN : 0) |
(mail_tbl_data->flags_deleted_field ? fDELETED : 0) |
(mail_tbl_data->flags_answered_field ? fANSWERED : 0) |
(mail_tbl_data->flags_recent_field ? fOLD : 0) |
(mail_tbl_data->flags_draft_field ? fDRAFT : 0) |
- (has_attachment ? fATTACHMENT : 0) |
+ (attachment_count ? fATTACHMENT : 0) |
(mail_tbl_data->flags_forwarded_field ? fFORWARD : 0);
ret = true;
return ret;
}
-INTERNAL_FUNC int em_convert_mail_tbl_to_mail_flag(emstorage_mail_tbl_t *mail_tbl_data, email_mail_flag_t *result_flag, int* err_code)
-{
- EM_DEBUG_FUNC_BEGIN("mail_tbl_data[%p], result_flag [%p], err_code[%p]", mail_tbl_data, result_flag, err_code);
- int ret = false, error_code = EMAIL_ERROR_NONE;
-
- if(!mail_tbl_data || !result_flag) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- error_code = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- result_flag->seen = mail_tbl_data->flags_seen_field;
- result_flag->deleted = mail_tbl_data->flags_deleted_field;
- result_flag->flagged = mail_tbl_data->flags_flagged_field;
- result_flag->answered = mail_tbl_data->flags_answered_field;
- result_flag->recent = mail_tbl_data->flags_recent_field;
- result_flag->draft = mail_tbl_data->flags_draft_field;
- result_flag->has_attachment = (mail_tbl_data->attachment_count > mail_tbl_data->inline_content_count) ? 1 : 0;
- result_flag->forwarded = mail_tbl_data->flags_forwarded_field;
-
- ret = true;
-FINISH_OFF:
- if (err_code != NULL)
- *err_code = error_code;
-
- EM_DEBUG_FUNC_END("ret [%d]", ret);
- return ret;
-}
-
-INTERNAL_FUNC int em_convert_mail_flag_to_mail_tbl(email_mail_flag_t *flag, emstorage_mail_tbl_t *result_mail_tbl_data, int* err_code)
-{
- EM_DEBUG_FUNC_BEGIN("flag[%p], result_mail_tbl_data [%p], err_code[%p]", flag, result_mail_tbl_data, err_code);
- int ret = false, error_code = EMAIL_ERROR_NONE;
-
- if(!flag || !result_mail_tbl_data) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- error_code = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- result_mail_tbl_data->flags_seen_field = flag->seen;
- result_mail_tbl_data->flags_deleted_field = flag->deleted;
- result_mail_tbl_data->flags_flagged_field = flag->flagged;
- result_mail_tbl_data->flags_answered_field = flag->answered;
- result_mail_tbl_data->flags_recent_field = flag->recent;
- result_mail_tbl_data->flags_draft_field = flag->draft;
- result_mail_tbl_data->flags_forwarded_field = flag->forwarded;
-
- ret = true;
-FINISH_OFF:
- if (err_code != NULL)
- *err_code = error_code;
-
- EM_DEBUG_FUNC_END("ret [%d]", ret);
- return ret;
-}
-
-
INTERNAL_FUNC int em_convert_account_to_account_tbl(email_account_t *account, emstorage_account_tbl_t *account_tbl)
{
EM_DEBUG_FUNC_BEGIN("account[%p], account_tbl[%p]", account, account_tbl);
temp_mail_data[i].server_mailbox_name = EM_SAFE_STRDUP(mail_table_data[i].server_mailbox_name);
temp_mail_data[i].server_mail_id = EM_SAFE_STRDUP(mail_table_data[i].server_mail_id);
temp_mail_data[i].message_id = EM_SAFE_STRDUP(mail_table_data[i].message_id);
+ temp_mail_data[i].reference_mail_id = mail_table_data[i].reference_mail_id;
temp_mail_data[i].full_address_from = EM_SAFE_STRDUP(mail_table_data[i].full_address_from);
temp_mail_data[i].full_address_reply = EM_SAFE_STRDUP(mail_table_data[i].full_address_reply);
temp_mail_data[i].full_address_to = EM_SAFE_STRDUP(mail_table_data[i].full_address_to);
temp_mail_tbl[i].server_mailbox_name = EM_SAFE_STRDUP(mail_data[i].server_mailbox_name);
temp_mail_tbl[i].server_mail_id = EM_SAFE_STRDUP(mail_data[i].server_mail_id);
temp_mail_tbl[i].message_id = EM_SAFE_STRDUP(mail_data[i].message_id);
+ temp_mail_tbl[i].reference_mail_id = mail_data[i].reference_mail_id;
temp_mail_tbl[i].full_address_from = EM_SAFE_STRDUP(mail_data[i].full_address_from);
temp_mail_tbl[i].full_address_reply = EM_SAFE_STRDUP(mail_data[i].full_address_reply);
temp_mail_tbl[i].full_address_to = EM_SAFE_STRDUP(mail_data[i].full_address_to);
#endif
}
-#define EMAIL_MAIL_DATA_FMT "S(" "iiiis" "iisss" "sssss" "sssss" "isssi"\
- "ccccc" "cciii" "iiiii" "isiii" "i" ")"
+#define EMAIL_MAIL_DATA_FMT "S(" "iiiis" "iisss" "issss" "sssss" "sisss"\
+ "icccc" "cccii" "iiiii" "iisii" "ii" ")"
-#if 0
INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_data, int *stream_len)
{
EM_DEBUG_FUNC_END();
EM_DEBUG_FUNC_END();
return (char*) buf;
-#endif
-INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *input_mail_data, int input_mail_data_count, int *output_stream_size)
-{
+#if 0
EM_DEBUG_FUNC_BEGIN("input_mail_data [%p], input_mail_data_count[%d], output_stream_size[%p]", input_mail_data, input_mail_data_count, output_stream_size);
char *result_stream = NULL;
result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].server_mailbox_name);
result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].server_mail_id);
result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].message_id);
+ result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_mail_data[i].reference_mail_id), sizeof(int));
result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].full_address_from);
result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].full_address_reply);
result_stream = append_string_to_stream(result_stream, &stream_size, input_mail_data[i].full_address_to);
EM_DEBUG_FUNC_END("stream_size [%d]", stream_size);
return result_stream;
+#endif
}
-#if 0
+
INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_len, email_mail_data_t *mail_data)
{
EM_NULL_CHECK_FOR_VOID(stream);
tpl_free(tn);
EM_DEBUG_FUNC_END();
-#endif
-INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *input_stream, email_mail_data_t **output_mail_data, int *output_mail_data_count)
-{
+#if 0
EM_DEBUG_FUNC_BEGIN("input_stream [%p], output_mail_data[%p], output_mail_data_count[%p]", input_stream, output_mail_data, output_mail_data_count);
int stream_offset = 0;
fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].server_mailbox_name);
fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].server_mail_id);
fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].message_id);
+ fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(*output_mail_data)[i].reference_mail_id);
fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].full_address_from);
fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].full_address_reply);
fetch_string_from_stream(input_stream, &stream_offset, &(*output_mail_data)[i].full_address_to);
}
EM_DEBUG_FUNC_END();
+#endif
}
INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(email_attachment_data_t *attachment, int attachment_count, int* stream_len)
{
-#if 0
EM_DEBUG_FUNC_BEGIN();
EM_IF_NULL_RETURN_VALUE(stream_len, NULL);
if(!attachment) {
EM_DEBUG_FUNC_END();
return (char*) buf;
-#endif
- EM_DEBUG_FUNC_BEGIN("attachment [%p], input_attachment_count [%d], output_stream_size [%p]", attachment, attachment_count, stream_len);
+#if 0
+ EM_DEBUG_FUNC_BEGIN("input_attachment_data [%p], input_attachment_count [%d], output_stream_size [%p]", input_attachment_data, input_attachment_count, output_stream_size);
char *result_stream = NULL;
int stream_size = 0;
int i = 0;
- if(attachment_count > 0)
- EM_IF_NULL_RETURN_VALUE(attachment, NULL);
- EM_IF_NULL_RETURN_VALUE(stream_len, NULL);
+ if(input_attachment_count > 0)
+ EM_IF_NULL_RETURN_VALUE(input_attachment_data, NULL);
+ EM_IF_NULL_RETURN_VALUE(output_stream_size, NULL);
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment_count, sizeof(int));
-
- for(i = 0; i < attachment_count; i++) {
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].attachment_id, sizeof(int));
- result_stream = append_string_to_stream(result_stream, &stream_size, attachment[i].attachment_name);
- result_stream = append_string_to_stream(result_stream, &stream_size, attachment[i].attachment_path);
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].attachment_size, sizeof(int));
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].mail_id, sizeof(int));
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].account_id, sizeof(int));
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].mailbox_id, sizeof(int));
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].save_status, sizeof(int));
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].drm_status, sizeof(int));
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].inline_content_status,sizeof(int));
+ result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_count, sizeof(int));
+
+ for(i = 0; i < input_attachment_count; i++) {
+ result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].attachment_id, sizeof(int));
+ result_stream = append_string_to_stream(result_stream, &stream_size, input_attachment_data[i].attachment_name);
+ result_stream = append_string_to_stream(result_stream, &stream_size, input_attachment_data[i].attachment_path);
+ result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].attachment_size, sizeof(int));
+ result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].mail_id, sizeof(int));
+ result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].account_id, sizeof(int));
+ result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].mailbox_id, sizeof(int));
+ result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].save_status, sizeof(int));
+ result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].drm_status, sizeof(int));
+ result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].inline_content_status,sizeof(int));
}
- *stream_len = stream_size;
+ *output_stream_size = stream_size;
EM_DEBUG_FUNC_END("stream_size [%d]", stream_size);
return result_stream;
-
+#endif
}
INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *stream, int stream_len, email_attachment_data_t **attachment_data, int *attachment_count)
{
-#if 0
EM_DEBUG_FUNC_BEGIN();
EM_NULL_CHECK_FOR_VOID(stream);
EM_NULL_CHECK_FOR_VOID(attachment_data);
*attachment_count = count;
*attachment_data = attached;
EM_DEBUG_FUNC_END();
-#endif
- EM_DEBUG_FUNC_BEGIN("stream [%p], attachment_data[%p]", stream, attachment_data);
+#if 0
+ EM_DEBUG_FUNC_BEGIN("input_stream [%p], output_attachment_data[%p]", input_stream, output_attachment_data);
int stream_offset = 0;
int i = 0;
- EM_NULL_CHECK_FOR_VOID(stream);
- EM_NULL_CHECK_FOR_VOID(attachment_data);
- EM_NULL_CHECK_FOR_VOID(attachment_count);
+ EM_NULL_CHECK_FOR_VOID(input_stream);
+ EM_NULL_CHECK_FOR_VOID(output_attachment_data);
+ EM_NULL_CHECK_FOR_VOID(output_attachment_count);
- fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)attachment_count);
+ fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)output_attachment_count);
- EM_DEBUG_LOG("*attachment_count [%d]", *attachment_count);
+ EM_DEBUG_LOG("*output_attachment_count [%d]", *output_attachment_count);
- if(attachment_count <= 0) {
+ if(output_attachment_count <= 0) {
EM_DEBUG_EXCEPTION("no attachment data.");
return;
}
- *attachment_data = (email_attachment_data_t*)em_malloc(sizeof(email_attachment_data_t) * (*attachment_count));
+ *output_attachment_data = (email_attachment_data_t*)em_malloc(sizeof(email_attachment_data_t) * (*output_attachment_count));
- if(!*attachment_data) {
+ if(!*output_attachment_data) {
EM_DEBUG_EXCEPTION("em_malloc failed");
return;
}
- for(i = 0; i < *attachment_count; i++) {
- fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].attachment_id));
- fetch_string_from_stream(stream, &stream_offset, &(*attachment_data)[i].attachment_name);
- fetch_string_from_stream(stream, &stream_offset, &(*attachment_data)[i].attachment_path);
- fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].attachment_size));
- fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].mail_id));
- fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].account_id));
- fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].mailbox_id));
- fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].save_status));
- fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].drm_status));
- fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].inline_content_status));
+ for(i = 0; i < *output_attachment_count; i++) {
+ fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].attachment_id));
+ fetch_string_from_stream(input_stream, &stream_offset, &(*output_attachment_data)[i].attachment_name);
+ fetch_string_from_stream(input_stream, &stream_offset, &(*output_attachment_data)[i].attachment_path);
+ fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].attachment_size));
+ fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].mail_id));
+ fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].account_id));
+ fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].mailbox_id));
+ fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].save_status));
+ fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].drm_status));
+ fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].inline_content_status));
}
EM_DEBUG_FUNC_END();
+#endif
}
#endif
}
-
-#if 0
-INTERNAL_FUNC char* em_convert_extra_flags_to_byte_stream(email_extra_flag_t extra_flag, int *stream_len)
-{
- EM_DEBUG_FUNC_BEGIN();
- char *result_stream = NULL;
- int stream_size = 0;
- int extra_flag_field = 0;
-
- EM_IF_NULL_RETURN_VALUE(output_stream_size, NULL);
-
- extra_flag_field = input_extra_flag.priority;
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&extra_flag_field, sizeof(int));
- extra_flag_field = input_extra_flag.status;
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&extra_flag_field, sizeof(int));
- extra_flag_field = input_extra_flag.noti;
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&extra_flag_field, sizeof(int));
- extra_flag_field = input_extra_flag.lock;
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&extra_flag_field, sizeof(int));
- extra_flag_field = input_extra_flag.report;
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&extra_flag_field, sizeof(int));
- extra_flag_field = input_extra_flag.drm;
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&extra_flag_field, sizeof(int));
- extra_flag_field = input_extra_flag.text_download_yn;
- result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&extra_flag_field, sizeof(int));
-
- *output_stream_size = stream_size;
-
- EM_DEBUG_FUNC_END();
-
- return result_stream;
-}
-
-
-INTERNAL_FUNC void em_convert_byte_stream_to_extra_flags(char *input_stream, email_extra_flag_t *output_extra_flag)
-{
- EM_DEBUG_FUNC_BEGIN();
-
- int stream_offset = 0;
- int extra_flag_field = 0;
-
- EM_NULL_CHECK_FOR_VOID(input_stream);
- EM_NULL_CHECK_FOR_VOID(output_extra_flag);
-
- fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&extra_flag_field);
- output_extra_flag->priority = extra_flag_field;
- fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&extra_flag_field);
- output_extra_flag->status = extra_flag_field;
- fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&extra_flag_field);
- output_extra_flag->noti = extra_flag_field;
- fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&extra_flag_field);
- output_extra_flag->lock = extra_flag_field;
- fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&extra_flag_field);
- output_extra_flag->report = extra_flag_field;
- fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&extra_flag_field);
- output_extra_flag->drm = extra_flag_field;
- fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&extra_flag_field);
- output_extra_flag->text_download_yn = extra_flag_field;
-
- EM_DEBUG_FUNC_END();
-}
-#endif
-
-
#define EMAIL_MEETING_REQUEST_FMT "iiBBs" "sic#Bi" "c#Bi"
INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(email_meeting_request_t *meeting_req, int *stream_len)
{
EM_DEBUG_FUNC_BEGIN("extension_string[%s]", extension_string);
int i = 0, err = EMAIL_ERROR_NONE, result_content_type = TYPEAPPLICATION;
- char *image_extension[] = { "jpeg", "jpg", "png", "gif", "bmp", "pic", "agif", "tif", "wbmp" , NULL};
+ char *image_extension[] = { "jpeg", "jpg", "png", "gif", "bmp", "pic", "agif", "tif", "wbmp" , "p7s", "p7m", NULL};
if (!extension_string) {
EM_DEBUG_EXCEPTION("Invalid Parameter");
while(image_extension[i]) {
EM_DEBUG_LOG("image_extension[%d] [%s]", i, image_extension[i]);
if(strcasecmp(image_extension[i], extension_string) == 0) {
- result_content_type = TYPEIMAGE;
break;
}
i++;
}
+
+ switch (i) {
+ case EXTENSION_JPEG:
+ case EXTENSION_JPG:
+ case EXTENSION_PNG:
+ case EXTENSION_GIF:
+ case EXTENSION_BMP:
+ case EXTENSION_PIC:
+ case EXTENSION_AGIF:
+ case EXTENSION_TIF:
+ case EXTENSION_WBMP:
+ result_content_type = TYPEIMAGE;
+ break;
+ case EXTENSION_P7S:
+ result_content_type = TYPEPKCS7_SIGN;
+ break;
+ case EXTENSION_P7M:
+ result_content_type = TYPEPKCS7_MIME;
+ break;
+ default:
+ break;
+ }
FINISH_OFF:
if (err_code)
DBusConnection *connection;
DBusMessage *signal = NULL;
DBusError error;
- const char *nullString = "";
int i = 0;
dbus_error_init (&error);
EM_DEBUG_LOG("handle:[%d]", data->send_mail.handle);
EM_DEBUG_LOG("account_id:[%d]", data->send_mail.account_id);
EM_DEBUG_LOG("mail_id:[%d]", data->send_mail.mail_id);
- EM_DEBUG_LOG("options.priority:[%d]", data->send_mail.options.priority);
- EM_DEBUG_LOG("options.keep_local_copy:[%d]", data->send_mail.options.keep_local_copy);
- EM_DEBUG_LOG("options.req_delivery_receipt:[%d]", data->send_mail.options.req_delivery_receipt);
- EM_DEBUG_LOG("options.req_read_receipt:[%d]", data->send_mail.options.req_read_receipt);
- /* download_limit, block_address, block_subject might not be needed */
- EM_DEBUG_LOG("options.download_limit:[%d]", data->send_mail.options.download_limit);
- EM_DEBUG_LOG("options.block_address:[%d]", data->send_mail.options.block_address);
- EM_DEBUG_LOG("options.block_subject:[%d]", data->send_mail.options.block_subject);
- EM_DEBUG_LOG("options.display_name_from:[%s]", data->send_mail.options.display_name_from);
- EM_DEBUG_LOG("options.reply_with_body:[%d]", data->send_mail.options.reply_with_body);
- EM_DEBUG_LOG("options.forward_with_files:[%d]", data->send_mail.options.forward_with_files);
- EM_DEBUG_LOG("options.add_myname_card:[%d]", data->send_mail.options.add_myname_card);
- EM_DEBUG_LOG("options.add_signature:[%d]", data->send_mail.options.add_signature);
- EM_DEBUG_LOG("options.signature:[%s]", data->send_mail.options.signature);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.handle), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.account_id), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.mail_id), DBUS_TYPE_INVALID);
- dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.priority), DBUS_TYPE_INVALID);
- dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.keep_local_copy), DBUS_TYPE_INVALID);
- dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.req_delivery_receipt), DBUS_TYPE_INVALID);
- dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.req_read_receipt), DBUS_TYPE_INVALID);
- if ( data->send_mail.options.display_name_from == NULL )
- dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID);
- else
- dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.options.display_name_from), DBUS_TYPE_INVALID);
-
- dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.reply_with_body), DBUS_TYPE_INVALID);
- dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.forward_with_files), DBUS_TYPE_INVALID);
- dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.add_myname_card), DBUS_TYPE_INVALID);
- dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.add_signature), DBUS_TYPE_INVALID);
- if ( data->send_mail.options.signature == NULL )
- dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID);
- else
- dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.options.signature), DBUS_TYPE_INVALID);
-
break;
case ACTIVE_SYNC_NOTI_SEND_SAVED: /* publish a send notification to ASE (active sync engine) */
EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_SEND_SAVED]", subType);
/* Mail */
-INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_data, int input_mail_data_count, int *stream_size);
-INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, email_mail_data_t **mail_data, int *output_mail_data_count);
+INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_data, int *stream_size);
+INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_len, email_mail_data_t *mail_data);
INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_table_data, int item_count, email_mail_data_t **mail_data, int *error);
INTERNAL_FUNC int em_convert_mail_data_to_mail_tbl(email_mail_data_t *mail_data, int item_count, emstorage_mail_tbl_t **mail_table_data, int *error);
INTERNAL_FUNC int em_convert_string_to_time_t(char *input_datetime_string, time_t *output_time);
INTERNAL_FUNC int em_convert_time_t_to_string(time_t *input_time, char **output_datetime_string);
-/* email_extra_flag_t */
-INTERNAL_FUNC char* em_convert_extra_flags_to_byte_stream(email_extra_flag_t new_flag, int* StreamSize);
-INTERNAL_FUNC void em_convert_byte_stream_to_extra_flags(char* pStream, email_extra_flag_t* new_flag);
-
/* email_meeting_request_t */
INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(email_meeting_request_t* meeting_req, int* nStreamSize);
INTERNAL_FUNC void em_convert_byte_stream_to_meeting_req(char* stream, int stream_len, email_meeting_request_t* meeting_req);
-INTERNAL_FUNC int em_convert_mail_flag_to_int(email_mail_flag_t flag, int* i_flag, int* err_code);
-INTERNAL_FUNC int em_convert_mail_int_to_flag(int i_flag, email_mail_flag_t* flag, int* err_code);
INTERNAL_FUNC int em_convert_mail_status_to_mail_tbl(int mail_status, emstorage_mail_tbl_t *result_mail_tbl_data, int* err_code);
INTERNAL_FUNC int em_convert_mail_tbl_to_mail_status(emstorage_mail_tbl_t *mail_tbl_data, int *result_mail_status, int* err_code);
-INTERNAL_FUNC int em_convert_mail_tbl_to_mail_flag(emstorage_mail_tbl_t *mail_tbl_data, email_mail_flag_t *result_flag, int* err_code);
-INTERNAL_FUNC int em_convert_mail_flag_to_mail_tbl(email_mail_flag_t *flag, emstorage_mail_tbl_t *result_mail_tbl_data, int* err_code);
/* Search filter options */
INTERNAL_FUNC char* em_convert_search_filter_to_byte_stream(email_search_filter_t *input_search_filter_list, int input_search_filter_count, int *output_stream_size);
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include <dlog.h>
#include <errno.h>
#define EMAIL_ERROR_NETWORK_NOT_AVAILABLE -1800 /* WIFI not availble*/
#define EMAIL_ERROR_CANNOT_STOP_THREAD -2000
#define EMAIL_ERROR_SECURED_STORAGE_FAILURE -2100 /* Error from secured storage */
+#define EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE -3000 /* Cannot load the certificate */
+#define EMAIL_ERROR_INVALID_CERTIFICATE -3001 /* invalid certificate */
#define EMAIL_ERROR_UNKNOWN -8000 /* unknown error */
#endif /* __EMAIL_ERRORS_H__ */
/* ----------------------------------------------------------------------------- */
/* Feature definitions */
+#define __FEATURE_USING_ACCOUNT_SVC__
#define __FEATURE_BACKUP_ACCOUNT__
#define __FEATURE_MOVE_TO_OUTBOX_FIRST__
/* #define __FEATURE_PARTIAL_BODY_FOR_POP3__ */
#define __FEATURE_DEBUG_LOG__
#define __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__
#define __FEATURE_XLIST_SUPPORT__
+#define __FEATURE_SUPPORT_REPORT_MAIL__
/* #define __FEATURE_USE_SHARED_MUTEX_FOR_PROTECTED_FUNC_CALL__ */
/* #define __FEATURE_IMAP_IDLE__ */
+#define _TIZEN_PUBLIC_ /* __FEATURE_WDS_SUPPORT__ and __FEATURE_NOTIFICATION_FOR_NEW_MAIL__ and MDM_PHASE_2*/
+
/* ----------------------------------------------------------------------------- */
/* Macro */
#ifndef NULL
#define VCONF_KEY_LATEST_MAIL_ID "db/private/email-service/latest_mail_id"
#define VCONF_KEY_DEFAULT_ACCOUNT_ID "db/private/email-service/default_account_id"
+#define OUTMODE "wb"
+#define INMODE "rb"
+#define READMODE "r"
+
+#define TYPEPKCS7_SIGN 10
+#define TYPEPKCS7_MIME 11
+
+/* __FEATURE_LOCAL_ACTIVITY__ supported
+#define BULK_OPERATION_COUNT 50
+#define ALL_ACTIVITIES 0
+*/
+
/* ----------------------------------------------------------------------------- */
/* Type */
typedef enum
} ;
#endif /* __FEATURE_KEEP_CONNECTION__ */
+enum
+{
+ EXTENSION_JPEG = 0,
+ EXTENSION_JPG = 1,
+ EXTENSION_PNG = 2,
+ EXTENSION_GIF = 3,
+ EXTENSION_BMP = 4,
+ EXTENSION_PIC = 5,
+ EXTENSION_AGIF = 6,
+ EXTENSION_TIF = 7,
+ EXTENSION_WBMP = 8,
+ EXTENSION_P7S = 9,
+ EXTENSION_P7M = 10
+};
+
/* event information */
typedef struct
{
/* Macros */
/*****************************************************************************/
-#define MAILBOX_NAME_LENGTH 256
-#define MAX_EMAIL_ADDRESS_LENGTH 320 /* 64(user name) + 1(@) + 255(host name */
-#define MAX_DATETIME_STRING_LENGTH 20
-#define MAX_PREVIEW_TEXT_LENGTH 512
-#define STRING_LENGTH_FOR_DISPLAY 100
-#define MEETING_REQ_OBJECT_ID_LENGTH 256
+#define MAILBOX_NAME_LENGTH 256
+#define MAX_EMAIL_ADDRESS_LENGTH 320 /* 64(user name) + 1(@) + 255(host name */
+#define MAX_DATETIME_STRING_LENGTH 20
+#define MAX_PREVIEW_TEXT_LENGTH 512
+#define STRING_LENGTH_FOR_DISPLAY 100
+#define MEETING_REQ_OBJECT_ID_LENGTH 256
-#define ALL_ACCOUNT 0
-#define NEW_ACCOUNT_ID 0xFFFFFFFE
-#define ALL_MAIL -1
+#define ALL_ACCOUNT 0
+#define NEW_ACCOUNT_ID 0xFFFFFFFE
+#define ALL_MAIL -1
#define EMAIL_SEARCH_FILTER_NONE 0x00
#define EMAIL_SEARCH_FILTER_SUBJECT 0x01
#define EMAIL_SEARCH_FILTER_RECIPIENT 0x04
#define EMAIL_SEARCH_FILTER_ALL 0x07 /* EMAIL_SEARCH_FILTER_SUBJECT + EMAIL_SEARCH_FILTER_SENDER + EMAIL_SEARCH_FILTER_RECIPIEN */
-#define EMAIL_SUCCESS 0 /* we need to modify the success return valu */
+#define EMAIL_SUCCESS 0 /* we need to modify the success return value */
#define EMAIL_ACC_GET_OPT_DEFAULT 0x01 /**< Default values without account name */
#define EMAIL_ACC_GET_OPT_ACCOUNT_NAME 0x02 /**< Account name */
#define EMAIL_ACC_GET_OPT_OPTIONS 0x08 /**< Account options : email_option_t */
#define EMAIL_ACC_GET_OPT_FULL_DATA 0xFF /**< With all data of account */
-#define GET_FULL_DATA (EMAIL_ACC_GET_OPT_FULL_DATA)
-#define GET_FULL_DATA_WITHOUT_PASSWORD (EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_ACCOUNT_NAME | EMAIL_ACC_GET_OPT_OPTIONS )
-#define WITHOUT_OPTION (EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_ACCOUNT_NAME )
-#define ONLY_OPTION (EMAIL_ACC_GET_OPT_OPTIONS)
+#define GET_FULL_DATA (EMAIL_ACC_GET_OPT_FULL_DATA)
+#define GET_FULL_DATA_WITHOUT_PASSWORD (EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_ACCOUNT_NAME | EMAIL_ACC_GET_OPT_OPTIONS )
+#define WITHOUT_OPTION (EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_ACCOUNT_NAME )
+#define ONLY_OPTION (EMAIL_ACC_GET_OPT_OPTIONS)
-#define THREAD_TYPE_RECEIVING 0 /**< for function 'email_activate_pdp' */
-#define THREAD_TYPE_SENDING 1 /**< for function 'email_activate_pdp' */
+#define THREAD_TYPE_RECEIVING 0 /**< for function 'email_activate_pdp' */
+#define THREAD_TYPE_SENDING 1 /**< for function 'email_activate_pdp' */
#define EMAIL_IMAP_PORT 143 /**< Specifies the default IMAP port.*/
#define EMAIL_POP3_PORT 110 /**< Specifies the default POP3 port.*/
#define EMAIL_SEARCH_RESULT_MAILBOX_NAME "_`S1!E2@A3#R4$C5^H6&R7*E8(S9)U0-L=T_" /**< Specifies the name of search result mailbox.*/
-#define SYNC_STATUS_FINISHED 0 /* BIN 00000000 */
-#define SYNC_STATUS_SYNCING 1 /* BIN 00000001 */
-#define SYNC_STATUS_HAVE_NEW_MAILS 2 /* BIN 00000010 */
+#define SYNC_STATUS_FINISHED 0 /* BIN 00000000 */
+#define SYNC_STATUS_SYNCING 1 /* BIN 00000001 */
+#define SYNC_STATUS_HAVE_NEW_MAILS 2 /* BIN 00000010 */
-#define FAILURE -1
-#define SUCCESS 0
+#define FAILURE -1
+#define SUCCESS 0
-#define DAEMON_EXECUTABLE_PATH "/usr/bin/email-service"
+#define DAEMON_EXECUTABLE_PATH "/usr/bin/email-service"
#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
+#define EXPORT_API __attribute__((visibility("default")))
#endif
#ifndef DEPRECATED
-#define DEPRECATED __attribute__((deprecated))
+#define DEPRECATED __attribute__((deprecated))
#endif
-/* __FEATURE_LOCAL_ACTIVITY__ supported
-#define BULK_OPERATION_COUNT 50
-#define ALL_ACTIVITIES 0
-*/
-
/*****************************************************************************/
/* Enumerations */
/*****************************************************************************/
/* Mailbox */
_EMAIL_API_ADD_MAILBOX = 0x01200000,
_EMAIL_API_DELETE_MAILBOX = 0x01200001,
- _EMAIL_API_UPDATE_MAILBOX = 0x01200002,
_EMAIL_API_SET_MAIL_SLOT_SIZE = 0x01200007,
_EMAIL_API_RENAME_MAILBOX = 0x01200008,
_EMAIL_API_SET_MAILBOX_TYPE = 0x01200009,
+ _EMAIL_API_SET_LOCAL_MAILBOX = 0x0120000A,
/* Network */
_EMAIL_API_SEND_MAIL = 0x01300000,
_EMAIL_API_PING_SERVICE = 0x01500000,
_EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL = 0x01500001,
_EMAIL_API_SHOW_USER_MESSAGE = 0x01500002,
+ _EMAIL_API_WRITE_MIME_FILE = 0x01500003,
/* Smime */
_EMAIL_API_ADD_CERTIFICATE = 0x01600000,
typedef enum
{
- EMAIL_DELETE_LOCALLY = 0, /**< Specifies Mail Delete local only */
+ EMAIL_DELETE_LOCALLY = 0, /**< Specifies Mail Delete local only */
EMAIL_DELETE_LOCAL_AND_SERVER, /**< Specifies Mail Delete local & server */
EMAIL_DELETE_FOR_SEND_THREAD, /**< Created to check which activity to delete in send thread */
EMAIL_DELETE_FROM_SERVER,
+ EMAIL_DELETE_MAIL_AND_MEETING_FOR_EAS, /**< Delete mails and meetings on an EAS account. */
} email_delete_option_t;
typedef enum
*/
typedef enum
{
- EMAIL_MAIL_REPORT_NONE = 0, /**< The mail isn't report mail.*/
- EMAIL_MAIL_REPORT_DSN, /**< The mail is a delivery-status report mail.*/
- EMAIL_MAIL_REPORT_MDN, /**< The mail is a read-status report mail.*/
- EMAIL_MAIL_REPORT_REQUEST, /**< The mail require a read-status report mail.*/
+ EMAIL_MAIL_REPORT_NONE = 0x00, /**< The mail isn't report mail.*/
+ EMAIL_MAIL_REPORT_REQUEST = 0x03, /* Deprecated */
+ EMAIL_MAIL_REPORT_DSN = 0x04, /**< The mail is a Delivery Status Notifications mail.*/
+ EMAIL_MAIL_REPORT_MDN = 0x08, /**< The mail is a Message Disposition Notifications mail.*/
+ EMAIL_MAIL_REQUEST_DSN = 0x10, /**< The mail requires Delivery Status Notifications.*/
+ EMAIL_MAIL_REQUEST_MDN = 0x20, /**< The mail requires Message Disposition Notifications.*/
} email_mail_report_t;
/**
} email_attachment_drm_t;
/**
- * This enumeration specifies the meeting request type
+ * This enumeration specifies the mail type
*/
typedef enum
{
EMAIL_FLAG_NONE = 0,
EMAIL_FLAG_FLAGED = 1,
EMAIL_FLAG_TASK_STATUS_CLEAR = 2,
- EMAIL_FLAG_TASK_STATUS_ACTIVE = 3,
- EMAIL_FLAG_TASK_STATUS_COMPLETE = 4,
+ EMAIL_FLAG_TASK_STATUS_COMPLETE = 3,
+ EMAIL_FLAG_TASK_STATUS_ACTIVE = 4,
} email_flagged_type;
typedef enum {
EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME = 8, /* string type */
EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID = 9, /* string type */
EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID = 10, /* string type */
- EMAIL_MAIL_ATTRIBUTE_FROM = 11, /* string type */
- EMAIL_MAIL_ATTRIBUTE_TO = 12, /* string type */
- EMAIL_MAIL_ATTRIBUTE_CC = 13, /* string type */
- EMAIL_MAIL_ATTRIBUTE_BCC = 14, /* string type */
- EMAIL_MAIL_ATTRIBUTE_BODY_DOWNLOAD_STATUS = 15, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN = 16, /* string type */
- EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML = 17, /* string type */
- EMAIL_MAIL_ATTRIBUTE_FILE_SIZE = 18, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_FLAGS_SEEN_FIELD = 19, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD = 20, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_FLAGS_FLAGGED_FIELD = 21, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_FLAGS_ANSWERED_FIELD = 22, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_FLAGS_RECENT_FIELD = 23, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_FLAGS_DRAFT_FIELD = 24, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_FLAGS_FORWARDED_FIELD = 25, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_DRM_STATUS = 26, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_PRIORITY = 27, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_SAVE_STATUS = 28, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_LOCK_STATUS = 29, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_REPORT_STATUS = 30, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT = 31, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_INLINE_CONTENT_COUNT = 32, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_THREAD_ID = 33, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_THREAD_ITEM_COUNT = 34, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT = 35, /* string type */
- EMAIL_MAIL_ATTRIBUTE_MEETING_REQUEST_STATUS = 36, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_MESSAGE_CLASS = 37, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_DIGEST_TYPE = 38, /* integer type */
- EMAIL_MAIL_ATTRIBUTE_SMIME_TYPE = 39, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_REFERENCE_MAIL_ID = 11, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_FROM = 12, /* string type */
+ EMAIL_MAIL_ATTRIBUTE_TO = 13, /* string type */
+ EMAIL_MAIL_ATTRIBUTE_CC = 14, /* string type */
+ EMAIL_MAIL_ATTRIBUTE_BCC = 15, /* string type */
+ EMAIL_MAIL_ATTRIBUTE_BODY_DOWNLOAD_STATUS = 16, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN = 17, /* string type */
+ EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML = 18, /* string type */
+ EMAIL_MAIL_ATTRIBUTE_FILE_SIZE = 19, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_FLAGS_SEEN_FIELD = 20, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD = 21, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_FLAGS_FLAGGED_FIELD = 22, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_FLAGS_ANSWERED_FIELD = 23, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_FLAGS_RECENT_FIELD = 24, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_FLAGS_DRAFT_FIELD = 25, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_FLAGS_FORWARDED_FIELD = 26, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_DRM_STATUS = 27, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_PRIORITY = 28, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_SAVE_STATUS = 29, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_LOCK_STATUS = 30, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_REPORT_STATUS = 31, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT = 32, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_INLINE_CONTENT_COUNT = 33, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_THREAD_ID = 34, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_THREAD_ITEM_COUNT = 35, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT = 36, /* string type */
+ EMAIL_MAIL_ATTRIBUTE_MEETING_REQUEST_STATUS = 37, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_MESSAGE_CLASS = 38, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_DIGEST_TYPE = 39, /* integer type */
+ EMAIL_MAIL_ATTRIBUTE_SMIME_TYPE = 40, /* integer type */
EMAIL_MAIL_ATTRIBUTE_END
} email_mail_attribute_type;
EMAIL_MESSAGE_CLASS_SHARING,
EMAIL_MESSAGE_CLASS_NOTE_EXCHANGE_ACTIVE_SYNC_REMOTE_WIPE_CONFIRMATION,
EMAIL_MESSAGE_CLASS_VOICE_MAIL,
- EMAIL_MESSAGE_CLASS_REPORT_DELIVERY_RECEIPT = 0x80000000,
- EMAIL_MESSAGE_CLASS_REPORT_NON_DELIVERY_RECEIPT = 0x40000000,
- EMAIL_MESSAGE_CLASS_REPORT_READ_REPORT = 0x20000000,
- EMAIL_MESSAGE_CLASS_REPORT_NOT_READ_REPORT = 0x10000000
+ EMAIL_MESSAGE_CLASS_SMS,
+ EMAIL_MESSAGE_CLASS_SMART_REPLY = 0x01000000,
+ EMAIL_MESSAGE_CLASS_SMART_FORWARD = 0x02000000,
+ EMAIL_MESSAGE_CLASS_REPORT_NOT_READ_REPORT = 0x10000000,
+ EMAIL_MESSAGE_CLASS_REPORT_READ_REPORT = 0x20000000,
+ EMAIL_MESSAGE_CLASS_REPORT_NON_DELIVERY_RECEIPT = 0x40000000,
+ EMAIL_MESSAGE_CLASS_REPORT_DELIVERY_RECEIPT = 0x80000000,
} email_message_class;
typedef enum{
char *server_mailbox_name; /**< Specifies the server mailbox.*/
char *server_mail_id; /**< Specifies the Server Mail ID.*/
char *message_id; /**< Specifies the message id */
- char *full_address_from; /**< Specifies the From Addr.*/
- char *full_address_reply; /**< Specifies the Reply to addr */
- char *full_address_to; /**< Specifies the To addr.*/
- char *full_address_cc; /**< Specifies the CC addr.*/
- char *full_address_bcc; /**< Specifies the BCC addr*/
+ int reference_mail_id; /**< Specifies the reference mail id */
+ char *full_address_from; /**< Specifies the From address.*/
+ char *full_address_reply; /**< Specifies the Reply to address */
+ char *full_address_to; /**< Specifies the To address.*/
+ char *full_address_cc; /**< Specifies the CC address.*/
+ char *full_address_bcc; /**< Specifies the BCC address*/
char *full_address_return; /**< Specifies the return Path*/
char *email_address_sender; /**< Specifies the email address of sender.*/
char *email_address_recipient; /**< Specifies the email address of recipients.*/
char *alias_sender; /**< Specifies the alias of sender. */
char *alias_recipient; /**< Specifies the alias of recipients. */
- int body_download_status; /**< Specifies the Text donwloaded or not.*/
+ int body_download_status; /**< Specifies the Text downloaded or not.*/
char *file_path_plain; /**< Specifies the path of text mail body.*/
char *file_path_html; /**< Specifies the path of HTML mail body.*/
- char *file_path_mime_entity; /**< Specifies the path of mime entity. */
+ char *file_path_mime_entity; /**< Specifies the path of MIME entity. */
int mail_size; /**< Specifies the Mail Size.*/
char flags_seen_field; /**< Specifies the seen flags*/
char flags_deleted_field; /**< Specifies the deleted flags*/
char flags_draft_field; /**< Specifies the draft flags*/
char flags_forwarded_field; /**< Specifies the forwarded flags*/
int DRM_status; /**< Has the mail DRM content? (1 : true, 0 : false) */
- email_mail_priority_t priority; /**< Specifies the priority of the mail.*/
- int save_status; /**< Specifies the save status*/
- int lock_status; /**< Specifies the Locked*/
- int report_status; /**< Specifies the Mail Report.*/
+ email_mail_priority_t priority; /**< Specifies the priority of the mail.*/ /* email_mail_priority_t */
+ email_mail_status_t save_status; /**< Specifies the save status*/ /* email_mail_status_t */
+ int lock_status; /**< Specifies the mail is locked*/
+ email_mail_report_t report_status; /**< Specifies the Mail Report.*/ /* email_mail_report_t */
int attachment_count; /**< Specifies the attachment count. */
int inline_content_count; /**< Specifies the inline content count. */
int thread_id; /**< Specifies the thread id for thread view. */
int thread_item_count; /**< Specifies the item count of specific thread. */
char *preview_text; /**< Specifies the preview body. */
- int meeting_request_status; /**< Specifies the status of meeting request. */
- email_message_class message_class;
- email_digest_type digest_type; /**< Sepeifies the digest algorithm*/
- email_smime_type smime_type; /**< Specifies the smime type. */
+ email_mail_type_t meeting_request_status; /**< Specifies the status of meeting request. */ /* email_mail_type_t */
+ int message_class; /**< Specifies the class of message for EAS. */ /* email_message_class */
+ email_digest_type digest_type; /**< Specifies the digest algorithm*/ /* email_digest_type */
+ email_smime_type smime_type; /**< Specifies the SMIME type. */ /* email_smime_type */
} email_mail_data_t;
/**
*/
typedef struct
{
- int mail_id; /**< Specifies the mail id.*/
- int account_id; /**< Specifies the account id.*/
- int mailbox_id; /**< Specifies the mailbox id.*/
- char from[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the from display name.*/
- char from_email_address[MAX_EMAIL_ADDRESS_LENGTH]; /**< Specifies the from email address.*/
- char recipients[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the recipients display name.*/
- char subject[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the subject.*/
- int is_text_downloaded; /**< Specifies the text donwloaded or not.*/
- time_t date_time; /**< Specifies the date time.*/
- char flags_seen_field; /**< Specifies the seen flags*/
- char flags_deleted_field; /**< Specifies the deleted flags*/
- char flags_flagged_field; /**< Specifies the flagged flags*/
- char flags_answered_field; /**< Specifies the answered flags*/
- char flags_recent_field; /**< Specifies the recent flags*/
- char flags_draft_field; /**< Specifies the draft flags*/
- char flags_forwarded_field; /**< Specifies the forwarded flags*/
- int priority; /**< Specifies the priority of Mails.*/
- int save_status; /**< Specifies the save status*/
- int is_locked; /**< Specifies the locked*/
- int is_report_mail; /**< Specifies the mail report.*/
- int recipients_count; /**< Specifies the number of to Recipients*/
- int has_attachment; /**< the mail has attachments or not[ 0: none, 1: over one] */
- int has_drm_attachment; /**< the mail has drm attachment or not*/
- char previewBodyText[MAX_PREVIEW_TEXT_LENGTH]; /**< text for preview body*/
- int thread_id; /**< thread id for thread view*/
- int thread_item_count; /**< item count of specific thread */
- int is_meeting_request; /**< Whether the mail is a meeting request or not */
- int message_class; /**< Specifies the message class */
- int smime_type; /**< Specifies the smime type */
+ int mail_id; /**< Specifies the mail id.*/
+ int account_id; /**< Specifies the account id.*/
+ int mailbox_id; /**< Specifies the mailbox id.*/
+ char full_address_from[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the from display name.*/
+ char email_address_sender[MAX_EMAIL_ADDRESS_LENGTH]; /**< Specifies the sender email address.*/
+ char email_address_recipient[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the recipients display name.*/
+ char subject[STRING_LENGTH_FOR_DISPLAY]; /**< Specifies the subject.*/
+ int body_download_status; /**< Specifies the text donwloaded or not.*/
+ time_t date_time; /**< Specifies the date time.*/
+ char flags_seen_field; /**< Specifies the seen flags*/
+ char flags_deleted_field; /**< Specifies the deleted flags*/
+ char flags_flagged_field; /**< Specifies the flagged flags*/
+ char flags_answered_field; /**< Specifies the answered flags*/
+ char flags_recent_field; /**< Specifies the recent flags*/
+ char flags_draft_field; /**< Specifies the draft flags*/
+ char flags_forwarded_field; /**< Specifies the forwarded flags*/
+ int DRM_status; /**< Has the mail DRM content? (1 : true, 0 : false) */
+ email_mail_priority_t priority; /**< Specifies the priority of Mails.*/ /* email_mail_priority_t*/
+ email_mail_status_t save_status; /**< Specifies the save status*/ /* email_mail_status_t */
+ int lock_status; /**< Specifies the locked*/
+ email_mail_report_t report_status; /**< Specifies the mail report.*/ /* email_mail_report_t */
+ int attachment_count; /**< Specifies the attachment count. */
+ int inline_content_count; /**< Specifies the inline content count. */
+ char preview_text[MAX_PREVIEW_TEXT_LENGTH]; /**< text for preview body*/
+ int thread_id; /**< thread id for thread view*/
+ int thread_item_count; /**< item count of specific thread */
+ email_mail_type_t meeting_request_status; /**< Whether the mail is a meeting request or not */ /* email_mail_type_t */
+ int message_class; /**< Specifies the message class */ /* email_message_class */
+ email_smime_type smime_type; /**< Specifies the smime type */ /* email_smime_type */
} email_mail_list_item_t;
/**
unsigned int answered : 1; /**< Reserved.*/
unsigned int recent : 1; /**< Reserved.*/
unsigned int draft : 1; /**< Specifies the draft email.*/
- unsigned int has_attachment : 1; /**< Reserved.*/
+ unsigned int attachment_count : 1; /**< Reserved.*/
unsigned int forwarded : 1; /**< Reserved.*/
unsigned int sticky : 1; /**< Sticky flagged mails cannot be deleted */
} email_mail_flag_t /* DEPRECATED */;
unsigned int report : 2; /**< Specifies the MDN/DSN mail. The value is a value of enumeration email_mail_report_t.*/
unsigned int drm : 1; /**< Specifies the drm mail.*/
unsigned int text_download_yn : 2; /**< body download y/n*/
-} email_extra_flag_t /* DEPRECATED */;
+} email_extra_flag_t DEPRECATED;
/**
* This structure is used to save the information of attachment.
int handle;
int account_id;
int mail_id;
- email_option_t options;
} send_mail;
struct _send_mail_saved
INCLUDE(FindPkgConfig)
-pkg_check_modules(core_pkgs REQUIRED glib-2.0 drm-client dlog dbus-1 gthread-2.0 uw-imap-toolkit vconf contacts-service secure-storage openssl accounts-svc mm-player mm-session devman_haptic alarm-service notification libcurl libxml-2.0 cert-svc)
+pkg_check_modules(core_pkgs REQUIRED glib-2.0 drm-client dlog dbus-1 gthread-2.0 uw-imap-toolkit vconf contacts-service secure-storage openssl accounts-svc mm-player mm-session devman_haptic alarm-service notification libcurl libxml-2.0 cert-svc cert-svc-vcore)
set(EXTRA_CFLAGS "")
FOREACH(flag ${core_pkgs_CFLAGS})
#include "email-core-mailbox.h"
#include "email-core-imap-mailbox.h"
+#ifdef __FEATURE_USING_ACCOUNT_SVC__
+#include "account.h"
+#endif /* __FEATURE_USING_ACCOUNT_SVC__ */
+
char *g_default_mbox_alias[MAILBOX_COUNT] =
{
EMAIL_INBOX_DISPLAY_NAME,
#endif
+#ifdef __FEATURE_USING_ACCOUNT_SVC__
+ {
+ int error_code;
+ email_account_t *account_to_be_deleted;
+
+ account_to_be_deleted = emcore_get_account_reference(account_id);
+ if (account_to_be_deleted && account_to_be_deleted->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
+ EM_DEBUG_LOG("Calling account_svc_delete with account_svc_id[%d]", account_to_be_deleted->account_svc_id);
+ error_code = account_connect();
+ EM_DEBUG_LOG("account_connect returns [%d]", error_code);
+ error_code = 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);
+ error_code = account_disconnect();
+ EM_DEBUG_LOG("account_disconnect returns [%d]", error_code);
+ }
+ }
+#endif
if (emcore_cancel_all_threads_of_an_account(account_id) < EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("There are some remaining jobs. I couldn't stop them.");
err = EMAIL_ERROR_CANNOT_STOP_THREAD;
#endif /* __FEATURE_BACKUP_ACCOUNT_ */
-
INTERNAL_FUNC int emcore_query_server_info(const char* domain_name, email_server_info_t **result_server_info)
{
EM_DEBUG_FUNC_BEGIN("domain_name [%s], result_server_info [%p]", domain_name, result_server_info);
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_set_operator [%d], input_sync_status [%d]", input_account_id, input_set_operator, input_sync_status);
int err = EMAIL_ERROR_NONE;
+ emstorage_account_tbl_t *account_tbl_data = NULL;
if (!emstorage_update_sync_status_of_account(input_account_id, input_set_operator, input_sync_status, true, &err))
EM_DEBUG_EXCEPTION("emstorage_update_sync_status_of_account failed [%d]", err);
+ if (account_tbl_data)
+ emstorage_free_account(&account_tbl_data, 1, NULL);
+
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
#include <openssl/err.h>
#include <cert-service.h>
#include <glib.h>
+#include <cert-svc/ccert.h>
+#include <cert-svc/cstring.h>
+#include <cert-svc/cpkcs12.h>
+#include <cert-svc/cinstance.h>
+#include <cert-svc/cprimitives.h>
#include "email-core-cert.h"
#include "email-core-mail.h"
+#include "email-core-utils.h"
#include "email-utilities.h"
#include "email-storage.h"
#include "email-debug-log.h"
#define READ_MODE "r"
#define WRITE_MODE "w"
-#define EMAIL_ERROR_CERTIFICATE_LOAD_FAIL 2300
-#define EMAIL_ERROR_FILE_NOT_OPEN 2301
-#define EMAIL_ERROR_INVALID_CERTIFICATE 2302
-
#define TRUSTED_USER "trusteduser/email/"
typedef enum {
return email_list;
}
-*/
-static int emcore_load_public_of_p7s(CERT_CONTEXT *context, char *public_cert_path, STACK_OF(X509) **certificates, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN();
-
- int ret = false;
- int err = EMAIL_ERROR_NONE;
- int cert_size = 0;
- unsigned char *cert_string = NULL;
- PKCS7 *pkcs7 = NULL;
- BIO *infile = NULL;
- X509 *cert = NULL;
- STACK_OF(X509) *certs = NULL;
-
- if (public_cert_path == NULL) {
- EM_DEBUG_EXCEPTION("Invalid parameter");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
- OpenSSL_add_all_algorithms();
-
- /* Open p7s file */
- infile = BIO_new_file(public_cert_path, READ_MODE);
- if (infile == NULL) {
- EM_DEBUG_EXCEPTION("File open failed [%s]", public_cert_path);
- err = EMAIL_ERROR_FILE_NOT_FOUND;
- goto FINISH_OFF;
- }
-
- /* Load the p7s file */
- pkcs7 = d2i_PKCS7_bio(infile, NULL);
- if (pkcs7 == NULL) {
- EM_DEBUG_EXCEPTION("smime.p7s load failed");
- err = EMAIL_ERROR_CERTIFICATE_LOAD_FAIL;
- goto FINISH_OFF;
- }
-
- /* Extract the signature in pkcs7 */
- certs = PKCS7_get0_signers(pkcs7, NULL, 0);
- if (certs == NULL) {
- EM_DEBUG_EXCEPTION("smime.p7s extract failed");
- err = EMAIL_ERROR_CERTIFICATE_LOAD_FAIL;
- goto FINISH_OFF;
- }
-
- /* Change from the p7s to the pem file */
- if (sk_X509_num(certs) > 1) {
- EM_DEBUG_EXCEPTION("Has one or more signature.\nIt is not support");
- err = EMAIL_ERROR_UNKNOWN;
- goto FINISH_OFF;
- }
-
- cert = sk_X509_value(certs, 0);
- cert_size = i2d_X509(cert, &cert_string);
- if (cert_size < 0) {
- EM_DEBUG_EXCEPTION("Fail to convert certificate");
- err = EMAIL_ERROR_UNKNOWN;
- goto FINISH_OFF;
- }
-
- /* Initilize the certificate and CERT_CONTEXT buffer */
- cert_string = (unsigned char *)em_malloc(sizeof(unsigned char *) * cert_size);
- if (cert_string == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- context->certBuf = (cert_svc_mem_buff *)em_malloc(sizeof(cert_svc_mem_buff));
- if (context->certBuf == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- /* Set CERT_CONTEXT structure */
- context->certBuf->data = cert_string;
- context->certBuf->size = cert_size;
-
- ret = true;
-
-FINISH_OFF:
-
- if (infile)
- BIO_free(infile);
-
- if (pkcs7)
- PKCS7_free(pkcs7);
-
- if (cert)
- X509_free(cert);
-
- if (ret) {
- if (certificates != NULL)
- *certificates = certs;
-
- if (err_code != NULL)
- *err_code = err;
- } else {
- if (certs)
- sk_X509_free(certs);
-
- EM_SAFE_FREE(cert_string);
- }
-
- EVP_cleanup();
-
- EM_DEBUG_FUNC_END();
-
- return ret;
-}
-/*
static char *emcore_store_public_certificate(STACK_OF(X509) *certificates, char *email_address, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
outfile = BIO_new_file(file_path, WRITE_MODE);
if (outfile == NULL) {
EM_DEBUG_EXCEPTION("File open failed[write mode]");
- err = EMAIL_ERROR_FILE_NOT_OPEN;
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
return ret;
}
+#if 0
+INTERNAL_FUNC int emcore_load_PFX_file(char *certificate, EVP_PKEY **pri_key, X509 **cert, STACK_OF(X509) **ca, int *err_code)
+{
+ EM_DEBUG_FUNC_BEGIN("certificate : [%s]", certificate);
+ int err = EMAIL_ERROR_NONE;
+ int ret = false;
+ int key_size = 0;
+ char *private_key = NULL;
+
+ /* Variable for certificate */
+ X509 *t_cert = NULL;
+// STACK_OF(X509) *t_ca = NULL;
+
+ /* Variable for private key */
+ EVP_PKEY *t_pri_key = NULL;
+ PKCS8_PRIV_KEY_INFO *p8inf = NULL;
+ const unsigned char *cu_private_key = NULL;
+
+ CertSvcString csstring;
+ CertSvcInstance cert_instance;
+ CertSvcCertificate csc_cert;
+ CertSvcCertificateList certificate_list;
+
+ if (certificate == NULL) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ /* Create instance */
+ err = certsvc_instance_new(&cert_instance);
+ if (err != CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_instance_new failed : [%d]", err);
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ /* Make the pfxID string */
+ err = certsvc_string_new(cert_instance, certificate, strlen(certificate), &csstring);
+ if (err != CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_string_new failed : [%d]", err);
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ /* Load the certificate list of pkcs12 type */
+ err = certsvc_pkcs12_load_certificate_list(cert_instance, csstring, &certificate_list);
+ if (err != CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_pkcs12_load_certificate_list failed : [%d]", err);
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ /* Get a certificate */
+ err = certsvc_certificate_list_get_one(certificate_list, 0, &csc_cert);
+ if (err != CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_certificate_list_get_one failed : [%d]", err);
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ /* Convert from char to X509 */
+ err = certsvc_certificate_dup_x509(csc_cert, &t_cert);
+ if (t_cert == NULL || err != CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_certificate_dup_x509 failed");
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ /* Get the private key */
+ err = certsvc_pkcs12_private_key_dup(cert_instance, csstring, &private_key, &key_size);
+ if (err != CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_pkcs12_private_key_dup failed : [%d]", err);
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ EM_DEBUG_LOG("private_key : [%s], key_size : [%d]", private_key, key_size);
+
+ /* Convert char to pkey */
+ cu_private_key = (const unsigned char *)private_key;
+ p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, &cu_private_key, key_size);
+ if (p8inf == NULL) {
+ EM_DEBUG_EXCEPTION("d2i_PKCS8_PRIV_KEY_INFO failed");
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+ t_pri_key = EVP_PKCS82PKEY(p8inf);
+
+ ret = true;
+
+FINISH_OFF:
+
+ if (true) {
+ if (cert)
+ *cert = t_cert;
+
+ if (pri_key)
+ *pri_key = t_pri_key;
+ } else {
+ X509_free(t_cert);
+ EVP_PKEY_free(t_pri_key);
+ }
+
+ if (p8inf)
+ PKCS8_PRIV_KEY_INFO_free(p8inf);
+
+ if (private_key)
+ EM_SAFE_FREE(private_key);
+
+ if (err_code)
+ *err_code = err;
+ return ret;
+}
+#endif
INTERNAL_FUNC int emcore_add_public_certificate(char *public_cert_path, char *save_name, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("Path [%s], filename [%s]", public_cert_path, save_name);
INTERNAL_FUNC int emcore_verify_signature(char *p7s_file_path, char *mime_entity, int *validity, int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("path[%s], mime_entiy[%s]", p7s_file_path, mime_entity);
+ EM_DEBUG_FUNC_BEGIN("path : [%s], mime_entity : [%s]", p7s_file_path, mime_entity);
int ret = false;
int err = EMAIL_ERROR_NONE;
- int i = 0, j = 0;
+ int t_validity = 0;
+ int flags = PKCS7_NOVERIFY;
- int p_validity = 0;
- int msg_len = 0;
- unsigned char *msg = NULL;
- int sig_len = 0;
- unsigned char *sig = NULL;
- unsigned char *tmp_sig = NULL;
- FILE *fp_msg = NULL;
- FILE *fp_sig = NULL;
- size_t f_size = 0;
+ BIO *bio_p7s = NULL;
- CERT_CONTEXT *context = NULL;
+ BIO *bio_indata = NULL;
- context = cert_svc_cert_context_init();
+ PKCS7 *pkcs7_p7s = NULL;
- if (!emcore_load_public_of_p7s(context, p7s_file_path, NULL, &err)) {
- EM_DEBUG_EXCEPTION("emcore_load_public_of_p7s failed");
- goto FINISH_OFF;
- }
+ /* Initialize */
+ OpenSSL_add_all_algorithms();
- fp_msg = fopen(mime_entity, "rb");
- fseek(fp_msg, 0L, SEEK_END);
- msg_len = ftell(fp_msg);
- fseek(fp_msg, 0L, SEEK_SET);
- msg = (unsigned char *)em_malloc(sizeof(unsigned char) * (msg_len + 1));
- if (msg == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
+ /* Open p7s file */
+ bio_p7s = BIO_new_file(p7s_file_path, INMODE);
+ if (!bio_p7s) {
+ EM_DEBUG_EXCEPTION("File open failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
- if ((f_size = fread(msg, sizeof(unsigned char), msg_len, fp_msg)) < 0) {
- EM_DEBUG_EXCEPTION("File read failed");
- goto FINISH_OFF;
- }
-
- fp_sig = fopen(p7s_file_path, "rb");
- fseek(fp_sig, 0L, SEEK_END);
- sig_len = ftell(fp_sig);
- fseek(fp_sig, 0L, SEEK_SET);
- sig = (unsigned char *)em_malloc(sizeof(unsigned char) * (sig_len + 1));
- if (sig == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
- tmp_sig = (unsigned char *)em_malloc(sizeof(unsigned char) * (sig_len + 1));
- if (tmp_sig == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
+ /* Open input data file */
+ bio_indata = BIO_new_file(mime_entity, INMODE);
+ if (!bio_p7s) {
+ EM_DEBUG_EXCEPTION("File open failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
- if ((f_size = fread(sig, sizeof(unsigned char), sig_len, fp_sig)) < 0) {
- EM_DEBUG_EXCEPTION("File read failed");
+ /* Load the p7s file */
+ pkcs7_p7s = d2i_PKCS7_bio(bio_p7s, NULL);
+ if (!pkcs7_p7s) {
+ EM_DEBUG_EXCEPTION("d2i_PKCS7_bio failed");
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
goto FINISH_OFF;
}
- for(i = 0; i < sig_len; i++) {
- if(sig[i] != '\n') {
- tmp_sig[j] = sig[i];
- j++;
- }
- }
-
- err = cert_svc_verify_signature(context, msg, msg_len, tmp_sig, NULL, &p_validity);
- if (err != CERT_SVC_ERR_NO_ERROR) {
- EM_DEBUG_EXCEPTION("Verify signature failed");
+ if (!PKCS7_verify(pkcs7_p7s, NULL, NULL, bio_indata, NULL, flags)) {
+ EM_DEBUG_EXCEPTION("PKCS7_verify failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
+ t_validity = 1;
+
ret = true;
FINISH_OFF:
- EM_SAFE_FREE(tmp_sig);
+ EVP_cleanup();
- EM_SAFE_FREE(sig);
+ if (pkcs7_p7s)
+ PKCS7_free(pkcs7_p7s);
- EM_SAFE_FREE(msg);
+ if (bio_p7s)
+ BIO_free(bio_p7s);
- if (fp_sig != NULL)
- fclose(fp_sig);
-
- if (fp_msg != NULL)
- fclose(fp_msg);
+ if (bio_indata)
+ BIO_free(bio_indata);
- cert_svc_cert_context_final(context);
+ if (validity)
+ *validity = t_validity;
-
-
- if (err_code != NULL)
+ if (err_code)
*err_code = err;
EM_DEBUG_FUNC_END();
EM_DEBUG_LOG(">>>>>>>>>>>>>>Got SEND event_data>>>>>>>>>>>>>>>>");
send_thread_run = 1;
g_client_run = 1;
- email_option_t *option = NULL;
if (!emnetwork_check_network_status( &err)) {
EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
case EMAIL_EVENT_SEND_MAIL:
emdevice_set_dimming_on_off(false, NULL);
- option = (email_option_t *)event_data.event_param_data_1;
- if (!emcore_send_mail(event_data.account_id, event_data.event_param_data_5, event_data.event_param_data_4, option, &err))
+ if (!emcore_send_mail(event_data.account_id, event_data.event_param_data_5, event_data.event_param_data_4, &err))
EM_DEBUG_EXCEPTION("emcore_send_mail failed [%d]", err);
- if (option)
- EM_SAFE_FREE(option->display_name_from);
emdevice_set_dimming_on_off(true, NULL);
break;
- case EMAIL_EVENT_SEND_MAIL_SAVED: /* send mails to been saved in offline-mode */
+ case EMAIL_EVENT_SEND_MAIL_SAVED: /* send mails to been saved in off-line mode */
emdevice_set_dimming_on_off(false, NULL);
-
- email_option_t *option = (email_option_t *)event_data.event_param_data_1;
- if (!emcore_send_saved_mail(event_data.account_id, event_data.event_param_data_3, option, &err))
+ if (!emcore_send_saved_mail(event_data.account_id, event_data.event_param_data_3, &err))
EM_DEBUG_EXCEPTION("emcore_send_saved_mail failed - %d", err);
-
- if (option)
- EM_SAFE_FREE(option->display_name_from);
emdevice_set_dimming_on_off(true, NULL);
break;
+
#ifdef __FEATURE_LOCAL_ACTIVITY__
- case EMAIL_EVENT_LOCAL_ACTIVITY: {
- emdevice_set_dimming_on_off(false, NULL);
- emstorage_activity_tbl_t *local_activity = NULL;
- int activity_id_count = 0;
- int activity_chunk_count = 0;
- int *activity_id_list = NULL;
- int i = 0;
-
- if (false == emstorage_get_activity_id_list(event_data.account_id, &activity_id_list, &activity_id_count, ACTIVITY_SAVEMAIL, ACTIVITY_DELETEMAIL_SEND, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_activity_id_list failed [%d]", err);
- }
- else {
- for (i = 0; i < activity_id_count; ++i) {
- if ((false == emstorage_get_activity(event_data.account_id, activity_id_list[i], &local_activity, &activity_chunk_count, true, &err)) || (NULL == local_activity) || (0 == activity_chunk_count)) {
- EM_DEBUG_EXCEPTION(" emstorage_get_activity Failed [ %d] or local_activity is NULL [%p] or activity_chunk_count is 0[%d]", err, local_activity, activity_chunk_count);
- }
- else {
- EM_DEBUG_LOG("Found local activity type - %d", local_activity[0].activity_type);
- switch (local_activity[0].activity_type) {
- case ACTIVITY_SAVEMAIL: {
- if (!emcore_sync_mail_from_client_to_server(event_data.account_id, local_activity[0].mail_id, &err)) {
- EM_DEBUG_EXCEPTION("emcore_sync_mail_from_client_to_server failed - %d ", err);
- }
- }
- break;
-
- case ACTIVITY_DELETEMAIL_SEND: /* New Activity Type Added for Race Condition and Crash Fix */ {
- if (!emcore_delete_mail(local_activity[0].account_id,
- &local_activity[0].mail_id,
- EMAIL_DELETE_FOR_SEND_THREAD,
- true,
- EMAIL_DELETED_BY_COMMAND,
- false,
- &err)) {
- EM_DEBUG_LOG("\t emcore_delete_mail failed - %d", err);
- }
+ case EMAIL_EVENT_LOCAL_ACTIVITY: {
+ emdevice_set_dimming_on_off(false, NULL);
+ emstorage_activity_tbl_t *local_activity = NULL;
+ int activity_id_count = 0;
+ int activity_chunk_count = 0;
+ int *activity_id_list = NULL;
+ int i = 0;
+
+ if (false == emstorage_get_activity_id_list(event_data.account_id, &activity_id_list, &activity_id_count, ACTIVITY_SAVEMAIL, ACTIVITY_DELETEMAIL_SEND, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_activity_id_list failed [%d]", err);
+ }
+ else {
+ for (i = 0; i < activity_id_count; ++i) {
+ if ((false == emstorage_get_activity(event_data.account_id, activity_id_list[i], &local_activity, &activity_chunk_count, true, &err)) || (NULL == local_activity) || (0 == activity_chunk_count)) {
+ EM_DEBUG_EXCEPTION(" emstorage_get_activity Failed [ %d] or local_activity is NULL [%p] or activity_chunk_count is 0[%d]", err, local_activity, activity_chunk_count);
+ }
+ else {
+ EM_DEBUG_LOG("Found local activity type - %d", local_activity[0].activity_type);
+ switch (local_activity[0].activity_type) {
+ case ACTIVITY_SAVEMAIL: {
+ if (!emcore_sync_mail_from_client_to_server(event_data.account_id, local_activity[0].mail_id, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_sync_mail_from_client_to_server failed - %d ", err);
}
- break;
-
- default: {
- EM_DEBUG_LOG(">>>> No such Local Activity Handled by this thread [ %d ] >>> ", local_activity[0].activity_type);
+ }
+ break;
+
+ case ACTIVITY_DELETEMAIL_SEND: /* New Activity Type Added for Race Condition and Crash Fix */ {
+ if (!emcore_delete_mail(local_activity[0].account_id,
+ &local_activity[0].mail_id,
+ EMAIL_DELETE_FOR_SEND_THREAD,
+ true,
+ EMAIL_DELETED_BY_COMMAND,
+ false,
+ &err)) {
+ EM_DEBUG_LOG("\t emcore_delete_mail failed - %d", err);
}
- break;
}
+ break;
- emstorage_free_local_activity(&local_activity, activity_chunk_count, NULL);
-
- if (g_save_local_activity_run == 1) {
- EM_DEBUG_LOG(" Network event_data found.. Local sync Stopped..! ");
- break;
+ default: {
+ EM_DEBUG_LOG(">>>> No such Local Activity Handled by this thread [ %d ] >>> ", local_activity[0].activity_type);
}
+ break;
}
+ emstorage_free_local_activity(&local_activity, activity_chunk_count, NULL);
+
+ if (g_save_local_activity_run == 1) {
+ EM_DEBUG_LOG(" Network event_data found.. Local sync Stopped..! ");
+ break;
+ }
}
- if (false == emstorage_free_activity_id_list(activity_id_list, &err)) {
- EM_DEBUG_LOG("emstorage_free_activity_id_list failed");
- }
- }
- emdevice_set_dimming_on_off(true, NULL);
+ }
+ if (false == emstorage_free_activity_id_list(activity_id_list, &err)) {
+ EM_DEBUG_LOG("emstorage_free_activity_id_list failed");
+ }
}
- break;
+
+ emdevice_set_dimming_on_off(true, NULL);
+ }
+ break;
#endif /* __FEATURE_LOCAL_ACTIVITY__ */
default:
- EM_DEBUG_LOG("Others not supported by Send Thread..! ");
+ EM_DEBUG_LOG("Others not supported by Send Thread..! [%d]", event_data.type);
break;
-
}
ENTER_RECURSIVE_CRITICAL_SECTION(_send_event_queue_lock);
-
memset(g_send_event_que+g_send_active_que, 0x00, sizeof(email_event_t));
-
LEAVE_RECURSIVE_CRITICAL_SECTION(_send_event_queue_lock);
FINISH_OFF:
if (!emstorage_close(&err))
EM_DEBUG_EXCEPTION("emstorage_close falied [%d]", err);
- EM_DEBUG_FUNC_END();
+ EM_DEBUG_FUNC_END("err [%d]", err);
return NULL;
}
}
for (counter = 0; counter < mailbox_count; counter++) {
+
+ EM_DEBUG_LOG("maiblox_name [%s], mailbox_id [%d], mailbox_type [%d]", mailbox_tbl_list[counter].mailbox_name, mailbox_tbl_list[counter].mailbox_id, mailbox_tbl_list[counter].mailbox_type);
+
if ( mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_ALL_EMAILS
|| mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_TRASH
/*|| mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX */)
EM_DEBUG_LOG("Skipped for all emails or trash");
else if (!mailbox_tbl_list[counter].local_yn) {
- EM_DEBUG_LOG("..........syncing %s mailbox( mailbox_id = %d)......", mailbox_tbl_list[counter].mailbox_name, mailbox_tbl_list[counter].mailbox_id);
+ EM_DEBUG_LOG("[%s] Syncing...", mailbox_tbl_list[counter].mailbox_name);
#ifdef __FEATURE_KEEP_CONNECTION__
if (!emcore_sync_header((mailbox_tbl_list + counter) , mailbox_tbl_spam, NULL, &uid_list, &unread, &err)) {
#else /* __FEATURE_KEEP_CONNECTION__ */
EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>");
goto FINISH_OFF;
}
-
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SEARCH_RESULT, &search_mailbox, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
+
+ search_mailbox = em_malloc(sizeof(emstorage_mailbox_tbl_t));
+ if (search_mailbox == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
if (!emstorage_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err))
EM_DEBUG_EXCEPTION("emstorage_notify_network_event [NOTI_SEARCH_ON_SERVER_FAIL] Failed >>>>");
goto FINISH_OFF;
}
+ search_mailbox->account_id = account_id;
+ search_mailbox->mailbox_id = mailbox_id;
+ 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(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 (!emstorage_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, handle_to_be_published, err))
break;
case EMAIL_EVENT_DELETE_MAIL: /* delete mails */
- event_handler_EMAIL_EVENT_DELETE_MAIL(event_data.account_id, (int *)event_data.event_param_data_3, event_data.event_param_data_4, &err);
+ event_handler_EMAIL_EVENT_DELETE_MAIL(event_data.account_id, (int*)event_data.event_param_data_3, event_data.event_param_data_4, &err);
EM_SAFE_FREE(event_data.event_param_data_3);
break;
PARAMETER *param = body->disposition.parameter;
while (param) {
- EM_DEBUG_LOG("param->attribute [%s], param->value [%s]", param->attribute, param->value);
+ EM_DEBUG_LOG("param->attribute [%s], param->value [%s]", param->attribute, param->value);
if (!strcasecmp(param->attribute, "filename")) { /* attribute is "filename" */
strncpy(filename, param->value, MAX_PATH);
}
else {
/* download all */
- EM_DEBUG_LOG("%d : body->size.bytes[%ld]", counter+1, body->size.bytes);
- multi_part_body_size = multi_part_body_size + body->size.bytes;
+ EM_DEBUG_LOG("%d : body->size.bytes[%ld]", counter+1, body->size.bytes);
+ multi_part_body_size = multi_part_body_size + body->size.bytes;
}
part_child = part_child->next;
counter++;
goto FINISH_OFF;
}
- if (account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC)
- from_server = EMAIL_DELETE_LOCALLY;
-
FINISH_OFF_IF_CANCELED;
if (from_server == EMAIL_DELETE_LOCALLY) /* Delete mails from local storage*/ {
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_ids[%p], num [%d], noti_param_1 [%d], noti_param_2 [%d], err_code[%p]", account_id, mail_ids, num, noti_param_1, noti_param_2, num, err_code);
int ret = false, err = EMAIL_ERROR_NONE, i;
- emstorage_mail_tbl_t *result_mail_list;
+ emstorage_mail_tbl_t *result_mail_list = NULL;
char mail_id_string[10], *noti_param_string = NULL, buf[512] = {0, };
/* Getting mail list by using select mail_id [in] */
int mail_id = 0;
int msgno = 0;
void *stream = NULL;
- email_internal_mailbox_t mailbox_data;
+ email_internal_mailbox_t mailbox_data = { 0, };
emstorage_mail_tbl_t *mail_tbl_data = NULL;
if (!input_account || !input_mail_ids) {
}
if (stream == NULL) {
- if (!emcore_connect_to_remote_mailbox(input_account->account_id, mail_tbl_data->mailbox_id , (void **)&stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(input_account->account_id, 0, (void **)&stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
mailbox_data.mail_stream = stream;
mailbox_data.account_id = input_account->account_id;
- mailbox_data.mailbox_id = mail_tbl_data->mailbox_id;
+ mailbox_data.mailbox_id = mail_tbl_data->mailbox_id;
}
if (mailbox_data.user_data != NULL) {
if(filter_list)
emstorage_free_list_filter(&filter_list, filter_count);
+ EM_SAFE_FREE(conditional_clause_string);
EM_SAFE_FREE(result_mail_id_list);
EM_DEBUG_FUNC_END("err [%d]", err);
emstorage_free_list_filter(&filter_list, filter_count);
EM_SAFE_FREE(result_mail_id_list);
+ EM_SAFE_FREE(conditional_clause_string);
EM_DEBUG_FUNC_END("err [%d]", err);
EM_DEBUG_EXCEPTION("emcore_save_mail_file failed [%d]", err);
goto FINISH_OFF2;
}
- EM_SAFE_FREE(input_mail_data->file_path_html);
- input_mail_data->file_path_html = EM_SAFE_STRDUP(filename_buf);
+ EM_SAFE_FREE(input_mail_data->file_path_mime_entity);
+ input_mail_data->file_path_mime_entity = EM_SAFE_STRDUP(filename_buf);
}
if (input_attachment_data_list && input_attachment_count) {
return err;
}
-INTERNAL_FUNC int emcore_fetch_flags(int account_id, int mail_id, email_mail_flag_t *mail_flag, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN();
-
- int ret = false;
- int err = 0;
- emstorage_mail_tbl_t *mail = NULL;
-
- EM_IF_NULL_RETURN_VALUE(mail_flag, false);
- if (account_id < FIRST_ACCOUNT_ID || mail_id < 1) {
- EM_DEBUG_EXCEPTION("emcore_fetch_flags : Invalid Param ");
- goto FINISH_OFF;
- }
-
- if (!emstorage_get_mail_field_by_id(mail_id, RETRIEVE_FLAG, &mail, true, &err) || !mail) {
- EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_id failed - %d ", err);
-
- goto FINISH_OFF;
- }
-
- if (!em_convert_mail_tbl_to_mail_flag(mail, mail_flag, &err)) {
- EM_DEBUG_EXCEPTION("em_convert_mail_flag_to_int failed - %d ", err);
- goto FINISH_OFF;
- }
-
- ret = true;
-
-FINISH_OFF:
- if(mail)
- emstorage_free_mail(&mail, 1, &err);
-
- if (err_code != NULL)
- *err_code = err;
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return ret;
-}
-/* description : modify flag of msgno.
- return 1(success), 0(failure)
- */
-INTERNAL_FUNC int emcore_modify_flag(int mail_id, email_mail_flag_t new_flag, int sticky_flag, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("mail_id[%d], err_code[%p]", mail_id, err_code);
-
- int ret = false;
- int err = EMAIL_ERROR_NONE;
- int old_seen, new_seen;
-
- emstorage_mail_tbl_t *mail = NULL;
- email_mail_flag_t old_flag;
-
- if (!emstorage_get_mail_field_by_id(mail_id, RETRIEVE_FLAG, &mail, true, &err) || !mail) {
- EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_id failed [%d]", err);
-
- goto FINISH_OFF;
- }
-
- if (!em_convert_mail_tbl_to_mail_flag(mail, &old_flag, &err)) {
- EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_flag failed [%d]", err);
- goto FINISH_OFF;
- }
-
- old_seen = mail->flags_seen_field;
- new_seen = new_flag.seen;
-
- if (!em_convert_mail_flag_to_mail_tbl(&new_flag, mail, &err)) {
- EM_DEBUG_EXCEPTION("em_convert_mail_flag_to_mail_tbl failed [%d]", err);
- goto FINISH_OFF;
- }
-
- mail->lock_status = sticky_flag;
-
- if (!emstorage_change_mail_field(mail_id, UPDATE_FLAG, mail, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
-
-
- goto FINISH_OFF;
- }
-
- if (old_seen != new_seen && new_seen == 0)
- emcore_delete_notification_for_read_mail(mail_id);
-
- emcore_check_unread_mail();
-
- ret = true;
-
-FINISH_OFF:
- if (mail)
- emstorage_free_mail(&mail, 1, NULL);
-
- if (err_code)
- *err_code = err;
- EM_DEBUG_FUNC_END("err [%d]", err);
- return ret;
-}
INTERNAL_FUNC int emcore_set_flags_field(int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code)
{
return ret;
}
-
-/* description : modify extra flag of msgno.
- return 0(success), -1(failure)
- */
-INTERNAL_FUNC int emcore_modify_extra_flag(int mail_id, email_extra_flag_t new_flag, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("mail_id[%d], err_code[%p]", mail_id, err_code);
-
- int ret = false;
- int err = EMAIL_ERROR_NONE;
- emstorage_mail_tbl_t mail;
-
- memset(&mail, 0x00, sizeof(emstorage_mail_tbl_t));
-
- mail.mail_id = mail_id;
- mail.save_status = new_flag.status;
- mail.lock_status = new_flag.report;
- mail.lock_status = new_flag.lock;
- mail.priority = new_flag.priority;
- mail.DRM_status = new_flag.drm;
-
- if (!emstorage_change_mail_field(mail_id, UPDATE_EXTRA_FLAG, &mail, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
-
- goto FINISH_OFF;
- }
-
- ret = true;
-
-FINISH_OFF:
- if (err_code != NULL)
- *err_code = err;
- EM_DEBUG_FUNC_END("err [%d]", err);
- return ret;
-}
-
-
int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, int *downloded_size, int *result_total_body_size, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("stream[%p], msgno[%d], limited_size[%d], err_code[%p]", stream, msgno, limited_size, err_code);
email_account_t *ref_account = NULL;
int account_id = 0;
int msgno = 0;
- email_mail_flag_t new_flag = {0};
char set_flags[100] = { 0, };
char clear_flags[100] = { 0, };
char tmp[100] = { 0, };
}
account_id = mail->account_id;
- em_convert_mail_tbl_to_mail_flag(mail, &new_flag, NULL);
if (!(ref_account = emcore_get_account_reference(account_id))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
sprintf (tmp, "%d", msgno);
- if (new_flag.seen)
+ if (mail->flags_seen_field)
sprintf(set_flags, "\\Seen");
else
sprintf(clear_flags, "\\Seen");
- if (new_flag.answered)
+ if (mail->flags_answered_field)
sprintf(set_flags, "%s \\Answered", set_flags);
else
sprintf(clear_flags, "%s \\Answered", clear_flags);
- if (new_flag.flagged)
+ if (mail->flags_flagged_field)
sprintf(set_flags, "%s \\Flagged", set_flags);
else
sprintf(clear_flags, "%s \\Flagged", clear_flags);
- if (new_flag.forwarded)
+ if (mail->flags_forwarded_field)
sprintf(set_flags, "%s $Forwarded", set_flags);
else
sprintf(clear_flags, "%s $Forwarded", clear_flags);
FINISH_OFF:
- if (stream) emcore_close_mailbox(account_id, stream);
- if (mail) emstorage_free_mail(&mail, 1, NULL);
+ if (stream)
+ emcore_close_mailbox(account_id, stream);
+
+ if (mail)
+ emstorage_free_mail(&mail, 1, NULL);
if (err_code != NULL)
*err_code = err;
email_account_t *ref_account = NULL;
int account_id = 0;
int msgno = 0;
- email_mail_flag_t new_flag;
char set_flags[100];
char clear_flags[100];
char tmp[100];
goto FINISH_OFF;
}
- /* account_id = mail->account_id; */
- em_convert_mail_tbl_to_mail_flag(mail, &new_flag, NULL);
-
if (!emcore_check_thread_status()) {
err = EMAIL_ERROR_CANCELLED;
goto FINISH_OFF;
memset(set_flags, 0x00, 100);
memset(clear_flags, 0x00, 100);
- if (new_flag.seen)
+ if (mail->flags_seen_field)
sprintf(set_flags, "\\Seen");
else
sprintf(clear_flags, "\\Seen");
temp_mail_tbl_data->flags_draft_field = mail_cache_element->draft;
temp_mail_tbl_data->flags_forwarded_field = input_uid_elem->flag.forwarded;
temp_mail_tbl_data->priority = priority;
- temp_mail_tbl_data->report_status = (req_read_receipt ? 3 : 0);
+ temp_mail_tbl_data->report_status = (req_read_receipt ? EMAIL_MAIL_REQUEST_MDN : 0);
temp_mail_tbl_data->attachment_count = 0;
emcore_fill_address_information_of_mail_tbl(temp_mail_tbl_data);
if (!uid_list) {
EM_DEBUG_EXCEPTION(" uid_list[%p]\n", uid_list);
-
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
/* Content-Type: IMAGE/octet-stream; name = Default.png */
/* Content-Transfer-Encoding: BASE64 */
-/* Content-ID: <4b0d6810b17291f9438783a8eb9d5228@org.tizen.email> */
+/* Content-ID: <4b0d6810b17291f9438783a8eb9d5228@com.tizen.email> */
/* Content-Disposition: inline; filename = Default.png */
static int emcore_parse_image_part_for_partial_body(char *header_start_string, char *start_header, char *boundary_string, char *bufsendforparse, email_image_data *image_data, int body_size)
int j = 0;
int i32_index = 0, temp_string_index = 0;
int no_alternative_part_flag = 0;
- int dec_len = 0, response_buffer_length = 0, mailparselen = 0, image_length = 0, tempmailparselen = 0;
+ int dec_len = 0, response_buffer_length = 0, image_length = 0, tempmailparselen = 0;
int temp_count = 0, total_mail_size = 0, attachment_num, body_size = 0, total_mail_size_except_attach = 0;
int total_parsed_len_per_uid = 0, total_parsed_len = 0;
unsigned long uidno = 0;
int no_html = 0;
char *temp_alternative_plain_header = NULL;
- p = (char *)strstr(response_buffer, " {");
+ p = (char *)strstr(response_buffer, "> {");
if (p != NULL){
EM_DEBUG_LOG("Getting the body size");
- p += strlen(" {");
+ p += strlen("> {");
s = p;
temp_string_index = 0;
/* goto FINISH_OFF; */
}
- /* Find next line */
- tempmailparselen = 0;
- while (tempmailparselen < response_buffer_length && response_buffer[tempmailparselen] != LF)
- tempmailparselen++;
- tempmailparselen++;
+ /* Find data line : 2 is CRLF, 1 is } */
+ EM_DEBUG_LOG("temp_string_index : [%d]", temp_string_index);
+ tempmailparselen = (p - response_buffer) + temp_string_index + 2 + 1;
if (imap_response->buflen < (total_parsed_len + body_size)){
err = EMAIL_ERROR_CONNECTION_BROKEN;
}
- /* Find next line. */
- mailparselen = 0;
-
- while (mailparselen < response_buffer_length && response_buffer[mailparselen] != LF)
- mailparselen++;
-
- mailparselen++;
-
/* Removed the response header and send the buffer for parsing */
- response_buffer = response_buffer + mailparselen;
- response_buffer_length = response_buffer_length - mailparselen;
+ response_buffer = response_buffer + tempmailparselen;
+ response_buffer_length = response_buffer_length - tempmailparselen;
bufsendforparse = em_malloc(body_size + 1); /* old */
/* bufsendforparse = em_malloc(response_buffer_length + 1); */ /* new */
}
else{ /* Partial body has headers with Content-Type: text/html or Content-Type: text/plain */
no_alternative_part_flag = 0;
- if (((temp_alternative_plain_header = (char *)strcasestr(p, "Content-type: multipart/alternative")) != NULL)){ /* Found 'alternative' */
- if (((temp_content_type1 = (char *)strcasestr(p, "Content-type: text/plain")) != NULL)){
+ if (((temp_alternative_plain_header = (char *)strcasestr(p, "Content-type: multipart/alternative")) != NULL)) { /* Found 'alternative' */
+ if (((temp_content_type1 = (char *)strcasestr(p, "Content-type: text/plain")) != NULL)) {
if (temp_content_type1 < temp_alternative_plain_header) /* This part is text/plain not alternative. */
no_html = 1;
no_alternative_part_flag = 1;
if (!emstorage_change_mail_field(mail->mail_id, UPDATE_PARTIAL_BODY_DOWNLOAD, mail, true, &err))
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed - %d", err);
-NEXTUIDPARSING:
-
+NEXTUIDPARSING:
response_buffer = response_buffer + body_size; /* Set pointer for next mail body. */
/* Find end of body */
response_buffer = response_buffer + 3;
total_parsed_len_per_uid = body_size+tempmailparselen + 3;
}
- else
+ else {
EM_DEBUG_EXCEPTION("Mail response end could not found, - %c : %c : %c", response_buffer[0], response_buffer[1], response_buffer[2]);
-
+ }
+
EM_SAFE_FREE(bufsendforparse);
memset(text_html, 0, input_download_size+1);
int bytes_copied = 0;
int temp_body_buffer_size = 0;
int flags = 0;
+ int count = 0;
int allocated_buffer_size = (BULK_PARTIAL_BODY_DOWNLOAD_COUNT + 2) * input_download_size ;
retPartialBuffer = (email_partial_buffer *)em_malloc(sizeof(email_partial_buffer));
return NIL;
}
- while (nstream){
+ while (nstream){
if (!(pline = net_getline(nstream))) {
EM_DEBUG_EXCEPTION("net_getline failed...");
EM_SAFE_FREE(retPartialBuffer->buffer);
return NIL;
}
-
linelen = strlen(pline);
if (strcasestr(pline, "BODYSTRUCTURE") != NULL) {
temp_body_buffer_size = 0;
flags = 0;
+ count++;
+ } else if (strstr(pline, "> {") != NULL) {
+ temp_body_buffer_size = 0;
+ flags = 0;
} else {
temp_body_buffer_size = temp_body_buffer_size + linelen + 2;
}
}
if (temp_body_buffer_size <= input_download_size) {
+ if (allocated_buffer_size < (bytes_copied + linelen)) {
+ allocated_buffer_size = allocated_buffer_size + (BULK_PARTIAL_BODY_DOWNLOAD_COUNT - count) * input_download_size;
+ retPartialBuffer->buffer = (char *)realloc(retPartialBuffer->buffer, allocated_buffer_size);
+ if (NULL == retPartialBuffer->buffer) {
+ EM_DEBUG_EXCEPTION("realloc failed");
+ EM_SAFE_FREE(retPartialBuffer);
+ return NIL;
+ }
+ }
memcpy(retPartialBuffer->buffer + bytes_copied, pline, linelen);
bytes_copied += linelen;
memcpy(retPartialBuffer->buffer + bytes_copied, CRLF_STRING, 2);
memset(mmsg, 0x00, sizeof(struct _m_mesg));
- /* 1. parse the first found heade */
+ /* 1. parse the first found header */
EM_DEBUG_LOG(">>>>>> 1. parse the first found header");
if (!emcore_mime_parse_header(stream, is_file, &mmsg->rfc822header, &mmsg->header, err_code)) {
EM_SAFE_FREE(mmsg);
return false;
}
- /* 2. parse bod */
+ /* 2. parse body */
EM_DEBUG_LOG(">>>>>> 2. parse body");
if (mmsg && mmsg->header && mmsg->header->part_header && mmsg->header->part_header->parameter) {
EM_DEBUG_LOG("name[%s]", mmsg->header->part_header->parameter->name);
return false;
}
- /* 3. free memor */
+ /* 3. free memory */
EM_DEBUG_LOG(">>>>>> 3. free memory");
if (mmsg && mmsg->header && mmsg->header->part_header && mmsg->header->part_header->parameter) {
EM_DEBUG_LOG("name[%s]", mmsg->header->part_header->parameter->name);
if (cnt_info->file) {
cnt_info->file->type = 2;
cnt_info->file->name = EM_SAFE_STRDUP(attachment_name);
- emcore_mime_get_content_data(stream, is_file, false, NULL, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code);
+ if (!emcore_mime_get_content_data(stream, is_file, false, NULL, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code)) {
+ EM_DEBUG_EXCEPTION("emcore_mime_get_content_data failed : [%d]", err_code);
+ return false;
+ }
cnt_info->file->save = holder;
cnt_info->file->size = size;
}
if (cnt_info->grab_type & GRAB_TYPE_TEXT) {
/* EM_DEBUG_LINE */
/* get content data. content data is saved in file */
- emcore_mime_get_content_data(stream, is_file, true, NULL, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code);
+ if (!emcore_mime_get_content_data(stream, is_file, true, NULL, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code)) {
+ EM_DEBUG_EXCEPTION("emcore_mime_get_content_data failed : [%d]", err_code);
+ return false;
+ }
EM_DEBUG_LOG("After emcore_mime_get_content_data");
if (!attachment_name)
attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_ID, err_code);
if (!attachment_name)
- attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_LOCATION, err_code);
+ attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_NAME, err_code);
content_disposition_type = 1;
} else if (!strcasecmp(content_disposition, "attachment")) {
- if (!attachment_name) {
+ if (!attachment_name)
+ attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_NAME, err_code);
+ if (!attachment_name)
attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_FILENAME, err_code);
- EM_DEBUG_LOG_MIME(">> attachment = [%s]", attachment_name ? attachment_name : NIL);
- }
+
content_disposition_type = 2;
}
} else if (strstr(content_type, "PKCS7")) {
attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_NAME, err_code);
EM_DEBUG_LOG_MIME(">> attachment = [%s]", attachment_name ? attachment_name : NIL);
- }
+ }
if (!emcore_check_thread_status()) {
if (err_code != NULL)
return false;
}
+ EM_DEBUG_LOG("attachment_name : [%s]", attachment_name);
/* get content and content information */
if (!attachment_name) { /* text */
- /* get content by buffe */
+ /* get content by buffer */
EM_DEBUG_LOG_MIME("attachment_name is NULL. It's a text message");
- emcore_mime_get_content_data(stream, is_file, true, boundary_str, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code);
+ if (!emcore_mime_get_content_data(stream, is_file, true, boundary_str, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code)) {
+ EM_DEBUG_EXCEPTION("emcore_mime_get_content_data failed [%d]", err_code);
+ return false;
+ }
EM_DEBUG_LOG("After emcore_mime_get_content_data");
if ( (cnt_info->grab_type & GRAB_TYPE_ATTACHMENT) || (*file)->type == 1) {
/* get content by file */
EM_DEBUG_LOG_MIME("Trying to get content");
- emcore_mime_get_content_data(stream, is_file, false, boundary_str, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code);
+ if (!emcore_mime_get_content_data(stream, is_file, false, boundary_str, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code)) {
+ EM_DEBUG_EXCEPTION("emcore_mime_get_content_data failed [%d]", err_code);
+ EM_DEBUG_FUNC_END("false");
+ return false;
+ }
(*file)->save = holder;
}
else {
/* only get content size */
EM_DEBUG_LOG_MIME("Pass downloading");
- emcore_mime_get_content_data(stream, is_file, false, boundary_str, content_encoding, &end_of_parsing, SAVE_TYPE_SIZE, NULL, &size, NULL, err_code);
+ if (!emcore_mime_get_content_data(stream, is_file, false, boundary_str, content_encoding, &end_of_parsing, SAVE_TYPE_SIZE, NULL, &size, NULL, err_code)) {
+ EM_DEBUG_EXCEPTION("emcore_mime_get_content_data failed [%d]", err_code);
+ EM_DEBUG_FUNC_END("false");
+ return false;
+ }
+
(*file)->save = NULL;
}
}
if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
+ if (err_code != NULL)
+ *err_code = EMAIL_ERROR_CANCELLED;
EM_DEBUG_EXCEPTION("EMAIL_ERROR_CANCELLED");
EM_DEBUG_FUNC_END("false");
- return false;
- }
+ return false;
+ }
if (!nested->body)
nested->body = tmp_body;
else { /* Content-Type Parameter (format : "name =value" */
if (emcore_mime_get_param_from_str(p_val, &p, err_code))
emcore_mime_add_param_to_list(&((*header)->parameter), p, err_code);
+ else /* name= CRLF value */ {
+ struct _parameter *t = (*header)->parameter;
+ while (t && t->next) {
+ t = t->next;
+ }
+
+ EM_DEBUG_LOG("name : [%s]", t->name);
+ EM_DEBUG_LOG("value : [%s]", t->value);
+
+ if (t->value == NULL) {
+ char *pointer = NULL;
+
+ if (strlen(p_val) > 0) {
+ if ((pointer = strchr(p_val, '\"'))) {
+ p_val = pointer + 1;
+ if (!*p_val) return false;
+ }
+ if ((pointer = strchr(p_val, '\"')))
+ *pointer = '\0';
+
+ /* = ? ENCODING_TYPE ? B(Q) ? ENCODED_STRING ? */
+ int err = EMAIL_ERROR_NONE;
+ char *utf8_text = NULL;
+
+ if (!(utf8_text = emcore_decode_rfc2047_text(p_val, &err)))
+ EM_DEBUG_EXCEPTION("emcore_decode_rfc2047_text failed [%d]", err);
+ EM_DEBUG_LOG("utf8_text : [%s]", utf8_text);
+ t->value = EM_SAFE_STRDUP(utf8_text);
+ }
+ }
+ }
+
}
/* repeatedly get paramete */
return true;
}
-/* get header parameter from strin */
+/* get header parameter from string */
int emcore_mime_get_param_from_str(char *str, struct _parameter **param, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("str[%s], param[%p], err_code[%p]", str, param, err_code);
*param = NULL;
- /* Parameter Chec */
+ /* Parameter Check */
if (!(p = strchr(str, '='))) return false;
*p = '\0';
if (!*p_name) return false;
- em_trim_left(p_val);
- em_trim_right(p_val);
-
- if (!*p_val) return false;
-
if (!(*param = em_malloc(sizeof(struct _parameter)))) return false;
(*param)->next = NULL;
- /* Name se */
- /* check string lengt */
+ /* Name set */
+ /* Check string length */
if (strlen(p_name) > 0) {
em_upper_string(p_name);
(*param)->name = EM_SAFE_STRDUP(p_name);
}
+ em_trim_left(p_val);
+ em_trim_right(p_val);
+
+ if (!*p_val) {
+ EM_DEBUG_LOG("Parameter value is NULL");
+ return true;
+ }
+
if (strlen(p_val) > 0) {
if ((p = strchr(p_val, '\"'))) {
p_val = p + 1;
if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, &error)) ||
(is_file == 1 && !emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, &error))) {
- if (error == EMAIL_ERROR_NO_MORE_DATA)
- EM_DEBUG_EXCEPTION("End of data");
- else
+ if (error != EMAIL_ERROR_NO_MORE_DATA) {
EM_DEBUG_EXCEPTION("emcore_mime_get_line_from_sock failed");
- *end_of_parsing = 1;
+ error = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ EM_DEBUG_LOG("This mail is partial body");
+
+ *end_of_parsing = 1;
ret = true;
goto FINISH_OFF;
char *emcore_get_line_from_file(void *stream, char *buf, int size, int *err_code)
{
if (!fgets(buf, size, (FILE *)stream)) {
- if (feof((FILE *)stream))
+ if (feof((FILE *)stream)) {
+ *err_code = EMAIL_ERROR_NO_MORE_DATA;
return NULL;
- else
+ } else
return NULL;
}
return buf;
case TYPEMODEL:
case TYPEOTHER:
+ EM_DEBUG_LOG("g_inline_count [%d], body->id [%s], body->location [%s], body->disposition.type[%s]", g_inline_count, body->id, body->location, body->disposition.type);
+
/* Form list of attachment followed by list of inline images */
- if (body->id || body->location || body->disposition.type) {
+ if (body->id && (g_inline_count || body->location || body->disposition.type)) {
char filename[512] = {0, };
struct attachment_info **ai = NULL;
return ret;
}
-INTERNAL_FUNC int emcore_load_eml_file_to_mail(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count, int *err_code)
+INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("eml_file_path : [%s], output_mail_data : [%p]", eml_file_path, output_mail_data);
return ret;
}
-INTERNAL_FUNC int emcore_delete_eml_data(email_mail_data_t *input_mail_data, int *err_code)
+INTERNAL_FUNC int emcore_delete_parsed_data(email_mail_data_t *input_mail_data, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data : [%p]", input_mail_data);
int err = EMAIL_ERROR_NONE;
int err = EMAIL_ERROR_NONE;
int is_file = 1;
int search = 0;
+ long start_mime_entity = 0;
+ long end_mime_entity = 0;
char buf[MIME_LINE_LEN] = {0x00, };
char *mime_entity_path = NULL;
char *content_type = NULL;
char boundary[BOUNDARY_LEN] = {0x00,};
char *boundary_string = NULL;
+ char *p_mime_entity = NULL;
FILE *fp_read = NULL;
FILE *fp_write = NULL;
struct _m_mesg *mmsg = NULL;
while (TRUE) {
if (!emcore_get_line_from_file((void *)fp_read, buf, MIME_LINE_LEN, &err)) {
EM_DEBUG_EXCEPTION("emcore_mime_get_line_from_file failed [%d]", err);
+ EM_DEBUG_LOG("this mail is partial body");
+ err = EMAIL_ERROR_INVALID_MAIL;
break;
}
if (!strcmp(buf, boundary)) {
search++;
- } else if (search == 1) {
- EM_DEBUG_LOG("Buf : [%s]", buf);
- fprintf(fp_write, "%s", buf);
- } else if (search == 2) {
- break;
+ if (search == 1) {
+ start_mime_entity = ftell(fp_read);
+ } else if (search == 2) {
+ end_mime_entity = ftell(fp_read);
+ break;
+ }
}
}
+ p_mime_entity = em_malloc(end_mime_entity - start_mime_entity);
+ if (p_mime_entity == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ if (fseek(fp_read, start_mime_entity, SEEK_SET)) {
+ EM_DEBUG_EXCEPTION("fseek failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ /* +2 : CRLF line */
+ if ((ret = fread(p_mime_entity, 1, end_mime_entity - (start_mime_entity + strlen(boundary) + 2), fp_read)) < 0) {
+ EM_DEBUG_EXCEPTION("fread failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ fprintf(fp_write, "%s", p_mime_entity);
+
ret = true;
FINISH_OFF:
if (err_code)
*err_code = err;
+ EM_SAFE_FREE(p_mime_entity);
+
EM_DEBUG_FUNC_END();
return ret;
}
#define SMIME_SIGNED_FILE "smime.p7s"
#define SMIME_ENCRYPT_FILE "smime.p7m"
-#define OUTMODE "wb"
-#define INMODE "rb"
-#define READMODE "r"
-
/* If not present then the default digest algorithm for signing key will be used SHA1 */
static const EVP_MD *emcore_get_digest_algorithm(email_digest_type digest_type)
{
smime_attachment = BIO_new_file(temp_smime_filepath, OUTMODE);
if (!smime_attachment) {
EM_DEBUG_EXCEPTION("Cannot open output file %s", temp_smime_filepath);
- err = EMAIL_ERROR_FILE_NOT_FOUND;
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
/* Load certificate for getting the certificate and private key */
+
if (!emcore_load_PFX_file(certificate, password, &private_key, &cert, &other_certs, &err)) {
EM_DEBUG_EXCEPTION("Load the private certificate failed : [%d]", err);
goto FINISH_OFF;
}
-
+/*
+ if (!emcore_load_PFX_file(certificate, &private_key, &cert, &other_certs, &err)) {
+ EM_DEBUG_EXCEPTION("Load the private certificate failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+*/
bio_mime_entity = BIO_new_file(mime_entity, READMODE);
if (!bio_mime_entity) {
EM_DEBUG_EXCEPTION("Cannot open file[%s]", mime_entity);
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
signed_message = PKCS7_sign(NULL, NULL, other_certs, bio_mime_entity, flags);
if (!signed_message) {
EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
if (!PKCS7_sign_add_signer(signed_message, cert, private_key, digest, flags)) {
EM_DEBUG_EXCEPTION("PKCS7_sign_add_signer failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
if (!PKCS7_final(signed_message, bio_mime_entity, flags)) {
EM_DEBUG_EXCEPTION("PKCS7_final failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
smime_attachment = BIO_new_file(temp_smime_filepath, OUTMODE);
if (!smime_attachment) {
EM_DEBUG_EXCEPTION("Cannot open output file %s", temp_smime_filepath);
- err = EMAIL_ERROR_FILE_NOT_FOUND;
+ 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());
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
smime_attachment = BIO_new_file(temp_smime_filepath, OUTMODE);
if (!smime_attachment) {
EM_DEBUG_EXCEPTION("Cannot open output file %s", temp_smime_filepath);
- err = EMAIL_ERROR_FILE_NOT_FOUND;
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
/* Signing the mail */
/* 1. Load the private certificate */
+
if (!emcore_load_PFX_file(certificate, password, &private_key, &cert, &other_certs, &err)) {
EM_DEBUG_EXCEPTION("Load the certificate failed : [%d]", err);
goto FINISH_OFF;
}
-
+/*
+ if (!emcore_load_PFX_file(certificate, &private_key, &cert, &other_certs, &err)) {
+ EM_DEBUG_EXCEPTION("Load the private certificate failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+*/
/* 2. Read mime entity */
bio_mime_entity = BIO_new_file(mime_entity, READMODE);
if (!bio_mime_entity) {
EM_DEBUG_EXCEPTION("Cannot open file[%s]", mime_entity);
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
signed_message = PKCS7_sign(NULL, NULL, other_certs, bio_mime_entity, flags);
if (!signed_message) {
EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure");
+ 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");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
/* 6. Create signing message */
if (!SMIME_write_PKCS7(bio_signed_message, signed_message, bio_mime_entity, flags | SMIME_OLDMIME | SMIME_CRLFEOL)) {
EM_DEBUG_EXCEPTION("SMIME_write_PKCS7 error");
+ 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());
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
}
*/
-static char *emcore_get_mime_entity(char *mime_path)
+static char *emcore_set_mime_entity(char *mime_path)
{
EM_DEBUG_FUNC_BEGIN("mime_path : [%s]", mime_path);
FILE *fp_read = NULL;
if (!input_mail_data || !(input_mail_data->account_id) || !(input_mail_data->mailbox_id)) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
#endif
if (!emcore_make_rfc822_file(input_mail_data, input_attachment_data_list, attachment_count, &rfc822_file, &err)) {
- EM_DEBUG_EXCEPTION("emcore_make_rfc822_file_from_mail failed [%d]", err);
+ EM_DEBUG_EXCEPTION("emcore_make_rfc822_file failed [%d]", err);
goto FINISH_OFF;
}
- mime_entity = emcore_get_mime_entity(rfc822_file);
+ mime_entity = emcore_set_mime_entity(rfc822_file);
smime_type = input_mail_data->smime_type;
if (!smime_type)
new_attachment_data.attachment_name = EM_SAFE_STRDUP(name + 1);
new_attachment_data.attachment_path = EM_SAFE_STRDUP(smime_file_path);
- new_attachment_data.attachment_size = 1;
- new_attachment_data.save_status = 1;
attachment_count += 1;
new_attachment_data.attachment_name = EM_SAFE_STRDUP(name + 1);
new_attachment_data.attachment_path = EM_SAFE_STRDUP(smime_file_path);
- new_attachment_data.attachment_size = 1;
- new_attachment_data.save_status = 1;
- attachment_count += 1;
+ attachment_count = 1;
break;
- case EMAIL_SMIME_SIGNED_AND_ENCRYPTED: /* Signed and Encryption message */
+ default: /* Signed and Encryption message */
address_length = EM_SAFE_STRLEN(input_mail_data->full_address_to) + EM_SAFE_STRLEN(input_mail_data->full_address_cc) + EM_SAFE_STRLEN(input_mail_data->full_address_bcc);
other_certificate_list = em_malloc(address_length + 3);
new_attachment_data.attachment_name = EM_SAFE_STRDUP(name + 1);
new_attachment_data.attachment_path = EM_SAFE_STRDUP(smime_file_path);
- new_attachment_data.attachment_size = 1;
- new_attachment_data.save_status = 1;
attachment_count = 1;
break;
- default:
- break;
}
+/*
+ if (!emcore_get_file_size(smime_file_path, &size, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_get_file_size failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+*/
+ new_attachment_data.attachment_size = 1;
+ new_attachment_data.save_status = 1;
+
temp_attachment_data = (email_attachment_data_t *)em_malloc(sizeof(email_attachment_data_t) * attachment_count);
if (input_attachment_data_list != NULL)
#ifdef SMIME_DEBUG
if (password)
EM_SAFE_FREE(password);
-#endif
+#endif // SMIME_DEBUG
return ret;
}
#ifdef __FEATURE_SUPPORT_REPORT_MAIL__
static int emcore_get_report_mail_body(ENVELOPE *envelope, BODY **multipart_body, int *err_code);
#endif
+static int emcore_make_envelope_from_mail(emstorage_mail_tbl_t *input_mail_tbl_data, ENVELOPE **output_envelope);
static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_file, int account_id, int mail_id, int *err_code);
/* Functions from uw-imap-toolkit */
return result_string;
}
+static int emcore_write_body(BODY *body, BODY *html_body, FILE *fp, int *err_code)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ char *file_path = NULL;
+ char buf[RFC822_STRING_BUFFER_SIZE + 1] = {0, };
+ char *img_tag_pos = NULL;
+ char *p = NULL;
+ char *replaced_string = NULL;
+ int fd, nread, nwrite, error = EMAIL_ERROR_NONE;
+ unsigned long len;
+
+ file_path = body->sparep;
+
+ if (!file_path || strlen(file_path) == 0) {
+ EM_DEBUG_LOG("There is no file path");
+ switch (body->encoding) {
+ case 0:
+ break;
+ default:
+ p = cpystr((const char *)body->contents.text.data);
+ len = body->contents.text.size;
+ break;
+ }
+
+ if (p) {
+ EM_DEBUG_LOG("p[%s]", p);
+ fprintf(fp, "%s"CRLF_STRING CRLF_STRING, p);
+ EM_SAFE_FREE(p);
+ }
+
+ EM_SAFE_FREE(body->sparep);
+ EM_DEBUG_FUNC_END();
+ return true;
+ }
+
+ EM_DEBUG_LOG("Opening a file[%s]", file_path);
+ fd = open(file_path, O_RDONLY);
+
+ if (fd < 0) {
+ EM_DEBUG_EXCEPTION("open(\"%s\") failed...", file_path);
+ return false;
+ }
+
+ while (1) {
+ nread = read(fd, buf, (body->encoding == ENCBASE64 ? 57 : RFC822_READ_BLOCK_SIZE - 2));
+
+ if (nread <= 0) {
+ EM_DEBUG_LOG("Can't read anymore");
+ break;
+ }
+
+ p = NULL;
+ len = nread;
+
+ /* EM_DEBUG_LOG("body->type[%d], body->subtype[%c]", body->type, body->subtype[0]); */
+
+ if (body->type == TYPETEXT && (body->subtype && (body->subtype[0] == 'H' || body->subtype[0] == 'h'))) {
+ EM_DEBUG_LOG("HTML Part");
+ img_tag_pos = emcore_find_img_tag(buf);
+
+ if (img_tag_pos) {
+ replaced_string = emcore_replace_inline_image_path_with_content_id(buf, html_body, &error);
+ if (replaced_string) {
+ EM_DEBUG_LOG("emcore_replace_inline_image_path_with_content_id succeeded");
+ strcpy(buf, replaced_string);
+ nread = len = strlen(buf);
+ EM_DEBUG_LOG("buf[%s], nread[%d], len[%d]", buf, nread, len);
+ }
+ else
+ EM_DEBUG_LOG("emcore_replace_inline_image_path_with_content_id failed[%d]", error);
+ }
+ }
+ /* EM_DEBUG_LOG("body->encoding[%d]", body->encoding); */
+// if (body->subtype[0] != 'S' || body->subtype[0] != 's') {
+ switch (body->encoding) {
+ case ENCQUOTEDPRINTABLE:
+ p = (char *)rfc822_8bit((unsigned char *)buf, (unsigned long)nread, (unsigned long *)&len);
+ break;
+ case ENCBASE64:
+ p = (char *)rfc822_binary((void *)buf, (unsigned long)nread, (unsigned long *)&len);
+ break;
+ default:
+ buf[len] = '\0';
+ break;
+ }
+// }
+
+ nwrite = fprintf(fp, "%s", (p ? p : buf));
+
+ if (nwrite != len) {
+ fclose(fp);
+ close(fd);
+ EM_SAFE_FREE(p);
+ EM_DEBUG_EXCEPTION("fprintf failed nwrite[%d], len[%d]", nwrite, len);
+ return false;
+ }
+ EM_SAFE_FREE(p);
+ }
+
+ if (body->encoding == ENCQUOTEDPRINTABLE || body->encoding == ENCBASE64)
+ fprintf(fp, CRLF_STRING);
+
+ fprintf(fp, CRLF_STRING);
+
+ if (body->sparep) {
+ free(body->sparep);
+ body->sparep = NULL;
+ }
+
+ EM_DEBUG_FUNC_END();
+ return true;
+}
+
static int emcore_write_rfc822_body(BODY *body, BODY *html_body, FILE *fp, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("body[%p], html_body[%p], fp[%p], err_code[%p]", body, html_body, fp, err_code);
PARAMETER *param = NULL;
PART *part = NULL;
- char *p = NULL, *bndry = NULL, buf[1025], *replaced_string = NULL;
- int fd, nread, nwrite, error = EMAIL_ERROR_NONE;
+ char *p = NULL, *bndry = NULL, buf[1025];
+ int error = EMAIL_ERROR_NONE;
switch (body->type) {
case TYPEMULTIPART:
rfc822_write_body_header(&p, &part->body);
fprintf(fp, "--%s"CRLF_STRING, bndry);
+ if (body->subtype[0] == 'S' || body->subtype[0] == 's') {
+ if (!emcore_write_body(body, html_body, fp, &error)) {
+ EM_DEBUG_EXCEPTION("emcore_write_body failed : [%d]", error);
+ return false;
+ }
+ fprintf(fp, "--%s"CRLF_STRING, bndry);
+ }
+
fprintf(fp, "%s"CRLF_STRING, buf);
-
+
emcore_write_rfc822_body(&part->body, html_body, fp, err_code);
} while ((part = part->next));
default: {
EM_DEBUG_LOG("body->type is not TYPEMULTIPART");
- char *file_path = body->sparep;
- char buf[RFC822_STRING_BUFFER_SIZE + 1] = { 0, }, *img_tag_pos = NULL;
- unsigned long len;
-
- p = NULL;
-
- if (!file_path || strlen(file_path) == 0) {
- EM_DEBUG_LOG("There is no file path");
- switch (body->encoding) {
- case 0:
- break;
- default:
- p = cpystr((const char *)body->contents.text.data);
- len = body->contents.text.size;
- break;
- }
-
- if (p) {
- EM_DEBUG_LOG("p[%s]", p);
- fprintf(fp, "%s"CRLF_STRING CRLF_STRING, p);
- EM_SAFE_FREE(p);
- }
-
- EM_SAFE_FREE(body->sparep);
- EM_DEBUG_FUNC_END();
- return true;
- }
-
- EM_DEBUG_LOG("Opening a file[%s]", file_path);
- fd = open(file_path, O_RDONLY);
-
- if (fd < 0) {
- EM_DEBUG_EXCEPTION("open(\"%s\") failed...", file_path);
+ if (!emcore_write_body(body, html_body, fp, &error)) {
+ EM_DEBUG_EXCEPTION("emcore_write_body failed : [%d]", error);
return false;
}
-
- while (1) {
- nread = read(fd, buf, (body->encoding == ENCBASE64 ? 57 : RFC822_READ_BLOCK_SIZE - 2));
-
- if (nread < 0) {
- close(fd);
- return false;
- }
-
- if (nread == 0) {
- close(fd);
- break;
- }
-
- p = NULL;
- len = nread;
-
- /* EM_DEBUG_LOG("body->type[%d], body->subtype[%c]", body->type, body->subtype[0]); */
- if (body->type == TYPETEXT && (body->subtype && (body->subtype[0] == 'H' || body->subtype[0] == 'h'))) {
- EM_DEBUG_LOG("HTML Part");
- img_tag_pos = emcore_find_img_tag(buf);
-
- if (img_tag_pos) {
- replaced_string = emcore_replace_inline_image_path_with_content_id(buf, html_body, &error);
- if (replaced_string) {
- EM_DEBUG_LOG("emcore_replace_inline_image_path_with_content_id succeeded");
- strcpy(buf, replaced_string);
- nread = len = strlen(buf);
- EM_DEBUG_LOG("buf[%s], nread[%d], len[%d]", buf, nread, len);
- }
- else
- EM_DEBUG_LOG("emcore_replace_inline_image_path_with_content_id failed[%d]", error);
- }
- }
-
- switch (body->encoding) {
- case ENCQUOTEDPRINTABLE:
- p = (char *)rfc822_8bit((unsigned char *)buf, (unsigned long)nread, (unsigned long *)&len);
- break;
- case ENCBASE64:
- p = (char *)rfc822_binary((void *)buf, (unsigned long)nread, (unsigned long *)&len);
- break;
- default:
- buf[len] = '\0';
- break;
- }
-
-
- nwrite = fprintf(fp, "%s", (p ? p : buf));
-
- if (nwrite != len) {
- fclose(fp);
- close(fd);
- EM_SAFE_FREE(p);
- EM_DEBUG_EXCEPTION("fprintf failed nwrite[%d], len[%d]", nwrite, len);
- return false;
- }
- EM_SAFE_FREE(p);
- }
-
- if (body->encoding == ENCQUOTEDPRINTABLE || body->encoding == ENCBASE64)
- fprintf(fp, CRLF_STRING);
-
- fprintf(fp, CRLF_STRING);
-
- if (body->sparep) {
- free(body->sparep);
- body->sparep = NULL;
- }
-
+
break;
} /* default: */
}
return true;
}
-static int emcore_write_rfc822(ENVELOPE *env, BODY *body, BODY *html_body, email_extra_flag_t flag, char **data, int *err_code)
+static int emcore_write_rfc822(ENVELOPE *env, BODY *body, BODY *html_body, email_mail_priority_t input_priority, email_mail_report_t input_report_flag, char **data, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("env[%p], body[%p], data[%p], err_code[%p]", env, body, data, err_code);
*(p + strlen(p) - 2) = '\0';
- if (flag.report) {
+ if (input_report_flag) {
char buf[512] = {0x00, };
- switch (flag.report) {
- case EMAIL_MAIL_REPORT_DSN: /* DSN (delivery status) */
- /* change content-type */
- /* Content-Type: multipart/report; */
- /* report-type= delivery-status; */
- /* boundary="----=_NextPart_000_004F_01C76EFF.54275C50" */
- break;
-
- case EMAIL_MAIL_REPORT_MDN: /* MDN (read receipt) */
- /* Content-Type: multipart/report; */
- /* report-type= disposition-notification; */
- /* boundary="----=_NextPart_000_004F_01C76EFF.54275C50" */
- break;
+
+ if(input_report_flag & EMAIL_MAIL_REPORT_DSN) {
+ /* DSN (delivery status) */
+ /* change content-type */
+ /* Content-Type: multipart/report; */
+ /* report-type= delivery-status; */
+ /* boundary="----=_NextPart_000_004F_01C76EFF.54275C50" */
+ }
+
+ if(input_report_flag & EMAIL_MAIL_REPORT_MDN) {
+ /* MDN (read receipt) */
+ /* Content-Type: multipart/report; */
+ /* report-type= disposition-notification; */
+ /* boundary="----=_NextPart_000_004F_01C76EFF.54275C50" */
+ }
- case EMAIL_MAIL_REPORT_REQUEST: /* require read status */
- rfc822_address(buf, env->from);
- if (strlen(buf))
- SNPRINTF(p + strlen(p), p_len-(strlen(p)), "Disposition-Notification-To: %s"CRLF_STRING, buf);
- break;
-
- default:
- break;
+ if(input_report_flag & EMAIL_MAIL_REQUEST_MDN) {
+ /* require read status */
+ rfc822_address(buf, env->from);
+ if (strlen(buf))
+ SNPRINTF(p + strlen(p), p_len-(strlen(p)), "Disposition-Notification-To: %s"CRLF_STRING, buf);
}
}
- if (flag.priority) { /* priority (1:high 3:normal 5:low) */
- SNPRINTF(p + strlen(p), p_len-(strlen(p)), "X-Priority: %d"CRLF_STRING, flag.priority);
+ if (input_priority) { /* priority (1:high 3:normal 5:low) */
+ SNPRINTF(p + strlen(p), p_len-(strlen(p)), "X-Priority: %d"CRLF_STRING, input_priority);
- switch (flag.priority) {
+ switch (input_priority) {
case EMAIL_MAIL_PRIORITY_HIGH:
SNPRINTF(p + strlen(p), p_len-(strlen(p)), "X-MSMail-Priority: HIgh"CRLF_STRING);
break;
int attachment_count = 0;
email_mail_data_t *mail_data = NULL;
email_attachment_data_t *attachment_data_list = NULL;
-
emstorage_mail_tbl_t *converted_mail_tbl = NULL;
emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
emstorage_attachment_tbl_t attachment_tbl = { 0 };
goto FINISH_OFF;
}
- if (mail_data->report_status == EMAIL_MAIL_REPORT_MDN) {
+ if (mail_data->report_status & EMAIL_MAIL_REPORT_MDN) {
/* check read-report mail */
if(!mail_data->full_address_to) { /* A report mail should have 'to' address */
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
if(mail_data->mail_size == 0)
emcore_calc_mail_size(mail_data, attachment_data_list, attachment_count, &(mail_data->mail_size)); /* Getting file size before file moved. */
+ EM_DEBUG_LOG("input_from_eas [%d] mail_data->body_download_status [%d]", input_from_eas, mail_data->body_download_status);
+
if (input_from_eas == 0|| mail_data->body_download_status) {
if (!emstorage_create_dir(mail_data->account_id, mail_data->mail_id, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
INTERNAL_FUNC int emcore_add_read_receipt(int input_read_mail_id, int *output_receipt_mail_id)
{
EM_DEBUG_FUNC_BEGIN("input_read_mail_id [%d], output_receipt_mail_id [%p]", input_read_mail_id, output_receipt_mail_id);
- int err = EMAIL_ERROR_NONE;
- email_mail_data_t *read_mail_data = NULL;
- email_mail_data_t *receipt_mail_data = NULL;
+ int err = EMAIL_ERROR_NONE;
+ int attachment_count = 0;
+ ENVELOPE *envelope = NULL;
+ email_mail_data_t *read_mail_data = NULL;
+ email_mail_data_t *receipt_mail_data = NULL;
+ emstorage_mail_tbl_t *receipt_mail_tbl_data = NULL;
+ email_attachment_data_t *attachment_data = NULL;
emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
+ BODY *root_body = NULL;
if( (err = emcore_get_mail_data(input_read_mail_id, &read_mail_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
memcpy(receipt_mail_data, read_mail_data, sizeof(email_mail_data_t));
- receipt_mail_data->full_address_to = EM_SAFE_STRDUP(read_mail_data->full_address_to);
+ receipt_mail_data->full_address_to = EM_SAFE_STRDUP(read_mail_data->full_address_from);
receipt_mail_data->message_id = EM_SAFE_STRDUP(read_mail_data->message_id);
if (read_mail_data->subject) {
goto FINISH_OFF;
}
- SNPRINTF(receipt_mail_data->subject, strlen(read_mail_data->subject) + 7 - 1, "Read: %s", read_mail_data->subject);
+ SNPRINTF(receipt_mail_data->subject, strlen(read_mail_data->subject) + 7, "Read: %s", read_mail_data->subject);
}
if (!emstorage_get_mailbox_by_mailbox_type(receipt_mail_data->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ receipt_mail_data->mailbox_id = mailbox_tbl->mailbox_id;
+ receipt_mail_data->mailbox_type = EMAIL_MAILBOX_TYPE_OUTBOX;
+ receipt_mail_data->file_path_html = NULL;
+ receipt_mail_data->flags_draft_field = 1;
+ receipt_mail_data->body_download_status = 1;
+ receipt_mail_data->save_status = (unsigned char)EMAIL_MAIL_STATUS_SENDING;
+ receipt_mail_data->report_status = (unsigned char)EMAIL_MAIL_REPORT_MDN;
+
+ if (!em_convert_mail_data_to_mail_tbl(receipt_mail_data, 1, &receipt_mail_tbl_data, &err)) {
+ EM_DEBUG_EXCEPTION("em_convert_mail_data_to_mail_tbl failed [%d]", err);
+ goto FINISH_OFF;
+ }
+ if ( (err = emcore_make_envelope_from_mail(receipt_mail_tbl_data, &envelope)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_make_envelope_from_mail failed [%d]", err);
goto FINISH_OFF;
}
- receipt_mail_data->mailbox_id = mailbox_tbl->mailbox_id;
- receipt_mail_data->mailbox_type = EMAIL_MAILBOX_TYPE_OUTBOX;
- receipt_mail_data->flags_draft_field = 1;
- receipt_mail_data->save_status = (unsigned char)EMAIL_MAIL_STATUS_SENDING;
- receipt_mail_data->report_status = (unsigned char)EMAIL_MAIL_REPORT_MDN;
+ envelope->references = EM_SAFE_STRDUP(read_mail_data->message_id);
- if ( (err = emcore_add_mail(receipt_mail_data, NULL, 0, NULL, 1)) != EMAIL_ERROR_NONE) {
+ if (!emcore_get_report_mail_body(envelope, &root_body, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_get_report_mail_body failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ receipt_mail_data->file_path_plain = EM_SAFE_STRDUP(root_body->nested.part->body.sparep);
+
+ /* Report attachment */
+ /* Final-Recipient : rfc822;digipop@gmail.com
+ Original-Message-ID: <r97a77ag0jdhkvvxke58u9i5.1345611508570@email.android.com>
+ Disposition : manual-action/MDN-sent-manually; displayed */
+
+ /*
+ receipt_mail_data->attachment_count = 1;
+ attachment_count = 1;
+
+ attachment_data = em_malloc(sizeof(email_attachment_data_t));
+ if (!attachment_data) {
+ EM_DEBUG_EXCEPTION("em_malloc failed...");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ attachment_data->save_status = 1;
+ attachment_data->attachment_path = EM_SAFE_STRDUP(root_body->nested.part->next->body.sparep);
+
+ if (!emcore_get_file_name(attachment_data->attachment_path, &p, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_get_file_name failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ attachment_data->attachment_name = cpystr(p);
+ */
+
+ if ( (err = emcore_add_mail(receipt_mail_data, attachment_data, attachment_count, NULL, 0)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err);
goto FINISH_OFF;
}
+ *output_receipt_mail_id = receipt_mail_data->mail_id;
+
FINISH_OFF:
if(receipt_mail_data) {
EM_SAFE_FREE(receipt_mail_data->full_address_to);
if(read_mail_data)
emcore_free_mail_data_list(&read_mail_data, 1);
+ if(attachment_data)
+ emcore_free_attachment_data(&attachment_data, 1, NULL);
+
+ if(receipt_mail_tbl_data)
+ emstorage_free_mail(&receipt_mail_tbl_data, 1, NULL);
+
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
}
/* send a mail */
-INTERNAL_FUNC int emcore_send_mail(int account_id, int input_mailbox_id, int mail_id, email_option_t *sending_option, int *err_code)
+INTERNAL_FUNC int emcore_send_mail(int account_id, int input_mailbox_id, int mail_id, int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], mail_id[%d], sending_option[%p], err_code[%p]", account_id, input_mailbox_id, mail_id, sending_option, err_code);
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], mail_id[%d], err_code[%p]", account_id, input_mailbox_id, mail_id, err_code);
EM_PROFILE_BEGIN(profile_emcore_send_mail);
int ret = false;
int err = EMAIL_ERROR_NONE, err2 = EMAIL_ERROR_NONE;
goto FINISH_OFF;
}
- if (sending_option != NULL)
- opt = sending_option;
- else
- opt = emcore_get_option(&err);
-
+ opt = &(ref_account->options);
/*Update status flag to DB*/
if (!envelope || (!envelope->to && !envelope->cc && !envelope->bcc)) {
EM_DEBUG_EXCEPTION(" no recipients found...");
-
err = EMAIL_ERROR_NO_RECIPIENT;
goto FINISH_OFF;
}
}
/* set request of delivery status. */
- if (opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON) {
+ EM_DEBUG_LOG("opt->req_delivery_receipt [%d]", opt->req_delivery_receipt);
+ EM_DEBUG_LOG("mail_tbl_data->report_status [%d]", mail_tbl_data->report_status);
+
+ if (opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON || (mail_tbl_data->report_status & EMAIL_MAIL_REQUEST_DSN)) {
+ EM_DEBUG_LOG("DSN is required.");
stream->protocol.esmtp.dsn.want = 1;
stream->protocol.esmtp.dsn.full = 0;
stream->protocol.esmtp.dsn.notify.failure = 1;
stream->protocol.esmtp.dsn.notify.success = 1;
- EM_DEBUG_LOG("opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON");
}
mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENDING;
}
/* send a saved all mails */
-INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_name, email_option_t *sending_option, int *err_code)
+INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_name, int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_name[%p], sending_option[%p], err_code[%p]", account_id, input_mailbox_name, sending_option, err_code);
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_name[%p], err_code[%p]", account_id, input_mailbox_name, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
FINISH_OFF_IF_CANCELED;
- if (sending_option)
- opt = sending_option;
- else
- opt = emcore_get_option(&err);
+ opt = &(ref_account->options);
/* search mail. */
if (!emstorage_mail_search_start(NULL, account_id, input_mailbox_name, 0, &handle, &total, true, &err)) {
if (stream->protocol.esmtp.ok) {
if (stream->protocol.esmtp.eightbit.ok && stream->protocol.esmtp.eightbit.want)
strncat (buf, " BODY=8BITMIME", sizeof(buf)-(strlen(buf)+1));
+
+ EM_DEBUG_LOG("stream->protocol.esmtp.dsn.ok [%d]", stream->protocol.esmtp.dsn.ok);
if (stream->protocol.esmtp.dsn.ok && stream->protocol.esmtp.dsn.want) {
EM_DEBUG_LOG("stream->protocol.esmtp.dsn.want is required");
SNPRINTF (buf + strlen (buf), sizeof(buf)-(strlen(buf)), " ENVID=%.100s", stream->protocol.esmtp.dsn.envid);
}
else
- EM_DEBUG_LOG("stream->protocol.esmtp.dsn.want is not required");
+ EM_DEBUG_LOG("stream->protocol.esmtp.dsn.want is not required or DSN is not supported");
}
EM_PROFILE_BEGIN(profile_prepare_and_head);
extension = em_get_extension_from_file_path(filename, NULL);
part->body.type = em_get_content_type_from_extension_string(extension, NULL);
- if(part->body.type == TYPEIMAGE)
+ if(part->body.type == TYPEIMAGE) {
part->body.subtype = strdup(extension);
- else
- part->body.subtype = cpystr("octet-stream");
+ } else if (part->body.type == TYPEPKCS7_SIGN) {
+ part->body.subtype = strdup("pkcs7-signature");
+ part->body.type = TYPEAPPLICATION;
+ } else if (part->body.type == TYPEPKCS7_MIME) {
+ part->body.subtype = strdup("pkcs7-mime");
+ part->body.type = TYPEAPPLICATION;
+ } else
+ part->body.subtype = strdup("octet-stream");
part->body.encoding = ENCBINARY;
part->body.size.bytes = data_len;
else {
/* text body (plain/html) */
part->body.type = TYPETEXT;
-
part->body.size.bytes = data_len;
+
if (data)
part->body.sparep = EM_SAFE_STRDUP((char *)data); /* file path */
else
}
#define DATE_STR_LENGTH 100
-/* Description : Make RFC822 text file from mail_tbl data */
-/* Parameters : */
-/* input_mail_tbl_data : */
-/* is_draft : this mail is draft mail. */
-/* file_path : path of file that rfc822 data will be written to. */
-INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_mail_tbl_data, emstorage_attachment_tbl_t *input_attachment_tbl, int input_attachment_count, ENVELOPE **env, char **file_path, email_option_t *sending_option, int *err_code)
+
+static int emcore_make_envelope_from_mail(emstorage_mail_tbl_t *input_mail_tbl_data, ENVELOPE **output_envelope)
{
- EM_DEBUG_FUNC_BEGIN("input_mail_tbl_data[%p], env[%p], file_path[%p], sending_option[%p], err_code[%p]", input_mail_tbl_data, env, file_path, sending_option, err_code);
-
- int ret = false;
- int error = EMAIL_ERROR_NONE;
- int is_incomplete = 0;
- int i = 0;
- ENVELOPE *envelope = NULL;
- BODY *text_body = NULL;
- BODY *html_body = NULL;
- BODY *root_body = NULL;
- PART *part_for_html = NULL;
- PART *part_for_text = NULL;
- char *pAdd = NULL;
- char *fname = NULL;
- email_extra_flag_t extra_flag;
- email_account_t *ref_account = NULL;
+ EM_DEBUG_FUNC_BEGIN("input_mail_tbl_data[%p], output_envelope[%p]", input_mail_tbl_data, output_envelope);
- if (!input_mail_tbl_data) {
+ int error = EMAIL_ERROR_NONE;
+ int is_incomplete = 0;
+ char *pAdd = NULL;
+ char *outgoing_server_address = NULL;
+ ENVELOPE *envelope = NULL;
+ email_account_t *ref_account = NULL;
+
+ if (!input_mail_tbl_data || !output_envelope) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
error = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
-
- if (input_mail_tbl_data->report_status != EMAIL_MAIL_REPORT_MDN && !input_mail_tbl_data->body_download_status) {
+
+ if ( (input_mail_tbl_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0 && !input_mail_tbl_data->body_download_status) {
EM_DEBUG_EXCEPTION("input_mail_tbl_data->body_download_status[%p]", input_mail_tbl_data->body_download_status);
error = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
-
- ref_account = emcore_get_account_reference(input_mail_tbl_data->account_id);
- if (!ref_account) {
- EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_mail_tbl_data->account_id);
- error = EMAIL_ERROR_INVALID_ACCOUNT;
- goto FINISH_OFF;
+ if (input_mail_tbl_data->account_id) {
+ ref_account = emcore_get_account_reference(input_mail_tbl_data->account_id);
+
+ if (!ref_account) {
+ EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_mail_tbl_data->account_id);
+ error = EMAIL_ERROR_INVALID_ACCOUNT;
+ goto FINISH_OFF;
+ }
+
+ outgoing_server_address = EM_SAFE_STRDUP(ref_account->outgoing_server_address);
}
-
+
if (!(envelope = mail_newenvelope())) {
EM_DEBUG_EXCEPTION("mail_newenvelope failed...");
error = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
-
+
is_incomplete = input_mail_tbl_data->flags_draft_field || (input_mail_tbl_data->save_status == EMAIL_MAIL_STATUS_SENDING);
-
+
if (is_incomplete) {
if (ref_account->user_email_address && ref_account->user_email_address[0] != '\0') {
char *p = cpystr(ref_account->user_email_address);
-
+
if (p == NULL) {
EM_DEBUG_EXCEPTION("cpystr failed...");
error = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
-
- EM_DEBUG_LOG("Assign envelop->from");
+
+ EM_DEBUG_LOG("Assign envelope->from");
if (input_mail_tbl_data->full_address_from) {
char *temp_address_string = NULL ;
em_skip_whitespace(input_mail_tbl_data->full_address_from , &temp_address_string);
EM_DEBUG_LOG("address[temp_address_string][%s]", temp_address_string);
- rfc822_parse_adrlist(&envelope->from, temp_address_string, ref_account->outgoing_server_address);
+ rfc822_parse_adrlist(&envelope->from, temp_address_string, outgoing_server_address);
EM_SAFE_FREE(temp_address_string);
temp_address_string = NULL ;
}
else
envelope->from = rfc822_parse_mailbox(&p, NULL);
- EM_SAFE_FREE(p);
+ EM_SAFE_FREE(p);
if (!envelope->from) {
EM_DEBUG_EXCEPTION("rfc822_parse_mailbox failed...");
error = EMAIL_ERROR_INVALID_ADDRESS;
- goto FINISH_OFF;
+ goto FINISH_OFF;
}
else {
-
if (envelope->from->personal == NULL) {
- if (sending_option && sending_option->display_name_from && sending_option->display_name_from[0] != '\0')
- envelope->from->personal = cpystr(sending_option->display_name_from);
- else
- envelope->from->personal =
- (ref_account->user_display_name && ref_account->user_display_name[0] != '\0') ?
- cpystr(ref_account->user_display_name) : NULL;
+ if (ref_account->options.display_name_from && ref_account->options.display_name_from[0] != '\0')
+ envelope->from->personal = cpystr(ref_account->options.display_name_from);
+ else
+ envelope->from->personal =
+ (ref_account->user_display_name && ref_account->user_display_name[0] != '\0') ?
+ cpystr(ref_account->user_display_name) : NULL;
+ }
}
}
- }
-
- if (ref_account->return_address && ref_account->return_address[0] != '\0') {
- char *p = cpystr(ref_account->return_address);
-
- if (p == NULL) {
- EM_DEBUG_EXCEPTION("cpystr failed...");
-
- error = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
+
+ if (ref_account->return_address && ref_account->return_address[0] != '\0') {
+ char *p = cpystr(ref_account->return_address);
+
+ if (p == NULL) {
+ EM_DEBUG_EXCEPTION("cpystr failed...");
+ error = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+ envelope->return_path = rfc822_parse_mailbox(&p, NULL);
+ EM_SAFE_FREE(p);
}
- envelope->return_path = rfc822_parse_mailbox(&p, NULL);
- EM_SAFE_FREE(p);
- }
}
else {
if (!input_mail_tbl_data->full_address_from || !input_mail_tbl_data->full_address_to) {
error = EMAIL_ERROR_INVALID_MAIL;
goto FINISH_OFF;
}
-
+
int i, j;
-
+
if (input_mail_tbl_data->full_address_from) {
for (i = 0, j = strlen(input_mail_tbl_data->full_address_from); i < j; i++) {
if (input_mail_tbl_data->full_address_from[i] == ';')
input_mail_tbl_data->full_address_from[i] = ',';
}
}
-
+
if (input_mail_tbl_data->full_address_return) {
for (i = 0, j = strlen(input_mail_tbl_data->full_address_return); i < j; i++) {
if (input_mail_tbl_data->full_address_return[i] == ';')
input_mail_tbl_data->full_address_return[i] = ',';
}
}
- em_skip_whitespace(input_mail_tbl_data->full_address_from , &pAdd);
+ em_skip_whitespace(input_mail_tbl_data->full_address_from , &pAdd);
EM_DEBUG_LOG("address[pAdd][%s]", pAdd);
-
- rfc822_parse_adrlist(&envelope->from, pAdd, ref_account->outgoing_server_address);
+
+ rfc822_parse_adrlist(&envelope->from, pAdd, outgoing_server_address);
EM_SAFE_FREE(pAdd);
- pAdd = NULL ;
+ pAdd = NULL;
em_skip_whitespace(input_mail_tbl_data->full_address_return , &pAdd);
EM_DEBUG_LOG("address[pAdd][%s]", pAdd);
-
- rfc822_parse_adrlist(&envelope->return_path, pAdd, ref_account->outgoing_server_address);
+
+ rfc822_parse_adrlist(&envelope->return_path, pAdd, outgoing_server_address);
EM_SAFE_FREE(pAdd);
- pAdd = NULL ;
+ pAdd = NULL;
}
{
int i, j;
-
+
if (input_mail_tbl_data->full_address_to) {
for (i = 0, j = strlen(input_mail_tbl_data->full_address_to); i < j; i++) {
if (input_mail_tbl_data->full_address_to[i] == ';')
input_mail_tbl_data->full_address_to[i] = ',';
}
}
-
+
if (input_mail_tbl_data->full_address_cc) {
for (i = 0, j = strlen(input_mail_tbl_data->full_address_cc); i < j; i++) {
if (input_mail_tbl_data->full_address_cc[i] == ';')
input_mail_tbl_data->full_address_cc[i] = ',';
}
}
-
+
if (input_mail_tbl_data->full_address_bcc) {
for (i = 0, j = strlen(input_mail_tbl_data->full_address_bcc); i < j; i++) {
if (input_mail_tbl_data->full_address_bcc[i] == ';')
em_skip_whitespace(input_mail_tbl_data->full_address_to , &pAdd);
EM_DEBUG_LOG("address[pAdd][%s]", pAdd);
-
- rfc822_parse_adrlist(&envelope->to, pAdd, ref_account->outgoing_server_address);
+
+ rfc822_parse_adrlist(&envelope->to, pAdd, outgoing_server_address);
EM_SAFE_FREE(pAdd);
pAdd = NULL ;
-
+
EM_DEBUG_LOG("address[input_mail_tbl_data->full_address_cc][%s]", input_mail_tbl_data->full_address_cc);
em_skip_whitespace(input_mail_tbl_data->full_address_cc , &pAdd);
EM_DEBUG_LOG("address[pAdd][%s]", pAdd);
-
- rfc822_parse_adrlist(&envelope->cc, pAdd, ref_account->outgoing_server_address);
+
+ rfc822_parse_adrlist(&envelope->cc, pAdd, outgoing_server_address);
EM_SAFE_FREE(pAdd);
pAdd = NULL ;
em_skip_whitespace(input_mail_tbl_data->full_address_bcc , &pAdd);
- rfc822_parse_adrlist(&envelope->bcc, pAdd, ref_account->outgoing_server_address);
+ rfc822_parse_adrlist(&envelope->bcc, pAdd, outgoing_server_address);
EM_SAFE_FREE(pAdd);
pAdd = NULL ;
if (!is_incomplete) {
char localtime_string[DATE_STR_LENGTH] = { 0, };
strftime(localtime_string, 128, "%a, %e %b %Y %H : %M : %S ", localtime(&input_mail_tbl_data->date_time));
- /* append last 5byes("+0900") */
+ /* append last 5byes("+0900") */
g_strlcat(localtime_string, rfc822_date_string + (strlen(rfc822_date_string) - 5), DATE_STR_LENGTH);
envelope->date = (unsigned char *)cpystr((const char *)localtime_string);
}
else {
envelope->date = (unsigned char *)cpystr((const char *)rfc822_date_string);
}
+
+ *output_envelope = envelope;
+
+FINISH_OFF:
+ if (outgoing_server_address)
+ EM_SAFE_FREE(outgoing_server_address);
+
+ EM_DEBUG_FUNC_END("error [%d]", error);
+ return error;
+}
+/* Description : Make RFC822 text file from mail_tbl data */
+/* Parameters : */
+/* input_mail_tbl_data : */
+/* is_draft : this mail is draft mail. */
+/* file_path : path of file that rfc822 data will be written to. */
+INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_mail_tbl_data, emstorage_attachment_tbl_t *input_attachment_tbl, int input_attachment_count, ENVELOPE **env, char **file_path, email_option_t *sending_option, int *err_code)
+{
+ EM_DEBUG_FUNC_BEGIN("input_mail_tbl_data[%p], env[%p], file_path[%p], sending_option[%p], err_code[%p]", input_mail_tbl_data, env, file_path, sending_option, err_code);
- /* memcpy(&extra_flag, &input_mail_tbl_data->info->extra_flags, sizeof(email_extra_flag_t)); */
+ int ret = false;
+ int error = EMAIL_ERROR_NONE;
+ int i = 0;
+ ENVELOPE *envelope = NULL;
+ BODY *text_body = NULL;
+ BODY *html_body = NULL;
+ BODY *root_body = NULL;
+ PART *part_for_html = NULL;
+ PARAMETER *param = NULL;
+ PART *part_for_text = NULL;
+ char *fname = NULL;
+
+ if (!input_mail_tbl_data) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ error = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
- /* check report input_mail_tbl_data */
- if (input_mail_tbl_data->report_status != EMAIL_MAIL_REPORT_MDN) {
- /* Non-report input_mail_tbl_data */
- EM_DEBUG_LOG("input_mail_tbl_data->file_path_plain[%s]", input_mail_tbl_data->file_path_plain);
- EM_DEBUG_LOG("input_mail_tbl_data->file_path_html[%s]", input_mail_tbl_data->file_path_html);
- EM_DEBUG_LOG("input_mail_tbl_data->body->attachment_num[%d]", input_mail_tbl_data->attachment_count);
-
+ if ( (input_mail_tbl_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0 && !input_mail_tbl_data->body_download_status) {
+ EM_DEBUG_EXCEPTION("input_mail_tbl_data->body_download_status[%p]", input_mail_tbl_data->body_download_status);
+ error = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ if ( (error = emcore_make_envelope_from_mail(input_mail_tbl_data, &envelope)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_make_envelope_from_mail failed [%d]", error);
+ goto FINISH_OFF;
+ }
+
+ EM_DEBUG_LOG("input_mail_tbl_data->file_path_plain[%s]", input_mail_tbl_data->file_path_plain);
+ EM_DEBUG_LOG("input_mail_tbl_data->file_path_html[%s]", input_mail_tbl_data->file_path_html);
+ EM_DEBUG_LOG("input_mail_tbl_data->file_path_mime_entity[%s]", input_mail_tbl_data->file_path_mime_entity);
+ EM_DEBUG_LOG("input_mail_tbl_data->body->attachment_num[%d]", input_mail_tbl_data->attachment_count);
+
+ if ((input_mail_tbl_data->attachment_count > 0) || (input_mail_tbl_data->file_path_plain && input_mail_tbl_data->file_path_html)) {
+ EM_DEBUG_LOG("attachment_num [%d]", input_mail_tbl_data->attachment_count);
+
+ root_body = mail_newbody();
+ param = mail_newbody_parameter();
+
+ if (root_body == NULL) {
+ EM_DEBUG_EXCEPTION("mail_newbody failed...");
+ error = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
- if ((input_mail_tbl_data->attachment_count > 0) || (input_mail_tbl_data->file_path_plain && input_mail_tbl_data->file_path_html)) {
- EM_DEBUG_LOG("attachment_num : %d", input_mail_tbl_data->attachment_count);
- root_body = mail_newbody();
+ if (input_mail_tbl_data->smime_type == EMAIL_SMIME_NONE) {
- if (root_body == NULL) {
- EM_DEBUG_EXCEPTION("mail_newbody failed...");
- error = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
root_body->type = TYPEMULTIPART;
root_body->subtype = EM_SAFE_STRDUP("MIXED");
- root_body->contents.text.data = NULL;
- root_body->contents.text.size = 0;
- root_body->size.bytes = 0;
+ param = NULL;
+
+ } else if (input_mail_tbl_data->smime_type == EMAIL_SMIME_SIGNED) {
+ PARAMETER *protocol_param = mail_newbody_parameter();
+
+ root_body->type = TYPEMULTIPART;
+ root_body->subtype = EM_SAFE_STRDUP("SIGNED");
+
+ param->attribute = cpystr("micalg");
+ switch (input_mail_tbl_data->digest_type) {
+ case DIGEST_TYPE_SHA1:
+ param->value = cpystr("sha1");
+ break;
+ case DIGEST_TYPE_MD5:
+ param->value = cpystr("md5");
+ break;
+ default:
+ EM_DEBUG_EXCEPTION("Invalid digest type");
+ break;
+ }
+
+ protocol_param->attribute = cpystr("protocol");
+ protocol_param->value = cpystr("application/pkcs7-signature");
+ protocol_param->next = NULL;
+ param->next = protocol_param;
+
+ input_mail_tbl_data->file_path_plain = NULL;
+ input_mail_tbl_data->file_path_html = NULL;
+
+ input_attachment_tbl = input_attachment_tbl + (input_attachment_count - 1);
+
+ input_attachment_count = 1;
+
+ } else {
+
+ root_body->type = TYPEAPPLICATION;
+ root_body->subtype = EM_SAFE_STRDUP("PKCS7-MIME");
+
+ param->attribute = cpystr("name");
+ param->value = cpystr("smime.p7m");
+ param->next = NULL;
+
+ input_mail_tbl_data->file_path_plain = NULL;
+ input_mail_tbl_data->file_path_html = NULL;
+ input_mail_tbl_data->file_path_mime_entity = NULL;
+
+ input_attachment_count = 1;
+ }
+
+ root_body->contents.text.data = NULL;
+ root_body->contents.text.size = 0;
+ root_body->size.bytes = 0;
+ root_body->parameter = param;
+
+ if (input_mail_tbl_data->smime_type == EMAIL_SMIME_NONE) {
part_for_text = attach_mutipart_with_sub_type(root_body, "ALTERNATIVE", &error);
if (!part_for_text) {
}
text_body = &part_for_text->body;
-
- if (input_mail_tbl_data->file_path_plain && strlen(input_mail_tbl_data->file_path_plain) > 0) {
- EM_DEBUG_LOG("file_path_plain[%s]", input_mail_tbl_data->file_path_plain);
- if (!attach_part(text_body, (unsigned char *)input_mail_tbl_data->file_path_plain, 0, NULL, NULL, false, &error)) {
- EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
- goto FINISH_OFF;
- }
+ }
+
+ if (input_mail_tbl_data->file_path_plain && strlen(input_mail_tbl_data->file_path_plain) > 0) {
+ EM_DEBUG_LOG("file_path_plain[%s]", input_mail_tbl_data->file_path_plain);
+ if (!attach_part(text_body, (unsigned char *)input_mail_tbl_data->file_path_plain, 0, NULL, NULL, false, &error)) {
+ EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+ goto FINISH_OFF;
}
-
- if (input_mail_tbl_data->file_path_html && strlen(input_mail_tbl_data->file_path_html) > 0) {
- EM_DEBUG_LOG("file_path_html[%s]", input_mail_tbl_data->file_path_html);
+ }
- part_for_html = attach_mutipart_with_sub_type(text_body, "RELATED", &error);
- if (!part_for_html) {
- EM_DEBUG_EXCEPTION("attach_mutipart_with_sub_type [part_for_html] failed [%d]", error);
- goto FINISH_OFF;
- }
+ if (input_mail_tbl_data->file_path_html && strlen(input_mail_tbl_data->file_path_html) > 0) {
+ EM_DEBUG_LOG("file_path_html[%s]", input_mail_tbl_data->file_path_html);
- if (!attach_part(&(part_for_html->body) , (unsigned char *)input_mail_tbl_data->file_path_html, 0, NULL, "html", false, &error)) {
- EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
- goto FINISH_OFF;
- }
+ part_for_html = attach_mutipart_with_sub_type(text_body, "RELATED", &error);
+ if (!part_for_html) {
+ EM_DEBUG_EXCEPTION("attach_mutipart_with_sub_type [part_for_html] failed [%d]", error);
+ goto FINISH_OFF;
}
+
+ if (!attach_part(&(part_for_html->body) , (unsigned char *)input_mail_tbl_data->file_path_html, 0, NULL, "html", false, &error)) {
+ EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+ goto FINISH_OFF;
+ }
+ }
+
+ if (input_mail_tbl_data->file_path_mime_entity && strlen(input_mail_tbl_data->file_path_mime_entity) > 0) {
+ EM_DEBUG_LOG("file_path_mime_entity[%s]", input_mail_tbl_data->file_path_mime_entity);
+ root_body->sparep = EM_SAFE_STRDUP(input_mail_tbl_data->file_path_mime_entity);
+ }
+
+ if (input_attachment_tbl && input_attachment_count) {
+ emstorage_attachment_tbl_t *temp_attachment_tbl = NULL;
+ char *name = NULL;
+ BODY *body_to_attach = NULL;
+ struct stat st_buf;
- if (input_attachment_tbl && input_attachment_count) {
- emstorage_attachment_tbl_t *temp_attachment_tbl = NULL;
- char *name = NULL;
- BODY *body_to_attach = NULL;
- struct stat st_buf;
-
- for(i = 0; i < input_attachment_count; i++) {
- temp_attachment_tbl = input_attachment_tbl + i;
- EM_DEBUG_LOG("attachment_name[%s], attachment_path[%s]", temp_attachment_tbl->attachment_name, temp_attachment_tbl->attachment_path);
- if (stat(temp_attachment_tbl->attachment_path, &st_buf) == 0) {
- if (!temp_attachment_tbl->attachment_name) {
- if (!emcore_get_file_name(temp_attachment_tbl->attachment_path, &name, &error)) {
- EM_DEBUG_EXCEPTION("emcore_get_file_name failed [%d]", error);
- continue;
- }
- }
- else
- name = temp_attachment_tbl->attachment_name;
- EM_DEBUG_LOG("name[%s]", name);
-
- if (temp_attachment_tbl->attachment_inline_content_status && part_for_html)
- body_to_attach = &(part_for_html->body);
- else
- body_to_attach = root_body;
-
- if (!attach_part(body_to_attach, (unsigned char *)temp_attachment_tbl->attachment_path, 0, name, NULL, temp_attachment_tbl->attachment_inline_content_status, &error)) {
- EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+ for(i = 0; i < input_attachment_count; i++) {
+ temp_attachment_tbl = input_attachment_tbl + i;
+ EM_DEBUG_LOG("attachment_name[%s], attachment_path[%s]", temp_attachment_tbl->attachment_name, temp_attachment_tbl->attachment_path);
+ if (stat(temp_attachment_tbl->attachment_path, &st_buf) == 0) {
+ if (!temp_attachment_tbl->attachment_name) {
+ if (!emcore_get_file_name(temp_attachment_tbl->attachment_path, &name, &error)) {
+ EM_DEBUG_EXCEPTION("emcore_get_file_name failed [%d]", error);
continue;
}
}
+ else
+ name = temp_attachment_tbl->attachment_name;
+
+ EM_DEBUG_LOG("name[%s]", name);
+
+ if (temp_attachment_tbl->attachment_inline_content_status && part_for_html)
+ body_to_attach = &(part_for_html->body);
+ else
+ body_to_attach = root_body;
+
+ if (!attach_part(body_to_attach, (unsigned char *)temp_attachment_tbl->attachment_path, 0, name, NULL, temp_attachment_tbl->attachment_inline_content_status, &error)) {
+ EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+ continue;
+ }
}
}
- text_body = NULL;
}
- else {
- text_body = mail_newbody();
-
- if (text_body == NULL) {
- EM_DEBUG_EXCEPTION("mail_newbody failed...");
-
- error = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- text_body->type = TYPETEXT;
- text_body->encoding = ENC8BIT;
- if (input_mail_tbl_data->file_path_plain || input_mail_tbl_data->file_path_html)
- text_body->sparep = EM_SAFE_STRDUP(input_mail_tbl_data->file_path_plain ? input_mail_tbl_data->file_path_plain : input_mail_tbl_data->file_path_html);
- else
- text_body->sparep = NULL;
+ text_body = NULL;
+ }
+ else {
+ text_body = mail_newbody();
+
+ if (text_body == NULL) {
+ EM_DEBUG_EXCEPTION("mail_newbody failed...");
- if (input_mail_tbl_data->file_path_html != NULL && input_mail_tbl_data->file_path_html[0] != '\0')
- text_body->subtype = EM_SAFE_STRDUP("html");
- if (text_body->sparep)
- text_body->size.bytes = strlen(text_body->sparep);
- else
- text_body->size.bytes = 0;
+ error = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
}
+
+ text_body->type = TYPETEXT;
+ text_body->encoding = ENC8BIT;
+ if (input_mail_tbl_data->file_path_plain || input_mail_tbl_data->file_path_html)
+ text_body->sparep = EM_SAFE_STRDUP(input_mail_tbl_data->file_path_plain ? input_mail_tbl_data->file_path_plain : input_mail_tbl_data->file_path_html);
+ else
+ text_body->sparep = NULL;
+
+ if (input_mail_tbl_data->file_path_html != NULL && input_mail_tbl_data->file_path_html[0] != '\0')
+ text_body->subtype = EM_SAFE_STRDUP("html");
+ if (text_body->sparep)
+ text_body->size.bytes = strlen(text_body->sparep);
+ else
+ text_body->size.bytes = 0;
}
- else { /* Report mail */
+
+
+ if (input_mail_tbl_data->report_status & EMAIL_MAIL_REPORT_MDN) {
+ /* Report mail */
EM_DEBUG_LOG("REPORT MAIL");
envelope->references = cpystr(input_mail_tbl_data->message_id);
- /* Below codes should not be here. TODO : Move these to proper location. */
-#ifdef __FEATURE_SUPPORT_REPORT_MAIL__
- if (emcore_get_report_mail_body(envelope, &root_body, &error)) {
- if (!input_mail_tbl_data) {
- input_mail_tbl_data->file_path_plain = EM_SAFE_STRDUP(root_body->nested.part->body.sparep);
- input_mail_tbl_data->attachment_count = 1;
- input_attachment_count = 1;
-
- if(input_attachment_tbl)
- emstorage_free_attachment(&input_attachment_tbl, input_attachment_count, NULL);
-
- input_attachment_tbl = em_malloc(sizeof(emstorage_attachment_tbl_t));
- if (!input_attachment_tbl) {
- EM_DEBUG_EXCEPTION("malloc failed...");
- EM_SAFE_FREE(input_mail_tbl_data->file_path_plain);
- error = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- input_mail_tbl_data->body->attachment->downloaded = 1;
- input_mail_tbl_data->body->attachment->savename = EM_SAFE_STRDUP(root_body->nested.part->next->body.sparep);
-
- char *p = NULL;
-
- if (!emcore_get_file_name(input_mail_tbl_data->body->attachment->savename, &p, &error)) {
- EM_DEBUG_EXCEPTION("emcore_get_file_name failed [%d]", error);
- goto FINISH_OFF;
- }
-
- input_mail_tbl_data->body->attachment->name = cpystr(p);
- }
- }
-#endif
}
if (file_path) {
- EM_DEBUG_LOG("write rfc822 : file_path[%s]", file_path);
+ EM_DEBUG_LOG("write rfc822 : file_path[%s]", file_path);
if (part_for_html)
html_body = &(part_for_html->body);
- if (!emcore_write_rfc822(envelope, root_body ? root_body : text_body, html_body, extra_flag, &fname, &error)) {
+ if (!emcore_write_rfc822(envelope, root_body ? root_body : text_body, html_body, input_mail_tbl_data->priority, input_mail_tbl_data->report_status, &fname, &error)) {
EM_DEBUG_EXCEPTION("emcore_write_rfc822 failed [%d]", error);
goto FINISH_OFF;
}
if (err_code != NULL)
*err_code = error;
+
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
}
char temp_file_path_html[512];
char *pAdd = NULL;
char *fname = NULL;
- email_extra_flag_t extra_flag;
- email_account_t *ref_account = NULL;
+ emstorage_account_tbl_t *ref_account = NULL;
if (!input_mail_tbl_data) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
goto FINISH_OFF;
}
- if (input_mail_tbl_data->report_status != EMAIL_MAIL_REPORT_MDN && !input_mail_tbl_data->body_download_status) {
+ if ( (input_mail_tbl_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0 && !input_mail_tbl_data->body_download_status) {
EM_DEBUG_EXCEPTION("input_mail_tbl_data->body_download_status[%p]", input_mail_tbl_data->body_download_status);
error = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(input_mail_tbl_data->account_id);
+ if (!emstorage_get_account_by_id(input_mail_tbl_data->account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &ref_account, true, &error)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed : [%d]", error);
+ goto FINISH_OFF;
+ }
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_mail_tbl_data->account_id);
else {
envelope->date = (unsigned char *)cpystr((const char *)rfc822_date_string);
}
- /* memcpy(&extra_flag, &input_mail_tbl_data->info->extra_flags, sizeof(email_extra_flag_t)); */
/* check report input_mail_tbl_data */
/* Non-report input_mail_tbl_data */
memset(temp_file_path_html, 0x00, sizeof(temp_file_path_html));
SNPRINTF(temp_file_path_html, sizeof(temp_file_path_html), "%s%s%s%s%s", MAILHOME, DIR_SEPERATOR, MAILTEMP, DIR_SEPERATOR, "UTF-8.htm");
- if (!emstorage_copy_file(input_mail_tbl_data->file_path_plain, temp_file_path_html, 0, &error)) {
+ if (!emstorage_copy_file(input_mail_tbl_data->file_path_html, temp_file_path_html, 0, &error)) {
EM_DEBUG_EXCEPTION("emstorage_copy_file failed : [%d]", error);
goto FINISH_OFF;
}
if (part_for_html)
html_body = &(part_for_html->body);
- if (!emcore_write_rfc822(envelope, root_body ? root_body : text_body, html_body, extra_flag, &fname, &error)) {
+ if (!emcore_write_rfc822(envelope, root_body ? root_body : text_body, html_body, input_mail_tbl_data->priority, input_mail_tbl_data->report_status, &fname, &error)) {
EM_DEBUG_EXCEPTION("emcore_write_rfc822 failed [%d]", error);
goto FINISH_OFF;
}
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
-
- if (envelope->from->personal)
+
+ /*
+ if (envelope->from->personal)
SNPRINTF(buf, sizeof(buf), "%s <%s@%s>", envelope->from->personal, envelope->from->mailbox, envelope->from->host);
- else
+ else
+ */
SNPRINTF(buf, sizeof(buf), "%s@%s", envelope->from->mailbox, envelope->from->host);
fprintf(fp, "Your message has been read by %s"CRLF_STRING, buf);
text_body->type = TYPETEXT;
text_body->encoding = ENC8BIT;
- text_body->sparep = fname;
+ text_body->sparep = EM_SAFE_STRDUP(fname);
text_body->size.bytes = (unsigned long)sz;
if (!emcore_get_temp_file_name(&fname, &err)) {
memset(&temp_attachment_tbl, 0x00, sizeof(emstorage_attachment_tbl_t));
- temp_attachment_tbl.attachment_path = fname;
+ temp_attachment_tbl.attachment_path = EM_SAFE_STRDUP(fname);
if (!emcore_get_file_size(fname, &temp_attachment_tbl.attachment_size, &err)) {
EM_DEBUG_EXCEPTION(" emcore_get_file_size failed [%d]", err);
goto FINISH_OFF;
}
- param->attribute = EM_SAFE_STRDUP("report-type");
- param->value = EM_SAFE_STRDUP("disposition-notification");
- param->next = m_body->parameter;
+ param->attribute = EM_SAFE_STRDUP("report-type");
+ param->value = EM_SAFE_STRDUP("disposition-notification");
+ param->next = m_body->parameter;
m_body->parameter = param;
p_body = &m_body->nested.part->next->body;
/* set content-type to message/disposition-notification */
- p_body->type = TYPEMESSAGE;
- p_body->encoding = ENC7BIT;
+ p_body->type = TYPEMESSAGE;
+ p_body->encoding = ENC7BIT;
EM_SAFE_FREE(p_body->subtype);
if (err_code != NULL)
*err_code = err;
-
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
return ret;
}
#endif
#define EMAIL_CH_SPACE ' '
#define EMAIL_NOTI_ICON_PATH "/opt/data/email/res/image/Q02_Notification_email.png"
-static char _g_display[G_DISPLAY_LENGTH];
-
-
typedef struct _em_transaction_info_type_t {
int mail_id;
int handle;
em_transaction_info_type_t *g_transaction_info_list;
-static email_option_t g_mail_option =
-{
- 0, /* priority */
- 1, /* keep_local_copy */
- 0, /* req_delivery_receipt */
- 0, /* req_read_receipt */
- 0, /* download_limit */
- 0, /* block_address */
- 0, /* block_subject */
- NULL, /* diplay name */
-};
-
static email_session_t g_session_list[SESSION_MAX] = { {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0},};
-
typedef struct emcore_account_list_t emcore_account_list_t;
struct emcore_account_list_t {
email_account_t *account;
return 1;
}
-email_option_t *emcore_get_option(int *err_code)
-{
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_NONE;
-
- return &g_mail_option;
-}
-
-INTERNAL_FUNC int emcore_set_option(email_option_t *opt, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("opt[%p], err_code[%p]", opt, err_code);
-
- int err = EMAIL_ERROR_NONE;
-
- if (!opt) {
- EM_DEBUG_EXCEPTION("opt[%p]", opt);
-
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return false;
- }
-
- memset(_g_display, 0, G_DISPLAY_LENGTH);
- memcpy(&g_mail_option, opt, sizeof(g_mail_option));
-
- if (opt->display_name_from && opt->display_name_from[0] != '\0') {
- strncpy(_g_display, opt->display_name_from, G_DISPLAY_LENGTH - 1);
- g_mail_option.display_name_from = _g_display;
- }
- else
- g_mail_option.display_name_from = NULL;
-
- if (err_code != NULL)
- *err_code = err;
-
- return true;
-}
-
-
-
-
-
/* in smtp case, path argument must be ENCODED_PATH_SMTP */
int emcore_get_long_encoded_path_with_account_info(email_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code)
{
local_preview_buffer_length = input_preview_buffer_length * 2;
- if (input_html_path != NULL) {
+ if ( input_html_path != NULL) {
/* get preview text from html file */
if( (err = em_get_encoding_type_from_file_path(input_html_path, &encoding_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%s]", err);
goto FINISH_OFF;
}
-
+
if (stat(input_html_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_html_path);
err = EMAIL_ERROR_INVALID_MAIL;
goto FINISH_OFF;
}
-
+
if (!(fp = fopen(input_html_path, "r"))) {
EM_DEBUG_EXCEPTION("fopen failed [%s]", input_html_path);
err = EMAIL_ERROR_SYSTEM_FAILURE;
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
-
+
byte_read = fread(local_preview_text, sizeof(char), st_buf.st_size, fp);
-
+
if (ferror(fp)) {
EM_DEBUG_EXCEPTION("fread failed [%s]", input_plain_path);
err = EMAIL_ERROR_SYSTEM_FAILURE;
result_strlen = EM_SAFE_STRLEN(local_preview_text);
}
- if (local_preview_text == NULL && input_plain_path != NULL) {
+ if ( (local_preview_text == NULL || (local_preview_text && strlen(local_preview_text) == 0) ) && input_plain_path != NULL) {
/* get preview text from plain text file */
if( (err = em_get_encoding_type_from_file_path(input_plain_path, &encoding_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%s]", err);
goto FINISH_OFF;
}
-
+
if (!(fp = fopen(input_plain_path, "r"))) {
EM_DEBUG_EXCEPTION("fopen failed [%s]", input_plain_path);
err = EMAIL_ERROR_SYSTEM_FAILURE;
EM_DEBUG_EXCEPTION("em_malloc failed");
goto FINISH_OFF;
}
-
+
byte_read = fread(local_preview_text, sizeof(char), local_preview_buffer_length - 1, fp);
-
+
if (ferror(fp)) {
EM_DEBUG_EXCEPTION("fread failed [%s]", input_plain_path);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
- reg_replace(local_preview_text, CR_STRING, "");
- reg_replace(local_preview_text, LF_STRING, "");
- reg_replace(local_preview_text, TAB_STRING, "");
-
+ reg_replace(local_preview_text, CR_STRING, " ");
+ reg_replace(local_preview_text, LF_STRING, " ");
+ reg_replace(local_preview_text, TAB_STRING, " ");
+
result_strlen = EM_SAFE_STRLEN(local_preview_text);
- }
-
+ }
+
+
if(local_preview_text) {
+ em_trim_left(local_preview_text);
if(encoding_type && strcasecmp(encoding_type, "UTF-8") != 0) {
EM_DEBUG_LOG("encoding_type [%s]", encoding_type);
utf8_encoded_string = (char*)g_convert (local_preview_text, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
reg_replace(source_string, CR_STRING, " ");
reg_replace(source_string, LF_STRING, " ");
- reg_replace(source_string, TAB_STRING, " ");
reg_replace(source_string, "<head[^>]*>", "<head>"); /* "<()*head([^>])*>", "<head>" */
reg_replace(source_string, "<*/head>", "</head>"); /* "(<()*(/)()*head()*>)", "</head>" */
reg_replace(source_string, "<head>.*</head>", ""); /* "(<head>).*(</head>)", "" */
+ reg_replace(source_string, "<style[^>]*>.*</style>", "");
reg_replace(source_string, "<*/p>", " ");
reg_replace(source_string, "<br>", " ");
return result;
}
-#define MAX_NOTI_STRING_LENGTH 8096
-
-INTERNAL_FUNC int emcore_convert_structure_to_string(void *struct_var, char **encoded_string, email_convert_struct_type_e type)
-{
- EM_DEBUG_FUNC_BEGIN("Struct type[%d]", type);
-
- char *buf = NULL;
- char delimiter[] = {0x01, 0x00};
- int error_code = EMAIL_ERROR_NONE;
-
- buf = (char *) malloc(MAX_NOTI_STRING_LENGTH * sizeof(char));
- if (NULL == buf) {
- error_code = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
- switch (type) {
- case EMAIL_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM: {
- email_mail_list_item_t *item = (email_mail_list_item_t *)struct_var;
- SNPRINTF(buf, MAX_NOTI_STRING_LENGTH,
- "%d%c" /* int mail_id ; */
- "%d%c" /* int account_id ; */
- "%d%c" /* int mailbox_id ; */
- "%s%c" /* char from[STRING_LENGTH_FOR_DISPLAY] ; */
- "%s%c" /* char from_email_address[MAX_EMAIL_ADDRESS_LENGTH]; */
- "%s%c" /* char recipients[STRING_LENGTH_FOR_DISPLAY] ; */
- "%s%c" /* char subject[STRING_LENGTH_FOR_DISPLAY] ; */
- "%d%c" /* int is_text_downloaded ; */
- "%d%c" /* time_t date_time ; */
- "%d%c" /* int flags_seen_field ; */
- "%d%c" /* int priority ; */
- "%d%c" /* int save_status ; */
- "%d%c" /* int is_locked ; */
- "%d%c" /* int is_report_mail ; */
- "%d%c" /* int recipients_count ; */
- "%d%c" /* int has_attachment ; */
- "%d%c" /* int has_drm_attachment ; */
- "%s%c" /* char previewBodyText[MAX_PREVIEW_TEXT_LENGTH] ; */
- "%d%c" /* int thread_id ; */
- "%d%c", /* int thread_item_count ; */
-
- item->mail_id, delimiter[0],
- item->account_id, delimiter[0],
- item->mailbox_id, delimiter[0],
- item->from, delimiter[0],
- item->from_email_address, delimiter[0],
- item->recipients, delimiter[0],
- item->subject, delimiter[0],
- item->is_text_downloaded, delimiter[0],
- (unsigned int)item->date_time, delimiter[0],
- item->flags_seen_field, delimiter[0],
- item->priority, delimiter[0],
- item->save_status, delimiter[0],
- item->is_locked, delimiter[0],
- item->is_report_mail, delimiter[0],
- item->recipients_count, delimiter[0],
- item->has_attachment, delimiter[0],
- item->has_drm_attachment, delimiter[0],
- item->previewBodyText, delimiter[0],
- item->thread_id, delimiter[0],
- item->thread_item_count, delimiter[0]
- );
- }
- break;
- }
-
-FINISH_OFF:
- if (encoded_string)
- *encoded_string = buf;
- EM_DEBUG_FUNC_END("Struct -> String:[%s]\n", buf);
- return error_code;
-}
-
-INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, void **struct_var, email_convert_struct_type_e type)
-{
- EM_DEBUG_FUNC_BEGIN();
-
- int ret = false;
- void *temp_struct = NULL;
- char *buff = NULL;
- char *current_pos = NULL;
- char *found_pos = NULL;
- char delimiter[] = {0x01, 0x00};
- int error_code = EMAIL_ERROR_NONE;
-
- EM_DEBUG_LOG("Struct Type[%d], String:[%s]", type, encoded_string);
-
- buff = (char *)EM_SAFE_STRDUP(encoded_string);
- if (NULL == buff) {
- error_code = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- switch (type) {
- case EMAIL_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM: {
- email_mail_list_item_t *item = (email_mail_list_item_t *)malloc(sizeof(email_mail_list_item_t));
- if (NULL == item) {
- error_code = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
- temp_struct = (void *)item;
-
- current_pos = buff;
-
- /* mail_id */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->mail_id = atoi(current_pos);
- EM_DEBUG_LOG("mail_id[%d]", item->mail_id);
- current_pos = found_pos + 1;
-
- /* account_id */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->account_id = atoi(current_pos);
- EM_DEBUG_LOG("account_id[%d]", item->account_id);
- current_pos = found_pos + 1;
-
- /* mailbox_id */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->mailbox_id = atoi(current_pos);
- EM_DEBUG_LOG("mailbox_id[%s]", item->mailbox_id);
- current_pos = found_pos + 1;
-
- /* from */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- strncpy(item->from, current_pos, STRING_LENGTH_FOR_DISPLAY-1);
- EM_DEBUG_LOG("from[%s]", item->from);
- current_pos = found_pos + 1;
-
- /* from_email_address */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- strncpy(item->from_email_address, current_pos, STRING_LENGTH_FOR_DISPLAY-1);
- EM_DEBUG_LOG("from_email_address[%s]", item->from_email_address);
- current_pos = found_pos + 1;
-
- /* recipients */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- strncpy(item->recipients, current_pos, STRING_LENGTH_FOR_DISPLAY-1);
- EM_DEBUG_LOG("recipients[%s]", item->recipients);
- current_pos = found_pos + 1;
-
- /* subject */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- strncpy(item->subject, current_pos, STRING_LENGTH_FOR_DISPLAY-1);
- EM_DEBUG_LOG("subject[%s]", item->subject);
- current_pos = found_pos + 1;
-
- /* is_text_downloaded */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->is_text_downloaded = atoi(current_pos);
- EM_DEBUG_LOG("is_text_downloaded[%d]", item->is_text_downloaded);
- current_pos = found_pos + 1;
-
- /* datatime */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->date_time = atoi(current_pos);
- EM_DEBUG_LOG("date_time[%d]", item->date_time);
- current_pos = found_pos + 1;
-
- /* flags_seen_field */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->flags_seen_field = atoi(current_pos);
- EM_DEBUG_LOG("flags_seen_field[%d]", item->flags_seen_field);
- current_pos = found_pos + 1;
-
- /* priority */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->priority = atoi(current_pos);
- EM_DEBUG_LOG("priority[%d]", item->priority);
- current_pos = found_pos + 1;
-
- /* save_status */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->save_status = atoi(current_pos);
- EM_DEBUG_LOG("save_status[%d]", item->save_status);
- current_pos = found_pos + 1;
-
- /* is_locked */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->is_locked = atoi(current_pos);
- EM_DEBUG_LOG("is_locked[%d]", item->is_locked);
- current_pos = found_pos + 1;
-
- /* is_report_mail */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->is_report_mail = atoi(current_pos);
- EM_DEBUG_LOG("is_report_mail[%d]", item->is_report_mail);
- current_pos = found_pos + 1;
-
- /* recipients_count */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->recipients_count = atoi(current_pos);
- EM_DEBUG_LOG("is_report_mail[%d]", item->recipients_count);
- current_pos = found_pos + 1;
-
- /* has_attachment */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->has_attachment = atoi(current_pos);
- EM_DEBUG_LOG("has_attachment[%d]", item->has_attachment);
- current_pos = found_pos + 1;
-
- /* has_drm_attachment */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->has_drm_attachment = atoi(current_pos);
- EM_DEBUG_LOG("has_drm_attachment[%d]", item->has_drm_attachment);
- current_pos = found_pos + 1;
-
- /* previewBodyText */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- strncpy(item->previewBodyText, current_pos, MAX_PREVIEW_TEXT_LENGTH-1);
- EM_DEBUG_LOG("previewBodyText[%s]", item->previewBodyText);
- current_pos = found_pos + 1;
-
- /* thread_id */
- found_pos = strstr(current_pos, delimiter);
- if (NULL == found_pos) {
- error_code = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- *found_pos = NULL_CHAR;
- item->thread_id = atoi(current_pos);
- EM_DEBUG_LOG("thread_id[%d]", item->thread_id);
- current_pos = found_pos + 1;
-
- /* thread_item_count - the last item */
- item->thread_item_count = atoi(current_pos);
- EM_DEBUG_LOG("thread_item_count[%d]", item->thread_item_count);
-
- }
- break;
-
- default:
- EM_DEBUG_EXCEPTION("Unknown structure type");
- break;
- }
-
- ret = true;
-
-FINISH_OFF:
- EM_SAFE_FREE(buff);
- if (ret == true) {
- if (struct_var)
- *struct_var = temp_struct;
- }
- else {
- switch (type) {
- case EMAIL_CONVERT_STRUCT_TYPE_MAIL_LIST_ITEM:
- EM_SAFE_FREE(temp_struct);
- break;
- default:
- break;
- }
- }
- EM_DEBUG_FUNC_END();
- return error_code;
-}
-
-
/* emcore_send_noti_for_new_mail is not used currently because DBUS could not send very long message.*/
/* But I think it can be used to notify incomming new mail for replacing NOTI_MAIL_ADD with some modification(uid should be replaced with mail_id). */
/* This notification is including addtional information comparing NOTI_MAIL_ADD. */
{
EM_DEBUG_FUNC_BEGIN();
int error_code = EMAIL_ERROR_NONE;
-
EM_DEBUG_FUNC_END();
return error_code;
}
}
if(network_status == 0) {
- if ( (err = _get_sim_status(&sim_status)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("_get_sim_status failed [%d]", err);
+ EM_DEBUG_LOG("VCONFKEY_NETWORK_STATUS is 0");
+
+ if ( (err = _get_wifi_status(&wifi_status)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("_get_wifi_status failed [%d]", err);
goto FINISH_OFF;
}
- if (sim_status != VCONFKEY_TELEPHONY_SIM_INSERTED) {
- EM_DEBUG_LOG("EMAIL_ERROR_NO_SIM_INSERTED");
- if ( (err = _get_wifi_status(&wifi_status)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("_get_wifi_status failed [%d]", err);
+ if (wifi_status == 0) {
+ EM_DEBUG_LOG("Furthermore, WIFI is off");
+
+ if ( (err = _get_sim_status(&sim_status)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("_get_sim_status failed [%d]", err);
goto FINISH_OFF;
}
- if (wifi_status == 0) {
- EM_DEBUG_EXCEPTION("Furthermore, WIFI is off");
+ if (sim_status != VCONFKEY_TELEPHONY_SIM_INSERTED) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_NO_SIM_INSERTED");
err = EMAIL_ERROR_NO_SIM_INSERTED;
goto FINISH_OFF;
}
+
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_NETWORK_NOT_AVAILABLE");
+ err = EMAIL_ERROR_NETWORK_NOT_AVAILABLE;
+ goto FINISH_OFF;
}
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_NETWORK_NOT_AVAILABLE");
- err = EMAIL_ERROR_NETWORK_NOT_AVAILABLE;
- goto FINISH_OFF;
}
EM_DEBUG_LOG("Data Network Mode is ON");
SERVER_MAILBOX_NAME_IDX_IN_MAIL_TBL,
SERVER_MAIL_ID_IDX_IN_MAIL_TBL,
MESSAGE_ID_IDX_IN_MAIL_TBL,
+ REFERENCE_ID_IDX_IN_MAIL_TBL,
FULL_ADDRESS_FROM_IDX_IN_MAIL_TBL,
FULL_ADDRESS_REPLY_IDX_IN_MAIL_TBL,
FULL_ADDRESS_TO_IDX_IN_MAIL_TBL,
" server_mail_status, "
" server_mailbox_name, "
" server_mail_id, "
- " message_id, "
+ " message_id, "
+ " reference_mail_id, "
" full_address_from, "
" full_address_reply, "
" full_address_to, "
" full_address_cc, "
" full_address_bcc, "
" full_address_return, "
- " email_address_sender, "
- " email_address_recipient, "
- " alias_sender, "
- " alias_recipient, "
+ " email_address_sender, "
+ " email_address_recipient, "
+ " alias_sender, "
+ " alias_recipient, "
" body_download_status, "
" file_path_plain, "
" file_path_html, "
" file_path_mime_entity, "
" mail_size, "
- " flags_seen_field ,"
- " flags_deleted_field ,"
- " flags_flagged_field ,"
- " flags_answered_field ,"
- " flags_recent_field ,"
- " flags_draft_field ,"
- " flags_forwarded_field,"
+ " flags_seen_field ,"
+ " flags_deleted_field ,"
+ " flags_flagged_field ,"
+ " flags_answered_field ,"
+ " flags_recent_field ,"
+ " flags_draft_field ,"
+ " flags_forwarded_field,"
" DRM_status, "
" priority, "
" save_status, "
", server_mailbox_name VARCHAR(129) \n"
", server_mail_id VARCHAR(129) \n"
", message_id VARCHAR(257) \n"
+ ", reference_mail_id INTEGER \n"
", full_address_from TEXT \n"
", full_address_reply TEXT \n"
", full_address_to TEXT \n"
_get_table_field_data_int(result, &(mail_list_item_from_tbl[i].mail_id), col_index++);
_get_table_field_data_int(result, &(mail_list_item_from_tbl[i].account_id), col_index++);
_get_table_field_data_int(result, &(mail_list_item_from_tbl[i].mailbox_id), col_index++);
- _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].from, STRING_LENGTH_FOR_DISPLAY, 1, col_index++);
- _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].from_email_address, MAX_EMAIL_ADDRESS_LENGTH, 1, col_index++);
- _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].recipients, STRING_LENGTH_FOR_DISPLAY, 1, col_index++);
+ _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].full_address_from, STRING_LENGTH_FOR_DISPLAY, 1, col_index++);
+ _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].email_address_sender, MAX_EMAIL_ADDRESS_LENGTH, 1, col_index++);
+ _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].email_address_recipient, STRING_LENGTH_FOR_DISPLAY, 1, col_index++);
_get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].subject, STRING_LENGTH_FOR_DISPLAY, 1, col_index++);
- _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].is_text_downloaded), col_index++);
+ _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].body_download_status), col_index++);
_get_table_field_data_char(result, &(mail_list_item_from_tbl[i].flags_seen_field), col_index++);
_get_table_field_data_char(result, &(mail_list_item_from_tbl[i].flags_deleted_field), col_index++);
_get_table_field_data_char(result, &(mail_list_item_from_tbl[i].flags_flagged_field), col_index++);
_get_table_field_data_char(result, &(mail_list_item_from_tbl[i].flags_recent_field), col_index++);
_get_table_field_data_char(result, &(mail_list_item_from_tbl[i].flags_draft_field), col_index++);
_get_table_field_data_char(result, &(mail_list_item_from_tbl[i].flags_forwarded_field), col_index++);
- _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].has_drm_attachment), col_index++);
- _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].priority), col_index++);
- _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].save_status), col_index++);
- _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].is_locked), col_index++);
+ _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].DRM_status), col_index++);
+ _get_table_field_data_int(result, (int*)&(mail_list_item_from_tbl[i].priority), col_index++);
+ _get_table_field_data_int(result, (int*)&(mail_list_item_from_tbl[i].save_status), col_index++);
+ _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].lock_status), col_index++);
_get_table_field_data_int(result, &local_attachment_count, col_index++);
_get_table_field_data_int(result, &local_inline_content_count, col_index++);
_get_table_field_data_time_t(result, &(mail_list_item_from_tbl[i].date_time), col_index++);
- _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].previewBodyText, MAX_PREVIEW_TEXT_LENGTH, 1, col_index++);
+ _get_table_field_data_string_without_allocation(result, mail_list_item_from_tbl[i].preview_text, MAX_PREVIEW_TEXT_LENGTH, 1, col_index++);
_get_table_field_data_int(result, &(mail_list_item_from_tbl[i].thread_id), col_index++);
_get_table_field_data_int(result, &(mail_list_item_from_tbl[i].thread_item_count), col_index++);
- _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].is_meeting_request), col_index++);
- _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].message_class), col_index++);
- _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].smime_type), col_index++);
+ _get_table_field_data_int(result, (int*)&(mail_list_item_from_tbl[i].meeting_request_status), col_index++);
+ _get_table_field_data_int(result, (int*)&(mail_list_item_from_tbl[i].message_class), col_index++);
+ _get_table_field_data_int(result, (int*)&(mail_list_item_from_tbl[i].smime_type), col_index++);
- mail_list_item_from_tbl[i].has_attachment = ((local_attachment_count - local_inline_content_count)>0)?1:0;
+ mail_list_item_from_tbl[i].attachment_count = ((local_attachment_count - local_inline_content_count)>0)?1:0;
}
EM_DEBUG_LOG(">>>> DATA ASSIGN END [count : %d] >> ", count);
EM_PROFILE_END(emstorage_query_mail_list_loop);
}
EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
+
+ sqlite3_release_memory(-1);
+
_DISCONNECT_DB;
EM_SAFE_FREE(date_time_string);
_get_table_field_data_string(result, &(p_data_tbl[i].server_mailbox_name), 0, col_index++);
_get_table_field_data_string(result, &(p_data_tbl[i].server_mail_id), 0, col_index++);
_get_table_field_data_string(result, &(p_data_tbl[i].message_id), 0, col_index++);
+ _get_table_field_data_int (result, &(p_data_tbl[i].reference_mail_id), col_index++);
_get_table_field_data_string(result, &(p_data_tbl[i].full_address_from), 1, col_index++);
_get_table_field_data_string(result, &(p_data_tbl[i].full_address_reply), 1, col_index++);
_get_table_field_data_string(result, &(p_data_tbl[i].full_address_to), 1, col_index++);
_get_table_field_data_char (result, &(p_data_tbl[i].flags_draft_field), col_index++);
_get_table_field_data_char (result, &(p_data_tbl[i].flags_forwarded_field), col_index++);
_get_table_field_data_int (result, &(p_data_tbl[i].DRM_status), col_index++);
- _get_table_field_data_int (result, &(p_data_tbl[i].priority), col_index++);
- _get_table_field_data_int (result, &(p_data_tbl[i].save_status), col_index++);
+ _get_table_field_data_int (result, (int*)&(p_data_tbl[i].priority), col_index++);
+ _get_table_field_data_int (result, (int*)&(p_data_tbl[i].save_status), col_index++);
_get_table_field_data_int (result, &(p_data_tbl[i].lock_status), col_index++);
- _get_table_field_data_int (result, &(p_data_tbl[i].report_status), col_index++);
+ _get_table_field_data_int (result, (int*)&(p_data_tbl[i].report_status), col_index++);
_get_table_field_data_int (result, &(p_data_tbl[i].attachment_count), col_index++);
_get_table_field_data_int (result, &(p_data_tbl[i].inline_content_count), col_index++);
_get_table_field_data_int (result, &(p_data_tbl[i].thread_id), col_index++);
_get_table_field_data_int (result, &(p_data_tbl[i].thread_item_count), col_index++);
_get_table_field_data_string(result, &(p_data_tbl[i].preview_text), 1, col_index++);
- _get_table_field_data_int (result, &(p_data_tbl[i].meeting_request_status), col_index++);
- _get_table_field_data_int (result, &(p_data_tbl[i].message_class), col_index++);
- _get_table_field_data_int (result, &(p_data_tbl[i].digest_type), col_index++);
- _get_table_field_data_int (result, &(p_data_tbl[i].smime_type), col_index++);
+ _get_table_field_data_int (result, (int*)&(p_data_tbl[i].meeting_request_status), col_index++);
+ _get_table_field_data_int (result, (int*)&(p_data_tbl[i].message_class), col_index++);
+ _get_table_field_data_int (result, (int*)&(p_data_tbl[i].digest_type), col_index++);
+ _get_table_field_data_int (result, (int*)&(p_data_tbl[i].smime_type), col_index++);
/* check real body file... */
if (p_data_tbl[i].body_download_status) {
struct stat buf;
EM_SAFE_FREE(p_data_tbl);
EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
+
+ sqlite3_release_memory(-1);
+
_DISCONNECT_DB;
if (err_code != NULL)
return ret;
}
-INTERNAL_FUNC int emstorage_query_mailbox_tbl(const char *input_conditional_clause, int input_get_mail_count, int input_transaction, emstorage_mailbox_tbl_t **output_mailbox_list, int *output_mailbox_count)
+INTERNAL_FUNC int emstorage_query_mailbox_tbl(const char *input_conditional_clause, const char *input_ordering_clause, int input_get_mail_count, int input_transaction, emstorage_mailbox_tbl_t **output_mailbox_list, int *output_mailbox_count)
{
- EM_DEBUG_FUNC_BEGIN("input_conditional_clause[%p], input_get_mail_count[%d], input_transaction[%d], output_mailbox_list[%p], output_mailbox_count[%d]", input_conditional_clause, input_get_mail_count, input_transaction, output_mailbox_list, output_mailbox_count);
+ EM_DEBUG_FUNC_BEGIN("input_conditional_clause[%p], input_ordering_clause [%p], input_get_mail_count[%d], input_transaction[%d], output_mailbox_list[%p], output_mailbox_count[%d]", input_conditional_clause, input_ordering_clause, input_get_mail_count, input_transaction, output_mailbox_list, output_mailbox_count);
int i = 0;
int rc;
}
else { /* with read count and total count */
col_index = 14;
- SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s, total, read FROM mail_box_tbl AS MBT LEFT OUTER JOIN (SELECT mailbox_name, count(mail_id) AS total, SUM(flags_seen_field) AS read FROM mail_tbl GROUP BY mailbox_name) AS MT ON MBT.mailbox_name = MT.mailbox_name %s", fields, input_conditional_clause);
+ SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s, total, read FROM mail_box_tbl AS MBT LEFT OUTER JOIN (SELECT mailbox_name, count(mail_id) AS total, SUM(flags_seen_field) AS read FROM mail_tbl %s GROUP BY mailbox_name) AS MT ON MBT.mailbox_name = MT.mailbox_name %s %s", fields, input_conditional_clause, input_conditional_clause, input_ordering_clause);
}
EM_DEBUG_LOG("query[%s]", sql_query_string);
int ret = false;
int error = EMAIL_ERROR_NONE;
char conditional_clause_string[QUERY_SIZE] = {0, };
+ char ordering_clause_string[QUERY_SIZE] = {0, };
if (account_id == ALL_ACCOUNT) {
if (local_yn == EMAIL_MAILBOX_FROM_SERVER || local_yn == EMAIL_MAILBOX_FROM_LOCAL)
SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " AND local_yn = %d ", local_yn);
}
+ EM_DEBUG_LOG("conditional_clause_string[%s]", conditional_clause_string);
+
switch (sort_type) {
case EMAIL_MAILBOX_SORT_BY_NAME_ASC :
- SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " ORDER BY mailbox_name ASC");
+ SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY mailbox_name ASC");
break;
case EMAIL_MAILBOX_SORT_BY_NAME_DSC :
- SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " ORDER BY mailbox_name DESC");
+ SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY mailbox_name DESC");
break;
case EMAIL_MAILBOX_SORT_BY_TYPE_ASC :
- SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " ORDER BY mailbox_type ASC");
+ SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY mailbox_type ASC");
break;
case EMAIL_MAILBOX_SORT_BY_TYPE_DSC :
- SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " ORDER BY mailbox_type DEC");
+ SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY mailbox_type DEC");
break;
}
- EM_DEBUG_LOG("conditional_clause_string[%s]", conditional_clause_string);
+ EM_DEBUG_LOG("ordering_clause_string[%s]", ordering_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+ if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, ordering_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
int error = EMAIL_ERROR_NONE;
int where_clause_count = 0;
char conditional_clause_string[QUERY_SIZE] = {0, };
+ char ordering_clause_string[QUERY_SIZE] = {0, };
if (!select_num || !mailbox_list) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " AND account_id = %d ", account_id);
}
- SNPRINTF(conditional_clause_string + strlen(conditional_clause_string), sizeof(conditional_clause_string)-(strlen(conditional_clause_string)+1), " ORDER BY MBT.mailbox_name ");
+ SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY MBT.mailbox_name ");
EM_DEBUG_LOG("conditional_clause_string[%s]", conditional_clause_string);
+ EM_DEBUG_LOG("ordering_clause_string[%s]", ordering_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, 1, 1, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+ if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, ordering_clause_string, 1, 1, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
char conditional_clause_string[QUERY_SIZE] = {0, };
if (parent_mailbox_name)
- SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND UPPER(mailbox_name) LIKE UPPER('%s/%%') ORDER BY mailbox_name", account_id, parent_mailbox_name);
+ SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND UPPER(mailbox_name) LIKE UPPER('%s/%%')", account_id, parent_mailbox_name);
else
- SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND (mailbox_name NOT LIKE '%%/%%') ORDER BY mailbox_name", account_id);
+ SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND (mailbox_name NOT LIKE '%%/%%')", account_id);
EM_DEBUG_LOG("conditional_clause_string", conditional_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+ if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, " ORDER BY mailbox_name", 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
int error = EMAIL_ERROR_NONE;
char conditional_clause_string[QUERY_SIZE] = {0, };
- SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND modifiable_yn = 0 ORDER BY mailbox_name", account_id);
+ SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND modifiable_yn = 0", account_id);
EM_DEBUG_LOG("conditional_clause_string [%s]", conditional_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+ if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, " ORDER BY mailbox_name", 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, 0, transaction, result_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
+ if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, "", 0, transaction, result_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_type[%d], mailbox_name[%p], transaction[%d], err_code[%p]", account_id, mailbox_type, mailbox_name, transaction, err_code);
- if (account_id < FIRST_ACCOUNT_ID || (mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS) || !mailbox_name) {
+ if (account_id < FIRST_ACCOUNT_ID || (mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_USER_DEFINED) || !mailbox_name) {
EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_type[%d], mailbox_name[%p]", account_id, mailbox_type, mailbox_name);
EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string);
- if( (ret = emstorage_query_mailbox_tbl(conditional_clause_string, false, false, output_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
+ if( (ret = emstorage_query_mailbox_tbl(conditional_clause_string, "", false, false, output_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", ret);
goto FINISH_OFF;
}
return ret;
}
+INTERNAL_FUNC int emstorage_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox, int transaction)
+{
+ EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], new_mailbox_type[%d], transaction[%d], err_code[%p]", input_mailbox_id, input_is_local_mailbox, transaction);
+
+ int rc, ret = false;
+ int error = EMAIL_ERROR_NONE;
+ char sql_query_string[QUERY_SIZE] = {0, };
+
+ if (input_mailbox_id < 0) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ return EMAIL_ERROR_INVALID_PARAM;
+ }
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection();
+
+ EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+
+ EM_DEBUG_LOG("emstorage_update_mailbox_type");
+
+ DB_STMT hStmt = NULL;
+ int i = 0;
+
+ /* Update mail_box_tbl */
+ SNPRINTF(sql_query_string, sizeof(sql_query_string),
+ "UPDATE mail_box_tbl SET"
+ " local_yn = ?"
+ " WHERE mailbox_id = %d"
+ , input_mailbox_id);
+
+ EM_DEBUG_LOG("SQL(%s)", sql_query_string);
+
+ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, strlen(sql_query_string), &hStmt, NULL), rc);
+ EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+ ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
+
+ _bind_stmt_field_data_int(hStmt, i++, input_is_local_mailbox);
+
+ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
+ EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+ ("sqlite3_step fail:%d", rc));
+ EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+ ("sqlite3_step fail:%d", rc));
+
+ if (hStmt != NULL) {
+ rc = sqlite3_finalize(hStmt);
+ if (rc != SQLITE_OK) {
+ EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc);
+ error = EMAIL_ERROR_DB_FAILURE;
+ }
+ hStmt = NULL;
+ }
+
+ ret = true;
+
+FINISH_OFF:
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ _DISCONNECT_DB;
+
+ if (hStmt != NULL) {
+ rc = sqlite3_finalize(hStmt);
+ if (rc != SQLITE_OK) {
+ EM_DEBUG_EXCEPTION(" sqlite3_finalize failed - %d", rc);
+ error = EMAIL_ERROR_DB_FAILURE;
+ }
+ }
+
+ EM_DEBUG_FUNC_END("error [%d]", error);
+ return error;
+}
+
INTERNAL_FUNC int emstorage_add_mailbox(emstorage_mailbox_tbl_t* mailbox_tbl, int transaction, int *err_code)
{
_get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_plain), 0, 7);
_get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_html), 0, 8);
_get_stmt_field_data_char(hStmt, &(p_data_tbl->flags_seen_field), 9);
- _get_stmt_field_data_int(hStmt, &(p_data_tbl->save_status), 10);
+ _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->save_status), 10);
_get_stmt_field_data_int(hStmt, &(p_data_tbl->lock_status), 11);
_get_stmt_field_data_int(hStmt, &(p_data_tbl->thread_id), 12);
_get_stmt_field_data_int(hStmt, &(p_data_tbl->thread_item_count), 13);
_get_table_field_data_string(result, &(p_data_tbl[i].file_path_plain), 0, col_index++);
_get_table_field_data_string(result, &(p_data_tbl[i].file_path_html), 0, col_index++);
_get_table_field_data_char(result, &(p_data_tbl[i].flags_seen_field), col_index++);
- _get_table_field_data_int(result, &(p_data_tbl[i].save_status), col_index++);
+ _get_table_field_data_int(result, (int*)&(p_data_tbl[i].save_status), col_index++);
_get_table_field_data_int(result, &(p_data_tbl[i].lock_status), col_index++);
_get_table_field_data_int(result, &(p_data_tbl[i].thread_id), col_index++);
_get_table_field_data_int(result, &(p_data_tbl[i].thread_item_count), col_index++);
_get_stmt_field_data_time_t(hStmt, &(p_data_tbl->date_time), DATETIME_IDX_IN_MAIL_TBL);
_get_stmt_field_data_char (hStmt, &(p_data_tbl->flags_seen_field), FLAGS_SEEN_FIELD_IDX_IN_MAIL_TBL);
_get_stmt_field_data_int (hStmt, &(p_data_tbl->DRM_status), DRM_STATUS_IDX_IN_MAIL_TBL);
- _get_stmt_field_data_int (hStmt, &(p_data_tbl->priority), PRIORITY_IDX_IN_MAIL_TBL);
- _get_stmt_field_data_int (hStmt, &(p_data_tbl->save_status), SAVE_STATUS_IDX_IN_MAIL_TBL);
+ _get_stmt_field_data_int (hStmt, (int*)&(p_data_tbl->priority), PRIORITY_IDX_IN_MAIL_TBL);
+ _get_stmt_field_data_int (hStmt, (int*)&(p_data_tbl->save_status), SAVE_STATUS_IDX_IN_MAIL_TBL);
_get_stmt_field_data_int (hStmt, &(p_data_tbl->lock_status), LOCK_STATUS_IDX_IN_MAIL_TBL);
- _get_stmt_field_data_int (hStmt, &(p_data_tbl->report_status), REPORT_STATUS_IDX_IN_MAIL_TBL);
+ _get_stmt_field_data_int (hStmt, (int*)&(p_data_tbl->report_status), REPORT_STATUS_IDX_IN_MAIL_TBL);
_get_stmt_field_data_string(hStmt, &(p_data_tbl->preview_text), 1, PREVIEW_TEXT_IDX_IN_MAIL_TBL);
- _get_stmt_field_data_int (hStmt, &(p_data_tbl->meeting_request_status), MEETING_REQUEST_STATUS_IDX_IN_MAIL_TBL);
- _get_stmt_field_data_int (hStmt, &(p_data_tbl->message_class), MESSAGE_CLASS_IDX_IN_MAIL_TBL);
- _get_stmt_field_data_int (hStmt, &(p_data_tbl->digest_type), DIGEST_TYPE_IDX_IN_MAIL_TBL);
- _get_stmt_field_data_int (hStmt, &(p_data_tbl->smime_type), SMIME_TYPE_IDX_IN_MAIL_TBL);
+ _get_stmt_field_data_int (hStmt, (int*)&(p_data_tbl->meeting_request_status), MEETING_REQUEST_STATUS_IDX_IN_MAIL_TBL);
+ _get_stmt_field_data_int (hStmt, (int*)&(p_data_tbl->message_class), MESSAGE_CLASS_IDX_IN_MAIL_TBL);
+ _get_stmt_field_data_int (hStmt, (int*)&(p_data_tbl->digest_type), DIGEST_TYPE_IDX_IN_MAIL_TBL);
+ _get_stmt_field_data_int (hStmt, (int*)&(p_data_tbl->smime_type), SMIME_TYPE_IDX_IN_MAIL_TBL);
if (type == RETRIEVE_ALL) {
_get_stmt_field_data_int (hStmt, &(p_data_tbl->server_mail_status), SERVER_MAIL_STATUS_IDX_IN_MAIL_TBL);
", server_mail_status = ?"
", server_mailbox_name = ?"
", server_mail_id = ?"
+ ", reference_mail_id = ?"
", full_address_from = ?"
", full_address_reply = ?" /* 10 */
", full_address_to = ?"
_bind_stmt_field_data_int (hStmt, i++, mail->server_mail_status);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->server_mailbox_name, 0, SERVER_MAILBOX_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->server_mail_id, 0, SERVER_MAIL_ID_LEN_IN_MAIL_TBL);
+ _bind_stmt_field_data_int (hStmt, i++, mail->reference_mail_id);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->full_address_from, 1, FROM_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->full_address_reply, 1, REPLY_TO_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->full_address_to, 1, TO_LEN_IN_MAIL_TBL);
", report_status = ?"
", DRM_status = ?"
", file_path_html = ?"
+ ", file_path_mime_entity = ?"
", mail_size = ?"
", preview_text = ?"
", body_download_status = ?"
_bind_stmt_field_data_int (hStmt, i++, mail->report_status);
_bind_stmt_field_data_int (hStmt, i++, mail->DRM_status);
_bind_stmt_field_data_string(hStmt, i++, (char*)mail->file_path_html, 0, TEXT_2_LEN_IN_MAIL_TBL);
+ _bind_stmt_field_data_string(hStmt, i++, (char*)mail->file_path_mime_entity, 0, MIME_ENTITY_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_int (hStmt, i++, mail->mail_size);
_bind_stmt_field_data_string(hStmt, i++, (char*)mail->preview_text, 1, PREVIEWBODY_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_int (hStmt, i++, mail->body_download_status);
", ?" /* server_mailbox_name */
", ?" /* server_mail_id */
", ?" /* message_id */
+ ", ?" /* reference_mail_id */
", ?" /* full_address_from */
", ?" /* full_address_reply */
", ?" /* full_address_to */
_bind_stmt_field_data_string(hStmt, SERVER_MAILBOX_NAME_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->server_mailbox_name, 0, SERVER_MAILBOX_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, SERVER_MAIL_ID_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->server_mail_id, 0, SERVER_MAIL_ID_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, MESSAGE_ID_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->message_id, 0, MESSAGE_ID_LEN_IN_MAIL_TBL);
+ _bind_stmt_field_data_int (hStmt, REFERENCE_ID_IDX_IN_MAIL_TBL, mail_tbl_data->reference_mail_id);
_bind_stmt_field_data_string(hStmt, FULL_ADDRESS_FROM_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->full_address_from, 1, FROM_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, FULL_ADDRESS_REPLY_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->full_address_reply, 1, REPLY_TO_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, FULL_ADDRESS_TO_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->full_address_to, 1, TO_LEN_IN_MAIL_TBL);
if (nread > 0 && nread <= buf_size) {
EM_DEBUG_LOG("Nread Value [%d]", nread);
if ((nwritten = write(fp_dst, buf, nread)) != nread) {
- EM_DEBUG_EXCEPTION("fwrite failed... : [%d], Error:[%s]", nwritten, strerror(errno));
+ EM_DEBUG_EXCEPTION("fwrite failed...[%d] : [%s]", errno, strerror(errno));
error = EMAIL_ERROR_UNKNOWN;
goto FINISH_OFF;
}
", ?" /* server_mail_status */
", ?" /* server_mailbox_name */
", ?" /* server_mail_id */
+ ", ?" /* reference_mail_id */
", ?" /* full_address_from */
", ?" /* full_address_reply */
", ?" /* full_address_to */
_bind_stmt_field_data_string(hStmt, SERVER_MAILBOX_NAME_IDX_IN_MAIL_TBL, "", 0, SERVER_MAILBOX_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, SERVER_MAIL_ID_IDX_IN_MAIL_TBL, "", 0, SERVER_MAIL_ID_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, MESSAGE_ID_IDX_IN_MAIL_TBL, "", 0, MESSAGE_ID_LEN_IN_MAIL_TBL);
+ _bind_stmt_field_data_int(hStmt, REFERENCE_ID_IDX_IN_MAIL_TBL, 0);
_bind_stmt_field_data_string(hStmt, FULL_ADDRESS_FROM_IDX_IN_MAIL_TBL, "<test08@streaming.s3glab.net>", 1, FROM_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, FULL_ADDRESS_REPLY_IDX_IN_MAIL_TBL, "", 1, REPLY_TO_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, FULL_ADDRESS_TO_IDX_IN_MAIL_TBL, full_address_to, 1, TO_LEN_IN_MAIL_TBL);
time_t date_time = 0;
char *mailbox_name = NULL, *subject = NULL;
char *sql_query_string = NULL, *sql_account = NULL;
- char *sql_format = "SELECT thread_id, date_time, mail_id FROM mail_tbl WHERE subject like \'%%%q\' AND mailbox_type NOT IN (3, 5, 7, 8)";
+ char *sql_format = "SELECT thread_id, date_time, mail_id FROM mail_tbl WHERE subject like \'%%%q\' AND mailbox_id = %d";
char *sql_format_account = " AND account_id = %d ";
char *sql_format_order_by = " ORDER BY date_time DESC ";
char **result = NULL;
EM_IF_NULL_RETURN_VALUE(result_latest_mail_id_in_thread, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(thread_item_count, EMAIL_ERROR_INVALID_PARAM);
- if (mail_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH ||
- mail_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX ||
- mail_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_ALL_EMAILS) {
- EM_DEBUG_LOG("the mail in trash, spambox, all email could not be thread mail.");
- goto FINISH_OFF;
- }
-
account_id = mail_tbl->account_id;
mailbox_name = mail_tbl->mailbox_name;
subject = mail_tbl->subject;
goto FINISH_OFF;
}
- sqlite3_snprintf(query_size, sql_query_string, sql_format, stripped_subject);
+ sqlite3_snprintf(query_size, sql_query_string, sql_format, stripped_subject, mail_tbl->mailbox_id);
if (account_id > 0)
strcat(sql_query_string, sql_account);
"server_mailbox_name",
"server_mail_id",
"message_id",
+ "reference_mail_id",
"full_address_from",
"full_address_to",
"full_address_cc",
case EMAIL_MAIL_ATTRIBUTE_MAILBOX_ID :
case EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE :
case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_STATUS :
+ case EMAIL_MAIL_ATTRIBUTE_REFERENCE_MAIL_ID :
case EMAIL_MAIL_ATTRIBUTE_BODY_DOWNLOAD_STATUS :
case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN :
case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML :
typedef struct
{
- int mail_id;
- int account_id;
- int mailbox_id;
- char *mailbox_name;
- int mailbox_type;
- char *subject;
- time_t date_time;
- int server_mail_status;
- char *server_mailbox_name;
- char *server_mail_id;
- char *message_id;
- char *full_address_from;
- char *full_address_reply;
- char *full_address_to;
- char *full_address_cc;
- char *full_address_bcc;
- char *full_address_return;
- char *email_address_sender;
- char *email_address_recipient;
- char *alias_sender;
- char *alias_recipient;
- int body_download_status;
- char *file_path_plain;
- char *file_path_html;
- char *file_path_mime_entity;
- int mail_size;
- char flags_seen_field;
- char flags_deleted_field;
- char flags_flagged_field;
- char flags_answered_field;
- char flags_recent_field;
- char flags_draft_field;
- char flags_forwarded_field;
- int DRM_status;
- int priority;
- int save_status;
- int lock_status;
- int report_status;
- int attachment_count;
- int inline_content_count;
- int thread_id;
- int thread_item_count;
- char *preview_text;
- int meeting_request_status;
- int message_class;
- int digest_type;
- int smime_type;
+ int mail_id;
+ int account_id;
+ int mailbox_id;
+ char *mailbox_name;
+ int mailbox_type;
+ char *subject;
+ time_t date_time;
+ int server_mail_status;
+ char *server_mailbox_name;
+ char *server_mail_id;
+ char *message_id;
+ int reference_mail_id;
+ char *full_address_from;
+ char *full_address_reply;
+ char *full_address_to;
+ char *full_address_cc;
+ char *full_address_bcc;
+ char *full_address_return;
+ char *email_address_sender;
+ char *email_address_recipient;
+ char *alias_sender;
+ char *alias_recipient;
+ int body_download_status;
+ char *file_path_plain;
+ char *file_path_html;
+ char *file_path_mime_entity;
+ int mail_size;
+ char flags_seen_field;
+ char flags_deleted_field;
+ char flags_flagged_field;
+ char flags_answered_field;
+ char flags_recent_field;
+ char flags_draft_field;
+ char flags_forwarded_field;
+ int DRM_status;
+ email_mail_priority_t priority;
+ email_mail_status_t save_status;
+ int lock_status;
+ email_mail_report_t report_status;
+ int attachment_count;
+ int inline_content_count;
+ int thread_id;
+ int thread_item_count;
+ char *preview_text;
+ email_mail_type_t meeting_request_status;
+ email_message_class message_class;
+ email_digest_type digest_type;
+ email_smime_type smime_type;
} emstorage_mail_tbl_t;
/* mail_attachment_tbl entity */
INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, char *mailbox_name, email_mailbox_type_e new_mailbox_type, int transaction, int *err_code);
/*
+ * emstorage_set_local_mailbox
+ *
+ * description : change 'local' field on mailbox table.
+ * arguments :
+ * return :
+ */
+INTERNAL_FUNC int emstorage_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox, int transaction);
+
+/*
* emstorage_add_mailbox
*
* description : add a local mailbox to local mailbox table
* description : query mail box table information
*/
-INTERNAL_FUNC int emstorage_query_mailbox_tbl(const char *input_conditional_clause, int input_get_mail_count, int input_transaction, emstorage_mailbox_tbl_t **output_mailbox_list, int *output_mailbox_count);
+INTERNAL_FUNC int emstorage_query_mailbox_tbl(const char *input_conditional_clause, const char *input_ordering_clause, int input_get_mail_count, int input_transaction, emstorage_mailbox_tbl_t **output_mailbox_list, int *output_mailbox_count);
/*
* emstorage_get_mail_list
INTERNAL_FUNC int emcore_free_certificate(email_certificate_t **certificate, int count, int *err_code);
INTERNAL_FUNC int emcore_load_PFX_file(char *certificate, char *password, EVP_PKEY **pri_key, X509 **cert, STACK_OF(X509) **ca, int *err_code);
-
+/*
+INTERNAL_FUNC int emcore_load_PFX_file(char *certificate, EVP_PKEY **pri_key, X509 **cert, STACK_OF(X509) **ca, int *err_code);
+*/
#endif
INTERNAL_FUNC int emcore_update_mail(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 sync_server);
-INTERNAL_FUNC int emcore_fetch_flags(int account_id, int mail_id, email_mail_flag_t *mail_flag, int *err_code);
INTERNAL_FUNC int emcore_delete_mails_from_local_storage(int account_id, int *mail_ids, int num, int noti_param_1, int noti_param_2, int *err_code);
INTERNAL_FUNC int emcore_get_mail_msgno_by_uid(email_account_t *account, email_internal_mailbox_t *mailbox, char *uid, int *msgno, int *err_code);
INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(int input_mailbox_id);
INTERNAL_FUNC int emcore_sync_flag_with_server(int mail_id, int *err_code);
INTERNAL_FUNC int emcore_sync_seen_flag_with_server(int mail_ids[], int num, int *err_code);
-INTERNAL_FUNC int emcore_modify_extra_flag(int mail_id, email_extra_flag_t new_flag, int *err_code);
-INTERNAL_FUNC int emcore_modify_flag(int mail_id, email_mail_flag_t new_flag, int sticky_flag, int *err_code);
INTERNAL_FUNC int emcore_set_flags_field(int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code);
INTERNAL_FUNC char* emcore_convert_mutf7_to_utf8(char *mailbox_name);
INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, void **struct_var, email_convert_struct_type_e type);
INTERNAL_FUNC char *emcore_decode_rfc2047_text(char *rfc2047_text, int *err_code);
INTERNAL_FUNC int emcore_decode_body_text(char *enc_buf, int enc_len, int enc_type, int *dec_len, int *err_code);
INTERNAL_FUNC int emcore_set_fetch_body_section(BODY *body, int enable_inline_list, int *total_mail_size, int *err_code);
-INTERNAL_FUNC int emcore_load_eml_file_to_mail(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count, int *err_code);
-INTERNAL_FUNC int emcore_delete_eml_data(email_mail_data_t *input_mail_data, int *err_code);
+INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count, int *err_code);
+INTERNAL_FUNC int emcore_delete_parsed_data(email_mail_data_t *input_mail_data, int *err_code);
INTERNAL_FUNC int emcore_get_mime_entity(char *mime_path, char **mime_entity, int *err_code);
#ifdef __cplusplus
#include "c-client.h"
#include "email-internal-types.h"
-INTERNAL_FUNC int emcore_send_mail(int account_id, int input_mailbox_id, int mail_id, email_option_t *sending_option, int *err_code);
+INTERNAL_FUNC int emcore_send_mail(int account_id, int input_mailbox_id, int mail_id, int *err_code);
-INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *mailbox, email_option_t *sending_option, int *err_code);
+INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *mailbox, int *err_code);
INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_mail_tbl_data, emstorage_attachment_tbl_t *input_attachment_tbl_t, int input_attachment_count, ENVELOPE **env, char **file_path, email_option_t *sending_option, int *err_code);
void emcore_fill_address_information_of_mail_tbl(emstorage_mail_tbl_t *mail_data);
-int emcore_get_preview_text_from_file(const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer);
+INTERNAL_FUNC int emcore_get_preview_text_from_file(const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer);
int reg_replace (char *input_source_text, char *input_old_pattern_string, char *input_new_string);
int emcore_strip_HTML(char *source_string);
int emcore_send_noti_for_new_mail(int account_id, char *mailbox_name, char *subject, char *from, char *uid, char *datetime);
int emcore_clear_session(email_session_t *session);
int emcore_get_current_session(email_session_t **session);
-INTERNAL_FUNC email_option_t *emcore_get_option(int *err_code);
-INTERNAL_FUNC int emcore_set_option(email_option_t *opt, int *err_code);
-
INTERNAL_FUNC int emcore_check_unread_mail();
INTERNAL_FUNC int emcore_set_network_error(int err_code);
INCLUDE(FindPkgConfig)
pkg_check_modules(main_pkgs REQUIRED glib-2.0 dlog dbus-1 gthread-2.0 db-util openssl uw-imap-toolkit vconf contacts-service alarm-service mm-player devman_haptic heynoti)
+# _TIZEN_PUBLIC_
FOREACH(flag ${main_pkgs_CFLAGS})
return dst;
}
-INTERNAL_FUNC int emdaemon_validate_account(int account_id, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_validate_account(int account_id, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p], err_code[%p]", account_id, handle, err_code);
}
-INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_account, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_account, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account[%p], handle[%p], err_code[%p]", new_account, handle, err_code);
return ret;
}
-INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email_account_t* new_account_info, unsigned* handle,int *err_code)
+INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email_account_t* new_account_info, int *handle,int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account[%d], new_account_info[%p], handle[%p], err_code[%p]", old_account_id, new_account_info, handle, err_code);
}
return true;
}
+
INTERNAL_FUNC int emdaemon_alarm_polling_cb(alarm_id_t alarm_id, void* user_param)
{
EM_DEBUG_FUNC_BEGIN();
-/* tzset(); */
- time_t ct = time(&ct);
+ email_mailbox_t mailbox = {0};
+ int account_id = 0, err = EMAIL_ERROR_NONE, timer_interval =0, alarmID =0,ret = false;
+ char* mailbox_name = NULL;
+
+ time_t ct = time(&ct);
struct tm* lt = localtime(&ct);
if (lt) {
lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
lt->tm_hour, lt->tm_min, lt->tm_sec);
}
-
-
- email_mailbox_t mailbox = {0};
- int account_id = 0, err = EMAIL_ERROR_NONE, timer_interval =0, alarmID =0,ret = false;
- char* mailbox_name = NULL;
if(!_emdaemon_get_polling_account_and_timeinterval(alarm_id,&account_id,&timer_interval)) {
EM_DEBUG_EXCEPTION("email_get_polling_account failed");
memset(&mailbox, 0x00, sizeof(email_mailbox_t));
mailbox.account_id = account_id;
- if (!emstorage_get_mailbox_name_by_mailbox_type(mailbox.account_id,EMAIL_MAILBOX_TYPE_INBOX,&mailbox_name, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
-
-
- goto FINISH_OFF;
- }
- mailbox.mailbox_name = mailbox_name;
+ if (!emstorage_get_mailbox_name_by_mailbox_type(mailbox.account_id,EMAIL_MAILBOX_TYPE_INBOX,&mailbox_name, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
+ goto FINISH_OFF;
+ }
+ mailbox.mailbox_name = mailbox_name;
if (!emdaemon_sync_header(account_id, mailbox.mailbox_id, NULL, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_sync_header falied [%d]", err);
ret = true;
FINISH_OFF :
+
EM_SAFE_FREE(mailbox_name);
return ret;
static void callback_for_SYNC_ALL_STATUS_from_account_svc(keynode_t *input_node, void *input_user_data)
{
EM_DEBUG_FUNC_BEGIN("input_node [%p], input_user_data [%p]", input_node, input_user_data);
- unsigned handle = 0;
+ int handle = 0;
int i = 0;
int err = EMAIL_ERROR_NONE;
int account_count = 0;
+ int sync_start_toggle = 0;
email_account_t *account_list = NULL;
emstorage_mailbox_tbl_t *mailbox_tbl_data = NULL;
goto FINISH_OFF;
}
+ if(input_node)
+ sync_start_toggle = vconf_keynode_get_int(input_node);
+
for(i = 0; i < account_count; i++) {
- if(!emstorage_get_mailbox_by_mailbox_type(account_list[i].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl_data, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type for [%d] failed [%d]", account_list[i].account_id, err);
- continue;
+ if(sync_start_toggle == 1) {
+ if(!emstorage_get_mailbox_by_mailbox_type(account_list[i].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl_data, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type for [%d] failed [%d]", account_list[i].account_id, err);
+ continue;
+ }
+
+ if(!emdaemon_sync_header(account_list[i].account_id, mailbox_tbl_data->mailbox_id, &handle, &err)) {
+ EM_DEBUG_EXCEPTION("emdaemon_sync_header for [%d] failed [%d]", account_list[i].account_id, err);
+ }
+ if(mailbox_tbl_data)
+ emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL);
+ mailbox_tbl_data = NULL;
}
-
- if(!emdaemon_sync_header(account_list[i].account_id, mailbox_tbl_data->mailbox_id, &handle, &err)) {
- EM_DEBUG_EXCEPTION("emdaemon_sync_header for [%d] failed [%d]", account_list[i].account_id, err);
+ else {
+ emcore_cancel_all_threads_of_an_account(account_list[i].account_id);
}
- if(mailbox_tbl_data)
- emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL);
- mailbox_tbl_data = NULL;
}
FINISH_OFF:
#endif
static int _emdaemon_check_mail_id(int mail_id, int* err_code);
-INTERNAL_FUNC int emdaemon_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_send_mail(int mail_id, int *handle, int* err_code)
{
- EM_DEBUG_FUNC_BEGIN("mail_id[%d], sending_option[%p], handle[%p], err_code[%p]", mail_id, sending_option, handle, err_code);
+ EM_DEBUG_FUNC_BEGIN("mail_id[%d], handle[%p], err_code[%p]", mail_id, handle, err_code);
int ret = false, err = EMAIL_ERROR_NONE, err_2 = EMAIL_ERROR_NONE;
int result_handle = 0, account_id = 0;
- email_option_t* option = NULL;
- email_event_t event_data;
+ email_event_t event_data = { 0, };
emstorage_mail_tbl_t* mail_table_data = NULL;
emstorage_mailbox_tbl_t* local_mailbox = NULL;
int dst_mailbox_id = 0;
account_id = mail_table_data->account_id;
- if (sending_option != NULL) {
- if (!(option = (email_option_t*)em_malloc(sizeof(email_option_t)))) {
- EM_DEBUG_EXCEPTION("em_malloc for sending_option failed...");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
- memcpy(option, sending_option, sizeof(email_option_t));
- option->display_name_from = EM_SAFE_STRDUP(sending_option->display_name_from);
- }
-
email_account_t* ref_account = emdaemon_get_account_reference(account_id);
if (!ref_account) {
goto FINISH_OFF;
}
- memset(&event_data, 0x00, sizeof(email_event_t));
event_data.type = EMAIL_EVENT_SEND_MAIL;
event_data.account_id = account_id;
- event_data.event_param_data_1 = (char*)option;
event_data.event_param_data_4 = mail_id;
event_data.event_param_data_5 = mail_table_data->mailbox_id;
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value [%d]",err);
EM_SAFE_FREE(event_data.event_param_data_3);
-
- if(option != NULL) {
- EM_SAFE_FREE(option->display_name_from);
- EM_SAFE_FREE(option);
- }
}
if(!emcore_add_transaction_info(mail_id , result_handle , &err_2))
return ret;
}
-INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, email_option_t* sending_option, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, int *handle, int* err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], sending_option[%p], handle[%p], err_code[%p]", account_id, sending_option, handle, err_code);
+ EM_DEBUG_FUNC_BEGIN("account_id[%d],handle[%p], err_code[%p]", account_id, handle, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
- email_option_t* option = NULL;
- email_event_t event_data;
+ email_event_t event_data = { 0 , };
char *mailbox_name = NULL;
- memset(&event_data, 0x00, sizeof(email_event_t));
-
if (account_id <= 0) {
EM_DEBUG_EXCEPTION("account_id = %d", account_id);
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- if (sending_option) {
- option = (email_option_t*)em_malloc(sizeof(email_option_t));
- if (!option) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- memcpy(option, sending_option, sizeof(email_option_t));
- }
-
email_account_t* ref_account = emdaemon_get_account_reference(account_id);
if (!ref_account) {
goto FINISH_OFF;
}
-
- event_data.type = EMAIL_EVENT_SEND_MAIL_SAVED;
-
if (!emstorage_get_mailbox_name_by_mailbox_type(account_id,EMAIL_MAILBOX_TYPE_OUTBOX,&mailbox_name, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
+
+ event_data.type = EMAIL_EVENT_SEND_MAIL_SAVED;
+ event_data.account_id = account_id;
event_data.event_param_data_3 = EM_SAFE_STRDUP(mailbox_name);
- event_data.account_id = account_id;
- event_data.event_param_data_1 = (char*)option;
if (!emcore_insert_event(&event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
FINISH_OFF:
if (ret == false) {
EM_SAFE_FREE(event_data.event_param_data_3);
- EM_SAFE_FREE(option);
}
EM_SAFE_FREE(mailbox_name);
email_event_t event_data = { 0 };
if (!input_mail_data || input_mail_data->account_id <= 0 ||
- (input_mail_data->report_status == EMAIL_MAIL_REPORT_MDN && !input_mail_data->full_address_to)) {
+ ( ((input_mail_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0) && !input_mail_data->full_address_to)) {
+ EM_DEBUG_LOG("input_mail_data->report_status [%d]", input_mail_data->report_status);
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
return ret;
}
-INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbose, int with_attachment, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbose, int with_attachment, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], verbose[%d], with_attachment[%d], handle[%p], err_code[%p]", account_id, mail_id, verbose, with_attachment, handle, err_code);
int emdaemon_delete_mail_attachment(int attachment_id, int* err_code)
{
- EM_DEBUG_FUNC_BEGIN("attachment_id[%s], err_code[%p]", attachment_id, err_code);
+ EM_DEBUG_FUNC_BEGIN("attachment_id[%d], err_code[%p]", attachment_id, err_code);
/* default variable */
int ret = false;
return ret;
}
-INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int nth, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int nth, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], nth[%d], handle[%p], err_code[%p]", account_id, mail_id, nth, handle, err_code);
int mail_id_count = 0;
int account_id = 0;
int from_server = 0;
- unsigned handle = 0;
+ int noti_param_2 = 0;
+ int handle = 0;
email_event_t *event_data = (email_event_t*)thread_argument;
account_id = event_data->account_id;
mail_id_count = event_data->event_param_data_4;
from_server = event_data->event_param_data_5;
- if (!emcore_delete_mail(account_id, mail_id_list, mail_id_count, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_BY_COMMAND, false, &err)) {
- EM_DEBUG_EXCEPTION(" emcore_delete_mail falied [%d]", err);
+ if (!emcore_delete_mail(account_id, mail_id_list, mail_id_count, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_BY_COMMAND, noti_param_2, &err)) {
+ EM_DEBUG_EXCEPTION(" emcore_delete_mail failed [%d]", err);
goto FINISH_OFF;
}
- if (from_server != EMAIL_DELETE_LOCALLY) {
+ if (from_server == EMAIL_DELETE_LOCAL_AND_SERVER || from_server == EMAIL_DELETE_FROM_SERVER) {
if (!emcore_insert_event(event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
goto FINISH_OFF;
return SUCCESS;
}
-INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_ids[], int mail_ids_count, int from_server, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_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);
int ret = false;
int err = EMAIL_ERROR_NONE;
int* p = NULL, thread_error;
+ email_account_t *ref_account = NULL;
email_event_t *event_data = NULL;
emstorage_mailbox_tbl_t *mailbox_tbl_data = NULL;
thread_t delete_thread;
goto FINISH_OFF;
}
+ ref_account = emcore_get_account_reference(mailbox_tbl_data->account_id);
+
+ if (!ref_account) {
+ EM_DEBUG_EXCEPTION("emcore_get_account_reference failed.");
+ err = EMAIL_ERROR_INVALID_ACCOUNT;
+ goto FINISH_OFF;
+ }
+
+ if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
+ from_server = EMAIL_DELETE_LOCALLY;
+ }
+
event_data->type = EMAIL_EVENT_DELETE_MAIL;
event_data->account_id = mailbox_tbl_data->account_id;
event_data->event_param_data_3 = (char*)p;
return ret;
}
-int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, unsigned *output_handle, int *output_err_code)
+int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, int *output_handle, int *output_err_code)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], input_from_server[%d], handle[%p], err_code[%p]", input_mailbox_id, input_from_server, output_handle, output_err_code);
{
EM_DEBUG_FUNC_BEGIN();
int *mail_ids = NULL, mail_ids_count, noti_param_1, noti_param_2, err;
- unsigned handle = 0;
+ int handle = 0;
email_event_t *event_data = (email_event_t*)thread_argument;
char *dst_mailbox_name = NULL;
int dst_mailbox_id = 0;
return ret;
}
-INTERNAL_FUNC int emdaemon_modify_flag(int mail_id, email_mail_flag_t new_flag, int onserver, int sticky_flag, int* err_code)
-{
- EM_DEBUG_FUNC_BEGIN("mail_id[%d], new_flag[%d], onserver[%d], sticky_flag[%d], err_code[%p]", mail_id, new_flag, onserver, sticky_flag, err_code);
-
- /* default variable */
- int ret = false;
- int err = EMAIL_ERROR_NONE;
-
- if (!emcore_modify_flag(mail_id, new_flag, sticky_flag, &err)) {
- EM_DEBUG_EXCEPTION(" emcore_modify_flag falled [%d]", err);
- goto FINISH_OFF;
- }
-
-#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
- if( onserver == 1) {
- email_event_t event_data;
- unsigned handle = 0;
- memset(&event_data, 0x00, sizeof(email_event_t));
-
- event_data.type = EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER;
- event_data.event_param_data_1 = NULL;
- event_data.event_param_data_4 = mail_id;
- event_data.account_id = 0;
-#ifdef __FEATURE_LOCAL_ACTIVITY__
- emstorage_mail_tbl_t *mail_table_data = NULL;
- if (!emstorage_get_mail_field_by_id(mail_id, RETRIEVE_SUMMARY, &mail_table_data, false, &err) || !mail_table_data) {
- EM_DEBUG_LOG(" emstorage_get_mail_field_by_id failed [%d]", err);
- goto FINISH_OFF;
- }
- event_data.account_id = mail_table_data->account_id;
- emstorage_free_mail(&mail_table_data,1,&err);
-
- emstorage_activity_tbl_t new_activity;
- new_activity.activity_type = ACTIVITY_MODIFYFLAG;
- new_activity.account_id = event_data.account_id;
- new_activity.mail_id = event_data.event_param_data_4;
- new_activity.dest_mbox = NULL;
- new_activity.server_mailid = NULL;
- new_activity.src_mbox = NULL;
-
- if (false == emcore_get_next_activity_id(&new_activity.activity_id,&err)) {
- EM_DEBUG_EXCEPTION(" emcore_get_next_activity_id Failed - %d \n", err);
- }
-
- if (!emcore_add_activity(&new_activity, &err)) {
- EM_DEBUG_EXCEPTION(" emcore_add_activity [ACTIVITY_MODIFYFLAG] Failed - %d \n", err);
- }
-
-#endif /* __FEATURE_LOCAL_ACTIVITY__ */
- if (!emcore_insert_event(&event_data, (int*)&handle, &err)) {
- EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
- goto FINISH_OFF;
- }
-
-#ifdef __FEATURE_LOCAL_ACTIVITY__
- EM_DEBUG_LOG("Setting g_local_activity_run ");
- g_local_activity_run = 1;
-#endif /* __FEATURE_LOCAL_ACTIVITY__ */
- }
-#endif /* __FEATURE_SYNC_CLIENT_TO_SERVER__ */
-
- ret = true;
-
-FINISH_OFF:
- if (err_code)
- *err_code = err;
- EM_DEBUG_FUNC_END();
- return ret;
-}
-
-INTERNAL_FUNC int emdaemon_modify_extra_flag(int mail_id, email_extra_flag_t new_flag, int* err_code)
-{
- EM_DEBUG_FUNC_BEGIN("mail_id[%d], err_code[%p]", mail_id, err_code);
-
- int ret = false;
- int err = EMAIL_ERROR_NONE;
-
- if (!_emdaemon_check_mail_id(mail_id, &err)) {
- EM_DEBUG_EXCEPTION("_emdaemon_check_mail_id failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emcore_modify_extra_flag(mail_id, new_flag, &err)) {
- EM_DEBUG_EXCEPTION("engine_mail_modify_extra_flag failed [%d]", err);
- goto FINISH_OFF;
- }
-
- ret = true;
-
-FINISH_OFF:
- if (err_code)
- *err_code = err;
-
- EM_DEBUG_FUNC_END("ret [%d]", ret);
- return ret;
- }
-
INTERNAL_FUNC int emdaemon_set_flags_field(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[%d], num[%d], field_type [%d], value[%d], err_code[%p]", mail_ids[0], num, field_type, value, err_code);
if( onserver && account_tbl->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 ) {
int *mail_id_array = NULL;
email_event_t event_data = {0};
- unsigned handle = 0;
+ int handle = 0;
mail_id_array = em_malloc(sizeof(int) * num);
email_account_t *ref_account = NULL;
if (!input_mail_data || input_mail_data->account_id <= 0 || input_mail_data->mail_id == 0 ||
- (input_mail_data->report_status == EMAIL_MAIL_REPORT_MDN && !input_mail_data->full_address_to)) {
+ (((input_mail_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0) && !input_mail_data->full_address_to)) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
-INTERNAL_FUNC int emdaemon_send_mail_retry( int mail_id, int timeout_in_sec, int* err_code)
+INTERNAL_FUNC int emdaemon_send_mail_retry(int mail_id, int timeout_in_sec, int* err_code)
{
int ret = false;
int err = EMAIL_ERROR_NONE;
long nTimerValue = 0;
char mail_id_string[10] = { 0, };
- email_mailbox_t mailbox;
- emstorage_mail_tbl_t* mail_table_data = NULL;
- email_option_t opt;
-
- memset(&opt, 0x00, sizeof(email_option_t));
- memset(&mailbox, 0x00, sizeof(email_mailbox_t));
if (!_emdaemon_check_mail_id(mail_id, &err)) {
EM_DEBUG_EXCEPTION("_emdaemon_check_mail_id failed [%d]", err);
goto FINISH_OFF;
}
-
- if( ! emstorage_get_mail_by_id(mail_id, &mail_table_data, false, &err) && !mail_table_data) {
- EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
- goto FINISH_OFF;
- }
-
- mailbox.mailbox_name = EM_SAFE_STRDUP(mail_table_data->mailbox_name);
-
- memcpy(&opt, emcore_get_option(&err), sizeof(email_option_t));
-
- if( mail_table_data ) {
- mailbox.account_id = mail_table_data->account_id;
- opt.priority = mail_table_data->priority;
- }
if ( timeout_in_sec == 0 ) {
- if(!emdaemon_send_mail(mail_id, &opt, NULL, &err)) {
+ if(!emdaemon_send_mail(mail_id, NULL, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_send_mail failed [%d]", err);
goto FINISH_OFF;
}
FINISH_OFF:
if (err_code)
*err_code = err;
-
- if(mail_table_data)
- emstorage_free_mail(&mail_table_data, 1, NULL);
-
- EM_SAFE_FREE(mailbox.mailbox_name);
return ret;
}
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- email_mailbox_t mailbox;
- emstorage_mail_tbl_t* mail_table_data = NULL;
int mail_id = 0 ;
- email_option_t opt;
-
- memset( &opt, 0x00, sizeof(email_option_t));
- memset( &mailbox, 0x00, sizeof(email_mailbox_t));
if( !data ) {
EM_DEBUG_LOG("Invalid param");
mail_id = atoi((char*)data);
-
if (!_emdaemon_check_mail_id(mail_id, &err)) {
EM_DEBUG_EXCEPTION("_emdaemon_check_mail_id failed [%d]", err);
goto FINISH_OFF;
}
- if( ! emstorage_get_mail_by_id(mail_id, &mail_table_data, false, &err) && !mail_table_data) {
- EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
- goto FINISH_OFF;
- }
-
- mailbox.mailbox_name = EM_SAFE_STRDUP(mail_table_data->mailbox_name);
- memcpy(&opt, emcore_get_option(&err), sizeof(email_option_t));
-
- if( mail_table_data ) {
- opt.priority = mail_table_data->priority;
- mailbox.account_id = mail_table_data->account_id;
- }
-
- if(!emdaemon_send_mail(mail_id, &opt, NULL, &err)) {
+ if(!emdaemon_send_mail(mail_id, NULL, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_send_mail failed [%d]", err);
goto FINISH_OFF;
}
FINISH_OFF:
- if(mail_table_data)
- emstorage_free_mail(&mail_table_data, 1, NULL);
-
- EM_SAFE_FREE(mailbox.mailbox_name);
EM_DEBUG_FUNC_END();
return;
return ret;
}
-INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_flag, unsigned* handle, int *err_code)
+INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_flag, int *handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("thread_id [%d], delete_always_flag [%d], err_code [%p]", thread_id, delete_always_flag, err_code);
int ret = false;
return ret;
}
-INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server, unsigned* handle, int *err_code)
+INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server, int *handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("thread_id [%d], seen_flag [%d], on_server [%d], handle [%p], err_code [%p]", thread_id, seen_flag, on_server, handle, err_code);
int ret = false;
return ret;
}
-INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, unsigned *output_handle)
+INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, int *output_handle)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_on_server [%d], output_handle [%p]", input_mailbox_id, input_on_server, output_handle);
int err = EMAIL_ERROR_NONE;
extern int g_local_activity_run;
#endif
-INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(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);
return ret;
}
-INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("new_mailbox[%p], err_code[%p]", new_mailbox, err_code);
}
-INTERNAL_FUNC int emdaemon_update_mailbox(email_mailbox_t* old_mailbox, email_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_update_mailbox(email_mailbox_t* old_mailbox, email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("old_mailbox[%p], new_mailbox[%p], on_server[%d], handle[%p], err_code[%p]", old_mailbox, new_mailbox, on_server, handle, err_code);
email_event_t event_data;
memset(&event_data, 0x00, sizeof(email_event_t));
-
- /* Unsupport sync with server */
- /* on_server is allowed to be only 0 when server_type is EMAIL_SERVER_TYPE_ACTIVE_SYNC */
- /*
- if ( ref_account->receiving_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
- on_server = 0;
- }
- if ( on_server ) {
- event_data.type = EMAIL_EVENT_UPDATE_MAILBOX;
- event_data.account_id = new_mailbox->account_id;
- event_data.event_param_data_1 = ;
- event_data.event_param_data_2 = ;
- event_data.event_param_data_4 = on_server;
- event_data.event_param_data_3 = GINT_TO_POINTER(new_mailbox->mailbox_type);
- if(!emcore_insert_event(&event_data, handle, &err)) {
- EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
- goto FINISH_OFF;
- }
- }
- else {
- if (!emcore_modify(old_mailbox, new_mailbox, on_server, &err)) {
- EM_DEBUG_EXCEPTION("emcore_create failed [%d]", err);
- goto FINISH_OFF;
- }
- }
- */
/* Update mailbox information only on local db */
if (!emcore_update_mailbox(old_mailbox, new_mailbox, &err)) {
EM_DEBUG_EXCEPTION("emcore_modify failed [%d]", err);
return err;
}
+INTERNAL_FUNC int emdaemon_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox)
+{
+ EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_mailbox_type [%d]", input_mailbox_id, input_is_local_mailbox);
+ /* default variable */
+ int err = EMAIL_ERROR_NONE;
+
+ if (input_mailbox_id <= 0) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ if ( (err = emstorage_set_local_mailbox(input_mailbox_id, input_is_local_mailbox, true)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_set_local_mailbox failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+
+FINISH_OFF:
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
-INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], err_code[%p]", input_mailbox_id, err_code);
}
-INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle, int* err_code)
+INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_id, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("input_account_id[%d], input_mailbox_id[%d], handle[%p], err_code[%p]", input_account_id, input_mailbox_id, handle, err_code);
return ret;
}
-INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, int mailbox_id, int new_slot_size, unsigned* handle, int *err_code)
+INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, int mailbox_id, int new_slot_size, int *handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_id[%d], handle[%p], err_code[%p]", account_id, mailbox_id, handle, err_code);
return ret;
}
-INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, int input_on_server, unsigned *output_handle)
+INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, int input_on_server, int *output_handle)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_mailbox_path [%p], input_mailbox_alias[%p], input_on_server [%d], output_handle[%p]", input_mailbox_id, input_mailbox_path, input_mailbox_alias, input_on_server, output_handle);
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_validate_account(int account_id, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_validate_account(int account_id, int *handle, int* err_code);
/**
* Change the information of a email account.
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email_account_t* new_account_info, unsigned* handle,int *err_code);
+INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email_account_t* new_account_info, int *handle,int *err_code);
/**
* Get a email account by ID.
* Send a mail.
*
* @param[in] mail_id Specifies the mail ID.
- * @param[in] sending_option Specifies the sending option.
* @param[in] callback Specifies the callback function for retrieving sending information.
* @param[in] handle Specifies the handle for stopping sending.
* @param[out] err_code Specifies the error code returned.
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_send_mail(int mail_id, int *handle, int* err_code);
/**
* Send all mails to been saved in Offline-mode.
*
* @param[in] account_id Specifies the account ID.
- * @param[in] sending_option Specifies the sending option.
* @param[in] callback Specifies the callback function for retrieving sending information.
* @param[in] handle Specifies the handle for stopping sending.
* @param[out] err_code Specifies the error code returned.
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, email_option_t* sending_option, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, int *handle, int* err_code);
INTERNAL_FUNC int emdaemon_add_mail(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);
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_id[], int num, int from_server, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_id[], int num, int from_server, int *handle, int* err_code);
/**
* Delete all mail from a mailbox.
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, unsigned *output_handle, int *output_err_code);
+INTERNAL_FUNC int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, int *output_handle, int *output_err_code);
/**
* Move a email to another mailbox.
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbose, int with_attachment, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbose, int with_attachment, int *handle, int* err_code);
/**
* Get a mail attachment.
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int nth, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int nth, int *handle, int* err_code);
/**
INTERNAL_FUNC int emdaemon_free_attachment_data(email_attachment_data_t** atch_info, int* err_code);
/**
- * Change email flag.
- *
- * @param[in] mailbox Reserved.
- * @param[in] mail_id Specifies the mail ID.
- * @param[in] new_flag Specifies the new email flag.
- * @param[out] err_code Specifies the error code returned.
- * @remarks N/A
- * @return This function returns true on success or false on failure.
- */
-INTERNAL_FUNC int emdaemon_modify_flag(int mail_id, email_mail_flag_t new_flag, int onserver, int sticky_flag, int* err_code);
-
-/**
- * Change email extra flag.
- *
- * @param[in] mailbox Reserved.
- * @param[in] mail_id Specifies the mail ID.
- * @param[in] new_flag Specifies the new email extra flag.
- * @param[out] err_code Specifies the error code returned.
- * @remarks N/A
- * @return This function returns true on success or false on failure.
- */
-INTERNAL_FUNC int emdaemon_modify_extra_flag(int mail_id, email_extra_flag_t new_flag, int* err_code);
-
-/**
* Change email read/unread flag.
* @param[in] account_id Specifies the account id.
* @param[in] mail_ids Specifies the array of mail ID.
/*****************************************************************************/
/* Mailbox */
/*****************************************************************************/
-INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox, int *handle, int* err_code);
/**
* Download header of new emails from mail server.
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_id, int *handle, int* err_code);
/**
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code);
/**
* Delete a mailbox.
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, int *handle, int* err_code);
/**
* Delete all sub-mailboxes from a specific mailbox.
INTERNAL_FUNC int emdaemon_update_accountinfo_to_contact(email_account_t* old_account, email_account_t* new_account);
-INTERNAL_FUNC int emdaemon_update_mailbox(email_mailbox_t* old_mailbox, email_mailbox_t* new_mailbox, int on_server, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_update_mailbox(email_mailbox_t* old_mailbox, email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code);
INTERNAL_FUNC int emdaemon_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type);
+INTERNAL_FUNC int emdaemon_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox);
+
INTERNAL_FUNC int emdaemon_search_mail_on_server(int input_account_id, int input_mailbox_id, email_search_filter_t *input_search_filter, int input_search_filter_count, unsigned int *output_handle, int *err_code);
INTERNAL_FUNC int emdaemon_clear_all_mail_data(int* err_code);
INTERNAL_FUNC int emdaemon_send_mail_retry( int mail_id, int timeout_in_sec, int* err_code);
-INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_account, unsigned* handle, int* err_code);
+INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_account, int *handle, int* err_code);
-INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, int mailbox_id, int new_slot_size, unsigned* handle, int *err_code);
+INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, int mailbox_id, int new_slot_size, int *handle, int *err_code);
-INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, int input_on_server, unsigned *output_handle);
+INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, int input_on_server, int *output_handle);
INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, int target_mailbox_id, int move_always_flag, int *err_code);
-INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_flag, unsigned* handle, int *err_code);
+INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_flag, int *handle, int *err_code);
-INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server, unsigned* handle, int *err_code);
+INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server, int *handle, int *err_code);
-INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, unsigned *output_handle);
+INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, int *output_handle);
#ifdef __cplusplus
}
email_account_t new_account_info = {0};
email_account_t old_account_info = {0};
int err = EMAIL_ERROR_NONE;
- unsigned int handle = 0;
+ int handle = 0;
account_id = *((int*)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0));
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
- local_result = emdaemon_validate_account(account_id, (unsigned*)&handle,&err_code);
+ local_result = emdaemon_validate_account(account_id, &handle,&err_code);
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
EM_DEBUG_LOG("emipc_add_parameter failed ");
EM_DEBUG_FUNC_END();
}
-void stb_modify_mail_flag(HIPC_API a_hAPI)
-{
- EM_DEBUG_FUNC_BEGIN();
- int err = EMAIL_ERROR_NONE;
- int mail_id = 0;
- int i_flag = 0;
- int onserver = 0;
- int sticky_flag = 0;
- email_mail_flag_t new_flag = { 0 };
-
- EM_DEBUG_LOG("mail_id");
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id);
- EM_DEBUG_LOG("mail_id[%d]", mail_id);
-
- EM_DEBUG_LOG("i_flag");
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &i_flag);
- EM_DEBUG_LOG("i_flag[%d]", i_flag);
-
- EM_DEBUG_LOG("Sticky flag");
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &sticky_flag);
- EM_DEBUG_LOG(">>> STICKY flag Value [ %d] ", sticky_flag);
-
- EM_DEBUG_LOG("onserver");
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 3, sizeof(int), &onserver);
- EM_DEBUG_LOG("onserver[%d]", onserver);
-
- EM_DEBUG_LOG("Flag Change 1>>> ");
- if(!em_convert_mail_int_to_flag(i_flag, &new_flag, &err)) {
- EM_DEBUG_EXCEPTION("em_convert_mail_int_to_flag failed");
- return;
- }
- if(emdaemon_modify_flag(mail_id, new_flag, onserver, sticky_flag, &err))
- EM_DEBUG_LOG("emdaemon_modify_flag - success");
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
- if (!emipc_execute_stub_api(a_hAPI))
- EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
- EM_DEBUG_FUNC_END();
-}
-
-#if 0
-void stb_modify_mail_extra_flag(HIPC_API a_hAPI)
-{
- EM_DEBUG_FUNC_BEGIN();
- int err = EMAIL_ERROR_NONE;
- int mail_id = 0;
- int buffer_size = 0;
- email_extra_flag_t new_flag= { 0 };
- char* local_stream = NULL;
-
- EM_DEBUG_LOG("mail_id");
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id);
-
- EM_DEBUG_LOG("extra_flag");
- buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1);
-
- if(buffer_size > 0) {
- local_stream = (char*)em_malloc(buffer_size);
- EM_NULL_CHECK_FOR_VOID(local_stream);
- if(local_stream) {
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, local_stream);
- em_convert_byte_stream_to_extra_flags(local_stream, &new_flag);
- EM_SAFE_FREE(local_stream);
- }
-
- if(emdaemon_modify_extra_flag(mail_id, new_flag, &err))
- EM_DEBUG_LOG("emdaemon_modify_extra_flag - success");
-
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
-
- if (!emipc_execute_stub_api(a_hAPI))
- EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
-
- }
- EM_DEBUG_FUNC_END();
-}
-
-
-void stb_get_mail_count_of_mailbox(HIPC_API a_hAPI)
-{
- EM_DEBUG_FUNC_BEGIN();
- int buffer_size = 0;
- int local_result = 0;
- char* local_stream = NULL;
- email_mailbox_t mailbox;
- int total_count = 0;
- int unseen= 0;
-
- EM_DEBUG_LOG("mailbox");
- buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
-
- if(buffer_size > 0) {
- local_stream = (char*)em_malloc(buffer_size);
- if(!local_stream) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
- goto FINISH_OFF;
- }
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream);
- em_convert_byte_stream_to_mailbox(local_stream, buffer_size, &mailbox);
- EM_SAFE_FREE(local_stream);
- }
-
- /*get the Mailbox Count */
- if (!emdaemon_get_mail_count_of_mailbox(&mailbox, &total_count, &unseen, NULL)) {
- EM_DEBUG_EXCEPTION("emdaemon_get_mail_count_of_mailbox - failed");
- goto FINISH_OFF;
- }
- else {
- EM_DEBUG_LOG("emdaemon_get_mail_count_of_mailbox - success");
- local_result = 1;
- }
-
-FINISH_OFF:
-
- if(local_result) {
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
-
- /* Totol count of mails */
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &total_count, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
-
- /* Unread Mail */
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &unseen, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
-
- if (!emipc_execute_stub_api(a_hAPI))
- EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
- }
- else {
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
- if (!emipc_execute_stub_api(a_hAPI))
- EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
- }
-
- emcore_free_mailbox(&mailbox);
-
- EM_DEBUG_FUNC_END();
-}
-#endif
-
/* sowmya.kr, 10-May-2010, changes for API improvement */
void stb_sync_header(HIPC_API a_hAPI)
{
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &maibox_id);
EM_DEBUG_LOG("maibox_id [%d]", maibox_id);
- if(emdaemon_sync_header(account_id, maibox_id, (unsigned*)&handle, &err)) {
+ if(emdaemon_sync_header(account_id, maibox_id, &handle, &err)) {
EM_DEBUG_LOG("emdaemon_sync_header success ");
}
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
int mail_id = 0;
- int has_attachment = 0;
- unsigned int handle = 0;
+ int attachment_count = 0;
+ int handle = 0;
int account_id = 0;
/* Account Id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id);
/* Has Attachment */
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &has_attachment);
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &attachment_count);
/*Download Body */
- if (!emdaemon_download_body(account_id, mail_id, 1, has_attachment, &handle, &err)) {
+ if (!emdaemon_download_body(account_id, mail_id, 1, attachment_count, &handle, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_download_body - failed");
goto FINISH_OFF;
}
void stb_create_mailbox(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
- int buffer_size = 0;
- int err = EMAIL_ERROR_NONE;
- char *local_stream = NULL;
- int on_server = 0;
+ int buffer_size = 0;
+ int err = EMAIL_ERROR_NONE;
+ char *local_stream = NULL;
+ int on_server = 0;
email_mailbox_t mailbox = {0};
- int handle = 0; /* Added for cancelling mailbox creating */
+ int handle = 0; /* Added for cancelling mailbox creating */
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0);
EM_DEBUG_LOG("size [%d]", buffer_size);
on_server = *((int*)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 1));
- emdaemon_add_mailbox(&mailbox, on_server, (unsigned*)&handle, &err);
+ emdaemon_add_mailbox(&mailbox, on_server, &handle, &err);
FINISH_OFF:
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
return;
}
-#if 0
- buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
- EM_DEBUG_LOG("size [%d]", buffer_size);
-
- if(buffer_size > 0) {
- local_stream = (char*)em_malloc(buffer_size);
- EM_NULL_CHECK_FOR_VOID(local_stream);
- if(local_stream) {
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_stream);
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &on_server);
- em_convert_byte_stream_to_mailbox(local_stream, buffer_size, &mailbox);
- EM_SAFE_FREE(local_stream);
-
- if (mailbox.mailbox_name)
- EM_DEBUG_LOG("Mailbox name - %s", mailbox.mailbox_name);
-
- if(emdaemon_add_mailbox(&mailbox, on_server, (unsigned*)&handle, &err))
- err = EMAIL_ERROR_NONE;
-
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter failed 2");
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &mailbox.mailbox_id, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter failed 3");
-
- if (!emipc_execute_stub_api(a_hAPI)) {
- EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
- return;
- }
- }
- }
-#endif
EM_DEBUG_FUNC_END();
}
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- int on_server = 0;
- int handle = 0; /* Added for cancelling mailbox deleting */
- int input_mailbox_id = 0;
+ int on_server = 0;
+ int handle = 0; /* Added for cancelling mailbox deleting */
+ int input_mailbox_id = 0;
/* src_mailbox_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &input_mailbox_id);
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &on_server);
- if(emdaemon_delete_mailbox(input_mailbox_id, on_server, (unsigned*)&handle, &err))
+ if(emdaemon_delete_mailbox(input_mailbox_id, on_server, &handle, &err))
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_FUNC_END();
}
-void stb_update_mailbox(HIPC_API a_hAPI)
+void stb_set_mailbox_type(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
- int buffer_size = 0;
- int err = EMAIL_ERROR_NONE;
- char *old_mailbox_stream = NULL;
- char *new_mailbox_stream = NULL;
- int on_server = 0;
- email_mailbox_t *old_mailbox = NULL;
- email_mailbox_t *new_mailbox = NULL;
- int handle = 0; /* Added for cancelling mailbox updating */
-
- buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
- EM_DEBUG_LOG("size [%d]", buffer_size);
- if(buffer_size > 0) {
- old_mailbox_stream = (char*)em_malloc(buffer_size);
- EM_NULL_CHECK_FOR_VOID(old_mailbox_stream);
- if(old_mailbox_stream) {
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, old_mailbox_stream);
- old_mailbox = (email_mailbox_t*)em_malloc(sizeof(email_mailbox_t));
- if ( old_mailbox == NULL ) {
- EM_DEBUG_EXCEPTION("em_malloc failed.");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- em_convert_byte_stream_to_mailbox(old_mailbox_stream, buffer_size, old_mailbox);
- EM_SAFE_FREE(old_mailbox_stream);
- }
- }
- else {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
+ int err = EMAIL_ERROR_NONE;
+ int mailbox_id = 0;
+ int mailbox_type = 0;
- buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1);
- EM_DEBUG_LOG("size [%d]", buffer_size);
- if(buffer_size > 0) {
- new_mailbox_stream = (char*)em_malloc(buffer_size);
- EM_NULL_CHECK_FOR_VOID(new_mailbox_stream);
- if(new_mailbox_stream) {
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, new_mailbox_stream);
- new_mailbox = (email_mailbox_t*)em_malloc(sizeof(email_mailbox_t));
- if ( new_mailbox == NULL ) {
- EM_DEBUG_EXCEPTION("em_malloc failed.");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
- em_convert_byte_stream_to_mailbox(new_mailbox_stream, buffer_size, new_mailbox);
- EM_SAFE_FREE(new_mailbox_stream);
- }
- }
- else {
- EM_DEBUG_EXCEPTION("INVALID PARAM : old mailbox");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id);
+ EM_DEBUG_LOG("mailbox_id[%d]", mailbox_id);
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &on_server);
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mailbox_type);
+ EM_DEBUG_LOG("mailbox_type[%d]", mailbox_type);
- if(emdaemon_update_mailbox(old_mailbox, new_mailbox, on_server, (unsigned*)&handle, &err))
+ if( (err = emdaemon_set_mailbox_type(mailbox_id, mailbox_type)) != EMAIL_ERROR_NONE)
err = EMAIL_ERROR_NONE;
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, &handle, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
if (!emipc_execute_stub_api(a_hAPI))
- EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
-
-
-FINISH_OFF:
- EM_SAFE_FREE(old_mailbox_stream);
- EM_SAFE_FREE(new_mailbox_stream);
-
- emcore_free_mailbox(old_mailbox);
- EM_SAFE_FREE(old_mailbox);
- emcore_free_mailbox(new_mailbox);
- EM_SAFE_FREE(new_mailbox);
+ EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
EM_DEBUG_FUNC_END();
}
-void stb_set_mailbox_type(HIPC_API a_hAPI)
+void stb_set_local_mailbox(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
int mailbox_id = 0;
- int mailbox_type = 0;
+ int is_local_mailbox = 0;
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id);
EM_DEBUG_LOG("mailbox_id[%d]", mailbox_id);
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mailbox_type);
- EM_DEBUG_LOG("mailbox_type[%d]", mailbox_type);
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &is_local_mailbox);
+ EM_DEBUG_LOG("is_local_mailbox[%d]", is_local_mailbox);
- if( (err = emdaemon_set_mailbox_type(mailbox_id, mailbox_type)) != EMAIL_ERROR_NONE)
+ if( (err = emdaemon_set_local_mailbox(mailbox_id, is_local_mailbox)) != EMAIL_ERROR_NONE)
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &mail_slot_size);
EM_DEBUG_LOG("mail_slot_size[%d]", mail_slot_size);
- if(emdaemon_set_mail_slot_size_of_mailbox(account_id, mailbox_id, mail_slot_size, (unsigned*)&handle, &err))
+ if(emdaemon_set_mail_slot_size_of_mailbox(account_id, mailbox_id, mail_slot_size, &handle, &err))
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 3, sizeof(int), &on_server);
EM_DEBUG_LOG("on_server[%d]", on_server);
- if ((err = emdaemon_rename_mailbox(mailbox_id, mailbox_path, mailbox_alias, on_server, (unsigned*)&handle)) != EMAIL_ERROR_NONE) {
+ if ((err = emdaemon_rename_mailbox(mailbox_id, mailbox_path, mailbox_alias, on_server, &handle)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emdaemon_rename_mailbox failed [%d]", err);
}
void stb_send_mail(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
- int buffer_size = 0;
- char* local_option_stream = NULL;
char* local_stream = NULL;
- email_mailbox_t* mailbox = NULL;
- email_option_t sending_option;
int mail_id;
int handle;
int err = EMAIL_ERROR_NONE;
- char* mailbox_name = NULL;
/* Mail_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id);
EM_DEBUG_LOG("mail_id [%d]", mail_id);
- /* Sending Option */
- buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1);
-
- if(buffer_size > 0) {
- local_option_stream = (char*)em_malloc(buffer_size);
-
- if(NULL == local_option_stream) {
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- if(local_option_stream) {
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, local_option_stream);
- em_convert_byte_stream_to_option(local_option_stream, buffer_size, &sending_option);
- }
- }
-
- if(emdaemon_send_mail(mail_id, &sending_option, (unsigned*)&handle, &err)) {
+ if(emdaemon_send_mail(mail_id, &handle, &err)) {
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
}
-FINISH_OFF:
EM_SAFE_FREE(local_stream);
- EM_SAFE_FREE(local_option_stream);
- EM_SAFE_FREE(mailbox);
- EM_SAFE_FREE(mailbox_name);
-
- emcore_free_option(&sending_option);
EM_DEBUG_FUNC_END();
}
int result_attachment_data_count = 0;
int param_index = 0;
int sync_server = 0;
- int mail_count = 0;
int err = EMAIL_ERROR_NONE;
- email_mail_data_t *result_mail_data = NULL;
+ email_mail_data_t result_mail_data = {0};
email_attachment_data_t *result_attachment_data = NULL;
email_meeting_request_t result_meeting_request = {0};
/* mail_data */
if(buffer_size > 0) {
char *stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
- em_convert_byte_stream_to_mail_data(stream, &result_mail_data, &mail_count);
+ em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data);
}
/* attachment */
/* meeting request */
EM_DEBUG_LOG("email_meeting_request_t");
- if ( result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST
- || result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE
- || result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) {
+ if ( result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST
+ || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE
+ || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) {
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
if(buffer_size > 0) {
EM_DEBUG_LOG("sync_server");
emipc_get_parameter(a_hAPI, ePARAMETER_IN, param_index++, sizeof(int), &sync_server);
- if( (err = emdaemon_add_mail(result_mail_data, result_attachment_data, result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) {
+ if( (err = emdaemon_add_mail(&result_mail_data, result_attachment_data, result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emdaemon_add_mail failed [%d]", err);
goto FINISH_OFF;
}
local_result = 1;
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, &(result_mail_data->mail_id), sizeof(int)))
+ if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.mail_id, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(result_mail_data->thread_id), sizeof(int)))
+ if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.thread_id, 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_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
}
- emcore_free_mail_data(result_mail_data);
+ emcore_free_mail_data(&result_mail_data);
if(result_attachment_data)
emcore_free_attachment_data(&result_attachment_data, result_attachment_data_count, NULL);
int result_attachment_data_count = 0;
int param_index = 0;
int sync_server = 0;
- int mail_count = 0;
- int *temp_buffer = NULL;
+ int *temp_buffer = NULL;
int err = EMAIL_ERROR_NONE;
- email_mail_data_t *result_mail_data = NULL;
+ email_mail_data_t result_mail_data = {0};
email_attachment_data_t *result_attachment_data = NULL;
email_meeting_request_t result_meeting_request = {0};
if(buffer_size > 0) {
char* stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
- em_convert_byte_stream_to_mail_data(stream, &result_mail_data, &mail_count);
+ em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data);
}
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
+
EM_DEBUG_LOG("email_attachment_data_t buffer_size[%d]", buffer_size);
if(buffer_size > 0) {
goto FINISH_OFF;
}
}
-
param_index++;
EM_DEBUG_LOG("email_meeting_request_t");
- if ( result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST
- || result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE
- || result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) {
+ if ( result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST
+ || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE
+ || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) {
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
if(buffer_size > 0) {
temp_buffer = emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
- if (!temp_buffer) {
- EM_DEBUG_EXCEPTION("emipc_get_nth_parameter_data[%d] failed ", param_index - 1);
+ if(!temp_buffer) {
+ EM_DEBUG_EXCEPTION("emipc_get_nth_parameter_data[%d] failed", param_index - 1);
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
goto FINISH_OFF;
}
sync_server = *temp_buffer;
- if( (err = emdaemon_update_mail(result_mail_data, result_attachment_data,
+ if( (err = emdaemon_update_mail(&result_mail_data, result_attachment_data,
result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emdaemon_update_mail failed [%d]", err);
goto FINISH_OFF;
local_result = 1;
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, &(result_mail_data->mail_id), sizeof(int)))
+ if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.mail_id, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(result_mail_data->thread_id), sizeof(int)))
+ if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.thread_id, 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_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
}
- emcore_free_mail_data(result_mail_data);
+ emcore_free_mail_data(&result_mail_data);
if(result_attachment_data)
emcore_free_attachment_data(&result_attachment_data, result_attachment_data_count, NULL);
EM_DEBUG_FUNC_BEGIN();
int thread_id = 0, delete_always_flag = 0;
- unsigned int handle = 0;
+ int handle = 0;
int err = EMAIL_ERROR_NONE;
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &thread_id);
EM_DEBUG_FUNC_BEGIN();
int thread_id = 0, seen_flag = 0, on_server = 0;
- unsigned int handle = 0;
+ int handle = 0;
int err = EMAIL_ERROR_NONE;
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &thread_id);
EM_DEBUG_FUNC_BEGIN();
int mailbox_id = 0, on_server = 0;
- unsigned int handle = 0;
+ int handle = 0;
int err = EMAIL_ERROR_NONE;
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), (void*)&mailbox_id);
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
int account_id = 0;
- unsigned int handle = 0;
+ int handle = 0;
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
int err = EMAIL_ERROR_NONE;
int mail_id = 0;
int nth = 0;
- unsigned int handle = 0;
+ int handle = 0;
int account_id = 0;
EM_DEBUG_LOG("account_id");
void stb_mail_send_saved(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
- int buffer_size = 0;
int err = EMAIL_ERROR_NONE;
- char* local_option_stream = NULL;
- email_option_t sending_option;
int account_id = 0;
- /* unsigned *handle = NULL; */
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
- /* Sending Option */
- EM_DEBUG_LOG("Sending option");
- buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1);
-
- if(buffer_size > 0) {
- local_option_stream = (char*)em_malloc(buffer_size);
- EM_NULL_CHECK_FOR_VOID(local_option_stream);
- if(local_option_stream) {
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, local_option_stream);
- em_convert_byte_stream_to_option(local_option_stream, buffer_size, &sending_option);
- /* EM_SAFE_FREE(local_option_stream); */
- }
- }
-
EM_DEBUG_LOG("calling emdaemon_send_mail_saved");
- if(emdaemon_send_mail_saved(account_id, &sending_option, NULL, &err))
+ if(emdaemon_send_mail_saved(account_id, NULL, &err))
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
- emcore_free_option(&sending_option);
-
EM_DEBUG_FUNC_END();
}
EM_DEBUG_FUNC_BEGIN();
int buffer_size = 0;
int local_result = 0;
- unsigned int handle = 0;
+ int handle = 0;
char* stream = NULL;
email_account_t *account = NULL;
int err = EMAIL_ERROR_NONE;
int err = EMAIL_ERROR_NONE;
int verify = 0;
int mail_id = 0;
- int cert_file_len = 0;
- char *cert_file_path = 0;
+ int count = 0;
+ int attachment_tbl_count = 0;
email_mail_data_t *mail_data = NULL;
+ emstorage_attachment_tbl_t *attachment_tbl_list = NULL;
- cert_file_len = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
- if (cert_file_len > 0) {
- cert_file_path = em_malloc(cert_file_len + 1);
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, cert_file_len, cert_file_path);
- }
-
- err = emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id);
+ err = emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id);
if (err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_get_parameter failed");
+ goto FINISH_OFF;
}
if (!emcore_get_mail_data(mail_id, &mail_data)) {
EM_DEBUG_EXCEPTION("emcore_get_mail_data failed");
+ goto FINISH_OFF;
}
- if (!emcore_verify_signature(cert_file_path, mail_data->file_path_mime_entity, &verify, &err)) {
- EM_DEBUG_EXCEPTION("em_core_smime_add_certificate failed");
+ if ((err = emstorage_get_attachment_list(mail_id, true, &attachment_tbl_list, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed : [%d]", err);
+ goto FINISH_OFF;
}
+ for (count = 0; count < attachment_tbl_count; count++) {
+ if (strcasestr(attachment_tbl_list[count].attachment_name, "p7s") == NULL)
+ continue;
+
+ break;
+ }
+
+ if (!emcore_verify_signature(attachment_tbl_list[count].attachment_path, mail_data->file_path_mime_entity, &verify, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_verify_signature failed");
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+
if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &verify, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
- EM_SAFE_FREE(cert_file_path);
+
+ if (attachment_tbl_list)
+ emstorage_free_attachment(&attachment_tbl_list, attachment_tbl_count, NULL);
+
+ if (mail_data)
+ emcore_free_mail_data(mail_data);
+
EM_DEBUG_FUNC_END();
}
EM_DEBUG_FUNC_END("err [%d]", err);
}
+void stb_write_mime_file(HIPC_API a_hAPI)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int i = 0;
+ int exist_file_path = 0;
+ int buffer_size = 0;
+ int local_result = 0;
+ int result_attachment_data_count = 0;
+ int param_index = 0;
+ int err = EMAIL_ERROR_NONE;
+ char *file_path = NULL;
+ char *output_file_path = NULL;
+ email_mail_data_t result_mail_data = {0};
+ email_attachment_data_t *result_attachment_data = NULL;
+ emstorage_mail_tbl_t *input_mail_tbl_data = NULL;
+ emstorage_attachment_tbl_t *input_attachment_tbl_data = NULL;
+
+ /* email_mail_data_t */;
+ buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
+ EM_DEBUG_LOG("email_mail_data_t buffer_size[%d]", buffer_size);
+
+ /* mail_data */
+ if(buffer_size > 0) {
+ char *stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
+ em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data);
+ }
+
+ /* attachment */
+ buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
+ EM_DEBUG_LOG("email_attachment_data_t buffer_size[%d]", buffer_size);
+
+ if(buffer_size > 0) {
+ char *stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index);
+ em_convert_byte_stream_to_attachment_data(stream, buffer_size, &result_attachment_data, &result_attachment_data_count);
+
+ EM_DEBUG_LOG("result_attachment_data_count[%d]", result_attachment_data_count);
+
+ if(result_attachment_data_count && !result_attachment_data) {
+ EM_DEBUG_EXCEPTION("em_convert_byte_stream_to_attachment_data failed");
+ err = EMAIL_ERROR_ON_PARSING;
+ goto FINISH_OFF;
+ }
+ }
+
+ param_index++;
+
+ buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
+ if (buffer_size > 0) {
+ output_file_path = (char *)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index);
+ EM_DEBUG_LOG("output_file_path : [%s]", output_file_path);
+ }
+
+ /* Convert mail_data to mail_tbl */
+ if (!em_convert_mail_data_to_mail_tbl(&result_mail_data, 1, &input_mail_tbl_data, &err)) {
+ EM_DEBUG_EXCEPTION("em_convert_mail_data_to_mail_tbl failed");
+ goto FINISH_OFF;
+ }
+
+ /* Convert attachment_data to attachment_tbl */
+ if (result_attachment_data_count > 0) {
+ input_attachment_tbl_data = (emstorage_attachment_tbl_t *)em_malloc(sizeof(emstorage_attachment_tbl_t) * result_attachment_data_count);
+ if (input_attachment_tbl_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+ }
+
+ for (i = 0; i < result_attachment_data_count ; i++) {
+ input_attachment_tbl_data[i].attachment_id = result_attachment_data[i].attachment_id;
+ input_attachment_tbl_data[i].attachment_name = EM_SAFE_STRDUP(result_attachment_data[i].attachment_name);
+ input_attachment_tbl_data[i].attachment_path = EM_SAFE_STRDUP(result_attachment_data[i].attachment_path);
+ input_attachment_tbl_data[i].attachment_size = result_attachment_data[i].attachment_size;
+ input_attachment_tbl_data[i].mail_id = result_attachment_data[i].mail_id;
+ input_attachment_tbl_data[i].account_id = result_attachment_data[i].account_id;
+ input_attachment_tbl_data[i].mailbox_id = result_attachment_data[i].mailbox_id;
+ input_attachment_tbl_data[i].attachment_save_status = result_attachment_data[i].save_status;
+ input_attachment_tbl_data[i].attachment_drm_type = result_attachment_data[i].drm_status;
+ input_attachment_tbl_data[i].attachment_inline_content_status = result_attachment_data[i].inline_content_status;
+ input_attachment_tbl_data[i].attachment_mime_type = EM_SAFE_STRDUP(result_attachment_data[i].attachment_mime_type);
+ }
+
+
+ if (!emcore_make_rfc822_file_from_mail(input_mail_tbl_data, input_attachment_tbl_data, result_attachment_data_count, NULL, &file_path, NULL, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_make_rfc822_file_from_mail failed");
+ goto FINISH_OFF;
+ }
+
+ if (output_file_path) {
+ if (!emstorage_move_file(file_path, output_file_path, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_move_file failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ exist_file_path = 1;
+ output_file_path = EM_SAFE_STRDUP(file_path);
+ }
+
+
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, (char *)output_file_path, strlen(output_file_path) + 1)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMAIL_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ local_result = 1;
+
+FINISH_OFF:
+ if ( local_result == 0 ) {
+ 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");
+
+ emcore_free_mail_data(&result_mail_data);
+
+ if(result_attachment_data)
+ emcore_free_attachment_data(&result_attachment_data, result_attachment_data_count, NULL);
+
+ EM_SAFE_FREE(file_path);
+ if (exist_file_path)
+ EM_SAFE_FREE(output_file_path);
+
+ em_flush_memory();
+ EM_DEBUG_FUNC_END();
+}
+
void stb_API_mapper(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
stb_delete_mailbox(a_hAPI);
break;
- case _EMAIL_API_UPDATE_MAILBOX:
- stb_update_mailbox(a_hAPI);
- break;
-
case _EMAIL_API_SET_MAILBOX_TYPE:
stb_set_mailbox_type(a_hAPI);
break;
+ case _EMAIL_API_SET_LOCAL_MAILBOX:
+ stb_set_local_mailbox(a_hAPI);
+ break;
+
case _EMAIL_API_SET_MAIL_SLOT_SIZE:
stb_set_mail_slot_size_of_mailbox(a_hAPI);
break;
stb_send_mail(a_hAPI);
break;
-#if 0
- case _EMAIL_API_GET_MAILBOX_COUNT:
- stb_get_mail_count_of_mailbox(a_hAPI);
- break;
-#endif
-
case _EMAIL_API_GET_MAILBOX_LIST:
stb_get_mailbox_list(a_hAPI);
break;
stb_delete_mail(a_hAPI);
break;
- case _EMAIL_API_MODIFY_MAIL_FLAG:
- stb_modify_mail_flag(a_hAPI);
- break;
-#if 0
- case _EMAIL_API_MODIFY_MAIL_EXTRA_FLAG:
- stb_modify_mail_extra_flag(a_hAPI);
- break;
-#endif
-
case _EMAIL_API_ADD_RULE:
stb_add_rule(a_hAPI);
break;
case _EMAIL_API_SHOW_USER_MESSAGE :
stb_show_user_message(a_hAPI);
break;
+
+ case _EMAIL_API_WRITE_MIME_FILE :
+ stb_write_mime_file(a_hAPI);
+ break;
}
EM_DEBUG_FUNC_END();
}
if (!parameters) {
EM_DEBUG_EXCEPTION("emipc_get_api_parameters failed");
return false;
-}
+ }
return emipc_add_param_to_param_list(parameters, data, data_length);
}
case _EMAIL_API_DELETE_MAILBOX:\
s = "_EMAIL_API_DELETE_MAILBOX";\
break;\
- case _EMAIL_API_UPDATE_MAILBOX:\
- s = "_EMAIL_API_UPDATE_MAILBOX";\
- break;\
case _EMAIL_API_RENAME_MAILBOX:\
s = "_EMAIL_API_RENAME_MAILBOX";\
break;\
case _EMAIL_API_SET_MAILBOX_TYPE:\
s = "_EMAIL_API_SET_MAILBOX_TYPE";\
break;\
+ case _EMAIL_API_SET_LOCAL_MAILBOX:\
+ s = "_EMAIL_API_SET_LOCAL_MAILBOX";\
+ break;\
case _EMAIL_API_SET_MAIL_SLOT_SIZE:\
s = "_EMAIL_API_SET_MAIL_SLOT_SIZE";\
break;\
case _EMAIL_API_MODIFY_MAIL_FLAG:\
s = "_EMAIL_API_MODIFY_MAIL_FLAG";\
break;\
- case _EMAIL_API_MODIFY_MAIL_EXTRA_FLAG:\
- s = "_EMAIL_API_MODIFY_MAIL_EXTRA_FLAG";\
- break;\
case _EMAIL_API_ADD_RULE:\
s = "_EMAIL_API_ADD_RULE";\
break;\
case _EMAIL_API_SHOW_USER_MESSAGE:\
s = "_EMAIL_API_SHOW_USER_MESSAGE";\
break;\
+ case _EMAIL_API_WRITE_MIME_FILE:\
+ s = "_EMAIL_API_WRITE_MIME_FILE";\
+ break;\
default : \
s = "UNKNOWN_APIID";\
}\
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-*
+*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
#include "email-api.h"
#include "email-types.h"
#include "email-internal-types.h"
-
-pthread_mutex_t proxy_mutex = PTHREAD_MUTEX_INITIALIZER;
+#include <glib.h>
EXPORT_API int emipc_initialize_proxy()
{
emipc_email_api_info *api_info = (emipc_email_api_info *)api;
EM_DEBUG_LOG("API [%p]", api_info);
-
+
if(api_info == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
return EMAIL_ERROR_INVALID_PARAM;
}
-
+
EM_DEBUG_LOG("APIID [%s], ResponseID [%d], APPID[%d]",
EM_APIID_TO_STR(api_info->api_id), api_info->response_id, api_info->app_id);
- ENTER_CRITICAL_SECTION(proxy_mutex);
ret = emipc_execute_api_of_proxy_main(api_info);
/* connection retry */
goto FINISH_OFF;
}
}
-
+
FINISH_OFF:
- LEAVE_CRITICAL_SECTION(proxy_mutex);
EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
+ return err;
}
+
#include "email-ipc-socket.h"
#include "email-debug-log.h"
+#include "email-internal-types.h"
+#include "email-utilities.h"
#include <errno.h>
+#include <glib.h>
+#include <pthread.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+typedef struct {
+ pid_t pid;
+ pthread_t tid;
+ int socket_fd;
+} thread_socket_t;
-static int proxy_socket_fd = 0;
+GList *socket_head = NULL;
+pthread_mutex_t proxy_mutex = PTHREAD_MUTEX_INITIALIZER;
EXPORT_API bool emipc_start_proxy_socket()
{
EM_DEBUG_FUNC_BEGIN();
int ret = true;
+ int socket_fd = 0;
- ret = emipc_init_email_socket(&proxy_socket_fd);
+ ret = emipc_init_email_socket(&socket_fd);
if (!ret) {
+ EM_DEBUG_EXCEPTION("emipc_init_email_socket failed");
+ return false;
+ }
+
+ ret = emipc_connect_email_socket(socket_fd);
+ if( !ret ) {
+ EM_DEBUG_EXCEPTION("emipc_connect_email_socket failed");
return false;
}
- ret = emipc_connect_email_socket(proxy_socket_fd);
+ thread_socket_t* cur = (thread_socket_t*) em_malloc(sizeof(thread_socket_t));
+ if(!cur) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ return false;
+ }
+
+ /* add a socket */
+ cur->pid = getpid();
+ cur->tid = pthread_self();
+ cur->socket_fd = socket_fd;
- return ret;
+ ENTER_CRITICAL_SECTION(proxy_mutex);
+ socket_head = g_list_prepend(socket_head, cur);
+ LEAVE_CRITICAL_SECTION(proxy_mutex);
+
+ return true;
}
EXPORT_API bool emipc_end_proxy_socket()
{
EM_DEBUG_FUNC_BEGIN();
EM_DEBUG_LOG("[IPCLib] emipc_end_proxy_socket_fd");
-
- if (proxy_socket_fd) {
- emipc_close_email_socket(&proxy_socket_fd);
+
+ pid_t pid = getpid();
+
+ ENTER_CRITICAL_SECTION(proxy_mutex);
+ GList *cur = socket_head;
+ while( cur ) {
+ thread_socket_t* cur_socket = g_list_nth_data(cur,0);
+
+ /* close all sockets of the pid */
+ if( pid == cur_socket->pid ) {
+ emipc_close_email_socket(&cur_socket->socket_fd);
+ EM_SAFE_FREE(cur_socket);
+ GList *del = cur;
+ cur = g_list_next(cur);
+ socket_head = g_list_remove_link(socket_head, del);
+ continue;
+ }
+
+ cur = g_list_next(cur);
}
+ LEAVE_CRITICAL_SECTION(proxy_mutex);
return true;
}
EXPORT_API int emipc_send_proxy_socket(unsigned char *data, int len)
{
EM_DEBUG_FUNC_BEGIN();
- if (!proxy_socket_fd) {
- EM_DEBUG_EXCEPTION("[IPCLib] emipc_send_proxy_socket_fd not connect");
- return EMAIL_ERROR_IPC_SOCKET_FAILURE;
+ int socket_fd = emipc_get_proxy_socket_id();
+
+ /* if thread socket is not created */
+ if (!socket_fd) {
+ int ret = emipc_start_proxy_socket();
+ if(!ret ) {
+ EM_DEBUG_EXCEPTION("[IPCLib] emipc_send_proxy_socket not connected");
+ return EMAIL_ERROR_IPC_SOCKET_FAILURE;
+ }
+ socket_fd = emipc_get_proxy_socket_id();
}
- int send_len = emipc_send_email_socket(proxy_socket_fd, data, len);
+
+ int send_len = emipc_send_email_socket(socket_fd, data, len);
if (send_len == 0) {
- EM_DEBUG_EXCEPTION("[IPCLib] server closed connection %x", proxy_socket_fd);
- emipc_close_email_socket(&proxy_socket_fd);
+ EM_DEBUG_EXCEPTION("[IPCLib] server closed connection %x", socket_fd);
+ emipc_end_proxy_socket();
}
+
return send_len;
}
EXPORT_API int emipc_get_proxy_socket_id()
{
EM_DEBUG_FUNC_BEGIN();
- return proxy_socket_fd;
+ pthread_t tid = pthread_self();
+ int socket_fd = 0;
+
+ ENTER_CRITICAL_SECTION(proxy_mutex);
+ GList *cur = socket_head;
+ /* need to acquire lock */
+ for( ; cur ; cur = g_list_next(cur) ) {
+ thread_socket_t* cur_socket = g_list_nth_data(cur,0);
+ if( pthread_equal(tid, cur_socket->tid) ) {
+ socket_fd = cur_socket->socket_fd;
+ break;
+ }
+ }
+ LEAVE_CRITICAL_SECTION(proxy_mutex);
+ EM_DEBUG_LOG("tid %d, socket_fd %d", tid, socket_fd);
+ return socket_fd;
}
/* return true, when event occurred
EXPORT_API int emipc_recv_proxy_socket(char **data)
{
EM_DEBUG_FUNC_BEGIN();
-
- if (!proxy_socket_fd) {
- EM_DEBUG_EXCEPTION("[IPCLib] proxy_socket_fd[%p] is not available or disconnected", proxy_socket_fd);
+ int socket_fd = emipc_get_proxy_socket_id();
+ if (!socket_fd) {
+ EM_DEBUG_EXCEPTION("[IPCLib] proxy_socket_fd[%p] is not available or disconnected", socket_fd);
return EMAIL_ERROR_IPC_SOCKET_FAILURE;
}
- if( !wait_for_reply(proxy_socket_fd) ) {
-
+ if( !wait_for_reply(socket_fd) ) {
return EMAIL_ERROR_IPC_SOCKET_FAILURE;
}
- int recv_len = emipc_recv_email_socket(proxy_socket_fd, data);
+ int recv_len = emipc_recv_email_socket(socket_fd, data);
if (recv_len == 0) {
- EM_DEBUG_EXCEPTION("[IPCLib] server closed connection %x", proxy_socket_fd);
- emipc_close_email_socket(&proxy_socket_fd);
+ EM_DEBUG_EXCEPTION("[IPCLib] server closed connection %x", socket_fd);
+ emipc_end_proxy_socket();
}
return recv_len;
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-*
+*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
EM_DEBUG_LOG("Socket fd = %d", *fd);
- return ret;
+ return ret;
}
/* Close */
EXPORT_API void emipc_close_email_socket(int* fd)
{
- EM_DEBUG_LOG("fd %d removal done", fd);
+ EM_DEBUG_LOG("fd %d removal done", *fd);
close(*fd);
*fd = 0;
}
}
EM_DEBUG_LOG("Sending %dB data to [fd = %d]", len, fd);
-
+
int write_len = emipc_writen(fd, (char*) buf, len);
if ( write_len != len) {
if ( write_len == 0 ) return 0;
EXPORT_API int emipc_recv_email_socket(int fd, char **buf)
{
EM_DEBUG_FUNC_BEGIN();
-
+
if (!buf) {
EM_DEBUG_LOG("Buffer must not null");
return EMAIL_ERROR_INVALID_PARAM;
EM_DEBUG_EXCEPTION("ioctl: %s", strerror(errno));
return EMAIL_ERROR_IPC_SOCKET_FAILURE;
}
- /* server closed socket or is downed*/
+ /* when server or client closed socket */
if ( read_len == 0 ) {
- EM_DEBUG_EXCEPTION("[IPC Socket] server closed connection");
+ EM_DEBUG_LOG("[IPC Socket] connection is closed");
return 0;
}
return EMAIL_ERROR_OUT_OF_MEMORY;
}
memset(*buf, 0x00, read_len);
-
+
EM_DEBUG_LOG("[IPC Socket] Receiving [%d] bytes", read_len);
int len = emipc_readn(fd, *buf, read_len);
if (read_len != len) {
EXPORT_API int emipc_accept_email_socket(int fd)
{
EM_DEBUG_FUNC_BEGIN();
-
+
if (fd == -1) {
EM_DEBUG_LOG("Server_socket not init");
return EMAIL_ERROR_INVALID_PARAM;
}
-
+
struct sockaddr_un remote;
int remote_len = sizeof(remote);
int client_fd = accept(fd, (struct sockaddr *)&remote, (socklen_t*) &remote_len);
}
EM_DEBUG_LOG("%d is added", client_fd);
-
+
EM_DEBUG_FUNC_END();
return client_fd;
}
EM_DEBUG_LOG("Path is null");
return EMAIL_ERROR_IPC_SOCKET_FAILURE;
}
-
+
if (fd <= 0) {
EM_DEBUG_LOG("Socket not created %d", fd);
return EMAIL_ERROR_IPC_SOCKET_FAILURE;
strcpy(server.sun_path, EM_SOCKET_PATH);
int len = strlen(server.sun_path) + sizeof(server.sun_family);
-
+
if (connect(fd, (struct sockaddr *)&server, len) == -1) {
EM_DEBUG_LOG("Cannot connect server %s", EM_STRERROR(errno));
return false;
<tr><td>int email_free_account(email_account_t** account_list, int count) </td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
-<tr><td>int email_validate_account(int account_id, unsigned* handle)</td>
+<tr><td>int email_validate_account(int account_id, int *handle)</td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
</table>
<table>
<tr><td>API</td><td>Return Value / Exceptions</td></tr>
-<tr><td>int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle) </td>
+<tr><td>int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle) </td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* new_mailbox should be allocated and deallocated by Application </td></tr>
-<tr><td>int email_delete_mailbox(email_mailbox_t* mailbox, int on_server, unsigned* handle) </td>
+<tr><td>int email_delete_mailbox(email_mailbox_t* mailbox, int on_server, int *handle) </td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
<tr><td>int email_update_mailbox(email_mailbox_t*old_mailbox, email_mailbox_t* new_mailbox)</td>
@li Create new mailbox
@code
email_mailbox_t *mailbox = NULL, *new_mailbox = NULL;
-unsigned handle = 0;
+int handle = 0;
int on_server = 0;
mailbox = malloc(sizeof(email_mailbox_t));
@code
email_mailbox_t *mailbox = NULL, *new_mailbox = NULL;
int on_server = 0;
-unsigned handle = 0;
+int handle = 0;
new_mailbox = malloc(sizeof(email_mailbox_t));
memset(new_mailbox, 0x00, sizeof(email_mailbox_t));
<tr><td>int email_free_attachment_info(email_attachment_data_t** atch_info) </td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
-<tr><td>int email_modify_mail_flag(int mail_id, email_mail_flag_t new_flag, int onserver) </td>
-<td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
-
<tr><td>int email_modify_seen_flag(int *mail_ids, int num, int seen_flag, int onserver) </td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param int *mail_ids should be allocated and deallocated by Application</td></tr>
-
-<tr><td>int email_modify_extra_mail_flag(int mail_id, email_extra_flag_t new_flag) </td>
-<td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
<tr><td>int email_move_mail_to_mailbox(int *mail_ids, int num, email_mailbox_t* new_mailbox) </td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and email_mailbox_t* new_mailbox should be allocated and deallocated by Application</td></tr>
<tr><td>int email_free_mailbox(email_mailbox_t** mailbox_list, int count) </td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
-
-<tr><td>int email_get_mail_flag(int account_id, int mail_id, email_mail_flag_t* mail_flag) </td>
-<td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
<tr><td>int email_retry_sending_mail( int mail_id, int timeout_in_sec) </td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
/* success */
@endcode
-@li Modify flag
-@code
-email_mail_flag_t newflag = {0};
-int mail_id = 0;
-int on_server = 0;
-
-/* Modify mail flag*/
-if(EMAIL_ERROR_NONE != email_modify_mail_flag(mail_id,newflag,on_server))
- /* failure */
-else
- /* success */
-
-int mail_ids[] = {1, 2};
-int num = 2;
-int seen_flag = 0;
-int on_server = 0;
-
-/* Modify seen flag*/
-if(EMAIL_ERROR_NONE != email_modify_seen_flag(mail_ids, num, seen_flag,on_server))
- /* failure */
-else
- /* success */
-
-/* Modify extra flag*/
-int mail_id = 1;
-if(EMAIL_ERROR_NONE != email_modify_extra_mail_flag(mail_id, newflag))
- /* failure */
-else
- /* success */
-@endcode
-
@li Move mail
@code
<tr><td>API</td>
<td>Return Value / Exceptions</td></tr>
-<tr><td>int email_send_mail( email_mailbox_t* mailbox, int mail_id, email_option_t* sending_option, unsigned* handle)</td>
+<tr><td>int email_send_mail( email_mailbox_t* mailbox, int mail_id, int *handle)</td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
-# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
-<tr><td>int email_sync_header(email_mailbox_t* mailbox, unsigned* handle)</td>
+<tr><td>int email_sync_header(email_mailbox_t* mailbox, int *handle)</td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
-# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
-<tr><td>int email_download_body(email_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle) </td>
+<tr><td>int email_download_body(email_mailbox_t* mailbox, int mail_id, int with_attachment, int *handle) </td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
-# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
-<tr><td>int email_download_attachment(email_mailbox_t* mailbox, int mail_id, const char* nth, unsigned* handle)</td>
+<tr><td>int email_download_attachment(email_mailbox_t* mailbox, int mail_id, const char* nth, int *handle)</td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
<tr><td>int email_cancel_job(int account_id, int handle)</td>
<tr><td>void email_get_network_status(int* on_sending, int* on_receiving) </td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
-<tr><td>int email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle)</td>
+<tr><td>int email_send_saved(int account_id, email_option_t* sending_option, int *handle)</td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
-# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
-<tr><td>int email_sync_imap_mailbox_list(int account_id, const char* mailbox, unsigned* handle)</td>
+<tr><td>int email_sync_imap_mailbox_list(int account_id, const char* mailbox, int *handle)</td>
<td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
<tr><td>int email_sync_local_activity(int account_id)</td>
email_mailbox_t mailbox;
int account_id = 1;
int err = EMAIL_ERROR_NONE;
-unsigned handle = 0;
+int handle = 0;
memset(&mailbox, 0x00, sizeof(email_mailbox_t));
int mail_id = 1;
int account_id = 1;
char arg[50]; /* Input attachment number need to be download */
-unsigned handle = 0;
+int handle = 0;
int err = EMAIL_ERROR_NONE;
memset(&mailbox, 0x00, sizeof(email_mailbox_t));
Name: email-service
Summary: E-mail Framework Middleware package
-Version: 0.9.9
+Version: 0.10.1
Release: 1
Group: System/Libraries
License: TBD
server_mailbox_name VARCHAR(129),
server_mail_id VARCHAR(129),
message_id VARCHAR(257),
+ reference_mail_id INTEGER,
full_address_from TEXT,
full_address_reply TEXT,
full_address_to TEXT,
char id_string[100] = { 0, }, password_string[100] = { 0, }, address_string[100] = { 0, };
int err_code = EMAIL_ERROR_NONE, samsung3g_account_index;
int result_from_scanf = 0;
- unsigned handle;
+ int handle;
switch(account_type) {
case 4 :
int account_id;
email_account_t *account=NULL;
int err_code = EMAIL_ERROR_NONE;
- unsigned account_handle = 0;
+ int handle = 0;
testapp_print("\n>> Enter Account No: ");
result_from_scanf = scanf("%d",&account_id);
else
testapp_print ("email_get_account result account_name - %s \n", account->account_name);
- if((err_code = email_validate_account(account_id, &account_handle)) == EMAIL_ERROR_NONE )
- testapp_print ("email_validate_account successful account_handle : %u\n",account_handle);
+ if((err_code = email_validate_account(account_id, &handle)) == EMAIL_ERROR_NONE )
+ testapp_print ("email_validate_account successful handle : %u\n",handle);
else
testapp_print ("email_validate_account failed err_code: %d \n",err_code);
#include "email-api-mail.h"
#include "email-api-mailbox.h"
#include "email-api-etc.h"
+#include "email-api-smime.h"
/* internal header */
#include "testapp-utility.h"
if ( mail_list_item[i].subject != NULL ) {
testapp_print(" >>> subject [ %s ] \n", mail_list_item[i].subject);
}
- testapp_print(" >>> text_download_yn [ %d ] \n", mail_list_item[i].is_text_downloaded);
+ testapp_print(" >>> text_download_yn [ %d ] \n", mail_list_item[i].body_download_status);
testapp_print(" >>> date_time [ %d ] \n", mail_list_item[i].date_time);
testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list_item[i].flags_seen_field);
testapp_print(" >>> priority [ %d ] \n", mail_list_item[i].priority);
testapp_print(" >>> save_status [ %d ] \n", mail_list_item[i].save_status);
- testapp_print(" >>> lock [ %d ] \n", mail_list_item[i].is_locked);
- testapp_print(" >>> is_report_mail [ %d ] \n", mail_list_item[i].is_report_mail);
+ testapp_print(" >>> lock [ %d ] \n", mail_list_item[i].lock_status);
+ testapp_print(" >>> report_status [ %d ] \n", mail_list_item[i].report_status);
testapp_print(" >>> recipients_count [ %d ] \n", mail_list_item[i].recipients_count);
- testapp_print(" >>> has_attachment [ %d ] \n", mail_list_item[i].has_attachment);
- testapp_print(" >>> has_drm_attachment [ %d ] \n", mail_list_item[i].has_drm_attachment);
+ testapp_print(" >>> attachment_count [ %d ] \n", mail_list_item[i].attachment_count);
+ testapp_print(" >>> DRM_status [ %d ] \n", mail_list_item[i].DRM_status);
- if ( mail_list_item[i].previewBodyText != NULL ) {
- testapp_print(" >>> previewBodyText [ %s ] \n", mail_list_item[i].previewBodyText);
+ if ( mail_list_item[i].preview_text != NULL ) {
+ testapp_print(" >>> preview_text [ %s ] \n", mail_list_item[i].preview_text);
}
testapp_print(" >>> thread_id [ %d ] \n", mail_list_item[i].thread_id);
}
*/
+static gboolean testapp_add_mail_for_sending (int *result_mail_id)
+{
+ int result_from_scanf = 0;
+ int i = 0;
+ int account_id = 0;
+ int err = EMAIL_ERROR_NONE;
+ int smime_type = 0;
+ char receipient_address[300] = { 0 , };
+ char from_address[300] = { 0 , };
+ const char *body_file_path = MAIL_TEMP_BODY;
+ email_account_t *account_data = NULL;
+ email_mailbox_t *mailbox_data = NULL;
+ email_mail_data_t *test_mail_data = NULL;
+ FILE *body_file;
+
+ testapp_print("\n > Enter account id : ");
+ result_from_scanf = scanf("%d", &account_id);
+
+ testapp_print("\n > Enter receipient address : ");
+ result_from_scanf = scanf("%s", receipient_address);
+
+ email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_data);
+
+ email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_data);
+
+ test_mail_data = malloc(sizeof(email_mail_data_t));
+ memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
+
+ SNPRINTF(from_address, 300, "<%s>", account_data->user_email_address);
+
+ test_mail_data->account_id = account_id;
+ test_mail_data->save_status = 1;
+ test_mail_data->body_download_status = 1;
+ test_mail_data->flags_seen_field = 1;
+ test_mail_data->file_path_plain = strdup(body_file_path);
+ test_mail_data->mailbox_id = mailbox_data->mailbox_id;
+ test_mail_data->mailbox_type = mailbox_data->mailbox_type;
+ test_mail_data->full_address_from = strdup(from_address);
+ test_mail_data->full_address_to = strdup(receipient_address);
+ test_mail_data->subject = strdup("Read receipt request from TIZEN");
+ test_mail_data->report_status = EMAIL_MAIL_REQUEST_DSN | EMAIL_MAIL_REQUEST_MDN;
+
+ body_file = fopen(body_file_path, "w");
+
+ testapp_print("\n body_file [%p]\n", body_file);
+
+ if(body_file == NULL) {
+ testapp_print("\n fopen [%s]failed\n", body_file_path);
+ return FALSE;
+ }
+
+ for(i = 0; i < 100; i++)
+ fprintf(body_file, "Mail sending Test. [%d]\n", i);
+
+ fflush(body_file);
+ fclose(body_file);
+
+ testapp_print(" > Select smime? [0: Normal, 1: sign, 2: Encrpyt, 3: sing + encrypt] : ");
+ result_from_scanf = scanf("%d", &smime_type);
+ test_mail_data->smime_type = smime_type;
+
+ if((err = email_add_mail(test_mail_data, NULL, 0, NULL, 0)) != EMAIL_ERROR_NONE)
+ testapp_print("email_add_mail failed. [%d]\n", err);
+ else
+ testapp_print("email_add_mail success.\n");
+
+ testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id);
+
+ if(result_mail_id)
+ *result_mail_id = test_mail_data->mail_id;
+
+ email_free_mail_data(&test_mail_data, 1);
+ email_free_mailbox(&mailbox_data, 1);
+ email_free_account(&account_data, 1);
+
+ return FALSE;
+}
+
static gboolean testapp_test_add_mail (int *result_mail_id)
{
int result_from_scanf = 0;
}
testapp_print("\n > Meeting Request? [0: no, 1: yes (request from server), 2: yes (response from local)]");
- result_from_scanf = scanf("%d", &(test_mail_data->meeting_request_status));
+ result_from_scanf = scanf("%d", (int*)&(test_mail_data->meeting_request_status));
if ( test_mail_data->meeting_request_status == 1
|| test_mail_data->meeting_request_status == 2 ) {
testapp_print(" >>> lock_status [ %d ] \n", mails[i].lock_status);
testapp_print(" >>> attachment_count [ %d ] \n", mails[i].attachment_count);
if ( mails[i].preview_text != NULL )
- testapp_print(" >>> previewBodyText [ %s ] \n", mails[i].preview_text);
+ testapp_print(" >>> preview_text [ %s ] \n", mails[i].preview_text);
}
free(mails);
}
{
int added_mail_id = 0;
int err = EMAIL_ERROR_NONE;
- unsigned handle = 0;
- email_option_t option = { 0 };
- email_mailbox_t mailbox_data = { 0 };
- email_mail_data_t *result_mail_data = NULL;
+ int handle = 0;
+ email_mail_data_t *result_mail_data = NULL;
- testapp_test_add_mail(&added_mail_id);
+ testapp_add_mail_for_sending(&added_mail_id);
- if(result_mail_id) {
+ if(added_mail_id) {
email_get_mail_data(added_mail_id, &result_mail_data);
- memset(&mailbox_data, 0x00, sizeof(email_mailbox_t));
- mailbox_data.account_id = result_mail_data->account_id;
- mailbox_data.mailbox_id = result_mail_data->mailbox_id;
- option.keep_local_copy = 1;
-
testapp_print("Calling email_send_mail...\n");
- if( email_send_mail(added_mail_id, &option, &handle) < 0) {
+ if( email_send_mail(added_mail_id, &handle) < 0) {
testapp_print("Sending failed[%d]\n", err);
}
else {
return FALSE;
}
-static gboolean testapp_test_get_mail_list()
+static gboolean testapp_test_get_mail_list_ex()
{
email_list_filter_t *filter_list = NULL;
email_list_sorting_rule_t *sorting_rule_list = NULL;
email_mail_list_item_t *result_mail_list = NULL;
+ int filter_rule_count = 0;
+ int sorting_rule_count = 0;
int result_mail_count = 0;
int err = EMAIL_ERROR_NONE;
int i = 0;
- filter_list = malloc(sizeof(email_list_filter_t) * 9);
- memset(filter_list, 0 , sizeof(email_list_filter_t) * 9);
+ filter_rule_count = 1;
+
+ filter_list = malloc(sizeof(email_list_filter_t) * filter_rule_count);
+ memset(filter_list, 0 , sizeof(email_list_filter_t) * filter_rule_count);
filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
- filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT;
- filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
- filter_list[0].list_filter_item.rule.key_value.string_type_value = strdup("RE");
- filter_list[0].list_filter_item.rule.case_sensitivity = false;
+ filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE;
+ filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
+ filter_list[0].list_filter_item.rule.key_value.integer_type_value = EMAIL_MAILBOX_TYPE_INBOX;
+ /*
filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR;
filter_list[8].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
filter_list[8].list_filter_item.rule.key_value.string_type_value = strdup("RE");
filter_list[8].list_filter_item.rule.case_sensitivity = false;
+ */
/*
filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("INBOX");
filter_list[2].list_filter_item.rule.case_sensitivity = true;
*/
+ sorting_rule_count = 1;
- sorting_rule_list = malloc(sizeof(email_list_sorting_rule_t) * 2);
- memset(sorting_rule_list, 0 , sizeof(email_list_sorting_rule_t) * 2);
+ sorting_rule_list = malloc(sizeof(email_list_sorting_rule_t) * sorting_rule_count);
+ memset(sorting_rule_list, 0 , sizeof(email_list_sorting_rule_t) * sorting_rule_count);
- sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT;
- sorting_rule_list[0].sort_order = EMAIL_SORT_ORDER_ASCEND;
- sorting_rule_list[0].force_boolean_check = true;
+ sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME;
+ sorting_rule_list[0].sort_order = EMAIL_SORT_ORDER_DESCEND;
- sorting_rule_list[1].target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME;
- sorting_rule_list[1].sort_order = EMAIL_SORT_ORDER_ASCEND;
-
- err = email_get_mail_list_ex(filter_list, 9, sorting_rule_list, 2, -1, -1, &result_mail_list, &result_mail_count);
+ err = email_get_mail_list_ex(filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &result_mail_list, &result_mail_count);
if(err == EMAIL_ERROR_NONE) {
testapp_print("email_get_mail_list_ex succeed.\n");
for(i = 0; i < result_mail_count; i++) {
- testapp_print("mail_id [%d], subject [%s], from [%s]\n", result_mail_list[i].mail_id, result_mail_list[i].subject, result_mail_list[i].from);
+ testapp_print("mail_id [%d], subject [%s], full_address_from [%s]\n", result_mail_list[i].mail_id, result_mail_list[i].subject, result_mail_list[i].full_address_from);
}
}
else {
int mailbox_id = 0;
int on_server = 0;
int err_code = EMAIL_ERROR_NONE;
- unsigned handle = 0;
+ int handle = 0;
int result_from_scanf = 0;
testapp_print("\n >>> Input target mailbox id: ");
return 0;
}
-static gboolean testapp_test_get_mail_list_ex()
+static gboolean testapp_test_send_read_receipt()
{
- testapp_print("\n >>> testapp_test_get_mail_list_ex : Entered \n");
+ int read_mail_id = 0;
+ int receipt_mail_id = 0;
+ int err_code = EMAIL_ERROR_NONE;
+ int result_from_scanf = 0;
+ int handle = 0;
+
+ testapp_print("\n >>> Input read mail id: ");
+ result_from_scanf = scanf("%d", &read_mail_id);
+
+ err_code = email_add_read_receipt(read_mail_id, &receipt_mail_id);
+
+ testapp_print("eamil_add_read_receipt returns receipt_mail_id [%d] - err[%d]\n", receipt_mail_id, err_code);
+ testapp_print("Calling email_send_mail...\n");
+
+ if( (err_code = email_send_mail(receipt_mail_id, &handle)) != EMAIL_ERROR_NONE) {
+ testapp_print("Sending failed[%d]\n", err_code);
+ }
+ else {
+ testapp_print("Start sending. handle[%d]\n", handle);
+ }
+
+ return 0;
+}
+
+static gboolean testapp_test_delete_attachment()
+{
+ int attachment_id = 0;
+ int err_code = EMAIL_ERROR_NONE;
+ int result_from_scanf = 0;
+
+ testapp_print("\n >>> Input attachment id: ");
+ result_from_scanf = scanf("%d", &attachment_id);
+
+ if( (err_code = email_delete_attachment(attachment_id)) != EMAIL_ERROR_NONE) {
+ testapp_print("email_delete_attachment failed[%d]\n", err_code);
+ }
+
+ return 0;
+}
+
+static gboolean testapp_test_get_mail_list()
+{
+ testapp_print("\n >>> testapp_test_get_mail_list : Entered \n");
email_mail_list_item_t *mail_list = NULL, **mail_list_pointer = NULL;
int mailbox_id = 0;
int count = 0, i = 0;
testapp_print(" >>> mailbox_id [ %d ] \n", mail_list[i].mailbox_id);
testapp_print(" >>> mail_id [ %d ] \n", mail_list[i].mail_id);
testapp_print(" >>> account_id [ %d ] \n", mail_list[i].account_id);
- if ( mail_list[i].from != NULL )
- testapp_print(" >>> From [ %s ] \n", mail_list[i].from);
- if ( mail_list[i].recipients != NULL )
- testapp_print(" >>> recipients [ %s ] \n", mail_list[i].recipients);
+ if ( mail_list[i].full_address_from != NULL )
+ testapp_print(" >>> full_address_from [ %s ] \n", mail_list[i].full_address_from);
+ if ( mail_list[i].email_address_recipient != NULL )
+ testapp_print(" >>> email_address_recipient [ %s ] \n", mail_list[i].email_address_recipient);
if ( mail_list[i].subject != NULL )
testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject);
- testapp_print(" >>> is_text_downloaded [ %d ] \n", mail_list[i].is_text_downloaded);
+ testapp_print(" >>> body_download_status [ %d ] \n", mail_list[i].body_download_status);
temp_time_info = localtime(&mail_list[i].date_time);
testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n",
temp_time_info->tm_year + 1900,
testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list[i].flags_seen_field);
testapp_print(" >>> priority [ %d ] \n", mail_list[i].priority);
testapp_print(" >>> save_status [ %d ] \n", mail_list[i].save_status);
- testapp_print(" >>> is_locked [ %d ] \n", mail_list[i].is_locked);
- testapp_print(" >>> has_attachment [ %d ] \n", mail_list[i].has_attachment);
- if ( mail_list[i].previewBodyText != NULL )
- testapp_print(" >>> previewBodyText [ %s ] \n", mail_list[i].previewBodyText);
+ testapp_print(" >>> lock_status [ %d ] \n", mail_list[i].lock_status);
+ testapp_print(" >>> attachment_count [ %d ] \n", mail_list[i].attachment_count);
+ if ( mail_list[i].preview_text != NULL )
+ testapp_print(" >>> preview_text [ %s ] \n", mail_list[i].preview_text);
}
free(mail_list);
}
email_mail_list_item_t *mail_list = NULL;
int count = 0, i = 0;
int account_id = 0;
+ int mailbox_id = 0;
+ int result_from_scanf;
int err_code = EMAIL_ERROR_NONE;
struct tm *time_info;
+ testapp_print("\nEnter account id\n");
+ result_from_scanf = scanf("%d",&account_id);
+
+ testapp_print("\nEnter mailbox id\n");
+ result_from_scanf = scanf("%d",&mailbox_id);
+
+
/* Get mail list */
- if ( email_get_mail_list(account_id, 0 , EMAIL_LIST_TYPE_THREAD, 0, 500, EMAIL_SORT_DATETIME_HIGH, &mail_list, &count) < 0) {
+ if ( email_get_mail_list(account_id, mailbox_id , EMAIL_LIST_TYPE_THREAD, 0, 500, EMAIL_SORT_DATETIME_HIGH, &mail_list, &count) < 0) {
testapp_print("email_get_mail_list failed : %d\n",err_code);
return FALSE;
}
if (mail_list) {
for (i=0; i< count; i++) {
testapp_print(" i [%d]\n", i);
- testapp_print(" >>> Mail ID [ %d ] \n", mail_list[i].mail_id);
- testapp_print(" >>> Account ID [ %d ] \n", mail_list[i].account_id);
- testapp_print(" >>> Mailbox id [ %d ] \n", mail_list[i].mailbox_id);
- testapp_print(" >>> From [ %s ] \n", mail_list[i].from);
- testapp_print(" >>> recipients [ %s ] \n", mail_list[i].recipients);
+ testapp_print(" >>> mail_id [ %d ] \n", mail_list[i].mail_id);
+ testapp_print(" >>> account_id [ %d ] \n", mail_list[i].account_id);
+ testapp_print(" >>> mailbox_id [ %d ] \n", mail_list[i].mailbox_id);
+ testapp_print(" >>> full_address_from [ %s ] \n", mail_list[i].full_address_from);
+ testapp_print(" >>> email_address_recipient [ %s ] \n", mail_list[i].email_address_recipient);
testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject);
- testapp_print(" >>> is_text_downloaded [ %d ] \n", mail_list[i].is_text_downloaded);
+ testapp_print(" >>> body_download_status [ %d ] \n", mail_list[i].body_download_status);
time_info = localtime(&mail_list[i].date_time);
testapp_print(" >>> date_time [ %s ] \n", asctime(time_info));
testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list[i].flags_seen_field);
testapp_print(" >>> priority [ %d ] \n", mail_list[i].priority);
testapp_print(" >>> save_status [ %d ] \n", mail_list[i].save_status);
- testapp_print(" >>> lock [ %d ] \n", mail_list[i].is_locked);
- testapp_print(" >>> has_attachment [ %d ] \n", mail_list[i].has_attachment);
- testapp_print(" >>> previewBodyText [ %s ] \n", mail_list[i].previewBodyText);
+ testapp_print(" >>> lock [ %d ] \n", mail_list[i].lock_status);
+ testapp_print(" >>> attachment_count [ %d ] \n", mail_list[i].attachment_count);
+ testapp_print(" >>> preview_text [ %s ] \n", mail_list[i].preview_text);
testapp_print(" >>> thread_id [ %d ] \n", mail_list[i].thread_id);
testapp_print(" >>> thread__item_count [ %d ] \n", mail_list[i].thread_item_count);
}
static gboolean testapp_test_download_body ()
{
int mail_id = 0;
- unsigned handle = 0, err;
+ int handle = 0, err;
int result_from_scanf = 0;
testapp_print("\n > Enter Mail Id: ");
int mail_id = 0;
int account_id = 0;
int yes = 0;
- unsigned handle = 0;
+ int handle = 0;
int result_from_scanf = 0;
email_mailbox_t mailbox;
{
int mail_id = 0;
int attachment_no = 0;
- unsigned handle = 0;
+ int handle = 0;
int result_from_scanf = 0;
testapp_print("\n > Enter Mail Id: ");
testapp_print("email_get_thread_information returns = %d\n", error_code);
testapp_print("subject = %s\n", result_mail->subject);
testapp_print("mail_id = %d\n", result_mail->mail_id);
- testapp_print("from = %s\n", result_mail->from);
+ testapp_print("full_address_from = %s\n", result_mail->full_address_from);
testapp_print("thrad_id = %d\n", result_mail->thread_id);
testapp_print("count = %d\n", result_mail->thread_item_count);
}
int result_from_scanf = 0;
email_search_filter_type search_filter_type = 0;
email_search_filter_t search_filter;
- unsigned int handle = 0;
+ int handle = 0;
char search_key_value_string[MAX_EMAIL_ADDRESS_LENGTH];
testapp_print("input account id : ");
}
testapp_print("\n > Meeting Request? [0: no, 1: yes (request from server), 2: yes (response from local)]");
- result_from_scanf = scanf("%d", &(test_mail_data->meeting_request_status));
+ result_from_scanf = scanf("%d", (int*)&(test_mail_data->meeting_request_status));
if ( test_mail_data->meeting_request_status == 1
|| test_mail_data->meeting_request_status == 2 ) {
return FALSE;
}
-static gboolean testapp_test_email_load_eml_file()
+static gboolean testapp_test_email_parse_mime_file()
{
email_mail_data_t *mail_data = NULL;
email_attachment_data_t *mail_attachment_data = NULL;
testapp_print("Input eml file path : ");
result_from_scanf = scanf("%s", eml_file_path);
- if ((err = email_open_eml_file(eml_file_path, &mail_data, &mail_attachment_data, &attachment_count)) != EMAIL_ERROR_NONE)
+ if ((err = email_parse_mime_file(eml_file_path, &mail_data, &mail_attachment_data, &attachment_count)) != EMAIL_ERROR_NONE)
{
- testapp_print("email_open_eml_file failed : [%d]\n", err);
+ testapp_print("email_parse_mime_file failed : [%d]\n", err);
return false;
}
testapp_print("Success : Open eml file\n");
- if ((err = email_delete_eml_data(mail_data)) != EMAIL_ERROR_NONE) {
+ if ((err = email_delete_parsed_data(mail_data)) != EMAIL_ERROR_NONE) {
testapp_print("email_delete_eml_data failed : [%d]\n", err);
return false;
}
}
+static gboolean testapp_test_email_write_mime_file()
+{
+ int err = EMAIL_ERROR_NONE;
+ int mail_id = 0;
+ int ret_scanf = 0;
+ int is_file_path = 0;
+ int attachment_count = 0;
+ int account_id = 0;
+ char *file_path = NULL;
+ email_mail_data_t *mail_data = NULL;
+ email_attachment_data_t *mail_attachment_data = NULL;
+
+ testapp_print("Is file path (0 or 1): ");
+ ret_scanf = scanf("%d", &is_file_path);
+
+ if (is_file_path) {
+ file_path = malloc(512);
+ memset(file_path, 0x00, 512);
+
+ testapp_print("Input output file path : ");
+ ret_scanf = scanf("%s", file_path);
+ }
+ testapp_print("Input mail id : ");
+ ret_scanf = scanf("%d", &mail_id);
+
+
+ err = email_get_mail_data(mail_id, &mail_data);
+ if (err != EMAIL_ERROR_NONE) {
+ testapp_print("email_get_mail_data failed : [%d]\n", err);
+ return false;
+ }
+
+ err = email_get_attachment_data_list(mail_id, &mail_attachment_data, &attachment_count);
+ if (err != EMAIL_ERROR_NONE) {
+ testapp_print("email_get_attachment_data_list failed : [%d]\n", err);
+ return false;
+ }
+
+ testapp_print("Input Account id : ");
+ ret_scanf = scanf("%d", &account_id);
+
+ mail_data->account_id = account_id;
+
+ err = email_write_mime_file(mail_data, mail_attachment_data, attachment_count, &file_path);
+ if (err != EMAIL_ERROR_NONE) {
+ testapp_print("email_write_mime_file failed : [%d]\n", err);
+ return false;
+ }
+
+ testapp_print("file path : [%s]\n", file_path);
+
+ if (mail_data)
+ email_free_mail_data(&mail_data, 1);
+
+ if (mail_attachment_data)
+ email_free_attachment_data(&mail_attachment_data, attachment_count);
+
+ if (file_path)
+ free(file_path);
+
+ return true;
+}
+
+static gboolean testapp_test_smime_verify_signature()
+{
+ int mail_id = 0;
+ int ret_scanf = 0;
+ int verify = 0;
+ int err = EMAIL_ERROR_NONE;
+
+ testapp_print("input mail_id :");
+ ret_scanf = scanf("%d", &mail_id);
+
+ err = email_verify_signature(mail_id, &verify);
+ if (err != EMAIL_ERROR_NONE) {
+ testapp_print("Failed Verify\n");
+ return false;
+ }
+
+ testapp_print("verify value : [%d]\n", verify);
+ return true;
+}
+
/* internal functions */
static gboolean testapp_test_interpret_command (int menu_number)
{
testapp_test_mail_send(NULL);
break;
case 3:
- testapp_test_get_mail_list();
+ testapp_test_get_mail_list_ex();
break;
case 4:
testapp_test_add_attachment();
case 6:
testapp_test_expunge_mails_deleted_flagged();
break;
+ case 7:
+ testapp_test_send_read_receipt();
+ break;
+ case 8:
+ testapp_test_delete_attachment();
+ break;
case 9:
testapp_test_count();
break;
testapp_test_test_get_thread_information();
break;
case 51:
- testapp_test_get_mail_list_ex();
+ testapp_test_get_mail_list();
break;
case 52:
testapp_test_get_address_info_list();
testapp_test_add_mail_to_search_result_box();
break;
case 60:
- testapp_test_email_load_eml_file();
+ testapp_test_email_parse_mime_file();
+ break;
+ case 62:
+ testapp_test_smime_verify_signature();
+ break;
+ case 61:
+ testapp_test_email_write_mime_file();
break;
case 0:
go_to_loop = FALSE;
int local_yn = 0;
char arg[500];
int ret;
- unsigned handle;
+ int handle;
int result_from_scanf = 0;
memset(arg, 0x00, 500);
int mailbox_id = 0;
int on_server = 0;
int ret;
- unsigned handle;
+ int handle;
int result_from_scanf = 0;
testapp_print("\n> Enter mailbox id:");
char mailbox_alias[500] = { 0, };
int err;
int result_from_scanf = 0;
- unsigned handle = 0;
+ int handle = 0;
testapp_print("> Enter mailbox id: ");
result_from_scanf = scanf("%d", &mailbox_id);
static gboolean testapp_test_get_imap_mailbox_list()
{
int account_id = 0;
- unsigned handle = 0;
+ int handle = 0;
int result_from_scanf = 0;
testapp_print("> Enter account id: ");
}
+static gboolean testapp_test_set_local_mailbox()
+{
+ int mailbox_id = 0;
+ int is_local_mailbox = 0;
+ int result_from_scanf = 0;
+
+ testapp_print("> Enter mailbox id: ");
+ result_from_scanf = scanf("%d", &mailbox_id);
+
+ testapp_print("> Enter local: ");
+ result_from_scanf = scanf("%d", &is_local_mailbox);
+
+ if( email_set_local_mailbox(mailbox_id, is_local_mailbox) < 0)
+ testapp_print("email_set_local_mailbox failed");
+
+ return FALSE;
+}
+
static gboolean testapp_test_get_mailbox_by_type ()
{
{
int result_from_scanf = 0;
int account_id = 0;
- unsigned handle = 0;
+ int handle = 0;
int mailbox_id = 0;
testapp_print("\n > Enter Account id (0: for all account) : ");
case 4:
testapp_test_get_imap_mailbox_list();
- break;
+ break;
+
+ case 5:
+ testapp_test_set_local_mailbox();
+ break;
case 7:
testapp_test_get_mailbox_by_type();
#include "testapp-utility.h"
#include "testapp-others.h"
#include "email-ipc.h"
+#include "email-core-utils.h"
static gboolean testapp_test_get_network_status()
{
return TRUE;
}
+static gboolean testapp_test_get_preview_text_from_file()
+{
+ int result_from_scanf;
+ char *preview_buffer = NULL;
+ char html_file_path[1024] = { 0, };
+
+ testapp_print("\n > Enter file path : ");
+ result_from_scanf = scanf("%s", html_file_path);
+
+ emcore_get_preview_text_from_file(NULL, html_file_path, 1024, &preview_buffer);
+
+ testapp_print("\n result :\n %s ", preview_buffer);
+
+ return TRUE;
+}
+
static gboolean testapp_test_print_receving_queue_via_debug_msg()
{
int err;
case 6:
testapp_test_get_dnet_proper_profile_type();
break;
+ case 7:
+ testapp_test_get_preview_text_from_file();
+ break;
case 11:
testapp_test_print_receving_queue_via_debug_msg();
break;
testapp_print (" Email test application \n");
testapp_print ("==========================================\n");
testapp_print ("1. Account Test\n");
- testapp_print ("2. Message Test\n");
+ testapp_print ("2. Mail Test\n");
testapp_print ("3. Mailbox Test\n");
testapp_print ("5. Rule Test\n");
testapp_print ("6. Thread Test\n");
testapp_print (" MAIL MENU\n");
testapp_print ("==========================================\n");
testapp_print ("1. Get mails\n");
- testapp_print ("2. Send a mail \n");
- testapp_print ("3. Get mail list\n");
+ testapp_print ("2. Send a mail\n");
+ testapp_print ("3. Get mail list ex\n");
testapp_print ("4. Add Attachment\n");
testapp_print ("5. Set deleted flag\n");
testapp_print ("6. Expunge deleted flagged mails\n");
+ testapp_print ("7. Send read receipt\n");
+ testapp_print ("8. Delete attachment\n");
testapp_print ("9. Mail Count \n");
testapp_print ("14. Delete a mail \n");
testapp_print ("16. Download mail body\n");
testapp_print ("42. Storage test : (Input : to fields)\n");
testapp_print ("43. Send mail Cancel\n");
testapp_print ("44. Cancel Download Body\n");
+ testapp_print ("46. Get thread list\n");
testapp_print ("48. Get thread information\n");
- testapp_print ("51. Get mail list ex\n");
+ testapp_print ("51. Get mail list\n");
testapp_print ("52. Get address info list\n");
testapp_print ("55. Set a field of flags\n");
testapp_print ("56. Add mail\n");
testapp_print ("57. Update mail\n");
testapp_print ("58. Search on server\n");
testapp_print ("59. Add mail to search result table\n");
- testapp_print ("60. Open eml file\n");
+ testapp_print ("60. Parse mime file\n");
+ testapp_print ("61. Write mime file\n");
testapp_print ("0. Go to Main Menu\n");
testapp_print ("------------------------------------------\n");
break;
testapp_print (" 2. Delete mailbox\n");
testapp_print (" 3. Raname mailbox\n");
testapp_print (" 4. Get IMAP mailbox List\n");
+ testapp_print (" 5. Set local mailbox\n");
testapp_print (" 7. Get mailbox by mailbox type\n");
testapp_print (" 8. Set mailbox type\n");
testapp_print (" 9. Set mail slot size\n");
testapp_print ("3. Cancel Job\n");
testapp_print ("5. Set DNET Proper Profile Type\n");
testapp_print ("6. Get DNET Proper Profile Type\n");
- testapp_print ("7. Send mail cancel job\n");
+ testapp_print ("7. Get preview text\n");
testapp_print ("11. Print receiving event queue via debug msg\n");
testapp_print ("12. Create DB full\n");
testapp_print ("13. Encoding Test\n");