|
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: For parsing PAOS XML documents |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <e32std.h> |
|
21 #include <xml/parser.h> // for compact XML parser |
|
22 #include <xml/documentparameters.h> // for RDocumentParameters |
|
23 #include <sysutil.h> |
|
24 #include <PnpToPaosInterface.h> |
|
25 #include "HdcToPaosInterface.h" |
|
26 |
|
27 #include "PnpPaosXml.h" |
|
28 #include "PnpPaosLogger.h" |
|
29 #include <PnpProvUtil.h> |
|
30 |
|
31 const TInt KMessageIdLength(12); |
|
32 const TInt KInitialResponseLength(512); |
|
33 const TInt KInitialReferenceMessageIdLength(32); |
|
34 const TInt KInitialUrlLength(128); |
|
35 |
|
36 _LIT8( KParserDataType, "text/xml" ); |
|
37 _LIT8( KUriPaosLiberty, "urn:liberty:paos:2003-08" ); |
|
38 _LIT8( KLocalNameRequest, "Request" ); |
|
39 _LIT8( KUriSbLiberty, "urn:liberty:sb:2003-08" ); |
|
40 _LIT8( KLocalNameCorrelation, "Correlation" ); |
|
41 _LIT8( KAttributeResponseConsumerUrl, "responseConsumerURL" ); |
|
42 _LIT8( KPnpMsNokiaUri, "http://pnpms.nokia.com/signkey" ); |
|
43 _LIT8( KAttributeMessageId, "messageID" ); |
|
44 _LIT8( KElementGetKey, "getkey" ); |
|
45 _LIT8( KKeyRequest, "Keyrequest" ); |
|
46 _LIT8( KContentSetOfKeys, "SetOfKeys" ); |
|
47 _LIT8( KContentHdcSetOfKeys, "HdcSetOfKeys" ); |
|
48 _LIT8( KContentHdcSetOfKeys2, "HDCSetOfKeys" ); |
|
49 |
|
50 |
|
51 enum TElementIds |
|
52 { |
|
53 EElementUnrecognized = 0, |
|
54 EElementKeyRequest, |
|
55 EElementGetKey |
|
56 }; |
|
57 |
|
58 // Panic texts |
|
59 _LIT( KResponseEmpty, "PnPMS PAOS Response" ); |
|
60 |
|
61 // PAOS data sent to the PnP MS server |
|
62 _LIT8( |
|
63 KPnpPaosResponse, |
|
64 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" |
|
65 "<soap:Header>" |
|
66 "%S" /* Add a KPaosResponseMessageIds here if the request has messageid field */ |
|
67 "</soap:Header>" |
|
68 "<soap:Body>" |
|
69 "<pp:Signkey xmlns:pp=\"http://pnpms.nokia.com/signkey\">" |
|
70 "<Keyinfo>%S</Keyinfo>" |
|
71 "<nonce>%S</nonce>" |
|
72 "<mcc>%S</mcc>" |
|
73 "<mnc>%S</mnc>" |
|
74 "<cmcc>%S</cmcc>" |
|
75 "<cmnc>%S</cmnc>" |
|
76 "<cVersion>%S</cVersion>" |
|
77 "<deviceinfo>%S</deviceinfo>" |
|
78 "</pp:Signkey>" |
|
79 "</soap:Body>" |
|
80 "</soap:Envelope>" |
|
81 ); |
|
82 |
|
83 // PAOS data sent to the HelpDeskConnect server |
|
84 _LIT8( |
|
85 KHdcPaosResponse, |
|
86 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" |
|
87 "<soap:Header>" |
|
88 "%S" /* Add a KPaosResponseMessageIds here if the request has messageid field */ |
|
89 "</soap:Header>" |
|
90 "<soap:Body>" |
|
91 "<pp:Signkey xmlns:pp=\"http://pnpms.nokia.com/signkey\">" |
|
92 "%S" /* Add a list of KHdcKeyInfoElement's here */ |
|
93 "<nonce>%S</nonce>" |
|
94 "<hdcVersion>%S</hdcVersion>" |
|
95 "</pp:Signkey>" |
|
96 "</soap:Body>" |
|
97 "</soap:Envelope>" |
|
98 ); |
|
99 |
|
100 _LIT8( |
|
101 KHdcKeyInfoElement, |
|
102 "<Keyinfo>%S</Keyinfo>" |
|
103 ); |
|
104 const TInt KHdcKeyInfoElementLength( 21 ); |
|
105 |
|
106 _LIT8( |
|
107 KPaosResponseMessageIds, |
|
108 "<sb:Correlation xmlns:sb=\"urn:liberty:paos:2003-08\" " |
|
109 "messageID=\"%S\" " |
|
110 "refToMessageID=\"%S\"/>" |
|
111 ); |
|
112 |
|
113 |
|
114 CPnpPaosXml* CPnpPaosXml::NewL() |
|
115 { |
|
116 LOGSTRING("CPnpPaosXml::NewL()"); |
|
117 CPnpPaosXml* self = new (ELeave) CPnpPaosXml(); |
|
118 CleanupStack::PushL( self ); |
|
119 self->ConstructL(); |
|
120 CleanupStack::Pop( self ); |
|
121 LOGSTRING("CPnpPaosXml::NewL() - done"); |
|
122 return self; |
|
123 } |
|
124 |
|
125 CPnpPaosXml::CPnpPaosXml() : |
|
126 iPaosStatus( EPaosStatusUnknown ), |
|
127 iResponseConsumerUrlFound( EFalse ), |
|
128 iErrorFound( EFalse ), |
|
129 iCurrentElement( EElementUnrecognized ) |
|
130 { |
|
131 LOGSTRING("constructor CPnpPaosXml()"); |
|
132 } |
|
133 |
|
134 void CPnpPaosXml::ConstructL() |
|
135 { |
|
136 LOGSTRING("CPnpPaosXml::ConstructL()"); |
|
137 |
|
138 iParser = Xml::CParser::NewL( KParserDataType, *this ); |
|
139 |
|
140 LOGSTRING("CPnpPaosXml::ConstructL() - 2"); |
|
141 iPaosPostUrlPath = HBufC8::NewL( KInitialUrlLength ); |
|
142 |
|
143 iMessageId = HBufC8::NewL( KMessageIdLength ); |
|
144 // We do not know the length of refToMessageID until we get it |
|
145 // from the service |
|
146 iReferenceMessageId = HBufC8::NewL( KInitialReferenceMessageIdLength ); |
|
147 iPaosResponse = HBufC8::NewL( KInitialResponseLength ); |
|
148 |
|
149 LOGSTRING("CPnpPaosXml::ConstructL() - done"); |
|
150 } |
|
151 |
|
152 CPnpPaosXml::~CPnpPaosXml() |
|
153 { |
|
154 LOGSTRING("CPnpPaosXml::~CPnpPaosXml()"); |
|
155 delete iParser; |
|
156 delete iPaosRequest; |
|
157 delete iPaosResponse; |
|
158 delete iMessageId; |
|
159 delete iReferenceMessageId; |
|
160 delete iPaosPostUrlPath; |
|
161 LOGSTRING("CPnpPaosXml::~CPnpPaosXml() - done"); |
|
162 } |
|
163 |
|
164 void CPnpPaosXml::OnOutOfData() |
|
165 { |
|
166 } |
|
167 |
|
168 void CPnpPaosXml::ParseL( TPaosStates& aPaosStatus ) |
|
169 { |
|
170 LOGSTRING("CPnpPaosXml::ParseL()"); |
|
171 |
|
172 // Reset possible previous paos response |
|
173 ReleaseData(); |
|
174 |
|
175 // Reset state variables |
|
176 iPaosStatus = EPaosStatusUnknown; |
|
177 iErrorFound = EFalse; |
|
178 iCurrentElement = EElementUnrecognized; |
|
179 iResponseConsumerUrlFound = EFalse; |
|
180 |
|
181 LOGSTRING("ParseBeginL()"); |
|
182 |
|
183 iParser->ParseBeginL(); |
|
184 Xml::ParseL( *iParser, *iPaosRequest ); |
|
185 |
|
186 aPaosStatus = iPaosStatus; // Store status |
|
187 LOGSTRING("ParseL() - done"); |
|
188 |
|
189 // There has to be a consumer URL in the document |
|
190 if( !iResponseConsumerUrlFound ) |
|
191 { |
|
192 LOGSTRING( "responseCosumerURL not found!" ); |
|
193 User::Leave( KErrArgument ); |
|
194 } |
|
195 |
|
196 // No errors allowed in the XML |
|
197 if( iErrorFound ) |
|
198 { |
|
199 LOGSTRING( "Error in the XML!" ); |
|
200 User::Leave( KErrArgument ); |
|
201 } |
|
202 |
|
203 // Only key requests for PnP-MS or HelpDeskConnect |
|
204 // keys (parameters) allowed with this PAOS parser |
|
205 switch( aPaosStatus ) |
|
206 { |
|
207 case EPaosStatusRequestingPnPKeys: |
|
208 ConstructPnPPaosResponseL(); |
|
209 break; |
|
210 case EPaosStatusRequestingHdcKeys: |
|
211 ConstructHdcPaosResponseL(); |
|
212 break; |
|
213 default: |
|
214 LOGSTRING( "Invalid PAOS request!" ); |
|
215 User::Leave( KErrArgument ); |
|
216 break; |
|
217 } |
|
218 |
|
219 #ifdef LOGGING_ENABLED |
|
220 for( TInt i(0); i < iPaosResponse->Length(); i += 128 ) |
|
221 { |
|
222 TPtrC8 logText = iPaosResponse->Right( iPaosResponse->Length() - i ); |
|
223 LOGTEXT( logText ); |
|
224 } |
|
225 #endif |
|
226 |
|
227 // Reset state variables |
|
228 iPaosStatus = EPaosStatusUnknown; |
|
229 iErrorFound = EFalse; |
|
230 iCurrentElement = EElementUnrecognized; |
|
231 |
|
232 LOGSTRING("CPnpPaosXml::ParseL - done()"); |
|
233 } |
|
234 |
|
235 TBool CPnpPaosXml::CollectResponseBodyL( MHTTPDataSupplier& aBody ) |
|
236 { |
|
237 LOGSTRING( "CPnpPaosXml::CollectResponseBodyL" ); |
|
238 |
|
239 // Store incoming body part |
|
240 TPtrC8 dataChunk; |
|
241 TBool returnValue = aBody.GetNextDataPart( dataChunk ); |
|
242 |
|
243 #ifdef LOGGING_ENABLED |
|
244 for( TInt i(0); i < dataChunk.Length(); i += 128 ) |
|
245 { |
|
246 LOGSTRING( "CPnpPaosXml: MHTTPDataSupplier:" ); |
|
247 TPtrC8 logText = dataChunk.Right( dataChunk.Length() - i ); |
|
248 LOGTEXT( logText ); |
|
249 } |
|
250 #endif |
|
251 |
|
252 if( !iPaosRequest ) |
|
253 { |
|
254 iPaosRequest = HBufC8::NewL( dataChunk.Length() ); |
|
255 } |
|
256 |
|
257 TPtr8 paosRequestPtr = iPaosRequest->Des(); |
|
258 if( paosRequestPtr.MaxLength() < ( iPaosRequest->Length() + dataChunk.Length() ) ) |
|
259 { |
|
260 LOGSTRING( "Re-allocate response buffer" ); |
|
261 iPaosRequest = iPaosRequest->ReAllocL( iPaosRequest->Length() + dataChunk.Length() ); |
|
262 paosRequestPtr.Set( iPaosRequest->Des() ); |
|
263 } |
|
264 paosRequestPtr.Append( dataChunk ); |
|
265 |
|
266 LOGSTRING( "CPnpPaosXml::CollectResponseBodyL - done" ); |
|
267 return returnValue; |
|
268 } |
|
269 /* |
|
270 #ifndef __SERIES60_ |
|
271 TPtrC8 CPnpPaosXml::ResponseBodyL() |
|
272 { |
|
273 LOGSTRING( "CPnpPaosXml::ResponseBodyL" ); |
|
274 if( !iPaosRequest ) |
|
275 { |
|
276 User::Leave( KErrNotFound ); |
|
277 } |
|
278 return *iPaosRequest; |
|
279 } |
|
280 #endif |
|
281 */ |
|
282 void CPnpPaosXml::ConstructHdcPaosResponseL() |
|
283 { |
|
284 LOGSTRING( "CPnpPaosXml::ConstructHdcPaosResponseL" ); |
|
285 |
|
286 // give empty parameter values in case there is no DLL for HelpDeskConnect |
|
287 // -> The service may then make the following assumptions: |
|
288 // 1. If there is no PAOS header in the first HTTP GET request -> link: "install HDC" |
|
289 // 2. If there is PAOS headers but PAOS response contains empty parameter values -> link: "install HDC" |
|
290 // 3. PAOS header and a valid PAOS response -> HDC installed OK, proceed to a HDC trigger file |
|
291 |
|
292 RLibrary library; |
|
293 const TUidType uid( KNullUid, KNullUid, KHdcUtilDllUid ); |
|
294 TInt result = library.Load( KHdcDllFileName, uid ); |
|
295 if( result != KErrNone ) |
|
296 { |
|
297 // if the dll is not found the response should be empty |
|
298 LOGSTRING2( "err in loading HDC dll: %i", result ); |
|
299 ConstructPaosResponseL( KHdcPaosResponse ); |
|
300 return; |
|
301 } |
|
302 CleanupClosePushL( library ); |
|
303 // Function at ordinal 1 is NewLC |
|
304 TLibraryFunction entry = library.Lookup(1); |
|
305 // Call the function to create new hdc dll object |
|
306 CHdcToPaosInterface* hdcUtil = ( CHdcToPaosInterface* ) entry(); |
|
307 |
|
308 // HDC-nonce |
|
309 // create new nonce |
|
310 TBuf8<KHdcNonceLength> nonce; |
|
311 hdcUtil->CreateNewNonceL( nonce ); |
|
312 |
|
313 // HDC-version |
|
314 TBuf8<KMaxHdcVersionStringLength> version; |
|
315 hdcUtil->Version( version ); |
|
316 |
|
317 // List of key-infos |
|
318 HdcKeyInfoList keyInfoList; |
|
319 hdcUtil->HdcKeyInfos( keyInfoList ); |
|
320 TInt keyInfoCount = keyInfoList.Count(); |
|
321 |
|
322 HBufC8* keyInfos = HBufC8::NewLC( |
|
323 keyInfoCount * KMaxHdcKeyInfoLength + /* space for keyinfos */ |
|
324 keyInfoCount * KHdcKeyInfoElement().Length() ); /* space for XML elements */ |
|
325 TPtr8 keyInfosPtr = keyInfos->Des(); |
|
326 for( TInt i(0); i < keyInfoCount; i++ ) |
|
327 { |
|
328 TBuf8<KMaxHdcKeyInfoLength + KHdcKeyInfoElementLength> keyInfoXmlElement; |
|
329 keyInfoXmlElement.Format( KHdcKeyInfoElement, &( keyInfoList[i] ) ); |
|
330 keyInfosPtr.Append( keyInfoXmlElement ); |
|
331 } |
|
332 |
|
333 LOGSTRING( "CPnpPaosXml::ConstructHdcPaosResponseL format response" ); |
|
334 // 1. KPaosResponseMessageIds |
|
335 // 2. List of KHdcKeyInfoElement's |
|
336 // 3. HDC nonce |
|
337 // 4. HDC version |
|
338 ConstructPaosResponseL( KHdcPaosResponse, *keyInfos, nonce, version ); |
|
339 LOGSTRING( "CPnpPaosXml::ConstructHdcPaosResponseL response formatted" ); |
|
340 |
|
341 // RArray must be closed before destructing |
|
342 keyInfoList.Close(); |
|
343 |
|
344 CleanupStack::PopAndDestroy( keyInfos ); |
|
345 CleanupStack::PopAndDestroy( hdcUtil ); |
|
346 CleanupStack::PopAndDestroy(); // library.Close() |
|
347 } |
|
348 |
|
349 void CPnpPaosXml::ConstructPnPPaosResponseL() |
|
350 { |
|
351 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL" ); |
|
352 |
|
353 // Dynamically load the pnp util DLL, |
|
354 const TUidType uid( KNullUid, KNullUid, KPnpUtilDllUid ); |
|
355 RLibrary pnpLibrary; |
|
356 TInt result = pnpLibrary.Load( KPnpUtilDllFileName, uid ); |
|
357 if( result != KErrNone ) |
|
358 { |
|
359 // if the dll is not found the response should be empty |
|
360 LOGSTRING2( "err in loading pnp util dll: %i", result ); |
|
361 ConstructPaosResponseL( KPnpPaosResponse ); |
|
362 return; |
|
363 } |
|
364 CleanupClosePushL( pnpLibrary ); |
|
365 |
|
366 // Function at ordinal 1 is NewPnpUtilLC |
|
367 //TLibraryFunction entry = pnpLibrary.Lookup(1); |
|
368 // Call the function to create new Pnp util object |
|
369 //MPnpToPaosInterface* pnpUtil = ( MPnpToPaosInterface* ) entry(); |
|
370 |
|
371 CPnpUtilImpl *pnpUtil = CPnpUtilImpl::NewLC(); |
|
372 |
|
373 // check version |
|
374 TBuf8<KMaxVersionStringLength> version; |
|
375 TBuf<KMaxVersionStringLength> version16; |
|
376 pnpUtil->Version( version16 ); |
|
377 version.Copy( version16 ); |
|
378 LOGTEXT( version ); |
|
379 // BC break between versions NPnPS60-0.10 and newer ones; Version function |
|
380 // should be binary compatible, though. |
|
381 // (older versions of pnputil should not be a problem as updating PAOS filter |
|
382 // without updating PnP-MS components should be possible only by installing |
|
383 // HelpDeskConnect With PAOS filter) |
|
384 if( version.Compare( _L8("NPnPS60-0.10") ) == 0 ) |
|
385 { |
|
386 // if the dll is not compatible give an empty response |
|
387 LOGSTRING( "Too old version of PnpUtil installed" ); |
|
388 ConstructPaosResponseL( KPnpPaosResponse ); |
|
389 CleanupStack::PopAndDestroy( pnpUtil ); |
|
390 CleanupStack::PopAndDestroy(); // pnpLibrary.Close(); |
|
391 return; |
|
392 } |
|
393 |
|
394 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL 2" ); |
|
395 |
|
396 // MNCs and MCCs |
|
397 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL 2.01" ); |
|
398 pnpUtil->FetchHomeNetworkInfoL(); |
|
399 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL 2.1" ); |
|
400 TRAPD( err, pnpUtil->FetchNetworkInfoL() ); |
|
401 if( err != KErrNone ) |
|
402 { |
|
403 LOGSTRING2( "CPnpPaosXml::Could not fetch network info %i", err ); |
|
404 pnpUtil->SetNetworkMccL( _L("") ); |
|
405 pnpUtil->SetNetworkMncL( _L("") ); |
|
406 } |
|
407 |
|
408 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL 2.2" ); |
|
409 RMobilePhone::TMobilePhoneNetworkCountryCode homeMcc = pnpUtil->HomeMccL(); |
|
410 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL 2.3" ); |
|
411 RMobilePhone::TMobilePhoneNetworkIdentity homeMnc = pnpUtil->HomeMncL(); |
|
412 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL 2.4" ); |
|
413 RMobilePhone::TMobilePhoneNetworkCountryCode networkMcc = pnpUtil->NetworkMccL(); |
|
414 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL 2.5" ); |
|
415 RMobilePhone::TMobilePhoneNetworkIdentity networkMnc = pnpUtil->NetworkMncL(); |
|
416 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL 2.6" ); |
|
417 TBuf8<4> hmcc; |
|
418 TBuf8<8> hmnc; |
|
419 TBuf8<4> nmcc; |
|
420 TBuf8<8> nmnc; |
|
421 hmcc.Copy( homeMcc ); |
|
422 hmnc.Copy( homeMnc ); |
|
423 nmcc.Copy( networkMcc ); |
|
424 nmnc.Copy( networkMnc ); |
|
425 |
|
426 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL 3" ); |
|
427 // keyinfo, nonce |
|
428 TBuf8<KMaxKeyInfoLength> keyInfo; |
|
429 pnpUtil->GetKeyInfoL( keyInfo ); |
|
430 TBuf8<KNonceLength> nonce; |
|
431 TInt timeout(0); |
|
432 pnpUtil->CreateNewNonceL( timeout, nonce ); |
|
433 |
|
434 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL 4" ); |
|
435 // product model |
|
436 TBuf8<KSysUtilVersionTextLength> deviceinfo; |
|
437 FetchProductModelL( deviceinfo ); |
|
438 |
|
439 // Clear all service activation data in case if service |
|
440 // activation fails |
|
441 // This will avoid displaying service specific notes for |
|
442 // example email service activation when help-portal service required |
|
443 // As of now only Help-portal server sends PAOS request |
|
444 // and NSA server(which provides email service activation) is not |
|
445 // supporting PAOS. |
|
446 // If NSA server provides PAOS then these resetting of |
|
447 // service activation data to be commented |
|
448 |
|
449 CPnpProvUtil* prov = CPnpProvUtil::NewLC(); |
|
450 |
|
451 const TUint32 uidval = 0; |
|
452 prov->SetApplicationUidL(uidval); |
|
453 |
|
454 |
|
455 TBuf<2> buf(_L("")); |
|
456 prov->SetProvAdapterAppIdL(buf); |
|
457 |
|
458 CleanupStack::PopAndDestroy(); |
|
459 |
|
460 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL format response" ); |
|
461 // 1. Keyinfo |
|
462 // 2. Nonce |
|
463 // 3. Home MCC |
|
464 // 4. Home MNC |
|
465 // 5. Network (current) MCC |
|
466 // 6. Network MNC |
|
467 // 7. Version |
|
468 // 8. deviceinfo |
|
469 ConstructPaosResponseL( KPnpPaosResponse, keyInfo, nonce, hmcc, hmnc, nmcc, nmnc, version, deviceinfo ); |
|
470 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL response formatted" ); |
|
471 |
|
472 LOGSTRING( "CleanupStack::PopAndDestroy( pnpUtil )" ); |
|
473 CleanupStack::PopAndDestroy( pnpUtil ); |
|
474 LOGSTRING( "pnpLibrary.Close()" ); |
|
475 CleanupStack::PopAndDestroy(); // pnpLibrary.Close() |
|
476 LOGSTRING( "CPnpPaosXml::ConstructPnPPaosResponseL - done" ); |
|
477 } |
|
478 |
|
479 void CPnpPaosXml::ConstructPaosResponseL( |
|
480 const TDesC8& aResponse, |
|
481 const TDesC8& aParameter1, |
|
482 const TDesC8& aParameter2, |
|
483 const TDesC8& aParameter3, |
|
484 const TDesC8& aParameter4, |
|
485 const TDesC8& aParameter5, |
|
486 const TDesC8& aParameter6, |
|
487 const TDesC8& aParameter7, |
|
488 const TDesC8& aParameter8 |
|
489 ) |
|
490 { |
|
491 // Construct PAOS message id element if reference message id is available |
|
492 HBufC8* messageIds(0); |
|
493 if( iReferenceMessageId->Length() ) |
|
494 { |
|
495 LOGSTRING( "iMessageId:" ); |
|
496 LOGTEXT( *iMessageId ); |
|
497 LOGSTRING( "iReferenceMessageId:" ); |
|
498 LOGTEXT( *iReferenceMessageId ); |
|
499 |
|
500 messageIds = HBufC8::NewLC( |
|
501 KPaosResponseMessageIds().Length() + |
|
502 iMessageId->Length() + |
|
503 iReferenceMessageId->Length() ); |
|
504 messageIds->Des().Format( KPaosResponseMessageIds, iMessageId, iReferenceMessageId ); |
|
505 } |
|
506 |
|
507 LOGSTRING( "CPnpPaosXml::ConstructPaosResponseL" ); |
|
508 // Construct a new PAOS response |
|
509 TInt responseLength( |
|
510 aResponse.Length() + |
|
511 aParameter1.Length() + |
|
512 aParameter2.Length() + |
|
513 aParameter3.Length() + |
|
514 aParameter4.Length() + |
|
515 aParameter5.Length() + |
|
516 aParameter6.Length() + |
|
517 aParameter7.Length() + |
|
518 aParameter8.Length() |
|
519 ); |
|
520 |
|
521 // Add the length of messageIds buffer to responseLength |
|
522 if( messageIds ) |
|
523 responseLength += messageIds->Length(); |
|
524 |
|
525 // Expand buffer if needed |
|
526 if( iPaosResponse->Des().MaxSize() < responseLength ) |
|
527 iPaosResponse = iPaosResponse->ReAllocL( responseLength ); |
|
528 |
|
529 LOGSTRING( "CPnpPaosXml::ConstructPaosResponseL - format" ); |
|
530 if( messageIds ) |
|
531 { |
|
532 iPaosResponse->Des().Format( |
|
533 aResponse, |
|
534 messageIds, /* The first parameter in aResponse is assumed to be messageids */ |
|
535 &aParameter1, |
|
536 &aParameter2, |
|
537 &aParameter3, |
|
538 &aParameter4, |
|
539 &aParameter5, |
|
540 &aParameter6, |
|
541 &aParameter7, |
|
542 &aParameter8 |
|
543 ); |
|
544 LOGSTRING( "CleanupStack::PopAndDestroy( messageIds )" ); |
|
545 CleanupStack::PopAndDestroy( messageIds ); |
|
546 } |
|
547 else |
|
548 { |
|
549 iPaosResponse->Des().Format( |
|
550 aResponse, |
|
551 &KNullDesC8(), |
|
552 &aParameter1, |
|
553 &aParameter2, |
|
554 &aParameter3, |
|
555 &aParameter4, |
|
556 &aParameter5, |
|
557 &aParameter6, |
|
558 &aParameter7, |
|
559 &aParameter8 |
|
560 ); |
|
561 } |
|
562 LOGSTRING( "CPnpPaosXml::ConstructPaosResponseL - done" ); |
|
563 } |
|
564 |
|
565 void CPnpPaosXml::ResetPaosRequest() |
|
566 { |
|
567 delete iPaosRequest; |
|
568 iPaosRequest = 0; |
|
569 } |
|
570 |
|
571 TBool CPnpPaosXml::GetNextDataPart( TPtrC8& aDataPart ) |
|
572 { |
|
573 LOGSTRING("CPnpPaosXml::GetNextDataPart"); |
|
574 |
|
575 if( !iPaosResponse ) |
|
576 { |
|
577 LOGSTRING( "empty response!" ); |
|
578 // Panics are not shown (on browser process), the browser is just closed |
|
579 __ASSERT_ALWAYS( EFalse, User::Panic( KResponseEmpty, KErrNotFound ) ); |
|
580 } |
|
581 aDataPart.Set( *iPaosResponse ); |
|
582 return ETrue; |
|
583 } |
|
584 |
|
585 void CPnpPaosXml::ReleaseData() |
|
586 { |
|
587 LOGSTRING("CPnpPaosXml::ReleaseData"); |
|
588 // No need to delete our data |
|
589 // They are deleted in the destructor and reallocated when needed |
|
590 iPaosResponse->Des().Zero(); |
|
591 iMessageId->Des().Zero(); |
|
592 iReferenceMessageId->Des().Zero(); |
|
593 iPaosPostUrlPath->Des().Zero(); |
|
594 } |
|
595 |
|
596 TInt CPnpPaosXml::OverallDataSize() |
|
597 { |
|
598 LOGSTRING("CPnpPaosXml::OverallDataSize"); |
|
599 if( !iPaosResponse ) |
|
600 { |
|
601 LOGSTRING( "empty response!" ); |
|
602 // Panics are not shown (on browser process), the browser is just closed |
|
603 __ASSERT_ALWAYS( EFalse, User::Panic( KResponseEmpty, KErrNotFound ) ); |
|
604 } |
|
605 return iPaosResponse->Length(); |
|
606 } |
|
607 |
|
608 TInt CPnpPaosXml::Reset() |
|
609 { |
|
610 LOGSTRING("CPnpPaosXml::Reset"); |
|
611 return KErrNone; |
|
612 } |
|
613 |
|
614 void CPnpPaosXml::OnStartDocumentL( const RDocumentParameters& aDocParam, TInt aErrorCode ) |
|
615 { |
|
616 LOGSTRING2( "CPnpPaosXml::OnStartDocumentL: %i", aErrorCode ); |
|
617 if( aErrorCode != KErrNone ) |
|
618 { |
|
619 User::Leave( KErrArgument ); |
|
620 } |
|
621 // Keep compiler happy |
|
622 (void)aDocParam; |
|
623 LOGRSTRING( "CharSet: %S", aDocParam.CharacterSetName() ); |
|
624 } |
|
625 |
|
626 void CPnpPaosXml::OnEndDocumentL( TInt aErrorCode ) |
|
627 { |
|
628 LOGSTRING2( "CPnpPaosXml::OnEndDocumentL: %i", aErrorCode ); |
|
629 if( aErrorCode != KErrNone ) |
|
630 { |
|
631 User::Leave( KErrArgument ); |
|
632 } |
|
633 } |
|
634 |
|
635 void CPnpPaosXml::OnStartElementL( const RTagInfo& aElement, const RAttributeArray& aAttributes, |
|
636 TInt aErrorCode ) |
|
637 { |
|
638 LOGSTRING2( "CPnpPaosXml::OnStartElementL: %i", aErrorCode ); |
|
639 if( aErrorCode != KErrNone ) |
|
640 { |
|
641 User::Leave( KErrArgument ); |
|
642 } |
|
643 |
|
644 RString uri = aElement.Uri(); |
|
645 RString localName = aElement.LocalName(); |
|
646 |
|
647 #ifdef LOGGING_ENABLED |
|
648 RString prefix = aElement.Prefix(); |
|
649 #endif |
|
650 LOGRSTRING( "uri: %S", uri ); |
|
651 LOGRSTRING( "localName: %S", localName ); |
|
652 LOGRSTRING( "prefix: %S", prefix ); |
|
653 |
|
654 if( iCurrentElement == EElementKeyRequest ) |
|
655 { |
|
656 if( localName.DesC().Compare( KElementGetKey ) == 0 ) |
|
657 { |
|
658 LOGSTRING( "setting iCurrentElement = EElementGetKey" ); |
|
659 iCurrentElement = EElementGetKey; |
|
660 } |
|
661 } |
|
662 else if( uri.DesC().Compare( KPnpMsNokiaUri ) == 0 ) |
|
663 { |
|
664 if( localName.DesC().Compare( KKeyRequest ) == 0 ) |
|
665 { |
|
666 LOGSTRING( "setting iCurrentElement = EElementKeyRequest" ); |
|
667 iCurrentElement = EElementKeyRequest; |
|
668 } |
|
669 } |
|
670 |
|
671 |
|
672 for( TInt i(0); i < aAttributes.Count(); i++ ) |
|
673 { |
|
674 RAttribute attribute = aAttributes[i]; |
|
675 RTagInfo tagInfo = attribute.Attribute(); |
|
676 RString attributeLocalName = tagInfo.LocalName(); |
|
677 RString value = attribute.Value(); |
|
678 |
|
679 #ifdef LOGGING_ENABLED |
|
680 RString attributeUri = tagInfo.Uri(); |
|
681 RString attributePrefix = tagInfo.Prefix(); |
|
682 #endif |
|
683 LOGRSTRING( "attribute uri: %S", attributeUri ); |
|
684 LOGRSTRING( "attribute localName: %S", attributeLocalName ); |
|
685 LOGRSTRING( "attribute prefix: %S", attributePrefix ); |
|
686 LOGRSTRING( "value: %S", value ); |
|
687 |
|
688 // According to PAOS spec: "SOAP request message that (provided that the |
|
689 // SOAP processor wishes to use the PAOS binding) MUST contain a <paos:Request> |
|
690 // SOAP header block." |
|
691 // For some reason Futurice uses prefix ns1 (ns1:Request) for a SOAP request. |
|
692 // So we allow any prefix for a SOAP request instead of only allowing "paos" |
|
693 |
|
694 if( localName.DesC().Compare( KLocalNameRequest ) == 0 && |
|
695 uri.DesC().Compare( KUriPaosLiberty ) == 0 ) |
|
696 { |
|
697 LOGSTRING("uri PAOS found"); |
|
698 const TDesC8& strAttributeLocalName = attributeLocalName.DesC(); |
|
699 const TDesC8& strValue = value.DesC(); |
|
700 |
|
701 if( strAttributeLocalName.Compare( KAttributeResponseConsumerUrl ) == 0 ) |
|
702 { |
|
703 LOGSTRING( "PAOS post url found" ); |
|
704 if( iPaosPostUrlPath->Des().MaxLength() < strValue.Length() ) |
|
705 { |
|
706 iPaosPostUrlPath = iPaosPostUrlPath->ReAllocL( strValue.Length() ); |
|
707 } |
|
708 iPaosPostUrlPath->Des().Copy( strValue ); |
|
709 LOGSTRING( "iResponseConsumerUrlFound = ETrue" ); |
|
710 iResponseConsumerUrlFound = ETrue; |
|
711 } |
|
712 else if( attributeLocalName.DesC().Compare( KAttributeMessageId ) == 0) |
|
713 { |
|
714 LOGSTRING("messageID found"); |
|
715 const TDesC8& strValue = value.DesC(); |
|
716 if( iReferenceMessageId->Des().MaxLength() < strValue.Length() ) |
|
717 { |
|
718 iReferenceMessageId = iReferenceMessageId->ReAllocL( strValue.Length() ); |
|
719 } |
|
720 iReferenceMessageId->Des().Copy( strValue ); |
|
721 // Generate a random character string for our own messageID |
|
722 TPtr8 messageIdPtr = iMessageId->Des(); |
|
723 GenerateNonceString( messageIdPtr ); |
|
724 } |
|
725 } |
|
726 else if( localName.DesC().Compare( KLocalNameCorrelation ) == 0 && |
|
727 uri.DesC().Compare( KUriSbLiberty ) == 0 ) |
|
728 { |
|
729 LOGSTRING("uri SB found"); |
|
730 if( attributeLocalName.DesC().Compare( KAttributeMessageId ) == 0) |
|
731 { |
|
732 LOGSTRING("messageID found"); |
|
733 const TDesC8& strValue = value.DesC(); |
|
734 iReferenceMessageId = iReferenceMessageId->ReAllocL( strValue.Length() ); |
|
735 iReferenceMessageId->Des().Copy( strValue ); |
|
736 // Generate a random character string for our own messageID |
|
737 TPtr8 messageIdPtr = iMessageId->Des(); |
|
738 GenerateNonceString( messageIdPtr ); |
|
739 } |
|
740 } |
|
741 } |
|
742 LOGSTRING("CPnpPaosXml::OnStartElementL - done"); |
|
743 } |
|
744 |
|
745 void CPnpPaosXml::GenerateNonceString( TDes8& aString ) |
|
746 { |
|
747 LOGSTRING("CPnpPaosXml::GenerateNonceString"); |
|
748 aString.Zero(); |
|
749 |
|
750 _LIT8( KTemp, "123456abcdef"); |
|
751 if( aString.MaxLength() <= KTemp().Length() ) |
|
752 { |
|
753 aString.Copy( KTemp().Left( aString.MaxLength() ) ); |
|
754 } |
|
755 else |
|
756 { |
|
757 aString.Copy( KTemp ); |
|
758 } |
|
759 |
|
760 LOGSTRING("CPnpPaosXml::GenerateNonceString - done"); |
|
761 } |
|
762 |
|
763 void CPnpPaosXml::OnEndElementL( const RTagInfo& aElement, TInt aErrorCode ) |
|
764 { |
|
765 LOGSTRING2( "CPnpPaosXml::OnEndElementL: %i", aErrorCode ); |
|
766 if( aErrorCode != KErrNone ) |
|
767 { |
|
768 User::Leave( KErrArgument ); |
|
769 } |
|
770 |
|
771 RString uri = aElement.Uri(); |
|
772 RString localName = aElement.LocalName(); |
|
773 RString prefix = aElement.Prefix(); |
|
774 |
|
775 TBuf<255> buff; |
|
776 buff.Copy( uri.DesC().Left(255) ); |
|
777 LOGSTRING2( "uri: %S", &buff ); |
|
778 buff.Copy( localName.DesC().Left(255) ); |
|
779 LOGSTRING2( "localName: %S", &buff ); |
|
780 buff.Copy( prefix.DesC().Left(255) ); |
|
781 LOGSTRING2( "prefix: %S", &buff ); |
|
782 |
|
783 if( iCurrentElement == EElementGetKey ) |
|
784 { |
|
785 // Ending Get key element? |
|
786 if( localName.DesC().Compare( KElementGetKey ) == 0 ) |
|
787 { |
|
788 LOGSTRING( "setting iCurrentElement = EElementKeyRequest" ); |
|
789 // Must be inside key request |
|
790 iCurrentElement = EElementKeyRequest; |
|
791 } |
|
792 } |
|
793 else if( iCurrentElement == EElementKeyRequest ) |
|
794 { |
|
795 // Ending Key request element? |
|
796 if( uri.DesC().Compare( KPnpMsNokiaUri ) == 0 ) |
|
797 { |
|
798 if( localName.DesC().Compare( KKeyRequest ) == 0 ) |
|
799 { |
|
800 LOGSTRING( "setting iCurrentElement = EElementUnrecognized" ); |
|
801 iCurrentElement = EElementUnrecognized; |
|
802 } |
|
803 } |
|
804 } |
|
805 } |
|
806 |
|
807 void CPnpPaosXml::OnContentL( const TDesC8& aBytes, TInt aErrorCode ) |
|
808 { |
|
809 LOGSTRING2( "CPnpPaosXml::OnContentL: %i", aErrorCode ); |
|
810 if( aErrorCode != KErrNone ) |
|
811 { |
|
812 User::Leave( KErrArgument ); |
|
813 } |
|
814 LOGTEXT( aBytes ); |
|
815 |
|
816 if( iCurrentElement == EElementGetKey ) |
|
817 { |
|
818 LOGSTRING( "Element GetKey" ); |
|
819 if( aBytes.Compare( KContentSetOfKeys ) == 0 ) |
|
820 { |
|
821 LOGSTRING("EPaosStatusRequestingPnPKeys"); |
|
822 iPaosStatus = EPaosStatusRequestingPnPKeys; |
|
823 } |
|
824 else if( aBytes.Compare( KContentHdcSetOfKeys ) == 0 || aBytes.Compare( KContentHdcSetOfKeys2 ) == 0 ) |
|
825 { |
|
826 LOGSTRING("EPaosStatusRequestingHdcKeys"); |
|
827 iPaosStatus = EPaosStatusRequestingHdcKeys; |
|
828 } |
|
829 } |
|
830 } |
|
831 |
|
832 void CPnpPaosXml::OnStartPrefixMappingL( const RString& /*aPrefix*/, const RString& /*aUri*/, |
|
833 TInt aErrorCode ) |
|
834 { |
|
835 LOGSTRING2( "CPnpPaosXml::OnStartPrefixMappingL: %i", aErrorCode ); |
|
836 if( aErrorCode != KErrNone ) |
|
837 { |
|
838 User::Leave( KErrArgument ); |
|
839 } |
|
840 } |
|
841 |
|
842 void CPnpPaosXml::OnEndPrefixMappingL( const RString& /*aPrefix*/, TInt aErrorCode ) |
|
843 { |
|
844 LOGSTRING2( "CPnpPaosXml::OnEndPrefixMappingL: %i", aErrorCode ); |
|
845 if( aErrorCode != KErrNone ) |
|
846 { |
|
847 User::Leave( KErrArgument ); |
|
848 } |
|
849 } |
|
850 |
|
851 void CPnpPaosXml::OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode ) |
|
852 { |
|
853 LOGSTRING2( "CPnpPaosXml::OnIgnorableWhiteSpaceL: %i", aErrorCode ); |
|
854 if( aErrorCode != KErrNone ) |
|
855 { |
|
856 User::Leave( KErrArgument ); |
|
857 } |
|
858 LOGTEXT( aBytes ); |
|
859 // Keep compiler happy |
|
860 (void)aBytes; |
|
861 } |
|
862 |
|
863 void CPnpPaosXml::OnSkippedEntityL( const RString& aName, TInt aErrorCode ) |
|
864 { |
|
865 LOGSTRING2( "CPnpPaosXml::OnSkippedEntityL: %i", aErrorCode ); |
|
866 if( aErrorCode != KErrNone ) |
|
867 { |
|
868 User::Leave( KErrArgument ); |
|
869 } |
|
870 LOGRSTRING( "name: %S", aName ); |
|
871 // Keep compiler happy |
|
872 (void)aName; |
|
873 } |
|
874 |
|
875 void CPnpPaosXml::OnProcessingInstructionL( const TDesC8& aTarget, const TDesC8& aData, |
|
876 TInt aErrorCode ) |
|
877 { |
|
878 LOGSTRING2( "CPnpPaosXml::OnProcessingInstructionL: %i", aErrorCode ); |
|
879 if( aErrorCode != KErrNone ) |
|
880 { |
|
881 User::Leave( KErrArgument ); |
|
882 } |
|
883 // Keep compiler happy |
|
884 (void)aTarget; |
|
885 (void)aData; |
|
886 LOGSTRING( "target:" ); |
|
887 LOGTEXT( aTarget ); |
|
888 LOGSTRING( "data:" ); |
|
889 LOGTEXT( aData ); |
|
890 } |
|
891 |
|
892 void CPnpPaosXml::OnError( TInt aErrorCode ) |
|
893 { |
|
894 LOGSTRING2( "CPnpPaosXml::OnError: %i", aErrorCode ); |
|
895 if( aErrorCode != KErrNone ) |
|
896 { |
|
897 iErrorFound = ETrue; |
|
898 } |
|
899 } |
|
900 |
|
901 TAny* CPnpPaosXml::GetExtendedInterface( const TInt32 aUid ) |
|
902 { |
|
903 LOGSTRING2( "CPnpPaosXml::GetExtendedInterface: %i", aUid ); |
|
904 // Keep compiler happy |
|
905 (void)aUid; |
|
906 return 0; |
|
907 } |
|
908 |
|
909 void CPnpPaosXml::FetchProductModelL( TDes8& aModel ) |
|
910 { |
|
911 HBufC* tmpVersion = HBufC::NewLC( KSysUtilVersionTextLength ); |
|
912 TPtr ptr( tmpVersion->Des() ); |
|
913 User::LeaveIfError( SysUtil::GetSWVersion( ptr ) ); |
|
914 LOGTEXT(ptr); |
|
915 |
|
916 _LIT(KVerStrStart,"V "); |
|
917 _LIT(KVerStrEnd,"\n"); |
|
918 |
|
919 TInt pos1 = tmpVersion->Find(KVerStrStart); |
|
920 TInt pos2 = tmpVersion->Find(KVerStrEnd); |
|
921 TInt verlen = ((TDesC)(KVerStrStart)).Length(); |
|
922 |
|
923 if( pos1==KErrNotFound) // Version does not start with "V " |
|
924 { |
|
925 pos1=0; |
|
926 verlen=0; |
|
927 } |
|
928 |
|
929 if( (pos1!=KErrNotFound) |
|
930 && (pos2!=KErrNotFound) |
|
931 && (pos2 > (pos1 + verlen) ) |
|
932 ) |
|
933 { |
|
934 TPtrC ptrSeek(ptr); |
|
935 pos1 = ptrSeek.Find(KVerStrEnd); |
|
936 if(pos1>=0) |
|
937 { |
|
938 ptrSeek.Set(ptrSeek.Mid(pos1+1)); |
|
939 pos1 = ptrSeek.Find(KVerStrEnd); |
|
940 if( pos1 >= 0 ) |
|
941 { |
|
942 ptrSeek.Set(ptrSeek.Mid(pos1+1)); |
|
943 pos1 = ptrSeek.Find(KVerStrEnd); |
|
944 if( pos1 < 0 ) |
|
945 { |
|
946 ptrSeek.Set(ptrSeek.Mid(1)); |
|
947 aModel.Copy(ptrSeek); |
|
948 } |
|
949 else if( pos1 > 0 ) |
|
950 { |
|
951 ptrSeek.Set(ptrSeek.Mid(1,pos1-1)); |
|
952 aModel.Copy(ptrSeek); |
|
953 } |
|
954 LOGTEXT(aModel); |
|
955 } |
|
956 } |
|
957 } |
|
958 CleanupStack::PopAndDestroy(); |
|
959 } |
|
960 // End of File |