merged from tizen 2.4 24/54224/1 accepted/tizen/mobile/20151215.054252 accepted/tizen/tv/20151215.054321 accepted/tizen/wearable/20151215.054345 submit/tizen/20151215.020358
authorSunghyun Kwon <sh0701.kwon@samsung.com>
Mon, 14 Dec 2015 08:00:16 +0000 (17:00 +0900)
committerSunghyun Kwon <sh0701.kwon@samsung.com>
Mon, 14 Dec 2015 08:00:16 +0000 (17:00 +0900)
Change-Id: Ibd0a4848d902620e1587b823a1292ce18d987c27

email-common-use/tpl.c
email-core/email-core-mailbox.c
email-core/email-core-smtp.c
email-core/email-storage/email-storage.c

index 0ea7c84..627e33c 100644 (file)
@@ -309,12 +309,9 @@ char *calc_field_addr(tpl_node *parent, int type, char *struct_addr, int ordinal
         align_sz = tpl_types[type].sz;
         break;
     }
-       EM_DEBUG_LOG("prev->addr: [%p], struct_addr: [%p]", prev->addr, struct_addr);
     offset = ((uintptr_t)prev->addr - (uintptr_t)struct_addr)
             + (tpl_types[prev->type].sz * prev->num);
-       EM_DEBUG_LOG("offset: [%d], align_sz: [%d]", offset, align_sz);
     offset = (offset + align_sz - 1) / align_sz * align_sz;
-       EM_DEBUG_LOG("Real offset: [%d]", offset);
     return struct_addr + offset;
 }
 
