4 * Copyright (c) 2012 - 2013 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.
24 #include "email-stub-main.h"
25 #include "email-ipc.h"
26 #include "email-ipc-param-list.h"
27 #include "email-ipc-build.h"
28 #include "email-dbus-activation.h"
29 #include "email-stub-socket.h"
31 #include "email-api.h"
32 #include "email-debug-log.h"
34 static bool stub_socket = false;
35 static PFN_EXECUTE_API this_fn_api_mapper = NULL;
37 EXPORT_API bool emipc_initialize_stub_main(PFN_EXECUTE_API fn_api_mapper)
39 EM_DEBUG_FUNC_BEGIN();
42 EM_DEBUG_EXCEPTION("Invalid Param");
46 this_fn_api_mapper = fn_api_mapper;
48 /* Initialize the socket */
49 stub_socket = emipc_start_stub_socket();
51 EM_DEBUG_EXCEPTION("Socket did not create");
55 emipc_init_dbus_connection();
61 EXPORT_API bool emipc_finalize_stub_main()
63 EM_DEBUG_FUNC_BEGIN();
66 emipc_end_stub_socket();
70 if (this_fn_api_mapper)
71 this_fn_api_mapper = NULL;
77 EXPORT_API bool emipc_execute_api_proxy_to_stub(emipc_email_api_info *api_info)
79 EM_DEBUG_FUNC_BEGIN();
81 EM_DEBUG_EXCEPTION("Invalid Param");
85 if (this_fn_api_mapper) {
86 this_fn_api_mapper(api_info);
93 EXPORT_API bool emipc_execute_api_stub_to_proxy(emipc_email_api_info *api_info)
95 EM_DEBUG_FUNC_BEGIN("api_info [%p]", api_info);
96 EM_IF_NULL_RETURN_VALUE(api_info, false);
97 EM_DEBUG_LOG("APIID [%s], response Socket ID [%d], APPID [%d]",
98 EM_APIID_TO_STR(api_info->api_id), api_info->response_id, api_info->app_id);
100 unsigned char *stream = NULL;
101 int stream_length = 0;
103 stream = emipc_serialize_api_info(api_info, ePARAMETER_OUT, &stream_length);
104 EM_DEBUG_LOG("Stub => Proxy Sending %dB", stream_length);
106 emipc_send_stub_socket(api_info->response_id, stream, stream_length);
108 #ifdef IPCLIB_STREAM_TRACE_ON
110 for (index = 0; index < stream_length; index++)
111 EM_DEBUG_LOG("Stream[index] : [%d]", stream[index]);