localisation/apparchitecture/apserv/APSRECUTIL.H
branchSymbian3
changeset 57 b8d18c84f71c
parent 6 c108117318cb
equal deleted inserted replaced
56:aa99f2208aad 57:b8d18c84f71c
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
       
    14 // apsrecutil.h
    14 //
    15 //
    15 
    16 
    16 
    17 
    17 #if !defined(__APSRECUTIL_H__)
    18 #ifndef __APSRECUTIL_H__
    18 #define __APSRECUTIL_H__
    19 #define __APSRECUTIL_H__
    19 
    20 
    20 #if !defined(__E32BASE_H__)
       
    21 #include <e32base.h>
    21 #include <e32base.h>
    22 #endif
       
    23 
       
    24 #include <apmrec.h>
    22 #include <apmrec.h>
    25 #include <apsserv.h>
    23 #include "apsserv.h"
    26 
    24 
    27 /**
    25 /**
    28 Reference-counted object which stores a recognition result in a more compact format
    26 Reference-counted object which stores a recognition result in a more compact format
    29 than TDataRecognitionResult does. Also includes the file name.
    27 than TDataRecognitionResult does. Also includes the file name.
    30 
    28 
    31 The reason why instances of this class are reference-counted is that they might 
    29 The reason why instances of this class are reference-counted is that they might 
    32 be "owned" by the cache and CDirectoryRecognitionResult at the same time. If both
    30 be "owned" by the cache and CDirectoryRecognitionResult at the same time. If both
    33 of them had their own copies unnecessarily much memory would be wasted.
    31 of them had their own copies unnecessarily much memory would be wasted.
    34 @internalComponent
    32 @internalComponent
    35 */
    33 */
    36 class CRecognitionResult : public CObject
    34 NONSHARABLE_CLASS(CRecognitionResult) : public CObject
    37 	{
    35 	{
    38 public:
    36 public:
    39 	static CRecognitionResult* NewL(const TDesC& aFileName, const TDataRecognitionResult& aRecognitionResult);
    37 	static CRecognitionResult* NewL(const TDesC& aFileName, const TDataRecognitionResult& aRecognitionResult);
    40 	TUint GetRequiredBufferSize() const;
    38 	TUint GetRequiredBufferSize() const;
    41 	void WriteToStreamL(RWriteStream& aWriteStream);
    39 	void WriteToStreamL(RWriteStream& aWriteStream);
    42 	
    40 	
    43 	void Get(TDataRecognitionResult& aRecognitionResult);
    41 	void Get(TDataRecognitionResult& aRecognitionResult);
    44 	inline const TDesC8& DataType() const { return *iDataType; }
    42 	inline const TDesC8& DataType() const { return *iDataType; }
    45 	inline const TDesC& FileName() const { return *iFileName; }
    43 	inline const TDesC& FileName() const { return *iFileName; }
    46 	
       
    47 private:
    44 private:
    48 	CRecognitionResult(HBufC* aFileName, HBufC8* aDataType, TUid aUid, TInt aConfidence);
    45 	CRecognitionResult(HBufC* aFileName, HBufC8* aDataType, TUid aUid, TInt aConfidence);
    49 	~CRecognitionResult();
    46 	~CRecognitionResult();
    50 private:
    47 private:
    51 	HBufC* iFileName;
    48 	const HBufC* const iFileName;
    52 	HBufC8* iDataType;
    49 	const HBufC8* const iDataType;
    53 	TUid iUid;
    50 	TUid iUid;
    54 	TInt iConfidence;
    51 	TInt iConfidence;
    55 	};
    52 	};
    56 
    53 
    57 /**
    54 /**
    58 Holds the recognition results of all files of a directory.
    55 Holds the recognition results of all files of a directory.
    59 @internalComponent
    56 @internalComponent
    60 */
    57 */
    61 class CDirectoryRecognitionResult : public CBase
    58 NONSHARABLE_CLASS(CDirectoryRecognitionResult) : public CBase
    62 	{
    59 	{
    63 public:
    60 public:
    64 	CDirectoryRecognitionResult(HBufC* aPath, HBufC8* aDataTypeFilter);
    61 	CDirectoryRecognitionResult(HBufC* aPath, HBufC8* aDataTypeFilter);
    65 	virtual ~CDirectoryRecognitionResult();
    62 	~CDirectoryRecognitionResult();
    66 	void AppendL(CRecognitionResult* aEntry);
    63 	void AppendL(CRecognitionResult* aEntry);
    67 	void WriteToStreamL(RWriteStream& aWriteStream);
    64 	void WriteToStreamL(RWriteStream& aWriteStream);
    68 	inline TInt RequiredBufferSize() const {return iRequiredBufferSize;}
    65 	inline TInt RequiredBufferSize() const {return iRequiredBufferSize;}
    69 	inline HBufC& Path() { return *iPath; }
    66 	inline HBufC& Path() { return *iPath; }
    70 private:
    67 private:
    76 
    73 
    77 /**
    74 /**
    78 Utility class which does synchronous and asynchronous file recognitions of a directory
    75 Utility class which does synchronous and asynchronous file recognitions of a directory
    79 @internalComponent
    76 @internalComponent
    80 */
    77 */
    81 class CFileRecognitionUtility : public CActive
    78 NONSHARABLE_CLASS(CFileRecognitionUtility) : public CActive
    82 	{
    79 	{
    83 public:
    80 public:
    84 	CFileRecognitionUtility(CApaAppListServer& aServer, TInt aMaxBufSize, RFs& aFs);
    81 	CFileRecognitionUtility(CApaAppArcServer& aServer, TInt aMaxBufSize, RFs& aFs);
    85 	~CFileRecognitionUtility();
    82 	~CFileRecognitionUtility();
    86 	void RecognizeSynchronouslyL(CDirectoryRecognitionResult& aResult);
    83 	void RecognizeSynchronouslyL(CDirectoryRecognitionResult& aResult);
    87 	void RecognizeAsynchronously(CDirectoryRecognitionResult& aResult, const RMessage2& aMessage);
    84 	void RecognizeAsynchronously(CDirectoryRecognitionResult& aResult, const RMessage2& aMessage);
    88 	void CancelRecognitionRequest();
    85 	void CancelRecognitionRequest();
    89 protected:
    86 protected:
    92 private:
    89 private:
    93 	void NextStep();
    90 	void NextStep();
    94 	void RunL();
    91 	void RunL();
    95 	void DoCancel();
    92 	void DoCancel();
    96 	TInt BufferSizeL() const;
    93 	TInt BufferSizeL() const;
    97 	
       
    98 private:
    94 private:
    99 	HBufC* iPath;
    95 	HBufC* iPath;
   100 	CDirectoryRecognitionResult* iResult;
    96 	CDirectoryRecognitionResult* iResult;
   101 	CApaAppListServer& iServer;
    97 	CApaAppArcServer& iServer;
   102 	TInt iMaxBufSize;
    98 	TInt iMaxBufSize;
   103 	RFs& iFs;
    99 	RFs& iFs;
   104 	CDir* iEntryList;
   100 	CDir* iEntryList;
   105 	TInt iIndex;
   101 	TInt iIndex;
   106 	TInt iStep;
   102 	TInt iStep;
   107 	RMessage2 iMessage;
   103 	RMessage2 iMessage;
   108 	};
   104 	};
   109 
   105 
   110 #endif	// __APSRECUTIL_H__
   106 #endif	// __APSRECUTIL_H__
       
   107