homescreenplugins/videochplugin/src/videocontentharvesterplugin.cpp
changeset 0 96612d01cf9f
child 1 6711b85517b7
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:    CVcxNsContentHarvesterPlugin class definition*
       
    15 */
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <e32std.h>
       
    20 #include <e32def.h>
       
    21 #include <e32cmn.h>
       
    22 
       
    23 #include <LiwServiceHandler.h>
       
    24 #include <LiwVariant.h>
       
    25 #include <LiwGenericParam.h>
       
    26 
       
    27 #include <vcxmyvideosdefs.h>
       
    28 #include <vcxmyvideosuids.h>
       
    29 
       
    30 #include <mpxcommandgeneraldefs.h>
       
    31 
       
    32 #include "IptvDebug.h"
       
    33 
       
    34 
       
    35 #include "videocontentharvesterplugin.h"
       
    36 #include "videocontentharvestermpxclient.h"
       
    37 #include "videocontentharvesterservicelistener.h"
       
    38 #include "videonotificationlauncher.h"
       
    39 #include "videochpublishabledata.h"
       
    40 #include "videochpublisher.h"
       
    41 #include "vcxnsmediatorids.h"
       
    42 #include "videochmcategorylistener.h"
       
    43 #include "videochiptvserverclient.h"
       
    44 #include "videochlastwatchedupdater.h"
       
    45 #include "iptvlastwatchedapi.h"
       
    46 #include "iptvlastwatcheddata.h"
       
    47 
       
    48 // ============================ MEMBER FUNCTIONS ==============================
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // Constructor
       
    52 // ----------------------------------------------------------------------------
       
    53 //
       
    54 CVcxNsContentHarvesterPlugin::CVcxNsContentHarvesterPlugin( MLiwInterface* aCPSInterface ) :
       
    55     iCPSInterface( aCPSInterface )
       
    56     {
       
    57     }
       
    58 
       
    59 // ----------------------------------------------------------------------------
       
    60 // Symbian 2nd phase constructor can leave.
       
    61 // ----------------------------------------------------------------------------
       
    62 //
       
    63 void CVcxNsContentHarvesterPlugin::ConstructL()
       
    64     {
       
    65     IPTVLOGSTRING_LOW_LEVEL("CVcxNsContentHarvesterPlugin::ConstructL IN");
       
    66     
       
    67     iPublishableData = CVcxNsChPublishableData::NewL();
       
    68     
       
    69     iPublisher = CVcxNsChPublisher::NewL( iCPSInterface, iPublishableData );
       
    70 
       
    71     iMpxClient = CVcxNsContentHarvesterMpxClient::NewL( iPublisher, iPublishableData, this );
       
    72 
       
    73     iServiceListener = CVcxNsContentHarvesterServiceListener::NewL( iPublisher, iPublishableData );
       
    74 
       
    75     iNotificationLauncer = CVcxNsNotificationLauncher::NewL( iPublishableData, iPublisher );
       
    76     
       
    77     iLwUpdater = CVcxNsChLastWatchedUpdater::NewL( iPublishableData, iPublisher );
       
    78     
       
    79     iIptvServerClient = CVcxNsChIptvServerClient::NewL( iPublisher, iPublishableData );
       
    80     
       
    81     IPTVLOGSTRING_LOW_LEVEL("CVcxNsContentHarvesterPlugin::ConstructL OUT");
       
    82     }
       
    83 
       
    84 // ----------------------------------------------------------------------------
       
    85 // Two-phased constructor.
       
    86 // ----------------------------------------------------------------------------
       
    87 //
       
    88 CVcxNsContentHarvesterPlugin* CVcxNsContentHarvesterPlugin::NewL(  MLiwInterface* aCPSInterface )
       
    89     {
       
    90     CVcxNsContentHarvesterPlugin* self = new ( ELeave ) CVcxNsContentHarvesterPlugin( 
       
    91                                                                              aCPSInterface );
       
    92     CleanupStack::PushL( self );
       
    93     self->ConstructL();
       
    94     CleanupStack::Pop( self );
       
    95     return self;
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // Destructor
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 CVcxNsContentHarvesterPlugin::~CVcxNsContentHarvesterPlugin()
       
   103     {
       
   104     delete iIptvServerClient;
       
   105     delete iLwUpdater;      
       
   106     delete iNotificationLauncer;    
       
   107     delete iServiceListener;   
       
   108     delete iMpxClient; 
       
   109     delete iPublisher;
       
   110     delete iPublishableData;
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // CVcxNsContentHarvesterPlugin::UpdateL() 
       
   115 // ----------------------------------------------------------------------------
       
   116 //    
       
   117 void CVcxNsContentHarvesterPlugin::UpdateL() 
       
   118     {
       
   119     IPTVLOGSTRING_LOW_LEVEL("CVcxNsContentHarvesterPlugin::UpdateL in");
       
   120     // check and update data content that needs refreshing during boot.
       
   121     // in case something fails, there's nothing to do
       
   122     
       
   123     // last watched  
       
   124     UpdateLastWatchedL();
       
   125     
       
   126     // preloaded video
       
   127     UpdatePreloadedVideoL();
       
   128     
       
   129     // predefined service group
       
   130     iIptvServerClient->StartIPTVServerInterfaceL();
       
   131     TRAPD( err, UpdatePredefinedServiceL() );
       
   132     iIptvServerClient->StopIPTVServerInterface();
       
   133     User::LeaveIfError( err );
       
   134 
       
   135     IPTVLOGSTRING_LOW_LEVEL("CVcxNsContentHarvesterPlugin::UpdateL out");
       
   136     }
       
   137 
       
   138 // ----------------------------------------------------------------------------
       
   139 // CVcxNsContentHarvesterPlugin::UpdateLastWatchedL()        
       
   140 // ----------------------------------------------------------------------------
       
   141 //    
       
   142 void CVcxNsContentHarvesterPlugin::UpdateLastWatchedL()
       
   143     {
       
   144     iPublisher->ReadContentL( EVCxNsCPContentLastWatched );
       
   145         
       
   146     TPtrC name = iPublishableData->GetDesCDataL( EVCxNsCPContentLastWatched,
       
   147                                                     TPtrC8( KTvVideoName ) );
       
   148     TInt lastWType = 
       
   149                     iPublishableData->GetIntDataL( EVCxNsCPContentLastWatched,
       
   150                                                      TPtrC8( KTvVideoLastWatchedType ) );
       
   151         
       
   152     if( name.Length() > 0 && lastWType == EVCxNsCPContentLastWatched )
       
   153         {
       
   154         // check last watched from the filesystem
       
   155         CIptvLastWatchedData* data = CIptvLastWatchedData::NewL();
       
   156         CleanupStack::PushL( data );
       
   157         iPublishableData->LastWatchedApi().GetLastWatchedDataL( *data );
       
   158 		
       
   159         if( data->MpxId() != KIdUndefined &&
       
   160             !iPublishableData->FileExists( data->Uri() ) )
       
   161             {
       
   162             // clear and publish empty content
       
   163             iPublishableData->ClearData( EVCxNsCPContentLastWatched );
       
   164             iPublisher->PublishContentL( EVCxNsCPContentLastWatched );
       
   165             }
       
   166         CleanupStack::PopAndDestroy( data );
       
   167         }
       
   168     else
       
   169         {
       
   170         // clear and publish empty content
       
   171         iPublishableData->ClearData( EVCxNsCPContentLastWatched );
       
   172         iPublisher->PublishContentL( EVCxNsCPContentLastWatched );
       
   173         }         
       
   174     }
       
   175         
       
   176 // ----------------------------------------------------------------------------
       
   177 // CVcxNsContentHarvesterPlugin::UpdatePreloadedVideoL()        
       
   178 // ----------------------------------------------------------------------------
       
   179 // 
       
   180 void CVcxNsContentHarvesterPlugin::UpdatePreloadedVideoL()
       
   181     {
       
   182     // read preloaded content from the CP and from the filesystem  
       
   183     iPublisher->ReadContentL( EVCxNsCPContentPreloaded );
       
   184     
       
   185     TPtrC preName = 
       
   186                 iPublishableData->GetDesCDataL( EVCxNsCPContentPreloaded,
       
   187                                                 TPtrC8( KTvVideoName ) ); 
       
   188     TPtrC prePath =
       
   189                 iPublishableData->GetDesCDataL( EVCxNsCPContentPreloaded,
       
   190                                                 TPtrC8( KTvVideoPath ) ); 
       
   191     
       
   192     if( preName.Length() == 0 || 
       
   193         !iPublishableData->FileExists( prePath ) ) 
       
   194         {
       
   195         // file does not exists, remove it's data from the CP so
       
   196         // that item is not shown
       
   197         iPublisher->DeleteContentL( EVCxNsCPContentPreloaded );
       
   198         }              
       
   199     }
       
   200         
       
   201 // ----------------------------------------------------------------------------
       
   202 // CVcxNsContentHarvesterPlugin::UpdatePredefinedServiceL()        
       
   203 // ----------------------------------------------------------------------------
       
   204 // 
       
   205 void CVcxNsContentHarvesterPlugin::UpdatePredefinedServiceL()
       
   206     {
       
   207     iPublisher->ReadContentL( EVCxNsCPContentServiceGroup );
       
   208 
       
   209     TPtrC serviceUri = iPublishableData->GetDesCDataL( EVCxNsCPContentServiceGroup,
       
   210                                                                 TPtrC8( KTvVideoPath ) ); 
       
   211     TInt id = iIptvServerClient->GetServiceGroupIdL( serviceUri ); 
       
   212         
       
   213     if(id != KErrNotFound )
       
   214         {                 
       
   215         // save ID and publish
       
   216         iPublishableData->SetDataL( EVCxNsCPContentServiceGroup,
       
   217                                                 TPtrC8( KTvVideoId ), id);
       
   218         iPublisher->PublishContentL( EVCxNsCPContentServiceGroup );
       
   219         }
       
   220     else 
       
   221         {   
       
   222         // Restore backed up data
       
   223         iPublisher->RestoreBackupL( EVCxNsCPContentServiceGroup );            
       
   224         }
       
   225     }
       
   226     
       
   227 // ----------------------------------------------------------------------------
       
   228 // CVcxNsContentHarvesterPlugin::NotificationLauncher()        
       
   229 // ----------------------------------------------------------------------------
       
   230 // 
       
   231 CVcxNsNotificationLauncher* CVcxNsContentHarvesterPlugin::NotificationLauncher()
       
   232     {
       
   233     return iNotificationLauncer;
       
   234     }
       
   235