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-init.c
29 * @brief This file contains the data structures and interfaces of Email FW intialization related Functionality provided by
33 #include "email-api.h"
35 #include "email-convert.h"
36 #include "email-storage.h"
37 #include "email-ipc.h"
41 EXPORT_API int email_open_db(void)
43 EM_DEBUG_FUNC_BEGIN();
44 int error = EMF_ERROR_NONE;
46 if (emstorage_db_open(&error) == NULL)
47 EM_DEBUG_EXCEPTION("emstorage_db_open failed [%d]", error);
50 EM_DEBUG_FUNC_END("error [%d]", error);
55 EXPORT_API int email_close_db(void)
57 EM_DEBUG_FUNC_BEGIN();
58 int error = EMF_ERROR_NONE;
60 if ( !emstorage_db_close(&error))
61 EM_DEBUG_EXCEPTION("emstorage_db_close failed [%d]", error);
63 EM_DEBUG_FUNC_END("error [%d]", error);
68 EXPORT_API int email_service_begin(void)
70 EM_DEBUG_FUNC_BEGIN();
73 signal(SIGPIPE, SIG_IGN); /* to ignore signal 13(SIGPIPE) */
75 ret = emipc_initialize_proxy();
76 if (ret != EMF_ERROR_NONE)
77 EM_DEBUG_FUNC_END("err[%d]", ret);
83 EXPORT_API int email_service_end(void)
85 EM_DEBUG_FUNC_BEGIN();
88 ret = emipc_finalize_proxy();
89 if (ret != EMF_ERROR_NONE)
90 EM_DEBUG_FUNC_END("err[%d]", ret);
95 /* API - Exposed to External Application- core team.Creates all Email DB tables [ EXTERNAL] */
98 EXPORT_API int email_init_storage(void)
100 EM_DEBUG_FUNC_BEGIN();
101 int error = EMF_ERROR_NONE;
103 if (!emstorage_create_table(EMF_CREATE_DB_CHECK, &error)) {
104 EM_DEBUG_EXCEPTION("emstorage_create_table failed [%d]", error);
107 EM_DEBUG_FUNC_END("error[%d]", error);
111 EXPORT_API int email_ping_service(void)
113 EM_DEBUG_FUNC_BEGIN();
114 int error = EMF_ERROR_NONE;
115 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_PING_SERVICE);
117 EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
119 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
120 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
121 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
124 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &error);
126 emipc_destroy_email_api(hAPI);
130 EM_DEBUG_FUNC_END("err[%d]", error);