mmsharing/mmshui/src/musuiclipsharingviewcontainer.cpp
branchRCL_3
changeset 33 bc78a40cd63c
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
       
     1 /*
       
     2 * Copyright (c) 2005 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 "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:  The MUS application's UI class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "musuidefinitions.h"
       
    20 #include "musuiclipsharingviewcontainer.h"
       
    21 #include "musuieventcontroller.h"
       
    22 #include "musuilevelindicator.h"
       
    23 #include "musuiclipsharingview.h"
       
    24 #include "musuiappui.h"
       
    25 #include "musuidialogutil.h"
       
    26 #include "musui.hrh"
       
    27 #include "muslogger.h" // debug logging
       
    28 #include "mussettings.h"
       
    29 #include <musui.rsg>
       
    30 
       
    31 
       
    32 #include <AknsDrawUtils.h>
       
    33 #include <AknProgressDialog.h>
       
    34 #include <eikprogi.h>                   // CEikProgressInfo
       
    35 #include <AknDef.h>
       
    36 #include <MGFetch.h>
       
    37 #include <MediaFileTypes.hrh>
       
    38 
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CMusUiClipSharingViewContainer::ConstructL( CMusUiGeneralView* aView,
       
    45                                                  const TRect& aRect )
       
    46     {
       
    47     MUS_LOG( "mus: [MUSUI ]  -> CMusUiClipSharingViewContainer::ConstructL" );
       
    48     
       
    49     CMusUiSendViewContainer::ConstructL( aView, 
       
    50                                          aRect,
       
    51                                          EAknOrientationHorizontal,
       
    52                                          ETrue,
       
    53                                          EFalse );
       
    54     // check if operator specific functionality is needed  
       
    55     iOperatorSpecificFunctionality = 
       
    56         ( MultimediaSharingSettings::OperatorVariantSettingL() == 
       
    57                                         MusSettingsKeys::EOperatorSpecific );
       
    58     
       
    59     MUS_LOG( "mus: [MUSUI ]  <- CMusUiClipSharingViewContainer::ConstructL" );
       
    60     }
       
    61 
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CMusUiClipSharingViewContainer::~CMusUiClipSharingViewContainer()
       
    68     {
       
    69     MUS_LOG( "mus: [MUSUI ]  -> CMusUiClipSharingViewContainer::~CMusUiClipSharingViewContainer" );
       
    70     
       
    71     delete iFileName;
       
    72 
       
    73     TRAP_IGNORE( CancelTranscodingL() );
       
    74 
       
    75     if ( iTranscodingDialog )
       
    76         {
       
    77         TRAP_IGNORE( iTranscodingDialog->ProcessFinishedL() );
       
    78         }
       
    79 
       
    80     MUS_LOG( "mus: [MUSUI ]  <- CMusUiClipSharingViewContainer::~CMusUiClipSharingViewContainer" );
       
    81     }
       
    82     
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CMusUiClipSharingViewContainer::ShowTranscodingProgressDialogL()
       
    89     {
       
    90     MUS_LOG( "mus: [MUSUI ]  -> CMusUiClipSharingViewContainer::ShowTranscodingProgressDialogL" );
       
    91     iTranscodingOngoing = ETrue;
       
    92     HBufC* transcodText;
       
    93     iTranscodingDialog =
       
    94         new ( ELeave ) CAknProgressDialog(
       
    95             ( reinterpret_cast<CEikDialog**>( &iTranscodingDialog ) ) );
       
    96 
       
    97     iTranscodingDialog->SetCallback( this );
       
    98     transcodText = iEikonEnv->AllocReadResourceLC(
       
    99                             R_MUS_PROGRESS_NOTE_CONVERTING_CLIP );
       
   100     iTranscodingDialog->SetCurrentLabelL( EAknCtNote, *transcodText );
       
   101     CleanupStack::PopAndDestroy( transcodText );
       
   102     iTranscodingDialog->ExecuteLD( R_MUS_VIEW_TRANSCODING_WAIT_NOTE );
       
   103     MUS_LOG( "mus: [MUSUI ]  <- CMusUiClipSharingViewContainer::ShowTranscodingProgressDialogL" );
       
   104     }
       
   105 
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CMusUiClipSharingViewContainer::UpdateClipTranscodingPercentageL(
       
   112                         TInt aPercentage )
       
   113     {
       
   114     MUS_LOG( "mus: [MUSUI ]  -> CMusUiClipSharingViewContainer::UpdateClipTranscodingPercentageL" );
       
   115     if ( iTranscodingDialog )
       
   116         {
       
   117         if ( aPercentage < KMusOneHundredPercent )
       
   118             {
       
   119             iTranscodingProgress = iTranscodingDialog->GetProgressInfoL();
       
   120             iTranscodingProgress->SetFinalValue( KMusOneHundredPercent );
       
   121             if ( iTranscodingProgress )
       
   122                 {
       
   123                 iTranscodingProgress->IncrementAndDraw(
       
   124                         aPercentage - iTranscodingProgress->CurrentValue() );
       
   125                 }
       
   126             }
       
   127         else
       
   128             {
       
   129             iTranscodingOngoing = EFalse;
       
   130             iTranscodingDialog->ProcessFinishedL();
       
   131             iTranscodingDialog = NULL;
       
   132             }
       
   133         }
       
   134     MUS_LOG( "mus: [MUSUI ]  <- CMusUiClipSharingViewContainer::UpdateClipTranscodingPercentageL" );
       
   135     }
       
   136 
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void CMusUiClipSharingViewContainer::CancelTranscodingL()
       
   143     {
       
   144     MUS_LOG( "mus: [MUSUI ]  -> CMusUiClipSharingViewContainer::CancelTranscodingL" );
       
   145     if ( iTranscodingOngoing )
       
   146         {
       
   147         iTranscodingOngoing = EFalse;
       
   148         MUS_LOG( "mus: [MUSUI ]     CMusUiClipSharingViewContainer::CancelTranscodingL: iTranscodingOngoing" );
       
   149         if ( iTranscodingDialog )
       
   150             {
       
   151             MUS_LOG( "mus: [MUSUI ]     CMusUiClipSharingViewContainer::CancelTranscodingL: iTranscodingDialog" );
       
   152             iTranscodingDialog->ProcessFinishedL();
       
   153             iTranscodingDialog = NULL;
       
   154             MUS_LOG( "mus: [MUSUI ]     CMusUiClipSharingViewContainer::CancelTranscodingL: ProcessFinishedL()" );
       
   155             }
       
   156         }
       
   157     MUS_LOG( "mus: [MUSUI ]  <- CMusUiClipSharingViewContainer::CancelTranscodingL" );
       
   158     }
       
   159 
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // Runs the Media Gallery Fetch dialog.
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 void CMusUiClipSharingViewContainer::RunFetchDialogL()
       
   166     {
       
   167     MUS_LOG( "mus: [MUSUI ]  -> CMusUiClipSharingViewContainer::RunFetchDialogL" );
       
   168 
       
   169     // Create array of descriptors for the selected files
       
   170     CDesCArrayFlat* fileArray = new ( ELeave ) CDesCArrayFlat( KMusDefaultArrayGranularity );
       
   171     CleanupStack::PushL( fileArray );
       
   172 
       
   173     // Open the dialog.
       
   174     TBool ret = MGFetch::RunL(
       
   175         *fileArray, // When dialog is closed, fileArray contains selected files
       
   176         EVideoFile, // Displays only media files of type aMediaType
       
   177         EFalse,     // Not used in S60 2.0 ( single or multiple file selection )
       
   178         this        // Pointer to class implementing MMGFetchVerifier;
       
   179                     // when user has selected file( s ),
       
   180                     // MMGFetchVerifier::VerifySelectionL is called.
       
   181         );
       
   182 
       
   183     if ( ret )
       
   184         {
       
   185         iFileSelected = ETrue;
       
   186         iFileName = fileArray->MdcaPoint( 0 ).AllocL();
       
   187         }
       
   188     else
       
   189         {
       
   190         // The user has not selected any file
       
   191         iFileSelected = EFalse;
       
   192         }
       
   193 
       
   194     CleanupStack::PopAndDestroy( fileArray );
       
   195 
       
   196     MUS_LOG( "mus: [MUSUI ]  <- CMusUiClipSharingViewContainer::RunFetchDialogL" );
       
   197     }
       
   198 
       
   199 
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 const TDesC& CMusUiClipSharingViewContainer::FetchedFileName()
       
   205     {
       
   206     MUS_LOG( "mus: [MUSUI ]     CMusUiClipSharingViewContainer::FetchedFileName" );
       
   207     return *iFileName;
       
   208     }
       
   209 
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 TBool CMusUiClipSharingViewContainer::FileSelected()
       
   216     {
       
   217     MUS_LOG( "mus: [MUSUI ]     CMusUiClipSharingViewContainer::FileSelected" );
       
   218     return iFileSelected;
       
   219     }
       
   220 
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 //
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 void CMusUiClipSharingViewContainer::SetDurationValue( TInt aDurationValue )
       
   227     {
       
   228     const TInt KMinLevel = 0;
       
   229     iIndicator->SetRange( KMinLevel, aDurationValue, EFalse );
       
   230     }
       
   231 
       
   232 
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 void CMusUiClipSharingViewContainer::SetPositionValueL( TInt aPositionValue )
       
   238     {
       
   239     iIndicator->SetLevelL( EMusUiIndicatorTypeDuration, 
       
   240                            aPositionValue, 
       
   241                            EFalse /*never use timer*/ );
       
   242     }
       
   243 
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 // -----------------------------------------------------------------------------
       
   248 //
       
   249 void CMusUiClipSharingViewContainer::SetDurationIndicatorVisible( TBool aVisible )
       
   250     {
       
   251     iIndicator->SetIndicatorType(EMusUiIndicatorTypeDuration);
       
   252     iIndicator->MakeVisible( aVisible );
       
   253     }
       
   254     
       
   255 
       
   256 // -----------------------------------------------------------------------------
       
   257 // Verifies the current user selection.
       
   258 // -----------------------------------------------------------------------------
       
   259 //
       
   260 TBool CMusUiClipSharingViewContainer::VerifySelectionL( const MDesCArray* 
       
   261                                                         aSelectedFiles )
       
   262     {
       
   263     MUS_LOG( "mus: [MUSUI ]     CMusUiClipSharingViewContainer::\
       
   264                                 VerifySelectionL" );
       
   265     return ( aSelectedFiles->MdcaCount() > 0 ) ? ETrue : EFalse;
       
   266     }
       
   267 
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 void CMusUiClipSharingViewContainer::DialogDismissedL( TInt /*aButtonId*/ )
       
   274     {
       
   275     MUS_LOG( "mus: [MUSUI ]  -> CMusUiClipSharingViewContainer::DialogDismissedL" );
       
   276     if ( iTranscodingOngoing )
       
   277         {
       
   278         (static_cast <CMusUiClipSharingView*>(MusUiView()))->CancelTranscodingL();
       
   279         iTranscodingOngoing = EFalse;
       
   280         }
       
   281     MUS_LOG( "mus: [MUSUI ]  <- CMusUiClipSharingViewContainer::DialogDismissedL" );
       
   282     }
       
   283 
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 // Called by framework when to retrieve the no. of controls.
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 TInt CMusUiClipSharingViewContainer::CountComponentControls() const
       
   290     {
       
   291     return 1; // return nbr of controls inside this container
       
   292     }
       
   293 
       
   294 
       
   295 // -----------------------------------------------------------------------------
       
   296 // Called by framework to retrieve the control specified by index.
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 CCoeControl* CMusUiClipSharingViewContainer::ComponentControl( TInt aIndex ) const
       
   300     {
       
   301     CCoeControl* control = NULL;
       
   302 
       
   303     switch ( aIndex )
       
   304         {
       
   305         case 0:
       
   306             control = iIndicator;
       
   307             break;
       
   308         default:
       
   309             break;
       
   310         }
       
   311     return control;
       
   312     }
       
   313 
       
   314 // -----------------------------------------------------------------------------
       
   315 // Called by framework to redraw the screen area.
       
   316 // -----------------------------------------------------------------------------
       
   317 //
       
   318 void CMusUiClipSharingViewContainer::Draw( const TRect& aRect ) const
       
   319     {
       
   320     CWindowGc& gc = SystemGc();
       
   321 
       
   322     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   323     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   324     if(!AknsDrawUtils::Background( skin, cc,this,gc,aRect,KAknsDrawParamDefault ))
       
   325         {
       
   326         MUS_LOG( "mus: [MUSUI ]     Skin not valid or not found" );
       
   327         gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) );
       
   328         gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   329         gc.Clear( aRect );
       
   330         }
       
   331     }
       
   332 
       
   333 // -----------------------------------------------------------------------------
       
   334 // Called by framework to act on key events if required.
       
   335 // -----------------------------------------------------------------------------
       
   336 //
       
   337 TKeyResponse CMusUiClipSharingViewContainer::OfferKeyEventL(
       
   338                         const TKeyEvent& aKeyEvent,
       
   339                         TEventCode aType )
       
   340     {
       
   341     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiClipSharingViewContainer::OfferKeyEventL: %d",
       
   342                             aKeyEvent.iCode );
       
   343     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiClipSharingViewContainer::OfferKeyEventL: %d",
       
   344                             aKeyEvent.iScanCode );
       
   345 
       
   346     TKeyResponse ret( EKeyWasNotConsumed );
       
   347 
       
   348     /**
       
   349     * special keys have scancode
       
   350     */
       
   351     switch( aKeyEvent.iScanCode )
       
   352         {
       
   353         // Fast Forward:
       
   354         case EStdKeyUpArrow: // EKeyUpArrow:
       
   355             {                
       
   356             if ( !MUS_NO_TOOLBAR )
       
   357                 {
       
   358             if( aType == EEventKeyDown )
       
   359                 {
       
   360                 (static_cast <CMusUiClipSharingView*>
       
   361                         (MusUiView()))->HandleCommandL( EMusuiCmdViewFastForward );
       
   362                 }
       
   363 
       
   364             if( aType == EEventKeyUp )
       
   365                 {
       
   366                 (static_cast <CMusUiClipSharingView*>
       
   367                         (MusUiView()))->HandleCommandL( EMusuiCmdViewFastForwardEnd );
       
   368                     }
       
   369                 }
       
   370             return EKeyWasConsumed;
       
   371             }
       
   372 
       
   373         // Fast Reverse:
       
   374         case EStdKeyDownArrow: // EKeyDownArrow:
       
   375             {
       
   376             if ( !MUS_NO_TOOLBAR )
       
   377             {
       
   378             if( aType == EEventKeyDown )
       
   379                 {
       
   380                 (static_cast <CMusUiClipSharingView*>
       
   381                             (MusUiView()))->HandleCommandL( EMusuiCmdViewFastReverse );
       
   382                 }
       
   383             if( aType == EEventKeyUp )
       
   384                 {
       
   385                 (static_cast <CMusUiClipSharingView*>
       
   386                             (MusUiView()))->HandleCommandL( EMusuiCmdViewFastReverseEnd );
       
   387                     }
       
   388                 }
       
   389             return EKeyWasConsumed;
       
   390             }
       
   391         default:
       
   392             {
       
   393             ret = EKeyWasNotConsumed;
       
   394             break;
       
   395             }
       
   396         }
       
   397 
       
   398 
       
   399     switch ( aKeyEvent.iCode )
       
   400         {
       
   401         // Volume Control
       
   402         case EKeyLeftArrow:
       
   403             {
       
   404             (static_cast <CMusUiClipSharingView*>
       
   405                     (MusUiView()))->HandleCommandL( EMusuiCmdViewVolumeDown );
       
   406             ret = EKeyWasConsumed;
       
   407             break;
       
   408             }
       
   409         case EKeyRightArrow:
       
   410             {
       
   411             (static_cast <CMusUiClipSharingView*>
       
   412                     (MusUiView()))->HandleCommandL( EMusuiCmdViewVolumeUp );
       
   413             ret = EKeyWasConsumed;
       
   414             break;
       
   415             }
       
   416 
       
   417         default:
       
   418             {
       
   419             ret = EKeyWasNotConsumed;
       
   420             break;
       
   421             }
       
   422         }
       
   423     
       
   424     return ret;
       
   425     }
       
   426 
       
   427 
       
   428 // end of file