* @since_tizen 2.3 */
typedef enum
{
- EMAIL_EVENT_STATUS_UNUSED = 0, /**< Initial status of event */
+ EMAIL_EVENT_STATUS_UNUSED = 0, /**< Initial status of event : DB data(priority low) */
+ EMAIL_EVENT_STATUS_DIRECT, /**< Direct input status : event data(priority high) */
EMAIL_EVENT_STATUS_WAIT, /**< Waiting status */
EMAIL_EVENT_STATUS_STARTED, /**< Event handling is started */
EMAIL_EVENT_STATUS_CANCELED, /**< Event handling is canceled */
int vibrate_status; /**< The repetition type */
int display_content_status; /**< The display_content status. 1 = ON, 0 = OFF */
int default_ringtone_status; /**< The badge status. 1 = ON, 0 = OFF */
- char *alert_ringtone_path; /**< The ringtone path */
+ char *alert_ringtone_path; /**< The ringtone path */
} email_option_t;
/**
return err;
}
-static int emcore_add_alarm_data_to_alarm_data_list(char *multi_user_name, alarm_id_t input_alarm_id, email_alarm_class_t input_class_id, int input_reference_id, time_t input_trigger_at_time, int (*input_alarm_callback)(email_alarm_data_t*, void *), void *user_data)
+static int emcore_add_alarm_data_to_alarm_data_list(char *multi_user_name,
+ alarm_id_t input_alarm_id,
+ email_alarm_class_t input_class_id,
+ int input_reference_id,
+ time_t input_trigger_at_time,
+ int (*input_alarm_callback)(email_alarm_data_t*, void *),
+ void *user_data)
{
EM_DEBUG_FUNC_BEGIN("input_alarm_id [%d] input_class_id[%d] input_reference_id[%d] input_trigger_at_time[%d] input_alarm_callback [%p] user_data[%p]", input_alarm_id, input_class_id, input_reference_id, input_trigger_at_time, input_alarm_callback, user_data);
int err = EMAIL_ERROR_NONE;
return err;
}
-INTERNAL_FUNC int emcore_add_alarm(char *multi_user_name, time_t input_trigger_at_time, email_alarm_class_t input_class_id, int input_reference_id, int (*input_alarm_callback)(email_alarm_data_t*, void *), void *input_user_data)
+INTERNAL_FUNC int emcore_add_alarm(char *multi_user_name,
+ time_t input_trigger_at_time,
+ email_alarm_class_t input_class_id,
+ int input_reference_id,
+ int (*input_alarm_callback)(email_alarm_data_t*, void *),
+ void *input_user_data)
{
- EM_DEBUG_FUNC_BEGIN("input_trigger_at_time[%d] input_class_id[%d] input_reference_id[%d] input_alarm_callback[%p] input_user_data[%p]", input_trigger_at_time, input_class_id, input_reference_id, input_alarm_callback, input_user_data);
+ EM_DEBUG_FUNC_BEGIN("input_trigger_at_time[%d] input_class_id[%d] input_reference_id[%d] "
+ "input_alarm_callback[%p] input_user_data[%p]",
+ input_trigger_at_time, input_class_id, input_reference_id,
+ input_alarm_callback, input_user_data);
int err = EMAIL_ERROR_NONE;
int ret = 0;
EM_DEBUG_ALARM_LOG("alarm_interval [%d]", (int)alarm_interval);
- if ((ret = alarmmgr_add_alarm(ALARM_TYPE_VOLATILE, alarm_interval, ALARM_REPEAT_MODE_ONCE, EMAIL_ALARM_DESTINATION, &alarm_id)) != ALARMMGR_RESULT_SUCCESS) {
+ if ((ret = alarmmgr_add_alarm(ALARM_TYPE_VOLATILE,
+ alarm_interval,
+ ALARM_REPEAT_MODE_ONCE,
+ EMAIL_ALARM_DESTINATION,
+ &alarm_id)) != ALARMMGR_RESULT_SUCCESS) {
EM_DEBUG_EXCEPTION("alarmmgr_add_alarm failed [%d]",ret);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
- if ((err = emcore_add_alarm_data_to_alarm_data_list(multi_user_name, alarm_id, input_class_id, input_reference_id, input_trigger_at_time, input_alarm_callback, input_user_data)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_add_alarm_data_to_alarm_data_list(multi_user_name,
+ alarm_id,
+ input_class_id,
+ input_reference_id,
+ input_trigger_at_time,
+ input_alarm_callback,
+ input_user_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_alarm_data_to_alarm_data_list failed [%d]", err);
goto FINISH_OFF;
}
q_length = g_queue_get_length(g_auto_download_que);
EM_DEBUG_LOG("Q Length : [%d]", q_length);
+ EM_DEBUG_LOG("event_data->status : [%d]", event_data->status);
+
if (q_length > AUTO_DOWNLOAD_QUEUE_MAX) {
EM_DEBUG_EXCEPTION("auto download que is full...");
error = EMAIL_ERROR_EVENT_QUEUE_FULL;
ret = false;
+ } else if (event_data->status == EMAIL_EVENT_STATUS_DIRECT) {
+ event_data->status = EMAIL_EVENT_STATUS_WAIT;
+ g_queue_push_head(g_auto_download_que, event_data);
+ //WAKE_CONDITION_VARIABLE(_auto_downalod_available_signal);
+ ret = true;
} else {
event_data->status = EMAIL_EVENT_STATUS_WAIT;
g_queue_push_tail(g_auto_download_que, event_data);
if (attachment_list[i].attachment_save_status)
continue;
- EM_DEBUG_LOG("#####AUTO DOWNLOAD ATTACHMENT[%d]: ACCOUNT_ID[%d] MAILBOX_ID[%d] MAIL_ID[%d] UID[%d] ACTIVITY[%d]#####",
- j, event_data->account_id, event_data->mailbox_id,
- event_data->mail_id, event_data->server_mail_id, event_data->activity_id);
-
- if (!emcore_gmime_download_attachment(event_data->multi_user_name, event_data->mail_id, j, 0, -1, 1, &err))
+ EM_DEBUG_LOG("#####AUTO DOWNLOAD ATTACHMENT[%d]: ACCOUNT_ID[%d] "
+ "MAILBOX_ID[%d] MAIL_ID[%d] UID[%d] ACTIVITY[%d]#####",
+ j, event_data->account_id, event_data->mailbox_id,
+ event_data->mail_id, event_data->server_mail_id, event_data->activity_id);
+
+ if (!emcore_gmime_download_attachment(event_data->multi_user_name,
+ event_data->mail_id,
+ j,
+ 0,
+ -1,
+ 1,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_gmime_download_attachment failed [%d]", err);
+ EM_DEBUG_LOG("Retry again");
+ if (!emcore_gmime_download_attachment(event_data->multi_user_name,
+ event_data->mail_id,
+ j,
+ 0,
+ -1,
+ 1,
+ &err))
+ EM_DEBUG_EXCEPTION("emcore_gmime_download_attachment failed [%d]", err);
+ }
}
if (attachment_list)
}
DELETE_ACTIVITY:
- if (!emcore_delete_auto_download_activity(event_data->multi_user_name, event_data->account_id, event_data->mail_id, event_data->activity_id, &err)) {
+ if (!emcore_delete_auto_download_activity(event_data->multi_user_name,
+ event_data->account_id,
+ event_data->mail_id,
+ event_data->activity_id,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_auto_download_activity failed [%d]", err);
}
}
-INTERNAL_FUNC int emcore_insert_auto_download_job(char *multi_user_name, int account_id, int mailbox_id, int mail_id, int auto_download_on, char *uid, int *err_code)
+INTERNAL_FUNC int emcore_insert_auto_download_job(char *multi_user_name,
+ int account_id,
+ int mailbox_id,
+ int mail_id,
+ int auto_download_on,
+ char *uid,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], maibox_id[%d], mail_id[%d], uid[%p]", account_id, mailbox_id, mail_id, uid);
EM_DEBUG_LOG("Activity inserted only in DB .. Queue is Full");
}
else {
+ ad_event->status = EMAIL_EVENT_STATUS_DIRECT;
+
if (!emcore_insert_auto_download_event(ad_event, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_auto_download_event is failed [%d]", err);
goto FINISH_OFF;
goto FINISH_OFF;
}
- if (!emcore_connect_to_remote_mailbox(multi_user_name,
- account_id,
- mailbox_id,
+ if (!emcore_connect_to_remote_mailbox(multi_user_name,
+ account_id,
+ mailbox_id,
true,
- (void **)ret,
+ (void **)ret,
&err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
EM_SAFE_FREE(ret);
/* description
* get local mailbox list
*/
-INTERNAL_FUNC int emcore_get_mailbox_list(char *multi_user_name, int account_id, email_mailbox_t **mailbox_list,
+INTERNAL_FUNC int emcore_get_mailbox_list(char *multi_user_name, int account_id, email_mailbox_t **mailbox_list,
int *p_count, int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], p_count[%p], err_code[%p]",
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], p_count[%p], err_code[%p]",
account_id, mailbox_list, p_count, err_code);
if (account_id <= 0 || !mailbox_list || !p_count) {
- EM_DEBUG_EXCEPTION("PARAM Failed account_id[%d], mailbox_list[%p], p_count[%p]",
+ EM_DEBUG_EXCEPTION("PARAM Failed account_id[%d], mailbox_list[%p], p_count[%p]",
account_id, mailbox_list, p_count);
if (err_code != NULL)
*err_code = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_list(multi_user_name, ref_account->account_id,
- EMAIL_MAILBOX_ALL, EMAIL_MAILBOX_SORT_BY_NAME_ASC,
- &count, &local_mailbox_list, true, &error)) {
+ if (!emstorage_get_mailbox_list(multi_user_name, ref_account->account_id,
+ EMAIL_MAILBOX_ALL, EMAIL_MAILBOX_SORT_BY_NAME_ASC,
+ &count, &local_mailbox_list, true, &error)) {
EM_DEBUG_EXCEPTION(" emstorage_get_mailbox failed - %d", error);
goto FINISH_OFF;
}
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_list(multi_user_name, ref_account->account_id, 0,
- EMAIL_MAILBOX_SORT_BY_TYPE_ASC, &count,
- &mailbox_tbl_list, true, &error)) {
+ if (!emstorage_get_mailbox_list(multi_user_name, ref_account->account_id, 0,
+ EMAIL_MAILBOX_SORT_BY_TYPE_ASC, &count,
+ &mailbox_tbl_list, true, &error)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed - %d", error);
goto FINISH_OFF;
}
#ifdef __FEATURE_DELETE_MAILBOX_RECURSIVELY__
if(input_recursive) {
/* Getting children mailbox list */
- if(!emstorage_get_child_mailbox_list(multi_user_name,
- target_mailbox->account_id,
- target_mailbox->mailbox_name,
- &mailbox_count,
- &target_mailbox_array,
+ if(!emstorage_get_child_mailbox_list(multi_user_name,
+ target_mailbox->account_id,
+ target_mailbox->mailbox_name,
+ &mailbox_count,
+ &target_mailbox_array,
false,
&err)) {
EM_DEBUG_EXCEPTION("emstorage_get_child_mailbox_list failed. [%d]", err);
continue;
}
}
-
+
EM_DEBUG_LOG("Deleting mailbox_id [%d]", target_mailbox_array[i].mailbox_id);
if (input_on_server) {
EM_DEBUG_LOG("Delete the mailbox in Sever >>> ");
EM_DEBUG_LOG("Delete the mailbox in server : success");
}
- if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
- target_mailbox_array[i].account_id,
+ if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
+ target_mailbox_array[i].account_id,
target_mailbox_array[i].mailbox_id,
0,
- false,
+ false,
&err)) {
if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err);
}
FINISH_OFF:
-
+
EM_SAFE_FREE(old_mailbox_name);
if (target_mailbox)
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
-
- if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
- mailbox->account_id,
+
+ if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
+ mailbox->account_id,
mailbox->mailbox_id,
0,
- 0, /*NULL, */
+ 0, /*NULL, */
&err)) {
if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
EM_DEBUG_EXCEPTION(" emcore_delete_all_mails_of_mailbox failed - %d", err);
return ret;
}
-INTERNAL_FUNC int emcore_rename_mailbox(char *multi_user_name,
- int input_mailbox_id,
- char *input_new_mailbox_name,
- char *input_new_mailbox_alias,
- void *input_eas_data,
- int input_eas_data_length,
- int input_on_server,
- int input_recursive,
+INTERNAL_FUNC int emcore_rename_mailbox(char *multi_user_name,
+ int input_mailbox_id,
+ char *input_new_mailbox_name,
+ char *input_new_mailbox_alias,
+ void *input_eas_data,
+ int input_eas_data_length,
+ int input_on_server,
+ int input_recursive,
int handle_to_be_published)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d] input_new_mailbox_name[%p] input_new_mailbox_alias[%p] input_eas_data[%p] input_eas_data_length[%d] input_on_server[%d] input_recursive[%d] handle_to_be_published[%d]", input_mailbox_id, input_new_mailbox_name, input_new_mailbox_alias, input_eas_data, input_eas_data_length, input_on_server, input_recursive, handle_to_be_published);
if (input_on_server) {
EM_DEBUG_LOG("Rename the mailbox in Sever >>> ");
- if ((err = emcore_rename_mailbox_on_imap_server(multi_user_name,
- target_mailbox->account_id,
- target_mailbox->mailbox_id,
- target_mailbox->mailbox_name,
- new_mailbox_name,
+ if ((err = emcore_rename_mailbox_on_imap_server(multi_user_name,
+ target_mailbox->account_id,
+ target_mailbox->mailbox_id,
+ target_mailbox->mailbox_name,
+ new_mailbox_name,
handle_to_be_published)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_rename_mailbox_on_imap_server failed [%d]", err);
goto FINISH_OFF;
#ifdef __FEATURE_RENAME_MAILBOX_RECURSIVELY__
if(account_ref->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_recursive) {
/* Getting children mailbox list */
- if(!emstorage_get_child_mailbox_list(multi_user_name,
- target_mailbox->account_id,
- target_mailbox->mailbox_name,
- &mailbox_count,
- &target_mailbox_array,
+ if(!emstorage_get_child_mailbox_list(multi_user_name,
+ target_mailbox->account_id,
+ target_mailbox->mailbox_name,
+ &mailbox_count,
+ &target_mailbox_array,
false,
&err)) {
EM_DEBUG_EXCEPTION("emstorage_get_child_mailbox_list failed. [%d]", err);
/* Rename mailboxes */
for(i = 0; i < mailbox_count ; i++) {
- EM_DEBUG_LOG_SEC("Rename mailbox_id [%d], mailbox_name [%s], old_mailbox_name [%s]",
- target_mailbox_array[i].mailbox_id,
+ EM_DEBUG_LOG_SEC("Rename mailbox_id [%d], mailbox_name [%s], old_mailbox_name [%s]",
+ target_mailbox_array[i].mailbox_id,
target_mailbox_array[i].mailbox_name,
old_mailbox_name);
}
if (input_mailbox_id == target_mailbox_array[i].mailbox_id) {
- if ((err = emstorage_rename_mailbox(multi_user_name,
- target_mailbox_array[i].mailbox_id,
- new_mailbox_name,
- input_new_mailbox_alias,
- input_eas_data,
- input_eas_data_length,
+ if ((err = emstorage_rename_mailbox(multi_user_name,
+ target_mailbox_array[i].mailbox_id,
+ new_mailbox_name,
+ input_new_mailbox_alias,
+ input_eas_data,
+ input_eas_data_length,
true)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_rename_mailbox failed [%d]", err);
goto FINISH_OFF;
else {
EM_DEBUG_LOG_SEC("target_mailbox_array[i].mailbox_name[%s] "
"old_mailbox_name[%s] "
- "new_mailbox_name [%s]",
- target_mailbox_array[i].mailbox_name,
- old_mailbox_name,
+ "new_mailbox_name [%s]",
+ target_mailbox_array[i].mailbox_name,
+ old_mailbox_name,
new_mailbox_name);
- renamed_mailbox_name = em_replace_string(target_mailbox_array[i].mailbox_name,
- old_mailbox_name,
+ renamed_mailbox_name = em_replace_string(target_mailbox_array[i].mailbox_name,
+ old_mailbox_name,
new_mailbox_name);
EM_DEBUG_LOG_SEC("renamed_mailbox_name[%s]", renamed_mailbox_name);
- if ((err = emstorage_rename_mailbox(multi_user_name,
- target_mailbox_array[i].mailbox_id,
- renamed_mailbox_name,
- target_mailbox_array[i].alias,
- NULL,
- 0,
+ if ((err = emstorage_rename_mailbox(multi_user_name,
+ target_mailbox_array[i].mailbox_id,
+ renamed_mailbox_name,
+ target_mailbox_array[i].alias,
+ NULL,
+ 0,
true)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_rename_mailbox failed [%d]", err);
goto FINISH_OFF;
extern long smtp_send(SENDSTREAM *stream, char *command, char *args);
#endif /* __FEATURE_KEEP_CONNECTION__ */
-INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(char *multi_user_name,
- email_account_t *account,
- int input_mailbox_id,
+INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(char *multi_user_name,
+ email_account_t *account,
+ int input_mailbox_id,
int reusable,
- /*either MAILSTREAM or SENDSTREAM*/ void **result_stream,
+ /*either MAILSTREAM or SENDSTREAM*/ void **result_stream,
int *err_code)
{
EM_PROFILE_BEGIN(emCoreMailboxOpen);
/* set current network error as EMAIL_ERROR_NONE before network operation */
session->error = EMAIL_ERROR_NONE;
- emcore_set_network_error(EMAIL_ERROR_NONE);
-
+ emcore_set_network_error(EMAIL_ERROR_NONE);
+
if (input_mailbox_id == EMAIL_CONNECT_FOR_SENDING) {
mailbox_name = EM_SAFE_STRDUP(ENCODED_PATH_SMTP);
} else if (input_mailbox_id == 0) {
if (is_connection_for == _SERVICE_THREAD_TYPE_RECEIVING) {
/* open pop3/imap server */
- if (!emcore_get_long_encoded_path_with_account_info(multi_user_name,
- account,
- mailbox_name,
- '/',
- &mbox_path,
+ if (!emcore_get_long_encoded_path_with_account_info(multi_user_name,
+ account,
+ mailbox_name,
+ '/',
+ &mbox_path,
&error)) {
EM_DEBUG_EXCEPTION("emcore_get_long_encoded_path failed - %d", error);
session->error = error;
session->auth = 0; /* ref_account->receiving_auth ? 1 : 0 */
if (!(*result_stream = mail_open(*result_stream, mbox_path, IMAP_2004_LOG))) {
- EM_DEBUG_EXCEPTION("mail_open failed. session->error[%d], session->network[%d]",
+ EM_DEBUG_EXCEPTION("mail_open failed. session->error[%d], session->network[%d]",
session->error, session->network);
*result_stream = mail_close(*result_stream);
- if (account->account_id > 0 && (session->network == EMAIL_ERROR_XOAUTH_BAD_REQUEST ||
+ if (account->account_id > 0 && (session->network == EMAIL_ERROR_XOAUTH_BAD_REQUEST ||
session->network == EMAIL_ERROR_XOAUTH_INVALID_UNAUTHORIZED)) {
error = emcore_refresh_xoauth2_access_token (multi_user_name, account->account_id);
sleep(3); /* wait for updating access token */
if (!(*result_stream = mail_open(*result_stream, mbox_path, IMAP_2004_LOG))) {
- EM_DEBUG_LOG("mail_open failed. session->error[%d], session->network[%d]",
+ EM_DEBUG_LOG("mail_open failed. session->error[%d], session->network[%d]",
session->error, session->network);
}
connection_retry_count++;
EM_DEBUG_LOG ("connection_retry_count [%d]", connection_retry_count);
}
}
- } else if ((session->error == EMAIL_ERROR_TLS_SSL_FAILURE ||
+ } else if ((session->error == EMAIL_ERROR_TLS_SSL_FAILURE ||
session->error == EMAIL_ERROR_CANNOT_NEGOTIATE_TLS)) {
char *replaced_mbox_path = NULL;
replaced_mbox_path = em_replace_string(mbox_path, "}", "/force_tls_v1_0}");
- if (replaced_mbox_path != NULL &&
+ if (replaced_mbox_path != NULL &&
!(*result_stream = mail_open(*result_stream, replaced_mbox_path, IMAP_2004_LOG))) {
- EM_DEBUG_EXCEPTION("retry --> mail_open failed. session->error[%d], session->network[%d]",
+ EM_DEBUG_EXCEPTION("retry --> mail_open failed. session->error[%d], session->network[%d]",
session->error, session->network);
*result_stream = mail_close(*result_stream);
}
}
#endif
if (!*result_stream) {
- if (!emcore_get_long_encoded_path_with_account_info(multi_user_name,
- account,
- mailbox_name,
- 0,
- &mbox_path,
+ if (!emcore_get_long_encoded_path_with_account_info(multi_user_name,
+ account,
+ mailbox_name,
+ 0,
+ &mbox_path,
&error)) {
EM_DEBUG_EXCEPTION(" emcore_get_long_encoded_path failed - %d", error);
session->error = error;
if (!(*result_stream = smtp_open (host_list, 1))) {
EM_DEBUG_EXCEPTION_SEC("smtp_open error : outgoing_server_secure_connection[%d] "
"session->error[%d] session->network[%d]",
- account->outgoing_server_secure_connection,
+ account->outgoing_server_secure_connection,
session->error, session->network);
if (account->account_id > 0 && (session->network == EMAIL_ERROR_XOAUTH_BAD_REQUEST ||
mail_close is only used in emcore_connect_to_remote_mailbox and emcore_reset_streams as an exception to above rule*/
-INTERNAL_FUNC int emcore_connect_to_remote_mailbox(char *multi_user_name,
- int account_id,
- char *mailbox,
+INTERNAL_FUNC int emcore_connect_to_remote_mailbox(char *multi_user_name,
+ int account_id,
+ char *mailbox,
int reusable,
- void **mail_stream,
+ void **mail_stream,
int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox[%p], reusable[%d], mail_stream[%p], err_code[%p]",
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox[%p], reusable[%d], mail_stream[%p], err_code[%p]",
account_id, mailbox, reusable, mail_stream, err_code);
int ret = false;
error = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
-
- ret = emcore_connect_to_remote_mailbox_with_account_info(multi_user_name,
- ref_account,
- mailbox,
+
+ ret = emcore_connect_to_remote_mailbox_with_account_info(multi_user_name,
+ ref_account,
+ mailbox,
reusable,
- mail_stream,
+ mail_stream,
&error);
FINISH_OFF:
#else /* __FEATURE_KEEP_CONNECTION__ */
-INTERNAL_FUNC int emcore_connect_to_remote_mailbox(char *multi_user_name,
- int account_id,
- int input_mailbox_id,
+INTERNAL_FUNC int emcore_connect_to_remote_mailbox(char *multi_user_name,
+ int account_id,
+ int input_mailbox_id,
int reusable,
- void **mail_stream,
+ void **mail_stream,
int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], reusable[%d], mail_stream[%p], err_code[%p]",
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], reusable[%d], mail_stream[%p], err_code[%p]",
account_id, input_mailbox_id, reusable, mail_stream, err_code);
int ret = false;
goto FINISH_OFF; */
}
- ret = emcore_connect_to_remote_mailbox_with_account_info(multi_user_name,
- ref_account,
- input_mailbox_id,
+ ret = emcore_connect_to_remote_mailbox_with_account_info(multi_user_name,
+ ref_account,
+ input_mailbox_id,
reusable,
- mail_stream,
+ mail_stream,
&error);
- EM_DEBUG_LOG("ret[%d] incoming_server_type[%d] input_mailbox_id[%d]",
+ EM_DEBUG_LOG("ret[%d] incoming_server_type[%d] input_mailbox_id[%d]",
ret, ref_account->incoming_server_type, input_mailbox_id);
if (ret == EMAIL_ERROR_NONE && input_mailbox_id == EMAIL_CONNECT_FOR_SENDING) {
if (activity_count > 0) {
event_data = em_malloc(sizeof(email_event_t));
+ if (!event_data) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_LOCAL_ACTIVITY;
event_data->account_id = account_id;
if (!emcore_insert_event_for_sending_mails(event_data, &handle, &err)) {
#include "email-internal-types.h"
#include "c-client.h"
+#include "email-daemon.h"
#include "email-core-global.h"
#include "email-core-utils.h"
#include "email-storage.h"
{
EM_DEBUG_FUNC_BEGIN("alarm_data [%p] user_parameter [%p]", alarm_data, user_parameter);
int err = EMAIL_ERROR_NONE;
- int ret = 0;
- char *multi_user_name = (char *)user_parameter;
if (alarm_data == NULL) {
EM_DEBUG_EXCEPTION("Invalid parameter");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ if (alarm_data->reference_id <= 0) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ /* Insert the sending mail event */
+ int account_id = 0;
+ int input_mail_id = alarm_data->reference_id;
+ int dst_mailbox_id = 0;
+ int result_handle = 0;
+ char *multi_user_name = alarm_data->multi_user_name;
+
+ email_event_t *event_data = NULL;
+ emstorage_mail_tbl_t *mail_data = NULL;
+ emstorage_mailbox_tbl_t *outbox_tbl = NULL;
+
+ if (!emstorage_get_mail_by_id(multi_user_name, input_mail_id, &mail_data, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ account_id = mail_data->account_id;
+
+ if (!emnetwork_check_network_status(&err)) {
+ EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed : [%d]", err);
goto FINISH_OFF;
}
- /* send mail here */
- if(!emcore_send_mail(multi_user_name, alarm_data->reference_id, &err)) {
- EM_DEBUG_EXCEPTION("emcore_send_mail failed [%d]", ret);
+#ifdef __FEATURE_MOVE_TO_OUTBOX_FIRST__
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name,
+ account_id,
+ EMAIL_MAILBOX_TYPE_OUTBOX,
+ &outbox_tbl,
+ false,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ dst_mailbox_id = outbox_tbl->mailbox_id;
+ emstorage_free_mailbox(&outbox_tbl, 1, NULL);
+ outbox_tbl = NULL;
+
+ if (mail_data->mailbox_id != dst_mailbox_id) {
+ if (!emcore_move_mail(multi_user_name,
+ &input_mail_id,
+ 1,
+ dst_mailbox_id,
+ EMAIL_MOVED_AFTER_SENDING,
+ 0,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emcore_move_mail failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ }
+#endif /* __FEATURE_MOVE_TO_OUTBOX_FIRST__ */
+
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name,
+ account_id,
+ &input_mail_id,
+ 1,
+ "save_status",
+ EMAIL_MAIL_STATUS_SEND_WAIT,
+ true,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ event_data->type = EMAIL_EVENT_SEND_MAIL;
+ event_data->account_id = account_id;
+ event_data->event_param_data_4 = input_mail_id;
+ event_data->event_param_data_5 = mail_data->mailbox_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+
+ if (!emcore_insert_event_for_sending_mails(event_data, &result_handle, &err)) {
+ EM_DEBUG_EXCEPTION(" emcore_insert_event failed [%d]", err);
goto FINISH_OFF;
}
FINISH_OFF:
+ emcore_add_transaction_info(input_mail_id, result_handle, NULL);
+
+ if (err != EMAIL_ERROR_NONE) {
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name,
+ account_id,
+ &input_mail_id,
+ 1,
+ "save_status",
+ EMAIL_MAIL_STATUS_SAVED,
+ true,
+ &err))
+ EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed : [%d]", err);
+
+ if (event_data) {
+ emcore_free_event(event_data);
+ EM_SAFE_FREE(event_data);
+ }
+ }
+
+ if (mail_data)
+ emstorage_free_mail(&mail_data, 1, NULL);
+
+ if (outbox_tbl)
+ emstorage_free_mailbox(&outbox_tbl, 1, NULL);
+
+
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
goto FINISH_OFF;
}
- /*
- if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, mail_data->account_id, &(mail_data->mail_id), 1, "save_status", EMAIL_MAIL_STATUS_SEND_SCHEDULED, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
- goto FINISH_OFF;
- }
- */
-
- if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, mail_data->account_id, &(mail_data->mail_id), 1, "scheduled_sending_time", input_time_to_send, true, &err)) {
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name,
+ mail_data->account_id,
+ &(mail_data->mail_id),
+ 1,
+ "scheduled_sending_time",
+ input_time_to_send,
+ true,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
goto FINISH_OFF;
}
/* add alarm */
- if ((err = emcore_add_alarm(multi_user_name, input_time_to_send, EMAIL_ALARM_CLASS_SCHEDULED_SENDING, input_mail_id, emcore_sending_alarm_cb, NULL)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_add_alarm(multi_user_name,
+ input_time_to_send,
+ EMAIL_ALARM_CLASS_SCHEDULED_SENDING,
+ input_mail_id,
+ emcore_sending_alarm_cb,
+ NULL)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]", err);
goto FINISH_OFF;
}
#define EMAIL_ALARM_DESTINATION "email-service-0"\r
\r
typedef struct _email_alarm_data_t {\r
- alarm_id_t alarm_id;\r
- email_alarm_class_t class_id;\r
- int reference_id;\r
- time_t trigger_at_time;\r
- int (*alarm_callback)(struct _email_alarm_data_t*, void *);\r
- char *multi_user_name;\r
- void *user_data;\r
+ alarm_id_t alarm_id;\r
+ email_alarm_class_t class_id;\r
+ int reference_id;\r
+ time_t trigger_at_time;\r
+ int (*alarm_callback)(struct _email_alarm_data_t*, void *);\r
+ char *multi_user_name;\r
+ void *user_data;\r
} email_alarm_data_t;\r
\r
\r
}
event_data = em_malloc(sizeof(email_event_t));
+ if (!event_data) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_VALIDATE_ACCOUNT;
event_data->event_param_data_1 = NULL;
event_data->event_param_data_3 = NULL;
email_event_t *event_data = NULL;
event_data = em_malloc(sizeof(email_event_t));
-
- if(!event_data) { /*prevent 53095*/
+ if (!event_data) { /*prevent 53095*/
EM_DEBUG_EXCEPTION("em_malloc failed");
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
email_event_t *event_data = NULL;
event_data = em_malloc(sizeof(email_event_t));
-
if(!event_data) { /*prevent 53093*/
EM_DEBUG_EXCEPTION("em_malloc failed");
err = EMAIL_ERROR_OUT_OF_MEMORY;
FINISH_OFF:
if (alarm_data) {
+ EM_SAFE_FREE(alarm_data->multi_user_name);
EM_SAFE_FREE(alarm_data->user_data);
EM_SAFE_FREE(alarm_data);
}
}
#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
- if ( input_from_eas == 0 && ref_account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
+ if (input_from_eas == 0 && ref_account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
event_data = em_malloc(sizeof(email_event_t));
if (event_data == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
}
if (from_server == EMAIL_DELETE_LOCAL_AND_SERVER || from_server == EMAIL_DELETE_FROM_SERVER) {
- if ((p = em_malloc(sizeof(int) * mail_ids_count)) == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc for p failed...");
+ if ((event_data = em_malloc(sizeof(email_event_t)) ) == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc for event_data failed...");
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
- memcpy(p, mail_ids, sizeof(int) * mail_ids_count);
-
- if ((event_data = em_malloc(sizeof(email_event_t)) ) == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc for event_data failed...");
+ if ((p = em_malloc(sizeof(int) * mail_ids_count)) == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc for p failed...");
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
+ memcpy(p, mail_ids, sizeof(int) * mail_ids_count);
+
event_data->type = EMAIL_EVENT_DELETE_MAIL;
event_data->account_id = account_id;
event_data->event_param_data_3 = (char*)p;
emcore_free_event(event_data);
EM_SAFE_FREE(event_data);
}
- EM_SAFE_FREE(p);
goto FINISH_OFF2;
}
}
emcore_free_event(thread_func_event_data);
EM_SAFE_FREE(thread_func_event_data);
}
- EM_SAFE_FREE(p2);
}
if (ref_account) {
new_activity.dest_mbox = NULL;
new_activity.account_id = mailbox->account_id;
- if (! emcore_add_activity(&new_activity, &err))
+ if (!emcore_add_activity(&new_activity, &err))
EM_DEBUG_EXCEPTION(" emcore_add_activity Failed - %d ", err);
}
emcore_free_event(event_data);
EM_SAFE_FREE(event_data);
}
- EM_SAFE_FREE(p);
goto FINISH_OFF2;
}
emcore_free_event(thread_func_event_data);
EM_SAFE_FREE(thread_func_event_data);
}
- EM_SAFE_FREE(p2);
}
#ifdef __FEATURE_LOCAL_ACTIVITY__
emcore_free_event(event_data);
EM_SAFE_FREE(event_data);
}
- EM_SAFE_FREE(p);
goto FINISH_OFF2;
}
emcore_free_event(thread_func_event_data);
EM_SAFE_FREE(thread_func_event_data);
}
- EM_SAFE_FREE(p2);
}
#ifdef __FEATURE_LOCAL_ACTIVITY__
}
if (onserver && account_tbl->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
+ event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
mail_id_array = em_malloc(sizeof(int) * num);
if (mail_id_array == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed...");
memcpy(mail_id_array, mail_ids, sizeof(int) * num);
- event_data = em_malloc(sizeof(email_event_t));
- if (event_data == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
event_data->type = EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER;
event_data->account_id = account_id;
event_data->event_param_data_1 = NULL;
FINISH_OFF:
if (event_insert == false && event_data) {
- EM_SAFE_FREE(event_data->multi_user_name);
emcore_free_event(event_data);
EM_SAFE_FREE(event_data);
}
extern int g_local_activity_run;
#endif
-INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(char *multi_user_name,
- int account_id,
- char* mailbox,
- int *handle,
+INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(char *multi_user_name,
+ int account_id,
+ char* mailbox,
+ int *handle,
int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d] mailbox[%p] err_code[%p]", account_id, mailbox, err_code);
if ( ref_account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC )
on_server = 0;
- if ( on_server ) { /* async */
+ if (on_server) { /* async */
+ event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
mailbox = em_malloc(sizeof(email_mailbox_t));
-
- if(mailbox == NULL) {
+ if (mailbox == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
memcpy(mailbox->eas_data, new_mailbox->eas_data, new_mailbox->eas_data_length);
}
- event_data = em_malloc(sizeof(email_event_t));
- if (event_data == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
event_data->type = EMAIL_EVENT_CREATE_MAILBOX;
event_data->account_id = new_mailbox->account_id;
event_data->event_param_data_1 = (char*)mailbox;
event_data->event_param_data_4 = on_server;
- event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if(!emcore_insert_event(event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
FINISH_OFF:
if (ret == false) {
- if(event_data) {
+ if (event_data) {
emcore_free_event(event_data);
EM_SAFE_FREE(event_data);
}
- if(mailbox) {
- emcore_free_mailbox(mailbox);
- EM_SAFE_FREE(mailbox);
- }
}
if (ref_account) {
event_data->type = EMAIL_EVENT_SYNC_HEADER;
event_data->account_id = input_account_id;
event_data->event_param_data_5 = input_mailbox_id;
- event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
/* In case of Mailbox NULL, we need to set arg as EMAIL_SYNC_ALL_MAILBOX */
if (input_mailbox_id == 0)
event_data->type = EMAIL_EVENT_SYNC_HEADER;
event_data->account_id = input_account_id;
event_data->event_param_data_5 = input_mailbox_id;
- event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
/* In case of Mailbox NULL, we need to set arg as EMAIL_SYNC_ALL_MAILBOX */
if (input_mailbox_id == 0)