|
1 /* |
|
2 * Copyright (c) 2002-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: Controls epg services update* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #include "IptvDebug.h" |
|
21 #include "CIptvEpgSession.h" |
|
22 #include "IptvEngineUids.h" |
|
23 #include <bautils.h> |
|
24 #include "CIptvEpgPluginInterface.h" |
|
25 #include "TIptvRssSearchQuery.h" |
|
26 #include "CIptvEpgDatabase.h" |
|
27 |
|
28 #include "IptvLiveEpgConstants.h" |
|
29 #include "CIptvEpgDb.h" |
|
30 #include "CIptvService.h" |
|
31 #include "CIptvEpgService.h" |
|
32 #include "CIptvMyVideosGlobalFileId.h" |
|
33 #include "CIptvEpgVodCallbackImpl.h" |
|
34 #include "CIptvEpgLiveTvCallbackImpl.h" |
|
35 #include "CIptvEpgVodClientImpl.h" |
|
36 #include "CIptvServer.h" |
|
37 #include "CIptvEpgManagerUpdater.h" |
|
38 #include "CIptvServiceManager.h" |
|
39 #include "CIptvEpgVodMsqQueue.h" |
|
40 #include "CIptvEpgManagerImpl.h" |
|
41 #include "CIptvSearchManager.h" |
|
42 #include "CIptvVodDlDownloadList.h" |
|
43 #if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__SERIES60_32__) |
|
44 #include "CIptvVodDownloadManager.h" |
|
45 #include "iptvvideostoragemyvideosadaptation.h" |
|
46 #include "iptvvideostoragesideloaderobserver.h" |
|
47 #endif // defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__SERIES60_32__) |
|
48 |
|
49 #include "CIptvMyVideosGlobalFolderId.h" |
|
50 #include "CIptvMyVideosFolder.h" |
|
51 #include "vcxgroupupdater.h" |
|
52 |
|
53 _LIT( KIptvEmptyAddress, "" ); |
|
54 |
|
55 #ifdef _DEBUG |
|
56 const TInt KIptvHundred = 100; |
|
57 #endif |
|
58 |
|
59 #if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__SERIES60_32__) |
|
60 static void CleanupVideoPointerArray( TAny* item ) |
|
61 { |
|
62 ( ( RPointerArray<CIptvMyVideosVideoBriefDetails>* ) item )->ResetAndDestroy(); |
|
63 } |
|
64 |
|
65 static void CleanupFolderPointerArray( TAny* item ) |
|
66 { |
|
67 ( ( RPointerArray<CIptvMyVideosFolder>* ) item )->ResetAndDestroy(); |
|
68 } |
|
69 |
|
70 static void CleanupFolderIdPointerArray( TAny* item ) |
|
71 { |
|
72 ( ( RPointerArray<CIptvMyVideosGlobalFolderId>* ) item )->ResetAndDestroy(); |
|
73 } |
|
74 #endif // defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__SERIES60_32__) |
|
75 |
|
76 // ======== MEMBER FUNCTIONS ======== |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CIptvEpgSession::CIptvEpgSession |
|
80 // C++ default constructor can NOT contain any code, that |
|
81 // might leave. |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CIptvEpgSession::CIptvEpgSession( |
|
85 CIptvEpgDb* aEpgDb, |
|
86 TUint32 aServiceId, |
|
87 CIptvEpgVodMsqQueue* aMsgQueue, |
|
88 CIptvServer& aServer, |
|
89 TBool aPluginCanRun ) : |
|
90 iServer( aServer ), |
|
91 iUpdater( NULL ), |
|
92 iVodClient( NULL ), |
|
93 iPlugin( NULL ), |
|
94 iVodCallback( NULL ), |
|
95 iEpgDb( aEpgDb ), |
|
96 iService( NULL ), |
|
97 iMsgQueue( aMsgQueue ), |
|
98 iPluginStarted( EFalse ), |
|
99 iDeleteDatabase( EFalse ), |
|
100 iServiceId( aServiceId ), |
|
101 iPluginCanRun( aPluginCanRun ), |
|
102 iReferenceCount( 0 ), |
|
103 iInitialized( EFalse ), |
|
104 iIsIap( EFalse ), |
|
105 iIap( 0 ), |
|
106 iUpdatePending( EFalse ), |
|
107 iReady( EFalse ) |
|
108 { |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CIptvEpgSession::CIptvEpgSession |
|
113 // C++ default constructor can NOT contain any code, that |
|
114 // might leave. |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 CIptvEpgSession::CIptvEpgSession( |
|
118 CIptvEpgDatabase* aLiveTvDb, |
|
119 TUint32 aServiceId, |
|
120 CIptvEpgVodMsqQueue* aMsgQueue, |
|
121 CIptvServer& aServer, |
|
122 TBool aPluginCanRun ) : |
|
123 iServer( aServer ), |
|
124 iUpdater( NULL ), |
|
125 iVodClient( NULL ), |
|
126 iPlugin( NULL ), |
|
127 iVodCallback( NULL ), |
|
128 iEpgDb( NULL ), |
|
129 iLiveTvDatabase( aLiveTvDb ), |
|
130 iService( NULL ), |
|
131 iMsgQueue( aMsgQueue ), |
|
132 iPluginStarted( EFalse ), |
|
133 iDeleteDatabase( EFalse ), |
|
134 iServiceId( aServiceId ), |
|
135 iPluginCanRun( aPluginCanRun ), |
|
136 iReferenceCount( 0 ), |
|
137 iInitialized( EFalse ), |
|
138 iIsIap( EFalse ), |
|
139 iIap( 0 ), |
|
140 iUpdatePending( EFalse ), |
|
141 iReady( EFalse ) |
|
142 { |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // CIptvEpgSession::ConstructL |
|
147 // Symbian 2nd phase constructor can leave. |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 TInt CIptvEpgSession::ConstructL() |
|
151 { |
|
152 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::ConstructL" ); |
|
153 |
|
154 TInt error = iFs.Connect(); |
|
155 if ( error != KErrNone ) |
|
156 { |
|
157 User::Leave( error ); |
|
158 } |
|
159 |
|
160 iSearchManager = iServer.GetSearchManagerL( iServiceId, *this, iMsgQueue ); |
|
161 |
|
162 error = GetServiceInformationL(); |
|
163 |
|
164 iSearchManager->SetServiceL( iService ); |
|
165 |
|
166 if ( ! iSearchManager->IsSearchPossible() ) |
|
167 { |
|
168 // Nullify the pointer. Search not supported so no need to use the implementation. |
|
169 iServer.RemoveQueueFromSearchManagerL( iServiceId, iMsgQueue ); |
|
170 iSearchManager = NULL; |
|
171 } |
|
172 |
|
173 if ( error == KErrNone ) |
|
174 { |
|
175 if ( iEpgDb ) |
|
176 { |
|
177 iVodClient = CIptvEpgVodClientImpl::NewL( *iEpgDb, *this, iSearchManager ); |
|
178 } |
|
179 } |
|
180 |
|
181 iUpdater = CIptvEpgManagerUpdater::NewL( *this ); |
|
182 |
|
183 User::LeaveIfError( iServer.iServiceManager->RegisterObserver( this ) ); |
|
184 |
|
185 return error; |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CIptvEpgSession::NewL |
|
190 // Two-phased constructor. |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 CIptvEpgSession* CIptvEpgSession::NewL( |
|
194 CIptvEpgDb* aEpgDb, |
|
195 TUint32 aServiceId, |
|
196 CIptvEpgVodMsqQueue* aMsgQueue, |
|
197 CIptvServer& aServer, |
|
198 TBool aPluginCanRun, |
|
199 TInt& aError ) |
|
200 { |
|
201 CIptvEpgSession* self = new( ELeave ) CIptvEpgSession( |
|
202 aEpgDb, |
|
203 aServiceId, |
|
204 aMsgQueue, |
|
205 aServer, |
|
206 aPluginCanRun ); |
|
207 |
|
208 CleanupStack::PushL( self ); |
|
209 aError = self->ConstructL(); |
|
210 CleanupStack::Pop( self ); |
|
211 |
|
212 return self; |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // CIptvEpgSession::NewL |
|
217 // Two-phased constructor. |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 CIptvEpgSession* CIptvEpgSession::NewL( |
|
221 CIptvEpgDatabase* aLiveTvDb, |
|
222 TUint32 aServiceId, |
|
223 CIptvEpgVodMsqQueue* aMsgQueue, |
|
224 CIptvServer& aServer, |
|
225 TBool aPluginCanRun, |
|
226 TInt& aError ) |
|
227 { |
|
228 CIptvEpgSession* self = new( ELeave ) CIptvEpgSession( |
|
229 aLiveTvDb, |
|
230 aServiceId, |
|
231 aMsgQueue, |
|
232 aServer, |
|
233 aPluginCanRun ); |
|
234 |
|
235 CleanupStack::PushL( self ); |
|
236 aError = self->ConstructL(); |
|
237 CleanupStack::Pop( self ); |
|
238 |
|
239 return self; |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CIptvEpgSession::~CIptvEpgSession() |
|
244 // Destructor. |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 CIptvEpgSession::~CIptvEpgSession() |
|
248 { |
|
249 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::~CIptvEpgSession" ); |
|
250 |
|
251 if ( iPluginStarted && iServer.EpgUpdating() ) |
|
252 { |
|
253 iServer.SetEpgUpdating( EFalse ); |
|
254 } |
|
255 |
|
256 delete iUpdater; |
|
257 delete iPlugin; |
|
258 delete iGroupUpdater; |
|
259 REComSession::FinalClose(); |
|
260 |
|
261 delete iVodCallback; |
|
262 delete iLiveTvCallback; |
|
263 delete iService; |
|
264 delete iVodClient; |
|
265 |
|
266 if ( iDeleteDatabase ) |
|
267 { |
|
268 // iDeleteDatabase basically means service is being deleted. |
|
269 // Therefore we also need to make sure search manager clears |
|
270 // it's data to avoid i.e. thumbnails to stay in device even though |
|
271 // the service itself has been deleted |
|
272 if ( iSearchManager ) |
|
273 { |
|
274 iSearchManager->ClearAllResults(); |
|
275 } |
|
276 |
|
277 // CIptvEpgDb will delete database file after it has been closed |
|
278 } |
|
279 |
|
280 if ( iSearchManager ) |
|
281 { |
|
282 TRAP_IGNORE( iServer.RemoveQueueFromSearchManagerL( iServiceId, iMsgQueue ) ); |
|
283 } |
|
284 |
|
285 iFs.Close(); |
|
286 |
|
287 iServer.iServiceManager->DeRegisterObserver( this ); |
|
288 |
|
289 CIptvEpgManagerImpl& epgManager = iServer.GetEpgManager(); |
|
290 epgManager.CloseSession( iServiceId ); |
|
291 } |
|
292 |
|
293 // --------------------------------------------------------------------------- |
|
294 // CIptvEpgSession::UpdateEcg |
|
295 // --------------------------------------------------------------------------- |
|
296 TInt CIptvEpgSession::UpdateEcg( TBool aForceUpdate ) |
|
297 { |
|
298 IPTVLOGSTRING2_LOW_LEVEL( "CIptvEpgSession::UpdateEcg, aForce: %d", aForceUpdate ); |
|
299 |
|
300 TInt retval( KErrNone ); |
|
301 TRAPD( err, retval = GetServiceInformationL() ); |
|
302 if ( iService && err == KErrNone && retval == KErrNone ) |
|
303 { |
|
304 switch ( iService->iServiceType ) |
|
305 { |
|
306 case CIptvService::EVod: |
|
307 case CIptvService::EVodCast: |
|
308 case CIptvService::EServiceGroup: |
|
309 { |
|
310 TRAPD( error, UpdateVodEcgL( aForceUpdate ) ); |
|
311 return error; |
|
312 } |
|
313 case CIptvService::ELiveTv: |
|
314 { |
|
315 TInt err( UpdateLiveEpg() ); |
|
316 return err; |
|
317 } |
|
318 case CIptvService::EOther: |
|
319 break; |
|
320 default: |
|
321 break; |
|
322 } |
|
323 } |
|
324 |
|
325 TInt status( KErrNone ); |
|
326 if ( err != KErrNone ) |
|
327 { |
|
328 status = err; |
|
329 } |
|
330 else if ( retval != KErrNone ) |
|
331 { |
|
332 status = retval; |
|
333 } |
|
334 |
|
335 return status; |
|
336 } |
|
337 |
|
338 // --------------------------------------------------------------------------- |
|
339 // CIptvEpgSession::Search |
|
340 // --------------------------------------------------------------------------- |
|
341 // |
|
342 TInt CIptvEpgSession::Search( TIptvRssSearchQuery& aSearchQuery ) |
|
343 { |
|
344 if ( ! iIsIap ) |
|
345 { |
|
346 // Service id = 0 because we dont have to bring this information |
|
347 // over IPC. Service ID is already on the client side. |
|
348 |
|
349 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
350 IPTVLOGSTRING_LOW_LEVEL( "------------------CIptvEpgSession::Search------------------" ); |
|
351 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
352 IPTVLOGSTRING_LOW_LEVEL( "SEARCH CANCELLED! NO IAP! KIptvErrorVodNoIap sent to client." ); |
|
353 IPTVLOGSTRING_LOW_LEVEL( "Update pending! Update is made when we get IAP!" ); |
|
354 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
355 IPTVLOGSTRING_LOW_LEVEL( "------------------CIptvEpgSession::Search------------------" ); |
|
356 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
357 |
|
358 // Now we disable update pending flag. There is a reason this is done: |
|
359 // If we start a vod UI and automatic update is initiated and user |
|
360 // is prompted for IAP selection while updating normal vod and that |
|
361 // dialog has been canceled -> user does not want to start vod update. |
|
362 // Then user select 'Search' and IAP dialog is prompted again. Now |
|
363 // if we dont disable update pending flag also vod content update |
|
364 // is started and that's something user already decided not to do. |
|
365 // This is the reason update pending flag is disabled here. |
|
366 iUpdatePending = EFalse; |
|
367 |
|
368 TRAP_IGNORE( SendMessageToClientL( KIptvErrorRssSearchNoIap, 0 ) ); |
|
369 return KErrCouldNotConnect; |
|
370 } |
|
371 |
|
372 TInt error( KErrNone ); |
|
373 |
|
374 TRAP_IGNORE( DoSearchL( error ) ); |
|
375 |
|
376 if ( error != KErrNone ) |
|
377 { |
|
378 return error; |
|
379 } |
|
380 |
|
381 return iSearchManager->Search( aSearchQuery ); |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // CIptvEpgSession::DoSearchL |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 void CIptvEpgSession::DoSearchL( TInt& error ) |
|
389 { |
|
390 // Refresh the service data. This is done to prevent situation where |
|
391 // search address in the service has been changed. |
|
392 GetServiceInformationL(); |
|
393 |
|
394 SendMessageToClientL( KIptvErrorRssSearchStarted, 0 ); |
|
395 |
|
396 if ( iSearchManager ) |
|
397 { |
|
398 // Before starting a new search, we gather a list of Content IDs that have |
|
399 // been used by downloads started from previous search results. This way the |
|
400 // Search Manager knows not to re-use the same IDs again, and we avoid the |
|
401 // possible ID collisions between old and new downloads. |
|
402 // |
|
403 UpdateSearchUsedContentIdsListL(); |
|
404 |
|
405 iSearchManager->SetServiceL( iService ); |
|
406 } |
|
407 else |
|
408 { |
|
409 error = KErrNotSupported; |
|
410 SendMessageToClientL( KIptvErrorRssSearchFailed, error ); |
|
411 } |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------------------------- |
|
415 // CIptvEpgSession::UpdateSearchUsedContentIdsListL |
|
416 // --------------------------------------------------------------------------- |
|
417 void CIptvEpgSession::UpdateSearchUsedContentIdsListL() |
|
418 { |
|
419 RArray<TInt> usedIdArray; |
|
420 CleanupClosePushL( usedIdArray ); |
|
421 |
|
422 #if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__SERIES60_32__) |
|
423 // First gather a list of used Content IDs from Download Manager. |
|
424 if ( iServer.iVodDownloadManager ) |
|
425 { |
|
426 CIptvVodDlDownloadList* downloadList = CIptvVodDlDownloadList::NewL(); |
|
427 |
|
428 if ( downloadList ) |
|
429 { |
|
430 CleanupStack::PushL( downloadList ); |
|
431 |
|
432 // Note, the method leaves if list is empty. |
|
433 TRAPD( dlMgrError, iServer.iVodDownloadManager->GetDownloadListL( *downloadList ) ); |
|
434 |
|
435 if ( dlMgrError == KErrNone ) |
|
436 { |
|
437 for ( TInt i = 0; i < downloadList->iList.Count(); i++ ) |
|
438 { |
|
439 CIptvVodDlDownloadListItem* downloadItem = downloadList->iList[i]; |
|
440 |
|
441 // Check for downloads with our service Id, and "search" content Id. |
|
442 if ( downloadItem->iServiceId == iService->iServiceId && |
|
443 downloadItem->iContentId >= KIptvRssSearchInitialContentId && |
|
444 downloadItem->iContentId != ( TIptvContentId ) KErrNotFound ) |
|
445 { |
|
446 usedIdArray.InsertInOrder( downloadItem->iContentId ); |
|
447 } |
|
448 } |
|
449 } |
|
450 |
|
451 CleanupStack::PopAndDestroy( downloadList ); |
|
452 } |
|
453 } |
|
454 #else |
|
455 |
|
456 // REL6: Similar functionality with MPX Collection? |
|
457 |
|
458 #endif // defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__SERIES60_32__) |
|
459 |
|
460 #if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__SERIES60_32__) |
|
461 // Then gather a list of used Content IDs from My Videos Manager. |
|
462 TUint32 totalNum = 0; |
|
463 |
|
464 RPointerArray<CIptvMyVideosVideoBriefDetails> files; |
|
465 TCleanupItem cleanupVideo( CleanupVideoPointerArray, &files ); |
|
466 CleanupStack::PushL( cleanupVideo ); |
|
467 |
|
468 RPointerArray<CIptvMyVideosFolder> folders; |
|
469 TCleanupItem cleanupFolder( CleanupFolderPointerArray, &folders ); |
|
470 CleanupStack::PushL( cleanupFolder ); |
|
471 |
|
472 RPointerArray<CIptvMyVideosGlobalFolderId> folderIds; |
|
473 TCleanupItem cleanupFolderId( CleanupFolderIdPointerArray, &folderIds ); |
|
474 CleanupStack::PushL( cleanupFolderId ); |
|
475 |
|
476 CIptvMyVideosGlobalFolderId* rootFolder = CIptvMyVideosGlobalFolderId::NewRootFolderL(); |
|
477 CleanupStack::PushL( rootFolder ); |
|
478 |
|
479 iServer.GetVideoStorageAdaptationL()->GetFolderListL( |
|
480 *rootFolder, |
|
481 0, |
|
482 0, |
|
483 totalNum, |
|
484 folders ); |
|
485 |
|
486 for ( TInt i = 0; i < folders.Count(); i++ ) |
|
487 { |
|
488 CIptvMyVideosGlobalFolderId* newFolderId = CIptvMyVideosGlobalFolderId::NewLC(); |
|
489 |
|
490 newFolderId->iDrive = folders[i]->iFolderId->iDrive; |
|
491 newFolderId->iFolderId = folders[i]->iFolderId->iFolderId; |
|
492 |
|
493 folderIds.AppendL( newFolderId ); |
|
494 CleanupStack::Pop( newFolderId ); |
|
495 } |
|
496 folderIds.AppendL( rootFolder ); |
|
497 CleanupStack::Pop( rootFolder ); |
|
498 |
|
499 for ( TInt j = 0; j < folderIds.Count(); j++ ) |
|
500 { |
|
501 iServer.GetVideoStorageAdaptationL()->GetVideoListL( |
|
502 *( folderIds[j] ), |
|
503 0, |
|
504 0, |
|
505 totalNum, |
|
506 files ); |
|
507 |
|
508 for ( TInt i = 0; i < files.Count(); i++ ) |
|
509 { |
|
510 // Check for downloads with our service Id, and "search" content Id. |
|
511 if ( files[i]->iServiceId == iService->iServiceId && |
|
512 files[i]->iContentId >= KIptvRssSearchInitialContentId && |
|
513 files[i]->iContentId != ( TIptvContentId ) KErrNotFound ) |
|
514 { |
|
515 usedIdArray.InsertInOrder( files[i]->iContentId ); // Note, prevents duplicates. |
|
516 } |
|
517 } |
|
518 files.ResetAndDestroy(); |
|
519 } |
|
520 |
|
521 CleanupStack::PopAndDestroy( &folderIds ); |
|
522 CleanupStack::PopAndDestroy( &folders ); |
|
523 CleanupStack::PopAndDestroy( &files ); |
|
524 #else |
|
525 |
|
526 // REL6: Similar functionality with MPX Collection? |
|
527 |
|
528 #endif // defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__SERIES60_32__) |
|
529 |
|
530 // Finally call Search Manager with our updated list. |
|
531 iSearchManager->UpdateUsedContentIdsListL( usedIdArray ); |
|
532 |
|
533 CleanupStack::PopAndDestroy( &usedIdArray ); |
|
534 } |
|
535 |
|
536 // --------------------------------------------------------------------------- |
|
537 // CIptvEpgSession::UpdateChangedContentIdsL |
|
538 // --------------------------------------------------------------------------- |
|
539 #if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__SERIES60_32__) |
|
540 void CIptvEpgSession::UpdateChangedContentIdsL( RArray<TUint32>& aOldContentIds, |
|
541 RArray<TUint32>& aNewContentIds ) |
|
542 { |
|
543 __ASSERT_DEBUG( aOldContentIds.Count() == aNewContentIds.Count(), |
|
544 User::Panic( KIptvEpgDb, EIptvEngineServerBadState ) ); |
|
545 |
|
546 if ( iServer.iVodDownloadManager ) |
|
547 { |
|
548 iServer.iVodDownloadManager->UpdateChangedContentIdsL( iServiceId, |
|
549 aOldContentIds, |
|
550 aNewContentIds ); |
|
551 } |
|
552 } |
|
553 #else |
|
554 void CIptvEpgSession::UpdateChangedContentIdsL( RArray<TUint32>& /*aOldContentIds*/, |
|
555 RArray<TUint32>& /*aNewContentIds*/ ) |
|
556 { |
|
557 // REL6? |
|
558 } |
|
559 #endif // defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__SERIES60_32__) |
|
560 |
|
561 // --------------------------------------------------------------------------- |
|
562 // CIptvEpgSession::CancelSearch |
|
563 // --------------------------------------------------------------------------- |
|
564 TInt CIptvEpgSession::CancelSearch() |
|
565 { |
|
566 TInt retVal = KErrNone; |
|
567 if ( iSearchManager ) |
|
568 { |
|
569 retVal = iSearchManager->CancelSearch(); |
|
570 } |
|
571 return retVal; |
|
572 } |
|
573 |
|
574 // --------------------------------------------------------------------------- |
|
575 // CIptvEpgSession::SendMessageToClientL |
|
576 // --------------------------------------------------------------------------- |
|
577 void CIptvEpgSession::SendMessageToClientL( TInt aMsg, TInt aInfo ) |
|
578 { |
|
579 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::SendMessageToClientL" ); |
|
580 |
|
581 if ( iMsgQueue ) |
|
582 { |
|
583 iMsgQueue->SendMessageToClientL( aMsg, aInfo ); |
|
584 } |
|
585 } |
|
586 |
|
587 // --------------------------------------------------------------------------- |
|
588 // CIptvEpgSession::UpdateVodEcgL |
|
589 // --------------------------------------------------------------------------- |
|
590 // |
|
591 void CIptvEpgSession::UpdateVodEcgL( TBool aForceUpdate ) |
|
592 { |
|
593 IPTVLOGSTRING2_LOW_LEVEL( "CIptvEpgSession::UpdateVodEcgL(), aForceUpdate: %d", aForceUpdate ); |
|
594 |
|
595 TInt err( KErrNone ); |
|
596 // Update is not possible if service has no address |
|
597 if ( iService && iService->iAddress.Compare( KIptvEmptyAddress ) == 0 ) |
|
598 { |
|
599 IPTVLOGSTRING_LOW_LEVEL( "Update failed. Address of service is empty!! " ); |
|
600 // Service id = 0 because we dont have to bring this information |
|
601 // over IPC. Service ID is already on the client side. |
|
602 if ( iService->SearchUrl().Compare( KIptvEmptyAddress ) != 0 ) |
|
603 { |
|
604 // Service has only search URL, don't report failed update |
|
605 SendMessageToClientL( KIptvVodUpdateNotStarted, 0 ); |
|
606 } |
|
607 else |
|
608 { |
|
609 SendMessageToClientL( KIptvErrorEpgUpdateFailed, 0 ); |
|
610 SendMessageToClientL( KIptvErrorEpgUpdateStopped, 0 ); |
|
611 } |
|
612 } |
|
613 else if ( !IsVodUpdateAllowedL( err ) ) |
|
614 { |
|
615 // Service id = 0 because we dont have to bring this information |
|
616 // over IPC. Service ID is already on the client side. |
|
617 SendMessageToClientL( KIptvVodUpdateNotStarted, err ); |
|
618 } |
|
619 else |
|
620 { |
|
621 if ( !iUpdatePending ) |
|
622 { |
|
623 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::UpdateVodEcgL(), Manual update !" ); |
|
624 RunVodPluginL( aForceUpdate ); |
|
625 iForceUpdatePending = ETrue; |
|
626 } |
|
627 else |
|
628 { |
|
629 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::UpdateVodEcgL(), Manual update ignored !" ); |
|
630 } |
|
631 } |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------------------------- |
|
635 // CIptvEpgSession::UpdateLiveEpg |
|
636 // --------------------------------------------------------------------------- |
|
637 TInt CIptvEpgSession::UpdateLiveEpg() |
|
638 { |
|
639 if ( !iIsIap ) |
|
640 { |
|
641 return KErrNotReady; |
|
642 } |
|
643 |
|
644 TRAPD( err, RunSmartVisionPluginL() ); |
|
645 return err; |
|
646 } |
|
647 |
|
648 // --------------------------------------------------------------------------- |
|
649 // CIptvEpgSession::RunSmartVisionPluginL |
|
650 // --------------------------------------------------------------------------- |
|
651 void CIptvEpgSession::RunSmartVisionPluginL() |
|
652 { |
|
653 if ( iPlugin ) |
|
654 { |
|
655 delete iPlugin; |
|
656 iPlugin = NULL; |
|
657 } |
|
658 |
|
659 if ( iLiveTvCallback ) |
|
660 { |
|
661 delete iLiveTvCallback; |
|
662 iLiveTvCallback = NULL; |
|
663 } |
|
664 |
|
665 if ( iGroupUpdater ) |
|
666 { |
|
667 delete iGroupUpdater; |
|
668 iGroupUpdater = NULL; |
|
669 } |
|
670 |
|
671 iPlugin = CIptvEpgPluginInterface::NewL( iService->iUid ); |
|
672 |
|
673 iLiveTvCallback = CIptvEpgLiveTvCallbackImpl::NewL( *iLiveTvDatabase ); |
|
674 iLiveTvCallback->SetServiceId( iServiceId ); |
|
675 |
|
676 if ( iPlugin && iLiveTvCallback ) |
|
677 { |
|
678 iPluginStarted = ETrue; |
|
679 iPlugin->SetVodCallback( NULL ); |
|
680 iPlugin->SetLiveTvCallback( iLiveTvCallback ); |
|
681 iPlugin->SetServiceInformation( iService ); |
|
682 iPlugin->RunPlugin(); |
|
683 } |
|
684 else |
|
685 { |
|
686 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession EPG plugin = NULL" ); |
|
687 |
|
688 // Service id = 0 because we dont have to bring this information |
|
689 // over IPC. Service ID is already on the client side. |
|
690 SendMessageToClientL( KIptvErrorFailedToLoadPlugin, 0 ); |
|
691 } |
|
692 } |
|
693 |
|
694 // --------------------------------------------------------------------------- |
|
695 // CIptvEpgSession::GetServiceInformationL |
|
696 // --------------------------------------------------------------------------- |
|
697 TInt CIptvEpgSession::GetServiceInformationL() |
|
698 { |
|
699 IPTVLOGSTRING2_LOW_LEVEL( "CIptvEpgSession::GetServiceInformationL:: Service ID = %d", iServiceId ); |
|
700 |
|
701 CIptvService* service = NULL; |
|
702 service = iServer.iServiceManager->GetServiceL( iServiceId, ETrue /* do open/close */ ); |
|
703 if ( !service ) |
|
704 { |
|
705 return KIptvErrorNoService; |
|
706 } |
|
707 |
|
708 CleanupStack::PushL( service ); |
|
709 |
|
710 // Create EPG service |
|
711 delete iService; |
|
712 iService = NULL; |
|
713 iService = CIptvEpgService::NewL(); |
|
714 iService->iAddress.Copy( service->GetAddress() ); |
|
715 iService->SetSearchUrlL( service->SearchUrl() ); |
|
716 iService->iUserName.Copy( service->GetUserName() ); |
|
717 iService->iPassword.Copy( service->GetPassword() ); |
|
718 iService->iUid = service->GetEpgPluginUid(); |
|
719 iService->iServiceType = service->GetType(); |
|
720 iService->iServiceId = iServiceId; |
|
721 iService->iIap = iIap; |
|
722 if ( CIptvService::EServiceGroup == service->GetType() ) |
|
723 { |
|
724 iService->iLastUpdated = service->GetEpgUpdateTimeL(); |
|
725 } |
|
726 |
|
727 CleanupStack::PopAndDestroy( service ); |
|
728 |
|
729 return KErrNone; |
|
730 } |
|
731 |
|
732 // --------------------------------------------------------------------------- |
|
733 // CIptvEpgSession::SetReady |
|
734 // ----------------------------------------------------------------------------- |
|
735 void CIptvEpgSession::SetReady() |
|
736 { |
|
737 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::SetReady" ); |
|
738 |
|
739 iReady = ETrue; |
|
740 } |
|
741 |
|
742 // --------------------------------------------------------------------------- |
|
743 // CIptvEpgSession::IsReadyL |
|
744 // --------------------------------------------------------------------------- |
|
745 TBool CIptvEpgSession::IsReadyL() |
|
746 { |
|
747 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::IsReadyL" ); |
|
748 |
|
749 TBool ready = EFalse; |
|
750 |
|
751 if ( iService ) |
|
752 { |
|
753 switch ( iService->iServiceType ) |
|
754 { |
|
755 case CIptvService::EVod: |
|
756 case CIptvService::EVodCast: |
|
757 case CIptvService::EServiceGroup: |
|
758 case CIptvService::ESearch: |
|
759 { |
|
760 ready = ETrue; |
|
761 } |
|
762 break; |
|
763 case CIptvService::ELiveTv: |
|
764 break; |
|
765 case CIptvService::EOther: |
|
766 break; |
|
767 default: |
|
768 break; |
|
769 } |
|
770 } |
|
771 |
|
772 return ready; |
|
773 } |
|
774 |
|
775 // --------------------------------------------------------------------------- |
|
776 // CIptvEpgSession::IsValidVodDbAvailableL |
|
777 // --------------------------------------------------------------------------- |
|
778 // |
|
779 TBool CIptvEpgSession::IsValidVodDbAvailableL( |
|
780 TTime& aLastUpdated, |
|
781 TTime& aInterval ) |
|
782 { |
|
783 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::IsValidVodDbAvailableL" ); |
|
784 |
|
785 TInt error = iEpgDb->GetServiceInformationL( aLastUpdated, aInterval ); |
|
786 if ( error != KErrNone ) |
|
787 { |
|
788 if ( error == KIptvErrorGetUpdateInformationLNotFound ) |
|
789 { |
|
790 return EFalse; |
|
791 } |
|
792 } |
|
793 |
|
794 // check if no data in database |
|
795 if ( aLastUpdated.Int64() == 0 || aInterval.Int64() == 0 ) |
|
796 { |
|
797 return EFalse; |
|
798 } |
|
799 |
|
800 return ETrue; |
|
801 } |
|
802 |
|
803 // --------------------------------------------------------------------------- |
|
804 // CIptvEpgSession::CheckIsVodUpdateNeededL |
|
805 // --------------------------------------------------------------------------- |
|
806 void CIptvEpgSession::CheckIsVodUpdateNeededL() |
|
807 { |
|
808 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::CheckIsVodUpdateNeededL() in" ); |
|
809 |
|
810 TInt err( KErrNone ); |
|
811 if ( !IsVodUpdateAllowedL( err ) ) |
|
812 { |
|
813 // Service id = 0 because we dont have to bring this information |
|
814 // over IPC. Service ID is already on the client side. |
|
815 |
|
816 SendMessageToClientL( KIptvVodUpdateNotStarted, err ); |
|
817 return; |
|
818 } |
|
819 |
|
820 TTime lastUpdated; |
|
821 TTime interval; |
|
822 TBool update = EFalse; |
|
823 |
|
824 if ( !IsValidVodDbAvailableL( lastUpdated, interval ) ) |
|
825 { |
|
826 update = ETrue; |
|
827 } |
|
828 |
|
829 if ( update ) |
|
830 { |
|
831 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::CheckIsVodUpdateNeededL(), UPDATE NEEDED! DATABASE MISSING OR OLD DATA!" ); |
|
832 |
|
833 RunVodPluginL(); |
|
834 iForceUpdatePending = EFalse; |
|
835 return; |
|
836 } |
|
837 |
|
838 #ifdef _DEBUG |
|
839 |
|
840 TBuf<KIptvHundred> datePrint; |
|
841 _LIT( KIptvDatePrint, "%D%M%Y%/0%1%/1%2%/2%3%/3" ); |
|
842 lastUpdated.FormatL( datePrint, KIptvDatePrint ); |
|
843 |
|
844 TBuf<KIptvHundred> timePrint; |
|
845 _LIT( KIptvTimePrint, "%-B%:0%J%:1%T%:2%S%.%*C4%:3%+B" ); |
|
846 lastUpdated.FormatL( timePrint, KIptvTimePrint ); |
|
847 |
|
848 TBuf<KIptvHundred> intervalDate; |
|
849 interval.FormatL( intervalDate, KIptvDatePrint ); |
|
850 |
|
851 TBuf<KIptvHundred> intervalTime; |
|
852 interval.FormatL( intervalTime, KIptvTimePrint ); |
|
853 |
|
854 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::CheckIsVodUpdateNeededL()" ); |
|
855 IPTVLOGSTRING3_LOW_LEVEL( "EPG database was last updated : %S %S", &datePrint, &timePrint ); |
|
856 IPTVLOGSTRING3_LOW_LEVEL( "Data is valid : %S %S", &intervalDate, &intervalTime ); |
|
857 |
|
858 #endif |
|
859 |
|
860 TTimeIntervalMicroSeconds add( interval.Int64() ); |
|
861 lastUpdated += add; |
|
862 |
|
863 TTime current; |
|
864 current.UniversalTime(); |
|
865 |
|
866 if ( current < lastUpdated ) |
|
867 { |
|
868 |
|
869 #ifdef _DEBUG |
|
870 |
|
871 TBuf<KIptvHundred> nextDate; |
|
872 lastUpdated.FormatL( nextDate, KIptvDatePrint ); |
|
873 |
|
874 TBuf<KIptvHundred> nextTime; |
|
875 lastUpdated.FormatL( nextTime, KIptvTimePrint ); |
|
876 |
|
877 IPTVLOGSTRING3_LOW_LEVEL( "Next update: : %S %S", &nextDate, &nextTime ); |
|
878 IPTVLOGSTRING_LOW_LEVEL( "UPDATE NOT NEEDED!" ); |
|
879 |
|
880 #endif |
|
881 |
|
882 // Service id = 0 because we dont have to bring this information |
|
883 // over IPC. Service ID is already on the client side. |
|
884 SendMessageToClientL( KIptvVodUpdateNotStarted, 0 ); |
|
885 } |
|
886 else |
|
887 { |
|
888 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::CheckIsVodUpdateNeededL(), UPDATE NEEDED! DATABASE MISSING OR OLD DATA!" ); |
|
889 |
|
890 RunVodPluginL(); |
|
891 iForceUpdatePending = EFalse; |
|
892 } |
|
893 |
|
894 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::CheckIsVodUpdateNeededL(), out" ); |
|
895 } |
|
896 |
|
897 // --------------------------------------------------------------------------- |
|
898 // CIptvEpgSession::IsUpdateAllowed |
|
899 // --------------------------------------------------------------------------- |
|
900 // |
|
901 TBool CIptvEpgSession::IsVodUpdateAllowedL( TInt& aErrorCode ) |
|
902 { |
|
903 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::IsVodUpdateAllowedL" ); |
|
904 aErrorCode = KErrNone; |
|
905 |
|
906 if ( iServer.EpgUpdating() ) |
|
907 { |
|
908 // This enables and requires retry. |
|
909 if ( IsVodUpdateNeededL() ) |
|
910 { |
|
911 aErrorCode = KErrServerBusy; |
|
912 } |
|
913 return EFalse; |
|
914 } |
|
915 |
|
916 if ( !iService ) |
|
917 { |
|
918 return EFalse; |
|
919 } |
|
920 |
|
921 if ( iService->iAddress.Compare( KIptvEmptyAddress ) == 0 ) |
|
922 { |
|
923 return EFalse; |
|
924 } |
|
925 |
|
926 if ( !iPluginCanRun ) |
|
927 { |
|
928 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::IsVodUpdateAllowedL -- iPluginCanRun == EFalse" ); |
|
929 return EFalse; |
|
930 } |
|
931 |
|
932 if ( iVodCallback ) |
|
933 { |
|
934 if ( iVodCallback->IsPluginRunning() ) |
|
935 { |
|
936 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::IsVodUpdateAllowedL -- Plugin already running!" ); |
|
937 return EFalse; |
|
938 } |
|
939 } |
|
940 |
|
941 if ( iPluginStarted ) |
|
942 { |
|
943 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::IsVodUpdateAllowedL -- Plugin already started!" ); |
|
944 return EFalse; |
|
945 } |
|
946 |
|
947 if ( iPlugin ) |
|
948 { |
|
949 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::IsVodUpdateAllowedL -- Plugin already started!" ); |
|
950 return EFalse; |
|
951 } |
|
952 else |
|
953 { |
|
954 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::IsVodUpdateAllowedL -- Plugin is NULL" ); |
|
955 } |
|
956 |
|
957 return ETrue; |
|
958 } |
|
959 |
|
960 // --------------------------------------------------------------------------- |
|
961 // CIptvEpgSession::ResetGlobalId |
|
962 // --------------------------------------------------------------------------- |
|
963 TInt CIptvEpgSession::ResetGlobalId( CIptvMyVideosGlobalFileId& aId ) |
|
964 { |
|
965 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::ResetGlobalId" ); |
|
966 |
|
967 TInt error = KErrNotFound; |
|
968 |
|
969 if ( iEpgDb ) |
|
970 { |
|
971 error = iEpgDb->ResetGlobalId( aId ); |
|
972 } |
|
973 |
|
974 if ( iSearchManager ) |
|
975 { |
|
976 TInt error2 = iSearchManager->ResetGlobalId( aId ); |
|
977 } |
|
978 |
|
979 return error; |
|
980 } |
|
981 |
|
982 // --------------------------------------------------------------------------- |
|
983 // CIptvEpgSession::SetGlobalId |
|
984 // --------------------------------------------------------------------------- |
|
985 TInt CIptvEpgSession::SetGlobalId( |
|
986 TUint32 aContentKey, |
|
987 CIptvMyVideosGlobalFileId& aId, |
|
988 TUint32 aIndex ) |
|
989 { |
|
990 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::SetGlobalId" ); |
|
991 |
|
992 TInt error = iEpgDb->SetGlobalId( aContentKey, aId, aIndex ); |
|
993 |
|
994 if ( iSearchManager ) |
|
995 { |
|
996 iSearchManager->SetGlobalId( aContentKey, aId, aIndex ); |
|
997 } |
|
998 |
|
999 return error; |
|
1000 } |
|
1001 |
|
1002 // --------------------------------------------------------------------------- |
|
1003 // CIptvEpgSession::DeleteDatabaseFile |
|
1004 // --------------------------------------------------------------------------- |
|
1005 void CIptvEpgSession::DeleteDatabaseFile() |
|
1006 { |
|
1007 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::DeleteDatabaseFile" ); |
|
1008 |
|
1009 if ( iEpgDb ) |
|
1010 { |
|
1011 iEpgDb->DeleteDatabaseFiles(); |
|
1012 } |
|
1013 |
|
1014 iDeleteDatabase = ETrue; |
|
1015 } |
|
1016 |
|
1017 // --------------------------------------------------------------------------- |
|
1018 // CIptvEpgSession::RunVodPluginL |
|
1019 // --------------------------------------------------------------------------- |
|
1020 // |
|
1021 void CIptvEpgSession::RunVodPluginL( TBool aForceUpdate ) |
|
1022 { |
|
1023 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::RunVodPluginL" ); |
|
1024 |
|
1025 if ( !iIsIap ) |
|
1026 { |
|
1027 // Service id = 0 because we dont have to bring this information |
|
1028 // over IPC. Service ID is already on the client side. |
|
1029 |
|
1030 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
1031 IPTVLOGSTRING_LOW_LEVEL( "------------------CIptvEpgSession::RunVodPluginL------------------" ); |
|
1032 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
1033 IPTVLOGSTRING_LOW_LEVEL( "UPDATE CANCELLED! NO IAP! KIptvErrorVodNoIap sent to client." ); |
|
1034 IPTVLOGSTRING_LOW_LEVEL( "Update pending! Update is made when we get IAP!" ); |
|
1035 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
1036 IPTVLOGSTRING_LOW_LEVEL( "------------------CIptvEpgSession::RunVodPluginL------------------" ); |
|
1037 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
1038 |
|
1039 iUpdatePending = ETrue; |
|
1040 SendMessageToClientL( KIptvErrorVodNoIap, 0 ); |
|
1041 return; |
|
1042 } |
|
1043 |
|
1044 iUpdatePending = EFalse; |
|
1045 |
|
1046 if ( !iService ) |
|
1047 { |
|
1048 return; |
|
1049 } |
|
1050 |
|
1051 if ( CIptvService::EServiceGroup == iService->iServiceType ) |
|
1052 { |
|
1053 RunVodPluginForGroupL( aForceUpdate ); |
|
1054 } |
|
1055 else |
|
1056 { |
|
1057 RunVodPluginForFeedL( aForceUpdate ); |
|
1058 } |
|
1059 } |
|
1060 |
|
1061 // --------------------------------------------------------------------------- |
|
1062 // CIptvEpgSession::RunVodPluginForFeedL |
|
1063 // --------------------------------------------------------------------------- |
|
1064 // |
|
1065 void CIptvEpgSession::RunVodPluginForFeedL( TBool aForceUpdate ) |
|
1066 { |
|
1067 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::RunVodPluginForFeedL" ); |
|
1068 |
|
1069 if ( iGroupUpdater ) |
|
1070 { |
|
1071 delete iGroupUpdater; |
|
1072 iGroupUpdater = NULL; |
|
1073 } |
|
1074 |
|
1075 if ( iPlugin ) |
|
1076 { |
|
1077 delete iPlugin; |
|
1078 iPlugin = NULL; |
|
1079 } |
|
1080 |
|
1081 if ( iVodCallback ) |
|
1082 { |
|
1083 delete iVodCallback; |
|
1084 iVodCallback = NULL; |
|
1085 } |
|
1086 |
|
1087 iPlugin = CIptvEpgPluginInterface::NewL( iService->iUid ); |
|
1088 iVodCallback = CIptvEpgVodCallbackImpl::NewL( *iEpgDb, iMsgQueue, *this ); |
|
1089 |
|
1090 if ( iPlugin && iVodCallback ) |
|
1091 { |
|
1092 TTime lastUpdated; |
|
1093 TTime interval; |
|
1094 |
|
1095 if ( iEpgDb ) |
|
1096 { |
|
1097 iEpgDb->GetServiceInformationL( lastUpdated, interval ); |
|
1098 } |
|
1099 |
|
1100 iService->iLastUpdated = lastUpdated; |
|
1101 |
|
1102 // Service id = 0 because we dont have to bring this information |
|
1103 // over IPC. Service ID is already on the client side. |
|
1104 SendMessageToClientL( KIptvVodUpdateStarted, 0 ); |
|
1105 |
|
1106 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
1107 IPTVLOGSTRING_LOW_LEVEL( "------------------CIptvEpgSession::RunVodPluginForFeedL------------------" ); |
|
1108 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
1109 IPTVLOGSTRING_LOW_LEVEL( "UPDATE STARTED!!! KIptvVodUpdateStarted sent to client!" ); |
|
1110 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
1111 IPTVLOGSTRING_LOW_LEVEL( "------------------CIptvEpgSession::RunVodPluginForFeedL------------------" ); |
|
1112 |
|
1113 iUpdater->Start(); |
|
1114 iPluginStarted = ETrue; |
|
1115 iPlugin->SetVodCallback( iVodCallback ); |
|
1116 iPlugin->SetLiveTvCallback( NULL ); |
|
1117 |
|
1118 if ( aForceUpdate ) |
|
1119 { |
|
1120 iService->iLastUpdated = TTime( 0L ); |
|
1121 } |
|
1122 iPlugin->SetServiceInformation( iService ); |
|
1123 iPlugin->RunPlugin(); |
|
1124 iServer.SetEpgUpdating( ETrue ); |
|
1125 } |
|
1126 else |
|
1127 { |
|
1128 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession EPG plugin = NULL" ); |
|
1129 } |
|
1130 } |
|
1131 |
|
1132 // --------------------------------------------------------------------------- |
|
1133 // CIptvEpgSession::RunVodPluginForGroupL |
|
1134 // --------------------------------------------------------------------------- |
|
1135 // |
|
1136 void CIptvEpgSession::RunVodPluginForGroupL( TBool aForceUpdate ) |
|
1137 { |
|
1138 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::RunVodPluginForGroupL" ); |
|
1139 |
|
1140 if ( iGroupUpdater ) |
|
1141 { |
|
1142 delete iGroupUpdater; |
|
1143 iGroupUpdater = NULL; |
|
1144 } |
|
1145 |
|
1146 if ( iPlugin ) |
|
1147 { |
|
1148 delete iPlugin; |
|
1149 iPlugin = NULL; |
|
1150 } |
|
1151 |
|
1152 iGroupUpdater = CVcxGroupUpdater::NewL( |
|
1153 iServer, |
|
1154 *this, |
|
1155 *iMsgQueue ); |
|
1156 |
|
1157 if ( iGroupUpdater ) |
|
1158 { |
|
1159 // Service id = 0 because we dont have to bring this information |
|
1160 // over IPC. Service ID is already on the client side. |
|
1161 SendMessageToClientL( KIptvVodUpdateStarted, 0 ); |
|
1162 |
|
1163 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
1164 IPTVLOGSTRING_LOW_LEVEL( "------------------CIptvEpgSession::RunVodPluginForGroupL------------------" ); |
|
1165 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
1166 IPTVLOGSTRING_LOW_LEVEL( "UPDATE STARTED!!! KIptvVodUpdateStarted sent to client!" ); |
|
1167 IPTVLOGSTRING_LOW_LEVEL( "" ); |
|
1168 IPTVLOGSTRING_LOW_LEVEL( "------------------CIptvEpgSession::RunVodPluginForGroupL------------------" ); |
|
1169 |
|
1170 iUpdater->Start(); |
|
1171 iPluginStarted = ETrue; |
|
1172 |
|
1173 if ( aForceUpdate ) |
|
1174 { |
|
1175 iService->iLastUpdated = TTime( 0L ); |
|
1176 } |
|
1177 |
|
1178 iGroupUpdater->StartGroupUpdateL( iService ); |
|
1179 iServer.SetEpgUpdating( ETrue ); |
|
1180 } |
|
1181 } |
|
1182 |
|
1183 // --------------------------------------------------------------------------- |
|
1184 // CIptvEpgSession::VodPluginStopped |
|
1185 // --------------------------------------------------------------------------- |
|
1186 // |
|
1187 void CIptvEpgSession::VodPluginStopped() |
|
1188 { |
|
1189 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::VodPluginStopped" ); |
|
1190 |
|
1191 iUpdater->Stop(); |
|
1192 iPluginStarted = EFalse; |
|
1193 delete iVodCallback; |
|
1194 iVodCallback = NULL; |
|
1195 delete iPlugin; |
|
1196 iPlugin = NULL; |
|
1197 delete iGroupUpdater; |
|
1198 iGroupUpdater = NULL; |
|
1199 |
|
1200 if ( iSearchManager ) |
|
1201 { |
|
1202 if ( ! iSearchManager->IsPluginRunning() ) |
|
1203 { |
|
1204 REComSession::FinalClose(); |
|
1205 } |
|
1206 } |
|
1207 else |
|
1208 { |
|
1209 REComSession::FinalClose(); |
|
1210 } |
|
1211 |
|
1212 iServer.SetEpgUpdating( EFalse ); |
|
1213 |
|
1214 // Service id = 0 because we dont have to bring this information |
|
1215 // over IPC. Service ID is already on the client side. |
|
1216 TRAP_IGNORE( SendMessageToClientL( KIptvErrorEpgUpdateStopped, 0 ) ); |
|
1217 } |
|
1218 |
|
1219 // --------------------------------------------------------------------------- |
|
1220 // CIptvEpgSession::GetVodClientImpl |
|
1221 // --------------------------------------------------------------------------- |
|
1222 // |
|
1223 CIptvEpgVodClientImpl* CIptvEpgSession::GetVodClientImplL() |
|
1224 { |
|
1225 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::GetVodClientImpl" ); |
|
1226 |
|
1227 return iVodClient; |
|
1228 } |
|
1229 |
|
1230 // --------------------------------------------------------------------------- |
|
1231 // CIptvEpgSession::CheckIsPluginRunning |
|
1232 // --------------------------------------------------------------------------- |
|
1233 // |
|
1234 void CIptvEpgSession::CheckIsPluginRunning() |
|
1235 { |
|
1236 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::CheckIsPluginRunning" ); |
|
1237 |
|
1238 TBool running( EFalse ); |
|
1239 |
|
1240 if ( iGroupUpdater ) |
|
1241 { |
|
1242 running = iGroupUpdater->IsGroupUpdateOngoing(); |
|
1243 } |
|
1244 |
|
1245 if ( iVodCallback && !running ) |
|
1246 { |
|
1247 running = iVodCallback->IsPluginRunning(); |
|
1248 } |
|
1249 |
|
1250 if ( !running ) |
|
1251 { |
|
1252 VodPluginStopped(); |
|
1253 } |
|
1254 |
|
1255 if ( iLiveTvCallback ) |
|
1256 { |
|
1257 if ( !iLiveTvCallback->IsPluginRunning() ) |
|
1258 { |
|
1259 // check |
|
1260 // LiveTvPluginStopped() |
|
1261 } |
|
1262 } |
|
1263 else |
|
1264 { |
|
1265 // check |
|
1266 // LiveTvPluginStopped() |
|
1267 } |
|
1268 } |
|
1269 |
|
1270 // --------------------------------------------------------------------------- |
|
1271 // CIptvEpgSession::InitializeL |
|
1272 // --------------------------------------------------------------------------- |
|
1273 void CIptvEpgSession::InitializeL() |
|
1274 { |
|
1275 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::InitializeL" ); |
|
1276 |
|
1277 if ( iService ) |
|
1278 { |
|
1279 if ( !iInitialized ) |
|
1280 { |
|
1281 iInitialized = ETrue; |
|
1282 switch ( iService->iServiceType ) |
|
1283 { |
|
1284 case CIptvService::EVod: |
|
1285 case CIptvService::EVodCast: |
|
1286 CheckIsVodUpdateNeededL(); |
|
1287 break; |
|
1288 case CIptvService::ELiveTv: |
|
1289 // check |
|
1290 // CheckIsLiveTvUpdateNeededL? |
|
1291 break; |
|
1292 case CIptvService::EOther: |
|
1293 break; |
|
1294 default: |
|
1295 break; |
|
1296 } |
|
1297 } |
|
1298 } |
|
1299 } |
|
1300 |
|
1301 // --------------------------------------------------------------------------- |
|
1302 // CIptvEpgSession::SetIapL |
|
1303 // --------------------------------------------------------------------------- |
|
1304 void CIptvEpgSession::SetIapL( TUint32 aIap ) |
|
1305 { |
|
1306 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::SetIapL" ); |
|
1307 |
|
1308 if ( iService ) |
|
1309 { |
|
1310 iService->iIap = aIap; |
|
1311 iIap = aIap; |
|
1312 iIsIap = ETrue; |
|
1313 |
|
1314 #if !defined(__SERIES60_30__) && !defined(__SERIES60_31__) && !defined(__SERIES60_32__) |
|
1315 if( iIap == 0 ) |
|
1316 { |
|
1317 iIsIap = EFalse; |
|
1318 } |
|
1319 #endif // !defined(__SERIES60_30__) && !defined(__SERIES60_31__) && !defined(__SERIES60_32__) |
|
1320 |
|
1321 if ( iUpdatePending ) |
|
1322 { |
|
1323 RunVodPluginL( iForceUpdatePending ); |
|
1324 iForceUpdatePending = EFalse; |
|
1325 } |
|
1326 } |
|
1327 } |
|
1328 |
|
1329 // --------------------------------------------------------------------------- |
|
1330 // CIptvEpgSession::UpdateServiceThumbnailL |
|
1331 // --------------------------------------------------------------------------- |
|
1332 // |
|
1333 void CIptvEpgSession::UpdateServiceThumbnailL( |
|
1334 const TDesC& aIconFilePath, const TBool aGrouped ) |
|
1335 { |
|
1336 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::UpdateServiceThumbnailL" ); |
|
1337 |
|
1338 CIptvService* service = NULL; |
|
1339 service = iServer.iServiceManager->GetServiceL( iServiceId, ETrue /* do open/close */ ); |
|
1340 if ( service ) |
|
1341 { |
|
1342 CleanupStack::PushL( service ); |
|
1343 if ( aGrouped || !( service->GetFlags() & CIptvService::EGroupedService ) ) |
|
1344 { |
|
1345 service->SetIconPath( aIconFilePath ); |
|
1346 iServer.iServiceManager->UpdateServiceL( *service ); |
|
1347 } |
|
1348 CleanupStack::PopAndDestroy( service ); |
|
1349 } |
|
1350 |
|
1351 return; |
|
1352 } |
|
1353 |
|
1354 // --------------------------------------------------------------------------- |
|
1355 // CIptvEpgSession::IsVodUpdateNeededL() |
|
1356 // --------------------------------------------------------------------------- |
|
1357 // |
|
1358 TBool CIptvEpgSession::IsVodUpdateNeededL() |
|
1359 { |
|
1360 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::IsVodUpdateNeededL()" ); |
|
1361 |
|
1362 TTime lastUpdated; |
|
1363 TTime interval; |
|
1364 |
|
1365 if ( !IsValidVodDbAvailableL( lastUpdated, interval ) ) |
|
1366 { |
|
1367 return ETrue; |
|
1368 } |
|
1369 |
|
1370 TTimeIntervalMicroSeconds add( interval.Int64() ); |
|
1371 lastUpdated += add; |
|
1372 |
|
1373 TTime current; |
|
1374 current.UniversalTime(); |
|
1375 |
|
1376 if ( current > lastUpdated ) |
|
1377 { |
|
1378 return ETrue; |
|
1379 } |
|
1380 |
|
1381 return EFalse; |
|
1382 } |
|
1383 |
|
1384 // --------------------------------------------------------------------------- |
|
1385 // CIptvEpgSession::VodPluginCancelled() |
|
1386 // --------------------------------------------------------------------------- |
|
1387 // |
|
1388 void CIptvEpgSession::VodPluginCancelled() |
|
1389 { |
|
1390 if ( iPluginStarted ) |
|
1391 { |
|
1392 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::VodPluginCancelled" ); |
|
1393 iUpdater->Stop(); |
|
1394 iPluginStarted = EFalse; |
|
1395 delete iVodCallback; |
|
1396 iVodCallback = NULL; |
|
1397 delete iPlugin; |
|
1398 iPlugin = NULL; |
|
1399 |
|
1400 if ( iSearchManager ) |
|
1401 { |
|
1402 if ( ! iSearchManager->IsPluginRunning() ) |
|
1403 { |
|
1404 REComSession::FinalClose(); |
|
1405 } |
|
1406 } |
|
1407 else |
|
1408 { |
|
1409 REComSession::FinalClose(); |
|
1410 } |
|
1411 |
|
1412 iServer.SetEpgUpdating( EFalse ); |
|
1413 } |
|
1414 } |
|
1415 |
|
1416 // --------------------------------------------------------------------------- |
|
1417 // CIptvEpgSession::HandleSmEvent |
|
1418 // --------------------------------------------------------------------------- |
|
1419 // |
|
1420 void CIptvEpgSession::HandleSmEvent( CIptvSmEvent& aEvent ) |
|
1421 { |
|
1422 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::HandleSmEvent" ); |
|
1423 |
|
1424 if ( aEvent.iEvent == CIptvSmEvent::EServiceModified ) |
|
1425 { |
|
1426 if ( aEvent.iServiceId == iServiceId ) |
|
1427 { |
|
1428 IPTVLOGSTRING_LOW_LEVEL( |
|
1429 "CIptvEpgSession::HandleSmEvent EServiceModified --> Cancel plugin" ); |
|
1430 if ( iPluginStarted ) |
|
1431 { |
|
1432 VodPluginStopped(); |
|
1433 TRAP_IGNORE( SendMessageToClientL( |
|
1434 KIptvErrorEpgUpdateFailed, EIptvDlGeneral ) ); |
|
1435 } |
|
1436 } |
|
1437 } |
|
1438 } |
|
1439 |
|
1440 // --------------------------------------------------------------------------- |
|
1441 // |
|
1442 // --------------------------------------------------------------------------- |
|
1443 // |
|
1444 TInt CIptvEpgSession::SetLastUpdateTimeL( const TTime& aLastUpdate ) |
|
1445 { |
|
1446 IPTVLOGSTRING_LOW_LEVEL( "CIptvEpgSession::SetLastUpdateTimeL" ); |
|
1447 TInt err( KErrNone ); |
|
1448 if ( iEpgDb ) |
|
1449 { |
|
1450 TTime tempLastUpdate( 0 ); |
|
1451 TTime interval( 0 ); |
|
1452 err = iEpgDb->GetServiceInformationL( tempLastUpdate, interval ); |
|
1453 if ( err == KErrNone ) |
|
1454 { |
|
1455 err = iEpgDb->UpdateServiceInformationL( aLastUpdate, interval ); |
|
1456 } |
|
1457 } |
|
1458 return err; |
|
1459 } |
|
1460 |