|
1 /* |
|
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_HNMDSERVICEHANDLER_H |
|
20 #define C_HNMDSERVICEHANDLER_H |
|
21 |
|
22 //#include <mnaiwservices.h> |
|
23 #include <liwcommon.h> |
|
24 #include <e32base.h> |
|
25 #include <xmlengelement.h> |
|
26 |
|
27 #include "hnglobals.h" |
|
28 |
|
29 class CLiwServiceHandler; |
|
30 class CHnMdQuery; |
|
31 class CLiwGenericParamList; |
|
32 class MLiwInterface; |
|
33 class CLiwDefaultMap; |
|
34 class CHnMdBaseKey; |
|
35 class CHnMdServiceCommand; |
|
36 class CHnServiceHandler; |
|
37 |
|
38 /** |
|
39 * Class represeting request to LIW service. |
|
40 * The request can be synchronous or asynchronous. |
|
41 * |
|
42 * @since S60 5.0 |
|
43 * @ingroup group_hnutilities |
|
44 */ |
|
45 NONSHARABLE_CLASS(CHnServiceHandler) : public CBase, public MLiwNotifyCallback |
|
46 { |
|
47 public: |
|
48 |
|
49 /** |
|
50 * Two-phase constructor. |
|
51 * |
|
52 * @since S60 5.0 |
|
53 * @param aService Service name. |
|
54 * @param aInterface Interface name. |
|
55 * @param aCommand Request to the Service. |
|
56 * @param aMode Asynchronous or Synchronous Request. |
|
57 * @param aConstructor Parameters used during Service construction. |
|
58 * @param aServiceCommand Additional Parameters for the Request. |
|
59 * @return Fully cosntructed object. |
|
60 */ |
|
61 IMPORT_C static CHnServiceHandler* NewL( |
|
62 const TDesC8& aService, const TDesC8& aInterface, |
|
63 const TDesC8& aCommand, TServiceMode aMode, |
|
64 CLiwGenericParamList* aConstructor, |
|
65 CLiwGenericParamList* aServiceCommand ); |
|
66 |
|
67 /** |
|
68 * Two-phase constructor. |
|
69 * |
|
70 * @since S60 5.0 |
|
71 * @param aService Service name. |
|
72 * @param aInterface Interface name. |
|
73 * @param aCommand Request to the Service. |
|
74 * @param aMode Asynchronous or Synchronous Request. |
|
75 * @param aConstructor Parameters used during Service construction. |
|
76 * @param aServiceCommand Additional Parameters for the Request. |
|
77 * @return Fully cosntructed object. |
|
78 */ |
|
79 IMPORT_C static CHnServiceHandler* NewLC( |
|
80 const TDesC8& aService, const TDesC8& aInterface, |
|
81 const TDesC8& aCommand, TServiceMode aMode, |
|
82 CLiwGenericParamList* aConstructor, |
|
83 CLiwGenericParamList* aServiceCommand ); |
|
84 |
|
85 /** |
|
86 * Standard C++ virtual destructor. |
|
87 * |
|
88 * @since S60 5.0 |
|
89 */ |
|
90 IMPORT_C virtual ~CHnServiceHandler(); |
|
91 |
|
92 /** |
|
93 * Executes the Request on the service. |
|
94 * |
|
95 * since S60 v5.0 |
|
96 * @param aOutParamList Request outcome. |
|
97 * @param aStatus Status for signalling when request completes. |
|
98 * @return Error code. |
|
99 */ |
|
100 IMPORT_C TInt ExecuteL( CLiwGenericParamList& aOutParamList, TRequestStatus& aStatus ); |
|
101 |
|
102 /** |
|
103 * Executes the query on the service, with external |
|
104 * notification callback. |
|
105 * |
|
106 * since S60 v5.0 |
|
107 * @param aCallback Notification callback. |
|
108 * @param aCmdOptions Additional options for the Request. |
|
109 * @return Error code. |
|
110 */ |
|
111 IMPORT_C TInt ExecuteL( MLiwNotifyCallback* aCallback, |
|
112 TInt aCmdOptions = 0 ); |
|
113 |
|
114 |
|
115 /** |
|
116 * Executes the query on the service. |
|
117 * Deprecated - Do not Use this method!!!! Will be removed asap. |
|
118 * |
|
119 * since S60 v5.0 |
|
120 * @return Error code. |
|
121 */ |
|
122 IMPORT_C TInt ExecuteL(); |
|
123 |
|
124 /** |
|
125 * Checks if an action model matches an existing service. |
|
126 * |
|
127 * since S60 v5.0 |
|
128 * @param aService service. |
|
129 * @param aInterface interface. |
|
130 * @param aConstructor constructor. |
|
131 * @return true if an action model matches the service. |
|
132 */ |
|
133 IMPORT_C TBool ServiceHandlerMatchesModel( |
|
134 const TDesC8& aService, |
|
135 const TDesC8& aInterface, |
|
136 const CLiwGenericParamList* aConstructor ) const; |
|
137 |
|
138 /** |
|
139 * Allows for reusing the object when a request needs to be invoked on |
|
140 * the same interface of the same service. |
|
141 * |
|
142 * @param aCommand Request to the Service. |
|
143 * @param aMode Asynchronous or Synchronous Request. |
|
144 * @param aServiceCommand Additional Parameters for the Request. |
|
145 */ |
|
146 IMPORT_C void PrepareForNextExecutionL( const TDesC8& aCommand, |
|
147 TServiceMode aMode, CLiwGenericParamList* aServiceCommand ); |
|
148 |
|
149 private: |
|
150 |
|
151 /** |
|
152 * Standard C++ constructor. |
|
153 * |
|
154 * @since S60 5.0 |
|
155 * @param aMode Synchronous or asynchronous. |
|
156 */ |
|
157 CHnServiceHandler( TServiceMode aMode ); |
|
158 |
|
159 |
|
160 /** |
|
161 * Standard symbian 2nd phase contructor. |
|
162 * |
|
163 * @since S60 5.0 |
|
164 * @param aService Service name. |
|
165 * @param aInterface Interface name. |
|
166 * @param aCommandName Request to the Service. |
|
167 * @param aConstructor Parameters used during Service construction. |
|
168 * @param aServiceCommand Additional Parameters for the Request. |
|
169 */ |
|
170 void ConstructL( |
|
171 const TDesC8& aService, const TDesC8& aInterface, |
|
172 const TDesC8& aCommandName, |
|
173 CLiwGenericParamList* aConstructor, |
|
174 CLiwGenericParamList* aServiceCommand ); |
|
175 |
|
176 |
|
177 /** |
|
178 * Handles notifications caused by an asynchronous Request. |
|
179 * |
|
180 * @param aCmdId The service command associated to the event. |
|
181 * @param aEventId Occured event, see LiwCommon.hrh. |
|
182 * @param aEventParamList Event parameters, if any, as defined per |
|
183 * each event. |
|
184 * @param aInParamList Input parameters, if any, given in the |
|
185 * related HandleCommmandL. |
|
186 * @return Error code for the callback. |
|
187 */ |
|
188 TInt HandleNotifyL( |
|
189 TInt aCmdId, |
|
190 TInt aEventId, |
|
191 CLiwGenericParamList& aEventParamList, |
|
192 const CLiwGenericParamList& aInParamList); |
|
193 |
|
194 /** |
|
195 * Creates interface. |
|
196 * |
|
197 * @param aConstructor constructor |
|
198 * @return Error code. |
|
199 */ |
|
200 TInt SetServiceInterfaceL( CLiwGenericParamList* aConstructor ); |
|
201 |
|
202 private: // data |
|
203 |
|
204 /** |
|
205 * Service name. |
|
206 * Own. |
|
207 */ |
|
208 RBuf8 iServiceName; |
|
209 |
|
210 /** |
|
211 * Interface name. |
|
212 * Own. |
|
213 */ |
|
214 RBuf8 iInterfaceName; |
|
215 |
|
216 /** |
|
217 * Command (Request) name. |
|
218 * Own. |
|
219 */ |
|
220 RBuf8 iCommandName; |
|
221 |
|
222 /** |
|
223 * Service mode. |
|
224 */ |
|
225 TServiceMode iMode; |
|
226 |
|
227 /** |
|
228 * Stores input parameters (not data) of the service search method\ |
|
229 * (ExecuteServiceCmdL). |
|
230 * Own. |
|
231 */ |
|
232 CLiwGenericParamList* iConstructor; |
|
233 |
|
234 /** |
|
235 * |
|
236 * Own. |
|
237 */ |
|
238 CLiwGenericParamList* iCommand; |
|
239 |
|
240 /** |
|
241 * Parameters for the Request. |
|
242 * Own. |
|
243 */ |
|
244 CLiwGenericParamList* iInput; |
|
245 |
|
246 /** |
|
247 * Request results from ExecuteL(); |
|
248 * Own. |
|
249 */ |
|
250 CLiwGenericParamList* iOutputForAS; |
|
251 |
|
252 /** |
|
253 * Request results from |
|
254 * ExecuteL( CLiwGenericParamList& aOutParamList, TRequestStatus& aStatus ). |
|
255 * Own. |
|
256 */ |
|
257 CLiwGenericParamList* iOutputForAO; |
|
258 |
|
259 /** |
|
260 * Service interface. |
|
261 */ |
|
262 MLiwInterface* iServiceInterface; |
|
263 |
|
264 /** |
|
265 * Service Handler. |
|
266 * Own. |
|
267 */ |
|
268 CLiwServiceHandler* iServiceHandler; |
|
269 |
|
270 /** |
|
271 * Client status. |
|
272 * Not Own. |
|
273 */ |
|
274 TRequestStatus* iClientStatus; |
|
275 |
|
276 /** |
|
277 * Waits for asynchronous queries. |
|
278 * Own. |
|
279 */ |
|
280 CActiveSchedulerWait* iWait; |
|
281 |
|
282 }; |
|
283 |
|
284 #endif // C_HNMDSERVICEHANDLER_H |