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 pProxy->CheckTrustedLocalPort(id, &trusted);
113 ret = pProxy->SendMessage(pName, trusted, remote_app_id, remote_port, false, message);
120 return MESSAGEPORT_ERROR_IO_ERROR;
124 messageport_send_bidirectional_trusted_message(int id, const char* remote_app_id, const char* remote_port, bundle* message)
126 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
129 bool trusted = false;
130 int ret = pProxy->CheckTrustedLocalPort(id, &trusted);
136 char* pName = pProxy->GetLocalPortNameN(id);
139 return MESSAGEPORT_ERROR_INVALID_PARAMETER;
142 ret = pProxy->SendMessage(pName, trusted, remote_app_id, remote_port, true, message);
149 return MESSAGEPORT_ERROR_IO_ERROR;
153 messageport_get_local_port_name(int id, char **name)
155 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
158 char* pName = pProxy->GetLocalPortNameN(id);
161 return MESSAGEPORT_ERROR_INVALID_PARAMETER;
170 return MESSAGEPORT_ERROR_IO_ERROR;
174 messageport_check_trusted_local_port(int id, bool *trusted)
176 MessagePortProxy* pProxy = MessagePortProxy::GetProxy();
179 return pProxy->CheckTrustedLocalPort(id, trusted);
182 return MESSAGEPORT_ERROR_IO_ERROR;