|
1 /* |
|
2 * Copyright (c) 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 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: Implementation of the scheduled download plugin engine.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <bldvariant.hrh> |
|
21 #include <e32cmn.h> |
|
22 #include <s32mem.h> |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <e32msgqueue.h> |
|
26 #include <ipvideo/CCseScheduledProgram.h> |
|
27 #include <ipvideo/MCsePluginObserver.h> |
|
28 #include "IptvLiveDataStructures.h" |
|
29 #include <hwrmpowerstatesdkpskeys.h> |
|
30 #include <commdb.h> |
|
31 #include "IptvDebug.h" |
|
32 #include <CProfileChangeNotifyHandler.h> |
|
33 #include <Profile.hrh> |
|
34 #include <MProfileEngine.h> |
|
35 #include "CIptvMediaContent.h" |
|
36 |
|
37 #include "vcnsscheduleddownloadpluginengine.h" |
|
38 #include "iptvbatterywatcher.h" |
|
39 #include "iptvphoneregistrationwatcher.h" |
|
40 #include "vcnsscheduleddownloadmpxclient.h" |
|
41 |
|
42 // MACROS |
|
43 #define RETURNONERROR(e) \ |
|
44 { \ |
|
45 if ( ( e ) != KErrNone ) \ |
|
46 { \ |
|
47 IPTVLOGSTRING2_HIGH_LEVEL( \ |
|
48 ">>> CIptvScheduledDownloadPluginEngine return with error code: %d", ( e ) ); \ |
|
49 return; \ |
|
50 } \ |
|
51 } |
|
52 |
|
53 // LOCAL CONSTANTS AND MACROS |
|
54 const TInt KIptvTimeoutInMicroseconds = 15 * 60 * 1000 * 1000 ; // 15 minutes |
|
55 const TInt KIptvSearchStringmaxLen = 10; |
|
56 const TInt KIptvGetAll = 0; |
|
57 const TInt KIptvNoFileOrDrive = 0; |
|
58 |
|
59 |
|
60 // ============================ MEMBER FUNCTIONS =============================== |
|
61 |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CIptvScheduledDownloadPluginEngine::NewL |
|
65 // |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CIptvScheduledDownloadPluginEngine* CIptvScheduledDownloadPluginEngine::NewL( |
|
69 MCsePluginObserver& aObserver ) |
|
70 { |
|
71 CIptvScheduledDownloadPluginEngine* self = |
|
72 new ( ELeave ) CIptvScheduledDownloadPluginEngine( aObserver ); |
|
73 |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL( ); |
|
76 CleanupStack::Pop( self ); |
|
77 |
|
78 return self; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CIptvScheduledDownloadPluginEngine::ConstructL |
|
83 // |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CIptvScheduledDownloadPluginEngine::ConstructL() |
|
87 { |
|
88 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::ConstructL"); |
|
89 |
|
90 iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; |
|
91 iVodDownloads = CIptvVodDlDownloadList::NewL(); |
|
92 iIptvServiceManagementClient = CIptvServiceManagementClient::NewL( *this ); |
|
93 iBatteryWatcher = CIptvBatteryWatcher::NewL(); |
|
94 iBatteryWatcher->AddObserverL( this ); |
|
95 CTimer::ConstructL(); |
|
96 CActiveScheduler::Add( this ); |
|
97 iProfChangeHandler = CProfileChangeNotifyHandler::NewL( this ); |
|
98 iPhoneRegistrationWatcher = CIptvPhoneRegistrationWatcher::NewL(); |
|
99 iPhoneRegistrationWatcher->AddObserverL( this ); |
|
100 |
|
101 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::ConstructL"); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CIptvScheduledDownloadPluginEngine::CIptvScheduledDownloadPluginEngine |
|
106 // |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 CIptvScheduledDownloadPluginEngine::CIptvScheduledDownloadPluginEngine( |
|
110 MCsePluginObserver& aObserver ) : |
|
111 CTimer( EPriorityNormal ), iObserver( aObserver ) |
|
112 { |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CIptvScheduledDownloadPluginEngine::~CIptvScheduledDownloadPluginEngine |
|
117 // |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 CIptvScheduledDownloadPluginEngine::~CIptvScheduledDownloadPluginEngine() |
|
121 { |
|
122 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::~CIptvScheduledDownloadPluginEngine"); |
|
123 |
|
124 // Set error value to KErrAbort. This will cause nearly instant return from |
|
125 // RunTaskL -method in case we're aborting plugin execution. This would mean |
|
126 // that we're actually running dead code. Class is already destroyed, but the |
|
127 // stack is still alive and kicking. This isn't a problems unless we change |
|
128 // internal class variables (class is destroyed, but the stack is still there). |
|
129 if ( iErrorReason ) |
|
130 { |
|
131 *iErrorReason = KErrAbort; |
|
132 } |
|
133 |
|
134 // Uses iActiveSchedulerWait so pointer must exists. |
|
135 if ( iActiveSchedulerWait ) |
|
136 { |
|
137 ActiveWait( EFalse ); |
|
138 } |
|
139 |
|
140 delete iPhoneRegistrationWatcher; |
|
141 delete iProfChangeHandler; |
|
142 delete iBatteryWatcher; |
|
143 delete iVodDlClient; |
|
144 delete iIptvVodContentClient; |
|
145 delete iIptvServiceManagementClient; |
|
146 delete iService; |
|
147 delete iVodDownloads; |
|
148 delete iActiveSchedulerWait; |
|
149 |
|
150 iEcgList.ResetAndDestroy(); |
|
151 iCategoryList.ResetAndDestroy(); |
|
152 |
|
153 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::~CIptvScheduledDownloadPluginEngine"); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CIptvScheduledDownloadPluginEngine::RunTaskL |
|
158 // |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 void CIptvScheduledDownloadPluginEngine::RunTaskL( |
|
162 CCseScheduledProgram& aProg, |
|
163 TInt& aEngineReturnValue ) |
|
164 { |
|
165 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::RunTaskL"); |
|
166 |
|
167 TInt errorReason( KErrNone ); |
|
168 |
|
169 iErrorReason = &errorReason; |
|
170 |
|
171 iState = EStarted; |
|
172 |
|
173 RestartTimeoutTimer(); |
|
174 |
|
175 // Check that we are not in offline mode, reschedule if we are |
|
176 CheckOfflineModeL(); |
|
177 aEngineReturnValue = errorReason; |
|
178 RETURNONERROR( errorReason ) |
|
179 |
|
180 // Get used Service ID |
|
181 iServiceID = GetServiceIdL( aProg ); |
|
182 |
|
183 if (iIptvVodContentClient) |
|
184 { |
|
185 delete iIptvVodContentClient; |
|
186 iIptvVodContentClient = NULL; |
|
187 } |
|
188 iIptvVodContentClient = CIptvVodContentClient::NewL( iServiceID, *this ); |
|
189 |
|
190 // Check Battery Status |
|
191 GetBatteryStatus(); |
|
192 aEngineReturnValue = errorReason; |
|
193 RETURNONERROR( errorReason ) |
|
194 |
|
195 // Get and check the used IAP |
|
196 GetUsableIapL(); |
|
197 aEngineReturnValue = errorReason; |
|
198 RETURNONERROR( errorReason ) |
|
199 |
|
200 iState = EUpdatingContentGuide; |
|
201 |
|
202 // Remember the time, this will be used as last successfull download time |
|
203 TTime now; |
|
204 now.HomeTime(); |
|
205 |
|
206 // Update ECG, blocks until the update either is either finished or fails |
|
207 UpdateEpgL(); |
|
208 aEngineReturnValue = errorReason; |
|
209 RETURNONERROR( errorReason); |
|
210 |
|
211 RestartTimeoutTimer(); |
|
212 |
|
213 // Update epg and start downloads |
|
214 LoadContentL(); |
|
215 aEngineReturnValue = errorReason; |
|
216 RETURNONERROR( errorReason ) |
|
217 |
|
218 // Are we downloading |
|
219 if (iState == EDownloadingFiles) |
|
220 { |
|
221 // This block until the files are downloaded |
|
222 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::RunTaskL starting to wait the downloads to finish"); |
|
223 ActiveWait( ETrue ); |
|
224 } |
|
225 |
|
226 aEngineReturnValue = errorReason; |
|
227 RETURNONERROR( errorReason ) |
|
228 |
|
229 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::RunTaskL downloads finished, updating schedules"); |
|
230 |
|
231 iState = EFinished; |
|
232 |
|
233 // Update all schedules by changing the last successfull download time |
|
234 UpdateLastDownloadTimeL( now ); |
|
235 |
|
236 iObserver.PluginCompleted( KErrNone ); |
|
237 |
|
238 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::RunTaskL"); |
|
239 |
|
240 } |
|
241 |
|
242 // from CTimer, CActive |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CIptvScheduledDownloadPluginEngine::RunL |
|
246 // |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 void CIptvScheduledDownloadPluginEngine::RunL() |
|
250 { |
|
251 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::RunL"); |
|
252 |
|
253 // No activity in KTimeoutInMilliseconds |
|
254 // Assuming some kind of error situation and aborting all activities |
|
255 *iErrorReason = KErrTimedOut; |
|
256 CancelDownloads(); |
|
257 ActiveWait( EFalse ); |
|
258 |
|
259 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::RunL"); |
|
260 } |
|
261 |
|
262 // from MIptvServiceManagementClientObserver |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CIptvScheduledDownloadPluginEngine::AddServiceResp |
|
266 // |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 void CIptvScheduledDownloadPluginEngine::AddServiceResp( |
|
270 TRespStatus /*aRespStatus*/) |
|
271 { |
|
272 IPTVLOGSTRING_HIGH_LEVEL(">>><<< CIptvScheduledDownloadPluginEngine::AddServiceResp"); |
|
273 } |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // CIptvScheduledDownloadPluginEngine::UpdateServiceResp |
|
277 // |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 void CIptvScheduledDownloadPluginEngine::UpdateServiceResp( |
|
281 TRespStatus /*aRespStatus*/) |
|
282 { |
|
283 IPTVLOGSTRING_HIGH_LEVEL(">>><<< CIptvScheduledDownloadPluginEngine::UpdateServiceResp"); |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CIptvScheduledDownloadPluginEngine::DeleteServiceResp |
|
288 // |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 void CIptvScheduledDownloadPluginEngine::DeleteServiceResp( |
|
292 TRespStatus /*aRespStatus*/) |
|
293 { |
|
294 IPTVLOGSTRING_HIGH_LEVEL(">>><<< CIptvScheduledDownloadPluginEngine::DeleteServiceResp"); |
|
295 } |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // CIptvScheduledDownloadPluginEngine::GetServicesResp |
|
299 // |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 void CIptvScheduledDownloadPluginEngine::GetServicesResp( |
|
303 TRespStatus /*aRespStatus*/, |
|
304 CDesC8ArraySeg* /*aServicesArray*/) |
|
305 { |
|
306 IPTVLOGSTRING_HIGH_LEVEL(">>><<< CIptvScheduledDownloadPluginEngine::GetServicesResp"); |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CIptvScheduledDownloadPluginEngine::GetUsedIapResp |
|
311 // |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void CIptvScheduledDownloadPluginEngine::GetUsedIapResp( |
|
315 TUint32 /*aIapId*/, |
|
316 const TDesC& /*aIapName*/, |
|
317 CIptvNetworkSelection::TConnectionPermission /*aConnectionPermission*/, |
|
318 TBool /*aWlanWhenGPRS*/, |
|
319 CIptvNetworkSelection::TRespStatus /*aRespStatus*/ ) |
|
320 { |
|
321 IPTVLOGSTRING_HIGH_LEVEL(">>><<< CIptvScheduledDownloadPluginEngine::GetUsedIapResp"); |
|
322 } |
|
323 |
|
324 // ----------------------------------------------------------------------------- |
|
325 // CIptvScheduledDownloadPluginEngine::ServerShutdownResp |
|
326 // |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 void CIptvScheduledDownloadPluginEngine::ServerShutdownResp( |
|
330 TRespStatus /*aRespStatus*/) |
|
331 { |
|
332 IPTVLOGSTRING_HIGH_LEVEL(">>><<< CIptvScheduledDownloadPluginEngine::ServerShutdownResp"); |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CIptvScheduledDownloadPluginEngine::HandleSmEvent |
|
337 // |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 void CIptvScheduledDownloadPluginEngine::HandleSmEvent( |
|
341 CIptvSmEvent& /*aEvent*/) |
|
342 { |
|
343 IPTVLOGSTRING_HIGH_LEVEL(">>><<< CIptvScheduledDownloadPluginEngine::HandleSmEvent"); |
|
344 } |
|
345 |
|
346 |
|
347 // from MIptvVodContentClientObserver |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CIptvScheduledDownloadPluginEngine::HandleEpgManagerMsgL |
|
351 // |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 void CIptvScheduledDownloadPluginEngine::HandleEpgManagerMsgL( |
|
355 TInt aMsg, |
|
356 TInt /*aInfo*/, |
|
357 TIptvServiceId /*aServiceId*/) |
|
358 { |
|
359 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::HandleEpgManagerMsgL"); |
|
360 IPTVLOGSTRING2_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::HandleEpgManagerMsgL, msg = %d", aMsg); |
|
361 |
|
362 switch (aMsg) |
|
363 { |
|
364 case KIptvErrorEpgUpdateFailed: |
|
365 { |
|
366 // EPG update failed for some reason, try again later |
|
367 *iErrorReason = EReschedule; |
|
368 ActiveWait( EFalse ); |
|
369 } |
|
370 break; |
|
371 |
|
372 case KIptvVodUpdateNotStarted: |
|
373 case KIptvErrorEpgUpdateSuccessed: |
|
374 { |
|
375 if (iState == EUpdatingContentGuide) |
|
376 { |
|
377 ActiveWait( EFalse ); |
|
378 } |
|
379 } |
|
380 break; |
|
381 |
|
382 case KIptvErrorVodNoIap: |
|
383 { |
|
384 if (iState == EUpdatingContentGuide) |
|
385 { |
|
386 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::HandleEpgManagerMsgL, setting iap"); |
|
387 iIptvVodContentClient->SetIapL( iIapId ); |
|
388 } |
|
389 } |
|
390 break; |
|
391 |
|
392 case KIptvVodUpdateStarted: |
|
393 case KIptvErrorEpgUpdateStopped: |
|
394 case KIptvContentUpdateCompleted: |
|
395 case KIptvServiceThumbnailDownloaded: |
|
396 case KIptvContentThumbnailDownloaded: |
|
397 default: |
|
398 { |
|
399 // No operation, update still in progress. |
|
400 } |
|
401 break; |
|
402 } |
|
403 |
|
404 RestartTimeoutTimer(); |
|
405 |
|
406 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::HandleEpgManagerMsgL"); |
|
407 } |
|
408 |
|
409 // from MIptvVodDlClientObserver |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // CIptvScheduledDownloadPluginEngine::HandleVodDlDownloadEvent |
|
413 // |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 void CIptvScheduledDownloadPluginEngine::HandleVodDlDownloadEvent( |
|
417 CIptvVodDlDownloadEvent& aEvent) |
|
418 { |
|
419 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::HandleVodDlDownloadEvent"); |
|
420 IPTVLOGSTRING2_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::HandleVodDlDownloadEvent, event = %d", aEvent.iEvent); |
|
421 |
|
422 switch (aEvent.iEvent) |
|
423 { |
|
424 case CIptvVodDlDownloadEvent::EDownloadState: |
|
425 { |
|
426 switch ( aEvent.iState ) |
|
427 { |
|
428 case KIptvVodDlDownloadInQueue: |
|
429 case KIptvVodDlDownloadStarting: |
|
430 case KIptvVodDlDownloadDeleted: |
|
431 case KIptvVodDlDownloadPermanentlyPausing: |
|
432 case KIptvVodDlDownloadCreated: |
|
433 case KIptvVodDlDownloadIdle: |
|
434 case KIptvVodDlDownloadGlobalFileIdIsValid: |
|
435 case KIptvVodDlDownloadRunning: |
|
436 case KIptvVodDlDownloadPausing: |
|
437 case KIptvVodDlDownloadPaused: |
|
438 { |
|
439 } |
|
440 break; |
|
441 |
|
442 case KIptvVodDlDownloadPermanentlyPaused: |
|
443 case KIptvVodDlDownloadFailed: |
|
444 { |
|
445 if (DeleteFromList( aEvent.iServiceId, aEvent.iContentId )) |
|
446 { |
|
447 TRAP_IGNORE( iVodDlClient->CancelDownloadL( |
|
448 aEvent.iServiceId, |
|
449 aEvent.iContentId ) ) |
|
450 } |
|
451 } |
|
452 break; |
|
453 |
|
454 case KIptvVodDlDownloadDeletedCompletely: |
|
455 case KIptvVodDlDownloadSucceeded: |
|
456 { |
|
457 DeleteFromList( aEvent.iServiceId, aEvent.iContentId ); |
|
458 } |
|
459 break; |
|
460 |
|
461 default: |
|
462 break; |
|
463 } |
|
464 } |
|
465 break; |
|
466 |
|
467 case CIptvVodDlDownloadEvent::EDownloadReqSucceeded: |
|
468 case CIptvVodDlDownloadEvent::ECancelReqFailed: |
|
469 case CIptvVodDlDownloadEvent::ECancelReqSucceeded: |
|
470 case CIptvVodDlDownloadEvent::EDownloadReqFailed: |
|
471 case CIptvVodDlDownloadEvent::EDownloadItemsModified: |
|
472 break; |
|
473 |
|
474 default: |
|
475 break; |
|
476 } |
|
477 |
|
478 RestartTimeoutTimer(); |
|
479 |
|
480 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::HandleVodDlDownloadEvent"); |
|
481 } |
|
482 |
|
483 |
|
484 |
|
485 // ----------------------------------------------------------------------------- |
|
486 // CIptvScheduledDownloadPluginEngine::BatteryLow |
|
487 // |
|
488 // ----------------------------------------------------------------------------- |
|
489 // |
|
490 void CIptvScheduledDownloadPluginEngine::BatteryLow() |
|
491 { |
|
492 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::BatteryLow"); |
|
493 |
|
494 // Set error reason, cancel downloads and finish the plugin |
|
495 *iErrorReason = KErrBadPower; |
|
496 CancelDownloads(); |
|
497 ActiveWait( EFalse ); |
|
498 |
|
499 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::BatteryLow"); |
|
500 } |
|
501 |
|
502 |
|
503 // ----------------------------------------------------------------------------- |
|
504 // CIptvScheduledDownloadPluginEngine::HandleActiveProfileEventL |
|
505 // |
|
506 // ----------------------------------------------------------------------------- |
|
507 // |
|
508 void CIptvScheduledDownloadPluginEngine::HandleActiveProfileEventL( |
|
509 TProfileEvent aProfileEvent, |
|
510 TInt aProfileId ) |
|
511 { |
|
512 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::HandleActiveProfileEventL"); |
|
513 |
|
514 if (aProfileEvent == EProfileNewActiveProfile) |
|
515 { |
|
516 if (aProfileId == EProfileOffLineId) |
|
517 { |
|
518 IPTVLOGSTRING_LOW_LEVEL("CIptvScheduledDownloadPluginEngine::HandleActiveProfileEventL phone changed to offline mode"); |
|
519 *iErrorReason = EReschedule; |
|
520 CancelDownloads(); |
|
521 ActiveWait( EFalse ); |
|
522 } |
|
523 } |
|
524 |
|
525 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::HandleActiveProfileEventL"); |
|
526 } |
|
527 |
|
528 |
|
529 // ----------------------------------------------------------------------------- |
|
530 // CIptvScheduledDownloadPluginEngine::OnHomeNetwork |
|
531 // |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 void CIptvScheduledDownloadPluginEngine::OnHomeNetwork( TBool aOnHomeNetwork ) |
|
535 { |
|
536 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::OnHomeNetwork"); |
|
537 |
|
538 if (!aOnHomeNetwork) |
|
539 { |
|
540 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::OnHomeNetwork, not in home network"); |
|
541 // Set error reason, cancel downloads and finish the plugin |
|
542 *iErrorReason = EReschedule; |
|
543 CancelDownloads(); |
|
544 ActiveWait( EFalse ); |
|
545 } |
|
546 |
|
547 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::OnHomeNetwork"); |
|
548 } |
|
549 |
|
550 |
|
551 // ----------------------------------------------------------------------------- |
|
552 // CIptvScheduledDownloadPluginEngine::GetBatteryStatus |
|
553 // |
|
554 // ----------------------------------------------------------------------------- |
|
555 // |
|
556 void CIptvScheduledDownloadPluginEngine::GetBatteryStatus() |
|
557 { |
|
558 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::GetBatteryStatus"); |
|
559 |
|
560 if (iBatteryWatcher->IsLowPower()) |
|
561 { |
|
562 *iErrorReason = KErrBadPower; |
|
563 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::GetBatteryStatus low power, aborting"); |
|
564 } |
|
565 |
|
566 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::GetBatteryStatus"); |
|
567 } |
|
568 |
|
569 |
|
570 // ----------------------------------------------------------------------------- |
|
571 // CIptvScheduledDownloadPluginEngine::CancelDownloads |
|
572 // |
|
573 // ----------------------------------------------------------------------------- |
|
574 // |
|
575 void CIptvScheduledDownloadPluginEngine::CancelDownloads() |
|
576 { |
|
577 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::CancelDownloads"); |
|
578 |
|
579 if (iState == EDownloadingFiles) |
|
580 { |
|
581 // Cancel the downloads |
|
582 while (iVodDownloads->iList.Count()) |
|
583 { |
|
584 // Remove in reverse order, otherwise DL manager will start new dl |
|
585 // after we cancel active one which are in the beginning of the list |
|
586 CIptvVodDlDownloadListItem* download = |
|
587 iVodDownloads->iList[iVodDownloads->iList.Count() - 1]; |
|
588 TUint32 contentId = download->iContentId; |
|
589 |
|
590 IPTVLOGSTRING3_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::CancelDownloads Cancelling %d %d", iServiceID, contentId ); |
|
591 iVodDownloads->Delete( iServiceID, contentId ); |
|
592 |
|
593 TRAP_IGNORE( |
|
594 iVodDlClient->CancelDownloadL( iServiceID, contentId ) ) |
|
595 } |
|
596 } |
|
597 |
|
598 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::CancelDownloads"); |
|
599 } |
|
600 |
|
601 |
|
602 // ----------------------------------------------------------------------------- |
|
603 // CIptvScheduledDownloadPluginEngine::GetUsableIapL |
|
604 // |
|
605 // ----------------------------------------------------------------------------- |
|
606 // |
|
607 void CIptvScheduledDownloadPluginEngine::GetUsableIapL() |
|
608 { |
|
609 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::GetUsableIapL"); |
|
610 |
|
611 CIptvNetworkSelection::TConnectionPermission connectionPermission = |
|
612 CIptvNetworkSelection::ENotAllowed; |
|
613 TBuf<KIptvNsIapNameMaxLength> apName; |
|
614 CIptvNetworkSelection::TRespStatus respStatus; |
|
615 |
|
616 iIptvServiceManagementClient->GetUsedIapL( |
|
617 iServiceID, |
|
618 iIapId, |
|
619 apName, |
|
620 connectionPermission, |
|
621 respStatus); |
|
622 |
|
623 // Check if IAP is retrieved successfully |
|
624 if (respStatus == CIptvNetworkSelection::ESucceeded) |
|
625 { |
|
626 // We even skip the CIptvNetworkSelection::EAlreadyActive case |
|
627 // because we don't want to download when something else is going on |
|
628 |
|
629 // Set not allowed and test the iap against scheduled download settings |
|
630 connectionPermission = CIptvNetworkSelection::ENotAllowed; |
|
631 |
|
632 // IAP was found, get the schduled download settings |
|
633 FetchServiceL(); |
|
634 if( *iErrorReason != KErrNone ) |
|
635 { |
|
636 User::Leave( *iErrorReason ); |
|
637 } |
|
638 |
|
639 TIptvVodScheduleConnectionCondition scheduledConnectionType = |
|
640 static_cast<TIptvVodScheduleConnectionCondition>( |
|
641 iService->ScheduleDlNetwork() ); |
|
642 |
|
643 *iErrorReason = KErrCouldNotConnect; |
|
644 |
|
645 // Check connection permission |
|
646 switch (scheduledConnectionType) |
|
647 { |
|
648 case EAlways: |
|
649 { |
|
650 connectionPermission = CIptvNetworkSelection::EAllowed; |
|
651 } |
|
652 break; |
|
653 |
|
654 case EWLAN: |
|
655 { |
|
656 if (CIptvUtil::ConnectionTypeL(iIapId) == CIptvUtil::EWlan) |
|
657 { |
|
658 connectionPermission = CIptvNetworkSelection::EAllowed; |
|
659 } |
|
660 else |
|
661 { |
|
662 // Iap does not support wlan, try again later |
|
663 *iErrorReason = EReschedule; |
|
664 } |
|
665 } |
|
666 break; |
|
667 |
|
668 case EHomeCellular: |
|
669 { |
|
670 CIptvUtil::TConnectionType |
|
671 connectionType = CIptvUtil::ConnectionTypeL(iIapId); |
|
672 if (connectionType == CIptvUtil::EWlan) |
|
673 { |
|
674 // Allow wlan always |
|
675 connectionPermission = CIptvNetworkSelection::EAllowed; |
|
676 } |
|
677 else |
|
678 { |
|
679 if (connectionType == CIptvUtil::EGprs) |
|
680 { |
|
681 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::GetUsableIapL, connection allowed only in home network, checking"); |
|
682 // Allow connection on home network |
|
683 if (iPhoneRegistrationWatcher->IsOnHomeNetwork()) |
|
684 { |
|
685 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::GetUsableIapL, allowed"); |
|
686 connectionPermission = CIptvNetworkSelection::EAllowed; |
|
687 } |
|
688 else |
|
689 { |
|
690 // Not on home network, reschedule |
|
691 *iErrorReason = EReschedule; |
|
692 } |
|
693 } |
|
694 } |
|
695 } |
|
696 break; |
|
697 |
|
698 default: |
|
699 { |
|
700 } |
|
701 break; |
|
702 } |
|
703 |
|
704 if (connectionPermission == CIptvNetworkSelection::EAllowed) |
|
705 { |
|
706 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::GetUsableIapL, connection allowed"); |
|
707 // Set the connection to be allowed |
|
708 iIptvServiceManagementClient->SetConnectionAllowedL( |
|
709 ETrue, iIapId, respStatus ); |
|
710 |
|
711 if(respStatus == CIptvNetworkSelection::ESucceeded) |
|
712 { |
|
713 // Set IAP |
|
714 iIptvVodContentClient->SetIapL( iIapId ); |
|
715 |
|
716 // All is fine |
|
717 *iErrorReason = KErrNone; |
|
718 } |
|
719 } |
|
720 } |
|
721 else if ( respStatus == CIptvNetworkSelection::EFailedAlwaysAskSelected ) |
|
722 { |
|
723 connectionPermission = CIptvNetworkSelection::ENotAllowed; |
|
724 *iErrorReason = EDontReschedule; // No reschedule, when 'Always Ask' is selected. |
|
725 } |
|
726 else |
|
727 { |
|
728 // No iap, try again later |
|
729 *iErrorReason = EReschedule; |
|
730 } |
|
731 |
|
732 RestartTimeoutTimer(); |
|
733 |
|
734 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::GetUsableIapL"); |
|
735 } |
|
736 |
|
737 // ----------------------------------------------------------------------------- |
|
738 // CIptvScheduledDownloadPluginEngine::GetServiceIdL |
|
739 // |
|
740 // ----------------------------------------------------------------------------- |
|
741 // |
|
742 TInt CIptvScheduledDownloadPluginEngine::GetServiceIdL( |
|
743 CCseScheduledProgram& aProg ) const |
|
744 { |
|
745 // Get Service ID |
|
746 RDesReadStream readStream; |
|
747 CleanupClosePushL( readStream ); |
|
748 readStream.Open( aProg.ApplicationData() ); |
|
749 TUint32 serviceId = readStream.ReadUint32L(); |
|
750 CleanupStack::PopAndDestroy( &readStream ); |
|
751 |
|
752 return serviceId; |
|
753 } |
|
754 |
|
755 // ----------------------------------------------------------------------------- |
|
756 // CIptvScheduledDownloadPluginEngine::UpdateEpgL |
|
757 // |
|
758 // ----------------------------------------------------------------------------- |
|
759 // |
|
760 void CIptvScheduledDownloadPluginEngine::UpdateEpgL() |
|
761 { |
|
762 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::UpdateEpgL"); |
|
763 |
|
764 iIptvVodContentClient->UpdateEcgL(); |
|
765 |
|
766 ActiveWait( ETrue ); |
|
767 |
|
768 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::UpdateEpgL"); |
|
769 } |
|
770 |
|
771 |
|
772 // ----------------------------------------------------------------------------- |
|
773 // CIptvScheduledDownloadPluginEngine::StartDownloadL |
|
774 // |
|
775 // ----------------------------------------------------------------------------- |
|
776 // |
|
777 TInt CIptvScheduledDownloadPluginEngine::StartDownloadL( CIptvVodContentContentBriefDetails* aContent ) |
|
778 { |
|
779 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::StartDownloadL"); |
|
780 |
|
781 // Create download item so that download events can be matched |
|
782 CIptvVodDlDownloadListItem* download = CIptvVodDlDownloadListItem::NewL(); |
|
783 CleanupStack::PushL(download); // 1-> |
|
784 download->iIapId = iIapId; |
|
785 download->iServiceId = iServiceID; |
|
786 download->iContentId = aContent->iContentId; |
|
787 download->iDlType = EIptvDownloadTypeImmediate; |
|
788 iVodDownloads->iList.AppendL( download ); |
|
789 CleanupStack::Pop(download); // <-1 |
|
790 |
|
791 TIptvDlError err = iVodDlClient->DownloadL( |
|
792 iIapId, |
|
793 iService, |
|
794 aContent->iContentId, |
|
795 aContent->iName ); |
|
796 |
|
797 if (err != EIptvDlNoError) |
|
798 { |
|
799 // Download not started |
|
800 iVodDownloads->Delete( iServiceID, aContent->iContentId ); |
|
801 iVodDownloads->iList.Remove( iVodDownloads->iList.Count() - 1 ); |
|
802 } |
|
803 else |
|
804 { |
|
805 IPTVLOGSTRING3_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::StartDownloadL Download started %d %d", iServiceID, aContent->iContentId ); |
|
806 } |
|
807 |
|
808 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::StartDownloadL"); |
|
809 |
|
810 RestartTimeoutTimer(); |
|
811 |
|
812 return err == EIptvDlNoError ? KErrNone : KErrCancel; |
|
813 } |
|
814 |
|
815 // ----------------------------------------------------------------------------- |
|
816 // CIptvScheduledDownloadPluginEngine::ActiveWait |
|
817 // |
|
818 // ----------------------------------------------------------------------------- |
|
819 // |
|
820 void CIptvScheduledDownloadPluginEngine::ActiveWait( TBool aStart ) |
|
821 { |
|
822 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::ActiveWait"); |
|
823 if (aStart) |
|
824 { |
|
825 if(!iActiveSchedulerWait->IsStarted()) |
|
826 { |
|
827 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::ActiveWait - On!"); |
|
828 iActiveSchedulerWait->Start( ); |
|
829 } |
|
830 } |
|
831 else |
|
832 { |
|
833 if(iActiveSchedulerWait->IsStarted()) |
|
834 { |
|
835 iActiveSchedulerWait->AsyncStop( ); |
|
836 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::ActiveWait - Off!"); |
|
837 } |
|
838 } |
|
839 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::ActiveWait"); |
|
840 } |
|
841 |
|
842 // ----------------------------------------------------------------------------- |
|
843 // CIptvScheduledDownloadPluginEngine::DeleteFromList |
|
844 // |
|
845 // ----------------------------------------------------------------------------- |
|
846 // |
|
847 TBool CIptvScheduledDownloadPluginEngine::DeleteFromList( |
|
848 TUint32 aServiceId, |
|
849 TUint32 aContentId ) |
|
850 { |
|
851 TBool isInList = EFalse; |
|
852 if (iState == EDownloadingFiles) |
|
853 { |
|
854 CIptvVodDlDownloadListItem* item = |
|
855 iVodDownloads->GetListItem( aServiceId, aContentId ); |
|
856 if (item) |
|
857 { |
|
858 isInList = ETrue; |
|
859 iVodDownloads->Delete( aServiceId, aContentId ); |
|
860 if (iVodDownloads->iList.Count() == 0) |
|
861 { |
|
862 ActiveWait( EFalse ); |
|
863 } |
|
864 } |
|
865 } |
|
866 return isInList; |
|
867 } |
|
868 |
|
869 // ----------------------------------------------------------------------------- |
|
870 // CIptvScheduledDownloadPluginEngine::FetchServiceL |
|
871 // |
|
872 // ----------------------------------------------------------------------------- |
|
873 // |
|
874 void CIptvScheduledDownloadPluginEngine::FetchServiceL() |
|
875 { |
|
876 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::FetchServiceL"); |
|
877 |
|
878 delete iService; |
|
879 iService = NULL; |
|
880 |
|
881 CDesC8ArraySeg* serializedServices; |
|
882 MIptvServiceManagementClientObserver::TRespStatus respStatus; |
|
883 |
|
884 TInt err = iIptvServiceManagementClient->GetServicesL( |
|
885 iServiceID, iServiceID, serializedServices, respStatus ); |
|
886 |
|
887 if (err == KErrNone && respStatus == ESucceeded) |
|
888 { |
|
889 CleanupStack::PushL( serializedServices ); |
|
890 // There should be one item, just check that it exists |
|
891 if (serializedServices->Count() > 0) |
|
892 { |
|
893 iService = CIptvService::NewL(); |
|
894 iService->SetL( serializedServices->MdcaPoint(0) ); |
|
895 } |
|
896 else |
|
897 { |
|
898 err = KErrGeneral; |
|
899 } |
|
900 CleanupStack::PopAndDestroy( serializedServices ); |
|
901 } |
|
902 else |
|
903 { |
|
904 // Didin't get the service, return error code |
|
905 err = (err == KErrNone) ? KErrGeneral : err; |
|
906 } |
|
907 |
|
908 if (err) |
|
909 { |
|
910 *iErrorReason = err; |
|
911 } |
|
912 |
|
913 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::FetchServiceL"); |
|
914 } |
|
915 |
|
916 |
|
917 // ----------------------------------------------------------------------------- |
|
918 // CIptvScheduledDownloadPluginEngine::LoadContentL |
|
919 // |
|
920 // ----------------------------------------------------------------------------- |
|
921 // |
|
922 TInt CIptvScheduledDownloadPluginEngine::LoadContentL() |
|
923 { |
|
924 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::LoadContentL"); |
|
925 |
|
926 iState = EGettingContent; |
|
927 |
|
928 // Get the categories |
|
929 iCategoryList.ResetAndDestroy(); |
|
930 *iErrorReason = iIptvVodContentClient->GetEcgCategoryListL( |
|
931 KIptvVodContentCategoryRootId, iCategoryList ); |
|
932 |
|
933 if( *iErrorReason != KErrNone ) |
|
934 { |
|
935 return *iErrorReason; |
|
936 } |
|
937 |
|
938 if( iVodDlClient ) |
|
939 { |
|
940 delete iVodDlClient; |
|
941 iVodDlClient = NULL; |
|
942 } |
|
943 |
|
944 iVodDlClient = CVcxNsScheduledDownloadMpxClient::NewL( *this, *iIptvVodContentClient, iServiceID ); |
|
945 |
|
946 iState = ECheckingDownloadedFiles; |
|
947 |
|
948 // Download all episodes which have been added after the last successfull |
|
949 // scheduled download and which aren't already downloaded |
|
950 TTime lastScheduledDl = iService->GetScheduledLastDownloadTime(); |
|
951 |
|
952 // Go through categories and load their content |
|
953 TInt count = iCategoryList.Count(); |
|
954 for (TInt i = 0; i < count && *iErrorReason == KErrNone; i++) |
|
955 { |
|
956 TUint32 totalAmount = 0; |
|
957 TBuf<KIptvSearchStringmaxLen> searchString( KNullDesC ); |
|
958 |
|
959 // If video search is in use and the category is search category, |
|
960 // the download is skipped |
|
961 if (!iCategoryList[i]->iIsSearchCategory) |
|
962 { |
|
963 // Get the episodes |
|
964 iEcgList.ResetAndDestroy(); |
|
965 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::LoadContentL getting categories"); |
|
966 *iErrorReason = iIptvVodContentClient->GetEcgListL( |
|
967 iCategoryList[i]->iCategoryId, |
|
968 searchString, |
|
969 KIptvGetAll, |
|
970 KIptvGetAll, |
|
971 totalAmount, |
|
972 iEcgList ); |
|
973 |
|
974 if( *iErrorReason != KErrNone ) |
|
975 { |
|
976 return *iErrorReason; |
|
977 } |
|
978 |
|
979 // Check if the episodes contain publish date |
|
980 TBool hasPublishDate = EFalse; |
|
981 |
|
982 for (TInt j = 0; j < iEcgList.Count() && !hasPublishDate; j++) |
|
983 { |
|
984 if (iEcgList[j]->iPubDate.Int64() != 0) |
|
985 { |
|
986 hasPublishDate = ETrue; |
|
987 } |
|
988 } |
|
989 |
|
990 if (hasPublishDate) |
|
991 { |
|
992 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::LoadContentL feed has publish dates."); |
|
993 |
|
994 // Publish date exists, download after last scheduled download |
|
995 for (TInt j = 0; |
|
996 j < iEcgList.Count() && *iErrorReason == KErrNone; |
|
997 j++) |
|
998 { |
|
999 CIptvVodContentContentBriefDetails* details = iEcgList[j]; |
|
1000 |
|
1001 // Check whether it has been downloaded already. |
|
1002 if ( details && details->iFileId && |
|
1003 details->iFileId->iDrive == KIptvNoFileOrDrive && |
|
1004 details->iFileId->iFileId == static_cast<TIptvFileId>( |
|
1005 KIptvNoFileOrDrive ) ) |
|
1006 { |
|
1007 // Check whether it has been added after the last scheduled |
|
1008 // download. |
|
1009 if (lastScheduledDl <= details->iPubDate) |
|
1010 { |
|
1011 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::LoadContentL video is new enough."); |
|
1012 |
|
1013 // Check whether it is a downloadable file. |
|
1014 if ( IsDownloadableL( details->iContentId ) ) |
|
1015 { |
|
1016 // Remember the old state. |
|
1017 TState oldState = iState; |
|
1018 iState = EDownloadingFiles; |
|
1019 if ( KErrNone != StartDownloadL( details ) ) |
|
1020 { |
|
1021 // Download not going on, restore old state. |
|
1022 iState = oldState; |
|
1023 } |
|
1024 } |
|
1025 } |
|
1026 else |
|
1027 { |
|
1028 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::LoadContentL video is not new enough."); |
|
1029 } |
|
1030 } |
|
1031 } |
|
1032 } |
|
1033 else |
|
1034 { |
|
1035 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::LoadContentL feed does not have publish dates."); |
|
1036 |
|
1037 // No publish date, download only the first one. |
|
1038 if (iEcgList.Count() > 0) |
|
1039 { |
|
1040 CIptvVodContentContentBriefDetails* details = iEcgList[0]; |
|
1041 |
|
1042 // Check whether it has been downloaded already. |
|
1043 if ( details && details->iFileId && |
|
1044 details->iFileId->iDrive == KIptvNoFileOrDrive && |
|
1045 details->iFileId->iFileId == static_cast<TIptvFileId>( |
|
1046 KIptvNoFileOrDrive ) ) |
|
1047 { |
|
1048 // Check whether it is a downloadable file. |
|
1049 if ( IsDownloadableL( details->iContentId )) |
|
1050 { |
|
1051 // Remember the old state. |
|
1052 TState oldState = iState; |
|
1053 iState = EDownloadingFiles; |
|
1054 if ( KErrNone != StartDownloadL( details ) ) |
|
1055 { |
|
1056 // Download not going on, restore old state. |
|
1057 iState = oldState; |
|
1058 } |
|
1059 } |
|
1060 } |
|
1061 } |
|
1062 } |
|
1063 } |
|
1064 } |
|
1065 |
|
1066 iEcgList.ResetAndDestroy(); |
|
1067 iCategoryList.ResetAndDestroy(); |
|
1068 |
|
1069 RestartTimeoutTimer(); |
|
1070 |
|
1071 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::LoadContentL"); |
|
1072 |
|
1073 return KErrNone; |
|
1074 } |
|
1075 |
|
1076 |
|
1077 // ----------------------------------------------------------------------------- |
|
1078 // CIptvScheduledDownloadPluginEngine::IsDownloadableL |
|
1079 // |
|
1080 // ----------------------------------------------------------------------------- |
|
1081 // |
|
1082 TBool CIptvScheduledDownloadPluginEngine::IsDownloadableL( TIptvContentId aContentId ) |
|
1083 { |
|
1084 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::IsDownloadableL"); |
|
1085 |
|
1086 TBool retVal = EFalse; |
|
1087 RPointerArray<CIptvMediaContent> caDetails; |
|
1088 CleanupClosePushL( caDetails ); |
|
1089 |
|
1090 if (iIptvVodContentClient->GetContentAccessListL( |
|
1091 aContentId, |
|
1092 caDetails ) == KErrNone) |
|
1093 { |
|
1094 // Go through the content access list and check it is downloadable |
|
1095 for (TInt i = 0; i < caDetails.Count() && !retVal; i++) |
|
1096 { |
|
1097 retVal = caDetails[i]->iDownloadType == EIptvDownloadTypeImmediate |
|
1098 && caDetails[i]->iExpression == CIptvMediaContent::EFull; |
|
1099 } |
|
1100 } |
|
1101 |
|
1102 CleanupStack::PopAndDestroy( &caDetails ); |
|
1103 |
|
1104 IPTVLOGSTRING2_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::IsDownloadableL: %d", retVal); |
|
1105 |
|
1106 return retVal; |
|
1107 } |
|
1108 |
|
1109 // ----------------------------------------------------------------------------- |
|
1110 // CIptvScheduledDownloadPluginEngine::UpdateLastDownloadTimeL |
|
1111 // |
|
1112 // ----------------------------------------------------------------------------- |
|
1113 // |
|
1114 void CIptvScheduledDownloadPluginEngine::UpdateLastDownloadTimeL( |
|
1115 const TTime& aTimestamp ) |
|
1116 { |
|
1117 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::UpdateLastDownloadTimeL"); |
|
1118 |
|
1119 // First get the service |
|
1120 FetchServiceL(); |
|
1121 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::UpdateLastDownloadTimeL service fetched"); |
|
1122 |
|
1123 // Update the last download time |
|
1124 iService->SetScheduledLastDownloadTime( aTimestamp ); |
|
1125 |
|
1126 // Update the service. |
|
1127 // No check on the result since nothing can be done if it fails |
|
1128 MIptvServiceManagementClientObserver::TRespStatus respStatus; |
|
1129 iIptvServiceManagementClient->UpdateServiceL( *iService, respStatus ); |
|
1130 |
|
1131 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::UpdateLastDownloadTimeL"); |
|
1132 } |
|
1133 |
|
1134 // ----------------------------------------------------------------------------- |
|
1135 // CIptvScheduledDownloadPluginEngine::RestartTimeoutTimer |
|
1136 // |
|
1137 // ----------------------------------------------------------------------------- |
|
1138 // |
|
1139 void CIptvScheduledDownloadPluginEngine::RestartTimeoutTimer() |
|
1140 { |
|
1141 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::RestartTimeoutTimer"); |
|
1142 |
|
1143 Cancel(); |
|
1144 After( TTimeIntervalMicroSeconds32( KIptvTimeoutInMicroseconds ) ); |
|
1145 |
|
1146 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::RestartTimeoutTimer"); |
|
1147 } |
|
1148 |
|
1149 // ----------------------------------------------------------------------------- |
|
1150 // CIptvScheduledDownloadPluginEngine::CheckOfflineModeL |
|
1151 // |
|
1152 // ----------------------------------------------------------------------------- |
|
1153 // |
|
1154 void CIptvScheduledDownloadPluginEngine::CheckOfflineModeL() |
|
1155 { |
|
1156 IPTVLOGSTRING_HIGH_LEVEL(">>> CIptvScheduledDownloadPluginEngine::CheckOfflineModeL"); |
|
1157 |
|
1158 MProfileEngine* profileEngine = CreateProfileEngineL(); |
|
1159 |
|
1160 if (profileEngine) |
|
1161 { |
|
1162 if ( profileEngine->ActiveProfileId() == EProfileOffLineId ) |
|
1163 { |
|
1164 *iErrorReason = EReschedule; |
|
1165 IPTVLOGSTRING_HIGH_LEVEL("CIptvScheduledDownloadPluginEngine::CheckOfflineModeL offline mode"); |
|
1166 } |
|
1167 |
|
1168 profileEngine->Release(); |
|
1169 } |
|
1170 |
|
1171 IPTVLOGSTRING_HIGH_LEVEL("<<< CIptvScheduledDownloadPluginEngine::CheckOfflineModeL"); |
|
1172 } |