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 FIoClientChannel.h
19 * @brief This is the header file for the %ClientChannel class.
21 * This header file contains the declarations of the %ClientChannel class.
24 #ifndef _FIO_CLIENT_CHANNEL_H_
25 #define _FIO_CLIENT_CHANNEL_H_
27 #include <FBaseResult.h>
28 #include <FBaseObject.h>
29 #include <FBaseDataType.h>
30 #include <FAppTypes.h>
31 #include <FIoIChannelResponseEventListener.h>
33 namespace Tizen { namespace Io
38 * @class ClientChannel
39 * @brief <i> [Deprecated] </i> This class provides methods for sending a request to another application.
41 * @deprecated This class is deprecated. Instead of using this class, use LocalMessagePort, RemoteMessagePort, and MessagePortManager classes.
44 * @final This class is not intended for extension.
46 * The %ClientChannel class provides methods for sending a request to another application's ServerChannel. To receive a response
47 * for the request, set the ChannelResponseEventListener interface. The instance of %ClientChannel can be retrieved
48 * using ClientChannel::GetInstance().
50 * The following example demonstrates how to use the %ClientChannel class.
57 * using namespace Tizen::Base;
58 * using namespace Tizen::Base::Collection;
59 * using namespace Tizen::Io;
60 * using namespace Tizen::App;
63 * : public Tizen::Io::IChannelResponseEventListener
66 * result Initialize(void);
67 * void virtual OnChannelResponseReceivedN(RequestId reqId, Tizen::Io::ClientChannel& clientChannel
68 * , const Tizen::Base::String& serverChannelId
69 * , Tizen::Base::Collection::IList* pArgs);
70 * void GetOnlineFriends(void);
74 * MyAppClass::Initialize(void)
76 * // Sets the channel response event listener.
77 * ClientChannel::GetInstance()->SetChannelResponseEventListener(this);
81 * MyAppClass::OnChannelResponseReceivedN(RequestId reqId, ClientChannel& clientChannel
82 * , const String& serverChannelId
85 * // Handles the channel response.
86 * for(int i = 0; i < pArgs->GetCount(); i++)
88 * AppLog("pData[%d]=%S", i, ((String*)(pArgs->GetAt(i)))->GetPointer());
91 * // Cleans up the arguments.
92 * pArgs->RemoveAll(true);
97 * MyAppClass::GetOnlineFriends(void)
99 * RequestId reqId = 0;
101 * ArrayList* pDataList = new ArrayList();
102 * pDataList->Construct();
104 * String* pData = new String(L"GetList");
105 * String* pData2 = new String(L"Friend");
107 * pDataList->Add(*pData);
108 * pDataList->Add(*pData2);
110 * ClientChannel::GetInstance()->SendRequest(L"1234567890.ContactSvc", pDataList, reqId);
112 * pDataList->RemoveAll(true);
120 class _OSP_EXPORT_ ClientChannel
121 : public Tizen::Base::Object
125 * Gets the default client channel of the application.
129 * @return A pointer to the %ClientChannel instance, @n
130 * else @c null if it fails
131 * @exception E_SUCCESS The method is successful.
132 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
133 * @remarks The specific error code can be accessed using the GetLastResult() method.
135 static ClientChannel* GetInstance(void);
138 * Gets the specific client channel of the application.
142 * @return A pointer to the %ClientChannel instance, @n
143 * else @c null if it fails
144 * @param[in] channelName The channel name
145 * @exception E_SUCCESS The method is successful.
146 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
147 * @remarks The specific error code can be accessed using the GetLastResult() method.
149 static ClientChannel* GetInstance(const Tizen::Base::String& channelName);
152 * Sets the response event listener. @n
153 * The listener is called when a response is received. To reset the event listener, @c null must be passed.
157 * @param[in] pResponseListener The response event listener
159 void SetChannelResponseEventListener(IChannelResponseEventListener* pResponseListener);
162 * Sends a request to the specific server channel of an application specified by the serverChannelId.
166 * @return An error code
167 * @param[in] serverChannelId The server channel ID which can be either application ID or appicationID.ChannelName
168 * @param[in] pArgs A pointer to an argument list of type String
169 * @param[out] reqId The request ID
170 * @exception E_SUCCESS The method is successful.
171 * @exception E_OBJ_NOT_FOUND The server channel is not found.
172 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
174 result SendRequest(const Tizen::Base::String& serverChannelId, const Tizen::Base::Collection::IList* pArgs, RequestId& reqId);
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 ~ClientChannel(void);
189 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
191 ClientChannel(const ClientChannel& clientChannel);
194 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
196 ClientChannel& operator =(const ClientChannel& clientChannel);
198 static void InitSingleton(void);
200 static void DestroySingleton(void);
202 static ClientChannel* __pClientChannelInstance;
204 friend class _ClientChannelImpl;
206 class _ClientChannelImpl* __pClientChannelImpl;
212 #endif //_FIO_CLIENT_CHANNEL_H_