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 FIoServerChannel.h
19 * @brief This is the header file for the %ServerChannel class.
21 * This header file contains the declarations of the %ServerChannel class.
23 #ifndef _FIO_SERVER_CHANNEL_H_
24 #define _FIO_SERVER_CHANNEL_H_
26 #include <FBaseResult.h>
27 #include <FBaseObject.h>
28 #include <FBaseDataType.h>
29 #include <FAppTypes.h>
30 #include <FIoIChannelRequestEventListener.h>
32 namespace Tizen { namespace Io
36 * @class ServerChannel
37 * @brief <i> [Deprecated] </i> This class provides methods to receive a request from a client application.
39 * @deprecated This class is deprecated. Instead of using this class, use LocalMessagePort, RemoteMessagePort, and MessagePortManager classes.
42 * @final This class is not intended for extension.
44 * The %ServerChannel class provides methods to receive a request from a client application. An application can receive a request from another application using the %ServerChannel class. The instance of %ServerChannel is retrieved using ServerChannel::GetInstance().
46 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/io/channels.htm">Channel Communication</a>.
48 * The following example demonstrates how to use the %ServerChannel class.
55 * using namespace Tizen::Base;
56 * using namespace Tizen::Base::Collection;
57 * using namespace Tizen::Io;
58 * using namespace Tizen::App;
61 * : public Tizen::Io::IChannelRequestEventListener
64 * result Initialize(void);
65 * ArrayList* GetOnlineFriends(void);
66 * void virtual OnChannelRequestReceivedN(RequestId reqId, Tizen::Io::ServerChannel& serverChannel
67 * , const Tizen::Base::String& clientChannelId
68 * , Tizen::Base::Collection::IList* pArgs);
72 * MyAppClass::Initialize(void)
74 * result r = E_SUCCESS;
76 * // Sets the channel request event listener.
77 * ServerChannel::GetInstance()->SetChannelRequestEventListener(this);
83 * MyAppClass::GetOnlineFriends(void)
85 * ArrayList* pDataList = new ArrayList();
86 * pDataList->Construct();
88 * String* pData = new String(L"Tom");
89 * String* pData2 = new String(L"Jane");
91 * pDataList->Add(*pData);
92 * pDataList->Add(*pData2);
98 * MyAppClass::OnChannelRequestReceivedN(RequestId reqId, ServerChannel& serverChannel
99 * , const String& clientChannelId
102 * // Handles the request.
103 * ArrayList* pList = GetOnlineFriends();
105 * // Sends the response to the client.
106 * serverChannel.SendResponse(clientChannelId, reqId, pList);
108 * // Removes the arguments.
109 * pList->RemoveAll(true);
112 * pArgs->RemoveAll(true);
120 class _OSP_EXPORT_ ServerChannel
121 : public Tizen::Base::Object
125 * Sets the request event listener. @n
126 * The listener is called when a request arrives. To reset the event listener, @c null must be passed.
130 * @param[in] pRequestListener The request event listener
132 void SetChannelRequestEventListener(IChannelRequestEventListener* pRequestListener);
135 * Gets the default server channel of the application.
139 * @return A pointer to the %ServerChannel instance, @n
140 * else @c null if it fails
141 * @exception E_SUCCESS The method is successful.
142 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
143 * @remarks The specific error code can be accessed using the GetLastResult() method.
146 static ServerChannel* GetInstance(void);
149 * Gets the specific server channel of the application.
153 * @return A pointer to the %ServerChannel instance, @n
154 * else @c null if it fails
155 * @param[in] channelName The channel name
156 * @exception E_SUCCESS The method is successful.
157 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
158 * @remarks The specific error code can be accessed using the GetLastResult() method.
160 static ServerChannel* GetInstance(const Tizen::Base::String& channelName);
163 * Sends a response to the specific client channel of an application specified by the clientChannelId.
167 * @return An error code
168 * @param[in] clientChannelId The client channel ID which can be either application ID or appicationID.ChannelName
169 * @param[in] reqId The request ID
170 * @param[in] pArgs A pointer to an argument list of type String
171 * @exception E_SUCCESS The method is successful.
172 * @exception E_OBJ_NOT_FOUND The specified client channel is not found.
173 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
175 result SendResponse(const Tizen::Base::String& clientChannelId, RequestId reqId, const Tizen::Base::Collection::IList* pArgs);
180 * This default constructor is intentionally declared as private to implement the Singleton semantic.
185 * This destructor is intentionally declared as private to implement the Singleton semantic.
187 virtual ~ServerChannel(void);
190 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
192 ServerChannel(const ServerChannel& serverChannel);
195 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
197 ServerChannel& operator =(const ServerChannel& serverChannel);
199 static void InitSingleton(void);
201 static void DestroySingleton(void);
203 friend class _ServerChannelImpl;
205 class _ServerChannelImpl * __pServerChannelImpl;
207 static ServerChannel* __pServerChannelInstance;
212 #endif //_FIO_SERVER_CHANNEL_H_