# HG changeset patch # User hgs # Date 1270980229 -19800 # Node ID 9dbc70490d9a412297addda2b9a345d870e0738f # Parent 1fa9b890f29c2c2cecf7174f0a64148c03adc53a 201014 diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/bsclientdefs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/bsclientdefs.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,30 @@ +/* +* 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 the License "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: CBSClientdefs.h +* +*/ + +#ifndef __BRANDINGDEFS_H__ +#define __BRANDINGDEFS_H__ +#include + + +#endif //__BRANDINGDEFS_H__ + +// END OF FILE + + + + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/bselementfactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/bselementfactory.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: bselementfactory.cpp +* +*/ + + + +// INCLUDE FILES + +#include "DebugTrace.h" +#include "bselementfactory.h" +#include "cbselement.h" + + + +EXPORT_C MBSElement* BSElementFactory::CreateBSElementL( const TDesC8& aElementId, + TBSElementType /*aElementType*/, + TInt aElementData ) + { + return CBSElement::NewL( aElementId, aElementData ); + } + + +EXPORT_C MBSElement* BSElementFactory::CreateBSElementL( const TDesC8& aElementId, + TBSElementType aElementType, + const TDesC& aElementData ) + { + return CBSElement::NewL( aElementId, aElementData, aElementType ); + } + + +EXPORT_C MBSElement* BSElementFactory::CreateBSElementL( const TDesC8& aElementId, + TBSElementType /*aElementType*/, + const TDesC8& aElementData ) + { + return CBSElement::NewL( aElementId, aElementData ); + } + + +EXPORT_C MBSElement* BSElementFactory::CreateBSElementL( const TDesC8& aElementId, + TBSElementType /*aElementType*/, + CBSBitmap* aElementData ) + { + return CBSElement::NewL( aElementId, aElementData ); + } + + + +EXPORT_C MBSElement* BSElementFactory::CreateBSElementL( const TDesC8& aElementId, + TBSElementType /*aElementType*/, + RBSObjOwningPtrArray& aElementData ) + { + return CBSElement::NewL( aElementId, aElementData ); + } + + + + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/bsprocessstarter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/bsprocessstarter.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,406 @@ +/* +* 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 the License "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: bsprocessstarter.cpp +* +*/ + +// INCLUDE FILES +#include "bsprocessstarter.h" +#include +#include + + +// CONSTANTS +_LIT( KEka2ExeDir,"\\sys\\bin\\"); +_LIT( KEka2LaunchMutexExt, "[lMtx]" ); +const TInt KEka2SrvConnTries = 7; +const TInt KEka2SrvConnInitialRetryWait = 500; //MicroSeconds => 0.0005s + + + +// ============================================================== +// ====================== HELPER CLASS ========================== +// ============================================================== + +/** + * RSessionBase accessor to give to the ProcessStarter + * access to RSessionBase::CreateSession(). + */ +class REka2SessionBaseAccessor : public RSessionBase + { + public: // Constructor + inline REka2SessionBaseAccessor() + { + } + + public: // New functions + + /** + * Public access to RSessionBase::CreateSession(). + */ + inline TInt CreateSession( const TDesC& aServer, + const TVersion& aVersion, + TInt aAsyncMessageSlots ) + { + return RSessionBase::CreateSession( aServer, + aVersion, + aAsyncMessageSlots ); + } + }; + + + + + +// ============================================================== +// ====================== PROCESSSTARTER ======================== +// ============================================================== + + +// -------------------------------------------------------------- +// BSProcessStarter::FullExePathForClienLocation() +// -------------------------------------------------------------- +// +void BSProcessStarter::FullExePathForClienLocation( + const TDesC& aExeName, + TFileName& aFullExePath ) + { + //Get drive (C:) where this client code is installed + { + TFileName tmp; + Dll::FileName( tmp ); + aFullExePath.Copy( TParsePtrC( tmp ).Drive() ); + } + + //Build the rest from the exe path + aFullExePath.Append( KEka2ExeDir ); + aFullExePath.Append( aExeName ); + } + + + +// -------------------------------------------------------------- +// BSProcessStarter::StartInstance() +// -------------------------------------------------------------- +// +TInt BSProcessStarter::StartInstance( + const TDesC& aFullExePath, + const TDesC& aCommand, + const TArray< TProcessStartupParam >* aParams ) + { + RMutex launchMutex; + TInt error = KErrNotFound; + + { + // Dynamic mutex name used to allow code share + TName launchMutexName( TParsePtrC( aFullExePath ).Name() ); + launchMutexName.Append( KEka2LaunchMutexExt ); + + // Open or Create mutex to serialize to access to server startup code. + // (race condition safe way) + while( error == KErrNotFound ) + { + error = launchMutex.CreateGlobal( launchMutexName ); + if( error != KErrAlreadyExists ) + { + break; + } + error = launchMutex.OpenGlobal( launchMutexName ); + } + + if( error != KErrNone ) + { + return error; + } + } + + + launchMutex.Wait(); + + //Serialized access + error = BSProcessStarter::DoStartInstance( aFullExePath, + aCommand, + aParams ); + + launchMutex.Signal(); + launchMutex.Close(); + + return error; + } + + + +// -------------------------------------------------------------- +// BSProcessStarter::ConnectToServer() +// -------------------------------------------------------------- +// +TInt BSProcessStarter::ConnectToServer( + const TDesC& aFullExePath, + const TDesC& aCommand, + const TArray< TProcessStartupParam >* aParams, + RSessionBase& aSessionToConnect, + const TDesC& aServerName, + const TVersion& aClientVersion, + TInt aAsyncMessageSlots ) + { + if( aSessionToConnect.Handle() != KNullHandle ) + { + return KErrInUse; + } + + TInt err = KErrNone; + TInt startupWait = KEka2SrvConnInitialRetryWait; + + //Server connect and launch loop + for( TInt trie = 0 ; trie < KEka2SrvConnTries ; trie++ ) + { + REka2SessionBaseAccessor acc; + err = acc.CreateSession( aServerName, + aClientVersion, + aAsyncMessageSlots ); + + if( err == KErrNone ) + { + //session ownership is now on client + aSessionToConnect = acc; + return KErrNone; + } + + else if( ( err == KErrNotFound ) || + ( err == KErrServerTerminated ) ) + { + //Server missing or died when connecting + //Start a new server + err = BSProcessStarter::StartInstance( aFullExePath, + aCommand, + aParams ); + + //If process exist already, then all is fine + //(some other process started it between the origical connect and launch trie) + if( err == KErrAlreadyExists ) + { + err = KErrNone; + } + + //If server process start failed, bail out. + if( err != KErrNone ) + { + return err; + } + + //If this is 2nd or subsequent try, + //give some time for server to startup + if( trie > 0 ) + { + // Code scanner warning : Use of User::After (id:92) + // it is required to be used here + User::After( startupWait ); // CSI: 92 # See above + startupWait = 2 * startupWait; + } + } + + else + { + //Server process start failed. Bail out. + return err; + } + } + + return err; + } + + + +// -------------------------------------------------------------- +// BSProcessStarter::DoStartServerInstance() +// -------------------------------------------------------------- +// +TInt BSProcessStarter::DoStartInstance( + const TDesC& aFullExePath, + const TDesC& aCommand, + const TArray< TProcessStartupParam >* aParams ) + { + TInt error = KErrNone; + + //Create process + RProcess process; + error = process.Create( aFullExePath, aCommand ); + + if( error == KErrNone ) + { + //Set process startup parameters + error = ApplyParameters( aParams, process ); + + //And execute the process and wait it's startup + if( error == KErrNone ) + { + TRequestStatus rendezvousStatus; + process.Rendezvous( rendezvousStatus ); + + process.Resume(); + // Codescanner warning: user of User::WaitForRequest (Id:94) + // it is required to use at server startup + User::WaitForRequest( rendezvousStatus ); // CSI: 94 # See above + error = rendezvousStatus.Int(); + + if( process.ExitType() != EExitPending ) + { + //Something failed in server startup + //Force the error code to be always something + //else than KErrNone + if( error == KErrNone ) + { + error = KErrServerTerminated; + } + } + } + } + + process.Close(); + + return error; + } + + + +// -------------------------------------------------------------- +// BSProcessStarter::ApplyParameters() +// -------------------------------------------------------------- +// +TInt BSProcessStarter::ApplyParameters( + const TArray< TProcessStartupParam >* aParams, + RProcess& aProcess ) + { + TInt error = KErrNone; + if( aParams ) + { + const TInt paramCount = aParams->Count(); + for( TInt ix = 0; ix < paramCount; ix++ ) + { + error = (*aParams)[ ix ].ApplyParam( aProcess ); + if( error != KErrNone ) + { + break; + } + } + } + + return error; + } + + + +// ============================================================== +// ================== TPROCESSSTARTUPPARAM ====================== +// ============================================================== + +// -------------------------------------------------------------- +// TProcessStartupParam::TProcessStartupParam() +// -------------------------------------------------------------- +// +TProcessStartupParam::TProcessStartupParam() + : iType( EUnknown ), + iSlot( KErrNotFound ) + { + } + + +// -------------------------------------------------------------- +// TProcessStartupParam::Set() +// -------------------------------------------------------------- +// +void TProcessStartupParam::Set( TInt aSlot, + const RHandleBase& aHandle ) + { + iType = EHandle; + iSlot = aSlot; + iHandle = &aHandle; + } + + +// -------------------------------------------------------------- +// TProcessStartupParam::Set() +// -------------------------------------------------------------- +// +void TProcessStartupParam::Set( TInt aSlot, + const RSubSessionBase& aSubSession ) + { + iType = ESubSession; + iSlot = aSlot; + iSubSession = &aSubSession; + } + + +// -------------------------------------------------------------- +// TProcessStartupParam::Set() +// -------------------------------------------------------------- +// +void TProcessStartupParam::Set( TInt aSlot, + const TDesC16& aDes ) + { + iType = EDes16; + iSlot = aSlot; + iDes16.Set( aDes ); + } + + +// -------------------------------------------------------------- +// TProcessStartupParam::Set() +// -------------------------------------------------------------- +// +void TProcessStartupParam::Set( TInt aSlot, + const TDesC8& aDes ) + { + iType = EDes8; + iSlot = aSlot; + iDes8.Set( aDes ); + } + + +// -------------------------------------------------------------- +// TProcessStartupParam::Set() +// -------------------------------------------------------------- +// +void TProcessStartupParam::Set( TInt aSlot, + TInt aInt ) + { + iType = EInt; + iSlot = aSlot; + iInt = aInt; + } + + +// -------------------------------------------------------------- +// TProcessStartupParam::ApplyParam() +// -------------------------------------------------------------- +// +TInt TProcessStartupParam::ApplyParam( RProcess& aProcess ) const + { + switch( iType ) + { + case EHandle: return aProcess.SetParameter( iSlot, *iHandle ); + case ESubSession: return aProcess.SetParameter( iSlot, *iSubSession ); + case EDes16: return aProcess.SetParameter( iSlot, iDes16 ); + case EDes8: return aProcess.SetParameter( iSlot, iDes8 ); + case EInt: return aProcess.SetParameter( iSlot, iInt ); + } + + return KErrUnknown; + } + + +// END OF FILE + + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/bsprocessstarter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/bsprocessstarter.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,105 @@ +/* +* 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 the License "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: bsprocessstarter.h +* +*/ + +#ifndef __PROCESSSTARTER_H__ +#define __PROCESSSTARTER_H__ + +#include +class TProcessStartupParam; + + + +/** + * Generic process starter. + */ +class BSProcessStarter + { + public: // New methods + + static void FullExePathForClienLocation( + const TDesC& aExeName, + TFileName& aFullExePath ); + + static TInt StartInstance( + const TDesC& aFullExePath, + const TDesC& aCommand, + const TArray< TProcessStartupParam >* aParams ); + + static TInt ConnectToServer( + const TDesC& aFullExePath, + const TDesC& aCommand, + const TArray< TProcessStartupParam >* aParams, + RSessionBase& aSessionToConnect, + const TDesC& aServerName, + const TVersion& aClientVersion, + TInt aAsyncMessageSlots ); + + + + private: // Helpers + static TInt DoStartInstance( + const TDesC& aFullExePath, + const TDesC& aCommand, + const TArray< TProcessStartupParam >* aParams ); + + static TInt ApplyParameters( + const TArray< TProcessStartupParam >* aParams, + RProcess& aProcess ); + + }; + + + + +/** + * Generic process startup parameters. + */ +class TProcessStartupParam + { + public: + + TProcessStartupParam(); + void Set( TInt aSlot, const RHandleBase& aHandle ); + void Set( TInt aSlot, const RSubSessionBase& aSubSession ); + void Set( TInt aSlot, const TDesC16& aDes ); + void Set( TInt aSlot, const TDesC8& aDes ); + void Set( TInt aSlot, TInt aInt ); + TInt ApplyParam( RProcess& aProcess ) const; + + + + private: //data + + enum TParamType{ EUnknown, EHandle, ESubSession, + EDes16, EDes8, EInt }; + + TParamType iType; + TInt iSlot; + const RHandleBase* iHandle; + const RSubSessionBase* iSubSession; + TPtrC16 iDes16; + TPtrC8 iDes8; + TInt iInt; + }; + + +#endif // __PROCESSSTARTER_H__ + + +//END OF FILE + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsaccess.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsaccess.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,292 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSAccess.cpp +* +*/ + + + +// INCLUDE FILES + +#include +#include // skins +#include +#include + +#include "cbsaccess.h" +#include "cbsbitmap.h" +#include "DebugTrace.h" +#include "mbsaccess.h" +#include "mbsupdater.h" +#include "cbsiconfileprovider.h" + +void Panic(TInt aPanic) + { + _LIT( KPanic, "CBS" ); + User::Panic( KPanic, aPanic ); + } + +// Two-phased constructor. +CBSAccess* CBSAccess::NewL( const TDesC8& aBrandId, + const TDesC8& aAppId, + const TDesC8& aDefaultBrandId, + TLanguage aLanguageId, + TBool aCacheData, + TInt aReserved ) + { + CBSAccess* self = new ( ELeave ) CBSAccess( aLanguageId, aCacheData, aReserved) ; + CleanupStack::PushL( self ); + self->ConstructL( aBrandId, aAppId, aDefaultBrandId ); + CleanupStack::Pop( self ); //self + return self; + } + +// Symbian OS default constructor can leave. +void CBSAccess::ConstructL( const TDesC8& aBrandId, const TDesC8& aAppId, + const TDesC8& aDefaultBrandId ) + { + iBrand = aBrandId.AllocL(); + iDefaultBrand = aDefaultBrandId.AllocL(); + iAppId = aAppId.AllocL(); + User::LeaveIfError( iClient.Connect() ); + + iClient.StartTransactionL( *iAppId, *iBrand, aDefaultBrandId, + iLanguageId, EBSTxAccess, iReserved ); + } + +// Destructor +CBSAccess::~CBSAccess() + { + delete iBrand; + delete iDefaultBrand; + delete iAppId; + iClient.Close(); + } + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CBSAccess::CBSAccess( TLanguage aLanguageId, TBool aCacheData, TInt aReserved ) +: iLanguageId( aLanguageId ), iUseCache( aCacheData ), iReserved( aReserved ) + { + } + +// ----------------------------------------------------------------------------- +// CBSAccess::Close() +// ----------------------------------------------------------------------------- +// +void CBSAccess::Close() + { + delete this; + } + +// ----------------------------------------------------------------------------- +// CBSAccess::GetTextL() +// ----------------------------------------------------------------------------- +// +HBufC* CBSAccess::GetTextL( const TDesC8& aId ) + { + HBufC* buffer = NULL; + + iClient.GetTextL( aId, buffer ); + + TRACE( T_LIT("iClient.GetText( iBrandId, aId, buffer )") ); + return buffer; + } + +// ----------------------------------------------------------------------------- +// CBSAccess::GetTextLC() +// ----------------------------------------------------------------------------- +// +HBufC* CBSAccess::GetTextLC( const TDesC8& aId ) + { + HBufC* buffer = NULL; + iClient.GetTextL( aId, buffer ); + TRACE( T_LIT("iClient.GetText( aBrandId, aId, buffer )") ); + + CleanupStack::PushL( buffer ); + return buffer; + } + + +// ----------------------------------------------------------------------------- +// CBSAccess::GetIntL() +// ----------------------------------------------------------------------------- +// +TInt CBSAccess::GetIntL( const TDesC8& aId ) + { + TInt value = 0; + + iClient.GetIntL( aId, value ); + return value; + } + +TInt CBSAccess :: isBrandUpdateRequiredL () +{ + TInt updateRequired = -1; + iClient.isBrandUpdateRequiredL (updateRequired); + return updateRequired; + +} + +// ----------------------------------------------------------------------------- +// CBSAccess::GetSeveralIntL() +// ----------------------------------------------------------------------------- +// +MBSElement* CBSAccess::GetSeveralL( MDesC8Array& aIds ) + { + MBSElement* returnValue = iClient.GetSeveralL( aIds ); + return returnValue; + } + +// ----------------------------------------------------------------------------- +// CBSAccess::GetFileL() +// ----------------------------------------------------------------------------- +// +void CBSAccess::GetFileL( const TDesC8& aId, + RFile& aFile ) + { + iClient.GetFileL( aId, aFile ); + } + +// ----------------------------------------------------------------------------- +// CBSAccess::GetStructureL() +// ----------------------------------------------------------------------------- +// +MBSElement* CBSAccess::GetStructureL( const TDesC8& aId ) + { + MBSElement* returnValue = NULL; + + returnValue = iClient.GetStructureL( aId ); + + return returnValue; + + } + +// ----------------------------------------------------------------------------- +// CBSAccess::GetBufferL() +// ----------------------------------------------------------------------------- +// +HBufC8* CBSAccess::GetBufferL( const TDesC8& aId ) + { + HBufC8* buffer = NULL; + iClient.GetBufferL( aId, buffer ); + return buffer; + } + +// ----------------------------------------------------------------------------- +// CBSAccess::GetBufferLC() +// ----------------------------------------------------------------------------- +// +HBufC8* CBSAccess::GetBufferLC( const TDesC8& aId ) + { + HBufC8* buffer = GetBufferL( aId ); + CleanupStack::PushL( buffer ); + return buffer; + } + +// ----------------------------------------------------------------------------- +// CBSAccess::RegisterObserverL() +// ----------------------------------------------------------------------------- +// +void CBSAccess::RegisterObserverL( MBSBrandChangeObserver* aObserver, MBSBackupRestoreStateObserver* aBackupObserver) + { + iClient.RegisterObserverL( aObserver, aBackupObserver ); + } + +// ----------------------------------------------------------------------------- +// CBSAccess::UnRegisterObserverL() +// ----------------------------------------------------------------------------- +// +void CBSAccess::UnRegisterObserverL( MBSBrandChangeObserver* aObserver, MBSBackupRestoreStateObserver* aBackupObserver ) + { + iClient.UnRegisterObserverL( aObserver, aBackupObserver ); + } + +// ----------------------------------------------------------------------------- +// CBSAccess::GetBitmapL() +// ----------------------------------------------------------------------------- +// +void CBSAccess::GetBitmapL( const TDesC8& aBitmapId, + CFbsBitmap*& aBitmap, + CFbsBitmap*& aMask ) + { + TBool useSkins = ETrue; + CCoeEnv* coeEnv = CCoeEnv::Static(); + if( !coeEnv ) + { + TRACE( T_LIT("GETBITMAPL NO COE ENV ") ); + // no CONE -> don't try to use skins + useSkins = EFalse; + } + + MBSElement* bitmapItem = NULL; + + // get the structure containing the info for the bitmap + bitmapItem = GetStructureL( aBitmapId ); + CleanupClosePushL( *bitmapItem ); + + // get the list from the bitmap element + const CBSBitmap* bitmap = &bitmapItem->BitmapDataL(); + + RFile bitmapFile; + + // we need to get the bitmap file from where we can load the bitmap + GetFileL( bitmap->BitmapFileId(), bitmapFile ); + + TInt err = KErrNotFound; + CFbsBitmap* skinBitmap = NULL; + if( useSkins ) + { + MAknsSkinInstance* skin = AknsUtils::SkinInstance(); + + TAknsItemID itemId; + itemId.Set( bitmap->SkinIdMajor(), bitmap->SkinIdMinor() ); + + // Codescanner warning: neglected to put variable on cleanup stack (id:35) + // This method cannot leave after this line if the bitmap is created + TRAP( err, skinBitmap = AknsUtils::CreateBitmapL( skin, itemId ) ); // CSI: 35 # See above + } + // if useSkins is TRUE that means there is a COE Env, and icons can be created + // otherwise, without CoeEnv, we cannot create icons, hence leave + if( err == KErrNotFound && useSkins) + { + // no skin bitmap found + + // icon server take ownership of of icon file provider + CBSIconFileProvider* ifp = CBSIconFileProvider::NewL( bitmapFile ); + CleanupStack::PushL( ifp ); + + AknIconUtils::CreateIconLC( aBitmap, aMask, + *ifp, + bitmap->BitmapId(), bitmap->BitmapMaskId() ); + + CleanupStack::Pop( 2 ); // aBitmap, aMask + CleanupStack::Pop(ifp) ; + } + else if( err ) + { + User::Leave( err ); + } + else + { + aBitmap = skinBitmap; + aMask = NULL; + } + bitmapFile.Close() ; + CleanupStack::PopAndDestroy(); // structure + } + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsaccess.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsaccess.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: cbsaccess.h +* +* Description: cbsaccess.h +* +*/ + + + +#ifndef __CBSACCESS_H__ +#define __CBSACCESS_H__ +#include +#include "mbsaccess.h" +#include "cbsclient.h" + + +// Forward declarations +class CFbsBitmap; + +/** + * + */ +NONSHARABLE_CLASS( CBSAccess ): public CBase, + public MBSAccess + { + public: + /** + * Two-phased constructor. + */ + static CBSAccess* NewL( const TDesC8& aBrandId, + const TDesC8& aAppId, + const TDesC8& aDefaultBrandId, + TLanguage aLanguageId, + TBool aCacheData, + TInt aReserved = 0 ); + + // destructor + virtual ~CBSAccess(); + + /* + * Close + */ + void Close(); + + private: + + void ConstructL( const TDesC8& aBrandId, + const TDesC8& aAppId, + const TDesC8& aDefaultBrandId ); + CBSAccess( TLanguage aLanguageId, TBool aCacheData, TInt aReserved = 0); + + + private: // from MBranding + + /* + * Get text type item + * @param aId ID of the item + * @return the text item + */ + HBufC* GetTextL( const TDesC8& aId ); + + /* + * Get text type item + * @param aId ID of the item + * @return the text item + */ + HBufC* GetTextLC( const TDesC8& aId ); + + /* + * Get 8-bit data type item + * @param aId ID of the item + * @return the data buffer item + */ + HBufC8* GetBufferL( const TDesC8& aId ); + + /* + * Get 8-bit data type item + * @param aId ID of the item + * @return the data buffer item + */ + HBufC8* GetBufferLC( const TDesC8& aId ); + + /* + * Get integer type item + * @param aId ID of the item + * @return the integer item + */ + TInt GetIntL( const TDesC8& aId ); + + + /* + * Get an array of items + * @param aIds ID's of the items + * @return the items + */ + MBSElement* GetSeveralL( MDesC8Array& aIds ); + + /* + * Get a file item + * @param aId ID of the item + * @param aFile on return will contain an open file handle + * to the file + */ + void GetFileL( const TDesC8& aId, RFile& aFile ); + + /* + * Get a structure type item + * @param aIds ID of the item + * @param aFile on return will contain the strucure type item + * @return structure branding element + */ + MBSElement* GetStructureL( const TDesC8& aId ); + + /* + * Register to observer brand data updates + * @param aObserver the observer interface + */ + void RegisterObserverL( MBSBrandChangeObserver* aObserver, MBSBackupRestoreStateObserver *aBackupObserver ); + + /* + * Unregister a brand data update observer + * @param aObserver the observer interface + */ + void UnRegisterObserverL( MBSBrandChangeObserver* aObserver, MBSBackupRestoreStateObserver *aBackupObserver); + + /* + * Get a bitmap type item + * @param aBitmapId the ID of the bitmap item itself + * @param aBitmap on return will contain the bitmap + * @param aMask on return will contain the mask + */ + void GetBitmapL( const TDesC8& aBitmapId, + CFbsBitmap*& aBitmap, + CFbsBitmap*& aMask ); + + + + TInt isBrandUpdateRequiredL (); + + + public: // New methods + + + + private: // data + HBufC8* iBrand; + HBufC8* iDefaultBrand; + HBufC8* iAppId; + TLanguage iLanguageId; + TBool iUseCache; + RBSClient iClient; + TInt iReserved; + }; + +#endif // __CBSACCESS_H__ + + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsbitmap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsbitmap.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,136 @@ +/* +* Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: cbsbitmap.cpp +* +*/ + + + +// INCLUDE FILES + +#include "e32base.h" +#include "cbsbitmap.h" + +// ----------------------------------------------------------------------------- +// CBSBitmap::NewLC +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CBSBitmap* CBSBitmap::NewLC( TInt aBitmapId, + TInt aBitmapMaskId, + TInt aSkinId, + TInt aSkinMaskId, + const TDesC8& aBitmapFileId ) + { + CBSBitmap* self = new ( ELeave ) CBSBitmap( aBitmapId, aBitmapMaskId, + aSkinId, aSkinMaskId ); + CleanupStack::PushL( self ); + self->ConstructL( aBitmapFileId ); + return self; + } + +// ----------------------------------------------------------------------------- +// CBSBitmap::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CBSBitmap* CBSBitmap::NewL( TInt aBitmapId, + TInt aBitmapMaskId, + TInt aSkinIdMajor, + TInt aSkinIdMinor, + const TDesC8& aBitmapFileId ) + { + CBSBitmap* self = NewLC( aBitmapId, + aBitmapMaskId, + aSkinIdMajor, + aSkinIdMinor, + aBitmapFileId ); + CleanupStack::Pop(); + return self; + } + + +// Symbian OS default constructor can leave. +void CBSBitmap::ConstructL( const TDesC8& aBitmapFileId ) + { + iBitmapFileId = aBitmapFileId.AllocL(); + } + +// destructor +CBSBitmap::~CBSBitmap() + { + delete iBitmapFileId; + } + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CBSBitmap::CBSBitmap( TInt aBitmapId, + TInt aBitmapMaskId, + TInt aSkinIdMajor, + TInt aSkinIdMinor ) +: iBitmapId( aBitmapId), iBitmapMaskId( aBitmapMaskId ), + iSkinIdMajor( aSkinIdMajor ), iSkinIdMinor( aSkinIdMinor ) + { + } + + +// ----------------------------------------------------------------------------- +// CBSBitmap::BitmapId() +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CBSBitmap::BitmapId() const + { + return iBitmapId; + } + +// ----------------------------------------------------------------------------- +// CBSBitmap::BitmapMaskId() +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CBSBitmap::BitmapMaskId() const + { + return iBitmapMaskId; + } + +// ----------------------------------------------------------------------------- +// CBSBitmap::SkinId() +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CBSBitmap::SkinIdMajor() const + { + return iSkinIdMajor; + } + +// ----------------------------------------------------------------------------- +// CBSBitmap::SkinMaskId() +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CBSBitmap::SkinIdMinor() const + { + return iSkinIdMinor; + } + +// ----------------------------------------------------------------------------- +// CBSBitmap::BitmapFileId() +// ----------------------------------------------------------------------------- +// +EXPORT_C const TDesC8& CBSBitmap::BitmapFileId() const + { + return *iBitmapFileId; + } + + + +// END OF FILE diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsbrandobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsbrandobserver.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,99 @@ +/* +* 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 the License "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: cbsbrandobserver.cpp +* +*/ + +// INCLUDE FILES + +#include "cbsbrandobserver.h" +#include +#include +#include "mbsbrandobserverregistrar.h" + +CBSBrandObserver* CBSBrandObserver::NewL( MBSBrandChangeObserver* aObserver, + MBSBackupRestoreStateObserver* aBackupObserver, + MBSBrandObserverRegistrar* aRegistrar ) + { + CBSBrandObserver* self = new ( ELeave ) CBSBrandObserver( aObserver, aBackupObserver, aRegistrar ) ; + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); //self + return self; + } + + +void CBSBrandObserver::ConstructL() + { + iContinueBackupStateObserving = ETrue ; + iContinueDataUpdateObserving = ETrue ; + + CActiveScheduler::Add( this ); + iRegistrar->RegisterObserverToServerL( iStatus ); + SetActive(); + } + + +CBSBrandObserver::~CBSBrandObserver() + { + Cancel(); + } + + +CBSBrandObserver::CBSBrandObserver( MBSBrandChangeObserver* aObserver, + MBSBackupRestoreStateObserver* aBackupObserver, + MBSBrandObserverRegistrar* aRegistrar ) +: CActive( CActive::EPriorityIdle ), iObserver( aObserver ), iBackupObserver( aBackupObserver ), + iRegistrar( aRegistrar ) + { + } + +void CBSBrandObserver::RunL() + { + + // Pankaj - chk for what has changed.. + TInt isBackupRestore = iRegistrar->GetBackupRestoreL() ; + if(isBackupRestore) + { + // if client donot want to listen backup state event any more donot call its observer.. + if(iBackupObserver && iContinueBackupStateObserving) + { + TInt activeState = iRegistrar->GetBackupStateL() ; + iContinueBackupStateObserving = iBackupObserver->BackupRestoreActivated(activeState) ; + } + } + else + { + // if client donot want to listen update data event any more donot call its observer.. + if(iObserver && iContinueDataUpdateObserving) + { + TInt newVersion = iRegistrar->GetNewVersionL(); + iContinueDataUpdateObserving = iObserver->BrandUpdateAvailable( newVersion ) ; + } + } + + if(iContinueBackupStateObserving || iContinueDataUpdateObserving) + { + iRegistrar->RegisterObserverToServerL( iStatus ); + SetActive(); + } + } + +void CBSBrandObserver::DoCancel() + { + + } + + +// END OF FILE diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsbrandobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsbrandobserver.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSBrandObserver.h +* +*/ + + + +#ifndef __CBSBRANDOBSERVER_H__ +#define __CBSBRANDOBSERVER_H__ +#include +#include + +class MBSBrandChangeObserver; +class MBSBackupRestoreStateObserver; +class MBSBrandObserverRegistrar; + +/** + * + */ +NONSHARABLE_CLASS( CBSBrandObserver ): public CActive + { + public: + /** + * Two-phased constructor. + */ + static CBSBrandObserver* NewL( MBSBrandChangeObserver* aObserver, + MBSBackupRestoreStateObserver* aBackupObserver, + MBSBrandObserverRegistrar* aRegistrar ); + + virtual ~CBSBrandObserver(); + + public: // From CActive + + void RunL(); + void DoCancel(); + + private: + CBSBrandObserver( MBSBrandChangeObserver* aObserver, + MBSBackupRestoreStateObserver* aBackupObserver, + MBSBrandObserverRegistrar* aRegistrar ); + + + void ConstructL(); + + private: + + + private: // data + + // doesn't own: observer + MBSBrandChangeObserver* iObserver ; + + // doesn't own: observer + MBSBackupRestoreStateObserver* iBackupObserver ; + + // doesn't own: registrar + MBSBrandObserverRegistrar* iRegistrar; + + TBool iContinueBackupStateObserving ; + TBool iContinueDataUpdateObserving ; + }; + +#endif // __CBSBRANDOBSERVER_H__ + + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsclient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsclient.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,754 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSClient.cpp +* +*/ + + + +// INCLUDE FILES +#include "cbsclient.h" +#include "bsclientdefs.h" +#include "bsprocessstarter.h" +#include "bsserverdefs.h" +#include "mbselement.h" +#include "bselementfactory.h" +#include "cbsbitmap.h" +#include "cbsbrandobserver.h" +#include +#include +#include "DebugTrace.h" + +// ============================================================== +// ======================== CLIENT ============================== +// ============================================================== + +// Destructor +RBSClient::~RBSClient() + { +#if _BullseyeCoverage + cov_write(); +#endif + } + +// C++ default constructor can NOT contain any code, that +// might leave. +// +RBSClient::RBSClient() + { + } + + +// ----------------------------------------------------------------------------- +// RBSClient::Connect() +// ----------------------------------------------------------------------------- +// +TInt RBSClient::Connect() + { + TRACE( T_LIT("RBSClient::Connect() begin") ); + TFileName fullExePath; + BSProcessStarter::FullExePathForClienLocation( KBSServerExe, + fullExePath ); + + return BSProcessStarter::ConnectToServer( fullExePath, + KNullDesC, + NULL, + *this, + KBSServerName, + TVersion( KBSVersionMajor, + KBSVersionMinor, + KBSVersionBuild ), + KBSMsgSlotCount ); + } + + +// ----------------------------------------------------------------------------- +// RBSClient::Close() +// ----------------------------------------------------------------------------- +// +void RBSClient::Close() + { + TRACE( T_LIT("RBSClient::Close() begin") ); + RSessionBase::Close(); + } + + +// ----------------------------------------------------------------------------- +// RBSClient::Close() +// ----------------------------------------------------------------------------- +// +void RBSClient::StartTransactionL( const TDesC8& aApplicationId, + const TDesC8& aBrandId, + const TDesC8& aDefaultBrandId, + TLanguage aLanguage, + TTransactionType aType, + TInt aReserved ) + { + TRACE( T_LIT("RBSClient::StartTransactionL() begin") ); + InitClientL( aApplicationId, aBrandId, aDefaultBrandId, + aLanguage, aType, aReserved ); + } + +// ----------------------------------------------------------------------------- +// RBSClient::Close() +// ----------------------------------------------------------------------------- +// +TInt RBSClient::StopTransactionL( const TDesC8& /*aApplicationId*/, + const TDesC8& /*aBrandId*/, + TLanguage /*aLanguage*/, + TInt /*aReserved*/ ) + { + TRACE( T_LIT("RBSClient::StopTransactionL() begin") ); + TInt returnValue = 0; + TPckg pack( returnValue ); + TIpcArgs args( &pack ); + TInt err = SendReceive( EBSStopTransaction, args ); + User::LeaveIfError( err ); + return returnValue; + } + +// ----------------------------------------------------------------------------- +// RBSClient::Close() +// ----------------------------------------------------------------------------- +// +void RBSClient::CancelTransactionL( const TDesC8& aApplicationId, + const TDesC8& aBrandId, + TLanguage aLanguage, + TInt aReserved ) + { + TIpcArgs args = CreateArgumentsL( aApplicationId, aBrandId, + aLanguage, aReserved ); + + TInt err = SendReceive( EBSCancelTransaction, args ); + User::LeaveIfError( err ); + } + +// ----------------------------------------------------------------------------- +// RBSClient::InitClientL() +// ----------------------------------------------------------------------------- +// +void RBSClient::InitClientL( const TDesC8& aApplicationId, + const TDesC8& aBrandId, + const TDesC8& aDefaultBrandId, + TLanguage aLanguage, + TTransactionType aType, + TInt aReserved ) + { + TRACE( T_LIT("RBSClient::InitClientL() begin aAppId[%S],aBrandId[%S],TAType[%d]"),&aApplicationId,&aBrandId,aType ); + CBufFlat* flatBuf = CBufFlat::NewL( aDefaultBrandId.Length() + aBrandId.Length() + 2 ); + CleanupStack::PushL( flatBuf ); + + RBufWriteStream stream; + CleanupClosePushL( stream ); + stream.Open( *flatBuf ); + stream.WriteInt16L( aBrandId.Length() ); + stream.WriteL( aBrandId ); + stream.WriteInt16L( aDefaultBrandId.Length() ); + stream.WriteL( aDefaultBrandId ); + + TPtr8 ptrElement( flatBuf->Ptr(0) ); + + // set the arguments for the message + TIpcArgs args( &aApplicationId ); + args.Set( 1, &ptrElement ); + args.Set( 2, aLanguage ); + args.Set( 3, aReserved ); + + TInt operation = 0; + switch( aType ) + { + case EBSTxInstall: + { + operation = EBSInitInstall; + break; + } + case EBSTxUninstall: + { + operation = EBSInitUninstall; + break; + } + case EBSTxAppend: + { + operation = EBSInitAppend; + break; + } + case EBSTxReplace: + { + operation = EBSInitReplace; + break; + } + case EBSTxAccess: + { + operation = EBSInitAccess; + break; + } + default: + { + User::Leave( KErrArgument ); + break; + } + } + TInt err = SendReceive( operation, args ); + TRACE( T_LIT("RBSClient::InitClientL() 1st SendReceive err=%d"),err ); + CleanupStack::PopAndDestroy( 2, flatBuf ); // stream, flatBuf + + User::LeaveIfError( err ); + + User::LeaveIfError( SendReceive( EBSStartTransaction ) ); + TRACE( T_LIT("RBSClient::InitClientL() end") ); + } + +// ----------------------------------------------------------------------------- +// RBSClient::CreateArgumentsL() +// ----------------------------------------------------------------------------- +// +TIpcArgs RBSClient::CreateArgumentsL( const TDesC8& aApplicationId, + const TDesC8& aBrandId, + TLanguage aLanguage, + TInt aReserved ) + { + // set the arguments for the message + TIpcArgs args( &aApplicationId ); + args.Set( 1, &aBrandId ); + args.Set( 2, aLanguage ); + args.Set( 3, aReserved ); + + return args; + } + + +// ----------------------------------------------------------------------------- +// RBSClient::InsertL() +// ----------------------------------------------------------------------------- +// +void RBSClient::InsertL( MBSElement* aElement ) + { + SendUpdateL( aElement, EBSInstall ); + } + + +// ----------------------------------------------------------------------------- +// RBSClient::ReplaceL() +// ----------------------------------------------------------------------------- +// +void RBSClient::ReplaceL( MBSElement* aElement ) + { + SendUpdateL( aElement, EBSReplace ); + } + +// ----------------------------------------------------------------------------- +// RBSClient::AppendL() +// ----------------------------------------------------------------------------- +// +void RBSClient::AppendL( MBSElement* aElement ) + { + SendUpdateL( aElement, EBSAppend ); + } + +// ----------------------------------------------------------------------------- +// RBSClient::SendUpdateL() +// ----------------------------------------------------------------------------- +// +void RBSClient::SendUpdateL( MBSElement* aElement, TBSMessages aMessage ) + { + // FIXME magic number + CBufFlat* flatBuf = CBufFlat::NewL( 128 ); + CleanupStack::PushL( flatBuf ); + + RBufWriteStream elementStream; + CleanupClosePushL( elementStream ); + elementStream.Open( *flatBuf ); + + aElement->ExternalizeL( elementStream ); + + TPtr8 ptrElement( flatBuf->Ptr(0) ); + TIpcArgs args( &ptrElement ); + + TInt err = SendReceive( aMessage, args ); + + CleanupStack::PopAndDestroy(); // elementStream + CleanupStack::PopAndDestroy( flatBuf ); + User::LeaveIfError( err ); + } + +// ----------------------------------------------------------------------------- +// RBSClient::GetTextL() +// ----------------------------------------------------------------------------- +// +void RBSClient::GetTextL( const TDesC8& aId, HBufC*& aValue ) + { + TInt size = 0; + TPckg pack( size ); + + TIpcArgs args( &aId ); + args.Set( 1, &pack ); + TInt err = SendReceive( EBSPrepareText, args ); + User::LeaveIfError( err ); + + aValue = HBufC::NewL( size ); + TPtr ptrBuf( aValue->Des() ); + + args.Set( 2, &ptrBuf ); + err = SendReceive( EBSGetText, args ); + + if( err ) + { + delete aValue; + aValue = NULL; + User::Leave( err ); + } + } + +// ----------------------------------------------------------------------------- +// RBSClient::GetIntL() +// ----------------------------------------------------------------------------- +// +void RBSClient::GetIntL( const TDesC8& aId, TInt& aValue ) + { + TPckg pack( aValue ); + TIpcArgs args( &aId); + args.Set( 1, &pack ); + TInt err = SendReceive( EBSGetInt, args ); + User::LeaveIfError( err ); + } + +void RBSClient :: isBrandUpdateRequiredL (TInt & aUpdateRequired) +{ + //TIpcArgs args; + + TPckg pack (aUpdateRequired); + //args.Set (0, &pack); + TInt err = SendReceive (EBSIsBrandUpdateRequired, TIpcArgs (&pack)); + + User :: LeaveIfError (err); +} +// ----------------------------------------------------------------------------- +// RBSClient::GetTextL() +// ----------------------------------------------------------------------------- +// +void RBSClient::GetBufferL( const TDesC8& aId, HBufC8*& aValue ) + { + TInt size = 0; + TPckg pack( size ); + + TIpcArgs args( &aId ); + args.Set( 1, &pack ); + TInt err = SendReceive( EBSPrepareBuffer, args ); + User::LeaveIfError( err ); + + aValue = HBufC8::NewL( size ); + TPtr8 ptrBuf( aValue->Des() ); + + args.Set( 2, &ptrBuf ); + err = SendReceive( EBSGetBuffer, args ); + + if( err ) + { + delete aValue; + aValue = NULL; + User::Leave( err ); + } + } + +// ----------------------------------------------------------------------------- +// RBSClient::GetSeveralL() +// ----------------------------------------------------------------------------- +// +MBSElement* RBSClient::GetSeveralL( MDesC8Array& aIds ) + { + TInt size = 0; + + TPckg pack( size ); + TIpcArgs args; + args.Set( 0, &pack ); + + + // FIXME magic number + CBufFlat* flatBuf = CBufFlat::NewL( 128 ); + CleanupStack::PushL( flatBuf ); + + RBufWriteStream idStream; + CleanupClosePushL( idStream ); + idStream.Open( *flatBuf ); + + ExternalizeIdArrayL( idStream, aIds ); + + TPtr8 flatPtr = flatBuf->Ptr(0); + args.Set( 1, &flatPtr ); + // get the size of the data + TInt err = SendReceive( EBSPrepareSeveral, args ); + + CleanupStack::PopAndDestroy(); // idStream + CleanupStack::PopAndDestroy( flatBuf ); + User::LeaveIfError( err ); + + HBufC8* buf = HBufC8::NewLC( size ); + TPtr8 ptrBuf( buf->Des() ); + + TIpcArgs msgArgs; + msgArgs.Set( 0, &ptrBuf ); + + err = SendReceive( EBSGetSeveral, msgArgs ); + + TInt length = buf->Size(); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( *buf ); + + MBSElement* returnValue = InternalizeElementL( readStream ); + + CleanupStack::PopAndDestroy(); // readStream + CleanupStack::PopAndDestroy( buf ); // buf + + User::LeaveIfError( err ); + return returnValue; + } + + +// ----------------------------------------------------------------------------- +// RBSClient::GetFileL() +// ----------------------------------------------------------------------------- +// +void RBSClient::GetFileL( const TDesC8& aId, RFile& aFile ) + { + TInt fsh; + + TPckgBuf fh; + + TIpcArgs args( &fh ); + args.Set( 2, &aId ); + + fsh = SendReceive( EBSGetFile, args ); + TInt err = aFile.AdoptFromServer( fsh, fh() ); + + User::LeaveIfError( err ); + } + +// ----------------------------------------------------------------------------- +// RBSClient::GetStructureL() +// ----------------------------------------------------------------------------- +// +MBSElement* RBSClient::GetStructureL( const TDesC8& aId ) + { + TInt size = 0; + + TPckg pack( size ); + TIpcArgs args; + args.Set( 0, &pack ); + + args.Set( 1, &aId ); + // get the size of the data + TInt err = SendReceive( EBSPrepareStructure, args ); + + User::LeaveIfError( err ); + + + HBufC8* buf = HBufC8::NewLC( size ); + TPtr8 ptrBuf( buf->Des() ); + + TIpcArgs msgArgs; + msgArgs.Set( 0, &ptrBuf ); + + err = SendReceive( EBSGetStructure, msgArgs ); + + TInt length = buf->Size(); + + RDesReadStream readStream; + CleanupClosePushL( readStream ); + readStream.Open( *buf ); + + MBSElement* returnValue = InternalizeElementL( readStream ); + CleanupStack::PopAndDestroy(); // readStream + CleanupStack::PopAndDestroy( buf ); // buf + + User::LeaveIfError( err ); + + return returnValue; + } + +// ----------------------------------------------------------------------------- +// RBSClient::InternalizeElementL() +// ----------------------------------------------------------------------------- +// +MBSElement* RBSClient::InternalizeElementL( RReadStream& aStream ) + { + MBSElement* returnValue= NULL; + // Write common header for all elements + TBSElementType type = (TBSElementType)aStream.ReadInt16L(); + + TInt idSize = aStream.ReadInt16L(); + + HBufC8* elementId = HBufC8::NewLC( idSize ); + TPtr8 elementIdPtr = elementId->Des(); + + if( idSize > 0 ) + { + // read ID only if it's defined + aStream.ReadL( elementIdPtr, idSize ); + elementIdPtr.SetLength( idSize );// Set length + } + +// Ptr() returns a pointer to the start address of decriptor data, +// TPtrC constructor then parses the data until null terminator met. +// This results in wrong descriptor length & bad data! +// Solution is either +// 1) to use PtrZ() which appends a zero terminator, +// or 2) pass to constructor an object that has length data. +// Option 2) is less prone to errors, so use it. +// In general, assignment operator with descriptors should be avoided! +// So use TPtrC16(const TDesC16 &aDes) instead +// of TPtrC16(const TUint16 *aString)! + TPtrC8 idPtrC( *elementId );//idPtrC creation moved here so it will be updated correctly. + + if( elementId->Length() == 0 ) + { + CleanupStack::PopAndDestroy( elementId ); + elementId = NULL; + idPtrC.Set( KNullDesC8 ); + } + + // Write element type specific data + switch( type ) + { + case EBSInt: + { + TInt intData = aStream.ReadInt16L(); + returnValue = BSElementFactory::CreateBSElementL( idPtrC, + EBSInt, + intData ); + + break; + } + case EBSText: // flowthrough + case EBSFile: + { + TInt textSize = aStream.ReadInt16L(); + HBufC* textData = HBufC::NewLC( textSize ); + + TPtr textPtr = textData->Des(); + aStream.ReadL( textPtr, textSize ); + + returnValue = BSElementFactory::CreateBSElementL( idPtrC, + type, + *textData ); + CleanupStack::PopAndDestroy( textData ); + break; + } + case EBSList: + { + RBSObjOwningPtrArray listData; + CleanupClosePushL( listData ); + TInt count = aStream.ReadInt16L(); + + for( TInt i = 0; i < count; i++ ) + { + MBSElement* subElement = InternalizeElementL( aStream ); + CleanupClosePushL( *subElement ); + listData.AppendL( subElement ); + CleanupStack::Pop(); // subElement + } + + returnValue = BSElementFactory::CreateBSElementL( idPtrC, + EBSList, + listData ); + + CleanupStack::Pop(); // listData + + break; + } + + case EBSBuffer: + { + TInt bufferSize = aStream.ReadInt16L(); + HBufC8* buffeData = HBufC8::NewLC( bufferSize ); + + TPtr8 bufferPtr = buffeData->Des(); + aStream.ReadL( bufferPtr, bufferSize ); + + returnValue = BSElementFactory::CreateBSElementL( idPtrC, + EBSBuffer, + *buffeData ); + + CleanupStack::PopAndDestroy( buffeData ); + break; + } + + case EBSBitmap: + { + TInt length = aStream.ReadInt16L(); + HBufC8* fileId = HBufC8::NewLC( length ); + + TPtr8 fileIdPtr = fileId->Des(); + aStream.ReadL( fileIdPtr, length ); + + TInt bitmapId = aStream.ReadInt16L(); + TInt maskId = aStream.ReadInt16L(); + TInt skinId = aStream.ReadInt16L(); + TInt skinMaskId = aStream.ReadInt16L(); + + CBSBitmap* bitmap = CBSBitmap::NewLC( bitmapId, + maskId, + skinId, + skinMaskId, + fileIdPtr ); + + returnValue = BSElementFactory::CreateBSElementL( idPtrC, + EBSBitmap, + bitmap ); + CleanupStack::Pop( bitmap ); // bitmap + CleanupStack::PopAndDestroy( fileId ); // bitmap + + break; + } + + default: + { + // unknown type! + User::Leave( KErrCorrupt ); + break; + } + } + + if( elementId ) + { + CleanupStack::PopAndDestroy( elementId ); + } + + return returnValue; + } + + +// ----------------------------------------------------------------------------- +// RBSClient::InternalizeElementL() +// ----------------------------------------------------------------------------- +// +void RBSClient::ExternalizeIdArrayL( RWriteStream& aStream, MDesC8Array& aArray ) + { + TInt count = aArray.MdcaCount(); + aStream.WriteInt16L( count ); + + for( TInt i = 0; i < count; i++ ) + { + TPtrC8 ptr = aArray.MdcaPoint(i); + aStream.WriteInt16L( aArray.MdcaPoint( i ).Length() ); + aStream.WriteL( aArray.MdcaPoint( i ) ); + } + + } + +// ----------------------------------------------------------------------------- +// RBSClient::RemoveBrandL() +// ----------------------------------------------------------------------------- +// +void RBSClient::RemoveBrandL( const TDesC8& aApplicationId, + const TDesC8& aBrandId ) + { + // set the arguments for the message + TIpcArgs args( &aApplicationId ); + args.Set( 1, &aBrandId ); + TInt err = SendReceive( EBSRemoveBrand, args ); + User::LeaveIfError( err ); + } + +// ----------------------------------------------------------------------------- +// RBSClient::RemoveBrandsL() +// ----------------------------------------------------------------------------- +// +void RBSClient::RemoveBrandsL( const TDesC8& aApplicationId ) + { + // set the arguments for the message + TIpcArgs args( &aApplicationId ); + + TInt err = SendReceive( EBSRemoveApplication, args ); + User::LeaveIfError( err ); + } + +// ----------------------------------------------------------------------------- +// RBSClient::RegisterObserverL() +// ----------------------------------------------------------------------------- +// +void RBSClient::RegisterObserverL( MBSBrandChangeObserver* aObserver, MBSBackupRestoreStateObserver* aBackupStateObserver ) + { + CBSBrandObserver* tempObserver = CBSBrandObserver::NewL( aObserver, aBackupStateObserver, this ); + if( iObserver ) + { + delete iObserver; + } + iObserver = tempObserver; + } + +// ----------------------------------------------------------------------------- +// RBSClient::UnRegisterObserverL() +// ----------------------------------------------------------------------------- +// +void RBSClient::UnRegisterObserverL( MBSBrandChangeObserver* /*aObserver*/, MBSBackupRestoreStateObserver* /*aBackupStateObserver*/ ) + { + delete iObserver; + iObserver = NULL; + } + +// ----------------------------------------------------------------------------- +// RBSClient::UnRegisterObserverL() +// ----------------------------------------------------------------------------- +// +void RBSClient::RegisterObserverToServerL( TRequestStatus& aStatus ) + { + TIpcArgs args; + SendReceive( EBSObserveBrand, args, aStatus ); + } + +// ----------------------------------------------------------------------------- +// RBSClient::GetNewVersionL() +// ----------------------------------------------------------------------------- +// +TInt RBSClient::GetNewVersionL() + { + return GetValueL( EBSObserveGetNewVersion); + } + +// ----------------------------------------------------------------------------- +// RBSClient::GetValueL() +// ----------------------------------------------------------------------------- +// +TInt RBSClient::GetValueL(TInt msg) + { + TInt returnValue = 0; + TPckg pack( returnValue ); + TIpcArgs args( &pack ); + TInt err = SendReceive( msg, args ); + User::LeaveIfError( err ); + return returnValue; + } + +// ----------------------------------------------------------------------------- +// RBSClient::GetBackupStateL() +// ----------------------------------------------------------------------------- +// +TInt RBSClient::GetBackupStateL() + { + return GetValueL( EBSObserveGetBackupState); + } + +// ----------------------------------------------------------------------------- +// RBSClient::GetBackupRestoreL() +// ----------------------------------------------------------------------------- +// +TInt RBSClient::GetBackupRestoreL() + { + return GetValueL( EBSObserveGetChange); + } + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsclient.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSClient.h +* +*/ + + + +#ifndef __CBSCLIENT_H__ +#define __CBSCLIENT_H__ +#include +#include +#include +#include +#include "mbsupdater.h" +#include "bsserverdefs.h" +#include "mbsbrandobserverregistrar.h" + +class MBSElement; +class MBSBrandChangeObserver; +class MBSBackupRestoreStateObserver; +class CBSBrandObserver; + +/** + * Simple ClientServer for + * testing and example purposes. + */ +class RBSClient : public RSessionBase, + public MBSBrandObserverRegistrar + { + + public: // Constructor and destructor + RBSClient(); + ~RBSClient(); + + + public: // New methods + + TInt Connect(); + void Close(); + + void StartTransactionL( const TDesC8& aApplicationId, + const TDesC8& aBrandId, + const TDesC8& aDefaultBrandId, + TLanguage aLanguage, + TTransactionType aType, + TInt aReserved = 0 ); + + TInt StopTransactionL( const TDesC8& aApplicationId, + const TDesC8& aBrandId, + TLanguage aLanguage, + TInt aReserved = 0 ); + + void CancelTransactionL( const TDesC8& aApplicationId, + const TDesC8& aBrandId, + TLanguage aLanguage, + TInt aReserved = 0); + + void InsertL( MBSElement* aElement ); + void ReplaceL( MBSElement* aElement ); + void AppendL( MBSElement* aElement ); + + void GetTextL( const TDesC8& aId, HBufC*& aValue ); + void GetBufferL( const TDesC8& aId, HBufC8*& aValue ); + void GetIntL( const TDesC8& aId, TInt& aValue ); + + MBSElement* GetSeveralL( MDesC8Array& aIds ); + MBSElement* GetStructureL( const TDesC8& aId ); + void GetFileL( const TDesC8& aId, RFile& aFile ); + + void RemoveBrandL( const TDesC8& aApplicationId, + const TDesC8& aBrandId ); + + void RemoveBrandsL( const TDesC8& aApplicationId ); + + void isBrandUpdateRequiredL (TInt& aUpdateRequired); + + /* + * Register to observer brand data updates + * @param aObserver the observer interface + */ + void RegisterObserverL( MBSBrandChangeObserver* aObserver, MBSBackupRestoreStateObserver* aBackupStateObserver); + + /* + * Unregister a brand data update observer + * @param aObserver the observer interface + */ + void UnRegisterObserverL( MBSBrandChangeObserver* aObserver, MBSBackupRestoreStateObserver* aBackupStateObserver ); + + + private: + + void InitClientL( const TDesC8& aApplicationId, + const TDesC8& aBrandId, + const TDesC8& aDefaultBrandId, + TLanguage aLanguage, + TTransactionType aType, + TInt aReserved ); + + TIpcArgs CreateArgumentsL( const TDesC8& aApplicationId, + const TDesC8& aBrandId, + TLanguage aLanguage, + TInt aReserved ); + + MBSElement* InternalizeElementL( RReadStream& aStream ); + + void ExternalizeIdArrayL( RWriteStream& aStream, MDesC8Array& aArray ); + + void SendUpdateL( MBSElement* aElement, TBSMessages aMessage ); + + private: // from MBSBrandObserverRegistrar + /* + * Registeres the brand observer to server + */ + void RegisterObserverToServerL( TRequestStatus& aStatus ); + + TInt GetNewVersionL(); + TInt GetValueL(TInt msg) ; + TInt GetBackupStateL() ; + TInt GetBackupRestoreL() ; + + + private: + TTransactionType iType; + CBSBrandObserver* iObserver; + TInt isUpdateRequired; + }; + +#endif // __CBSCLIENT_H__ + + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbselement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbselement.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,344 @@ +/* +* 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 the License "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: cbselement.cpp +* +*/ + +// INCLUDE FILES + +#include +#include "e32base.h" +#include "s32strm.h" +#include "cbselement.h" +#include "cbsbitmap.h" + + +CBSElement* CBSElement::NewL( + const TDesC8& aElementId, + TInt aData ) + { + + CBSElement* self = new ( ELeave ) CBSElement() ; + CleanupStack::PushL( self ); + self->ConstructL( EBSInt, + aElementId, + aData, + ETrue, + NULL, + KNullDesC, + KNullDesC8, + NULL ); + CleanupStack::Pop( self ); //self + return self; + } + + +CBSElement* CBSElement::NewL( + const TDesC8& aElementId, + const TDesC& aData, + TBSElementType aType /*= EText*/ ) + { + if( aType != EBSFile && aType != EBSText ) + { + User::Leave( KErrArgument ); + } + + CBSElement* self = new ( ELeave ) CBSElement() ; + CleanupStack::PushL( self ); + self->ConstructL( aType, + aElementId, + 0, + EFalse, + NULL, + aData, + KNullDesC8, + NULL); + CleanupStack::Pop( self ); //self + return self; + } + + +CBSElement* CBSElement::NewL( + const TDesC8& aElementId, + const TDesC8& aData ) + { + CBSElement* self = new ( ELeave ) CBSElement() ; + CleanupStack::PushL( self ); + self->ConstructL( EBSBuffer, + aElementId, + 0, + EFalse, + NULL, + KNullDesC, + aData, + NULL); + CleanupStack::Pop( self ); //self + return self; + } + +CBSElement* CBSElement::NewL( + const TDesC8& aElementId, + RBSObjOwningPtrArray& aStructure ) + { + CBSElement* self = new ( ELeave ) CBSElement(); + CleanupStack::PushL( self ); + self->ConstructL( EBSList, + aElementId, + 0, + EFalse, + NULL, + KNullDesC, + KNullDesC8, + &aStructure ); + CleanupStack::Pop( self ); //self + return self; + } + +CBSElement* CBSElement::NewL( + const TDesC8& aElementId, + CBSBitmap* aBitmap ) + { + CBSElement* self = new ( ELeave ) CBSElement() ; + CleanupStack::PushL( self ); + self->ConstructL( EBSBitmap, + aElementId, + 0, + EFalse, + aBitmap, + KNullDesC, + KNullDesC8, + NULL ); + + if( !aBitmap ) + { + User::Leave( KErrArgument ); + } + + CleanupStack::Pop( self ); //self + return self; + } + +void CBSElement::ConstructL( + TBSElementType aElementType, + const TDesC8& aElementId, + TInt aIntData, + TBool aIntDataInitialized, + CBSBitmap* aBitmap, + const TDesC& aTextData, + const TDesC8& aBufferData, + RBSObjOwningPtrArray* aStructure ) + { + iElementType = aElementType; + + iElementId = aElementId.AllocL(); + + iIntData = aIntData; + iIntDataInitialized = aIntDataInitialized; + + iBitmapData = aBitmap; + + if( 0 != aTextData.Compare( KNullDesC() ) ) + { + iTextData = aTextData.AllocL(); + } + if( 0 != aBufferData.Compare( KNullDesC8() ) ) + { + iBufferData = aBufferData.AllocL(); + } + if( aStructure ) + { + iArrayInitialized = ETrue; + iArray = *aStructure; + } + } + + +CBSElement::~CBSElement() + { + delete iTextData; + delete iBufferData; + delete iElementId; + + iArray.Close(); + delete iBitmapData; + } + + +CBSElement::CBSElement() + { + } + +void CBSElement::Close() + { + delete this; + } + + +TBSElementType CBSElement::ElementType() + { + return iElementType; + } + +const TDesC8& CBSElement::ElementId() + { + return *iElementId; + } + +TInt CBSElement::IntDataL() + { + if( !iIntDataInitialized ) + { + User::Leave( KErrArgument ); + } + return iIntData; + } + +const TDesC& CBSElement::TextDataL() + { + if( !iTextData ) + { + User::Leave( KErrArgument ); + } + return *iTextData; + } + +const TDesC8& CBSElement::BufferDataL() + { + if( !iBufferData ) + { + User::Leave( KErrArgument ); + } + return *iBufferData; + } + +const CBSBitmap& CBSElement::BitmapDataL() + { + if( !iBitmapData ) + { + User::Leave( KErrArgument ); + } + return *iBitmapData; + } + +TArray CBSElement::GetStructureL() + { + if( !iArrayInitialized ) + { + User::Leave( KErrArgument ); + } + + return iArray.Array(); + } + +const MBSElement& CBSElement::FindSubEntryL( const TDesC& aElementId ) + { + if ( !iArray.Count() ) + { + User::Leave( KErrNotFound ); + } + + MBSElement* element = NULL; + HBufC8* id = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aElementId ); + User::LeaveIfNull( id ); + CleanupStack::PushL( id ); + for ( TInt i( 0 ) ; i < iArray.Count() ; i++ ) + { + if ( iArray[ i ] ) + { + if ( !iArray[ i ]->ElementId().CompareC( *id ) ) + { + // Match found + element = iArray[ i ]; + i = iArray.Count();// Exit loop. + } + } + } + CleanupStack::PopAndDestroy( id ); + + if ( !element ) + { + User::Leave( KErrNotFound ); + } + + return *element; + } + +void CBSElement::ExternalizeL( RWriteStream& aWriteStream ) + { + // Write common header for all elements + aWriteStream.WriteInt16L( iElementType ); + aWriteStream.WriteInt16L( iElementId->Length() ); + if( iElementId->Length() > 0 ) + { + // Write ID only if it's defined + aWriteStream.WriteL( *iElementId ); + } + + // Write element type specific data + switch( iElementType ) + { + case EBSInt: + { + aWriteStream.WriteInt16L( iIntData ); + break; + } + case EBSText: // flowthrough + case EBSFile: + { + aWriteStream.WriteInt16L( iTextData->Length() ); + aWriteStream.WriteL( *iTextData ); + break; + } + case EBSList: + { + TInt count = iArray.Count(); + aWriteStream.WriteInt16L( count ); + // Write all subitems to stream + for( TInt i = 0; i < count; i++ ) + { + MBSElement* element = iArray[i]; + element->ExternalizeL( aWriteStream ); + } + break; + } + case EBSBitmap: + { + TPtrC8 ptr = iBitmapData->BitmapFileId(); + aWriteStream.WriteInt16L( ptr.Length() ); + aWriteStream.WriteL( ptr ); + + aWriteStream.WriteInt16L( iBitmapData->BitmapId() ); + aWriteStream.WriteInt16L( iBitmapData->BitmapMaskId() ); + aWriteStream.WriteInt16L( iBitmapData->SkinIdMajor() ); + aWriteStream.WriteInt16L( iBitmapData->SkinIdMinor() ); + + break; + } + case EBSBuffer: + { + aWriteStream.WriteInt16L( iBufferData->Length() ); + aWriteStream.WriteL( *iBufferData ); + break; + } + default: + { + // unknown type! + User::Leave( KErrCorrupt ); + break; + } + } + } + + +// END OF FILE diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbselement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbselement.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: cbselement.h +* +*/ + + + +#ifndef __CBSELEMENT_H__ +#define __CBSELEMENT_H__ +#include + +#include "mbselement.h" +#include "RBSObjOwningPtrArray.h" + +class RWriteStream; + +/** + * + */ +NONSHARABLE_CLASS( CBSElement ): public CBase, + public MBSElement + { + public: + /** + * Two-phased constructor. + */ + static CBSElement* NewL( + const TDesC8& aElementId, + TInt aData ); + + static CBSElement* NewL( + const TDesC8& aElementId, + const TDesC& aData, + TBSElementType aType = EBSText ); + + static CBSElement* NewL( + const TDesC8& aElementId, + const TDesC8& aData ); + + // Transfers ownership + static CBSElement* NewL( + const TDesC8& aElementId, + CBSBitmap* aBitmap ); + + static CBSElement* NewL( + const TDesC8& aElementId, + RBSObjOwningPtrArray& aStructure ); + + void Close(); + + virtual ~CBSElement(); + + private: + CBSElement(); + + + void ConstructL( TBSElementType aElementType, + const TDesC8& aElementId, + TInt aIntData, + TBool aIntDataInitialized, + CBSBitmap* aBitmap, + const TDesC& aTextData, + const TDesC8& aBufferData, + RBSObjOwningPtrArray* aStructure ); + + private: + TBSElementType ElementType(); + const TDesC8& ElementId(); + + // Leaves with KErrArgument if trying to + // get wrong type + TInt IntDataL(); + const TDesC& TextDataL(); + const TDesC8& BufferDataL(); + const CBSBitmap& BitmapDataL(); + TArray GetStructureL(); + + const MBSElement& FindSubEntryL( const TDesC& aElementId ); + + void ExternalizeL( RWriteStream& aWriteStream ); + + + + private: // data + TBSElementType iElementType; + HBufC8* iElementId; + TInt iIntData; + TBool iIntDataInitialized; + HBufC* iTextData; + HBufC8* iBufferData; + TBool iArrayInitialized; + RBSObjOwningPtrArray iArray; + CBSBitmap* iBitmapData; + + }; + +#endif // __CBSELEMENT_H__ + + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsfactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsfactory.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,131 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Factory for creating branding +* +*/ + + +// INCLUDE FILES +#include "cbsfactory.h" +#include "cbsaccess.h" +#include "cbsupdater.h" +#include "mbsaccess.h" +#include "mbsupdater.h" +#include "cbsclient.h" +#include "DebugTrace.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// BrandingFactory::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +EXPORT_C CBSFactory* CBSFactory::NewL( const TDesC8& aDefaultBrandId, + const TDesC8& aApplicationId ) + { + TRACE( T_LIT("CBSFactory::NewL begin") ); + CBSFactory* self = new ( ELeave ) CBSFactory() ; + CleanupStack::PushL( self ); + self->ConstructL( aDefaultBrandId, aApplicationId ); + CleanupStack::Pop( self ); //self + TRACE( T_LIT("CBSFactory::NewL end") ); + return self; + } + + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CBSFactory::CBSFactory() + { + } + +// destructor +CBSFactory::~CBSFactory() + { + delete iDefaultBrand; + delete iApplicationId; + if( iServerKeepAlive ) + { + iServerKeepAlive->Close(); + } + delete iServerKeepAlive; + } + +// Symbian OS default constructor can leave. +void CBSFactory::ConstructL( const TDesC8& aDefaultBrandId, + const TDesC8& aApplicationId ) + { + iDefaultBrand = aDefaultBrandId.AllocL(); + iApplicationId = aApplicationId.AllocL(); + iServerKeepAlive = new(ELeave) RBSClient(); // CSI: 74 # this needs to be like this + User::LeaveIfError( iServerKeepAlive->Connect() ); + } + + +// ----------------------------------------------------------------------------- +// CBSFactory::CreateAccessL() +// ----------------------------------------------------------------------------- +// +EXPORT_C MBSAccess* CBSFactory::CreateAccessL( const TDesC8& aBrandId, + TLanguage aLanguageId, + TBool aCacheData, /* = EFalse */ + TInt aReserved /*= 0*/ ) + { + TRACE( T_LIT("CBSFactory::CreateAccessL begin") ); + CBSAccess* access = CBSAccess::NewL( aBrandId, *iApplicationId, *iDefaultBrand, + aLanguageId, aCacheData, aReserved ); + TRACE( T_LIT("CBSFactory::CreateAccessL end") ); + return access; + } + +// ----------------------------------------------------------------------------- +// CBSFactory::CreateAccessL() +// ----------------------------------------------------------------------------- +// +EXPORT_C MBSAccess* CBSFactory::CreateAccessLC( const TDesC8& aBrandId, + TLanguage aLanguageId, + TBool aCacheData, /* = EFalse */ + TInt aReserved /*= 0 */) + { + CBSAccess* access = CBSAccess::NewL( aBrandId, *iApplicationId, *iDefaultBrand, + aLanguageId, aCacheData, aReserved ); + CleanupClosePushL( *access ); + return access; + } + +// ----------------------------------------------------------------------------- +// CBSFactory::CreateUpdaterL() +// ----------------------------------------------------------------------------- +// +EXPORT_C MBSUpdater* CBSFactory::CreateUpdaterL() + { + CBSUpdater* updater = CBSUpdater::NewL( *iApplicationId ); + return updater; + } + +// ----------------------------------------------------------------------------- +// CBSFactory::CreateUpdaterLC() +// ----------------------------------------------------------------------------- +// +EXPORT_C MBSUpdater* CBSFactory::CreateUpdaterLC() + { + CBSUpdater* updater = CBSUpdater::NewL( *iApplicationId ); + CleanupClosePushL( *updater ); + return updater; + } + +// End of File + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsiconfileprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsiconfileprovider.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Icon file provider. + * +*/ + + + +// INCLUDE FILES +#include "cbsiconfileprovider.h" +#include +#include + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CBSIconFileProvider::CBSIconFileProvider +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CBSIconFileProvider::CBSIconFileProvider() + { + } +// ----------------------------------------------------------------------------- +// CBSIconFileProvider::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CBSIconFileProvider::ConstructL(RFile& aFile) + { + User::LeaveIfError( iFile.Duplicate( aFile ) ); + } + +// ----------------------------------------------------------------------------- +// CBSIconFileProvider::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBSIconFileProvider* CBSIconFileProvider::NewL( + RFile& aFile ) + { + CBSIconFileProvider* self = new( ELeave ) CBSIconFileProvider(); + + CleanupStack::PushL( self ); + self->ConstructL(aFile); + CleanupStack::Pop( self ); + return self; + } + + +// Destructor +CBSIconFileProvider::~CBSIconFileProvider() + { + delete iFilename; + iFile.Close(); + } + +// ----------------------------------------------------------------------------- +// CBSIconFileProvider::RetrieveIconFileHandleL +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CBSIconFileProvider::RetrieveIconFileHandleL( + RFile& aFile, const TIconFileType /*aType*/ ) + { + aFile.Duplicate( iFile ); + } + +// ----------------------------------------------------------------------------- +// CBSIconFileProvider::Finished +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CBSIconFileProvider::Finished() + { + // commit suicide because Avkon Icon Server said so + delete this; + } + +// End of File diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsiconfileprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsiconfileprovider.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Icon file provider. + * +*/ + + + + +#ifndef CBSICONFILEPROVIDER_H +#define CBSICONFILEPROVIDER_H + +// INCLUDES +#include +#include +#include + + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +/** + * Icon file provider. + * See MAknIconFileProvider.h for comments. + * + * @lib chat.app + * @since 3.0 + */ +class CBSIconFileProvider : public CBase, public MAknIconFileProvider + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBSIconFileProvider* NewL( RFile& aFile ); + /** + * Destructor. + */ + virtual ~CBSIconFileProvider(); + + public: // Functions from base classes + + /** + * @see MAknIconFileProvider + */ + void RetrieveIconFileHandleL( + RFile& aFile, const TIconFileType aType ); + + /** + * @see MAknIconFileProvider + */ + void Finished(); + + private: + + /** + * C++ default constructor. + */ + CBSIconFileProvider(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(RFile& aFile); + + private: // Data + + // owned. filename of this icon. must be a copy, + // a reference could end up pointing into another file. + HBufC* iFilename; + + RFile iFile; + }; + +#endif // CBSICONFILEPROVIDER_H + +// End of File diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsupdater.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsupdater.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,539 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSUpdater.cpp +* +*/ + + + +// INCLUDE FILES + +#include "e32base.h" + +#include "cbsupdater.h" +#include "DebugTrace.h" +#include "mbsaccess.h" +#include "bselementfactory.h" +#include "mbselement.h" +#include "bsserverdefs.h" + +// Two-phased constructor. +CBSUpdater* CBSUpdater::NewL( const TDesC8& aApplicationId ) + { + CBSUpdater* self = new ( ELeave ) CBSUpdater() ; + CleanupStack::PushL( self ); + self->ConstructL( aApplicationId ); + CleanupStack::Pop( self ); //self + return self; + } + +// Symbian OS default constructor can leave. +void CBSUpdater::ConstructL( const TDesC8& aApplicationId ) + { + iApplicationId = aApplicationId.AllocL(); + User::LeaveIfError( iClient.Connect() ); + } + +// Destructor +CBSUpdater::~CBSUpdater() + { + delete iApplicationId; + delete iBrandId; + iClient.Close(); + } + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CBSUpdater::CBSUpdater() + { + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::Close() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::Close() + { + delete this; + } + +// ----------------------------------------------------------------------------- +// CBSUpdater::StartTransactionL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::StartTransactionL( const TDesC8& aBrandId, + TLanguage aLanguageId, + TUpdateTransactionType aType, /*EUpdateInstall*/ + TInt aReserved) + { + if( iActive ) + { + User::Leave( KErrAlreadyExists ); + } + + iActive = ETrue; + HBufC8* tmp = aBrandId.AllocL(); + delete iBrandId; + iBrandId = tmp; + iLanguageId = aLanguageId; + iReserved = aReserved; + iTxType = aType; + + TTransactionType operation = EBSTxAccess; + switch( aType ) + { + case EUpdateInstall: + { + operation = EBSTxInstall; + break; + } + case EUpdateAppend: + { + operation = EBSTxAppend; + break; + } + case EUpdateReplace: + { + operation = EBSTxReplace; + break; + } + case EUpdateUninstall: + { + operation = EBSTxUninstall; + break; + } + default: + break; + } + + TRAPD( err, iClient.StartTransactionL( *iApplicationId, aBrandId, KNullDesC8, + aLanguageId, operation, aReserved ) ); + if( err ) + { + iActive = EFalse; + User::Leave( err ); + } + + } +// ----------------------------------------------------------------------------- +// CBSUpdater::StopTransactionL() +// ----------------------------------------------------------------------------- +// +TInt CBSUpdater::StopTransactionL() + { + if( !iActive ) + { + User::Leave( KErrNotFound ); + } + + TInt returnValue = iClient.StopTransactionL( *iApplicationId, + *iBrandId, + iLanguageId, + iReserved ); + iActive = EFalse; + return returnValue; + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::CancelTransactionL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::CancelTransactionL() + { + if( !iActive ) + { + User::Leave( KErrNotFound ); + } + + iClient.CancelTransactionL( *iApplicationId, *iBrandId, iLanguageId, iReserved ); + iActive = EFalse; + } + + + +//*** BRAND INSTALLING ***// +// ----------------------------------------------------------------------------- +// CBSUpdater::InsertTextL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::InsertTextL( const TDesC8& aId, + const TDesC& aText ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateInstall ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSText, aText ); + CleanupClosePushL( *element ); + InsertElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::InsertBufferL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::InsertBufferL( const TDesC8& aId, + const TDesC8& aBuffer ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateInstall ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSBuffer, aBuffer ); + CleanupClosePushL( *element ); + InsertElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::InsertIntL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::InsertIntL( const TDesC8& aId, + TInt aInt ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateInstall ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSInt, aInt ); + CleanupClosePushL( *element ); + InsertElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::InsertFileL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::InsertFileL( const TDesC8& aId, + const TDesC& aFileName ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateInstall ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSFile, aFileName ); + CleanupClosePushL( *element ); + InsertElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::InsertElementL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::InsertElementL( MBSElement* aElement ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateInstall ) + { + User::Leave( KErrArgument ); + } + iClient.InsertL( aElement ); + } + + + + +//*** BRAND UPDATING - replacing ***// +// ----------------------------------------------------------------------------- +// CBSUpdater::ReplaceTextL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::ReplaceTextL( const TDesC8& aId, + const TDesC& aText ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateReplace ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSText, aText ); + CleanupClosePushL( *element ); + ReplaceElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::ReplaceBufferL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::ReplaceBufferL( const TDesC8& aId, + const TDesC8& aBuffer ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateReplace ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSBuffer, aBuffer ); + CleanupClosePushL( *element ); + ReplaceElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::ReplaceIntL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::ReplaceIntL( const TDesC8& aId, + TInt aInt ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateReplace ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSInt, aInt ); + CleanupClosePushL( *element ); + ReplaceElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::ReplaceFileL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::ReplaceFileL( const TDesC8& aId, + const TDesC& aFileName ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateReplace ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSFile, aFileName ); + CleanupClosePushL( *element ); + ReplaceElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::ReplaceElementL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::ReplaceElementL( MBSElement* aElement ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateReplace ) + { + User::Leave( KErrArgument ); + } + iClient.ReplaceL( aElement ); + } + + + + +//*** BRAND UPDATING - appending ***// +// ----------------------------------------------------------------------------- +// CBSUpdater::AppendTextL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::AppendTextL( const TDesC8& aId, + const TDesC& aText ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateAppend ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSText, aText ); + CleanupClosePushL( *element ); + AppendElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::AppendBufferL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::AppendBufferL( const TDesC8& aId, + const TDesC8& aBuffer ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateAppend ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSBuffer, aBuffer ); + CleanupClosePushL( *element ); + AppendElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::AppendIntL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::AppendIntL( const TDesC8& aId, + TInt aInt ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateAppend ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSInt, aInt ); + CleanupClosePushL( *element ); + AppendElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::AppendFileL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::AppendFileL( const TDesC8& aId, + const TDesC& aFileName ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateAppend ) + { + User::Leave( KErrArgument ); + } + MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSFile, aFileName ); + CleanupClosePushL( *element ); + AppendElementL( element ); + CleanupStack::PopAndDestroy(); // element + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::AppendElementL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::AppendElementL( MBSElement* aElement ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + if( iTxType != EUpdateAppend ) + { + User::Leave( KErrArgument ); + } + iClient.AppendL( aElement ); + } + + +// ----------------------------------------------------------------------------- +// CBSUpdater::AppendElementL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater::RemoveBrandL( const TDesC8& aApplicationId, + const TDesC8& aBrandId ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + iClient.RemoveBrandL( aApplicationId, aBrandId ); + } + +// ----------------------------------------------------------------------------- +// CBSUpdater::AppendElementL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater:: RemoveBrandsL( const TDesC8& aApplicationId ) + { + if( !iActive ) + { + User::Leave( KErrNotReady ); + } + iClient.RemoveBrandsL( aApplicationId ); + } + +// ----------------------------------------------------------------------------- +// CBSUpdater::RegisterObserverL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater:: RegisterObserverL( MBSBackupRestoreStateObserver* aBackupObserver ) +{ + iClient.RegisterObserverL(NULL, aBackupObserver) ; +} + +// ----------------------------------------------------------------------------- +// CBSUpdater::UnRegisterObserverL() +// ----------------------------------------------------------------------------- +// +void CBSUpdater:: UnRegisterObserverL( MBSBackupRestoreStateObserver* aObserver ) +{ + iClient.UnRegisterObserverL(NULL, aObserver) ; +} + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/cbsupdater.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/cbsupdater.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,206 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSUpdater.h +* +*/ + + + +#ifndef __CBSUPDATER_H__ +#define __CBSUPDATER_H__ +#include +#include "mbsupdater.h" +#include "cbsclient.h" + +/** + * Simple ClientServer for + * testing and example purposes. + */ +NONSHARABLE_CLASS( CBSUpdater ): public CBase, + public MBSUpdater + { + public: + /** + * Two-phased constructor. + */ + static CBSUpdater* NewL( const TDesC8& aApplicationId ); + + virtual ~CBSUpdater(); + + /* + * @see MBSUpdater + */ + void Close(); + + private: + void ConstructL( const TDesC8& aApplicationId ); + CBSUpdater(); + + + private: // from MBSUpdater + + /* + * @see MBSUpdater + */ + void StartTransactionL( const TDesC8& aBrandId, + TLanguage aLanguageId, + TUpdateTransactionType aType = EUpdateInstall, + TInt aReserved = 0 ); + /* + * @see MBSUpdater + */ + TInt StopTransactionL(); + + /* + * @see MBSUpdater + */ + void CancelTransactionL(); + + + /* + * @see MBSUpdater + */ + void RemoveBrandL( const TDesC8& aApplicationId, + const TDesC8& aBrandId ); + + /* + * @see MBSUpdater + */ + void RemoveBrandsL( const TDesC8& aApplicationId ); + + + //*** BRAND INSTALLING ***// + /* + * @see MBSUpdater + */ + void InsertTextL( const TDesC8& aId, + const TDesC& aText ); + + /* + * @see MBSUpdater + */ + void InsertBufferL( const TDesC8& aId, + const TDesC8& aBuffer ); + + /* + * @see MBSUpdater + */ + void InsertIntL( const TDesC8& aId, + TInt aInt ); + + /* + * @see MBSUpdater + */ + void InsertFileL( const TDesC8& aId, + const TDesC& aFileName ); + + /* + * @see MBSUpdater + */ + void InsertElementL( MBSElement* aElement ); + + + + //*** BRAND UPDATING - replacing ***// + /* + * @see MBSUpdater + */ + void ReplaceTextL( const TDesC8& aId, + const TDesC& aText ); + + /* + * @see MBSUpdater + */ + void ReplaceBufferL( const TDesC8& aId, + const TDesC8& aBuffer ); + + /* + * @see MBSUpdater + */ + void ReplaceIntL( const TDesC8& aId, + TInt aInt ); + + /* + * @see MBSUpdater + */ + void ReplaceFileL( const TDesC8& aId, + const TDesC& aFileName ); + + /* + * @see MBSUpdater + */ + void ReplaceElementL( MBSElement* aElement ); + + + + //*** BRAND UPDATING - appending ***// + /* + * @see MBSUpdater + */ + void AppendTextL( const TDesC8& aId, + const TDesC& aText ); + + /* + * @see MBSUpdater + */ + void AppendBufferL( const TDesC8& aId, + const TDesC8& aBuffer ); + + /* + * @see MBSUpdater + */ + void AppendIntL( const TDesC8& aId, + TInt aInt ); + + /* + * @see MBSUpdater + */ + void AppendFileL( const TDesC8& aId, + const TDesC& aFileName ); + + /* + * @see MBSUpdater + */ + void AppendElementL( MBSElement* aElement ); + + /* + * @see MBSUpdater + */ + void RegisterObserverL( MBSBackupRestoreStateObserver* aBackupObserver ) ; + + /* + * @see MBSUpdater + */ + void UnRegisterObserverL( MBSBackupRestoreStateObserver* aObserver ) ; + + + private: // data + + // tells if a transaction is ongoing or not + TBool iActive; + + HBufC8* iApplicationId; + HBufC8* iBrandId; + TLanguage iLanguageId; + TBool iUseCache; + RBSClient iClient; + TUpdateTransactionType iTxType; + TInt iReserved; + }; + +#endif // __CBSUPDATER_H__ + + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/mbsbrandobserverregistrar.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/mbsbrandobserverregistrar.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: MBSBrandObserverRegistrar.h +* +*/ + + + + +#ifndef __MBSBRANDOBSERVERREGISTRAR_H +#define __MBSBRANDOBSERVERREGISTRAR_H + +#include + + +/** + * An interface through which client can take into use + * available brand data updates. + * + * @since + */ +class MBSBrandObserverRegistrar + { + public: + + /* + * Registeres the brand observer to server + */ + virtual void RegisterObserverToServerL( TRequestStatus& aStatus) = 0; + + + /* + * Gets the new updated version number + */ + virtual TInt GetNewVersionL() = 0; + + virtual TInt GetBackupRestoreL() = 0; + + virtual TInt GetBackupStateL() = 0; + +protected: + /* + * Destructor + */ + virtual ~MBSBrandObserverRegistrar() {}; + }; + +#endif //__MBSBRANDOBSERVERREGISTRAR_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/tbselementiterator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/tbselementiterator.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: tbselementiterator.cpp +* +*/ + + + + +// INCLUDE FILES +#include "tbselementiterator.h" +#include + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// TBSElementIterator::TBSElementIterator +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +TBSElementIterator::TBSElementIterator( const TDesC& aElementId ) + : iElementId( aElementId ) + { + } + +MBSElement& TBSElementIterator::Next() + { + } + + +// End of File diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSClient/tbsmdescarrayadapter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSClient/tbsmdescarrayadapter.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: One value adapter for MDesCArray. +* +*/ + + +// INCLUDES +#include "tbsmdescarrayadapter.h" +#include +#include + + +//LOCAL constants +namespace + { + //Panic + _LIT( KBSMDesArrayAdapterPanic, "BSDesArrAdp" ); + + //Panic reasons + enum TBSMDesArrayAdapterReasons + { + EMdcaPointOutOfBounds + }; + + void BSMDesAdapPanic( TBSMDesArrayAdapterReasons aPanicReason ) + { + User::Panic( KBSMDesArrayAdapterPanic, aPanicReason ); + } + } + + + + +// ================= MEMBER FUNCTIONS ======================= +// C++ default constructor can NOT contain any code, that +// might leave. +// +EXPORT_C TBSMDesCArrayAdapter::TBSMDesCArrayAdapter( const TDesC& aDesc ) + : iDesc( aDesc ) + { + } + +// ----------------------------------------------------------------------------- +// TBSMDesCArrayAdapter::MdcaCount() +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt TBSMDesCArrayAdapter::MdcaCount() const + { + //there is just one adapted descriptor + return 1; + } + +// ----------------------------------------------------------------------------- +// TBSMDesCArrayAdapter::MdcaPoint() +// ----------------------------------------------------------------------------- +// +EXPORT_C TPtrC TBSMDesCArrayAdapter::MdcaPoint( TInt aIndex ) const + { + //there is just one adapted descriptor + __ASSERT_ALWAYS( aIndex == 0, BSMDesAdapPanic( EMdcaPointOutOfBounds ) ); + return iDesc; + } + + + +// End of File + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/bsimportconstants.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/bsimportconstants.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,65 @@ +/* +* 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 the License "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: BrandingServer constants. +* +*/ + +// CONSTANTS + +// Characters to strip from xml text values +_LIT( KCommonControlCharacters, "\n\t\r" ); +_LIT( KEndl, "\n\r" ); + +// === Directory & file constants ============================================= +_LIT( KDirSeparator, "\\" ); +_LIT( KDot, "." ); +_LIT( KDefFileName, "brandfile.bin.r" ); +_LIT( KDefEventLogDir, "BSImport" ); +_LIT( KDefEventLogFile, "eventlog.txt" ); +_LIT( KFileElementStore, "files" ); +_LIT( KBSDataStore, "data" ); +_LIT( KAllFilesWildCard, "*.*" ); +_LIT( KBSCDrive, "C:" ); +_LIT( KBSZDrive, "Z:" ); +// Codescanner warning : hard-coded drive letters (id:25) +// this folder is always on c-drive +_LIT( KBSIbyDirectory, "c:\\data\\bs\\" ); // CSI: 25 # See above +_LIT( KBSIbyExtension, ".iby" ); +_LIT( KBSFileLangSuffix, "r" ); +const TInt KMaxVersionLenght = 3; + +const TInt KLeadingZero = 0; +const TInt KLangBufLength = 2; + +// folders inside server's private: "\\private\\102828DD\\" +_LIT( KInstallObservePath, "import\\install\\" ); // new files +_LIT( KInstallPath, "install\\" ); // installed files + +// drive where installation files are saved +_LIT( KInstallDrive, "C:" ); + +// brand installation file extension +_LIT( KBrandInstallExt, ".install" ); + +// Separator which separates brand id from application id in +// uninstall buffer +_LIT( KInstallFileDataSeparator, "$" ); + +_LIT( KDiscardBrandFileName, "discardedbrand.txt" ); + + + + + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/bsserverdefs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/bsserverdefs.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,118 @@ +/* +* 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 the License "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: server defintions. +* +*/ + +#ifndef __BSSERVERDEFS_H__ +#define __BSSERVERDEFS_H__ +#include + +/** + * + * + */ +const TInt KBSVersionMajor = 1; +const TInt KBSVersionMinor = 1; +const TInt KBSVersionBuild = 1; + +/** + * + * + */ +_LIT( KBSServerExe, "bsserver.exe" ); + + +/** + * + * + */ +_LIT( KBSServerName, "bs" ); + + +/** + * + * + */ +const TUint KBSMsgSlotCount = 4; + + +enum TTransactionType + { + EBSTxInstall = 1, + EBSTxUninstall, + EBSTxAppend, + EBSTxReplace, + EBSTxAccess + }; + +/** + * + * + */ +enum TBSMessages + { + // access API + EBSInitInstall = 1, + EBSInitUninstall, + EBSInitAppend, + EBSInitReplace, + EBSInitAccess, + EBSPrepareText, + EBSGetText, + EBSGetInt, + EBSPrepareBuffer, + EBSGetBuffer, + EBSPrepareSeveral, + EBSGetSeveral, + EBSGetFile, + EBSPrepareStructure, + EBSGetStructure, + + EBSStartTransaction, + EBSStopTransaction, + EBSCancelTransaction, + + // installing + EBSInstall, + + // replacing + EBSReplace, + + // appending + EBSAppend, + + // removing + EBSRemoveBrand, + + EBSRemoveApplication, + + // observing + EBSObserveBrand, + EBSObserveGetNewVersion, + EBSObserveGetChange, + EBSObserveGetBackupState, + EBSIsBrandUpdateRequired, + EBSOperationLast + }; + + +#endif //__BSSERVERDEFS_H__ + +// END OF FILE + + + + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsbackupobserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsbackupobserver.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,196 @@ +/* +* Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Stores element data and writes it to stream +* +*/ + + + +#include + +#include "cbsbackupobserver.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CBSBackupObserver::NewL +// --------------------------------------------------------------------------- +// +CBSBackupObserver* CBSBackupObserver::NewL() + { + CBSBackupObserver* self = NewLC(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::NewLC +// --------------------------------------------------------------------------- +// +CBSBackupObserver* CBSBackupObserver::NewLC() + { + CBSBackupObserver* self = new (ELeave) CBSBackupObserver(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::ConstructL +// --------------------------------------------------------------------------- +// +void CBSBackupObserver::ConstructL() + { + CActiveScheduler::Add( this ); + iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey ); + iLatestState = BackupStateL(); + Subscribe(); + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::CBSBackupObserver +// --------------------------------------------------------------------------- +// +CBSBackupObserver::CBSBackupObserver() : + CActive( EPriorityStandard ) + { + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::~CBSBackupObserver +// --------------------------------------------------------------------------- +// +CBSBackupObserver::~CBSBackupObserver() + { + Cancel(); + iObservers.Close(); + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::RunL +// --------------------------------------------------------------------------- +// +void CBSBackupObserver::RunL() + { + MBSBackupObserver::TBackupState newState = BackupStateL(); + if( newState != iLatestState ) + { + // state changed + iLatestState = newState; + NotifyObserversL( iLatestState ); + } + Subscribe(); + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::DoCancel +// --------------------------------------------------------------------------- +// +void CBSBackupObserver::DoCancel() + { + iProperty.Cancel(); + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::RunError +// --------------------------------------------------------------------------- +// +TInt CBSBackupObserver::RunError( TInt /*aError*/ ) + { + return KErrNone; + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::RegisterObserver +// --------------------------------------------------------------------------- +// +TInt CBSBackupObserver::RegisterObserver( MBSBackupObserver* aObserver ) + { + TInt err = iObservers.InsertInAddressOrder( aObserver ); + if( err == KErrAlreadyExists ) + { + // ignore duplicate registration + err = KErrNone; + } + + // if backup is already active -> notify + if( iLatestState == MBSBackupObserver::EBackupActive ) + { + TRAP_IGNORE( aObserver->HandleBackupStateL( iLatestState ) ); + } + + return err; + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::UnregisterObserver +// --------------------------------------------------------------------------- +// +void CBSBackupObserver::UnregisterObserver( MBSBackupObserver* aObserver ) + { + TInt index = iObservers.FindInAddressOrder( aObserver ); + if( index != KErrNotFound ) + { + iObservers.Remove( index ); + } + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::Subscribe +// --------------------------------------------------------------------------- +// +void CBSBackupObserver::Subscribe() + { + if( IsActive() ) + { + // already active + return; + } + iStatus = KRequestPending; + iProperty.Subscribe( iStatus ); + SetActive(); + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::NotifyObservers +// --------------------------------------------------------------------------- +// +void CBSBackupObserver::NotifyObserversL( MBSBackupObserver::TBackupState aState ) + { + TInt count = iObservers.Count(); + for( TInt i = 0; i < count; i++ ) + { + TRAP_IGNORE( iObservers[i]->HandleBackupStateL( aState ) ); + } + } + +// --------------------------------------------------------------------------- +// CBSBackupObserver::BackupState +// --------------------------------------------------------------------------- +// +MBSBackupObserver::TBackupState CBSBackupObserver::BackupStateL() + { + TInt value = 0; + User::LeaveIfError( iProperty.Get( value ) ); + if( value == 0 || + value == ( conn::EBURNormal | conn::ENoBackup ) ) + { + // backup or restore is not active at the moment + return MBSBackupObserver::EBackupNotActive; + } + return MBSBackupObserver::EBackupActive; + } + +// End of file diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsbackupobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsbackupobserver.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Gets and notifies backup and Restore events from system +* +*/ + + + +#ifndef CBSBACKUPOBSERVER_H +#define CBSBACKUPOBSERVER_H + +#include +#include + +#include "mbsbackupobserver.h" + +/** + * Gets and notifies backup and Restore events from system + * + * @lib bsserver.exe + * @since S60 v3.2 + */ +class CBSBackupObserver : public CActive +{ +public: + + static CBSBackupObserver* NewL(); + + static CBSBackupObserver* NewLC(); + + ~CBSBackupObserver(); + + +private: // From CActive + + /** + * @see CActive + */ + void RunL(); + + /** + * @see CActive + */ + void DoCancel(); + + /** + * @see CActive + */ + TInt RunError( TInt aError ); + + +private: // Private constructors + + CBSBackupObserver(); + + void ConstructL(); + + +public: // New Methods + + /** + * Register observer to observe backup state changes + * @param aObserver observer to register + * @return KErrNone or some other system wide errorcode + */ + TInt RegisterObserver( MBSBackupObserver* aObserver ); + + /** + * Unregister observer + * @param aObserver observer to remove + */ + void UnregisterObserver( MBSBackupObserver* aObserver ); + + +private: // New methods + + /** + * Subscribes to backup and restore P&S value. + */ + void Subscribe(); + + /** + * Notify registered observers of new backup state + */ + void NotifyObserversL( MBSBackupObserver::TBackupState aState ); + + /** + * Read current backup state + * @return current backup state + */ + MBSBackupObserver::TBackupState BackupStateL(); + + +private: // Data + + // backup state property + RProperty iProperty; + + // Own (array only). Observers + RPointerArray iObservers; + + // latest state of backup and restore; + MBSBackupObserver::TBackupState iLatestState; +}; + +#endif //CBSBACKUPOBSERVER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsbrandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsbrandhandler.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,612 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSBrandHandler.cpp +* +*/ + + + +// INCLUDE FILES + +#include "cbsbrandhandler.h" +#include "bselementfactory.h" +#include "DebugTrace.h" +#include "cbsstoragemanager.h" +#include "cbsbitmap.h" +#include "bsimportconstants.h" + +#include +#include +#include + +void Panic(TInt aPanic) + { + _LIT( KPanic, "CBS" ); + User::Panic( KPanic, aPanic ); + } + +// Two-phased constructor. +CBSBrandHandler* CBSBrandHandler::NewL( const TDesC& aApplicationId, + const TDesC& aBrandId, + const TDesC& aDefaultBrandId, + TLanguage aLanguage, + CBSSession* aSession, + TInt aReserved ) + { + CBSBrandHandler* self = new ( ELeave ) CBSBrandHandler( aLanguage, aReserved ) ; + CleanupStack::PushL( self ); + self->ConstructL( aApplicationId, aBrandId, aDefaultBrandId, aSession ); + CleanupStack::Pop( self ); //self + return self; + } + +// Symbian OS default constructor can leave. +void CBSBrandHandler::ConstructL( const TDesC& aApplicationId, + const TDesC& aBrandId, + const TDesC& aDefaultBrandId, + CBSSession* aSession ) + { + iApplicationId = aApplicationId.AllocL(); + iBrandId = aBrandId.AllocL(); + iDefaultBrandId = aDefaultBrandId.AllocL(); + iSession = aSession; + + User::LeaveIfError( iFs.Connect() ); + + iHandle = new(ELeave) RFile(); // CSI: 74 # this needs to be like this + + isDefaultBrandUsed = ETrue; + iStorageManager = CBSStorageManager::NewL( iSession, KNullDesC ); + TInt err = -1; + TRAP (err, iStorageManager->BrandHandleL( *iApplicationId, + *iBrandId, iLanguage, + *iHandle, + iReserved )); + + + if (err != KErrNone) + { + iStorageManager->BrandHandleL( *iApplicationId, + *iDefaultBrandId, iLanguage, + *iHandle, + iReserved ); + } + VerifyVersionL(); + } + +// Destructor +CBSBrandHandler::~CBSBrandHandler() + { + delete iDefaultBrand; + delete iApplicationId; + delete iBrandId; + delete iDefaultBrandId; + if( iHandle ) + { + iHandle->Close(); + delete iHandle; + iHandle = NULL; + } + + delete iStorageManager; + + iFs.Close(); + } + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CBSBrandHandler::CBSBrandHandler( TLanguage aLanguage, + TInt aReserved ) +: iLanguage( aLanguage ), iReserved( aReserved) + { + } + + + +TInt CBSBrandHandler:: isBrandUpdateRequiredL () +{ + TRACE( T_LIT( "isBrandUpdateRequired entered")); + TInt updateRequired = -1; + if (isDefaultBrandUsed) + { + TRACE( T_LIT( "isBrandUpdateRequired isDefaultBrandused is TRUE.")); + /* default brand is used, so can check if the actual brand is installed by anychance or not */ + updateRequired = iStorageManager->isActualBrandInstalledL (*iApplicationId, *iBrandId, iLanguage ); + if (1 == updateRequired) + { + TRACE( T_LIT( "isBrandUpdateRequired isDefaultBrandused returned 1, so update required, setting defaultbrand FALSE.")); + isDefaultBrandUsed = EFalse; + } + } + TRACE( T_LIT( "isBrandUpdateRequired isDefaultBrandused leaving..")); + return updateRequired; +} + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::SetDefaultBrandIdL() +// ----------------------------------------------------------------------------- +// +void CBSBrandHandler::SetDefaultBrandIdL( const TDesC8& aBrandId ) + { + HBufC* temp = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aBrandId ); + delete iDefaultBrand; + iDefaultBrand = temp; + } + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::GetTextL() +// ----------------------------------------------------------------------------- +// +HBufC* CBSBrandHandler::GetTextL( const TDesC8& aId ) + { + TRACE( T_LIT( "CBranding::GetTextL begin [%S]"), &aId); + + MBSElement* element = ReadElementLC( aId ); + + HBufC* returnValue = element->TextDataL().AllocL(); + + CleanupStack::PopAndDestroy(); // element + TRACE( T_LIT( "CBranding::GetTextL end") ); + return returnValue; + } + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::GetBufferL() +// ----------------------------------------------------------------------------- +// +HBufC8* CBSBrandHandler::GetBufferL( const TDesC8& aId ) + { + TRACE( T_LIT( "CBSBrandHandler::GetBufferL begin") ); + + MBSElement* element = ReadElementLC( aId ); + + HBufC8* returnValue = element->BufferDataL().AllocL(); + + CleanupStack::PopAndDestroy(); // element + TRACE( T_LIT( "CBSBrandHandler::GetBufferL end") ); + return returnValue; + } + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::GetIntL() +// ----------------------------------------------------------------------------- +// +TInt CBSBrandHandler::GetIntL( const TDesC8& aId ) + { + TRACE( T_LIT( "CBSBrandHandler::GetIntL begin") ); + TInt value = 0; + + MBSElement* element = ReadElementLC( aId ); + + value = element->IntDataL(); + + CleanupStack::PopAndDestroy(); // element + + TRACE( T_LIT( "CBSBrandHandler::GetIntL end") ); + return value; + } + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::GetFileL() +// ----------------------------------------------------------------------------- +// +void CBSBrandHandler::GetFileL( const TDesC8& aId, RFile& aFile ) + { + TRACE( T_LIT( "CBSBrandHandler::GetFileL begin aId[%S] "), &aId ); + RFile file; + User::LeaveIfError( iFs.ShareProtected() ); + + if (iLanguage >= 100) + User::LeaveIfError (KErrNotFound); + HBufC* fileName = GetTextL( aId ); + + TBuf buffer; +// append leading zero only if language code is <10. + if ( 10 > iLanguage ) + { + buffer.AppendNum( KLeadingZero ); + } + + buffer.AppendNum( iLanguage ); + + TInt err = -1; + TRAP (err, iStorageManager->FileElementHandleL( *iApplicationId, + *iBrandId, + *fileName, + buffer, + file )); + + if (KErrNone != err) + { + /* if the file is not found in the default brand also, then leave */ + iStorageManager->FileElementHandleL( *iApplicationId, + *iDefaultBrandId, + *fileName, + buffer, + file); + + TRACE( T_LIT( "CBSBrandHandler::GetFileL found in default brand") ); + + } + + aFile = file; + TRACE( T_LIT( "CBSBrandHandler::GetFileL end") ); + } + + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::GetSeveralL() +// ----------------------------------------------------------------------------- +// +MBSElement* CBSBrandHandler::GetSeveralL( RBSObjOwningPtrArray& aIds ) + { + MBSElement* returnValue = NULL; + TInt count = aIds.Count(); + + RBSObjOwningPtrArray listData; + CleanupClosePushL( listData ); + for(TInt i = 0; i < count; i++ ) + { + MBSElement* subElement = ReadElementLC( *aIds[ i ] ); + listData.AppendL( subElement ); + CleanupStack::Pop( subElement ); + } + returnValue = BSElementFactory::CreateBSElementL( KNullDesC8, + EBSList, + listData ); + CleanupStack::Pop(); // listData + return returnValue; + } + + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::GetStructureL() +// ----------------------------------------------------------------------------- +// +MBSElement* CBSBrandHandler::GetStructureL( TDesC8& aId ) + { + MBSElement* returnValue = NULL; + + TRACE( T_LIT( "CBSBrandHandler::GetStructureL begin") ); + + returnValue = ReadElementLC( aId ); + + CleanupStack::Pop(); // element + + TRACE( T_LIT( "CBSBrandHandler::GetStructureL end") ); + + return returnValue; + } + + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::ReadElementLC() +// ----------------------------------------------------------------------------- +// +MBSElement* CBSBrandHandler::ReadElementLC( const TDesC8& aId, TBool aForceDefault /*= EFalse*/ ) + { + TRACE( T_LIT( "CBSBrandHandler::ReadElementLC begin aId")); + + if( aForceDefault ) + { + TRACE( T_LIT( "CBSBrandHandler::ReadElementLC default brand")); + iStorageManager->BrandHandleL( *iApplicationId, + *iDefaultBrandId, iLanguage, + *iHandle, + iReserved ); + } + else + { + TInt err = -1; + TRAP (err, iStorageManager->BrandHandleL( *iApplicationId, + *iBrandId, iLanguage, + *iHandle, + iReserved )); + if (KErrNone != err) + { + iStorageManager->BrandHandleL( *iApplicationId, + *iDefaultBrandId, iLanguage, + *iHandle, + iReserved ); + } + } + + RFileReadStream stream; + stream.Attach( *iHandle ); + CleanupClosePushL( stream ); + + VerifyVersionL( stream ); + + TInt count = stream.ReadInt16L(); + + MBSElement* returnValue = NULL; + + for( TInt i = 0; i < count; i++ ) + { + TRAPD( err, returnValue = ReadStreamL( aId, stream ) ); + + if( err == KErrEof ) + { + TRACE( T_LIT( "CBSBrandHandler::ReadElementLC EOF!") ); + // the id is not found in this file + User::Leave( KErrNotFound ); + } + if( returnValue ) + { + TRACE( T_LIT( "CBSBrandHandler::ReadElementLC ELEMENT FOUND.. at position %d"), i); + // we found what we are looking for + break; + } + } + + CleanupStack::PopAndDestroy( &stream ); // stream + + TBool popElementFromCleanupStack( EFalse ); + + /* If retur value is not found and if its read the actual brand, then try in default brand as well. aForceDefault will decide that. */ + if( !returnValue && !aForceDefault) + { + TRACE( T_LIT( "CBSBrandHandler::ReadElementLC force default is true") ); + + // the element was not found + // try the default brand if it's not the same as wanted brand + if( 0 != iBrandId->Compare( *iDefaultBrandId ) ) + { + TRACE( T_LIT( "CBSBrandHandler::ReadElementLC calling READELEMENTLC again") ); + + /* Call ReadElementLC wiht aForceDefault set to TRUE */ + returnValue = ReadElementLC( aId, ETrue ); + + if ( returnValue ) + { + TRACE( T_LIT( "CBSBrandHandler::ReadElementLC VALUE IS FOUND!!!") ); + popElementFromCleanupStack = ETrue; + } + else + { + TRACE( T_LIT( "CBSBrandHandler::ReadElementLC VALUE IS NOT FOUND!!!") ); + CleanupStack :: Pop (returnValue); + } + } + if( !returnValue ) + { + TRACE( T_LIT( "CBSBrandHandler::ReadElementLC VALUE not FOUND LEAVING WITH -1 !!!") ); + User::Leave( KErrNotFound ); + } + } + + CleanupClosePushL( *returnValue ); + // since we make one function call to ReadElementLC in case the default + // brand id is used to retrieved the element, we have to pop one returnValue + // pointer from CleanupStack (otherwise we have two identical pointers on + // the stack!!!) + if ( popElementFromCleanupStack ) + { + CleanupStack::Pop( returnValue ); + } + + TRACE( T_LIT( "CBSBrandHandler::ReadElementLC end ") ); + return returnValue; + } + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::VerifyVersionL() +// ----------------------------------------------------------------------------- +// +void CBSBrandHandler::VerifyVersionL( RFileReadStream& aStream ) + { + TInt version = aStream.ReadInt16L(); + if( version != iReserved ) + { + User::Leave( KErrArgument ); + } + } + + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::VerifyVersionL() +// ----------------------------------------------------------------------------- +// +void CBSBrandHandler::VerifyVersionL() + { + if( !iHandle ) + { + User::Leave( KErrNotReady ); + } + RFileReadStream stream; + stream.Attach( *iHandle ); + CleanupClosePushL( stream ); + + VerifyVersionL( stream ); + + CleanupStack::PopAndDestroy(); // stream + } + +// ----------------------------------------------------------------------------- +// CBSBrandHandler::ReadStreamL() +// ----------------------------------------------------------------------------- +// +MBSElement* CBSBrandHandler::ReadStreamL( const TDesC8& aId, RFileReadStream& aStream, + TBool aAllowEmptyId /* = EFalse */ ) + { + TRACE( T_LIT( "CBSBrandHandler::ReadStreamL BEGIN")); + TBSElementType type = (TBSElementType)aStream.ReadInt16L(); + MBSElement* returnValue = NULL; + + TInt idSize = aStream.ReadInt16L(); + + HBufC8* elementId = HBufC8::NewLC( idSize ); + TPtr8 elementIdPtr = elementId->Des(); + + if( idSize == 0 && aAllowEmptyId ) + { + // we don't read empty ID + } + else + { + aStream.ReadL( elementIdPtr, idSize ); + elementIdPtr.SetLength( idSize );// Set length + } + + + TBool match = EFalse; + if( aAllowEmptyId || ( 0 == elementIdPtr.Compare( aId ) ) ) + { + match = ETrue; + } + + TPtrC8 idPtrC( *elementId );// idPtrC creation moved here so it will be updated correctly. + if( elementId->Length() == 0 ) + { + CleanupStack::PopAndDestroy( elementId ); + elementId = NULL; + idPtrC.Set( KNullDesC8 ); + } + + switch( type ) + { + case EBSInt: + { + TInt intData = aStream.ReadInt16L(); + TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type INT")); + if( match ) + { + // Codescanner warning: neglected to put variable on cleanup stack (id:35) + // This method cannot leave after this line + returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above + EBSInt, + intData ); + } + break; + } + case EBSText: + case EBSFile: // flow through + { + TInt textSize = aStream.ReadInt16L(); + HBufC* textData = HBufC::NewLC( textSize ); + + TPtr textPtr = textData->Des(); + aStream.ReadL( textPtr, textSize ); + + TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type TEXT/ FILE")); + if( match ) + { + // Codescanner warning: neglected to put variable on cleanup stack (id:35) + // This method cannot leave after this line + returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above + type, + *textData ); + } + + CleanupStack::PopAndDestroy( textData ); + break; + } + case EBSList: + { + RBSObjOwningPtrArray listData; + CleanupClosePushL( listData ); + TInt count = aStream.ReadInt16L(); + + for( TInt i = 0; i < count; i++ ) + { + MBSElement* subElement = ReadStreamL( KNullDesC8, aStream, ETrue ); + CleanupDeletePushL( subElement ); + listData.AppendL( subElement ); + CleanupStack::Pop(); // subElement + } + + if( match ) + { + // Codescanner warning: neglected to put variable on cleanup stack (id:35) + // This method cannot leave after this line + returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above + EBSList, + listData ); + } + CleanupStack::Pop(); // listData + break; + } + case EBSBuffer: + { + TInt bufferSize = aStream.ReadInt16L(); + HBufC8* buffeData = HBufC8::NewLC( bufferSize ); + + TPtr8 bufferPtr = buffeData->Des(); + aStream.ReadL( bufferPtr, bufferSize ); + + if( match ) + { + // Codescanner warning: neglected to put variable on cleanup stack (id:35) + // This method cannot leave after this line + returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above + EBSBuffer, + *buffeData ); + } + + CleanupStack::PopAndDestroy( buffeData ); + break; + } + case EBSBitmap: + { + TInt length = aStream.ReadInt16L(); + HBufC8* fileId = HBufC8::NewLC( length ); + + TPtr8 fileIdPtr = fileId->Des(); + aStream.ReadL( fileIdPtr, length ); + + TInt bitmapId = aStream.ReadInt16L(); + TInt maskId = aStream.ReadInt16L(); + TInt skinId = aStream.ReadInt16L(); + TInt skinMaskId = aStream.ReadInt16L(); + + TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type BITMAP .. bitmap ID is [%d]"), bitmapId); + if( match ) + { + CBSBitmap* bitmap = CBSBitmap::NewLC( bitmapId, + maskId, + skinId, + skinMaskId, + fileIdPtr ); + + // Codescanner warning: neglected to put variable on cleanup stack (id:35) + // This method cannot leave after this line + returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above + EBSBitmap, + bitmap ); + CleanupStack::Pop( bitmap ); + } + CleanupStack::PopAndDestroy( fileId ); + + break; + } + default: + { + TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type DEFAULT : corrupt")); + User::Leave( KErrCorrupt ); + break; + } + } + + if( elementId ) + { + CleanupStack::PopAndDestroy( elementId ); + } + + TRACE( T_LIT( "CBSBrandHandler::ReadStreamL END")); + return returnValue; + } + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsbrandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsbrandhandler.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSBrandHandler.h +* +*/ + + + +#ifndef __CBSBRANDHANDLER_H__ +#define __CBSBRANDHANDLER_H__ + +#include "rbsobjowningptrarray.h" + +#include +#include +#include +#include +#include +#include + +// FORWARD DECLARATIONS +class MBSElement; +class CBSStorageManager; +class CBSSession; + +/** + * + * + */ +NONSHARABLE_CLASS( CBSBrandHandler ): public CBase + { + public: + /** + * Two-phased constructor. + */ + static CBSBrandHandler* NewL( const TDesC& aApplicationId, + const TDesC& aBrandId, + const TDesC& aDefaultBrandId, + TLanguage aLanguage, + CBSSession* aSession, + TInt aReserved = 0); + + + + virtual ~CBSBrandHandler(); + + private: // constructors + + void ConstructL( const TDesC& aApplicationId, + const TDesC& aBrandId, + const TDesC& aDefaultBrandId, + CBSSession* aSession ); + + CBSBrandHandler( TLanguage aLanguage, + TInt aReserved ); + + public: + HBufC* GetTextL( const TDesC8& aId ); + HBufC8* GetBufferL( const TDesC8& aId ); + TInt GetIntL( const TDesC8& aId ); + MBSElement* GetSeveralL( RBSObjOwningPtrArray& aIds ); + void GetFileL( const TDesC8& aId, RFile& aFile ); + MBSElement* GetStructureL( TDesC8& aId ); + void SetDefaultBrandIdL( const TDesC8& aBrandId ); + + + TInt isBrandUpdateRequiredL (); + + private: // New methods + + MBSElement* ReadElementLC( const TDesC8& aId, TBool aForceDefault = EFalse ); + + MBSElement* ReadStreamL( const TDesC8& aId, + RFileReadStream& aStream, + TBool aAllowEmptyId = EFalse ); + + void VerifyVersionL(); + void VerifyVersionL( RFileReadStream& aStream ); + + private: // data + HBufC* iDefaultBrand; + /// +#include +#include + +#include "cbsibywriter.h" +#include "bsimportconstants.h" +//#include "importlogwriter.h" +#include "DebugTrace.h" + +// CONSTANTS +_LIT8( KIBYHeader1, "\n#ifndef __BRAND_" ); +_LIT8( KIBYHeader2, "\n#define __BRAND_" ); +_LIT8( KIBYHeaderEnd, "_IBY_" ); +_LIT8( KIBYFileItem, "\nfile=" ); +_LIT8( KIBYEmptyLine, "\n" ); +_LIT8( KIBYSpace, " \t\t " ); +_LIT8( KIBYFooter, "\n#endif //__BRAND_" ); + +// File & dir +_LIT8( KIBYBaseSource, "\\epoc32\\winscw\\c" ); + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CBSIBYWriter::NewL +// --------------------------------------------------------------------------- +// +CBSIBYWriter* CBSIBYWriter::NewL() + { + CBSIBYWriter* self = NewLC(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- +// CBSIBYWriter::NewLC +// --------------------------------------------------------------------------- +// +CBSIBYWriter* CBSIBYWriter::NewLC() + { + CBSIBYWriter* self = new (ELeave) CBSIBYWriter(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- +// CBSIBYWriter::ConstructL +// --------------------------------------------------------------------------- +// +void CBSIBYWriter::ConstructL() + { + } + +// --------------------------------------------------------------------------- +// CBSIBYWriter::CBSIBYWriter +// --------------------------------------------------------------------------- +// +CBSIBYWriter::CBSIBYWriter() + { + } + +// --------------------------------------------------------------------------- +// CBSIBYWriter::~CBSIBYWriter +// --------------------------------------------------------------------------- +// +CBSIBYWriter::~CBSIBYWriter() + { + iSourcePath.ResetAndDestroy(); + iSourceFiles.ResetAndDestroy(); + iDestinations.ResetAndDestroy(); + delete iIbyFile; + } + +// --------------------------------------------------------------------------- +// CBSIBYWriter::SetFileItemL +// --------------------------------------------------------------------------- +// +void CBSIBYWriter::SetFileItemL( const TDesC& aSrc, const TDesC& aDest ) + { + TRACE( T_LIT( "CBSIBYWriter::SetFileItemL begin") ); + // Parse and construct filenames + TParse srcparse; + srcparse.Set( aSrc, NULL, NULL ); + + TParse dstparse; + dstparse.Set( aDest, NULL, NULL ); + + // Path + HBufC8* srcpath = HBufC8::NewLC( srcparse.Path().Length() ); + TPtr8 ptr( srcpath->Des() ); + CnvUtfConverter::ConvertFromUnicodeToUtf8( ptr, srcparse.Path() ); + + HBufC8* src = HBufC8::NewLC( srcparse.NameAndExt().Length() ); + ptr.Set( src->Des() ); + CnvUtfConverter::ConvertFromUnicodeToUtf8( ptr, srcparse.NameAndExt() ); + + HBufC8* dst = HBufC8::NewLC( aDest.Length() ); + ptr.Set( dst->Des() ); + + HBufC* newDst = HBufC::NewLC( aDest.Length() ); + TPtr dstPtr( newDst->Des() ); + TPtrC name = dstparse.NameAndExt(); + TPtrC path = dstparse.Path(); + dstPtr.Append( KBSZDrive ); + dstPtr.Append( path ); + dstPtr.Append( name ); + + CnvUtfConverter::ConvertFromUnicodeToUtf8( ptr, dstPtr ); + + TRACE( T_LIT( "CBSIBYWriter::SetFileItemL - setting source file %S"), &aSrc ); + TRACE( T_LIT( "CBSIBYWriter::SetFileItemL - setting destination file %S"), newDst ); + CleanupStack::PopAndDestroy( newDst ); + CleanupStack::Pop( 3 ); + + // Append filepair + iSourcePath.Append( srcpath ); + iSourceFiles.Append( src ); + iDestinations.Append( dst ); + + TRACE( T_LIT( "CBSIBYWriter::SetFileItemL end") ); + } + +// --------------------------------------------------------------------------- +// CBSIBYWriter::WriteIBYFile() +// --------------------------------------------------------------------------- +// +void CBSIBYWriter::WriteIBYFileL( RFs& aFs, const TDesC& aFileName ) + { + TRACE( T_LIT( "CBSIBYWriter::WriteIBYFileL begin") ); + + TInt count = iSourceFiles.Count(); + if( count == 0 ) + { + TRACE( T_LIT( "CBSIBYWriter::WriteIBYFileL - No file elements, nothing to do.") ); + return; + } + if( count != iDestinations.Count() ) + { + TRACE( T_LIT("Internal error: IBY filename count mismatch ( %d != %d )"), + count, iDestinations.Count() ); + User::Leave( KErrCorrupt ); + } + + RFile outfile; + TInt err = outfile.Open( aFs, aFileName, EFileWrite ); + if( err == KErrNotFound ) + { + TRACE( T_LIT( "CBSIBYWriter::WriteIBYFileL - IBY file not initialized!") ); + // if the file is not initialized -> not ready + err = KErrNotReady; + } + User::LeaveIfError( err ); + + // write data + TInt size = -1; + User::LeaveIfError( outfile.Size( size ) ); + + outfile.Write( size, KIBYEmptyLine ); + + TRACE( T_LIT( "CBSIBYWriter::WriteIBYFileL - start writing files to IBY") ); + + for( TInt i = 0; i < count; i++ ) + { + outfile.Write( KIBYFileItem ); + outfile.Write( KIBYBaseSource ); + outfile.Write( iSourcePath[i]->Des() ); + outfile.Write( iSourceFiles[i]->Des() ); + outfile.Write( KIBYSpace ); + outfile.Write( iDestinations[i]->Des() ); + TRACE( T_LIT( "CBSIBYWriter::WriteIBYFileL - %S"), iDestinations[i] ); + } + + TRACE( T_LIT( "CBSIBYWriter::WriteIBYFileL - writing IBY file footer") ); + outfile.Write( KIBYEmptyLine ); + outfile.Write( KIBYFooter ); + outfile.Write( KIBYHeaderEnd ); + + // cleanup + outfile.Close(); + TRACE( T_LIT( "CBSIBYWriter::WriteIBYFileL end") ); + } + +// --------------------------------------------------------------------------- +// CBSIBYWriter::WriteIBYFile() +// --------------------------------------------------------------------------- +// +void CBSIBYWriter::InitIbyFileL( RFs& aFs, const TDesC& aFileName ) + { + TRACE( T_LIT( "CBSIBYWriter::InitIbyFileL begin") ); + HBufC* temp = aFileName.AllocL(); + delete iIbyFile; + iIbyFile = temp; + + TInt err = aFs.MkDir( KBSIbyDirectory ); + if( err == KErrAlreadyExists ) + { + err = KErrNone; + } + User::LeaveIfError( err ); + + TRACE( T_LIT( "CBSIBYWriter::InitIbyFileL IBY directory (%S) created"), &KBSIbyDirectory() ); + + // Open file for writing + RFile outfile; + User::LeaveIfError( outfile.Replace( aFs, aFileName, EFileWrite ) ); + + TRACE( T_LIT( "CBSIBYWriter::InitIbyFileL IBY file (%S) created"), &aFileName ); + + outfile.Write( KIBYHeader1 ); + outfile.Write( KIBYHeaderEnd ); + outfile.Write( KIBYHeader2 ); + outfile.Write( KIBYHeaderEnd ); + outfile.Close(); + TRACE( T_LIT( "CBSIBYWriter::InitIbyFileL end") ); + } +// End of file diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsibywriter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsibywriter.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Writes IBY files +* +*/ + + + +#ifndef CBSIBYWRITER_H +#define CBSIBYWRITER_H + +#include + +class RFs; + +/** + * Writes IBY files + * + * @lib + * @since S60 v3.2 + */ +class CBSIBYWriter : public CBase +{ +public: + + static CBSIBYWriter* NewL(); + + static CBSIBYWriter* NewLC(); + + ~CBSIBYWriter(); + + /** + * Initialize IBY file + * + * @param aFs file system handle + * @param aFileName Full name of the iby file + * @since S60 3.2 + * @return none + */ + void InitIbyFileL( RFs& aFs, const TDesC& aFileName ); + + /** + * File item included in IBY file + * + * @since S60 3.2 + * @param aSrc source file + * @param aDest destination file + * @return none + */ + void SetFileItemL( const TDesC& aSrc, const TDesC& aDest ); + + /** + * Writes Iby file from given file items + * + * @since S60 3.2 + * @param aFs file system handle + * @param aFileName Full name of the iby file + * @return none + */ + void WriteIBYFileL( RFs& aFs, const TDesC& aFileName ); + +private: + + CBSIBYWriter(); + + void ConstructL(); + +private: // Data + + // Own. Source path array + RPointerArray iSourcePath; + + // Own. Source files + RPointerArray iSourceFiles; + + // Own. Destination files + RPointerArray iDestinations; + + // Own. Iby file name + HBufC* iIbyFile; +}; + +#endif //CBSIBYWRITER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsinstallhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsinstallhandler.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,565 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSInstallhandler.cpp +* +*/ + + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include + +#include "cbsinstallhandler.h" +#include "DebugTrace.h" +#include "bsimportconstants.h" +#include "cbsstoragemanager.h" + + +// CONSTANTS +// branding installer application +_LIT( KInstallerApp, "bsinstall.exe" ); + + +// wildcard for finding installed brand files +_LIT( KBrandWild, "*" ); + +// Line feed separates uninstalled brands from each other +_LIT( KLineFeed, "\n" ); + + +// Pub&Sub Key for uninstalled brands +const TUint KUninstallKey = 0x01; + + +// METHODS + +// Two-phased constructor. +CBSInstallHandler* CBSInstallHandler::NewL( ) + { + TRACE( T_LIT( "CBSInstallHandler::NewL begin") ); + CBSInstallHandler* self = new ( ELeave ) CBSInstallHandler() ; + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + TRACE( T_LIT( "CBSInstallHandler::NewL end") ); + return self; + } + +// Symbian OS default constructor can leave. +void CBSInstallHandler::ConstructL() + { + User::LeaveIfError( iFs.Connect() ); + CActiveScheduler::Add( this ); + } + +// Destructor +CBSInstallHandler::~CBSInstallHandler() + { + Cancel(); + iFs.Close(); + } + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CBSInstallHandler::CBSInstallHandler() : + CActive( EPriorityIdle ) + { + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::InstallNewFilesL() +// ----------------------------------------------------------------------------- +// +void CBSInstallHandler::InstallNewFilesL() + { + TRACE( T_LIT( "CBSInstallHandler::InstallNewFilesL begin") ); + TInt needInstaller = 0; + + + TRAP_IGNORE( needInstaller += CheckForDiscardedBrandsL( KBSDataStore ) ); + + // uninstall removed brands + needInstaller += + SyncFilesL( KInstallPath, KInstallObservePath, EInstallDeleteFromSrc ); + + // install new brands + needInstaller += + SyncFilesL( KInstallObservePath, KInstallPath, EInstallCopyNewToDest ); + + if( needInstaller ) + { + // something new was installed + LaunchInstallerAppL(); + } + TRACE( T_LIT( "CBSInstallHandler::InstallNewFilesL end") ); + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::StartObservingL() +// ----------------------------------------------------------------------------- +// +void CBSInstallHandler::StartObservingL() + { + TRACE( T_LIT( "CBSInstallHandler::StartObservingL begin") ); + if( IsActive() ) + { + __ASSERT_DEBUG( EFalse, User::Leave( KErrAlreadyExists ) ); + return; + } + + // observe path: (drive:)[private](/import/install) + TPath path( KNullDesC ); + GetPrivateFolder( path, KInstallObservePath ); + + iFs.NotifyChange( ENotifyEntry, iStatus, path ); + SetActive(); + TRACE( T_LIT( "CBSInstallHandler::StartObservingL end") ); + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::StopObserving() +// ----------------------------------------------------------------------------- +// +void CBSInstallHandler::StopObserving() + { + TRACE( T_LIT( "CBSInstallHandler::StopObserving begin") ); + Cancel(); + TRACE( T_LIT( "CBSInstallHandler::StopObserving end") ); + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::DoCancel() +// ----------------------------------------------------------------------------- +// +void CBSInstallHandler::DoCancel() + { + iFs.NotifyChangeCancel(); + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::RunL() +// ----------------------------------------------------------------------------- +// +void CBSInstallHandler::RunL() + { + TRACE( T_LIT( "CBSInstallHandler::RunL start") ); + if( iStatus == KErrNone ) + { + TRACE( T_LIT( "CBSInstallHandler::RunL installing...") ); + TRAP_IGNORE( InstallNewFilesL() ); + StartObservingL(); + } + else + { + TRACE( T_LIT( "CBSInstallHandler::RunL observing stopped") ); + } + TRACE( T_LIT( "CBSInstallHandler::RunL end") ); + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::LaunchInstallerAppL() +// ----------------------------------------------------------------------------- +// +void CBSInstallHandler::LaunchInstallerAppL() + { + TRACE( T_LIT( "CBSInstallHandler::LaunchInstallerAppL start") ); + // initialize RApaLsSession + RApaLsSession apas; + User::LeaveIfError( apas.Connect() ); + CleanupClosePushL( apas ); + apas.GetAllApps(); + + // start installer + CApaCommandLine* command = CApaCommandLine::NewLC(); + command->SetExecutableNameL( KInstallerApp ); + User::LeaveIfError( apas.StartApp( *command ) ); + TRACE( T_LIT( "CBSInstallHandler::LaunchInstallerAppL bsinstall.exe launched OK") ); + + CleanupStack::PopAndDestroy( 2 ); // apas, command + TRACE( T_LIT( "CBSInstallHandler::LaunchInstallerAppL end") ); + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::SyncFilesL() +// ----------------------------------------------------------------------------- +// +TBool CBSInstallHandler::SyncFilesL( const TDesC& aSrcDir, const TDesC& aDestDir, + TInstallOperation aOperation ) + { + TRACE( T_LIT( "CBSInstallHandler::SyncFilesL start") ); + + // Check new install folder + HBufC* fileBuf = HBufC::NewLC( KMaxFileName ); + TPtr file( fileBuf->Des() ); + GetPrivateFolder( file, aSrcDir ); + + TBool ret = BaflUtils::PathExists( iFs, file ); + if( !ret ) + { + // install folder doesn't exist. + TRACE( T_LIT( + "CBSInstallHandler::SyncFilesL no src folder!") ); + CleanupStack::PopAndDestroy( fileBuf ); + return EFalse; + } + + // Apply extension filter + file.Append( KBrandWild ); // + file.Append( KBrandInstallExt ); // *.install + + // Get list of src dir files + CDir* dir = NULL; + User::LeaveIfError( iFs.GetDir( file, + KEntryAttNormal, ESortNone, dir ) ); + CleanupStack::PushL( dir ); + + // Create destination directory + GetPrivateFolder( file, aDestDir ); + BaflUtils::EnsurePathExistsL( iFs, file ); + + // Compare source dir to destination + TBool OperationExecuted = EFalse; + TInt count = dir->Count(); + + for( TInt i = 0; i < count; i++ ) + { + GetPrivateFolder( file, aDestDir ); + file.Append( (*dir)[i].iName ); + if( !BaflUtils::FileExists( iFs, file ) ) + { + // file does not exist in destionation dir + // => react according to operation + HBufC* fileSrcBuf = HBufC::NewLC( KMaxFileName ); + TPtr fileSrc( fileSrcBuf->Des() ); + GetPrivateFolder( fileSrc, aSrcDir ); + fileSrc.Append( (*dir)[i].iName ); + + switch( aOperation ) + { + case EInstallCopyNewToDest: + { + // copy new files from src to destination + TRACE( T_LIT( "CBSInstallHandler::SyncFilesL copy") ); + OperationNotifyL( aOperation, file ); + User::LeaveIfError( BaflUtils::CopyFile( + iFs, fileSrc, file ) ); + break; + } + case EInstallDeleteFromSrc: + { + // delete files from src if they are not found from dest + TRACE( T_LIT( "CBSInstallHandler::SyncFilesL del") ); + OperationNotifyL( aOperation, fileSrc ); + User::LeaveIfError( BaflUtils::DeleteFile( iFs, fileSrc ) ); + break; + } + default: + { + // Every operation should have a case! + __ASSERT_DEBUG( EFalse, + User::LeaveIfError( KErrArgument ) ); + } + } + + OperationExecuted = ETrue; + CleanupStack::PopAndDestroy( fileSrcBuf ); + } + } + CleanupStack::PopAndDestroy( 2 ); // fileBuf, dir + TRACE( T_LIT( "CBSInstallHandler::SyncFilesL end") ); + return OperationExecuted; + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::OperationNotifyL() +// ----------------------------------------------------------------------------- +// +void CBSInstallHandler::OperationNotifyL( TInstallOperation aOperation, + const TDesC& aSrcFile ) + { + TRACE( T_LIT( "CBSInstallHandler::OperationNotifyL start") ); + if( aOperation == EInstallDeleteFromSrc ) + { + // parse brand id and application id from filename + TParse parse; + parse.Set( aSrcFile, NULL, NULL ); + + // find ids from filename + TInt firstSepar = parse.Name().Find( KInstallFileDataSeparator ); + TInt secondSepar = parse.Name(). + Mid( firstSepar + 1 ).Find( KInstallFileDataSeparator ); + TInt cutlen = 0; + secondSepar == KErrNotFound ? cutlen = parse.Name().Length() : + cutlen = firstSepar + secondSepar + 1; + + // brandString: [brandId]$[appId] + TPtrC brandString ( parse.Name().Left( cutlen ) ); + if( IsBrandInstalled( brandString ) ) + { + TRACE( T_LIT( "CBSInstallHandler::OperationNotifyL %S exists in import\\install =>RProperty NOT UPDATED!"),&aSrcFile ); + // brand still exists, so no need to uninstall. + return; + } + + // Create discardedbrand.txt file in the /appid/brandid path + CreateFlagFile( aSrcFile ); + + UpdateRPropertyL( brandString ); + + TRACE( T_LIT( "CBSInstallHandler::OperationNotifyL uninstall string to pub&sub updated OK") ); + } + TRACE( T_LIT( "CBSInstallHandler::OperationNotifyL end") ); + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::IsBrandInstalled() +// ----------------------------------------------------------------------------- +// +TBool CBSInstallHandler::IsBrandInstalled( const TDesC& aBrand ) + { + TRACE( T_LIT( "CBSInstallHandler::IsBrandInstalled start") ); + TFileName file; + GetPrivateFolder( file, KInstallObservePath ); + file.Append( aBrand ); + file.Append( KBrandInstallExt ); + + // check file directly: + // aaa$bbb -> aaa$bbb.install + CDir* dir = NULL; + iFs.GetDir( file, KEntryAttNormal, ESortNone, dir ); + if( dir->Count() > 0 ) + { + // brand is installed + delete dir; + TRACE( T_LIT( "CBSInstallHandler::IsBrandInstalled true") ); + return ETrue; + } + delete dir; + dir = NULL; + + GetPrivateFolder( file, KInstallObservePath ); + file.Append( aBrand ); + file.Append( KInstallFileDataSeparator ); + file.Append( KBrandWild ); + file.Append( KBrandInstallExt ); + + // check file with different versions: + // aaa$bbb -> aaa$bbb$*.install + iFs.GetDir( file, KEntryAttNormal, ESortNone, dir ); + if( dir->Count() > 0 ) + { + // brand is installed + delete dir; + TRACE( T_LIT( "CBSInstallHandler::IsBrandInstalled true") ); + return ETrue; + } + delete dir; + + // brand is not installed + TRACE( T_LIT( "CBSInstallHandler::IsBrandInstalled false") ); + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::GetPrivateFolder() +// ----------------------------------------------------------------------------- +// +void CBSInstallHandler::GetPrivateFolder( TDes& aPath, const TDesC& aAppend ) + { + iFs.PrivatePath( aPath ); + aPath.Insert( 0, KInstallDrive ); + aPath.Append( aAppend ); + } + +void CBSInstallHandler::CreateFlagFile(const TDesC& aSrcFile) + { + TRACE( T_LIT( "CBSInstallHandler::CreateFlagFile begin") ); + // parse brand id and application id from aSrcFile + TParse parse; + parse.Set( aSrcFile, NULL, NULL ); + + // find ids from filename + TInt firstSepar = parse.Name().Find( KInstallFileDataSeparator ); + + // Get the brand Id + HBufC* brandId = (parse.Name().Left(firstSepar)).AllocL(); + + // to get application id + TInt secondSepar = parse.Name(). + Mid( firstSepar + 1 ).Find( KInstallFileDataSeparator ); + + TInt cutlen = 0; + secondSepar == KErrNotFound ? cutlen = parse.Name().Length() : + cutlen = firstSepar + secondSepar + 1; + + + TParse parseAgain; + parseAgain.Set(parse.Name().Left( cutlen ), NULL, NULL ); + HBufC* applicationId = (parseAgain.Name().Right( cutlen - firstSepar - 1)).AllocL(); + + + HBufC *fileName = CBSStorageManager::ConstructDiscardBrandFileNameL(*applicationId, *brandId) ; + CleanupStack::PushL(fileName); + HBufC *fullPath = CBSStorageManager::FullDiscardBrandFileNameLC( *fileName ) ; + + // crate a flag file + RFile file; + file.Create(iFs, *fullPath, EFileWrite); + file.Close() ; + + delete brandId ; + delete applicationId ; + + CleanupStack::PopAndDestroy(fullPath) ; + CleanupStack::PopAndDestroy(fileName) ; + TRACE( T_LIT( "CBSInstallHandler::CreateFlagFile end") ); + } + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::CheckForDiscardedBrandsL() +// ----------------------------------------------------------------------------- +// +TBool CBSInstallHandler::CheckForDiscardedBrandsL( const TDesC& aDir ) + { + TRACE( T_LIT( "CBSInstallHandler::CheckForDiscardedBrandsL begin") ); + TBool discardedBrandExists( EFalse ); + + CDir* appDir = NULL; // will contain all application folders + + TPath path; + iFs.PrivatePath( path ); + path.Insert( 0, KInstallDrive ); + path.Append( aDir ); + path.Append( KDirSeparator ); // "C:\\private\\102828dd\\data\\" + + User::LeaveIfError( + iFs.GetDir( path, KEntryAttDir, ESortNone, appDir ) ); + CleanupStack::PushL( appDir ); + + /*TFileName find( path ); + find.Append( KInstallFiles );*/ + + // create array of files (as text) + TInt count = appDir->Count(); + //for each application do... + for( TInt i = 0; i < count; i++ ) + { + TFileName file( path ); + file.Append( (*appDir)[i].iName ); + file.Append( KDirSeparator ); // "C:\\private\\102828dd\\data\\xsp\\" + + TRACE( T_LIT( "CBSInstallHandler::CheckForDiscardedBrandsL AppDir='%S'"),&file ); + CDir* brandDir = NULL; // will contain all brand folder for each application + User::LeaveIfError( + iFs.GetDir( file, KEntryAttDir, ESortNone, brandDir ) ); + CleanupStack::PushL( brandDir ); + + TInt countBrands = brandDir->Count(); + //for each brand of a certain application do... + for( TInt j(0) ; j < countBrands ; j++ ) + { + TFileName discardedFile( file ); + discardedFile.Append( (*brandDir)[j].iName ); + discardedFile.Append( KDirSeparator ); + discardedFile.Append( KDiscardBrandFileName ); // "C:\\private\\102828dd\\data\\xsp\\branda\\discarded.txt" + + TRACE( T_LIT( "CBSInstallHandler::CheckForDiscardedBrandsL BrandDir='%S'"),&file ); + + // check for the existance of the 'discarded.txt' file + if ( BaflUtils::FileExists( iFs, discardedFile ) ) + { + TRACE( T_LIT( "CBSInstallHandler::CheckForDiscardedBrandsL '%S' found!=>brand is discarded."),&discardedFile ); + discardedBrandExists = ETrue; + + //set RProperty for this brand + + //the string written to RProperty: + //"[brandId]$[applicationId]"(e.g."branda$xsp") + HBufC* writeBuf = HBufC::NewLC( RProperty::KMaxPropertySize ); + TPtr writeData( writeBuf->Des() ); + writeData.Append( (*brandDir)[j].iName ); + writeData.Append( KInstallFileDataSeparator ); + writeData.Append( (*appDir)[i].iName ); + TRACE( T_LIT( "CBSInstallHandler::CheckForDiscardedBrandsL uninstallstring='%S'"),writeBuf ); + + //UpdateProperty here!!! + UpdateRPropertyL( writeData ); + + CleanupStack::PopAndDestroy( writeBuf ); + } + } + CleanupStack::PopAndDestroy( brandDir ); + } + + CleanupStack::PopAndDestroy( appDir ); + TRACE( T_LIT( "CBSInstallHandler::CheckForDiscardedBrandsL end") ); + return discardedBrandExists; + } + + +// ----------------------------------------------------------------------------- +// CBSInstallHandler::UpdateRPropertyL +// ----------------------------------------------------------------------------- +// +void CBSInstallHandler::UpdateRPropertyL( const TDesC& aUninstallationString ) + { + HBufC* dataBuf = HBufC::NewLC( RProperty::KMaxPropertySize ); + TPtr data( dataBuf->Des() ); + + // Update uninstall string to pub&sub (only if the RProperty does not + // contain the unistallation string yet) + RProcess me; + TUid uid = me.Identity(); + TInt ret = RProperty::Define( uid, KUninstallKey, RProperty::EText); + if( ret != KErrAlreadyExists ) + { + TRACE( T_LIT( "CBSInstallHandler::UpdateRPropertyL RProperty does not exist") ); + User::LeaveIfError( ret ); + } + TRACE( T_LIT( "CBSInstallHandler::UpdateRPropertyL RProperty created/exists OK") ); + User::LeaveIfError( RProperty::Get( uid, KUninstallKey, data ) ); + + // don't append the uninstall string in case it already exists + // in the RProperty + if( KErrNotFound == data.Find( aUninstallationString ) ) + { + if( data.Length() > 0 ) + { + data.Append( KLineFeed ); + TRACE( T_LIT( "CBSInstallHandler::UpdateRPropertyL lineFeed appended to RProperty uninstallstring") ); + } + data.Append( aUninstallationString ); + TRACE( T_LIT( "CBSInstallHandler::UpdateRPropertyL '%S' appended to RProperty uninstallstring"), &aUninstallationString ); + if( data.Length() <= RProperty::KMaxPropertySize ) + { + User::LeaveIfError( RProperty::Set( uid, KUninstallKey, data ) ); + TRACE( T_LIT( "CBSInstallHandler::UpdateRPropertyL RProperty::Set OK") ); + } + } + else + { + TRACE( T_LIT( "CBSInstallHandler::UpdateRPropertyL '%S' already exists in RProperty"), &aUninstallationString ); + } + + CleanupStack::PopAndDestroy( dataBuf ); + + } + +// END OF FILE diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsinstallhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsinstallhandler.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,177 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: cbsinstallhandler.h +* +*/ + + + +#ifndef __CBSINSTALLHANDLER_H__ +#define __CBSINSTALLHANDLER_H__ + +#include + +// FORWARD DECLARATIONS +class RFs; + +/** + * CBSInstallHandler + * + * Handles installation and uninstallation of brand packages. + * Calls external application "bsinstall.exe" to do the actual work. + * Can Observe the installation directory so that any sis installation + * can be detected while the server is running. + * + */ +NONSHARABLE_CLASS( CBSInstallHandler ): public CActive + { + public: + + // Operations for folder synchronization: + enum TInstallOperation + { + // copy files from source to destination if they don't + // already exists. + EInstallCopyNewToDest, + + // Delete files from source directory if the same + // files doesn't exist in destination directory. + EInstallDeleteFromSrc + }; + + public: // constructors + + static CBSInstallHandler* NewL(); + + virtual ~CBSInstallHandler(); + + private: // constructors + + void ConstructL(); + + CBSInstallHandler(); + + public: + + /** + * Uninstall removed brands and installs new brands. + * This should be called right after construction to sync the + * installation state. + */ + void InstallNewFilesL(); + + /** + * Start observing installation folder. Detects new brands if they + * are installed while the server is active. + */ + void StartObservingL(); + + /** + * Stop observing installation folder. All new brands are installed + * only when calling InstallNewFilesL. + */ + void StopObserving(); + + private: // From CActive + + /** + * @see CActive + */ + void RunL(); + + /** + * @see CActive + */ + void DoCancel(); + + private: // new methods + + /** + * Launches external installer application. It should install all + * available brands into server. + */ + void LaunchInstallerAppL(); + + /** + * Sync files between aSrcDir and aDestDir, according to given + * operation. See TInstallOperation for operations. Calls + * OperationNotifyL before every operation. + * + * @param aSrcDir Source directory + * @param aDestDir Destination directory + * @param aOperation Sync operation to execute + * @return ETrue - Something synchronized + * EFalse - Nothing synchronized + */ + TBool SyncFilesL( const TDesC& aSrcDir, const TDesC& aDestDir, + TInstallOperation aOperation ); + + /** + * Notification that file is about to be synchronized. + * + * @param aOperation operation type which will be executed + * @param aSrcFile file under operation + */ + void OperationNotifyL( TInstallOperation aOperation, + const TDesC& aSrcFile ); + + /** + * check if some version of given brand is installed in + * branding server. + * + * @param aBrand brand installation file to check + * this has to be brand file name without extension and + * version information. + */ + TBool IsBrandInstalled( const TDesC& aBrand ); + + /** + * Helper method to get servers private path + * @param aPath contains the path to servers private folder + * @param aAppend text to add into private path. + */ + void GetPrivateFolder( TDes& aPath, const TDesC& aAppend = KNullDesC ); + + /** + * To create a flag file if brand gets discarded + * @param aSrcFile file under operation + */ + void CreateFlagFile(const TDesC& aSrcFile); + + /** + * Checks if an discarded brand exists. + * (It also writes the RProperty for the bsinstall.exe) + * + * @param aDir the folder of the data storages + * @return ETrue, in case a discarded brand was found, EFalse otherwise + */ + TBool CheckForDiscardedBrandsL( const TDesC& aDir ); + + + /** + * Updates the RProperty. The specified string is added to the + * RProperty only if RProperty does not contain the same string yet. + * + * @param aUninstallationString a string + */ + void UpdateRPropertyL( const TDesC& aUninstallationString ); + + private: // data + + // Own. File server session handle. + RFs iFs; + }; + +#endif // __CBSINSTALLHANDLER_H__ +// END OF FILE diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsserver.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,665 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: cbsserver.cpp +* +*/ + + + +// INCLUDE FILES + +#define __INCLUDE_CAPABILITY_NAMES__ +#define __INCLUDE_ALL_SUPPORTED_CAPABILITIES__ + +#include "cbsserver.h" +#include "cbssession.h" +#include "bsserverdefs.h" +#include "DebugTrace.h" +#include "cbsstoragemanager.h" +#include "cbsinstallhandler.h" +#include "cbsbackupobserver.h" + +// CBSFileMapping + +CBSServer::CBSFileMapping* CBSServer::CBSFileMapping::NewL( CBSSession* aSession, + const TDesC& aFile, + TBool aVersioned ) + { + CBSFileMapping* self = new( ELeave ) CBSFileMapping( aVersioned ); + CleanupStack::PushL( self ); + self->ConstructL( aSession, aFile ); + CleanupStack::Pop( self ); + return self; + } +void CBSServer::CBSFileMapping::ConstructL( CBSSession* aSession, + const TDesC& aFile ) + { + iSession = aSession; + iFile = aFile.AllocL(); + } +CBSServer::CBSFileMapping::CBSFileMapping( TBool aVersioned ) +: iVersioned( aVersioned ) + { + } +CBSServer::CBSFileMapping::~CBSFileMapping() + { + delete iFile; + } + +CBSSession* CBSServer::CBSFileMapping::Session() + { + return iSession; + } +const TDesC& CBSServer::CBSFileMapping::File() + { + return *iFile; + } +TBool CBSServer::CBSFileMapping::Versioned() + { + return iVersioned; + } + + +// ============================================================== +// =============== PLATSEC POLICY CONFIGURATION ================= +// ============================================================== + +static const TInt KBSPlatSecRangeCount = 2; + +//Ranges for the Request values +static const TInt KBSPlatSecRanges[ KBSPlatSecRangeCount ] = + { + 0, + EBSOperationLast + }; + + +// Element indexes for the defined ranges +static const TUint8 KBSPlatSecElementsIndex[ KBSPlatSecRangeCount ] = + { + 0, + CPolicyServer::ENotSupported + }; + + +// Policy elements +static const CPolicyServer::TPolicyElement KBSPlatSecElements[] = + { + { + _INIT_SECURITY_POLICY_C2( ECapabilityReadUserData, + ECapabilityWriteUserData ), + -5 //CPolicyServer::EFailClient + } + }; + + +// The platsec policy +static const CPolicyServer::TPolicy KBSPlatSecPolicy = + { + // Shortcut to the index into Elements,that is used to check a connection attempt + 0, + + // Number of ranges in the iRanges array + KBSPlatSecRangeCount, + + // A pointer to an array of ordered ranges of request numbers + KBSPlatSecRanges, + + // A pointer to an array of TUint8 values specifying + // the appropriate action to take for each range in iRanges + KBSPlatSecElementsIndex, + + // A pointer to an array of distinct policy elements + KBSPlatSecElements + }; + + + +// ============================================================== +// ======================= SERVER ============================== +// ============================================================== +void CBSServer::ExecuteL() + { + TRACE( T_LIT( "CBrandingServer::ExecuteL() begin") ); + // start scheduler + CActiveScheduler* pA = new( ELeave )CActiveScheduler; + CleanupStack::PushL( pA ); + CActiveScheduler::Install( pA ); + + + // create server + CBSServer* server = new( ELeave ) CBSServer(); + CleanupStack::PushL( server ); + server->InitializeL(); + server->StartL( KBSServerName ); + + + //Signal client that we are started + RProcess().Rendezvous( KErrNone ); + + //Execute the server + // Codescanner warning: using CActiveScheduler::Start (id:3) + // this has to be called for server starting. + CActiveScheduler::Start(); // CSI: 3 # See above + + + //Cleanup + CleanupStack::PopAndDestroy( server );//server + CleanupStack::PopAndDestroy( pA ); + CActiveScheduler::Install( NULL ); + TRACE( T_LIT( "CBrandingServer::ExecuteL() end") ); + } + + + +CBSServer::~CBSServer() + { + TRACE( T_LIT( "CBrandingServer::~CBSServer() begin") ); + delete iBackupObserver; + delete iInstallHandler; + iSessions.Close(); + iFileMapping.Close(); + delete iStorageManager; + +#if _BullseyeCoverage + cov_write(); +#endif + TRACE( T_LIT( "CBrandingServer::~CBSServer() end") ); + } + + + +CBSServer::CBSServer() + : CPolicyServer( CActive::EPriorityStandard, + KBSPlatSecPolicy ) + { + } + + + +CSession2* CBSServer::NewSessionL( const TVersion &aVersion, + const RMessage2& /*aMessage*/ ) const + { + TRACE( T_LIT( "CBrandingServer::NewSessionL() begin") ); + TVersion srvVersion( KBSVersionMajor, + KBSVersionMinor, + KBSVersionBuild ); + + + if( !User::QueryVersionSupported( aVersion, srvVersion ) ) + { + User::Leave( KErrNotSupported ); + } + + CBSSession* session = CBSSession::NewL(); + //enable backup observer + iBackupObserver->RegisterObserver( session ); + + TRACE( T_LIT( "CBrandingServer::NewSessionL() end session[%d] created"), session ); + return session; + } + + +CPolicyServer::TCustomResult + CBSServer::CustomFailureActionL( const RMessage2& aMsg, + TInt /*aAction*/, + const TSecurityInfo& aMissing ) + { + TRACE( T_LIT( "CBrandingServer::CustomFailureActionL() Request %d to session [%d] failed."), + aMsg.Function(), aMsg.Session() ); + + TBuf<512> diagnosticMsg; + _LIT( KDetails, "Failure details: "); + diagnosticMsg.Append( KDetails ); + _LIT( KFormat, "SecureId[%d] VendorId[%d] Missing caps[" ); + diagnosticMsg.AppendFormat( KFormat, + aMissing.iSecureId.iId, aMissing.iVendorId.iId ); + + const SCapabilitySet& missingCaps = (const SCapabilitySet&) aMissing.iCaps; + TBuf<1> separator; + _LIT( KSeparator, "]" ); + for( TInt ix = 0; ix < ECapability_Limit; ix++ ) + { + if( missingCaps[ix>>5] &(1<<(ix&31))) + { + diagnosticMsg.Append( separator ); + + const char* capName = CapabilityNames[ ix ]; + while( *capName ) + { + TUint16 c = *capName; + diagnosticMsg.Append( &c, 1 ); + ++capName; + } + + separator = KSeparator; + } + } + + diagnosticMsg.Append( KSeparator ); + TRACE( T_LIT( "%S"), &diagnosticMsg ); + + return CPolicyServer::EFail; + } + +void CBSServer::HandleBackupStateL( TBackupState aState ) + { + switch( aState ) + { + case EBackupNotActive: // backup has completed + { + // restart install handler and check for brand changes + iInstallHandler->InstallNewFilesL(); + iInstallHandler->StartObservingL(); + + //notify clients that we're back in business + break; + } + case EBackupActive: // backup activated + { + // stop install handler + iInstallHandler->StopObserving(); + + // Notify clients that branding data is not currently + // available + break; + } + default: + { + // unknown state + } + } + } + +void CBSServer::SessionCreatedL( CBSSession* aSession ) + { + TRACE( T_LIT( "CBSServer::SessionCreatedL begin aSession[%d]"),aSession ); + iSessionCount++; + iSessions.AppendL( aSession ); + } + + +void CBSServer::SessionDied( CBSSession* aSession ) + { + TInt count = iSessions.Count(); + for( TInt i = 0; i < count; i++ ) + { + if( iSessions[i] == aSession ) + { + iSessions.Remove( i ); + break; + } + } + TInt ignore = 0; + TRAP( ignore, UnRegisterSessionL( aSession ) ); + + //enable backup observer + iBackupObserver->UnregisterObserver( aSession ); + + iSessionCount--; + if( iSessionCount == 0 ) + { + // Codescanner warning: using CActiveScheduler::Stop ( Id: 4) + // it is required to stop the server + CActiveScheduler::Stop(); // CSI: 4 # See above + } + } + + + +TBool CBSServer::MatchSessionL( const TDesC& aApplicationId, + const TDesC& aBrandId, + TLanguage aLanguageId, + CBSSession* aSession, + TInt aReserved ) + { + TInt sessionCount = iSessions.Count(); + TBool returnValue = EFalse; + for( TInt i = 0; i < sessionCount; i++ ) + { + if( iSessions[i] == aSession ) + { + // we don't want to report the querying session itself + continue; + } + if( iSessions[i]->MatchSessionL( aApplicationId, + aBrandId, + aLanguageId, + aReserved ) ) + { + // even one match is enough for us + returnValue = ETrue; + break; + } + } + return returnValue; + } + +TBool CBSServer::MatchSessionUninstallL( const TDesC& aApplicationId, + const TDesC& aBrandId, CBSSession* aSession) +{ + TInt sessionCount = iSessions.Count(); + TBool returnValue = EFalse; + for( TInt i = 0; i < sessionCount; i++ ) + { + if( iSessions[i] == aSession ) + { + // we don't want to report the querying session itself + continue; + } + if( iSessions[i]->MatchSessionUninstallL( aApplicationId, + aBrandId )) + { + // even one match is enough for us + returnValue = ETrue; + break; + } + } + return returnValue; + +} + +void CBSServer::RegisterFileForSessionL( CBSSession* aSession, + const TDesC& aFile, + TBool aVersioned ) + { + TRACE( T_LIT( "CBSServer::RegisterFileForSessionL begin aSession[%d],aFile[%S]"),aSession,&aFile ); + TBool found = EFalse; + TInt count = iFileMapping.Count(); + for( TInt i = 0; i < count; i ++ ) + { + if( iFileMapping[i]->Session() == aSession && iFileMapping[i]->File() == aFile && + iFileMapping[i]->Versioned() == aVersioned) + { + found = ETrue; + } + } + + if(!found) + { + + CBSFileMapping* fileMapping = CBSFileMapping::NewL( aSession, aFile, aVersioned ); + CleanupStack::PushL( fileMapping ); + iFileMapping.AppendL( fileMapping ); + CleanupStack::Pop( fileMapping ); + } + TRACE( T_LIT( "CBSServer::RegisterFileForSessionL end") ); + } + +void CBSServer::UnRegisterSessionL( CBSSession* aSession ) + { + TRACE( T_LIT( "CBSServer::RegisterFileForSessionL begin aSession[%d]"),aSession ); + TInt count = iFileMapping.Count(); + for( TInt i = 0; i < count; i ++ ) + { + if( iFileMapping[i]->Session() == aSession ) + { + + if( !iStorageManager ) + { + iStorageManager = CBSStorageManager::NewL( aSession, KNullDesC ); + } + if( !FileStillInUse( aSession, iFileMapping[i]->File() ) ) + { + TPtrC baseFile = KNullDesC(); + if( iFileMapping[i]->Versioned() ) + { + baseFile.Set( iStorageManager->FilenameWithoutVersion( iFileMapping[i]->File() ) ); + } + else + { + baseFile.Set( iFileMapping[i]->File() ); + } + // we found the session, now check if any other + // session is using the same file + if( !FileStillInUse( aSession, baseFile ) ) + { + // no other sessions using the file + // cleanup versioned file + CleanupFileL( iFileMapping[i]->File() ); + } + + } + CBSFileMapping* fileMapping = iFileMapping[i]; + iFileMapping.Remove( i ); + delete fileMapping; + break; + } + } + TRACE( T_LIT( "CBSServer::RegisterFileForSessionL end") ); + } + +TBool CBSServer::FileStillInUse( CBSSession* aSession, + const TDesC& aFile ) + { + TBool returnValue = EFalse; + TInt count = iFileMapping.Count(); + for( TInt i = 0; i < count; i ++ ) + { + if( 0 == iFileMapping[i]->File().Compare( aFile ) ) + { + // file found, check that it's not the same sesion + if( iFileMapping[i]->Session() != aSession ) + { + + // it's not the same session + // so the file is still in use, we can + // return ETrue + returnValue = ETrue; + break; + } + } + } + return returnValue; + } + +void CBSServer::CleanupFileL( const TDesC& aFile ) + { + if( !iStorageManager ) + { + iStorageManager = CBSStorageManager::NewL( NULL, KNullDesC); + } + iStorageManager->CleanupFileL( aFile ); + } + +TArray CBSServer::RegisteredFiles() + { + return iFileMapping.Array(); + } + +void CBSServer::InitializeL() + { + TRACE( T_LIT( "CBSServer::InitializeL begin") ); + // Initialize brand install handler + iInstallHandler = CBSInstallHandler::NewL(); + iInstallHandler->InstallNewFilesL(); + iInstallHandler->StartObservingL(); + + //to enable backup observer + // Initialize backup and restore observer + CBSBackupObserver* tmp = CBSBackupObserver::NewL(); + delete iBackupObserver; + iBackupObserver = tmp; + User::LeaveIfError( iBackupObserver->RegisterObserver( this ) ); + TRACE( T_LIT( "CBSServer::InitializeL end") ); + } + +void CBSServer::BrandUpdatedL( const TDesC& aApplicationId, + const TDesC& aBrandId, + TLanguage aLanguageId, + CBSSession* aSession, + TInt aReserved ) + { + TRACE( T_LIT( "CBSServer::BrandUpdatedL begin aAppid[%S],aBrandId[%S]"),&aApplicationId, &aBrandId ); + TInt sessionCount = iSessions.Count(); + for( TInt i = 0; i < sessionCount; i++ ) + { + if( iSessions[i] == aSession ) + { + // we don't want to report the querying session itself + continue; + } + iSessions[i]->BrandUpdatedL( aApplicationId, + aBrandId, + aLanguageId, + aReserved ); + } + TRACE( T_LIT( "CBSServer::BrandUpdatedL end") ); + } + + + +// --------------------------------------------------------------------------- +// CBSServer::DisplaySessionInfoL display the info for each open session, +// except for the one that called this method +// --------------------------------------------------------------------------- +// +void CBSServer::DisplaySessionInfoL( CBSSession* aSession, TInt aErrorCode ) + { + TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() begin aSession[%d], aErrorCode[%d]"),aSession,aErrorCode ); + + User::LeaveIfNull( aSession ); + // some constants + const TInt KStringLength = 512; + const TInt KNumberLength = 16; + _LIT( KMessage0,"Operation failed.Errorcode:"); + _LIT( KMessage1," Info on open sessions [ProcessFileName|ThreadId|ProcessId|Caption]:"); + _LIT( KBracketOpen, " ["); + _LIT( KBracketClose, "]"); + _LIT( KSeparator, "|"); + + + HBufC* outputString = HBufC::NewLC( KStringLength ); + TPtr outputStringPtr( outputString->Des() ); + + TBuf number; + number.Num( aErrorCode ); + + //make sure the string is long enough + TInt newLength = outputString->Length() + + KMessage0().Length() + + number.Length() + + KMessage1().Length(); + + //reallocate if necessary + if ( outputStringPtr.MaxLength() < newLength ) + { + CleanupStack::Pop( outputString ); + outputString = outputString->ReAllocL( newLength ); + outputStringPtr.Set( outputString->Des() ); + CleanupStack::PushL( outputString ); + } + + outputStringPtr.Append( KMessage0 ); + outputStringPtr.Append( number ); + outputStringPtr.Append( KMessage1 ); + + + TInt count = iSessions.Count(); + TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() numberSessions=%d"),count ); + CBSSession* currentSession; + for( TInt i = 0; i < count; i++ ) + { + currentSession = iSessions[i]; + TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() iteration=%d session=%d"),i,currentSession ); + if ( currentSession + && currentSession->InfoAvailable() + && currentSession != aSession ) + { + TBuf threadIdStr; + TThreadId threadId; + if ( KErrNone == currentSession->ThreadId( threadId ) ) + { + threadIdStr.NumUC( threadId.Id(), EDecimal ); + } + TBuf processIdStr; + TProcessId processId; + if ( KErrNone == currentSession->ProcessId( processId ) ) + { + processIdStr.NumUC( processId.Id(), EDecimal ); + } + + //make sure the string is long enough + newLength = outputString->Length() + + KBracketOpen().Length() + + currentSession->FileName().Length() + + threadIdStr.Length() + + processIdStr.Length() + + currentSession->Caption().Length() + + ( 3 * KSeparator().Length() ) + + KBracketClose().Length(); + + //reallocate if necessary + if ( outputStringPtr.MaxLength() < newLength ) + { + CleanupStack::Pop( outputString ); + outputString = outputString->ReAllocL( newLength ); + outputStringPtr.Set( outputString->Des() ); + CleanupStack::PushL( outputString ); + } + + outputStringPtr.Append( KBracketOpen ); + + //processfilename + outputStringPtr.Append( currentSession->FileName() ); + outputStringPtr.Append( KSeparator ); + + //threadid + outputStringPtr.Append( threadIdStr ); + outputStringPtr.Append( KSeparator ); + + //processid + outputStringPtr.Append( processIdStr ); + outputStringPtr.Append( KSeparator ); + + //caption + outputStringPtr.Append( currentSession->Caption() ); + + outputStringPtr.Append( KBracketClose ); + } + } + + TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() string creation OK") ); + TRACE( T_LIT( "%S"), outputString ); + CleanupStack::PopAndDestroy( outputString ); + TRACE( T_LIT( "CBSServer::DisplaySessionInfoL() end") ); + } + +// ============================================================== +// ====================== ENTRY POINT =========================== +// ============================================================== +GLDEF_C TInt E32Main() + { + TRACE( T_LIT("E32Main - enter") ); + + User::RenameThread( KBSServerName ); + + CTrapCleanup* tc = CTrapCleanup::New(); + if( !tc ) + { + return KErrNoMemory; + } + + TRAPD( err, CBSServer::ExecuteL() ); + delete tc; + + TRACE( T_LIT("E32Main - exit: %d"), err ); + return err; + } + + + +// END OF FILE + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsserver.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,148 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSSERVER.H +* +*/ + + + +#ifndef __CBSSERVER_H__ +#define __CBSSERVER_H__ +#include + +#include "rbsobjowningptrarray.h" +#include "mbsbackupobserver.h" + +// FORWARD DECLARATIONS +class CBSSession; +class CBSStorageManager; +class CBSInstallHandler; +class CBSBackupObserver; + +/** + * Service server. + */ +NONSHARABLE_CLASS( CBSServer ): public CPolicyServer, + public MBSBackupObserver + { + public: + NONSHARABLE_CLASS( CBSFileMapping ): public CBase + { + public: + static CBSFileMapping* NewL( CBSSession* aSession, + const TDesC& aFile, + TBool aVersioned ); + + ~CBSFileMapping(); + private: // constructors + void ConstructL( CBSSession* aSession, + const TDesC& aFile ); + CBSFileMapping( TBool aVersioned ); + + public: // new methods + CBSSession* Session(); + const TDesC& File(); + TBool Versioned(); + + private: // data + // doesn't own: session + CBSSession* iSession; + HBufC* iFile; + TBool iVersioned; + }; + + public: // Execution and destructors + static void ExecuteL(); + virtual ~CBSServer(); + + private: // C++ constructor + CBSServer(); + + protected: // Methods from CPolicyServer + + CSession2* NewSessionL( const TVersion& aVersion, + const RMessage2& aMessage ) const; + + + CPolicyServer::TCustomResult CustomFailureActionL( + const RMessage2& aMsg, + TInt aAction, + const TSecurityInfo& aMissing); + + public: // From MBSBackupObserver + + void HandleBackupStateL( TBackupState aState ); + + public: //New methods + void SessionCreatedL( CBSSession* aSession ); + void SessionDied( CBSSession* aSession ); + + TBool MatchSessionL( const TDesC& aApplicationId, + const TDesC& aBrandId, + TLanguage aLanguageId, + CBSSession* aSession, + TInt aReserved = 0 ); + + TBool MatchSessionUninstallL( const TDesC& aApplicationId, + const TDesC& aBrandId, CBSSession* aSession); + + void RegisterFileForSessionL( CBSSession* aSession, + const TDesC& aFile, + TBool aVersioned ); + + TArray RegisteredFiles(); + + TBool FileStillInUse( CBSSession* aSession, + const TDesC& aFile ); + + void BrandUpdatedL( const TDesC& aApplicationId, + const TDesC& aBrandId, + TLanguage aLanguageId, + CBSSession* aSession, + TInt aReserved ); + /** + * Displays the info for each open session - except for the one that + * called this method. + * + * @param aSession the session that called this method + * @param aErrorCode a system-wide errorcode which is simply displayed + * by this method + */ + void DisplaySessionInfoL( CBSSession* aSession, TInt aErrorCode ); + + private: // New methods + void UnRegisterSessionL( CBSSession* aSession ); + + + void CleanupFileL( const TDesC& aFile ); + + void InitializeL(); + + private: //Data + TInt iSessionCount; + RPointerArray iSessions; + RBSObjOwningPtrArray iFileMapping; + CBSStorageManager* iStorageManager; + CBSInstallHandler* iInstallHandler; + + // Own. Observer for backup and restore events + CBSBackupObserver* iBackupObserver; + }; + +#endif // __CBSSERVER_H__ + + +// END OF FILE + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbssession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbssession.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,1729 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CBSSession.cpp +* +*/ + + + +// INCLUDE FILES +#include +#include + +#include "cbssession.h" +#include "cbsserver.h" +#include "DebugTrace.h" +#include "cbsbrandhandler.h" +#include "cbsstoragemanager.h" +#include "cbsstorage.h" +#include "cbsbitmap.h" +//#include "cbselement.h" +#include "rbsobjowningptrarray.h" +#include "bselementfactory.h" +#include "bsimportconstants.h" +#include +#include +#include +#include +#include + +// ============================================================== +// ======================== SESSION ============================= +// ============================================================== + +// Two-phased constructor. +CBSSession* CBSSession::NewL() + { + TRACE( T_LIT("CBSSession::NewL begin") ); + CBSSession* self = new( ELeave ) CBSSession(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + TRACE( T_LIT("CBSSession::NewL end") ); + return self; + } + +// Symbian OS default constructor can leave. +void CBSSession::ConstructL() + { + } + + +// destructor +CBSSession::~CBSSession() + { + TRACE( T_LIT("CBSSession[%d]::~CBSSession()"), this ); + + if( Server() ) + { + Server()->SessionDied( this ); + } + delete iText; + delete iBuffer; + delete iBranding; + delete iSeveralData; + +#ifdef __WINSCW__ + if( iStorageManager ) + { + iStorageManager->WriteIbyFiles(); + } +#endif + delete iStorageManager; + delete iSessionInfo; + + } + + +// C++ default constructor can NOT contain any code, that +// might leave. +// +CBSSession::CBSSession() + { + } + +// --------------------------------------------------------- +// CBSSession::CreateL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::CreateL() + { + TRACE( T_LIT("CBSSession[%d]::CreateL()"), this ); + Server()->SessionCreatedL( this ); + } + +// --------------------------------------------------------- +// CBSSession::ServiceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::ServiceL( const RMessage2 &aMessage ) + { + + /*if( !iSessionInfo ) + { + TRAPD( err, ExtractInfoL( aMessage ) ); + TRACE( T_LIT("CBSSession::ServiceL() ExtractInfoL returned with [%d]"), err ); + } + */ + if( DispatchMessageL( aMessage ) ) + { + if( !iMessageCompleted ) + { + aMessage.Complete( KErrNone ); + } + } + } + +// --------------------------------------------------------- +// CBSSession::ServiceError +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::ServiceError( const RMessage2& aMessage, + TInt aError ) + { + aMessage.Complete( aError ); + } + +// --------------------------------------------------------- +// CBSSession::HandleBackupStateL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::HandleBackupStateL( TBackupState aState ) + { + iIsBackup = ETrue ; + switch( aState ) + { + case EBackupNotActive: // backup is complete + { + // release session lock + iBackupActive = EFalse; + if( iStorageManager ) + { + iStorageManager->ReleaseLockL(); + } + + // Sending backup active state change event after unlocking it + if( iObserverActive ) + { + iObserverMessage.Complete( KErrNone ); + iObserverActive = EFalse; + } + + break; + } + case EBackupActive: // backup activated + { + + // Lock session. Branding data is not available until + // backup is completed. + iBackupActive = ETrue; + + // Sending backup active state change event before locking it + if( iObserverActive ) + { + iObserverMessage.Complete( KErrNone ); + iObserverActive = EFalse; + } + + if( iStorageManager ) + { + iStorageManager->LockStorage(); + } + break; + } + default: + { + // unknown state + } + } + + + } + +// --------------------------------------------------------- +// CBSSession::DispatchMessageL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CBSSession::DispatchMessageL( const RMessage2& aMessage ) + { + TRACE( T_LIT("CBrandingSession[%d]::DispatchMessageL() %d"), + this, aMessage.Function() ); + iMessageCompleted = EFalse; + TBool msgNeedsToBeCompleted = ETrue; + + if( iBackupActive ) + { + // if backup is active, we don't take requests. + // We could take some requests which do not require disk + // operations. This is not a good solution and a better one should be + // investigated. I'm running out of time. + TInt msg = aMessage.Function() ; + if( msg == EBSObserveGetChange || + msg == EBSObserveGetBackupState || + msg == EBSObserveBrand) + { + //allow to do the operation + } + else + { + User::Leave( KErrNotReady ); + } + + } + + switch( aMessage.Function() ) + { + case EBSInitInstall: + { + InitUpdateL( aMessage, EBSTxInstall ); + break; + } + case EBSInitUninstall: + { + InitUpdateL( aMessage, EBSTxUninstall ); + break; + } + case EBSInitAppend: + { + InitUpdateL( aMessage, EBSTxAppend ); + break; + } + case EBSInitReplace: + { + InitUpdateL( aMessage, EBSTxReplace ); + break; + } + case EBSInitAccess: + { + InitAccessL( aMessage ); + break; + } + case EBSPrepareText: + { + GetTextL( aMessage ); + break; + } + case EBSGetText: + { + if( iText ) + { + aMessage.WriteL( 2, *iText ); + } + else + { + aMessage.WriteL( 2, KNullDesC() ); + } + break; + } + + case EBSIsBrandUpdateRequired: + isBrandUpdateRequiredL (aMessage); + break; + + case EBSGetInt: + { + GetIntL( aMessage ); + break; + } + + case EBSPrepareBuffer: + { + GetBufferL( aMessage ); + break; + } + + case EBSGetBuffer: + { + if( iBuffer ) + { + aMessage.WriteL( 2, *iBuffer ); + } + else + { + aMessage.WriteL( 2, KNullDesC8() ); + } + break; + } + + case EBSGetFile: + { + GetFileL( aMessage ); + break; + } + + case EBSPrepareSeveral: + { + PrepareSeveralL( aMessage ); + break; + } + + case EBSGetSeveral: + { + GetSeveralL( aMessage ); + break; + } + + case EBSPrepareStructure: + { + PrepareStructureL( aMessage ); + break; + } + + case EBSGetStructure: + { + GetStructureL( aMessage ); + break; + } + + case EBSStartTransaction: + { + StartTransactionL( aMessage ); + break; + } + + case EBSStopTransaction: + { + StopTransactionL( aMessage ); + break; + } + case EBSCancelTransaction: + { + CancelTransactionL( aMessage ); + break; + } + + case EBSInstall: + { + InstallL( aMessage ); + break; + } + + case EBSReplace: + { + ReplaceL( aMessage ); + break; + } + + case EBSAppend: + { + AppendL( aMessage ); + break; + } + + case EBSRemoveBrand: + { + RemoveBrandL( aMessage ); + break; + } + case EBSRemoveApplication: + { + RemoveApplicationL( aMessage ); + break; + } + + case EBSObserveBrand: + { + if( iObserverActive ) + { + // complete the old observer request with KErrCancel + iObserverMessage.Complete( KErrCancel ); + } + iObserverMessage = aMessage; + iObserverActive = ETrue; + msgNeedsToBeCompleted = EFalse; + break; + } + + case EBSObserveGetNewVersion: + { + TInt newVersion = GetNewVersionL(); + TPckgC pack( newVersion ); + aMessage.WriteL( 0, pack ); + break; + } + + // Get what change happen + case EBSObserveGetChange: + { + TPckgC pack( iIsBackup ); + aMessage.WriteL( 0, pack ); + break ; + } + + // Get the backup state + case EBSObserveGetBackupState: + { + TPckgC pack( iBackupActive ); + aMessage.WriteL( 0, pack ); + break ; + } + + default: + { + User::Leave( KErrNotSupported ); + break; + } + } + + return msgNeedsToBeCompleted; + } + + +// --------------------------------------------------------- +// CBSSession::InitUpdateL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::InitUpdateL( const RMessage2 &aMessage, TTransactionType aType) + { + TRACE( T_LIT("CBSSession::InitUpdateL: begin TTransactionType[%d] "),aType ); + + // get the application id + TInt bufferSize( aMessage.GetDesLength( 0 ) ); + + HBufC8* appId = HBufC8::NewLC( bufferSize ); + TPtr8 appPtr = appId->Des(); + aMessage.ReadL( 0, appPtr ); + + HBufC* tmpAppId = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *appId ); + CleanupStack::PopAndDestroy( appId ); + + delete iApplicationId; + iApplicationId = tmpAppId; + + // get the brand id + bufferSize = aMessage.GetDesLength( 1 ); + HBufC8* streamBuf = HBufC8::NewLC( bufferSize ); + TPtr8 streamPtr = streamBuf->Des(); + aMessage.ReadL( 1, streamPtr ); + + RDesReadStream stream; + CleanupClosePushL( stream ); + stream.Open( streamPtr ); + + TInt descriptorLength = stream.ReadInt16L(); + HBufC8* brandId = HBufC8::NewLC( descriptorLength ); + TPtr8 brandPtr = brandId->Des(); + stream.ReadL( brandPtr, descriptorLength ); + + HBufC* tmpBrandId = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *brandId ); + CleanupStack::PopAndDestroy( brandId ); + delete iBrandId; + iBrandId = tmpBrandId; + + descriptorLength = stream.ReadInt16L(); + HBufC8* defaultBrandId = HBufC8::NewLC( descriptorLength ); + TPtr8 defaultPtr = defaultBrandId->Des(); + stream.ReadL( defaultPtr, descriptorLength ); + + HBufC* tmpDefaultBrandId = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *defaultBrandId ); + CleanupStack::PopAndDestroy( defaultBrandId ); + delete iDefaultBrandId; + iDefaultBrandId = tmpDefaultBrandId; + + CleanupStack::PopAndDestroy( 2, streamBuf ); // stream, streamBuf + + + // get the language id + iLanguageId = (TLanguage)aMessage.Int2(); + + // get the version + iReserved = aMessage.Int3(); + + // Check if brand is discarded and client is trying to access/append/replace on that + // give error message saying brand not found so that client will not use that brand + if(aType == EBSTxAccess || aType == EBSTxAppend || aType == EBSTxReplace ) + { + if(!iStorageManager) + { + iStorageManager = CBSStorageManager::NewL( this, *iApplicationId ); + } + + TBool brandDiscarded = EFalse ; + brandDiscarded = iStorageManager->CheckBrandDiscarded(*iApplicationId, *iBrandId) ; + + if(brandDiscarded) + { + TRACE( T_LIT("CBSSession::InitUpdateL: Brand discarded!->LeaveWith KErrNotFound") ); + ///Server()->DisplaySessionInfoL( this, KErrNotFound ); + User::Leave( KErrNotFound ); + } + } + + if( aType == EBSTxAppend ) + { + PrepareAppendL(); + } + else if( aType == EBSTxReplace ) + { + PrepareReplaceL(); + } + else if(aType == EBSTxUninstall) + { + if( !iStorageManager ) + { + iStorageManager = CBSStorageManager::NewL( this, *iApplicationId ); + } + // if any client is accessing same brand leave with KErrInUse. + // check if the brand has any active clients + TBool brandActive = EFalse; + CBSServer* server = Server(); + if( server ) + { + brandActive = server->MatchSessionUninstallL( *iApplicationId, *iBrandId, + this); + } + + if(brandActive) + { + TRACE( T_LIT("CBSSession::InitUpdateL: UnInstallation aborted -> LeaveWith KErrInUse") ); + //Server()->DisplaySessionInfoL( this,KErrInUse); + //when changing this errorcode: please read the note in + //UninstallL() ( installer.cpp ) + User::Leave( KErrInUse ); + } + } + else if( aType == EBSTxInstall ) + { + if( !iStorageManager ) + { + iStorageManager = CBSStorageManager::NewL( this, *iApplicationId ); + } + + HBufC* drive = HBufC::NewLC(3); + TRAPD( err, iStorageManager->GetNewestVersionL( *iApplicationId, + *iBrandId, + iLanguageId ) ); + if( ( err == KErrNotFound ) || ( err == KErrPathNotFound ) ) + { + CleanupStack::PopAndDestroy(drive); + // this brand is not yet there, which is the correct situation here + // for starting install. We can just ignore this error + } + + else if( !err ) + { + // there was no error, therefore this brand already exists in the ROM + // (Z drive). + // we leave with KErrAlreadyExists + if( 0 == (drive->Des().Compare(KBSZDrive)) ) + { + CleanupStack::PopAndDestroy(drive); + User::Leave( KErrAlreadyExists ); + } + else + { + //PopAndDestroy drive as it is not needed any longer. + CleanupStack::PopAndDestroy(drive); + + // if any client is accessing same brand leave with KErrInUse. + // check if the brand has any active clients + TBool brandActive = EFalse; + CBSServer* server = Server(); + if( server ) + { + brandActive = server->MatchSessionL( *iApplicationId, *iBrandId, + iLanguageId, this, iReserved ); + } + + if(brandActive == EFalse) + { + TRACE( T_LIT("CBSSession::InitUpdateL: Brand not used -> remove") ); + iStorageManager->RemoveBrandL( *iApplicationId, *iBrandId, + iLanguageId, iReserved ); + } + else + { + TRACE( T_LIT("CBSSession::InitUpdateL: Installation aborted->LeaveWith KErrInUse") ); + //Server()->DisplaySessionInfoL( this,KErrInUse); + //when changing this errorcode: please read the note in + //UninstallL() ( installer.cpp ) + User::Leave( KErrInUse ); + } + } + } + else + { + CleanupStack::PopAndDestroy(drive); + // some other error + TRACE( T_LIT("CBSSession::InitUpdateL: ERROR aType[%d] LeaveWith[%d]"),aType,err ); + User::Leave( err ); + } + } + + + iInitialized = ETrue; + + TRACE( T_LIT("Server initialized") ); + } + + + +// --------------------------------------------------------- +// CBSSession::PrepareAppendL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::PrepareAppendL() + { + if( !iStorageManager ) + { + iStorageManager = CBSStorageManager::NewL( this, *iApplicationId ); + } + + RFile brandHandle; + iStorageManager->BrandHandleL( *iApplicationId, + *iBrandId, iLanguageId, brandHandle, iReserved ); + CleanupClosePushL( brandHandle ); + RFileReadStream oldStream; + oldStream.Attach( brandHandle ); + CleanupClosePushL( oldStream ); + TInt version = oldStream.ReadInt16L(); + + TInt count = oldStream.ReadInt16L(); + + if( !iStorageManager->Storage() ) + { + iStorageManager->CreateStorageL(); + } + for( TInt i = 0; i < count; i++ ) + { + MBSElement* element = InternalizeElementL( oldStream, ETrue ); + CleanupDeletePushL( element ); + // transfers ownership + iStorageManager->Storage()->AppendElementsL( element ); + CleanupStack::Pop(); // element + } + + iStorageManager->Storage()->SetVersion( iReserved ); + iStorageManager->Storage()->SetStorageIdL( *iBrandId ); + iStorageManager->Storage()->SetApplicationIdL( *iApplicationId ); + iStorageManager->Storage()->SetLanguageL( iLanguageId ); + + CleanupStack::PopAndDestroy( 2 ); // oldStream, brandHandle + iAppending = ETrue; + } +// --------------------------------------------------------- +// CBSSession::PrepareReplaceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::PrepareReplaceL() + { + PrepareAppendL(); + } + +// --------------------------------------------------------- +// CBSSession::InitAccessL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::InitAccessL( const RMessage2 &aMessage ) + { + InitUpdateL( aMessage, EBSTxAccess ); + + iBranding = CBSBrandHandler::NewL( *iApplicationId, *iBrandId, *iDefaultBrandId, + iLanguageId, this, iReserved ); + + + iAccessInit = ETrue; + TRACE( T_LIT("Access initialized") ); + } + + +// --------------------------------------------------------- +// CBSSession::GetTextL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::GetTextL( const RMessage2 &aMessage ) + { + if( !iAccessInit ) + { + User::Leave( KErrNotReady ); + } + TInt idSize( aMessage.GetDesLength( 0 ) ); + + HBufC8* idBuffer = HBufC8::NewLC( idSize ); + TPtr8 ptrId = idBuffer->Des(); + aMessage.ReadL( 0, ptrId ); + + HBufC* temp = iBranding->GetTextL( ptrId ); + delete iText; + iText = temp; + + CleanupStack::PopAndDestroy( idBuffer ); + TPckgC pack( iText->Size() ); + aMessage.WriteL( 1, pack ); + TRACE( T_LIT("aMessage.WriteL( 1, %d );"), iText->Size() ); + } + +void CBSSession :: isBrandUpdateRequiredL (const RMessage2 &aMessage) +{ + if( !iAccessInit ) + { + User::Leave( KErrNotReady ); + } + TInt updateRequired = iBranding->isBrandUpdateRequiredL (); +// iValue = updateRequired; + TPckgC pack (updateRequired); + aMessage.WriteL( 0, pack ); +} +// --------------------------------------------------------- +// CBSSession::GetIntL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::GetIntL( const RMessage2 &aMessage ) + { + if( !iInitialized ) + { + User::Leave( KErrNotReady ); + } + TInt idSize( aMessage.GetDesLength( 0 ) ); + + HBufC8* idBuffer = HBufC8::NewLC( idSize ); + TPtr8 ptrId = idBuffer->Des(); + aMessage.ReadL( 0, ptrId ); + + iValue = iBranding->GetIntL( ptrId ); + TPckgC pack( iValue ); + aMessage.WriteL( 1, pack ); + CleanupStack::PopAndDestroy( idBuffer ); + } + +// --------------------------------------------------------- +// CBSSession::GetBufferL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::GetBufferL( const RMessage2 &aMessage ) + { + if( !iAccessInit ) + { + User::Leave( KErrNotReady ); + } + TInt idSize( aMessage.GetDesLength( 0 ) ); + + HBufC8* idBuffer = HBufC8::NewLC( idSize ); + TPtr8 ptrId = idBuffer->Des(); + aMessage.ReadL( 0, ptrId ); + + HBufC8* temp = iBranding->GetBufferL( ptrId ); + delete iBuffer; + iBuffer = temp; + + CleanupStack::PopAndDestroy( idBuffer ); + TPckgC pack( iBuffer->Size() ); + aMessage.WriteL( 1, pack ); + TRACE( T_LIT("aMessage.WriteL( 1, %d );"), iBuffer->Size() ); + } + + +// --------------------------------------------------------- +// CBSSession::GetFileL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::GetFileL( const RMessage2 &aMessage ) + { + TRACE( T_LIT("CBSSession::GetFileL begin") ); + if( !iInitialized ) + { + User::Leave( KErrNotReady ); + } + TInt idSize( aMessage.GetDesLength( 2 ) ); + HBufC8* idBuffer = HBufC8::NewLC( idSize ); + TPtr8 ptrId = idBuffer->Des(); + aMessage.ReadL( 2, ptrId ); + + RFile file; + iBranding->GetFileL( ptrId, file ); + + CleanupStack::PopAndDestroy( idBuffer ); + + User::LeaveIfError( file.TransferToClient( aMessage, 0 ) ); + + iMessageCompleted = ETrue; + + file.Close(); + TRACE( T_LIT("CBSSession::GetFileL end") ); + } + + +// --------------------------------------------------------- +// CBSSession::InternalizeElementIdsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::InternalizeElementIdsL( RReadStream& aStream, RBSObjOwningPtrArray& aArray ) + { + TInt count = aStream.ReadInt16L(); + + for(TInt i = 0; i < count; i++ ) + { + TInt length = aStream.ReadInt16L(); + HBufC8* id = HBufC8::NewLC( length ); + TPtr8 ptrId = id->Des(); + aStream.ReadL( ptrId, length ); + aArray.AppendL( id ); + CleanupStack::Pop( id ); + } + } + +// --------------------------------------------------------- +// CBSSession::PrepareTextL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::PrepareSeveralL( const RMessage2 &aMessage ) + { + if( !iInitialized ) + { + User::Leave( KErrNotReady ); + } + + TInt msgSize( aMessage.GetDesLength( 1 ) ); + + HBufC8* idBuffer = HBufC8::NewLC( msgSize ); + TPtr8 ptrId = idBuffer->Des(); + aMessage.ReadL( 1, ptrId ); + + RDesReadStream idStream; + CleanupClosePushL( idStream ); + idStream.Open( ptrId ); + + RBSObjOwningPtrArray idArray; + CleanupClosePushL( idArray ); + + InternalizeElementIdsL( idStream, idArray ); + + + MBSElement* texts = iBranding->GetSeveralL( idArray ); + + CleanupStack::PopAndDestroy(); // idArray + CleanupStack::PopAndDestroy(); // idStream + CleanupStack::PopAndDestroy(); // idBuffer + + CleanupDeletePushL( texts ); + + // FIXME magic number + CBufFlat* data = CBufFlat::NewL( 2000 ); + CleanupStack::PushL( data ); + + RBufWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( *data ); + + texts->ExternalizeL( writeStream ); + + CleanupStack::PopAndDestroy(); // writeStream + + delete iSeveralData; + iSeveralData = data; + CleanupStack::Pop( data ); + + CleanupStack::PopAndDestroy(); // texts + + delete iBuffer; + iBuffer = NULL; + iBuffer = iSeveralData->Ptr(0).AllocL(); + + delete iSeveralData; + iSeveralData = NULL; + TPckgC pack( iBuffer->Size() ); + TRACE( T_LIT("DispatchMessageL - EPlatSecPrepareSeveral writing size %d"), iBuffer->Size() ); + aMessage.WriteL( 0, pack ); + + } + +// --------------------------------------------------------- +// CBSSession::GetSeveralTextL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::GetSeveralL( const RMessage2 &aMessage ) + { + if( !iInitialized ) + { + User::Leave( KErrNotReady ); + } + aMessage.WriteL( 0, *iBuffer ); + + delete iBuffer; + iBuffer = NULL; + } + + +// --------------------------------------------------------- +// CBSSession::PrepareStructureL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::PrepareStructureL( const RMessage2 &aMessage ) + { + if( !iInitialized ) + { + User::Leave( KErrNotReady ); + } + TInt idSize( aMessage.GetDesLength( 1 ) ); + + RBSObjOwningPtrArray valueArray; + CleanupClosePushL( valueArray ); + + HBufC8* idBuffer = HBufC8::NewLC( idSize ); + TPtr8 ptrId = idBuffer->Des(); + aMessage.ReadL( 1, ptrId ); + + + MBSElement* extElement = iBranding->GetStructureL( ptrId ); + CleanupDeletePushL( extElement ); + // FIXME magic number + CBufFlat* data = CBufFlat::NewL( 2000 ); + CleanupStack::PushL( data ); + + RBufWriteStream writeStream; + CleanupClosePushL( writeStream ); + writeStream.Open( *data ); + + extElement->ExternalizeL( writeStream ); + + CleanupStack::PopAndDestroy(); // writeStream + + delete iSeveralData; + iSeveralData = data; + CleanupStack::Pop( data ); + + CleanupStack::PopAndDestroy( extElement ); + + delete iBuffer; + iBuffer = NULL; + iBuffer = iSeveralData->Ptr(0).AllocL(); + + delete iSeveralData; + iSeveralData = NULL; + TPckgC pack( iBuffer->Size() ); + TRACE( T_LIT("DispatchMessageL - EPlatSecPrepareSeveral writing size %d"), iBuffer->Size() ); + aMessage.WriteL( 0, pack ); + + + CleanupStack::PopAndDestroy(idBuffer); + + CleanupStack::PopAndDestroy(); // valueArray + + } + +// --------------------------------------------------------- +// CBSSession::GetStructureL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::GetStructureL( const RMessage2 &aMessage ) + { + if( !iInitialized ) + { + User::Leave( KErrNotReady ); + } + aMessage.WriteL( 0, *iBuffer ); + + delete iBuffer; + iBuffer = NULL; + } + + + +// --------------------------------------------------------- +// CBSSession::InstallL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::InstallL( const RMessage2 &aMessage ) + { + TRACE( T_LIT( "CBSSession::InstallL begin") ); + if( !iInitialized || !iStorageManager ) + { + User::Leave( KErrNotReady ); + } + + if( !iStorageManager->Storage() ) + { + iStorageManager->CreateStorageL(); + } + + iStorageManager->ConnectTransactionL( *iApplicationId, + *iBrandId, iLanguageId, EFalse, iReserved ); + + TInt msgSize( aMessage.GetDesLength( 0 ) ); + + HBufC8* buffer = HBufC8::NewLC( msgSize ); + TPtr8 ptr = buffer->Des(); + aMessage.ReadL( 0, ptr ); + + RDesReadStream stream; + CleanupClosePushL( stream ); + stream.Open( ptr ); + + MBSElement* element = InternalizeElementL( stream ); + CleanupDeletePushL( element ); + + iStorageManager->Storage()->SetVersion( iReserved ); + iStorageManager->Storage()->SetStorageIdL( *iBrandId ); + iStorageManager->Storage()->SetApplicationIdL( *iApplicationId ); + iStorageManager->Storage()->SetLanguageL( iLanguageId ); + // transfers ownership + iStorageManager->Storage()->AppendElementsL( element ); + + CleanupStack::Pop(); // element + CleanupStack::PopAndDestroy( 2, buffer ); + iWriteNeeded = ETrue; + TRACE( T_LIT( "CBSSession::InstallL end") ); + } + +// --------------------------------------------------------- +// CBSSession::ReplaceL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::ReplaceL( const RMessage2 &aMessage ) + { + TRACE( T_LIT( "CBSSession::ReplaceL begin") ); + if( !iInitialized || !iStorageManager ) + { + User::Leave( KErrNotReady ); + } + + iStorageManager->ConnectTransactionL( *iApplicationId, + *iBrandId, iLanguageId, EFalse, iReserved ); + + TInt msgSize( aMessage.GetDesLength( 0 ) ); + + HBufC8* buffer = HBufC8::NewLC( msgSize ); + TPtr8 ptr = buffer->Des(); + aMessage.ReadL( 0, ptr ); + + RDesReadStream stream; + CleanupClosePushL( stream ); + stream.Open( ptr ); + + MBSElement* element = InternalizeElementL( stream ); + CleanupDeletePushL( element ); + + // transfers ownership + iStorageManager->Storage()->ReplaceElementL( element ); + + CleanupStack::Pop(); // element + CleanupStack::PopAndDestroy( 2, buffer ); + iWriteNeeded = ETrue; + TRACE( T_LIT( "CBSSession::ReplaceL end") ); + } + + +// --------------------------------------------------------- +// CBSSession::AppendL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::AppendL( const RMessage2 &aMessage ) + { + TRACE( T_LIT( "CBSSession::AppendL begin") ); + if( !iInitialized || !iStorageManager ) + { + User::Leave( KErrNotReady ); + } + + iStorageManager->ConnectTransactionL( *iApplicationId, + *iBrandId, iLanguageId, EFalse, iReserved ); + + TInt msgSize( aMessage.GetDesLength( 0 ) ); + + HBufC8* buffer = HBufC8::NewLC( msgSize ); + TPtr8 ptr = buffer->Des(); + aMessage.ReadL( 0, ptr ); + + RDesReadStream stream; + CleanupClosePushL( stream ); + stream.Open( ptr ); + + MBSElement* element = InternalizeElementL( stream ); + CleanupDeletePushL( element ); + + iStorageManager->Storage()->SetVersion( iReserved ); + iStorageManager->Storage()->SetStorageIdL( *iBrandId ); + iStorageManager->Storage()->SetApplicationIdL( *iApplicationId ); + iStorageManager->Storage()->SetLanguageL( iLanguageId ); + // transfers ownership + iStorageManager->Storage()->AppendElementsL( element ); + + CleanupStack::Pop(); // element + CleanupStack::PopAndDestroy( 2, buffer ); + iWriteNeeded = ETrue; + TRACE( T_LIT( "CBSSession::AppendL end") ); + } + +// --------------------------------------------------------- +// CBSSession::StartTransactionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::StartTransactionL( const RMessage2& /*aMessage*/ ) + { + if( !iStorageManager ) + { + iStorageManager = CBSStorageManager::NewL( this, *iApplicationId ); + } + // if we are appending or replacing, we don't need to + // create storage + if( !iAppending ) + { + iStorageManager->CreateStorageL(); + } + } + + +// --------------------------------------------------------- +// CBSSession::CancelTransactionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::CancelTransactionL( const RMessage2 &aMessage ) + { + // get the application id + TInt bufferSize( aMessage.GetDesLength( 0 ) ); + + HBufC8* appId = HBufC8::NewLC( bufferSize ); + TPtr8 appPtr = appId->Des(); + aMessage.ReadL( 0, appPtr ); + + + // get the brand id + bufferSize = aMessage.GetDesLength( 1 ); + HBufC8* brandId = HBufC8::NewLC( bufferSize ); + TPtr8 brandPtr = brandId->Des(); + aMessage.ReadL( 1, brandPtr ); + + // get the language id + TLanguage language = (TLanguage)aMessage.Int2(); + + // get the version + TInt version = aMessage.Int3(); + + + HBufC* tmpBrandId = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *brandId ); + CleanupStack::PopAndDestroy( brandId ); + CleanupStack::PushL( tmpBrandId ); + HBufC* tmpAppId = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *appId ); + CleanupStack::PushL( tmpAppId ); + + // check if the transaction is correct + iStorageManager->ConnectTransactionL( *tmpAppId, + *tmpBrandId, iLanguageId, + EFalse, iReserved ); + + CleanupStack::PopAndDestroy( 2, tmpBrandId ); // tmpBrandId, tmpAppId + CleanupStack::PopAndDestroy( appId ); + // cancel the transaction + iStorageManager->CancelTransactionL(); + iWriteNeeded = EFalse; + } + +// --------------------------------------------------------- +// CBSSession::StopTransactionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::StopTransactionL( const RMessage2 &aMessage ) + { + if( !iStorageManager ) + { + // transaction not found + User::Leave( KErrNotFound ); + } + if( iAppending ) + { + // find next available version number + TInt nextVersion = iStorageManager->NextAvailableVersionL(); + iStorageManager->SetVersion( nextVersion ); + iStorageManager->Storage()->SetVersion( nextVersion ); + } + + if( iWriteNeeded ) + { + iReserved = iStorageManager->WriteStorageFilesL(); + iWriteNeeded = EFalse; + } + + delete iStorageManager; + iStorageManager = NULL; + + TPckgC pack( iReserved ); + aMessage.WriteL( 0, pack ); + + } + + +// --------------------------------------------------------- +// CBSSession::InternalizeElementL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +MBSElement* CBSSession::InternalizeElementL( RReadStream& aStream, TBool aAppending /*= EFalse*/ ) + { + MBSElement* returnValue = NULL; + + TBSElementType type = (TBSElementType)aStream.ReadInt16L(); + TInt idSize = aStream.ReadInt16L(); + HBufC8* elementId = HBufC8::NewLC( idSize ); + TPtr8 elementIdPtr = elementId->Des(); + aStream.ReadL( elementIdPtr, idSize ); + + + switch( type ) + { + case EBSInt: + { + TInt intData = aStream.ReadInt16L(); + returnValue = BSElementFactory::CreateBSElementL( *elementId, + EBSInt, + intData ); + break; + } + case EBSText: + { + TInt textSize = aStream.ReadInt16L(); + HBufC* textData = HBufC::NewLC( textSize ); + + TPtr textPtr = textData->Des(); + aStream.ReadL( textPtr, textSize ); + + returnValue = BSElementFactory::CreateBSElementL( *elementId, + type, + *textData ); + + CleanupStack::Pop( textData ); + break; + } + + case EBSFile: + { + TInt nameSize = aStream.ReadInt16L(); + HBufC* fileName = HBufC::NewLC( nameSize ); + + TPtr filePtr = fileName->Des(); + aStream.ReadL( filePtr, nameSize ); + + if( !aAppending ) + { + // we are installing, so the filename is pointing to a file + // that has to be installed + // Install file and get the filename without path + HBufC* strippedName = iStorageManager->InstallFileLC( *fileName ); + returnValue = BSElementFactory::CreateBSElementL( *elementId, + type, + *strippedName ); + CleanupStack::Pop( strippedName ); + CleanupStack::PopAndDestroy( fileName ); + } + else + { + // we are appending, so this is really the filename + returnValue = BSElementFactory::CreateBSElementL( *elementId, + type, + *fileName ); + CleanupStack::Pop( fileName ); + } + break; + } + + case EBSList: + { + RBSObjOwningPtrArray listData; + CleanupClosePushL( listData ); + TInt listCount = aStream.ReadInt16L(); + for( TInt i = 0; i < listCount; i++ ) + { + MBSElement* listElement = InternalizeElementL( aStream ); + CleanupDeletePushL( listElement ); + listData.AppendL( listElement ); + CleanupStack::Pop(); // listElement + } + + returnValue = BSElementFactory::CreateBSElementL( *elementId, + EBSList, + listData ); + CleanupStack::Pop(); // listData + break; + } + case EBSBuffer: + { + TInt bufferSize = aStream.ReadInt16L(); + HBufC8* buffer = HBufC8::NewLC( bufferSize ); + + TPtr8 buffPtr = buffer->Des(); + aStream.ReadL( buffPtr, bufferSize ); + + returnValue = BSElementFactory::CreateBSElementL( *elementId, + EBSBuffer, + *buffer ); + + CleanupStack::Pop( buffer ); + break; + } + case EBSBitmap: + { + TInt length = aStream.ReadInt16L(); + HBufC8* fileId = HBufC8::NewLC( length ); + + TPtr8 fileIdPtr = fileId->Des(); + aStream.ReadL( fileIdPtr, length ); + + TInt bitmapId = aStream.ReadInt16L(); + TInt maskId = aStream.ReadInt16L(); + TInt skinId = aStream.ReadInt16L(); + TInt skinMaskId = aStream.ReadInt16L(); + + + CBSBitmap* bitmap = CBSBitmap::NewLC( bitmapId, + maskId, + skinId, + skinMaskId, + fileIdPtr ); + + returnValue = BSElementFactory::CreateBSElementL( *elementId, + EBSBitmap, + bitmap ); + CleanupStack::Pop( bitmap ); + CleanupStack::PopAndDestroy( fileId ); + break; + } + + default: + { + User::Leave( KErrArgument ); + break; + } + } + + CleanupStack::PopAndDestroy( elementId ); + + return returnValue; + } + + +// --------------------------------------------------------- +// CBSSession::MatchSessionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CBSSession::MatchSessionL( const TDesC& aApplicationId, + const TDesC& aBrandId, + TLanguage aLanguageId, + TInt aReserved ) + { + TBool returnValue = EFalse; + if( iApplicationId && iBrandId ) + { + if( ( 0 == iApplicationId->Compare( aApplicationId ) ) && + ( 0 == iBrandId->Compare( aBrandId ) ) && + ( iLanguageId == aLanguageId ) && + ( iReserved == aReserved )) + { + returnValue = ETrue; + } + } + + return returnValue; + } + +// --------------------------------------------------------- +// CBSSession::MatchSessionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TBool CBSSession::MatchSessionUninstallL( const TDesC& aApplicationId, + const TDesC& aBrandId) + { + TBool returnValue = EFalse; + if( iApplicationId && iBrandId ) + { + if( ( 0 == iApplicationId->Compare( aApplicationId ) ) && + ( 0 == iBrandId->Compare( aBrandId ) ) ) + { + returnValue = ETrue; + } + } + + return returnValue; + } +// --------------------------------------------------------- +// CBSSession::BrandUpdatedL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::BrandUpdatedL( const TDesC& aApplicationId, + const TDesC& aBrandId, + TLanguage aLanguageId, + TInt /*aReserved*/ ) + { + TRACE( T_LIT( "CBSSession::BrandUpdatedL begin aAppId[%S] aBrandId[%S]"), &aApplicationId, &aBrandId ); + iIsBackup = EFalse ; + if( iApplicationId && iBrandId ) + { + if( ( 0 == iApplicationId->Compare( aApplicationId ) ) && + ( 0 == iBrandId->Compare( aBrandId ) ) && + ( iLanguageId == aLanguageId ) ) + { + // this event is for us + // complete the observer request from client + if( iObserverActive ) + { + iObserverMessage.Complete( KErrNone ); + iObserverActive = EFalse; + } + } + } + TRACE( T_LIT( "CBSSession::BrandUpdatedL end") ); + } + + +// --------------------------------------------------------- +// CBSSession::RemoveBrandL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::RemoveBrandL( const RMessage2& /*aMessage*/ ) + { + TRACE( T_LIT( "CBSSession::RemoveBrandL begin") ); + if( !iInitialized || !iStorageManager ) + { + User::Leave( KErrNotReady ); + } + + iStorageManager->RemoveBrandL( *iApplicationId, *iBrandId, + iLanguageId, iReserved ); + + + + TRACE( T_LIT( "CBSSession::RemoveBrandL end") ); + } + +// --------------------------------------------------------- +// CBSSession::RemoveApplicationL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CBSSession::RemoveApplicationL( const RMessage2& /*aMessage*/ ) + { + TRACE( T_LIT( "CBSSession::RemoveApplicationL begin") ); + if( !iInitialized || !iStorageManager ) + { + User::Leave( KErrNotReady ); + } + iStorageManager->RemoveApplicationL( *iApplicationId ); + TRACE( T_LIT( "CBSSession::RemoveApplicationL end") ); + } + +// --------------------------------------------------------- +// CBSSession::GetNewVersionL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +TInt CBSSession::GetNewVersionL() + { + if( !iStorageManager ) + { + iStorageManager = CBSStorageManager::NewL( this, KNullDesC ); + } + + return iStorageManager->GetNewestVersionL( *iApplicationId, *iBrandId, iLanguageId ); + } + + +// CBSSessionInfo +CBSSession::CBSSessionInfo* CBSSession::CBSSessionInfo::NewL( const TDesC& aFileName, + const TDesC& aCaption, + TThreadId aThreadId, + TProcessId aProcessId ) + { + CBSSessionInfo* self = new( ELeave ) CBSSessionInfo( aThreadId, aProcessId ); + CleanupStack::PushL( self ); + self->ConstructL( aFileName, aCaption ); + CleanupStack::Pop( self ); + return self; + } +void CBSSession::CBSSessionInfo::ConstructL( const TDesC& aFileName, const TDesC& aCaption ) + { + iFileName = aFileName.AllocL(); + iCaption = aCaption.AllocL(); + } +CBSSession::CBSSessionInfo::CBSSessionInfo( TThreadId aThreadId, TProcessId aProcessId ) +: iThreadId( aThreadId ), + iProcessId( aProcessId ) + { + } +CBSSession::CBSSessionInfo::~CBSSessionInfo() + { + delete iFileName; + delete iCaption; + } + +const TDesC& CBSSession::CBSSessionInfo::FileName() + { + return *iFileName; + } +const TDesC& CBSSession::CBSSessionInfo::Caption() + { + return *iCaption; + } + +TThreadId CBSSession::CBSSessionInfo::ThreadId() + { + return iThreadId; + } +TProcessId CBSSession::CBSSessionInfo::ProcessId() + { + return iProcessId; + } + + +// --------------------------------------------------------------------------- +// CBSSession::ExtractInfoL +// Extracts some information from the specified RMessage2 and saves it. +// --------------------------------------------------------------------------- +// +void CBSSession::ExtractInfoL( const RMessage2& aMessage ) + { + TRACE( T_LIT( "CBSSession::ExtractInfoL begin") ); + //Collect all necessary data + RThread thread; + TInt getProcessErr,getClientThreadErr; + getClientThreadErr = aMessage.Client( thread ); + CleanupClosePushL( thread ); + + if ( KErrNone == getClientThreadErr ) + { + TRACE( T_LIT( "CBSSession::ExtractInfoL Client retrieved OK") ); + TThreadId threadId = thread.Id(); + RProcess process; + getProcessErr = thread.Process( process ); + CleanupClosePushL( process ); + if ( getProcessErr == KErrNone ) + { + TRACE( T_LIT( "CBSSession::ExtractInfoL Processfilename retrieved OK") ); + TFileName fileName = process.FileName(); + TParsePtrC parser( fileName ); + TPtrC processFileNameAndExt( parser.NameAndExt() ); + + RApaLsSession session; + TInt connectErr = session.Connect(); + User :: LeaveIfError (connectErr); + session.GetAllApps(); + CleanupClosePushL( session ); + + TApaAppInfo info; + TPtrC captionPtr( KNullDesC ); + TPtrC printCaptionPtr( KNullDesC ); + TPtrC fullName( KNullDesC ); + while ( KErrNone == session.GetNextApp( info ) ) + { + fullName.Set( info.iFullName ); + printCaptionPtr.Set( info.iCaption ); + if( KErrNotFound != fullName.Find( processFileNameAndExt ) ) + { + captionPtr.Set( info.iCaption ); + TRACE( T_LIT( "CBSSession::ExtractInfoL caption saved: %S"),&captionPtr ); + break; + } + } + + CBSSessionInfo* temp = + CBSSessionInfo::NewL( processFileNameAndExt, + captionPtr, + threadId, + process.Id() ); + TRACE( T_LIT( "CBSSession::ExtractInfoL SessionInfo object creation OK") ); + delete iSessionInfo; + iSessionInfo = NULL; + iSessionInfo = temp; + CleanupStack::PopAndDestroy( &session ); + } + CleanupStack::PopAndDestroy( &process ); + } + CleanupStack::PopAndDestroy( &thread ); + TRACE( T_LIT( "CBSSession::ExtractInfoL end") ); + } + + +// --------------------------------------------------------------------------- +// CBSSession::FileName +// --------------------------------------------------------------------------- +// +const TDesC& CBSSession::FileName() + { + TRACE( T_LIT( "CBSSession::FileName begin") ); + if ( iSessionInfo ) + { + TRACE( T_LIT( "CBSSession::FileName SessionInfo exists") ); + return iSessionInfo->FileName(); + } + else + { + TRACE( T_LIT( "CBSSession::FileName SessionInfo does not exist") ); + return KNullDesC; + } + } + +// --------------------------------------------------------------------------- +// CBSSession::Caption +// --------------------------------------------------------------------------- +// +const TDesC& CBSSession::Caption() + { + TRACE( T_LIT( "CBSSession::Caption begin") ); + if ( iSessionInfo ) + { + TRACE( T_LIT( "CBSSession::Caption SessionInfo exists") ); + return iSessionInfo->Caption(); + } + else + { + TRACE( T_LIT( "CBSSession::Caption SessionInfo does not exist") ); + return KNullDesC; + } + } + + +// --------------------------------------------------------------------------- +// CBSSession::ThreadId +// --------------------------------------------------------------------------- +// +TInt CBSSession::ThreadId( TThreadId& aThreadId ) + { + TRACE( T_LIT( "CBSSession::ThreadId begin") ); + TInt err( KErrNotFound ); + if ( iSessionInfo ) + { + TRACE( T_LIT( "CBSSession::ThreadId SessionInfo exists") ); + aThreadId = iSessionInfo->ThreadId(); + err = KErrNone; + } + return err; + } + + +// --------------------------------------------------------------------------- +// CBSSession::ProcessId +// --------------------------------------------------------------------------- +// +TInt CBSSession::ProcessId( TProcessId& aProcessId ) + { + TRACE( T_LIT( "CBSSession::ProcessId begin") ); + TInt err( KErrNotFound ); + if ( iSessionInfo ) + { + TRACE( T_LIT( "CBSSession::ProcessId SessionInfo exists") ); + aProcessId = iSessionInfo->ProcessId(); + err = KErrNone; + } + return err; + } + + +// --------------------------------------------------------------------------- +// CBSSession::InfoAvailable +// --------------------------------------------------------------------------- +// +TBool CBSSession::InfoAvailable() + { + return iSessionInfo ? ETrue : EFalse; + } + +// END OF FILE + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbssession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbssession.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,462 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: cbssession.h +* +*/ + + + +#ifndef __CBSSESSION_H__ +#define __CBSSESSION_H__ + +#include +#include +#include "rbsobjowningptrarray.h" +#include "bsserverdefs.h" +#include "mbsbackupobserver.h" + +class CBSServer; +class CBSBrandHandler; +class MBSElement; +class CBSStorageManager; + +/** + * Service side session. + * + * @lib + * @since + */ + class CBSSession : public CSession2, + public MBSBackupObserver + { + + + public: + + /** + * Class for encapsulating the session information. + */ + NONSHARABLE_CLASS( CBSSessionInfo ): public CBase + { + public: + + /** + * Creates a new CBSSessionInfo + * + * @param aFileName the filename of the process, that created + * this session + * @param aCaption a caption of the process, that created this + * session + * @param aThreadId thread id where this session was created + * @param aProcessId processId of the process, that created + * this session + * @return a new CBSSessionInfo instance + */ + static CBSSessionInfo* NewL( const TDesC& aFileName, + const TDesC& aCaption, + TThreadId aThreadId, + TProcessId aProcessId ); + /** + * Destructor. + */ + ~CBSSessionInfo(); + + private: + + /** + * Symbian second-phase constructor + * + * @param aFileName the filename of the process, that created + * this session + * @param aCaption a caption of the process, that created this + * session + */ + void ConstructL( const TDesC& aFileName, + const TDesC& aCaption ); + + /** + * Constructor. + * + * @param aThreadId thread id where this session was created + * @param aProcessId processId of the process, that created + * this session + */ + CBSSessionInfo( TThreadId aThreadId, TProcessId aProcessId ); + + public: + + /** + * Returns the filename of the process, that created this + * session. + * + * @return a filename + */ + const TDesC& FileName(); + + /** + * Returns the caption of the process, that created this + * session. + * + * @return a caption + */ + const TDesC& Caption(); + + /** + * Returns the thread id where this session was created. + * + * @return a thread id + */ + TThreadId ThreadId(); + + /** + * Returns the processId of the process, that created + * this session. + * + * @return a process id + */ + TProcessId ProcessId(); + + private: // data + + /** + * Filename + * Own. + */ + HBufC* iFileName; + + /** + * Caption + * Own. + */ + HBufC* iCaption; + + /** + * Thread Id. + */ + TThreadId iThreadId; + + /** + * Process Id. + */ + TProcessId iProcessId; + }; + + + public: // Constructors and destructors + static CBSSession* NewL(); + virtual ~CBSSession(); + + + protected: // C++ constructors + /** + * C++ default constructor. + */ + CBSSession(); + + /** + * Symbian OS constructor + */ + void ConstructL(); + + public: // Methods derived from CSession2 + /** + * From CSession2 + */ + void CreateL(); + /** + * From CSession2 + */ + void ServiceL( const RMessage2 &aMessage ); + /** + * From CSession2 + */ + void ServiceError( const RMessage2& aMessage, + TInt aError ); + + public: // From MBSBackupObserver + + /* + * @see MBSBackupObserver + */ + void HandleBackupStateL( TBackupState aState ); + + public: // New methods + + /** + * + */ + CBSServer* Server() { return (CBSServer*) CSession2::Server(); } + + + TBool MatchSessionL( const TDesC& aApplicationId, + const TDesC& aBrandId, + TLanguage aLanguageId, + TInt aReserved ); + + TBool MatchSessionUninstallL( const TDesC& aApplicationId, + const TDesC& aBrandId); + + void BrandUpdatedL( const TDesC& aApplicationId, + const TDesC& aBrandId, + TLanguage aLanguageId, + TInt aReserved ); + + + + /** + * Returns the filename of the process, that created this + * session. + * + * @return a filename + */ + const TDesC& FileName(); + + /** + * Returns the caption of the process, that created this + * session. + * + * @return a caption + */ + const TDesC& Caption(); + + /** + * Returns the thread id where this session was created. + * + * @return a thread id + */ + TInt ThreadId( TThreadId& aThreadId ); + + /** + * Returns the processId of the process, that created + * this session. + * + * @return a process id + */ + TInt ProcessId( TProcessId& aProcessId ); + + /** + * Returns, if the session info for this object is available. + * + * @return ETrue, if information about this object is available; + * EFalse otherwise + */ + TBool InfoAvailable(); + + + private: // New methods + + /** + * Dispatch clients message + * + * @since + * @param aMessage client's message + */ + TBool DispatchMessageL( const RMessage2 &aMessage ); + + + /** + * Initializes the server + * @param aMessage client's message + */ + void InitUpdateL( const RMessage2 &aMessage, TTransactionType aType ); + + /** + * Initializes the server + * @param aMessage client's message + */ + void InitAccessL( const RMessage2 &aMessage ); + + + /** + * Get text type branding item + * @param aMessage client's message + */ + void GetTextL( const RMessage2 &aMessage ); + + /** + * Get text type branding item + * @param aMessage client's message + */ + void GetBufferL( const RMessage2 &aMessage ); + + /** + * Get integer type branding item + * @param aMessage client's message + */ + void GetIntL( const RMessage2 &aMessage ); + + /** + * Get file type branding item + * @param aMessage client's message + */ + void GetFileL( const RMessage2 &aMessage ); + + /** + * Prepares several textual type branding items. + * These have to be fetched with GetSeveralText. + * @param aMessage client's message + */ + void PrepareSeveralL( const RMessage2 &aMessage ); + + /** + * Gets the several textual branding items + * previously prepared. + * @param aMessage client's message + */ + void GetSeveralL( const RMessage2 &aMessage ); + + + /** + * Prepares several structure type branding items. + * These have to be fetched with GetStructure. + * @param aMessage client's message + */ + void PrepareStructureL( const RMessage2 &aMessage ); + + /** + * Gets the several structure type branding items + * previously prepared. + * @param aMessage client's message + */ + void GetStructureL( const RMessage2 &aMessage ); + + void isBrandUpdateRequiredL (const RMessage2 &aMessage); + + + + /** + * + * + * @param aMessage client's message + */ + void InstallL( const RMessage2 &aMessage ); + + /** + * + * + * @param aMessage client's message + */ + void ReplaceL( const RMessage2 &aMessage ); + + + /** + * + * + * @param aMessage client's message + */ + void AppendL( const RMessage2 &aMessage ); + + /** + * + * + * @param aMessage client's message + */ + MBSElement* InternalizeElementL( RReadStream& aStream, TBool aAppending = EFalse ); + + + /** + * Cancels the transaction + */ + void StartTransactionL( const RMessage2 &aMessage ); + + + /** + * Cancels the transaction + */ + void CancelTransactionL( const RMessage2 &aMessage ); + + /** + * Finishes the transaction + */ + void StopTransactionL( const RMessage2 &aMessage ); + + + /** + * Internalize element ids + */ + void InternalizeElementIdsL( RReadStream& aStream, RBSObjOwningPtrArray& aArray ); + + /** + * + * + * @param aMessage client's message + */ + void RemoveBrandL( const RMessage2 &aMessage ); + + + /** + * + * + * @param aMessage client's message + */ + void RemoveApplicationL( const RMessage2 &aMessage ); + + void PrepareAppendL(); + + void PrepareReplaceL(); + + TInt GetNewVersionL(); + + + /** + * Extracts some information from the specified RMessage2 + * and saves it. + * + * @param aMessage a message from a client + */ + void ExtractInfoL( const RMessage2& aMessage ); + + private: // Data + TBool iInitialized; + TBool iAppending; + TBool iAccessInit; + TBool iWriteNeeded; + + // is backup process currently active + TBool iBackupActive; + + HBufC* iBrandId; + HBufC* iDefaultBrandId; + HBufC* iApplicationId; + TLanguage iLanguageId; + + TInt iValue; + HBufC* iText; + CBSBrandHandler* iBranding; + CBufFlat* iSeveralData; + HBufC8* iBuffer; + TBool iMessageCompleted; + + CBSStorageManager* iStorageManager; + + TBool iObserverActive; + RMessage2 iObserverMessage; + + // To send backup event to client + TBool iIsBackup ; + TInt iReserved; + + /** + * Contains information about this object. + * Own. + */ + CBSSessionInfo* iSessionInfo; + + }; + +#endif // __CBSSESSION_H__ + + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsstorage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsstorage.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,372 @@ +/* +* Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Stores element data and writes it to stream +* +*/ + + + +#include "cbsstorage.h" +#include "bsimportconstants.h" +#include "DebugTrace.h" + + +#include +#include +#include + +//#include "mbsimportlogger.h" +//#include "importlogwriter.h" + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CBSStorage::NewL +// --------------------------------------------------------------------------- +// +CBSStorage* CBSStorage::NewL() + { + CBSStorage* self = NewLC(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- +// CBSStorage::NewLC +// --------------------------------------------------------------------------- +// +CBSStorage* CBSStorage::NewLC() + { + CBSStorage* self = new (ELeave) CBSStorage(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- +// CBSStorage::ConstructL +// --------------------------------------------------------------------------- +// +void CBSStorage::ConstructL() + { + } + +// --------------------------------------------------------------------------- +// CBSStorage::CBSStorage +// --------------------------------------------------------------------------- +// +CBSStorage::CBSStorage() + { + } + +// --------------------------------------------------------------------------- +// CBSStorage::~CBSStorage +// --------------------------------------------------------------------------- +// +CBSStorage::~CBSStorage() + { + iElements.Close(); + delete iAppId; + delete iStorageId; + delete iLanguage; + delete iFilename; + } + +// --------------------------------------------------------------------------- +// CBSStorage::AppendElement +// --------------------------------------------------------------------------- +// +void CBSStorage::AppendElementsL( MBSElement* aElement ) + { + if( !aElement ) + { + // Ignore empty + return; + } + + TPtrC8 id = aElement->ElementId(); + + // check if the id is unique + TInt count = iElements.Count(); + + for( TInt i = 0; i < count; i++ ) + { + if( 0 == iElements[i]->ElementId().Compare( id ) ) + { + // duplicate found + User::Leave( KErrAlreadyExists ); + } + } + + iElements.AppendL( aElement ); + } + + +// --------------------------------------------------------------------------- +// CBSStorage::ReplacesElementL +// --------------------------------------------------------------------------- +// +void CBSStorage::ReplaceElementL( MBSElement* aElement ) + { + if( !aElement ) + { + // Ignore empty + return; + } + + TPtrC8 id = aElement->ElementId(); + + // check if the id is unique + TInt count = iElements.Count(); + + for( TInt i = 0; i < count; i++ ) + { + if( 0 == iElements[i]->ElementId().Compare( id ) ) + { + // item found + MBSElement* element = iElements[i]; + iElements.Remove( i ); + delete element; + // put the new element + iElements.AppendL( aElement ); + return; + } + } + // the element was not found from this storage + User::Leave( KErrNotFound ); + } + + +// --------------------------------------------------------------------------- +// CBSStorage::ElementCount +// --------------------------------------------------------------------------- +// +TInt CBSStorage::ElementCount() + { + return iElements.Count(); + } + +// --------------------------------------------------------------------------- +// CBSStorage::ExternalizeL +// --------------------------------------------------------------------------- +// +void CBSStorage::ExternalizeL( RWriteStream& aWriteStream ) + { + if( !VerifyHeader() || !VerifyDataL( iElements ) ) + { + // Header not complete. Will not write to stream + User::Leave( KErrCorrupt ); + } + // Write header + aWriteStream.WriteInt16L( iVersion ); + + // Write elements + TInt count = iElements.Count(); + aWriteStream.WriteInt16L( count ); + for( TInt i = 0; i < count; i++ ) + { + iElements[i]->ExternalizeL( aWriteStream ); + } + } + +// --------------------------------------------------------------------------- +// CBSStorage::SetVersion +// --------------------------------------------------------------------------- +// +void CBSStorage::SetVersion( TInt aVersion ) + { + iVersion = aVersion; + } + +// --------------------------------------------------------------------------- +// CBSStorage::SetApplicationIdL +// --------------------------------------------------------------------------- +// +void CBSStorage::SetApplicationIdL( const TDesC& aAppId ) + { + HBufC* tmp = aAppId.AllocL(); + + delete iAppId; + iAppId = tmp; + } + +// --------------------------------------------------------------------------- +// CBSStorage::SetStorageIdL +// --------------------------------------------------------------------------- +// +void CBSStorage::SetStorageIdL( const TDesC& aStorageId ) + { + HBufC* tmp = aStorageId.AllocL(); + delete iStorageId; + iStorageId = tmp; + } + +// --------------------------------------------------------------------------- +// CBSStorage::SetLanguageL +// --------------------------------------------------------------------------- +// +void CBSStorage::SetLanguageL( TLanguage aLanguage ) + { + TBuf buffer; + buffer.AppendNum( aLanguage ); + + HBufC* tmp = buffer.AllocL(); + delete iLanguage; + iLanguage = tmp; + } + +// --------------------------------------------------------------------------- +// CBSStorage::VerifyHeader +// --------------------------------------------------------------------------- +// +TBool CBSStorage::VerifyHeader() + { + // not checking version as it is been consider not to use. - Pankaj - 31 may 07 + //return ( iAppId && iStorageId && iVersion > 0 && iLanguage ); + return ( iAppId && iStorageId && iLanguage ); + } + + +// --------------------------------------------------------------------------- +// CBSStorage::VerifyDataL +// --------------------------------------------------------------------------- +// +TBool CBSStorage::VerifyDataL( TArray aArray, + TBool aIgnoreEmptyID /* = EFalse */ ) + { + // Check that elements have unique ID's in their own namespace + TInt count = aArray.Count(); + for( TInt i = 0; i < count; i++ ) + { + // Verify inside list elements + if( aArray[i]->ElementType() == EBSList ) + { + TArray listArray = aArray[i]->GetStructureL(); + if( !VerifyDataL( listArray, ETrue ) ) + { + return EFalse; + } + } + + if( aIgnoreEmptyID && + aArray[i]->ElementId().CompareC( KNullDesC8() ) == 0 ) + { + // ignore empty id + continue; + } + + // Check that sibling elements have unique ID + for( TInt j = i + 1; j < count; j++ ) + { + if( aArray[i]->ElementId().CompareC( aArray[j]->ElementId() ) == 0 ) + { + // convert elementID to 16-bit for event logger + TPtrC8 id( aArray[i]->ElementId() ); + HBufC* conv = HBufC::NewLC( id.Length() ); + TPtr uniptr( conv->Des() ); + CnvUtfConverter::ConvertToUnicodeFromUtf8( uniptr, id ); + TRACE( T_LIT("ERROR: Found duplicate element ID (%S)!"), &uniptr ); + CleanupStack::PopAndDestroy(); + return EFalse; + } + } + } + + // All elements ok + return ETrue; + } + + +// --------------------------------------------------------------------------- +// CBSStorage::VerifyDataL +// --------------------------------------------------------------------------- +// +TBool CBSStorage::VerifyDataL( RBSObjOwningPtrArray& aArray, + TBool aIgnoreEmptyID /* = EFalse */ ) + { + return VerifyDataL( aArray.Array(), aIgnoreEmptyID ); + } + + +// --------------------------------------------------------------------------- +// CBSStorage::ProposeFileNameL +// --------------------------------------------------------------------------- +// +TPtrC CBSStorage::ProposeFileNameL() + { + if( !iFilename ) + { + User::Leave( KErrNotReady ); + } + return iFilename->Des(); + } + +// --------------------------------------------------------------------------- +// CBSStorage::ProposeFileNameL +// --------------------------------------------------------------------------- +// +TPtrC CBSStorage::ProposedDirL() + { + if( !iFilename ) + { + User::Leave( KErrNotReady ); + } + return iDir; + } + + +// --------------------------------------------------------------------------- +// CBSStorage::GetListOfFiles() +// --------------------------------------------------------------------------- +// +void CBSStorage::GetListOfFilesL( RArray& aFileList ) + { + TInt count = iElements.Count(); + for( TInt i = 0; i < count; i++ ) + { + AppendFilesL( iElements[i], aFileList ); + } + } + +// --------------------------------------------------------------------------- +// CBSStorage::AppendFiles() +// --------------------------------------------------------------------------- +// +void CBSStorage::AppendFilesL( MBSElement* aElement, RArray& aFileList ) + { + if( !aElement ) + { + // invalid element + return; + } + + TBSElementType type = aElement->ElementType(); + if( EBSList == type ) + { + TArray list = aElement->GetStructureL(); + + TInt count = list.Count(); + for( TInt i = 0; i < count; i++ ) + { + AppendFilesL( list[i], aFileList ); + } + } + else if( EBSFile == type ) + { + TPtrC ptr( aElement->TextDataL() ); + aFileList.Append( aElement->TextDataL() ); + } + } + +// End of file diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsstorage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsstorage.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,172 @@ +/* +* Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Stores element data and writes it to stream +* +*/ + + + +#ifndef CBSSTORAGE_H +#define CBSSTORAGE_H + +#include + +#include "rbsobjowningptrarray.h" + +class MBSElement; +class RWriteStream; +class MBSImportLogger; + + +/** + * Stores element data and writes it to stream + * + * @lib brandimporter.exe + * @since S60 v3.2 + */ +class CBSStorage : public CBase +{ +public: + + static CBSStorage* NewL(); + + static CBSStorage* NewLC(); + + ~CBSStorage(); + + /** + * Set version of brand storage + * + * @since S60 3.2 + * @param aVersion version + */ + void SetVersion( TInt aVersion ); + + /** + * Set application ID of brand storage + * + * @since S60 3.2 + * @param aAppId application ID + * @return none + */ + void SetApplicationIdL( const TDesC& aAppId ); + + /** + * Set storage ID of brand storage + * + * @since S60 3.2 + * @param aStorageId storage ID + * @return none + */ + void SetStorageIdL( const TDesC& aStorageId ); + + /** + * Set language of brand storage + * + * @since S60 3.2 + * @param aLanguage language + * @return none + */ + void SetLanguageL( TLanguage aLanguage ); + + /** + * Store element to storage. Storage takes the ownership of element. + * + * @since S60 3.2 + * @param aElement element to store. + * @return General Symbian errorcode. + */ + void AppendElementsL( MBSElement* aElement ); + + /** + * Return the count of elements in storage + * + * @since S60 3.2 + * @return count of elements + */ + TInt ElementCount(); + + /** + * Externalize storage into stream + * + * @since S60 3.2 + * @param aWriteStream output stream + * @return none + */ + void ExternalizeL( RWriteStream& aWriteStream ); + + /** + * Replaces an element in the storage + * + * @since S60 3.2 + * @param aElement the element to be replaced + */ + void ReplaceElementL( MBSElement* aElement ); + + + TPtrC ProposeFileNameL(); + TPtrC ProposedDirL(); + void GetListOfFilesL( RArray& aFileList ); + +private: + + CBSStorage(); + + void ConstructL(); + + /** + * Check that header information is complete + * + * @since S60 3.2 + * @return ETrue - header information ok + * EFalse - header information missing or incomplete + */ + TBool VerifyHeader(); + + TBool VerifyDataL( TArray aArray, + TBool aIgnoreEmptyID = EFalse ); + TBool VerifyDataL( RBSObjOwningPtrArray& aArray, + TBool aIgnoreEmptyID = EFalse ); + + void HandleIfErrorL( TInt aError, const TDesC& aText ); + + void AppendFilesL( MBSElement* aElement, RArray& aFileList ); + +private: // Data + + // Own. Array of stored elements. + RBSObjOwningPtrArray iElements; + + // Own. Proposed file name + HBufC* iFilename; + + // Proposed directory (points to iFilename) + TPtrC iDir; + + // HEADER DATA + + // Version number of storage + TInt iVersion; + + // Own. Language ID of storage + HBufC* iLanguage; + + // Own. Application ID of storage + HBufC* iAppId; + + // Own. Storage ID.of storage + HBufC* iStorageId; +}; + +#endif //CBSSTORAGE_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsstoragemanager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsstoragemanager.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,1419 @@ +/* +* Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Stores element data and writes it to stream +* +*/ + + + +#include +#include +#include + +#include +#include + + +#include "bsimportconstants.h" +#include "cbsstoragemanager.h" +#include "cbsstorage.h" +#ifdef __WINSCW__ +#include "cbsibywriter.h" +#endif +#include "cbsserver.h" +#include "cbssession.h" +#include "mbsupdater.h" +//#include "importlogwriter.h" +#include "DebugTrace.h" + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CBSStorageManager::NewL +// --------------------------------------------------------------------------- +// +CBSStorageManager* CBSStorageManager::NewL( CBSSession* aSession, const TDesC& aAppId ) + { + CBSStorageManager* self = NewLC( aSession, aAppId ); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::NewLC +// --------------------------------------------------------------------------- +// +CBSStorageManager* CBSStorageManager::NewLC( CBSSession* aSession, const TDesC& aAppId ) + { + CBSStorageManager* self = + new (ELeave) CBSStorageManager(); + CleanupStack::PushL( self ); + self->ConstructL( aSession, aAppId ); + return self; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::ConstructL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::ConstructL( CBSSession* aSession, const TDesC& aAppId ) + { + TRACE( T_LIT( "CBSStorageManager::ConstructL begin aAppId[%S]"), &aAppId ); + User::LeaveIfError( iFs.Connect() ); + +// RFs::ShareProtected() needs to be called for the session +// used to open the handle that is going to be shared. +// ShareProtected() was called to a wrong Fs-session in +// CBSBrandHandler::GetFileL(). + User::LeaveIfError( iFs.ShareProtected() ); + + iFs.CreatePrivatePath( EDriveC ); + + iSession = aSession; + + +#ifdef __WINSCW__ + if( !iWriter ) + { + iWriter = CBSIBYWriter::NewL(); + } + if( aAppId.Compare( KNullDesC ) ) + { + HBufC* temp = HBufC::NewL( KBSIbyDirectory().Length() + + aAppId.Length() + + KBSIbyExtension().Length() ); + TPtr ptr( temp->Des() ); + ptr.Append( KBSIbyDirectory ); + ptr.Append( aAppId ); + ptr.Append( KBSIbyExtension ); + delete iIbyFile; + iIbyFile = temp; + iWriter->InitIbyFileL( iFs, *iIbyFile ); + } +#endif + TRACE( T_LIT( "CBSStorageManager::ConstructL end") ); + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::CBSStorageManager +// --------------------------------------------------------------------------- +// +CBSStorageManager::CBSStorageManager() : + iCurrent( KErrNotFound ) + { + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::~CBSStorageManager +// --------------------------------------------------------------------------- +// +CBSStorageManager::~CBSStorageManager() + { + TRACE( T_LIT( "CBSStorageManager::~CBSStorageManager begin") ); + iStorages.ResetAndDestroy(); + iFs.Close(); + + delete iAppId; + delete iBrandId; + delete iLanguageId; + delete iFilename; + + #ifdef __WINSCW__ + delete iWriter; + #endif + + delete iIbyFile; + TRACE( T_LIT( "CBSStorageManager::~CBSStorageManager end") ); + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::InitTransactionL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::ConnectTransactionL(const TDesC& aAppId, + const TDesC& aBrandId, + TLanguage aLanguageId, + TBool aAppending, /*= EFalse*/ + TInt aReserved /*=0*/) + { + TRACE( T_LIT( "CBSStorageManager::ConnectTransactionL begin AppId[%S],BrandId[%S]"),&aAppId, &aBrandId ); + if( iActive ) + { + TBool transactionOk = ETrue; + + transactionOk = iReserved == aReserved; + + if( transactionOk ) + { + transactionOk = iLanguageIdNum == aLanguageId; + } + + if( transactionOk ) + { + transactionOk != iAppId->Compare( aAppId ); + } + + if( transactionOk ) + { + transactionOk != iBrandId->Compare( aBrandId ); + } + + if( !transactionOk ) + { + User::Leave( KErrArgument ); + } + // the same transaction as is ongoing + return; + } + iActive = ETrue; + + HBufC* tmpAppId = aAppId.AllocL(); + delete iAppId; + iAppId = tmpAppId; + + HBufC* tmpBrandId = aBrandId.AllocL(); + delete iBrandId; + iBrandId = tmpBrandId; + + iLanguageIdNum = aLanguageId; + + TBuf buffer; + if( aLanguageId < 10 ) + { + // we want two digit languageid + buffer.AppendNum( KLeadingZero ); + } + buffer.AppendNum( aLanguageId ); + HBufC* tmp = buffer.AllocL(); + delete iLanguageId; + iLanguageId = tmp; + + iReserved = aReserved; + + HBufC* tempFile = ConstructFileNameL(); + delete iFilename; + iFilename = tempFile; + + iAppending = aAppending; + TRACE( T_LIT( "CBSStorageManager::ConnectTransactionL end") ); + } + + +// --------------------------------------------------------------------------- +// CBSStorageManager::CancelTransactionL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::CancelTransactionL() + { + TRACE( T_LIT( "CBSStorageManager::CancelTransactionL begin") ); + if( !iActive ) + { + User::Leave( KErrNotFound ); + } + // this closes the transaction + CleanupTransaction(); + TRACE( T_LIT( "CBSStorageManager::CancelTransactionL end") ); + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::ConstructFileNameL() +// --------------------------------------------------------------------------- +// +HBufC* CBSStorageManager::ConstructFileNameL( TInt aReserved /* = 0 */ ) + { + HBufC* fileName = NULL; + if( iAppId && iBrandId && iLanguageId ) + { + fileName = ConstructFileNameL( *iAppId, *iBrandId, iLanguageIdNum, aReserved ); + } + return fileName; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::ConstructFileNameL() +// --------------------------------------------------------------------------- +// +HBufC* CBSStorageManager::ConstructFileNameL( const TDesC& aAppId, + const TDesC& aBrandId, + TLanguage aLanguage, + TInt aReserved /* = 0 */ ) + { + HBufC* fileName = NULL; + + TBuf langBuf; + if (aLanguage >= 100) + User::LeaveIfError (KErrNotFound); + if( aLanguage < 10 ) + { + // we want two digit languageid + langBuf.AppendNum( KLeadingZero ); + } + langBuf.AppendNum( aLanguage ); + + TInt length = aAppId.Length() + aBrandId.Length() + + KDefFileName().Length() + KDirSeparator().Length() * 2 + + langBuf.Length() + KDot().Length() * 3 + KMaxVersionLenght; + fileName = HBufC::NewLC( length ); + + TPtr file( fileName->Des() ); + + // [application_id]\[brand_id]\[def_filename][language_id] + // + + file.Append( aAppId ); + file.Append( KDirSeparator ); + file.Append( aBrandId ); + file.Append( KDirSeparator ); + iDir.Set( file.Left( file.Length() ) ); + file.Append( KDefFileName ); + file.Append( langBuf ); + if( aReserved > 0 ) + { + TBuf versionBuffer; + versionBuffer.AppendNum( aReserved ); + file.Append( KDot() ); + file.Append( versionBuffer ); + } + + if( fileName ) + { + CleanupStack::Pop( fileName ); + } + return fileName; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::CreateStorageL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::CreateStorageL() + { + CBSStorage* tmp = CBSStorage::NewL(); + iStorages.Append( tmp ); + iCurrent = iStorages.Find( tmp ); + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::StorageCount +// --------------------------------------------------------------------------- +// +TInt CBSStorageManager::StorageCount() + { + return iStorages.Count(); + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::Storage +// --------------------------------------------------------------------------- +// +CBSStorage* CBSStorageManager::Storage( TInt aIndex ) + { + return iStorages[ aIndex ]; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::Storage +// --------------------------------------------------------------------------- +// +CBSStorage* CBSStorageManager::Storage() + { + if( iStorages.Count() > 0 ) + { + return iStorages[ iCurrent ]; + } + return NULL; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::WriteStorageFilesL +// --------------------------------------------------------------------------- +// +TInt CBSStorageManager::WriteStorageFilesL() + { + TRACE( T_LIT( "CBSStorageManager::WriteStorageFilesL begin") ); + if( !iActive ) + { + User::Leave( KErrNotFound ); + } + TInt count = iStorages.Count(); + for( TInt i = 0; i < count; i++ ) + { + // get the private path + TBuf path; + User::LeaveIfError( iFs.PrivatePath( path ) ); + + // construct absolute filename + HBufC* fullname = FullFileNameLC( *iFilename, ETrue ); + + TParse filestorename; + iFs.Parse( *fullname, filestorename ); + + RFileWriteStream outstream; + + TInt currentVersion = iReserved; + TInt newVersion = iReserved; + // check if the brand has any active clients + TBool brandActive = ETrue; + if( iSession ) + { + CBSServer* server = iSession->Server(); + if( server ) + { + brandActive = server->MatchSessionL( *iAppId, *iBrandId, + iLanguageIdNum, iSession, currentVersion ); + } + } + + if( BaflUtils::FileExists( iFs, filestorename.FullName() ) ) + { + currentVersion = ReadVersionL( filestorename.FullName() ); + + if( iReserved == KBSAutomaticVersionUpdate && brandActive ) + { + + // the brand has active clients + // check if there is already a versioned file for this version + HBufC* fileName = FindAvailableVersionL( currentVersion + 1, newVersion ); + CleanupStack::PushL( fileName); + + HBufC* newName = FullFileNameLC( *fileName, ETrue ); + + iFs.Parse( *newName, filestorename ); + + if( BaflUtils::FileExists( iFs, filestorename.FullName() ) ) + { + // the file already exists + User::Leave( KErrAlreadyExists ); + } + CleanupStack::PopAndDestroy( 2, fileName ); // newName, fileName + } + + else if( ( iReserved == currentVersion ) ) + { + // this version is already installed + User::Leave( KErrAlreadyExists ); + } + + else + { + // check if the current version brand is active + brandActive = iSession->Server()->MatchSessionL( *iAppId, *iBrandId, + iLanguageIdNum, iSession, currentVersion ); + // new version + if( brandActive ) + { + // brand is active + // check if there is already a versioned file for this version + HBufC* fileName = ConstructFileNameL( iReserved ); + CleanupStack::PushL( fileName ); + + HBufC* newName = FullFileNameLC( *fileName, ETrue ); + + iFs.Parse( *newName, filestorename ); + + if( BaflUtils::FileExists( iFs, filestorename.FullName() ) ) + { + // the file already exists + User::Leave( KErrAlreadyExists ); + } + CleanupStack::PopAndDestroy( 2, fileName ); // newName, fileName + } + } + } + + + // write a new brand file + + // Construct the output file & stream. + iFs.MkDirAll( filestorename.DriveAndPath() ); + + TInt err = outstream.Replace( iFs, filestorename.FullName(), EFileWrite ); + + + if( err ) + { + TRACE( T_LIT("ERROR: Cannot create branding file: '%S'"), fullname ); + + User::Leave( err ); + } + + CleanupClosePushL( outstream ); + + if( iReserved == KBSAutomaticVersionUpdate ) + { + // set the next version + iStorages[i]->SetVersion( newVersion ); + iReserved = newVersion; + } + + // Write data to file + TRAPD( extError, iStorages[i]->ExternalizeL( outstream ) ); + if( extError && !iAppending ) + { + // there was an error externalizing the data and we are installing + // delete the file, since it's not complete + iFs.Delete( filestorename.DriveAndPath() ); + } + User::LeaveIfError( extError ); + + +#ifdef __WINSCW__ + // Add to IBY file + iWriter->SetFileItemL( *fullname, *fullname ); +#endif + + CleanupStack::PopAndDestroy( 2 ); // fullname, outstream + + + // existing brand modified --> inform server + if( iSession ) + { + CBSServer* server = iSession->Server(); + if( server ) + { + server->BrandUpdatedL( *iAppId, *iBrandId, + iLanguageIdNum, iSession, iReserved ); + } + } + } + + // this closes the transaction + CleanupTransaction(); + TRACE( T_LIT( "CBSStorageManager::WriteStorageFilesL end") ); + return iReserved; + } + + +// --------------------------------------------------------------------------- +// CBSStorageManager::ReadVersionL +// --------------------------------------------------------------------------- +// +TInt CBSStorageManager::ReadVersionL( const TDesC& aFilename ) + { + RFile handle; + User::LeaveIfError( handle.Open( iFs, aFilename, EFileRead ) ); + CleanupClosePushL( handle ); + RFileReadStream stream; + stream.Attach( handle ); + CleanupClosePushL( stream ); + TInt version = stream.ReadInt16L(); + CleanupStack::PopAndDestroy( 2 ); // stream, handle + return version; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::FindAvailableVersionL +// --------------------------------------------------------------------------- +// +HBufC* CBSStorageManager::FindAvailableVersionL( TInt /*aCurrentVersion*/, TInt& aNewVersion ) + { + HBufC* fileName = NULL; + TInt newVersion = GetNewestVersionL( *iAppId, *iBrandId, iLanguageIdNum ); + aNewVersion = newVersion++; + fileName = ConstructFileNameL( aNewVersion ); + + return fileName; + } + + +// --------------------------------------------------------------------------- +// CBSStorageManager::CleanupTransaction +// --------------------------------------------------------------------------- +// +void CBSStorageManager::CleanupTransaction() + { + iActive = EFalse; + delete iAppId; + iAppId = NULL; + delete iBrandId; + iBrandId = NULL; + delete iLanguageId; + iLanguageId = NULL; + delete iFilename; + iFilename = NULL; + + iStorages.ResetAndDestroy(); + } + + +TInt CBSStorageManager :: isActualBrandInstalledL ( const TDesC& aAppId, const TDesC& aBrandId, TLanguage aLanguage) +{ + TInt actualBrandInstalled = -1; + HBufC *actualBrandFileName = ConstructFileNameL(aAppId, aBrandId, aLanguage); + CleanupStack::PushL( actualBrandFileName ); + HBufC* newName = FullFileNameLC( *actualBrandFileName , ETrue ); + if (newName) + { + RFile handle; + TInt err = handle.Open( iFs, *newName, EFileShareAny ); + if (KErrNone == err) + { + actualBrandInstalled = 1; + handle.Close (); + } + } + + CleanupStack::PopAndDestroy (2); + return actualBrandInstalled; +} +// --------------------------------------------------------------------------- +// CBSStorageManager::BrandHandleL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::BrandHandleL( const TDesC& aAppId, + const TDesC& aBrandId, + TLanguage aLanguageId, + RFile& aFile, + TInt aReserved ) + { + TRACE( T_LIT( "CBSStorageManager::BrandHandleL begin AppId[%S],BrandId[%S]"),&aAppId, &aBrandId ); + TBuf langBuf; + if (aLanguageId >= 100) + User::LeaveIfError( KErrNotFound ); + if( aLanguageId < 10 ) + { + // we want two digit languageid + langBuf.AppendNum( KLeadingZero ); + } + langBuf.AppendNum( aLanguageId ); + + TInt length = aAppId.Length() + aBrandId.Length() + + KDefFileName().Length() + KDirSeparator().Length() * 2 + + langBuf.Length(); + + HBufC* fileName = HBufC::NewLC( length ); + + TPtr filePtr( fileName->Des() ); + + // [application_id]\[brand_id]\[def_filename][language_id] + // + filePtr.Append( aAppId ); + filePtr.Append( KDirSeparator ); + filePtr.Append( aBrandId ); + filePtr.Append( KDirSeparator ); + + TPtrC directory; + directory.Set( filePtr.Left( filePtr.Length() ) ); + + filePtr.Append( KDefFileName ); + filePtr.Append( langBuf ); + + HBufC* fullname = FullFileNameLC( filePtr ); + + RFile handle; + + TBool versioned = EFalse; + + TParse findname; + iFs.Parse( *fullname, findname ); + + TFileName fullPtr = fullname->Des(); + + + // seems like nearestlanguagefile is only + // searching from z-drive by default, unless + // some other drive is explicitely defined + // for that reason we first try from + // default drive and then force c-drive if + // not found. + BaflUtils::NearestLanguageFile( iFs, fullPtr ); + + TInt currentVersion = 0; + TRAPD( err, currentVersion = ReadVersionL( fullPtr ) ); + if( ( err == KErrNotFound ) || ( err == KErrPathNotFound ) ) + { + // not found, we try forcing c-drive + HBufC* driveForced = FullFileNameLC( filePtr, ETrue ); + TFileName forcedPtr = driveForced->Des(); + BaflUtils::NearestLanguageFile( iFs, forcedPtr ); + TRAP( err, currentVersion = ReadVersionL( forcedPtr ) ); + + if( err == KErrPathNotFound ) + { + // switching the error code to be more clear + err = KErrNotFound; + } + User::LeaveIfError( err ); + + // this file was found, we can use this + CleanupStack::Pop( driveForced ); + CleanupStack::PopAndDestroy( fullname ); + fullname = driveForced; + CleanupStack::PushL( fullname ); + } + else + { + User::LeaveIfError( err ); + } + err = KErrNone; + if( currentVersion != aReserved ) + { + // not the base version, check if we have a versioned file for this + HBufC* versionedName = ConstructFileNameL( aAppId, aBrandId, + aLanguageId, aReserved ); + CleanupStack::PushL( versionedName ); + HBufC* fullVersionedName = FullFileNameLC( *versionedName, ETrue ); + + err = handle.Open( iFs, *fullVersionedName, EFileShareAny ); + CleanupStack::Pop( fullVersionedName ); + CleanupStack::PopAndDestroy( versionedName ); + CleanupStack::PopAndDestroy( fullname ); + fullname = fullVersionedName; + CleanupStack::PushL( fullname ); + versioned = ETrue; + } + else + { + err = handle.Open( iFs, *fullname, EFileShareAny ); + } + + if( err == KErrBadName ) + { + // change bad name to not found + err = KErrNotFound; + } + User::LeaveIfError( err ); + + aFile = handle; + + if( iSession ) + { + CBSServer* server = iSession->Server(); + if( server ) + { + server->RegisterFileForSessionL( iSession, *fullname, versioned ); + } + } + + CleanupStack::PopAndDestroy( 2, fileName ); // fullname, fileName + TRACE( T_LIT( "CBSStorageManager::BrandHandleL end") ); + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::FileElementHandleL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::FileElementHandleL( const TDesC& aAppId, + const TDesC& aBrandId, + const TDesC& aFileName, + const TDesC& aLanguageBuf, + RFile& aFile ) + { + TRACE( T_LIT( "CBSStorageManager::FileElementHandleL begin AppId[%S],BrandId[%S],Filename[%S]"),&aAppId, &aBrandId, &aFileName ); +// Modified file name format: "r[n].filename.ext", +// where "n" is the language code. +// Format used to be "filename.ext.r[n]". + HBufC* internalFn = HBufC::NewLC( aFileName.Length() + + KBSFileLangSuffix().Length() + + aLanguageBuf.Length() + + KDot().Length() ); + TPtr pInternalFn( internalFn->Des() ); + pInternalFn.Append( KBSFileLangSuffix() ); + pInternalFn.Append( aLanguageBuf ); + pInternalFn.Append( KDot() ); + pInternalFn.Append( aFileName ); + + TInt length = aAppId.Length() + + aBrandId.Length() + + pInternalFn.Length() + + ( KDirSeparator().Length() * 3 ) + + KFileElementStore().Length(); + + HBufC* fileName = HBufC::NewL( length ); // replaced NewLC with NewL + + TPtr filePtr( fileName->Des() ); + + // [application_id]\[brand_id]\files\[aFilename] + // + filePtr.Append( aAppId ); + filePtr.Append( KDirSeparator ); + filePtr.Append( aBrandId ); + filePtr.Append( KDirSeparator ); + filePtr.Append( KFileElementStore ); + filePtr.Append( KDirSeparator ); + filePtr.Append( pInternalFn ); + + CleanupStack::PopAndDestroy( internalFn ); + internalFn = NULL; + pInternalFn.Set( 0, 0, 0 ); + + CleanupStack::PushL( fileName ); + HBufC* fullname = FullFileNameLC( filePtr ); + +// Make a TPtr instead of TFileName because after mod, "fullPtr" +// does not need to be passed to BaflUtils::NearestLanguageFile() +// old implementation: TFileName fullPtr = fullname->Des(); + TPtr fullPtr( fullname->Des() ); + + +// A few thoughts about language suffix of files: +// NOTE: NOT about brand file (e.g. "brandfile.bin.r99" ), +// but about other files which belong to the branding package, +// since language suffix added by branding server to a +// mif-file is not acceptable later when calling +// AknIconUtils::CreateIconLC() on the mif-file. +// Skipped call to BaflUtils::NearestLanguageFile() because "XSP MOD" +// moves language code from suffix to prefix. +// NearestLanguageFile()-call could be replaced by an op where +// manager seeks a file only from c and z, or from all drives, +// but does so only for file matching to current or requested +// language. Meaning will not try to get the nearest language +// file but the matching one. +// If nearest language file is actually needed, then +// manager could for example implement a seek-function similar to +// BaflUtils::NearestLanguageFile(), but with the difference that +// it will inspect file prefix instead of suffix. + + + RFile handle; +// RFs::ShareProtected() needs to be called for the Fs-session +// used to open the handle that is about to be shared. +// ShareProtected() was called to a wrong Fs session in +// CBSBrandHandler::GetFileL()! + TInt err = handle.Open( iFs, fullPtr, EFileShareReadersOnly ); + if( err == KErrPathNotFound ) + { + // not found, we try forcing c-drive + HBufC* driveForced = FullFileNameLC( filePtr, ETrue ); + + TFileName forcedPtr = driveForced->Des(); + + + err = handle.Open( iFs, forcedPtr, EFileShareReadersOnly ); + User::LeaveIfError( err ); + // this file was found, we can use this + CleanupStack::Pop( driveForced ); + CleanupStack::PopAndDestroy( fullname ); + fullname = driveForced; + CleanupStack::PushL( fullname ); + } + else + { + User::LeaveIfError( err ); + } + + CleanupStack::PopAndDestroy( 2, fileName ); // fullname, fileName + aFile = handle; + TRACE( T_LIT( "CBSStorageManager::FileElementHandleL end") ); + } + + +// --------------------------------------------------------------------------- +// CBSStorageManager::FullFileNameLC +// --------------------------------------------------------------------------- +// +HBufC* CBSStorageManager::FullFileNameLC( const TDesC& aFilename, TBool aForceCDrive /*= EFalse*/ ) + { + // get the private path + TBuf path; + User::LeaveIfError( iFs.PrivatePath( path ) ); + + // construct absolute filename + HBufC* fullname = HBufC::NewLC( KBSCDrive().Length() + aFilename.Length() + path.Length() + + KBSDataStore().Length() + KDirSeparator().Length() ); + TPtr fullPtr( fullname->Des() ); + fullPtr.Append( KBSCDrive ); + fullPtr.Append( path ); + fullPtr.Append( KBSDataStore ); + fullPtr.Append( KDirSeparator ); + fullPtr.Append( aFilename ); + + TParse filename; + iFs.Parse( fullPtr, filename ); + + if( !aForceCDrive ) + { + // C-drive not explicitely requested + if( !BaflUtils::FileExists( iFs, fullPtr ) ) + { + // the file does not exist in C-drive, so + // we have to return a path to Z-drive + fullPtr.Zero(); + fullPtr.Append( KBSZDrive ); + fullPtr.Append( path ); + fullPtr.Append( KBSDataStore ); + fullPtr.Append( KDirSeparator ); + fullPtr.Append( aFilename ); + } + } + + return fullname; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::CleanupFileL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::CleanupFileL( const TDesC& aFileName ) + { + TRACE( T_LIT( "CBSStorageManager::CleanupFileL begin") ); + // we have a versioned file we need to clean up + // get the file name without the version information + if( !IsBaseFileL( aFileName) ) + { + // this is not a basefile + // we need to check if basefile should be replaced + // with this one + TPtrC baseFile = FilenameWithoutVersion( aFileName ); + TInt version = ReadVersionL( aFileName ); + TInt baseVersion = ReadVersionL( baseFile ); + if( version > baseVersion ) + { + // newer version --> replace basefile + TInt err = iFs.Replace( aFileName, baseFile); + User::LeaveIfError( err ); + } + else + { + // same or older version --> delete + TInt err = iFs.Delete( aFileName ); + User::LeaveIfError( err ); + } + } + else + { + // this is a basefile + // we need to check if there are any newer versioned files + // that are not in use + + TParse filename; + iFs.Parse( aFileName, filename ); + TPtrC driveAndPath = filename.DriveAndPath(); + + HBufC* nameWithDrive = HBufC::NewLC( aFileName.Length() + KBSCDrive().Length() ); + TPtr nameWithDrivePtr = nameWithDrive->Des(); + + nameWithDrivePtr.Append( aFileName ); + + CDir* files = NULL; + CDir* directories = NULL; + + User::LeaveIfError( iFs.GetDir( driveAndPath, KEntryAttNormal, ESortByName, files, directories ) ); + + TInt count = files->Count(); + for( TInt i = 0; i < count; i++ ) + { + const TEntry file = (*files)[ i ]; + TBufC name = file.iName; + + HBufC* fullName = HBufC::NewLC( driveAndPath.Length() + name.Length() ); + TPtr fullPtr = fullName->Des(); + + fullPtr.Append( driveAndPath ); + fullPtr.Append( name ); + + TPtrC strippedName = FilenameWithoutVersion( *fullName ); + + if( 0 == strippedName.Compare( nameWithDrivePtr ) ) + { + // there is a versioned file, that might be newer + // than the basefile + TInt baseVersion = ReadVersionL( nameWithDrivePtr ); + + TInt versionedVersion = ReadVersionL( fullPtr ); + if( versionedVersion > baseVersion ) + { + // versioned file newer than base file + // check if the versioned file is still in use + if( !iSession->Server()->FileStillInUse( iSession, fullPtr ) ) + { + // the file is not in use, we can replace the basefile + // with the versioned file + TInt err = iFs.Replace( fullPtr, nameWithDrivePtr ); + User::LeaveIfError( err ); + } + } + } + CleanupStack::PopAndDestroy( fullName ); + } + CleanupStack::PopAndDestroy( nameWithDrive ); + } + TRACE( T_LIT( "CBSStorageManager::CleanupFileL end") ); + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::FilenameWithoutVersionL +// --------------------------------------------------------------------------- +// +TPtrC CBSStorageManager::FilenameWithoutVersion( const TDesC& aFileName ) + { + TParse filename; + iFs.Parse( aFileName, filename ); + TPtrC extension = filename.Ext(); + TPtrC strippedName = aFileName.Left( aFileName.Length() - ( extension.Length() ) ); + return strippedName; + } + + +// --------------------------------------------------------------------------- +// CBSStorageManager::IsBaseFileL +// --------------------------------------------------------------------------- +// +TBool CBSStorageManager::IsBaseFileL( const TDesC& aFileName ) + { + TBool returnValue = ETrue; + TPtrC fileName = FilenameWithoutVersion( aFileName ); + if( BaflUtils::FileExists( iFs, fileName ) ) + { + // file with one extension stripped out exists + // --> the file was not a base file + returnValue = EFalse; + } + return returnValue; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::InstallFile +// --------------------------------------------------------------------------- +// +HBufC* CBSStorageManager::InstallFileLC( const TDesC& aFileName ) + { + TRACE( T_LIT( "CBSStorageManager::InstallFileLC begin") ); + if( !iAppId || !iBrandId ) + { + User::Leave( KErrNotReady ); + } + TParse filename; + iFs.Parse( aFileName, filename ); + + TInt length = iAppId->Length() + iBrandId->Length() + + aFileName.Length() + KDirSeparator().Length() * 3 + + KFileElementStore().Length() + iLanguageId->Length() + + KDot().Length() + KBSFileLangSuffix().Length(); + + HBufC* fileName = HBufC::NewLC( length ); + + TPtr filePtr( fileName->Des() ); + + filePtr.Append( *iAppId ); + filePtr.Append( KDirSeparator ); + filePtr.Append( *iBrandId ); + filePtr.Append( KDirSeparator ); + filePtr.Append( KFileElementStore ); + filePtr.Append( KDirSeparator ); + filePtr.Append( KBSFileLangSuffix() ); + filePtr.Append( *iLanguageId ); + filePtr.Append( KDot() ); + filePtr.Append( filename.NameAndExt() ); + + HBufC* fullname = FullFileNameLC( filePtr, ETrue ); + + TParse directory; + iFs.Parse( *fullname, directory ); + TPtrC ptr = directory.DriveAndPath(); + TInt dirError = iFs.MkDirAll( directory.DriveAndPath() ); + if( dirError == KErrAlreadyExists ) + { + // ignore already exists + dirError = KErrNone; + } + User::LeaveIfError( dirError ); + + CFileMan* fileMan = CFileMan::NewL( iFs ); + CleanupStack::PushL( fileMan ); + + // copy the file, no overwriting + TInt err = fileMan->Copy( aFileName, *fullname, 1 ); + User::LeaveIfError( err ); + +#ifdef __WINSCW__ + // Add to IBY file + iWriter->SetFileItemL( *fullname, *fullname ); +#endif + + CleanupStack::PopAndDestroy( 3, fileName ); // fileMan, fullname, fileName + + + HBufC* returnValue = filename.NameAndExt().AllocLC(); + TRACE( T_LIT( "CBSStorageManager::InstallFileLC end") ); + return returnValue; + } + + +// --------------------------------------------------------------------------- +// CBSStorageManager::RemoveBrandL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::RemoveBrandL( const TDesC& aAppId, + const TDesC& aBrandId, + TLanguage aLanguageId, + TInt aReserved ) + { + TRACE( T_LIT( "CBSStorageManager::RemoveBrandL begin") ); + HBufC* fileName = ConstructFileNameL( aAppId, + aBrandId, + aLanguageId, + aReserved ); + CleanupStack::PushL( fileName ); + + HBufC* fullname = FullFileNameLC( *fileName, ETrue ); + + TParse parseName; + iFs.Parse( *fullname, parseName ); + + TPtrC directory = parseName.DriveAndPath(); + + CFileMan* fileMan = CFileMan::NewL( iFs ); + CleanupStack::PushL( fileMan ); + + // delete all files under this brand and language + TInt err = fileMan->RmDir( directory ); + TRACE( T_LIT( "CBSStorageManager::RemoveBrandL dir='%S' err=%d "), &directory, err ); + + //in case the removal of the entire brand failed because the brand was + //in use, we set this brand as discarded (since parts of the package + //might have been removed) + if ( KErrInUse == err ) + { + MarkBrandAsDiscardedL( aAppId, aBrandId ); + } + + User::LeaveIfError( err ); + + CleanupStack::PopAndDestroy( 3, fileName ); + TRACE( T_LIT( "CBSStorageManager::RemoveBrandL end ") ); + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::RemoveApplicationL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::RemoveApplicationL( const TDesC& aAppId ) + { + TRACE( T_LIT( "CBSStorageManager::RemoveApplicationL begin") ); + TInt length = aAppId.Length() + + KDefFileName().Length() + KDirSeparator().Length(); + + + HBufC* fileName = HBufC::NewLC( length ); + + TPtr file( fileName->Des() ); + + file.Append( aAppId ); + file.Append( KDirSeparator ); + + HBufC* fullName = FullFileNameLC( *fileName, ETrue ); + + CFileMan* fileMan = CFileMan::NewL( iFs ); + CleanupStack::PushL( fileMan ); + + // delete all files under this brand and language + TInt err = fileMan->RmDir( *fullName ); + User::LeaveIfError( err ); + + CleanupStack::PopAndDestroy( 3, fileName ); + TRACE( T_LIT( "CBSStorageManager::RemoveApplicationL end") ); + } + + +// --------------------------------------------------------------------------- +// CBSStorageManager::NextAvailableVersionL +// --------------------------------------------------------------------------- +// +TInt CBSStorageManager::NextAvailableVersionL() + { + TRACE( T_LIT( "CBSStorageManager::NextAvailableVersionL begin") ); + TInt returnValue = 0; + + if( iAppId && iBrandId ) + { + TInt newVersion = 0; + TRAPD( err, newVersion = GetNewestVersionL( *iAppId, *iBrandId, iLanguageIdNum ) ); + if( err == KErrNotFound ) + { + // ignore not found -> we default to 1 + err = KErrNone; + returnValue = iReserved; + } + else + { + returnValue = newVersion + 1; + } + User::LeaveIfError( err ); + } + TRACE( T_LIT( "CBSStorageManager::NextAvailableVersionL end") ); + return returnValue; + } + + +// --------------------------------------------------------------------------- +// CBSStorageManager::NextAvailableVersionL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::SetVersion( TInt aReserved ) + { + iReserved = aReserved; + } + + +// --------------------------------------------------------------------------- +// CBSStorageManager::GetCurrentVersionL +// --------------------------------------------------------------------------- +// +TInt CBSStorageManager::GetNewestVersionL( const TDesC& aAppId, + const TDesC& aBrandId, + TLanguage aLanguageId, + TPtr* aDrive /*= KNullDesC()*/ ) + { + TRACE( T_LIT( "CBSStorageManager::GetNewestVersionL begin") ); + HBufC* fileName = ConstructFileNameL( aAppId, aBrandId, aLanguageId ); + CleanupStack::PushL( fileName ); + + + // FullFileNameLC returns the file from C-drive if it exists there + // and if not, then from ROM + HBufC* fullFileName = FullFileNameLC( *fileName ); + + TParse parse; + iFs.Parse( *fullFileName, parse ); + TPtrC driveAndPath = parse.DriveAndPath(); + + CDir* files = NULL; + CDir* directories = NULL; + + TInt err = iFs.GetDir( driveAndPath, KEntryAttNormal, ESortByName, files, directories ); + if(KErrNone == err ) + { + if(aDrive) + { + (*aDrive).Copy(KBSZDrive); + } + + } + if( err == KErrPathNotFound ) + { + // not found from Z-drive, try from C-drive + CleanupStack::PopAndDestroy( fullFileName ); + fullFileName = FullFileNameLC( *fileName, ETrue ); + driveAndPath.Set( parse.DriveAndPath() ); + err = iFs.GetDir( driveAndPath, KEntryAttNormal, ESortByName, files, directories ); + if(KErrNone == err ) + { + if(aDrive) + { + (*aDrive).Copy(KBSCDrive); + } + } + if( err == KErrPathNotFound ) + { + // switching error code to make it more clear + err = KErrNotFound; + } + // as we are leaving here cleanup the stack + CleanupStack::PopAndDestroy( 2, fileName ); // fullFileName, fileName + User::LeaveIfError( err ); + } + + // get the base file version + TInt returnValue = ReadVersionL( *fullFileName ); + + TInt count = files->Count(); + for( TInt i = 0; i < count; i++ ) + { + const TEntry file = (*files)[ i ]; + TBufC name = file.iName; + + HBufC* fullName = HBufC::NewLC( driveAndPath.Length() + name.Length() ); + TPtr fullPtr = fullName->Des(); + + fullPtr.Append( driveAndPath ); + fullPtr.Append( name ); + + TPtrC strippedName = FilenameWithoutVersion( *fullName ); + + if( 0 == strippedName.Compare( *fullFileName ) ) + { + // there is a versioned file, that might be newer + // than the basefile + TInt versionedVersion = ReadVersionL( fullPtr ); + if( versionedVersion > returnValue ) + { + // versioned file newer than base file + returnValue = versionedVersion; + } + } + CleanupStack::PopAndDestroy( fullName ); + } + + CleanupStack::PopAndDestroy( 2, fileName ); // fullFileName, fileName + + TRACE( T_LIT( "CBSStorageManager::GetNewestVersionL end") ); + return returnValue; + } + + +// --------------------------------------------------------------------------- +// CBSStorageManager::WriteIbyFiles +// --------------------------------------------------------------------------- +// +TInt CBSStorageManager::WriteIbyFiles() + { + TInt err = KErrNone; +#ifdef __WINSCW__ + if( !iWriter ) + { + return KErrNone; + } + + TRAP( err, iWriter->WriteIBYFileL( iFs, *iIbyFile ) ); + delete iIbyFile; + iIbyFile = NULL; + delete iWriter; + iWriter = NULL; + +#endif + return err; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::LockStorage +// --------------------------------------------------------------------------- +// +void CBSStorageManager::LockStorage() + { + TRACE( T_LIT( "CBSStorageManager::LockStorage begin") ); + // This will disable all filehandles, so that clients can't use them + iFs.Close(); + TRACE( T_LIT( "CBSStorageManager::LockStorage end") ); + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::ReleaseLockL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::ReleaseLockL() + { + TRACE( T_LIT( "CBSStorageManager::ReleaseLockL begin") ); + User::LeaveIfError( iFs.Connect() ); + TRACE( T_LIT( "CBSStorageManager::ReleaseLockL end") ); + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::CheckBrandDiscarded +// --------------------------------------------------------------------------- +// +TBool CBSStorageManager::CheckBrandDiscarded(const TDesC& aAppId, + const TDesC& aBrandId) +{ + TBool flag = EFalse ; + + HBufC *fileName = ConstructDiscardBrandFileNameL(aAppId, aBrandId) ; + CleanupStack::PushL(fileName); + HBufC *fullPath = FullDiscardBrandFileNameLC( *fileName ) ; + + // crate a flag file + RFile file; + TInt err = file.Open(iFs, *fullPath, EFileWrite); + if(err == KErrNone) + { + // file exists. + file.Close() ; + flag = ETrue ; + } + + CleanupStack::PopAndDestroy(fullPath) ; + CleanupStack::PopAndDestroy(fileName) ; + return flag ; +} + +// --------------------------------------------------------------------------- +// CBSStorageManager::ConstructDiscardBrandFileNameL +// --------------------------------------------------------------------------- +// +HBufC* CBSStorageManager::ConstructDiscardBrandFileNameL( const TDesC& aAppId, + const TDesC& aBrandId ) + { + HBufC* fileName = NULL; + + TInt length = aAppId.Length() + aBrandId.Length() + + KDiscardBrandFileName().Length() + KDirSeparator().Length() * 2 ; + fileName = HBufC::NewLC( length ); + + TPtr file( fileName->Des() ); + + // [application_id]\[brand_id]\discardedbrand.txt + file.Append( aAppId ); + file.Append( KDirSeparator ); + file.Append( aBrandId ); + file.Append( KDirSeparator ); + file.Append( KDiscardBrandFileName ); + + if( fileName ) + { + CleanupStack::Pop( fileName ); + } + + return fileName; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::FullDiscardBrandFileNameLC +// --------------------------------------------------------------------------- +// +HBufC* CBSStorageManager::FullDiscardBrandFileNameLC( TDesC& aFilename ) + { + // get the private path + TBuf path; + RFs fs ; + User::LeaveIfError( fs.Connect() ); + CleanupClosePushL(fs); + User::LeaveIfError( fs.PrivatePath( path ) ); + + // construct absolute filename + HBufC* fullname = HBufC::NewLC( KBSCDrive().Length() + aFilename.Length() + path.Length() + + KBSDataStore().Length() + KDirSeparator().Length() ); + TPtr fullPtr( fullname->Des() ); + fullPtr.Append( KBSCDrive ); + fullPtr.Append( path ); + fullPtr.Append( KBSDataStore ); + fullPtr.Append( KDirSeparator ); + fullPtr.Append( aFilename ); + + CleanupStack::Pop(); // fullname + CleanupStack::PopAndDestroy() ; //fs + CleanupStack::PushL(fullname) ; + + return fullname; + } + +// --------------------------------------------------------------------------- +// CBSStorageManager::MarkBrandAsDiscardedL +// --------------------------------------------------------------------------- +// +void CBSStorageManager::MarkBrandAsDiscardedL( const TDesC& aAppId, + const TDesC& aBrandId ) + { + TRACE( T_LIT( "CBSStorageManager::MarkBrandAsDiscardedL begin app='%S' brand='%S'"), &aAppId, &aBrandId ); + + HBufC *fileName = ConstructDiscardBrandFileNameL( aAppId, aBrandId ) ; + CleanupStack::PushL( fileName ); + HBufC *fullPath = FullDiscardBrandFileNameLC( *fileName ) ; + TRACE( T_LIT( "CBSStorageManager::MarkBrandAsDiscardedL discardedfile='%S'"), &fullPath ); + + // create flag file + RFile file; + TInt err = file.Replace( iFs, *fullPath, EFileWrite ); + TRACE( T_LIT( "CBSStorageManager::MarkBrandAsDiscardedL discarded file creation result='%d'"), err ); + file.Close(); + + CleanupStack::PopAndDestroy( fullPath ); + fullPath = NULL; + CleanupStack::PopAndDestroy( fileName ); + fileName = NULL; + + TRACE( T_LIT( "CBSStorageManager::MarkBrandAsDiscardedL begin") ); + } + +// End of file diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BSServer/cbsstoragemanager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BSServer/cbsstoragemanager.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,226 @@ +/* +* Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Storage handler +* +*/ + + + +#ifndef CBSSTORAGEMANAGER_H +#define CBSSTORAGEMANAGER_H + +#include +#include + +class CBSSession; +class CBSIBYWriter; +class MBSElement; +class CBSStorage; +class RWriteStream; + + +/** + * Storage handler + * + * @lib .exe + * @since S60 v3.2 + */ +class CBSStorageManager : public CBase +{ +public: + + static CBSStorageManager* NewL( CBSSession* aSession, const TDesC& aAppId ); + + static CBSStorageManager* NewLC( CBSSession* aSession, const TDesC& aAppId ); + + ~CBSStorageManager(); + + + /** + * Initializes the transaction to the + * storagemanager + * + * @since S60 3.2 + * @return none + */ + void ConnectTransactionL(const TDesC& aAppId, + const TDesC& aBrandId, + TLanguage aLanguageId, + TBool aAppending = EFalse, + TInt aReserved = 0 ); + + + /** + * Create a new storage and set it to current. + * + * @since S60 3.2 + * @return none + */ + void CreateStorageL(); + + /** + * Return the count of storages + * + * @since S60 3.2 + * @return count of elements + */ + TInt StorageCount(); + + /** + * Get stored storage at index or current storage. + * + * @since S60 3.2 + * @param aIndex index of storage to fetch. + * @return Stored storage + */ + CBSStorage* Storage( TInt aIndex ); + CBSStorage* Storage(); + + /** + * Externalize storage files into file system + * + * @since S60 3.2 + * @param aFs filesystem handle + * @param aBaseDir Base directory for writing + * @return the new brand version + */ + TInt WriteStorageFilesL(); + + void CancelTransactionL(); + + void BrandHandleL( const TDesC& aAppId, + const TDesC& aBrandId, + TLanguage aLanguageId, + RFile& aFile, + TInt aReserved ); + + void FileElementHandleL( const TDesC& aAppId, + const TDesC& aBrandId, + const TDesC& aFileName, + const TDesC& aLanguageBuf, + RFile& aFile ); + + void CleanupFileL( const TDesC& aFileName ); + + TPtrC FilenameWithoutVersion( const TDesC& aFileName ); + + /** + * Externalize storage files into file system + * + * @since S60 3.2 + * @param aFileName the name of the installed file + * including path + * @return the filename without path component + */ + HBufC* InstallFileLC( const TDesC& aFileName ); + + void RemoveBrandL( const TDesC& aAppId, + const TDesC& aBrandId, + TLanguage aLanguageId, + TInt aReserved = 0); + + void RemoveApplicationL( const TDesC& aAppId ); + + TInt NextAvailableVersionL(); + void SetVersion( TInt aVersionId ); + + TInt GetNewestVersionL( const TDesC& aAppId, + const TDesC& aBrandId, + TLanguage aLanguageId, + TPtr* aDrive = NULL); + TInt WriteIbyFiles(); + + void LockStorage(); + + void ReleaseLockL(); + + TBool CheckBrandDiscarded(const TDesC& aAppId, + const TDesC& aBrandId) ; + static HBufC* ConstructDiscardBrandFileNameL( const TDesC& aAppId, + const TDesC& aBrandId ); + + static HBufC* FullDiscardBrandFileNameLC( TDesC& aFilename ) ; + + TInt isActualBrandInstalledL ( const TDesC& aAppId, const TDesC& aBrandId, TLanguage aLanguage); +private: + + CBSStorageManager(); + + void ConstructL( CBSSession* aSession, const TDesC& aAppId ); + + HBufC* ConstructFileNameL( TInt aVersion = 0 ); + + HBufC* ConstructFileNameL( const TDesC& aAppId, + const TDesC& aBrandId, + TLanguage aLanguage, + TInt aReserved = 0 ); + + void CleanupTransaction(); + + HBufC* FullFileNameLC( const TDesC& aFilename, TBool aForceCDrive = EFalse ); + + TInt ReadVersionL( const TDesC& aFilename ); + + HBufC* FindAvailableVersionL( TInt aCurrentVersion, TInt& aNewVersion ); + + TBool IsBaseFileL( const TDesC& aFileName ); + + + /** + * Mark a brand package as discarded. Future attempts to create an + * access to this brand package will fail. + * + * @since S60 3.2 + * @param aAppId a application id + * @param aBrandId a brand id + */ + void MarkBrandAsDiscardedL( const TDesC& aAppId, + const TDesC& aBrandId ); + +private: // Data + + // Own. Array of stored storages. + RPointerArray iStorages; + + // Index of currently active storage + TInt iCurrent; + + // IBY writer + CBSIBYWriter* iWriter; + + RFs iFs; + TBool iActive; + + HBufC* iAppId; + HBufC* iBrandId; + HBufC* iLanguageId; + TLanguage iLanguageIdNum; + + // Own. Proposed file name + HBufC* iFilename; + + // Proposed directory (points to iFilename) + TPtrC iDir; + + // doesn't own: the server + CBSSession* iSession; + + TBool iAppending; + + HBufC* iIbyFile; + TInt iReserved; + +}; + +#endif //CBSSTORAGEMANAGER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/BWINS/bsclientU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/BWINS/bsclientU.DEF Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,21 @@ +EXPORTS + ??1CBSBitmap@@UAE@XZ @ 1 NONAME ; CBSBitmap::~CBSBitmap(void) + ??1CBSFactory@@UAE@XZ @ 2 NONAME ; CBSFactory::~CBSFactory(void) + ?BitmapFileId@CBSBitmap@@QBEABVTDesC8@@XZ @ 3 NONAME ; class TDesC8 const & CBSBitmap::BitmapFileId(void) const + ?BitmapId@CBSBitmap@@QBEHXZ @ 4 NONAME ; int CBSBitmap::BitmapId(void) const + ?BitmapMaskId@CBSBitmap@@QBEHXZ @ 5 NONAME ; int CBSBitmap::BitmapMaskId(void) const + ?CreateAccessL@CBSFactory@@QAEPAVMBSAccess@@ABVTDesC8@@W4TLanguage@@HH@Z @ 6 NONAME ; class MBSAccess * CBSFactory::CreateAccessL(class TDesC8 const &, enum TLanguage, int, int) + ?CreateAccessLC@CBSFactory@@QAEPAVMBSAccess@@ABVTDesC8@@W4TLanguage@@HH@Z @ 7 NONAME ; class MBSAccess * CBSFactory::CreateAccessLC(class TDesC8 const &, enum TLanguage, int, int) + ?CreateBSElementL@BSElementFactory@@SAPAVMBSElement@@ABVTDesC8@@W4TBSElementType@@0@Z @ 8 NONAME ; class MBSElement * BSElementFactory::CreateBSElementL(class TDesC8 const &, enum TBSElementType, class TDesC8 const &) + ?CreateBSElementL@BSElementFactory@@SAPAVMBSElement@@ABVTDesC8@@W4TBSElementType@@AAV?$RBSObjOwningPtrArray@VMBSElement@@@@@Z @ 9 NONAME ; class MBSElement * BSElementFactory::CreateBSElementL(class TDesC8 const &, enum TBSElementType, class RBSObjOwningPtrArray &) + ?CreateBSElementL@BSElementFactory@@SAPAVMBSElement@@ABVTDesC8@@W4TBSElementType@@ABVTDesC16@@@Z @ 10 NONAME ; class MBSElement * BSElementFactory::CreateBSElementL(class TDesC8 const &, enum TBSElementType, class TDesC16 const &) + ?CreateBSElementL@BSElementFactory@@SAPAVMBSElement@@ABVTDesC8@@W4TBSElementType@@H@Z @ 11 NONAME ; class MBSElement * BSElementFactory::CreateBSElementL(class TDesC8 const &, enum TBSElementType, int) + ?CreateBSElementL@BSElementFactory@@SAPAVMBSElement@@ABVTDesC8@@W4TBSElementType@@PAVCBSBitmap@@@Z @ 12 NONAME ; class MBSElement * BSElementFactory::CreateBSElementL(class TDesC8 const &, enum TBSElementType, class CBSBitmap *) + ?CreateUpdaterL@CBSFactory@@QAEPAVMBSUpdater@@XZ @ 13 NONAME ; class MBSUpdater * CBSFactory::CreateUpdaterL(void) + ?CreateUpdaterLC@CBSFactory@@QAEPAVMBSUpdater@@XZ @ 14 NONAME ; class MBSUpdater * CBSFactory::CreateUpdaterLC(void) + ?NewL@CBSBitmap@@SAPAV1@HHHHABVTDesC8@@@Z @ 15 NONAME ; class CBSBitmap * CBSBitmap::NewL(int, int, int, int, class TDesC8 const &) + ?NewL@CBSFactory@@SAPAV1@ABVTDesC8@@0@Z @ 16 NONAME ; class CBSFactory * CBSFactory::NewL(class TDesC8 const &, class TDesC8 const &) + ?NewLC@CBSBitmap@@SAPAV1@HHHHABVTDesC8@@@Z @ 17 NONAME ; class CBSBitmap * CBSBitmap::NewLC(int, int, int, int, class TDesC8 const &) + ?SkinIdMajor@CBSBitmap@@QBEHXZ @ 18 NONAME ; int CBSBitmap::SkinIdMajor(void) const + ?SkinIdMinor@CBSBitmap@@QBEHXZ @ 19 NONAME ; int CBSBitmap::SkinIdMinor(void) const + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/EABI/bsclientU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/EABI/bsclientU.DEF Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,25 @@ +EXPORTS + _ZN10CBSFactory13CreateAccessLERK6TDesC89TLanguageii @ 1 NONAME + _ZN10CBSFactory14CreateAccessLCERK6TDesC89TLanguageii @ 2 NONAME + _ZN10CBSFactory14CreateUpdaterLEv @ 3 NONAME + _ZN10CBSFactory15CreateUpdaterLCEv @ 4 NONAME + _ZN10CBSFactory4NewLERK6TDesC8S2_ @ 5 NONAME + _ZN16BSElementFactory16CreateBSElementLERK6TDesC814TBSElementTypeP9CBSBitmap @ 6 NONAME + _ZN16BSElementFactory16CreateBSElementLERK6TDesC814TBSElementTypeR20RBSObjOwningPtrArrayI10MBSElementE @ 7 NONAME + _ZN16BSElementFactory16CreateBSElementLERK6TDesC814TBSElementTypeRK7TDesC16 @ 8 NONAME + _ZN16BSElementFactory16CreateBSElementLERK6TDesC814TBSElementTypeS2_ @ 9 NONAME + _ZN16BSElementFactory16CreateBSElementLERK6TDesC814TBSElementTypei @ 10 NONAME + _ZN9CBSBitmap4NewLEiiiiRK6TDesC8 @ 11 NONAME + _ZN9CBSBitmap5NewLCEiiiiRK6TDesC8 @ 12 NONAME + _ZNK9CBSBitmap11SkinIdMajorEv @ 13 NONAME + _ZNK9CBSBitmap11SkinIdMinorEv @ 14 NONAME + _ZNK9CBSBitmap12BitmapFileIdEv @ 15 NONAME + _ZNK9CBSBitmap12BitmapMaskIdEv @ 16 NONAME + _ZNK9CBSBitmap8BitmapIdEv @ 17 NONAME + _ZTI10CBSFactory @ 18 NONAME ; ## + _ZTI19CBSIconFileProvider @ 19 NONAME ; ## + _ZTI9RBSClient @ 20 NONAME ; ## + _ZTV10CBSFactory @ 21 NONAME ; ## + _ZTV19CBSIconFileProvider @ 22 NONAME ; ## + _ZTV9RBSClient @ 23 NONAME ; ## + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Group/BSClient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Group/BSClient.mmp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,56 @@ +/* +* 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 the License "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: Branding server client component project descripton file. +* +*/ + +#include "bsuids.h" +#include +#include + +TARGET bsclient.dll +TARGETTYPE dll +UID KStaticInterfaceDllUid2 KBrandingClientUid3 +CAPABILITY CAP_CLIENT_DLL +VENDORID VID_DEFAULT + + +SOURCEPATH ../BSClient +SOURCE cbsclient.cpp +SOURCE bsprocessstarter.cpp +SOURCE cbsfactory.cpp +SOURCE cbsaccess.cpp +SOURCE cbsupdater.cpp +SOURCE cbselement.cpp +SOURCE bselementfactory.cpp +SOURCE cbsbitmap.cpp +SOURCE cbsbrandobserver.cpp +SOURCE cbsiconfileprovider.cpp + + +USERINCLUDE ../Group +USERINCLUDE ../BSServer +USERINCLUDE ../BSClient + +APP_LAYER_SYSTEMINCLUDE + + +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY flogger.lib +LIBRARY estor.lib +LIBRARY AknSkins.lib +LIBRARY aknicon.lib //avkon icons +LIBRARY cone.lib +LIBRARY charconv.lib diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Group/BSServer.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Group/BSServer.mmp Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,68 @@ +/* +* 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 the License "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: Branding server, server comopnent project description file. +* +*/ + +#include "bsuids.h" +#include +#include + +TARGET bsserver.exe +TARGETTYPE exe + + +UID 0x0 KBrandingSrvUid3 +VENDORID VID_DEFAULT +CAPABILITY CAP_SERVER +TARGETPATH /system/libs + + +SOURCEPATH ../BSServer +SOURCE cbsserver.cpp +SOURCE cbssession.cpp +SOURCE cbsbrandhandler.cpp +SOURCE cbsibywriter.cpp +SOURCE cbsstoragemanager.cpp +SOURCE cbsstorage.cpp +SOURCE cbsinstallhandler.cpp +SOURCE cbsbackupobserver.cpp + +SOURCEPATH ../BSClient +SOURCE cbselement.cpp +SOURCE cbsbitmap.cpp +SOURCE bselementfactory.cpp + + + +USERINCLUDE ../Group +USERINCLUDE ../BSServer +USERINCLUDE ../BSClient +USERINCLUDE ../Inc + +APP_LAYER_SYSTEMINCLUDE + + + +LIBRARY euser.lib +LIBRARY flogger.lib +LIBRARY efsrv.lib + +LIBRARY bafl.lib +LIBRARY estor.lib +LIBRARY charconv.lib + +// for install handler +LIBRARY apgrfx.lib +LIBRARY apparc.lib diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Group/DebugTrace.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Group/DebugTrace.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,163 @@ +/* +* 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 the License "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: Debug Traces. +* +*/ + +#ifndef __DEBUGTRACE_H__ +#define __DEBUGTRACE_H__ + +// INCLUDES +#include "e32std.h" + +// DEFINES +//Undefine: tracing disabled +//Define 1: Traces goes to file log +//Define 2: Traces goes to RDebug output +//Define 3: Trace goes both file and RDebug output +#undef TRACE_MODE +//#define TRACE_MODE 3 + + + +// ----------------------------------------------------------------------------- +// Trace definitions +// ----------------------------------------------------------------------------- +#ifdef TRACE_MODE + + // INCLUDES + #include + #include + + // CONSTANTS + _LIT( KTraceLogDir, "BS" ); + _LIT( KTraceLogFile, "BS.log" ); + + //TRACE INDIRECTION + #define T_LIT(s) _L(s) // CSI: 78 # See above + #define TRACE Trace::Emit + #define IF_TRACE_ON( aStatement ) aStatement +#endif // TRACE_MODE + + +//----------------------------------------------------------------------------- +// Empty trace definitions +//----------------------------------------------------------------------------- +#ifndef TRACE_MODE + struct TEmptyTraceString { }; + #define T_LIT(s) TEmptyTraceString() + #define IF_TRACE_ON( aStatement ) + + inline void TRACE(TEmptyTraceString){} + + template + inline void TRACE(TEmptyTraceString,T1){} + + template + inline void TRACE(TEmptyTraceString,T1,T2){} + + template + inline void TRACE(TEmptyTraceString,T1,T2,T3){} + + template + inline void TRACE(TEmptyTraceString,T1,T2,T3,T4){} + + template + inline void TRACE(TEmptyTraceString,T1,T2,T3,T4,T5){} + + template + inline void TRACE(TEmptyTraceString,T1,T2,T3,T4,T5,T6){} + + template + inline void TRACE(TEmptyTraceString,T1,T2,T3,T4,T5,T6,T7){} + + template + inline void TRACE(TEmptyTraceString,T1,T2,T3,T4,T5,T6,T7,T8){} + +#endif // TRACE_MODE + + + + +// ----------------------------------------------------------------------------- +// Trace implementation +// ----------------------------------------------------------------------------- +#ifdef TRACE_MODE + #include + #include + + // TARGET WARNING + #if !defined(_DEBUG) + + #if defined(__CW32__) + #pragma message("Trace logging on.") // CSI: 68 # See above + #else + //ARMCC warning + #endif + #endif + + namespace Trace + { + class TOverflowHandler : public TDes16Overflow + { + inline void Overflow( TDes16& /*aDes*/ ) {} + }; + + inline void Emit( TRefByValue aFmt, ... ) + { + //Format the log line + TBuf< 250 > buffer; + buffer.Append( _L("[") ); // CSI: 78 # See above + buffer.Append( RThread().Name() ); + buffer.Append( _L("] ") ); // CSI: 78 # See above + + TOverflowHandler overflowHandler; + + VA_LIST list; + VA_START( list, aFmt ); + buffer.AppendFormatList( aFmt, list, &overflowHandler ); + + TInt theTraceMode = TRACE_MODE; + + //Send trace to file + if( ( theTraceMode == 1 ) || + ( theTraceMode == 3 ) ) + { + RFileLogger logger; + if( logger.Connect() == KErrNone ) + { + logger.SetDateAndTime( EFalse, ETrue ); + logger.CreateLog( KTraceLogDir, + KTraceLogFile, + EFileLoggingModeAppend ); + + logger.Write( buffer ); + logger.CloseLog(); + logger.Close(); + } + } + + //Send trace to default debug output + if( ( theTraceMode == 2 ) || + ( theTraceMode == 3 ) ) + { + RDebug::Print( _L("%S"), &buffer ); + } + } + } +#endif //TRACE_MODE + +#endif //__DEBUGTRACE_H__ + +// END OF FILE diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Group/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Group/backup_registration.xml Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Group/bld.inf Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,47 @@ +/* +* 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 the License "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: branding server BLD.INF which builds, tools and also server and client. +* +*/ + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +BSClient.mmp +BSServer.mmp +../tools/bsimport/group/importer.mmp +../tools/bsimport/group/installer.mmp + +PRJ_EXPORTS +// Headers exported to source tree +../Inc/cbsfactory.h MW_LAYER_PLATFORM_EXPORT_PATH(cbsfactory.h) +../Inc/mbsaccess.h MW_LAYER_PLATFORM_EXPORT_PATH(mbsaccess.h) +../Inc/mbsupdater.h MW_LAYER_PLATFORM_EXPORT_PATH(mbsupdater.h) +../Inc/mbselement.h MW_LAYER_PLATFORM_EXPORT_PATH(mbselement.h) +../Inc/cbsbitmap.h MW_LAYER_PLATFORM_EXPORT_PATH(cbsbitmap.h) +../Inc/bselementfactory.h MW_LAYER_PLATFORM_EXPORT_PATH(bselementfactory.h) +../Inc/tbselementiterator.h MW_LAYER_PLATFORM_EXPORT_PATH(TBSElementIterator.h) +../Inc/rbsobjowningptrarray.h MW_LAYER_PLATFORM_EXPORT_PATH(RBSObjOwningPtrArray.h) +../Inc/rbsobjowningptrarray.inl MW_LAYER_PLATFORM_EXPORT_PATH(RBSObjOwningPtrArray.inl) +../Inc/mbsbrandchangeobserver.h MW_LAYER_PLATFORM_EXPORT_PATH(mbsbrandchangeobserver.h) +../Inc/mbsbackuprestorestateobserver.h MW_LAYER_PLATFORM_EXPORT_PATH(mbsbackuprestorestateobserver.h) + +../Group/backup_registration.xml z:/private/102828dd/backup_registration.xml + +// Exporting iby file + +../ROM/brandingserver.iby CORE_MW_LAYER_IBY_EXPORT_PATH(brandingserver.iby) \ No newline at end of file diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Group/bsuids.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Group/bsuids.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,35 @@ +/* +* 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 the License "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: BRANDINGSERVER UIDs +* +*/ + +#ifndef __BRANDINGUIDS_H +#define __BRANDINGUIDS_H + +//Uid2:s +#define KStaticInterfaceDllUid2 0x1000008d // CSI: 8 # + + +//Uid3:s +#define KBrandingClientUid3 0x102828DE // CSI: 8 # +#define KBrandingSrvUid3 0x102828DD // CSI: 8 # + + +#endif // __BRANDINGUIDS_H + + +// END OF FILE + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/bselementfactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/bselementfactory.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: bselementfactory.h +* +*/ + + + +#ifndef __BSELEMENTFACTORY_H +#define __BSELEMENTFACTORY_H + +#include +#include + + +class CBSElement; + + +/** + * Factory for creating branding elements + * + * @since + */ +class BSElementFactory + { + public: + + /* + * Create integer type element. + * @param aElementId id of the element + * @param aElementType type of the element + * @param aElementData the element data + */ + IMPORT_C static MBSElement* CreateBSElementL( const TDesC8& aElementId, + TBSElementType aElementType, + TInt aElementData ); + + /* + * Create text or file type element. + * @param aElementId id of the element + * @param aElementType type of the element + * @param aElementData the element data, if the element is file type + * then this should contain the file name + */ + IMPORT_C static MBSElement* CreateBSElementL( const TDesC8& aElementId, + TBSElementType aElementType, + const TDesC& aElementData ); + + /* + * Create buffer type element. + * @param aElementId id of the element + * @param aElementType type of the element + * @param aElementData the element data + */ + IMPORT_C static MBSElement* CreateBSElementL( const TDesC8& aElementId, + TBSElementType aElementType, + const TDesC8& aElementData ); + + /* + * Create bitmap type element. + * @param aElementId id of the element + * @param aElementType type of the element + * @param aElementData the element data + */ + IMPORT_C static MBSElement* CreateBSElementL( const TDesC8& aElementId, + TBSElementType aElementType, + CBSBitmap* aElementData ); + + /* + * Create an element containing a list of other elements. + * @param aElementId id of the element + * @param aElementType type of the element + * @param aElementData the element data + */ + IMPORT_C static MBSElement* CreateBSElementL( const TDesC8& aElementId, + TBSElementType aElementType, + RBSObjOwningPtrArray& aElementData ); + + }; + +#endif //__BSELEMENTFACTORY_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/cbsbitmap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/cbsbitmap.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: cbsbitmap.h +* +*/ + + + + +#ifndef __CBSBITMAP_H__ +#define __CBSBITMAP_H__ + +#include + +/** + * + */ +NONSHARABLE_CLASS( CBSBitmap ): public CBase + { + public: + /** + * Two-phased constructor. + * @param aBitmapId the bitmap id + * @param aBitmapMaskId the bitmap mask id + * @param aSkinId the skin id + * @param aSkinMaskId the skin mask id + * @param aBitmapFileId the bitmap file id + */ + IMPORT_C static CBSBitmap* NewL( TInt aBitmapId, + TInt aBitmapMaskId, + TInt aSkinIdMajor, + TInt aSkinIdMinor, + const TDesC8& aBitmapFileId ); + + /** + * Two-phased constructor. + * @see NewL + */ + IMPORT_C static CBSBitmap* NewLC( TInt aBitmapId, + TInt aBitmapMaskId, + TInt aSkinIdMajor, + TInt aSkinIdMinor, + const TDesC8& aBitmapFileId ); + + // destructor + IMPORT_C virtual ~CBSBitmap(); + + private: + /** + * @see NewL + */ + CBSBitmap( TInt aBitmapId, + TInt aBitmapMaskId, + TInt aSkinIdMajor, + TInt aSkinIdMinor ); + + /** + * @see NewL + */ + void ConstructL( const TDesC8& aBitmapFileId ); + + public: + /** + * Getter for bitmap id + * @return the bitmap id + */ + IMPORT_C TInt BitmapId() const; + + /** + * Getter for bitmap mask id + * @return the bitmap mask id + */ + IMPORT_C TInt BitmapMaskId() const; + + /** + * Getter for skin id + * @return the skin id + */ + IMPORT_C TInt SkinIdMajor() const; + + /** + * Getter for skin mask id + * @return the skin mask id + */ + IMPORT_C TInt SkinIdMinor() const; + + /** + * Getter for bitmap file id + * @return bitmap file id + */ + IMPORT_C const TDesC8& BitmapFileId() const; + + + private: // data + TInt iBitmapId; + TInt iBitmapMaskId; + TInt iSkinIdMajor; + TInt iSkinIdMinor; + HBufC8* iBitmapFileId; + }; + +#endif // __CBSBITMAP_H__ + + +// END OF FILE + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/cbsfactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/cbsfactory.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: cbsfactory.h +* +*/ + + +#ifndef __CBSFACTORY_H +#define __CBSFACTORY_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class MBSAccess; +class MBSUpdater; +class RBSClient; + + +// CLASS DECLARATION + +class CBSFactory : public CBase + { + + public: + + /** + * Two-phased constructor. + * @param aDefaultBrandId the default brand id for branding interfaces + * that are created through this factory. If this parameter + * is given the branding items will be taken from the given + * default brand if they are not found from the wanted brand. + * brand. + * @param aApplicationId application id + */ + IMPORT_C static CBSFactory* NewL( const TDesC8& aDefaultBrandId, + const TDesC8& aApplicationId ); + + // destructor + IMPORT_C virtual ~CBSFactory(); + + private: + + // constructor + CBSFactory(); + + void ConstructL( const TDesC8& aDefaultBrandId, const TDesC8& aApplicationId ); + + + public: + + /** + * Creates a brand access interface + * @param aBrandId the brand to be used with this interface instance + * @param aLanguageId the language id to be used with this interface instance + * @param aCacheData should the interface cache the branding data + * @param aReserved for further use + * @return the access interface + */ + IMPORT_C MBSAccess* CreateAccessL( const TDesC8& aBrandId, + TLanguage aLanguageId, + TBool aCacheData = EFalse, + TInt aReserved = 0 ); + + /** + * Creates a brand access interface + * @param aBrandId the brand to be used with this interface instance + * @param aLanguageId the language id to be used with this interface instance + * @param aCacheData should the interface cache the branding data + * @param aReserved for further use + * @return the access interface + */ + IMPORT_C MBSAccess* CreateAccessLC( const TDesC8& aBrandId, + TLanguage aLanguageId, + TBool aCacheData = EFalse, + TInt aReserved = 0 ); + + /** + * Creates a brand update interface + * @return the interface + */ + IMPORT_C MBSUpdater* CreateUpdaterL(); + + /** + * Creates a brand update interface + * @return the interface + */ + IMPORT_C MBSUpdater* CreateUpdaterLC(); + + + private: // data + HBufC8* iDefaultBrand; + bool iUseDefaultBrand; + HBufC8* iApplicationId; + RBSClient* iServerKeepAlive; + + }; + +#endif // __CBSFACTORY_H + +// End of File diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/mbsaccess.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/mbsaccess.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: MBSAccess +* +*/ + + + + +#ifndef __MBSACCESS_H +#define __MBSACCESS_H + +#include +#include +#include +#include + + +// forward declarations +class MBSBrandChangeObserver; +class MBSBackupRestoreStateObserver; +class CFbsBitmap; + +/** + * An interface for getting branding information + * + * @since + */ +class MBSAccess + { + public: + + /* + * Get text type item + * @param aId ID of the item + * @return the text item + */ + virtual HBufC* GetTextL( const TDesC8& aId ) = 0; + + /* + * Get text type item + * @param aId ID of the item + * @return the text item + */ + virtual HBufC* GetTextLC( const TDesC8& aId ) = 0; + + /* + * Get 8-bit data type item + * @param aId ID of the item + * @return the data buffer item + */ + virtual HBufC8* GetBufferL( const TDesC8& aId ) = 0; + + /* + * Get 8-bit data type item + * @param aId ID of the item + * @return the data buffer item + */ + virtual HBufC8* GetBufferLC( const TDesC8& aId ) = 0; + + /* + * Get integer type item + * @param aId ID of the item + * @return the integer item + */ + virtual TInt GetIntL( const TDesC8& aId ) = 0; + + + /* + * Get an array of items + * @param aIds ID's of the items + * @return the items + */ + virtual MBSElement* GetSeveralL( MDesC8Array& aIds ) = 0; + + + /* + * Get a file item + * @param aId ID of the item + * @param aFile on return will contain an open file handle + * to the file + */ + virtual void GetFileL( const TDesC8& aId, + RFile& aFile ) = 0; + + /* + * Get a structure type item + * @param aIds ID of the item + * @return structure branding element + */ + virtual MBSElement* GetStructureL( const TDesC8& aId ) = 0; + + /* + * Register to observer brand data updates + * @param aObserver the observer interface + */ + virtual void RegisterObserverL( MBSBrandChangeObserver* aObserver, MBSBackupRestoreStateObserver* aBackupObserver ) = 0; + + /* + * Unregister a brand data update observer + * @param aObserver the observer interface + */ + virtual void UnRegisterObserverL( MBSBrandChangeObserver* aObserver, MBSBackupRestoreStateObserver *aBackupObserver ) = 0; + + /* + * Get a bitmap type item. + * Note that this method supports skins, but as skin support + * requires CONE, it will only try to load skin bitmaps if + * CONE is available. Else it will only load normal bitmaps. + * @param aBitmapId the ID of the bitmap item itself + * @param aBitmap on return will contain the bitmap + * @param aMask on return will contain the mask + */ + virtual void GetBitmapL( const TDesC8& aBitmapId, + CFbsBitmap*& aBitmap, + CFbsBitmap*& aMask ) = 0; + + + virtual TInt isBrandUpdateRequiredL () = 0; + /* + * Closes the handle to server and deletes the object. + */ + virtual void Close() = 0; + + protected: + + /* + * Destructor + */ + virtual ~MBSAccess() {}; + }; + +#endif //__MBSACCESS_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/mbsbackupobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/mbsbackupobserver.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: Backup and Restore observer interface +* +*/ + + + +#ifndef __MBSBACKUPOBSERVER_H +#define __MBSBACKUPOBSERVER_H + +#include + +/** + * Observer interface for backup and restore events + * @since S60 v3.2 + */ +NONSHARABLE_CLASS( MBSBackupObserver ) + { + public: + + // Backup and restore states + enum TBackupState + { + EBackupNotActive, + EBackupActive + }; + + /* + * Hanlder method to receive observer events + * @param aEvent new state of backup and restore + */ + virtual void HandleBackupStateL( TBackupState aState ) = 0; + + /* + * Destructor + */ + virtual ~MBSBackupObserver() {}; + }; + +#endif //__MBSBACKUPOBSERVER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/mbsbackuprestorestateobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/mbsbackuprestorestateobserver.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: MBS Backup restore observer definition. +* +*/ + + + + +#ifndef __MBSBACKUPRESTORESTATEOBSERVER_H +#define __MBSBACKUPRESTORESTATEOBSERVER_H + +#include + + +/** + * An interface through which client gets information + * about available brand data updates. + * + * @since + */ +class MBSBackupRestoreStateObserver + { + public: + + /* + * Gets called when backup restore operation begins or ends + * Client can then decide wether to store accessing date or not + * @return ETrue if observer should continue observing + */ + virtual TBool BackupRestoreActivated(TInt activeState) = 0 ; + +protected: + /* + * Destructor + */ + virtual ~MBSBackupRestoreStateObserver() {}; + }; + +#endif //__MBSBACKUPRESTORESTATEOBSERVER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/mbsbrandchangeobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/mbsbrandchangeobserver.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: MBSBrandChangeObserver +* +*/ + + + + +#ifndef __MBSBRANDCHANGEOBSERVER_H +#define __MBSBRANDCHANGEOBSERVER_H + +#include + + +/** + * An interface through which client gets information + * about available brand data updates. + * + * @since + */ +class MBSBrandChangeObserver + { + public: + + /* + * Gets called when brand data update is available. + * Client can then decide wether to use the old one + * or the updated one. + * @return ETrue if observer should continue observing + */ + virtual TBool BrandUpdateAvailable( TInt aNewVersion ) = 0; + + +protected: + /* + * Destructor + */ + virtual ~MBSBrandChangeObserver() {}; + }; + +#endif //__MBSBRANDCHANGEOBSERVER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/mbselement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/mbselement.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,128 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: MBSElement.h +* +*/ + + + +#ifndef __MBSELEMENT_H +#define __MBSELEMENT_H + +#include +#include + +enum TBSElementType + { + EBSInt, + EBSText, + EBSList, + EBSBuffer, + EBSBitmap, + EBSFile + }; + +/** + * Class encapsulating the structure type branding items + * + * @since + */ + +class RWriteStream; +class CBSBitmap; + +NONSHARABLE_CLASS( MBSElement ) + { + + public: + + /* + * Element type + * @return the element type + */ + virtual TBSElementType ElementType() = 0; + + /* + * Element id + * @return the element id + */ + virtual const TDesC8& ElementId() = 0; + + /* + * Integer data + * Panics if trying to get wrong type data. + * @return the integer data of the item + */ + virtual TInt IntDataL() = 0; + + /* + * Text data + * Panics if trying to get wrong type data. + * @return the text data of the item + */ + virtual const TDesC& TextDataL() = 0; + + /* + * 8-bit buffer data + * Panics if trying to get wrong type data. + * @return the text data of the item + */ + virtual const TDesC8& BufferDataL() = 0; + + /* + * Bitmap data + * Panics if trying to get wrong type data. + * @return the text data of the item + */ + virtual const CBSBitmap& BitmapDataL() = 0; + + /* + * Structure data + * Panics if trying to get wrong type data. + * @return the list data + */ + virtual TArray GetStructureL() = 0; + + /* + * Finds the first entry from the list of a list type element with + * the given element id. Note that if there are several subelements + * with the same elementId then TBrandingElementIterator should be + * used to iterate through them. + * @param aElementId elementId of the subelement to be found. + * @return the subelement + */ + virtual const MBSElement& FindSubEntryL( const TDesC& aElementId ) = 0; + + /* + * Writes the internal state to stream. + * @param aWriteStream output stream; + */ + virtual void ExternalizeL( RWriteStream& aWriteStream ) = 0; + + /* + * Deletes the element. + */ + virtual void Close() = 0; + + /* + * Destructor + */ + virtual ~MBSElement() {}; + + }; + + + + +#endif //__MBSELEMENT_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/mbsupdater.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/mbsupdater.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,245 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: MBSUpdater + * +*/ + + + + + #ifndef __MBSUPDATER_H + #define __MBSUPDATER_H + + #include + #include + +class MBSBackupRestoreStateObserver ; + +const TInt KBSAutomaticVersionUpdate = -1; + + /** + * An interface for updating branding information + * + * @since + */ + class MBSUpdater + { + public: + + enum TUpdateTransactionType + { + EUpdateInstall = 1, + EUpdateAppend, + EUpdateReplace, + EUpdateUninstall + }; + + //*** TRANSACTION HANDLING ***// + + /* + * Start transaction for installing a brand. + * @param aApplicationId id of the application + * @param aBrandId id of the brand + * @param aLanguageId languageid of the brand + * @param aReserved for further use + */ + virtual void StartTransactionL( const TDesC8& aBrandId, + TLanguage aLanguageId, + TUpdateTransactionType aType = EUpdateInstall, + TInt aReserved = 0 ) = 0; + + /* + * Stop brand installation transaction. + * Calling this will indicate that the brand has + * been updated completely and it will be taken + * into use. + * @return new version of the installed/updated brand + */ + virtual TInt StopTransactionL() = 0; + + /* + * Cancels brand installation transaction. + * All the elements updated in this transaction + * will be discarded. + */ + virtual void CancelTransactionL() = 0; + + + //*** BRAND REMOVING ***// + + /* + * Removes all brand data from the specified brand. + */ + virtual void RemoveBrandL( const TDesC8& aApplicationId, + const TDesC8& aBrandId ) = 0; + + /* + * Removes all brand data from the specified application. + */ + virtual void RemoveBrandsL( const TDesC8& aApplicationId ) = 0; + + + //*** BRAND INSTALLING ***// + + + /* + * Insert text type item into the new brand + * @param aId ID of the item + * @param aText the text item + */ + virtual void InsertTextL( const TDesC8& aId, const TDesC& aText ) = 0; + + /* + * Insert 8-bit data type item into the new brand + * @param aId ID of the item + * @param aBuffer the data item + */ + virtual void InsertBufferL( const TDesC8& aId, const TDesC8& aBuffer ) = 0; + + /* + * Insert integer type item into the new brand + * @param aId ID of the item + * @param aInt the integer item + */ + virtual void InsertIntL( const TDesC8& aId, TInt aInt ) = 0; + + /* + * Insert a file type item into the new brand. + * Note that the this is only the id and file name pair, + * the file itself has to be imported separately. + * @param aId ID of the item + * @param aFile the integer item + */ + virtual void InsertFileL( const TDesC8& aId, + const TDesC& aFileName ) = 0; + + /* + * Inserts an element into the brand that is being installed. + * @param aElement the element + */ + virtual void InsertElementL( MBSElement* aElement ) = 0; + + + + + + //*** BRAND UPDATING - replacing ***// + + + /* + * Insert text type item into the new brand + * @param aId ID of the item + * @param aText the text item + */ + virtual void ReplaceTextL( const TDesC8& aId, const TDesC& aText ) = 0; + + /* + * Insert 8-bit data type item into the new brand + * @param aId ID of the item + * @param aBuffer the data item + */ + virtual void ReplaceBufferL( const TDesC8& aId, const TDesC8& aBuffer ) = 0; + + /* + * Insert integer type item into the new brand + * @param aId ID of the item + * @param aInt the integer item + */ + virtual void ReplaceIntL( const TDesC8& aId, TInt aInt ) = 0; + + /* + * Insert a file type item into the new brand. + * Note that the this is only the id and file name pair, + * the file itself has to be imported separately. + * @param aId ID of the item + * @param aFile the integer item + */ + virtual void ReplaceFileL( const TDesC8& aId, + const TDesC& aFileName ) = 0; + + /* + * Inserts an element into the brand that is being installed. + * @param aElement the element + */ + virtual void ReplaceElementL( MBSElement* aElement ) = 0; + + + + //*** BRAND UPDATING - appending ***// + + + /* + * Insert text type item into the new brand + * @param aId ID of the item + * @param aText the text item + */ + virtual void AppendTextL( const TDesC8& aId, const TDesC& aText ) = 0; + + /* + * Insert 8-bit data type item into the new brand + * @param aId ID of the item + * @param aBuffer the data item + */ + virtual void AppendBufferL( const TDesC8& aId, const TDesC8& aBuffer ) = 0; + + /* + * Insert integer type item into the new brand + * @param aId ID of the item + * @param aInt the integer item + */ + virtual void AppendIntL( const TDesC8& aId, TInt aInt ) = 0; + + /* + * Insert a file type item into the new brand. + * Note that the this is only the id and file name pair, + * the file itself has to be imported separately. + * @param aId ID of the item + * @param aFile the integer item + */ + virtual void AppendFileL( const TDesC8& aId, + const TDesC& aFileName ) = 0; + + /* + * Inserts an element into the brand that is being installed. + * @param aElement the element + */ + virtual void AppendElementL( MBSElement* aElement ) = 0; + + + /* + * Closes the handle to server and deletes the object. + */ + virtual void Close() = 0; + + /* + * Register to observer backup restore state change + * @param aObserver the observer interface + */ + virtual void RegisterObserverL( MBSBackupRestoreStateObserver* aBackupObserver ) = 0; + + /* + * Unregister a backup restore state change observer + * @param aObserver the observer interface + */ + virtual void UnRegisterObserverL( MBSBackupRestoreStateObserver* aObserver ) = 0; + + + protected: + /* + * Destructor + */ + virtual ~MBSUpdater() {}; + }; + + #endif //__MBSUPDATER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/rbsobjowningptrarray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/rbsobjowningptrarray.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: RBSOBJOWNINGPTRaRRAY.H +* +*/ + + +#ifndef _RBSOBJOWNINGPTRARRAY_H +#define _RBSOBJOWNINGPTRARRAY_H + +#include + + + +/** + * Templated array of pointers. Array owns the pointed objects + * and overwrites the normal RPointerArray::Close() + * behaviour to destroy objects, before reseting the + * array contents. + * + * Array is used with Presence Framework interface objects. + * + * @since S60 v3.2 + */ +template< class T > +class RBSObjOwningPtrArray : public RPointerArray + { + public: + + /** + * Default C++ constructor. + */ + inline RBSObjOwningPtrArray(); + + + /** + * Overwritten Close(). + * + * Calls ResetAndDestroy() to delete holded objects + * before reseting array contents. Thus array can be + * pushed on the cleanup stack with CleanupClosePushL(). + */ + inline void Close(); + }; + + + + +#include "rbsobjowningptrarray.inl" + +#endif // _RBSOBJOWNINGPTRARRAY_H + + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/rbsobjowningptrarray.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/rbsobjowningptrarray.inl Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: rbsobjowningptrarray.inl +* +*/ + + + +#include + +// ----------------------------------------------------------------------------- +// RBSObjOwningPtrArray::RBSObjOwningPtrArray() implementation. +// +// ----------------------------------------------------------------------------- +// +template +inline RBSObjOwningPtrArray::RBSObjOwningPtrArray() + { + } + + +// ----------------------------------------------------------------------------- +// RBSObjOwningPtrArray::Close() implementation. +// Calls ResetAndDestroy() to destroy holded objects. +// ----------------------------------------------------------------------------- +// +template +inline void RBSObjOwningPtrArray::Close() + { + RPointerArray::ResetAndDestroy(); + } diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/tbselementiterator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/tbselementiterator.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: tbselementiterator.h +* +*/ + + + + +#ifndef TBSELEMENTITERATOR_H +#define TBSELEMENTITERATOR_H + +#include + +// CLASS DECLARATION + +/** +* +* +* @lib +* @since +*/ + +class MBSElement; + + +class TBSElementIterator + { + public: // New functions + + IMPORT_C MBSElement& Next(); + + /** + * C++ default constructor. + */ + IMPORT_C TBSElementIterator( const TDesC& aElementId ); + + private: + TInt iIndex; + const TDesC& iElementId; + }; + +#endif // TBSELEMENTITERATOR_H + +// End of File diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/Inc/tbsmdescarrayadapter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/Inc/tbsmdescarrayadapter.h Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: One value adapter for MDesCArray. +* +*/ + + +#ifndef TBSMDESCARRAYADAPTER_H__ +#define TBSMDESCARRAYADAPTER_H__ + +// INCLUDES +#include +#include + + +// CLASS DECLARATION +/** + * One value adapter for MDesCArray. + * + * @since 3.0 + */ +class TBSMDesCArrayAdapter : public MDesCArray + { + public: //Constructor & destructor + + /** + * C++ constructor. + * Takes the descriptor to adapt. + */ + IMPORT_C TBSMDesCArrayAdapter( const TDesC& aDesc ); + + + public: //From MDesCArray + + IMPORT_C TInt MdcaCount() const; + IMPORT_C TPtrC MdcaPoint( TInt aIndex ) const; + + + private: //Data + + //OWN: Adapted descriptor + TPtrC iDesc; + }; + + +#endif //TBSMDESCARRAYADAPTER_H__ + +// End of File + + + + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/ROM/brandingserver.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/ROM/brandingserver.iby Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,36 @@ +/* +* 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 the License "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: Branding Server IBY +* +*/ + +#ifndef __BS_IBY__ +#define __BS_IBY__ + +#include + + +// branding client +file=ABI_DIR\BUILD_DIR\bsclient.dll SHARED_LIB_DIR\bsclient.dll +// branding server +file=ABI_DIR\BUILD_DIR\bsserver.exe PROGRAMS_DIR\bsserver.exe + +// Add bsinstall.exe to rom to get xml importing working. +file=ABI_DIR\BUILD_DIR\bsinstall.exe PROGRAMS_DIR\bsinstall.exe + +// backup registration file +data=ZPRIVATE\102828dd\backup_registration.xml private\102828dd\backup_registration.xml + + +#endif // __BS_IBY__ \ No newline at end of file diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/sis/bs.pkg --- a/brandingserver/sis/bs.pkg Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/sis/bs.pkg Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ ; 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" +; under the terms of the License "Eclipse Public License v1.0" ; which accompanies this distribution, and is available ; at the URL "http://www.eclipse.org/legal/epl-v10.html". ; @@ -11,9 +11,8 @@ ; ; Contributors: ; -; Description: +; Description: ; -;Language &EN ;Header diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/sis/bsstub.pkg --- a/brandingserver/sis/bsstub.pkg Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/sis/bsstub.pkg Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ ; 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" +; under the terms of the License "Eclipse Public License v1.0" ; which accompanies this distribution, and is available ; at the URL "http://www.eclipse.org/legal/epl-v10.html". ; @@ -11,20 +11,7 @@ ; ; Contributors: ; -; Description: -; -; -; Package file for presencefw SIS stub in ROM -; and a ximp framework upgrade SIS. -; Including the stub in ROM enables components -; defined in stub to be updated by SIS installer. -; When adding or removing components from presencefw -; please update this pkg file and create an updated -; stub to group directory. -; -; To create SIS stub: makesis -s ximpfw_upgrade.pkg ximpfwstub.sis -; Copy ximpfwstub.sis to z:\system\install\ximpfwstub.sis -; or use abld export to export it automatically. +; Description: ; ;Language diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/group/bld.inf --- a/brandingserver/tools/bsimport/group/bld.inf Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/group/bld.inf Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,9 +11,10 @@ * * Contributors: * -* Description: bld.inf file project inclusions. +* Description: bld.inf file project inclusions. * */ + // BLD.INF PRJ_MMPFILES diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/group/brandimporter_UID_.cpp --- a/brandingserver/tools/bsimport/group/brandimporter_UID_.cpp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/group/brandimporter_UID_.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,9 +11,10 @@ * * Contributors: * -* Description: UID file +* Description: UID file * */ + // Makmake-generated uid source file #include #pragma data_seg(".SYMBIAN") diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/group/importer.mmp --- a/brandingserver/tools/bsimport/group/importer.mmp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/group/importer.mmp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,11 +11,12 @@ * * Contributors: * -* Description: Project definition file for project bsimport +* Description: Project definition file for project bsimport * */ + #include TARGET bsimport.exe diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/group/installer.mmp --- a/brandingserver/tools/bsimport/group/installer.mmp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/group/installer.mmp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,11 +11,12 @@ * * Contributors: * -* Description: Project definition file for project bsinstall +* Description: Project definition file for project bsinstall * */ + #include TARGET bsinstall.exe diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/inc/cbsimportconstants.h --- a/brandingserver/tools/bsimport/inc/cbsimportconstants.h Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/inc/cbsimportconstants.h Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,9 +11,10 @@ * * Contributors: * -* Description: Constants header file +* Description: Constants header file * */ + // CONSTANTS // default build language diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/inc/cbsimportfilereader.h --- a/brandingserver/tools/bsimport/inc/cbsimportfilereader.h Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/inc/cbsimportfilereader.h Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,153 +11,80 @@ * * Contributors: * -* Description: Import reader opens and reads the XML file to CMDXMLDocument - -* object - +* Description: Import reader opens and reads the XML file to CMDXMLDocument +* object * */ - -#ifndef CBSIMPORTFILEREADER_H - -#define CBSIMPORTFILEREADER_H - - - -#include - -#include - - - -class CMDXMLDocument; - -class CActiveScheduler; - - - -/** - - * Import reader opens and reads the XML file to CMDXMLDocument object - - * - - * @lib brandimporter.exe - - * @since S60 v3.2 - - */ - -class CBSImportFileReader : public CBase, - - public MMDXMLParserObserver - - { - -public: - - - - static CBSImportFileReader* NewL( TBool aUseScheduler ); - - - - static CBSImportFileReader* NewLC( TBool aUseScheduler ); - - - - ~CBSImportFileReader(); - - - - /** - - * Reads XML file to CMDXMLDocument object - - * - - * @since S60 v3.2 - - * @param aFs file system handle - - * @param aFileName XML file to read - - */ - - CMDXMLDocument* ReadXMLFileL( RFs& aFs, const TDesC& aFileName ); - - - -private: - - - - void ConstructL(); - - - - CBSImportFileReader( TBool aUseScheduler ); - - - -// from base class MMDXMLParserObserver - - - - /** - - * From MMDXMLParserObserver. - - * Writes text to log - - * - - * @since S60 v3.2 - - * @param aText text to write - - */ - - void ParseFileCompleteL(); - - - -private: // Data - - - - // Own. XML parser - - CMDXMLParser* iParser; - - - - // Own. XML document from parser - - CMDXMLDocument* iDocument; - - - - // Own. ActiveScheduler - - CActiveScheduler* iScheduler; - - - - // Own. Scheduler waiter. Used when we can't use scheduler directly. - - CActiveSchedulerWait* iWaiter; - - - - // Wheter we use CActiveScheduler or CActiveSchedulerWait - - TBool iUseScheduler; - - }; - - - -#endif //CBSIMPORTFILEREADER_H - + +#ifndef CBSIMPORTFILEREADER_H +#define CBSIMPORTFILEREADER_H + +#include +#include + +class CMDXMLDocument; +class CActiveScheduler; + +/** + * Import reader opens and reads the XML file to CMDXMLDocument object + * + * @lib brandimporter.exe + * @since S60 v3.2 + */ +class CBSImportFileReader : public CBase, + public MMDXMLParserObserver + { +public: + + static CBSImportFileReader* NewL( TBool aUseScheduler ); + + static CBSImportFileReader* NewLC( TBool aUseScheduler ); + + ~CBSImportFileReader(); + + /** + * Reads XML file to CMDXMLDocument object + * + * @since S60 v3.2 + * @param aFs file system handle + * @param aFileName XML file to read + */ + CMDXMLDocument* ReadXMLFileL( RFs& aFs, const TDesC& aFileName ); + +private: + + void ConstructL(); + + CBSImportFileReader( TBool aUseScheduler ); + +// from base class MMDXMLParserObserver + + /** + * From MMDXMLParserObserver. + * Writes text to log + * + * @since S60 v3.2 + * @param aText text to write + */ + void ParseFileCompleteL(); + +private: // Data + + // Own. XML parser + CMDXMLParser* iParser; + + // Own. XML document from parser + CMDXMLDocument* iDocument; + + // Own. ActiveScheduler + CActiveScheduler* iScheduler; + + // Own. Scheduler waiter. Used when we can't use scheduler directly. + CActiveSchedulerWait* iWaiter; + + // Wheter we use CActiveScheduler or CActiveSchedulerWait + TBool iUseScheduler; + }; + +#endif //CBSIMPORTFILEREADER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/inc/cbsimportmanager.h --- a/brandingserver/tools/bsimport/inc/cbsimportmanager.h Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/inc/cbsimportmanager.h Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,11 +11,12 @@ * * Contributors: * -* Description: Import manager handles the reading, parsing and writing of +* Description: Import manager handles the reading, parsing and writing of * Brand data. * */ + #ifndef CBSIMPORTMANAGER_H #define CBSIMPORTMANAGER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/inc/cbsimportstorage.h --- a/brandingserver/tools/bsimport/inc/cbsimportstorage.h Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/inc/cbsimportstorage.h Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,11 +11,12 @@ * * Contributors: * -* Description: Stores element data and writes it to stream +* Description: Stores element data and writes it to stream * */ + #ifndef CBSIMPORTSTORAGE_H #define CBSIMPORTSTORAGE_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/inc/cbsimportstoragemanager.h --- a/brandingserver/tools/bsimport/inc/cbsimportstoragemanager.h Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/inc/cbsimportstoragemanager.h Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,11 +11,12 @@ * * Contributors: * -* Description: Storage handler +* Description: Storage handler * */ + #ifndef CBSIMPORTSTORAGEMANAGER_H #define CBSIMPORTSTORAGEMANAGER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/inc/cbsimportxmlparser-1.h --- a/brandingserver/tools/bsimport/inc/cbsimportxmlparser-1.h Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/inc/cbsimportxmlparser-1.h Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,6 +11,7 @@ * * Contributors: * -* Description: Parses XML content and stores data to storage* +* Description: Parses XML content and stores data to storage* */ + #ifndef CBSIMPORTXMLPARSER_H#define CBSIMPORTXMLPARSER_H// INCLUDE FILES#include #include #include #include #include class CMDXMLNode;class CBSImportStorageManager;// CLASS DEFINITIONclass CBSImportXMLParser : public CBase {private: // Definitions struct TImportBitmap { TInt iBitmapId; TInt iBitmapMaskId; TInt iSkinId; TInt iSkinMaskId; }; enum TXMLBaseTagTypes { EBrandUnknown, EBrandAppID, EBrandID, EBrandLanguage, EBrandVersion, EBrandElement }; public: static CBSImportXMLParser* NewL( CBSImportStorageManager* aStorage ); static CBSImportXMLParser* NewLC( CBSImportStorageManager* aStorage ); ~CBSImportXMLParser(); /** * Parse XML document and store data to storage * * @since S60 3.2 * @param aDocument XML document to parse * @return none */ void ParseDocumentL( CMDXMLDocument& aDocument );private: CBSImportXMLParser( CBSImportStorageManager* aStorage ); void ConstructL(); /** * Parses full the base element and it's child elements. * * @since S60 v3.2 * @param aElement to parse */ void ParseDocumentBaseL( CMDXMLNode* aElement ); /** * Analyzes a child node of and stores the value to storage. * Ignores undetected XML nodes. * * @since S60 v3.2 * @param aElement to parse */ void AnalyzeNodeL( CMDXMLNode* aNode ); /** * Converts a given node to TXMLBaseTagTypes. This can handle all * child nodes of * * @since S60 v3.2 * @param aNode node to check * @return corresponding TXMLBaseTagTypes value (or EBrandUnknown). */ TXMLBaseTagTypes SolveTagTypeL( CMDXMLNode* aNode ); /** * Parses full node. Returns a newly constructed MBSElement * from the content of teh node. * Ownership is transferred! * * @since S60 v3.2 * @param aNode node * @return Concrete element constructed from node. */ MBSElement* ParseBrandElementL( CMDXMLNode* aNode ); /** * Converts elements type attribute value to TBSElementType * (see MBSElement). * * @since S60 v3.2 * @param aType value of type attribute * @return corresponding TBrandingElementType value or KErrNotFound. */ TInt SolveElementType( const TDesC& aType ); /** * Search a child node with name inside another node. Returns the first match * * @since S60 v3.2 * @param aNode parent node to search * @param aTagName Child nodes name * @return found node or NULL if not found; */ CMDXMLNode* SearchChild( CMDXMLNode* aNode, const TDesC& aChildName ); /** * Parse value from tag. Leaves if parse fails. * Ownership is transferred to caller (NodeTextLC) * * @since S60 3.2 * @param aNode XML node to parse. should be . * @return value from */ HBufC* NodeTextLC( CMDXMLNode* elNode ); TInt NodeIntL ( CMDXMLNode* elNode ); /** * Parse tag for given value type. Leaves if parsing fails. * * @since S60 3.2 * @param aNode XML node to parse * @param aValue Parsed value * @return none */ void DoParseIntegerL( CMDXMLNode* aNode, TInt& aValue ); void DoParseTextL ( CMDXMLNode* aNode, HBufC*& aText ); void DoParseFileL ( CMDXMLNode* aNode, HBufC*& aText ); void DoParseListL ( CMDXMLNode* aNode, RBSObjOwningPtrArray& aElementArray ); void DoParseBitmapL ( CMDXMLNode* aNode, CBSBitmap*& aBitmap ); private: // Data // Not owned. Storage where to put parsed elements CBSImportStorageManager* iStorage; };#endif //CBSIMPORTXMLPARSER_H \ No newline at end of file diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/inc/cbsimportxmlparser.h --- a/brandingserver/tools/bsimport/inc/cbsimportxmlparser.h Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/inc/cbsimportxmlparser.h Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,307 +11,157 @@ * * Contributors: * -* Description: Parses XML content and stores data to storage - +* Description: Parses XML content and stores data to storage * */ - -#ifndef CBSIMPORTXMLPARSER_H - -#define CBSIMPORTXMLPARSER_H - - - -// INCLUDE FILES - -#include - -#include - -#include - -#include - -#include - - - -class CMDXMLNode; - -class CBSImportStorageManager; - - - -// CLASS DEFINITION - -class CBSImportXMLParser : public CBase - - { - -private: // Definitions - - - - struct TImportBitmap - - { - - TInt iBitmapId; - - TInt iBitmapMaskId; - - TInt iSkinId; - - TInt iSkinMaskId; - - }; - - - - enum TXMLBaseTagTypes - - { - - EBrandUnknown, - - EBrandAppID, - - EBrandID, - - EBrandLanguage, - - EBrandVersion, - - EBrandElement - - }; - - - -public: - - - - static CBSImportXMLParser* NewL( CBSImportStorageManager* aStorage ); - - - - static CBSImportXMLParser* NewLC( CBSImportStorageManager* aStorage ); - - - - ~CBSImportXMLParser(); - - - - /** - - * Parse XML document and store data to storage - - * - - * @since S60 3.2 - - * @param aDocument XML document to parse - - * @return none - - */ - - void ParseDocumentL( CMDXMLDocument& aDocument ); - - - -private: - - - - CBSImportXMLParser( CBSImportStorageManager* aStorage ); - - - - void ConstructL(); - - - - /** - - * Parses full the base element and it's child elements. - - * - - * @since S60 v3.2 - - * @param aElement to parse - - */ - - void ParseDocumentBaseL( CMDXMLNode* aElement ); - - - - /** - - * Analyzes a child node of and stores the value to storage. - - * Ignores undetected XML nodes. - - * - - * @since S60 v3.2 - - * @param aElement to parse - - */ - - void AnalyzeNodeL( CMDXMLNode* aNode ); - - - - /** - - * Converts a given node to TXMLBaseTagTypes. This can handle all - - * child nodes of - - * - - * @since S60 v3.2 - - * @param aNode node to check - - * @return corresponding TXMLBaseTagTypes value (or EBrandUnknown). - - */ - - TXMLBaseTagTypes SolveTagTypeL( CMDXMLNode* aNode ); - - - - /** - - * Parses full node. Returns a newly constructed MBSElement - - * from the content of teh node. - - * Ownership is transferred! - - * - - * @since S60 v3.2 - - * @param aNode node - - * @return Concrete element constructed from node. - - */ - - MBSElement* ParseBrandElementL( CMDXMLNode* aNode ); - - - - /** - - * Converts elements type attribute value to TBSElementType - - * (see MBSElement). - - * - - * @since S60 v3.2 - - * @param aType value of type attribute - - * @return corresponding TBrandingElementType value or KErrNotFound. - - */ - - TInt SolveElementType( const TDesC& aType ); - - - - /** - - * Search a child node with name inside another node. Returns the first match - - * - - * @since S60 v3.2 - - * @param aNode parent node to search - - * @param aTagName Child nodes name - - * @return found node or NULL if not found; - - */ - - CMDXMLNode* SearchChild( CMDXMLNode* aNode, const TDesC& aChildName ); - - - - /** - - * Parse value from tag. Leaves if parse fails. - - * Ownership is transferred to caller (NodeTextLC) - - * - - * @since S60 3.2 - - * @param aNode XML node to parse. should be . - - * @return value from - - */ - - HBufC* NodeTextLC( CMDXMLNode* elNode ); - - TInt NodeIntL ( CMDXMLNode* elNode ); - - - - /** - - * Parse tag for given value type. Leaves if parsing fails. - - * - - * @since S60 3.2 - - * @param aNode XML node to parse - - * @param aValue Parsed value - - * @return none - - */ - - void DoParseIntegerL( CMDXMLNode* aNode, TInt& aValue ); - - void DoParseTextL ( CMDXMLNode* aNode, HBufC*& aText ); - - void DoParseFileL ( CMDXMLNode* aNode, HBufC*& aText ); - - void DoParseListL ( CMDXMLNode* aNode, RBSObjOwningPtrArray& aElementArray ); - - void DoParseBitmapL ( CMDXMLNode* aNode, CBSBitmap*& aBitmap ); - - - -private: // Data - - - - // Not owned. Storage where to put parsed elements - - CBSImportStorageManager* iStorage; - - }; - - - -#endif //CBSIMPORTXMLPARSER_H - + +#ifndef CBSIMPORTXMLPARSER_H +#define CBSIMPORTXMLPARSER_H + +// INCLUDE FILES +#include +#include +#include +#include +#include + +class CMDXMLNode; +class CBSImportStorageManager; + +// CLASS DEFINITION +class CBSImportXMLParser : public CBase + { +private: // Definitions + + struct TImportBitmap + { + TInt iBitmapId; + TInt iBitmapMaskId; + TInt iSkinId; + TInt iSkinMaskId; + }; + + enum TXMLBaseTagTypes + { + EBrandUnknown, + EBrandAppID, + EBrandID, + EBrandLanguage, + EBrandVersion, + EBrandElement + }; + +public: + + static CBSImportXMLParser* NewL( CBSImportStorageManager* aStorage ); + + static CBSImportXMLParser* NewLC( CBSImportStorageManager* aStorage ); + + ~CBSImportXMLParser(); + + /** + * Parse XML document and store data to storage + * + * @since S60 3.2 + * @param aDocument XML document to parse + * @return none + */ + void ParseDocumentL( CMDXMLDocument& aDocument ); + +private: + + CBSImportXMLParser( CBSImportStorageManager* aStorage ); + + void ConstructL(); + + /** + * Parses full the base element and it's child elements. + * + * @since S60 v3.2 + * @param aElement to parse + */ + void ParseDocumentBaseL( CMDXMLNode* aElement ); + + /** + * Analyzes a child node of and stores the value to storage. + * Ignores undetected XML nodes. + * + * @since S60 v3.2 + * @param aElement to parse + */ + void AnalyzeNodeL( CMDXMLNode* aNode ); + + /** + * Converts a given node to TXMLBaseTagTypes. This can handle all + * child nodes of + * + * @since S60 v3.2 + * @param aNode node to check + * @return corresponding TXMLBaseTagTypes value (or EBrandUnknown). + */ + TXMLBaseTagTypes SolveTagTypeL( CMDXMLNode* aNode ); + + /** + * Parses full node. Returns a newly constructed MBSElement + * from the content of teh node. + * Ownership is transferred! + * + * @since S60 v3.2 + * @param aNode node + * @return Concrete element constructed from node. + */ + MBSElement* ParseBrandElementL( CMDXMLNode* aNode ); + + /** + * Converts elements type attribute value to TBSElementType + * (see MBSElement). + * + * @since S60 v3.2 + * @param aType value of type attribute + * @return corresponding TBrandingElementType value or KErrNotFound. + */ + TInt SolveElementType( const TDesC& aType ); + + /** + * Search a child node with name inside another node. Returns the first match + * + * @since S60 v3.2 + * @param aNode parent node to search + * @param aTagName Child nodes name + * @return found node or NULL if not found; + */ + CMDXMLNode* SearchChild( CMDXMLNode* aNode, const TDesC& aChildName ); + + /** + * Parse value from tag. Leaves if parse fails. + * Ownership is transferred to caller (NodeTextLC) + * + * @since S60 3.2 + * @param aNode XML node to parse. should be . + * @return value from + */ + HBufC* NodeTextLC( CMDXMLNode* elNode ); + TInt NodeIntL ( CMDXMLNode* elNode ); + + /** + * Parse tag for given value type. Leaves if parsing fails. + * + * @since S60 3.2 + * @param aNode XML node to parse + * @param aValue Parsed value + * @return none + */ + void DoParseIntegerL( CMDXMLNode* aNode, TInt& aValue ); + void DoParseTextL ( CMDXMLNode* aNode, HBufC*& aText ); + void DoParseFileL ( CMDXMLNode* aNode, HBufC*& aText ); + void DoParseListL ( CMDXMLNode* aNode, RBSObjOwningPtrArray& aElementArray ); + void DoParseBitmapL ( CMDXMLNode* aNode, CBSBitmap*& aBitmap ); + +private: // Data + + // Not owned. Storage where to put parsed elements + CBSImportStorageManager* iStorage; + }; + +#endif //CBSIMPORTXMLPARSER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/inc/importlogwriter.h --- a/brandingserver/tools/bsimport/inc/importlogwriter.h Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/inc/importlogwriter.h Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,12 +11,13 @@ * * Contributors: * -* Description: Log writer macros +* Description: Log writer macros * */ + /* * * Description: diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/internal/Test/BWINS/UT_CBSImportFileReaderU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/tools/bsimport/internal/Test/BWINS/UT_CBSImportFileReaderU.DEF Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,3 @@ +EXPORTS + ?CreateTestSuiteL@@YAPAVMEUnitTest@@XZ @ 1 NONAME ; class MEUnitTest * CreateTestSuiteL(void) + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/internal/Test/BWINS/UT_CBSImportStorageManagerU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/tools/bsimport/internal/Test/BWINS/UT_CBSImportStorageManagerU.DEF Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,2 @@ +EXPORTS + ?CreateTestSuiteL@@YAPAVMEUnitTest@@XZ @ 1 NONAME ; class MEUnitTest * CreateTestSuiteL(void) diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/internal/Test/BWINS/UT_CBSImportStorageU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/tools/bsimport/internal/Test/BWINS/UT_CBSImportStorageU.DEF Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,3 @@ +EXPORTS + ?CreateTestSuiteL@@YAPAVMEUnitTest@@XZ @ 1 NONAME ; class MEUnitTest * CreateTestSuiteL(void) + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/internal/Test/BWINS/UT_CBSImportXMLParserU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brandingserver/tools/bsimport/internal/Test/BWINS/UT_CBSImportXMLParserU.DEF Sun Apr 11 15:33:49 2010 +0530 @@ -0,0 +1,16 @@ +EXPORTS + ?CreateTestSuiteL@@YAPAVMEUnitTest@@XZ @ 1 NONAME ; class MEUnitTest * CreateTestSuiteL(void) + ??0CBSBitmap@@AAE@HHHH@Z @ 2 NONAME ; CBSBitmap::CBSBitmap(int, int, int, int) + ??1CBSBitmap@@UAE@XZ @ 3 NONAME ; CBSBitmap::~CBSBitmap(void) + ?BitmapFileId@CBSBitmap@@QBEABVTDesC8@@XZ @ 4 NONAME ; class TDesC8 const & CBSBitmap::BitmapFileId(void) const + ?BitmapId@CBSBitmap@@QBEHXZ @ 5 NONAME ; int CBSBitmap::BitmapId(void) const + ?BitmapMaskId@CBSBitmap@@QBEHXZ @ 6 NONAME ; int CBSBitmap::BitmapMaskId(void) const + ?ConstructL@CBSBitmap@@AAEXABVTDesC8@@@Z @ 7 NONAME ; void CBSBitmap::ConstructL(class TDesC8 const &) + ?CreateBSElementL@BSElementFactory@@SAPAVMBSElement@@ABVTDesC8@@W4TBSElementType@@0@Z @ 8 NONAME ; class MBSElement * BSElementFactory::CreateBSElementL(class TDesC8 const &, enum TBSElementType, class TDesC8 const &) + ?CreateBSElementL@BSElementFactory@@SAPAVMBSElement@@ABVTDesC8@@W4TBSElementType@@AAV?$RBSObjOwningPtrArray@VMBSElement@@@@@Z @ 9 NONAME ; class MBSElement * BSElementFactory::CreateBSElementL(class TDesC8 const &, enum TBSElementType, class RBSObjOwningPtrArray &) + ?CreateBSElementL@BSElementFactory@@SAPAVMBSElement@@ABVTDesC8@@W4TBSElementType@@ABVTDesC16@@@Z @ 10 NONAME ; class MBSElement * BSElementFactory::CreateBSElementL(class TDesC8 const &, enum TBSElementType, class TDesC16 const &) + ?CreateBSElementL@BSElementFactory@@SAPAVMBSElement@@ABVTDesC8@@W4TBSElementType@@H@Z @ 11 NONAME ; class MBSElement * BSElementFactory::CreateBSElementL(class TDesC8 const &, enum TBSElementType, int) + ?CreateBSElementL@BSElementFactory@@SAPAVMBSElement@@ABVTDesC8@@W4TBSElementType@@PAVCBSBitmap@@@Z @ 12 NONAME ; class MBSElement * BSElementFactory::CreateBSElementL(class TDesC8 const &, enum TBSElementType, class CBSBitmap *) + ?NewL@CBSBitmap@@SAPAV1@HHHHABVTDesC8@@@Z @ 13 NONAME ; class CBSBitmap * CBSBitmap::NewL(int, int, int, int, class TDesC8 const &) + ?NewLC@CBSBitmap@@SAPAV1@HHHHABVTDesC8@@@Z @ 14 NONAME ; class CBSBitmap * CBSBitmap::NewLC(int, int, int, int, class TDesC8 const &) + diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/src/bsbrandremover.cpp --- a/brandingserver/tools/bsimport/src/bsbrandremover.cpp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/src/bsbrandremover.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,10 +11,11 @@ * * Contributors: * -* Description: Removes brands from branding server +* Description: Removes brands from branding server * */ + #include #include diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/src/bsbrandremover.h --- a/brandingserver/tools/bsimport/src/bsbrandremover.h Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/src/bsbrandremover.h Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,10 +11,11 @@ * * Contributors: * -* Description: Helper class for removing brands +* Description: Helper class for removing brands * */ + #ifndef BSBRANDREMOVER_H #define BSBRANDREMOVER_H diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/src/cbsimportfilereader.cpp --- a/brandingserver/tools/bsimport/src/cbsimportfilereader.cpp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/src/cbsimportfilereader.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,12 +11,13 @@ * * Contributors: * -* Description: Import reader opens and reads the XML file to CMDXMLDocument +* Description: Import reader opens and reads the XML file to CMDXMLDocument * object * */ + #include #include diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/src/cbsimportmanager.cpp --- a/brandingserver/tools/bsimport/src/cbsimportmanager.cpp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/src/cbsimportmanager.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,12 +11,13 @@ * * Contributors: * -* Description: Import manager handles the reading, parsing and writing of +* Description: Import manager handles the reading, parsing and writing of * Brand data. * */ + #include #include #include diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/src/cbsimportstorage.cpp --- a/brandingserver/tools/bsimport/src/cbsimportstorage.cpp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/src/cbsimportstorage.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,11 +11,12 @@ * * Contributors: * -* Description: Stores element data and writes it to stream +* Description: Stores element data and writes it to stream * */ + #include #include #include diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/src/cbsimportstoragemanager.cpp --- a/brandingserver/tools/bsimport/src/cbsimportstoragemanager.cpp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/src/cbsimportstoragemanager.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,11 +11,12 @@ * * Contributors: * -* Description: Stores element data and writes it to stream +* Description: Stores element data and writes it to stream * */ + #include #include #include diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/src/cbsimportxmlparser.cpp --- a/brandingserver/tools/bsimport/src/cbsimportxmlparser.cpp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/src/cbsimportxmlparser.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,11 +11,12 @@ * * Contributors: * -* Description: Parses XML content and stores data to storage +* Description: Parses XML content and stores data to storage * */ + #include #include #include diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/src/importer.cpp --- a/brandingserver/tools/bsimport/src/importer.cpp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/src/importer.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,11 +11,12 @@ * * Contributors: * -* Description: Global methods for brandimporter +* Description: Global methods for brandimporter * */ + #include #include #include diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/bsimport/src/installer.cpp --- a/brandingserver/tools/bsimport/src/installer.cpp Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/bsimport/src/installer.cpp Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2006-2006 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" +* under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * @@ -11,11 +11,12 @@ * * Contributors: * -* Description: Global methods for brandinstaller +* Description: Global methods for brandinstaller * */ + #include #include #include diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/makefile/import.mk --- a/brandingserver/tools/makefile/import.mk Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/makefile/import.mk Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ # Copyright (c) 2006 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" +# under the terms of the License "Eclipse Public License v1.0" # which accompanies this distribution, and is available # at the URL "http://www.eclipse.org/legal/epl-v10.html". # @@ -11,7 +11,7 @@ # # Contributors: # -# Description: make file +# Description: make file # diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/sis/brand-example.pkg --- a/brandingserver/tools/sis/brand-example.pkg Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/sis/brand-example.pkg Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ ; Copyright (c) 2006-2006 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" +; under the terms of the License "Eclipse Public License v1.0" ; which accompanies this distribution, and is available ; at the URL "http://www.eclipse.org/legal/epl-v10.html". ; @@ -11,7 +11,7 @@ ; ; Contributors: ; -; Description: Example PKG file for branding installer +; Description: Example PKG file for branding installer ; ; -------- general -------- diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/sis/make-example.cmd --- a/brandingserver/tools/sis/make-example.cmd Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/sis/make-example.cmd Sun Apr 11 15:33:49 2010 +0530 @@ -1,8 +1,9 @@ +@echo off rem rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). rem All rights reserved. rem This component and the accompanying materials are made available -rem under the terms of "Eclipse Public License v1.0" +rem under the terms of the License "Eclipse Public License v1.0" rem which accompanies this distribution, and is available rem at the URL "http://www.eclipse.org/legal/epl-v10.html". rem @@ -11,8 +12,9 @@ rem rem Contributors: rem -rem Description: Example to make the brand sis file +rem Description: Example to make the brand sis file rem +@echo on @echo off call t:\epoc32\tools\makesis brand-example.pkg diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/xml/loc2xml.pl --- a/brandingserver/tools/xml/loc2xml.pl Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/xml/loc2xml.pl Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ # Copyright (c) 2006-2006 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" +# under the terms of the License "Eclipse Public License v1.0" # which accompanies this distribution, and is available # at the URL "http://www.eclipse.org/legal/epl-v10.html". # @@ -11,7 +11,7 @@ # # Contributors: # -# Description: Converts loc file into branding xml file +# Description: Converts loc file into branding xml file # #------------------------------------------------------------------------------ diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/xml/mbg2xml.pl --- a/brandingserver/tools/xml/mbg2xml.pl Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/xml/mbg2xml.pl Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ # Copyright (c) 2006-2006 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" +# under the terms of the License "Eclipse Public License v1.0" # which accompanies this distribution, and is available # at the URL "http://www.eclipse.org/legal/epl-v10.html". # @@ -11,7 +11,7 @@ # # Contributors: # -# Description: Converts mbg file into branding xml file +# Description: Converts mbg file into branding xml file # # SETUP diff -r 1fa9b890f29c -r 9dbc70490d9a brandingserver/tools/xml/xml2h.pl --- a/brandingserver/tools/xml/xml2h.pl Fri Apr 09 20:37:41 2010 +0530 +++ b/brandingserver/tools/xml/xml2h.pl Sun Apr 11 15:33:49 2010 +0530 @@ -2,7 +2,7 @@ # Copyright (c) 2006-2006 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" +# under the terms of the License "Eclipse Public License v1.0" # which accompanies this distribution, and is available # at the URL "http://www.eclipse.org/legal/epl-v10.html". # @@ -11,7 +11,7 @@ # # Contributors: # -# Description: Writes a header file based on brand xml file +# Description: Writes a header file based on brand xml file # #------------------------------------------------------------------------------ diff -r 1fa9b890f29c -r 9dbc70490d9a imservices/imfeatureplugin/srcimdatamodel/imconversation/conversationsubscriptionitem.h --- a/imservices/imfeatureplugin/srcimdatamodel/imconversation/conversationsubscriptionitem.h Fri Apr 09 20:37:41 2010 +0530 +++ b/imservices/imfeatureplugin/srcimdatamodel/imconversation/conversationsubscriptionitem.h Sun Apr 11 15:33:49 2010 +0530 @@ -71,7 +71,7 @@ * Ownership is transferred! * @param aList New blocklist. */ - void SetConversationInfoL(CImConversationInfoImp* aImMessage); + IMPORT_C void SetConversationInfoL(CImConversationInfoImp* aImMessage); public: // From MXIMPSubscriptionItem /**