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