core/src/command_factory.h
author Tom Sutcliffe <thomas.sutcliffe@accenture.com>
Sat, 06 Nov 2010 20:15:03 +0000
changeset 87 63fd51b1ff80
parent 78 b3ffff030d5c
permissions -rw-r--r--
Changed the CCommandFactory logic that searches for commands. * Changed the CCommandFactory logic that searches for commands; it now scans \resource\cif\fshell rather than \sys\bin. This means that the 'help' command now works on the emulator and on installs without all capabilities. * Fixed wslog ciftest

// command_factory.h
// 
// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the "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:
// Accenture - Initial contribution
//


#ifndef __COMMAND_FACTORY_H__
#define __COMMAND_FACTORY_H__

#include <e32base.h>
#include "command_wrappers.h"
class CCommandConstructorBase;
class CThreadPool;
#include "error.h"

class RFs;
class MCommand;
class CCommandSet;

class CCommandFactory : public CActive
	{
public:
	static CCommandFactory* NewL(RFs& aFs);
	~CCommandFactory();
	MCommand* CreateCommandL(const TDesC& aCommandName, TError& aErrorContext, const TDesC& aArguments);
	void ListCommandsL(RArray<TPtrC>& aList);
	TInt CountUniqueCommandsL();
	void GetCommandInfoL(const TDesC& aCommand, RLtkBuf16& aDescriptionBuf);
private:
	CCommandFactory(RFs& aFs);
	void ConstructL();
	void WatchFileSystem();
	void AddCommandL(CCommandConstructorBase* aCommandConstructor);
	void AddThreadCommandL(TCommandConstructor aConstructor, TUint aFlags = 0);
	void AddThreadCommandL(const TDesC& aCommandName, TCommandConstructor aConstructor, TUint aAttributes, TUint aFlags = 0);
	void AddAliasCommandL(const TDesC& aAliasName, TCommandConstructor aConstructor, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments, TUint aAttributes, TUint aFlags = 0);
	void CheckExternalCommands();
	void FindExternalCommandsL();
	void AppendExternalCommandsL(const TUidType& aUidType, const TDesC& aExtension);
	void AppendExternalCifCommandsL();
	void DoAppendExternalCommandL(const TEntry& aEntry, TInt aUid);
	void WaitLC() const;
	TInt FindCommandL(const TDesC& aCommandName);
	MCommand* DoCreateCommandL(const TDesC& aCommandName, const TDesC& aArguments, RProcess& aProcess);
	static void Signal(TAny* aSelf);
private: // From CActive.
	virtual void RunL();
	virtual void DoCancel();
	virtual TInt RunError(TInt aError);

private:
	RFs& iFs;
	mutable RMutex iLock;
	RPointerArray<CCommandConstructorBase> iCommands;
	TDriveList iDriveList;
	TBool iFileSystemScanned;
	TBool iFailedToScanFileSystem;
	TThreadId iFactoryThreadId; // The one the CCommandFactory active object lives in
	RAllocator* iFactoryAllocator;
	CThreadPool* iThreadPool;
	};


#endif // __COMMAND_FACTORY_H__