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 FIoLocalMessagePort.h
19 * @brief This is the header file for the %LocalMessagePort class.
21 * This header file contains declarations of the %LocalMessagePort class.
23 #ifndef _FIO_LOCAL_MESSAGE_PORT_H_
24 #define _FIO_LOCAL_MESSAGE_PORT_H_
26 #include <FBaseResult.h>
27 #include <FBaseDataType.h>
28 #include <FBaseObject.h>
29 #include <FBaseString.h>
31 namespace Tizen { namespace Io
34 class IMessagePortListener;
37 * @class LocalMessagePort
38 * @brief This class provides methods for receiving messages from other applications.
42 * @final This class is not intended for extension.
44 * The %LocalMessagePort class provides methods for receiving messages from other applications.
46 * For more information on the class features,
47 * see <a href="../org.tizen.native.appprogramming/html/guide/io/messageport.htm">Message Port Communication</a>.
49 * @see Tizen::Io::MessagePortManager
50 * @see Tizen::Io::RemoteMessagePort
52 * The following example demonstrates how to use the %LocalMessagePort class.
59 * using namespace Tizen::Base;
60 * using namespace Tizen::Base::Collection;
61 * using namespace Tizen::Io;
64 * : public Tizen::Io::IMessagePortListener
67 * void Initialize(void);
68 * virtual void OnMessageReceivedN(RemoteMessagePort* pRemoteMessagePort, IMap* pMessage);
69 * IMap* GetOnlineFriends(void);
72 * LocalMessagePort* pLocalPort;
76 * MyAppClass::Initialize(void)
78 * pLocalPort = MessagePortManager::RequestLocalMessagePort(L"PortB");
79 * pLocalPort->AddMessagePortListener(*this);
83 * MyAppClass::OnMessageReceivedN(RemoteMessagePort* pRemoteMessagePort, IMap* pMessage)
85 * String* pValue = static_cast<String*> (pMessage->GetValue(String(L"Request")));
87 * if (*pValue == L"Friend")
89 * HashMap* pMap = GetOnlineFriends();
90 * pRemoteMessagePort->SendMessage(pLocalPort, pMap);
99 * MyAppClass::GetOnlineFriends(void)
101 * HashMap* pMap = new HashMap(SingleObjectDeleter);
104 * pMap->Add(new String(L"Reply"), new String(L"Kim"));
112 class _OSP_EXPORT_ LocalMessagePort
113 : public Tizen::Base::Object
117 * Adds a message port listener that is called when a message is received.
121 * @return An error code
122 * @param[in] listener The message port listener
123 * @exception E_SUCCESS The method is successful.
124 * @exception E_OBJ_ALREADY_EXIST The listener instance already exists.
126 result AddMessagePortListener(IMessagePortListener& listener);
129 * Removes a message port listener.
133 * @return An error code
134 * @param[in] listener The message port listener
135 * @exception E_SUCCESS The method is successful.
136 * @exception E_OBJ_NOT_FOUND The listener instance is not found.
138 result RemoveMessagePortListener(IMessagePortListener& listener);
141 * Gets the name of a local message port.
145 * @return The name of a local message port
147 Tizen::Base::String GetName(void) const;
150 * Checks whether an instance is a trusted message port or not.
154 * @return @c true if this instance is a trusted message port, @n
157 bool IsTrusted(void) const;
161 * This default constructor is intentionally declared as private so that only the platform can create an instance.
163 LocalMessagePort(void);
166 * This destructor is intentionally declared as private so that only the platform can delete an instance.
168 virtual ~LocalMessagePort(void);
171 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
173 LocalMessagePort(const LocalMessagePort& localMessagePort);
176 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
178 LocalMessagePort& operator =(const LocalMessagePort& localMessagePort);
181 friend class _LocalMessagePortImpl;
183 class _LocalMessagePortImpl * __pLocalMessagePortImpl;
185 }; // LocalMessagePort
189 #endif //_FIO_LOCAL_MESSAGE_PORT_H_