extern void imap_parse_body_structure (MAILSTREAM *stream, BODY *body, unsigned char **txtptr, IMAPPARSEDREPLY *reply);
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
-static emf_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply);
-static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, char *uid, char *mailbox, int *err_code);
+static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply, int input_download_size);
+static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, char *uid, int mailbox_id, int *err_code);
#endif
#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
EM_DEBUG_FUNC_BEGIN();
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
POP3LOCAL *pop3local = NULL;
char command[16];
if (!stream || !size) {
EM_DEBUG_EXCEPTION(" stream[%p], msgno[%d], size[%p]\n", stream, msgno, size);
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
if (!(pop3local = stream->local) || !pop3local->netstream) {
- err = EMF_ERROR_INVALID_STREAM;
+ err = EMAIL_ERROR_INVALID_STREAM;
goto FINISH_OFF;
}
if (!net_sout(pop3local->netstream, command, (int)strlen(command))) {
EM_DEBUG_EXCEPTION(" net_sout failed...");
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
/* receive response */
if (!(response = net_getline(pop3local->netstream))) {
- err = EMF_ERROR_CONNECTION_BROKEN; /* EMF_ERROR_UNKNOWN; */
+ err = EMAIL_ERROR_CONNECTION_BROKEN; /* EMAIL_ERROR_UNKNOWN; */
goto FINISH_OFF;
}
char *p = NULL;
if (!(p = strchr(response + strlen("+OK "), ' '))) {
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
*size = atoi(p + 1);
}
else if (*response == '-') { /* "- ERR" */
- err = EMF_ERROR_POP3_LIST_FAILURE;
+ err = EMAIL_ERROR_POP3_LIST_FAILURE;
goto FINISH_OFF;
}
else {
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
EM_DEBUG_FUNC_BEGIN();
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
IMAPLOCAL *imaplocal = NULL;
char tag[32], command[128];
if (!stream || !size) {
EM_DEBUG_EXCEPTION("stream[%p], msgno[%d], size[%p]", stream, msgno, size);
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
if (!(imaplocal = stream->local) || !imaplocal->netstream) {
- err = EMF_ERROR_INVALID_STREAM;
+ err = EMAIL_ERROR_INVALID_STREAM;
goto FINISH_OFF;
}
if (!net_sout(imaplocal->netstream, command, (int)strlen(command))) {
EM_DEBUG_EXCEPTION(" net_sout failed...");
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
break;
}
else { /* 'NO' or 'BAD' */
- err = EMF_ERROR_IMAP4_FETCH_SIZE_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */
+ err = EMAIL_ERROR_IMAP4_FETCH_SIZE_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */
goto FINISH_OFF;
}
}
s = t + strlen("FETCH (RFC822.SIZE ");
if (!(t = strchr(s, ' '))) {
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
EM_DEBUG_FUNC_BEGIN("stream[%p], uid_list[%p], err_code[%p]", stream, uid_list, err_code);
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
POP3LOCAL *pop3local = NULL;
char command[64];
if (!stream || !uid_list) {
EM_DEBUG_EXCEPTION("stream[%p], uid_list[%p]n", stream, uid_list);
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
if (!(pop3local = stream->local) || !pop3local->netstream) {
EM_DEBUG_EXCEPTION("invalid POP3 stream detected...");
- err = EMF_ERROR_INVALID_STREAM;
+ err = EMAIL_ERROR_INVALID_STREAM;
goto FINISH_OFF;
}
/* send command : get msgno/uid for all message */
if (!net_sout(pop3local->netstream, command, (int)strlen(command))) {
EM_DEBUG_EXCEPTION("net_sout failed...");
- err = EMF_ERROR_CONNECTION_BROKEN; /* EMF_ERROR_UNKNOWN; */
+ err = EMAIL_ERROR_CONNECTION_BROKEN; /* EMAIL_ERROR_UNKNOWN; */
goto FINISH_OFF;
}
/* receive response */
if (!(response = net_getline(pop3local->netstream))) {
EM_DEBUG_EXCEPTION("net_getline failed...");
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
#endif
if (*response == '-') { /* "-ERR" */
- err = EMF_ERROR_POP3_UIDL_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */
+ err = EMAIL_ERROR_POP3_UIDL_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */
goto FINISH_OFF;
}
if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) {
EM_DEBUG_EXCEPTION("malloc failed...");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
*uid_list = uid_elem;
}
else {
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
EM_DEBUG_FUNC_BEGIN("stream[%p], uid_list[%p], err_code[%p]", stream, uid_list, err_code);
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
IMAPLOCAL *imaplocal = NULL;
char tag[16], command[64];
if (!stream || !uid_list) {
EM_DEBUG_EXCEPTION("stream[%p], uid_list[%p]", stream, uid_list);
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
if (!(imaplocal = stream->local) || !imaplocal->netstream) {
EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected...");
- err = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN */
+ err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN */
goto FINISH_OFF;
}
if (stream->nmsgs == 0){
- err = EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER;
+ err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER;
goto FINISH_OFF;
}
memset(tag, 0x00, sizeof(tag));
/* send command : get msgno/uid for all message */
if (!net_sout(imaplocal->netstream, command, (int)strlen(command))) {
EM_DEBUG_EXCEPTION(" net_sout failed...\n");
- err = EMF_ERROR_CONNECTION_BROKEN;
+ err = EMAIL_ERROR_CONNECTION_BROKEN;
goto FINISH_OFF;
}
/* receive response */
if (!(response = net_getline(imaplocal->netstream))) {
EM_DEBUG_EXCEPTION("net_getline failed...");
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
break;
}
else { /* 'NO' or 'BAD' */
- err = EMF_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */
+ err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */
goto FINISH_OFF;
}
}
if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) {
EM_DEBUG_EXCEPTION("em_malloc failed...");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
*uid_list = uid_elem;
}
else {
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
}
}
else {
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
EM_DEBUG_FUNC_BEGIN("stream[%p], uid_list[%p], err_code[%p]", stream, uid_list, err_code);
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
IMAPLOCAL *imaplocal = NULL;
char tag[16], command[64];
if (!stream || !uid_list) {
EM_DEBUG_EXCEPTION(" stream[%p], uid_list[%p]", stream, uid_list);
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
if (!(imaplocal = stream->local) || !imaplocal->netstream) {
EM_DEBUG_EXCEPTION(" invalid IMAP4 stream detected...");
- err = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN */
+ err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN */
goto FINISH_OFF;
}
/* send command : get msgno/uid for all message */
if (!net_sout(imaplocal->netstream, command, (int)strlen(command))) {
EM_DEBUG_EXCEPTION(" net_sout failed...");
- err = EMF_ERROR_CONNECTION_BROKEN; /* EMF_ERROR_UNKNOWN */
+ err = EMAIL_ERROR_CONNECTION_BROKEN; /* EMAIL_ERROR_UNKNOWN */
goto FINISH_OFF;
}
/* receive response */
if (!(response = net_getline(imaplocal->netstream))) {
EM_DEBUG_EXCEPTION(" net_getline failed...");
- err = EMF_ERROR_INVALID_RESPONSE; /* EMF_ERROR_UNKNOWN; */
+ err = EMAIL_ERROR_INVALID_RESPONSE; /* EMAIL_ERROR_UNKNOWN; */
goto FINISH_OFF;
}
#ifdef FEATURE_CORE_DEBUG
break;
}
else { /* 'NO' or 'BAD' */
- err = EMF_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMF_ERROR_INVALID_RESPONSE; */
+ err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */
goto FINISH_OFF;
}
}
if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) {
EM_DEBUG_EXCEPTION(" malloc failed...");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
return 1;
}
else {
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
return false;
if (err_code)
- *err_code = EMF_ERROR_NONE;
+ *err_code = EMAIL_ERROR_NONE;
EM_PROFILE_BEGIN(emCoreMailboxParseHeader);
EM_PROFILE_END(emCoreMailboxParseHeader);
if (err_code)
- *err_code = EMF_ERROR_NONE;
+ *err_code = EMAIL_ERROR_NONE;
return true;
}
EM_DEBUG_FUNC_BEGIN("stream[%p], msgno[%d], req_read_receipt[%p], priority[%p], err_code[%p]", stream, msgno, req_read_receipt, priority, err_code);
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
char *rfc822_header = NULL;
unsigned long len = 0;
if (!rfc822_header || !*rfc822_header) {
EM_DEBUG_EXCEPTION("mail_fetch_header failed...");
- err = EMF_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMF_ERROR_UNKNOWN; */
+ err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMAIL_ERROR_UNKNOWN; */
goto FINISH_OFF;
}
return ret;
}
-static int emcore_get_uids_to_download(MAILSTREAM *stream, emf_account_t *account, emstorage_mailbox_tbl_t *input_mailbox_tbl, int limit_count, emcore_uid_list** uid_list, int *uids, int retrieve_mode , int *err_code)
+static int emcore_get_uids_to_download(MAILSTREAM *stream, email_account_t *account, emstorage_mailbox_tbl_t *input_mailbox_tbl, int limit_count, emcore_uid_list** uid_list, int *uids, int retrieve_mode , int *err_code)
{
EM_PROFILE_BEGIN(emCoreGetUidsDownload);
EM_DEBUG_FUNC_BEGIN("account[%p], input_mailbox_tbl[%p], limit_count[%d], uid_list[%p], err_code[%p]", account, input_mailbox_tbl, limit_count, uid_list, err_code);
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
emstorage_read_mail_uid_tbl_t *downloaded_uids = NULL;
int i = 0, j = 0, uid_count = 0, uid_to_be_downloaded_count = 0;
if (!account || !input_mailbox_tbl || !uid_list) {
EM_DEBUG_EXCEPTION("account[%p], input_mailbox_tbl[%p], uid_list[%p]", account, input_mailbox_tbl, uid_list);
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
*uid_list = NULL;
- if (account->receiving_server_type == EMF_SERVER_TYPE_POP3) {
+ if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) {
if (!pop3_mailbox_get_uids(stream, uid_list, &err)) {
EM_DEBUG_EXCEPTION("pop3_mailbox_get_uids failed - %d", err);
goto FINISH_OFF;
}
}
- else { /* EMF_SERVER_TYPE_IMAP4 */
+ else { /* EMAIL_SERVER_TYPE_IMAP4 */
/* sowmya.kr commented , since imap4_mailbox_get_uids_by_timestamp will fetch mails since last week and not all mails */
EM_DEBUG_LOG("calling imap4_mailbox_get_uids");
if (!imap4_mailbox_get_uids(stream, uid_list, &err)) {
EM_DEBUG_EXCEPTION("imap4_mailbox_get_uids failed [%d]", err);
- if (err != EMF_ERROR_MAIL_NOT_FOUND_ON_SERVER)
+ if (err != EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER)
goto FINISH_OFF;
}
}
- if (!emstorage_get_downloaded_list(input_mailbox_tbl->account_id, input_mailbox_tbl->mailbox_name, &downloaded_uids, &j, true, &err)) {
+ if (!emstorage_get_downloaded_list(input_mailbox_tbl->account_id,
+ (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) ? 0 : input_mailbox_tbl->mailbox_id,
+ &downloaded_uids, &j, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_downloaded_list failed [%d]", err);
goto FINISH_OFF;
while (uid_elem) {
next_uid_elem = uid_elem->next;
- if ((account->retrieval_mode == EMF_IMAP4_RETRIEVAL_MODE_NEW) && (uid_elem->flag.seen != 0)){ /* already seen */
+ if ((account->retrieval_mode == EMAIL_IMAP4_RETRIEVAL_MODE_NEW) && (uid_elem->flag.seen != 0)){ /* already seen */
if (uid_elem->uid)
free(uid_elem->uid);
/* EM_DEBUG_LOG("Is uid[%s] going to be downloded ? [%d]", uid_elem->uid, to_be_downloaded); */
if (to_be_downloaded) {
- if (retrieve_mode == EMF_SYNC_OLDEST_MAILS_FIRST){
+ if (retrieve_mode == EMAIL_SYNC_OLDEST_MAILS_FIRST){
uid_elem->next = head_uid_elem;
head_uid_elem = uid_elem;
}
- else{ /* if retrieve_mode is EMF_SYNC_LATEST_MAILS_FIRST, add uid elem to end so that latest mails are in front of list */
+ else{ /* if retrieve_mode is EMAIL_SYNC_LATEST_MAILS_FIRST, add uid elem to end so that latest mails are in front of list */
if (head_uid_elem == NULL){
uid_elem->next = head_uid_elem;
head_uid_elem = uid_elem;
if (downloaded_uids[i].reserved == 0) { /* deleted on server */
if (!emstorage_get_maildata_by_servermailid(input_mailbox_tbl->account_id, downloaded_uids[i].s_uid, &mail, true, &err)){
EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid for uid[%s] Failed [%d] \n ", downloaded_uids[i].s_uid, err);
- if (err == EMF_ERROR_MAIL_NOT_FOUND){
+ if (err == EMAIL_ERROR_MAIL_NOT_FOUND){
continue;
}
}
- if (account->receiving_server_type == EMF_SERVER_TYPE_IMAP4) {
- if (!emcore_delete_mail_from_local_storage(input_mailbox_tbl->account_id, &(mail->mail_id), 1, EMF_DELETED_FROM_SERVER, false, &err)) {
- EM_DEBUG_EXCEPTION("emcore_delete_mail_from_local_storage falied - %d", err);
+ if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
+ if (!emcore_delete_mails_from_local_storage(input_mailbox_tbl->account_id, &(mail->mail_id), 1, EMAIL_DELETED_FROM_SERVER, false, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_delete_mails_from_local_storage falied - %d", err);
goto FINISH_OFF;
}
/* emcore_delete_notification_for_read_mail(mail->mail_id); */
}
}
- else if (account->receiving_server_type == EMF_SERVER_TYPE_IMAP4 && downloaded_uids[i].reserved == 1) {
+ else if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && downloaded_uids[i].reserved == 1) {
/* unseen on server */
if (!emstorage_get_mail_by_id(downloaded_uids[i].local_uid, &mail, true, &err)){
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed for [%d] - [%d]", downloaded_uids[i].local_uid, err);
/* insert received mail UID to read mail uid table */
static int emcore_add_read_mail_uid(emstorage_mailbox_tbl_t *input_maibox_data, char *server_mailbox_name, int mail_id, char *uid, int rfc822_size, int rule_id, int *err_code)
{
- EM_PROFILE_BEGIN(emCoreMailboxAddReadMailUid);
EM_DEBUG_FUNC_BEGIN("input_maibox_data[%p], server_mailbox_name[%s], uid[%s], rfc822_size[%d], rule_id[%d], err_code[%p]", input_maibox_data, server_mailbox_name, uid, rfc822_size, rule_id, err_code);
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
- emstorage_read_mail_uid_tbl_t read_mail_uid = { 0 };
- char *mailbox_name = NULL;
+ emstorage_read_mail_uid_tbl_t read_mail_uid = { 0 };
+ emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
if (!input_maibox_data || !uid) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
- err = EMF_ERROR_INVALID_PARAM;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
read_mail_uid.account_id = input_maibox_data->account_id;
if (!(input_maibox_data->mailbox_name) || !(server_mailbox_name)){
- if (!emstorage_get_mailboxname_by_mailbox_type(input_maibox_data->account_id, EMF_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailboxname_by_mailbox_type failed [%d]", err);
-
+ if (!emstorage_get_mailbox_by_mailbox_type(input_maibox_data->account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
}
- if (input_maibox_data->mailbox_name)
- read_mail_uid.local_mbox = input_maibox_data->mailbox_name;
+ if (input_maibox_data->mailbox_id)
+ read_mail_uid.mailbox_id = input_maibox_data->mailbox_id;
else
- read_mail_uid.local_mbox = mailbox_name;
+ read_mail_uid.mailbox_id = mailbox_tbl->mailbox_id;
read_mail_uid.local_uid = mail_id;
EM_DEBUG_LOG("MAIL ID [%d] LOCAL_UID [%d]", mail_id, read_mail_uid.local_uid);
if (server_mailbox_name)
read_mail_uid.mailbox_name = server_mailbox_name;
else
- read_mail_uid.mailbox_name = mailbox_name;
+ read_mail_uid.mailbox_name = mailbox_tbl->mailbox_name;
read_mail_uid.s_uid = uid;
read_mail_uid.data1 = rfc822_size;
ret = true;
FINISH_OFF:
- EM_SAFE_FREE(mailbox_name);
+ if (mailbox_tbl)
+ emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
if (err_code)
*err_code = err;
- EM_PROFILE_END(emCoreMailboxAddReadMailUid);
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
}
-static int emcore_add_mail_to_mailbox(emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, int *output_mail_id, int *output_thread_id)
+int emcore_add_mail_to_mailbox(emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, int *output_mail_id, int *output_thread_id)
{
EM_DEBUG_FUNC_BEGIN("input_maibox_data[%p], input_new_mail_tbl_data[%p], uid_elem[%p], output_mail_id[%p], output_thread_id[%p]", mail_stream, input_maibox_data, input_new_mail_tbl_data, output_mail_id, output_thread_id);
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
int thread_id = -1;
int thread_item_count = 0;
int latest_mail_id_in_thread = -1;
if (!input_maibox_data || !input_new_mail_tbl_data) {
EM_DEBUG_EXCEPTION("Invalid Parameter");
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
goto FINISH_OFF;
}
- if (emstorage_get_thread_id_of_thread_mails(input_new_mail_tbl_data, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMF_ERROR_NONE)
+ if (emstorage_get_thread_id_of_thread_mails(input_new_mail_tbl_data, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed.");
if (thread_id == -1){
{
EM_DEBUG_FUNC_BEGIN("input_full_address_from [%p], input_subject [%p], rule [%p], rule_len [%d], matched [%p], err_code [%p]", input_full_address_from, input_subject, rule, rule_len, matched, err_code);
- int ret = false, err = EMF_ERROR_NONE, i;
+ int ret = false, err = EMAIL_ERROR_NONE, i;
size_t len = 0;
char *src = NULL; /* string which will be compared with rules */
char *from_address = NULL;
ADDRESS *addr = NULL;
if (!matched || !input_full_address_from || !input_subject) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
- err = EMF_ERROR_INVALID_PARAM;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
if (!(from_address = em_malloc(len))) {
EM_DEBUG_EXCEPTION("em_malloc failed...");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
}
else {
EM_DEBUG_EXCEPTION("rfc822_parse_adrlist failed.");
- err = EMF_ERROR_INVALID_ADDRESS;
+ err = EMAIL_ERROR_INVALID_ADDRESS;
goto FINISH_OFF;
}
for (i = 0; i < rule_len; i++) {
if (!(rule + i)) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
- err = EMF_ERROR_INVALID_PARAM;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
/* 'ON' */
EM_DEBUG_LOG("rule[%d].flag2(rule id[%d]) is %d", i, rule[i].rule_id, rule[i].flag2);
switch (rule[i].type) {
- case EMF_FILTER_FROM:
+ case EMAIL_FILTER_FROM:
src = from_address;
break;
- case EMF_FILTER_SUBJECT:
+ case EMAIL_FILTER_SUBJECT:
src = (char*)input_subject;
break;
- case EMF_FILTER_BODY:
- err = EMF_ERROR_NOT_SUPPORTED;
+ case EMAIL_FILTER_BODY:
+ err = EMAIL_ERROR_NOT_SUPPORTED;
goto FINISH_OFF;
break;
}
if (!dest || !address) {
EM_DEBUG_EXCEPTION("dest[%p], address[%p]", dest, address);
if (err_code != NULL)
- *err_code = EMF_ERROR_INVALID_PARAM;
+ *err_code = EMAIL_ERROR_INVALID_PARAM;
return false;
}
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
gchar *concatenated = NULL;
gchar *utf8_address = NULL;
}
-static int emcore_make_mail_tbl_data_from_envelope(MAILSTREAM *mail_stream, ENVELOPE *input_envelope, emcore_uid_list *input_uid_elem, emstorage_mail_tbl_t **output_mail_tbl_data, int *err_code)
+int emcore_make_mail_tbl_data_from_envelope(MAILSTREAM *mail_stream, ENVELOPE *input_envelope, emcore_uid_list *input_uid_elem, emstorage_mail_tbl_t **output_mail_tbl_data, int *err_code)
{
EM_PROFILE_BEGIN(emCoreParseEnvelope);
EM_DEBUG_FUNC_BEGIN("input_envelope[%p], input_uid_elem [%p], output_mail_tbl_data[%p], err_code[%p]", input_envelope, input_uid_elem, output_mail_tbl_data, err_code);
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
int priority = 3;
int req_read_receipt = 0;
struct tm temp_time_info;
emstorage_mail_tbl_t *temp_mail_tbl_data = NULL;
if (!output_mail_tbl_data) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
- err = EMF_ERROR_INVALID_PARAM;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
if (!(temp_mail_tbl_data = em_malloc(sizeof(emstorage_mail_tbl_t)))) {
EM_DEBUG_EXCEPTION("em_malloc failed...");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
if (!(mail_cache_element = mail_elt(mail_stream, input_uid_elem->msgno))) {
EM_DEBUG_EXCEPTION("mail_elt failed...");
- err = EMF_ERROR_UNKNOWN;
+ err = EMAIL_ERROR_UNKNOWN;
goto FINISH_OFF;
}
EM_DEBUG_FUNC_BEGIN("input_mailbox_tbl[%p], input_mailbox_tbl_spam[%p], input_uid_list [%p], err_code[%p]", input_mailbox_tbl, input_mailbox_tbl_spam, input_uid_list, err_code);
int ret = false;
- int err = EMF_ERROR_NONE, err_2 = EMF_ERROR_NONE;
- int status = EMF_LIST_FAIL;
+ int err = EMAIL_ERROR_NONE, err_2 = EMAIL_ERROR_NONE;
+ int status = EMAIL_LIST_FAIL;
int download_limit_count;
- emf_account_t *account_ref = NULL;
+ email_account_t *account_ref = NULL;
emstorage_rule_tbl_t *rule = NULL;
emcore_uid_list *uid_list = NULL;
emcore_uid_list *uid_elem = NULL;
int account_id = 0, mail_id = 0, rule_len = 1000, total = 0, unread = 0, i = 0, percentage = 0, thread_id = -1;
void *stream = NULL;
char *uid_range = NULL;
+ char mailbox_id_param_string[10] = {0,};
if (!input_mailbox_tbl) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM:input_mailbox_tbl[%p]", input_mailbox_tbl);
- err = EMF_ERROR_INVALID_PARAM;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM:input_mailbox_tbl[%p]", input_mailbox_tbl);
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
account_ref = emcore_get_account_reference(account_id);
if (!account_ref) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", account_id);
- err = EMF_ERROR_INVALID_ACCOUNT;
+ err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if(account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4 && input_mailbox_tbl->sync_with_server_yn == 0) {
- EM_DEBUG_EXCEPTION("sync_with_server_yn flag is false for this mailbox");
- err = EMF_ERROR_INVALID_MAILBOX;
+ if(account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && input_mailbox_tbl->local_yn == 1) {
+ EM_DEBUG_EXCEPTION("local_yn flag is false for this mailbox");
+ err = EMAIL_ERROR_INVALID_MAILBOX;
goto FINISH_OFF;
}
stream = stream_recycle; /* set stream for recycling connection. */
#endif
- if (!emcore_connect_to_remote_mailbox(account_id, input_mailbox_tbl->mailbox_name, (void **)&stream, &err) || !stream){
+ if (!emcore_connect_to_remote_mailbox(account_id, input_mailbox_tbl->mailbox_id, (void **)&stream, &err) || !stream){
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err);
- status = EMF_LIST_CONNECTION_FAIL;
+ status = EMAIL_LIST_CONNECTION_FAIL;
goto FINISH_OFF;
}
FINISH_OFF_IF_CANCELED;
/* save total mail count on server to DB */
- if (!emstorage_update_mailbox_total_count(account_id, input_mailbox_tbl->mailbox_name, ((MAILSTREAM *)stream)->nmsgs, 1, &err)){
+ if (!emstorage_update_mailbox_total_count(account_id, input_mailbox_tbl->mailbox_id, ((MAILSTREAM *)stream)->nmsgs, 1, &err)){
EM_DEBUG_EXCEPTION("emstorage_update_mailbox_total_count failed [%d]", err);
goto FINISH_OFF;
/* if (((MAILSTREAM *)stream)->nmsgs > 0) */
{
- emf_option_t *opt_ref = &account_ref->options;
+ email_option_t *opt_ref = &account_ref->options;
EM_DEBUG_LOG("block_address = %d, block_subject = %d", opt_ref->block_address, opt_ref->block_subject);
if (opt_ref->block_address || opt_ref->block_subject) {
int type = 0;
if (!opt_ref->block_address)
- type = EMF_FILTER_SUBJECT;
+ type = EMAIL_FILTER_SUBJECT;
else if (!opt_ref->block_subject)
- type = EMF_FILTER_FROM;
+ type = EMAIL_FILTER_FROM;
if (!emstorage_get_rule(ALL_ACCOUNT, type, 0, &rule_len, &is_completed, &rule, true, &err) || !rule)
EM_DEBUG_EXCEPTION("emstorage_get_rule failed - %d", err);
}
download_limit_count = input_mailbox_tbl->mail_slot_size;
- if (!emcore_get_uids_to_download(stream, account_ref, input_mailbox_tbl, download_limit_count, &uid_list, &total, EMF_SYNC_LATEST_MAILS_FIRST, &err)){
+ if (!emcore_get_uids_to_download(stream, account_ref, input_mailbox_tbl, download_limit_count, &uid_list, &total, EMAIL_SYNC_LATEST_MAILS_FIRST, &err)){
EM_DEBUG_EXCEPTION("emcore_get_uids_to_download failed [%d]", err);
uid_list = NULL;
goto FINISH_OFF;
EM_DEBUG_LOG("((MAILSTREAM *)stream)->nmsgs [%d]", ((MAILSTREAM *)stream)->nmsgs);
EM_DEBUG_LOG("uid_list [%p]", uid_list);
- if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4 && uid_list != NULL){
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && uid_list != NULL){
emcore_uid_list *uid_list_prev = NULL;
emcore_uid_list *uid_list_fast = uid_list;
int index = 0;
if (uid_range == NULL){
EM_DEBUG_EXCEPTION("memory allocation for uid_range failed");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
/* h.gahlaut@samsung.com : Clear the event queue of partial body download thread before starting fetching new headers */
#ifndef __PARTIAL_BODY_FOR_POP3__
- if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4){
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4){
#endif /* __PARTIAL_BODY_FOR_POP3__ */
/* Partial body download feature is only for IMAP accounts */
if (false == emcore_clear_partial_body_thd_event_que(&err))
else{
#ifdef __FEATURE_HEADER_OPTIMIZATION__
- if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4) /* Fetch env from cache in case of IMAP */
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) /* Fetch env from cache in case of IMAP */
env = mail_fetchstructure_full(stream, uid_elem->msgno, NULL, FT_PEEK, 0);
else /* Fetch header from network in case of POP */
env = mail_fetchstructure_full(stream, uid_elem->msgno, NULL, FT_PEEK, 1);
if (matched >= 0 && input_mailbox_tbl_spam){ /* add filtered mails to SPAMBOX */
EM_DEBUG_LOG("mail[%d] added to spambox", mail_id);
- if ( (err = emcore_add_mail_to_mailbox(input_mailbox_tbl_spam, new_mail_tbl_data, &mail_id, &thread_id)) != EMF_ERROR_NONE) {
+ if ( (err = emcore_add_mail_to_mailbox(input_mailbox_tbl_spam, new_mail_tbl_data, &mail_id, &thread_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox falied [%d]", err);
goto FINISH_OFF;
}
- if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4){
- if (!emcore_move_mail_on_server(account_id, input_mailbox_tbl->mailbox_name, &mail_id, 1, input_mailbox_tbl_spam->mailbox_name, &err)){
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4){
+ if (!emcore_move_mail_on_server(account_id, input_mailbox_tbl->mailbox_id, &mail_id, 1, input_mailbox_tbl_spam->mailbox_name, &err)){
EM_DEBUG_EXCEPTION("emcore_move_mail_on_server falied [%d]", err);
goto FINISH_OFF;
}
} else {
/* add mails to specified mail box */
EM_DEBUG_LOG("mail[%d] moved to input_mailbox_tbl [%s]", mail_id, input_mailbox_tbl->mailbox_name);
- if ( (err = emcore_add_mail_to_mailbox(input_mailbox_tbl, new_mail_tbl_data, &mail_id, &thread_id)) != EMF_ERROR_NONE) {
+ if ( (err = emcore_add_mail_to_mailbox(input_mailbox_tbl, new_mail_tbl_data, &mail_id, &thread_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox falied [%d]", err);
goto FINISH_OFF;
}
/*h.gahlaut : Start partial body dowload using partial body thread only for IMAP accounts*/
#ifndef __PARTIAL_BODY_FOR_POP3__
- if (account_ref->receiving_server_type == EMF_SERVER_TYPE_IMAP4) {
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
#endif /* __PARTIAL_BODY_FOR_POP3__ */
- if (false == emcore_initiate_pbd(stream, account_id, mail_id, uid_elem->uid, input_mailbox_tbl->mailbox_name, &err))
- EM_DEBUG_LOG("Partial body download initiation failed [%d]", err);
+ if (account_ref->auto_download_size != 0) {
+ if (false == emcore_initiate_pbd(stream, account_id, mail_id, uid_elem->uid, input_mailbox_tbl->mailbox_id, &err))
+ EM_DEBUG_LOG("Partial body download initiation failed [%d]", err);
+ }
#ifndef __PARTIAL_BODY_FOR_POP3__
}
#endif /* __PARTIAL_BODY_FOR_POP3__ */
- if (!uid_elem->flag.seen && input_mailbox_tbl->mailbox_type != EMF_MAILBOX_TYPE_SPAMBOX)
+ if (!uid_elem->flag.seen && input_mailbox_tbl->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX)
emcore_add_notification_for_unread_mail(new_mail_tbl_data);
FINISH_OFF_IF_CANCELED;
percentage = ((i+1) * 100) / total ;
EM_DEBUG_LOG("Header Percentage Completed [%d] : [%d/%d] mail_id [%d]", percentage, i+1, total, mail_id);
+ SNPRINTF(mailbox_id_param_string, 10, "%d", input_mailbox_tbl->mailbox_id);
- if (!emstorage_notify_storage_event(NOTI_MAIL_ADD, account_id, mail_id, input_mailbox_tbl->mailbox_name, thread_id))
+ if (!emstorage_notify_storage_event(NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id))
EM_DEBUG_EXCEPTION("emstorage_notify_storage_event [NOTI_MAIL_ADD] failed");
}
if (!emcore_remove_overflowed_mails(input_mailbox_tbl, &err_2))
EM_DEBUG_EXCEPTION("emcore_remove_overflowed_mails failed - %d", err_2);
+ emstorage_stamp_last_sync_time_of_mailbox(input_mailbox_tbl->mailbox_id, 1);
+
if (new_mail_tbl_data)
emstorage_free_mail(&new_mail_tbl_data, 1, NULL);
-int emcore_download_uid_all(emf_mailbox_t *mailbox, emcore_uid_list** uid_list, int *total, emstorage_read_mail_uid_tbl_t *downloaded_uids, int count, emcore_get_uids_for_delete_t for_delete, int *err_code)
+int emcore_download_uid_all(email_internal_mailbox_t *mailbox, emcore_uid_list** uid_list, int *total, emstorage_read_mail_uid_tbl_t *downloaded_uids, int count, emcore_get_uids_for_delete_t for_delete, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mailbox[%p], uid_list[%p], total[%p], downloaded_uids[%p], count[%d], for_delete[%d], err_code[%p]", mailbox, uid_list, total, downloaded_uids, count, for_delete, err_code);
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
MAILSTREAM *stream = NULL;
- emf_account_t *ref_account = NULL;
+ email_account_t *ref_account = NULL;
emcore_uid_list *uid_elem = NULL;
emcore_uid_list *fetch_data_p = NULL;
void *tmp_stream = NULL;
if (!mailbox || !uid_list) {
EM_DEBUG_EXCEPTION("mailbox[%p], uid_list[%p], total[%p], downloaded_uids[%p], count[%d], for_delete[%d]", mailbox, uid_list, total, downloaded_uids, count, for_delete);
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
if (!(ref_account = emcore_get_account_reference(mailbox->account_id))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", mailbox->account_id);
- err = EMF_ERROR_INVALID_ACCOUNT;
+ err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
if (!mailbox->mail_stream) {
- if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->name, (void **)&tmp_stream, &err)){
+ if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->mailbox_id, (void **)&tmp_stream, &err)){
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed...");
goto FINISH_OFF;
else
stream = mailbox->mail_stream;
- if (ref_account->receiving_server_type == EMF_SERVER_TYPE_POP3) { /* POP3 */
+ if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { /* POP3 */
POP3LOCAL *pop3local = NULL;
if (!stream || !(pop3local = stream->local) || !pop3local->netstream) {
- err = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN; */
+ err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN; */
goto FINISH_OFF;
}
if (!net_sout(pop3local->netstream, cmd, (int)strlen(cmd))) {
EM_DEBUG_EXCEPTION("net_sout failed...");
- err = EMF_ERROR_CONNECTION_BROKEN;
+ err = EMAIL_ERROR_CONNECTION_BROKEN;
goto FINISH_OFF;
}
/* replied error "-ERR" */
if (*p == '-') {
- err = EMF_ERROR_MAIL_NOT_FOUND;
+ err = EMAIL_ERROR_MAIL_NOT_FOUND;
goto FINISH_OFF;
}
if (!uid_elem) {
EM_DEBUG_EXCEPTION("malloc falied...");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
char *t = NULL;
if (!stream || !(imaplocal = stream->local) || !imaplocal->netstream) {
- err = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN; */
+ err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN; */
goto FINISH_OFF;
}
if (!net_sout(imaplocal->netstream, cmd, (int)strlen(cmd))) {
EM_DEBUG_EXCEPTION("net_sout failed...");
- err = EMF_ERROR_CONNECTION_BROKEN;
+ err = EMAIL_ERROR_CONNECTION_BROKEN;
goto FINISH_OFF;
}
}
if (for_delete == EM_CORE_GET_UIDS_FOR_NO_DELETE) {
- if ((ref_account->retrieval_mode == EMF_IMAP4_RETRIEVAL_MODE_NEW) && (strstr(p, "\\Seen"))) {
+ if ((ref_account->retrieval_mode == EMAIL_IMAP4_RETRIEVAL_MODE_NEW) && (strstr(p, "\\Seen"))) {
free(p); p = NULL;
continue;
}
if (!uid_elem) {
EM_DEBUG_EXCEPTION("malloc failed...");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
t = strchr(s, ' ');
if (!t) {
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
t = strchr(s, ')');
if (!t) {
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
*t = '\0';
}
else {
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
return ret;
}
-int emcore_download_imap_msgno(emf_mailbox_t *mailbox, char *uid, int *msgno, int *err_code)
+int emcore_download_imap_msgno(email_internal_mailbox_t *mailbox, char *uid, int *msgno, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mailbox[%p], uid[%p], msgno[%p], err_code[%p]", mailbox, uid, msgno, err_code);
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
MAILSTREAM *stream = NULL;
IMAPLOCAL *imaplocal = NULL;
- emf_account_t *ref_account = NULL;
+ email_account_t *ref_account = NULL;
void *tmp_stream = NULL;
char tag[32], cmd[64];
char *p = NULL;
if (!mailbox || !uid) {
EM_DEBUG_EXCEPTION("mailbox[%p], uid[%p], msgno[%p]", mailbox, uid, msgno);
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
if (!(ref_account = emcore_get_account_reference(mailbox->account_id))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", mailbox->account_id);
- err = EMF_ERROR_INVALID_ACCOUNT;
+ err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if (ref_account->receiving_server_type != EMF_SERVER_TYPE_IMAP4) {
- err = EMF_ERROR_INVALID_ACCOUNT; /* EMF_ERROR_INVALID_PARAM; */
+ if (ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) {
+ err = EMAIL_ERROR_INVALID_ACCOUNT; /* EMAIL_ERROR_INVALID_PARAM; */
goto FINISH_OFF;
}
if (!mailbox->mail_stream) {
- if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->name, (void **)&tmp_stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->mailbox_id, (void **)&tmp_stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err);
goto FINISH_OFF;
stream = mailbox->mail_stream;
if (!stream || !(imaplocal = stream->local) || !imaplocal->netstream) {
- err = EMF_ERROR_INVALID_PARAM; /* EMF_ERROR_UNKNOWN; */
+ err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN; */
goto FINISH_OFF;
}
if (!net_sout(imaplocal->netstream, cmd, (int)strlen(cmd))) {
EM_DEBUG_EXCEPTION("net_sout failed...");
- err = EMF_ERROR_CONNECTION_BROKEN;
+ err = EMAIL_ERROR_CONNECTION_BROKEN;
goto FINISH_OFF;
}
}
if (ret != true)
- err = EMF_ERROR_MAIL_NOT_FOUND;
+ err = EMAIL_ERROR_MAIL_NOT_FOUND;
FINISH_OFF:
if (p)
EM_DEBUG_FUNC_BEGIN("uid_list[%p], uid[%s], msgno[%p], err_code[%p]", uid_list, uid, msgno, err_code);
int ret = false;
- int err = EMF_ERROR_MAIL_NOT_FOUND; /* EMF_ERROR_NONE; */
+ int err = EMAIL_ERROR_MAIL_NOT_FOUND; /* EMAIL_ERROR_NONE; */
if (!uid || !msgno || !uid_list) {
EM_DEBUG_EXCEPTION("uid_list[%p], uid[%p], msgno[%p]", uid_list, uid, msgno);
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
EM_DEBUG_LOG("*msgno[%d]", *msgno);
- err = EMF_ERROR_NONE;
+ err = EMAIL_ERROR_NONE;
ret = true;
break;
{
EM_DEBUG_FUNC_BEGIN();
- int ret = false, err = EMF_ERROR_NONE;
+ int ret = false, err = EMAIL_ERROR_NONE;
if (!uid || msgno <= 0 || !uid_list){
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
if (uid) {
if (!(*uid = EM_SAFE_STRDUP(uid_list->uid))) {
EM_DEBUG_EXCEPTION("strdup failed...");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
}
if (ret != true)
- err = EMF_ERROR_MAIL_NOT_FOUND;
+ err = EMAIL_ERROR_MAIL_NOT_FOUND;
FINISH_OFF:
if (err_code)
EM_DEBUG_FUNC_BEGIN("uid_list[%p], err_code[%p]", uid_list, err_code);
int ret = false;
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
emcore_uid_list *p = NULL;
if (!uid_list) {
EM_DEBUG_EXCEPTION(" uid_list[%p]\n", uid_list);
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_id [%d], err_code [%p]", account_id, mail_id, *err_code);
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
int ret = false;
int len = 0;
int read_size = 0;
emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
if (mail_id < 1){
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
- err = EMF_ERROR_INVALID_PARAM;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
goto FINISH_OFF;
}
- if ( (err = emstorage_get_attachment_list(mail_id, false, &attachment_tbl_data, &attachment_tbl_count)) != EMF_ERROR_NONE) {
+ if ( (err = emstorage_get_attachment_list(mail_id, false, &attachment_tbl_data, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
goto FINISH_OFF;
}
if (mailbox_tbl->sync_with_server_yn == 0) {
EM_DEBUG_EXCEPTION("The mailbox [%s] is not on server.", mail_table_data->mailbox_name);
- err = EMF_ERROR_INVALID_MAILBOX;
+ err = EMAIL_ERROR_INVALID_MAILBOX;
goto FINISH_OFF;
}
if (fname){
if (!(fp = fopen(fname, "a+"))) {
EM_DEBUG_EXCEPTION("fopen failed - %s", fname);
- err = EMF_ERROR_SYSTEM_FAILURE;
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
}
if (!fp) {
EM_DEBUG_EXCEPTION("fp is NULL..!");
- err = EMF_ERROR_SYSTEM_FAILURE;
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
ret = 0;
stream = NULL;
- if (!emcore_connect_to_remote_mailbox(mail_table_data->account_id, NULL, (void **)&stream, &err)){
+ if (!emcore_connect_to_remote_mailbox(mail_table_data->account_id, 0, (void **)&stream, &err)){
EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed : Mailbox open[%d]", err);
goto FINISH_OFF;
}
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
-static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, char *uid, char *input_mailbox_name, int *err_code)
+static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, char *uid, int input_maibox_id, int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_id[%d], uid[%p], input_mailbox_name[%p]", account_id, mail_id, uid, input_mailbox_name);
+ EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_id[%d], uid[%p], input_maibox_id[%d]", account_id, mail_id, uid, input_maibox_id);
int ret = false;
- int err = EMF_ERROR_NONE;
- emf_account_t *account_ref;
+ int err = EMAIL_ERROR_NONE;
+ email_account_t *account_ref;
+ emstorage_mailbox_tbl_t* mailbox = NULL;
- if (account_id < FIRST_ACCOUNT_ID || mail_id < 0 || NULL == uid || NULL == input_mailbox_name){
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
- err = EMF_ERROR_INVALID_PARAM;
+ if (account_id < FIRST_ACCOUNT_ID || mail_id < 0 || NULL == uid || 0 == input_maibox_id){
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
account_ref = emcore_get_account_reference(account_id);
- emf_event_partial_body_thd pbd_event;
+ email_event_partial_body_thd pbd_event;
- memset(&pbd_event, 0x00, sizeof(emf_event_partial_body_thd));
+ memset(&pbd_event, 0x00, sizeof(email_event_partial_body_thd));
pbd_event.account_id = account_id;
- if (account_ref && account_ref->receiving_server_type == EMF_SERVER_TYPE_POP3)
+ if (account_ref && account_ref->incoming_server_type == EMAIL_SERVER_TYPE_POP3)
pbd_event.activity_type = ACTIVITY_PARTIAL_BODY_DOWNLOAD_POP3_WAIT;
else
pbd_event.activity_type = ACTIVITY_PARTIAL_BODY_DOWNLOAD_IMAP4;
+
+ if ( (err = emstorage_get_mailbox_by_id(input_maibox_id, &mailbox)) != EMAIL_ERROR_NONE || !mailbox) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
+ goto FINISH_OFF;
+ }
- pbd_event.mailbox_name = EM_SAFE_STRDUP(input_mailbox_name);
- pbd_event.mail_id = mail_id;
+ pbd_event.mailbox_id = input_maibox_id;
+ pbd_event.mail_id = mail_id;
pbd_event.server_mail_id = strtoul(uid, NULL, 0);
+ pbd_event.mailbox_name = EM_SAFE_STRDUP(mailbox->mailbox_name);
- EM_DEBUG_LOG("input_mailbox_name name [%s]", pbd_event.mailbox_name);
+ EM_DEBUG_LOG("input_mailbox_name name [%d]", pbd_event.mailbox_id);
EM_DEBUG_LOG("uid [%s]", uid);
EM_DEBUG_LOG("pbd_event.account_id[%d], pbd_event.mail_id[%d], pbd_event.server_mail_id [%d]", pbd_event.account_id, pbd_event.mail_id , pbd_event.server_mail_id);
on the basis of activity_type and event_type fields */
pbd_event.activity_type = 0;
- pbd_event.event_type = EMF_EVENT_BULK_PARTIAL_BODY_DOWNLOAD;
+ pbd_event.event_type = EMAIL_EVENT_BULK_PARTIAL_BODY_DOWNLOAD;
if (!emcore_insert_partial_body_thread_event(&pbd_event, &err)){
EM_DEBUG_EXCEPTION("Inserting Partial body thread event failed with error[%d]", err);
FINISH_OFF:
+ if (mailbox) {
+ emstorage_free_mailbox(&mailbox, 1, &err);
+ }
+
if (NULL != err_code)
*err_code = err;
{
EM_DEBUG_FUNC_BEGIN("start_header [%s], boundary_string [%s], bufsendforparse [%s], text_html [%s], body_size [%d]", start_header, boundary_string, bufsendforparse, text_html, body_size);
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
int html_uidno = 0;
int iEncodingHeader = 0;
int enc_type = ENCOTHER, dec_len = 0, html_length = 0;
EM_DEBUG_LOG("end [%p], txt_html [%p]", end, txt_html);
if (end == NULL) {
- EM_DEBUG_LOG("HTML body contents exceeds %d Bytes", PARTIAL_BODY_SIZE_IN_BYTES);
+ EM_DEBUG_LOG("HTML body contents exceeds limited Bytes");
end = txt_html + body_size - (txt_html - bufsendforparse);
html_uidno = 1;
static int emcore_parse_plain_part_for_partial_body(char *header_start_string, char *start_header, char *boundary_string, char *bufsendforparse, char *text_plain, int body_size)
{
EM_DEBUG_FUNC_BEGIN("header_start_string[%s], start_header[%s], boundary_string [%s], bufsendforparse [%s], text_plain [%s]", header_start_string, start_header, boundary_string, bufsendforparse, text_plain);
- int err = EMF_ERROR_NONE, iEncodingHeader = 0, enc_type = ENCOTHER;
+ int err = EMAIL_ERROR_NONE, iEncodingHeader = 0, enc_type = ENCOTHER;
int dec_len = 0, strcmpret = -1;
char *pHeaderStart = NULL, *pEncodingHeaderEnd = NULL;
char EncodingHeader[40] = {0, };
end = strstr(txt_plain, boundary_string);
if (end == NULL){
- EM_DEBUG_LOG("Text body contents exceeds %d Bytes", PARTIAL_BODY_SIZE_IN_BYTES);
+ EM_DEBUG_LOG("Text body contents exceeds limited Bytes");
end = txt_plain + body_size - (txt_plain - bufsendforparse);
}
else{
/* Content-Type: IMAGE/octet-stream; name = Default.png */
/* Content-Transfer-Encoding: BASE64 */
-/* Content-ID: <4b0d6810b17291f9438783a8eb9d5228@com.samsung.slp.email> */
+/* Content-ID: <4b0d6810b17291f9438783a8eb9d5228@org.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, emf_image_data *image_data, int body_size)
+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)
{
EM_DEBUG_FUNC_BEGIN();
- int err = EMF_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
char *multiple_image = NULL;
int donot_parse_next_image = 0;
char *image_boundary = NULL;
char *cid_end = NULL;
char *temp_enc1 = NULL;
+ if(image_data == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ return 0;
+ }
image_boundary = start_header;
image_boundary_end = image_boundary - 2;
int boundarylen = -1;
char *cid = NULL;
char *temp_name = NULL;
+ char *decoded_filename = NULL;
memset(image_data[i].image_file_name, 0, 100);
txt_image = start_header;
if ((*(temp_name+4) == '=') && (*(temp_name+5) != '\"'))
image_data[i].image_file_name[ch_image-1] = '\0';
+
+ decoded_filename = emcore_decode_rfc2047_text(image_data[i].image_file_name, &err);
+ if(decoded_filename) {
+ memset(image_data[i].image_file_name, 0, 100);
+ memcpy(image_data[i].image_file_name, decoded_filename, EM_SAFE_STRLEN(decoded_filename));
+ EM_SAFE_FREE(decoded_filename);
+ }
}
if (((temp_cid1 = (char *)strcasestr((const char *)start_header, "Content-ID: <")) != NULL)){
cid_end = strstr(temp_image, "\076"); /* 076 == '>' */
image_data[i].content_id = (char *)em_malloc(cid_end-cid+5);
- if (image_data[i].content_id != NULL){
+ if (image_data[i].content_id != NULL){
strcpy(image_data[i].content_id, "cid:");
memcpy(image_data[i].content_id+4, cid, cid_end-cid);
}
if (end == NULL){
- EM_DEBUG_LOG("HTML body contents exceeds %d Bytes", PARTIAL_BODY_SIZE_IN_BYTES);
+ EM_DEBUG_LOG("HTML body contents exceeds limited Bytes");
/* end points to end of partial body data */
end = txt_image + body_size - (txt_image-bufsendforparse);
}
static int emcore_find_boundary_string_of_the_part(const char *whole_string, const char *first_line_of_part, char **result_boundary_string, int *error)
{
EM_DEBUG_FUNC_BEGIN("whole_string[%p], first_line_of_part[%p], result_boundary_string[%p]", whole_string, first_line_of_part, result_boundary_string);
- int ret = false, err = EMF_ERROR_NONE;
+ int ret = false, err = EMAIL_ERROR_NONE;
char *boundary_cur = NULL, *boundary_end = NULL, *boundary_string = NULL;
if(!whole_string || !first_line_of_part || !result_boundary_string) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
- err = EMF_ERROR_INVALID_PARAM;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
boundary_string = em_malloc(boundary_end - boundary_cur + 15);
if(!boundary_string) {
EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
memcpy(boundary_string, boundary_cur, boundary_end - boundary_cur);
}
else {
EM_DEBUG_EXCEPTION("There is no string before the part");
- err = EMF_ERROR_ON_PARSING;
+ err = EMAIL_ERROR_ON_PARSING;
goto FINISH_OFF;
}
}
else {
EM_DEBUG_EXCEPTION("There is no string before the part");
- err = EMF_ERROR_ON_PARSING;
+ err = EMAIL_ERROR_ON_PARSING;
goto FINISH_OFF;
}
ret = true;
#define TAG_LENGTH 16
#define COMMAND_LENGTH 2000
-INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *stream, emf_event_partial_body_thd *pbd_event, int item_count, int *error)
+static int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *stream, int input_download_size, email_event_partial_body_thd *pbd_event, int item_count, int *error)
{
- EM_DEBUG_FUNC_BEGIN("stream [%p], pbd_event [%p], item_count [%d], error [%p]", stream, pbd_event, item_count, error);
+ EM_DEBUG_FUNC_BEGIN("stream [%p], input_download_size[%d], pbd_event [%p], item_count [%d], error [%p]", stream, input_download_size, pbd_event, item_count, error);
- int ret = false, err = EMF_ERROR_NONE;
+ int ret = false, err = EMAIL_ERROR_NONE;
int encoding = 0;
int j = 0;
int i32_index = 0, temp_string_index = 0;
int total_parsed_len_per_uid = 0, total_parsed_len = 0;
unsigned long uidno = 0;
char buf[512] = {0, };
- char text_plain[PARTIAL_BODY_SIZE_IN_BYTES + 1] = {0, };
- char text_html[PARTIAL_BODY_SIZE_IN_BYTES + 1] = {0, };
- char temp_text_buf[PARTIAL_BODY_SIZE_IN_BYTES + 1] = {0, };
+ char *text_plain = NULL;
+ char *text_html = NULL;
+ char *temp_text_buf = NULL;
char uid_range_string_to_be_downloaded[UID_RANGE_STRING_LENGTH] = {0, };
char imap_tag[TAG_LENGTH] = {0, };
char command[COMMAND_LENGTH] = {0, };
char *start_header = NULL;
char *boundary_string = NULL;
char *temp_content_type1 = NULL;
+ char *temp_data_html = NULL;
char *bodystructure_start = NULL, *bodystructure_end = NULL, *body_structure_string = NULL, *modified_body_structure_string = NULL;
char *plain_text_file_name_from_content_info = NULL, *html_text_file_name_from_content_info = NULL, *plain_charset_from_content_info = NULL;
char temp_string[TEMP_STRING_LENGTH] = {0, };
IMAPLOCAL *imaplocal = NULL;
IMAPPARSEDREPLY *reply_from_server = NULL;
emstorage_mail_tbl_t *mail = NULL;
- emf_partial_buffer *imap_response = NULL;
+ email_partial_buffer *imap_response = NULL;
BODY *body = NULL;
struct _m_content_info *cnt_info = NULL;
struct attachment_info *attach_info = NULL;
emstorage_attachment_tbl_t attachment_tbl;
- emf_event_partial_body_thd *stSectionNo = NULL;
- emf_image_data image_data[IMAGE_DISPLAY_PARTIAL_BODY_COUNT];
+ email_event_partial_body_thd *stSectionNo = NULL;
+ email_image_data image_data[IMAGE_DISPLAY_PARTIAL_BODY_COUNT];
if (!(stream) || !(imaplocal = stream->local) || !imaplocal->netstream || !pbd_event) {
EM_DEBUG_EXCEPTION("invalid parameter");
- err = EMF_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
}
- memset(image_data, 0x00 , sizeof(emf_image_data) * IMAGE_DISPLAY_PARTIAL_BODY_COUNT);
+ text_plain = em_malloc(sizeof(char) * (input_download_size + 1));
+ text_html = em_malloc(sizeof(char) * (input_download_size + 1));
+ temp_text_buf = em_malloc(sizeof(char) * (input_download_size + 1));
+
+ if(!text_plain || !text_plain || !temp_text_buf) {
+ EM_SAFE_FREE(text_plain);
+ EM_SAFE_FREE(text_html);
+ EM_SAFE_FREE(temp_text_buf);
+
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ return EMAIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ memset(image_data, 0x00 , sizeof(email_image_data) * IMAGE_DISPLAY_PARTIAL_BODY_COUNT);
EM_DEBUG_LOG("Start of emcore_get_section_for_partial_download, item_count = %d ", item_count);
}
SNPRINTF(imap_tag, TAG_LENGTH, "%08lx", 0xffffffff & (stream->gensym++));
- SNPRINTF(command, COMMAND_LENGTH, "%s UID FETCH %s (BODYSTRUCTURE BODY.PEEK[TEXT]<0.15360>)\015\012", imap_tag, uid_range_string_to_be_downloaded);
+ SNPRINTF(command, COMMAND_LENGTH, "%s UID FETCH %s (BODYSTRUCTURE BODY.PEEK[TEXT]<0.%d>)\015\012", imap_tag, uid_range_string_to_be_downloaded, input_download_size);
EM_DEBUG_LOG("command : %s", command);
/* Sending out the IMAP request */
if (!net_sout(imaplocal->netstream, command, (int)strlen(command))) {
EM_DEBUG_EXCEPTION("net_sout failed...");
- err = EMF_ERROR_CONNECTION_BROKEN;
+ err = EMAIL_ERROR_CONNECTION_BROKEN;
goto FINISH_OFF;
}
/* responce from the server */
- imap_response = emcore_get_response_from_server(imaplocal->netstream, imap_tag, &reply_from_server);
+ imap_response = emcore_get_response_from_server(imaplocal->netstream, imap_tag, &reply_from_server, input_download_size);
if (!imap_response || !reply_from_server ){
EM_DEBUG_EXCEPTION(" Invalid response from emcore_get_response_from_server");
if (bodystructure_length > response_buffer_length){
EM_DEBUG_EXCEPTION("bodystructure_length[%d] is longer than response_buffer_length[%d]", bodystructure_length, response_buffer_length);
- err = EMF_ERROR_INVALID_RESPONSE;
+ err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
if (NULL == body_structure_string){
EM_DEBUG_EXCEPTION("em_malloc failed...!");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
if (!(cnt_info = em_malloc(sizeof(struct _m_content_info)))) {
EM_DEBUG_EXCEPTION("em_malloc failed...");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
if (emcore_get_body(stream, 0, 0, 0, body, cnt_info, &err) < 0 || !cnt_info) {
EM_DEBUG_EXCEPTION("emcore_get_body falied [%d]", err);
- err = EMF_ERROR_IMAP4_FETCH_UID_FAILURE;
+ err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE;
goto FINISH_OFF;
}
}
body_size = atoi(temp_string);
- if (body_size > PARTIAL_BODY_SIZE_IN_BYTES)
- body_size = PARTIAL_BODY_SIZE_IN_BYTES;
+ if (body_size >= input_download_size)
+ body_size = input_download_size + 2;
EM_DEBUG_LOG("body_size [%d]", body_size);
}
else{
body_size = 0;
EM_DEBUG_EXCEPTION("Can't find body size from MIME header");
- /* err = EMF_ERROR_INVALID_RESPONSE; */
+ /* err = EMAIL_ERROR_INVALID_RESPONSE; */
/* goto FINISH_OFF; */
}
tempmailparselen++;
if (imap_response->buflen < (total_parsed_len + body_size)){
- err = EMF_ERROR_CONNECTION_BROKEN;
- EM_DEBUG_EXCEPTION("EMF_ERROR_CONNECTION_BROKEN : imap_response->buflen [%d], total_parsed_len [%d], body_size [%d]", imap_response->buflen, total_parsed_len, body_size);
+ err = EMAIL_ERROR_CONNECTION_BROKEN;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_CONNECTION_BROKEN : imap_response->buflen [%d], total_parsed_len [%d], body_size [%d]", imap_response->buflen, total_parsed_len, body_size);
goto FINISH_OFF;
}
else {
if (!emstorage_get_maildata_by_servermailid(pbd_event[temp_count].account_id, temp_string, &mail , true, &err) || !mail){
EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid failed [%d]", err);
- if (err == EMF_ERROR_MAIL_NOT_FOUND || !mail)
+ if (err == EMAIL_ERROR_MAIL_NOT_FOUND || !mail)
goto FINISH_OFF;
}
/* Update attachment details except inline content */
if (cnt_info->file && cnt_info->file->name){
- memset(&attachment_tbl, 0x00, sizeof(emf_attachment_info_t));
+ memset(&attachment_tbl, 0x00, sizeof(email_attachment_data_t));
attachment_tbl.account_id = pbd_event[temp_count].account_id;
attachment_tbl.mail_id = mail->mail_id;
- attachment_tbl.mailbox_name = pbd_event[temp_count].mailbox_name;
+ attachment_tbl.mailbox_id = pbd_event[temp_count].mailbox_id;
attachment_tbl.attachment_save_status = 0;
for (attachment_num = 1, attach_info = cnt_info->file; attach_info; attach_info = attach_info->next, attachment_num++) {
if (bufsendforparse == NULL){
EM_DEBUG_EXCEPTION("Allocation for bufsendforparse failed.");
- err = EMF_ERROR_OUT_OF_MEMORY;
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
EM_DEBUG_LOG("string bufendforparse :[%s]", bufsendforparse);
p = bufsendforparse;
- if (mail && mail->body_download_status == EMF_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED) /* No need to save */
+ if (mail && mail->body_download_status == EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED) /* No need to save */
goto NEXTUIDPARSING;
if (!strcasestr(p, "Content-Type: text/plain") && !strcasestr(p, "Content-Type: text/html") && !strcasestr(p, "Content-type: image/jpeg")
}
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_content_type1 < temp_alternative_plain_header) /* This part is text/plain not alternative. */
}
if (((start_header = (char *)strcasestr((const char *)p, "Content-type: image/jpeg")) != (char *)NULL) ||
+ ((start_header = (char *)strcasestr((const char *)p, "Content-Type: image/jpg")) != (char *)NULL) ||
((start_header = (char *)strcasestr((const char *)p, "Content-Type: image/gif")) != (char *)NULL) ||
((start_header = (char *)strcasestr((const char *)p, "Content-Type: image/bmp")) != (char *)NULL) ||
((start_header = (char *)strcasestr((const char *)p, "Content-Type: image/png")) != (char *)NULL))
if (image_data[0].text_image != NULL && image_data[0].text_image[0] != NULL_CHAR){
char *result_string_of_replcaing = NULL;
- char temp_data_html[PARTIAL_BODY_SIZE_IN_BYTES + 1] = {0};
int store_file = 0;
int content_index = 0;
+ temp_data_html = em_malloc(sizeof(char) * (input_download_size + 1));
+
+ if(!temp_data_html) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
memset(buf, 0x00, sizeof(buf));
if (text_html[0] != NULL_CHAR)
memcpy(temp_data_html, text_html, strlen(text_html));
if (!emstorage_create_file(image_data[store_file].text_image, image_data[store_file].dec_len, buf, &err))
EM_DEBUG_EXCEPTION("emstorage_create_file failed [%d]", err);
- if (mail->body_download_status != EMF_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED){
+ if (mail->body_download_status != EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED){
memset(&attachment_tbl, 0x00, sizeof(emstorage_attachment_tbl_t));
attachment_tbl.mail_id = mail->mail_id;
attachment_tbl.account_id = pbd_event[temp_count].account_id;
- attachment_tbl.mailbox_name = stream->mailbox;
+ attachment_tbl.mailbox_id = pbd_event[temp_count].mailbox_id;
attachment_tbl.attachment_name = image_data[store_file].image_file_name;
attachment_tbl.attachment_size = image_data[store_file].dec_len;
attachment_tbl.attachment_path = buf;
image_data[content_index].content_id && image_data[content_index].content_id[0] != NULL_CHAR && (content_index < IMAGE_DISPLAY_PARTIAL_BODY_COUNT)){ /* Finding CID in HTML and replacing with image name. */
result_string_of_replcaing = em_replace_string((char *)temp_data_html, (char *)image_data[content_index].content_id, (char *)image_data[content_index].image_file_name);
- EM_SAFE_STRNCPY(temp_data_html, result_string_of_replcaing, PARTIAL_BODY_SIZE_IN_BYTES);
+ EM_SAFE_STRNCPY(temp_data_html, result_string_of_replcaing, input_download_size);
EM_SAFE_FREE(result_string_of_replcaing);
if (strstr(temp_data_html, image_data[content_index].content_id) != NULL)
}
image_length = 0;
- memset(text_html, 0, PARTIAL_BODY_SIZE_IN_BYTES+1);
+ memset(text_html, 0, (input_download_size + 1));
if (temp_data_html[0] != NULL_CHAR)
memcpy(text_html, temp_data_html, strlen(temp_data_html));
- memset(temp_data_html, 0x00, PARTIAL_BODY_SIZE_IN_BYTES+1);
+ memset(temp_data_html, 0x00, (input_download_size + 1));
+
+ EM_SAFE_FREE(temp_data_html);
}
if (strlen(text_html) > 0){
}
- mail->body_download_status = (total_mail_size_except_attach < PARTIAL_BODY_SIZE_IN_BYTES) ? 1 : 2;
+ mail->body_download_status = (total_mail_size_except_attach < input_download_size) ? 1 : 2;
EM_DEBUG_LOG("total_mail_size_except_attach [%d], mail->body_download_status [%d]", total_mail_size_except_attach, mail->body_download_status);
/* Get preview text */
- if ( (err = emcore_get_preview_text_from_file(mail->file_path_plain, mail->file_path_html, MAX_PREVIEW_TEXT_LENGTH, &(mail->preview_text))) != EMF_ERROR_NONE)
+ if ( (err = emcore_get_preview_text_from_file(mail->file_path_plain, mail->file_path_html, MAX_PREVIEW_TEXT_LENGTH, &(mail->preview_text))) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file() failed[%d]", err);
/* Update body contents */
EM_SAFE_FREE(bufsendforparse);
- memset(text_html, 0, PARTIAL_BODY_SIZE_IN_BYTES+1);
- memset(text_plain, 0, PARTIAL_BODY_SIZE_IN_BYTES+1);
- memset(temp_text_buf, 0, PARTIAL_BODY_SIZE_IN_BYTES+1);
+ memset(text_html, 0, input_download_size+1);
+ memset(text_plain, 0, input_download_size+1);
+ memset(temp_text_buf, 0, input_download_size+1);
if (mail)
emstorage_free_mail(&mail, 1, NULL);
EM_SAFE_FREE(reply_from_server);
}
+ EM_SAFE_FREE(text_plain);
+ EM_SAFE_FREE(text_html);
+ EM_SAFE_FREE(temp_text_buf);
+
EM_SAFE_FREE(bufsendforparse);
EM_SAFE_FREE(plain_text_file_name_from_content_info);
EM_SAFE_FREE(html_text_file_name_from_content_info);
return ret;
}
-INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_pop3(MAILSTREAM *stream, emf_event_partial_body_thd *pbd_event, int item_count, int *error)
+INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_pop3(MAILSTREAM *stream, int input_download_size, email_event_partial_body_thd *pbd_event, int item_count, int *error)
{
EM_DEBUG_FUNC_BEGIN("stream [%p], pbd_event [%p], item_count [%d], error [%p]", stream, pbd_event, item_count, error);
- int ret = false, err = EMF_ERROR_NONE;
+ int ret = false, err = EMAIL_ERROR_NONE;
int i;
if (!stream || !pbd_event) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
- err = EMF_ERROR_INVALID_PARAM;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
EM_DEBUG_LOG("pbd_event[%d].account_id [%d], mail_id [%d], server_mail_id [%d], activity_id [%d]", \
i, pbd_event[i].account_id, pbd_event[i].mail_id, pbd_event[i].server_mail_id, pbd_event[i].activity_id);
- if (!emcore_download_body_multi_sections_bulk(stream, pbd_event[i].account_id, pbd_event[i].mail_id, false, false, PARTIAL_BODY_SIZE_IN_BYTES, 0 , &err)){
+ if (!emcore_download_body_multi_sections_bulk(stream, pbd_event[i].account_id, pbd_event[i].mail_id, false, false, input_download_size, 0 , &err)){
EM_DEBUG_EXCEPTION("emcore_download_body_multi_sections_bulk failed");
goto FINISH_OFF;
}
-INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, emf_event_partial_body_thd *pbd_event, int item_count, int *error)
+INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, email_event_partial_body_thd *pbd_event, int item_count, int *error)
{
EM_DEBUG_FUNC_BEGIN("stream [%p], pbd_event [%p], item_count [%d], error [%p]", stream, pbd_event, item_count, error);
- int ret = false, err = EMF_ERROR_NONE;
- emf_account_t *pbd_account = NULL;
+ int ret = false, err = EMAIL_ERROR_NONE;
+ emstorage_account_tbl_t *pbd_account_tbl = NULL;
+ int auto_download_size = 0;
if (!stream || !pbd_event) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
- err = EMF_ERROR_INVALID_PARAM;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- pbd_account = emcore_get_account_reference(pbd_event[0].account_id);
-
- if (pbd_account == NULL){
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_ACCOUNT");
- err = EMF_ERROR_INVALID_ACCOUNT;
+ if (!emstorage_get_account_by_id(pbd_event[0].account_id, EMAIL_ACC_GET_OPT_DEFAULT, &pbd_account_tbl, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
goto FINISH_OFF;
}
- switch (pbd_account->receiving_server_type){
- case EMF_SERVER_TYPE_IMAP4:
- ret = emcore_download_bulk_partial_mail_body_for_imap(stream, pbd_event, item_count, &err);
+ auto_download_size = (pbd_account_tbl->auto_download_size<4096)?4096:pbd_account_tbl->auto_download_size;
+
+ switch (pbd_account_tbl->incoming_server_type){
+ case EMAIL_SERVER_TYPE_IMAP4:
+ ret = emcore_download_bulk_partial_mail_body_for_imap(stream, auto_download_size, pbd_event, item_count, &err);
break;
- case EMF_SERVER_TYPE_POP3:
- ret = emcore_download_bulk_partial_mail_body_for_pop3(stream, pbd_event, item_count, &err);
+ case EMAIL_SERVER_TYPE_POP3:
+ ret = emcore_download_bulk_partial_mail_body_for_pop3(stream, auto_download_size, pbd_event, item_count, &err);
break;
default:
- err = EMF_ERROR_NOT_SUPPORTED;
+ err = EMAIL_ERROR_NOT_SUPPORTED;
ret = false;
break;
}
}
-static emf_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply)
+static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply, int input_download_size)
{
EM_DEBUG_FUNC_BEGIN();
if (!nstream || !tag || !reply){
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
return NIL;
}
- emf_partial_buffer *retPartialBuffer = NULL;
+ email_partial_buffer *retPartialBuffer = NULL;
IMAPPARSEDREPLY *ret_reply = NULL;
char *pline = NULL;
int linelen = 0;
int bytes_copied = 0;
int temp_body_buffer_size = 0;
int flags = 0;
- int allocated_buffer_size = (BULK_PARTIAL_BODY_DOWNLOAD_COUNT + 2) * PARTIAL_BODY_SIZE_IN_BYTES ;
+ int allocated_buffer_size = (BULK_PARTIAL_BODY_DOWNLOAD_COUNT + 2) * input_download_size ;
- retPartialBuffer = (emf_partial_buffer *)em_malloc(sizeof(emf_partial_buffer));
+ retPartialBuffer = (email_partial_buffer *)em_malloc(sizeof(email_partial_buffer));
if (NULL == retPartialBuffer){
EM_DEBUG_EXCEPTION("em_malloc failed");
temp_body_buffer_size = temp_body_buffer_size + linelen + 2;
}
- if (temp_body_buffer_size > PARTIAL_BODY_SIZE_IN_BYTES && !flags) {
- linelen = linelen - (temp_body_buffer_size - PARTIAL_BODY_SIZE_IN_BYTES);
- temp_body_buffer_size = PARTIAL_BODY_SIZE_IN_BYTES;
+ if (temp_body_buffer_size > input_download_size && !flags) {
+ linelen = linelen - (temp_body_buffer_size - input_download_size) + 2;
+ temp_body_buffer_size = input_download_size;
flags = 1;
}
- if (temp_body_buffer_size <= PARTIAL_BODY_SIZE_IN_BYTES) {
+ if (temp_body_buffer_size <= input_download_size) {
memcpy(retPartialBuffer->buffer + bytes_copied, pline, linelen);
bytes_copied += linelen;
memcpy(retPartialBuffer->buffer + bytes_copied, CRLF_STRING, 2);