Add systemd service file; create initscripts and db in %install
[framework/messaging/email-service.git] / email-ipc / email-ipc-proxy.c
1 /* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved \r
2  *\r
3  * PROPRIETARY/CONFIDENTIAL\r
4  *\r
5  * This software is the confidential and proprietary information of SAMSUNG \r
6  * ELECTRONICS ("Confidential Information"). You agree and acknowledge that \r
7  * this software is owned by Samsung and you shall not disclose such \r
8  * Confidential Information and shall use it only in accordance with the terms\r
9  * of the license agreement you entered into with SAMSUNG ELECTRONICS. \r
10  * SAMSUNG make no representations or warranties about the suitability of the \r
11  * software, either express or implied, including but not limited to the \r
12  * implied warranties of merchantability, fitness for a particular purpose, \r
13  * or non-infringement. SAMSUNG shall not be liable for any damages suffered \r
14  * by licensee arising out of or releated to this software.\r
15  * \r
16  */\r
17 \r
18 #include "email-ipc-build.h"\r
19 #include "email-ipc.h"\r
20 #include "email-ipc-api-info.h"\r
21 #include "email-ipc-param-list.h"\r
22 #include "email-ipc-socket.h"\r
23 #include "email-proxy-main.h"\r
24 \r
25 #include "email-debug-log.h"\r
26 #include "email-api.h"\r
27 #include "email-types.h"\r
28 \r
29 EXPORT_API int emipc_initialize_proxy()\r
30 {\r
31         EM_DEBUG_FUNC_BEGIN();\r
32 \r
33         int err = emipc_initialize_proxy_main();\r
34 \r
35         EM_DEBUG_FUNC_END();\r
36         return err;\r
37 }\r
38 \r
39 EXPORT_API int emipc_finalize_proxy()\r
40 {\r
41         EM_DEBUG_FUNC_BEGIN();\r
42         return emipc_finalize_proxy_main();\r
43 }\r
44 \r
45 EXPORT_API bool emipc_execute_proxy_api(HIPC_API api)\r
46 {\r
47         EM_DEBUG_FUNC_BEGIN();\r
48         int ret;\r
49         int err = EMF_ERROR_NONE;\r
50         emipc_email_api_info *api_info = (emipc_email_api_info *)api;\r
51 \r
52         EM_DEBUG_LOG("API [%p]", api_info);\r
53                 \r
54         if(api_info == NULL) {\r
55                 EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");\r
56                 return EMF_ERROR_INVALID_PARAM;\r
57         }\r
58                 \r
59         EM_DEBUG_LOG("APIID [%s], ResponseID [%d], APPID[%d]", EM_APIID_TO_STR(emipc_get_api_id_of_api_info(api_info)), emipc_get_response_id_of_api_info(api_info), emipc_get_app_id_of_api_info(api_info));\r
60 \r
61         ret = emipc_execute_api_of_proxy_main(api_info);\r
62 \r
63         /* connection retry */\r
64         if (!ret) {\r
65                 emipc_finalize_proxy();\r
66 \r
67                 err = emipc_initialize_proxy();\r
68                 if (err != EMF_ERROR_NONE) {\r
69                         EM_DEBUG_EXCEPTION("Failed to open the socket : [%d]", err);\r
70                         return EMF_ERROR_CONNECTION_FAILURE;\r
71                 }\r
72 \r
73                 ret = emipc_execute_api_of_proxy_main(api_info);\r
74                 if (!ret) {\r
75                         EM_DEBUG_EXCEPTION("emipc_proxy_main : emipc_execute_api failed [%d]", err);\r
76                         return EMF_ERROR_CONNECTION_FAILURE;\r
77                 }\r
78         }\r
79         EM_DEBUG_FUNC_END("err [%d]", err);\r
80         return err;     \r
81 }\r