telephonyprotocols/csdagt/script/SCHAT.H
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 /**
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Header for classes for manipulting of received data.
       
    16 * This should all be 8-bit so we don't need to deal with any conversions at this level.
       
    17 * 
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 /**
       
    24  @file Schat.h
       
    25 */
       
    26 
       
    27 #if !defined(__SCHAT_H__)
       
    28 #define __SCHAT_H__
       
    29 
       
    30 #include <e32base.h>
       
    31 
       
    32 // Forward declarations 
       
    33 class CCommChatString;
       
    34 
       
    35 class MCommChatNotify
       
    36 /**
       
    37 Interface between CScriptIO and CCommChatter object.
       
    38 
       
    39 @internalComponent
       
    40 */
       
    41 	{
       
    42 public:
       
    43 	virtual void ChatStringMatch(TInt aIndex)=0;
       
    44 	virtual void ChatTimeout()=0;
       
    45 	};
       
    46 
       
    47 class CCommChatter : public CTimer
       
    48 /**
       
    49 Deals with data received from the comm port.  One of these for each CScriptIO object.
       
    50 
       
    51 @internalComponent
       
    52 */
       
    53 	{
       
    54 public:
       
    55 	static CCommChatter* NewL(MCommChatNotify* aNotify,TInt aPriority,TInt aBufferSize);
       
    56 	CCommChatter(MCommChatNotify* aNotify,TInt aPriority);
       
    57 	virtual ~CCommChatter();	
       
    58 	void ConstructL(TInt aBufSize);
       
    59 	void ClearHistory();
       
    60 	void AddChar(TText8 aChar);
       
    61 	TBool Match(const CCommChatString* aString) const;
       
    62 	TBool MatchF(const CCommChatString* aString) const;
       
    63 	void AddString(CCommChatString* aString);
       
    64 	void RemoveString(CCommChatString* aString);
       
    65 	void DeleteAllAndStop();
       
    66 	void StartTimer(const TTimeIntervalMicroSeconds32& aTimeout);
       
    67 	void StopTimer();
       
    68 protected:
       
    69 	virtual void RunL();
       
    70 protected:
       
    71 	MCommChatNotify* iNotify;
       
    72 	TDblQue<CCommChatString> iList;
       
    73 	TText8* iBuffer;
       
    74 	TText8* iBufferEnd;
       
    75 	TText8* iLastChar;	///< Last character added
       
    76 	TInt iCount;		///< No of chars added to buffer
       
    77 	};
       
    78 
       
    79 
       
    80 class CCommChatString : public CBase
       
    81 /**
       
    82 @internalComponent
       
    83 */
       
    84 	{
       
    85 public:
       
    86 	static CCommChatString* NewL(const TDesC8& aDes,TBool aIsFolded);
       
    87 	CCommChatString();
       
    88 	void ConstructL(const TDesC8& aDes,TBool aIsFolded);
       
    89 	virtual ~CCommChatString();
       
    90 	inline TText8 LastChar() const { return *iLastChar; }
       
    91 	inline TInt Length() const { return (iLastChar-iString)+1; }
       
    92 	inline const TText8* Ptr() const { return iString; }
       
    93 	inline const TText8* EndPtr() const { return iLastChar; }
       
    94 	inline TBool IsFolded() const { return iIsFolded; }
       
    95 	inline TPtrC8 Des() { return TPtrC8(Ptr(), Length()); }
       
    96 private:
       
    97 	friend class CCommChatter;
       
    98 	TDblQueLink iLink;
       
    99 protected:
       
   100 	TBool iIsFolded;
       
   101 	TText8* iString;
       
   102 	TText8* iLastChar;
       
   103 	};
       
   104 
       
   105 #endif