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.
27 #include "email-ipc.h"
28 #include "email-ipc-build.h"
29 #include "email-proxy-main.h"
30 #include "email-proxy-socket.h"
31 #include "email-proxy-callback-info.h"
33 #include "email-debug-log.h"
35 EXPORT_API int emipc_initialize_proxy_main()
37 EM_DEBUG_FUNC_BEGIN();
40 sock_fd = emipc_get_proxy_socket_id();
43 EM_DEBUG_LOG("Socket already initialized");
44 return EMAIL_ERROR_IPC_ALREADY_INITIALIZED;
47 if (!emipc_start_proxy_socket()) {
48 EM_DEBUG_EXCEPTION("Socket start failed");
49 return EMAIL_ERROR_IPC_CONNECTION_FAILURE;
52 EM_DEBUG_LOG("Socket ID : %d", emipc_get_proxy_socket_id());
54 return EMAIL_ERROR_NONE;
57 EXPORT_API int emipc_finalize_proxy_main()
59 EM_DEBUG_FUNC_BEGIN();
60 if (!emipc_end_proxy_socket()) {
61 EM_DEBUG_EXCEPTION("emipc_finalize_proxy_main failed");
62 return EMAIL_ERROR_IPC_SOCKET_FAILURE;
66 return EMAIL_ERROR_NONE;
69 EXPORT_API bool emipc_execute_api_of_proxy_main(emipc_email_api_info *api_info)
71 EM_DEBUG_FUNC_BEGIN();
74 unsigned char *in_stream = NULL;
80 EM_DEBUG_EXCEPTION("Invalid Parameter");
84 in_stream = emipc_serialize_api_info(api_info, ePARAMETER_IN, &length);
86 EM_DEBUG_EXCEPTION("NULL stream");
90 sending_bytes = emipc_send_proxy_socket(in_stream, length);
92 EM_DEBUG_LOG("Proxy=>stub sending %d byte.", sending_bytes);
94 if (sending_bytes > 0) {
95 #ifdef IPCLIB_STREAM_TRACE_ON
97 for (index=0;index<length;index++)
98 EM_DEBUG_LOG("in_stream[index] : [%x]", in_stream[index]);
100 char *ipc_buf = NULL;
102 ret = emipc_recv_proxy_socket(&ipc_buf);
104 EM_DEBUG_LOG("Recv length : %d", ret);
107 result = emipc_deserialize_api_info(api_info, ePARAMETER_OUT, ipc_buf);
111 EM_SAFE_FREE(ipc_buf);