index 2098dbf..54d569c 100755 (executable)
@@ -1667,7 +1667,7 @@ INTERNAL_FUNC int emcore_save_local_activity_sync(int account_id, int *err_code)
        if (activity_count > 0) {
                event_data = em_malloc(sizeof(email_event_t));
                if (!event_data) {
-                       EM_DEBUG_EXCEPTION("em_mallocfailed");
+                       EM_DEBUG_EXCEPTION("em_malloc failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
index aedc1ca..c3dc2f5 100755 (executable)
@@ -4670,7 +4670,7 @@ static int emcore_sending_alarm_cb(email_alarm_data_t *alarm_data, void *user_pa
 
        event_data = em_malloc(sizeof(email_event_t));
        if (event_data == NULL) {
-               EM_DEBUG_EXCEPTION("em_mallocfailed");
+               EM_DEBUG_EXCEPTION("em_malloc failed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -4778,9 +4778,12 @@ static int emcore_auto_resend_cb(email_alarm_data_t *alarm_data, void *user_para
        int filter_rule_count = 5;
        int sorting_rule_count = 2;
        int result_mail_count = 0;
+       int result_handle = 0;
        int i = 0;
        char *multi_user_name = (char *)user_parameter;
 
+       email_event_t *event_data = NULL;
+
        /* Get all mails have remaining resend counts in outbox with status 'EMAIL_MAIL_STATUS_SEND_FAILURE or EMAIL_MAIL_STATUS_SEND_WAIT' */
        attribute_field_name = emcore_get_mail_field_name_by_attribute_type(EMAIL_MAIL_ATTRIBUTE_REMAINING_RESEND_TIMES);
 
@@ -4827,20 +4830,53 @@ static int emcore_auto_resend_cb(email_alarm_data_t *alarm_data, void *user_para
        }
 
        /* Send mails in loop */
-
        for (i = 0; i < result_mail_count; i++) {
-               if (!emcore_send_mail(multi_user_name, result_mail_list[i].mail_id, &err)) {
-                       EM_DEBUG_EXCEPTION("emcore_send_mail failed [%d]", err);
+               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 = result_mail_list[i].account_id;
+               event_data->event_param_data_4 = result_mail_list[i].mail_id;
+               event_data->event_param_data_5 = result_mail_list[i].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_for_sending_mails failed : [%d]", err);
+                       goto FINISH_OFF;
                }
 
                if (attribute_field_name) {
-                       if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, result_mail_list[i].account_id, &(result_mail_list[i].mail_id), 1, attribute_field_name, result_mail_list[i].remaining_resend_times - 1, true, &err)) {
+                       if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name,
+                                                                                                                                       result_mail_list[i].account_id,
+                                                                                                                                       &(result_mail_list[i].mail_id),
+                                                                                                                                       1,
+                                                                                                                                       attribute_field_name,
+                                                                                                                                       result_mail_list[i].remaining_resend_times - 1,
+                                                                                                                                       true,
+                                                                                                                                       &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
                        }
                }
+
+               /* Do not free the event_data */
+               /* Because the event_data is freed in event_handler */
+               event_data = NULL;
+               err = EMAIL_ERROR_NONE;
        }
 
 FINISH_OFF:
+
+       if (err != EMAIL_ERROR_NONE) {
+               if (event_data) {
+                       emcore_free_event(event_data);
+                       EM_SAFE_FREE(event_data);
+               }
+       }
+
        EM_SAFE_FREE(conditional_clause_string); /* detected by valgrind */
        EM_SAFE_FREE(result_mail_list);
 
index 8181b02..e1fb35c 100755 (executable)
@@ -11558,6 +11558,7 @@ INTERNAL_FUNC int emstorage_get_save_name(char *multi_user_name, int account_id,
        char create_dir[1024] = {0};
        char *temp_file = NULL;
        char *prefix_path = NULL;
+       char *modified_fname = NULL;
 
        if (!move_buf || !path_buf || account_id < FIRST_ACCOUNT_ID || mail_id < 0 || atch_id < 0) {
                EM_DEBUG_EXCEPTION(" account_id[%d], mail_id[%d], atch_id[%d], fname[%p], move_buf[%p], path_buf[%p]", account_id, mail_id, atch_id, fname, move_buf, path_buf);
@@ -11590,7 +11591,14 @@ INTERNAL_FUNC int emstorage_get_save_name(char *multi_user_name, int account_id,
 
        if (fname) {
                EM_DEBUG_LOG_DEV(">>>>> fname [%s]", fname);
-               if (EM_SAFE_STRLEN(fname) + EM_SAFE_STRLEN(path_buf) + strlen(DIR_SEPERATOR) > maxlen - 1) {
+
+               /* Did not allow the slash */
+               modified_fname = reg_replace_new(fname, "/", "_");
+               EM_DEBUG_LOG("modified_fname : [%s]", modified_fname);
+
+               if (modified_fname == NULL) modified_fname = g_strdup(fname);
+
+               if (EM_SAFE_STRLEN(modified_fname) + EM_SAFE_STRLEN(path_buf) + strlen(DIR_SEPERATOR) > maxlen - 1) {
                        char *modified_name = NULL;
                        int remain_len  = (maxlen - 1) - EM_SAFE_STRLEN(path_buf) - strlen(DIR_SEPERATOR);
 
@@ -11603,7 +11611,7 @@ INTERNAL_FUNC int emstorage_get_save_name(char *multi_user_name, int account_id,
                                remain_len = MAX_FILENAME;
                        }
 
-                       modified_name = em_shrink_filename(fname, remain_len);
+                       modified_name = em_shrink_filename(modified_fname, remain_len);
 
                        if (!modified_name) {
                                error = EMAIL_ERROR_MAX_EXCEEDED;
@@ -11614,10 +11622,10 @@ INTERNAL_FUNC int emstorage_get_save_name(char *multi_user_name, int account_id,
                        EM_DEBUG_LOG(">>>>> Modified fname [%s]", modified_name);
                        EM_SAFE_FREE(modified_name);
                } else {
-                       if (EM_SAFE_STRLEN(fname) > MAX_FILENAME - 1) {
+                       if (EM_SAFE_STRLEN(modified_fname) > MAX_FILENAME - 1) {
                                char *modified_name = NULL;
 
-                               modified_name = em_shrink_filename(fname, MAX_FILENAME);
+                               modified_name = em_shrink_filename(modified_fname, MAX_FILENAME);
                                if (!modified_name) {
                                        error = EMAIL_ERROR_MAX_EXCEEDED;
                                        goto FINISH_OFF;
@@ -11627,7 +11635,7 @@ INTERNAL_FUNC int emstorage_get_save_name(char *multi_user_name, int account_id,
                                EM_DEBUG_LOG(">>>>> Modified fname [%s]", modified_name);
                                EM_SAFE_FREE(modified_name);
                        } else {
-                               sprintf(path_buf+EM_SAFE_STRLEN(path_buf), "%s%s", DIR_SEPERATOR, fname);
+                               sprintf(path_buf+EM_SAFE_STRLEN(path_buf), "%s%s", DIR_SEPERATOR, modified_fname);
                        }
                }
        }
@@ -11653,6 +11661,7 @@ FINISH_OFF:
 
        EM_SAFE_FREE(temp_file);
        EM_SAFE_FREE(prefix_path);
+       EM_SAFE_FREE(modified_fname);
 
        if (err_code != NULL)
                *err_code = error;