remove wrong link page
[platform/framework/native/appfw.git] / inc / FIoServerChannel.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16 /**
17  * @file                FIoServerChannel.h
18  * @brief               This is the header file for the %ServerChannel class.
19  *
20  * This header file contains the declarations of the %ServerChannel class.
21  */
22 #ifndef _FIO_SERVER_CHANNEL_H_
23 #define _FIO_SERVER_CHANNEL_H_
24
25 #include <FBaseResult.h>
26 #include <FBaseObject.h>
27 #include <FBaseDataType.h>
28 #include <FAppTypes.h>
29 #include <FIoIChannelRequestEventListener.h>
30
31 namespace Tizen { namespace Io
32 {
33 /**
34 * @if OSPDEPREC
35 * @class    ServerChannel
36 * @brief    <i> [Deprecated] </i> This class provides methods to receive a request from a client application.
37 *
38 * @deprecated   This class is deprecated. Instead of using this class, use LocalMessagePort, RemoteMessagePort, and MessagePortManager classes.
39 * @since    2.0
40 *
41 * @final        This class is not intended for extension.
42 *
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().
44 *
45 * The following example demonstrates how to use the %ServerChannel class.
46 *
47 * @code
48 *
49 * #include <FBase.h>
50 * #include <FIo.h>
51 *
52 * using namespace Tizen::Base;
53 * using namespace Tizen::Base::Collection;
54 * using namespace Tizen::Io;
55 * using namespace Tizen::App;
56 *
57 * class MyAppClass
58 *       : public Tizen::Io::IChannelRequestEventListener
59 * {
60 * public:
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);
66 * };
67 *
68 * result
69 * MyAppClass::Initialize(void)
70 * {
71 *       result r = E_SUCCESS;
72 *
73 *       // Sets the channel request event listener.
74 *       ServerChannel::GetInstance()->SetChannelRequestEventListener(this);
75 *
76 *       return r;
77 * }
78 *
79 * ArrayList*
80 * MyAppClass::GetOnlineFriends(void)
81 * {
82 *       ArrayList* pDataList = new ArrayList();
83 *       pDataList->Construct();
84
85 *       String* pData = new String(L"Tom");
86 *       String* pData2 = new String(L"Jane");
87 *
88 *       pDataList->Add(*pData);
89 *       pDataList->Add(*pData2);
90 *
91 *       return pDataList;
92 * }
93 *
94 * void
95 * MyAppClass::OnChannelRequestReceivedN(RequestId reqId, ServerChannel& serverChannel
96 *                                                                               , const String& clientChannelId
97 *                                                                               , IList* pArgs)
98 * {
99 *       // Handles the request.
100 *       ArrayList* pList = GetOnlineFriends();
101 *
102 *       // Sends the response to the client.
103 *       serverChannel.SendResponse(clientChannelId, reqId, pList);
104 *
105 *       // Removes the arguments.
106 *       pList->RemoveAll(true);
107 *       delete pList;
108 *
109 *       pArgs->RemoveAll(true);
110 *       delete pArgs;
111 * }
112 *
113 * @endcode
114 * @endif
115 */
116
117 class _OSP_EXPORT_ ServerChannel
118         : public Tizen::Base::Object
119 {
120 public:
121         /**
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.
124         *
125         * @since 2.0
126         *
127         * @param[in] pRequestListener    The request event listener
128         */
129         void SetChannelRequestEventListener(IChannelRequestEventListener* pRequestListener);
130
131         /**
132         * Gets the default server channel of the application.
133         *
134         * @since    2.0
135         *
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.
141         */
142
143         static ServerChannel* GetInstance(void);
144
145         /**
146         * Gets the specific server channel of the application.
147         *
148         * @since        2.0
149         *
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.
156         */
157         static ServerChannel* GetInstance(const Tizen::Base::String& channelName);
158
159         /**
160         * Sends a response to the specific client channel of an application specified by the clientChannelId.
161         *
162         * @since        2.0
163         *
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.
171         */
172         result SendResponse(const Tizen::Base::String& clientChannelId, RequestId reqId, const Tizen::Base::Collection::IList* pArgs);
173
174
175 private:
176         /**
177          * This default constructor is intentionally declared as private to implement the Singleton semantic.
178          */
179         ServerChannel(void);
180
181         /**
182         * This destructor is intentionally declared as private to implement the Singleton semantic.
183         */
184         virtual ~ServerChannel(void);
185
186         /**
187         * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
188         */
189         ServerChannel(const ServerChannel& serverChannel);
190
191         /**
192         * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
193         */
194         ServerChannel& operator =(const ServerChannel& serverChannel);
195
196         static void InitSingleton(void);
197
198         static void DestroySingleton(void);
199
200         friend class _ServerChannelImpl;
201
202         class _ServerChannelImpl * __pServerChannelImpl;
203
204         static ServerChannel* __pServerChannelInstance;
205 }; // ServerChannel
206
207 } } // Tizen::Io
208
209 #endif //_FIO_SERVER_CHANNEL_H_