videoplayerapp/mpxvideoplayer/src/mpxvideoplayeriadupdate.cpp
branchRCL_3
changeset 70 375929f879c2
parent 64 3eb824b18d67
child 73 f89a65650939
equal deleted inserted replaced
64:3eb824b18d67 70:375929f879c2
     1 /*
       
     2 * Copyright (c) 2004-2010 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:    IAD update handling.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // Version : %version: 1 %
       
    20 
       
    21 #include <iaupdate.h>
       
    22 #include <iaupdateparameters.h>
       
    23 #include <iaupdateresult.h>
       
    24 #include <featmgr.h>
       
    25 #include <mpxviewutility.h>
       
    26 
       
    27 #include "mpxvideoplayeriadupdate.h"
       
    28 #include "mpxvideoplayerconstants.h"
       
    29 #include "mpxvideo_debug.h"
       
    30 
       
    31 const TUid KIadParamUid = { 0x200159B2 }; // Uid of VideoPlayer.sis
       
    32 _LIT( KIadParamExec, "mpxvideoplayer.exe" );
       
    33 
       
    34 
       
    35 // --------------------------------------------------------------------------
       
    36 // Two-phased constructor.
       
    37 // --------------------------------------------------------------------------
       
    38 //
       
    39 CMpxVideoPlayerIadUpdate* CMpxVideoPlayerIadUpdate::NewL( MMPXViewUtility& aViewUtility )
       
    40     {
       
    41     CMpxVideoPlayerIadUpdate* self = new( ELeave ) CMpxVideoPlayerIadUpdate( aViewUtility );
       
    42     CleanupStack::PushL( self );
       
    43     self->ConstructL();
       
    44     CleanupStack::Pop( self );
       
    45     return self;
       
    46     }
       
    47 
       
    48 // --------------------------------------------------------------------------
       
    49 // C++ default constructor can NOT contain any code, that might leave.
       
    50 // --------------------------------------------------------------------------
       
    51 //
       
    52 CMpxVideoPlayerIadUpdate::CMpxVideoPlayerIadUpdate( MMPXViewUtility& aViewUtility )
       
    53   : iUpdate( NULL ), iParameters( NULL ), iViewUtility( aViewUtility )
       
    54     {
       
    55     // None
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // Symbian 2nd phase constructor can leave.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CMpxVideoPlayerIadUpdate::ConstructL()
       
    63     {
       
    64     MPX_ENTER_EXIT( _L("CMpxVideoPlayerIadUpdate::ConstructL()") );
       
    65 
       
    66     if( FeatureManager::FeatureSupported( KFeatureIdIAUpdate ) )
       
    67         {
       
    68         iUpdate = CIAUpdate::NewL( *this );
       
    69         iParameters = CIAUpdateParameters::NewL();
       
    70         }
       
    71     else
       
    72         {
       
    73         MPX_DEBUG(_L("CMpxVideoPlayerIadUpdate::ConstructL(), Feature not supported"));
       
    74         }
       
    75     }
       
    76 
       
    77 // --------------------------------------------------------------------------
       
    78 // Destructor
       
    79 // --------------------------------------------------------------------------
       
    80 //
       
    81 CMpxVideoPlayerIadUpdate::~CMpxVideoPlayerIadUpdate()
       
    82     {
       
    83     Delete();
       
    84     }
       
    85 
       
    86 // --------------------------------------------------------------------------
       
    87 // Starts update process.
       
    88 // --------------------------------------------------------------------------
       
    89 //
       
    90 void CMpxVideoPlayerIadUpdate::StartL()
       
    91     {
       
    92     MPX_ENTER_EXIT( _L("CMpxVideoPlayerIadUpdate::StartL()") );
       
    93 
       
    94     if( iUpdate && iParameters )
       
    95         {
       
    96         iParameters->SetUid( KIadParamUid );
       
    97         // We want Videos to be started after update is finished
       
    98         iParameters->SetCommandLineExecutableL( KIadParamExec );
       
    99         iParameters->SetShowProgress( EFalse );
       
   100     
       
   101         // Check the updates
       
   102         iUpdate->CheckUpdates( *iParameters );
       
   103         }
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // 
       
   108 // -----------------------------------------------------------------------------
       
   109 //  
       
   110 void CMpxVideoPlayerIadUpdate::CheckUpdatesComplete( TInt aErrorCode, TInt aAvailableUpdates )
       
   111     {
       
   112     MPX_ENTER_EXIT( _L("CMpxVideoPlayerIadUpdate::CheckUpdatesComplete()"), 
       
   113         _L("aErrorCode: %d, aAvailableUpdates: %d"), aErrorCode, aAvailableUpdates );
       
   114 
       
   115     if ( aErrorCode == KErrNone )
       
   116         {
       
   117         if ( aAvailableUpdates > 0 && iViewUtility.ActiveViewType() == KUidMyVideosViewType )
       
   118             {
       
   119             // There were some updates available and video list is active.
       
   120             iUpdate->UpdateQuery();
       
   121             }
       
   122         else
       
   123             {
       
   124             // No updates available or playback ongoing.
       
   125             Delete();
       
   126             }
       
   127         }
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // 
       
   132 // -----------------------------------------------------------------------------
       
   133 //  
       
   134 void CMpxVideoPlayerIadUpdate::UpdateComplete( TInt aErrorCode, CIAUpdateResult* aResult )
       
   135     {
       
   136     MPX_ENTER_EXIT( _L("CMpxVideoPlayerIadUpdate::UpdateComplete()"), 
       
   137         _L("aErrorCode: %d, SuccessCount: %d"), aErrorCode, aResult->SuccessCount() );
       
   138 
       
   139     delete aResult; // Ownership was transferred, so this must be deleted by the client
       
   140 
       
   141     // We do not need the client-server session anymore
       
   142     Delete();
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // 
       
   147 // -----------------------------------------------------------------------------
       
   148 //  
       
   149 void CMpxVideoPlayerIadUpdate::UpdateQueryComplete( TInt aErrorCode, TBool aUpdateNow )
       
   150     {
       
   151     MPX_ENTER_EXIT( _L("CMpxVideoPlayerIadUpdate::UpdateQueryComplete()"),
       
   152         _L("aErrorCode: %d, aUpdateNow: %d"), aErrorCode, aUpdateNow );
       
   153 
       
   154     if ( aErrorCode == KErrNone )
       
   155         {
       
   156         if ( aUpdateNow )
       
   157             {
       
   158             // User choosed to update now, so let's launch the IAUpdate UI.
       
   159             iUpdate->ShowUpdates( *iParameters );
       
   160             }
       
   161         else
       
   162             {
       
   163             // The answer was 'Later'. 
       
   164             Delete();
       
   165             }
       
   166         }
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // 
       
   171 // -----------------------------------------------------------------------------
       
   172 //  
       
   173 void CMpxVideoPlayerIadUpdate::Delete()
       
   174     {
       
   175     if ( iUpdate )
       
   176         {
       
   177         delete iUpdate;
       
   178         iUpdate = NULL;
       
   179         }
       
   180     if ( iParameters )
       
   181         {
       
   182         delete iParameters; 
       
   183         iParameters = NULL;
       
   184         }
       
   185     }
       
   186