diff -r 000000000000 -r 2e3d3ce01487 appfw/apparchitecture/apserv/APSRECUTIL.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/appfw/apparchitecture/apserv/APSRECUTIL.H Tue Feb 02 10:12:00 2010 +0200 @@ -0,0 +1,107 @@ +// Copyright (c) 1997-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: +// apsrecutil.h +// + + +#ifndef __APSRECUTIL_H__ +#define __APSRECUTIL_H__ + +#include +#include +#include "apsserv.h" + +/** +Reference-counted object which stores a recognition result in a more compact format +than TDataRecognitionResult does. Also includes the file name. + +The reason why instances of this class are reference-counted is that they might +be "owned" by the cache and CDirectoryRecognitionResult at the same time. If both +of them had their own copies unnecessarily much memory would be wasted. +@internalComponent +*/ +NONSHARABLE_CLASS(CRecognitionResult) : public CObject + { +public: + static CRecognitionResult* NewL(const TDesC& aFileName, const TDataRecognitionResult& aRecognitionResult); + TUint GetRequiredBufferSize() const; + void WriteToStreamL(RWriteStream& aWriteStream); + + void Get(TDataRecognitionResult& aRecognitionResult); + inline const TDesC8& DataType() const { return *iDataType; } + inline const TDesC& FileName() const { return *iFileName; } +private: + CRecognitionResult(HBufC* aFileName, HBufC8* aDataType, TUid aUid, TInt aConfidence); + ~CRecognitionResult(); +private: + const HBufC* const iFileName; + const HBufC8* const iDataType; + TUid iUid; + TInt iConfidence; + }; + +/** +Holds the recognition results of all files of a directory. +@internalComponent +*/ +NONSHARABLE_CLASS(CDirectoryRecognitionResult) : public CBase + { +public: + CDirectoryRecognitionResult(HBufC* aPath, HBufC8* aDataTypeFilter); + ~CDirectoryRecognitionResult(); + void AppendL(CRecognitionResult* aEntry); + void WriteToStreamL(RWriteStream& aWriteStream); + inline TInt RequiredBufferSize() const {return iRequiredBufferSize;} + inline HBufC& Path() { return *iPath; } +private: + TInt iRequiredBufferSize; + HBufC* iPath; + HBufC8* iDataTypeFilter; + RPointerArray iEntries; + }; + +/** +Utility class which does synchronous and asynchronous file recognitions of a directory +@internalComponent +*/ +NONSHARABLE_CLASS(CFileRecognitionUtility) : public CActive + { +public: + CFileRecognitionUtility(CApaAppArcServer& aServer, TInt aMaxBufSize, RFs& aFs); + ~CFileRecognitionUtility(); + void RecognizeSynchronouslyL(CDirectoryRecognitionResult& aResult); + void RecognizeAsynchronously(CDirectoryRecognitionResult& aResult, const RMessage2& aMessage); + void CancelRecognitionRequest(); +protected: + void ReadDirectoryL(); + void RecognizeFileL(); +private: + void NextStep(); + void RunL(); + void DoCancel(); + TInt BufferSizeL() const; +private: + HBufC* iPath; + CDirectoryRecognitionResult* iResult; + CApaAppArcServer& iServer; + TInt iMaxBufSize; + RFs& iFs; + CDir* iEntryList; + TInt iIndex; + TInt iStep; + RMessage2 iMessage; + }; + +#endif // __APSRECUTIL_H__ +