commands/tail/tail.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // tail.h
       
     2 // 
       
     3 // Copyright (c) 2005 - 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 #include <fshell/ioutils.h>
       
    14 #include "file_reader.h"
       
    15 #include "character_converter.h"
       
    16 
       
    17 using namespace IoUtils;
       
    18 
       
    19 class CFileWatcher;
       
    20 class CTrailingLineFinder;
       
    21 
       
    22 
       
    23 class MTrailingLineFinderObserver
       
    24 	{
       
    25 public:
       
    26 	virtual void HandleTrailingLines(TInt aNumLinesFound, TInt aEndFilePos) = 0;
       
    27 	virtual void HandleTrailingLineError(TInt aError) = 0;
       
    28 	};
       
    29 
       
    30 
       
    31 class MFileChangeObserver
       
    32 	{
       
    33 public:
       
    34 	virtual void HandleFileChange(const TDesC& aFileName) = 0;
       
    35 	};
       
    36 
       
    37 
       
    38 class CCmdTail : public CCommandBase, public MTrailingLineFinderObserver, public MFileChangeObserver, public MFileReaderObserver
       
    39 	{
       
    40 public:
       
    41 	static CCommandBase* NewLC();
       
    42 	~CCmdTail();
       
    43 private:
       
    44 	CCmdTail();
       
    45 	void ConstructL();
       
    46 	void WriteChunkToConsoleL(const TDesC8& aData, TReadType aType);
       
    47 private: // From CCommandBase.
       
    48 	virtual const TDesC& Name() const;
       
    49 	virtual void DoRunL();
       
    50 	virtual void OptionsL(RCommandOptionList& aOptions);
       
    51 	virtual void ArgumentsL(RCommandArgumentList& aArguments);
       
    52 private: // From MTrailingLineFinderObserver.
       
    53 	virtual void HandleTrailingLines(TInt aNumLinesFound, TInt aEndFilePos);
       
    54 	virtual void HandleTrailingLineError(TInt aError);
       
    55 private: // From MFileChangeObserver.
       
    56 	virtual void HandleFileChange(const TDesC& aFileName);
       
    57 private: // From MFileReaderObserver.
       
    58 	virtual void HandleFileData(const TDesC8& aData, TReadType aType, TBool& aContinue);
       
    59 	virtual void HandleFileReadError(TInt aError);
       
    60 private:
       
    61 	TFileName2 iFileName;
       
    62 	CCharacterConverter* iCharacterConverter;
       
    63 	CTrailingLineFinder* iTrailingLineFinder;
       
    64 	CFileWatcher* iFileWatcher;
       
    65 	CFileReader* iFileReader;
       
    66 	TBool iFollow;
       
    67 	TInt iNumLines;
       
    68 	TInt iFilePos;
       
    69 	};