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 request from another application using the %ServerChannel class. The instance of %ServerChannel is retrieved using ServerChannel::GetInstance().
47 * The following example demonstrates how to use the %ServerChannel class.
54 * using namespace Tizen::Base;
55 * using namespace Tizen::Base::Collection;
56 * using namespace Tizen::Io;
57 * using namespace Tizen::App;
60 * : public Tizen::Io::IChannelRequestEventListener
63 * result Initialize(void);
64 * ArrayList* GetOnlineFriends(void);
65 * void virtual OnChannelRequestReceivedN(RequestId reqId, Tizen::Io::ServerChannel& serverChannel
66 * , const Tizen::Base::String& clientChannelId
67 * , Tizen::Base::Collection::IList* pArgs);
71 * MyAppClass::Initialize(void)
73 * result r = E_SUCCESS;
75 * // Sets the channel request event listener.
76 * ServerChannel::GetInstance()->SetChannelRequestEventListener(this);
82 * MyAppClass::GetOnlineFriends(void)
84 * ArrayList* pDataList = new ArrayList();
85 * pDataList->Construct();
87 * String* pData = new String(L"Tom");
88 * String* pData2 = new String(L"Jane");
90 * pDataList->Add(*pData);
91 * pDataList->Add(*pData2);
97 * MyAppClass::OnChannelRequestReceivedN(RequestId reqId, ServerChannel& serverChannel
98 * , const String& clientChannelId
101 * // Handles the request.
102 * ArrayList* pList = GetOnlineFriends();
104 * // Sends the response to the client.
105 * serverChannel.SendResponse(clientChannelId, reqId, pList);
107 * // Removes the arguments.
108 * pList->RemoveAll(true);
111 * pArgs->RemoveAll(true);
119 class _OSP_EXPORT_ ServerChannel
120 : public Tizen::Base::Object
124 * Sets the request event listener. @n
125 * The listener is called when a request arrives. To reset the event listener, @c null must be passed.
129 * @param[in] pRequestListener The request event listener
131 void SetChannelRequestEventListener(IChannelRequestEventListener* pRequestListener);
134 * Gets the default server channel of the application.
138 * @return A pointer to the %ServerChannel instance, @n
139 * else @c null if it fails
140 * @exception E_SUCCESS The method is successful.
141 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
142 * @remarks The specific error code can be accessed using the GetLastResult() method.
145 static ServerChannel* GetInstance(void);
148 * Gets the specific server channel of the application.
152 * @return A pointer to the %ServerChannel instance, @n
153 * else @c null if it fails
154 * @param[in] channelName The channel name
155 * @exception E_SUCCESS The method is successful.
156 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
157 * @remarks The specific error code can be accessed using the GetLastResult() method.
159 static ServerChannel* GetInstance(const Tizen::Base::String& channelName);
162 * Sends a response to the specific client channel of an application specified by the clientChannelId.
166 * @return An error code
167 * @param[in] clientChannelId The client channel ID which can be either application ID or appicationID.ChannelName
168 * @param[in] reqId The request ID
169 * @param[in] pArgs A pointer to an argument list of type String
170 * @exception E_SUCCESS The method is successful.
171 * @exception E_OBJ_NOT_FOUND The specified client channel is not found.
172 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
174 result SendResponse(const Tizen::Base::String& clientChannelId, RequestId reqId, const Tizen::Base::Collection::IList* pArgs);
179 * This default constructor is intentionally declared as private to implement the Singleton semantic.
184 * This destructor is intentionally declared as private to implement the Singleton semantic.
186 virtual ~ServerChannel(void);
189 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
191 ServerChannel(const ServerChannel& serverChannel);
194 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
196 ServerChannel& operator =(const ServerChannel& serverChannel);
198 static void InitSingleton(void);
200 static void DestroySingleton(void);
202 friend class _ServerChannelImpl;
204 class _ServerChannelImpl * __pServerChannelImpl;
206 static ServerChannel* __pServerChannelInstance;
211 #endif //_FIO_SERVER_CHANNEL_H_