Modify Scanner class
[platform/framework/native/appfw.git] / inc / FIoServerChannel.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 /**
18  * @file                FIoServerChannel.h
19  * @brief               This is the header file for the %ServerChannel class.
20  *
21  * This header file contains the declarations of the %ServerChannel class.
22  */
23 #ifndef _FIO_SERVER_CHANNEL_H_
24 #define _FIO_SERVER_CHANNEL_H_
25
26 #include <FBaseResult.h>
27 #include <FBaseObject.h>
28 #include <FBaseDataType.h>
29 #include <FAppTypes.h>
30 #include <FIoIChannelRequestEventListener.h>
31
32 namespace Tizen { namespace Io
33 {
34 /**
35 * @if OSPDEPREC
36 * @class    ServerChannel
37 * @brief    <i> [Deprecated] </i> This class provides methods to receive a request from a client application.
38 *
39 * @deprecated   This class is deprecated. Instead of using this class, use LocalMessagePort, RemoteMessagePort, and MessagePortManager classes.
40 * @since    2.0
41 *
42 * @final        This class is not intended for extension.
43 *
44 * 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 * @n
46 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/io/channels.htm">Channel Communication</a>.
47 *
48 * The following example demonstrates how to use the %ServerChannel class.
49 *
50 * @code
51 *
52 * #include <FBase.h>
53 * #include <FIo.h>
54 *
55 * using namespace Tizen::Base;
56 * using namespace Tizen::Base::Collection;
57 * using namespace Tizen::Io;
58 * using namespace Tizen::App;
59 *
60 * class MyAppClass
61 *       : public Tizen::Io::IChannelRequestEventListener
62 * {
63 * public:
64 *       result Initialize(void);
65 *       ArrayList* GetOnlineFriends(void);
66 *       void virtual OnChannelRequestReceivedN(RequestId reqId, Tizen::Io::ServerChannel& serverChannel
67 *                                                                               , const Tizen::Base::String& clientChannelId
68 *                                                                               , Tizen::Base::Collection::IList* pArgs);
69 * };
70 *
71 * result
72 * MyAppClass::Initialize(void)
73 * {
74 *       result r = E_SUCCESS;
75 *
76 *       // Sets the channel request event listener.
77 *       ServerChannel::GetInstance()->SetChannelRequestEventListener(this);
78 *
79 *       return r;
80 * }
81 *
82 * ArrayList*
83 * MyAppClass::GetOnlineFriends(void)
84 * {
85 *       ArrayList* pDataList = new ArrayList();
86 *       pDataList->Construct();
87
88 *       String* pData = new String(L"Tom");
89 *       String* pData2 = new String(L"Jane");
90 *
91 *       pDataList->Add(*pData);
92 *       pDataList->Add(*pData2);
93 *
94 *       return pDataList;
95 * }
96 *
97 * void
98 * MyAppClass::OnChannelRequestReceivedN(RequestId reqId, ServerChannel& serverChannel
99 *                                                                               , const String& clientChannelId
100 *                                                                               , IList* pArgs)
101 * {
102 *       // Handles the request.
103 *       ArrayList* pList = GetOnlineFriends();
104 *
105 *       // Sends the response to the client.
106 *       serverChannel.SendResponse(clientChannelId, reqId, pList);
107 *
108 *       // Removes the arguments.
109 *       pList->RemoveAll(true);
110 *       delete pList;
111 *
112 *       pArgs->RemoveAll(true);
113 *       delete pArgs;
114 * }
115 *
116 * @endcode
117 * @endif
118 */
119
120 class _OSP_EXPORT_ ServerChannel
121         : public Tizen::Base::Object
122 {
123 public:
124         /**
125         * Sets the request event listener. @n
126         * The listener is called when a request arrives. To reset the event listener, @c null must be passed.
127         *
128         * @since 2.0
129         *
130         * @param[in] pRequestListener    The request event listener
131         */
132         void SetChannelRequestEventListener(IChannelRequestEventListener* pRequestListener);
133
134         /**
135         * Gets the default server channel of the application.
136         *
137         * @since    2.0
138         *
139         * @return       A pointer to the %ServerChannel instance, @n
140         *                       else @c null if it fails
141         * @exception    E_SUCCESS           The method is successful.
142         * @exception    E_SYSTEM            The method cannot proceed due to a severe system error.
143         * @remarks              The specific error code can be accessed using the GetLastResult() method.
144         */
145
146         static ServerChannel* GetInstance(void);
147
148         /**
149         * Gets the specific server channel of the application.
150         *
151         * @since        2.0
152         *
153         * @return       A pointer to the %ServerChannel instance, @n
154         *                       else @c null if it fails
155         * @param[in]    channelName         The channel name
156         * @exception    E_SUCCESS           The method is successful.
157         * @exception    E_SYSTEM            The method cannot proceed due to a severe system error.
158         * @remarks              The specific error code can be accessed using the GetLastResult() method.
159         */
160         static ServerChannel* GetInstance(const Tizen::Base::String& channelName);
161
162         /**
163         * Sends a response to the specific client channel of an application specified by the clientChannelId.
164         *
165         * @since        2.0
166         *
167         * @return    An error code
168         * @param[in]    clientChannelId     The client channel ID which can be either application ID or appicationID.ChannelName
169         * @param[in]    reqId               The request ID
170         * @param[in]    pArgs               A pointer to an argument list of type String
171         * @exception    E_SUCCESS           The method is successful.
172         * @exception    E_OBJ_NOT_FOUND     The specified client channel is not found.
173         * @exception    E_SYSTEM            The method cannot proceed due to a severe system error.
174         */
175         result SendResponse(const Tizen::Base::String& clientChannelId, RequestId reqId, const Tizen::Base::Collection::IList* pArgs);
176
177
178 private:
179         /**
180          * This default constructor is intentionally declared as private to implement the Singleton semantic.
181          */
182         ServerChannel(void);
183
184         /**
185         * This destructor is intentionally declared as private to implement the Singleton semantic.
186         */
187         virtual ~ServerChannel(void);
188
189         /**
190         * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
191         */
192         ServerChannel(const ServerChannel& serverChannel);
193
194         /**
195         * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
196         */
197         ServerChannel& operator =(const ServerChannel& serverChannel);
198
199         static void InitSingleton(void);
200
201         static void DestroySingleton(void);
202
203         friend class _ServerChannelImpl;
204
205         class _ServerChannelImpl * __pServerChannelImpl;
206
207         static ServerChannel* __pServerChannelInstance;
208 }; // ServerChannel
209
210 } } // Tizen::Io
211
212 #endif //_FIO_SERVER_CHANNEL_H_