uigraphics/AknIcon/src/AknFileHandleIconManager.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2002 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:   Implementation of class CAknFileHandleIconManager.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "AknFileHandleIconManager.h"
       
    23 #include "AknBitmap.h"
       
    24 #include <MifconvDefs.h>
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CAknFileHandleIconManager::CAknFileHandleIconManager
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CAknFileHandleIconManager::CAknFileHandleIconManager()
       
    35 	{
       
    36 	}
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CAknFileHandleIconManager::ConstructL
       
    40 // Symbian 2nd phase constructor can leave.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 void CAknFileHandleIconManager::ConstructL(
       
    44     RFile& aFile, const TInt16 aBitmapId, const TInt16 aMaskId )
       
    45     {
       
    46     iBitmapId = aBitmapId;
       
    47     iMaskId = aMaskId;
       
    48 
       
    49     TFileName name;
       
    50     User::LeaveIfError( aFile.FullName( name ) ); // This is an expensive call.
       
    51 
       
    52     // Test that the given file has the correct extension.
       
    53     if ( name.Length() <= KExtensionLength )
       
    54         {
       
    55         User::Leave( KErrArgument );
       
    56         }
       
    57     
       
    58     if ( aBitmapId < KMifIdFirst )
       
    59         {
       
    60         if ( name.Right( KExtensionLength ).CompareF( KMbmExtension ) )
       
    61             {
       
    62             User::Leave( KErrArgument );
       
    63             }
       
    64         }
       
    65     else
       
    66         {
       
    67         if ( name.Right( KExtensionLength ).CompareF( KMifExtension ) )
       
    68             {
       
    69             User::Leave( KErrArgument );
       
    70             }
       
    71         }
       
    72 
       
    73     // Check for the default icon dir. It is indicated with a flag, to save RAM.
       
    74     if ( name.Length() >= KAknIconDefaultDirLength &&
       
    75          name.Left( KAknIconDefaultDirLength ).CompareF( 
       
    76             KAknIconDefaultDir ) == 0 )
       
    77         {
       
    78         iFlags |= KFlagUsesDefaultIconDir;
       
    79 
       
    80         iFileName = name.Mid( KAknIconDefaultDirLength ).AllocL();
       
    81         }
       
    82     else
       
    83         {
       
    84         iFileName = name.AllocL();
       
    85         }
       
    86         
       
    87     iFile = aFile;
       
    88     }
       
    89 
       
    90 CAknFileHandleIconManager* CAknFileHandleIconManager::NewL(
       
    91     RFile& aFile, const TInt16 aBitmapId, const TInt16 aMaskId )
       
    92     {
       
    93     CAknFileHandleIconManager* self = new( ELeave ) CAknFileHandleIconManager();
       
    94     CleanupStack::PushL( self );
       
    95     self->ConstructL( aFile, aBitmapId, aMaskId );
       
    96     CleanupStack::Pop();
       
    97     return self;
       
    98     }
       
    99 
       
   100 // Destructor
       
   101 CAknFileHandleIconManager::~CAknFileHandleIconManager()
       
   102     {
       
   103     iFile.Close();
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CAknFileHandleIconManager::LoadBitmapIconL
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void CAknFileHandleIconManager::LoadBitmapIconL()
       
   111     {
       
   112     User::LeaveIfError( iBitmap->Load( iFile, iBitmapId ) );
       
   113     
       
   114     if ( iMask )
       
   115         {
       
   116         User::LeaveIfError( iMask->Load( iFile, iMaskId ) );
       
   117         }
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CAknFileHandleIconManager::FileHandleL
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 RFile* CAknFileHandleIconManager::FileHandleL(
       
   125     MAknIconFileProvider::TIconFileType /*aType*/ )
       
   126     {
       
   127     return &iFile;
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CAknFileHandleIconManager::ReleaseFileHandle
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CAknFileHandleIconManager::ReleaseFileHandle()
       
   135     {
       
   136     // Cannot close the file here, because it is required again
       
   137     // when SetSize is called... This class is to be removed, anyway,
       
   138     // and replaced by CAknFileProviderIconManager.
       
   139     }
       
   140 
       
   141 //  End of File