diff -r 000000000000 -r c53acadfccc6 harvester/common/src/harvestercenreputil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/harvester/common/src/harvestercenreputil.cpp Mon Jan 18 20:34:07 2010 +0200 @@ -0,0 +1,244 @@ +/* +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Harvester Central Repository utility class* +*/ + + +#include "harvestercenreputil.h" +#include "centralrepository.h" +#include "mdsutils.h" +#include "mdeconstants.h" + +const TUid KHarvesterRepoUid = { 0x200009FE }; +const TUint32 KSearchMask = 0xFFFF0000; +const TUint32 KIgnorePathPartialKey = 0x00010000; +const TUint32 KBootScanPartialKey = 0x00020000; +const TUint32 KBootIgnorePartialKey = 0x00030000; +const TUint32 KPartialRestorePartialKey = 0x00040000; +const TUint32 KPartialRestoreIgnorePartialKey = 0x00050000; + +const TUint32 KRomScanEnabledKey = 0x00090000; + +const TInt32 KThumbnailManagerCenrepUID = 0x102830B0; // TNM cenrep uid +const TUint32 KEnableDaemon = 0x300; // from TNM + +CHarvesterCenRepUtil::CHarvesterCenRepUtil() + { + // No implementation required + } + + +EXPORT_C CHarvesterCenRepUtil::~CHarvesterCenRepUtil() + { + iFspEngine.Close(); + iFs.Close(); + } + +EXPORT_C CHarvesterCenRepUtil* CHarvesterCenRepUtil::NewLC() + { + CHarvesterCenRepUtil* self = new (ELeave)CHarvesterCenRepUtil(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +EXPORT_C CHarvesterCenRepUtil* CHarvesterCenRepUtil::NewL() + { + CHarvesterCenRepUtil* self=CHarvesterCenRepUtil::NewLC(); + CleanupStack::Pop(); // self; + return self; + } + +void CHarvesterCenRepUtil::ConstructL() + { + User::LeaveIfError( iFs.Connect() ); + User::LeaveIfError( iFspEngine.Open( iFs, KMdsFSPluginPosition ) ); + } + +EXPORT_C RMdsFSPEngine& CHarvesterCenRepUtil::FspEngine() + { + return iFspEngine; + } + +EXPORT_C void CHarvesterCenRepUtil::AddIgnorePathsToFspL( const TDesC& aDrivePrefix ) + { + AddOrRemoveIgnorePathsL( aDrivePrefix, ETrue, KNullDesC ); + } + +EXPORT_C void CHarvesterCenRepUtil::AddIgnorePathsToFspL( const TDesC& aDrivePrefix, + const TDesC& aFilterPrefix ) + { + AddOrRemoveIgnorePathsL( aDrivePrefix, ETrue, aFilterPrefix); + } + +EXPORT_C void CHarvesterCenRepUtil::RemoveIgnorePathsFromFspL( const TDesC& aDrivePrefix ) + { + AddOrRemoveIgnorePathsL( aDrivePrefix, EFalse, KNullDesC ); + } + +void CHarvesterCenRepUtil::AddOrRemoveIgnorePathsL( const TDesC& aDrivePrefix, + TBool aAdd, + const TDesC& aFilterPrefix ) + { + CRepository* repo = CRepository::NewLC( KHarvesterRepoUid ); + RArray ignoredKeys; + CleanupClosePushL( ignoredKeys ); + TInt ret = repo->FindL( KIgnorePathPartialKey, KSearchMask, ignoredKeys ); + + TBuf path; + const TInt count = ignoredKeys.Count(); + for( TInt i=0;iGet( ignoredKeys[i], path ) ); + if( error != KErrNone ) + { + continue; + } + if( aFilterPrefix != KNullDesC ) + { + TPtrC pathStart = path.Left( aFilterPrefix.Length() ); + if( MdsUtils::Compare( pathStart, aFilterPrefix ) != 0 ) + { + continue; + } + } + HBufC* ignorePath = HBufC::NewL( aDrivePrefix.Length() + path.Length() ); + TPtr ptr = ignorePath->Des(); + ptr.Append( aDrivePrefix ); + ptr.Append( path ); + if( aAdd ) + { + iFspEngine.AddIgnorePath( *ignorePath ); + } + else + { + iFspEngine.RemoveIgnorePath( *ignorePath ); + } + delete ignorePath; + ignorePath = NULL; + } + CleanupStack::PopAndDestroy( &ignoredKeys ); + CleanupStack::PopAndDestroy( repo ); + } + +EXPORT_C void CHarvesterCenRepUtil::GetIgnorePathL( + RPointerArray& aIgnorePaths ) + { + GetPathsL( KIgnorePathPartialKey, aIgnorePaths ); + } + +EXPORT_C void CHarvesterCenRepUtil::GetScanItemsL( + RPointerArray& aItems ) + { + GetItemsL( KBootScanPartialKey, aItems ); + } + +EXPORT_C void CHarvesterCenRepUtil::GetIgnoredScanPathsL( + RPointerArray& aIngorePaths ) + { + GetPathsL( KBootIgnorePartialKey, aIngorePaths ); + } + +EXPORT_C void CHarvesterCenRepUtil::GetPartialRestorePathsL( + RPointerArray& aPaths ) + { + GetItemsL( KPartialRestorePartialKey, aPaths ); + } + +EXPORT_C void CHarvesterCenRepUtil::GetIgnoredPartialRestorePathsL( + RPointerArray& aIngorePaths ) + { + GetPathsL( KPartialRestoreIgnorePartialKey, aIngorePaths ); + } + +EXPORT_C void CHarvesterCenRepUtil::IsRomScanEnabledL( TBool& aEnabled ) + { + CRepository* rep = CRepository::NewLC( KHarvesterRepoUid ); + + rep->Get( KRomScanEnabledKey, aEnabled ); + + CleanupStack::PopAndDestroy( rep ); + } + +EXPORT_C void CHarvesterCenRepUtil::IsThumbnailDaemonEnabledL( TBool& aEnabled ) + { + CRepository* rep = CRepository::NewLC( TUid::Uid( KThumbnailManagerCenrepUID ) ); + + rep->Get( KEnableDaemon, aEnabled ); + + CleanupStack::PopAndDestroy( rep ); + } + +void CHarvesterCenRepUtil::GetPathsL( TUint32 aPartialKey, RPointerArray& aPaths ) + { + CRepository* repo = CRepository::NewLC( KHarvesterRepoUid ); + RArray scanPathKeys; + CleanupClosePushL( scanPathKeys ); + + repo->FindL( aPartialKey, KSearchMask, scanPathKeys ); + + TBuf path; + const TInt count = scanPathKeys.Count(); + aPaths.ReserveL( count ); + for( TInt i = 0; i < count; i++ ) + { + const TInt error( repo->Get( scanPathKeys[i], path ) ); + if( error != KErrNone ) + { + continue; + } + HBufC* pathBuf = path.AllocL(); + aPaths.Append( pathBuf ); + } + + CleanupStack::PopAndDestroy( &scanPathKeys ); + CleanupStack::PopAndDestroy( repo ); + } + +void CHarvesterCenRepUtil::GetItemsL( TUint32 aPartialKey, RPointerArray& aItems ) + { + CRepository* repo = CRepository::NewLC( KHarvesterRepoUid ); + RArray scanPathKeys; + CleanupClosePushL( scanPathKeys ); + + repo->FindL( aPartialKey, KSearchMask, scanPathKeys ); + + TBuf path; + const TInt count = scanPathKeys.Count(); + for( TInt i = 0; i < count; i++ ) + { + const TInt error( repo->Get( scanPathKeys[i], path ) ); + if( error != KErrNone ) + { + continue; + } + TUint32 preinstalled = MdeConstants::MediaObject::ENotPreinstalled; + if( path[ path.Length() - 1 ] != TChar('\\') ) + { + User::LeaveIfError( repo->GetMeta( scanPathKeys[i], preinstalled ) ); + } + TScanItem* item = new (ELeave) TScanItem(); + CleanupStack::PushL( item ); + item->iPath = path.AllocL(); + item->iPreinstalled = preinstalled; + CleanupStack::Pop( item ); + aItems.Append( item ); // ownership is transferred + } + + CleanupStack::PopAndDestroy( &scanPathKeys ); + CleanupStack::PopAndDestroy( repo ); + } + +// End of file +