|
1 /* |
|
2 * Copyright (c) 2005 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: Common Agent SyncML command handling |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <nsmlconstants.h> |
|
22 #include <nsmldebug.h> |
|
23 #include <nsmldefines.h> |
|
24 #include <nsmlphoneinfo.h> |
|
25 #include <nsmlunicodeconverter.h> |
|
26 #include "nsmlcliagconstants.h" |
|
27 #include "NSmlCmdsBase.h" |
|
28 #include "NSmlAgentBase.h" |
|
29 #include "NSmlStatusContainer.h" |
|
30 #include "NSmlResponseController.h" |
|
31 #include "NSmlResultsContainer.h" |
|
32 #include "NSmlURI.h" |
|
33 #include "NSmlAuth.h" |
|
34 #include "WBXMLSyncMLGenerator.h" |
|
35 #include "WBXMLSyncMLParser.h" |
|
36 #include "WBXMLGeneratorError.h" |
|
37 #include "WBXMLParser.h" |
|
38 #include "smldtd.h" |
|
39 |
|
40 |
|
41 // --------------------------------------------------------- |
|
42 // CNSmlCmdsBase::CNSmlCmdsBase() |
|
43 // Constructor |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C CNSmlCmdsBase::CNSmlCmdsBase() |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------- |
|
51 // CNSmlCmdsBase::~CNSmlCmdsBase() |
|
52 // Destructor |
|
53 // --------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C CNSmlCmdsBase::~CNSmlCmdsBase() |
|
56 { |
|
57 //1.2 CHANGES: 1.1 and 1.2 version support |
|
58 delete iVerDTD; |
|
59 //end changes |
|
60 delete iVerProto; |
|
61 delete iSentSyncHdrTarget; |
|
62 delete iSentSyncHdrSource; |
|
63 delete iRespURI; |
|
64 delete iStatusToServer; |
|
65 delete iResponseController; |
|
66 delete iResultsToServer; |
|
67 delete iGenerator; |
|
68 delete iParser; |
|
69 delete iDocHandler; |
|
70 delete iPhoneInfo; |
|
71 delete iServerAuth; |
|
72 delete iSessionID; |
|
73 delete iSyncMLUserName; |
|
74 delete iSyncServer; |
|
75 delete iLargeObjectItem; |
|
76 delete iRecBuf; |
|
77 delete iLargeObjectUID; |
|
78 delete iCurrServerMsgID; |
|
79 delete iBufferArea; |
|
80 iReadStream.Close(); |
|
81 } |
|
82 |
|
83 |
|
84 // --------------------------------------------------------- |
|
85 // CNSmlCmdsBase::ProcessCopyCmdL |
|
86 // |
|
87 // --------------------------------------------------------- |
|
88 EXPORT_C void CNSmlCmdsBase::ProcessCopyCmdL(SmlCopy_t* /*aCopy*/) |
|
89 { |
|
90 //for future use |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CNSmlCmdsBase::ProcessExecCmdL |
|
95 // |
|
96 // --------------------------------------------------------- |
|
97 EXPORT_C void CNSmlCmdsBase::ProcessExecCmdL(SmlExec_t* /*aExec*/) |
|
98 { |
|
99 //for future use |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------- |
|
103 // CNSmlCmdsBase::ProcessMapCmdL |
|
104 // |
|
105 // --------------------------------------------------------- |
|
106 EXPORT_C void CNSmlCmdsBase::ProcessMapCmdL(SmlMap_t* /*aContent*/) |
|
107 { |
|
108 //for future use |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // CNSmlCmdsBase::ProcessSearchCmdL |
|
113 // |
|
114 // --------------------------------------------------------- |
|
115 EXPORT_C void CNSmlCmdsBase::ProcessSearchCmdL(SmlSearch_t* /*aSearch*/) |
|
116 { |
|
117 //for future use |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------- |
|
121 // CNSmlCmdsBase::FetchIDMappingTableL |
|
122 // |
|
123 // --------------------------------------------------------- |
|
124 EXPORT_C void CNSmlCmdsBase::FetchIDMappingTableL(const TInt /*aType*/) |
|
125 { |
|
126 //for future use |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CNSmlCmdsBase::CloseIDMappingTableL |
|
131 // |
|
132 // --------------------------------------------------------- |
|
133 EXPORT_C void CNSmlCmdsBase::CloseIDMappingTableL() |
|
134 { |
|
135 //for future use |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------- |
|
139 // CNSmlCmdsBase::DeleteIDMappingTableL |
|
140 // |
|
141 // --------------------------------------------------------- |
|
142 EXPORT_C TBool CNSmlCmdsBase::DeleteIDMappingTableL(const TDesC& /*aId*/, const TDesC& /*aDatabase*/) |
|
143 { |
|
144 //for future use |
|
145 return EFalse; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------- |
|
149 // CNSmlCmdsBase::EndOfServerMessageL |
|
150 // |
|
151 // --------------------------------------------------------- |
|
152 EXPORT_C void CNSmlCmdsBase::EndOfServerMessageL() const |
|
153 { |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------- |
|
157 // CNSmlCmdsBase::WriteMappingInfoToDbL |
|
158 // Empty default implementation. |
|
159 // --------------------------------------------------------- |
|
160 EXPORT_C TInt CNSmlCmdsBase::WriteMappingInfoToDbL() const |
|
161 { |
|
162 // Defined only in DM agent |
|
163 return KErrNone; |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------- |
|
167 // CNSmlCmdsBase::DoSyncHdrL |
|
168 // Makes SyncHdr element and calls parser to generate xml |
|
169 // --------------------------------------------------------- |
|
170 EXPORT_C void CNSmlCmdsBase::DoSyncHdrL() |
|
171 { |
|
172 // create generator instance first |
|
173 if ( !iGenerator ) |
|
174 { |
|
175 iGenerator = new( ELeave ) CWBXMLSyncMLGenerator( iVersionPublicId ); |
|
176 } |
|
177 // create workspace |
|
178 iGenerator->CreateWorkspaceL( iWorkspaceSize ); |
|
179 //initialise SyncHdr |
|
180 SmlSyncHdr_t* syncHdr = new( ELeave ) SmlSyncHdr_t; |
|
181 CleanupStack::PushL( syncHdr ); |
|
182 //element type |
|
183 syncHdr->elementType = SML_PE_HEADER; |
|
184 //VerDTD element |
|
185 |
|
186 //1.2 CHANGES: 1.2 and 1.1 version support |
|
187 PcdataNewL ( syncHdr->version, *iVerDTD ); |
|
188 //changes end |
|
189 |
|
190 //VerProto element |
|
191 PcdataNewL ( syncHdr->proto, *iVerProto ); |
|
192 //sessionID element |
|
193 PcdataNewL ( syncHdr->sessionID, *iSessionID ); |
|
194 //msgID element |
|
195 TBuf8<16> stringMsgID; |
|
196 stringMsgID.Num( ++iCurrMsgID ); |
|
197 PcdataNewL( syncHdr->msgID, stringMsgID ); |
|
198 //Target element |
|
199 delete iSentSyncHdrTarget; |
|
200 iSentSyncHdrTarget = NULL; |
|
201 if ( iRespURI ) |
|
202 { |
|
203 // Target changes if a server has issued RespURI in previous message |
|
204 DoTargetL( syncHdr->target, iRespURI->HostName() ); |
|
205 iSentSyncHdrTarget = CNSmlURI::NewL( iRespURI->HostName() ); |
|
206 } |
|
207 else |
|
208 { |
|
209 DoTargetL( syncHdr->target, iSyncServer->HostName() ); |
|
210 iSentSyncHdrTarget = CNSmlURI::NewL( iSyncServer->HostName() ); |
|
211 } |
|
212 //Source element |
|
213 HBufC* imeiCode = HBufC::NewLC( 50 ); |
|
214 TPtr imeiCodePtr = imeiCode->Des(); |
|
215 iPhoneInfo->PhoneDataL( CNSmlPhoneInfo::EPhoneSerialNumber, imeiCodePtr ); |
|
216 CNSmlAgentBase::TAuthenticationType authType; |
|
217 authType = iAgent->AuthTypeL(); |
|
218 if ( ( !iAlreadyAuthenticated ) && ( authType == CNSmlAgentBase::EMD5 ) ) |
|
219 { |
|
220 DoSourceL( syncHdr->source, imeiCodePtr, *iSyncMLUserName); |
|
221 } |
|
222 else |
|
223 { |
|
224 DoSourceL( syncHdr->source, imeiCodePtr ); |
|
225 } |
|
226 delete iSentSyncHdrSource; |
|
227 iSentSyncHdrSource = NULL; |
|
228 iSentSyncHdrSource = CNSmlURI::NewL( *imeiCode ); |
|
229 CleanupStack::PopAndDestroy(); //imeiCode |
|
230 // Cred element |
|
231 if ( authType == CNSmlAgentBase::ENoAuth || iAgent->AlreadyAuthenticated() ) |
|
232 { |
|
233 syncHdr->cred = NULL; |
|
234 } |
|
235 else |
|
236 { |
|
237 syncHdr->cred = new( ELeave ) SmlCred_t; |
|
238 SmlMetInfMetInf_t* metInf; |
|
239 DoMetInfLC( metInf ); |
|
240 if ( authType == CNSmlAgentBase::EMD5 ) |
|
241 { |
|
242 PcdataNewL( metInf->type, KNSmlAgentAuthMD5 ); |
|
243 PcdataNewL( metInf->format, KNSmlAgentBase64Format ); |
|
244 } |
|
245 else // Basic |
|
246 { |
|
247 PcdataNewL( metInf->type, KNSmlAgentAuthBasic ); |
|
248 } |
|
249 DoMetaL( syncHdr->cred->meta, metInf ); |
|
250 CleanupStack::Pop(); //metInf |
|
251 |
|
252 HBufC8* credential; |
|
253 if ( authType == CNSmlAgentBase::EMD5 ) |
|
254 { |
|
255 credential = iAgent->Md5CredentialL(); |
|
256 } |
|
257 else // Basic |
|
258 { |
|
259 credential = iAgent->BasicCredentialL(); |
|
260 } |
|
261 CleanupStack::PushL( credential ); |
|
262 PcdataNewL ( syncHdr->cred->data, *credential ); |
|
263 CleanupStack::PopAndDestroy(); //credential |
|
264 } |
|
265 // MaxMsgSize |
|
266 SmlMetInfMetInf_t* maxMsgMetInf; |
|
267 DoMetInfLC( maxMsgMetInf ); |
|
268 TBuf<16> maxMsgSize; |
|
269 maxMsgSize.Num( iWorkspaceSize ); |
|
270 HBufC8* maxMsgSizeInUTF8 = NULL; |
|
271 NSmlUnicodeConverter::HBufC8InUTF8LC( maxMsgSize, maxMsgSizeInUTF8 ); |
|
272 PcdataNewL( maxMsgMetInf->maxmsgsize, *maxMsgSizeInUTF8 ); |
|
273 CleanupStack::PopAndDestroy(); //maxMsgSizeInUTF8 |
|
274 if ( iSynchHdrMaxObjSize > 0 ) |
|
275 { |
|
276 DoMaxObjSizeL( *maxMsgMetInf, iSynchHdrMaxObjSize ); |
|
277 } |
|
278 DoMetaL( syncHdr->meta, maxMsgMetInf ); |
|
279 CleanupStack::Pop(); //maxMsgMetInf |
|
280 TInt ret; |
|
281 ret = iGenerator->smlStartMessage( syncHdr ); |
|
282 if ( ret != KWBXMLGeneratorOk ) |
|
283 { |
|
284 User::Leave( ret ); |
|
285 } |
|
286 CleanupStack::PopAndDestroy(); //syncHdr |
|
287 iCurrCmdID = 0; |
|
288 //save Status response information for response status controlling |
|
289 CreateAndInitResponseItemL( KNSmlAgentSyncHdr ); |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------- |
|
293 // CNSmlCmdsBase::DoStatusL |
|
294 // Generate Status element and calls Ref.Toolkit parser to generate xml |
|
295 // --------------------------------------------------------- |
|
296 EXPORT_C CNSmlCmdsBase::TReturnValue CNSmlCmdsBase::DoStatusL( SmlStatus_t* aStatus ) |
|
297 { |
|
298 TReturnValue returnValue = EReturnOK; |
|
299 //CmdID element |
|
300 SmlPcdata_t* cmdID = NULL; |
|
301 DoCmdIdL( cmdID ); |
|
302 CleanupStack::PushL( cmdID ); |
|
303 TInt entryID = iStatusToServer->CurrentEntryID(); |
|
304 iStatusToServer->SetCmdIDL( entryID, cmdID ); |
|
305 CleanupStack::PopAndDestroy(); //cmdID |
|
306 // call SyncML generator |
|
307 TInt ret = iGenerator->smlStatusCmd( aStatus ); |
|
308 switch ( ret ) |
|
309 { |
|
310 case KWBXMLGeneratorOk: |
|
311 iStatusToServer->RemoveWritten( entryID ); |
|
312 break; |
|
313 case KWBXMLGeneratorBufferFull: |
|
314 returnValue = CNSmlCmdsBase::EReturnBufferFull; |
|
315 break; |
|
316 default: |
|
317 User::Leave( ret ); |
|
318 } |
|
319 return returnValue; |
|
320 } |
|
321 |
|
322 // FOTA |
|
323 // --------------------------------------------------------- |
|
324 // CNSmlCmdsBase::DoGenericAlertL |
|
325 // Makes generic alert. |
|
326 // This is needed only in Device Management. |
|
327 // --------------------------------------------------------- |
|
328 EXPORT_C void CNSmlCmdsBase::DoGenericAlertL ( const TDesC8& /*aFwMgmtUri*/, const TDesC8& /*aMetaType*/, |
|
329 const TDesC8& /*aMetaFormat*/, TInt /*aFinalResult*/, const TDesC8& /*aFwCorrelator*/ ) |
|
330 { |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------- |
|
334 // CNSmlCmdsBase::DoGenericAlertL |
|
335 // Makes generic alert. |
|
336 // This is needed only in Device Management. |
|
337 // --------------------------------------------------------- |
|
338 EXPORT_C void CNSmlCmdsBase::DoGenericAlertL ( const TDesC8& /*aCorrelator*/, const RArray<CNSmlDMAlertItem>& /*aData*/ ) |
|
339 { |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------- |
|
343 // CNSmlCmdsBase::DoGenericUserAlertL |
|
344 // Makes generic user alert. |
|
345 // This is needed only in Device Management. |
|
346 // --------------------------------------------------------- |
|
347 EXPORT_C TBool CNSmlCmdsBase::DoGenericUserAlertL ( TInt /*aProfileId*/ ) |
|
348 { |
|
349 return EFalse; |
|
350 } |
|
351 |
|
352 // --------------------------------------------------------- |
|
353 // CNSmlCmdsBase::ResetGenericUserAlertL |
|
354 // Resets a user request for fw update in the central repository. |
|
355 // This is needed only in Device Management. |
|
356 // --------------------------------------------------------- |
|
357 EXPORT_C void CNSmlCmdsBase::ResetGenericUserAlertL() |
|
358 { |
|
359 } |
|
360 |
|
361 // --------------------------------------------------------- |
|
362 // CNSmlCmdsBase::MarkGenAlertsSentL |
|
363 // When the generic alerts are successfully sent to the remote |
|
364 // server, the FOTA adapter needs to be informed about this. |
|
365 // This is needed only in Device Management. |
|
366 // --------------------------------------------------------- |
|
367 EXPORT_C void CNSmlCmdsBase::MarkGenAlertsSentL() |
|
368 { |
|
369 } |
|
370 // --------------------------------------------------------- |
|
371 // CNSmlCmdsBase::MarkGenAlertsSentL(const TDesC8) |
|
372 // When the generic alerts are successfully sent to the remote |
|
373 // server, the respective adapter needs to be informed about this. |
|
374 // URI will have adapter's root node. |
|
375 // This is needed only in Device Management. |
|
376 // --------------------------------------------------------- |
|
377 EXPORT_C void CNSmlCmdsBase::MarkGenAlertsSentL(const TDesC8 &aURI) |
|
378 { |
|
379 |
|
380 } |
|
381 // --------------------------------------------------------- |
|
382 // CNSmlCmdsBase::DisconnectFromOtherServers |
|
383 // Closes the connections to callback server and host servers. |
|
384 // This is needed only in Device Management, since the |
|
385 // disconnecting cannot be made after the active scheduler |
|
386 // of the thread is stopped. |
|
387 // --------------------------------------------------------- |
|
388 EXPORT_C void CNSmlCmdsBase::DisconnectFromOtherServers() |
|
389 { |
|
390 } |
|
391 |
|
392 // FOTA end |
|
393 |
|
394 // --------------------------------------------------------- |
|
395 // CNSmlCmdsBase::ProcessReceivedDataL |
|
396 // Parse next received SyncML command using Ref.Toolkit parser |
|
397 // --------------------------------------------------------- |
|
398 EXPORT_C TBool CNSmlCmdsBase::ProcessReceivedDataL() |
|
399 { |
|
400 if ( !iDocHandler ) |
|
401 { |
|
402 iDocHandler = CWBXMLSyncMLDocHandler::NewL( iAgent ); |
|
403 } |
|
404 if ( !iParser ) |
|
405 { |
|
406 iParser = CWBXMLParser::NewL(); |
|
407 iParser->SetDocumentHandler( iDocHandler ); |
|
408 iParser->SetExtensionHandler( iDocHandler ); |
|
409 if ( !iBufferArea ) |
|
410 { |
|
411 iBufferArea = HBufC8::NewL( iWorkspaceSize ); |
|
412 } |
|
413 iReadStream.Open( *iBufferArea ); |
|
414 iParser->SetDocumentL( iReadStream ); |
|
415 } |
|
416 |
|
417 TWBXMLParserError ret = KWBXMLParserErrorOk; |
|
418 iAgent->SetOffCallbackCalled(); |
|
419 while ( ret == KWBXMLParserErrorOk && !iAgent->CallbackCalled() ) |
|
420 { |
|
421 ret = iParser->ParseL(); |
|
422 } |
|
423 if ( ret == KWBXMLParserErrorOk ) |
|
424 { |
|
425 return ETrue; |
|
426 } |
|
427 else |
|
428 { |
|
429 delete iBufferArea; |
|
430 iBufferArea = NULL; |
|
431 delete iParser; |
|
432 iParser = NULL; |
|
433 if ( ret == KWBXMLParserErrorEof ) |
|
434 { |
|
435 return EFalse; |
|
436 } |
|
437 else |
|
438 { |
|
439 User::Leave( ret ); |
|
440 return EFalse; // this sentence ignores compiler warning |
|
441 } |
|
442 } |
|
443 } |
|
444 // --------------------------------------------------------- |
|
445 // CNSmlCmdsBase::ProcessSyncHdrL |
|
446 // Process received SyncHdr element |
|
447 // --------------------------------------------------------- |
|
448 EXPORT_C void CNSmlCmdsBase::ProcessSyncHdrL( SmlSyncHdr_t* aSyncHdr ) |
|
449 { |
|
450 if ( !aSyncHdr ) |
|
451 { |
|
452 User::Leave( TNSmlError::ESmlSyncHdrMissing ); |
|
453 } |
|
454 // Status response flag |
|
455 if ( IsFlagSet( aSyncHdr->flags, SmlNoResp_f ) ) |
|
456 { |
|
457 iStatusToServerNoResponse = ETrue; |
|
458 } |
|
459 else |
|
460 { |
|
461 iStatusToServerNoResponse = EFalse; |
|
462 } |
|
463 // build corresponding status element to server |
|
464 if ( !iStatusToServer ) |
|
465 { |
|
466 iStatusToServer = CNSmlStatusContainer::NewL(); |
|
467 } |
|
468 iStatusToServer->InitMsgRefL( aSyncHdr->msgID ); |
|
469 delete iCurrServerMsgID; |
|
470 iCurrServerMsgID = NULL; |
|
471 iCurrServerMsgID = HBufC8::NewL(0); |
|
472 |
|
473 TInt statusID; |
|
474 statusID = iStatusToServer->CreateNewStatusElementL(); |
|
475 HBufC8* cmdRef = HBufC8::NewLC( KNSmlAgentSyncHdrCmdID.iTypeLength ); |
|
476 *cmdRef = KNSmlAgentSyncHdrCmdID; |
|
477 SmlPcdata_t* cmdRefElement; |
|
478 PcdataNewL ( cmdRefElement, *cmdRef ); |
|
479 CleanupStack::PushL( cmdRefElement ); |
|
480 iStatusToServer->SetCmdRefL( statusID, cmdRefElement ); |
|
481 CleanupStack::PopAndDestroy( 2 ); //cmdRefElement, cmdRef |
|
482 iStatusToServer->SetCmdL( statusID, KNSmlAgentSyncHdr ); |
|
483 iStatusToServer->SetNoResponse( statusID, IsFlagSet( aSyncHdr->flags, SmlNoResp_f ) ); |
|
484 iStatusToServer->AddTargetRefL( statusID, aSyncHdr->target ); |
|
485 iStatusToServer->AddSourceRefL( statusID, aSyncHdr->source ); |
|
486 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusOK ); |
|
487 //respURI |
|
488 if ( aSyncHdr->respURI ) |
|
489 { |
|
490 HBufC* respURI; |
|
491 PCDATAToUnicodeLC( *aSyncHdr->respURI, respURI ); |
|
492 respURI->Des().TrimRight(); |
|
493 if ( respURI->Length() > 0 ) |
|
494 { |
|
495 delete iRespURI; |
|
496 iRespURI = NULL; |
|
497 iRespURI = CNSmlURI::NewL( *respURI ); |
|
498 } |
|
499 CleanupStack::PopAndDestroy(); //respURI |
|
500 } |
|
501 // verDTD and verProto (Check only once) |
|
502 // sync is interrupted if version is other than 1.1 |
|
503 if ( !iVersionCheck ) |
|
504 { |
|
505 iVersionIsChecked = ETrue; |
|
506 } |
|
507 if ( !iVersionIsChecked ) |
|
508 { |
|
509 if ( !aSyncHdr->version->content ) |
|
510 { |
|
511 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusVersionNotSupported ); |
|
512 iAgent->Interrupt( TNSmlError::ESmlVerDTDMissing, EFalse, EFalse ); |
|
513 return; |
|
514 } |
|
515 TPtr8 verDTD( (TUint8*) aSyncHdr->version->content, aSyncHdr->version->length, aSyncHdr->version->length ); |
|
516 TrimRightSpaceAndNull( verDTD ); |
|
517 //1.2 CHANGES: 1.1 and 1.2 version support |
|
518 if ( ( verDTD != KNSmlAgentVerDTD11 ) && (verDTD != KNSmlAgentVerDTD12 )) |
|
519 { |
|
520 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusVersionNotSupported ); |
|
521 SmlPcdata_t* data = NULL; |
|
522 |
|
523 PcdataNewL( data, *iVerDTD ); |
|
524 //changes end |
|
525 CleanupStack::PushL( data ); |
|
526 iStatusToServer->AddItemDataL( statusID, data ); |
|
527 CleanupStack::PopAndDestroy(); //data |
|
528 iAgent->Interrupt( TNSmlError::ESmlVerDTDNotSupported, EFalse, EFalse ); |
|
529 return; |
|
530 } |
|
531 if ( !aSyncHdr->proto->content ) |
|
532 { |
|
533 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusProtocolVersionNotSupported ); |
|
534 iAgent->Interrupt( TNSmlError::ESmlVerProtoMissing, EFalse, EFalse ); |
|
535 return; |
|
536 } |
|
537 TPtr8 verProto( (TUint8*) aSyncHdr->proto->content, aSyncHdr->proto->length, aSyncHdr->proto->length ); |
|
538 TrimRightSpaceAndNull( verProto ); |
|
539 if ( verProto != *iVerProto ) |
|
540 { |
|
541 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusProtocolVersionNotSupported ); |
|
542 SmlPcdata_t* data = NULL; |
|
543 PcdataNewL( data, *iVerProto ); |
|
544 CleanupStack::PushL( data ); |
|
545 iStatusToServer->AddItemDataL( statusID, data ); |
|
546 CleanupStack::PopAndDestroy(); //data |
|
547 iAgent->Interrupt( TNSmlError::ESmlVerProtoNotSupported, EFalse, EFalse ); |
|
548 return; |
|
549 } |
|
550 iVersionIsChecked = ETrue; |
|
551 } |
|
552 // msgID |
|
553 TPtr8 msgID( (TUint8*) aSyncHdr->msgID->content, aSyncHdr->msgID->length, aSyncHdr->msgID->length ); |
|
554 delete iCurrServerMsgID; |
|
555 iCurrServerMsgID = NULL; |
|
556 iCurrServerMsgID = msgID.AllocL(); |
|
557 if ( msgID.Length() == 0 ) |
|
558 { |
|
559 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusIncompleteCommand ); |
|
560 iAgent->Interrupt( TNSmlError::ESmlMsgIDMissing, EFalse, EFalse ); |
|
561 return; |
|
562 } |
|
563 // target |
|
564 // here must be client's Source (IMEI), check that client has got its message |
|
565 if ( !aSyncHdr->target ) |
|
566 { |
|
567 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusIncompleteCommand ); |
|
568 iAgent->Interrupt( TNSmlError::ESmlTargetLocURIMissing, EFalse, EFalse ); |
|
569 return; |
|
570 } |
|
571 else |
|
572 if ( !aSyncHdr->target->locURI ) |
|
573 { |
|
574 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusIncompleteCommand ); |
|
575 iAgent->Interrupt( TNSmlError::ESmlTargetLocURIMissing, EFalse, EFalse ); |
|
576 return; |
|
577 } |
|
578 else |
|
579 { |
|
580 HBufC* syncHdrTarget; |
|
581 PCDATAToUnicodeLC( *aSyncHdr->target->locURI, syncHdrTarget ); |
|
582 syncHdrTarget->Des().TrimRight(); |
|
583 CNSmlURI* syncHdrTargetURI = CNSmlURI::NewLC( *syncHdrTarget ); |
|
584 if ( syncHdrTargetURI->HostName().Length() != 0 && syncHdrTargetURI->HostName() != _L("/") ) |
|
585 { |
|
586 HBufC* imeiCode = HBufC::NewLC( 50 ); |
|
587 TPtr imeiCodePtr = imeiCode->Des(); |
|
588 iPhoneInfo->PhoneDataL( CNSmlPhoneInfo::EPhoneSerialNumber, imeiCodePtr ); |
|
589 if ( syncHdrTargetURI->HostName() != *imeiCode ) |
|
590 { |
|
591 iUnknownDevice = ETrue; |
|
592 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusNotFound ); |
|
593 CleanupStack::PopAndDestroy( 3 ); //imeiCode, syncHdrTargetURI,syncHdrTarget |
|
594 iAgent->Interrupt( TNSmlError::ESmlTargetLocURIInvalid, EFalse, EFalse ); |
|
595 return; |
|
596 } |
|
597 CleanupStack::PopAndDestroy(); //imeiCode |
|
598 } |
|
599 CleanupStack::PopAndDestroy( 2 ); //syncHdrTargetURI, syncHdrTarget |
|
600 } |
|
601 // Cred |
|
602 if ( aSyncHdr->cred ) |
|
603 { |
|
604 HBufC8* type = MetaTypeInUtf8LC( aSyncHdr->cred->meta ); |
|
605 iServerAuth->SetTypeL( *type ); |
|
606 CleanupStack::PopAndDestroy(); //type |
|
607 HBufC8* format = MetaFormatInUtf8LC( aSyncHdr->cred->meta ); |
|
608 iServerAuth->SetFormatL( *format ); |
|
609 CleanupStack::PopAndDestroy(); //format |
|
610 if ( aSyncHdr->cred->data ) |
|
611 { |
|
612 if ( aSyncHdr->cred->data->content ) |
|
613 { |
|
614 TPtr8 credential( (TUint8*) aSyncHdr->cred->data->content, aSyncHdr->cred->data->length, aSyncHdr->cred->data->length ); |
|
615 iServerAuth->SetCredentialL( credential ); |
|
616 } |
|
617 } |
|
618 } |
|
619 TNSmlError::TNSmlSyncMLStatusCode authStatus = iServerAuth->StatusCodeL(); |
|
620 iStatusToServer->SetStatusCodeL( statusID, authStatus ); |
|
621 if ( authStatus == TNSmlError::ESmlStatusUnauthorized ) |
|
622 { |
|
623 iAgent->Interrupt( TNSmlError::ESmlServerUnauthorized, EFalse, ETrue ); |
|
624 iServerAuth->CreateAndSaveNewNonceL(); |
|
625 } |
|
626 |
|
627 if ( iServerAuth->ChallengeNeeded() ) |
|
628 { |
|
629 iStatusToServer->SetChalL( statusID, iServerAuth->NonceL() ); |
|
630 iServerAuth->SetChallenced(); |
|
631 } |
|
632 |
|
633 |
|
634 //MaxMsgSize |
|
635 //Client must obey this value in the next message to server |
|
636 if ( aSyncHdr->meta ) |
|
637 { |
|
638 if ( ( aSyncHdr->meta->content ) && ( aSyncHdr->meta->contentType == SML_PCDATA_EXTENSION ) && ( aSyncHdr->meta->extension == SML_EXT_METINF ) ) |
|
639 { |
|
640 SmlMetInfMetInf_t* metInf; |
|
641 metInf = (SmlMetInfMetInf_t*) aSyncHdr->meta->content; |
|
642 if ( metInf->maxmsgsize ) |
|
643 { |
|
644 if ( metInf->maxmsgsize->content ) |
|
645 { |
|
646 TPtr8 maxMsgSize( (TUint8*) metInf->maxmsgsize->content, metInf->maxmsgsize->length, metInf->maxmsgsize->length ); |
|
647 TrimRightSpaceAndNull( maxMsgSize ); |
|
648 TLex8 lexicalValue( maxMsgSize ); |
|
649 TInt maxMsgSizeNum; |
|
650 if ( lexicalValue.Val( maxMsgSizeNum ) != KErrNone ) |
|
651 { |
|
652 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusIncompleteCommand ); |
|
653 iAgent->Interrupt( TNSmlError::ESmlMaxMsgSizeInvalid, EFalse, EFalse ); |
|
654 return; |
|
655 } |
|
656 else |
|
657 { |
|
658 |
|
659 if ( maxMsgSizeNum < KNSmlMininumWorkspaceSize ) |
|
660 { |
|
661 iWorkspaceSize = maxMsgSizeNum; |
|
662 } |
|
663 else |
|
664 { |
|
665 if ( maxMsgSizeNum > iMaxWorkspaceSize ) |
|
666 { |
|
667 iWorkspaceSize = iMaxWorkspaceSize; |
|
668 } |
|
669 else |
|
670 { |
|
671 iWorkspaceSize = maxMsgSizeNum; |
|
672 } |
|
673 } |
|
674 } |
|
675 } |
|
676 } |
|
677 } |
|
678 } |
|
679 iServerMaxObjectSize = ServerMaxObjSize( aSyncHdr->meta ); |
|
680 } |
|
681 |
|
682 |
|
683 // --------------------------------------------------------- |
|
684 // CNSmlCmdsBase::ProcessStatusCmdL |
|
685 // Handles Status command from a server. |
|
686 // --------------------------------------------------------- |
|
687 EXPORT_C void CNSmlCmdsBase::ProcessStatusCmdL( SmlStatus_t* aStatus ) |
|
688 { |
|
689 //msgRef |
|
690 if ( !aStatus->msgRef ) |
|
691 { |
|
692 return; |
|
693 } |
|
694 if ( !aStatus->msgRef->content ) |
|
695 { |
|
696 return; |
|
697 } |
|
698 TPtr8 msgRef( (TUint8*) aStatus->msgRef->content, aStatus->msgRef->length, aStatus->msgRef->length ); |
|
699 TrimRightSpaceAndNull( msgRef ); |
|
700 if ( msgRef.Length() == 0 ) |
|
701 { |
|
702 return; |
|
703 } |
|
704 //cmd |
|
705 if ( !aStatus->cmd ) |
|
706 { |
|
707 return; |
|
708 } |
|
709 if ( !aStatus->cmd->content ) |
|
710 { |
|
711 return; |
|
712 } |
|
713 TPtr8 cmd( (TUint8*) aStatus->cmd->content, aStatus->cmd->length, aStatus->cmd->length ); |
|
714 TrimRightSpaceAndNull( cmd ); |
|
715 if ( cmd.Length() == 0 ) |
|
716 { |
|
717 return; |
|
718 } |
|
719 //cmdRef |
|
720 HBufC8* cmdRef = NULL; |
|
721 if ( !aStatus->cmdRef ) |
|
722 { |
|
723 if ( cmd == KNSmlAgentSyncHdr ) |
|
724 { |
|
725 cmdRef = HBufC8::NewLC( KNSmlAgentSyncHdrCmdID.iTypeLength ); |
|
726 *cmdRef = KNSmlAgentSyncHdrCmdID; |
|
727 } |
|
728 else |
|
729 { |
|
730 return; |
|
731 } |
|
732 } |
|
733 else |
|
734 if ( !aStatus->cmdRef->content ) |
|
735 { |
|
736 if ( cmd == KNSmlAgentSyncHdr ) |
|
737 { |
|
738 cmdRef = HBufC8::NewLC( KNSmlAgentSyncHdrCmdID.iTypeLength ); |
|
739 *cmdRef = KNSmlAgentSyncHdrCmdID; |
|
740 } |
|
741 else |
|
742 { |
|
743 return; |
|
744 } |
|
745 } |
|
746 else |
|
747 { |
|
748 TPtr8 cmdRefPtr ( (TUint8*) aStatus->cmdRef->content, aStatus->cmdRef->length, aStatus->cmdRef->length ); |
|
749 TrimRightSpaceAndNull( cmdRefPtr ); |
|
750 if ( cmdRefPtr.Length() == 0 ) |
|
751 { |
|
752 if ( cmd == KNSmlAgentSyncHdr ) |
|
753 { |
|
754 cmdRef = HBufC8::NewLC( KNSmlAgentSyncHdrCmdID.iTypeLength ); |
|
755 *cmdRef = KNSmlAgentSyncHdrCmdID; |
|
756 } |
|
757 else |
|
758 { |
|
759 return; |
|
760 } |
|
761 } |
|
762 else |
|
763 { |
|
764 cmdRef = HBufC8::NewLC( cmdRefPtr.Length() ); |
|
765 *cmdRef = cmdRefPtr; |
|
766 } |
|
767 } |
|
768 // Status code |
|
769 TPtr8 statusCode( (TUint8*) aStatus->data->content, aStatus->data->length, aStatus->data->length ); |
|
770 TrimRightSpaceAndNull( statusCode ); |
|
771 if ( statusCode.Length() == 0 ) |
|
772 { |
|
773 CleanupStack::PopAndDestroy(); //cmdRef |
|
774 return; |
|
775 } |
|
776 TLex8 lexicalStatus( statusCode ); |
|
777 TInt numericStatus; |
|
778 if ( lexicalStatus.Val (numericStatus ) != KErrNone ) |
|
779 { |
|
780 CleanupStack::PopAndDestroy(); //cmdRef |
|
781 return; |
|
782 } |
|
783 TInt entryID = 0; |
|
784 TBool statusIsMatching; |
|
785 statusIsMatching = iResponseController->MatchStatusElement( msgRef, *cmdRef , numericStatus, entryID ); |
|
786 if ( !statusIsMatching ) |
|
787 { |
|
788 } |
|
789 else |
|
790 { |
|
791 // chal element is stored for later use |
|
792 if ( aStatus->chal ) |
|
793 { |
|
794 if ( aStatus->chal->meta ) |
|
795 { |
|
796 if ( aStatus->chal->meta->content && aStatus->chal->meta->contentType == SML_PCDATA_EXTENSION && aStatus->chal->meta->extension == SML_EXT_METINF ) |
|
797 { |
|
798 SmlMetInfMetInf_t* metInf; |
|
799 metInf = (SmlMetInfMetInf_t*) aStatus->chal->meta->content; |
|
800 if ( metInf->type ) |
|
801 { |
|
802 if ( metInf->type->content ) |
|
803 { |
|
804 TPtr8 chalType( (TUint8*) metInf->type->content, metInf->type->length, metInf->type->length ); |
|
805 TrimRightSpaceAndNull( chalType ); |
|
806 if ( chalType.Length() > 0 ) |
|
807 { |
|
808 iResponseController->SetChalTypeL( entryID, chalType ); |
|
809 } |
|
810 } |
|
811 } |
|
812 if ( metInf->format ) |
|
813 { |
|
814 if ( metInf->format->content ) |
|
815 { |
|
816 TPtr8 chalFormat( (TUint8*) metInf->format->content, metInf->format->length, metInf->format->length ); |
|
817 TrimRightSpaceAndNull( chalFormat ); |
|
818 if ( chalFormat.Length() > 0 ) |
|
819 { |
|
820 iResponseController->SetChalFormatL( entryID, chalFormat ); |
|
821 } |
|
822 else |
|
823 { |
|
824 iResponseController->SetChalFormatL( entryID, KNSmlAgentChrFormat ); |
|
825 } |
|
826 } |
|
827 else |
|
828 { |
|
829 iResponseController->SetChalFormatL( entryID, KNSmlAgentChrFormat ); |
|
830 } |
|
831 } |
|
832 else |
|
833 { |
|
834 iResponseController->SetChalFormatL( entryID, KNSmlAgentChrFormat ); |
|
835 } |
|
836 if ( metInf->nextnonce ) |
|
837 { |
|
838 if ( metInf->nextnonce->content ) |
|
839 { |
|
840 TPtr8 chalNextNonce( (TUint8*) metInf->nextnonce->content, metInf->nextnonce->length, metInf->nextnonce->length ); |
|
841 TrimRightSpaceAndNull( chalNextNonce ); |
|
842 if ( chalNextNonce.Length() > 0 ) |
|
843 { |
|
844 iResponseController->SetChalNextNonceL( entryID, chalNextNonce ); |
|
845 } |
|
846 } |
|
847 } |
|
848 } |
|
849 } |
|
850 } |
|
851 } |
|
852 CleanupStack::PopAndDestroy(); //cmdRef |
|
853 if ( statusIsMatching ) |
|
854 { |
|
855 iAgent->CheckServerStatusCodeL( entryID ); |
|
856 } |
|
857 } |
|
858 |
|
859 // --------------------------------------------------------- |
|
860 // CNSmlCmdsBase::AlertCode |
|
861 // |
|
862 // --------------------------------------------------------- |
|
863 EXPORT_C TPtr8 CNSmlCmdsBase::AlertCode( SmlAlert_t* aAlert ) const |
|
864 { |
|
865 TPtr8 alertCode( NULL,0,0 ); |
|
866 if ( aAlert ) |
|
867 { |
|
868 if ( aAlert->data ) |
|
869 { |
|
870 if ( aAlert->data->content ) |
|
871 { |
|
872 alertCode.Set( (TUint8*) aAlert->data->content, aAlert->data->length, aAlert->data->length ); |
|
873 TrimRightSpaceAndNull( alertCode ); |
|
874 } |
|
875 } |
|
876 } |
|
877 return alertCode; |
|
878 } |
|
879 |
|
880 |
|
881 // --------------------------------------------------------- |
|
882 // CNSmlCmdsBase::StatusToUnsupportedCommandL() |
|
883 // Makes status data to unsupported or illegal SyncML command |
|
884 // --------------------------------------------------------- |
|
885 EXPORT_C void CNSmlCmdsBase::StatusToUnsupportedCommandL( TBool aIllegal, const TDesC8& aCmd, const SmlPcdata_t* aCmdRef, Flag_t aFlags ) |
|
886 { |
|
887 if ( iStatusToServer ) |
|
888 { |
|
889 TInt statusID( 0 ); |
|
890 statusID = iStatusToServer->CreateNewStatusElementL(); |
|
891 iStatusToServer->SetCmdRefL( statusID, aCmdRef ); |
|
892 iStatusToServer->SetCmdL( statusID, aCmd ); |
|
893 if ( iStatusToServerNoResponse || IsFlagSet( aFlags, SmlNoResp_f ) ) |
|
894 { |
|
895 iStatusToServer->SetNoResponse( statusID, ETrue ); |
|
896 } |
|
897 else |
|
898 { |
|
899 iStatusToServer->SetNoResponse( statusID, EFalse ); |
|
900 } |
|
901 if ( aIllegal ) |
|
902 { |
|
903 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusCommandFailed ); |
|
904 } |
|
905 else |
|
906 { |
|
907 iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusOptFeatureNotSupported ); |
|
908 } |
|
909 } |
|
910 } |
|
911 |
|
912 // --------------------------------------------------------- |
|
913 // CNSmlCmdsBase::GeneratedDocument() |
|
914 // |
|
915 // --------------------------------------------------------- |
|
916 TPtrC8 CNSmlCmdsBase::GeneratedDocument() const |
|
917 { |
|
918 return ( iGenerator->Document() ); |
|
919 } |
|
920 |
|
921 // --------------------------------------------------------- |
|
922 // CNSmlCmdsBase::BufferAreaForParsingL |
|
923 // |
|
924 // --------------------------------------------------------- |
|
925 EXPORT_C TPtr8 CNSmlCmdsBase::BufferAreaForParsingL() |
|
926 { |
|
927 delete iBufferArea; |
|
928 iBufferArea = 0; |
|
929 iBufferArea = HBufC8::NewL( iWorkspaceSize ); |
|
930 return iBufferArea->Des(); |
|
931 } |
|
932 // --------------------------------------------------------- |
|
933 // CNSmlCmdsBase::BusyStatus |
|
934 // |
|
935 // --------------------------------------------------------- |
|
936 EXPORT_C TBool CNSmlCmdsBase::BusyStatus() const |
|
937 { |
|
938 TBool busyStatusReceived = EFalse; |
|
939 if ( iResponseController ) |
|
940 { |
|
941 if ( iResponseController->BusyStatus( iCurrMsgID ) ) |
|
942 { |
|
943 busyStatusReceived = ETrue; |
|
944 } |
|
945 } |
|
946 return ( busyStatusReceived ); |
|
947 } |
|
948 // --------------------------------------------------------- |
|
949 // CNSmlCmdsBase::StatusContainer() |
|
950 // |
|
951 // --------------------------------------------------------- |
|
952 EXPORT_C CNSmlStatusContainer* CNSmlCmdsBase::StatusContainer() const |
|
953 { |
|
954 return iStatusToServer; |
|
955 } |
|
956 // --------------------------------------------------------- |
|
957 // CNSmlCmdsBase::ResponseController() |
|
958 // |
|
959 // --------------------------------------------------------- |
|
960 EXPORT_C CNSmlResponseController* CNSmlCmdsBase::ResponseController() const |
|
961 { |
|
962 return iResponseController; |
|
963 } |
|
964 // --------------------------------------------------------- |
|
965 // CNSmlCmdsBase::ResultsContainer() |
|
966 // |
|
967 // --------------------------------------------------------- |
|
968 EXPORT_C CNSmlResultsContainer* CNSmlCmdsBase::ResultsContainer() const |
|
969 { |
|
970 return iResultsToServer; |
|
971 } |
|
972 // --------------------------------------------------------- |
|
973 // CNSmlCmdsBase::ServerAuth() |
|
974 // |
|
975 // --------------------------------------------------------- |
|
976 EXPORT_C CNSmlAuth* CNSmlCmdsBase::ServerAuth() const |
|
977 { |
|
978 return iServerAuth; |
|
979 } |
|
980 // --------------------------------------------------------- |
|
981 // CNSmlCmdsBase::RespURI |
|
982 // |
|
983 // --------------------------------------------------------- |
|
984 EXPORT_C CNSmlURI* CNSmlCmdsBase::RespURI() const |
|
985 { |
|
986 return iRespURI; |
|
987 } |
|
988 // --------------------------------------------------------- |
|
989 // CNSmlCmdsBase::DoMetaL |
|
990 // Makes Meta element |
|
991 // --------------------------------------------------------- |
|
992 EXPORT_C void CNSmlCmdsBase::DoMetaL( SmlPcdata_t*& aMeta, const SmlMetInfMetInf_t* aMetaData ) const |
|
993 { |
|
994 aMeta = new( ELeave ) SmlPcdata_t; |
|
995 aMeta->length = 0; |
|
996 aMeta->content = ( TAny* ) aMetaData; |
|
997 aMeta->contentType = SML_PCDATA_EXTENSION; |
|
998 aMeta->extension = SML_EXT_METINF; |
|
999 } |
|
1000 // --------------------------------------------------------- |
|
1001 // CNSmlCmdsBase::DoMetInfLC |
|
1002 // Initialises empty MetInf structure |
|
1003 // --------------------------------------------------------- |
|
1004 EXPORT_C void CNSmlCmdsBase::DoMetInfLC( SmlMetInfMetInf_t*& aMeta ) const |
|
1005 { |
|
1006 aMeta = new( ELeave ) SmlMetInfMetInf_t; |
|
1007 CleanupStack::PushL( aMeta ); |
|
1008 } |
|
1009 // --------------------------------------------------------- |
|
1010 // CNSmlCmdsBase::PcDataNewL |
|
1011 // Create Pcdata |
|
1012 // --------------------------------------------------------- |
|
1013 EXPORT_C void CNSmlCmdsBase::PcdataNewL( SmlPcdata_t*& aPcdata, const TDesC8& aContent ) const |
|
1014 { |
|
1015 aPcdata = new( ELeave ) SmlPcdata_t; |
|
1016 aPcdata->SetDataL( aContent ); |
|
1017 aPcdata->contentType = SML_PCDATA_OPAQUE; |
|
1018 aPcdata->extension = SML_EXT_UNDEFINED; |
|
1019 } |
|
1020 |
|
1021 //1.2 CHANGES |
|
1022 |
|
1023 // --------------------------------------------------------- |
|
1024 // CNSmlCmdsBase::DoSourceL |
|
1025 // Makes Source or Target element without LocName element |
|
1026 // --------------------------------------------------------- |
|
1027 EXPORT_C void CNSmlCmdsBase::DoSourceL( sml_source_s*& aSource, const TDesC& aLocURIData ) const |
|
1028 { |
|
1029 aSource = new( ELeave ) sml_source_s; |
|
1030 HBufC8* locURIDataInUTF8 = NULL; |
|
1031 NSmlUnicodeConverter::HBufC8InUTF8LC( aLocURIData, locURIDataInUTF8 ); |
|
1032 PcdataNewL ( aSource->locURI, *locURIDataInUTF8 ); |
|
1033 CleanupStack::PopAndDestroy(); //locURIDataInUTF8 |
|
1034 aSource->locName = NULL; |
|
1035 } |
|
1036 |
|
1037 // --------------------------------------------------------- |
|
1038 // CNSmlCmdsBase::DoSourceL |
|
1039 // Makes Source or Target element without LocName element |
|
1040 // --------------------------------------------------------- |
|
1041 EXPORT_C void CNSmlCmdsBase::DoSourceL( sml_source_s*& aSource, const TDesC8& aLocURIData ) const |
|
1042 { |
|
1043 aSource = new( ELeave ) sml_source_s; |
|
1044 PcdataNewL ( aSource->locURI, aLocURIData ); |
|
1045 aSource->locName = NULL; |
|
1046 } |
|
1047 |
|
1048 // --------------------------------------------------------- |
|
1049 // CNSmlCmdsBase::DoSourceL |
|
1050 // Makes Source or Target element with LocName element |
|
1051 // --------------------------------------------------------- |
|
1052 EXPORT_C void CNSmlCmdsBase::DoSourceL( sml_source_s*& aSource, const TDesC& aLocURIData, const TDesC& aLocNameData ) const |
|
1053 { |
|
1054 aSource = new( ELeave ) sml_source_s; |
|
1055 HBufC8* locURIDataInUTF8 = NULL; |
|
1056 NSmlUnicodeConverter::HBufC8InUTF8LC( aLocURIData, locURIDataInUTF8 ); |
|
1057 PcdataNewL ( aSource->locURI, *locURIDataInUTF8 ); |
|
1058 CleanupStack::PopAndDestroy(); //locURIDataInUTF8 |
|
1059 HBufC8* locNameDataInUTF8 = NULL; |
|
1060 NSmlUnicodeConverter::HBufC8InUTF8LC( aLocNameData, locNameDataInUTF8 ); |
|
1061 PcdataNewL ( aSource->locName, *locNameDataInUTF8 ); |
|
1062 CleanupStack::PopAndDestroy(); //locNameDataInUTF8 |
|
1063 } |
|
1064 |
|
1065 // --------------------------------------------------------- |
|
1066 // CNSmlCmdsBase::DoTargetL |
|
1067 // Makes Source or Target element without LocName element |
|
1068 // --------------------------------------------------------- |
|
1069 EXPORT_C void CNSmlCmdsBase::DoTargetL( sml_target_s*& aTarget, const TDesC& aLocURIData ) const |
|
1070 { |
|
1071 aTarget = new( ELeave ) sml_target_s; |
|
1072 HBufC8* locURIDataInUTF8 = NULL; |
|
1073 NSmlUnicodeConverter::HBufC8InUTF8LC( aLocURIData, locURIDataInUTF8 ); |
|
1074 PcdataNewL ( aTarget->locURI, *locURIDataInUTF8 ); |
|
1075 CleanupStack::PopAndDestroy(); //locURIDataInUTF8 |
|
1076 aTarget->locName = NULL; |
|
1077 } |
|
1078 |
|
1079 // --------------------------------------------------------- |
|
1080 // CNSmlCmdsBase::DoTargetL |
|
1081 // Makes Source or Target element without LocName element |
|
1082 // --------------------------------------------------------- |
|
1083 EXPORT_C void CNSmlCmdsBase::DoTargetL( sml_target_s*& aTarget, const TDesC8& aLocURIData ) const |
|
1084 { |
|
1085 aTarget = new( ELeave ) sml_target_s; |
|
1086 PcdataNewL ( aTarget->locURI, aLocURIData ); |
|
1087 aTarget->locName = NULL; |
|
1088 } |
|
1089 |
|
1090 // --------------------------------------------------------- |
|
1091 // CNSmlCmdsBase::DoTargetL |
|
1092 // Makes Source or Target element with LocName element |
|
1093 // --------------------------------------------------------- |
|
1094 EXPORT_C void CNSmlCmdsBase::DoTargetL( sml_target_s*& aTarget, const TDesC& aLocURIData, const TDesC& aLocNameData ) const |
|
1095 { |
|
1096 aTarget = new( ELeave ) sml_target_s; |
|
1097 HBufC8* locURIDataInUTF8 = NULL; |
|
1098 NSmlUnicodeConverter::HBufC8InUTF8LC( aLocURIData, locURIDataInUTF8 ); |
|
1099 PcdataNewL ( aTarget->locURI, *locURIDataInUTF8 ); |
|
1100 CleanupStack::PopAndDestroy(); //locURIDataInUTF8 |
|
1101 HBufC8* locNameDataInUTF8 = NULL; |
|
1102 NSmlUnicodeConverter::HBufC8InUTF8LC( aLocNameData, locNameDataInUTF8 ); |
|
1103 PcdataNewL ( aTarget->locName, *locNameDataInUTF8 ); |
|
1104 CleanupStack::PopAndDestroy(); //locNameDataInUTF8 |
|
1105 } |
|
1106 //end changes |
|
1107 |
|
1108 // --------------------------------------------------------- |
|
1109 // CNSmlCmdsBase::PCDATAToUnicodeLC |
|
1110 // Converts data in Pcdata structure (used by xml parser) |
|
1111 // to Unicode |
|
1112 // --------------------------------------------------------- |
|
1113 EXPORT_C void CNSmlCmdsBase::PCDATAToUnicodeLC( const SmlPcdata_t& aPcdata, HBufC*& aUnicodeData ) const |
|
1114 { |
|
1115 if ( !aPcdata.content ) |
|
1116 { |
|
1117 aUnicodeData = NULL; |
|
1118 aUnicodeData = HBufC16::NewLC( 0 ); |
|
1119 } |
|
1120 TPtr8 pcdata( (TUint8*) aPcdata.content, aPcdata.length, aPcdata.length ); |
|
1121 TrimRightSpaceAndNull( pcdata ); |
|
1122 NSmlUnicodeConverter::HBufC16InUnicodeLC( pcdata, aUnicodeData ); |
|
1123 } |
|
1124 |
|
1125 // --------------------------------------------------------- |
|
1126 // CNSmlCmdsBase::ResetLargeObjectBuffer() |
|
1127 // |
|
1128 // --------------------------------------------------------- |
|
1129 EXPORT_C void CNSmlCmdsBase::ResetLargeObjectBuffer() |
|
1130 { |
|
1131 delete iRecBuf; |
|
1132 iRecBuf = NULL; |
|
1133 iServerLargeObjectSize = 0; |
|
1134 } |
|
1135 |
|
1136 // --------------------------------------------------------- |
|
1137 // CNSmlCmdsBase::WaitingLargeObjectChunk() |
|
1138 // |
|
1139 // --------------------------------------------------------- |
|
1140 EXPORT_C TBool CNSmlCmdsBase::WaitingLargeObjectChunk() const |
|
1141 { |
|
1142 if ( iRecBuf != NULL ) |
|
1143 { |
|
1144 return ETrue; |
|
1145 } |
|
1146 else |
|
1147 { |
|
1148 return EFalse; |
|
1149 } |
|
1150 } |
|
1151 // --------------------------------------------------------- |
|
1152 // CNSmlCmdsBase::ConstructL |
|
1153 // |
|
1154 // --------------------------------------------------------- |
|
1155 EXPORT_C void CNSmlCmdsBase::ConstructL( CNSmlAgentBase* aAgentBase, const TDesC8& aSessionID, const TDesC8& aVerProto, const TInt aPublicId, const HBufC& aSyncMLUserName, CNSmlURI* aSyncServer, TBool aVersionCheck ) |
|
1156 { |
|
1157 iMaxWorkspaceSize = KNSmlDefaultWorkspaceSize; |
|
1158 iAgent = aAgentBase; |
|
1159 iSessionID = aSessionID.AllocL(); |
|
1160 iWorkspaceSize = iMaxWorkspaceSize; |
|
1161 iVerProto = aVerProto.AllocL(); |
|
1162 iVersionPublicId = aPublicId; |
|
1163 |
|
1164 //1.2 CHANGES: 1.1 and 1.2 version support |
|
1165 if ( aPublicId == KNSmlSyncMLPublicId ) |
|
1166 { |
|
1167 iVerDTD = KNSmlAgentVerDTD11().AllocL(); |
|
1168 } |
|
1169 else |
|
1170 { |
|
1171 iVerDTD = KNSmlAgentVerDTD12().AllocL(); |
|
1172 } |
|
1173 //end changes |
|
1174 |
|
1175 iVersionCheck = aVersionCheck; |
|
1176 iSyncMLUserName = aSyncMLUserName.AllocL(); |
|
1177 iSyncServer = CNSmlURI::NewL( aSyncServer->HostNameWithPortL() ); |
|
1178 iPhoneInfo = CNSmlPhoneInfo::NewL(); |
|
1179 iStatusToServer = CNSmlStatusContainer::NewL(); |
|
1180 iResponseController = CNSmlResponseController::NewL(); |
|
1181 iResultsToServer = CNSmlResultsContainer::NewL(); |
|
1182 iServerAuth = CNSmlAuth::NewL(); |
|
1183 } |
|
1184 // --------------------------------------------------------- |
|
1185 // CNSmlCmdsBase::DoCmdIdL |
|
1186 // Makes CmdID element |
|
1187 // --------------------------------------------------------- |
|
1188 EXPORT_C void CNSmlCmdsBase::DoCmdIdL( SmlPcdata_t*& aCmdID ) |
|
1189 { |
|
1190 HBufC8* stringCmdID = HBufC8::NewLC( 16 ); |
|
1191 stringCmdID->Des().Num( ++iCurrCmdID ); |
|
1192 PcdataNewL ( aCmdID, *stringCmdID ); |
|
1193 CleanupStack::PopAndDestroy(); //stringCmdID |
|
1194 } |
|
1195 |
|
1196 |
|
1197 |
|
1198 // --------------------------------------------------------- |
|
1199 // CNSmlCmdsBase::DoAnchorsL |
|
1200 // Makes Anchor elements in MetInf DTD |
|
1201 // --------------------------------------------------------- |
|
1202 EXPORT_C void CNSmlCmdsBase::DoAnchorsL( SmlMetInfMetInf_t& aMetInf, const TDesC8* aLast, const TDesC8* aNext ) const |
|
1203 { |
|
1204 aMetInf.anchor = new ( ELeave) SmlMetInfAnchor_t; |
|
1205 if ( aLast ) |
|
1206 { |
|
1207 PcdataNewL( aMetInf.anchor->last, *aLast ); |
|
1208 } |
|
1209 else |
|
1210 { |
|
1211 aMetInf.anchor->last = NULL; |
|
1212 } |
|
1213 if ( aNext ) |
|
1214 { |
|
1215 PcdataNewL( aMetInf.anchor->next, *aNext ); |
|
1216 } |
|
1217 else |
|
1218 { |
|
1219 aMetInf.anchor->next = NULL; |
|
1220 } |
|
1221 } |
|
1222 // --------------------------------------------------------- |
|
1223 // CNSmlCmdsBase::DoMaxObjSizeL() |
|
1224 // Set MaxObjSize element with default value |
|
1225 // --------------------------------------------------------- |
|
1226 EXPORT_C void CNSmlCmdsBase::DoMaxObjSizeL( SmlMetInfMetInf_t& aMetInf, TInt aMaxObjSize ) const |
|
1227 { |
|
1228 HBufC8* stringSize = HBufC8::NewLC( 16 ); |
|
1229 stringSize->Des().Num( aMaxObjSize ); |
|
1230 PcdataNewL( aMetInf.maxobjsize, *stringSize ); |
|
1231 CleanupStack::PopAndDestroy(); //stringSize |
|
1232 } |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 // --------------------------------------------------------- |
|
1239 // CNSmlCmdsBase::SubtractConsumedFromPcData |
|
1240 // |
|
1241 // --------------------------------------------------------- |
|
1242 EXPORT_C void CNSmlCmdsBase::SubtractConsumedFromPcData( SmlItem_t*& aItem, TInt aConsumed ) |
|
1243 { |
|
1244 TPtr8 data( (TUint8*) aItem->data->content, aItem->data->length ); |
|
1245 data.SetLength( aItem->data->length ); |
|
1246 if ( data.Length() < aConsumed ) |
|
1247 { |
|
1248 data.Delete( 0, data.Length() ); |
|
1249 aItem->data->length = 0; |
|
1250 } |
|
1251 else |
|
1252 { |
|
1253 data.Delete( 0, aConsumed ); |
|
1254 aItem->data->length -= aConsumed; |
|
1255 } |
|
1256 } |
|
1257 |
|
1258 // --------------------------------------------------------- |
|
1259 // CNSmlCmdsBase::StatusDataToGenericCommandL() |
|
1260 // Save status data to Add, Replace and Delete commands |
|
1261 // --------------------------------------------------------- |
|
1262 EXPORT_C TInt CNSmlCmdsBase::StatusDataToGenericCommandL( const TDesC8& aCmd, const SmlGenericCmd_t* aContent, const SmlItem_t* aItem, TNSmlError::TNSmlSyncMLStatusCode aStatusCode, const TDesC8* aStatusItem ) |
|
1263 { |
|
1264 return StatusDataToCommandL( aCmd, aContent->cmdID, aContent->flags, aItem, aStatusCode, aStatusItem ); |
|
1265 } |
|
1266 |
|
1267 // --------------------------------------------------------- |
|
1268 // CNSmlCmdsBase::StatusDataToGetCommandL() |
|
1269 // Save status data to Get command |
|
1270 // --------------------------------------------------------- |
|
1271 EXPORT_C TInt CNSmlCmdsBase::StatusDataToGetCommandL( const SmlGet_t* aContent, const SmlItem_t* aItem, TNSmlError::TNSmlSyncMLStatusCode aStatusCode, const TDesC8* aStatusItem ) |
|
1272 { |
|
1273 return StatusDataToCommandL( KNSmlAgentGet, aContent->cmdID, aContent->flags, aItem, aStatusCode, aStatusItem ); |
|
1274 } |
|
1275 // --------------------------------------------------------- |
|
1276 // CNSmlCmdsBase::StatusDataToCommandL() |
|
1277 // Save status data to command |
|
1278 // --------------------------------------------------------- |
|
1279 EXPORT_C TInt CNSmlCmdsBase::StatusDataToCommandL( const TDesC8& aCmd, const SmlPcdata_t* aCmdID, TUint aFlags, const SmlItem_t* aItem, TNSmlError::TNSmlSyncMLStatusCode aStatusCode, const TDesC8* aStatusItem ) |
|
1280 { |
|
1281 TInt statusID( 0 ); |
|
1282 statusID = iStatusToServer->CreateNewStatusElementL(); |
|
1283 iStatusToServer->SetCmdRefL( statusID, aCmdID ); |
|
1284 iStatusToServer->SetCmdL( statusID, aCmd ); |
|
1285 if ( iStatusToServerNoResponse || IsFlagSet( aFlags, SmlNoResp_f ) ) |
|
1286 { |
|
1287 iStatusToServer->SetNoResponse( statusID, ETrue ); |
|
1288 } |
|
1289 else |
|
1290 { |
|
1291 iStatusToServer->SetNoResponse( statusID, EFalse ); |
|
1292 } |
|
1293 if ( aItem ) |
|
1294 { |
|
1295 iStatusToServer->AddTargetRefL( statusID, aItem->target ); |
|
1296 iStatusToServer->AddSourceRefL( statusID, aItem->source ); |
|
1297 } |
|
1298 if ( aStatusItem ) |
|
1299 { |
|
1300 SmlPcdata_t* data = NULL; |
|
1301 PcdataNewL( data, *aStatusItem ); |
|
1302 CleanupStack::PushL( data ); |
|
1303 iStatusToServer->AddItemDataL( statusID, data ); |
|
1304 CleanupStack::PopAndDestroy(); //data |
|
1305 } |
|
1306 iStatusToServer->SetStatusCodeL( statusID, aStatusCode ); |
|
1307 return statusID; |
|
1308 } |
|
1309 |
|
1310 // --------------------------------------------------------- |
|
1311 // CNSmlCmdsBase::CreateAndInitResponseItemL() |
|
1312 // Creates and initialises response controller for Clients commands |
|
1313 // --------------------------------------------------------- |
|
1314 EXPORT_C TInt CNSmlCmdsBase::CreateAndInitResponseItemL( const TDesC8& aCommand ) |
|
1315 { |
|
1316 TInt respID; |
|
1317 respID = iResponseController->CreateNewResponseItemL(); |
|
1318 iResponseController->SetMsgID( respID, iCurrMsgID ); |
|
1319 iResponseController->SetCmdID( respID, iCurrCmdID ); |
|
1320 iResponseController->SetCmdL( respID, aCommand ); |
|
1321 return respID; |
|
1322 } |
|
1323 |
|
1324 |
|
1325 |
|
1326 // --------------------------------------------------------- |
|
1327 // CNSmlCmdsBase::TargetIsUnderItem() |
|
1328 // |
|
1329 // --------------------------------------------------------- |
|
1330 EXPORT_C TBool CNSmlCmdsBase::TargetIsUnderItem( const SmlItemList_t* aItemList ) const |
|
1331 { |
|
1332 if ( aItemList ) |
|
1333 { |
|
1334 if ( aItemList->item ) |
|
1335 { |
|
1336 if ( aItemList->item->target ) |
|
1337 { |
|
1338 if ( aItemList->item->target->locURI ) |
|
1339 { |
|
1340 return ETrue; |
|
1341 } |
|
1342 } |
|
1343 } |
|
1344 } |
|
1345 return EFalse; |
|
1346 } |
|
1347 // --------------------------------------------------------- |
|
1348 // CNSmlCmdsBase::SourceIsUnderItem() |
|
1349 // |
|
1350 // --------------------------------------------------------- |
|
1351 EXPORT_C TBool CNSmlCmdsBase::SourceIsUnderItem( const SmlItemList_t* aItemList ) const |
|
1352 { |
|
1353 if ( aItemList ) |
|
1354 { |
|
1355 if ( aItemList->item ) |
|
1356 { |
|
1357 if ( aItemList->item->source ) |
|
1358 { |
|
1359 if ( aItemList->item->source->locURI ) |
|
1360 { |
|
1361 return ETrue; |
|
1362 } |
|
1363 } |
|
1364 } |
|
1365 } |
|
1366 return EFalse; |
|
1367 } |
|
1368 // --------------------------------------------------------- |
|
1369 // CNSmlCmdsBase::MetaTypeInUtf8LC() |
|
1370 // |
|
1371 // --------------------------------------------------------- |
|
1372 EXPORT_C HBufC8* CNSmlCmdsBase::MetaTypeInUtf8LC( const SmlPcdata_t* aMeta ) const |
|
1373 { |
|
1374 HBufC8* typeInUtf8 = NULL; |
|
1375 if ( aMeta ) |
|
1376 { |
|
1377 if ( ( aMeta->content ) && ( aMeta->contentType == SML_PCDATA_EXTENSION ) && ( aMeta->extension == SML_EXT_METINF ) ) |
|
1378 { |
|
1379 SmlMetInfMetInf_t* metInf; |
|
1380 metInf = (SmlMetInfMetInf_t*) aMeta->content; |
|
1381 if ( metInf->type ) |
|
1382 { |
|
1383 if ( metInf->type->content ) |
|
1384 { |
|
1385 TPtr8 type( (TUint8*) metInf->type->content, metInf->type->length, metInf->type->length ); |
|
1386 TrimRightSpaceAndNull( type ); |
|
1387 typeInUtf8 = type.AllocLC(); |
|
1388 } |
|
1389 } |
|
1390 } |
|
1391 } |
|
1392 if ( typeInUtf8 == NULL ) |
|
1393 { |
|
1394 typeInUtf8 = HBufC8::NewLC( 0 ); |
|
1395 } |
|
1396 return typeInUtf8; |
|
1397 } |
|
1398 // --------------------------------------------------------- |
|
1399 // CNSmlCmdsBase::MetaTypeLC() |
|
1400 // |
|
1401 // --------------------------------------------------------- |
|
1402 EXPORT_C HBufC* CNSmlCmdsBase::MetaTypeLC( const SmlPcdata_t* aMeta ) const |
|
1403 { |
|
1404 HBufC* typeInUnicode = NULL; |
|
1405 if ( aMeta ) |
|
1406 { |
|
1407 if ( ( aMeta->content ) && ( aMeta->contentType == SML_PCDATA_EXTENSION ) && ( aMeta->extension == SML_EXT_METINF ) ) |
|
1408 { |
|
1409 SmlMetInfMetInf_t* metInf; |
|
1410 metInf = (SmlMetInfMetInf_t*) aMeta->content; |
|
1411 if ( metInf->type ) |
|
1412 { |
|
1413 PCDATAToUnicodeLC( *metInf->type, typeInUnicode ); |
|
1414 } |
|
1415 } |
|
1416 } |
|
1417 if ( typeInUnicode == NULL ) |
|
1418 { |
|
1419 typeInUnicode = HBufC::NewLC( 0 ); |
|
1420 } |
|
1421 return typeInUnicode; |
|
1422 } |
|
1423 // --------------------------------------------------------- |
|
1424 // CNSmlCmdsBase::MetaFormatInUtf8LC() |
|
1425 // |
|
1426 // --------------------------------------------------------- |
|
1427 EXPORT_C HBufC8* CNSmlCmdsBase::MetaFormatInUtf8LC( const SmlPcdata_t* aMeta ) const |
|
1428 { |
|
1429 HBufC8* formatInUtf8 = NULL; |
|
1430 if ( aMeta ) |
|
1431 { |
|
1432 if ( ( aMeta->content ) && ( aMeta->contentType == SML_PCDATA_EXTENSION ) && ( aMeta->extension == SML_EXT_METINF ) ) |
|
1433 { |
|
1434 SmlMetInfMetInf_t* metInf; |
|
1435 metInf = (SmlMetInfMetInf_t*) aMeta->content; |
|
1436 if ( metInf->format ) |
|
1437 { |
|
1438 if ( metInf->format->content ) |
|
1439 { |
|
1440 TPtr8 format( (TUint8*) metInf->format->content, metInf->format->length, metInf->format->length ); |
|
1441 TrimRightSpaceAndNull( format ); |
|
1442 formatInUtf8 = format.AllocLC(); |
|
1443 } |
|
1444 } |
|
1445 } |
|
1446 } |
|
1447 if ( formatInUtf8 == NULL ) |
|
1448 { |
|
1449 formatInUtf8 = HBufC8::NewLC( 0 ); |
|
1450 } |
|
1451 return formatInUtf8; |
|
1452 } |
|
1453 // --------------------------------------------------------- |
|
1454 // CNSmlCmdsBase::IsFlagSet |
|
1455 // |
|
1456 // --------------------------------------------------------- |
|
1457 EXPORT_C TBool CNSmlCmdsBase::IsFlagSet( const TUint& aValue, const TUint& aBit ) const |
|
1458 { |
|
1459 return( (aValue & aBit) == aBit ); |
|
1460 } |
|
1461 |
|
1462 |
|
1463 // --------------------------------------------------------- |
|
1464 // CNSmlCmdsBase::TrimRightSpaceAndNull |
|
1465 // Trims right spaces and zero terminator (NULL) |
|
1466 // --------------------------------------------------------- |
|
1467 EXPORT_C void CNSmlCmdsBase::TrimRightSpaceAndNull( TDes8& aDes ) const |
|
1468 { |
|
1469 aDes.TrimRight(); |
|
1470 if ( aDes.Length() > 0 ) |
|
1471 { |
|
1472 if ( aDes[aDes.Length() - 1] == NULL ) |
|
1473 { |
|
1474 aDes.SetLength( aDes.Length() - 1 ); |
|
1475 } |
|
1476 } |
|
1477 } |
|
1478 |
|
1479 // --------------------------------------------------------- |
|
1480 // CNSmlCmdsBase::MoreDataL |
|
1481 // Handles the buffering of received chunked large objects |
|
1482 // --------------------------------------------------------- |
|
1483 EXPORT_C TNSmlError::TNSmlSyncMLStatusCode CNSmlCmdsBase::MoreDataL( const HBufC8* aUID, const SmlItem_t* aCurrentItem, const SmlPcdata_t* aMetaInCommand, CBufBase*& aTotalItem ) |
|
1484 { |
|
1485 aTotalItem = NULL; |
|
1486 TNSmlError::TNSmlSyncMLStatusCode statusCode = TNSmlError::ESmlStatusOK; |
|
1487 TBool moreData = IsFlagSet( aCurrentItem->flags, SmlMoreData_f ); |
|
1488 |
|
1489 if ( iRecBuf != NULL ) // previous chunks, check that UID is same |
|
1490 { |
|
1491 HBufC8* UID; |
|
1492 if ( aUID ) |
|
1493 { |
|
1494 UID = aUID->AllocLC(); |
|
1495 } |
|
1496 else |
|
1497 { |
|
1498 UID = HBufC8::NewLC( 0 ); |
|
1499 } |
|
1500 if ( *UID != *iLargeObjectUID ) |
|
1501 { |
|
1502 iAgent->SetEndOfDataAlertRequest(); |
|
1503 delete iRecBuf; |
|
1504 iRecBuf = NULL; |
|
1505 delete iLargeObjectUID; |
|
1506 iLargeObjectUID = NULL; |
|
1507 iServerLargeObjectSize = 0; |
|
1508 } |
|
1509 CleanupStack::PopAndDestroy(); //UID |
|
1510 } |
|
1511 if ( moreData && iRecBuf == NULL ) //save object size when the first chunk |
|
1512 { |
|
1513 iServerLargeObjectSize = ServerObjectSize( aCurrentItem->meta ); |
|
1514 if ( iServerLargeObjectSize == 0 ) |
|
1515 { |
|
1516 iServerLargeObjectSize = ServerObjectSize( aMetaInCommand ); |
|
1517 } |
|
1518 delete iLargeObjectUID; |
|
1519 iLargeObjectUID = NULL; |
|
1520 if ( aUID ) |
|
1521 { |
|
1522 iLargeObjectUID = aUID->AllocL(); |
|
1523 } |
|
1524 else |
|
1525 { |
|
1526 iLargeObjectUID = HBufC8::NewL( 0 ); |
|
1527 } |
|
1528 } |
|
1529 |
|
1530 TBool previousChunks = EFalse; |
|
1531 if ( iRecBuf == NULL ) |
|
1532 { |
|
1533 iRecBuf = CBufFlat::NewL( 1 ); |
|
1534 } |
|
1535 else |
|
1536 { |
|
1537 previousChunks = ETrue; |
|
1538 } |
|
1539 if ( aCurrentItem->data ) |
|
1540 { |
|
1541 if ( aCurrentItem->data->content ) |
|
1542 { |
|
1543 TPtr8 data( (TUint8*) aCurrentItem->data->content, aCurrentItem->data->length, aCurrentItem->data->length ); |
|
1544 iRecBuf->InsertL( iRecBuf->Size(), data ); |
|
1545 } |
|
1546 } |
|
1547 if ( !moreData ) |
|
1548 { |
|
1549 if ( (previousChunks) && (iRecBuf->Size() != iServerLargeObjectSize) ) |
|
1550 { // size check with large objects |
|
1551 statusCode = TNSmlError::ESmlStatusSizeMismatch; |
|
1552 delete iRecBuf; |
|
1553 } |
|
1554 else |
|
1555 { // it is the last chunk, ownership of the buffer is moved to a caller |
|
1556 aTotalItem = iRecBuf; |
|
1557 } |
|
1558 iRecBuf = NULL; |
|
1559 iServerLargeObjectSize = 0; |
|
1560 } |
|
1561 else |
|
1562 { |
|
1563 aTotalItem = NULL; |
|
1564 statusCode = TNSmlError::ESmlStatusItemAccepted; |
|
1565 } |
|
1566 |
|
1567 return statusCode; |
|
1568 } |
|
1569 |
|
1570 // --------------------------------------------------------- |
|
1571 // CNSmlCmdsBase::ServerMaxObjSize |
|
1572 // MaxObjSize from Meta element structure |
|
1573 // --------------------------------------------------------- |
|
1574 EXPORT_C TInt CNSmlCmdsBase::ServerMaxObjSize( const SmlPcdata_t* aMeta ) const |
|
1575 { |
|
1576 TInt maxObjSizeNum = 0; |
|
1577 if ( aMeta ) |
|
1578 { |
|
1579 if ( ( aMeta->content ) && ( aMeta->contentType == SML_PCDATA_EXTENSION ) && ( aMeta->extension == SML_EXT_METINF ) ) |
|
1580 { |
|
1581 SmlMetInfMetInf_t* metInf; |
|
1582 metInf = (SmlMetInfMetInf_t*) aMeta->content; |
|
1583 if ( metInf->maxobjsize ) |
|
1584 { |
|
1585 if ( metInf->maxobjsize->content ) |
|
1586 { |
|
1587 TPtr8 maxObjSize( (TUint8*) metInf->maxobjsize->content, metInf->maxobjsize->length, metInf->maxobjsize->length ); |
|
1588 TrimRightSpaceAndNull( maxObjSize ); |
|
1589 TLex8 lexicalValue( maxObjSize ); |
|
1590 if ( lexicalValue.Val( maxObjSizeNum ) != KErrNone ) |
|
1591 { |
|
1592 maxObjSizeNum = 0; |
|
1593 } |
|
1594 } |
|
1595 } |
|
1596 } |
|
1597 } |
|
1598 return maxObjSizeNum; |
|
1599 } |
|
1600 |
|
1601 // --------------------------------------------------------- |
|
1602 // CNSmlCmdsBase::ServerObjectSize() |
|
1603 // Size from Meta element structure |
|
1604 // --------------------------------------------------------- |
|
1605 EXPORT_C TInt CNSmlCmdsBase::ServerObjectSize( const SmlPcdata_t* aMeta ) const |
|
1606 { |
|
1607 TInt sizeNum = 0; |
|
1608 if ( aMeta ) |
|
1609 { |
|
1610 if ( ( aMeta->content ) && ( aMeta->contentType == SML_PCDATA_EXTENSION ) && ( aMeta->extension == SML_EXT_METINF ) ) |
|
1611 { |
|
1612 SmlMetInfMetInf_t* metInf; |
|
1613 metInf = (SmlMetInfMetInf_t*) aMeta->content; |
|
1614 if ( metInf->size ) |
|
1615 { |
|
1616 if ( metInf->size->content ) |
|
1617 { |
|
1618 TPtr8 size( (TUint8*) metInf->size->content, metInf->size->length, metInf->size->length ); |
|
1619 TrimRightSpaceAndNull( size ); |
|
1620 TLex8 lexicalValue( size ); |
|
1621 if ( lexicalValue.Val( sizeNum ) != KErrNone ) |
|
1622 { |
|
1623 sizeNum = 0; |
|
1624 } |
|
1625 } |
|
1626 } |
|
1627 } |
|
1628 } |
|
1629 return sizeNum; |
|
1630 } |
|
1631 |
|
1632 // ----------------------------------------------------------------------------- |
|
1633 // CNSmlCmdsBase::SetMaximumWorkspaceSize |
|
1634 // Sets the maximum workspace size |
|
1635 // ----------------------------------------------------------------------------- |
|
1636 // |
|
1637 EXPORT_C void CNSmlCmdsBase::SetMaximumWorkspaceSize( const TInt aMaxSize ) |
|
1638 { |
|
1639 iMaxWorkspaceSize = aMaxSize; |
|
1640 |
|
1641 if ( iWorkspaceSize == KNSmlDefaultWorkspaceSize ) |
|
1642 { |
|
1643 iWorkspaceSize = aMaxSize; |
|
1644 } |
|
1645 } |
|
1646 |
|
1647 // --------------------------------------------------------- |
|
1648 // CNSmlCmdsBase::BufferAreaForDebugDumpL |
|
1649 // |
|
1650 // --------------------------------------------------------- |
|
1651 #ifdef __NOTRANSPORT |
|
1652 |
|
1653 TPtr8 CNSmlCmdsBase::BufferAreaForDebugDumpL() |
|
1654 { |
|
1655 return iBufferArea->Des(); |
|
1656 } |
|
1657 |
|
1658 #endif |
|
1659 |