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.
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.
24 #ifndef _FIO_SERVER_CHANNEL_H_
25 #define _FIO_SERVER_CHANNEL_H_
27 #include <FBaseResult.h>
28 #include <FBaseObject.h>
29 #include <FBaseDataType.h>
30 #include <FAppTypes.h>
31 #include <FIoIChannelRequestEventListener.h>
33 namespace Tizen { namespace Io
37 * @class ServerChannel
38 * @brief <i> [Deprecated] </i> This class provides methods to receive a request from a client application.
40 * @deprecated This class is deprecated. Instead of using this class, use LocalMessagePort, RemoteMessagePort, and MessagePortManager classes.
43 * @final This class is not intended for extension.
45 * The %ServerChannel class provides methods to receive a request from a client application. An application can receive a
46 * request from another application using the %ServerChannel class. The instance of %ServerChannel is retrieved using
47 * ServerChannel::GetInstance().
49 * The following example demonstrates how to use the %ServerChannel class.
56 * using namespace Tizen::Base;
57 * using namespace Tizen::Base::Collection;
58 * using namespace Tizen::Io;
59 * using namespace Tizen::App;
62 * : public Tizen::Io::IChannelRequestEventListener
65 * result Initialize(void);
66 * ArrayList* GetOnlineFriends(void);
67 * void virtual OnChannelRequestReceivedN(RequestId reqId, Tizen::Io::ServerChannel& serverChannel
68 * , const Tizen::Base::String& clientChannelId
69 * , Tizen::Base::Collection::IList* pArgs);
73 * MyAppClass::Initialize(void)
75 * result r = E_SUCCESS;
77 * // Sets the channel request event listener.
78 * ServerChannel::GetInstance()->SetChannelRequestEventListener(this);
84 * MyAppClass::GetOnlineFriends(void)
86 * ArrayList* pDataList = new ArrayList();
87 * pDataList->Construct();
89 * String* pData = new String(L"Tom");
90 * String* pData2 = new String(L"Jane");
92 * pDataList->Add(*pData);
93 * pDataList->Add(*pData2);
99 * MyAppClass::OnChannelRequestReceivedN(RequestId reqId, ServerChannel& serverChannel
100 * , const String& clientChannelId
103 * // Handles the request.
104 * ArrayList* pList = GetOnlineFriends();
106 * // Sends the response to the client.
107 * serverChannel.SendResponse(clientChannelId, reqId, pList);
109 * // Removes the arguments.
110 * pList->RemoveAll(true);
113 * pArgs->RemoveAll(true);
121 class _OSP_EXPORT_ ServerChannel
122 : public Tizen::Base::Object
126 * Sets the request event listener. @n
127 * The listener is called when a request arrives. To reset the event listener, @c null must be passed.
131 * @param[in] pRequestListener The request event listener
133 void SetChannelRequestEventListener(IChannelRequestEventListener* pRequestListener);
136 * Gets the default server channel of the application.
140 * @return The pointer to the %ServerChannel instance, @n
141 * else @c null if it fails
142 * @exception E_SUCCESS The method is successful.
143 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
144 * @remarks The specific error code can be accessed using the GetLastResult() method.
147 static ServerChannel* GetInstance(void);
150 * Gets the specific server channel of the application.
154 * @return The pointer to the %ServerChannel instance, @n
155 * else @c null if it fails
156 * @param[in] channelName The channel name
157 * @exception E_SUCCESS The method is successful.
158 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
159 * @remarks The specific error code can be accessed using the GetLastResult() method.
161 static ServerChannel* GetInstance(const Tizen::Base::String& channelName);
164 * Sends a response to the specific client channel of an application specified by the clientChannelId.
168 * @return An error code
169 * @param[in] clientChannelId The client channel ID which can be either application ID or appicationID.ChannelName
170 * @param[in] reqId The request ID
171 * @param[in] pArgs A pointer to an argument list of type String
172 * @exception E_SUCCESS The method is successful.
173 * @exception E_OBJ_NOT_FOUND The specified client channel is not found.
174 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
176 result SendResponse(const Tizen::Base::String& clientChannelId, RequestId reqId, const Tizen::Base::Collection::IList* pArgs);
181 * This default constructor is intentionally declared as private to implement the Singleton semantic.
186 * This destructor is intentionally declared as private to implement the Singleton semantic.
188 virtual ~ServerChannel(void);
191 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
193 ServerChannel(const ServerChannel& serverChannel);
196 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
198 ServerChannel& operator =(const ServerChannel& serverChannel);
200 static void InitSingleton(void);
202 static void DestroySingleton(void);
204 friend class _ServerChannelImpl;
206 class _ServerChannelImpl * __pServerChannelImpl;
208 static ServerChannel* __pServerChannelInstance;
213 #endif //_FIO_SERVER_CHANNEL_H_