4 * Copyright (c) 2012 - 2013 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-network.c
29 * @brief This file contains the data structures and interfaces of Network related Functionality provided by
34 #include "email-convert.h"
35 #include "email-api-mailbox.h"
36 #include "email-types.h"
37 #include "email-core-signal.h"
38 #include "email-utilities.h"
39 #include "email-ipc.h"
40 #include "email-storage.h"
43 EXPORT_API int email_send_mail(int mail_id, int *handle)
45 EM_DEBUG_API_BEGIN("mail_id[%d] handle[%p]", mail_id, handle);
47 int err = EMAIL_ERROR_NONE;
48 char *multi_user_name = NULL;
49 emstorage_mail_tbl_t* mail_table_data = NULL;
50 email_account_server_t account_server_type;
52 ASNotiData as_noti_data;
54 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
56 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
62 EM_DEBUG_EXCEPTION("mail_id is not valid");
63 err = EMAIL_ERROR_INVALID_PARAM;
67 if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data) {
68 EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
72 if (mail_table_data->account_id <= 0) {
74 EM_DEBUG_EXCEPTION("EM_IF_ACCOUNT_ID_NULL: Account ID [ %d ] ", mail_table_data->account_id);
75 emstorage_free_mail(&mail_table_data, 1, NULL);
76 return EMAIL_ERROR_INVALID_PARAM;
80 EM_DEBUG_LOG("mail_table_data->account_id[%d], mail_table_data->mailbox_id[%d]", mail_table_data->account_id, mail_table_data->mailbox_id);
82 memset(&as_noti_data, 0x00, sizeof(ASNotiData));
84 /* check account bind type and branch off */
85 if (em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false) {
86 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
87 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
91 if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
93 if (em_get_handle_for_activesync(&as_handle, &err) == false) {
94 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
95 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
99 /* noti to active sync */
100 as_noti_data.send_mail.handle = as_handle;
101 as_noti_data.send_mail.account_id = mail_table_data->account_id;
102 as_noti_data.send_mail.mail_id = mail_id;
103 as_noti_data.send_mail.multi_user_name = multi_user_name;
105 if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL, &as_noti_data) == false) {
106 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
107 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
114 hAPI = emipc_create_email_api(_EMAIL_API_SEND_MAIL);
117 /* LCOV_EXCL_START */
118 EM_DEBUG_EXCEPTION("INVALID PARAM: hAPI NULL ");
119 emstorage_free_mail(&mail_table_data, 1, NULL);
120 return EMAIL_ERROR_NULL_VALUE;
125 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
126 /* LCOV_EXCL_START */
127 EM_DEBUG_EXCEPTION("email_send_mail--Add Param mail_id failed");
128 emstorage_free_mail(&mail_table_data, 1, NULL);
129 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
133 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
134 /* LCOV_EXCL_START */
135 EM_DEBUG_EXCEPTION("email_send_mail--emipc_execute_proxy_api failed ");
136 emstorage_free_mail(&mail_table_data, 1, NULL);
137 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_CRASH);
141 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
142 if (err == EMAIL_ERROR_NONE) {
144 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
149 emipc_destroy_email_api(hAPI);
150 hAPI = (HIPC_API)NULL;
152 emstorage_free_mail(&mail_table_data, 1, NULL);
154 EM_SAFE_FREE(multi_user_name);
156 EM_DEBUG_API_END("err[%d]", err);
160 EXPORT_API int email_send_mail_with_downloading_attachment_of_original_mail(int input_mail_id, int *output_handle)
162 EM_DEBUG_API_BEGIN("input_mail_id[%d] output_handle[%p]", input_mail_id, output_handle);
164 int err = EMAIL_ERROR_NONE;
165 char *multi_user_name = NULL;
166 emstorage_mail_tbl_t* mail_table_data = NULL;
167 email_account_server_t account_server_type;
168 HIPC_API hAPI = NULL;
169 task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL task_parameter;
171 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
172 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
176 if (input_mail_id <= 0) {
177 EM_DEBUG_EXCEPTION("mail_id is not valid");
178 err = EMAIL_ERROR_INVALID_PARAM;
182 if (!emstorage_get_mail_by_id(multi_user_name, input_mail_id, &mail_table_data, true, &err) || !mail_table_data) {
183 EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
187 if (mail_table_data->account_id <= 0) {
188 EM_DEBUG_EXCEPTION("EM_IF_ACCOUNT_ID_NULL: Account ID [ %d ] ", mail_table_data->account_id);
189 emstorage_free_mail(&mail_table_data, 1, NULL);
190 return EMAIL_ERROR_INVALID_PARAM;
193 EM_DEBUG_LOG("mail_table_data->account_id[%d], mail_table_data->mailbox_id[%d]", mail_table_data->account_id, mail_table_data->mailbox_id);
195 /* check account bind type and branch off */
196 if (em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false) {
197 /* LCOV_EXCL_START */
198 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
199 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
204 if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
206 ASNotiData as_noti_data;
208 memset(&as_noti_data, 0x00, sizeof(ASNotiData));
210 if (em_get_handle_for_activesync(&as_handle, &err) == false) {
211 /* LCOV_EXCL_START */
212 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
213 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
218 /* noti to active sync */
219 as_noti_data.send_mail_with_downloading_attachment_of_original_mail.handle = as_handle;
220 as_noti_data.send_mail_with_downloading_attachment_of_original_mail.mail_id = input_mail_id;
221 as_noti_data.send_mail_with_downloading_attachment_of_original_mail.account_id = mail_table_data->account_id;
222 as_noti_data.send_mail_with_downloading_attachment_of_original_mail.multi_user_name = multi_user_name;
224 if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL_WITH_DOWNLOADING_OF_ORIGINAL_MAIL, &as_noti_data) == false) {
225 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
226 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
231 *output_handle = as_handle;
233 task_parameter.mail_id = input_mail_id;
235 if ((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, &task_parameter)) != EMAIL_ERROR_NONE) {
236 EM_DEBUG_EXCEPTION("execute_proxy_task failed [%d]", err);
242 emipc_destroy_email_api(hAPI);
243 hAPI = (HIPC_API)NULL;
245 emstorage_free_mail(&mail_table_data, 1, NULL);
247 EM_SAFE_FREE(multi_user_name);
249 EM_DEBUG_API_END("err[%d]", err);
253 EXPORT_API int email_schedule_sending_mail(int input_mail_id, time_t input_scheduled_time)
255 EM_DEBUG_API_BEGIN("mail_id[%d] input_time[%d]", input_mail_id, input_scheduled_time);
257 int err = EMAIL_ERROR_NONE;
258 char *multi_user_name = NULL;
259 emstorage_mail_tbl_t* mail_table_data = NULL;
260 email_account_server_t account_server_type;
261 HIPC_API hAPI = NULL;
262 task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL task_parameter;
264 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
265 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
269 if (input_mail_id <= 0) {
270 EM_DEBUG_EXCEPTION("mail_id is not valid");
271 err = EMAIL_ERROR_INVALID_PARAM;
275 if (!emstorage_get_mail_by_id(multi_user_name, input_mail_id, &mail_table_data, true, &err) || !mail_table_data) {
276 EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
280 /* check account bind type and branch off */
281 if (em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false) {
282 /* LCOV_EXCL_START */
283 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
284 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
289 if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
291 ASNotiData as_noti_data;
293 memset(&as_noti_data, 0x00, sizeof(ASNotiData));
294 /* LCOV_EXCL_START */
295 if (em_get_handle_for_activesync(&as_handle, &err) == false) {
296 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
297 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
301 /* noti to active sync */
302 as_noti_data.schedule_sending_mail.handle = as_handle;
303 as_noti_data.schedule_sending_mail.account_id = mail_table_data->account_id;
304 as_noti_data.schedule_sending_mail.mail_id = input_mail_id;
305 as_noti_data.schedule_sending_mail.scheduled_time = input_scheduled_time;
306 as_noti_data.schedule_sending_mail.multi_user_name = multi_user_name;
308 if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SCHEDULE_SENDING_MAIL, &as_noti_data) == false) {
309 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
310 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
314 task_parameter.mail_id = input_mail_id;
315 task_parameter.scheduled_time = input_scheduled_time;
317 if ((err = emipc_execute_proxy_task(EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL, &task_parameter)) != EMAIL_ERROR_NONE) {
318 EM_DEBUG_EXCEPTION("execute_proxy_task failed [%d]", err);
324 emipc_destroy_email_api(hAPI);
325 hAPI = (HIPC_API)NULL;
327 emstorage_free_mail(&mail_table_data, 1, NULL);
329 EM_SAFE_FREE(multi_user_name);
331 EM_DEBUG_API_END("err[%d]", err);
335 EXPORT_API int email_send_saved(int account_id, int *handle)
337 EM_DEBUG_API_BEGIN("account_id[%d] handle[%p]", account_id, handle);
339 char* pOptionStream = NULL;
340 int err = EMAIL_ERROR_NONE;
342 EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM);
343 EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM);
345 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SEND_SAVED);
347 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
350 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &(account_id), sizeof(int))) {
351 /* LCOV_EXCL_START */
352 EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed");
353 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
358 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
359 /* LCOV_EXCL_START */
360 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
361 EM_SAFE_FREE(pOptionStream);
362 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
366 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
367 emipc_destroy_email_api(hAPI);
370 EM_SAFE_FREE(pOptionStream);
372 EM_DEBUG_API_END("err[%d]", err);
376 EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, int *handle)
378 EM_DEBUG_API_BEGIN("input_account_id[%d] input_mailbox_id[%d] handle[%p]", input_account_id, input_mailbox_id, handle);
379 int err = EMAIL_ERROR_NONE;
380 char *multi_user_name = NULL;
381 /* int total_count = 0; */
383 EM_IF_ACCOUNT_ID_NULL(input_account_id, EMAIL_ERROR_INVALID_PARAM);
385 email_account_server_t account_server_type;
386 HIPC_API hAPI = NULL;
387 ASNotiData as_noti_data;
388 memset(&as_noti_data, 0x00, sizeof(ASNotiData));
390 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
391 /* LCOV_EXCL_START */
392 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
397 /* 2010/02/12 ch715.lee : check account bind type and branch off */
398 if (em_get_account_server_type_by_account_id(multi_user_name, input_account_id, &account_server_type, true, &err) == false) {
399 /* LCOV_EXCL_START */
400 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
405 if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
407 if (em_get_handle_for_activesync(&as_handle, &err) == false) {
408 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
412 /* noti to active sync */
413 as_noti_data.sync_header.handle = as_handle;
414 as_noti_data.sync_header.account_id = input_account_id;
415 /* In case that Mailbox is NULL, SYNC ALL MAILBOX */
416 as_noti_data.sync_header.mailbox_id = input_mailbox_id;
417 as_noti_data.sync_header.multi_user_name = multi_user_name;
419 if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) {
420 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
421 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
429 hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER);
431 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
433 /* input_account_id */
434 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_account_id, sizeof(int))) {
435 /* LCOV_EXCL_START */
436 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
437 err = EMAIL_ERROR_OUT_OF_MEMORY;
442 /* input_mailbox_id */
443 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
444 /* LCOV_EXCL_START */
445 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
446 err = EMAIL_ERROR_OUT_OF_MEMORY;
451 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
452 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
453 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
456 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
458 if (err != EMAIL_ERROR_NONE)
462 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
467 emipc_destroy_email_api(hAPI);
470 EM_SAFE_FREE(multi_user_name);
472 EM_DEBUG_API_END("err[%d]", err);
477 EXPORT_API int email_sync_header_for_all_account(int *handle)
479 EM_DEBUG_API_BEGIN("handle[%p]", handle);
480 char *multi_user_name = NULL;
481 int err = EMAIL_ERROR_NONE;
482 HIPC_API hAPI = NULL;
484 ASNotiData as_noti_data;
485 int i, account_count = 0;
486 emstorage_account_tbl_t *account_tbl_array = NULL;
488 int input_account_id = ALL_ACCOUNT;
489 int input_mailbox_id = 0; /* all case */
491 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
492 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
496 hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER);
498 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
500 /* input_account_id */
501 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_account_id, sizeof(int))) {
502 /* LCOV_EXCL_START */
503 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
504 err = EMAIL_ERROR_OUT_OF_MEMORY;
509 /* input_account_id */
510 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
511 /* LCOV_EXCL_START */
512 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
513 err = EMAIL_ERROR_OUT_OF_MEMORY;
518 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
519 /* LCOV_EXCL_START */
520 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
521 EM_SAFE_FREE(multi_user_name);
522 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
526 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
528 if (err != EMAIL_ERROR_NONE)
531 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &return_handle);
533 memset(&as_noti_data, 0x00, sizeof(ASNotiData));
535 /* Get all accounts for sending notification to active sync engine. */
536 if (!emstorage_get_account_list(multi_user_name, &account_count, &account_tbl_array , true, false, &as_err)) {
537 EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [ %d ] ", as_err);
541 for (i = 0; i < account_count; i++) {
542 if (account_tbl_array[i].incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
543 /* use returned handle value for a active sync handle */
546 if (em_get_handle_for_activesync(&as_handle, &err) == false) {
547 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
552 /* noti to active sync */
553 as_noti_data.sync_header.handle = return_handle;
554 as_noti_data.sync_header.account_id = account_tbl_array[i].account_id;
555 /* In case that Mailbox is NULL, SYNC ALL MAILBOX */
556 as_noti_data.sync_header.mailbox_id = 0;
557 as_noti_data.sync_header.multi_user_name = multi_user_name;
559 if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) {
560 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
561 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
568 *handle = return_handle;
572 emipc_destroy_email_api(hAPI);
575 if (account_tbl_array)
576 emstorage_free_account(&account_tbl_array, account_count, NULL);
578 EM_SAFE_FREE(multi_user_name);
579 EM_DEBUG_API_END("err[%d]", err);
583 EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle)
585 EM_DEBUG_API_BEGIN("mail_id[%d] with_attachment[%d]", mail_id, with_attachment);
586 int err = EMAIL_ERROR_NONE;
587 emstorage_mail_tbl_t* mail_table_data = NULL;
589 email_account_server_t account_server_type;
590 HIPC_API hAPI = NULL;
591 ASNotiData as_noti_data;
592 char *multi_user_name = NULL;
594 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
595 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
599 memset(&as_noti_data, 0x00, sizeof(ASNotiData));
602 EM_DEBUG_EXCEPTION("mail_id is not valid");
603 err = EMAIL_ERROR_INVALID_PARAM;
607 if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data) {
608 EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
612 if (mail_table_data->account_id <= 0) {
613 EM_DEBUG_EXCEPTION("EM_IF_ACCOUNT_ID_NULL: Account ID [ %d ] ", mail_table_data->account_id);
617 account_id = mail_table_data->account_id;
619 /* 2010/02/12 ch715.lee : check account bind type and branch off */
620 if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, true, &err) == false) {
621 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
625 if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
627 if (em_get_handle_for_activesync(&as_handle, &err) == false) {
628 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
632 /* noti to active sync */
633 as_noti_data.download_body.handle = as_handle;
634 as_noti_data.download_body.account_id = account_id;
635 as_noti_data.download_body.mail_id = mail_id;
636 as_noti_data.download_body.with_attachment = with_attachment;
637 as_noti_data.download_body.multi_user_name = multi_user_name;
639 if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_BODY, &as_noti_data) == false) {
640 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
641 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
648 hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_BODY);
650 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
653 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
654 /* LCOV_EXCL_START */
655 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
656 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
660 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
661 /* LCOV_EXCL_START */
662 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
663 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
667 /* with_attachment */
668 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_attachment, sizeof(int))) {
669 /* LCOV_EXCL_START */
670 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
671 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
675 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
676 /* LCOV_EXCL_START */
677 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
678 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
682 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
683 if (err != EMAIL_ERROR_NONE)
687 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
688 EM_DEBUG_LOG("RETURN VALUE : %d handle %d", err, *handle);
693 emipc_destroy_email_api(hAPI);
696 if (mail_table_data) {
697 emstorage_free_mail(&mail_table_data, 1, &err);
700 EM_SAFE_FREE(multi_user_name);
702 EM_DEBUG_API_END("err[%d]", err);
708 /* API - Downloads the Email Attachment Information [ INTERNAL ] */
710 EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
712 EM_DEBUG_API_BEGIN("mail_id[%d] nth[%d] handle[%p]", mail_id, nth, handle);
713 int err = EMAIL_ERROR_NONE;
714 emstorage_mail_tbl_t* mail_table_data = NULL;
716 email_account_server_t account_server_type;
717 HIPC_API hAPI = NULL;
718 ASNotiData as_noti_data;
719 char *multi_user_name = NULL;
721 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
722 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
726 memset(&as_noti_data, 0x00, sizeof(ASNotiData));
729 EM_DEBUG_EXCEPTION("mail_id is not valid");
730 err = EMAIL_ERROR_INVALID_PARAM;
734 if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data) {
735 EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
739 if (mail_table_data->account_id <= 0) {
740 EM_DEBUG_EXCEPTION("EM_IF_ACCOUNT_ID_NULL: Account ID [ %d ] ", mail_table_data->account_id);
744 account_id = mail_table_data->account_id;
746 if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, true, &err) == false) {
747 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
751 if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
753 if (em_get_handle_for_activesync(&as_handle, &err) == false) {
754 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
758 /* noti to active sync */
759 as_noti_data.download_attachment.handle = as_handle;
760 as_noti_data.download_attachment.account_id = account_id;
761 as_noti_data.download_attachment.mail_id = mail_id;
762 as_noti_data.download_attachment.attachment_order = nth;
763 as_noti_data.download_attachment.multi_user_name = multi_user_name;
765 if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT, &as_noti_data) == false) {
766 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
767 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
774 hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_ATTACHMENT);
776 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
779 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
780 /* LCOV_EXCL_START */
781 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
782 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
787 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
788 /* LCOV_EXCL_START */
789 EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed");
790 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
795 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &(nth), sizeof(int))) {
796 /* LCOV_EXCL_START */
797 EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed");
798 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
803 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
804 /* LCOV_EXCL_START */
805 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
806 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
810 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
811 if (err != EMAIL_ERROR_NONE)
815 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
820 emipc_destroy_email_api(hAPI);
823 if (mail_table_data) {
824 emstorage_free_mail(&mail_table_data, 1, &err);
827 EM_SAFE_FREE(multi_user_name);
829 EM_DEBUG_API_END("err[%d]", err);
835 EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_cancelation_type input_cancel_type)
837 EM_DEBUG_API_BEGIN("input_account_id[%d] input_handle[%d] input_cancel_type[%d]", input_account_id, input_handle, input_cancel_type);
838 int err = EMAIL_ERROR_NONE;
839 email_account_server_t account_server_type;
840 HIPC_API hAPI = NULL;
841 ASNotiData as_noti_data;
842 emstorage_account_tbl_t *account_list = NULL;
843 int i, account_count = 0;
844 char *multi_user_name = NULL;
846 if (input_account_id < 0)
847 return EMAIL_ERROR_INVALID_PARAM;
849 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
850 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
854 if (input_account_id == ALL_ACCOUNT) {
855 /* this means that job is executed with all account */
856 /* Get all accounts for sending notification to active sync engine. */
857 if (!emstorage_get_account_list(multi_user_name, &account_count, &account_list , true, false, &err)) {
858 EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
862 for (i = 0; i < account_count; i++) {
863 if (em_get_account_server_type_by_account_id(multi_user_name, account_list[i].account_id, &account_server_type, true, &err) == false) {
864 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
868 if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
869 memset(&as_noti_data, 0x00, sizeof(ASNotiData));
870 as_noti_data.cancel_job.account_id = account_list[i].account_id;
871 as_noti_data.cancel_job.handle = input_handle;
872 as_noti_data.cancel_job.cancel_type = input_cancel_type;
873 as_noti_data.cancel_job.multi_user_name = multi_user_name;
875 if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) {
876 /* LCOV_EXCL_START */
877 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
878 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
885 /* request canceling to stub */
886 hAPI = emipc_create_email_api(_EMAIL_API_CANCEL_JOB);
889 /* LCOV_EXCL_START */
890 EM_DEBUG_EXCEPTION("INVALID PARAM: hAPI NULL ");
891 err = EMAIL_ERROR_NULL_VALUE;
896 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_account_id, sizeof(int))) { /* input_account_id == 0 */
897 /* LCOV_EXCL_START */
898 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
899 err = EMAIL_ERROR_NULL_VALUE;
904 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_handle, sizeof(int))) {
905 /* LCOV_EXCL_START */
906 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
907 err = EMAIL_ERROR_NULL_VALUE;
913 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
914 /* LCOV_EXCL_START */
915 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
916 err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
921 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
922 emipc_destroy_email_api(hAPI);
925 if (em_get_account_server_type_by_account_id(multi_user_name, input_account_id, &account_server_type, true, &err) == false) {
926 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
930 if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
931 memset(&as_noti_data, 0x00, sizeof(ASNotiData));
932 as_noti_data.cancel_job.account_id = input_account_id;
933 as_noti_data.cancel_job.handle = input_handle;
934 as_noti_data.cancel_job.multi_user_name = multi_user_name;
936 if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) {
937 /* LCOV_EXCL_START */
938 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
939 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
944 hAPI = emipc_create_email_api(_EMAIL_API_CANCEL_JOB);
946 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
948 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_account_id, sizeof(int))) {
949 /* LCOV_EXCL_START */
950 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
951 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
955 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_handle, sizeof(int))) {
956 /* LCOV_EXCL_START */
957 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
958 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
963 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
964 /* LCOV_EXCL_START */
965 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
966 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
969 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
970 emipc_destroy_email_api(hAPI);
976 emipc_destroy_email_api(hAPI);
979 emstorage_free_account(&account_list, account_count, NULL);
981 EM_SAFE_FREE(multi_user_name);
982 EM_DEBUG_API_END("err[%d]", err);
988 EXPORT_API int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status)
990 EM_DEBUG_API_BEGIN("action[%d] account_id[%d] mail_id[%d] status[%p]", action, account_id, mail_id, status);
991 int err = EMAIL_ERROR_NOT_SUPPORTED;
992 EM_DEBUG_API_END("err[%d]", err);
997 EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving)
999 EM_DEBUG_API_BEGIN("on_sending[%p] on_receiving[%p]", on_sending, on_receiving);
1000 int err = EMAIL_ERROR_NOT_SUPPORTED;
1001 EM_DEBUG_API_END("err[%d]", err);
1005 EXPORT_API int email_get_task_information(email_task_information_t **output_task_information, int *output_task_information_count)
1007 EM_DEBUG_API_BEGIN("output_task_information[%p] output_task_information_count[%p]", output_task_information, output_task_information_count);
1008 int err = EMAIL_ERROR_NONE;
1009 int task_information_stream_length = 0;
1010 HIPC_API hAPI = NULL;
1011 char *task_information_stream = NULL;
1013 if (output_task_information == NULL || output_task_information_count == NULL) {
1014 EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
1015 return EMAIL_ERROR_INVALID_PARAM;
1018 if ((hAPI = emipc_create_email_api(_EMAIL_API_GET_TASK_INFORMATION)) == NULL) {
1019 /* LCOV_EXCL_START */
1020 EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
1021 err = EMAIL_ERROR_IPC_CRASH;
1023 /* LCOV_EXCL_STOP */
1026 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
1027 /* LCOV_EXCL_START */
1028 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
1029 err = EMAIL_ERROR_IPC_CRASH;
1031 /* LCOV_EXCL_STOP */
1033 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1035 if (EMAIL_ERROR_NONE == err) {
1036 task_information_stream_length = emipc_get_parameter_length(hAPI, ePARAMETER_OUT, 1);
1037 if (task_information_stream_length > 0) {
1038 task_information_stream = (char*)em_malloc(task_information_stream_length + 1);
1040 if (!task_information_stream) {
1041 /* LCOV_EXCL_START */
1042 EM_DEBUG_EXCEPTION("em_malloc failed");
1043 err = EMAIL_ERROR_OUT_OF_MEMORY;
1045 /* LCOV_EXCL_STOP */
1048 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, task_information_stream_length, task_information_stream);
1049 em_convert_byte_stream_to_task_information(task_information_stream, task_information_stream_length, output_task_information, output_task_information_count);
1050 EM_SAFE_FREE(task_information_stream); /*prevent 18951*/
1053 if (!output_task_information) {
1054 /* LCOV_EXCL_START */
1055 EM_DEBUG_EXCEPTION("EMAIL_ERROR_NULL_VALUE");
1056 err = EMAIL_ERROR_NULL_VALUE;
1058 /* LCOV_EXCL_STOP */
1062 if (err == EMAIL_ERROR_DATA_NOT_FOUND)
1063 err = EMAIL_ERROR_NONE;
1067 emipc_destroy_email_api(hAPI);
1069 EM_DEBUG_API_END("err[%d]", err);
1073 EXPORT_API int email_sync_imap_mailbox_list(int account_id, int *handle)
1075 EM_DEBUG_API_BEGIN();
1077 int err = EMAIL_ERROR_NONE;
1079 if (account_id <= 0) {
1080 EM_DEBUG_EXCEPTION("invalid parameters");
1081 return EMAIL_ERROR_INVALID_PARAM;
1084 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_IMAP_MAILBOX_LIST);
1087 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
1088 /* LCOV_EXCL_START */
1089 EM_DEBUG_LOG("emipc_add_parameter failed ");
1090 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
1091 /* LCOV_EXCL_STOP */
1094 if (!emipc_execute_proxy_api(hAPI)) {
1095 /* LCOV_EXCL_START */
1096 EM_DEBUG_LOG("ipcProxy_ExecuteAsyncAPI failed");
1097 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
1098 /* LCOV_EXCL_STOP */
1101 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1103 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
1105 emipc_destroy_email_api(hAPI);
1108 EM_DEBUG_API_END("err[%d]", err);
1112 EXPORT_API int email_search_mail_on_server(int input_account_id,
1113 int input_mailbox_id,
1114 email_search_filter_t *input_search_filter_list,
1115 int input_search_filter_count,
1118 EM_DEBUG_API_BEGIN("input_account_id[%d] input_mailbox_id[%d] input_search_filter_list[%p] "
1119 "input_search_filter_count[%d] output_handle[%p]",
1120 input_account_id, input_mailbox_id, input_search_filter_list,
1121 input_search_filter_count, output_handle);
1123 int err = EMAIL_ERROR_NONE;
1124 int return_value = 0;
1125 int stream_size_for_search_filter_list = 0;
1126 char *stream_for_search_filter_list = NULL;
1127 char *multi_user_name = NULL;
1128 HIPC_API hAPI = NULL;
1129 email_account_server_t account_server_type = EMAIL_SERVER_TYPE_NONE;
1130 ASNotiData as_noti_data;
1132 EM_IF_NULL_RETURN_VALUE(input_account_id, EMAIL_ERROR_INVALID_PARAM);
1133 EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
1134 EM_IF_NULL_RETURN_VALUE(input_search_filter_list, EMAIL_ERROR_INVALID_PARAM);
1136 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
1137 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
1141 memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
1143 if (em_get_account_server_type_by_account_id(multi_user_name,
1145 &account_server_type,
1148 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
1152 if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
1155 if (em_get_handle_for_activesync(&as_handle, &err) == false) {
1156 /* LCOV_EXCL_START */
1157 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
1159 /* LCOV_EXCL_STOP */
1162 /* noti to active sync */
1163 as_noti_data.search_mail_on_server.handle = as_handle;
1164 as_noti_data.search_mail_on_server.account_id = input_account_id;
1165 as_noti_data.search_mail_on_server.mailbox_id = input_mailbox_id;
1166 as_noti_data.search_mail_on_server.search_filter_list = input_search_filter_list;
1167 as_noti_data.search_mail_on_server.search_filter_count = input_search_filter_count;
1168 as_noti_data.search_mail_on_server.multi_user_name = multi_user_name;
1170 return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER, &as_noti_data);
1172 if (return_value == false) {
1173 /* LCOV_EXCL_START */
1174 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
1175 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
1177 /* LCOV_EXCL_STOP */
1181 *output_handle = as_handle;
1183 hAPI = emipc_create_email_api(_EMAIL_API_SEARCH_MAIL_ON_SERVER);
1185 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
1187 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_account_id, sizeof(int))) {
1188 /* LCOV_EXCL_START */
1189 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
1190 err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
1192 /* LCOV_EXCL_STOP */
1195 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_mailbox_id, sizeof(int))) {
1196 /* LCOV_EXCL_START */
1197 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
1198 err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
1200 /* LCOV_EXCL_STOP */
1203 stream_for_search_filter_list = em_convert_search_filter_to_byte_stream(input_search_filter_list,
1204 input_search_filter_count,
1205 &stream_size_for_search_filter_list);
1207 EM_PROXY_IF_NULL_RETURN_VALUE(stream_for_search_filter_list, hAPI, EMAIL_ERROR_NULL_VALUE);
1209 if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN,
1210 stream_for_search_filter_list,
1211 stream_size_for_search_filter_list)) { /*prevent 18950*/
1212 /* LCOV_EXCL_START */
1213 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
1214 err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
1216 /* LCOV_EXCL_STOP */
1219 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
1220 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
1221 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
1224 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1226 if (err != EMAIL_ERROR_NONE) {
1227 EM_DEBUG_EXCEPTION("_EMAIL_API_SEARCH_MAIL_ON_SERVER failed [%d]", err);
1232 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_handle);
1237 emipc_destroy_email_api(hAPI);
1241 EM_SAFE_FREE(multi_user_name);
1242 EM_DEBUG_API_END("err[%d]", err);
1246 EXPORT_API int email_clear_result_of_search_mail_on_server(int input_account_id)
1248 EM_DEBUG_API_BEGIN("input_account_id[%d]", input_account_id);
1250 int err = EMAIL_ERROR_NONE;
1251 int return_value = 0;
1252 HIPC_API hAPI = NULL;
1253 char *multi_user_name = NULL;
1254 email_account_server_t account_server_type = EMAIL_SERVER_TYPE_NONE;
1255 ASNotiData as_noti_data;
1257 EM_IF_NULL_RETURN_VALUE(input_account_id, EMAIL_ERROR_INVALID_PARAM);
1259 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
1260 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
1264 memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
1266 if (em_get_account_server_type_by_account_id(multi_user_name,
1268 &account_server_type,
1271 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
1275 if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
1278 if (em_get_handle_for_activesync(&as_handle, &err) == false) {
1279 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
1283 /* noti to active sync */
1284 as_noti_data.clear_result_of_search_mail_on_server.handle = as_handle;
1285 as_noti_data.clear_result_of_search_mail_on_server.account_id = input_account_id;
1286 as_noti_data.clear_result_of_search_mail_on_server.multi_user_name = multi_user_name;
1288 return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER,
1290 if (return_value == false) {
1291 /* LCOV_EXCL_START */
1292 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
1293 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
1295 /* LCOV_EXCL_STOP */
1298 hAPI = emipc_create_email_api(_EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER);
1300 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
1302 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_account_id, sizeof(int))) {
1303 /* LCOV_EXCL_START */
1304 EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
1305 err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
1307 /* LCOV_EXCL_STOP */
1310 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
1311 /* LCOV_EXCL_START */
1312 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
1313 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
1314 /* LCOV_EXCL_STOP */
1317 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1318 if (err != EMAIL_ERROR_NONE) {
1319 /* LCOV_EXCL_START */
1320 EM_DEBUG_EXCEPTION("_EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER failed [%d]", err);
1322 /* LCOV_EXCL_STOP */
1328 emipc_destroy_email_api(hAPI);
1332 EM_SAFE_FREE(multi_user_name);
1333 EM_DEBUG_API_END("err[%d]", err);
1337 EXPORT_API int email_query_smtp_mail_size_limit(int account_id, int *handle)
1339 EM_DEBUG_API_BEGIN("account_id[%d] handle[%p]", account_id, handle);
1340 int err = EMAIL_ERROR_NONE;
1341 char *multi_user_name = NULL;
1342 email_account_server_t account_server_type;
1343 HIPC_API hAPI = NULL;
1345 if (account_id <= 0) {
1346 EM_DEBUG_EXCEPTION("account_id is not valid");
1347 err = EMAIL_ERROR_INVALID_PARAM;
1351 if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
1352 EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
1356 if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, false, &err) == false) {
1357 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
1361 if (account_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
1362 hAPI = emipc_create_email_api(_EMAIL_API_QUERY_SMTP_MAIL_SIZE_LIMIT);
1365 EM_DEBUG_EXCEPTION("INVALID PARAM: hAPI NULL");
1366 return EMAIL_ERROR_NULL_VALUE;
1370 if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
1371 EM_DEBUG_EXCEPTION("email_query_smtp_mail_size_limit--Add Param mail_id failed");
1372 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
1375 if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
1376 EM_DEBUG_EXCEPTION("email_query_smtp_mail_size_limit--emipc_execute_proxy_api failed ");
1377 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_CRASH);
1380 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
1381 if (err == EMAIL_ERROR_NONE) {
1383 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
1388 emipc_destroy_email_api(hAPI);
1389 hAPI = (HIPC_API)NULL;
1391 EM_SAFE_FREE(multi_user_name);
1392 EM_DEBUG_API_END("err[%d]", err);