|
1 // Copyright (c) 2002-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 // |
|
15 |
|
16 #ifndef __CMESSAGECOMPOSERDRIVER_H__ |
|
17 #define __CMESSAGECOMPOSERDRIVER_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <rhttpmessagecomposer.h> |
|
21 #include <mhttpmessagecomposerobserver.h> |
|
22 |
|
23 #include "mbodydatasupplierobserver.h" |
|
24 |
|
25 class MDriverObserver; |
|
26 class CBodyDataSupplier; |
|
27 |
|
28 class CMessageComposerDriver : public CActive, |
|
29 public MHttpMessageComposerObserver, |
|
30 public MBodyDataSupplierObserver |
|
31 { |
|
32 public: // methods |
|
33 |
|
34 static CMessageComposerDriver* NewL(MDriverObserver& aObserver); |
|
35 |
|
36 virtual ~CMessageComposerDriver(); |
|
37 |
|
38 void SetMessageData(const TDesC8& aMessageData); |
|
39 void SetStartLine(const TDesC8& aToken1, const TDesC8& aToken2, const TDesC8& aToken3); |
|
40 void SetHeaderL(const TDesC8& aFieldName, const TDesC8& aFieldValue); |
|
41 void SetBodyDataL(const TDesC8& aBodyPart); |
|
42 void SetBodySize(TInt aSize); |
|
43 void SetTrailerL(const TDesC8& aFieldName, const TDesC8& aFieldValue); |
|
44 |
|
45 void Start(TInt aExpectedError, TBool aTestReset = EFalse); |
|
46 |
|
47 private: // methods from CActive |
|
48 |
|
49 virtual void RunL(); |
|
50 virtual void DoCancel(); |
|
51 virtual TInt RunError(TInt aError); |
|
52 |
|
53 private: // methods from MHttpMessageComposerObserver |
|
54 |
|
55 virtual void StartLineL(TPtrC8& aToken1, TPtrC8& aToken2, TPtrC8& aToken3); |
|
56 virtual TInt NextHeaderL(TPtrC8& aHeaderName, TPtrC8& aHeaderValue); |
|
57 virtual MHTTPDataSupplier* HasBodyL(); |
|
58 virtual TInt NextTrailerL(TPtrC8& aHeaderName, TPtrC8& aHeaderValue); |
|
59 virtual void MessageComplete(); |
|
60 virtual void MessageDataReadyL(); |
|
61 |
|
62 virtual TInt HandleComposeError(TInt aError); |
|
63 |
|
64 virtual void Reserved_MHttpMessageComposerObserver(); |
|
65 |
|
66 private: // methods from MBodyDataSupplierObserver |
|
67 |
|
68 virtual void NotifyMoreData(); |
|
69 |
|
70 private: // enums |
|
71 |
|
72 enum TMessageState |
|
73 { |
|
74 EPendingStartLine = 0, |
|
75 EPendingNextHeader, |
|
76 EPendingHasBody, |
|
77 EPendingNextTrailer, |
|
78 EPendingMessageComplete, |
|
79 EDone |
|
80 }; |
|
81 |
|
82 private: // helper classes |
|
83 |
|
84 class THeaderField |
|
85 { |
|
86 public: // methods |
|
87 |
|
88 THeaderField(const TDesC8& aName, const TDesC8& aValue) : iName(aName), iValue(aValue) {}; |
|
89 |
|
90 public: // attributes |
|
91 |
|
92 TPtrC8 iName; |
|
93 TPtrC8 iValue; |
|
94 |
|
95 }; |
|
96 |
|
97 private: // methods |
|
98 |
|
99 CMessageComposerDriver(MDriverObserver& aObserver); |
|
100 void ConstructL(); |
|
101 |
|
102 void CompleteSelf(); |
|
103 void DoReset(); |
|
104 |
|
105 private: |
|
106 |
|
107 MDriverObserver& iObserver; |
|
108 RHttpMessageComposer iMessageComposer; |
|
109 TMessageState iState; |
|
110 |
|
111 TPtrC8 iMessageData; |
|
112 TPtrC8 iExpectedData; |
|
113 TPtrC8 iStartLine1; |
|
114 TPtrC8 iStartLine2; |
|
115 TPtrC8 iStartLine3; |
|
116 |
|
117 RArray<THeaderField> iHeaders; |
|
118 TInt iHeaderIndex; |
|
119 |
|
120 RArray<THeaderField> iTrailers; |
|
121 TInt iTrailerIndex; |
|
122 CBodyDataSupplier* iBodyData; |
|
123 |
|
124 TInt iExpectedError; |
|
125 TBool iTestFailed; |
|
126 |
|
127 TInt iResetIndex; |
|
128 TBool iDoReset; |
|
129 TBool iReset; |
|
130 TMessageState iResetState; |
|
131 |
|
132 TInt iChunkCount; |
|
133 TInt iChunkIndex; |
|
134 |
|
135 TInt iMessageChunk; |
|
136 TInt iMessageIndex; |
|
137 |
|
138 }; |
|
139 |
|
140 #endif // __CMESSAGECOMPOSERDRIVER_H__ |