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 FIoClientChannel.h
19 * @brief This is the header file for the %ClientChannel class.
21 * This header file contains the declarations of the %ClientChannel class.
23 #ifndef _FIO_CLIENT_CHANNEL_H_
24 #define _FIO_CLIENT_CHANNEL_H_
26 #include <FBaseResult.h>
27 #include <FBaseObject.h>
28 #include <FBaseDataType.h>
29 #include <FAppTypes.h>
30 #include <FIoIChannelResponseEventListener.h>
32 namespace Tizen { namespace Io
37 * @class ClientChannel
38 * @brief <i> [Deprecated] </i> This class provides methods for sending a request to another 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 %ClientChannel class provides methods for sending a request to another application's ServerChannel. To receive a response
46 * for the request, set the ChannelResponseEventListener interface. The instance of %ClientChannel can be retrieved
47 * using ClientChannel::GetInstance().
49 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/io/channels.htm">Channel Communication</a>.
51 * The following example demonstrates how to use the %ClientChannel class.
58 * using namespace Tizen::Base;
59 * using namespace Tizen::Base::Collection;
60 * using namespace Tizen::Io;
61 * using namespace Tizen::App;
64 * : public Tizen::Io::IChannelResponseEventListener
67 * result Initialize(void);
68 * void virtual OnChannelResponseReceivedN(RequestId reqId, Tizen::Io::ClientChannel& clientChannel
69 * , const Tizen::Base::String& serverChannelId
70 * , Tizen::Base::Collection::IList* pArgs);
71 * void GetOnlineFriends(void);
75 * MyAppClass::Initialize(void)
77 * // Sets the channel response event listener.
78 * ClientChannel::GetInstance()->SetChannelResponseEventListener(this);
82 * MyAppClass::OnChannelResponseReceivedN(RequestId reqId, ClientChannel& clientChannel
83 * , const String& serverChannelId
86 * // Handles the channel response.
87 * for(int i = 0; i < pArgs->GetCount(); i++)
89 * AppLog("pData[%d]=%S", i, ((String*)(pArgs->GetAt(i)))->GetPointer());
92 * // Cleans up the arguments.
93 * pArgs->RemoveAll(true);
98 * MyAppClass::GetOnlineFriends(void)
100 * RequestId reqId = 0;
102 * ArrayList* pDataList = new ArrayList();
103 * pDataList->Construct();
105 * String* pData = new String(L"GetList");
106 * String* pData2 = new String(L"Friend");
108 * pDataList->Add(*pData);
109 * pDataList->Add(*pData2);
111 * ClientChannel::GetInstance()->SendRequest(L"1234567890.ContactSvc", pDataList, reqId);
113 * pDataList->RemoveAll(true);
121 class _OSP_EXPORT_ ClientChannel
122 : public Tizen::Base::Object
126 * Gets the default client channel of the application.
130 * @return A pointer to the %ClientChannel instance, @n
131 * else @c null if it fails
132 * @exception E_SUCCESS The method is successful.
133 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
134 * @remarks The specific error code can be accessed using the GetLastResult() method.
136 static ClientChannel* GetInstance(void);
139 * Gets the specific client channel of the application.
143 * @return A pointer to the %ClientChannel instance, @n
144 * else @c null if it fails
145 * @param[in] channelName The channel name
146 * @exception E_SUCCESS The method is successful.
147 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
148 * @remarks The specific error code can be accessed using the GetLastResult() method.
150 static ClientChannel* GetInstance(const Tizen::Base::String& channelName);
153 * Sets the response event listener. @n
154 * The listener is called when a response is received. To reset the event listener, @c null must be passed.
158 * @param[in] pResponseListener The response event listener
160 void SetChannelResponseEventListener(IChannelResponseEventListener* pResponseListener);
163 * Sends a request to the specific server channel of an application specified by the serverChannelId.
167 * @return An error code
168 * @param[in] serverChannelId The server channel ID which can be either application ID or appicationID.ChannelName
169 * @param[in] pArgs A pointer to an argument list of type String
170 * @param[out] reqId The request ID
171 * @exception E_SUCCESS The method is successful.
172 * @exception E_OBJ_NOT_FOUND The server channel is not found.
173 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
175 result SendRequest(const Tizen::Base::String& serverChannelId, const Tizen::Base::Collection::IList* pArgs, RequestId& reqId);
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 ~ClientChannel(void);
190 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
192 ClientChannel(const ClientChannel& clientChannel);
195 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
197 ClientChannel& operator =(const ClientChannel& clientChannel);
199 static void InitSingleton(void);
201 static void DestroySingleton(void);
203 static ClientChannel* __pClientChannelInstance;
205 friend class _ClientChannelImpl;
207 class _ClientChannelImpl* __pClientChannelImpl;
213 #endif //_FIO_CLIENT_CHANNEL_H_