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 = EMAIL_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 = EMAIL_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();
77 EM_DEBUG_FUNC_END("err[%d]", ret);
82 EXPORT_API int email_service_end(void)
84 EM_DEBUG_FUNC_BEGIN();
87 ret = emipc_finalize_proxy();
88 if (ret != EMAIL_ERROR_NONE)
89 EM_DEBUG_FUNC_END("err[%d]", ret);
94 /* API - Exposed to External Application- core team.Creates all Email DB tables [ EXTERNAL] */
97 EXPORT_API int email_init_storage(void)
99 EM_DEBUG_FUNC_BEGIN();
100 int error = EMAIL_ERROR_NONE;
102 if (!emstorage_create_table(EMAIL_CREATE_DB_CHECK, &error)) {
103 EM_DEBUG_EXCEPTION("emstorage_create_table failed [%d]", error);
106 EM_DEBUG_FUNC_END("error[%d]", error);
110 EXPORT_API int email_ping_service(void)
112 EM_DEBUG_FUNC_BEGIN();
113 int error = EMAIL_ERROR_NONE;
114 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_PING_SERVICE);
116 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
118 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
119 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
120 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
123 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &error);
125 emipc_destroy_email_api(hAPI);
129 EM_DEBUG_FUNC_END("err[%d]", error);