|
1 /* |
|
2 * Copyright (c) 2009-2010 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 * Initial Contributors: |
|
9 * Nokia Corporation - initial contribution. |
|
10 * Contributors: |
|
11 * |
|
12 * Description: |
|
13 * MSRP Implementation |
|
14 * |
|
15 */ |
|
16 |
|
17 #ifndef CMSRPMSGPARSER_H_ |
|
18 #define CMSRPMSGPARSER_H_ |
|
19 |
|
20 #ifdef UT_TEST |
|
21 #include "../../tsrc/conn_parser/inc/CMSRPMessageHandler.h" |
|
22 #else |
|
23 #include "CMSRPMessageHandler.h" |
|
24 #endif |
|
25 |
|
26 #include "MMSRPParserObserver.h" |
|
27 #include "MSRPBuffer.h" |
|
28 |
|
29 #define MSRP_COLON ':' |
|
30 #define MSRP_SPACE ' ' |
|
31 #define MSRP_CARRIAGE '\r' |
|
32 #define MSRP_TERMINATE '#' |
|
33 #define MSRP_CONTINUE '+' |
|
34 #define MSRP_END '$' |
|
35 |
|
36 #define KMSRPIDLenMax 32 |
|
37 #define KMSRPIDLenMin 4 |
|
38 #define KMSRPEndTokenMax KMSRPIDLenMax+8+2 //init-crlf |
|
39 |
|
40 class CMSRPMsgParser: public CBase |
|
41 { |
|
42 friend class CMSRPParser; |
|
43 public: |
|
44 enum TParseState |
|
45 { |
|
46 EIdle = 0, |
|
47 ETitleLine, |
|
48 EToPath, |
|
49 EFromPath, |
|
50 //EMandatoryHeader, |
|
51 EOptionalHeaders, |
|
52 EBody, |
|
53 EExtraCRLF, |
|
54 EEndofEndLine |
|
55 }; |
|
56 |
|
57 enum TMatchType |
|
58 { |
|
59 ENoMatch, |
|
60 EFullMatch, |
|
61 EPartialMatch |
|
62 }; |
|
63 |
|
64 static CMSRPMsgParser* NewL(MMSRPParserObserver& aConnection); |
|
65 virtual ~CMSRPMsgParser(); |
|
66 |
|
67 TBool ParseL(); |
|
68 |
|
69 private: |
|
70 CMSRPMsgParser(MMSRPParserObserver& aConnection); |
|
71 void ConstructL(); |
|
72 |
|
73 TBool HandleFullMatchL(TPtrC8& aToken, TInt aMatchPos, TBool aCopyToLocal = FALSE); |
|
74 TBool HandlePartialMatchL(TPtrC8& aToken, TInt aCurBufMatchPos); |
|
75 TBool HandleNoMatchL(TPtrC8& aToken, TInt aCurBufMatchPos); |
|
76 |
|
77 void HandleStateL(const TDesC8& aString, TInt aMatchPos); |
|
78 void HandleTitleLineL(const TDesC8& aString, TInt aMatchPos); |
|
79 void HandleHeaderL(const TDesC8& aString, TInt aMatchPos); |
|
80 void HandleOptionalHeaderL(const TDesC8& aString, TInt aMatchPos); |
|
81 void HandleBodyL(const TDesC8& aString, TInt aMatchPos); |
|
82 void HandleXtraCrlfL(const TDesC8& aString, TInt aMatchPos); |
|
83 void HandleEndofEndLineL(const TDesC8& aString, TInt aMatchPos); |
|
84 |
|
85 TMatchType FindToken(const TDesC8& aString, const TDesC8& aToken, TInt& aMatchPos); |
|
86 |
|
87 |
|
88 private: |
|
89 MMSRPParserObserver& iConnection; |
|
90 RPointerArray<RMsrpBuf> iParseBuffers; |
|
91 TParseState iState; |
|
92 RMsrpBuf* iLocalBuf;//keep it above pool |
|
93 CMSRPMessageHandler* iMessage; |
|
94 CMSRPBufPool iBufPool; |
|
95 HBufC8* iEndToken; |
|
96 }; |
|
97 #endif /* CMSRPMSGPARSER_H_ */ |