|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Provides interface to Service Management and Network Selection* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 #include "IptvDebug.h" |
|
23 |
|
24 #include "IptvClientServerCommon.h" |
|
25 #include "CIptvService.h" |
|
26 #include "CIptvServices.h" |
|
27 #include "CIptvServiceManagementClient.h" |
|
28 #include "MIptvServiceManagementClientObserver.h" |
|
29 #include "CIptvServiceManager.h" |
|
30 #include "IptvServer.pan" |
|
31 #include "CIptvSmEvent.h" |
|
32 #include "CIptvEventListener.h" |
|
33 |
|
34 // ========================= MEMBER FUNCTIONS ================================== |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CIptvServiceManagementClient::NewL() |
|
38 // Two-phased constructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 EXPORT_C CIptvServiceManagementClient* CIptvServiceManagementClient::NewL(MIptvServiceManagementClientObserver& aClient) |
|
41 { |
|
42 CIptvServiceManagementClient* self = |
|
43 new ( ELeave ) CIptvServiceManagementClient(aClient); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return( self ) ; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CIptvServiceManagementClient::ConstructL() |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CIptvServiceManagementClient::ConstructL() |
|
56 { |
|
57 User::LeaveIfError( iSession.Connect() ); |
|
58 iMsg = NULL; |
|
59 |
|
60 CIptvSmEvent* event = CIptvSmEvent::NewL(); |
|
61 CleanupStack::PushL(event); // 1-> |
|
62 iEventListener = CIptvEventListener::NewL( *this, |
|
63 event /* ownership moves */, |
|
64 EIptvEngineSmGetEventSizeReq, |
|
65 EIptvEngineSmGetEventData, |
|
66 EIptvEngineSmCancelGetEventSizeReq ); |
|
67 CleanupStack::Pop(event); // <-1 |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CIptvServiceManagementClient::CIptvServiceManagementClient() |
|
72 // C++ default constructor can NOT contain any code, that might leave. |
|
73 // ----------------------------------------------------------------------------- |
|
74 EXPORT_C CIptvServiceManagementClient::CIptvServiceManagementClient(MIptvServiceManagementClientObserver& aClient) |
|
75 : CIptvClientBase(), iClient(aClient), iMsgPtr((unsigned char*)0, 0) |
|
76 { |
|
77 CActiveScheduler::Add( this ); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CIptvServiceManagementClient::~CIptvServiceManagementClient() |
|
82 // Destructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C CIptvServiceManagementClient::~CIptvServiceManagementClient() |
|
86 { |
|
87 IPTVLOGSTRING_LOW_LEVEL("~CIptvServiceManagementClient()"); |
|
88 |
|
89 delete iEventListener; |
|
90 |
|
91 Cancel(); // Causes call to DoCancel() if there is message pending |
|
92 |
|
93 iSession.Close(); |
|
94 |
|
95 delete iMsg; |
|
96 iMsg = NULL; |
|
97 IPTVLOGSTRING_LOW_LEVEL("~CIptvServiceManagementClient() exit"); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CIptvServiceManagementClient::AddServiceReq() |
|
102 // Adds a service to Service data base. |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 EXPORT_C TInt CIptvServiceManagementClient::AddServiceReqL(CIptvService& aService) |
|
106 { |
|
107 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::AddServiceReq()"); |
|
108 |
|
109 if ( IsActive() ) |
|
110 { |
|
111 return KErrNotReady; |
|
112 } |
|
113 |
|
114 BuildAddServiceReqL( aService ); |
|
115 |
|
116 //send it |
|
117 iSession.SendRequest( EIptvEngineSmAddServiceReq, iMsgPtr, iStatus ); |
|
118 SetActive(); |
|
119 iRequestPendingFor = EServiceManagerRequestPending; |
|
120 iResponseMsgId = EIptvEngineSmAddServiceResp; |
|
121 |
|
122 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::AddServiceReq() exit"); |
|
123 return KErrNone; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CIptvServiceManagementClient::AddServiceL() |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 EXPORT_C TInt CIptvServiceManagementClient::AddServiceL( |
|
131 CIptvService& aService, |
|
132 MIptvServiceManagementClientObserver::TRespStatus& aRespStatus) |
|
133 { |
|
134 BuildAddServiceReqL( aService ); |
|
135 TInt err = iSession.SendRequest( EIptvEngineSmAddServiceReq, iMsgPtr ); |
|
136 if ( err == KErrNone ) |
|
137 { |
|
138 aRespStatus = GetRespStatusL(); |
|
139 } |
|
140 else |
|
141 { |
|
142 aRespStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
143 } |
|
144 return err; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CIptvServiceManagementClient::UpdateServiceReqL() |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C TInt CIptvServiceManagementClient::UpdateServiceReqL(CIptvService& aService) |
|
152 { |
|
153 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::UpdateServiceReq()"); |
|
154 |
|
155 if(IsActive()) |
|
156 { |
|
157 return KErrNotReady; |
|
158 } |
|
159 |
|
160 BuildUpdateServiceReqL(aService); |
|
161 |
|
162 //send it |
|
163 iSession.SendRequest(EIptvEngineSmUpdateServiceReq, iMsgPtr, iStatus); |
|
164 SetActive(); |
|
165 iRequestPendingFor = EServiceManagerRequestPending; |
|
166 iResponseMsgId = EIptvEngineSmUpdateServiceResp; |
|
167 |
|
168 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::UpdateServiceReq() exit"); |
|
169 return KErrNone; |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CIptvServiceManagementClient::UpdateServiceL() |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 EXPORT_C TInt CIptvServiceManagementClient::UpdateServiceL(CIptvService& aService, |
|
177 MIptvServiceManagementClientObserver::TRespStatus& aRespStatus) |
|
178 { |
|
179 BuildUpdateServiceReqL(aService); |
|
180 TInt err = iSession.SendRequest(EIptvEngineSmUpdateServiceReq, iMsgPtr); |
|
181 if(err == KErrNone) |
|
182 { |
|
183 aRespStatus = GetRespStatusL(); |
|
184 } |
|
185 else |
|
186 { |
|
187 aRespStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
188 } |
|
189 |
|
190 delete iMsg; |
|
191 iMsg = NULL; |
|
192 |
|
193 return err; |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CIptvServiceManagementClient::GetServicesReq() |
|
198 // Requests services from the database. The request is done in 2 phases, first |
|
199 // request gets only data size, second transaction gets the data. |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 EXPORT_C TInt CIptvServiceManagementClient::GetServicesReqL(TUint32 aSearchLimitFlags, |
|
203 TOrder aOrder) |
|
204 { |
|
205 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::GetServicesReqL(aSearchLimitFlags, aOrder)"); |
|
206 |
|
207 if(IsActive()) |
|
208 { |
|
209 return KErrNotReady; |
|
210 } |
|
211 |
|
212 BuildGetServicesSizeReqL(aSearchLimitFlags, aOrder); |
|
213 |
|
214 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: Sending EIptvEngineGetServicesSizeReq"); |
|
215 iSession.SendRequest(EIptvEngineSmGetServicesSizeReq, iMsgPtr, iStatus); |
|
216 SetActive(); |
|
217 iRequestPendingFor = EServiceManagerRequestPending; |
|
218 iResponseMsgId = EIptvEngineSmGetServicesSizeResp; |
|
219 |
|
220 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::GetServicesReqL(aSearchLimitFlags, aOrder) exit"); |
|
221 return KErrNone; |
|
222 } |
|
223 |
|
224 EXPORT_C TInt CIptvServiceManagementClient::GetServicesL( |
|
225 TUint32 aSearchLimitFlags, |
|
226 TOrder aOrder, |
|
227 CDesC8ArraySeg*& aServicesArray, |
|
228 MIptvServiceManagementClientObserver::TRespStatus& aRespStatus ) |
|
229 { |
|
230 BuildGetServicesSizeReqL( aSearchLimitFlags, aOrder ); |
|
231 |
|
232 TInt err = iSession.SendRequest( EIptvEngineSmGetServicesSizeReq, iMsgPtr ); |
|
233 if ( err != KErrNone ) |
|
234 { |
|
235 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: GetServicesL() error when requesting size"); |
|
236 aRespStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
237 return err; |
|
238 } |
|
239 else |
|
240 { |
|
241 RDesReadStream readStream; |
|
242 readStream.Open( iMsgPtr); |
|
243 CleanupClosePushL( readStream ); |
|
244 TUint8 status = readStream.ReadUint8L(); |
|
245 TUint32 size = readStream.ReadUint32L(); |
|
246 CleanupStack::PopAndDestroy( &readStream ); |
|
247 |
|
248 if ( status != MIptvServiceManagementClientObserver::ESucceeded ) |
|
249 { |
|
250 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: GetServicesL() error when requesting size"); |
|
251 aRespStatus = ( MIptvServiceManagementClientObserver::TRespStatus )status; |
|
252 return KErrGeneral; |
|
253 } |
|
254 |
|
255 IPTVLOGSTRING2_LOW_LEVEL("CIptvServiceManagementClient:: Size: %d", size); |
|
256 |
|
257 if ( iMsg ) |
|
258 { |
|
259 delete iMsg; |
|
260 iMsg = NULL; |
|
261 } |
|
262 |
|
263 iMsg = HBufC8::NewL( size ); |
|
264 iMsgPtr.Set( iMsg->Des() ); |
|
265 |
|
266 err = iSession.SendRequest( EIptvEngineSmGetServicesDataReq, iMsgPtr ); |
|
267 if ( err != KErrNone ) |
|
268 { |
|
269 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: EIptvEngineSmGetServicesDataReq failed"); |
|
270 aRespStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
271 return err; |
|
272 } |
|
273 else |
|
274 { |
|
275 CDesC8ArraySeg* services = NULL; |
|
276 TRAPD( err, services = InternalizeGetServicesDataRespL() ); |
|
277 if ( err != KErrNone ) |
|
278 { |
|
279 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: failed to internalize GetServicesDataResp ipc msg"); |
|
280 aRespStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
281 return err; |
|
282 } |
|
283 aRespStatus = MIptvServiceManagementClientObserver::ESucceeded; |
|
284 aServicesArray = services; |
|
285 return KErrNone; |
|
286 } |
|
287 } |
|
288 } |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // CIptvServiceManagementClient::GetServicesReqL() |
|
292 // Gets service entries from Services database. Request is done asynchronously. |
|
293 // GetServicesResp is the callback function. |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 EXPORT_C TInt CIptvServiceManagementClient::GetServicesReqL(TUint32 aStartId, TUint32 aEndId) |
|
297 { |
|
298 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::GetServicesReqL(aStartId, aEndId)"); |
|
299 |
|
300 if(IsActive()) |
|
301 { |
|
302 return KErrNotReady; |
|
303 } |
|
304 |
|
305 BuildGetServicesUsingIndexSizeReqL(aStartId, aEndId); |
|
306 |
|
307 IPTVLOGSTRING_HIGH_LEVEL("CIptvServiceManagementClient:: Sending EIptvEngineGetServicesUsingIdSizeReq"); |
|
308 |
|
309 iSession.SendRequest(EIptvEngineSmGetServicesUsingIdSizeReq, iMsgPtr, iStatus); |
|
310 SetActive(); |
|
311 iRequestPendingFor = EServiceManagerRequestPending; |
|
312 iResponseMsgId = EIptvEngineSmGetServicesUsingIdSizeResp; |
|
313 |
|
314 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::GetServicesReqL(aStartId, aEndId) exit"); |
|
315 return KErrNone; |
|
316 } |
|
317 |
|
318 // ----------------------------------------------------------------------------- |
|
319 // CIptvServiceManagementClient::GetServices() |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 EXPORT_C TInt CIptvServiceManagementClient::GetServicesL(TUint32 aStartId, |
|
323 TUint32 aEndId, |
|
324 CDesC8ArraySeg*& aServicesArray, |
|
325 MIptvServiceManagementClientObserver::TRespStatus& aRespStatus) |
|
326 { |
|
327 BuildGetServicesUsingIndexSizeReqL(aStartId, aEndId); |
|
328 |
|
329 TInt err = iSession.SendRequest(EIptvEngineSmGetServicesUsingIdSizeReq, iMsgPtr); |
|
330 if (err != KErrNone) |
|
331 { |
|
332 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: Error in SendRequest"); |
|
333 aRespStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
334 aServicesArray = NULL; |
|
335 return err; |
|
336 } |
|
337 |
|
338 TUint8 status; |
|
339 TUint32 size; |
|
340 |
|
341 RDesReadStream readStream; |
|
342 readStream.Open(iMsgPtr); |
|
343 CleanupClosePushL( readStream ); |
|
344 status = readStream.ReadUint8L(); |
|
345 |
|
346 if(status != MIptvServiceManagementClientObserver::ESucceeded) |
|
347 { |
|
348 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: Error"); |
|
349 iClient.GetServicesResp((MIptvServiceManagementClientObserver::TRespStatus)status, NULL); |
|
350 CleanupStack::PopAndDestroy( &readStream ); |
|
351 return KErrGeneral; |
|
352 } |
|
353 |
|
354 size = readStream.ReadUint32L(); |
|
355 CleanupStack::PopAndDestroy( &readStream ); |
|
356 |
|
357 IPTVLOGSTRING2_LOW_LEVEL("CIptvServiceManagementClient:: Size: %d", size); |
|
358 |
|
359 if (iMsg) |
|
360 { |
|
361 delete iMsg; |
|
362 iMsg = NULL; |
|
363 } |
|
364 |
|
365 iMsg = HBufC8::NewL(size); |
|
366 iMsgPtr.Set(iMsg->Des()); |
|
367 |
|
368 err = iSession.SendRequest(EIptvEngineSmGetServicesUsingIdDataReq, iMsgPtr); |
|
369 |
|
370 if (err != KErrNone) |
|
371 { |
|
372 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: EIptvEngineSmGetServicesUsingIdDataReq failed"); |
|
373 aRespStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
374 return err; |
|
375 } |
|
376 else |
|
377 { |
|
378 CDesC8ArraySeg* services = NULL; |
|
379 |
|
380 TRAPD(err, services = InternalizeGetServicesDataRespL()); |
|
381 if (err != KErrNone) |
|
382 { |
|
383 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: failed to internalize GetServicesDataResp ipc msg"); |
|
384 aRespStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
385 return err; |
|
386 } |
|
387 aRespStatus = MIptvServiceManagementClientObserver::ESucceeded; |
|
388 aServicesArray = services; |
|
389 return KErrNone; |
|
390 } |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CIptvServiceManagementClient::DeleteServiceReqL() |
|
395 // Deletes a service from the database. |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 |
|
399 EXPORT_C TInt CIptvServiceManagementClient::DeleteServiceReqL(TUint32 aId) |
|
400 { |
|
401 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::DeleteServiceReqL()"); |
|
402 |
|
403 if(IsActive()) |
|
404 { |
|
405 return KErrNotReady; |
|
406 } |
|
407 |
|
408 BuildDeleteServiceReqL(aId); |
|
409 |
|
410 IPTVLOGSTRING2_LOW_LEVEL("CIptvServiceManagementClient:: Making delete request for ID: %d", aId); |
|
411 |
|
412 iSession.SendRequest(EIptvEngineSmDeleteServiceReq, iMsgPtr, iStatus); |
|
413 SetActive(); |
|
414 iRequestPendingFor = EServiceManagerRequestPending; |
|
415 iResponseMsgId = EIptvEngineSmDeleteServiceResp; |
|
416 |
|
417 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::DeleteServiceReq() exit"); |
|
418 return KErrNone; |
|
419 } |
|
420 |
|
421 // ----------------------------------------------------------------------------- |
|
422 // CIptvServiceManagementClient::DeleteServiceL() |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 EXPORT_C TInt CIptvServiceManagementClient::DeleteServiceL(TUint32 aId, |
|
426 MIptvServiceManagementClientObserver::TRespStatus& aRespStatus) |
|
427 { |
|
428 BuildDeleteServiceReqL(aId); |
|
429 IPTVLOGSTRING2_LOW_LEVEL("CIptvServiceManagementClient:: Making delete request for ID: %d", aId); |
|
430 TInt err = iSession.SendRequest(EIptvEngineSmDeleteServiceReq, iMsgPtr); |
|
431 if (err != KErrNone) |
|
432 { |
|
433 aRespStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
434 } |
|
435 else |
|
436 { |
|
437 aRespStatus = GetRespStatusL(); |
|
438 } |
|
439 return err; |
|
440 } |
|
441 |
|
442 // ----------------------------------------------------------------------------- |
|
443 // CIptvServiceManagementClient::ServerShutDownReq() |
|
444 // Requests server to shutdown itself. |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 EXPORT_C TInt CIptvServiceManagementClient::ServerShutdownReq() |
|
448 { |
|
449 if(IsActive()) |
|
450 { |
|
451 return KErrNotReady; |
|
452 } |
|
453 |
|
454 iSession.SendRequest(EIptvEngineServerShutdownReq, iStatus); |
|
455 SetActive(); |
|
456 iRequestPendingFor = EServerRequestPending; |
|
457 iResponseMsgId = EIptvEngineShutdownResp; |
|
458 |
|
459 return KErrNone; |
|
460 } |
|
461 |
|
462 EXPORT_C TInt CIptvServiceManagementClient::ServerShutdown(MIptvServiceManagementClientObserver::TRespStatus& /*aRespStatus*/) |
|
463 { |
|
464 return KErrNotSupported; |
|
465 } |
|
466 |
|
467 // ----------------------------------------------------------------------------- |
|
468 // CIptvServiceManagementClient::CancelRequest() |
|
469 // Cancels an outstanding request. |
|
470 // ----------------------------------------------------------------------------- |
|
471 // |
|
472 EXPORT_C void CIptvServiceManagementClient::CancelRequest() |
|
473 { |
|
474 Cancel() ; // Causes call to DoCancel() if there is message pending |
|
475 } |
|
476 |
|
477 // ----------------------------------------------------------------------------- |
|
478 // CIptvServiceManagementClient::RunL() |
|
479 // Invoked to handle responses from Iptv server. |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 void CIptvServiceManagementClient::RunL() |
|
483 { |
|
484 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::RunL()"); |
|
485 |
|
486 iRequestPendingFor = ENoRequestPending; |
|
487 TInt error = iStatus.Int(); |
|
488 |
|
489 if(error != KErrNone) |
|
490 { |
|
491 IPTVLOGSTRING2_LOW_LEVEL("CIptvServiceManagementClient:: error received from server: %d", error); |
|
492 } |
|
493 |
|
494 switch ( iResponseMsgId ) |
|
495 { |
|
496 case EIptvEngineShutdownResp: |
|
497 IPTVLOGSTRING_HIGH_LEVEL("CIptvServiceManagementClient:: EIptvEngineShutdownResp"); |
|
498 iClient.ServerShutdownResp(GetRespStatusL()); |
|
499 break; |
|
500 |
|
501 case EIptvEngineSmGetServicesSizeResp: |
|
502 IPTVLOGSTRING_HIGH_LEVEL("CIptvServiceManagementClient:: EIptvEngineSmGetServicesSizeResp"); |
|
503 HandleGetServicesSizeRespL(EIptvEngineSmGetServicesSizeResp); |
|
504 break; |
|
505 case EIptvEngineSmGetServicesDataResp: |
|
506 IPTVLOGSTRING_HIGH_LEVEL("CIptvServiceManagementClient:: EIptvEngineSmGetServicesDataResp"); |
|
507 HandleGetServicesDataRespL(EIptvEngineSmGetServicesDataResp); |
|
508 break; |
|
509 |
|
510 case EIptvEngineSmGetServicesUsingIdSizeResp: |
|
511 IPTVLOGSTRING_HIGH_LEVEL("CIptvServiceManagementClient:: EIptvEngineSmGetServicesUsingIdSizeResp"); |
|
512 HandleGetServicesSizeRespL(EIptvEngineSmGetServicesUsingIdSizeResp); |
|
513 break; |
|
514 case EIptvEngineSmGetServicesUsingIdDataResp: |
|
515 IPTVLOGSTRING_HIGH_LEVEL("CIptvServiceManagementClient:: EIptvEngineSmGetServicesUsingIdDataResp"); |
|
516 HandleGetServicesDataRespL(EIptvEngineSmGetServicesUsingIdDataResp); |
|
517 break; |
|
518 |
|
519 case EIptvEngineSmAddServiceResp: |
|
520 IPTVLOGSTRING_HIGH_LEVEL("CIptvServiceManagementClient:: EIptvEngineSmAddServiceResp"); |
|
521 iClient.AddServiceResp(GetRespStatusL()); |
|
522 break; |
|
523 |
|
524 case EIptvEngineSmDeleteServiceResp: |
|
525 IPTVLOGSTRING_HIGH_LEVEL("CIptvServiceManagementClient:: EIptvEngineSmDeleteServiceResp"); |
|
526 iClient.DeleteServiceResp(GetRespStatusL()); |
|
527 break; |
|
528 |
|
529 case EIptvEngineSmUpdateServiceResp: |
|
530 IPTVLOGSTRING_HIGH_LEVEL("CIptvServiceManagementClient:: EIptvEngineSmUpdateServiceResp"); |
|
531 iClient.UpdateServiceResp(GetRespStatusL()); |
|
532 break; |
|
533 |
|
534 case EIptvEngineNsGetUsedIapResp: |
|
535 { |
|
536 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: EIptvEngineNsGetUsedIapResp"); |
|
537 |
|
538 TUint32 iapId; |
|
539 TBuf<KIptvNsIapNameMaxLength> iapName; |
|
540 CIptvNetworkSelection::TConnectionPermission connPerm; |
|
541 CIptvNetworkSelection::TRespStatus respStatus; |
|
542 TUint8 wlanWhenGprs; |
|
543 |
|
544 if ( iStatus.Int() == KErrNone ) |
|
545 { |
|
546 HandleGetUsedIapRespL( iapId, iapName, connPerm, wlanWhenGprs, respStatus ); |
|
547 } |
|
548 else |
|
549 { |
|
550 IPTVLOGSTRING2_HIGH_LEVEL("CIptvServiceManagementClient:: message completed with error: %d", iStatus.Int()); |
|
551 respStatus = CIptvNetworkSelection::EGeneralError; |
|
552 } |
|
553 iClient.GetUsedIapResp(iapId, iapName, connPerm, wlanWhenGprs, respStatus); |
|
554 } |
|
555 break; |
|
556 |
|
557 default: |
|
558 IPTVLOGSTRING_HIGH_LEVEL("CIptvServiceManagementClient:: UNKNOWN MESSAGE, PANICING"); |
|
559 User::Panic( KIptvServiceManagementClient, EIptvUnknownMessage ); // Unexpected error |
|
560 break; |
|
561 } |
|
562 |
|
563 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::RunL() exit"); |
|
564 } |
|
565 |
|
566 // ----------------------------------------------------------------------------- |
|
567 // CIptvServiceManagementClient::DoCancel() |
|
568 // Cancels any outstanding operation. |
|
569 // ----------------------------------------------------------------------------- |
|
570 // |
|
571 void CIptvServiceManagementClient::DoCancel() |
|
572 { |
|
573 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::DoCancel()"); |
|
574 |
|
575 switch(iRequestPendingFor) |
|
576 { |
|
577 case EServerRequestPending: |
|
578 iSession.SendRequest(EIptvEngineServerCancel); //sync |
|
579 break; |
|
580 |
|
581 case EServiceManagerRequestPending: |
|
582 iSession.SendRequest(EIptvEngineSmCancel); //sync |
|
583 break; |
|
584 |
|
585 case ENetworkSelectionRequestPending: |
|
586 { |
|
587 TInt err = iSession.SendRequest(EIptvEngineNsCancel); //sync |
|
588 if(err == KErrNone) |
|
589 { |
|
590 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: EIptvEngineNsCancel successful"); |
|
591 } |
|
592 else |
|
593 { |
|
594 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: EIptvEngineNsCancel failed"); |
|
595 } |
|
596 } |
|
597 break; |
|
598 |
|
599 default: |
|
600 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: there was no message pending, ignoring cancel req"); |
|
601 break; |
|
602 } |
|
603 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::DoCancel() exit"); |
|
604 } |
|
605 |
|
606 // ----------------------------------------------------------------------------- |
|
607 // CIptvServiceManagementClient::HandleGetServicesSizeRespL() |
|
608 // Handles EIptvEngineGetServicesSizeResp and EIptvEngineGetServicesUsingIdSizeResp |
|
609 // messages. |
|
610 // Allocates new iMsg of the size fetched from the incoming message and sends |
|
611 // corresponding data request message to server. |
|
612 // ----------------------------------------------------------------------------- |
|
613 // |
|
614 void CIptvServiceManagementClient::HandleGetServicesSizeRespL(TUint8 aMsgId) |
|
615 { |
|
616 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::HandleGetServicesSizeResp()"); |
|
617 |
|
618 if(iStatus.Int() != KErrNone) |
|
619 { |
|
620 //operation leaved on server side -> mark request as failed |
|
621 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: operation leaved on server side->EGeneralError"); |
|
622 iClient.GetServicesResp(MIptvServiceManagementClientObserver::EGeneralError, NULL); |
|
623 return; |
|
624 } |
|
625 |
|
626 TUint8 status; |
|
627 TUint32 size; |
|
628 |
|
629 RDesReadStream readStream; |
|
630 readStream.Open(iMsgPtr); |
|
631 CleanupClosePushL( readStream ); |
|
632 status = readStream.ReadUint8L(); |
|
633 |
|
634 if(status != MIptvServiceManagementClientObserver::ESucceeded) |
|
635 { |
|
636 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: Error"); |
|
637 iClient.GetServicesResp((MIptvServiceManagementClientObserver::TRespStatus)status, NULL); |
|
638 CleanupStack::PopAndDestroy( &readStream ); |
|
639 return; |
|
640 } |
|
641 |
|
642 size = readStream.ReadUint32L(); |
|
643 CleanupStack::PopAndDestroy( &readStream ); |
|
644 |
|
645 IPTVLOGSTRING2_LOW_LEVEL("CIptvServiceManagementClient:: Size: %d", size); |
|
646 |
|
647 delete iMsg; |
|
648 iMsg = NULL; |
|
649 iMsg = HBufC8::NewL(size); |
|
650 iMsgPtr.Set(iMsg->Des()); |
|
651 |
|
652 switch(aMsgId) |
|
653 { |
|
654 case EIptvEngineSmGetServicesSizeResp: |
|
655 iSession.SendRequest(EIptvEngineSmGetServicesDataReq, iMsgPtr, iStatus); |
|
656 iResponseMsgId = EIptvEngineSmGetServicesDataResp; |
|
657 break; |
|
658 case EIptvEngineSmGetServicesUsingIdSizeResp: |
|
659 iSession.SendRequest(EIptvEngineSmGetServicesUsingIdDataReq, iMsgPtr, iStatus); |
|
660 iResponseMsgId = EIptvEngineSmGetServicesUsingIdDataResp; |
|
661 break; |
|
662 } |
|
663 |
|
664 SetActive(); |
|
665 iRequestPendingFor = EServiceManagerRequestPending; |
|
666 |
|
667 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::HandleGetServicesSizeRespL() exit"); |
|
668 } |
|
669 |
|
670 // ----------------------------------------------------------------------------- |
|
671 // CIptvServiceManagementClient::HandleGetServicesDataReqCompletes() |
|
672 // Handles EIptvEngineGetServicesDataResp and EIptvEngineGetServicesUsingIdDataResp |
|
673 // messages. |
|
674 // Unpacks data from stream format(externalize/internalize) and sends services to |
|
675 // client as an array of data descriptors fetched from CIptvService::GetL(). |
|
676 // ----------------------------------------------------------------------------- |
|
677 // |
|
678 void CIptvServiceManagementClient::HandleGetServicesDataRespL(TUint8 aMsgId) |
|
679 { |
|
680 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::HandleGetServicesDataRespL()"); |
|
681 |
|
682 if(iStatus.Int() != KErrNone) |
|
683 { |
|
684 //operation leaved on server side -> mark request as failed |
|
685 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: operation leaved on server side->EGeneralError"); |
|
686 iClient.GetServicesResp(MIptvServiceManagementClientObserver::EGeneralError, NULL); |
|
687 return; |
|
688 } |
|
689 |
|
690 CDesC8ArraySeg* services = NULL; |
|
691 |
|
692 TRAPD(err, services = InternalizeGetServicesDataRespL()); |
|
693 if (err != KErrNone) |
|
694 { |
|
695 iClient.GetServicesResp(MIptvServiceManagementClientObserver::EGeneralError, NULL); |
|
696 return; |
|
697 } |
|
698 |
|
699 switch(aMsgId) |
|
700 { |
|
701 case EIptvEngineSmGetServicesDataResp: |
|
702 iClient.GetServicesResp(MIptvServiceManagementClientObserver::ESucceeded, services); |
|
703 break; |
|
704 case EIptvEngineSmGetServicesUsingIdDataResp: |
|
705 iClient.GetServicesResp(MIptvServiceManagementClientObserver::ESucceeded, services); |
|
706 break; |
|
707 default: |
|
708 break; |
|
709 } |
|
710 |
|
711 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::HandleGetServicesDataRespL() exit"); |
|
712 } |
|
713 |
|
714 // ----------------------------------------------------------------------------- |
|
715 // CIptvServiceManagementClient::SetUsedIapL() |
|
716 // ----------------------------------------------------------------------------- |
|
717 // |
|
718 EXPORT_C void CIptvServiceManagementClient::SetUsedIapL(TUint32 aIapId, |
|
719 TUint32 aServiceId, |
|
720 TBool aSetToDefaultForService, |
|
721 CIptvNetworkSelection::TRespStatus& aRespStatus) |
|
722 { |
|
723 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::SetUsedIapL()"); |
|
724 |
|
725 if(IsActive()) |
|
726 { |
|
727 User::Leave(KErrNotReady); |
|
728 } |
|
729 |
|
730 delete iMsg; |
|
731 iMsg = NULL; |
|
732 |
|
733 /* EIptvEngineNsSetUsedIap message format: |
|
734 * ------------------------------- |
|
735 * TUint32 aIapId |
|
736 * TUint32 aServiceId |
|
737 * TUint8 aSetToDefaultForService |
|
738 * ------------------------------- |
|
739 */ |
|
740 |
|
741 /* EIptvEngineNsSetUsedIap response message format |
|
742 * -------------------- |
|
743 * TUint8 aRespStatus |
|
744 * -------------------- |
|
745 */ |
|
746 |
|
747 iMsg = HBufC8::NewL(4+4+1); |
|
748 iMsgPtr.Set(iMsg->Des()); |
|
749 |
|
750 RDesWriteStream writeStream; |
|
751 writeStream.Open(iMsgPtr); |
|
752 CleanupClosePushL( writeStream ); |
|
753 writeStream.WriteUint32L(aIapId); |
|
754 writeStream.WriteUint32L(aServiceId); |
|
755 writeStream.WriteUint8L(static_cast<TUint8>(aSetToDefaultForService)); |
|
756 writeStream.WriteUint8L(static_cast<TUint8>(aRespStatus)); |
|
757 CleanupStack::PopAndDestroy( &writeStream ); |
|
758 TInt err( KErrNotReady ); |
|
759 if ( !iSession.IsNull() ) |
|
760 { |
|
761 err = iSession.SendRequest(EIptvEngineNsSetUsedIap, iMsgPtr); |
|
762 } |
|
763 |
|
764 if(err == KErrNone) |
|
765 { |
|
766 RDesReadStream readStream; |
|
767 readStream.Open(iMsgPtr); |
|
768 CleanupClosePushL( readStream ); |
|
769 aRespStatus = static_cast<CIptvNetworkSelection::TRespStatus>(readStream.ReadUint8L()); |
|
770 CleanupStack::PopAndDestroy( &readStream ); |
|
771 } |
|
772 else |
|
773 { |
|
774 IPTVLOGSTRING2_LOW_LEVEL("CIptvServiceManagementClient:: SendRequest(EIptvEngineNsSetUsedIap) failed, error code = %d", err); |
|
775 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: aRespStatus set to CIptvNetworkSelection::EGeneralError"); |
|
776 aRespStatus = CIptvNetworkSelection::EGeneralError; |
|
777 } |
|
778 |
|
779 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::SetUsedIapL() exit"); |
|
780 } |
|
781 |
|
782 // ----------------------------------------------------------------------------- |
|
783 // CIptvServiceManagementClient::ClearUsedIap() |
|
784 // ----------------------------------------------------------------------------- |
|
785 // |
|
786 EXPORT_C TInt CIptvServiceManagementClient::ClearUsedIap() |
|
787 { |
|
788 return iSession.SendRequest(EIptvEngineNsClearUsedIap); |
|
789 } |
|
790 |
|
791 // ----------------------------------------------------------------------------- |
|
792 // CIptvServiceManagementClient::GetUsedIapReqL() |
|
793 // ----------------------------------------------------------------------------- |
|
794 // |
|
795 EXPORT_C void CIptvServiceManagementClient::GetUsedIapReqL( TUint32 aServiceId ) |
|
796 { |
|
797 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::GetUsedIapReqL()"); |
|
798 |
|
799 if ( IsActive() ) |
|
800 { |
|
801 User::Leave( KErrNotReady ); |
|
802 } |
|
803 BuildGetUsedIapReqL( aServiceId ); |
|
804 |
|
805 iSession.SendRequest(EIptvEngineNsGetUsedIapReq, iMsgPtr, iStatus); |
|
806 SetActive(); |
|
807 iRequestPendingFor = ENetworkSelectionRequestPending; |
|
808 iResponseMsgId = EIptvEngineNsGetUsedIapResp; |
|
809 |
|
810 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::GetUsedIapReqL() exit"); |
|
811 } |
|
812 |
|
813 // ----------------------------------------------------------------------------- |
|
814 // CIptvServiceManagementClient::GetUsedIapL() |
|
815 // ----------------------------------------------------------------------------- |
|
816 // |
|
817 EXPORT_C void CIptvServiceManagementClient::GetUsedIapL( TUint32 aServiceId, |
|
818 TUint32& aIapId, |
|
819 TDes& aIapName, |
|
820 CIptvNetworkSelection::TConnectionPermission& aConnectionPermission, |
|
821 CIptvNetworkSelection::TRespStatus& aRespStatus ) |
|
822 { |
|
823 BuildGetUsedIapReqL( aServiceId ); |
|
824 |
|
825 IPTVLOGSTRING2_LOW_LEVEL("CIptvServiceManagementClient:: sending EIptvEngineNsGetUsedIapReq for service %d", aServiceId); |
|
826 TInt err = iSession.SendRequest( EIptvEngineNsGetUsedIapReq, iMsgPtr ); |
|
827 |
|
828 if ( err != KErrNone ) |
|
829 { |
|
830 User::Leave( err ); |
|
831 } |
|
832 else |
|
833 { |
|
834 TUint8 temp; // Not used syncronous call |
|
835 HandleGetUsedIapRespL( aIapId, aIapName, aConnectionPermission, temp, aRespStatus ); |
|
836 } |
|
837 } |
|
838 |
|
839 // ----------------------------------------------------------------------------- |
|
840 // CIptvServiceManagementClient::IsConnectionAllowedL() |
|
841 // ----------------------------------------------------------------------------- |
|
842 // |
|
843 EXPORT_C void CIptvServiceManagementClient::IsConnectionAllowedL(TUint32 aServiceId, |
|
844 CIptvNetworkSelection::TConnectionPermission& aConnectionPermission, |
|
845 CIptvNetworkSelection::TRespStatus& aRespStatus) |
|
846 { |
|
847 |
|
848 if(IsActive()) |
|
849 { |
|
850 User::Leave(KErrNotReady); |
|
851 } |
|
852 |
|
853 delete iMsg; |
|
854 iMsg = NULL; |
|
855 |
|
856 /* EIptvEngineNsIsConnectionAllowed message format: |
|
857 * ------------------- |
|
858 * TUint32 aServiceId |
|
859 * ------------------- |
|
860 */ |
|
861 |
|
862 /* EIptvEngineNsIsConnectionAllowed response message format: |
|
863 * ----------------------------- |
|
864 * TUint8 aRespStatus |
|
865 * TUint8 aConnectionPermission |
|
866 * ----------------------------- |
|
867 */ |
|
868 |
|
869 iMsg = HBufC8::NewL(4); |
|
870 iMsgPtr.Set(iMsg->Des()); |
|
871 |
|
872 RDesWriteStream writeStream; |
|
873 writeStream.Open(iMsgPtr); |
|
874 CleanupClosePushL( writeStream ); |
|
875 writeStream.WriteUint32L(aServiceId); |
|
876 CleanupStack::PopAndDestroy( &writeStream ); |
|
877 |
|
878 TInt error = iSession.SendRequest(EIptvEngineNsIsConnectionAllowed, iMsgPtr); |
|
879 if(error == KErrNone) |
|
880 { |
|
881 RDesReadStream readStream; |
|
882 readStream.Open(iMsgPtr); |
|
883 CleanupClosePushL( readStream ); |
|
884 aRespStatus = static_cast<CIptvNetworkSelection::TRespStatus>(readStream.ReadUint8L()); |
|
885 aConnectionPermission = static_cast<CIptvNetworkSelection::TConnectionPermission>(readStream.ReadUint8L()); |
|
886 CleanupStack::PopAndDestroy( &readStream ); |
|
887 } |
|
888 else |
|
889 { |
|
890 aRespStatus = CIptvNetworkSelection::EGeneralError; |
|
891 } |
|
892 |
|
893 User::LeaveIfError(error); |
|
894 } |
|
895 |
|
896 // ----------------------------------------------------------------------------- |
|
897 // CIptvServiceManagementClient::SetConnectionAllowedL() |
|
898 // ----------------------------------------------------------------------------- |
|
899 // |
|
900 EXPORT_C void CIptvServiceManagementClient::SetConnectionAllowedL(TBool aConnectionAllowed, |
|
901 TUint32 aIapId, |
|
902 CIptvNetworkSelection::TRespStatus& aRespStatus) |
|
903 { |
|
904 |
|
905 if(IsActive()) |
|
906 { |
|
907 User::Leave(KErrNotReady); |
|
908 } |
|
909 |
|
910 delete iMsg; |
|
911 iMsg = NULL; |
|
912 |
|
913 /* EIptvEngineNsSetConnectionAllowed message format: |
|
914 * -------------------------- |
|
915 * TUint8 aConnectionAllowed |
|
916 * TUint32 aIapId |
|
917 * -------------------------- |
|
918 */ |
|
919 |
|
920 /* response message format: |
|
921 * ------------------- |
|
922 * TUint8 aRespStatus |
|
923 * ------------------- |
|
924 */ |
|
925 |
|
926 iMsg = HBufC8::NewL(1+4); |
|
927 iMsgPtr.Set(iMsg->Des()); |
|
928 |
|
929 RDesWriteStream writeStream; |
|
930 writeStream.Open(iMsgPtr); |
|
931 CleanupClosePushL( writeStream ); |
|
932 writeStream.WriteUint8L(aConnectionAllowed); |
|
933 writeStream.WriteUint32L(aIapId); |
|
934 CleanupStack::PopAndDestroy( &writeStream ); |
|
935 |
|
936 TInt error = iSession.SendRequest(EIptvEngineNsSetConnectionAllowed, iMsgPtr); |
|
937 |
|
938 if(error == KErrNone) |
|
939 { |
|
940 RDesReadStream readStream; |
|
941 readStream.Open(iMsgPtr); |
|
942 CleanupClosePushL( readStream ); |
|
943 aRespStatus = static_cast<CIptvNetworkSelection::TRespStatus>(readStream.ReadUint8L()); |
|
944 CleanupStack::PopAndDestroy( &readStream ); |
|
945 } |
|
946 else |
|
947 { |
|
948 aRespStatus = CIptvNetworkSelection::EGeneralError; |
|
949 } |
|
950 |
|
951 User::LeaveIfError(error); |
|
952 } |
|
953 |
|
954 // ----------------------------------------------------------------------------- |
|
955 // CIptvServiceManagementClient::GetRespStatusL() |
|
956 // ----------------------------------------------------------------------------- |
|
957 // |
|
958 MIptvServiceManagementClientObserver::TRespStatus CIptvServiceManagementClient::GetRespStatusL() |
|
959 { |
|
960 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::GetRespStatusL()"); |
|
961 |
|
962 if(iStatus.Int() != KErrNone) |
|
963 { |
|
964 //operation leaved on server side -> mark request as failed |
|
965 IPTVLOGSTRING2_LOW_LEVEL("CIptvServiceManagementClient:: operation leaved on server side (error code = %d)->EGeneralError", iStatus.Int()); |
|
966 return MIptvServiceManagementClientObserver::EGeneralError; |
|
967 } |
|
968 |
|
969 RDesReadStream readStream; |
|
970 readStream.Open(iMsgPtr); |
|
971 CleanupClosePushL( readStream ); |
|
972 MIptvServiceManagementClientObserver::TRespStatus respStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
973 |
|
974 TRAPD(err, |
|
975 respStatus = static_cast<MIptvServiceManagementClientObserver::TRespStatus>(readStream.ReadUint8L()); |
|
976 ); |
|
977 |
|
978 if (err != KErrNone) |
|
979 { |
|
980 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: failed to read status!"); |
|
981 respStatus = MIptvServiceManagementClientObserver::EGeneralError; |
|
982 } |
|
983 |
|
984 CleanupStack::PopAndDestroy( &readStream ); |
|
985 |
|
986 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::GetRespStatusL() exit"); |
|
987 return respStatus; |
|
988 } |
|
989 |
|
990 // ----------------------------------------------------------------------------- |
|
991 // CIptvServiceManagementClient::GetServicesL() |
|
992 // ----------------------------------------------------------------------------- |
|
993 // |
|
994 EXPORT_C TInt CIptvServiceManagementClient::GetServicesL(const TDesC& aProviderId, |
|
995 CIptvServices& aServices) |
|
996 { |
|
997 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::GetServicesL(aProviderId)"); |
|
998 |
|
999 if(IsActive()) |
|
1000 { |
|
1001 return KErrNotReady; |
|
1002 } |
|
1003 |
|
1004 /* EIptvEngineSmGetServiceSizeUsingProviderId client->server message format: |
|
1005 * ------------------------------------ |
|
1006 * TUint32 aProviderIdLength |
|
1007 * TBuf<aProviderIdLength> aProviderId |
|
1008 * ------------------------------------ |
|
1009 */ |
|
1010 |
|
1011 /* EIptvEngineSmGetServiceSizeUsingProviderId server->client message format: |
|
1012 * ------------------------------- |
|
1013 * TUint32 aSize |
|
1014 * ------------------------------- |
|
1015 */ |
|
1016 |
|
1017 /* EIptvEngineSmGetServiceDataUsingProviderId client->server message format: |
|
1018 * -------------------- |
|
1019 * -------------------- |
|
1020 */ |
|
1021 |
|
1022 /* EIptvEngineSmGetServiceDataUsingProviderId server->client message format: |
|
1023 * --------------------------------------------- |
|
1024 * CIptvServices object in binary format |
|
1025 * --------------------------------------------- |
|
1026 */ |
|
1027 |
|
1028 //build EIptvEngineSmGetServiceSizeUsingProviderId client->server |
|
1029 HBufC8* ipcMsg = HBufC8::NewL(4 + aProviderId.Length()*2); |
|
1030 CleanupStack::PushL(ipcMsg); |
|
1031 TPtr8 ipcMsgPtr(ipcMsg->Des()); |
|
1032 ipcMsgPtr.Zero(); |
|
1033 |
|
1034 RDesWriteStream writeStream; |
|
1035 writeStream.Open(ipcMsgPtr); |
|
1036 CleanupClosePushL( writeStream ); |
|
1037 writeStream.WriteUint32L(aProviderId.Length()); |
|
1038 TInt i; |
|
1039 for(i = 0; i < aProviderId.Length(); i++) |
|
1040 { |
|
1041 writeStream.WriteInt16L(aProviderId[i]); |
|
1042 } |
|
1043 |
|
1044 CleanupStack::PopAndDestroy( &writeStream ); |
|
1045 |
|
1046 //send size request |
|
1047 TInt resp = iSession.SendRequest(EIptvEngineSmGetServiceSizeUsingProviderId, ipcMsgPtr); |
|
1048 |
|
1049 if(resp != KErrNone) |
|
1050 { |
|
1051 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: size resp error"); |
|
1052 CleanupStack::PopAndDestroy(ipcMsg); |
|
1053 return resp; |
|
1054 } |
|
1055 |
|
1056 //build data request |
|
1057 TUint32 dataSize; |
|
1058 RDesReadStream readStream; |
|
1059 readStream.Open(ipcMsgPtr); |
|
1060 CleanupClosePushL( readStream ); |
|
1061 dataSize = readStream.ReadUint32L(); |
|
1062 CleanupStack::PopAndDestroy( &readStream ); |
|
1063 CleanupStack::PopAndDestroy(ipcMsg); |
|
1064 ipcMsg = NULL; |
|
1065 ipcMsg = HBufC8::NewL(dataSize); |
|
1066 CleanupStack::PushL(ipcMsg); |
|
1067 ipcMsgPtr.Set(ipcMsg->Des()); |
|
1068 |
|
1069 //send data request |
|
1070 resp = iSession.SendRequest(EIptvEngineSmGetServiceDataUsingProviderId, ipcMsgPtr); |
|
1071 |
|
1072 if(resp != KErrNone) |
|
1073 { |
|
1074 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: data resp error"); |
|
1075 CleanupStack::PopAndDestroy(ipcMsg); |
|
1076 return resp; |
|
1077 } |
|
1078 |
|
1079 //read services data |
|
1080 readStream.Open(ipcMsgPtr); |
|
1081 CleanupClosePushL( readStream ); |
|
1082 aServices.InternalizeL(readStream); |
|
1083 CleanupStack::PopAndDestroy( &readStream ); |
|
1084 |
|
1085 CleanupStack::PopAndDestroy(ipcMsg); // <-1 |
|
1086 |
|
1087 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: Get services using provider id successful."); |
|
1088 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::GetServicesL(aProviderId) exit"); |
|
1089 return resp; |
|
1090 } |
|
1091 |
|
1092 // ----------------------------------------------------------------------------- |
|
1093 // CIptvServiceManagementClient::SetAllIapsReqL() |
|
1094 // ----------------------------------------------------------------------------- |
|
1095 // |
|
1096 EXPORT_C void CIptvServiceManagementClient::SetAllIapsReqL(CIptvIapList& /* aIapList */, |
|
1097 TBool /*aIgnoreReadOnlyFlag*/) |
|
1098 { |
|
1099 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::SetAllIapsReqL()"); |
|
1100 |
|
1101 if(IsActive()) |
|
1102 { |
|
1103 User::Leave(KErrNotReady); |
|
1104 } |
|
1105 |
|
1106 delete iMsg; |
|
1107 iMsg = NULL; |
|
1108 |
|
1109 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: !!! Not Supported Yet!!!"); |
|
1110 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::SetAllIapsReqL() exit"); |
|
1111 User::Leave(KErrNotSupported); //not supported yet |
|
1112 } |
|
1113 |
|
1114 // ----------------------------------------------------------------------------- |
|
1115 // CIptvServiceManagementClient::SetAllIapsL() |
|
1116 // ----------------------------------------------------------------------------- |
|
1117 // |
|
1118 EXPORT_C void CIptvServiceManagementClient::SetAllIapsL( |
|
1119 CIptvIapList& /*aIapList*/, |
|
1120 TBool /*aIgnoreReadOnlyFlag*/, |
|
1121 MIptvServiceManagementClientObserver::TRespStatus& /*aRespStatus*/) |
|
1122 { |
|
1123 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::SetAllIapsL()"); |
|
1124 |
|
1125 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient:: !!! Not Supported Yet!!!"); |
|
1126 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::SetAllIapsL() exit"); |
|
1127 User::Leave( KErrNotSupported ); |
|
1128 } |
|
1129 // ----------------------------------------------------------------------------- |
|
1130 // CIptvServiceManagementClient::HandleEvent() |
|
1131 // ----------------------------------------------------------------------------- |
|
1132 // |
|
1133 void CIptvServiceManagementClient::HandleEvent( MIptvEvent& aEvent ) |
|
1134 { |
|
1135 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::HandleEvent()"); |
|
1136 |
|
1137 //this event is never routed to synchronizer |
|
1138 iClient.HandleSmEvent( static_cast<CIptvSmEvent&>( aEvent ) ); |
|
1139 |
|
1140 IPTVLOGSTRING_LOW_LEVEL("CIptvServiceManagementClient::HandleEvent() exit"); |
|
1141 } |
|
1142 |
|
1143 // ----------------------------------------------------------------------------- |
|
1144 // CIptvServiceManagementClient::BuildAddServiceReqL() |
|
1145 // ----------------------------------------------------------------------------- |
|
1146 // |
|
1147 void CIptvServiceManagementClient::BuildAddServiceReqL( CIptvService& aService ) |
|
1148 { |
|
1149 delete iMsg; |
|
1150 iMsg = NULL; |
|
1151 iMsg = HBufC8::NewL( aService.CountExternalizeSize() ); |
|
1152 iMsgPtr.Set( iMsg->Des() ); |
|
1153 iMsgPtr.Zero(); |
|
1154 |
|
1155 //initialize stream object to use ipc msg as a data buffer |
|
1156 RDesWriteStream writeStream; |
|
1157 writeStream.Open( iMsgPtr ); |
|
1158 CleanupClosePushL( writeStream ); |
|
1159 aService.ExternalizeL( writeStream ); |
|
1160 CleanupStack::PopAndDestroy( &writeStream ); |
|
1161 } |
|
1162 |
|
1163 // ----------------------------------------------------------------------------- |
|
1164 // CIptvServiceManagementClient::BuildUpdateServiceReqL() |
|
1165 // ----------------------------------------------------------------------------- |
|
1166 // |
|
1167 void CIptvServiceManagementClient::BuildUpdateServiceReqL( CIptvService& aService ) |
|
1168 { |
|
1169 delete iMsg; |
|
1170 iMsg = NULL; |
|
1171 iMsg = HBufC8::NewL( aService.CountExternalizeSize() ); |
|
1172 iMsgPtr.Set( iMsg->Des() ); |
|
1173 |
|
1174 iMsgPtr.Zero(); |
|
1175 |
|
1176 RDesWriteStream writeStream; |
|
1177 |
|
1178 //initialize stream object to use ipc msg as a data buffer |
|
1179 writeStream.Open( iMsgPtr ); |
|
1180 CleanupClosePushL( writeStream ); |
|
1181 aService.ExternalizeL(writeStream); |
|
1182 CleanupStack::PopAndDestroy( &writeStream ); |
|
1183 } |
|
1184 |
|
1185 // ----------------------------------------------------------------------------- |
|
1186 // CIptvServiceManagementClient::BuildGetServicesReqL() |
|
1187 // ----------------------------------------------------------------------------- |
|
1188 // |
|
1189 void CIptvServiceManagementClient::BuildGetServicesSizeReqL( |
|
1190 TUint32 aSearchLimitFlags, |
|
1191 TOrder aOrder) |
|
1192 { |
|
1193 delete iMsg; |
|
1194 iMsg = NULL; |
|
1195 iMsg = HBufC8::NewL(4 /* TUint32 aSearchLimitFlags*/ + 1 /* TUint8 aOrder*/); |
|
1196 iMsgPtr.Set( iMsg->Des() ); |
|
1197 iMsgPtr.Zero(); |
|
1198 |
|
1199 RDesWriteStream writeStream; |
|
1200 writeStream.Open( iMsgPtr ); |
|
1201 CleanupClosePushL( writeStream ); |
|
1202 writeStream.WriteUint32L( aSearchLimitFlags ); |
|
1203 writeStream.WriteUint8L( aOrder ); |
|
1204 CleanupStack::PopAndDestroy( &writeStream ); |
|
1205 } |
|
1206 |
|
1207 // ----------------------------------------------------------------------------- |
|
1208 // CIptvServiceManagementClient::InternalizeGetServicesDataRespL() |
|
1209 // ----------------------------------------------------------------------------- |
|
1210 // |
|
1211 CDesC8ArraySeg* CIptvServiceManagementClient::InternalizeGetServicesDataRespL() |
|
1212 { |
|
1213 RDesReadStream readStream; |
|
1214 readStream.Open(iMsgPtr); // open |
|
1215 CleanupClosePushL( readStream ); |
|
1216 TUint8 status = readStream.ReadUint8L(); |
|
1217 |
|
1218 if(status != MIptvServiceManagementClientObserver::ESucceeded) |
|
1219 { |
|
1220 IPTVLOGSTRING2_LOW_LEVEL("CIptvServiceManagementClient:: get services data req failed: %d", status); |
|
1221 CleanupStack::PopAndDestroy( &readStream ); |
|
1222 User::Leave(KErrGeneral); |
|
1223 } |
|
1224 |
|
1225 TUint32 itemCount = readStream.ReadUint32L(); |
|
1226 TUint32 i; |
|
1227 |
|
1228 CDesC8ArraySeg* stringArray; |
|
1229 stringArray = new (ELeave) CDesC8ArraySeg(10); |
|
1230 CleanupStack::PushL(stringArray); |
|
1231 |
|
1232 CIptvService* service = CIptvService::NewL(); |
|
1233 CleanupStack::PushL(service); |
|
1234 |
|
1235 for(i = 0; i < itemCount; i++) |
|
1236 { |
|
1237 service->InternalizeL(readStream); |
|
1238 HBufC8* serviceData = service->GetL(); |
|
1239 CleanupStack::PushL(serviceData); |
|
1240 stringArray->AppendL(serviceData->Des()); |
|
1241 CleanupStack::PopAndDestroy(serviceData); |
|
1242 } |
|
1243 |
|
1244 CleanupStack::PopAndDestroy(service); |
|
1245 CleanupStack::Pop(stringArray); // don't delete since it's given to caller |
|
1246 CleanupStack::PopAndDestroy( &readStream ); |
|
1247 |
|
1248 delete iMsg; |
|
1249 iMsg = NULL; |
|
1250 |
|
1251 return stringArray; |
|
1252 } |
|
1253 |
|
1254 // ----------------------------------------------------------------------------- |
|
1255 // CIptvServiceManagementClient::BuildDeleteServiceReqL() |
|
1256 // ----------------------------------------------------------------------------- |
|
1257 // |
|
1258 void CIptvServiceManagementClient::BuildDeleteServiceReqL(TUint32 aId) |
|
1259 { |
|
1260 delete iMsg; |
|
1261 iMsg = NULL; |
|
1262 iMsg = HBufC8::NewL(4); |
|
1263 iMsgPtr.Set(iMsg->Des()); |
|
1264 |
|
1265 RDesWriteStream writeStream; |
|
1266 writeStream.Open(iMsgPtr); |
|
1267 CleanupClosePushL( writeStream ); |
|
1268 writeStream.WriteUint32L(aId); |
|
1269 CleanupStack::PopAndDestroy( &writeStream ); |
|
1270 } |
|
1271 |
|
1272 // ----------------------------------------------------------------------------- |
|
1273 // CIptvServiceManagementClient::BuildGetServicesUsingIndexSizeReq() |
|
1274 // ----------------------------------------------------------------------------- |
|
1275 // |
|
1276 void CIptvServiceManagementClient::BuildGetServicesUsingIndexSizeReqL(TUint32 aStartId, TUint32 aEndId) |
|
1277 { |
|
1278 delete iMsg; |
|
1279 iMsg = NULL; |
|
1280 iMsg = HBufC8::NewL(4 /* TUint32 aStartId */ + 4 /* TUint32 aEndId */); |
|
1281 iMsgPtr.Set(iMsg->Des()); |
|
1282 |
|
1283 RDesWriteStream writeStream; |
|
1284 writeStream.Open(iMsgPtr); |
|
1285 CleanupClosePushL( writeStream ); |
|
1286 writeStream.WriteUint32L(aStartId); //+4 |
|
1287 writeStream.WriteUint32L(aEndId); //+4 |
|
1288 CleanupStack::PopAndDestroy( &writeStream ); |
|
1289 } |
|
1290 |
|
1291 // ----------------------------------------------------------------------------- |
|
1292 // CIptvServiceManagementClient::BuildGetUsedIapReqL() |
|
1293 // ----------------------------------------------------------------------------- |
|
1294 // |
|
1295 void CIptvServiceManagementClient::BuildGetUsedIapReqL( TUint32 aServiceId ) |
|
1296 { |
|
1297 delete iMsg; |
|
1298 iMsg = NULL; |
|
1299 |
|
1300 /* EIptvEngineNsGetUsedIapReq message format: |
|
1301 * ------------------ |
|
1302 * TUint32 aServiceId |
|
1303 * ------------------ |
|
1304 */ |
|
1305 |
|
1306 /* EIptvEngineNsGetUsedIapResp message format: |
|
1307 * ------------------- |
|
1308 * TUint8 aRespStatus |
|
1309 * TUint32 aIapId |
|
1310 * TUint16 aIapNameLength |
|
1311 * <aIapNameLength * TUint16> aIapNameData (contains SSID if iapname not found) |
|
1312 * TUint8 aConnectionPermission |
|
1313 * ------------------- |
|
1314 */ |
|
1315 |
|
1316 iMsg = HBufC8::NewL( 1+4+2+(KIptvNsIapNameMaxLength*2)+1 ); |
|
1317 iMsgPtr.Set( iMsg->Des() ); |
|
1318 |
|
1319 RDesWriteStream writeStream; |
|
1320 writeStream.Open(iMsgPtr); |
|
1321 CleanupClosePushL( writeStream ); |
|
1322 writeStream.WriteUint32L( aServiceId ); |
|
1323 CleanupStack::PopAndDestroy( &writeStream ); |
|
1324 } |
|
1325 |
|
1326 // ----------------------------------------------------------------------------- |
|
1327 // CIptvServiceManagementClient::HandleGetUsedIapRespL() |
|
1328 // ----------------------------------------------------------------------------- |
|
1329 // |
|
1330 void CIptvServiceManagementClient::HandleGetUsedIapRespL( TUint32& aIapId, |
|
1331 TDes& aIapName, |
|
1332 CIptvNetworkSelection::TConnectionPermission& aConnectionPermission, |
|
1333 TUint8& aWlanWhenGprs, |
|
1334 CIptvNetworkSelection::TRespStatus& aRespStatus ) |
|
1335 { |
|
1336 /* EIptvEngineNsGetUsedIapReq message format: |
|
1337 * ------------------ |
|
1338 * TUint32 aServiceId |
|
1339 * ------------------ |
|
1340 */ |
|
1341 |
|
1342 /* EIptvEngineNsGetUsedIapResp message format: |
|
1343 * ------------------- |
|
1344 * TUint8 aRespStatus |
|
1345 * TUint32 aIapId |
|
1346 * TUint16 aIapNameLength |
|
1347 * <aIapNameLength * TUint16> aIapNameData (contains SSID if iapname not found) |
|
1348 * TUint8 aConnectionPermission |
|
1349 * TUint8 aWlanWhenGprs |
|
1350 * ------------------- |
|
1351 */ |
|
1352 |
|
1353 RDesReadStream readStream; |
|
1354 readStream.Open( iMsgPtr ); |
|
1355 CleanupClosePushL( readStream ); |
|
1356 aRespStatus |
|
1357 = static_cast<CIptvNetworkSelection::TRespStatus>(readStream.ReadUint8L()); |
|
1358 aIapId = readStream.ReadUint32L(); |
|
1359 CIptvUtil::ReadDesFromStreamL( aIapName, readStream ); |
|
1360 aConnectionPermission = |
|
1361 static_cast<CIptvNetworkSelection::TConnectionPermission>( readStream.ReadUint8L() ); |
|
1362 aWlanWhenGprs = readStream.ReadUint8L(); |
|
1363 CleanupStack::PopAndDestroy( &readStream ); |
|
1364 } |