filemanager/App/src/CFileManagerMemoryStoreView.cpp
branchRCL_3
changeset 20 491b3ed49290
parent 19 95243422089a
child 21 65326cf895ed
equal deleted inserted replaced
19:95243422089a 20:491b3ed49290
     1 /*
       
     2 * Copyright (c) 2006-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 "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:  Memory store view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <StringLoader.h>
       
    22 #include <aknlists.h>
       
    23 #include <akntitle.h>
       
    24 #include <CFileManagerEngine.h>
       
    25 #include <filemanager.rsg>
       
    26 #include <csxhelp/fmgr.hlp.hrh>
       
    27 #include <FileManagerDebug.h>
       
    28 #include "CFileManagerMemoryStoreView.h"
       
    29 #include "CFileManagerFileListContainer.h"
       
    30 #include "CFileManagerAppUi.h"
       
    31 #include "CFileManagerDocument.h"
       
    32 #include "FileManager.hrh"
       
    33 
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 // ----------------------------------------------------------------------------
       
    38 // CFileManagerMemoryStoreView::CFileManagerMemoryStoreView
       
    39 // ----------------------------------------------------------------------------
       
    40 //
       
    41 CFileManagerMemoryStoreView::CFileManagerMemoryStoreView()
       
    42     {
       
    43     }
       
    44 
       
    45 // ----------------------------------------------------------------------------
       
    46 // CFileManagerMemoryStoreView::NewLC
       
    47 // ----------------------------------------------------------------------------
       
    48 //
       
    49 CFileManagerMemoryStoreView* CFileManagerMemoryStoreView::NewLC()
       
    50     {
       
    51     CFileManagerMemoryStoreView* self =
       
    52         new( ELeave ) CFileManagerMemoryStoreView();
       
    53 
       
    54     CleanupStack::PushL( self );
       
    55     self->ConstructL( R_FILEMANAGER_FOLDERS_VIEW );
       
    56 
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ----------------------------------------------------------------------------
       
    61 // CFileManagerMemoryStoreView::~CFileManagerMemoryStoreView
       
    62 // ----------------------------------------------------------------------------
       
    63 // 
       
    64 CFileManagerMemoryStoreView::~CFileManagerMemoryStoreView()
       
    65     {  
       
    66     }
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 // CFileManagerMemoryStoreView::DoActivateL
       
    70 // ----------------------------------------------------------------------------
       
    71 // 
       
    72 void CFileManagerMemoryStoreView::DoActivateL(
       
    73         const TVwsViewId& aPrevViewId,
       
    74         TUid aCustomMessageId,
       
    75         const TDesC8& aCustomMessage )
       
    76     {
       
    77     FUNC_LOG
       
    78 
       
    79     // Check embedded app exit first
       
    80     CFileManagerAppUi* appUi = 
       
    81         static_cast< CFileManagerAppUi* >( AppUi() );
       
    82     appUi->ExitEmbeddedAppIfNeededL();
       
    83 
       
    84     CFileManagerViewBase::DoActivateL(
       
    85         aPrevViewId, aCustomMessageId, aCustomMessage );
       
    86 
       
    87     TBool showRemoteNotConnected( EFalse );
       
    88     // Ensure that root directory is defined
       
    89     TInt count( iEngine.NavigationLevel() );
       
    90     if ( count > 0 )
       
    91         {
       
    92         iIndex = 0;
       
    93         for ( TInt i( 0 ); i < count; i++ )
       
    94             {
       
    95             TRAP_IGNORE( iEngine.BackstepL() );
       
    96             }
       
    97         showRemoteNotConnected = ETrue;
       
    98         }
       
    99 
       
   100     TRAP_IGNORE ( RefreshDriveInfoL() );
       
   101     RefreshTitleL();
       
   102     iEngine.SetState( CFileManagerEngine::ENavigation );
       
   103     iEngine.SetObserver( this );
       
   104     if ( DriveAvailableL( showRemoteNotConnected ) )
       
   105         {
       
   106         iEngine.RefreshDirectory();
       
   107         }
       
   108     else
       
   109         {
       
   110         UpdateCbaL();
       
   111         }
       
   112     }
       
   113 
       
   114 // ----------------------------------------------------------------------------
       
   115 // CFileManagerMemoryStoreView::DoDeactivate
       
   116 // ----------------------------------------------------------------------------
       
   117 // 
       
   118 void CFileManagerMemoryStoreView::DoDeactivate()
       
   119     {
       
   120     FUNC_LOG
       
   121 
       
   122     CFileManagerViewBase::DoDeactivate();
       
   123     }
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // CFileManagerMemoryStoreView::DirectoryChangedL
       
   127 // ----------------------------------------------------------------------------
       
   128 // 
       
   129 void CFileManagerMemoryStoreView::DirectoryChangedL()
       
   130     {
       
   131     FUNC_LOG
       
   132 
       
   133     TBool drvAvailable( DriveAvailableL( ETrue ) );
       
   134 
       
   135     if ( iContainer )
       
   136         {
       
   137         if ( drvAvailable )
       
   138             {
       
   139             TInt index = iEngine.CurrentIndex();
       
   140             if (  index != KErrNotFound )
       
   141                 {
       
   142                 iIndex = index;
       
   143                 }
       
   144             iContainer->RefreshListL( iIndex );
       
   145             }
       
   146         else
       
   147             {
       
   148             iIndex = 0;
       
   149             }
       
   150         RefreshTitleL();
       
   151         }
       
   152     }
       
   153 
       
   154 // ----------------------------------------------------------------------------
       
   155 // CFileManagerMemoryStoreView::Id
       
   156 // ----------------------------------------------------------------------------
       
   157 // 
       
   158 TUid CFileManagerMemoryStoreView::Id() const
       
   159     {
       
   160     return CFileManagerAppUi::KFileManagerMemoryStoreViewId;
       
   161     }
       
   162 
       
   163 // ----------------------------------------------------------------------------
       
   164 // CFileManagerMemoryStoreView::CreateContainerL
       
   165 // ----------------------------------------------------------------------------
       
   166 // 
       
   167 CFileManagerContainerBase* CFileManagerMemoryStoreView::CreateContainerL()
       
   168     {
       
   169     return CFileManagerFileListContainer::NewL(
       
   170         ClientRect(),
       
   171         iIndex,
       
   172         CFileManagerFileListContainer::EListMemoryStore,
       
   173         R_QTN_SELEC_EMPTY_LIST,
       
   174         KFMGR_HLP_MEM_STORE_VIEW );
       
   175     }
       
   176 
       
   177 // ----------------------------------------------------------------------------
       
   178 // CFileManagerMemoryStoreView::HandleCommandL
       
   179 // ----------------------------------------------------------------------------
       
   180 // 
       
   181 void CFileManagerMemoryStoreView::HandleCommandL( TInt aCommand )
       
   182     {
       
   183     switch( aCommand )
       
   184         {
       
   185         case EFileManagerOpen:
       
   186             {
       
   187             CmdOpenL();
       
   188             break;
       
   189             }
       
   190         case EAknSoftkeyBack:
       
   191             {
       
   192             CmdBackL();
       
   193             break;
       
   194             }
       
   195         default:
       
   196             {
       
   197             CFileManagerViewBase::HandleCommandL( aCommand );
       
   198             break;
       
   199             }
       
   200         }
       
   201     }
       
   202 
       
   203 // ----------------------------------------------------------------------------
       
   204 // CFileManagerMemoryStoreView::DriveAvailableL
       
   205 // ----------------------------------------------------------------------------
       
   206 //
       
   207 TBool CFileManagerMemoryStoreView::DriveAvailableL(
       
   208         TBool aShowRemoteNotConnected )
       
   209     {
       
   210     HBufC* error = NULL;
       
   211     TFileManagerDriveInfo& drvInfo( DriveInfo() );
       
   212     if ( drvInfo.iState & (
       
   213             TFileManagerDriveInfo::EDriveRemovable |
       
   214             TFileManagerDriveInfo::EDriveRemote ) )
       
   215         {
       
   216         TRAP_IGNORE( RefreshDriveInfoL() );
       
   217         }    
       
   218 
       
   219     TInt drvNum = drvInfo.iDrive;
       
   220     iEngine.GetDriveInfoL(drvNum,drvInfo);
       
   221 
       
   222     INFO_LOG1( "CFileManagerMemoryStoreView::DriveAvailableL-drvState=%d",
       
   223         drvInfo.iState )
       
   224 
       
   225     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote )
       
   226         {
       
   227         iEngine.SetMemoryL( EFmRemoteDrive );
       
   228         }
       
   229 #ifdef RD_MULTIPLE_DRIVE
       
   230     else if ( drvInfo.iState & TFileManagerDriveInfo::EDriveMassStorage )
       
   231         {
       
   232         iEngine.SetMemoryL( EFmMassStorage );
       
   233         }
       
   234 #endif // RD_MULTIPLE_DRIVE
       
   235     else if ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable )
       
   236         {
       
   237         iEngine.SetMemoryL( EFmMemoryCard );
       
   238         }
       
   239     else if ( drvInfo.iState & TFileManagerDriveInfo::EDriveUsbMemory )
       
   240         {
       
   241         iEngine.SetMemoryL( EFmUsbMemory );
       
   242         }
       
   243     else
       
   244         {
       
   245         iEngine.SetMemoryL( EFmPhoneMemory );
       
   246         }
       
   247 
       
   248 #ifdef RD_MULTIPLE_DRIVE
       
   249     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveMassStorage )
       
   250         {
       
   251         // Handle mass storage states
       
   252         if ( !( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) ||
       
   253              ( drvInfo.iState & TFileManagerDriveInfo::EDriveInUse ) )
       
   254             {
       
   255             error = StringLoader::LoadLC( R_QTN_MEMC_MASS_STORAGE_IN_USE );
       
   256             }
       
   257         else if ( drvInfo.iState & TFileManagerDriveInfo::EDriveCorrupted )
       
   258             {
       
   259             error = StringLoader::LoadLC( R_QTN_MEMC_MASS_STORAGE_CORRUPTED );
       
   260             }
       
   261         }
       
   262     else
       
   263         {
       
   264         // Handle other drives
       
   265 #endif // RD_MULTIPLE_DRIVE
       
   266         if ( drvInfo.iState & TFileManagerDriveInfo::EDriveInUse )
       
   267             {
       
   268             error = StringLoader::LoadLC( R_QTN_MEMC_MAINPAGE_ERROR4 );
       
   269             }
       
   270         else if ( drvInfo.iState & TFileManagerDriveInfo::EDriveLocked )
       
   271             {
       
   272             error = StringLoader::LoadLC( R_QTN_MEMC_MAINPAGE_ERROR2 );
       
   273             }
       
   274         else if ( drvInfo.iState & TFileManagerDriveInfo::EDriveCorrupted )
       
   275             {
       
   276             error = StringLoader::LoadLC( R_QTN_MEMC_MAINPAGE_ERROR3 );
       
   277             }
       
   278         else if ( !( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) )
       
   279             {
       
   280             error = StringLoader::LoadLC( R_QTN_MEMC_NOT_AVAILABLE );
       
   281             }
       
   282         else if ( aShowRemoteNotConnected &&
       
   283                  ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote ) &&
       
   284                  ! ( drvInfo.iState & TFileManagerDriveInfo::EDriveConnected ) )
       
   285             {
       
   286             error = StringLoader::LoadLC( R_QTN_FMGR_EMPTY_REMOTE_DRIVE );
       
   287             }
       
   288 #ifdef RD_MULTIPLE_DRIVE
       
   289         }
       
   290 #endif // RD_MULTIPLE_DRIVE
       
   291     if ( error )
       
   292         {
       
   293         if ( iContainer )
       
   294             {
       
   295             iContainer->ListBoxSetTextL( *error );
       
   296             }
       
   297         CleanupStack::PopAndDestroy( error );
       
   298         return EFalse;
       
   299         }
       
   300     return ETrue;
       
   301     }
       
   302 
       
   303 // ----------------------------------------------------------------------------
       
   304 // CFileManagerMemoryStoreView::RefreshTitleL
       
   305 // ----------------------------------------------------------------------------
       
   306 //
       
   307 void CFileManagerMemoryStoreView::RefreshTitleL()
       
   308     {
       
   309     static_cast< CFileManagerAppUi* >( AppUi() )->SetTitleL(
       
   310         iEngine.CurrentDriveName() );
       
   311     }
       
   312 
       
   313 // ----------------------------------------------------------------------------
       
   314 // CFileManagerMemoryStoreView::CmdOpenL
       
   315 // ----------------------------------------------------------------------------
       
   316 //
       
   317 void CFileManagerMemoryStoreView::CmdOpenL()
       
   318     {
       
   319     StoreIndex();
       
   320     CFileManagerViewBase::CmdOpenL();
       
   321     }
       
   322 
       
   323 // ----------------------------------------------------------------------------
       
   324 // CFileManagerMemoryStoreView::CmdBackL
       
   325 // ----------------------------------------------------------------------------
       
   326 //
       
   327 void CFileManagerMemoryStoreView::CmdBackL()
       
   328     {
       
   329     if ( iActiveProcess != ENoProcess )
       
   330         {
       
   331         return; // Ignore to avoid container mess up
       
   332         }
       
   333     CFileManagerAppUi* appUi =
       
   334         static_cast< CFileManagerAppUi* >( AppUi() );
       
   335     iEngine.BackstepL();
       
   336     iIndex = 0;
       
   337     appUi->CloseMemoryStoreViewL();
       
   338     }
       
   339 
       
   340 // ----------------------------------------------------------------------------
       
   341 // CFileManagerMemoryStoreView::UpdateCbaL
       
   342 // ----------------------------------------------------------------------------
       
   343 //
       
   344 void CFileManagerMemoryStoreView::UpdateCbaL()
       
   345     {
       
   346     UpdateCommonCbaL();
       
   347     }
       
   348 
       
   349 //  End of File