summaryrefslogtreecommitdiff
path: root/email-api/email-api-init.c
diff options
context:
space:
mode:
authorJinkun Jang <jinkun.jang@samsung.com>2013-03-13 01:48:48 +0900
committerJinkun Jang <jinkun.jang@samsung.com>2013-03-13 01:48:48 +0900
commite0eadfbda442a8a655185b2969889994004b8099 (patch)
tree2382a0f456cbcfd24a7a5d6a9a2375620fed6b9e /email-api/email-api-init.c
parent4c73c3e1e4085d17f8f9cfe0ec4c41bc9e0cb826 (diff)
downloademail-service-e0eadfbda442a8a655185b2969889994004b8099.tar.gz
email-service-e0eadfbda442a8a655185b2969889994004b8099.tar.bz2
email-service-e0eadfbda442a8a655185b2969889994004b8099.zip
Tizen 2.1 base
Diffstat (limited to 'email-api/email-api-init.c')
-rwxr-xr-xemail-api/email-api-init.c134
1 files changed, 134 insertions, 0 deletions
diff --git a/email-api/email-api-init.c b/email-api/email-api-init.c
new file mode 100755
index 0000000..0adc2c3
--- /dev/null
+++ b/email-api/email-api-init.c
@@ -0,0 +1,134 @@
+/*
+* email-service
+*
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-init.c
+ * @brief This file contains the data structures and interfaces of Email FW intialization related Functionality provided by
+ * email-service .
+ */
+
+#include "email-api.h"
+#include "string.h"
+#include "email-convert.h"
+#include "email-storage.h"
+#include "email-ipc.h"
+#include "email-core-task-manager.h"
+#include <sqlite3.h>
+
+
+EXPORT_API int email_open_db(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int error = EMAIL_ERROR_NONE;
+
+ if (emstorage_db_open(&error) == NULL)
+ EM_DEBUG_EXCEPTION("emstorage_db_open failed [%d]", error);
+
+
+ EM_DEBUG_FUNC_END("error [%d]", error);
+
+ return error;
+}
+
+EXPORT_API int email_close_db(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int error = EMAIL_ERROR_NONE;
+
+ if ( !emstorage_db_close(&error))
+ EM_DEBUG_EXCEPTION("emstorage_db_close failed [%d]", error);
+
+ EM_DEBUG_FUNC_END("error [%d]", error);
+ return error;
+}
+
+
+EXPORT_API int email_service_begin(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int ret = -1;
+
+ signal(SIGPIPE, SIG_IGN); /* to ignore signal 13(SIGPIPE) */
+
+ ret = emipc_initialize_proxy();
+
+ emcore_init_task_handler_array();
+
+ EM_DEBUG_FUNC_END("err[%d]", ret);
+ return ret;
+}
+
+
+EXPORT_API int email_service_end(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int ret = -1;
+
+ ret = emipc_finalize_proxy();
+ if (ret != EMAIL_ERROR_NONE)
+ EM_DEBUG_FUNC_END("err[%d]", ret);
+
+ return ret;
+}
+
+/* API - Exposed to External Application- core team.Creates all Email DB tables [ EXTERNAL] */
+
+
+EXPORT_API int email_init_storage(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int error = EMAIL_ERROR_NONE;
+
+ if (!emstorage_create_table(EMAIL_CREATE_DB_CHECK, &error)) {
+ EM_DEBUG_EXCEPTION("emstorage_create_table failed [%d]", error);
+ }
+
+ EM_DEBUG_FUNC_END("error[%d]", error);
+ return error;
+}
+
+EXPORT_API int email_ping_service(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int error = EMAIL_ERROR_NONE;
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_PING_SERVICE);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
+
+ if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &error);
+
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+
+ EM_DEBUG_FUNC_END("err[%d]", error);
+ return error;
+}