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 MessagePortProxy.h
20 * @brief This is the header file for the MessagePortProxy class.
22 * This file contains the declarations of MessagePortProxy.
26 #ifndef _MESSAGE_PORT_PROXY_H_
27 #define _MESSAGE_PORT_PROXY_H_
35 #include "message-port.h"
36 #include "message-port-data-types.h"
38 #include "IIpcClientEventListener.h"
40 namespace IPC { class Message; }
44 class MessagePortProxy
45 : public IIpcClientEventListener
48 virtual ~MessagePortProxy(void);
52 virtual void OnIpcResponseReceived(IpcClient& client, const IPC::Message& message);
55 int RegisterMessagePort(const std::string& localPort,
57 messageport_message_cb callback);
59 int CheckRemotePort(const std::string& remoteAppId,
60 const std::string& remotePort,
64 int SendMessage(const std::string& remoteAppId,
65 const std::string& remotePort,
69 int SendMessage(const std::string& localPort,
71 const std::string& remoteAppId,
72 const std::string& remotePort,
76 char* GetLocalPortNameN(int id);
78 int CheckTrustedLocalPort(int id, bool* trusted);
80 static MessagePortProxy* GetProxy(void);
83 MessagePortProxy(void);
85 int SendMessageInternal(const BundleBuffer& buffer);
87 bool OnSendMessageInternal(const BundleBuffer& buffer);
91 bool IsLocalPortRegisted(const std::string& localPort, bool trusted, int &id);
93 int CheckCertificate(const std::string& remoteAppId);
95 bool IsPreloaded(const std::string& remoteAppId);
98 IpcClient* __pIpcClient;
99 pthread_mutex_t* __pMutex;
103 std::map<std::string, messageport_message_cb> __listeners;
104 std::map<std::string, int> __idFromString;
105 std::map<int, std::string> __ids;
107 std::map<std::string, messageport_message_cb> __trustedListeners;
108 std::map<std::string, int> __trustedIdFromString;
109 std::map<int, std::string> __trustedIds;
111 }; // MessagePortProxy
113 #endif // _MESSAGE_PORT_PROXY_H_