38 #define KMSRPEndTokenMax KMSRPIDLenMax+8+2 //init-crlf |
38 #define KMSRPEndTokenMax KMSRPIDLenMax+8+2 //init-crlf |
39 |
39 |
40 class CMSRPMsgParser: public CBase |
40 class CMSRPMsgParser: public CBase |
41 { |
41 { |
42 friend class CMSRPParser; |
42 friend class CMSRPParser; |
43 public: |
43 public: |
44 enum TParseState |
44 enum TParseState |
45 { |
45 { |
46 EIdle = 0, |
46 EIdle = 0, |
47 ETitleLine, |
47 ETitleLine, |
48 EToPath, |
48 EToPath, |
49 EFromPath, |
49 EFromPath, |
50 //EMandatoryHeader, |
50 //EMandatoryHeader, |
51 EOptionalHeaders, |
51 EOptionalHeaders, |
52 EBody, |
52 EBody, |
53 EExtraCRLF, |
53 EExtraCRLF, |
54 EEndofEndLine |
54 EEndofEndLine |
55 }; |
55 }; |
|
56 |
|
57 enum TMatchType |
|
58 { |
|
59 ENoMatch, |
|
60 EFullMatch, |
|
61 EPartialMatch |
|
62 }; |
56 |
63 |
57 enum TMatchType |
64 static CMSRPMsgParser* NewL(MMSRPParserObserver& aConnection); |
58 { |
65 virtual ~CMSRPMsgParser(); |
59 ENoMatch, |
66 |
60 EFullMatch, |
67 TBool ParseL(); |
61 EPartialMatch |
|
62 }; |
|
63 |
68 |
64 static CMSRPMsgParser* NewL(MMSRPParserObserver& aConnection); |
69 private: |
65 virtual ~CMSRPMsgParser(); |
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 * Check if this chunk belongs to one of messages received |
|
89 * earlier. If so, the messages are combined to one |
|
90 * entity |
|
91 */ |
|
92 void CheckMessageChunkL( ); |
66 |
93 |
67 TBool ParseL(); |
94 private: |
68 |
|
69 private: |
|
70 CMSRPMsgParser(MMSRPParserObserver& aConnection); |
|
71 void ConstructL(); |
|
72 |
95 |
73 TBool HandleFullMatchL(TPtrC8& aToken, TInt aMatchPos, TBool aCopyToLocal = FALSE); |
96 MMSRPParserObserver& iConnection; |
74 TBool HandlePartialMatchL(TPtrC8& aToken, TInt aCurBufMatchPos); |
97 RPointerArray<RMsrpBuf> iParseBuffers; |
75 TBool HandleNoMatchL(TPtrC8& aToken, TInt aCurBufMatchPos); |
98 TParseState iState; |
76 |
99 RMsrpBuf* iLocalBuf;//keep it above pool |
77 void HandleStateL(const TDesC8& aString, TInt aMatchPos); |
100 CMSRPMessageHandler* iMessage; |
78 void HandleTitleLineL(const TDesC8& aString, TInt aMatchPos); |
101 CMSRPBufPool iBufPool; |
79 void HandleHeaderL(const TDesC8& aString, TInt aMatchPos); |
102 HBufC8* iEndToken; |
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 |
103 |
85 TMatchType FindToken(const TDesC8& aString, const TDesC8& aToken, TInt& aMatchPos); |
104 // byte-range header included indicator |
|
105 TBool iByteRangeHeaderFound; |
86 |
106 |
87 |
107 // pool of incoming message chunks. This array contains unfinished |
88 private: |
108 // message chunks which are waiting for the next chunk to arrive |
89 MMSRPParserObserver& iConnection; |
109 RPointerArray< CMSRPMessageHandler > iIncomingMessageChunks; |
90 RPointerArray<RMsrpBuf> iParseBuffers; |
|
91 TParseState iState; |
|
92 RMsrpBuf* iLocalBuf;//keep it above pool |
|
93 CMSRPMessageHandler* iMessage; |
|
94 CMSRPBufPool iBufPool; |
|
95 HBufC8* iEndToken; |
|
96 }; |
110 }; |
97 #endif /* CMSRPMSGPARSER_H_ */ |
111 #endif /* CMSRPMSGPARSER_H_ */ |