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.
18 * @file FIoRemoteMessagePort.h
19 * @brief This is the header file for the %RemoteMessagePort class.
21 * This header file contains declarations of the %RemoteMessagePort class.
23 #ifndef _FIO_REMOTE_MESSAGE_PORT_H_
24 #define _FIO_REMOTE_MESSAGE_PORT_H_
26 #include <FBaseResult.h>
27 #include <FBaseObject.h>
28 #include <FBaseDataType.h>
29 #include <FBaseColIMap.h>
30 #include <FAppTypes.h>
32 namespace Tizen { namespace Io
35 class LocalMessagePort;
38 * @class RemoteMessagePort
39 * @brief This class provides methods for sending messages to message ports of another application.
43 * @final This class is not intended for extension.
45 * The %RemoteMessagePort class provides methods for sending messages to message ports of another application.
47 * For more information on the class features,
48 * see <a href="../org.tizen.native.appprogramming/html/guide/io/messageport.htm">Message Port Communication</a>.
50 * @see Tizen::Io::MessagePortManager
51 * @see Tizen::Io::LocalMessagePort
58 * using namespace Tizen::Base;
59 * using namespace Tizen::Base::Collection;
60 * using namespace Tizen::Io;
63 * : public Tizen::Io::IMessagePortListener
66 * result Initialize(void);
67 * virtual void OnMessageReceivedN(RemoteMessagePort* pRemoteMessagePort, IMap* pMessage);
68 * void GetOnlineFriends(void);
71 * LocalMessagePort* pLocalPort;
72 * RemoteMessagePort* pRemotePort;
76 * MyAppClass::Initialize(void)
78 * pLocalPort = MessagePortManager::RequestLocalMessagePort(L"PortA");
79 * pLocalPort->AddMessagePortListener(*this);
81 * pRemotePort = MessagePortManager::RequestRemoteMessagePort(L"1234567890.RemoteApp", L"PortB");
85 * MyAppClass::OnMessageReceivedN(RemoteMessagePort* pRemoteMessagePort, IMap* pMessage);
87 * String* pValue = static_cast<String*>(pMessage->GetValue(String(L"Reply")));
89 * AppLog("My friend's name is %ls", pValue->GetPointer());
95 * MyAppClass::GetOnlineFriends(void)
97 * HashMap* pMap = new HashMap(SingleObjectDeleter);
100 * pMap->Add(new String(L"Request"), new String(L"Friend"));
102 * pRemotePort->SendMessage(pLocalPort, pMap);
110 class _OSP_EXPORT_ RemoteMessagePort
111 : public Tizen::Base::Object
116 * Gets the name of a remote message port.
120 * @return The name of a remote message port
122 Tizen::Base::String GetName(void) const;
125 * Gets the ID of a remote application.
129 * @return The ID of a remote application
131 Tizen::App::AppId GetAppId(void) const;
134 * Checks whether an instance is a trusted message port or not.
138 * @return @c true if the instance is a trusted message port, @n
141 bool IsTrusted(void) const;
144 * Sends a message to the message port of a remote application. This method is used for the unidirectional communication.
148 * @return An error code
149 * @param[in] pMessage A pointer to an argument map of key (String) and value (String or ByteBuffer) pair @n
150 * The recommended message size is under 4KB.
151 * @exception E_SUCCESS The method is successful.
152 * @exception E_INVALID_ARG The message argument is not a map of key (String) and value (String or ByteBuffer) pair.
153 * @exception E_OBJ_NOT_FOUND The message port of the target application is not found.
154 * @exception E_MAX_EXCEEDED The size of @c pMessage has exceeded the maximum limit.
155 * @exception E_SYSTEM The method has failed due to a severe system error.
156 * @remarks The recommended message size is under 4KB because severe system performance degradation may occur for large messages. E_MAX_EXCEEDED may be returned for messages over 4KB size.
158 result SendMessage(const Tizen::Base::Collection::IMap* pMessage);
162 * Sends a message to the message port of a remote application. This method is used for the bidirectional communication.
166 * @return An error code
167 * @param[in] pLocalMessagePort The local message port
168 * @param[in] pMessage A pointer to an argument map of key (String) and value (String or ByteBuffer) pair @n
169 * The recommended message size is under 4KB.
170 * @exception E_SUCCESS The method is successful.
171 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
172 * - The local message port is @c null. @n
173 * - The message argument is not a map of key (String) and value (String or ByteBuffer) pair.
174 * @exception E_OBJ_NOT_FOUND The message port of the target application is not found.
175 * @exception E_MAX_EXCEEDED The size of @c pMessage has exceeded the maximum limit.
176 * @exception E_SYSTEM The method has failed due to a severe system error.
177 * @remarks The recommended message size is under 4KB because severe system performance degradation may occur for large messages. E_MAX_EXCEEDED may be returned for messages over 4KB size.
179 result SendMessage(const LocalMessagePort* pLocalMessagePort, const Tizen::Base::Collection::IMap* pMessage);
183 * This default constructor is intentionally declared as private so that only the platform can create an instance.
185 RemoteMessagePort(void);
188 * This destructor is intentionally declared as private so that only the platform can delete an instance.
190 virtual ~RemoteMessagePort(void);
193 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
195 RemoteMessagePort(const RemoteMessagePort& localMessagePort);
198 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
200 RemoteMessagePort& operator =(const RemoteMessagePort& localMessagePort);
203 friend class _RemoteMessagePortImpl;
205 class _RemoteMessagePortImpl * __pRemoteMessagePortImpl;
207 }; // RemoteMessagePort
211 #endif //_FIO_REMOTE_MESSAGE_PORT_H_