videofeeds/server/IptvEpgManager/src/vcxgroupupdater.cpp
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     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:    Implements customised service update*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <apgtask.h>
       
    22 #include <apgcli.h>
       
    23 #include <bautils.h>    // file helpers
       
    24 #include "vcxgroupupdater.h"
       
    25 #include "CIptvServer.h"
       
    26 #include "CIptvEpgSession.h"
       
    27 #include "CIptvService.h"
       
    28 #include "IptvDebug.h"
       
    29 #include "CIptvTimer.h"
       
    30 #include "CIptvEpgService.h"
       
    31 #include "CIptvEpgVodMsqQueue.h"
       
    32 
       
    33 const TInt KIptvVcfgFileParseWait( 500000 ); // 0.5 s
       
    34 const TInt KIptvVcfgFileParseMaxTry( 10 );   // 5 s
       
    35 
       
    36 // ======== MEMBER FUNCTIONS ========
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // Constructors and destructors.
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CVcxGroupUpdater* CVcxGroupUpdater::NewL(
       
    43     CIptvServer& aServer,
       
    44     CIptvEpgSession& aSession,
       
    45     CIptvEpgVodMsqQueue& aMsgQueue )
       
    46     {
       
    47     IPTVLOGSTRING_LOW_LEVEL( "CVcxGroupUpdater::NewL" );
       
    48 
       
    49     CVcxGroupUpdater* self =
       
    50         new( ELeave ) CVcxGroupUpdater( aServer, aSession, aMsgQueue );
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop( self );
       
    54     return self;
       
    55     }
       
    56 
       
    57 CVcxGroupUpdater::CVcxGroupUpdater(
       
    58     CIptvServer& aServer,
       
    59     CIptvEpgSession& aSession,
       
    60     CIptvEpgVodMsqQueue& aMsgQueue ) :
       
    61     iServer( aServer ),
       
    62     iSession( aSession ),
       
    63     iMsgQueue( aMsgQueue ),
       
    64     iCurrentAction( CIptvEpgPluginInterface::EIptvRssNone )
       
    65     {
       
    66     IPTVLOGSTRING_LOW_LEVEL(
       
    67         "CVcxGroupUpdater::CVcxGroupUpdater" );
       
    68     }
       
    69 
       
    70 void CVcxGroupUpdater::ConstructL()
       
    71     {
       
    72     IPTVLOGSTRING_LOW_LEVEL( "CVcxGroupUpdater::ConstructL" );
       
    73 
       
    74     User::LeaveIfError( iFs.Connect() );
       
    75     }
       
    76 
       
    77 CVcxGroupUpdater::~CVcxGroupUpdater()
       
    78     {
       
    79     IPTVLOGSTRING_LOW_LEVEL(
       
    80         "CVcxGroupUpdater::~CVcxGroupUpdater" );
       
    81 
       
    82     if ( iVcfgParseTimer )
       
    83         {
       
    84         iVcfgParseTimer->Cancel();
       
    85         delete iVcfgParseTimer;
       
    86         }
       
    87 
       
    88     delete iDownloadedVcfgPath;
       
    89     delete iPlugin;
       
    90     REComSession::FinalClose();
       
    91 
       
    92     iFs.Close();
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // Start download.
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CVcxGroupUpdater::StartGroupUpdateL( CIptvEpgService* aService )
       
   100     {
       
   101     IPTVLOGSTRING_LOW_LEVEL(
       
   102         "CVcxGroupUpdater::StartGroupDownloadL - enter" );
       
   103 
       
   104     iLocalValid = EFalse;
       
   105 
       
   106     // Create download plugin.
       
   107     if ( iPlugin )
       
   108         {
       
   109         delete iPlugin;
       
   110         iPlugin = NULL;
       
   111         REComSession::FinalClose();
       
   112         }
       
   113 
       
   114     if ( !iPlugin )
       
   115         {
       
   116         iPlugin = CIptvEpgPluginInterface::NewL( aService->iUid );
       
   117         }
       
   118 
       
   119     iCurrentGroupServiceId = aService->iServiceId;
       
   120     iDownloadStartTime.UniversalTime();
       
   121 
       
   122     // Initialize download plugin.
       
   123     iPlugin->SetVodCallback( this );
       
   124     iCurrentAction = CIptvEpgPluginInterface::EIptvRssServiceGroup;
       
   125     iPlugin->SetServiceInformationL( aService, iCurrentAction );
       
   126 
       
   127     // Start actual download.
       
   128     iPlugin->RunPlugin();
       
   129 
       
   130     IPTVLOGSTRING_LOW_LEVEL(
       
   131         "CVcxGroupUpdater::StartDownloadL - exit" );
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // Cancel current download download, if any.
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 void CVcxGroupUpdater::CancelGroupUpdate()
       
   139     {
       
   140     IPTVLOGSTRING3_LOW_LEVEL(
       
   141         "CVcxGroupUpdater::CancelGroupUpdate -- %d/%d",
       
   142         iPluginRunning,
       
   143         iCurrentAction );
       
   144 
       
   145     if ( iPlugin )
       
   146         {
       
   147         delete iPlugin;
       
   148         iPlugin = NULL;
       
   149         REComSession::FinalClose();
       
   150         }
       
   151 
       
   152     iPluginRunning = EFalse;
       
   153     iCurrentAction = CIptvEpgPluginInterface::EIptvRssNone;
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // Enquire is download ongoing.
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 TBool CVcxGroupUpdater::IsGroupUpdateOngoing()
       
   161     {
       
   162     IPTVLOGSTRING2_LOW_LEVEL(
       
   163         "CVcxGroupUpdater::IsGroupUpdateOngoing -- %d",
       
   164         iPluginRunning );
       
   165 
       
   166     return iPluginRunning;
       
   167     }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // From MIptvEpgVodCallback interface
       
   171 // ---------------------------------------------------------------------------
       
   172 //
       
   173 void CVcxGroupUpdater::StartedL()
       
   174     {
       
   175     IPTVLOGSTRING_LOW_LEVEL(
       
   176         "CVcxGroupUpdater::StartedL -- Rss Plugin started" );
       
   177 
       
   178     iPluginRunning = ETrue;
       
   179     }
       
   180 
       
   181 // ---------------------------------------------------------------------------
       
   182 // From MIptvEpgVodCallback interface
       
   183 // ---------------------------------------------------------------------------
       
   184 //
       
   185 void CVcxGroupUpdater::ContentUpdateCompletedL()
       
   186     {
       
   187     IPTVLOGSTRING_LOW_LEVEL(
       
   188         "CVcxGroupUpdater::ContentUpdateCompletedL" );
       
   189     }
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 // From MIptvEpgVodCallback interface
       
   193 // ---------------------------------------------------------------------------
       
   194 //
       
   195 TInt CVcxGroupUpdater::FinishedL(
       
   196     TTime& /* aUpdateInterval */ )
       
   197     {
       
   198     IPTVLOGSTRING_LOW_LEVEL(
       
   199         "CVcxGroupUpdater::FinishedL -- Rss Plugin finished" );
       
   200 
       
   201     iPluginRunning = EFalse;
       
   202     iCurrentAction = CIptvEpgPluginInterface::EIptvRssNone;
       
   203 
       
   204     return KErrNone;
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // From MIptvEpgVodCallback interface
       
   209 // ---------------------------------------------------------------------------
       
   210 //
       
   211 TInt CVcxGroupUpdater::AddCategoryL(
       
   212     CIptvEpgCategory& /* aCategory */,
       
   213     TUint32& /* aCategoryKey */ )
       
   214     {
       
   215     IPTVLOGSTRING_LOW_LEVEL( "CVcxGroupUpdater::AddCategoryL" );
       
   216 
       
   217     return KErrNone;
       
   218     }
       
   219 
       
   220 // ---------------------------------------------------------------------------
       
   221 // From MIptvEpgVodCallback interface
       
   222 // ---------------------------------------------------------------------------
       
   223 //
       
   224 TInt CVcxGroupUpdater::AddContentL(
       
   225     CIptvEpgContent& /* aContent */,
       
   226     RPointerArray<CIptvMediaContent> /* aMediaContents */,
       
   227     TUint32& /* aContentKey */ )
       
   228     {
       
   229     IPTVLOGSTRING_LOW_LEVEL( "CVcxGroupUpdater::AddContentL" );
       
   230 
       
   231     return KErrNone;
       
   232     }
       
   233 
       
   234 // ---------------------------------------------------------------------------
       
   235 // From MIptvEpgVodCallback interface
       
   236 // ---------------------------------------------------------------------------
       
   237 //
       
   238 TInt CVcxGroupUpdater::UpdateServiceThumbnailL(
       
   239     TDesC& aFilePath,
       
   240     const TBool aGrouped )
       
   241     {
       
   242     IPTVLOGSTRING_LOW_LEVEL(
       
   243         "CVcxGroupUpdater::UpdateServiceThumbnailL" );
       
   244 
       
   245     // Also VCFG file download is indicated here.
       
   246     if ( CIptvEpgPluginInterface::EIptvRssServiceGroup == iCurrentAction )
       
   247         {
       
   248         StartVcfgFileParseL( aFilePath );
       
   249         }
       
   250     else
       
   251         {
       
   252         iSession.UpdateServiceThumbnailL( aFilePath, aGrouped );
       
   253         }
       
   254 
       
   255     return KErrNone;
       
   256     }
       
   257 
       
   258 // ---------------------------------------------------------------------------
       
   259 // From MIptvEpgVodCallback interface
       
   260 // ---------------------------------------------------------------------------
       
   261 //
       
   262 TInt CVcxGroupUpdater::AddRelationL(
       
   263     TUint32& /* aCategoryKey */,
       
   264     TUint32& /* aContentKey */ )
       
   265     {
       
   266     IPTVLOGSTRING_LOW_LEVEL( "CVcxGroupUpdater::AddRelationL" );
       
   267 
       
   268     return KErrNone;
       
   269     }
       
   270 
       
   271 // ---------------------------------------------------------------------------
       
   272 // From MIptvEpgVodCallback interface
       
   273 // ---------------------------------------------------------------------------
       
   274 //
       
   275 void CVcxGroupUpdater::ErrorL(
       
   276     TInt aError,
       
   277     TInt aInfo )
       
   278     {
       
   279     IPTVLOGSTRING3_HIGH_LEVEL(
       
   280         "CVcxGroupUpdater::ErrorL( %d, %d )", aError, aInfo );
       
   281 
       
   282 #ifdef _DEBUG
       
   283 
       
   284     switch ( aError )
       
   285         {
       
   286         case KIptvContentUpdateCompleted:
       
   287             IPTVLOGSTRING_HIGH_LEVEL( " -- KIptvContentUpdateCompleted" );
       
   288             break;
       
   289         case KIptvServiceThumbnailDownloaded:
       
   290             IPTVLOGSTRING_HIGH_LEVEL( " -- KIptvServiceThumbnailDownloaded" );
       
   291             break;
       
   292         case KIptvThumbnailCount:
       
   293             IPTVLOGSTRING_HIGH_LEVEL( " -- KIptvThumbnailCount" );
       
   294             break;
       
   295         case KIptvRssSearchThumbnailCount:
       
   296             IPTVLOGSTRING_HIGH_LEVEL( " -- KIptvRssSearchThumbnailCount" );
       
   297             break;
       
   298         case KIptvErrorEpgUpdateSuccessed:
       
   299             IPTVLOGSTRING_HIGH_LEVEL( " -- KIptvErrorEpgUpdateSuccessed" );
       
   300             break;
       
   301         case KIptvErrorRssSearchSucceed:
       
   302             IPTVLOGSTRING_HIGH_LEVEL( " -- KIptvErrorRssSearchSucceed" );
       
   303             break;
       
   304         case KIptvContentThumbnailDownloaded:
       
   305             IPTVLOGSTRING_HIGH_LEVEL( " -- KIptvContentThumbnailDownloaded" );
       
   306             break;
       
   307         case KIptvRssSearchContentThumbnailDownloaded:
       
   308             IPTVLOGSTRING_HIGH_LEVEL( " -- KIptvRssSearchContentThumbnailDownloaded" );
       
   309             break;
       
   310         case KIptvErrorEpgUpdateFailed:
       
   311             IPTVLOGSTRING_HIGH_LEVEL( " -- KIptvErrorEpgUpdateFailed" );
       
   312             break;
       
   313         case KIptvErrorRssSearchFailed:
       
   314             IPTVLOGSTRING_HIGH_LEVEL( " -- KIptvErrorRssSearchFailed" );
       
   315             break;
       
   316         default:
       
   317             IPTVLOGSTRING_HIGH_LEVEL( " -- Unknown" );
       
   318         }
       
   319 
       
   320 #endif // _DEBUG
       
   321 
       
   322     if ( ( KIptvContentUpdateCompleted == aError ) &&
       
   323          ( EIptvDlNoErrorUpToDate == aInfo ) )
       
   324         {
       
   325         IPTVLOGSTRING_HIGH_LEVEL( " -- Local VCFG-file valid" );
       
   326         iLocalValid = ETrue;
       
   327         }
       
   328     else
       
   329         {
       
   330         if ( ( KIptvErrorEpgUpdateSuccessed == aError ) &&
       
   331              ( KErrNone == aInfo ) )
       
   332             {
       
   333 
       
   334 #ifdef _DEBUG
       
   335 
       
   336                 // Debug print last updated info.
       
   337                 TBuf<KIptvEpgDbLastModifiedMaxLength> lastModifiedDatePrint;
       
   338                 _LIT( KIptvDatePrint, "%D%M%Y%/0%1%/1%2%/2%3%/3" );
       
   339                 iDownloadStartTime.FormatL( lastModifiedDatePrint, KIptvDatePrint );
       
   340 
       
   341                 TBuf<KIptvEpgDbLastModifiedMaxLength> lastModifiedTimePrint;
       
   342                 _LIT( KIptvTimePrint, "%-B%:0%J%:1%T%:2%S%.%*C4%:3%+B" );
       
   343                 iDownloadStartTime.FormatL( lastModifiedTimePrint, KIptvTimePrint );
       
   344 
       
   345                 IPTVLOGSTRING3_LOW_LEVEL( " -- Group update ok, last modified set: %S %S",
       
   346                     &lastModifiedDatePrint,
       
   347                     &lastModifiedTimePrint );
       
   348 
       
   349 #endif // _DEBUG
       
   350 
       
   351             SetLastModifiedL( iCurrentGroupServiceId, iDownloadStartTime );
       
   352             }
       
   353 
       
   354         // Inform clients about failure.
       
   355         iMsgQueue.SendMessageToClientL( aError, aInfo );
       
   356         }
       
   357     }
       
   358 
       
   359 // ---------------------------------------------------------------------------
       
   360 // From MIptvEpgVodCallback interface
       
   361 // ---------------------------------------------------------------------------
       
   362 //
       
   363 TInt CVcxGroupUpdater::UpdateCategoryIconL(
       
   364     TUint32& /* aCategoryKey */,
       
   365     TUint32& /* aIconFileId */,
       
   366     TDesC& /* aIconFilePath */,
       
   367     TBool /* aIsUrl */ )
       
   368     {
       
   369     IPTVLOGSTRING_LOW_LEVEL( "CVcxGroupUpdater::UpdateCategoryIconL" );
       
   370 
       
   371     return KErrNotFound;
       
   372     }
       
   373 
       
   374 // ---------------------------------------------------------------------------
       
   375 // From MIptvEpgVodCallback interface
       
   376 // ---------------------------------------------------------------------------
       
   377 //
       
   378 TInt CVcxGroupUpdater::UpdateContentIconL(
       
   379     TUint32& aContentKey,
       
   380     TUint32& /* aIconFileId */,
       
   381     TDesC& aIconFilePath,
       
   382     TBool /* aIsUrl */ )
       
   383     {
       
   384     IPTVLOGSTRING_LOW_LEVEL( "CVcxGroupUpdater::UpdateContentIconL" );
       
   385 
       
   386     // Update icon pathname to service.
       
   387     CIptvService* service = iServer.iServiceManager->GetServiceL(
       
   388         aContentKey, ETrue /* do open/close */ );
       
   389     if ( service )
       
   390         {
       
   391         CleanupStack::PushL( service );  // 1->
       
   392         service->SetIconPath( aIconFilePath );
       
   393         iServer.iServiceManager->UpdateServiceL( *service );
       
   394         CleanupStack::PopAndDestroy( service ); //<-1
       
   395         return KErrNone;
       
   396         }
       
   397 
       
   398     return KErrNone;
       
   399     }
       
   400 
       
   401 // ---------------------------------------------------------------------------
       
   402 // Starts parsing of downloaded VCFG file.
       
   403 // ---------------------------------------------------------------------------
       
   404 //
       
   405 void CVcxGroupUpdater::StartVcfgFileParseL(
       
   406     const TDesC& aPathName )
       
   407     {
       
   408     IPTVLOGSTRING_HIGH_LEVEL(
       
   409         "CVcxGroupUpdater::StartVcfgFileParseL" );
       
   410 
       
   411     TInt error( KErrNone );
       
   412 
       
   413     if ( iLocalValid )
       
   414         {
       
   415         iMsgQueue.SendMessageToClientL(
       
   416             KIptvContentUpdateCompleted,
       
   417             EIptvDlNoErrorUpToDate );
       
   418         }
       
   419     else
       
   420         {
       
   421         // Save file name for deletion.
       
   422         if ( iDownloadedVcfgPath )
       
   423             {
       
   424             delete iDownloadedVcfgPath;
       
   425             iDownloadedVcfgPath = NULL;
       
   426             }
       
   427 
       
   428         iDownloadedVcfgPath = aPathName.AllocL();
       
   429 
       
   430         // Clear vcfg received flag
       
   431         SetNotParsedL( iCurrentGroupServiceId );
       
   432 
       
   433         // Send vcfg to provision
       
   434         RApaLsSession ls;
       
   435         error = ls.Connect();
       
   436         if ( error == KErrNone )
       
   437             {
       
   438             // Get UID of application which handles this type of file
       
   439             TUid appUid( TUid::Null() );
       
   440             TDataType dataType( appUid );
       
   441             error = ls.AppForDocument( aPathName, appUid, dataType );
       
   442             if ( appUid == KNullUid )
       
   443                 {
       
   444                 error = KErrNotSupported;
       
   445                 }
       
   446 
       
   447             // Start application
       
   448             if ( error == KErrNone )
       
   449                 {
       
   450                 TThreadId id( 0 );
       
   451                 error = ls.StartDocument( aPathName, appUid, id );
       
   452                 }
       
   453 
       
   454             ls.Close();
       
   455             }
       
   456         }
       
   457 
       
   458     if ( error == KErrNone )
       
   459         {
       
   460         // Start timer to wait provision parsing
       
   461         if ( !iVcfgParseTimer )
       
   462             {
       
   463             iVcfgParseTimer =
       
   464                 CIptvTimer::NewL( CActive::EPriorityStandard, *this );
       
   465             }
       
   466 
       
   467         if ( !iVcfgParseTimer->IsActive() )
       
   468             {
       
   469             iVcfgParseTimer->After( KIptvVcfgFileParseWait );
       
   470             }
       
   471 
       
   472         iVcfgParseMaxCount = KIptvVcfgFileParseMaxTry;
       
   473         }
       
   474     else
       
   475         {
       
   476         // Notfy immediately on error case
       
   477         iMsgQueue.SendMessageToClientL(
       
   478             KIptvContentUpdateCompleted,
       
   479             error );
       
   480         iPluginRunning = EFalse;
       
   481         }
       
   482     }
       
   483 
       
   484 // -----------------------------------------------------------------------------
       
   485 // CVcxGroupUpdater::TimerExpired
       
   486 // -----------------------------------------------------------------------------
       
   487 //
       
   488 void CVcxGroupUpdater::TimerExpired( CIptvTimer* aTimer )
       
   489     {
       
   490     IPTVLOGSTRING_LOW_LEVEL( "CVcxGroupUpdater::TimerExpired()" );
       
   491 
       
   492     TRAPD( err, DoTimerExpiredL( aTimer ) );
       
   493     if ( err != KErrNone )
       
   494         {
       
   495         IPTVLOGSTRING2_LOW_LEVEL(
       
   496             "CVcxGroupUpdater::DoTimerExpiredL leaved (%d)",
       
   497             err );
       
   498         }
       
   499     }
       
   500 
       
   501 // -----------------------------------------------------------------------------
       
   502 // CVcxGroupUpdater::DoTimerExpiredL
       
   503 // -----------------------------------------------------------------------------
       
   504 //
       
   505 void CVcxGroupUpdater::DoTimerExpiredL( CIptvTimer* aTimer )
       
   506     {
       
   507     IPTVLOGSTRING_LOW_LEVEL( "CVcxGroupUpdater::DoTimerExpiredL()" );
       
   508 
       
   509     // %% How about parse really failed...
       
   510     if ( aTimer == iVcfgParseTimer )
       
   511         {
       
   512         TBool completed( EFalse );
       
   513 
       
   514         if ( iLocalValid )
       
   515             {
       
   516             // Parsing not needed.
       
   517             completed = ETrue;
       
   518             iLocalValid = EFalse;
       
   519             StartThumbnailDownloadL();
       
   520             }
       
   521         else if ( IsServiceParsed( iCurrentGroupServiceId ) )
       
   522             {
       
   523             // Parsing complete.
       
   524             iMsgQueue.SendMessageToClientL(
       
   525                 KIptvContentUpdateCompleted,
       
   526                 KErrNone );
       
   527             completed = ETrue;
       
   528             StartThumbnailDownloadL();
       
   529             }
       
   530         else if ( 0 < iVcfgParseMaxCount-- )
       
   531             {
       
   532             // Continue to wait parsing complete.
       
   533             if ( !iVcfgParseTimer->IsActive() )
       
   534                 {
       
   535                 iVcfgParseTimer->After( KIptvVcfgFileParseWait );
       
   536                 }
       
   537             }
       
   538         else
       
   539             {
       
   540             IPTVLOGSTRING_LOW_LEVEL(
       
   541                 "CVcxGroupUpdater:: NotifySingleFileDownloadCompleteL timeout" );
       
   542             iMsgQueue.SendMessageToClientL(
       
   543                 KIptvErrorEpgUpdateFailed,
       
   544                 KIptvRssParserError );
       
   545             completed = ETrue;
       
   546             iPluginRunning = EFalse;
       
   547             }
       
   548 
       
   549         // Parsed file is no more needed, so delete it.
       
   550         if ( completed && iDownloadedVcfgPath )
       
   551             {
       
   552             if ( BaflUtils::FileExists( iFs, iDownloadedVcfgPath->Des() ) )
       
   553                 {
       
   554                 iFs.Delete( iDownloadedVcfgPath->Des() );
       
   555                 }
       
   556 
       
   557             delete iDownloadedVcfgPath;
       
   558             iDownloadedVcfgPath = NULL;
       
   559             }
       
   560         }
       
   561     }
       
   562 
       
   563 // ---------------------------------------------------------------------------
       
   564 // Initialize VCFG provision done flag.
       
   565 // ---------------------------------------------------------------------------
       
   566 //
       
   567 void CVcxGroupUpdater::SetNotParsedL(
       
   568     TUint32 aServiceId )
       
   569     {
       
   570     IPTVLOGSTRING_HIGH_LEVEL( "CVcxGroupUpdater::SetNotParsedL" );
       
   571 
       
   572     // Set parsing status of service.
       
   573     CIptvService* service( NULL );
       
   574     service = iServer.iServiceManager->GetServiceL(
       
   575         aServiceId, ETrue /* do open/close */ );
       
   576     if ( service )
       
   577         {
       
   578         CleanupStack::PushL( service );  // 1->
       
   579         service->SetFlags(
       
   580             service->GetFlags() & ~CIptvService::EGroupReceived );
       
   581         iServer.iServiceManager->UpdateServiceL( *service );
       
   582         CleanupStack::PopAndDestroy( service ); //<-1
       
   583         }
       
   584     }
       
   585 
       
   586 // ---------------------------------------------------------------------------
       
   587 // Indication of VCFG file download completion.
       
   588 // ---------------------------------------------------------------------------
       
   589 //
       
   590 TBool CVcxGroupUpdater::IsServiceParsed(
       
   591     TUint32 aServiceId )
       
   592     {
       
   593     IPTVLOGSTRING_HIGH_LEVEL( "CVcxGroupUpdater::IsServiceParsed" );
       
   594 
       
   595     TBool parsed( EFalse );
       
   596 
       
   597     // Get parsing status of service.
       
   598     CIptvService* service( NULL );
       
   599     TRAPD( err, service = iServer.iServiceManager->GetServiceL(
       
   600         aServiceId, ETrue /* do open/close */ ) );
       
   601     if ( service )
       
   602         {
       
   603         if ( KErrNone == err )
       
   604             {
       
   605             parsed = ( service->GetFlags() & CIptvService::EGroupReceived ) > 0;
       
   606             }
       
   607 
       
   608         delete service;
       
   609         }
       
   610 
       
   611     return parsed;
       
   612     }
       
   613 
       
   614 // ---------------------------------------------------------------------------
       
   615 // Set service Last Modified.
       
   616 // ---------------------------------------------------------------------------
       
   617 //
       
   618 void CVcxGroupUpdater::SetLastModifiedL(
       
   619     TUint32 aServiceId,
       
   620     TTime aLastModified )
       
   621     {
       
   622     IPTVLOGSTRING_HIGH_LEVEL( "CVcxGroupUpdater::SetLastModifiedL" );
       
   623 
       
   624     CIptvService* service( NULL );
       
   625     service = iServer.iServiceManager->GetServiceL(
       
   626         aServiceId, ETrue /* do open/close */ );
       
   627     if ( service )
       
   628         {
       
   629         CleanupStack::PushL( service );  // 1->
       
   630         service->SetEpgUpdateTimeL( aLastModified );
       
   631         iServer.iServiceManager->UpdateServiceL( *service );
       
   632         CleanupStack::PopAndDestroy( service ); //<-1
       
   633         }
       
   634     }
       
   635 
       
   636 // ---------------------------------------------------------------------------
       
   637 // Collect list of required thumbnails and start download.
       
   638 // ---------------------------------------------------------------------------
       
   639 //
       
   640 void CVcxGroupUpdater::StartThumbnailDownloadL()
       
   641     {
       
   642     if ( iPlugin )
       
   643         {
       
   644         // Service group thumbnail
       
   645         TUint32 groupId( 0 );
       
   646         TInt thumbnailCount( 0 );
       
   647         CIptvService* tempService = iServer.iServiceManager->GetServiceL(
       
   648             iCurrentGroupServiceId, ETrue /* do open/close */ );
       
   649         if ( tempService )
       
   650             {
       
   651             CleanupStack::PushL( tempService );// 1->
       
   652 
       
   653             CIptvEpgService* service = CIptvEpgService::NewL();
       
   654             CleanupStack::PushL( service ); // 2->
       
   655             service->iAddress.Copy( tempService->GetIconUrl() );
       
   656             service->iServiceId = tempService->GetId();
       
   657 
       
   658             thumbnailCount++;
       
   659             groupId = tempService->GetGroupId();
       
   660             iPlugin->SetServiceInformationL(
       
   661                 service,
       
   662                 CIptvEpgPluginInterface::EIptvRssAddServiceThumbnailToDlQueue );
       
   663 
       
   664             CleanupStack::PopAndDestroy( service ); //<-2
       
   665             CleanupStack::PopAndDestroy( tempService ); //<-1
       
   666             }
       
   667 
       
   668         iCurrentAction =
       
   669             CIptvEpgPluginInterface::EIptvRssAddServiceThumbnailToDlQueue;
       
   670         // For each sub service thumbnail
       
   671         CIptvServices* services = iServer.iServiceManager->GetServicesL(
       
   672             CIptvServiceManagementClient::EGroupedServices,
       
   673             CIptvServiceManagementClient::EDisplayOrderDescending,
       
   674             0 /*Latest*/ );
       
   675         if ( services )
       
   676             {
       
   677             CleanupStack::PushL( services ); // 1->
       
   678 
       
   679             // Find all services matching to group.
       
   680             for ( TInt i( services->Count() - 1 ); i >= 0 ; i-- )
       
   681                 {
       
   682                 tempService = services->GetServiceL( i );
       
   683                 CleanupStack::PushL( tempService ); // 2->
       
   684 
       
   685                 // Verify group id
       
   686                 if ( groupId == tempService->GetGroupId() )
       
   687                     {
       
   688                     CIptvEpgService* service = CIptvEpgService::NewL();
       
   689                     CleanupStack::PushL( service ); // 3->
       
   690                     service->iAddress.Copy( tempService->GetIconUrl() );
       
   691                     service->iServiceId = tempService->GetId();
       
   692 
       
   693                     thumbnailCount++;
       
   694                     iPlugin->SetServiceInformationL(
       
   695                         service,
       
   696                         CIptvEpgPluginInterface::EIptvRssAddItemThumbnailToDlQueue );
       
   697 
       
   698                     CleanupStack::PopAndDestroy( service ); //<-3
       
   699                     }
       
   700 
       
   701                 CleanupStack::PopAndDestroy( tempService ); //<-2
       
   702                 }
       
   703 
       
   704             CleanupStack::PopAndDestroy( services ); //<-1
       
   705             }
       
   706 
       
   707         iMsgQueue.SendMessageToClientL( KIptvThumbnailCount, thumbnailCount );
       
   708         iPlugin->RunPlugin();
       
   709         }
       
   710     }