videocollection/hgmyvideos/src/vcxhgmyvideosvideomodelhandler.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:      UI level handler for video data.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <StringLoader.h>
       
    22 #include <mpxmediageneraldefs.h>
       
    23 #include <mpxmediageneralextdefs.h>
       
    24 #include <mpxmedia.h>
       
    25 #include <mpxmediaarray.h>
       
    26 
       
    27 #include <ganes/HgScroller.h>
       
    28 #include <ganes/HgItem.h>
       
    29 
       
    30 #include <vcxhgmyvideos.rsg>
       
    31 #include <vcxmyvideosdefs.h>
       
    32 #include <MPFileDetailsDialog.h>
       
    33 #include <myvideosindicator.h>
       
    34 #include "IptvDebug.h"
       
    35 
       
    36 #include "vcxhgmyvideosmodel.h"
       
    37 #include "vcxhgmyvideosmainview.h"
       
    38 #include "vcxhgmyvideoscollectionclient.h"
       
    39 #include "vcxhgmyvideosdownloadclient.h"
       
    40 #include "vcxhgmyvideosvideomodelhandler.h"
       
    41 #include "vcxhgmyvideosvideolistimpl.h"
       
    42 #include "vcxhgmyvideosvideodataupdater.h"
       
    43 #include "vcxhgmyvideosdownloadupdater.h"
       
    44 
       
    45 #include "vcxhgmyvideos.hrh"
       
    46 #include "vcxhgmyvideoslistbase.h"
       
    47 #include "vcxhgmyvideosindicatorhelper.h"
       
    48 #include "vcxhgmyvideosvideodetailsdialog.h"
       
    49 #include "vcxhgmyvideosvideolist.h"
       
    50 #include "vcxhgmyvideospanics.h"
       
    51 
       
    52 
       
    53 #include <videoplayercustommessage.h>
       
    54 
       
    55 // CONSTANTS
       
    56 const TUint KVcxSecondsInMinute( 60 );
       
    57 const TUint KVcxSecondsInHour( 3600 );
       
    58 const TUint KVcxVideoSizeGB( 0x40000000 );
       
    59 const TUint KVcxVideoSizeHalfGB( 0x20000000 );
       
    60 const TUint KVcxVideoSizeMB( 0x100000 );
       
    61 const TUint KVcxVideoSizeHalfMB( 0x80000 );
       
    62 const TUint KVcxVideoSizeKB( 0x400 );
       
    63 const TUint KVcxVideoSizeHalfKB( 0x200 ); 
       
    64 
       
    65 const TUint KHgBufferSize( 250 );
       
    66 const TUint KHgBufferTreshold( 50 );
       
    67 
       
    68 // ============================ MEMBER FUNCTIONS ===============================
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CVcxHgMyVideosVideoModelHandler::NewL()
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 CVcxHgMyVideosVideoModelHandler* CVcxHgMyVideosVideoModelHandler::NewL( 
       
    75         CVcxHgMyVideosVideoListImpl& aVideoListImpl,
       
    76         CVcxHgMyVideosModel& aModel,
       
    77         CVcxHgMyVideosMainView& aView,
       
    78         CHgScroller& aScroller )        
       
    79     {
       
    80     CVcxHgMyVideosVideoModelHandler* self = 
       
    81         CVcxHgMyVideosVideoModelHandler::NewLC( 
       
    82             aVideoListImpl, aModel, aView, aScroller );
       
    83     CleanupStack::Pop( self );
       
    84     return self;
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CVcxHgMyVideosVideoModelHandler::NewLC()
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 CVcxHgMyVideosVideoModelHandler* CVcxHgMyVideosVideoModelHandler::NewLC(
       
    92         CVcxHgMyVideosVideoListImpl& aVideoListImpl,
       
    93         CVcxHgMyVideosModel& aModel,
       
    94         CVcxHgMyVideosMainView& aView,
       
    95         CHgScroller& aScroller )        
       
    96     {
       
    97     CVcxHgMyVideosVideoModelHandler* self = 
       
    98         new (ELeave) CVcxHgMyVideosVideoModelHandler( 
       
    99             aVideoListImpl, aModel, aView, aScroller );
       
   100     CleanupStack::PushL( self );
       
   101     self->ConstructL();
       
   102     return self;
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // Constructor
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 CVcxHgMyVideosVideoModelHandler::CVcxHgMyVideosVideoModelHandler(
       
   110         CVcxHgMyVideosVideoListImpl& aVideoListImpl,
       
   111         CVcxHgMyVideosModel& aModel,
       
   112         CVcxHgMyVideosMainView& aView,
       
   113         CHgScroller& aScroller )
       
   114     : iVideoListImpl( aVideoListImpl ),
       
   115       iModel( aModel ),
       
   116       iView( aView ),
       
   117       iScroller( aScroller ),
       
   118       iCurrentCategoryIndex( KErrNotFound ),
       
   119       iRestoreHighlightPosition( EFalse )
       
   120     {
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CVcxHgMyVideosVideoModelHandler::ConstructL()
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 void CVcxHgMyVideosVideoModelHandler::ConstructL()
       
   128     {
       
   129     iVideoArray = CVcxHgMyVideosVideoList::NewL();
       
   130 
       
   131     iDataUpdater = CVcxHgMyVideosVideoDataUpdater::NewL( iModel,
       
   132                                                          iScroller,                                                        
       
   133                                                          *iVideoArray );
       
   134 
       
   135     iDownloadUpdater = CVcxHgMyVideosDownloadUpdater::NewL( *this, *iVideoArray );
       
   136     
       
   137     iVideoIndicator = CMyVideosIndicator::NewL();
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // Destructor
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 CVcxHgMyVideosVideoModelHandler::~CVcxHgMyVideosVideoModelHandler()
       
   145     {
       
   146     iResumeArray.Close();
       
   147     
       
   148     delete iVideoIndicator;
       
   149     delete iDataUpdater;
       
   150     delete iDownloadUpdater;
       
   151     delete iVideoArray;
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CVcxHgMyVideosVideoModelHandler::DoModelActivateL()
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 void CVcxHgMyVideosVideoModelHandler::DoModelActivateL()
       
   159     {
       
   160     IPTVLOGSTRING_LOW_LEVEL( 
       
   161         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::DoModelActivateL() - Enter" );
       
   162     
       
   163     iDataUpdater->SetPausedL( EFalse );
       
   164     iDownloadUpdater->SetPausedL( EFalse );
       
   165     iModel.CollectionClient().SetVideoModelObserver( this );
       
   166 
       
   167     // Set scroller strip type
       
   168     TVcxMyVideosSortingOrder sortOrder = iModel.VideolistSortOrderL();
       
   169     UpdateScrollbarTypeL( sortOrder );
       
   170 
       
   171     // Set up scroll buffer
       
   172     iScroller.EnableScrollBufferL( *this, KHgBufferSize, KHgBufferTreshold ); 
       
   173     
       
   174     IPTVLOGSTRING_LOW_LEVEL( 
       
   175         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::DoModelActivateL() - Exit" );    
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // CVcxHgMyVideosVideoModelHandler::DoModelDeactivate()
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 void CVcxHgMyVideosVideoModelHandler::DoModelDeactivate()
       
   183     {
       
   184     IPTVLOGSTRING_LOW_LEVEL( 
       
   185         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::DoModelDeactivate() - Enter" );
       
   186     
       
   187     TRAP_IGNORE( iDataUpdater->SetPausedL( ETrue ) );
       
   188     TRAP_IGNORE( iDownloadUpdater->SetPausedL( ETrue ) );
       
   189     iModel.CollectionClient().SetVideoModelObserver( NULL );
       
   190     iScroller.DisableScrollBuffer();
       
   191     
       
   192     TRAP_IGNORE( SaveHighlightedItemIdL() );
       
   193     
       
   194     IPTVLOGSTRING_LOW_LEVEL( 
       
   195         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::DoModelDeactivate() - Exit" );    
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CVcxHgMyVideosVideoModelHandler::SaveHighlightedItemIdL()
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 void CVcxHgMyVideosVideoModelHandler::SaveHighlightedItemIdL()
       
   203     {    
       
   204     iHighlightedItemId = iVideoArray->ArrayIndexToMpxItemIdL( Highlight() );
       
   205     }
       
   206 
       
   207 // -----------------------------------------------------------------------------
       
   208 // CVcxHgMyVideosVideoModelHandler::UpdateVideoListL()
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 void CVcxHgMyVideosVideoModelHandler::UpdateVideoListL( TInt aCategoryIndex )
       
   212     {
       
   213     IPTVLOGSTRING_LOW_LEVEL( 
       
   214         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::UpdateVideoListL() - Enter" );
       
   215 
       
   216     CVcxHgMyVideosCollectionClient& collectionClient = iModel.CollectionClient();
       
   217 
       
   218     // If we are re-opening the same video list again, then try 
       
   219     // restore the highlight to previous position.
       
   220     aCategoryIndex == iCurrentCategoryIndex ? iRestoreHighlightPosition = ETrue :
       
   221                                               iRestoreHighlightPosition = EFalse;
       
   222     // Removes videos from video list.
       
   223     iVideoArray->RemoveVideoList();
       
   224          
       
   225     // Removes videos from scroller. After this command, list highlight 
       
   226     // disappears, so don't forget to set highlight in NewVideoListL() 
       
   227     // function.
       
   228     iScroller.Reset();
       
   229         
       
   230     // Ask for video list from MPX collection.
       
   231     collectionClient.GetVideoListL( aCategoryIndex );
       
   232 
       
   233     iCurrentCategoryIndex = aCategoryIndex;
       
   234     
       
   235     IPTVLOGSTRING_LOW_LEVEL( 
       
   236         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::UpdateVideoListL() - Exit" );    
       
   237     }
       
   238 
       
   239 // -----------------------------------------------------------------------------
       
   240 // CVcxHgMyVideosVideoModelHandler::ResortVideoListL()
       
   241 // -----------------------------------------------------------------------------
       
   242 //
       
   243 void CVcxHgMyVideosVideoModelHandler::ResortVideoListL()
       
   244     {    
       
   245     IPTVLOGSTRING_LOW_LEVEL( 
       
   246         "MPX My Videos UI # ResortVideoListL() - Enter" );
       
   247         	
       
   248     if ( iScroller.ItemCount() > 0 )
       
   249         {
       
   250         iDownloadUpdater->SetPausedL( ETrue );
       
   251     	
       
   252         TVcxMyVideosSortingOrder sortOrder = iModel.VideolistSortOrderL();
       
   253         iVideoArray->ResortVideoListL( sortOrder );
       
   254         
       
   255         TInt highlight = iScroller.SelectedIndex();
       
   256         
       
   257         // It is enough to reset scroll buffer only, not whole scroller
       
   258         iScroller.DisableScrollBuffer();
       
   259         iScroller.EnableScrollBufferL( *this, KHgBufferSize, KHgBufferTreshold );
       
   260         
       
   261         iScroller.SetSelectedIndex( highlight );
       
   262         
       
   263         iView.DynInitMskL();
       
   264     	
       
   265         iDownloadUpdater->VideoArrayChangedL();
       
   266         iDownloadUpdater->SetPausedL( EFalse );
       
   267 
       
   268         // Switch to appropriate scroller strip
       
   269         UpdateScrollbarTypeL( sortOrder );
       
   270         }
       
   271         IPTVLOGSTRING_LOW_LEVEL( 
       
   272             "MPX My Videos UI # ResortVideoListL() - Exit" );
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CVcxHgMyVideosVideoModelHandler::Highlight()
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 TInt CVcxHgMyVideosVideoModelHandler::Highlight()
       
   280     {
       
   281     return iScroller.SelectedIndex();
       
   282     }
       
   283 
       
   284 // -----------------------------------------------------------------------------
       
   285 // CVcxHgMyVideosVideoModelHandler::VideoCount()
       
   286 // -----------------------------------------------------------------------------
       
   287 //
       
   288 TInt CVcxHgMyVideosVideoModelHandler::VideoCount()
       
   289     {
       
   290     return iScroller.ItemCount();
       
   291     }
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CVcxHgMyVideosVideoModelHandler::CurrentCategoryIndex() 
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 TInt CVcxHgMyVideosVideoModelHandler::CurrentCategoryIndex()
       
   298     {
       
   299     return iCurrentCategoryIndex;
       
   300     }
       
   301 
       
   302 // -----------------------------------------------------------------------------
       
   303 // CVcxHgMyVideosVideoModelHandler::MarkedVideosL()
       
   304 // -----------------------------------------------------------------------------
       
   305 //
       
   306 void CVcxHgMyVideosVideoModelHandler::MarkedVideosL( 
       
   307         RArray<TInt>& aMarkedVideos )
       
   308     {
       
   309     iScroller.GetMarkedItemsL( aMarkedVideos );
       
   310     }
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // CVcxHgMyVideosVideoModelHandler::OngoingDownloads()
       
   314 // -----------------------------------------------------------------------------
       
   315 //
       
   316 void CVcxHgMyVideosVideoModelHandler::OngoingDownloads(
       
   317         RArray<TInt>& aDownloads )
       
   318     {
       
   319     iVideoArray->GetOngoingDownloads( aDownloads );
       
   320     }
       
   321 
       
   322 // -----------------------------------------------------------------------------
       
   323 // CVcxHgMyVideosVideoModelHandler::VideoDownloadState()
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 TVcxMyVideosDownloadState CVcxHgMyVideosVideoModelHandler::VideoDownloadState( 
       
   327         TInt aIndex )
       
   328     {
       
   329     return iVideoArray->VideoDownloadState( aIndex );
       
   330     }
       
   331 
       
   332 // -----------------------------------------------------------------------------
       
   333 // CVcxHgMyVideosVideoModelHandler::IsProgressivePlayPossible()
       
   334 // -----------------------------------------------------------------------------
       
   335 //
       
   336 TBool CVcxHgMyVideosVideoModelHandler::IsProgressivePlayPossible( TInt aIndex )
       
   337     {
       
   338     return iDownloadUpdater->IsPlayPossible( aIndex );
       
   339     }
       
   340 
       
   341 // -----------------------------------------------------------------------------
       
   342 // CVcxHgMyVideosVideoModelHandler::HandleMarkCommandL()
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 void CVcxHgMyVideosVideoModelHandler::HandleMarkCommandL( TInt aMarkCommand )
       
   346     {
       
   347     switch ( aMarkCommand )
       
   348         {
       
   349         case EVcxHgMyVideosCmdMark:
       
   350             {
       
   351             TInt highlight = Highlight();
       
   352             iScroller.Mark( highlight );
       
   353             iScroller.RefreshScreen( highlight );
       
   354             }
       
   355             break;
       
   356         case EVcxHgMyVideosCmdUnmark:
       
   357             {
       
   358             TInt highlight = Highlight();
       
   359             iScroller.UnMark( highlight );
       
   360             iScroller.RefreshScreen( highlight );
       
   361             }            
       
   362             break;
       
   363         case EVcxHgMyVideosCmdMarkAll:
       
   364             {
       
   365             iScroller.MarkAll();
       
   366             }
       
   367             break;
       
   368         case EVcxHgMyVideosCmdUnmarkAll:
       
   369             {
       
   370             iScroller.UnMarkAll();
       
   371             }
       
   372             break;
       
   373         default:
       
   374             {
       
   375             IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # HandleMarkCommandL - LEAVE: Invalid mark command" );
       
   376             User::Leave( KErrNotSupported );
       
   377             }
       
   378             break;
       
   379         }
       
   380     }
       
   381 
       
   382 // -----------------------------------------------------------------------------
       
   383 // CVcxHgMyVideosVideoModelHandler::GetVideoPlayerCustomMessage()
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 TInt CVcxHgMyVideosVideoModelHandler::GetVideoPlayerCustomMessage(
       
   387         TInt aIndex, TVideoPlayerCustomMessage& aVideoInfo, TInt& aMpxId1 )
       
   388     {
       
   389     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   390 
       
   391     if ( ( ! media ) || ( ! media->IsSupported( KMPXMediaGeneralId ) ) )
       
   392         {
       
   393         return KErrNotFound;
       
   394         }
       
   395     
       
   396     TMPXItemId mpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
       
   397     
       
   398     if ( GetVideoPlayerCustomMessage( mpxItemId, aVideoInfo ) != KErrNone )
       
   399         {
       
   400         return KErrNotFound;
       
   401         }
       
   402 		
       
   403     aMpxId1 = ( media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ).iId1;
       
   404 
       
   405     return KErrNone;
       
   406     }
       
   407 
       
   408 // -----------------------------------------------------------------------------
       
   409 // CVcxHgMyVideosVideoModelHandler::GetVideoPlayerCustomMessage()
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 TInt CVcxHgMyVideosVideoModelHandler::GetVideoPlayerCustomMessage(
       
   413         TMPXItemId& aMpxItemId, TVideoPlayerCustomMessage& aVideoInfo )
       
   414     {
       
   415     CMPXMedia* media = iVideoArray->MPXMediaByMPXItemId( aMpxItemId );
       
   416 
       
   417     if ( ! media )
       
   418         {
       
   419         return KErrNotFound;
       
   420         }
       
   421 
       
   422     if ( media->IsSupported( KMPXMediaGeneralUri ) )
       
   423         {
       
   424         aVideoInfo.iContent = media->ValueText( KMPXMediaGeneralUri );
       
   425         }
       
   426 
       
   427     if ( media->IsSupported( KMPXMediaGeneralTitle ) )
       
   428         {
       
   429         aVideoInfo.iName = media->ValueText( KMPXMediaGeneralTitle );
       
   430         }
       
   431 
       
   432     if ( media->IsSupported( KMPXMediaGeneralThumbnail1 ) )
       
   433         {
       
   434         aVideoInfo.iIcon = media->ValueText( KMPXMediaGeneralThumbnail1 );
       
   435         }
       
   436 
       
   437     return KErrNone;
       
   438     }
       
   439 
       
   440 // -----------------------------------------------------------------------------
       
   441 // CVcxHgMyVideosVideoModelHandler::VideoAgeProfileL()
       
   442 // -----------------------------------------------------------------------------
       
   443 //
       
   444 TInt32 CVcxHgMyVideosVideoModelHandler::VideoAgeProfileL( TInt aIndex )
       
   445     {
       
   446     return VideoAgeProfileL( iVideoArray->MPXMedia( aIndex ) );
       
   447     }
       
   448 
       
   449 // -----------------------------------------------------------------------------
       
   450 // CVcxHgMyVideosVideoModelHandler::VideoAgeProfileL()
       
   451 // -----------------------------------------------------------------------------
       
   452 //
       
   453 TInt32 CVcxHgMyVideosVideoModelHandler::VideoAgeProfileL( TMPXItemId aId )
       
   454     {
       
   455     return VideoAgeProfileL( iVideoArray->MPXMediaByMPXItemId( aId ) );
       
   456     }
       
   457 
       
   458 // -----------------------------------------------------------------------------
       
   459 // CVcxHgMyVideosVideoModelHandler::VideoAgeProfileL()
       
   460 // -----------------------------------------------------------------------------
       
   461 //
       
   462 TInt32 CVcxHgMyVideosVideoModelHandler::VideoAgeProfileL( CMPXMedia* aMedia )
       
   463     {
       
   464     TInt32 ageProfile( 0 );
       
   465 
       
   466     if ( aMedia )
       
   467         {
       
   468         if ( aMedia->IsSupported( KVcxMediaMyVideosAgeProfile ) )
       
   469             {
       
   470             ageProfile = aMedia->ValueTObjectL<TInt32>( KVcxMediaMyVideosAgeProfile );
       
   471             }
       
   472         }
       
   473     
       
   474     return ageProfile;
       
   475     }
       
   476 
       
   477 // -----------------------------------------------------------------------------
       
   478 // CVcxHgMyVideosVideoModelHandler::FindVideoMpxIdL()
       
   479 // Tries to find MPX Item Id based on URI. Does not modify MPX Item Id's initial
       
   480 // value if video not found.
       
   481 // -----------------------------------------------------------------------------
       
   482 //
       
   483 TBool CVcxHgMyVideosVideoModelHandler::FindVideoMpxIdL( const TDesC& aVideoPath,
       
   484                                                         TMPXItemId& aMpxItemId )
       
   485     {
       
   486     CMPXMedia* media = iVideoArray->MPXMediaByUri( aVideoPath );
       
   487     if ( media )
       
   488         {
       
   489         if ( media->IsSupported( KMPXMediaGeneralId ) )
       
   490             {
       
   491             aMpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
       
   492             return ETrue;
       
   493             }
       
   494         }
       
   495     return EFalse;
       
   496     }
       
   497 
       
   498 // -----------------------------------------------------------------------------
       
   499 // CVcxHgMyVideosVideoModelHandler::ClearNewVideoIndicatorL()
       
   500 // Informative call about video being played. Method removes possible new indicator
       
   501 // from video.
       
   502 // -----------------------------------------------------------------------------
       
   503 //
       
   504 void CVcxHgMyVideosVideoModelHandler::ClearNewVideoIndicatorL( TInt aIndex )
       
   505     {
       
   506     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   507 
       
   508     if ( media )
       
   509         {
       
   510         if ( media->IsSupported( KMPXMediaGeneralFlags ) &&
       
   511              media->IsSupported( KMPXMediaGeneralId ) )
       
   512             {
       
   513             TUint32 flags = media->ValueTObjectL<TUint32>( KMPXMediaGeneralFlags );
       
   514             if ( flags & EVcxMyVideosVideoNew )
       
   515                 {
       
   516                 flags &= ~EVcxMyVideosVideoNew;
       
   517                 CVcxHgMyVideosCollectionClient& collectionClient = iModel.CollectionClient();
       
   518                 collectionClient.SetAttributeL( *media, KMPXMediaGeneralFlags, flags );
       
   519                 
       
   520                 if ( media->IsSupported( KVcxMediaMyVideosOrigin ) && 
       
   521                      ( media->ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ) == EVcxMyVideosOriginDownloaded ) )
       
   522                     {
       
   523                     iModel.ResetDownloadNotification();
       
   524                     }
       
   525                 }
       
   526             }
       
   527         }
       
   528     }
       
   529 
       
   530 // -----------------------------------------------------------------------------
       
   531 // CVcxHgMyVideosVideoModelHandler::ClearNewVideoIndicatorL()
       
   532 // Informative call about video being played. Method removes possible new indicator
       
   533 // from video.
       
   534 // -----------------------------------------------------------------------------
       
   535 //
       
   536 void CVcxHgMyVideosVideoModelHandler::ClearNewVideoIndicatorL( TMPXItemId& aMpxItemId )
       
   537     {
       
   538     CMPXMedia* media = iVideoArray->MPXMediaByMPXItemId( aMpxItemId );
       
   539 
       
   540     if ( media )
       
   541         {
       
   542         if ( media->IsSupported( KMPXMediaGeneralFlags ) &&
       
   543              media->IsSupported( KMPXMediaGeneralId ) )
       
   544             {
       
   545             TUint32 flags = media->ValueTObjectL<TUint32>( KMPXMediaGeneralFlags );
       
   546             if ( flags & EVcxMyVideosVideoNew )
       
   547                 {
       
   548                 flags &= ~EVcxMyVideosVideoNew;
       
   549                 CVcxHgMyVideosCollectionClient& collectionClient = iModel.CollectionClient();
       
   550                 collectionClient.SetAttributeL( *media, KMPXMediaGeneralFlags, flags );
       
   551                 
       
   552                 if ( media->IsSupported( KVcxMediaMyVideosOrigin ) && 
       
   553                      ( media->ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ) == EVcxMyVideosOriginDownloaded ) )
       
   554                     {
       
   555                     iModel.ResetDownloadNotification();
       
   556                     }
       
   557                 }
       
   558             }
       
   559         }
       
   560     }
       
   561 
       
   562 // -----------------------------------------------------------------------------
       
   563 // CVcxHgMyVideosVideoModelHandler::ShowVideoDetailsDialogL()
       
   564 // -----------------------------------------------------------------------------
       
   565 //
       
   566 void CVcxHgMyVideosVideoModelHandler::ShowVideoDetailsDialogL()
       
   567     {
       
   568     TInt highlight = Highlight();
       
   569     
       
   570     if ( highlight != KErrNotFound )
       
   571         {
       
   572         TMPXItemId mpxItemId = iVideoArray->ArrayIndexToMpxItemIdL( highlight );
       
   573         iModel.CollectionClient().GetVideoDetailsL( mpxItemId );        
       
   574         }
       
   575     }
       
   576 
       
   577 // -----------------------------------------------------------------------------
       
   578 // 
       
   579 // -----------------------------------------------------------------------------
       
   580 //
       
   581 CMyVideosIndicator& CVcxHgMyVideosVideoModelHandler::VideoIndicator()
       
   582     {
       
   583     return *iVideoIndicator;
       
   584     }
       
   585 
       
   586 // -----------------------------------------------------------------------------
       
   587 // CVcxHgMyVideosVideoModelHandler::LastPlaybackPosition()
       
   588 // -----------------------------------------------------------------------------
       
   589 //
       
   590 TInt CVcxHgMyVideosVideoModelHandler::LastPlaybackPosition( const TDesC& aContentUri )
       
   591     {
       
   592     TInt position = 0;
       
   593     
       
   594     if ( CIptvUtil::LastPlaybackPositionFeatureSupported() )
       
   595         {
       
   596         CMPXMedia* media = iVideoArray->MPXMediaByUri( aContentUri );
       
   597 
       
   598         if ( media )
       
   599             {
       
   600             if ( media->IsSupported( KMPXMediaGeneralLastPlaybackPosition ) )
       
   601                 {
       
   602                 position = *media->Value<TInt>( KMPXMediaGeneralLastPlaybackPosition );            
       
   603                 }
       
   604             }
       
   605         IPTVLOGSTRING3_LOW_LEVEL( "MPX My Videos UI # Found position %d for clip %S", 
       
   606                                   position, &aContentUri );
       
   607         }
       
   608     else
       
   609         {
       
   610         IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # LastPlaybackPosition() - Feature is not supported, position = 0" );
       
   611         }		
       
   612 
       
   613     return position;
       
   614     }
       
   615 
       
   616 // -----------------------------------------------------------------------------
       
   617 // CVcxHgMyVideosVideoModelHandler::SetLastPlaybackPositionL()
       
   618 // -----------------------------------------------------------------------------
       
   619 //
       
   620 void CVcxHgMyVideosVideoModelHandler::SetLastPlaybackPositionL( const TDesC& aContentUri,
       
   621                                                                 TInt aPosition )
       
   622     {
       
   623     if ( CIptvUtil::LastPlaybackPositionFeatureSupported() )
       
   624         {
       
   625         CMPXMedia* media = iVideoArray->MPXMediaByUri( aContentUri );
       
   626 
       
   627         // If media is not in our own list, it was launched from external source. In this
       
   628         // case the MPX Media object could be fetched on background to allow position storing.
       
   629         if ( ! media )
       
   630             {
       
   631             media = iModel.CollectionClient().GetLatestFetchedMpxMediaL();
       
   632 
       
   633             if ( media )
       
   634                 {
       
   635                 TBool match( EFalse );            
       
   636                 if ( media->IsSupported( KMPXMediaGeneralUri ) )
       
   637                     {
       
   638                     if ( aContentUri.CompareF( media->ValueText( KMPXMediaGeneralUri ) ) == 0 )
       
   639                         {
       
   640                         match = ETrue;
       
   641                         }
       
   642                     }
       
   643                 if ( ! match )
       
   644                     {
       
   645                     media = NULL;
       
   646                     }
       
   647                 }
       
   648             }
       
   649 
       
   650         if ( media )
       
   651             {
       
   652             IPTVLOGSTRING3_LOW_LEVEL( "MPX My Videos UI # Storing position %d for clip %S", 
       
   653                                       aPosition, &aContentUri );
       
   654 
       
   655             // Change data type of last playback position?
       
   656 
       
   657             iModel.CollectionClient().SetAttributeL( *media, 
       
   658                                                      KMPXMediaGeneralLastPlaybackPosition, 
       
   659                                                      TUint32( aPosition ) );
       
   660             }
       
   661         iModel.UpdateLastWatchedPlayPositionL( aPosition );    
       
   662         }
       
   663     else
       
   664 	    {
       
   665         IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # SetLastPlaybackPositionL() - Feature is not supported" ); 
       
   666         }    
       
   667     }
       
   668 
       
   669 // -----------------------------------------------------------------------------
       
   670 // CVcxHgMyVideosVideoModelHandler::GetVideoName()
       
   671 // -----------------------------------------------------------------------------
       
   672 //
       
   673 const TDesC& CVcxHgMyVideosVideoModelHandler::GetVideoName( TInt aIndex )
       
   674     {
       
   675     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   676 
       
   677     if ( media && media->IsSupported( KMPXMediaGeneralTitle ) )
       
   678         {
       
   679         return media->ValueText( KMPXMediaGeneralTitle );
       
   680         }
       
   681     return KNullDesC;
       
   682     }
       
   683 
       
   684 // -----------------------------------------------------------------------------
       
   685 // CVcxHgMyVideosVideoModelHandler::GetVideoUri()
       
   686 // -----------------------------------------------------------------------------
       
   687 //
       
   688 const TDesC& CVcxHgMyVideosVideoModelHandler::GetVideoUri( TInt aIndex )
       
   689     {
       
   690     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   691 
       
   692     if ( media && media->IsSupported( KMPXMediaGeneralUri ) )
       
   693         {
       
   694         return media->ValueText( KMPXMediaGeneralUri );
       
   695         }
       
   696     return KNullDesC;
       
   697     }
       
   698 
       
   699 // -----------------------------------------------------------------------------
       
   700 // CVcxHgMyVideosVideoModelHandler::GetVideoSize()
       
   701 // -----------------------------------------------------------------------------
       
   702 //
       
   703 TInt64 CVcxHgMyVideosVideoModelHandler::GetVideoSize( TInt aIndex )
       
   704     {
       
   705     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   706 
       
   707     if ( media && media->IsSupported( KMPXMediaGeneralExtSizeInt64 ) )
       
   708         {
       
   709         return media->ValueTObjectL<TInt64>( KMPXMediaGeneralExtSizeInt64 );
       
   710         }
       
   711     return 0;
       
   712     }
       
   713 
       
   714 // -----------------------------------------------------------------------------
       
   715 // CVcxHgMyVideosVideoModelHandler::DeleteVideosL()
       
   716 // -----------------------------------------------------------------------------
       
   717 //
       
   718 void CVcxHgMyVideosVideoModelHandler::DeleteVideosL( 
       
   719         const RArray<TInt>& aOperationTargets )
       
   720     {
       
   721     CMPXMedia* media = NULL;
       
   722     TMPXItemId mpxItemId;
       
   723     CMPXMedia* mediaToDelete = NULL;
       
   724     CMPXMediaArray* mediasToDelete = CMPXMediaArray::NewL();
       
   725     CleanupStack::PushL( mediasToDelete );
       
   726 
       
   727     for ( TInt i = 0; i < aOperationTargets.Count(); i++ )
       
   728         {
       
   729         media = iVideoArray->MPXMedia( aOperationTargets[i] );
       
   730 
       
   731         if ( media && media->IsSupported( KMPXMediaGeneralId ) )
       
   732             {
       
   733             mpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
       
   734             mediaToDelete = CMPXMedia::NewL();
       
   735             CleanupStack::PushL( mediaToDelete );
       
   736             mediaToDelete->SetTObjectValueL( KMPXMediaGeneralId, mpxItemId );
       
   737             mediasToDelete->AppendL( *mediaToDelete );
       
   738             CleanupStack::PopAndDestroy( mediaToDelete );
       
   739             }
       
   740         }
       
   741 
       
   742     TRAPD( err, iModel.CollectionClient().DeleteVideosL( mediasToDelete ) );
       
   743     	
       
   744     if ( err != KErrNone )
       
   745         {
       
   746         VideoDeletionCompletedL( aOperationTargets.Count(), mpxItemId );
       
   747 		if ( err != KErrNotReady )
       
   748 		    {
       
   749 			User::Leave( err );
       
   750 			}
       
   751         }
       
   752     CleanupStack::PopAndDestroy( mediasToDelete );
       
   753     }
       
   754 
       
   755 // -----------------------------------------------------------------------------
       
   756 // CVcxHgMyVideosVideoModelHandler::MoveOrCopyVideosL()
       
   757 // -----------------------------------------------------------------------------
       
   758 //
       
   759 void CVcxHgMyVideosVideoModelHandler::MoveOrCopyVideosL( 
       
   760         const RArray<TInt>& aOperationTargets,
       
   761         TInt aTargetDrive,
       
   762         TBool aCopy )
       
   763     {
       
   764     CMPXMedia* media = NULL;
       
   765     TMPXItemId mpxItemId;
       
   766     CMPXMedia* mediaToMoveOrCopy = NULL;
       
   767     CMPXMediaArray* mediasToMoveOrCopy = CMPXMediaArray::NewL();
       
   768     CleanupStack::PushL( mediasToMoveOrCopy );
       
   769 
       
   770     for ( TInt i = 0; i < aOperationTargets.Count(); i++ )
       
   771         {
       
   772         media = iVideoArray->MPXMedia( aOperationTargets[i] );
       
   773                     
       
   774         if ( media && media->IsSupported( KMPXMediaGeneralId ) )
       
   775             {
       
   776             mpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
       
   777             mediaToMoveOrCopy = CMPXMedia::NewL();
       
   778             CleanupStack::PushL( mediaToMoveOrCopy );
       
   779             mediaToMoveOrCopy->SetTObjectValueL( KMPXMediaGeneralId, mpxItemId );
       
   780             mediasToMoveOrCopy->AppendL( *mediaToMoveOrCopy );
       
   781             CleanupStack::PopAndDestroy( mediaToMoveOrCopy );
       
   782             }
       
   783         }
       
   784 
       
   785     iModel.CollectionClient().MoveOrCopyVideosL( mediasToMoveOrCopy, aTargetDrive, aCopy );
       
   786     CleanupStack::PopAndDestroy( mediasToMoveOrCopy );    
       
   787     }
       
   788 
       
   789 // -----------------------------------------------------------------------------
       
   790 // CVcxHgMyVideosVideoModelHandler::PlayVideoL()
       
   791 // -----------------------------------------------------------------------------
       
   792 //
       
   793 void CVcxHgMyVideosVideoModelHandler::PlayVideoL( TInt aIndex )
       
   794     {
       
   795     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   796 
       
   797     if ( media && media->IsSupported( KMPXMediaGeneralId ) )
       
   798         {
       
   799         // Playback should be tried always when single clicking a video in My Videos
       
   800         TMPXItemId mpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
       
   801         IPTVLOGSTRING3_LOW_LEVEL( "CVcxHgMyVideosVideoModelHandler::PlayVideoL() aIndex=%d mpxItemId=%d", aIndex, (TInt) mpxItemId );
       
   802         iModel.CollectionClient().PlayVideoL( mpxItemId );        
       
   803         }
       
   804     }
       
   805 
       
   806 // -----------------------------------------------------------------------------
       
   807 // CVcxHgMyVideosVideoModelHandler::ResumeDownloadL()
       
   808 // -----------------------------------------------------------------------------
       
   809 //
       
   810 void CVcxHgMyVideosVideoModelHandler::ResumeDownloadL( TInt aIndex )
       
   811     {
       
   812     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   813 
       
   814     if ( media && media->IsSupported( KMPXMediaGeneralId ) )
       
   815         {
       
   816         TVcxMyVideosDownloadState dlState = VideoDownloadState( aIndex );
       
   817         
       
   818         if ( dlState == EVcxMyVideosDlStatePaused || dlState == EVcxMyVideosDlStateFailed )
       
   819             {
       
   820             iModel.DownloadClient().ResumeDownloadL( *media );
       
   821             
       
   822             TUint32 mpxId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ).iId1;
       
   823             if ( iResumeArray.Find( mpxId ) == KErrNotFound )
       
   824                 {
       
   825                 iResumeArray.AppendL( mpxId );
       
   826                 }
       
   827             }
       
   828         }
       
   829     }
       
   830 
       
   831 // -----------------------------------------------------------------------------
       
   832 // CVcxHgMyVideosVideoModelHandler::CancelDownloadL()
       
   833 // -----------------------------------------------------------------------------
       
   834 //
       
   835 void CVcxHgMyVideosVideoModelHandler::CancelDownloadL( TInt aIndex )
       
   836     {
       
   837     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   838 
       
   839     if ( media )
       
   840         {            
       
   841         iModel.DownloadClient().CancelDownloadL( *media );
       
   842         }
       
   843     }
       
   844 
       
   845 // -----------------------------------------------------------------------------
       
   846 // CVcxHgMyVideosVideoModelHandler::Release()
       
   847 // -----------------------------------------------------------------------------
       
   848 //
       
   849 void CVcxHgMyVideosVideoModelHandler::Release( TInt aReleaseStart, 
       
   850                                                TInt aReleaseEnd )
       
   851     {   
       
   852     for ( TInt i = aReleaseStart; i <= aReleaseEnd; i++ )
       
   853         {
       
   854         TRAP_IGNORE( iDataUpdater->ReleaseData( iVideoArray->ArrayIndexToMpxItemIdL( i ) ) );
       
   855         }
       
   856     }
       
   857 
       
   858 // -----------------------------------------------------------------------------
       
   859 // CVcxHgMyVideosVideoModelHandler::Request()
       
   860 // -----------------------------------------------------------------------------
       
   861 //
       
   862 void CVcxHgMyVideosVideoModelHandler::Request( TInt aRequestStart, 
       
   863                                                TInt aRequestEnd,
       
   864                                                THgScrollDirection aDirection )
       
   865     {
       
   866     TRAP_IGNORE( HandleRequestL( aRequestStart, aRequestEnd, aDirection ) );
       
   867     }
       
   868 
       
   869 // -----------------------------------------------------------------------------
       
   870 // CVcxHgMyVideosVideoModelHandler::HandleRequestL()
       
   871 // -----------------------------------------------------------------------------
       
   872 //
       
   873 void CVcxHgMyVideosVideoModelHandler::HandleRequestL( TInt aRequestStart, 
       
   874                                                       TInt aRequestEnd,
       
   875                                                       THgScrollDirection /*aDirection*/ )
       
   876     {
       
   877     IPTVLOGSTRING_LOW_LEVEL(
       
   878         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::HandleRequestL - Enter" );
       
   879     
       
   880     TInt videoCount = iVideoArray->VideoCount();
       
   881     TInt requestStart = ( aRequestStart >= 0 ? aRequestStart : 0 );
       
   882     TInt requestEnd = ( aRequestEnd < videoCount ? aRequestEnd : ( videoCount - 1 ) );
       
   883     
       
   884     IPTVLOGSTRING3_LOW_LEVEL(
       
   885         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::HandleRequestL - aRequestStart: %d, aRequestEnd: %d", requestStart, requestEnd );
       
   886         
       
   887     for ( TInt i = requestStart; i <= requestEnd; i++ )
       
   888         {
       
   889         UpdateVideoListItemL( i );
       
   890         iDataUpdater->RequestDataL( iVideoArray->ArrayIndexToMpxItemIdL( i ) );
       
   891         }
       
   892 
       
   893     iScroller.DrawDeferred();
       
   894         
       
   895     IPTVLOGSTRING_LOW_LEVEL( 
       
   896         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::HandleRequestL() - Exit" );    
       
   897     }
       
   898 
       
   899 // -----------------------------------------------------------------------------
       
   900 // CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowLC()
       
   901 // -----------------------------------------------------------------------------
       
   902 // 
       
   903 HBufC* CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowLC(
       
   904             TInt aIndex,
       
   905             CMPXMedia& aMedia,
       
   906             TBool& aIsDownloading )
       
   907 
       
   908     {
       
   909     if ( VideoDownloadState( aIndex ) == EVcxMyVideosDlStateNone )
       
   910         {
       
   911         aIsDownloading = EFalse;
       
   912         return FormatVideoSecondRowCompletedLC( aMedia );
       
   913         }
       
   914     else
       
   915         {
       
   916         aIsDownloading = ETrue;
       
   917         return FormatVideoSecondRowDownloadingLC( aIndex, aMedia );
       
   918         }
       
   919     }
       
   920 
       
   921 // -----------------------------------------------------------------------------
       
   922 // CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowCompletedLC()
       
   923 // -----------------------------------------------------------------------------
       
   924 // 
       
   925 HBufC* CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowCompletedLC( 
       
   926         CMPXMedia& aMedia )
       
   927     {
       
   928     _LIT( KVcxSecondLineSeparator, "," );
       
   929 
       
   930     HBufC* details = NULL;
       
   931     HBufC* sizeStr = NULL;
       
   932     HBufC* lengthStr = NULL;
       
   933     TReal32 length( 0 );
       
   934     TInt64 size( 0 );
       
   935     TInt detailsSize( 0 );
       
   936 
       
   937     // Use KMPXMediaGeneralDuration or KVcxMediaMyVideosDuration?
       
   938     if ( aMedia.IsSupported( KVcxMediaMyVideosDuration ) )
       
   939         {
       
   940         length = *( aMedia.Value<TReal32>( KVcxMediaMyVideosDuration ) ); // In seconds
       
   941         IPTVLOGSTRING2_LOW_LEVEL( "MPX My Videos UI # FormatVideoSecondRowCompletedLC() length=%f", length );
       
   942         }
       
   943 
       
   944     if ( aMedia.IsSupported( KMPXMediaGeneralExtSizeInt64 ) )
       
   945         {
       
   946         size = *( aMedia.Value<TInt64>( KMPXMediaGeneralExtSizeInt64 ) ); // In bytes
       
   947         IPTVLOGSTRING2_LOW_LEVEL( "MPX My Videos UI # FormatVideoSecondRowCompletedLC() size=%ld", size );
       
   948         }
       
   949 
       
   950     if ( size > 0 )
       
   951         {
       
   952         TUint64 bytes = static_cast<TUint64>( size );
       
   953         TUint64 dispSize = 0;
       
   954 
       
   955         if ( bytes >= KVcxVideoSizeGB )
       
   956             {
       
   957             dispSize  = bytes + KVcxVideoSizeHalfGB;
       
   958             dispSize /= KVcxVideoSizeGB;
       
   959             sizeStr = StringLoader::LoadLC( R_VCXHGMYVIDEOS_SIZE_LIST_GB, dispSize );
       
   960             }
       
   961         else if ( bytes >= KVcxVideoSizeMB )
       
   962             {
       
   963             dispSize  = bytes + KVcxVideoSizeHalfMB;
       
   964             dispSize /= KVcxVideoSizeMB;
       
   965             sizeStr = StringLoader::LoadLC( R_VCXHGMYVIDEOS_SIZE_LIST_MB, dispSize );
       
   966             }
       
   967         else
       
   968             {
       
   969             dispSize  = bytes + KVcxVideoSizeHalfKB;
       
   970             dispSize /= KVcxVideoSizeKB;
       
   971             sizeStr = StringLoader::LoadLC( R_VCXHGMYVIDEOS_LIST_SIZE_KB, dispSize );
       
   972             }
       
   973         detailsSize += sizeStr->Length();
       
   974         }
       
   975     if ( length > 0 )
       
   976         {
       
   977         TUint total = static_cast<TUint>( length );
       
   978         
       
   979         TUint hours = total / KVcxSecondsInHour;
       
   980         TUint minutes = total / KVcxSecondsInMinute % KVcxSecondsInMinute;
       
   981         TUint seconds = total % KVcxSecondsInMinute;
       
   982 
       
   983         if ( hours > 0 )
       
   984             {
       
   985             CArrayFix<TInt>* numbers = new (ELeave) CArrayFixFlat<TInt>(2);
       
   986             CleanupStack::PushL( numbers );
       
   987             numbers->AppendL( hours );
       
   988             numbers->AppendL( minutes );
       
   989             lengthStr = StringLoader::LoadL( R_VCXHGMYVIDEOS_VIDEO_LIST_LENGTH_H_MIN, *numbers );
       
   990             CleanupStack::PopAndDestroy( numbers );
       
   991             CleanupStack::PushL( lengthStr );
       
   992             }
       
   993         else if ( minutes > 0 )
       
   994             {
       
   995             CArrayFix<TInt>* numbers = new (ELeave) CArrayFixFlat<TInt>(2);
       
   996             CleanupStack::PushL( numbers );
       
   997             numbers->AppendL( minutes );
       
   998             numbers->AppendL( seconds );
       
   999             lengthStr = StringLoader::LoadL( R_VCXHGMYVIDEOS_VIDEO_LIST_LENGTH_MIN_SEC, *numbers );
       
  1000             CleanupStack::PopAndDestroy( numbers );
       
  1001             CleanupStack::PushL( lengthStr );
       
  1002             }
       
  1003         else
       
  1004             {
       
  1005             lengthStr = StringLoader::LoadLC( R_VCXHGMYVIDEOS_VIDEO_LIST_LENGTH_SEC, seconds ); 
       
  1006             }
       
  1007         detailsSize += lengthStr->Length();
       
  1008         }      
       
  1009 
       
  1010     details = HBufC::NewL( detailsSize + KVcxSecondLineSeparator().Length() );
       
  1011     if ( lengthStr )
       
  1012         {
       
  1013         details->Des().Append( *lengthStr );
       
  1014         CleanupStack::PopAndDestroy( lengthStr );
       
  1015         }
       
  1016     if ( sizeStr )
       
  1017         {
       
  1018         if ( lengthStr ) // Add separator when both are available.
       
  1019             {
       
  1020             details->Des().Append( KVcxSecondLineSeparator );
       
  1021             }
       
  1022         details->Des().Append( *sizeStr );
       
  1023         CleanupStack::PopAndDestroy( sizeStr );
       
  1024         }
       
  1025 
       
  1026     CleanupStack::PushL( details );
       
  1027     return details;
       
  1028     }
       
  1029 
       
  1030 // -----------------------------------------------------------------------------
       
  1031 // CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowDownloadingLC()
       
  1032 // -----------------------------------------------------------------------------
       
  1033 // 
       
  1034 HBufC* CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowDownloadingLC(
       
  1035             TInt aIndex,
       
  1036             CMPXMedia& aMedia )
       
  1037     {
       
  1038     HBufC* details = NULL;
       
  1039     TInt progress = DownloadProgressL( aMedia );
       
  1040 
       
  1041     switch ( VideoDownloadState( aIndex ) )
       
  1042         {
       
  1043         case EVcxMyVideosDlStateDownloading:
       
  1044             {
       
  1045             details = StringLoader::LoadLC( R_VCXHGMYVIDEOS_VIDEO_DOWNLOADING, progress );
       
  1046             break;
       
  1047             }
       
  1048         case EVcxMyVideosDlStateFailed:
       
  1049             {
       
  1050             details = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DOWNLOAD_FAILED, progress );
       
  1051             break;
       
  1052             }
       
  1053         case EVcxMyVideosDlStatePaused:
       
  1054             {
       
  1055             details = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DOWNLOAD_PAUSED, progress );
       
  1056             break;
       
  1057             }
       
  1058         case EVcxMyVideosDlStateNone:            
       
  1059         case EVcxMyVideosDlStateDownloaded:
       
  1060         default:
       
  1061             {
       
  1062             IPTVLOGSTRING2_LOW_LEVEL( 
       
  1063                 "MPX My Videos UI # FormatVideoSecondRowDownloadingL() Unexpected state (%d)!",
       
  1064                 VideoDownloadState( aIndex ) );
       
  1065             #ifdef _DEBUG
       
  1066             User::Panic( KVcxHgMyVideosPanic, EVcxHgMyVideosPanicLogicalVideo );
       
  1067             #else
       
  1068             User::Leave( KErrArgument );
       
  1069             #endif // _DEBUG
       
  1070             }
       
  1071         }
       
  1072 
       
  1073     return details;
       
  1074     }
       
  1075 
       
  1076 // -----------------------------------------------------------------------------
       
  1077 // CVcxHgMyVideosVideoModelHandler::ReplaceVideoArrayL()
       
  1078 // -----------------------------------------------------------------------------
       
  1079 // 
       
  1080 void CVcxHgMyVideosVideoModelHandler::ReplaceVideoArrayL( CMPXMediaArray& aVideoList )
       
  1081     {
       
  1082     iVideoArray->ReplaceVideoListL( aVideoList );
       
  1083     iDataUpdater->InfoArrayChanged();
       
  1084     iDownloadUpdater->VideoArrayChangedL();
       
  1085     }
       
  1086 
       
  1087 // -----------------------------------------------------------------------------
       
  1088 // CVcxHgMyVideosVideoModelHandler::DownloadProgressL()
       
  1089 // -----------------------------------------------------------------------------
       
  1090 // 
       
  1091 TInt CVcxHgMyVideosVideoModelHandler::DownloadProgressL( const CMPXMedia& aMpxMedia )
       
  1092     {
       
  1093     TInt progress = 0;
       
  1094 
       
  1095     if ( aMpxMedia.IsSupported( KVcxMediaMyVideosDownloadProgress ) )
       
  1096         {
       
  1097         progress = static_cast<TInt>( 
       
  1098                        aMpxMedia.ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress ) );
       
  1099         }
       
  1100 
       
  1101     IPTVLOGSTRING3_LOW_LEVEL(
       
  1102         "MPX My Videos UI # DownloadProgressL() Id:%d Progress:%d",
       
  1103         static_cast<TInt>( aMpxMedia.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ),
       
  1104         progress );
       
  1105 
       
  1106     progress = ( progress >= 0 ? progress : 0 );
       
  1107     progress = ( progress < 100 ? progress : 99 );
       
  1108 
       
  1109     return progress;
       
  1110     }
       
  1111 
       
  1112 // -----------------------------------------------------------------------------
       
  1113 // CVcxHgMyVideosVideoModelHandler::UpdateVideoListItemL()
       
  1114 // -----------------------------------------------------------------------------
       
  1115 // 
       
  1116 void CVcxHgMyVideosVideoModelHandler::UpdateVideoListItemL( TInt aListIndex )
       
  1117     {
       
  1118     if ( aListIndex >= 0 && aListIndex < iScroller.ItemCount() )
       
  1119         {
       
  1120         TVcxHgMyVideosIndicatorHelper indicatorHelper;
       
  1121         CMPXMedia* media( NULL );
       
  1122         
       
  1123         media = iVideoArray->MPXMedia( aListIndex );
       
  1124 
       
  1125         if ( media )
       
  1126             {           
       
  1127             CHgItem& item = iScroller.ItemL( aListIndex );
       
  1128             TBool isMarked = ( item.Flags() & CHgItem::EHgItemFlagMarked );
       
  1129             item.ClearFlags( item.Flags() );
       
  1130             
       
  1131             if ( media->IsSupported( KMPXMediaGeneralTitle ) )
       
  1132                 {
       
  1133                 HBufC* name( NULL );        
       
  1134                 name = media->ValueText( KMPXMediaGeneralTitle ).AllocLC();
       
  1135                 if ( name->Length() > 0 )
       
  1136                     {
       
  1137                     item.SetTitleL( *name );
       
  1138                     }
       
  1139                 CleanupStack::PopAndDestroy( name );
       
  1140                 }
       
  1141             TBool isDownloading( EFalse );
       
  1142             HBufC* details( NULL );
       
  1143             
       
  1144             details = FormatVideoSecondRowLC( aListIndex, *media, isDownloading );
       
  1145             if ( details->Length() > 0 )
       
  1146                 {
       
  1147                 item.SetTextL( *details );
       
  1148                 }
       
  1149             CleanupStack::PopAndDestroy( details );
       
  1150     
       
  1151             TBool isNewVideo( EFalse );
       
  1152             if ( media->IsSupported( KMPXMediaGeneralFlags ) )
       
  1153                 {
       
  1154                 if ( media->ValueTObjectL<TUint32>( KMPXMediaGeneralFlags ) &
       
  1155                      EVcxMyVideosVideoNew )
       
  1156                     {
       
  1157                     isNewVideo = ETrue;
       
  1158                     }
       
  1159                 }
       
  1160             TInt indicator1( 0 );
       
  1161             TInt indicator2( 0 );            
       
  1162             
       
  1163             indicatorHelper.GetIndicatorsForVideoL(
       
  1164                 iModel,
       
  1165                 isNewVideo,
       
  1166                 EFalse, // *Recordings*
       
  1167                 media->ValueText( KMPXMediaGeneralUri ),
       
  1168                 TVcxHgMyVideosIndicatorHelper::EIndicatorDrmStatusUnknown,
       
  1169                 indicator1,
       
  1170                 indicator2 );   
       
  1171             if ( indicator1 )
       
  1172                 {
       
  1173                 item.SetFlags( indicator1 );
       
  1174                 }
       
  1175             if ( indicator2 )
       
  1176                 {
       
  1177                 item.SetFlags( indicator2 );
       
  1178                 }
       
  1179             if ( isMarked )
       
  1180                 {
       
  1181                 item.SetFlags( CHgItem::EHgItemFlagMarked );
       
  1182                 }
       
  1183             if ( VideoIndicator().IsIndicatorShown( *media ) )
       
  1184                 {
       
  1185                 item.SetFlags( CHgItem::EHgItemFlagsIconOverlayIndicator );
       
  1186                 }
       
  1187             if ( media->IsSupported( KMPXMediaGeneralDate ) )
       
  1188                 {
       
  1189                 TInt64 itemDate = media->ValueTObjectL<TInt64>( KMPXMediaGeneralDate );
       
  1190                 item.SetTime( itemDate );
       
  1191                 }    
       
  1192             }
       
  1193         }
       
  1194     }
       
  1195 
       
  1196 // -----------------------------------------------------------------------------
       
  1197 // CVcxHgMyVideosVideoModelHandler::DeleteItemL()
       
  1198 // -----------------------------------------------------------------------------
       
  1199 // 
       
  1200 void CVcxHgMyVideosVideoModelHandler::DeleteItemL( TMPXItemId aMpxItemId )
       
  1201     {
       
  1202     // Remove video from data and download updaters.
       
  1203     iDataUpdater->ReleaseData( aMpxItemId );
       
  1204     iDownloadUpdater->RemoveDownload( aMpxItemId );
       
  1205 
       
  1206     // Remove video from video array.
       
  1207     TInt removedIndex = iVideoArray->RemoveVideo( aMpxItemId );
       
  1208     
       
  1209     if ( removedIndex != KErrNotFound )
       
  1210         {
       
  1211         // Remove item from the list.
       
  1212         iScroller.RemoveItem( removedIndex );
       
  1213         
       
  1214         if ( iScroller.ItemCount() > 0 )
       
  1215             {
       
  1216             TInt selectedIndex = iScroller.SelectedIndex();
       
  1217             
       
  1218             // Selected index number is greater than
       
  1219             // item count. Set the last item to be highlighted.
       
  1220             if ( selectedIndex >= iScroller.ItemCount() )
       
  1221                 {
       
  1222                 iScroller.SetSelectedIndex( iScroller.ItemCount() - 1 );
       
  1223                 }
       
  1224             }
       
  1225         else
       
  1226             {
       
  1227             // Last item has deleted, set empty text and reset list.
       
  1228             iVideoListImpl.SetEmptyListTextByResourceL( R_VCXHGMYVIDEOS_NO_VIDEOS );
       
  1229             iScroller.Reset();
       
  1230             }
       
  1231         
       
  1232         // fix for error where highlight was sometimes lost after delete. Problem is 
       
  1233         // that someone is 'stealing' keyboard focus from the scroller (probably the
       
  1234         // confirmation note, as user needs to clicks them to start the delete).
       
  1235         iScroller.SetFocus( ETrue ); 
       
  1236         
       
  1237         iScroller.DrawDeferred();
       
  1238         iView.DynInitMskL();
       
  1239         }
       
  1240     
       
  1241     TInt index( KErrNotFound );
       
  1242     index = iResumeArray.Find( aMpxItemId.iId1 );
       
  1243     
       
  1244     if ( index >= 0 && index < iResumeArray.Count() )
       
  1245         {
       
  1246         iResumeArray.Remove( index );
       
  1247         }
       
  1248     }
       
  1249 
       
  1250 // -----------------------------------------------------------------------------
       
  1251 // CVcxHgMyVideosVideoModelHandler::InsertVideoL()
       
  1252 // -----------------------------------------------------------------------------
       
  1253 // 
       
  1254 void CVcxHgMyVideosVideoModelHandler::InsertVideoL( CMPXMedia* aVideo )
       
  1255     {
       
  1256     if ( aVideo )
       
  1257         {		
       
  1258         if ( aVideo->IsSupported( KMPXMediaGeneralId ) )
       
  1259             {           
       
  1260             CleanupStack::PushL( aVideo );
       
  1261 		    TMPXItemId itemId = aVideo->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
       
  1262             
       
  1263             // Get current sort order.
       
  1264             TVcxMyVideosSortingOrder sortOrder = iModel.VideolistSortOrderL();
       
  1265             
       
  1266             // Ownership of video item is transferred to video array.
       
  1267             CleanupStack::Pop( aVideo );
       
  1268             iVideoArray->AddToCorrectPlaceL( aVideo, sortOrder );
       
  1269             
       
  1270             TInt index = iVideoArray->IndexByMPXItemId( itemId );
       
  1271             
       
  1272             if ( index >= 0 )
       
  1273                 {
       
  1274                 // Create a new Hg list item. Ownership of list item  
       
  1275                 // is transferred to scroller.
       
  1276                 CHgItem* listItem = CHgItem::NewL();
       
  1277                 iScroller.InsertItem( listItem, index );
       
  1278                             
       
  1279                 if ( iScroller.SelectedIndex() == KErrNotFound )
       
  1280                     {
       
  1281                     iScroller.SetSelectedIndex( 0 );
       
  1282                     }    
       
  1283                 UpdateVideoListItemL( index );
       
  1284                 
       
  1285                 // Update screen.
       
  1286                 iScroller.DrawDeferred();
       
  1287                 iView.DynInitMskL();
       
  1288                                                     
       
  1289                 iDataUpdater->RequestDataL( itemId );    
       
  1290                 iDownloadUpdater->VideoModifiedL( 
       
  1291                     EMPXItemInserted, itemId, EVcxMyVideosListNoInfo );
       
  1292                 }
       
  1293             }
       
  1294          else
       
  1295             {
       
  1296             delete aVideo;
       
  1297             }
       
  1298         }
       
  1299     }
       
  1300 
       
  1301 // -----------------------------------------------------------------------------
       
  1302 // CVcxHgMyVideosVideoModelHandler::ValidOrigin()
       
  1303 // -----------------------------------------------------------------------------
       
  1304 // 
       
  1305 TBool CVcxHgMyVideosVideoModelHandler::ValidOrigin( CMPXMedia& aMedia )
       
  1306     {
       
  1307     IPTVLOGSTRING_LOW_LEVEL( 
       
  1308         "MPX My Videos UI # ValidOrigin - Enter" );
       
  1309     
       
  1310     TBool isValid( EFalse );
       
  1311 	
       
  1312     if ( aMedia.IsSupported( KVcxMediaMyVideosOrigin ) )
       
  1313         {
       
  1314         TUint8 mediaOrigin( EVcxMyVideosOriginOther );
       
  1315         mediaOrigin = aMedia.ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin );   
       
  1316 		
       
  1317         // All videos
       
  1318         if ( CurrentCategoryIndex() == KVcxMvcCategoryIdAll )
       
  1319             {
       
  1320             IPTVLOGSTRING_LOW_LEVEL( 
       
  1321                 "MPX My Videos UI # ValidOrigin - Origin: All" );
       
  1322             isValid = ETrue;
       
  1323             }
       
  1324         // Captured
       
  1325         else if ( CurrentCategoryIndex() == KVcxMvcCategoryIdCaptured && 
       
  1326                 mediaOrigin == EVcxMyVideosOriginCapturedWithCamera )
       
  1327             {
       
  1328             IPTVLOGSTRING_LOW_LEVEL( 
       
  1329                 "MPX My Videos UI # ValidOrigin - Origin: Captured" );
       
  1330             isValid = ETrue;
       
  1331             }
       
  1332         // Downloads
       
  1333         else if ( CurrentCategoryIndex() == KVcxMvcCategoryIdDownloads &&
       
  1334                 mediaOrigin == EVcxMyVideosOriginDownloaded )
       
  1335             {
       
  1336             IPTVLOGSTRING_LOW_LEVEL( 
       
  1337                 "MPX My Videos UI # ValidOrigin - Origin: Downloads" );    	
       
  1338             isValid = ETrue;
       
  1339             }
       
  1340         // Other
       
  1341         else if ( CurrentCategoryIndex() == KVcxMvcCategoryIdOther && 
       
  1342                 ( mediaOrigin == EVcxMyVideosOriginSideLoaded ||
       
  1343                 mediaOrigin == EVcxMyVideosOriginOther ) )
       
  1344             {
       
  1345             IPTVLOGSTRING_LOW_LEVEL( 
       
  1346                 "MPX My Videos UI # ValidOrigin - Origin: Other" ); 
       
  1347             isValid = ETrue;
       
  1348             }
       
  1349         }
       
  1350     IPTVLOGSTRING2_LOW_LEVEL( 
       
  1351         "MPX My Videos UI # ValidOrigin, isValid %b - Exit", isValid );
       
  1352     return isValid;
       
  1353     }
       
  1354 
       
  1355 // -----------------------------------------------------------------------------
       
  1356 // CVcxHgMyVideosVideoModelHandler::NewVideoListL()
       
  1357 // MPX Collection calls this callback when video list is available.
       
  1358 // -----------------------------------------------------------------------------
       
  1359 // 
       
  1360 void CVcxHgMyVideosVideoModelHandler::NewVideoListL( CMPXMediaArray& aVideoList )
       
  1361     {
       
  1362     IPTVLOGSTRING2_LOW_LEVEL( 
       
  1363         "MPX My Videos UI # NewVideoListL(count=%d) - Enter", aVideoList.Count() );
       
  1364         
       
  1365     ReplaceVideoArrayL( aVideoList );
       
  1366             
       
  1367     if ( iVideoArray->VideoCount() > 0 )
       
  1368         {
       
  1369         iScroller.ResizeL( iVideoArray->VideoCount() );               
       
  1370 		
       
  1371         TInt highlight( KErrNotFound );
       
  1372 		
       
  1373         if ( iRestoreHighlightPosition )
       
  1374             {
       
  1375             highlight = iVideoArray->IndexByMPXItemId( iHighlightedItemId );
       
  1376             }
       
  1377         
       
  1378         highlight != KErrNotFound ? iScroller.SetSelectedIndex( highlight ) :
       
  1379 		                            iScroller.SetSelectedIndex( 0 );
       
  1380         }
       
  1381     else
       
  1382         {
       
  1383         iVideoListImpl.SetEmptyListTextByResourceL( R_VCXHGMYVIDEOS_NO_VIDEOS );
       
  1384         iScroller.DrawDeferred();
       
  1385         }        
       
  1386     iView.DynInitMskL();
       
  1387  
       
  1388     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # NewVideoListL() - Exit" );
       
  1389     }
       
  1390 
       
  1391 // -----------------------------------------------------------------------------
       
  1392 // CVcxHgMyVideosVideoModelHandler::VideoListModifiedL()
       
  1393 // MPX Collection calls this callback when the video list has been modified.
       
  1394 // -----------------------------------------------------------------------------
       
  1395 // 
       
  1396 void CVcxHgMyVideosVideoModelHandler::VideoListModifiedL()
       
  1397     {
       
  1398     IPTVLOGSTRING2_LOW_LEVEL( 
       
  1399         "MPX My Videos UI # VideoListModifiedL(count=%d) - Enter", 
       
  1400         iVideoArray->VideoCount() );
       
  1401 
       
  1402     TInt videoCount = iVideoArray->VideoCount();
       
  1403         
       
  1404     if ( iScroller.ItemCount() != videoCount )
       
  1405         {
       
  1406         iScroller.ResizeL( videoCount );
       
  1407         }
       
  1408         
       
  1409     if ( iScroller.ItemCount() > 0 )
       
  1410        {
       
  1411        iScroller.DrawDeferred();
       
  1412        }
       
  1413               
       
  1414     iView.DynInitMskL();       
       
  1415 
       
  1416     IPTVLOGSTRING_LOW_LEVEL( 
       
  1417         "MPX My Videos UI # VideoListModifiedL() - Exit" );            
       
  1418     }
       
  1419 
       
  1420 // -----------------------------------------------------------------------------
       
  1421 // CVcxHgMyVideosVideoModelHandler::VideoModifiedL()
       
  1422 // MPX Collection calls this callback when single video item has been modified.
       
  1423 // -----------------------------------------------------------------------------
       
  1424 // 
       
  1425 void CVcxHgMyVideosVideoModelHandler::VideoModifiedL( TMPXChangeEventType aEventType,
       
  1426                                                       TMPXItemId aMpxItemId,
       
  1427                                                       TInt32 aExtraInfo,
       
  1428                                                       TBool aSimulated )
       
  1429     {
       
  1430     IPTVLOGSTRING2_LOW_LEVEL( 
       
  1431         "MPX My Videos UI # VideoModifiedL(event=%d)", aEventType );
       
  1432         
       
  1433     switch ( aEventType )
       
  1434         {
       
  1435         case EMPXItemInserted:
       
  1436             {
       
  1437             if ( aMpxItemId.iId2 < 2 )
       
  1438                 {
       
  1439                 iModel.CollectionClient().FetchMpxMediaByMpxIdL( aMpxItemId );
       
  1440                 }
       
  1441             }
       
  1442             break;
       
  1443             
       
  1444         case EMPXItemModified:
       
  1445             {
       
  1446             if ( aExtraInfo == EVcxMyVideosVideoListOrderChanged )
       
  1447                 {
       
  1448                 if ( aMpxItemId.iId1 == iCurrentCategoryIndex &&
       
  1449                      aMpxItemId.iId2 == 1 )
       
  1450                     {                    
       
  1451                     // Re-fetch current list completely, MMC card has 
       
  1452                     // removed or inserted.
       
  1453                     iModel.CollectionClient().GetVideoListL( KErrNotFound );
       
  1454                     }
       
  1455                 }
       
  1456             else
       
  1457                 {
       
  1458                 TInt index = iVideoArray->IndexByMPXItemId( aMpxItemId );
       
  1459                 if ( index != KErrNotFound )
       
  1460                     {
       
  1461                     UpdateVideoListItemL( index );              
       
  1462                     iScroller.RefreshScreen( index );
       
  1463                 
       
  1464                     if ( ! aSimulated )
       
  1465                         {
       
  1466                         iDownloadUpdater->VideoModifiedL( aEventType, aMpxItemId, aExtraInfo );
       
  1467                         iDataUpdater->RequestDataL( aMpxItemId );    
       
  1468 					    }                      
       
  1469                     iView.DynInitMskL();
       
  1470                     }
       
  1471                 }
       
  1472             }
       
  1473             break;
       
  1474         
       
  1475         case EMPXItemDeleted:
       
  1476             {
       
  1477             if ( aMpxItemId.iId2 < 2 )
       
  1478                 {
       
  1479                 DeleteItemL( aMpxItemId );    
       
  1480                 }
       
  1481             }
       
  1482             break;
       
  1483         
       
  1484         default:
       
  1485             {
       
  1486             IPTVLOGSTRING_LOW_LEVEL( 
       
  1487                 "MPX My Videos UI # VideoModifiedL() Unexpected change!" );
       
  1488             #ifdef _DEBUG
       
  1489             User::Panic( KVcxHgMyVideosPanic, EVcxHgMyVideosPanicLogicalVideo );
       
  1490             #endif // _DEBUG            
       
  1491             }
       
  1492             break;
       
  1493         } 
       
  1494     }
       
  1495 
       
  1496 // -----------------------------------------------------------------------------
       
  1497 // CVcxHgMyVideosVideoModelHandler::VideoFetchingCompletedL()
       
  1498 // MPX Collection calls this callback when a single video has fetched.
       
  1499 // -----------------------------------------------------------------------------
       
  1500 // 
       
  1501 void CVcxHgMyVideosVideoModelHandler::VideoFetchingCompletedL( CMPXMedia* aVideo )
       
  1502     {
       
  1503     if ( ValidOrigin( *aVideo ) )
       
  1504         {
       
  1505         // Ownership of video item is transferred.
       
  1506         InsertVideoL( aVideo );	
       
  1507         }
       
  1508     else
       
  1509         {
       
  1510         delete aVideo;
       
  1511         }
       
  1512     }
       
  1513 
       
  1514 // -----------------------------------------------------------------------------
       
  1515 // CVcxHgMyVideosVideoModelHandler::ResumeStartedFromBeginningL()
       
  1516 // Download updater calls this when resume has started from beginning.
       
  1517 // -----------------------------------------------------------------------------
       
  1518 // 
       
  1519 void CVcxHgMyVideosVideoModelHandler::ResumeStartedFromBeginningL( TUint32 aMpxId )
       
  1520     {
       
  1521     TInt index = iResumeArray.Find( aMpxId );
       
  1522     if ( index >= 0 )
       
  1523         {
       
  1524         iResumeArray.Remove( index );
       
  1525         iVideoListImpl.ShowResumeStartsFromBeginningNoteL();
       
  1526         }
       
  1527     }
       
  1528 
       
  1529 // -----------------------------------------------------------------------------
       
  1530 // CVcxHgMyVideosVideoModelHandler::VideoDeletionCompletedL()
       
  1531 // MPX Collection calls this callback when deletion of multiple videos completes.
       
  1532 // -----------------------------------------------------------------------------
       
  1533 // 
       
  1534 void CVcxHgMyVideosVideoModelHandler::VideoDeletionCompletedL( TInt aFailedCount,
       
  1535                                                                TMPXItemId aFailedMpxId )
       
  1536     {
       
  1537     CMPXMedia* media = iVideoArray->MPXMediaByMPXItemId( aFailedMpxId );
       
  1538 
       
  1539     if ( aFailedCount == 1 && media && media->IsSupported( KMPXMediaGeneralTitle ) )
       
  1540         {
       
  1541         iVideoListImpl.VideoDeletionCompletedL( aFailedCount, 
       
  1542                                                 media->ValueText( KMPXMediaGeneralTitle ) );
       
  1543         }
       
  1544     else
       
  1545         {
       
  1546         iVideoListImpl.VideoDeletionCompletedL( aFailedCount, 
       
  1547                                                 KNullDesC );
       
  1548         }
       
  1549     }
       
  1550 
       
  1551 // -----------------------------------------------------------------------------
       
  1552 // CVcxHgMyVideosVideoModelHandler::VideoMoveOrCopyCompletedL()
       
  1553 // MPX Collection calls this callback when move or copy command is completed.
       
  1554 // -----------------------------------------------------------------------------
       
  1555 // 
       
  1556 void CVcxHgMyVideosVideoModelHandler::VideoMoveOrCopyCompletedL( TInt aFailedCount,
       
  1557                                                                  TMPXItemId aFailedMpxId )
       
  1558     {
       
  1559     CMPXMedia* media = iVideoArray->MPXMediaByMPXItemId( aFailedMpxId );
       
  1560 
       
  1561     if ( aFailedCount == 1 && media && media->IsSupported( KMPXMediaGeneralTitle ) )
       
  1562         {    
       
  1563         iVideoListImpl.VideoMoveOrCopyCompletedL( aFailedCount, 
       
  1564                                                   media->ValueText( KMPXMediaGeneralTitle ) );
       
  1565         }
       
  1566     else
       
  1567         {
       
  1568         iVideoListImpl.VideoMoveOrCopyCompletedL( aFailedCount, 
       
  1569                                                   KNullDesC );
       
  1570         }
       
  1571     }
       
  1572 
       
  1573 // -----------------------------------------------------------------------------
       
  1574 // CVcxHgMyVideosVideoModelHandler::VideoDetailsCompletedL()
       
  1575 // MPX Collection calls this callback when details fetching is completed.
       
  1576 // -----------------------------------------------------------------------------
       
  1577 // 
       
  1578 void CVcxHgMyVideosVideoModelHandler::VideoDetailsCompletedL( const CMPXMedia& aMedia )
       
  1579     {
       
  1580     iVideoDetails->ShowVideoDetailsDialogL( aMedia );
       
  1581     }
       
  1582 
       
  1583 // -----------------------------------------------------------------------------
       
  1584 // CVcxHgMyVideosVideoModelHandler::UpdateScrollbarTypeL()
       
  1585 // Update scrollbar strip type depending on sort order
       
  1586 // -----------------------------------------------------------------------------
       
  1587 // 
       
  1588 void CVcxHgMyVideosVideoModelHandler::UpdateScrollbarTypeL( const TVcxMyVideosSortingOrder& aSortingOrder )
       
  1589     {
       
  1590     if ( EVcxMyVideosSortingName == aSortingOrder )
       
  1591         {
       
  1592         // First letter on strip
       
  1593         iScroller.SetScrollBarTypeL( CHgScroller::EHgScrollerLetterStripLite );        
       
  1594         }
       
  1595     else if ( EVcxMyVideosSortingCreationDate == aSortingOrder )
       
  1596         {
       
  1597         // Show date on strip
       
  1598         iScroller.SetScrollBarTypeL( CHgScroller::EHgScrollerTimeStrip );
       
  1599         }
       
  1600     else
       
  1601         {
       
  1602         // No strip
       
  1603         iScroller.SetScrollBarTypeL( CHgScroller::EHgScrollerScrollBar );
       
  1604         }
       
  1605     }