4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
26 * This file contains the data structures and interfaces needed for application,
27 * to interact with email-service.
28 * @file email-api-mail.c
29 * @brief This file contains the data structures and interfaces of Message related Functionality provided by
36 #include "email-api.h"
37 #include "email-ipc.h"
38 #include "email-convert.h"
39 #include "email-core-utils.h"
40 #include "email-core-mail.h"
41 #include "email-core-smtp.h"
42 #include "email-storage.h"
43 #include "email-utilities.h"
46 #define DIR_SEPERATOR_CH '/'
50 EXPORT_API int email_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas)
52 EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count [%d], input_meeting_request [%p], input_from_eas [%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
54 EM_IF_NULL_RETURN_VALUE(input_mail_data, EMF_ERROR_INVALID_PARAM);
55 EM_IF_NULL_RETURN_VALUE(input_mail_data->account_id, EMF_ERROR_INVALID_PARAM);
56 EM_IF_NULL_RETURN_VALUE(input_mail_data->mailbox_name, EMF_ERROR_INVALID_PARAM);
58 if(input_attachment_count > 0 && !input_attachment_data_list) {
59 EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
60 return EMF_ERROR_INVALID_PARAM;
63 int err = EMF_ERROR_NONE;
65 char *mail_data_stream = NULL;
66 char *attachment_data_list_stream = NULL;
67 char *meeting_request_stream = NULL;
70 if(input_from_eas == 0) {
71 hAPI = emipc_create_email_api(_EMAIL_API_ADD_MAIL);
74 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
75 err = EMF_ERROR_NULL_VALUE;
80 mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, 1, &size);
82 if(!mail_data_stream) {
83 EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed");
84 err = EMF_ERROR_NULL_VALUE;
88 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size)) {
89 EM_DEBUG_EXCEPTION("emipc_add_parameter for head failed");
90 err = EMF_ERROR_OUT_OF_MEMORY;
94 /* emf_attachment_data_t */
95 attachment_data_list_stream = em_convert_attachment_data_to_byte_stream(input_attachment_data_list, input_attachment_count, &size);
97 if(!attachment_data_list_stream) {
98 EM_DEBUG_EXCEPTION("em_convert_attachment_data_to_byte_stream failed");
99 err = EMF_ERROR_NULL_VALUE;
103 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) {
104 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
105 err = EMF_ERROR_OUT_OF_MEMORY;
109 /* emf_meeting_request_t */
110 if ( input_mail_data->meeting_request_status != EMF_MAIL_TYPE_NORMAL ) {
111 meeting_request_stream = em_convert_meeting_req_to_byte_stream(input_meeting_request, &size);
113 if(!meeting_request_stream) {
114 EM_DEBUG_EXCEPTION("em_convert_meeting_req_to_byte_stream failed");
115 err = EMF_ERROR_NULL_VALUE;
119 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, meeting_request_stream, size)) {
120 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
121 err = EMF_ERROR_OUT_OF_MEMORY;
127 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int))) {
128 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
129 err = EMF_ERROR_OUT_OF_MEMORY;
134 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
135 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
136 err = EMF_ERROR_IPC_SOCKET_FAILURE;
140 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
142 if(err == EMF_ERROR_NONE) {
143 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &input_mail_data->mail_id); /* result mail_id */
144 emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), &input_mail_data->thread_id); /* result thread_id */
148 if((err = emcore_add_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMF_ERROR_NONE) {
149 EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err);
156 emipc_destroy_email_api(hAPI);
158 EM_SAFE_FREE(mail_data_stream);
159 EM_SAFE_FREE(attachment_data_list_stream);
161 EM_DEBUG_FUNC_END("err [%d]", err);
166 EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receipt_mail_id)
168 EM_DEBUG_FUNC_BEGIN("input_read_mail_id [%d], output_receipt_mail_id [%p]", input_read_mail_id, output_receipt_mail_id);
170 EM_IF_NULL_RETURN_VALUE(output_receipt_mail_id, EMF_ERROR_INVALID_PARAM);
172 int err = EMF_ERROR_NONE;
173 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_READ_RECEIPT);
175 EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
177 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_read_mail_id, sizeof(int))) {
178 EM_DEBUG_EXCEPTION("Add Param mail body Fail");
179 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
183 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
184 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
185 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
188 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
190 EM_DEBUG_LOG("err [%d]", err);
192 if(err == EMF_ERROR_NONE) {
193 /* Get receipt mail id */
194 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_receipt_mail_id);
195 EM_DEBUG_LOG("output_receipt_mail_id [%d]", *output_receipt_mail_id);
198 emipc_destroy_email_api(hAPI);
202 EM_DEBUG_FUNC_END("err [%d]", err);
207 int email_create_db_full()
209 int mailbox_index, mail_index, mailbox_count, mail_slot_size;
210 emstorage_mail_tbl_t mail_table_data = {0};
211 emf_mailbox_t *mailbox_list = NULL;
212 int err = EMF_ERROR_NONE;
214 if ( (err = email_open_db()) != EMF_ERROR_NONE) {
215 EM_DEBUG_EXCEPTION("email_open_db failed [%d]", err);
219 mail_table_data.subject = (char*) em_malloc(50);
220 mail_table_data.full_address_from = strdup("<dummy_from@nowhere.com>");
221 mail_table_data.full_address_to = strdup("<dummy_to@nowhere.com>");
222 mail_table_data.account_id =1;
223 mail_table_data.mailbox_name = (char*) em_malloc(250);
225 if( (err = email_get_mailbox_list_ex(1, -1, 0, &mailbox_list, &mailbox_count)) < EMF_ERROR_NONE) {
226 EM_DEBUG_EXCEPTION("email_get_mailbox_list_ex failed [%d]", err);
230 for(mailbox_index = 0; mailbox_index < mailbox_count; mailbox_index++) {
231 mail_slot_size= mailbox_list[mailbox_index].mail_slot_size;
232 for(mail_index = 0; mail_index < mail_slot_size; mail_index++) {
233 sprintf(mail_table_data.subject, "Subject #%d",mail_index);
234 strncpy(mail_table_data.mailbox_name, mailbox_list[mailbox_index].name, 250 - 1);
235 mail_table_data.mailbox_type = mailbox_list[mailbox_index].mailbox_type;
236 if( !emstorage_add_mail(&mail_table_data, 1, true, &err)) {
237 EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]",err);
245 if ( (err = email_close_db()) != EMF_ERROR_NONE) {
246 EM_DEBUG_EXCEPTION("email_close_db failed [%d]", err);
250 email_free_mailbox(&mailbox_list, mailbox_count);
252 EM_SAFE_FREE(mail_table_data.subject);
253 EM_SAFE_FREE(mail_table_data.mailbox_name);
254 EM_SAFE_FREE(mail_table_data.full_address_from);
255 EM_SAFE_FREE(mail_table_data.full_address_to);
260 EXPORT_API int email_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas)
262 EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count [%d], input_meeting_request [%p], input_from_eas [%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
264 EM_IF_NULL_RETURN_VALUE(input_mail_data, EMF_ERROR_INVALID_PARAM);
265 EM_IF_NULL_RETURN_VALUE(input_mail_data->account_id, EMF_ERROR_INVALID_PARAM);
266 EM_IF_NULL_RETURN_VALUE(input_mail_data->mailbox_name, EMF_ERROR_INVALID_PARAM);
268 if(input_attachment_count > 0 && !input_attachment_data_list) {
269 EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
270 return EMF_ERROR_INVALID_PARAM;
273 int err = EMF_ERROR_NONE;
275 char *mail_data_stream = NULL;
276 char *attachment_data_list_stream = NULL;
277 char *meeting_request_stream = NULL;
279 HIPC_API hAPI = NULL;
281 if(input_from_eas == 0) {
282 hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_MAIL);
285 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
286 err = EMF_ERROR_NULL_VALUE;
290 /* emf_mail_data_t */
291 mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, 1, &size);
293 if(!mail_data_stream) {
294 EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed");
295 err = EMF_ERROR_NULL_VALUE;
299 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size)) {
300 EM_DEBUG_EXCEPTION("emipc_add_parameter for head failed");
301 err = EMF_ERROR_OUT_OF_MEMORY;
305 /* emf_attachment_data_t */
306 attachment_data_list_stream = em_convert_attachment_data_to_byte_stream(input_attachment_data_list, input_attachment_count, &size);
308 if(!attachment_data_list_stream) {
309 EM_DEBUG_EXCEPTION("em_convert_attachment_data_to_byte_stream failed");
310 err = EMF_ERROR_NULL_VALUE;
314 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) {
315 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
316 err = EMF_ERROR_OUT_OF_MEMORY;
320 /* emf_meeting_request_t */
321 if ( input_mail_data->meeting_request_status != EMF_MAIL_TYPE_NORMAL ) {
322 meeting_request_stream = em_convert_meeting_req_to_byte_stream(input_meeting_request, &size);
324 if(!meeting_request_stream) {
325 EM_DEBUG_EXCEPTION("em_convert_meeting_req_to_byte_stream failed");
326 err = EMF_ERROR_NULL_VALUE;
330 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, meeting_request_stream, size)) {
331 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
332 err = EMF_ERROR_OUT_OF_MEMORY;
338 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int))) {
339 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
340 err = EMF_ERROR_OUT_OF_MEMORY;
345 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
346 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
347 err = EMF_ERROR_IPC_SOCKET_FAILURE;
351 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
353 if(err == EMF_ERROR_NONE) {
354 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &input_mail_data->mail_id);
355 emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), &input_mail_data->thread_id);
359 if( (err = emcore_update_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMF_ERROR_NONE) {
360 EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err);
367 emipc_destroy_email_api(hAPI);
369 EM_SAFE_FREE(mail_data_stream);
370 EM_SAFE_FREE(attachment_data_list_stream);
372 EM_DEBUG_FUNC_END("err [%d]", err);
377 EXPORT_API int email_clear_mail_data()
379 EM_DEBUG_FUNC_BEGIN();
380 int err = EMF_ERROR_NONE;
382 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_CLEAR_DATA);
384 EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
386 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
387 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api Fail");
388 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
390 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
393 emipc_destroy_email_api(hAPI);
395 EM_DEBUG_FUNC_END("err [%d]", err);
400 EXPORT_API int email_count_message(emf_mailbox_t* mailbox, int* total, int* unseen)
402 EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p], unseen[%p]", mailbox, total, unseen);
406 int err = EMF_ERROR_NONE;
408 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
409 EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM);
410 EM_IF_NULL_RETURN_VALUE(unseen, EMF_ERROR_INVALID_PARAM);
412 if (!emstorage_get_mail_count(mailbox->account_id, mailbox->name, &total_count, &unread, true, &err)) {
413 EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed");
416 *total = total_count;
419 EM_DEBUG_FUNC_END("err [%d]", err);
426 EXPORT_API int email_count_message_all_mailboxes(emf_mailbox_t* mailbox, int* total, int* unseen)
428 EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p], unseen[%p]", mailbox, total, unseen);
432 int err = EMF_ERROR_NONE;
434 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
435 EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM);
436 EM_IF_NULL_RETURN_VALUE(unseen, EMF_ERROR_INVALID_PARAM);
437 EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
439 if (!emstorage_get_mail_count(mailbox->account_id, NULL, &total_count, &unread, true, &err)) {
440 EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed");
443 *total = total_count;
446 EM_DEBUG_FUNC_END("err [%d]", err);
452 EXPORT_API int email_delete_message(emf_mailbox_t* mailbox, int *mail_ids, int num, int from_server)
454 EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%p], num[%d], from_server[%d]", mailbox, mail_ids, num, from_server);
456 char* mailbox_stream = NULL;
458 int err = EMF_ERROR_NONE;
459 HIPC_API hAPI = NULL;
461 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
462 EM_IF_NULL_RETURN_VALUE(mail_ids, EMF_ERROR_INVALID_PARAM);
463 EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
466 EM_DEBUG_EXCEPTION("num = %d", num);
467 err = EMF_ERROR_INVALID_PARAM;
471 hAPI = emipc_create_email_api(_EMAIL_API_DELETE_MAIL);
474 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
475 err = EMF_ERROR_NULL_VALUE;
480 mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
482 if(!mailbox_stream) {
483 EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
484 err = EMF_ERROR_NULL_VALUE;
488 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
489 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
490 err = EMF_ERROR_OUT_OF_MEMORY;
494 /* Number of mail_ids */
495 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) {
496 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
497 err = EMF_ERROR_OUT_OF_MEMORY;
501 /* set of mail_ids */
502 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) {
503 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
504 err = EMF_ERROR_OUT_OF_MEMORY;
509 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&from_server, sizeof(int))) {
510 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
511 err = EMF_ERROR_OUT_OF_MEMORY;
515 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
516 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
517 err = EMF_ERROR_IPC_SOCKET_FAILURE;
521 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
525 emipc_destroy_email_api(hAPI);
527 EM_SAFE_FREE(mailbox_stream);
529 EM_DEBUG_FUNC_END("err [%d]", err);
534 EXPORT_API int email_delete_all_message_in_mailbox(emf_mailbox_t* mailbox, int from_server)
536 EM_DEBUG_FUNC_BEGIN("mailbox[%p], from_server[%d]", mailbox, from_server);
538 char* mailbox_stream = NULL;
540 int err = EMF_ERROR_NONE;
541 HIPC_API hAPI = NULL;
543 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
544 EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
546 hAPI =emipc_create_email_api(_EMAIL_API_DELETE_ALL_MAIL);
549 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
550 err = EMF_ERROR_NULL_VALUE;
554 mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
556 if(!mailbox_stream) {
557 EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
558 err = EMF_ERROR_NULL_VALUE;
562 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
563 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
564 err = EMF_ERROR_OUT_OF_MEMORY;
568 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&from_server, sizeof(int))){
569 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
570 err = EMF_ERROR_OUT_OF_MEMORY;
574 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
575 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
576 err = EMF_ERROR_IPC_SOCKET_FAILURE;
580 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int),&err );
585 emipc_destroy_email_api(hAPI);
587 EM_SAFE_FREE(mailbox_stream);
589 EM_DEBUG_FUNC_END("err [%d]", err);
595 EXPORT_API int email_add_attachment( emf_mailbox_t* mailbox, int mail_id, emf_attachment_info_t* attachment)
597 EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment[%p]", mailbox, mail_id, attachment);
598 int err = EMF_ERROR_NONE;
599 char* mailbox_stream = NULL;
600 char* pAttchStream = NULL;
602 HIPC_API hAPI = NULL;
604 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
605 EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
606 EM_IF_NULL_RETURN_VALUE(attachment, EMF_ERROR_INVALID_PARAM);
607 EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
609 hAPI = emipc_create_email_api(_EMAIL_API_ADD_ATTACHMENT);
612 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
613 err = EMF_ERROR_NULL_VALUE;
618 mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
620 if(!mailbox_stream) {
621 EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
622 err = EMF_ERROR_NULL_VALUE;
626 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
627 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
628 err = EMF_ERROR_OUT_OF_MEMORY;
633 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
634 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
635 err = EMF_ERROR_OUT_OF_MEMORY;
640 pAttchStream = em_convert_attachment_info_to_byte_stream(attachment, &size);
643 EM_DEBUG_EXCEPTION("em_convert_attachment_info_to_byte_stream failed");
644 err = EMF_ERROR_NULL_VALUE;
648 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pAttchStream, size)){
649 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
650 err = EMF_ERROR_OUT_OF_MEMORY;
655 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
656 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
657 err = EMF_ERROR_IPC_SOCKET_FAILURE;
661 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
663 if(EMF_ERROR_NONE == err) {
664 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &attachment->attachment_id);
668 EM_SAFE_FREE(mailbox_stream);
669 EM_SAFE_FREE(pAttchStream);
672 emipc_destroy_email_api(hAPI);
674 EM_DEBUG_FUNC_END("err [%d]", err);
679 EXPORT_API int email_delete_attachment(emf_mailbox_t * mailbox, int mail_id, const char *attachment_id)
681 EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment_id[%s]", mailbox, mail_id, attachment_id);
682 int err = EMF_ERROR_NONE;
683 char* mailbox_stream = NULL;
686 HIPC_API hAPI = NULL;
688 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
689 EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
690 EM_IF_NULL_RETURN_VALUE(attachment_id, EMF_ERROR_INVALID_PARAM);
692 hAPI = emipc_create_email_api(_EMAIL_API_DELETE_ATTACHMENT);
695 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
696 err = EMF_ERROR_NULL_VALUE;
701 mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
703 if(!mailbox_stream) {
704 EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
705 err = EMF_ERROR_NULL_VALUE;
709 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
710 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
711 err = EMF_ERROR_OUT_OF_MEMORY;
716 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
717 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
718 err = EMF_ERROR_OUT_OF_MEMORY;
723 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)attachment_id, strlen(attachment_id))) {
724 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
725 err = EMF_ERROR_OUT_OF_MEMORY;
730 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
731 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
732 err = EMF_ERROR_IPC_SOCKET_FAILURE;
736 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
740 emipc_destroy_email_api(hAPI);
742 EM_SAFE_FREE(mailbox_stream);
747 /* -----------------------------------------------------------
749 -----------------------------------------------------------*/
751 EXPORT_API int email_query_mails(char *conditional_clause_string, emf_mail_data_t** mail_list, int *result_count)
753 EM_DEBUG_FUNC_BEGIN("conditional_clause_string [%s], mail_list [%p], result_count [%p]", conditional_clause_string, mail_list, result_count);
755 int err = EMF_ERROR_NONE;
756 emstorage_mail_tbl_t *result_mail_tbl;
758 EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
759 EM_IF_NULL_RETURN_VALUE(conditional_clause_string, EMF_ERROR_INVALID_PARAM);
761 if (!emstorage_query_mail_tbl(conditional_clause_string, true, &result_mail_tbl, result_count, &err)) {
762 EM_DEBUG_EXCEPTION("emstorage_query_mail_list failed [%d]", err);
767 if(!em_convert_mail_tbl_to_mail_data(result_mail_tbl, *result_count, mail_list, &err)) {
768 EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_data failed [%d]", err);
773 if(result_mail_tbl && !emstorage_free_mail(&result_mail_tbl, *result_count, &err))
774 EM_DEBUG_EXCEPTION("emstorage_free_mail failed [%d]", err);
776 EM_DEBUG_FUNC_END("err [%d]", err);
780 EXPORT_API int email_query_message_ex(char *conditional_clause_string, emf_mail_list_item_t** mail_list, int *result_count)
782 EM_DEBUG_FUNC_BEGIN("conditional_clause_string [%s], mail_list [%p], result_count [%p]", conditional_clause_string, mail_list, result_count);
784 int err = EMF_ERROR_NONE;
786 EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
787 EM_IF_NULL_RETURN_VALUE(conditional_clause_string, EMF_ERROR_INVALID_PARAM);
789 if (!emstorage_query_mail_list(conditional_clause_string, true, mail_list, result_count, &err)) {
790 EM_DEBUG_EXCEPTION("emstorage_query_mail_list failed [%d]", err);
796 EM_DEBUG_FUNC_END("err [%d]", err);
801 /* -----------------------------------------------------------
803 -----------------------------------------------------------*/
804 EXPORT_API int email_get_attachment_info(emf_mailbox_t* mailbox, int mail_id, const char* attachment_id, emf_attachment_info_t** attachment)
806 EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment_id[%s], attachment[%p]", mailbox, mail_id, attachment_id, attachment);
808 int err = EMF_ERROR_NONE;
811 char* mailbox_stream = NULL;
812 char* pAttchStream = NULL;
813 emf_attachment_info_t* pAttch = NULL;
816 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
817 EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
818 EM_IF_NULL_RETURN_VALUE(attachment_id, EMF_ERROR_INVALID_PARAM);
819 EM_IF_NULL_RETURN_VALUE(attachment, EMF_ERROR_INVALID_PARAM);
820 EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
822 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_ATTACHMENT);
824 EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
827 mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
829 if(!mailbox_stream) {
830 EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
831 err = EMF_ERROR_NULL_VALUE;
835 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
836 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
837 err = EMF_ERROR_OUT_OF_MEMORY;
842 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
843 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
844 err = EMF_ERROR_OUT_OF_MEMORY;
850 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)attachment_id, strlen(attachment_id))) {
851 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
852 err = EMF_ERROR_OUT_OF_MEMORY;
857 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
858 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
859 err = EMF_ERROR_IPC_SOCKET_FAILURE;
863 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
865 if(EMF_ERROR_NONE == err) {
866 nSize = emipc_get_parameter_length(hAPI, ePARAMETER_OUT, 1);
868 pAttchStream = (char*)em_malloc(nSize+1);
871 EM_DEBUG_EXCEPTION("em_malloc failed");
872 err = EMF_ERROR_OUT_OF_MEMORY;
876 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, nSize, pAttchStream);
877 em_convert_byte_stream_to_attachment_info(pAttchStream, 1, &pAttch);
881 EM_DEBUG_EXCEPTION("EMF_ERROR_NULL_VALUE");
882 err = EMF_ERROR_NULL_VALUE;
886 *attachment = pAttch;
890 EM_SAFE_FREE(pAttchStream);
893 emipc_destroy_email_api(hAPI);
895 EM_DEBUG_FUNC_END("err [%d]", err);
900 EXPORT_API int email_get_attachment_data_list(int input_mail_id, emf_attachment_data_t **output_attachment_data, int *output_attachment_count)
902 EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], output_attachment_data[%p], output_attachment_count[%p]", input_mail_id, output_attachment_data, output_attachment_count);
903 int err = EMF_ERROR_NONE;
905 if((err = emcore_get_attachment_data_list(input_mail_id, output_attachment_data, output_attachment_count)) != EMF_ERROR_NONE) {
906 EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed [%d]", err);
909 EM_DEBUG_FUNC_END("err [%d]", err);
913 EXPORT_API int email_free_attachment_info(emf_attachment_info_t** atch_info)
915 EM_DEBUG_FUNC_BEGIN("atch_info[%p]", atch_info);
917 int err = EMF_ERROR_NONE;
919 if (!atch_info || !*atch_info)
920 return EMF_ERROR_INVALID_PARAM;
922 emf_attachment_info_t* p = *atch_info;
923 emf_attachment_info_t* t;
926 EM_SAFE_FREE(p->name);
927 EM_SAFE_FREE(p->savename);
932 EM_DEBUG_FUNC_END("err [%d]", err);
936 EXPORT_API int email_free_attachment_data(emf_attachment_data_t **attachment_data_list, int attachment_data_count)
938 EM_DEBUG_FUNC_BEGIN("attachment_data_list[%p], attachment_data_count[%d]", attachment_data_list, attachment_data_count);
940 int err = EMF_ERROR_NONE;
942 emcore_free_attachment_data(attachment_data_list, attachment_data_count, &err);
944 EM_DEBUG_FUNC_END("err [%d]", err);
949 EXPORT_API int email_get_mails(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_data_t** mail_list, int* result_count)
951 EM_DEBUG_FUNC_BEGIN();
953 int err = EMF_ERROR_NONE;
954 emstorage_mail_tbl_t *mail_tbl_list = NULL;
955 EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
957 if( account_id < ALL_ACCOUNT) {
958 EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
959 err = EMF_ERROR_INVALID_PARAM ;
963 if (!emstorage_get_mails(account_id, (char*)mailbox_name, NULL, thread_id, start_index, limit_count, sorting, true, &mail_tbl_list, result_count, &err)) {
964 EM_DEBUG_EXCEPTION("emstorage_get_mails failed [%d]", err);
969 if(!em_convert_mail_tbl_to_mail_data(mail_tbl_list, *result_count, mail_list, &err)) {
970 EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_data failed [%d]", err);
975 if(mail_tbl_list && !emstorage_free_mail(&mail_tbl_list, *result_count, &err))
976 EM_DEBUG_EXCEPTION("emstorage_free_mail failed [%d]", err);
978 EM_DEBUG_FUNC_END("err [%d]", err);
982 EXPORT_API int email_get_mail_list_ex(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count)
984 EM_DEBUG_FUNC_BEGIN();
986 int err = EMF_ERROR_NONE;
988 EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
990 if( account_id < ALL_ACCOUNT) {
991 EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
992 return EMF_ERROR_INVALID_PARAM;
995 if (!emstorage_get_mail_list(account_id, (char*) mailbox_name, NULL, thread_id, start_index, limit_count, 0, NULL, sorting, true, mail_list, result_count, &err)) {
996 EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err);
1002 EM_DEBUG_FUNC_END("err [%d]", err);
1006 EXPORT_API int email_find_mail (int account_id , const char *mailbox_name, int thread_id,
1007 int search_type, char *search_value, int start_index, int limit_count,
1008 emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count)
1010 EM_DEBUG_FUNC_BEGIN();
1012 int err = EMF_ERROR_NONE;
1014 emf_mail_list_item_t* mail_list_item = NULL;
1016 EM_IF_NULL_RETURN_VALUE(mail_list, EMF_ERROR_INVALID_PARAM);
1017 EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
1018 EM_IF_NULL_RETURN_VALUE(search_value, EMF_ERROR_INVALID_PARAM);
1020 switch ( search_type ) {
1021 case EMF_SEARCH_FILTER_SUBJECT:
1022 case EMF_SEARCH_FILTER_SENDER:
1023 case EMF_SEARCH_FILTER_RECIPIENT:
1024 case EMF_SEARCH_FILTER_ALL:
1027 EM_DEBUG_EXCEPTION("Invalid search filter type[%d]", search_type);
1028 err = EMF_ERROR_INVALID_PARAM;
1032 if (!emstorage_get_searched_mail_list(account_id, (char*)mailbox_name, thread_id, search_type, search_value, start_index, limit_count, sorting, true, &mail_list_item, &search_num, &err)) {
1033 EM_DEBUG_EXCEPTION("emstorage_search_mails -- Failed [%d]", err);
1038 *mail_list = mail_list_item;
1039 *result_count = search_num;
1042 EM_DEBUG_FUNC_END("err [%d]", err);
1046 EXPORT_API int email_get_mail_by_address(int account_id , const char *mailbox_name, emf_email_address_list_t* addr_list,
1047 int start_index, int limit_count, int search_type, const char *search_value, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count)
1049 EM_DEBUG_FUNC_BEGIN();
1050 int err = EMF_ERROR_NONE;
1052 emf_mail_list_item_t* mail_list_item = NULL;
1054 EM_IF_NULL_RETURN_VALUE(mail_list, EMF_ERROR_INVALID_PARAM);
1055 EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
1057 if( account_id < ALL_ACCOUNT) {
1058 EM_DEBUG_EXCEPTION("Invalid account id param");
1059 err = EMF_ERROR_INVALID_PARAM ;
1063 if (!emstorage_get_mail_list(account_id, (char*)mailbox_name, addr_list, EMF_LIST_TYPE_NORMAL, start_index, limit_count, search_type, search_value, sorting, true, &mail_list_item, result_count, &err)) {
1064 EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err);
1069 *mail_list = mail_list_item;
1072 EM_DEBUG_FUNC_END("err [%d]", err);
1076 EXPORT_API int email_get_thread_information_by_thread_id(int thread_id, emf_mail_data_t** thread_info)
1078 EM_DEBUG_FUNC_BEGIN();
1079 int err = EMF_ERROR_NONE;
1080 emstorage_mail_tbl_t *mail_table_data = NULL;
1082 EM_IF_NULL_RETURN_VALUE(thread_info, EMF_ERROR_INVALID_PARAM);
1084 if (!emstorage_get_thread_information(thread_id, &mail_table_data , true, &err)) {
1085 EM_DEBUG_EXCEPTION("emstorage_get_thread_information failed [%d]", err);
1089 if(!em_convert_mail_tbl_to_mail_data(mail_table_data, 1, thread_info, &err)) {
1090 EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_data failed [%d]", err);
1096 if(mail_table_data && !emstorage_free_mail(&mail_table_data, 1, &err))
1097 EM_DEBUG_EXCEPTION("emstorage_free_mail failed [%d]", err);
1099 EM_DEBUG_FUNC_END("err [%d]", err);
1103 EXPORT_API int email_get_thread_information_ex(int thread_id, emf_mail_list_item_t** thread_info)
1105 EM_DEBUG_FUNC_BEGIN();
1106 int err = EMF_ERROR_NONE;
1107 emstorage_mail_tbl_t *mail_table_data = NULL;
1108 emf_mail_list_item_t *temp_thread_info = NULL;
1110 EM_IF_NULL_RETURN_VALUE(thread_info, EMF_ERROR_INVALID_PARAM);
1112 if (!emstorage_get_thread_information(thread_id, &mail_table_data , true, &err)) {
1113 EM_DEBUG_EXCEPTION("emstorage_get_thread_information -- failed [%d]", err);
1117 temp_thread_info = em_malloc(sizeof(emf_mail_list_item_t));
1119 if(!temp_thread_info) {
1120 EM_DEBUG_EXCEPTION("em_malloc failed");
1121 err = EMF_ERROR_OUT_OF_MEMORY;
1125 EM_SAFE_STRNCPY(temp_thread_info->mailbox_name , mail_table_data->mailbox_name, STRING_LENGTH_FOR_DISPLAY);
1126 EM_SAFE_STRNCPY(temp_thread_info->from , mail_table_data->full_address_from, STRING_LENGTH_FOR_DISPLAY);
1127 EM_SAFE_STRNCPY(temp_thread_info->from_email_address , mail_table_data->email_address_sender, MAX_EMAIL_ADDRESS_LENGTH);
1128 EM_SAFE_STRNCPY(temp_thread_info->recipients , mail_table_data->email_address_recipient, STRING_LENGTH_FOR_DISPLAY);
1129 EM_SAFE_STRNCPY(temp_thread_info->subject , mail_table_data->subject, STRING_LENGTH_FOR_DISPLAY);
1130 EM_SAFE_STRNCPY(temp_thread_info->previewBodyText , mail_table_data->preview_text, MAX_PREVIEW_TEXT_LENGTH);
1131 temp_thread_info->mail_id = mail_table_data->mail_id;
1132 temp_thread_info->account_id = mail_table_data->account_id;
1133 temp_thread_info->date_time = mail_table_data->date_time;
1134 temp_thread_info->is_text_downloaded = mail_table_data->body_download_status;
1135 temp_thread_info->flags_seen_field = mail_table_data->flags_seen_field;
1136 temp_thread_info->priority = mail_table_data->priority;
1137 temp_thread_info->save_status = mail_table_data->save_status;
1138 temp_thread_info->is_locked = mail_table_data->lock_status;
1139 temp_thread_info->is_report_mail = mail_table_data->report_status;
1140 temp_thread_info->has_attachment = mail_table_data->attachment_count;
1141 temp_thread_info->has_drm_attachment = mail_table_data->DRM_status;
1142 temp_thread_info->thread_id = mail_table_data->thread_id;
1143 temp_thread_info->thread_item_count = mail_table_data->thread_item_count;
1144 temp_thread_info->is_meeting_request = mail_table_data->meeting_request_status;
1146 *thread_info = temp_thread_info;
1151 emstorage_free_mail(&mail_table_data, 1, NULL);
1153 EM_DEBUG_FUNC_END("err [%d]", err);
1157 EXPORT_API int email_get_mail_data(int input_mail_id, emf_mail_data_t **output_mail_data)
1159 EM_DEBUG_FUNC_BEGIN();
1160 int err = EMF_ERROR_NONE;
1162 if ( ((err = emcore_get_mail_data(input_mail_id, output_mail_data)) != EMF_ERROR_NONE) || !output_mail_data)
1163 EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
1165 EM_DEBUG_FUNC_END("err [%d]", err);
1170 /* -----------------------------------------------------------
1172 -----------------------------------------------------------*/
1173 EXPORT_API int email_modify_mail_flag(int mail_id, emf_mail_flag_t new_flag, int onserver)
1175 EM_DEBUG_FUNC_BEGIN("mail_id[%d], on_server [ %d] ", mail_id, onserver);
1177 int err = EMF_ERROR_NONE;
1179 int i_flag, sticky = 0;
1181 if ( mail_id <= 0 || (onserver != 0 && onserver != 1) ) {
1182 EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
1183 return EMF_ERROR_INVALID_PARAM;
1186 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MODIFY_MAIL_FLAG);
1189 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
1190 err = EMF_ERROR_NULL_VALUE;
1195 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
1196 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1197 err = EMF_ERROR_OUT_OF_MEMORY;
1202 if(!em_convert_mail_flag_to_int(new_flag, &i_flag, &err)) {
1203 EM_DEBUG_EXCEPTION("em_convert_mail_flag_to_int failed ");
1207 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(i_flag), sizeof(int))) {
1208 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1209 err = EMF_ERROR_OUT_OF_MEMORY;
1213 sticky = new_flag.sticky;
1215 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(sticky), sizeof(int))) {
1216 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1217 err = EMF_ERROR_OUT_OF_MEMORY;
1222 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(onserver), sizeof(int))) {
1223 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1224 err = EMF_ERROR_OUT_OF_MEMORY;
1230 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
1231 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
1232 err = EMF_ERROR_IPC_SOCKET_FAILURE;
1236 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1240 emipc_destroy_email_api(hAPI);
1242 EM_DEBUG_FUNC_END("err [%d]", err);
1249 EXPORT_API int email_modify_seen_flag(int *mail_ids, int num, int seen_flag, int onserver)
1251 EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num[%d],seen_flag[%d], on_server [ %d]", mail_ids, num, seen_flag, onserver);
1252 EM_DEBUG_FUNC_END("EMF_ERROR_NOT_IMPLEMENTED");
1253 return EMF_ERROR_NOT_IMPLEMENTED;
1256 EXPORT_API int email_set_flags_field(int account_id, int *mail_ids, int num, emf_flags_field_type field_type, int value, int onserver)
1258 EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_ids[%p], num[%d], field_type [%d], seen_flag[%d], on_server [ %d]", account_id, mail_ids, num, field_type, value, onserver);
1260 int err = EMF_ERROR_NONE;
1263 EM_IF_NULL_RETURN_VALUE(mail_ids, EMF_ERROR_INVALID_PARAM);
1264 if (account_id == 0 || num <= 0 || (onserver != 0 && onserver != 1)) {
1265 EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
1266 return EMF_ERROR_INVALID_PARAM;
1269 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_FLAGS_FIELD);
1272 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
1273 err = EMF_ERROR_NULL_VALUE;
1278 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
1279 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1280 err = EMF_ERROR_OUT_OF_MEMORY;
1284 /* Number of mail_ids */
1285 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) {
1286 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1287 err = EMF_ERROR_OUT_OF_MEMORY;
1291 /* set of mail_ids */
1292 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) {
1293 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1294 err = EMF_ERROR_OUT_OF_MEMORY;
1299 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&field_type, sizeof(int))) {
1300 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1301 err = EMF_ERROR_OUT_OF_MEMORY;
1306 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&value, sizeof(int))) {
1307 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1308 err = EMF_ERROR_OUT_OF_MEMORY;
1313 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(onserver), sizeof(int))) {
1314 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1315 err = EMF_ERROR_OUT_OF_MEMORY;
1320 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
1321 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
1322 err = EMF_ERROR_IPC_SOCKET_FAILURE;
1326 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1330 emipc_destroy_email_api(hAPI);
1332 EM_DEBUG_FUNC_END("err [%d]", err);
1336 EXPORT_API int email_modify_extra_mail_flag(int mail_id, emf_extra_flag_t new_flag)
1338 EM_DEBUG_FUNC_BEGIN("mail_id[%d]", mail_id);
1341 int err = EMF_ERROR_NONE;
1342 char* pMailExtraFlagsStream = NULL;
1345 EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
1347 pMailExtraFlagsStream = em_convert_extra_flags_to_byte_stream(new_flag, &size);
1349 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MODIFY_MAIL_EXTRA_FLAG);
1352 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
1353 err = EMF_ERROR_NULL_VALUE;
1358 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
1359 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
1360 err = EMF_ERROR_OUT_OF_MEMORY;
1364 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pMailExtraFlagsStream, size)) {
1365 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
1366 err = EMF_ERROR_OUT_OF_MEMORY;
1371 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
1372 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
1373 err = EMF_ERROR_IPC_SOCKET_FAILURE;
1377 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1380 emipc_destroy_email_api(hAPI);
1381 EM_SAFE_FREE(pMailExtraFlagsStream);
1383 EM_DEBUG_FUNC_END("err [%d]", err);
1390 /* -----------------------------------------------------------
1392 -----------------------------------------------------------*/
1393 EXPORT_API int email_move_mail_to_mailbox(int *mail_ids, int num, emf_mailbox_t* mailbox)
1395 EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num [%d], mailbox[%p]", mail_ids, num, mailbox);
1398 char* mailbox_stream = NULL;
1399 int err = EMF_ERROR_NONE;
1400 HIPC_API hAPI = NULL;
1403 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
1404 EM_IF_NULL_RETURN_VALUE(mail_ids, EMF_ERROR_INVALID_PARAM);
1405 EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
1408 EM_DEBUG_LOG("num = %d", num);
1409 err = EMF_ERROR_INVALID_PARAM;
1413 hAPI = emipc_create_email_api(_EMAIL_API_MOVE_MAIL);
1416 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
1417 err = EMF_ERROR_NULL_VALUE;
1421 /* Number of mail_ids */
1422 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) {
1423 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1424 err = EMF_ERROR_OUT_OF_MEMORY;
1428 /* set of mail_ids */
1429 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) {
1430 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1431 err = EMF_ERROR_OUT_OF_MEMORY;
1436 mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
1438 if(!mailbox_stream) {
1439 EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
1440 err = EMF_ERROR_NULL_VALUE;
1444 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
1445 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1446 err = EMF_ERROR_OUT_OF_MEMORY;
1451 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
1452 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
1453 err = EMF_ERROR_IPC_SOCKET_FAILURE;
1457 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1460 EM_SAFE_FREE(mailbox_stream);
1463 emipc_destroy_email_api(hAPI);
1465 EM_DEBUG_FUNC_END("err [%d]", err);
1470 EXPORT_API int email_move_all_mails_to_mailbox(emf_mailbox_t* src_mailbox, emf_mailbox_t* new_mailbox)
1472 EM_DEBUG_FUNC_BEGIN("src_mailbox[%p] , new_mailbox[%p]", src_mailbox, new_mailbox);
1475 int err = EMF_ERROR_NONE;
1476 char *dest_mailbox_stream = NULL;
1477 char *source_mailbox_stream = NULL;
1478 HIPC_API hAPI = NULL;
1481 EM_IF_NULL_RETURN_VALUE(src_mailbox, EMF_ERROR_INVALID_PARAM);
1482 EM_IF_NULL_RETURN_VALUE(new_mailbox, EMF_ERROR_INVALID_PARAM);
1483 EM_IF_ACCOUNT_ID_NULL(new_mailbox->account_id, EMF_ERROR_INVALID_PARAM);
1484 EM_IF_ACCOUNT_ID_NULL(src_mailbox->account_id, EMF_ERROR_INVALID_PARAM);
1486 hAPI = emipc_create_email_api(_EMAIL_API_MOVE_ALL_MAIL);
1489 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
1490 err = EMF_ERROR_NULL_VALUE;
1494 /* Src Mailbox Information */
1495 source_mailbox_stream = em_convert_mailbox_to_byte_stream(src_mailbox, &size);
1497 if(!source_mailbox_stream) {
1498 EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
1499 err = EMF_ERROR_NULL_VALUE;
1503 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, source_mailbox_stream, size)) {
1504 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1505 err = EMF_ERROR_OUT_OF_MEMORY;
1511 /* Dst Mailbox Information */
1512 dest_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size);
1514 if(!dest_mailbox_stream) {
1515 EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
1516 err = EMF_ERROR_NULL_VALUE;
1520 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, dest_mailbox_stream, size)) {
1521 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1522 err = EMF_ERROR_OUT_OF_MEMORY;
1527 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
1528 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
1529 err = EMF_ERROR_IPC_SOCKET_FAILURE;
1533 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1536 EM_SAFE_FREE(source_mailbox_stream);
1537 EM_SAFE_FREE(dest_mailbox_stream);
1540 emipc_destroy_email_api(hAPI);
1542 EM_DEBUG_FUNC_END("err [%d]", err);
1548 EXPORT_API int email_count_message_with_draft_flag(emf_mailbox_t* mailbox, int* total)
1550 EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p]", mailbox, total);
1552 int err = EMF_ERROR_NONE;
1553 int total_count = 0;
1555 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
1556 EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM);
1558 if (!emstorage_get_mail_count_with_draft_flag(mailbox->account_id, mailbox->name, &total_count, false, &err)) {
1559 EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed");
1562 *total = total_count;
1564 EM_DEBUG_FUNC_END("err [%d]", err);
1569 EXPORT_API int email_count_message_on_sending(emf_mailbox_t* mailbox, int* total)
1571 EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p]", mailbox, total);
1572 int err = EMF_ERROR_NONE;
1573 int total_count = 0;
1576 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
1577 EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM);
1579 if (!emstorage_get_mail_count_on_sending(mailbox->account_id, mailbox->name, &total_count, false, &err)) {
1580 EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed");
1583 *total = total_count;
1584 EM_DEBUG_FUNC_END("err [%d]", err);
1591 * @fn email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag)
1592 * @brief Get the Mail Flag information based on the account id and Mail Id.
1594 * @param[in] account_id Specifies the Account ID
1595 * @param[in] mail_id Specifies the Mail id for which Flag details need to be fetched
1596 * @param[in/out] mail_flag Specifies the Pointer to the structure emf_mail_flag_t.
1598 * @return True on Success, False on Failure.
1600 EXPORT_API int email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag)
1602 EM_DEBUG_FUNC_BEGIN();
1604 int err = EMF_ERROR_NONE;
1606 if (account_id < FIRST_ACCOUNT_ID|| mail_id < 1 || mail_flag == NULL) {
1607 EM_DEBUG_EXCEPTION("Invalid Param");
1608 err = EMF_ERROR_INVALID_PARAM ;
1612 /* Fetch the flag Information */
1613 if (!emcore_fetch_flags(account_id, mail_id, mail_flag, &err)) {
1614 EM_DEBUG_EXCEPTION("emcore_fetch_flags Failed [%d]", err);
1618 EM_DEBUG_FUNC_END("err [%d]", err);
1624 EXPORT_API int email_free_mail_data(emf_mail_data_t** mail_list, int count)
1626 EM_DEBUG_FUNC_BEGIN("mail_list[%p], count[%d]", mail_list, count);
1627 int err = EMF_ERROR_NONE;
1628 emcore_free_mail_data(mail_list, count, &err);
1629 EM_DEBUG_FUNC_END("err [%d]", err);
1633 /* Convert Modified UTF-7 mailbox name to UTF-8 */
1634 /* returns modified UTF-8 Name if success else NULL */
1636 EXPORT_API int email_cancel_send_mail( int mail_id)
1638 EM_DEBUG_FUNC_BEGIN("Mail ID [ %d]", mail_id);
1639 EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
1641 int err = EMF_ERROR_NONE;
1643 emf_mail_data_t* mail_data = NULL;
1645 HIPC_API hAPI = NULL;
1648 if ((err = emcore_get_mail_data(mail_id, &mail_data)) != EMF_ERROR_NONE) {
1649 EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
1654 EM_DEBUG_EXCEPTION("mail_data is null");
1655 err = EMF_ERROR_NULL_VALUE;
1659 account_id = mail_data->account_id;
1661 hAPI = emipc_create_email_api(_EMAIL_API_SEND_MAIL_CANCEL_JOB);
1664 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
1665 err = EMF_ERROR_NULL_VALUE;
1670 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
1671 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1672 err = EMF_ERROR_OUT_OF_MEMORY;
1677 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
1678 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1679 err = EMF_ERROR_OUT_OF_MEMORY;
1684 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
1685 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
1686 err = EMF_ERROR_IPC_SOCKET_FAILURE;
1690 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1694 emipc_destroy_email_api(hAPI);
1696 if ( !emcore_free_mail_data(&mail_data, 1, &err))
1697 EM_DEBUG_EXCEPTION("emcore_free_mail_data Failed [%d ] ", err);
1699 EM_DEBUG_FUNC_END("err [%d]", err);
1704 * EmfSendCancel - Callback function for cm popup. We set the status as EMF_MAIL_STATUS_NONE
1709 EXPORT_API int email_retry_send_mail( int mail_id, int timeout_in_sec)
1711 EM_DEBUG_FUNC_BEGIN();
1713 int err = EMF_ERROR_NONE;
1716 EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
1717 if( timeout_in_sec < 0 ) {
1718 EM_DEBUG_EXCEPTION("Invalid timeout_in_sec");
1719 err = EMF_ERROR_INVALID_PARAM;
1723 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SEND_RETRY);
1726 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
1727 err = EMF_ERROR_NULL_VALUE;
1732 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
1733 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1734 err = EMF_ERROR_OUT_OF_MEMORY;
1739 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(timeout_in_sec), sizeof(int))) {
1740 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
1741 err = EMF_ERROR_OUT_OF_MEMORY;
1746 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
1747 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
1748 err = EMF_ERROR_IPC_SOCKET_FAILURE;
1752 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1756 emipc_destroy_email_api(hAPI);
1758 EM_DEBUG_FUNC_END("err [%d]", err);
1763 EXPORT_API int email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name)
1765 EM_DEBUG_FUNC_BEGIN();
1767 int err = EMF_ERROR_NONE;
1768 char* mailbox_name = NULL;
1769 emstorage_mail_tbl_t* mail_table_data = NULL;
1772 EM_DEBUG_EXCEPTION("mail_id is not valid");
1773 err= EMF_ERROR_INVALID_PARAM;
1776 EM_IF_NULL_RETURN_VALUE(pMailbox_name, EMF_ERROR_INVALID_PARAM);
1778 if(!emstorage_get_mail_by_id(mail_id, &mail_table_data, true, &err)) {
1779 EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
1784 if(mail_table_data->mailbox_name)
1785 mailbox_name = strdup(mail_table_data->mailbox_name);
1787 *pMailbox_name = mailbox_name;
1790 if(mail_table_data) {
1791 emstorage_free_mail(&mail_table_data, 1, &err);
1794 EM_DEBUG_FUNC_END("err [%d]", err);
1799 EXPORT_API int email_get_latest_unread_mail_id(int account_id, int *pMailID)
1801 EM_DEBUG_FUNC_BEGIN();
1803 int err = EMF_ERROR_NONE;
1805 if( (!pMailID) ||(account_id <= 0 && account_id != -1)) {
1806 err = EMF_ERROR_INVALID_PARAM;
1809 if(!emstorage_get_latest_unread_mailid(account_id,pMailID, &err)) {
1810 EM_DEBUG_LOG("emstorage_get_latest_unread_mailid - failed");
1813 EM_DEBUG_FUNC_END("err [%d]", err);
1817 EXPORT_API int email_get_max_mail_count(int *Count)
1819 EM_DEBUG_FUNC_BEGIN();
1820 int err = EMF_ERROR_NONE;
1821 EM_IF_NULL_RETURN_VALUE(Count, EMF_ERROR_INVALID_PARAM);
1822 *Count = emstorage_get_max_mail_count();
1823 EM_DEBUG_FUNC_END("err [%d]", err);
1829 /* for setting application,disk usage of email in KB */
1830 EXPORT_API int email_get_disk_space_usage(unsigned long *total_size)
1832 EM_DEBUG_FUNC_BEGIN("total_size[%p]", total_size);
1833 int err = EMF_ERROR_NONE;
1835 EM_IF_NULL_RETURN_VALUE(total_size, EMF_ERROR_INVALID_PARAM);
1837 if (!emstorage_mail_get_total_diskspace_usage(total_size,true,&err)) {
1838 EM_DEBUG_EXCEPTION("emstorage_mail_get_total_diskspace_usage failed [%d]", err);
1843 EM_DEBUG_FUNC_END("err [%d]", err);
1847 EXPORT_API int email_get_recipients_list(int account_id, const char *mailbox_name, emf_sender_list_t **recipients_list)
1849 EM_DEBUG_FUNC_BEGIN("recipients_list[%p]", recipients_list);
1851 int number_of_mails, index;
1852 int number_of_recipients;
1855 emf_sender_list_t *temp_recipients_list = NULL;
1856 emf_sender_list_t *p_recipients_list = NULL;
1857 GList *addr_list = NULL, *temp_addr_list = NULL;
1858 emstorage_mail_tbl_t *mail_table_data = NULL;
1860 if (!emstorage_get_mails(account_id, (char*)mailbox_name, NULL, EMF_LIST_TYPE_NORMAL, -1, -1, EMF_SORT_SENDER_HIGH, true, &mail_table_data, &number_of_mails, &err)) {
1861 EM_DEBUG_EXCEPTION("emstorage_get_mails failed");
1866 for (index = 0; index < number_of_mails; index++) {
1867 addr_list = emcore_get_recipients_list(addr_list, mail_table_data[index].full_address_to, &err);
1868 addr_list = emcore_get_recipients_list(addr_list, mail_table_data[index].full_address_cc, &err);
1869 addr_list = emcore_get_recipients_list(addr_list, mail_table_data[index].full_address_bcc, &err);
1872 number_of_recipients = g_list_length(addr_list);
1874 p_recipients_list = (emf_sender_list_t *)malloc(sizeof(emf_sender_list_t) * number_of_recipients);
1875 if (p_recipients_list == NULL) {
1876 EM_DEBUG_EXCEPTION("malloc for emf_sender_list_t failed...");
1877 err = EMF_ERROR_OUT_OF_MEMORY;
1881 memset(p_recipients_list, 0x00, sizeof(emf_sender_list_t) * number_of_recipients);
1883 temp_addr_list = g_list_first(addr_list);
1885 while (temp_addr_list != NULL) {
1886 temp_recipients_list = (emf_sender_list_t *)temp_addr_list->data;
1887 p_recipients_list[index].address = temp_recipients_list->address;
1888 p_recipients_list[index].display_name = temp_recipients_list->display_name;
1889 p_recipients_list[index].total_count = temp_recipients_list->total_count + 1;
1890 EM_DEBUG_LOG("address[%s], display_name[%s], total_count[%d]", p_recipients_list[index].address, p_recipients_list[index].display_name, p_recipients_list[index].total_count);
1891 temp_addr_list = g_list_next(temp_addr_list);
1897 if (ret == true && recipients_list)
1898 *recipients_list = p_recipients_list; else if (p_recipients_list != NULL) {
1899 email_free_sender_list(&p_recipients_list, number_of_recipients);
1902 EM_DEBUG_FUNC_END();
1906 EXPORT_API int email_get_sender_list(int account_id, const char *mailbox_name, int search_type, const char *search_value, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count)
1908 EM_DEBUG_FUNC_BEGIN("sender_list[%p],sender_count[%p], sorting[%d]", sender_list, sender_count, sorting);
1910 int err = EMF_ERROR_NONE;
1912 emf_sender_list_t *temp_sender_list = NULL;
1914 EM_IF_NULL_RETURN_VALUE(sender_list, EMF_ERROR_INVALID_PARAM);
1915 EM_IF_NULL_RETURN_VALUE(sender_count, EMF_ERROR_INVALID_PARAM);
1916 if( account_id < ALL_ACCOUNT) {
1917 EM_DEBUG_EXCEPTION(" Invalid Account Id Param ");
1918 err = EMF_ERROR_INVALID_PARAM ;
1922 if ( !emstorage_get_sender_list(account_id, mailbox_name, search_type, search_value, sorting, &temp_sender_list, sender_count, &err) ) {
1923 EM_DEBUG_EXCEPTION("emstorage_get_sender_list failed [%d]", err);
1929 *sender_list = temp_sender_list;
1932 EM_DEBUG_FUNC_END("err [%d]", err);
1936 EXPORT_API int email_get_sender_list_ex(int account_id, const char *mailbox_name, int start_index, int limit_count, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count)
1938 return EMF_ERROR_NONE;
1941 EXPORT_API int email_free_sender_list(emf_sender_list_t **sender_list, int count)
1943 EM_DEBUG_FUNC_BEGIN("sender_list[%p], count[%d]", sender_list, count);
1945 int err = EMF_ERROR_NONE;
1948 if (!sender_list || !*sender_list) {
1949 EM_DEBUG_EXCEPTION("sender_list[%p], count[%d]", sender_list, count);
1950 err = EMF_ERROR_INVALID_PARAM;
1954 emf_sender_list_t* p = *sender_list;
1957 for (; i < count; i++) {
1958 EM_SAFE_FREE(p[i].address);
1959 EM_SAFE_FREE(p[i].display_name);
1963 *sender_list = NULL;
1965 EM_DEBUG_FUNC_END("err [%d]", err);
1969 EXPORT_API int email_get_address_info_list(int mail_id, emf_address_info_list_t** address_info_list)
1971 EM_DEBUG_FUNC_BEGIN("mail_id[%d], address_info_list[%p]", mail_id, address_info_list);
1973 int err = EMF_ERROR_NONE;
1975 emf_address_info_list_t *temp_address_info_list = NULL;
1977 EM_IF_NULL_RETURN_VALUE(address_info_list, EMF_ERROR_INVALID_PARAM);
1979 EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
1980 err = EMF_ERROR_INVALID_PARAM ;
1984 if ( !emcore_get_mail_address_info_list(mail_id, &temp_address_info_list, &err) ) {
1985 EM_DEBUG_EXCEPTION("emcore_get_mail_address_info_list failed [%d]", err);
1990 if ( address_info_list ) {
1991 *address_info_list = temp_address_info_list;
1992 temp_address_info_list = NULL;
1996 if ( temp_address_info_list )
1997 emstorage_free_address_info_list(&temp_address_info_list);
1998 EM_DEBUG_FUNC_END("err [%d]", err);
2002 EXPORT_API int email_free_address_info_list(emf_address_info_list_t **address_info_list)
2004 EM_DEBUG_FUNC_BEGIN("address_info_list[%p]", address_info_list);
2006 int err = EMF_ERROR_NONE;
2008 if ( (err = emstorage_free_address_info_list(address_info_list)) != EMF_ERROR_NONE ) {
2009 EM_DEBUG_EXCEPTION("address_info_list[%p] free failed.", address_info_list);
2011 EM_DEBUG_FUNC_END("err [%d]", err);
2015 EXPORT_API int email_get_structure(const char*encoded_string, void **struct_var, emf_convert_struct_type_e type)
2017 EM_DEBUG_FUNC_BEGIN("encoded_string[%s], struct_var[%p], type[%d]", encoded_string, struct_var, type);
2019 int err = EMF_ERROR_NONE;
2020 void * temp_struct = NULL;
2022 EM_IF_NULL_RETURN_VALUE(encoded_string, EMF_ERROR_INVALID_PARAM);
2023 EM_IF_NULL_RETURN_VALUE(struct_var, EMF_ERROR_INVALID_PARAM);
2025 if ( (err = emcore_convert_string_to_structure((char*)encoded_string, &temp_struct, type)) != EMF_ERROR_NONE ) {
2026 EM_DEBUG_EXCEPTION("emcore_convert_string_to_structure failed[%d]", err);
2031 *struct_var = temp_struct;
2034 EM_DEBUG_FUNC_END("err [%d]", err);
2038 EXPORT_API int email_get_meeting_request(int mail_id, emf_meeting_request_t **meeting_req)
2040 EM_DEBUG_FUNC_BEGIN("mail_id[%d],meeting_req[%p]", mail_id, meeting_req);
2042 int err = EMF_ERROR_NONE;
2044 emf_meeting_request_t *temp_meeting_req = NULL;
2046 EM_IF_NULL_RETURN_VALUE(meeting_req, EMF_ERROR_INVALID_PARAM);
2047 if( mail_id <= 0 ) {
2048 EM_DEBUG_EXCEPTION(" Invalid Mail Id Param ");
2049 err = EMF_ERROR_INVALID_PARAM ;
2053 if ( !emstorage_get_meeting_request(mail_id, &temp_meeting_req, 1, &err) ) {
2054 EM_DEBUG_EXCEPTION("emstorage_get_meeting_request -- Failed [%d]", err);
2060 *meeting_req = temp_meeting_req;
2063 EM_DEBUG_FUNC_END("err [%d]", err);
2067 EXPORT_API int email_free_meeting_request(emf_meeting_request_t** meeting_req, int count)
2069 EM_DEBUG_FUNC_BEGIN("meeting_req[%p], count[%d]", meeting_req, count);
2071 int err = EMF_ERROR_NONE;
2073 emstorage_free_meeting_request(meeting_req, count, &err);
2075 EM_DEBUG_FUNC_END("err [%d]", err);
2079 EXPORT_API int email_move_thread_to_mailbox(int thread_id, char *target_mailbox_name, int move_always_flag)
2081 EM_DEBUG_FUNC_BEGIN("thread_id[%d], target_mailbox_name[%p], move_always_flag[%d]", thread_id, target_mailbox_name, move_always_flag);
2082 int err = EMF_ERROR_NONE;
2085 EM_IF_NULL_RETURN_VALUE(target_mailbox_name, EMF_ERROR_INVALID_PARAM);
2087 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MOVE_THREAD_TO_MAILBOX);
2090 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
2091 err = EMF_ERROR_NULL_VALUE;
2096 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))){
2097 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
2098 err = EMF_ERROR_OUT_OF_MEMORY;
2102 /* target mailbox information */
2103 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, target_mailbox_name, strlen(target_mailbox_name))){
2104 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
2105 err = EMF_ERROR_OUT_OF_MEMORY;
2109 /* move_always_flag */
2110 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&move_always_flag, sizeof(int))){
2111 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
2112 err = EMF_ERROR_OUT_OF_MEMORY;
2117 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
2118 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
2119 err = EMF_ERROR_IPC_SOCKET_FAILURE;
2123 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
2127 emipc_destroy_email_api(hAPI);
2129 EM_DEBUG_FUNC_END("err [%d]", err);
2133 EXPORT_API int email_delete_thread(int thread_id, int delete_always_flag)
2135 EM_DEBUG_FUNC_BEGIN("thread_id[%d], delete_always_flag[%d]", thread_id, delete_always_flag);
2136 int err = EMF_ERROR_NONE;
2138 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_THREAD);
2141 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
2142 err = EMF_ERROR_NULL_VALUE;
2147 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))){
2148 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
2149 err = EMF_ERROR_OUT_OF_MEMORY;
2153 /* delete_always_flag */
2154 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&delete_always_flag, sizeof(int))){
2155 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
2156 err = EMF_ERROR_OUT_OF_MEMORY;
2161 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
2162 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
2163 err = EMF_ERROR_IPC_SOCKET_FAILURE;
2167 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
2171 emipc_destroy_email_api(hAPI);
2173 EM_DEBUG_FUNC_END("err [%d]", err);
2177 EXPORT_API int email_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server)
2179 EM_DEBUG_FUNC_BEGIN("thread_id[%d], seen_flag[%d], on_server[%d]", thread_id, seen_flag, on_server);
2180 int err = EMF_ERROR_NONE;
2181 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD);
2184 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
2185 err = EMF_ERROR_NULL_VALUE;
2190 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))) {
2191 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
2192 err = EMF_ERROR_OUT_OF_MEMORY;
2197 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&seen_flag, sizeof(int))) {
2198 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
2199 err = EMF_ERROR_OUT_OF_MEMORY;
2204 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&on_server, sizeof(int))) {
2205 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
2206 err = EMF_ERROR_OUT_OF_MEMORY;
2211 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
2212 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
2213 err = EMF_ERROR_IPC_SOCKET_FAILURE;
2217 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
2221 emipc_destroy_email_api(hAPI);
2222 EM_DEBUG_FUNC_END("err [%d]", err);