|
1 /* |
|
2 * Copyright (c) 2005-2006 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 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: PnP Paos filter definitions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef WSPAOSFILTER_H |
|
21 #define WSPAOSFILTER_H |
|
22 |
|
23 |
|
24 #include <flogger.h> |
|
25 //#include <RXMLReader.h> |
|
26 #include <http/mhttpfilter.h> |
|
27 #include <http/cecomfilter.h> |
|
28 #include <http/mhttptransactioncallback.h> |
|
29 #include <httpstringconstants.h> |
|
30 #include <http/mhttpdatasupplier.h> // for MHTTPDataSupplier |
|
31 //#include <HDCUtil.h> // for HdcTrustedDomainList |
|
32 #include "HdcToPaosInterface.h" // for HdcTrustedDomainList |
|
33 |
|
34 //const TInt KMaxURLLength(255); |
|
35 typedef TBuf8<KMaxURLLength> TrustedDomain; |
|
36 typedef RArray<TrustedDomain> PaosTrustedDomainList; |
|
37 |
|
38 class CEComFilter; |
|
39 class CPnpPaosXml; |
|
40 |
|
41 /** |
|
42 PnP Mobile Services PAOS filter class. Adds PAOS content type to the outgoing |
|
43 http GET requests. Catches incoming PAOS requests and responds (with HTTP SOAP |
|
44 posts) giving the parameters the server asked for. Only accepts PAOS requests |
|
45 from certain URLs (for example help-portal.com, nokia.com). |
|
46 |
|
47 Message exchange pattern: |
|
48 1. HTTP GET (by the client) |
|
49 * includes PAOS headers |
|
50 2. HTTP 200 (server responds by making a PAOS reques) |
|
51 * Content type: application/vnd.paos+xml |
|
52 * SOAP envelope |
|
53 3. HTTP POST |
|
54 * Content type: application/vnd.paos+xml |
|
55 4. HTTP 200 |
|
56 |
|
57 @see Liberty Reverse HTTP binding for SOAP specification 1.1 |
|
58 */ |
|
59 |
|
60 class CPnpPaosFilter : |
|
61 public CEComFilter, |
|
62 public MHTTPFilter, |
|
63 public MHTTPDataSupplier |
|
64 /* public MHTTPTransactionCallback, to close a transaction |
|
65 * and open a new transaction |
|
66 */ |
|
67 { |
|
68 public: |
|
69 /** |
|
70 * This method creates an instance of the filter and |
|
71 * installs it to the HTTP session's filter queue. |
|
72 * This method is called by the ECOM framework. |
|
73 * |
|
74 * @param aSession a handle to the http session. |
|
75 * @return pointer to the newly installed filter. |
|
76 */ |
|
77 static CEComFilter* InstantiateL( TAny* aSession ); |
|
78 |
|
79 static CPnpPaosFilter* NewL( RHTTPSession* pSession ); |
|
80 virtual ~CPnpPaosFilter(); |
|
81 |
|
82 public: // from MHTTPDataSupplier |
|
83 |
|
84 TBool GetNextDataPart( TPtrC8& aDataPart ); |
|
85 void ReleaseData(); |
|
86 TInt OverallDataSize(); |
|
87 TInt Reset(); |
|
88 |
|
89 public: |
|
90 |
|
91 /** |
|
92 * From MHTTPFilterBase::MHFRunL. |
|
93 * Called when the filter's registration conditions are satisfied |
|
94 * for events that occur on a transaction. |
|
95 * Leaves with KErrNotSupported if making a PAOS request from |
|
96 * an untrusted domain. (other but nokia.com and help-portal.com) |
|
97 * , KErrArgument if PAOS request could not be parsed. |
|
98 * |
|
99 * @param aTransaction The transaction that the event has occurred on |
|
100 * @param aEvent The event that has occurred |
|
101 */ |
|
102 virtual void MHFRunL( RHTTPTransaction aTransaction, |
|
103 const THTTPEvent& aEvent); |
|
104 |
|
105 /** |
|
106 * From MHTTPFilterBase::MHFRunError. |
|
107 * Called when RunL leaves from a transaction event. |
|
108 * |
|
109 * @param aError The leave code that RunL left with |
|
110 * @param aTransaction The transaction that was being processed |
|
111 * @param aEvent The Event that was being processed |
|
112 * @return KErrNone if the error has been cancelled or the code |
|
113 * of the continuing error otherwise |
|
114 */ |
|
115 virtual TInt MHFRunError( TInt aError, |
|
116 RHTTPTransaction aTransaction, |
|
117 const THTTPEvent& aEvent); |
|
118 |
|
119 |
|
120 /** |
|
121 * From MHTTPFilter::MHFUnload. |
|
122 * Called when the filter is being removed from a session's |
|
123 * filter queue. |
|
124 * |
|
125 * @param aSession The session it's being removed from |
|
126 * @param aHandle The filter handle. Complex filters may need to |
|
127 * refer to this to keep track of which particular registration |
|
128 * is being unloaded |
|
129 */ |
|
130 virtual void MHFUnload( RHTTPSession aSession, THTTPFilterHandle aHandle); |
|
131 |
|
132 /** |
|
133 * From MHTTPFilter::MHFLoad. |
|
134 * Called when the filter is being added to the session's |
|
135 * filter queue. |
|
136 * |
|
137 * @param aSession The session it's being added to |
|
138 * @param aHandle The filter handle. Complex filters may need to keep |
|
139 * track of this, for instance if generating events in |
|
140 * response to external stimuli. |
|
141 */ |
|
142 virtual void MHFLoad( RHTTPSession aSession, THTTPFilterHandle aHandle ); |
|
143 |
|
144 private: |
|
145 CPnpPaosFilter( RHTTPSession* pSession ); |
|
146 void ConstructL(); |
|
147 |
|
148 private: |
|
149 /** |
|
150 Read allowed domains into iTrustedHdcDomains |
|
151 */ |
|
152 void ReadAllowedDomainsL(); |
|
153 |
|
154 /** |
|
155 Read allowed domains into iTrustedPnpDomains |
|
156 */ |
|
157 void ReadAllowedPnpDomainsL(); |
|
158 |
|
159 /** |
|
160 Add PAOS header and paos content type to accept header. |
|
161 */ |
|
162 void AddPaosHeadersL( RHTTPHeaders& requestHeaders ); |
|
163 |
|
164 /** |
|
165 Append the received data chunk to an internal buffer |
|
166 */ |
|
167 void CollectResponseBodyL( MHTTPDataSupplier& aBody ); |
|
168 |
|
169 /** |
|
170 Removes components EUriUserinfo, EUriPath, EUriQuery and EUriFragment |
|
171 from the uri. Only EUriScheme, EUriHost and EUriPort are left. |
|
172 */ |
|
173 void HostFromUriL( CUri8* aUri ); |
|
174 |
|
175 /** |
|
176 Check whether the content type of http headers match to the PAOS content |
|
177 type. |
|
178 */ |
|
179 TBool IsPaosContentTypeL( RHTTPHeaders& aHeaders ); |
|
180 |
|
181 /** |
|
182 Read PAOS request from iPnpPaosXml, construct a PAOS response and |
|
183 post it using PaosPostL. |
|
184 */ |
|
185 void PostPaosResponseL( RHTTPTransaction& aTransaction ); |
|
186 |
|
187 /** |
|
188 Cancels the current transaction and makes |
|
189 a HTTP Post with iPaosResponse as a body. |
|
190 */ |
|
191 void PaosPostL( RHTTPTransaction& aTransaction ); |
|
192 |
|
193 /** |
|
194 Save HDC trigger response to a file and open it with HelpDeskConnect client |
|
195 */ |
|
196 void HandleHdcTriggerL(); |
|
197 |
|
198 /** |
|
199 Add/Replace a header in RHTTPHeaders |
|
200 */ |
|
201 void SetHttpHeaderL( RHTTPHeaders& aMessage, const HTTP::TStrings aIndex, |
|
202 const TDesC8& aString ); |
|
203 |
|
204 TBool IsPaosHomeDomainL( const TPtrC8 aHost ); |
|
205 |
|
206 private: |
|
207 /** A counter for tracking filter usage. */ |
|
208 TInt iLoadCount; |
|
209 /** Transaction id of the current PAOS request. */ |
|
210 TInt iTransactionId; |
|
211 /** Filter name for filter listening for events */ |
|
212 RStringF iFilterName; |
|
213 /** The URL (exluding path info) in the current PAOS request */ |
|
214 CUri8* iPaosPostUrl; |
|
215 /** Parses the received XML documents and constructs a response */ |
|
216 CPnpPaosXml* iPnpPaosXml; |
|
217 /** http session */ |
|
218 RHTTPSession* iSession; |
|
219 /** string pool for storing RStrings */ |
|
220 RStringPool iSessionStringPool; |
|
221 /** Set to ETrue if a request made to nokia.com or help-portal.com |
|
222 This member tells if a PAOS request is allowed or not */ |
|
223 TBool iMakePaosResponse; |
|
224 #ifndef __SERIES60_ |
|
225 /** |
|
226 Set to ETrue when a HelpDeskConnect PAOS post has been successfully done. |
|
227 May be used to check if a HDC trigger file should be expected next |
|
228 */ |
|
229 TBool iHdcPaosPostDone; |
|
230 #endif |
|
231 /** Domains that are allowed to make PAOS requests for HDC parameters */ |
|
232 HdcTrustedDomainList iTrustedHdcDomains; |
|
233 |
|
234 PaosTrustedDomainList iTrustedPnpDomains; |
|
235 }; |
|
236 |
|
237 |
|
238 #endif // WSPAOSFILTER_H |
|
239 |