appfw/apparchitecture/apserv/APSRECUTIL.H
author William Roberts <williamr@symbian.org>
Fri, 23 Apr 2010 14:37:17 +0100
branchRCL_3
changeset 22 c82a39b81a38
parent 0 2e3d3ce01487
permissions -rw-r--r--
Rework addition of Symbian splash screen to reduce the source impact (uses SVG from Bug 2414) Notes: by using the OPTION SOURCEDIR parameter in the mifconv extension instructions, I can arrange to use the same source file name in sfimage, without having to export over the original Nokia file. This means that the name inside splashscreen.mbg is the same, which removes the need for the conditional compilation in SplashScreen.cpp, and gets rid of sf_splashscreen.mmp.

// 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 <e32base.h>
#include <apmrec.h>
#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<CRecognitionResult> 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__