videocollection/hgmyvideos/src/vcxhgmyvideosvideolistimpl.cpp
changeset 0 96612d01cf9f
child 6 7d91903f795f
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:      Implementation of UI functionality for video list.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <StringLoader.h>
       
    22 #include <aknnotewrappers.h>
       
    23 #include <centralrepository.h>
       
    24 #include <AknsUtils.h>
       
    25 #include <AknUtils.h>
       
    26 #include <aknlayoutscalable_avkon.cdl.h>
       
    27 #include <bautils.h>  
       
    28 #include <gulicon.h>
       
    29 #include <fbs.h>
       
    30 
       
    31 #include <sendui.h>
       
    32 #include <SendUiConsts.h>
       
    33 #include <CMessageData.h>
       
    34 #include <MessagingDomainCRKeys.h>
       
    35 
       
    36 #include <ganes/HgScroller.h>
       
    37 #include <ganes/HgDoubleGraphicList.h>
       
    38 #include <AknWaitDialog.h> 
       
    39 
       
    40 #include <vcxhgmyvideos.rsg>
       
    41 #include <vcxhgmyvideosicons.mbg>
       
    42 #include <vcxmyvideosdefs.h>
       
    43 #include <myvideosindicator.h>
       
    44 #include "IptvDebug.h"
       
    45 
       
    46 #include <mpxplaybackutility.h>
       
    47 #include <mpxviewutility.h>
       
    48 #include <mpxcommandgeneraldefs.h>
       
    49 
       
    50 #include "vcxhgmyvideosvideolistimpl.h"
       
    51 #include "vcxhgmyvideosvideomodelhandler.h"
       
    52 #include "vcxhgmyvideosmodel.h"
       
    53 #include "vcxhgmyvideosmainview.h"
       
    54 #include "vcxhgmyvideoscollectionclient.h"
       
    55 #include "vcxhgmyvideos.hrh"
       
    56 #include "vcxhgmyvideosvideocopier.h"
       
    57 #include "vcxhgmyvideospanics.h"
       
    58 #include "vcxhgmyvideosupnpinterface.h"
       
    59 #include "vcxhgtelephonyclient.h"
       
    60 #include "vcxhgmyvideosaiwmenuhandler.h"
       
    61 
       
    62 _LIT( KVcxHgMyVideosMifFile, "\\resource\\apps\\vcxhgmyvideosicons.mif" );
       
    63 
       
    64 // ============================ MEMBER FUNCTIONS ===============================
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CVcxHgMyVideosVideoListImpl::NewL()
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CVcxHgMyVideosVideoListImpl* CVcxHgMyVideosVideoListImpl::NewL(
       
    71         CVcxHgMyVideosModel& aModel,
       
    72         CVcxHgMyVideosMainView& aView,
       
    73         CHgScroller& aScroller )
       
    74     {
       
    75     CVcxHgMyVideosVideoListImpl* self = 
       
    76         CVcxHgMyVideosVideoListImpl::NewLC( aModel, aView, aScroller );
       
    77     CleanupStack::Pop( self );
       
    78     return self;
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CVcxHgMyVideosVideoListImpl::NewLC()
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 CVcxHgMyVideosVideoListImpl* CVcxHgMyVideosVideoListImpl::NewLC(
       
    86         CVcxHgMyVideosModel& aModel,
       
    87         CVcxHgMyVideosMainView& aView,
       
    88         CHgScroller& aScroller )
       
    89     {
       
    90     CVcxHgMyVideosVideoListImpl* self = 
       
    91         new (ELeave) CVcxHgMyVideosVideoListImpl( aModel, aView, aScroller );
       
    92     CleanupStack::PushL( self );
       
    93     self->ConstructL();
       
    94     return self;
       
    95     }
       
    96     
       
    97 // -----------------------------------------------------------------------------
       
    98 // CVcxHgMyVideosVideoListImpl::CVcxHgMyVideosVideoListImpl()
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 CVcxHgMyVideosVideoListImpl::CVcxHgMyVideosVideoListImpl( 
       
   102         CVcxHgMyVideosModel& aModel,
       
   103         CVcxHgMyVideosMainView& aView,
       
   104         CHgScroller& aScroller )
       
   105   : CVcxHgMyVideosListBase( aModel, aView, aScroller ),
       
   106     iCurrentlyPlayedVideo( KErrNotFound ),
       
   107     iMultipleMarkingActive( EFalse ),
       
   108     iAiwMenuHandler( NULL )
       
   109     {
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CVcxHgMyVideosVideoListImpl::ConstructL()
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 void CVcxHgMyVideosVideoListImpl::ConstructL()
       
   117     {
       
   118     CVcxHgMyVideosListBase::ConstructL();
       
   119 
       
   120     iVideoModel = CVcxHgMyVideosVideoModelHandler::NewL( 
       
   121                       *this, iModel, iView, *iScroller );
       
   122 
       
   123     iVideoCopier = CVcxHgMyVideosVideoCopier::NewL( *this, *iVideoModel, iModel );
       
   124     
       
   125     iUPnP = CVcxHgMyVideosUPnPInterface::NewL( this );
       
   126     
       
   127     CFbsBitmap* bitmap( NULL );
       
   128     CFbsBitmap* mask( NULL );
       
   129     CGulIcon* defaultIcon( NULL );
       
   130     
       
   131     // Create default icon for Hg list.
       
   132     AknsUtils::CreateIconLC( AknsUtils::SkinInstance(), 
       
   133                              KAknsIIDQgnPropMtvProgClip,
       
   134                              bitmap,
       
   135                              mask,
       
   136                              KVcxHgMyVideosMifFile,
       
   137                              EMbmVcxhgmyvideosiconsQgn_prop_mtv_prog_clip,
       
   138                              EMbmVcxhgmyvideosiconsQgn_prop_mtv_prog_clip_mask );
       
   139     
       
   140     TInt error( KErrNone );
       
   141     error = AknIconUtils::SetSize( bitmap, 
       
   142                                    CHgDoubleGraphicList::PreferredImageSize(), 
       
   143                                    EAspectRatioPreservedAndUnusedSpaceRemoved );
       
   144     User::LeaveIfError( error );
       
   145     
       
   146     error = AknIconUtils::SetSize( mask, 
       
   147                                    CHgDoubleGraphicList::PreferredImageSize(), 
       
   148                                    EAspectRatioPreservedAndUnusedSpaceRemoved );
       
   149     User::LeaveIfError( error );
       
   150     
       
   151     // Ownership of bitmap and mask is transferred to icon.
       
   152     defaultIcon = CGulIcon::NewL( bitmap, mask );
       
   153     CleanupStack::Pop( 2 ); // bitmap and mask
       
   154     
       
   155     CleanupStack::PushL( defaultIcon );
       
   156              
       
   157     // Ownership of icon is transferred.
       
   158     iScroller->SetDefaultIconL( defaultIcon );
       
   159     CleanupStack::Pop( defaultIcon );
       
   160     
       
   161     CGulIcon* ind = iVideoModel->VideoIndicator().VideoOverlayIndicatorL();
       
   162     if ( ind )
       
   163         {
       
   164         CleanupStack::PushL( ind );
       
   165         // Ownership of the icon is transferred
       
   166         static_cast<CHgDoubleGraphicList*>( iScroller )->SetIconOverlayIndicator( ind );
       
   167         CleanupStack::Pop( ind );
       
   168         }
       
   169     
       
   170     iScroller->SetMarkingObserver( *this );
       
   171     iScroller->SetSelectionObserver( *this );
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CVcxHgMyVideosVideoListImpl::~CVcxHgMyVideosVideoListImpl()
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 CVcxHgMyVideosVideoListImpl::~CVcxHgMyVideosVideoListImpl()
       
   179     {
       
   180     CloseDeleteWaitNote();
       
   181     delete iTelephonyClient;
       
   182     delete iCenRep;
       
   183     delete iUPnP;
       
   184     delete iVideoCopier;
       
   185     delete iVideoModel;
       
   186     delete iSendUi;
       
   187     delete iAiwMenuHandler;
       
   188     }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CVcxHgMyVideosVideoListImpl::DoListActivateL()
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 void CVcxHgMyVideosVideoListImpl::DoListActivateL( TInt aIndex )
       
   195     {
       
   196     TInt index = aIndex;
       
   197     index = ( ( index != KErrNotFound ) ? index : iVideoModel->CurrentCategoryIndex() );
       
   198     index = ( ( index != KErrNotFound ) ? index : 0 );
       
   199 
       
   200     iVideoModel->UpdateVideoListL( index );
       
   201     
       
   202     iVideoModel->DoModelActivateL();
       
   203     CVcxHgMyVideosListBase::DoListActivateL( index );
       
   204     iScroller->SetFocus( ETrue );
       
   205     }
       
   206 
       
   207 // -----------------------------------------------------------------------------
       
   208 // CVcxHgMyVideosVideoListImpl::DoListDeactivate()
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 void CVcxHgMyVideosVideoListImpl::DoListDeactivate()
       
   212     {
       
   213     CVcxHgMyVideosListBase::DoListDeactivate();
       
   214     iVideoModel->DoModelDeactivate();
       
   215     iScroller->SetFocus( EFalse );
       
   216     }
       
   217 
       
   218 // -----------------------------------------------------------------------------
       
   219 // CVcxHgMyVideosVideoListImpl::VideoModel()
       
   220 // -----------------------------------------------------------------------------
       
   221 //
       
   222 CVcxHgMyVideosVideoModelHandler& CVcxHgMyVideosVideoListImpl::VideoModel()
       
   223     {
       
   224     return *iVideoModel;
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CVcxHgMyVideosVideoListImpl::UPnPInterface()
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 CVcxHgMyVideosUPnPInterface& CVcxHgMyVideosVideoListImpl::UPnPInterface()
       
   232     {
       
   233     return *iUPnP;
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CVcxHgMyVideosVideoListImpl::HandleSelectL()
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 void CVcxHgMyVideosVideoListImpl::HandleSelectL( TInt /*aIndex*/ )
       
   241     {
       
   242 	iView.DynInitMskL();
       
   243     }
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 // CVcxHgMyVideosVideoListImpl::HandleOpenL()
       
   247 // -----------------------------------------------------------------------------
       
   248 //
       
   249 void CVcxHgMyVideosVideoListImpl::HandleOpenL( TInt /*aIndex*/ )
       
   250     {
       
   251     if ( iModel.TouchSupport() )
       
   252         {    
       
   253         PlayCurrentVideoL();
       
   254         }
       
   255     }
       
   256 
       
   257 // -----------------------------------------------------------------------------
       
   258 // CVcxHgMyVideosVideoListImpl::HandleMarkingL()
       
   259 // -----------------------------------------------------------------------------
       
   260 //
       
   261 void CVcxHgMyVideosVideoListImpl::HandleMarkingL( TInt /*aIndex*/, TBool /*aMarked*/ )
       
   262     {    
       
   263     iView.DynInitMskL();
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 // CVcxHgMyVideosVideoListImpl::Highlight()
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 TInt CVcxHgMyVideosVideoListImpl::Highlight()
       
   271     {
       
   272     return iVideoModel->Highlight();
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CVcxHgMyVideosVideoListImpl::GetOperationTargetIndexesL()
       
   277 // Returns the index(es) of videos that should be the target for user's 
       
   278 // operation.
       
   279 // -----------------------------------------------------------------------------
       
   280 //
       
   281 void CVcxHgMyVideosVideoListImpl::GetOperationTargetIndexesL( 
       
   282         RArray<TInt>& aOperationTargets )
       
   283     {
       
   284     iVideoModel->MarkedVideosL( aOperationTargets );
       
   285 
       
   286     if ( aOperationTargets.Count() == 0 )
       
   287         {
       
   288         TInt highlight = Highlight();
       
   289         if ( highlight == KErrNotFound )
       
   290             {
       
   291             User::Leave( KErrNotFound );
       
   292             }
       
   293 
       
   294         aOperationTargets.AppendL( highlight );
       
   295         }
       
   296     }
       
   297 
       
   298 // -----------------------------------------------------------------------------
       
   299 // CVcxHgMyVideosVideoListImpl::PlayCurrentVideoL()
       
   300 // -----------------------------------------------------------------------------
       
   301 //
       
   302 void CVcxHgMyVideosVideoListImpl::PlayCurrentVideoL()
       
   303     {
       
   304     PlayVideoL();
       
   305     }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // CVcxHgMyVideosVideoListImpl::DeleteVideosL()
       
   309 // -----------------------------------------------------------------------------
       
   310 //
       
   311 void CVcxHgMyVideosVideoListImpl::DeleteVideosL()
       
   312     {
       
   313     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoListImpl::DeleteVideosL()" );
       
   314     RArray<TInt> operationTargets;
       
   315     CleanupClosePushL( operationTargets );
       
   316     
       
   317     GetOperationTargetIndexesL( operationTargets );
       
   318 
       
   319     if ( ConfirmDeleteVideosL( operationTargets.Count(),
       
   320                                iVideoModel->GetVideoName( operationTargets[0] ) ) )
       
   321         {
       
   322         HandleMarkCommandL( EVcxHgMyVideosCmdUnmarkAll );
       
   323 
       
   324         // Wait note is closed in destructor (CloseDeleteWaitNote()), 
       
   325         // in DialogDismissedL() or in VideoDeletionCompletedL().
       
   326         OpenDeleteWaitNoteL();
       
   327 
       
   328         iVideoModel->DeleteVideosL( operationTargets );
       
   329         }
       
   330     CleanupStack::PopAndDestroy( &operationTargets );
       
   331     }
       
   332 
       
   333 // -----------------------------------------------------------------------------
       
   334 // CVcxHgMyVideosVideoListImpl::ConfirmDeleteVideosL()
       
   335 // -----------------------------------------------------------------------------
       
   336 //
       
   337 TBool CVcxHgMyVideosVideoListImpl::ConfirmDeleteVideosL( TInt aTargetCount,
       
   338                                                          const TDesC& aTargetName )
       
   339     {
       
   340     HBufC* text = NULL;
       
   341 
       
   342     if ( aTargetCount == 1 )
       
   343         {
       
   344         text = StringLoader::LoadLC( R_VCXHGMYVIDEOS_QUERY_COMMON_CONF_DELETE, aTargetName );
       
   345         }
       
   346     else if ( aTargetCount > 1 )
       
   347         {
       
   348         text = StringLoader::LoadLC( R_VCXHGMYVIDEOS_FLDR_DEL_ITEMS_QUERY, aTargetCount );
       
   349         }
       
   350 
       
   351     if ( text )
       
   352         {
       
   353         CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   354 
       
   355         TInt result = dlg->ExecuteLD( R_VCXHGMYVIDEOS_DELETE_CONFIRMATION_QUERY, *text );
       
   356         CleanupStack::PopAndDestroy( text );
       
   357 
       
   358         if ( result == EAknSoftkeyYes || result == EAknSoftkeyOk )
       
   359             {
       
   360             return ETrue;
       
   361             }
       
   362         }
       
   363 
       
   364     return EFalse;
       
   365     }
       
   366 
       
   367 // -----------------------------------------------------------------------------
       
   368 // CVcxHgMyVideosVideoListImpl::OpenDeleteWaitNoteL()
       
   369 // -----------------------------------------------------------------------------
       
   370 //
       
   371 void CVcxHgMyVideosVideoListImpl::OpenDeleteWaitNoteL()
       
   372     {
       
   373     CloseDeleteWaitNote();
       
   374 
       
   375     iDeleteWaitDialog = new (ELeave) 
       
   376             CAknWaitDialog( ( REINTERPRET_CAST( CEikDialog**, &iDeleteWaitDialog ) ), ETrue );
       
   377     iDeleteWaitDialog->SetCallback( this );
       
   378     iDeleteWaitDialog->ExecuteLD( R_VCXHGMYVIDEOS_DELETING_WAIT_NOTE );
       
   379     }
       
   380 
       
   381 // -----------------------------------------------------------------------------
       
   382 // CVcxHgMyVideosVideoListImpl::CloseDeleteWaitNote()
       
   383 // -----------------------------------------------------------------------------
       
   384 //
       
   385 void CVcxHgMyVideosVideoListImpl::CloseDeleteWaitNote()
       
   386     {
       
   387     if ( iDeleteWaitDialog )
       
   388         {
       
   389         TRAPD( error, iDeleteWaitDialog->ProcessFinishedL() );
       
   390         if ( error != KErrNone )
       
   391             {
       
   392             delete iDeleteWaitDialog;
       
   393             }
       
   394         iDeleteWaitDialog = NULL;
       
   395         }
       
   396     }
       
   397 
       
   398 // -----------------------------------------------------------------------------
       
   399 // CVcxHgMyVideosVideoListImpl::CommandComplete()
       
   400 // -----------------------------------------------------------------------------
       
   401 //
       
   402 void CVcxHgMyVideosVideoListImpl::CommandComplete( TInt /*aStatusCode*/ )
       
   403     {
       
   404     // status larger than KErrNone does not require any attention.
       
   405     }
       
   406 
       
   407 // -----------------------------------------------------------------------------
       
   408 // CVcxHgMyVideosVideoListImpl::DialogDismissedL()
       
   409 // Callback about (delete) wait note dismissal.
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 void CVcxHgMyVideosVideoListImpl::DialogDismissedL( TInt aButtonId )
       
   413     {
       
   414     if ( aButtonId == EAknSoftkeyCancel )
       
   415         {
       
   416         iModel.CollectionClient().CancelDeleteVideosL();
       
   417         }
       
   418     
       
   419     iDeleteWaitDialog = NULL;
       
   420     }
       
   421 
       
   422 // -----------------------------------------------------------------------------
       
   423 // CVcxHgMyVideosVideoListImpl::VideoDeletionCompletedL()
       
   424 // -----------------------------------------------------------------------------
       
   425 // 
       
   426 void CVcxHgMyVideosVideoListImpl::VideoDeletionCompletedL( TInt aFailedCount,
       
   427                                                            const TDesC& aFailedName )
       
   428     {
       
   429     CloseDeleteWaitNote();
       
   430 
       
   431     if ( aFailedCount > 0 )
       
   432         {
       
   433         HBufC* text = NULL;
       
   434 
       
   435         if ( aFailedCount == 1 )
       
   436             {
       
   437             text = StringLoader::LoadLC( R_VCXHGMYVIDEOS_FLDR_CANT_DELETE_FILE_OPEN, aFailedName );
       
   438             }
       
   439         else
       
   440             {
       
   441             text = StringLoader::LoadLC( R_VCXHGMYVIDEOS_CANT_DELETE_ITEMS );
       
   442             }
       
   443 
       
   444         CAknErrorNote* note = new ( ELeave ) CAknErrorNote( ETrue );
       
   445         note->ExecuteLD( *text );
       
   446         CleanupStack::PopAndDestroy( text );  
       
   447         }    
       
   448     }
       
   449 
       
   450 // -----------------------------------------------------------------------------
       
   451 // CVcxHgMyVideosVideoListImpl::PlayVideoL()
       
   452 // -----------------------------------------------------------------------------
       
   453 //
       
   454 void CVcxHgMyVideosVideoListImpl::PlayVideoL()
       
   455     {
       
   456     RArray<TInt> operationTargets;
       
   457     CleanupClosePushL( operationTargets );
       
   458     
       
   459     GetOperationTargetIndexesL( operationTargets );
       
   460     HandleMarkCommandL( EVcxHgMyVideosCmdUnmarkAll );
       
   461     
       
   462     // Currently only play one video
       
   463     // Need to handle multiply selected videos
       
   464     for ( TInt i = operationTargets.Count() - 1; i >= 0; i-- )
       
   465         {
       
   466         CheckParentalControlL( iVideoModel->VideoAgeProfileL( operationTargets[i] ) );
       
   467 
       
   468         if( !iUPnP->IsStarted() )
       
   469             {    
       
   470             TVideoPlayerCustomMessage* videoInfo = new (ELeave) TVideoPlayerCustomMessage;
       
   471             CleanupStack::PushL( videoInfo );
       
   472             TInt mpxId1( 0 );
       
   473                        
       
   474             if ( iVideoModel->GetVideoPlayerCustomMessage( operationTargets[i], *videoInfo, mpxId1 )
       
   475                  == KErrNone )
       
   476                 {
       
   477                 iCurrentlyPlayedVideo = operationTargets[i];
       
   478        
       
   479                 iVideoModel->PlayVideoL( operationTargets[i] );
       
   480 
       
   481                 iModel.SetAppState( CVcxHgMyVideosModel::EVcxMyVideosAppStatePlayer );
       
   482                 iModel.SetVideoAsLastWatchedL( *videoInfo, mpxId1,
       
   483                    iVideoModel->VideoAgeProfileL( iCurrentlyPlayedVideo ) );
       
   484                 
       
   485                 //Sometimes MDS has database locked and this fails, we still want to start the playback -> trap ignore
       
   486                 TRAP_IGNORE( iVideoModel->ClearNewVideoIndicatorL( iCurrentlyPlayedVideo ) );
       
   487                 }
       
   488             else
       
   489                 {
       
   490                 // Error notes?
       
   491                 }
       
   492             CleanupStack::PopAndDestroy( videoInfo );
       
   493             }
       
   494         else // UPnP started
       
   495             {
       
   496             TInt err(KErrNone); 
       
   497             
       
   498             err = iUPnP->ShowVideo( iVideoModel->GetVideoUri( operationTargets[0] ) );
       
   499 
       
   500             if( err != KErrNone )
       
   501                 {
       
   502                 // some general upnp framework error, 
       
   503                 // call stop to deallocate
       
   504                 iUPnP->Stop();
       
   505                 }
       
   506             }        
       
   507         break;
       
   508         }
       
   509     
       
   510     CleanupStack::PopAndDestroy( &operationTargets );
       
   511     }
       
   512 
       
   513 // -----------------------------------------------------------------------------
       
   514 // CVcxHgMyVideosVideoListImpl::ResumeDownloadL()
       
   515 // -----------------------------------------------------------------------------
       
   516 //
       
   517 void CVcxHgMyVideosVideoListImpl::ResumeDownloadL()
       
   518     {
       
   519     iVideoModel->ResumeDownloadL( Highlight() );
       
   520     }
       
   521 
       
   522 // -----------------------------------------------------------------------------
       
   523 // CVcxHgMyVideosVideoListImpl::CancelDownloadL()
       
   524 // -----------------------------------------------------------------------------
       
   525 //
       
   526 void CVcxHgMyVideosVideoListImpl::CancelDownloadL()
       
   527     {
       
   528     iVideoModel->CancelDownloadL( Highlight() );   
       
   529     }
       
   530 
       
   531 // -----------------------------------------------------------------------------
       
   532 // CVcxHgMyVideosVideoListImpl::HandleSortCommandL()
       
   533 // -----------------------------------------------------------------------------
       
   534 //
       
   535 void CVcxHgMyVideosVideoListImpl::HandleSortCommandL( TInt aSortCommand )
       
   536     {
       
   537     TVcxMyVideosSortingOrder currentOrder = iModel.VideolistSortOrderL();
       
   538     TVcxMyVideosSortingOrder wantedOrder( EVcxMyVideosSortingNone );
       
   539         
       
   540     switch ( aSortCommand )
       
   541         {
       
   542         case EVcxHgMyVideosCmdSortByDate:
       
   543             {
       
   544             wantedOrder = EVcxMyVideosSortingCreationDate;
       
   545             break;
       
   546             }
       
   547         case EVcxHgMyVideosCmdSortByName:
       
   548             {
       
   549             wantedOrder = EVcxMyVideosSortingName;
       
   550             break;
       
   551             }            
       
   552         case EVcxHgMyVideosCmdSortBySize:
       
   553             {
       
   554             wantedOrder = EVcxMyVideosSortingSize;
       
   555             break;
       
   556             }
       
   557         default:
       
   558             {
       
   559             User::Leave( KErrNotSupported );
       
   560             break;
       
   561             }
       
   562         }
       
   563 
       
   564     if ( currentOrder != wantedOrder )
       
   565         {
       
   566         iModel.SetVideolistSortOrderL( wantedOrder );
       
   567         iVideoModel->ResortVideoListL();
       
   568         }
       
   569     }
       
   570 
       
   571 // -----------------------------------------------------------------------------
       
   572 // CVcxHgMyVideosVideoListImpl::ShowMarkMenuItemsL()
       
   573 // -----------------------------------------------------------------------------
       
   574 //
       
   575 void CVcxHgMyVideosVideoListImpl::ShowMarkMenuItemsL( 
       
   576         TBool& aShowMarkSubmenu,
       
   577         TBool& showStartMarking,
       
   578         TBool& showEndMarking, 
       
   579         TBool& aShowMarkAll,
       
   580         TBool& aShowUnmarkAll )
       
   581     {
       
   582     RArray<TInt> markedVideos;
       
   583     CleanupClosePushL( markedVideos );
       
   584     
       
   585     iVideoModel->MarkedVideosL( markedVideos );
       
   586     
       
   587     TInt count = iVideoModel->VideoCount();
       
   588     TInt highlight = Highlight();
       
   589 
       
   590     // Set menu visibility information.
       
   591     showStartMarking = !iMultipleMarkingActive;
       
   592     showEndMarking = iMultipleMarkingActive;
       
   593     aShowMarkAll = ( ( count > 0 ) && ( markedVideos.Count() < count ) );
       
   594     aShowUnmarkAll = ( ( count > 0 ) && ( markedVideos.Count() > 0 ) );
       
   595     aShowMarkSubmenu = ( showStartMarking || showEndMarking || aShowMarkAll || aShowUnmarkAll );
       
   596     
       
   597     CleanupStack::PopAndDestroy( &markedVideos );
       
   598     }
       
   599 
       
   600 // -----------------------------------------------------------------------------
       
   601 // CVcxHgMyVideosVideoListImpl::HandleMarkCommandL()
       
   602 // -----------------------------------------------------------------------------
       
   603 //
       
   604 void CVcxHgMyVideosVideoListImpl::HandleMarkCommandL( TInt aMarkCommand )
       
   605     {
       
   606     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoListImpl::HandleMarkCommandL()" );
       
   607     
       
   608     switch ( aMarkCommand )
       
   609         {
       
   610         case EVcxHgMyVideosCmdToggleMultipleMarking:
       
   611             {
       
   612             StartMarkingMode();
       
   613             break;
       
   614             }
       
   615         case EVcxHgMyVideosCmdStopMarking:
       
   616             {
       
   617             EndMarkingMode();
       
   618             break;
       
   619             }
       
   620         case EVcxHgMyVideosCmdMark:
       
   621         case EVcxHgMyVideosCmdMarkAll:
       
   622             {
       
   623             iVideoModel->HandleMarkCommandL( aMarkCommand );
       
   624             StartMarkingMode();
       
   625             break;
       
   626             }
       
   627         case EVcxHgMyVideosCmdUnmark:
       
   628         case EVcxHgMyVideosCmdUnmarkAll:
       
   629             {
       
   630             iVideoModel->HandleMarkCommandL( aMarkCommand );
       
   631             EndMarkingMode();
       
   632             break;
       
   633             }
       
   634         }
       
   635     
       
   636     iView.DynInitMskL();
       
   637     iView.DynInitRskL();
       
   638     }
       
   639 
       
   640 // -----------------------------------------------------------------------------
       
   641 // CVcxHgMyVideosVideoListImpl::ShowMoveAndCopyMenuItemsL()
       
   642 // -----------------------------------------------------------------------------
       
   643 //
       
   644 void CVcxHgMyVideosVideoListImpl::ShowMoveAndCopyMenuItemsL( 
       
   645         TBool& aShowMoveAndCopySubmenu, TBool& aShowCopy, TBool& aShowMove )
       
   646     {
       
   647     RArray<TInt> operationTargets;
       
   648     CleanupClosePushL( operationTargets );
       
   649     
       
   650     TRAPD( error, GetOperationTargetIndexesL( operationTargets ) );
       
   651 
       
   652     if ( error != KErrNone )
       
   653         {
       
   654         aShowMoveAndCopySubmenu = aShowCopy = aShowMove = EFalse;
       
   655         }
       
   656 	else
       
   657         {
       
   658         iVideoCopier->ShowMenuItemsL( operationTargets, 
       
   659                                       aShowMoveAndCopySubmenu,
       
   660                                       aShowCopy,
       
   661                                       aShowMove );
       
   662         }
       
   663     
       
   664     CleanupStack::PopAndDestroy( &operationTargets );
       
   665     }
       
   666 
       
   667 // -----------------------------------------------------------------------------
       
   668 // CVcxHgMyVideosVideoListImpl::HandleMoveOrCopyCommandL() 
       
   669 // -----------------------------------------------------------------------------
       
   670 //
       
   671 void CVcxHgMyVideosVideoListImpl::HandleMoveOrCopyCommandL( TBool aCopy )
       
   672     {
       
   673     RArray<TInt> operationTargets;
       
   674     CleanupClosePushL( operationTargets );
       
   675     
       
   676     GetOperationTargetIndexesL( operationTargets );
       
   677     HandleMarkCommandL( EVcxHgMyVideosCmdUnmarkAll );
       
   678     iVideoCopier->MoveOrCopyL( operationTargets, aCopy );
       
   679     
       
   680     CleanupStack::PopAndDestroy( &operationTargets );
       
   681     }
       
   682 
       
   683 // -----------------------------------------------------------------------------
       
   684 // CVcxHgMyVideosVideoListImpl::VideoMoveOrCopyCompletedL()
       
   685 // -----------------------------------------------------------------------------
       
   686 //
       
   687 void CVcxHgMyVideosVideoListImpl::VideoMoveOrCopyCompletedL( TInt aFailedCount,
       
   688                                                              const TDesC& aFailedName )
       
   689     {
       
   690     iVideoCopier->VideoMoveOrCopyCompletedL( aFailedCount, aFailedName );
       
   691     }
       
   692 
       
   693 // -----------------------------------------------------------------------------
       
   694 // CVcxHgMyVideosVideoListImpl::ShowResumeStartsFromBeginningNoteL() 
       
   695 // -----------------------------------------------------------------------------
       
   696 //
       
   697 void CVcxHgMyVideosVideoListImpl::ShowResumeStartsFromBeginningNoteL()
       
   698     {
       
   699     HBufC* text = StringLoader::LoadLC( R_VCXHGMYVIDEOS_RESUME_NOT_POSSIBLE );
       
   700     CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue );
       
   701     note->ExecuteLD( *text );
       
   702     CleanupStack::PopAndDestroy( text );     
       
   703     }
       
   704 
       
   705 // ------------------------------------------------------------------------------
       
   706 // CVcxHgMyVideosVideoListImpl::DynInitMenuPaneL()
       
   707 // ------------------------------------------------------------------------------
       
   708 //
       
   709 void CVcxHgMyVideosVideoListImpl::DynInitMenuPaneL( TInt aResourceId,
       
   710                                                     CEikMenuPane* aMenuPane )
       
   711     {
       
   712     if ( AiwMenuHandlerL()->TryHandleSubmenuL( aMenuPane ) )
       
   713         {
       
   714         // Submenu was initialized by Aiw
       
   715         return;
       
   716         }
       
   717 
       
   718     RArray<TInt> markedVideos;
       
   719     CleanupClosePushL( markedVideos );
       
   720     
       
   721     iVideoModel->MarkedVideosL( markedVideos );
       
   722     TInt highlight = Highlight();        
       
   723     TInt count = iVideoModel->VideoCount();
       
   724 
       
   725     TVcxMyVideosDownloadState dlState( EVcxMyVideosDlStateNone );
       
   726     TBool progressivePlay( EFalse );
       
   727     
       
   728     if ( count > 0 && highlight >= 0 )
       
   729         {
       
   730         dlState = iVideoModel->VideoDownloadState( highlight );
       
   731         progressivePlay = iVideoModel->IsProgressivePlayPossible( highlight );
       
   732         }
       
   733 
       
   734     // Check if there are marked items on the list that can be deleted
       
   735     TBool itemsToDelete( EFalse );
       
   736     
       
   737     for ( TInt i = 0; i < markedVideos.Count(); i++ )
       
   738         {
       
   739         if ( iVideoModel->VideoDownloadState( markedVideos[i] ) == EVcxMyVideosDlStateNone )
       
   740             {    
       
   741             itemsToDelete = ETrue;
       
   742             break;
       
   743             }
       
   744         }
       
   745 
       
   746     TBool showDelete = ( ( highlight >= 0 ) && ( count > 0 ) 
       
   747                          && ( ( dlState == EVcxMyVideosDlStateNone && markedVideos.Count() == 0 ) 
       
   748                          || itemsToDelete ) );
       
   749     
       
   750     if ( aResourceId == R_VCXHGMYVIDEOS_MAINVIEW_MENU )
       
   751         {      
       
   752         if ( ! iModel.TouchSupport() )
       
   753             {
       
   754             TBool showPlay = ( ( markedVideos.Count() == 0 ) && ( highlight >= 0 ) && ( count > 0 )
       
   755                            && ( ( dlState == EVcxMyVideosDlStateNone ) || ( progressivePlay ) ) );
       
   756             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdPlay, ! showPlay );
       
   757             }
       
   758 
       
   759         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdDelete, ! showDelete );
       
   760 
       
   761         TBool showCancel = ( ( markedVideos.Count() == 0 ) && ( highlight >= 0 ) && ( count > 0 )
       
   762                              && ( dlState != EVcxMyVideosDlStateNone ) );
       
   763         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdCancelDownload, ! showCancel );
       
   764 
       
   765         TBool showResume = showCancel && ( ( dlState == EVcxMyVideosDlStatePaused ) ||
       
   766                                            ( dlState == EVcxMyVideosDlStateFailed ) );
       
   767         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdResumeDownload, ! showResume );
       
   768 
       
   769         TBool showVideoDetails = ( ( markedVideos.Count() == 0 ) &&
       
   770                                    ( highlight >= 0 ) && 
       
   771                                    ( count > 0 ) && 
       
   772                                    ( ( dlState == EVcxMyVideosDlStateNone ) ||
       
   773                                      ( progressivePlay ) ) );        
       
   774         
       
   775         // Dont show file details if file isn't downloaded yet.
       
   776         if( ( VideoModel().VideoDownloadState( Highlight() ) == EVcxMyVideosDlStateDownloading ) ||
       
   777             ( VideoModel().VideoDownloadState( Highlight() ) == EVcxMyVideosDlStateFailed ) ||
       
   778             ( VideoModel().VideoDownloadState( Highlight() ) == EVcxMyVideosDlStatePaused ) )
       
   779             {
       
   780             showVideoDetails = EFalse;
       
   781             }
       
   782         
       
   783         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdVideoDetails, ! showVideoDetails );        
       
   784 
       
   785         // UPnP menu item. Item's behaviour follows video details item.     
       
   786         if ( showVideoDetails && count > 0 && highlight >= 0 && iUPnP->IsApplicable() )
       
   787             {
       
   788             if ( iUPnP->IsStarted() )
       
   789                 {
       
   790                 aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdStopShowViaHomenet, EFalse);
       
   791                 }
       
   792             else
       
   793                 {
       
   794                 aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdShowViaHomenet, EFalse );
       
   795                 }
       
   796             }
       
   797         
       
   798         // Send menu item.
       
   799         if ( ( highlight >= 0 ) && ( count > 0 ) &&
       
   800                 ( dlState == EVcxMyVideosDlStateNone ) )
       
   801             {
       
   802             // Get total size for marked videos
       
   803             RArray<TInt> operationTargets;
       
   804             CleanupClosePushL( operationTargets );
       
   805             
       
   806             GetOperationTargetIndexesL( operationTargets );
       
   807             TInt64 attachmentsTotalSize( 0 );
       
   808             for ( TInt i = 0; i < operationTargets.Count(); i++ )
       
   809                 {
       
   810                 attachmentsTotalSize += iVideoModel->GetVideoSize( operationTargets[i] );
       
   811                 }
       
   812 
       
   813             IPTVLOGSTRING3_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::DynInitMenuPaneL() %d files with total size %ld", operationTargets.Count(), attachmentsTotalSize );
       
   814             
       
   815             // SendUi uses TInt for size, hide Send menu item for over 2GB attachments
       
   816             if ( attachmentsTotalSize > 0 && attachmentsTotalSize < KMaxTInt )
       
   817                 {
       
   818                 // Place Send menu item on top of "Use as" (Assign) submenu
       
   819                 TInt sendItemIndex = 0;
       
   820                 aMenuPane->ItemAndPos( EVcxHgMyVideosCmdAiwAssign, sendItemIndex );
       
   821                 // Add Send item to menu
       
   822                 TSendingCapabilities capabilities(
       
   823                     0,
       
   824                     attachmentsTotalSize,
       
   825                     TSendingCapabilities::ESupportsAttachments );
       
   826                 SendUiL()->AddSendMenuItemL(
       
   827                         *aMenuPane,
       
   828                         sendItemIndex,
       
   829                         EVcxHgMyVideosCmdSend,
       
   830                         capabilities );
       
   831                 aMenuPane->SetItemSpecific( EVcxHgMyVideosCmdSend, ETrue );
       
   832 
       
   833                 // The Send item also needs to be flagged as a list query.
       
   834                 CEikMenuPaneItem::SData& itemData = aMenuPane->ItemData( EVcxHgMyVideosCmdSend );
       
   835                 itemData.iFlags |= EEikMenuItemSpecificListQuery;
       
   836                 }
       
   837             CleanupStack::PopAndDestroy( &operationTargets );
       
   838             }
       
   839 
       
   840         // Assign (use as) menu item
       
   841         if ( ( markedVideos.Count() == 0 ) &&
       
   842                 ( highlight >= 0 ) && ( count > 0 ) &&
       
   843                 ( ( dlState == EVcxMyVideosDlStateNone ) ) )
       
   844             {
       
   845             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdAiwAssign, EFalse );
       
   846             }
       
   847         else
       
   848             {
       
   849             // Hide Assign (use as) menu item
       
   850             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdAiwAssign, ETrue );
       
   851             }
       
   852 
       
   853         // Marking submenu
       
   854         if( count > 0 )
       
   855             {
       
   856             // Show "Mark/Unmark" only if there are videos in the list
       
   857             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMarkUnmarkSubMenu, EFalse);
       
   858             }
       
   859 
       
   860         // "Sort by" submenu
       
   861         if( count == 0 )
       
   862             {
       
   863             // Dont show "Sort by" if list is empty.
       
   864             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdSortSubMenu, ETrue );
       
   865             }
       
   866         }
       
   867     else if ( aResourceId == R_VCXHGMYVIDEOS_USE_AS_SUBMENU )
       
   868         {
       
   869         RArray<TInt> operationTargets;
       
   870         CleanupClosePushL( operationTargets );
       
   871 
       
   872         GetOperationTargetIndexesL( operationTargets );
       
   873         if ( operationTargets.Count() > 0 )
       
   874             {
       
   875             HBufC* videoUri = iVideoModel->GetVideoUri( operationTargets[0] ).AllocLC();
       
   876             if ( videoUri->Length() 
       
   877                     && BaflUtils::FileExists( iModel.FileServerSessionL(), *videoUri ) )
       
   878                 {
       
   879                 AiwMenuHandlerL()->InitializeMenuPaneL(
       
   880                         aResourceId,
       
   881                         aMenuPane,
       
   882                         *videoUri,
       
   883                         KNullDesC );    //mime type
       
   884                 }
       
   885             CleanupStack::PopAndDestroy( videoUri );
       
   886             }
       
   887         CleanupStack::PopAndDestroy( &operationTargets );
       
   888         }
       
   889     CleanupStack::PopAndDestroy( &markedVideos );
       
   890     }
       
   891 
       
   892 // -----------------------------------------------------------------------------
       
   893 // CVcxHgMyVideosVideoListImpl::SetEmptyListTextL()
       
   894 // -----------------------------------------------------------------------------
       
   895 //
       
   896 void CVcxHgMyVideosVideoListImpl::SetEmptyListTextL()
       
   897     {
       
   898     CVcxHgMyVideosListBase::SetEmptyListTextByResourceL( R_VCXHGMYVIDEOS_OPENING_VIDEOS );
       
   899     }
       
   900 
       
   901 // -----------------------------------------------------------------------------
       
   902 // CVcxHgMyVideosVideoListImpl::SetTitleTextL()
       
   903 // -----------------------------------------------------------------------------
       
   904 //
       
   905 void CVcxHgMyVideosVideoListImpl::SetTitleTextL( TInt aIndex )
       
   906     {
       
   907     switch ( aIndex )
       
   908         {
       
   909         case KVcxMvcCategoryIdAll:
       
   910             CVcxHgMyVideosListBase::SetTitleTextByResourceL( R_VCXHGMYVIDEOS_ALL_VIDEOS_TITLE );
       
   911             break;
       
   912         case KVcxMvcCategoryIdDownloads:
       
   913             CVcxHgMyVideosListBase::SetTitleTextByResourceL( R_VCXHGMYVIDEOS_DOWNLOADS_TITLE );
       
   914             break;
       
   915         case KVcxMvcCategoryIdCaptured:
       
   916             CVcxHgMyVideosListBase::SetTitleTextByResourceL( R_VCXHGMYVIDEOS_CAPTURED_TITLE );
       
   917             break;
       
   918         case KVcxMvcCategoryIdOther:
       
   919             CVcxHgMyVideosListBase::SetTitleTextByResourceL( R_VCXHGMYVIDEOS_OTHER_TITLE );
       
   920             break;
       
   921         default:
       
   922             {
       
   923             IPTVLOGSTRING_LOW_LEVEL(
       
   924                 "MPX My Videos UI # ...VideoListImpl::SetTitleTextL() Unexpected category!" );
       
   925             }
       
   926             break;
       
   927         }
       
   928     }
       
   929 
       
   930 // -----------------------------------------------------------------------------
       
   931 // CVcxHgMyVideosVideoListImpl::GetMskResourceL()
       
   932 // -----------------------------------------------------------------------------
       
   933 //
       
   934 TInt CVcxHgMyVideosVideoListImpl::GetMskResourceL()
       
   935     {
       
   936     RArray<TInt> markedVideos;
       
   937     CleanupClosePushL( markedVideos );
       
   938     
       
   939     iVideoModel->MarkedVideosL( markedVideos );
       
   940     TInt highlight = Highlight();
       
   941     TInt count = iVideoModel->VideoCount();
       
   942     TVcxMyVideosDownloadState dlState( EVcxMyVideosDlStateNone );
       
   943     TBool progressivePlay( EFalse );
       
   944     if ( count > 0 && highlight >= 0 )
       
   945         {
       
   946         dlState = iVideoModel->VideoDownloadState( highlight );
       
   947         progressivePlay = iVideoModel->IsProgressivePlayPossible( highlight );
       
   948         }
       
   949     TBool showPlay = ( ( markedVideos.Count() == 0 ) && ( highlight >= 0 ) && ( count > 0 )
       
   950                        && ( ( dlState == EVcxMyVideosDlStateNone ) || ( progressivePlay ) ) );
       
   951     
       
   952     CleanupStack::PopAndDestroy( &markedVideos );
       
   953     
       
   954     if ( showPlay )
       
   955         {
       
   956         return R_VCXHGMYVIDEOS_MSK_PLAY;
       
   957         }
       
   958     else if ( count == 0 )
       
   959         {
       
   960         return R_VCXHGMYVIDEOS_MSK_NOTHING;
       
   961         }
       
   962     else
       
   963         {
       
   964         return R_VCXHGMYVIDEOS_MSK_CONTEXTMENU;
       
   965         }
       
   966     }
       
   967 
       
   968 // -----------------------------------------------------------------------------
       
   969 // CVcxHgMyVideosVideoListImpl::CheckParentalControlL()
       
   970 // -----------------------------------------------------------------------------
       
   971 //
       
   972 void CVcxHgMyVideosVideoListImpl::CheckParentalControlL( TUint32 aAgeProfile )
       
   973     {
       
   974     TInt parentControlSetting( KVcxMyvideosCenRepParentControlKeyDefault );
       
   975     TInt error( KErrNone );
       
   976     if ( !iCenRep )
       
   977         {
       
   978         TRAP( error, iCenRep = CRepository::NewL( TUid::Uid( KVcxMyVideosCenRepUid ) ) )
       
   979         }
       
   980     if ( error == KErrNone )
       
   981         {
       
   982         error = iCenRep->Get( KVcxMyvideosCenRepParentControlKey, parentControlSetting );
       
   983         if ( error == KErrNone && parentControlSetting != KVcxMyvideosCenRepParentControlKeyOff )
       
   984             {
       
   985             // Parental control has been set
       
   986             if ( static_cast<TInt>( aAgeProfile ) >= parentControlSetting )
       
   987                 {
       
   988                 // Must ask lock code to allow playing
       
   989                 if ( !iTelephonyClient )
       
   990                     {
       
   991                     iTelephonyClient = new( ELeave ) CVcxHgTelephonyClient();
       
   992                     }
       
   993                 if ( !iTelephonyClient->CheckLockCodeL() )
       
   994                     {
       
   995                     User::Leave( KErrPermissionDenied );
       
   996                     }
       
   997                 }
       
   998             }
       
   999         }
       
  1000     }
       
  1001 
       
  1002 // ---------------------------------------------------------------------------
       
  1003 // CVcxHgMyVideosVideoListImpl::StartMarkingMode()
       
  1004 // ---------------------------------------------------------------------------
       
  1005 //  
       
  1006 void CVcxHgMyVideosVideoListImpl::StartMarkingMode()
       
  1007     {
       
  1008     IPTVLOGSTRING2_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoListImpl::StartMarkingMode() iMultipleMarkingActive = %d", iMultipleMarkingActive );
       
  1009     
       
  1010     // Start multiple marking mode
       
  1011     if ( iModel.TouchSupport() )
       
  1012         {
       
  1013         iScroller->SetFlags( CHgScroller::EHgScrollerSelectionMode );
       
  1014         iMultipleMarkingActive = ETrue;
       
  1015         }
       
  1016     }
       
  1017 
       
  1018 // ---------------------------------------------------------------------------
       
  1019 // CVcxHgMyVideosVideoListImpl::EndMarkingMode()
       
  1020 // ---------------------------------------------------------------------------
       
  1021 //  
       
  1022 void CVcxHgMyVideosVideoListImpl::EndMarkingMode()
       
  1023     {
       
  1024     IPTVLOGSTRING2_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoListImpl::EndMarkingMode() iMultipleMarkingActive = %d", iMultipleMarkingActive );
       
  1025 
       
  1026     // End multiple marking mode
       
  1027     iScroller->ClearFlags( CHgScroller::EHgScrollerSelectionMode );
       
  1028     iMultipleMarkingActive = EFalse;
       
  1029     }
       
  1030 
       
  1031 // ---------------------------------------------------------------------------
       
  1032 // CVcxHgMyVideosVideoListImpl::HandleSendL()
       
  1033 // ---------------------------------------------------------------------------
       
  1034 //  
       
  1035 void CVcxHgMyVideosVideoListImpl::HandleSendL()
       
  1036     {
       
  1037     IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::HandleSendL() ENTER" );
       
  1038 
       
  1039     // Create message and disabled transports filter
       
  1040     CMessageData* message = CMessageData::NewLC();
       
  1041     CArrayFixFlat< TUid >* mtmFilter = new( ELeave ) CArrayFixFlat< TUid >( 1 );
       
  1042     CleanupStack::PushL( mtmFilter );
       
  1043 
       
  1044     if ( MessagingConfL() & KMuiuEmailDisabledInMultimedia )
       
  1045         {
       
  1046         IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::HandleSendL() send via email disabled" );
       
  1047         // Send via email disabled in CenRep, add to filter to disable
       
  1048         mtmFilter->AppendL( KSenduiMtmSmtpUid );
       
  1049         mtmFilter->AppendL( KSenduiMtmSyncMLEmailUid );
       
  1050         }
       
  1051 
       
  1052     // Get the selected video(s) and attach
       
  1053     RArray<TInt> operationTargets;
       
  1054     CleanupClosePushL( operationTargets );
       
  1055     
       
  1056     GetOperationTargetIndexesL( operationTargets );
       
  1057     TInt64 attachmentsTotalSize( 0 );
       
  1058 
       
  1059     IPTVLOGSTRING2_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::HandleSendL() targets count: %d", operationTargets.Count() );
       
  1060     for ( TInt i = 0; i < operationTargets.Count(); i++ )
       
  1061         {
       
  1062         HBufC* videoUri = iVideoModel->GetVideoUri( operationTargets[i] ).AllocLC();
       
  1063         TInt64 videoSize = iVideoModel->GetVideoSize( operationTargets[i] );
       
  1064         TVcxMyVideosDownloadState dlState = iVideoModel->VideoDownloadState( operationTargets[i] );
       
  1065 
       
  1066         IPTVLOGSTRING3_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::HandleSendL() file: %S (%ld bytes)", videoUri, videoSize );
       
  1067 
       
  1068         // Attach file to message
       
  1069         if ( videoUri->Length() > 0 &&
       
  1070                 videoSize > 0 &&
       
  1071                 EVcxMyVideosDlStateNone == dlState )
       
  1072             {
       
  1073             message->AppendAttachmentL( *videoUri );
       
  1074             attachmentsTotalSize += videoSize;
       
  1075             }
       
  1076 
       
  1077         CleanupStack::PopAndDestroy( videoUri );
       
  1078         }
       
  1079 
       
  1080     // Send message if it has attachment(s)
       
  1081     TSendingCapabilities capabilities( 0, attachmentsTotalSize, TSendingCapabilities::ESupportsAttachments );
       
  1082     if ( message->AttachmentArray().MdcaCount() > 0 )
       
  1083         {
       
  1084         IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::HandleSendL() send message" );
       
  1085         SendUiL()->ShowQueryAndSendL( message, capabilities, mtmFilter, KNullUid, EFalse );
       
  1086         HandleMarkCommandL( EVcxHgMyVideosCmdUnmarkAll );
       
  1087         }
       
  1088 
       
  1089     CleanupStack::PopAndDestroy( &operationTargets );
       
  1090     CleanupStack::PopAndDestroy( mtmFilter );
       
  1091     CleanupStack::PopAndDestroy( message );
       
  1092 
       
  1093     IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::HandleSendL() EXIT" );
       
  1094     }
       
  1095 
       
  1096 // ---------------------------------------------------------------------------
       
  1097 // CVcxHgMyVideosVideoListImpl::MessagingConfL()
       
  1098 // ---------------------------------------------------------------------------
       
  1099 //
       
  1100 TInt CVcxHgMyVideosVideoListImpl::MessagingConfL()
       
  1101     {
       
  1102     IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::MessagingConfL()" );
       
  1103     TInt messagingConf;
       
  1104     CRepository* cenrep = CRepository::NewL( KCRUidMuiuMessagingConfiguration );
       
  1105     TInt cenrepErr( cenrep->Get( KMuiuSendUiConfiguration, messagingConf ) );
       
  1106     delete cenrep;
       
  1107     User::LeaveIfError( cenrepErr );
       
  1108     return messagingConf;
       
  1109     }
       
  1110 
       
  1111 // ---------------------------------------------------------------------------
       
  1112 // CVcxHgMyVideosVideoListImpl::SendUi()
       
  1113 // ---------------------------------------------------------------------------
       
  1114 //
       
  1115 CSendUi* CVcxHgMyVideosVideoListImpl::SendUiL()
       
  1116     {
       
  1117     if ( !iSendUi )
       
  1118         {
       
  1119         iSendUi = CSendUi::NewL();
       
  1120         }
       
  1121     return iSendUi;
       
  1122     }
       
  1123 
       
  1124 // ---------------------------------------------------------------------------
       
  1125 // CVcxHgMyVideosVideoListImpl::TryHandleAiwCommandL()
       
  1126 // ---------------------------------------------------------------------------
       
  1127 //
       
  1128 void CVcxHgMyVideosVideoListImpl::TryHandleAiwCommandL( TInt aCommand )
       
  1129     {
       
  1130     if ( AiwMenuHandlerL()->IsAiwCommand( aCommand ) )
       
  1131         {
       
  1132         // Call AIW service handler
       
  1133         RArray<TInt> operationTargets;
       
  1134         CleanupClosePushL( operationTargets );
       
  1135         
       
  1136         GetOperationTargetIndexesL( operationTargets );
       
  1137         if ( operationTargets.Count() > 0 )
       
  1138             {
       
  1139             HBufC* videoUri = iVideoModel->GetVideoUri( operationTargets[0] ).AllocLC();
       
  1140             if ( videoUri->Length() )
       
  1141                 {
       
  1142                 AiwMenuHandlerL()->HandleAiwCommandL(
       
  1143                         aCommand,
       
  1144                         *videoUri,
       
  1145                         KNullDesC );    //mime type
       
  1146                 }
       
  1147             CleanupStack::PopAndDestroy( videoUri );
       
  1148             }
       
  1149         CleanupStack::PopAndDestroy( &operationTargets );
       
  1150         }
       
  1151     }
       
  1152 
       
  1153 // ---------------------------------------------------------------------------
       
  1154 // CVcxHgMyVideosVideoListImpl::IsMarking()
       
  1155 // ---------------------------------------------------------------------------
       
  1156 //
       
  1157 TBool CVcxHgMyVideosVideoListImpl::IsMarking()
       
  1158     {
       
  1159     TBool ret( EFalse );
       
  1160     
       
  1161     if( iScroller->Flags() & CHgScroller::EHgScrollerSelectionMode )
       
  1162         {
       
  1163         ret = ETrue;
       
  1164         }
       
  1165     return ret;
       
  1166     }
       
  1167 
       
  1168 // ---------------------------------------------------------------------------
       
  1169 // CVcxHgMyVideosVideoListImpl::AiwMenuHandlerL()
       
  1170 // ---------------------------------------------------------------------------
       
  1171 //
       
  1172 CHgMyVideosAiwMenuHandler* CVcxHgMyVideosVideoListImpl::AiwMenuHandlerL()
       
  1173     {
       
  1174     if ( !iAiwMenuHandler )
       
  1175         {
       
  1176         iAiwMenuHandler = new (ELeave) CHgMyVideosAiwMenuHandler();
       
  1177         iAiwMenuHandler->AttachMenuL( R_VCXHGMYVIDEOS_USE_AS_SUBMENU );
       
  1178         }
       
  1179     return iAiwMenuHandler;
       
  1180     }