networkingtestandutils/networkingintegrationtest/NTRas/CHAT.H
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #if !defined(__CHAT_H__)
       
    17 #define __CHAT_H__
       
    18 
       
    19 #ifndef	_NOECONS
       
    20 #define	_NOECONS
       
    21 #endif
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 class CCommChatString;
       
    26 
       
    27 class MCommChatNotify
       
    28 /**
       
    29 @internalComponent
       
    30 */
       
    31 	{
       
    32 public:
       
    33 	virtual void ChatStringMatch(CCommChatString* aString)=0;
       
    34 	virtual void ChatTimeout()=0;
       
    35 	};
       
    36 
       
    37 class CCommChatter : public CTimer
       
    38 /**
       
    39 @internalComponent
       
    40 */
       
    41 	{
       
    42 public:
       
    43 	CCommChatter(MCommChatNotify* aNotify, TInt aPriority);
       
    44 	virtual ~CCommChatter();	
       
    45 	void CreateL(TInt aBufferSize);
       
    46 	TBool Match(const CCommChatString* aString) const;
       
    47 	TBool MatchF(const CCommChatString* aString) const;
       
    48 	void AddChar(TText8 aChar);
       
    49 	void ClearHistory();
       
    50 	void AddString(CCommChatString* aString);
       
    51 	void RemoveString(CCommChatString* aString);
       
    52 	void StartTimer(TTimeIntervalMicroSeconds32 aTimeout);
       
    53 	void StopTimer();
       
    54 	void DeleteAllAndStop();
       
    55 protected:
       
    56 	virtual void RunL();
       
    57 protected:
       
    58 	MCommChatNotify* iNotify;
       
    59 	TDblQue<CCommChatString> iList;
       
    60 	TText8* iBuffer;
       
    61 	TText8* iBufferEnd;
       
    62 	TText8* iLastChar;	// Last character added
       
    63 	TInt iCount;		// No of chars added to buffer
       
    64 	};
       
    65 
       
    66 class CCommChatString : public CBase
       
    67 /**
       
    68 @internalComponent
       
    69 */
       
    70 	{
       
    71 public:
       
    72 	static CCommChatString* NewL(const TDesC8& aDes, TBool aIsFolded);
       
    73 	CCommChatString();
       
    74 	virtual ~CCommChatString();
       
    75 	void CreateL(const TDesC8& aDes, TBool aIsFolded);
       
    76 	inline TText8 LastChar() const { return *iLastChar; }
       
    77 	inline TInt Length() const { return (iLastChar-iString)+1; }
       
    78 	inline const TText8* Ptr() const { return iString; }
       
    79 	inline const TText8* EndPtr() const { return iLastChar; }
       
    80 	inline TBool IsFolded() const { return iIsFolded; }
       
    81 	inline TPtrC8 Des() { return TPtrC8(Ptr(), Length()); }
       
    82 protected:
       
    83 	TBool iIsFolded;
       
    84 	TText8* iString;
       
    85 	TText8* iLastChar;
       
    86 private:
       
    87 	friend class CCommChatter;
       
    88 	TDblQueLink iLink;
       
    89 	};
       
    90 
       
    91 #endif