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 FIoServerChannel.h
18 * @brief This is the header file for the %ServerChannel class.
20 * This header file contains the declarations of the %ServerChannel class.
22 #ifndef _FIO_SERVER_CHANNEL_H_
23 #define _FIO_SERVER_CHANNEL_H_
25 #include <FBaseResult.h>
26 #include <FBaseObject.h>
27 #include <FBaseDataType.h>
28 #include <FAppTypes.h>
29 #include <FIoIChannelRequestEventListener.h>
31 namespace Tizen { namespace Io
35 * @class ServerChannel
36 * @brief <i> [Deprecated] </i> This class provides methods to receive a request from a client application.
38 * @deprecated This class is deprecated. Instead of using this class, use LocalMessagePort, RemoteMessagePort, and MessagePortManager classes.
41 * @final This class is not intended for extension.
43 * 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().
45 * The following example demonstrates how to use the %ServerChannel class.
52 * using namespace Tizen::Base;
53 * using namespace Tizen::Base::Collection;
54 * using namespace Tizen::Io;
55 * using namespace Tizen::App;
58 * : public Tizen::Io::IChannelRequestEventListener
61 * result Initialize(void);
62 * ArrayList* GetOnlineFriends(void);
63 * void virtual OnChannelRequestReceivedN(RequestId reqId, Tizen::Io::ServerChannel& serverChannel
64 * , const Tizen::Base::String& clientChannelId
65 * , Tizen::Base::Collection::IList* pArgs);
69 * MyAppClass::Initialize(void)
71 * result r = E_SUCCESS;
73 * // Sets the channel request event listener.
74 * ServerChannel::GetInstance()->SetChannelRequestEventListener(this);
80 * MyAppClass::GetOnlineFriends(void)
82 * ArrayList* pDataList = new ArrayList();
83 * pDataList->Construct();
85 * String* pData = new String(L"Tom");
86 * String* pData2 = new String(L"Jane");
88 * pDataList->Add(*pData);
89 * pDataList->Add(*pData2);
95 * MyAppClass::OnChannelRequestReceivedN(RequestId reqId, ServerChannel& serverChannel
96 * , const String& clientChannelId
99 * // Handles the request.
100 * ArrayList* pList = GetOnlineFriends();
102 * // Sends the response to the client.
103 * serverChannel.SendResponse(clientChannelId, reqId, pList);
105 * // Removes the arguments.
106 * pList->RemoveAll(true);
109 * pArgs->RemoveAll(true);
117 class _OSP_EXPORT_ ServerChannel
118 : public Tizen::Base::Object
122 * Sets the request event listener. @n
123 * The listener is called when a request arrives. To reset the event listener, @c null must be passed.
127 * @param[in] pRequestListener The request event listener
129 void SetChannelRequestEventListener(IChannelRequestEventListener* pRequestListener);
132 * Gets the default server channel of the application.
136 * @return A pointer to the %ServerChannel instance, @n
137 * else @c null if it fails
138 * @exception E_SUCCESS The method is successful.
139 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
140 * @remarks The specific error code can be accessed using the GetLastResult() method.
143 static ServerChannel* GetInstance(void);
146 * Gets the specific server channel of the application.
150 * @return A pointer to the %ServerChannel instance, @n
151 * else @c null if it fails
152 * @param[in] channelName The channel name
153 * @exception E_SUCCESS The method is successful.
154 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
155 * @remarks The specific error code can be accessed using the GetLastResult() method.
157 static ServerChannel* GetInstance(const Tizen::Base::String& channelName);
160 * Sends a response to the specific client channel of an application specified by the clientChannelId.
164 * @return An error code
165 * @param[in] clientChannelId The client channel ID which can be either application ID or appicationID.ChannelName
166 * @param[in] reqId The request ID
167 * @param[in] pArgs A pointer to an argument list of type String
168 * @exception E_SUCCESS The method is successful.
169 * @exception E_OBJ_NOT_FOUND The specified client channel is not found.
170 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
172 result SendResponse(const Tizen::Base::String& clientChannelId, RequestId reqId, const Tizen::Base::Collection::IList* pArgs);
177 * This default constructor is intentionally declared as private to implement the Singleton semantic.
182 * This destructor is intentionally declared as private to implement the Singleton semantic.
184 virtual ~ServerChannel(void);
187 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
189 ServerChannel(const ServerChannel& serverChannel);
192 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
194 ServerChannel& operator =(const ServerChannel& serverChannel);
196 static void InitSingleton(void);
198 static void DestroySingleton(void);
200 friend class _ServerChannelImpl;
202 class _ServerChannelImpl * __pServerChannelImpl;
204 static ServerChannel* __pServerChannelInstance;
209 #endif //_FIO_SERVER_CHANNEL_H_