24
|
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 |
// This file defines the classes necessary for buffer and expect string management in the
|
|
15 |
// regression test harness.
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
@internalComponent
|
|
22 |
*/
|
|
23 |
#if !defined(__CHAT_H__)
|
|
24 |
#define __CHAT_H__
|
|
25 |
|
|
26 |
#include <e32std.h>
|
|
27 |
#include <e32base.h>
|
|
28 |
|
|
29 |
const TInt KChatBufferSize = 400;
|
|
30 |
|
|
31 |
struct TInputBufferMark {
|
|
32 |
TText8* iMarkChar;
|
|
33 |
TUint iMarkWrap;
|
|
34 |
};
|
|
35 |
|
|
36 |
class CCommChatString;
|
|
37 |
|
|
38 |
/**
|
|
39 |
* A mixin class used to notify the derived class that either a string match has been
|
|
40 |
* found or a time out has occurred.
|
|
41 |
*/
|
|
42 |
class MCommChatNotify
|
|
43 |
{
|
|
44 |
public:
|
|
45 |
// Used to notify the derived class that a string has been matched.
|
|
46 |
virtual void ChatStringMatchL(CCommChatString* aCs)=0;
|
|
47 |
// Used to notify the derived class that the timer has expired.
|
|
48 |
virtual void ChatTimeout()=0;
|
|
49 |
};
|
|
50 |
|
|
51 |
/**
|
|
52 |
* CCommChatter class is used to buffer and manage the information coming from the GSMTSY and
|
|
53 |
* to correlate it with the expected strings (see class CCommChatString). This is derived from
|
|
54 |
* the CTimer class. Every time a character is added to the iBuffer, the outstanding chat strings
|
|
55 |
* are checked to see if they have completed.
|
|
56 |
*/
|
|
57 |
class CCommChatter : public CTimer
|
|
58 |
{
|
|
59 |
public:
|
|
60 |
CCommChatter(MCommChatNotify* aNotify, TInt aPriority);
|
|
61 |
virtual ~CCommChatter();
|
|
62 |
void CreateL(TInt aBufferSize);
|
|
63 |
TBool Match(const CCommChatString* aString) const;
|
|
64 |
TBool MatchF(const CCommChatString* aString) const;
|
|
65 |
void AddCharL(TText8 aChar);
|
|
66 |
CCommChatString* AddString(const TDesC8& aString);
|
|
67 |
void RemoveString(CCommChatString* aString);
|
|
68 |
void GetChatBufferMarker(TInputBufferMark& aBufferMarker);
|
|
69 |
TPtrC8 GetChatBufferLC(TInputBufferMark& aBufferMarker);
|
|
70 |
void StartTimer(const TTimeIntervalMicroSeconds32 aTimeout);
|
|
71 |
void StopTimer();
|
|
72 |
void DeleteAllAndStop();
|
|
73 |
protected:
|
|
74 |
virtual void RunL();
|
|
75 |
void ClearHistory();
|
|
76 |
protected:
|
|
77 |
MCommChatNotify* iNotify; //< Pointer to Mixin class for notifications.
|
|
78 |
TDblQue<CCommChatString> iList; //< Doubly linked list of all outstanding Chat strings
|
|
79 |
TText8* iBuffer; //< Pointer to allocated buffer to contain cmds/data from GSMTSY
|
|
80 |
TText8* iBufferEnd; //< Pointer to last character in iBuffer
|
|
81 |
TText8* iLastChar; //< Last character added
|
|
82 |
TUint iMarkWrapCnt; //< Count of number of times iBuffer has wrapped (used in buffer marking)
|
|
83 |
TInt iCount; //< No of chars added to buffer
|
|
84 |
};
|
|
85 |
|
|
86 |
/**
|
|
87 |
* This class is the object that manages expect strings for the Regression Test Harness.
|
|
88 |
* It is derived from CBase.
|
|
89 |
* A Chat string in the regression test harness is created by ERx type commands in the
|
|
90 |
* command script. These chat strings are the expect strings and are used to match up
|
|
91 |
* the progress of the modem to the expected progress of the script.
|
|
92 |
*/
|
|
93 |
class CCommChatString : public CBase
|
|
94 |
{
|
|
95 |
public:
|
|
96 |
static CCommChatString* NewL(const TDesC8& aDes, TBool aIsFolded);
|
|
97 |
CCommChatString();
|
|
98 |
virtual ~CCommChatString();
|
|
99 |
void CreateL(const TDesC8& aDes, TBool aIsFolded);
|
|
100 |
inline TText8 LastChar() const { return *iLastChar; }
|
|
101 |
inline TInt Length() const { return (iLastChar-iString)+1; }
|
|
102 |
inline const TText8* Ptr() const { return iString; }
|
|
103 |
inline const TText8* EndPtr() const { return iLastChar; }
|
|
104 |
inline TBool IsFolded() const { return iIsFolded; }
|
|
105 |
inline TPtrC8 Des() { return TPtrC8(Ptr(), Length()); }
|
|
106 |
protected:
|
|
107 |
TBool iIsFolded; //< Is this string folded or not
|
|
108 |
TText8* iString; //< Pointer to memory which contains expected string (memory from heap).
|
|
109 |
TText8* iLastChar; //< Pointer to last character in iString
|
|
110 |
private:
|
|
111 |
friend class CCommChatter;
|
|
112 |
TDblQueLink iLink; //< Links to previous and next chat strings in linked list.
|
|
113 |
};
|
|
114 |
|
|
115 |
#endif
|