core/src/fshell.h
changeset 0 7f656887cf89
child 78 b3ffff030d5c
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // fshell.h
       
     2 // 
       
     3 // Copyright (c) 2006 - 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 // 
       
     9 // Initial Contributors:
       
    10 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 
       
    14 #ifndef __SHELL_H__
       
    15 #define __SHELL_H__
       
    16 
       
    17 #include <e32base.h>
       
    18 #include <fshell/iocli.h>
       
    19 #include <fshell/ioutils.h>
       
    20 #include "job.h"
       
    21 #include "error.h"
       
    22 #include "console.h"
       
    23 #include <fshell/line_editor.h>
       
    24 #include <fshell/iocons_writer.h>
       
    25 
       
    26 
       
    27 _LIT(KScriptPath, "SCRIPT_PATH");
       
    28 _LIT(KScriptName, "SCRIPT_NAME");
       
    29 _LIT(KScriptLine, "SCRIPT_LINE");
       
    30 _LIT(KScriptArgCount, "ARG_COUNT");
       
    31 _LIT(KKeepGoing, "KEEP_GOING");
       
    32 
       
    33 class CLineCompleter;
       
    34 class CCommandFactory;
       
    35 
       
    36 
       
    37 class CShell : public IoUtils::CCommandBase, public MConsoleObserver, public MLineEditorObserver, public MJobObserver, public MParserObserver
       
    38 	{
       
    39 public:
       
    40 	static CShell* NewLC();
       
    41 	~CShell();
       
    42 	CCommandFactory& CommandFactory();
       
    43 	void ClaimJobsLockLC();
       
    44 	TInt BringJobToForeground(TInt aJobId);
       
    45 	void SendJobToBackground(TInt aJobId);
       
    46 	const RPointerArray<CJob>& Jobs() const;
       
    47 	CJob* Job(TInt aId);
       
    48 	TInt DisownJob(TInt aId);
       
    49 	static HBufC* ReadScriptL(const TDesC& aScriptName, const TDesC* aArguments, IoUtils::CEnvironment& aEnv, RFs& aFs, TIoHandleSet& aIoHandles, TBool& aHelpPrinted, RPointerArray<HBufC>* aAdditionalPrefixArguments=NULL);
       
    50 private:
       
    51 	CShell();
       
    52 	void ConstructL();
       
    53 	void PrintPrompt();
       
    54 	void PrintErr(TInt aError);
       
    55 	void ProcessLineL(const TDesC& aLine);
       
    56 	TInt NextJobId();
       
    57 	CJob& ForegroundJob();
       
    58 	void SetToForeground();
       
    59 	static void ReleaseJobsLock(TAny* aSelf);
       
    60 private: // From IoUtils::CCommandBase.
       
    61 	virtual const TDesC& Name() const;
       
    62 	virtual void DoRunL();
       
    63 	virtual void OptionsL(RCommandOptionList& aOptions);
       
    64 	virtual void ArgumentsL(RCommandArgumentList& aArguments);
       
    65 	virtual void StdinChange(TUint aChange);
       
    66 private: // From MConsoleObserver.
       
    67 	virtual void CoHandleKey(TUint aKeyCode, TUint aModifiers);
       
    68 	virtual void CoHandleError(TInt aError);
       
    69 private: // From MLineEditorObserver.
       
    70 	virtual void LeoHandleLine(const TDesC& aLine);
       
    71 private: // From MJobObserver.
       
    72 	virtual void HandleJobComplete(CJob& aJob, const TError& aError);
       
    73 private: // From MParserObserver.
       
    74 	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
       
    75 private:
       
    76 	RFs iFs;
       
    77 	CConsoleReader* iConsole;
       
    78 	CLineEditor* iLineEditor;
       
    79 	CLineCompleter* iLineCompleter;
       
    80 	CCommandFactory* iCommandFactory;
       
    81 	RPointerArray<CJob> iJobs;
       
    82 	HBufC* iScriptData;
       
    83 	CParser* iParser;
       
    84 	TInt iForegroundJobId;
       
    85 	TInt iNextJobId;
       
    86 	TIoConsWriterAdaptor iWriterAdaptor;
       
    87 	TFileName2 iScriptName;
       
    88 	HBufC* iScriptArgs;
       
    89 	HBufC* iOneLiner;
       
    90 	TBool iKeepGoing;
       
    91 	TBool iIgnoreNextStdinChange;
       
    92 	RMutex iJobsLock;
       
    93 	};
       
    94 
       
    95 extern CShell* gShell;
       
    96 extern TInt gExitValue;
       
    97 void Log(TRefByValue<const TDesC8> aFmt, ...);
       
    98 
       
    99 
       
   100 #endif // __SHELL_H__