diff -r f72a12da539e -r 5315654608de widgetmanager/src/wmresourceloader.cpp --- a/widgetmanager/src/wmresourceloader.cpp Thu Dec 17 08:40:49 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,199 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).. -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* loads widget manager resources and icons -* -*/ - -// INCLUDE FILES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "wmresourceloader.h" - -// CONSTANTS -_LIT( KRelativeMifPath, "\\resource\\apps\\widgetmanager.mif" ); -_LIT( KRelativeResourcePathWithWildcard, "\\resource\\widgetmanagerview.r*" ); -_LIT( KRelativeResourcePath, "\\resource\\widgetmanagerview.rsc" ); - - -// --------------------------------------------------------- -// CWmResourceLoader::NewL -// --------------------------------------------------------- -// -CWmResourceLoader* CWmResourceLoader::NewL( - CEikonEnv& aEnv ) - { - CWmResourceLoader* self = new (ELeave) CWmResourceLoader( aEnv ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------- -// CWmResourceLoader::CWmResourceLoader -// --------------------------------------------------------- -// -CWmResourceLoader::CWmResourceLoader( CEikonEnv& aEnv ) - : iEnv( aEnv ) - { - } - -// --------------------------------------------------------- -// CWmResourceLoader::~CWmResourceLoader -// --------------------------------------------------------- -// -CWmResourceLoader::~CWmResourceLoader() - { - UnloadResources(); - delete iNote; - delete iDescription; - } - -// --------------------------------------------------------- -// CWmResourceLoader::ConstructL -// --------------------------------------------------------- -// -void CWmResourceLoader::ConstructL() - { - Dll::FileName( iDllName ); - - LoadResourcesL(); - DetermineIconFilePath(); - - iDescription = StringLoader::LoadL( - R_QTN_WM_DETAILS_NO_DESCRIPTION, &iEnv ); - } - -// --------------------------------------------------------- -// CWmResourceLoader::LoadResourcesL -// --------------------------------------------------------- -// -void CWmResourceLoader::LoadResourcesL() - { - TFileName resourceFile; - RFs& fs = iEnv.FsSession(); - resourceFile.Copy( iDllName.Left(2) ); - resourceFile.Append( KRelativeResourcePathWithWildcard ); - BaflUtils::NearestLanguageFile( fs, resourceFile ); - if ( !BaflUtils::FileExists( fs, resourceFile ) ) - { - resourceFile.Copy( iDllName.Left(2) ); - resourceFile.Append( KRelativeResourcePath ); - BaflUtils::NearestLanguageFile( fs, resourceFile ); - } - iResourceFileOffset = iEnv.AddResourceFileL( resourceFile ); - } - -// --------------------------------------------------------- -// CWmResourceLoader::UnloadResources -// --------------------------------------------------------- -// -void CWmResourceLoader::UnloadResources() - { - if ( iResourceFileOffset ) - { - iEnv.DeleteResourceFile( iResourceFileOffset ); - } - } - -// --------------------------------------------------------- -// CWmResourceLoader::DetermineIconFilePath -// --------------------------------------------------------- -// -void CWmResourceLoader::DetermineIconFilePath() - { - iMifFile.Copy( iDllName.Left(2) ); - iMifFile.Append( KRelativeMifPath ); - } - -// --------------------------------------------------------- -// CWmResourceLoader::IconFilePath -// --------------------------------------------------------- -// -const TDesC& CWmResourceLoader::IconFilePath() - { - return iMifFile; - } - -// --------------------------------------------------------- -// CWmResourceLoader::LoadButtonL -// --------------------------------------------------------- -void CWmResourceLoader::LoadButtonL( - CAknButton& aResource, - TInt aResourceId ) - { - TResourceReader reader; - iEnv.CreateResourceReaderLC( reader, aResourceId ); - aResource.ConstructFromResourceL( reader ); - CleanupStack::PopAndDestroy(); // reader - } - -// --------------------------------------------------------- -// LoadStringLC -// loads a string from resource. If an additional string is -// given (the length is greater than zero) uses a different -// StringLoader method to load. -// --------------------------------------------------------- -// -HBufC* LoadStringLC( TInt aResourceId, const TDesC& aString, CEikonEnv* aEnv ) - { - if ( aString.Length() > 0 ) - return StringLoader::LoadLC( aResourceId, aString, aEnv ); - else - return StringLoader::LoadLC( aResourceId, aEnv ); - } - -// --------------------------------------------------------- -// CWmResourceLoader::InfoPopupL -// --------------------------------------------------------- -// -void CWmResourceLoader::InfoPopupL( TInt aResourceId, const TDesC& aString ) - { - HBufC* infoMsg = LoadStringLC( aResourceId, aString, &iEnv ); - iNote = new (ELeave) CAknInformationNote( &iNote ); - iNote->SetTimeout( CAknNoteDialog::ELongTimeout ); - iNote->ExecuteLD( *infoMsg ); - CleanupStack::PopAndDestroy( infoMsg ); - } - -// --------------------------------------------------------- -// CWmResourceLoader::ErrorPopup -// --------------------------------------------------------- -// -void CWmResourceLoader::ErrorPopup( TInt aErrorCode ) - { - iEnv.HandleError( aErrorCode ); - } - -// --------------------------------------------------------- -// CWmResourceLoader::NoDescriptionText -// --------------------------------------------------------- -// -const TDesC& CWmResourceLoader::NoDescriptionText() - { - return *iDescription; - } - -// end of file -