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.
25 * This file contains the data structures and interfaces needed for application,
26 * to interact with email-service.
27 * @file email-api-account.c
28 * @brief This file contains the data structures and interfaces of Account related Functionality provided by
32 #include "email-api.h"
34 #include "email-convert.h"
35 #include "email-api-account.h"
36 #include "email-storage.h"
37 #include "email-core-mail.h"
38 #include "email-core-account.h"
39 #include "email-core-utils.h"
40 #include "email-utilities.h"
41 #include "email-ipc.h"
43 /* API - Adds the Email Account */
44 EXPORT_API int email_add_account(email_account_t* account)
46 EM_DEBUG_FUNC_BEGIN("account[%p]", account);
47 char* local_account_stream = NULL;
49 int err = EMAIL_ERROR_NONE;
50 int ret_from_ipc = EMAIL_ERROR_NONE;
54 EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
55 return EMAIL_ERROR_INVALID_PARAM;
58 /* composing account information to be added */
59 hAPI = emipc_create_email_api(_EMAIL_API_ADD_ACCOUNT);
60 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
62 local_account_stream = em_convert_account_to_byte_stream(account, &size);
63 EM_PROXY_IF_NULL_RETURN_VALUE(local_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
65 if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
66 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
67 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
69 EM_DEBUG_LOG("APPID[%d], APIID [%d]", emipc_get_app_id(hAPI), emipc_get_api_id(hAPI));
71 /* passing account information to service */
72 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
73 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
74 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
77 /* get result from service */
78 if( (ret_from_ipc = emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err)) != EMAIL_ERROR_NONE) {
79 EM_DEBUG_EXCEPTION("emipc_get_parameter failed [%d]", ret_from_ipc);
84 if(err == EMAIL_ERROR_NONE) {
85 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &account->account_id);
87 else { /* get error code */
88 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
94 emipc_destroy_email_api(hAPI);
96 EM_DEBUG_FUNC_END("ERROR CODE [%d]", err);
101 EXPORT_API int email_free_account(email_account_t** account_list, int count)
103 EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%d]", account_list, count);
105 /* default variable */
106 int err = EMAIL_ERROR_NONE;
109 if (!account_list || !*account_list) {
110 err = EMAIL_ERROR_INVALID_PARAM;
113 email_account_t* p = *account_list;
116 for (i = 0; i < count; i++) {
117 EM_SAFE_FREE(p[i].account_name);
118 EM_SAFE_FREE(p[i].incoming_server_address);
119 EM_SAFE_FREE(p[i].user_email_address);
120 EM_SAFE_FREE(p[i].incoming_server_user_name);
121 EM_SAFE_FREE(p[i].incoming_server_password);
122 EM_SAFE_FREE(p[i].outgoing_server_address);
123 EM_SAFE_FREE(p[i].outgoing_server_user_name);
124 EM_SAFE_FREE(p[i].outgoing_server_password);
125 EM_SAFE_FREE(p[i].user_display_name);
126 EM_SAFE_FREE(p[i].reply_to_address);
127 EM_SAFE_FREE(p[i].return_address);
128 EM_SAFE_FREE(p[i].logo_icon_path);
129 EM_SAFE_FREE(p[i].user_data);
130 p[i].user_data_length = 0;
131 EM_SAFE_FREE(p[i].options.display_name_from);
132 EM_SAFE_FREE(p[i].options.signature);
134 free(p); *account_list = NULL;
138 EM_DEBUG_FUNC_END("ERROR CODE [%d]", err);
143 /* API - Delete the Email Account */
144 EXPORT_API int email_delete_account(int account_id)
146 EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id);
149 int err = EMAIL_ERROR_NONE;
151 if (account_id < 0 || account_id == 0) {
152 EM_DEBUG_EXCEPTION(" account_id[%d]", account_id);
153 err = EMAIL_ERROR_INVALID_PARAM;
157 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_ACCOUNT);
159 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
162 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
163 EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed ");
164 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
167 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
168 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed ");
169 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
172 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
173 if(ret != EMAIL_ERROR_NONE) { /* get error code */
174 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
176 emipc_destroy_email_api(hAPI);
179 EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err);
183 /* API - Update the Email Account */
184 EXPORT_API int email_update_account(int account_id, email_account_t* new_account)
186 EM_DEBUG_FUNC_BEGIN("account_id[%d], new_account[%p]", account_id, new_account);
190 int err = EMAIL_ERROR_NONE;
191 int with_validation = false;
192 char* new_account_stream = NULL;
194 if ( account_id <= 0 || !new_account ) { /*prevent 23138*/
195 EM_DEBUG_EXCEPTION("account_id[%d], new_account[%p], with_validation[%d]", account_id, new_account, with_validation);
196 return EMAIL_ERROR_INVALID_PARAM;
199 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_ACCOUNT);
201 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
204 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
205 EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed ");
210 new_account_stream = em_convert_account_to_byte_stream(new_account, &size);
211 EM_PROXY_IF_NULL_RETURN_VALUE(new_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
212 if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) {
213 EM_DEBUG_EXCEPTION("emipc_add_parameter new_account failed ");
217 /* with_validation */
218 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_validation, sizeof(int))) {
219 EM_DEBUG_EXCEPTION("emipc_add_parameter with_validation failed ");
223 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
224 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
225 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
228 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
229 if(ret != EMAIL_ERROR_NONE) {
231 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
236 emipc_destroy_email_api(hAPI);
239 EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err);
243 /* API - Update the Email Account */
244 EXPORT_API int email_update_account_with_validation(int account_id, email_account_t* new_account)
246 EM_DEBUG_FUNC_BEGIN("account_id[%d], new_account[%p]", account_id, new_account);
250 int err = EMAIL_ERROR_NONE;
251 int with_validation = true;
252 char* new_account_stream = NULL;
254 if ((account_id <= 0) || !new_account || (with_validation != false && with_validation != true)) {
255 EM_DEBUG_EXCEPTION(" account_id[%d], new_account[%p], with_validation[%d]", account_id, new_account, with_validation);
256 err = EMAIL_ERROR_INVALID_PARAM;
260 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_ACCOUNT);
262 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
265 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
266 EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter account_id failed ");
267 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
271 new_account_stream = em_convert_account_to_byte_stream(new_account, &size);
272 EM_PROXY_IF_NULL_RETURN_VALUE(new_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
273 if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) {
274 EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter new_account failed ");
275 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
278 /* with_validation */
279 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_validation, sizeof(int))) {
280 EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter with_validation failed ");
281 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
284 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
285 EM_DEBUG_EXCEPTION("email_update_account--emipc_execute_proxy_api failed ");
286 /* Prevent defect 18624 */
287 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
290 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
291 if(ret != EMAIL_ERROR_NONE) { /* get error code */
292 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
295 emipc_destroy_email_api(hAPI);
298 EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err);
303 /* API - Get the account Information based on the account ID */
304 EXPORT_API int email_get_account(int account_id, int pulloption, email_account_t** account)
306 EM_DEBUG_FUNC_BEGIN();
308 int err = EMAIL_ERROR_NONE;
309 emstorage_account_tbl_t *account_tbl = NULL;
311 EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM);
312 EM_IF_NULL_RETURN_VALUE(account, EMAIL_ERROR_INVALID_PARAM);
314 if (pulloption == GET_FULL_DATA)
315 pulloption = EMAIL_ACC_GET_OPT_FULL_DATA;
317 if (pulloption & EMAIL_ACC_GET_OPT_PASSWORD) {
318 pulloption = pulloption & (~(EMAIL_ACC_GET_OPT_PASSWORD)); /* disable password -Can't obtain password by MAPI */
319 EM_DEBUG_LOG("change pulloption : disable password");
322 if (!emstorage_get_account_by_id(account_id, pulloption, &account_tbl, true, &err)) {
323 EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", err);
327 *account = em_malloc(sizeof(email_account_t));
329 EM_DEBUG_EXCEPTION("allocation failed [%d]", err);
332 memset((void*)*account, 0, sizeof(email_account_t));
333 em_convert_account_tbl_to_account(account_tbl, *account);
340 emstorage_free_account(&account_tbl, 1, NULL);
346 EXPORT_API int email_get_account_list(email_account_t** account_list, int* count)
348 EM_DEBUG_FUNC_BEGIN();
350 int err = EMAIL_ERROR_NONE, i = 0;
351 emstorage_account_tbl_t *temp_account_tbl = NULL;
353 EM_IF_NULL_RETURN_VALUE(account_list, EMAIL_ERROR_INVALID_PARAM);
354 EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
356 if (!emstorage_get_account_list(count, &temp_account_tbl , true, false, &err)) {
357 EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
362 if(temp_account_tbl && (*count) > 0) {
363 *account_list = em_malloc(sizeof(email_account_t) * (*count));
365 EM_DEBUG_EXCEPTION("allocation failed [%d]", err);
368 memset((void*)*account_list, 0, sizeof(email_account_t) * (*count));
369 for(i = 0; i < (*count); i++)
370 em_convert_account_tbl_to_account(temp_account_tbl + i, (*account_list) + i);
377 emstorage_free_account(&temp_account_tbl, (*count), NULL);
378 EM_DEBUG_FUNC_END("err[%d]", err);
383 EXPORT_API int email_validate_account(int account_id, int *handle)
385 EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p]", account_id, handle);
388 int err = EMAIL_ERROR_NONE;
389 if (account_id <= 0) {
390 EM_DEBUG_EXCEPTION("account_id[%d]", account_id);
391 err = EMAIL_ERROR_INVALID_PARAM;
395 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_VALIDATE_ACCOUNT);
397 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
400 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
401 EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed ");
402 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
405 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
406 EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
407 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
410 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); /* return */
411 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); /* error code */
414 emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), handle);
416 emipc_destroy_email_api(hAPI);
419 EM_DEBUG_FUNC_END("err[%d]", err);
425 EXPORT_API int email_add_account_with_validation(email_account_t* account, int *handle)
427 EM_DEBUG_FUNC_BEGIN("account[%p]", account);
428 char* local_account_stream = NULL;
431 int err = EMAIL_ERROR_NONE;
433 EM_IF_NULL_RETURN_VALUE(account, false);
435 if(emstorage_check_duplicated_account(account, true, &err) == false) {
436 EM_DEBUG_EXCEPTION("emstorage_check_duplicated_account failed (%d) ", err);
440 /* create account information */
441 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION);
442 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
444 local_account_stream = em_convert_account_to_byte_stream(account, &size);
445 EM_PROXY_IF_NULL_RETURN_VALUE(local_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
446 if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
447 EM_DEBUG_EXCEPTION(" emipc_add_parameter failed ");
448 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
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), &ret);
457 if(ret == EMAIL_ERROR_NONE) {
459 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
462 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
465 emipc_destroy_email_api(hAPI);
468 EM_DEBUG_FUNC_END("err[%d]", err);
473 EXPORT_API int email_backup_accounts_into_secure_storage(const char *file_name)
475 EM_DEBUG_FUNC_BEGIN("file_name[%s]", file_name);
477 int err = EMAIL_ERROR_NONE;
480 EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
481 err = EMAIL_ERROR_INVALID_PARAM;
485 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_BACKUP_ACCOUNTS);
487 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
490 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)file_name, EM_SAFE_STRLEN(file_name)+1)) {
491 EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed ");
492 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
495 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
496 EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
497 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
500 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
502 if(0 == ret) { /* get error code */
503 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
506 emipc_destroy_email_api(hAPI);
509 EM_DEBUG_FUNC_END("err[%d]", err);
513 EXPORT_API int email_restore_accounts_from_secure_storage(const char * file_name)
515 EM_DEBUG_FUNC_BEGIN("file_name[%s]", file_name);
517 int err = EMAIL_ERROR_NONE;
520 EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
521 err = EMAIL_ERROR_INVALID_PARAM;
525 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_RESTORE_ACCOUNTS);
527 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
530 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)file_name, EM_SAFE_STRLEN(file_name)+1)) {
531 EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed ");
532 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
535 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
536 EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
537 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
540 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
542 if(0==ret) { /* get error code */
543 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
546 emipc_destroy_email_api(hAPI);
549 EM_DEBUG_FUNC_END("err[%d]", err);
553 EXPORT_API int email_get_password_length_of_account(const int account_id, int *password_length)
555 EM_DEBUG_FUNC_BEGIN("account_id[%d], password_length[%p]", account_id, password_length);
557 int err = EMAIL_ERROR_NONE;
559 if (account_id <= 0 || password_length == NULL) {
560 EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
561 err = EMAIL_ERROR_INVALID_PARAM;
565 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT);
567 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
570 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
571 EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed ");
572 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
575 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
576 EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
577 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
580 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
581 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
582 emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), password_length);
584 emipc_destroy_email_api(hAPI);
587 EM_DEBUG_FUNC_END("*password_length[%d]", *password_length);
591 EXPORT_API int email_query_server_info(const char* domain_name, email_server_info_t **result_server_info)
593 EM_DEBUG_FUNC_BEGIN("domain_name [%s], result_server_info [%p]", domain_name, result_server_info);
594 int err = EMAIL_ERROR_NONE;
596 if (!domain_name || !result_server_info) {
597 EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
598 err = EMAIL_ERROR_INVALID_PARAM;
602 err = emcore_query_server_info(domain_name, result_server_info);
604 EM_DEBUG_FUNC_END("err[%d]", err);
609 EXPORT_API int email_free_server_info(email_server_info_t **result_server_info)
611 EM_DEBUG_FUNC_BEGIN("result_server_info [%p]", result_server_info);
612 int err = EMAIL_ERROR_NONE;
614 if (!result_server_info) {
615 EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
616 err = EMAIL_ERROR_INVALID_PARAM;
620 err = emcore_free_server_info(result_server_info);
622 EM_DEBUG_FUNC_END("ret[%d]", err);
626 EXPORT_API int email_update_notification_bar(int account_id)
628 EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id);
629 int err = EMAIL_ERROR_NONE;
631 if (account_id == 0) {
632 EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
633 err = EMAIL_ERROR_INVALID_PARAM;
637 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL);
639 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
642 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
643 EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed");
644 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
647 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
648 EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
649 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
652 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
653 emipc_destroy_email_api(hAPI);
656 EM_DEBUG_FUNC_END("ret[%d]", err);
661 EXPORT_API int email_clear_all_notification_bar()
663 EM_DEBUG_FUNC_BEGIN();
664 int err = EMAIL_ERROR_NONE;
666 err = emcore_clear_all_notifications();
668 EM_DEBUG_FUNC_END("ret[%d]", err);
672 EXPORT_API int email_save_default_account_id(int input_account_id)
674 EM_DEBUG_FUNC_BEGIN("input_account_id [%d]", input_account_id);
675 int err = EMAIL_ERROR_NONE;
677 err = emcore_save_default_account_id(input_account_id);
679 EM_DEBUG_FUNC_END("ret[%d]", err);
683 EXPORT_API int email_load_default_account_id(int *output_account_id)
685 EM_DEBUG_FUNC_BEGIN("output_account_id [%p]", output_account_id);
686 int err = EMAIL_ERROR_NONE;
688 err = emcore_load_default_account_id(output_account_id);
690 EM_DEBUG_FUNC_END("ret[%d]", err);