From: Sunghyun Kwon Date: Sun, 9 Sep 2012 07:23:15 +0000 (+0900) Subject: Fixed the missed attachment X-Git-Tag: submit/submit/20141001.115906~33^2~58 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74bbdf734b9f9f18be95d87c6c02efe377d9d427;p=platform%2Fframework%2Fnative%2Fmessaging.git Fixed the missed attachment --- diff --git a/email-api/email-api-mail.c b/email-api/email-api-mail.c index 5781c22..fe52b73 100755 --- a/email-api/email-api-mail.c +++ b/email-api/email-api-mail.c @@ -79,7 +79,7 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme } /* email_mail_data_t */ - mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, &size); + mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, 1, &size); if(!mail_data_stream) { EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed"); @@ -270,7 +270,7 @@ EXPORT_API int email_update_mail(email_mail_data_t *input_mail_data, email_attac } /* email_mail_data_t */ - mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, &size); + mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, 1, &size); if(!mail_data_stream) { EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed"); diff --git a/email-common-use/email-convert.c b/email-common-use/email-convert.c index 07834af..36d482f 100755 --- a/email-common-use/email-convert.c +++ b/email-common-use/email-convert.c @@ -997,6 +997,7 @@ INTERNAL_FUNC void em_convert_byte_stream_to_account(char *stream, int stream_le #define EMAIL_MAIL_DATA_FMT "S(" "iiiis" "iisss" "sssss" "sssss" "isssi"\ "ccccc" "cciii" "iiiii" "isiii" "i" ")" +#if 0 INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_data, int *stream_len) { EM_DEBUG_FUNC_END(); @@ -1018,7 +1019,9 @@ INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_ EM_DEBUG_FUNC_END(); return (char*) buf; -#if 0 +#endif +INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *input_mail_data, int input_mail_data_count, int *output_stream_size) +{ EM_DEBUG_FUNC_BEGIN("input_mail_data [%p], input_mail_data_count[%d], output_stream_size[%p]", input_mail_data, input_mail_data_count, output_stream_size); char *result_stream = NULL; @@ -1083,9 +1086,8 @@ INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_ EM_DEBUG_FUNC_END("stream_size [%d]", stream_size); return result_stream; -#endif } - +#if 0 INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_len, email_mail_data_t *mail_data) { EM_NULL_CHECK_FOR_VOID(stream); @@ -1099,7 +1101,9 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_ tpl_free(tn); EM_DEBUG_FUNC_END(); -#if 0 +#endif +INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *input_stream, email_mail_data_t **output_mail_data, int *output_mail_data_count) +{ EM_DEBUG_FUNC_BEGIN("input_stream [%p], output_mail_data[%p], output_mail_data_count[%p]", input_stream, output_mail_data, output_mail_data_count); int stream_offset = 0; @@ -1175,7 +1179,6 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_ } EM_DEBUG_FUNC_END(); -#endif } @@ -1183,6 +1186,7 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_ INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(email_attachment_data_t *attachment, int attachment_count, int* stream_len) { +#if 0 EM_DEBUG_FUNC_BEGIN(); EM_IF_NULL_RETURN_VALUE(stream_len, NULL); if(!attachment) { @@ -1216,42 +1220,43 @@ INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(email_attachment_d EM_DEBUG_FUNC_END(); return (char*) buf; +#endif -#if 0 - EM_DEBUG_FUNC_BEGIN("input_attachment_data [%p], input_attachment_count [%d], output_stream_size [%p]", input_attachment_data, input_attachment_count, output_stream_size); + EM_DEBUG_FUNC_BEGIN("attachment [%p], input_attachment_count [%d], output_stream_size [%p]", attachment, attachment_count, stream_len); char *result_stream = NULL; int stream_size = 0; int i = 0; - if(input_attachment_count > 0) - EM_IF_NULL_RETURN_VALUE(input_attachment_data, NULL); - EM_IF_NULL_RETURN_VALUE(output_stream_size, NULL); + if(attachment_count > 0) + EM_IF_NULL_RETURN_VALUE(attachment, NULL); + EM_IF_NULL_RETURN_VALUE(stream_len, NULL); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_count, sizeof(int)); - - for(i = 0; i < input_attachment_count; i++) { - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].attachment_id, sizeof(int)); - result_stream = append_string_to_stream(result_stream, &stream_size, input_attachment_data[i].attachment_name); - result_stream = append_string_to_stream(result_stream, &stream_size, input_attachment_data[i].attachment_path); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].attachment_size, sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].mail_id, sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].account_id, sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].mailbox_id, sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].save_status, sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].drm_status, sizeof(int)); - result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&input_attachment_data[i].inline_content_status,sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment_count, sizeof(int)); + + for(i = 0; i < attachment_count; i++) { + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].attachment_id, sizeof(int)); + result_stream = append_string_to_stream(result_stream, &stream_size, attachment[i].attachment_name); + result_stream = append_string_to_stream(result_stream, &stream_size, attachment[i].attachment_path); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].attachment_size, sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].mail_id, sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].account_id, sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].mailbox_id, sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].save_status, sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].drm_status, sizeof(int)); + result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&attachment[i].inline_content_status,sizeof(int)); } - *output_stream_size = stream_size; + *stream_len = stream_size; EM_DEBUG_FUNC_END("stream_size [%d]", stream_size); return result_stream; -#endif + } INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *stream, int stream_len, email_attachment_data_t **attachment_data, int *attachment_count) { +#if 0 EM_DEBUG_FUNC_BEGIN(); EM_NULL_CHECK_FOR_VOID(stream); EM_NULL_CHECK_FOR_VOID(attachment_data); @@ -1295,47 +1300,46 @@ INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *stream, int s *attachment_count = count; *attachment_data = attached; EM_DEBUG_FUNC_END(); -#if 0 - EM_DEBUG_FUNC_BEGIN("input_stream [%p], output_attachment_data[%p]", input_stream, output_attachment_data); +#endif + EM_DEBUG_FUNC_BEGIN("stream [%p], attachment_data[%p]", stream, attachment_data); int stream_offset = 0; int i = 0; - EM_NULL_CHECK_FOR_VOID(input_stream); - EM_NULL_CHECK_FOR_VOID(output_attachment_data); - EM_NULL_CHECK_FOR_VOID(output_attachment_count); + EM_NULL_CHECK_FOR_VOID(stream); + EM_NULL_CHECK_FOR_VOID(attachment_data); + EM_NULL_CHECK_FOR_VOID(attachment_count); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)output_attachment_count); + fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)attachment_count); - EM_DEBUG_LOG("*output_attachment_count [%d]", *output_attachment_count); + EM_DEBUG_LOG("*attachment_count [%d]", *attachment_count); - if(output_attachment_count <= 0) { + if(attachment_count <= 0) { EM_DEBUG_EXCEPTION("no attachment data."); return; } - *output_attachment_data = (email_attachment_data_t*)em_malloc(sizeof(email_attachment_data_t) * (*output_attachment_count)); + *attachment_data = (email_attachment_data_t*)em_malloc(sizeof(email_attachment_data_t) * (*attachment_count)); - if(!*output_attachment_data) { + if(!*attachment_data) { EM_DEBUG_EXCEPTION("em_malloc failed"); return; } - for(i = 0; i < *output_attachment_count; i++) { - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].attachment_id)); - fetch_string_from_stream(input_stream, &stream_offset, &(*output_attachment_data)[i].attachment_name); - fetch_string_from_stream(input_stream, &stream_offset, &(*output_attachment_data)[i].attachment_path); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].attachment_size)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].mail_id)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].account_id)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].mailbox_id)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].save_status)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].drm_status)); - fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&((*output_attachment_data)[i].inline_content_status)); + for(i = 0; i < *attachment_count; i++) { + fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].attachment_id)); + fetch_string_from_stream(stream, &stream_offset, &(*attachment_data)[i].attachment_name); + fetch_string_from_stream(stream, &stream_offset, &(*attachment_data)[i].attachment_path); + fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].attachment_size)); + fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].mail_id)); + fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].account_id)); + fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].mailbox_id)); + fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].save_status)); + fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].drm_status)); + fetch_sized_data_from_stream(stream, &stream_offset, sizeof(int), (char*)&((*attachment_data)[i].inline_content_status)); } EM_DEBUG_FUNC_END(); -#endif } diff --git a/email-common-use/include/email-convert.h b/email-common-use/include/email-convert.h index ba040f5..646b711 100755 --- a/email-common-use/include/email-convert.h +++ b/email-common-use/include/email-convert.h @@ -35,8 +35,8 @@ INTERNAL_FUNC int em_convert_account_tbl_to_account(emstorage_account_tbl_t *a /* Mail */ -INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_data, int *stream_size); -INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_len, email_mail_data_t *mail_data); +INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_data, int input_mail_data_count, int *stream_size); +INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, email_mail_data_t **mail_data, int *output_mail_data_count); INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_table_data, int item_count, email_mail_data_t **mail_data, int *error); INTERNAL_FUNC int em_convert_mail_data_to_mail_tbl(email_mail_data_t *mail_data, int item_count, emstorage_mail_tbl_t **mail_table_data, int *error); diff --git a/email-core/email-storage/email-storage.c b/email-core/email-storage/email-storage.c index cbf7fb6..79db260 100755 --- a/email-core/email-storage/email-storage.c +++ b/email-core/email-storage/email-storage.c @@ -10327,7 +10327,7 @@ INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_s if (nread > 0 && nread <= buf_size) { EM_DEBUG_LOG("Nread Value [%d]", nread); if ((nwritten = write(fp_dst, buf, nread)) != nread) { - EM_DEBUG_EXCEPTION("fwrite failed..."); + EM_DEBUG_EXCEPTION("fwrite failed... : [%d], Error:[%s]", nwritten, strerror(errno)); error = EMAIL_ERROR_UNKNOWN; goto FINISH_OFF; } diff --git a/email-daemon/main.c b/email-daemon/main.c index 97fda37..a12a0cc 100755 --- a/email-daemon/main.c +++ b/email-daemon/main.c @@ -1380,8 +1380,9 @@ void stb_add_mail(HIPC_API a_hAPI) int result_attachment_data_count = 0; int param_index = 0; int sync_server = 0; + int mail_count = 0; int err = EMAIL_ERROR_NONE; - email_mail_data_t result_mail_data = {0}; + email_mail_data_t *result_mail_data = NULL; email_attachment_data_t *result_attachment_data = NULL; email_meeting_request_t result_meeting_request = {0}; @@ -1393,7 +1394,7 @@ void stb_add_mail(HIPC_API a_hAPI) /* mail_data */ if(buffer_size > 0) { char *stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++); - em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data); + em_convert_byte_stream_to_mail_data(stream, &result_mail_data, &mail_count); } /* attachment */ @@ -1417,9 +1418,9 @@ void stb_add_mail(HIPC_API a_hAPI) /* meeting request */ EM_DEBUG_LOG("email_meeting_request_t"); - if ( result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST - || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE - || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { + if ( result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST + || result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE + || result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index); if(buffer_size > 0) { @@ -1431,7 +1432,7 @@ void stb_add_mail(HIPC_API a_hAPI) EM_DEBUG_LOG("sync_server"); emipc_get_parameter(a_hAPI, ePARAMETER_IN, param_index++, sizeof(int), &sync_server); - if( (err = emdaemon_add_mail(&result_mail_data, result_attachment_data, result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) { + if( (err = emdaemon_add_mail(result_mail_data, result_attachment_data, result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emdaemon_add_mail failed [%d]", err); goto FINISH_OFF; } @@ -1439,9 +1440,9 @@ void stb_add_mail(HIPC_API a_hAPI) local_result = 1; if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.mail_id, sizeof(int))) + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(result_mail_data->mail_id), sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.thread_id, sizeof(int))) + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(result_mail_data->thread_id), sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed"); @@ -1454,7 +1455,7 @@ FINISH_OFF: EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed"); } - emcore_free_mail_data(&result_mail_data); + emcore_free_mail_data(result_mail_data); if(result_attachment_data) emcore_free_attachment_data(&result_attachment_data, result_attachment_data_count, NULL); @@ -1581,9 +1582,10 @@ void stb_update_mail(HIPC_API a_hAPI) int result_attachment_data_count = 0; int param_index = 0; int sync_server = 0; + int mail_count = 0; int *temp_buffer = NULL; int err = EMAIL_ERROR_NONE; - email_mail_data_t result_mail_data = {0}; + email_mail_data_t *result_mail_data = NULL; email_attachment_data_t *result_attachment_data = NULL; email_meeting_request_t result_meeting_request = {0}; @@ -1592,7 +1594,7 @@ void stb_update_mail(HIPC_API a_hAPI) if(buffer_size > 0) { char* stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++); - em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data); + em_convert_byte_stream_to_mail_data(stream, &result_mail_data, &mail_count); } buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index); @@ -1615,9 +1617,9 @@ void stb_update_mail(HIPC_API a_hAPI) EM_DEBUG_LOG("email_meeting_request_t"); - if ( result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST - || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE - || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { + if ( result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST + || result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE + || result_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index); if(buffer_size > 0) { @@ -1637,7 +1639,7 @@ void stb_update_mail(HIPC_API a_hAPI) sync_server = *temp_buffer; - if( (err = emdaemon_update_mail(&result_mail_data, result_attachment_data, + if( (err = emdaemon_update_mail(result_mail_data, result_attachment_data, result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emdaemon_update_mail failed [%d]", err); goto FINISH_OFF; @@ -1646,9 +1648,9 @@ void stb_update_mail(HIPC_API a_hAPI) local_result = 1; if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.mail_id, sizeof(int))) + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(result_mail_data->mail_id), sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); - if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.thread_id, sizeof(int))) + if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(result_mail_data->thread_id), sizeof(int))) EM_DEBUG_EXCEPTION("emipc_add_parameter failed"); if (!emipc_execute_stub_api(a_hAPI)) EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed"); @@ -1661,7 +1663,7 @@ FINISH_OFF: EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed"); } - emcore_free_mail_data(&result_mail_data); + emcore_free_mail_data(result_mail_data); if(result_attachment_data) emcore_free_attachment_data(&result_attachment_data, result_attachment_data_count, NULL); diff --git a/packaging/email-service.spec b/packaging/email-service.spec index 369ff10..4daa1d9 100755 --- a/packaging/email-service.spec +++ b/packaging/email-service.spec @@ -1,6 +1,6 @@ Name: email-service Summary: E-mail Framework Middleware package -Version: 0.9.8 +Version: 0.9.9 Release: 1 Group: System/Libraries License: TBD