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;
}
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;
}
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;
}
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);
}
/* 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);
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);
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);
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;
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;
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);
}
}
}
EM_SAFE_FREE(temp_file);
EM_SAFE_FREE(prefix_path);
+ EM_SAFE_FREE(modified_fname);
if (err_code != NULL)
*err_code = error;