skins/AknSkins/src/AknsFsHandleProvider.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Skin server's file handle provider.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "AknsFsHandleProvider.h"
       
    20 #include <AknsSrvClient.h>
       
    21 
       
    22 // MIF file extension.
       
    23 _LIT( KAknsSkinSrvMifFileExt, ".mif" );
       
    24 
       
    25 // MBM file extension.
       
    26 _LIT( KAknsSkinSrvMbmFileExt, ".mbm" );
       
    27 
       
    28 // Extension length
       
    29 const TInt KAknsExtensionLength = 4;
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CAknsFsHandleProvider::NewL
       
    33 // (documented in the header).
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CAknsFsHandleProvider* CAknsFsHandleProvider::NewL(
       
    37     RAknsSrvSession* aSkinSrvSession, const TDesC& aFilename)
       
    38     {
       
    39     CAknsFsHandleProvider* self =
       
    40         new (ELeave) CAknsFsHandleProvider(aSkinSrvSession);
       
    41     CleanupStack::PushL(self);
       
    42     self->ConstructL(aFilename);
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CAknsFsHandleProvider::~CAknsFsHandleProvider
       
    49 // (documented in the header).
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CAknsFsHandleProvider::~CAknsFsHandleProvider()
       
    53     {
       
    54     delete iFilename;
       
    55     iFilename = NULL;
       
    56     iSkinSrvSession = NULL;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CAknsFsHandleProvider::CAknsFsHandleProvider
       
    61 // (documented in the header).
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CAknsFsHandleProvider::CAknsFsHandleProvider(RAknsSrvSession* aSkinSrvSession) :
       
    65     iSkinSrvSession(aSkinSrvSession)
       
    66     {
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CAknsFsHandleProvider::ConstructL
       
    71 // (documented in the header).
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void CAknsFsHandleProvider::ConstructL(const TDesC& aFilename)
       
    75     {
       
    76     iFilename = aFilename.AllocL();
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CAknsFsHandleProvider::RetrieveIconFileHandleL
       
    81 // (documented in the header).
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CAknsFsHandleProvider::RetrieveIconFileHandleL(
       
    85     RFile& aFile, const TIconFileType aType )
       
    86     {
       
    87     TInt filehandle = 0;
       
    88     TFileName fn;
       
    89     if ( iFilename )
       
    90         {
       
    91         fn = iFilename->Left( iFilename->Length() - KAknsExtensionLength );
       
    92         }
       
    93 
       
    94     if (aType) // mif
       
    95         {
       
    96         fn.Append( KAknsSkinSrvMifFileExt );
       
    97         }
       
    98     else       // mbm
       
    99         {
       
   100         fn.Append( KAknsSkinSrvMbmFileExt );
       
   101         }
       
   102 
       
   103     TInt fshandle = iSkinSrvSession->OpenBitmapFile( fn, filehandle);
       
   104     if (fshandle <=0 || filehandle == 0)
       
   105         {
       
   106         User::Leave(fshandle);
       
   107         }
       
   108 
       
   109     User::LeaveIfError(aFile.AdoptFromServer(fshandle, filehandle));
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CAknsFsHandleProvider::Finished
       
   114 // (documented in the header).
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void CAknsFsHandleProvider::Finished()
       
   118     {
       
   119     delete this;
       
   120     }
       
   121 
       
   122 // End of file
       
   123