telephonyserverplugins/multimodetsy/test/Te_LoopBack/Te_LoopBackSCHAT.H
author Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
Thu, 06 May 2010 15:10:38 +0100
branchopencode
changeset 24 6638e7f4bd8f
parent 0 3553901f7fa8
permissions -rw-r--r--
opencode
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     2
// All rights reserved.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     3
// This component and the accompanying materials are made available
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     5
// which accompanies this distribution, and is available
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     7
//
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     8
// Initial Contributors:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     9
// Nokia Corporation - initial contribution.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    10
//
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    11
// Contributors:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    12
//
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    13
// Description:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    14
// This file defines the classes necessary for buffer and expect string management in the 
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    15
// regression test harness.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    16
// 
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    17
//
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    18
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    19
/**
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    20
 @file
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    21
 @internalComponent
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    22
*/
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    23
#if !defined(__CHAT_H__)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    24
#define __CHAT_H__
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    25
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    26
#include <e32std.h>
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    27
#include <e32base.h>
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    28
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    29
const TInt KChatBufferSize = 400;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    30
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    31
struct TInputBufferMark {
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    32
	TText8* iMarkChar;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    33
	TUint iMarkWrap;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    34
	};
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    35
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    36
class CCommChatString;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    37
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    38
/**
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    39
 * A mixin class used to notify the derived class that either a string match has been
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    40
 * found or a time out has occurred.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    41
 */
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    42
class MCommChatNotify
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    43
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    44
public:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    45
	// Used to notify the derived class that a string has been matched.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    46
	virtual void ChatStringMatchL(CCommChatString* aCs)=0;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    47
	// Used to notify the derived class that the timer has expired.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    48
	virtual void ChatTimeout()=0;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    49
	};
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    50
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    51
/**
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    52
 * CCommChatter class is used to buffer and manage the information coming from the GSMTSY and
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    53
 * to correlate it with the expected strings (see class CCommChatString).  This is derived from
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    54
 * the CTimer class.  Every time a character is added to the iBuffer, the outstanding chat strings
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    55
 * are checked to see if they have completed.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    56
 */
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    57
class CCommChatter : public CTimer
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    58
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    59
public:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    60
	CCommChatter(MCommChatNotify* aNotify, TInt aPriority);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    61
	virtual ~CCommChatter();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    62
	void CreateL(TInt aBufferSize);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    63
	TBool Match(const CCommChatString* aString) const;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    64
	TBool MatchF(const CCommChatString* aString) const;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    65
	void AddCharL(TText8 aChar);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    66
	CCommChatString* AddString(const TDesC8& aString);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    67
	void RemoveString(CCommChatString* aString);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    68
	void GetChatBufferMarker(TInputBufferMark& aBufferMarker);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    69
	TPtrC8 GetChatBufferLC(TInputBufferMark& aBufferMarker);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    70
	void StartTimer(const TTimeIntervalMicroSeconds32 aTimeout);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    71
	void StopTimer();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    72
	void DeleteAllAndStop();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    73
protected:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    74
	virtual void RunL();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    75
	void ClearHistory();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    76
protected:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    77
	MCommChatNotify* iNotify;		//< Pointer to Mixin class for notifications.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    78
	TDblQue<CCommChatString> iList;	//< Doubly linked list of all outstanding Chat strings
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    79
	TText8* iBuffer;				//< Pointer to allocated buffer to contain cmds/data from GSMTSY
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    80
	TText8* iBufferEnd;				//< Pointer to last character in iBuffer
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    81
	TText8* iLastChar;				//< Last character added
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    82
	TUint iMarkWrapCnt;				//< Count of number of times iBuffer has wrapped (used in buffer marking)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    83
	TInt iCount;					//< No of chars added to buffer
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    84
	};
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    85
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    86
/**
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    87
 * This class is the object that manages expect strings for the Regression Test Harness.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    88
 * It is derived from CBase.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    89
 * A Chat string in the regression test harness is created by ERx type commands in the
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    90
 * command script.  These chat strings are the expect strings and are used to match up
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    91
 * the progress of the modem to the expected progress of the script.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    92
 */
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    93
class CCommChatString : public CBase
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    94
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    95
public:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    96
	static CCommChatString* NewL(const TDesC8& aDes, TBool aIsFolded);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    97
	CCommChatString();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    98
	virtual ~CCommChatString();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    99
	void CreateL(const TDesC8& aDes, TBool aIsFolded);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   100
	inline TText8 LastChar() const { return *iLastChar; }
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   101
	inline TInt Length() const { return (iLastChar-iString)+1; }
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   102
	inline const TText8* Ptr() const { return iString; }
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   103
	inline const TText8* EndPtr() const { return iLastChar; }
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   104
	inline TBool IsFolded() const { return iIsFolded; }
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   105
	inline TPtrC8 Des() { return TPtrC8(Ptr(), Length()); }
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   106
protected:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   107
	TBool iIsFolded;		//< Is this string folded or not
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   108
	TText8* iString;		//< Pointer to memory which contains expected string (memory from heap).
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   109
	TText8* iLastChar;		//< Pointer to last character in iString
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   110
private:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   111
	friend class CCommChatter;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   112
	TDblQueLink iLink;		//< Links to previous and next chat strings in linked list.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   113
	};
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   114
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   115
#endif