wvuing/IMPSConnectionUI/ConnectionSrc/cimpsresourcereader.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 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:  Resource reader
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <bautils.h>
       
    20 #include <ImpsConnectionUiNg.rsg>
       
    21 
       
    22 #include "cimpsresourcereader.h"
       
    23 
       
    24 // Constants
       
    25 _LIT( KIMPSConnectionUINGResFile, "IMPSConnectionUiNG.rsc" );
       
    26 _LIT( KIMPSConnectionUiNGResourcePath, "\\Resource\\" );
       
    27 
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CIMPSResourceReader::NewL()
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 EXPORT_C CIMPSResourceReader* CIMPSResourceReader::NewL()
       
    34     {
       
    35     CIMPSResourceReader* self =  CIMPSResourceReader::NewLC();
       
    36     CleanupStack::Pop( self );
       
    37     return self;
       
    38     }
       
    39 
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CIMPSResourceReader::NewLC()
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 EXPORT_C CIMPSResourceReader* CIMPSResourceReader::NewLC()
       
    46     {
       
    47     CIMPSResourceReader* self = new( ELeave )CIMPSResourceReader;
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     return self;
       
    51     }
       
    52 
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CIMPSResourceReader::CIMPSResourceReader()
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CIMPSResourceReader::CIMPSResourceReader()
       
    59     {
       
    60     }
       
    61 
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CIMPSResourceReader::~CIMPSResourceReader()
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 EXPORT_C CIMPSResourceReader::~CIMPSResourceReader()
       
    68     {
       
    69     iResFile.Close();
       
    70     iFs.Close();
       
    71     }
       
    72 
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CIMPSResourceReader::ConstructL()
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void CIMPSResourceReader::ConstructL()
       
    79     {
       
    80     User::LeaveIfError( iFs.Connect() );
       
    81 
       
    82     TFileName resourceFileName;
       
    83     resourceFileName.Zero();
       
    84 
       
    85     TFileName drivePath;
       
    86     Dll::FileName( drivePath );
       
    87     resourceFileName.Append( TParsePtrC( drivePath ).Drive() );
       
    88     resourceFileName.Append( KIMPSConnectionUiNGResourcePath() );
       
    89     resourceFileName.Append( KIMPSConnectionUINGResFile );
       
    90 
       
    91     if ( resourceFileName.Length() > 0 )
       
    92         {
       
    93         // when baflutils gets an empty string, it returns "C:",
       
    94         // which breaks things
       
    95         BaflUtils::NearestLanguageFile( iFs, resourceFileName );
       
    96         }
       
    97 
       
    98     iResFile.OpenL( iFs, resourceFileName );
       
    99     iResFile.ConfirmSignatureL();
       
   100     }
       
   101 
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CIMPSResourceReader::IntResourceValueL()
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C TBool CIMPSResourceReader::IsRoamingWarningRequiredL()
       
   108     {
       
   109     return IntResourceValueL( RSC_CHAT_VARIATION_IMPSCU_ROAMING_WARNING );
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CIMPSResourceReader::IntResourceValueL()
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 TInt CIMPSResourceReader::IntResourceValueL( TInt aResourceId )
       
   117     {
       
   118     //Own resource reader for AA plug-in environment (no CONE facilities available)
       
   119     TInt plainResourceId = 0x00000fff & aResourceId; // Remove offset from id
       
   120 
       
   121     HBufC8* rawDataBuf = iResFile.AllocReadLC( plainResourceId );
       
   122 
       
   123     TResourceReader reader;
       
   124     reader.SetBuffer( rawDataBuf );
       
   125 
       
   126     TInt value = reader.ReadInt32();
       
   127 
       
   128     CleanupStack::PopAndDestroy( rawDataBuf );
       
   129 
       
   130     return value;
       
   131     }
       
   132 
       
   133 
       
   134 
       
   135 
       
   136 
       
   137 
       
   138 
       
   139 
       
   140 
       
   141 
       
   142 
       
   143 
       
   144 
       
   145 
       
   146 
       
   147 
       
   148