2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file message-port.cpp
20 * @brief This is the implementation file for the MessagePort.
25 #include "message-port.h"
26 #include "message-port-log.h"
28 #include "MessagePortProxy.h"
31 messageport_register_local_port(const char* local_port, messageport_message_cb callback)
33 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
36 return pProxy->RegisterMessagePort(local_port, false, callback);
39 return MESSAGEPORT_ERROR_IO_ERROR;
43 messageport_register_trusted_local_port(const char* local_port, messageport_message_cb callback)
45 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
48 return pProxy->RegisterMessagePort(local_port, true, callback);
51 return MESSAGEPORT_ERROR_IO_ERROR;
55 messageport_check_remote_port(const char* remote_app_id, const char *remote_port, bool* exist)
57 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
60 return pProxy->CheckRemotePort(remote_app_id, remote_port, false, exist);
63 return MESSAGEPORT_ERROR_IO_ERROR;
67 messageport_check_trusted_remote_port(const char* remote_app_id, const char *remote_port, bool* exist)
69 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
72 return pProxy->CheckRemotePort(remote_app_id, remote_port, true, exist);
75 return MESSAGEPORT_ERROR_IO_ERROR;
79 messageport_send_message(const char* remote_app_id, const char* remote_port, bundle* message)
81 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
84 return pProxy->SendMessage(remote_app_id, remote_port, false, message);
87 return MESSAGEPORT_ERROR_IO_ERROR;
91 messageport_send_trusted_message(const char* remote_app_id, const char* remote_port, bundle* message)
93 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
96 return pProxy->SendMessage(remote_app_id, remote_port, true, message);
99 return MESSAGEPORT_ERROR_IO_ERROR;
103 messageport_send_bidirectional_message(int id, const char* remote_app_id, const char* remote_port, bundle* message)
106 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
109 char* pName = pProxy->GetLocalPortNameN(id);
110 bool trusted = false;
111 ret = pProxy->CheckTrustedLocalPort(id, &trusted);
115 return MESSAGEPORT_ERROR_INVALID_PARAMETER;
118 ret = pProxy->SendMessage(pName, trusted, remote_app_id, remote_port, false, message);
125 return MESSAGEPORT_ERROR_IO_ERROR;
129 messageport_send_bidirectional_trusted_message(int id, const char* remote_app_id, const char* remote_port, bundle* message)
131 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
134 bool trusted = false;
135 int ret = pProxy->CheckTrustedLocalPort(id, &trusted);
141 char* pName = pProxy->GetLocalPortNameN(id);
144 return MESSAGEPORT_ERROR_INVALID_PARAMETER;
147 ret = pProxy->SendMessage(pName, trusted, remote_app_id, remote_port, true, message);
154 return MESSAGEPORT_ERROR_IO_ERROR;
158 messageport_get_local_port_name(int id, char **name)
160 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
163 char* pName = pProxy->GetLocalPortNameN(id);
166 return MESSAGEPORT_ERROR_INVALID_PARAMETER;
175 return MESSAGEPORT_ERROR_IO_ERROR;
179 messageport_check_trusted_local_port(int id, bool *trusted)
181 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
184 return pProxy->CheckTrustedLocalPort(id, trusted);
187 return MESSAGEPORT_ERROR_IO_ERROR;