2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 * @file FIoLocalMessagePort.h
18 * @brief This is the header file for the %LocalMessagePort class.
20 * This header file contains declarations of the %LocalMessagePort class.
22 #ifndef _FIO_LOCAL_MESSAGE_PORT_H_
23 #define _FIO_LOCAL_MESSAGE_PORT_H_
25 #include <FBaseResult.h>
26 #include <FBaseDataType.h>
27 #include <FBaseObject.h>
28 #include <FBaseString.h>
30 namespace Tizen { namespace Io
33 class IMessagePortListener;
36 * @class LocalMessagePort
37 * @brief This class provides methods for receiving messages from other applications.
41 * @final This class is not intended for extension.
43 * The %LocalMessagePort class provides methods for receiving messages from other applications.
45 * For more information on the class features,
46 * see <a href="../org.tizen.native.appprogramming/html/guide/io/messageport.htm">Message Port Communication</a>.
48 * @see Tizen::Io::MessagePortManager
49 * @see Tizen::Io::RemoteMessagePort
51 * The following example demonstrates how to use the %LocalMessagePort class.
58 * using namespace Tizen::Base;
59 * using namespace Tizen::Base::Collection;
60 * using namespace Tizen::Io;
63 * : public Tizen::Io::IMessagePortListener
66 * void Initialize(void);
67 * virtual void OnMessageReceivedN(RemoteMessagePort* pRemoteMessagePort, IMap* pMessage);
68 * IMap* GetOnlineFriends(void);
71 * LocalMessagePort* pLocalPort;
75 * MyAppClass::Initialize(void)
77 * pLocalPort = MessagePortManager::RequestLocalMessagePort(L"PortB");
78 * pLocalPort->AddMessagePortListener(*this);
82 * MyAppClass::OnMessageReceivedN(RemoteMessagePort* pRemoteMessagePort, IMap* pMessage)
84 * String* pValue = static_cast<String*> (pMessage->GetValue(String(L"Request")));
86 * if (*pValue == L"Friend")
88 * HashMap* pMap = GetOnlineFriends();
89 * pRemoteMessagePort->SendMessage(pLocalPort, pMap);
98 * MyAppClass::GetOnlineFriends(void)
100 * HashMap* pMap = new HashMap(SingleObjectDeleter);
103 * pMap->Add(new String(L"Reply"), new String(L"Kim"));
111 class _OSP_EXPORT_ LocalMessagePort
112 : public Tizen::Base::Object
116 * Adds a message port listener that is called when a message is received.
120 * @return An error code
121 * @param[in] listener The message port listener
122 * @exception E_SUCCESS The method is successful.
123 * @exception E_OBJ_ALREADY_EXIST The listener instance already exists.
125 result AddMessagePortListener(IMessagePortListener& listener);
128 * Removes a message port listener.
132 * @return An error code
133 * @param[in] listener The message port listener
134 * @exception E_SUCCESS The method is successful.
135 * @exception E_OBJ_NOT_FOUND The listener instance is not found.
137 result RemoveMessagePortListener(IMessagePortListener& listener);
140 * Gets the name of a local message port.
144 * @return The name of a local message port
146 Tizen::Base::String GetName(void) const;
149 * Checks whether an instance is a trusted message port or not.
153 * @return @c true if this instance is a trusted message port, @n
156 bool IsTrusted(void) const;
160 * This default constructor is intentionally declared as private so that only the platform can create an instance.
162 LocalMessagePort(void);
165 * This destructor is intentionally declared as private so that only the platform can delete an instance.
167 virtual ~LocalMessagePort(void);
170 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
172 LocalMessagePort(const LocalMessagePort& localMessagePort);
175 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
177 LocalMessagePort& operator =(const LocalMessagePort& localMessagePort);
180 friend class _LocalMessagePortImpl;
182 class _LocalMessagePortImpl * __pLocalMessagePortImpl;
184 }; // LocalMessagePort
188 #endif //_FIO_LOCAL_MESSAGE_PORT_H_