|
1 /* |
|
2 * Copyright (c) 2002-2005 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 the License "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: header file for CIptvServiceManagementSync class* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CIPTVSERVICEMANAGEMENTSYNC_H__ |
|
21 #define __CIPTVSERVICEMANAGEMENTSYNC_H__ |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <e32base.h> |
|
25 #include "MIptvServiceManagementClientObserver.h" |
|
26 #include "CIptvServiceManagementClient.h" |
|
27 #include "CIptvService.h" |
|
28 #include "MIptvTestTimerObserver.h" |
|
29 #include <badesca.h> |
|
30 #include <f32file.h> |
|
31 #include <S32FILE.H> |
|
32 |
|
33 // DATA TYPES |
|
34 typedef MIptvServiceManagementClientObserver::TRespStatus TRespStatus; |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class CIptvServiceManagementClient; |
|
38 class CIptvTestTimer; |
|
39 class CIptvTestUtilities; |
|
40 class CIptvTestActiveWait; |
|
41 class CIptvSmEvent; |
|
42 |
|
43 // CLASS DECLARATION |
|
44 class CIptvServiceManagementSync : public CBase, public MIptvServiceManagementClientObserver, public MIptvTestTimerObserver |
|
45 { |
|
46 public: //enums |
|
47 |
|
48 /** |
|
49 * TIptvSmTestConnection |
|
50 */ |
|
51 enum TIptvSmTestConnection |
|
52 { |
|
53 EIptvSmTestSync, |
|
54 EIptvSmTestAsync |
|
55 } ; |
|
56 /** |
|
57 * TIptvSmSpecialAction |
|
58 */ |
|
59 enum TIptvSmSpecialAction |
|
60 { |
|
61 EIptvSmNoSpecialAction, |
|
62 EIptvSmCancelNextAsyncRequest, |
|
63 EIptvSmWaitNoEvents |
|
64 }; |
|
65 |
|
66 public: // Constructors and destructors |
|
67 /** |
|
68 * NewL. |
|
69 * Two-phased constructor. |
|
70 * Creates a CIptvServiceManagementSync object using two phase construction, |
|
71 * and return a pointer to the created object. |
|
72 * @param aClient pointer to client, no ownership is transferred. |
|
73 * @return A pointer to the created instance of CIptvServiceManagementSync. |
|
74 */ |
|
75 static CIptvServiceManagementSync* NewL(); |
|
76 |
|
77 /** |
|
78 * ~CIptvServiceManagementSync. |
|
79 * Destructor. |
|
80 * Destroys the object and releases all memory objects. |
|
81 */ |
|
82 virtual ~CIptvServiceManagementSync(); |
|
83 |
|
84 public: // New functions |
|
85 |
|
86 /** |
|
87 * Adds service to service database using CIptvServiceManagementClient method AddServiceReqL or AddServiceL. |
|
88 * @param aConn Async/sync call. |
|
89 * @param aService Service data which is added to database. |
|
90 * @return Response status. |
|
91 */ |
|
92 TRespStatus CallAddService(TIptvSmTestConnection aConn, CIptvService& aService); |
|
93 |
|
94 /** |
|
95 * Updates existing service in service database using CIptvServiceManagementClient method UpdateServiceReqL or UpdateServiceL. |
|
96 * @param aConn Async/sync call. |
|
97 * @param aService Updated service data. |
|
98 * @param aExpectedEvent Expected event, this usually is CIptvSmEvent::EServiceModified. |
|
99 * @return Response status. |
|
100 */ |
|
101 TRespStatus CallUpdateService(TIptvSmTestConnection aConn, CIptvService& aService, CIptvSmEvent::TEvent aExpectedEvent); |
|
102 |
|
103 /** |
|
104 * Gets services by id from service database using CIptvServiceManagementClient method |
|
105 * GetServicesReqL or GetServicesL. |
|
106 * @param aConn Async/sync call. |
|
107 * @param aStartId |
|
108 * @param aEndId |
|
109 * @param aServicesArray Returned serviecs are stored here |
|
110 * @return Response status. |
|
111 */ |
|
112 TRespStatus CallGetServices( |
|
113 TIptvSmTestConnection aConn, |
|
114 TUint32 aStartId, |
|
115 TUint32 aEndId, |
|
116 CDesC8ArraySeg** aServicesArray |
|
117 ); |
|
118 |
|
119 /** |
|
120 * Gets services by provider id from service database by calling method CIptvServiceManagementClient::GetServicesL. |
|
121 * @param aProviderId |
|
122 * @param aServices Returned serviecs are stored here |
|
123 * @return Response status. |
|
124 */ |
|
125 TRespStatus CallGetServicesByProviderId( |
|
126 TDesC& aProviderId, |
|
127 CIptvServices& aServices |
|
128 ); |
|
129 |
|
130 /** |
|
131 * Gets filtered services from service database using CIptvServiceManagementClient method GetServicesReqL or |
|
132 * GetServicesL. |
|
133 * @param aSearchLimitFlags |
|
134 * @param aOrder |
|
135 * @param aConn Async/sync call. |
|
136 * @param aServicesArray Returned serviecs are stored here. |
|
137 * @return Response status. |
|
138 */ |
|
139 TRespStatus CallGetServicesFiltered( |
|
140 TUint32 aSearchLimitFlags, |
|
141 CIptvServiceManagementClient::TOrder aOrder, |
|
142 TIptvSmTestConnection aConn, |
|
143 CDesC8ArraySeg** aServicesArray |
|
144 ); |
|
145 |
|
146 /** |
|
147 * Deletes a service from service database using CIptvServiceManagementClient method DeleteServiceReqL or |
|
148 * DeleteServiceL. |
|
149 * @param aConn Async/sync call. |
|
150 * @param aId Id of service to be deleted. |
|
151 * @return Response status. |
|
152 */ |
|
153 TRespStatus CallDeleteService(TIptvSmTestConnection aConn, TUint32 aId); |
|
154 |
|
155 /** |
|
156 * Functionality disabled in CIptvServiceManagementClient. |
|
157 * Requests IPTV server to shutdown itself. Request is asynchronous. |
|
158 * @param aConn Async/sync call. |
|
159 * @return Response status. |
|
160 */ |
|
161 TRespStatus CallShutdownServer(TIptvSmTestConnection aConn ); |
|
162 |
|
163 /** |
|
164 * Sets the used IAP for a service using CIptvServiceManagementClient method SetUsedIapL. |
|
165 * @param aIapId |
|
166 * @param aServiceId |
|
167 * @param aSetToDefaultForService |
|
168 * @return Response status. |
|
169 */ |
|
170 TRespStatus CallSetUsedIap(TUint32 aIapId, |
|
171 TUint32 aServiceId, |
|
172 TBool aSetToDefaultForService |
|
173 ); |
|
174 /** |
|
175 * Gets the used IAP for a service using CIptvServiceManagementClient method GetUsedIapL or GetUsedIapReqL. |
|
176 * @param aConn Async/sync call. |
|
177 * @param aServiceId |
|
178 * @param aIapId |
|
179 * @return Response status. |
|
180 */ |
|
181 TRespStatus CallGetUsedIap( |
|
182 TIptvSmTestConnection aConn, |
|
183 TUint32 aServiceId, |
|
184 TUint32& aIapId |
|
185 ); |
|
186 |
|
187 /** |
|
188 * Clears the used IAP for a service using CIptvServiceManagementClient method ClearUsedIap. |
|
189 * @return Response status. |
|
190 */ |
|
191 TRespStatus CallClearUsedIap(); |
|
192 |
|
193 /** |
|
194 * Sets IAP list to all services using CIptvServiceManagementClient method SetAllIapsReqL or SetAllIapsL. |
|
195 * @param aConn Async/sync call. |
|
196 * @param aIapList |
|
197 * @param aIgnoreReadOnlyFlag |
|
198 * @return Response status. |
|
199 */ |
|
200 TRespStatus CIptvServiceManagementSync::CallSetAllIaps( |
|
201 TIptvSmTestConnection aConn, |
|
202 CIptvIapList& aIapList, |
|
203 TBool aIgnoreReadOnlyFlag |
|
204 ); |
|
205 |
|
206 /** |
|
207 * Sets connection allowed flag for service using CIptvServiceManagementClient method SetConnectionAllowedL. |
|
208 * @param aConnectionAllowed |
|
209 * @param aIapId |
|
210 * @return Response status. |
|
211 */ |
|
212 TRespStatus CallSetConnectionAllowed(TBool aConnectionAllowed, |
|
213 TUint32 aIapId); |
|
214 |
|
215 /** |
|
216 * Gets the connection allowed flag for service using CIptvServiceManagementClient method IsConnectionAllowedL. |
|
217 * @param aPermission |
|
218 * @param aIapId |
|
219 * @return Response status. |
|
220 */ |
|
221 TRespStatus CallIsConnectionAllowed(CIptvNetworkSelection::TConnectionPermission &aPermission, |
|
222 TUint32 aIapId); |
|
223 |
|
224 |
|
225 |
|
226 /** |
|
227 * Cancels the outstanding request. |
|
228 */ |
|
229 void CancelRequest() ; |
|
230 |
|
231 /** |
|
232 * Sets the repeat count for next request. Async requests will be sent w/o waiting the request to complete |
|
233 * @param aCount |
|
234 */ |
|
235 void RepeatNextRequest(TInt aRequestRepeatCount); |
|
236 |
|
237 /** |
|
238 * Gets the count of repeats for next request. |
|
239 * @return Count of repeats. |
|
240 */ |
|
241 TUint GetRepeatNextRequestCount(); |
|
242 |
|
243 /** |
|
244 * Sets the member variables which point to the database locations. |
|
245 * @param aServicesDbFile |
|
246 * @param aPasswordsDbFile |
|
247 */ |
|
248 void SetDbFileLocations(TDesC& aServicesDbFile, TDesC& aPasswordsDbFile); |
|
249 |
|
250 /** |
|
251 * Sets special action. |
|
252 * @param aSpecialAction |
|
253 */ |
|
254 void SetSpecialAction(TInt aSpecialAction); |
|
255 |
|
256 /** |
|
257 * Waits for a second for SM events and if event is received starts the wait again. |
|
258 */ |
|
259 void WaitForProvisioningEvents(); |
|
260 |
|
261 /** |
|
262 * Gets the instance of CIptvServiceManagementClient. Ownership doesn't transfer. |
|
263 * @return Pointer to instance of iIptvServiceManagementClient. |
|
264 */ |
|
265 CIptvServiceManagementClient* GetSmClient() { return iIptvServiceManagementClient; } |
|
266 |
|
267 protected: // Functions from base classes |
|
268 |
|
269 |
|
270 public: // Functions from base classes |
|
271 |
|
272 /** |
|
273 * From MIptvTestTimerObserver. Asynchronous callback observer function signaling application that timer has elapsed. |
|
274 * @since |
|
275 * @param error Error code. |
|
276 */ |
|
277 virtual void TimerComplete(TInt aTimerId, TInt aError); |
|
278 |
|
279 /* |
|
280 * From MIptvServiceManagementClientObserver. Callback function for AddServiceReq operation. |
|
281 * @param aRespStatus |
|
282 */ |
|
283 void AddServiceResp(TRespStatus aRespStatus); |
|
284 |
|
285 /** |
|
286 * From MIptvServiceManagementClientObserver. Callback function for UpdateServiceReq. |
|
287 * @param aRespStatus |
|
288 */ |
|
289 void UpdateServiceResp(TRespStatus aRespStatus); |
|
290 |
|
291 /** |
|
292 * From MIptvServiceManagementClientObserver. Callback function for DeleteServiceReq operation. |
|
293 * @param aRespStatus |
|
294 */ |
|
295 void DeleteServiceResp(TRespStatus aRespStatus); |
|
296 |
|
297 /** |
|
298 * From MIptvServiceManagementClientObserver. Callback function for GetServiceReq operation. |
|
299 * aServicesArray ownership moves from dll to application, ie application |
|
300 * is responsible for freeing the array. |
|
301 * Array elements are binary descriptors built with CIptvService::GetL() method. |
|
302 * CIptvService::Set() method can be used to init CIptvService class with |
|
303 * array element data. |
|
304 * @param aRespStatus |
|
305 * @param aServicesArray contains array of pointers to descriptors. |
|
306 */ |
|
307 void GetServicesResp(TRespStatus aRespStatus, |
|
308 CDesC8ArraySeg* aServicesArray); |
|
309 |
|
310 /** |
|
311 * From MIptvServiceManagementClientObserver. Callback function for ShutdownServerReq operation. |
|
312 * @param aRespStatus |
|
313 */ |
|
314 void ServerShutdownResp(TRespStatus aRespStatus); |
|
315 |
|
316 /** |
|
317 * From MIptvServiceManagementClientObserver. Callback function for GetUsedIapReq() method. |
|
318 * @param aRespStatus |
|
319 * @param aIapId IAP ID which client should use. |
|
320 * In case of error, aIapId is 0. |
|
321 */ |
|
322 void GetUsedIapResp(TUint32 aIapId, |
|
323 const TDesC& aIapName, |
|
324 CIptvNetworkSelection::TConnectionPermission aConnectionPermission, |
|
325 TBool aWlanWhenGPRS, |
|
326 CIptvNetworkSelection::TRespStatus aRespStatus); |
|
327 |
|
328 /** |
|
329 * From MIptvServiceManagementClientObserver. Callback for Service Manager generated events. |
|
330 * @param aEvent |
|
331 */ |
|
332 void HandleSmEvent(CIptvSmEvent& aEvent); |
|
333 |
|
334 /** |
|
335 * Increases the expected event count. |
|
336 */ |
|
337 void IncreaseExpectedEventCount( TInt aAmount ); |
|
338 |
|
339 |
|
340 private: |
|
341 /** |
|
342 * CIptvServiceManagementSync. |
|
343 * Default C++ constructor. |
|
344 * @param |
|
345 */ |
|
346 CIptvServiceManagementSync(); |
|
347 |
|
348 /** |
|
349 * ConstructL. |
|
350 * Performs the second phase construction of a |
|
351 * CIptvRequestHandler object. |
|
352 */ |
|
353 void ConstructL(); |
|
354 |
|
355 /** |
|
356 * Sets iSyncReturnValue member variable. |
|
357 */ |
|
358 TInt ResponseStatus(TUint8 aStatus); |
|
359 |
|
360 /** |
|
361 * Prepares for a request. Special actions set etc. |
|
362 */ |
|
363 TInt PrepareForRequest(); |
|
364 |
|
365 /** |
|
366 * Finishes request. |
|
367 */ |
|
368 TInt FinishRequest(); |
|
369 |
|
370 /** |
|
371 * Sets the expected event from CIptvServiceManagementClient. |
|
372 */ |
|
373 void SetExpectedSmEvent(CIptvSmEvent::TEvent aEvent, TInt aEventCount); |
|
374 |
|
375 /** |
|
376 * Starts waiting asynchronously for next event from CIptvServiceManagementClient. |
|
377 */ |
|
378 TInt WaitForSmEvent(); |
|
379 |
|
380 private: // Data |
|
381 |
|
382 // Instance of CIptvTestActiveWait |
|
383 CIptvTestActiveWait* iActiveWait; |
|
384 |
|
385 // iSyncReturnValue Return value of synchronous request function. |
|
386 MIptvServiceManagementClientObserver::TRespStatus iSyncReturnValue; |
|
387 |
|
388 // Services from async GetService requests response are stored here. |
|
389 CDesC8ArraySeg* iServicesArray; |
|
390 |
|
391 // Instance of CIptvServiceManagementClient |
|
392 CIptvServiceManagementClient* iIptvServiceManagementClient; |
|
393 |
|
394 // Iap ID from async GetUsedIap request response is stored here. |
|
395 TUint32 iIapId; |
|
396 |
|
397 // How many times next request is repeated. |
|
398 TInt iRequestRepeatCount; |
|
399 |
|
400 // The *special* action |
|
401 TIptvSmSpecialAction iSpecialAction; |
|
402 |
|
403 // Instance of CIptvTestTimer |
|
404 CIptvTestTimer* iIptvTestTimer; |
|
405 |
|
406 // Instance of CIptvTestUtilities |
|
407 CIptvTestUtilities* iIptvTestUtilities; |
|
408 |
|
409 /* |
|
410 ->PrepareForRequest sets IgnoreEvents OFF if WaitNoEvents is not set |
|
411 ->WaitingForEvent is SET |
|
412 ->Expected event is SET |
|
413 ->Request is made |
|
414 ->WaitForSmEvent is called, wait 6 seconds |
|
415 ->HandleSmEvent callback is called when events are received |
|
416 -> events are checked if ignoring is OFF |
|
417 ->FinishRequest sets IgnoreEvents ON |
|
418 */ |
|
419 |
|
420 // Ignore is set always when there's no request made by this class |
|
421 TBool iIgnoreEvents; |
|
422 |
|
423 // Set when updating other service field than address because only that causes modify event |
|
424 TBool iWaitNoEvents; |
|
425 |
|
426 // Set when waiting for an event. |
|
427 TBool iWaitingForEvent; |
|
428 |
|
429 // Set when event is received. |
|
430 TBool iEventReceived; |
|
431 |
|
432 // The expected event. |
|
433 CIptvSmEvent::TEvent iExpectedSmEvent; |
|
434 |
|
435 TInt iExpectedEventCount; |
|
436 |
|
437 // The expected events. |
|
438 RArray<CIptvSmEvent::TEvent> iExpectedSmEvents; |
|
439 |
|
440 // Are we currently waiting for provisioining to finish |
|
441 TBool iProvisioningWaitGoing; |
|
442 |
|
443 // Is provisioning event received. |
|
444 TBool iProvisioningEventReceived; |
|
445 }; |
|
446 |
|
447 |
|
448 #endif //__CIptvServiceManagementSync_H__ |
|
449 |
|
450 // End of File |