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.
25 * This file contains the data structures and interfaces needed for application,
26 * to interact with email-service.
27 * @file email-api-etc.c
28 * @brief This file contains the data structures and interfaces of functionalities provided by email-service .
31 #include "email-api.h"
32 #include "email-types.h"
33 #include "email-ipc.h"
34 #include "email-debug-log.h"
35 #include "email-core-utils.h"
36 #include "email-core-mime.h"
38 EXPORT_API int email_show_user_message(int id, email_action_t action, int error_code)
40 EM_DEBUG_FUNC_BEGIN("id [%d], action [%d], error_code [%d]", id, action, error_code);
41 int err = EMAIL_ERROR_NONE;
43 if(id < 0 || action < 0) {
44 EM_DEBUG_LOG("EMAIL_ERROR_INVALID_PARAM");
45 return EMAIL_ERROR_INVALID_PARAM;
48 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SHOW_USER_MESSAGE);
51 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&id, sizeof(int))) {
52 EM_DEBUG_LOG("emipc_add_parameter failed ");
53 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
57 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&action, sizeof(int))) {
58 EM_DEBUG_LOG("emipc_add_parameter failed ");
59 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
63 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&error_code, sizeof(int))) {
64 EM_DEBUG_LOG("emipc_add_parameter failed ");
65 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
68 if(!emipc_execute_proxy_api(hAPI)) {
69 EM_DEBUG_LOG("ipcProxy_ExecuteAsyncAPI failed");
70 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
73 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
75 emipc_destroy_email_api(hAPI);
78 EM_DEBUG_FUNC_END("err [%d]", err);
82 EXPORT_API int email_open_eml_file(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
84 EM_DEBUG_FUNC_BEGIN("eml_file_path : [%s], output_mail_data : [%p], output_attachment_data : [%p]", eml_file_path, output_mail_data, output_attachment_data);
85 int err = EMAIL_ERROR_NONE;
87 EM_IF_NULL_RETURN_VALUE(eml_file_path, EMAIL_ERROR_INVALID_PARAM);
89 if (!emcore_load_eml_file_to_mail(eml_file_path, output_mail_data, output_attachment_data, output_attachment_count, &err) || !*output_mail_data)
90 EM_DEBUG_EXCEPTION("emcore_load_eml_file_to_mail_data failed [%d]", err);
92 EM_DEBUG_FUNC_END("err [%d]", err);
96 EXPORT_API int email_delete_eml_data(email_mail_data_t *input_mail_data)
98 EM_DEBUG_FUNC_BEGIN("mail_data : [%p]", input_mail_data);
99 int err = EMAIL_ERROR_NONE;
101 EM_IF_NULL_RETURN_VALUE(input_mail_data, EMAIL_ERROR_INVALID_PARAM);
103 if (!emcore_delete_eml_data(input_mail_data, &err))
104 EM_DEBUG_EXCEPTION("emcore_load_eml_file_to_mail_data failed [%d]", err);
106 EM_DEBUG_FUNC_END("err [%d]", err);
110 EXPORT_API int email_get_mime_entity(char *mime_path, char **mime_entity)
112 EM_DEBUG_FUNC_BEGIN("mime_path : [%s]", mime_path);
113 int err = EMAIL_ERROR_NONE;
115 EM_IF_NULL_RETURN_VALUE(mime_path, EMAIL_ERROR_INVALID_PARAM);
117 if (!emcore_get_mime_entity(mime_path, mime_entity, &err))
118 EM_DEBUG_EXCEPTION("emcore_get_mime_entity failed [%d]", err);