1 /* |
|
2 * Copyright (c) 2002 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: DM Startup Adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /* |
|
20 ./Customization -+--> Startup -+--> WelcomeData |
|
21 */ |
|
22 |
|
23 // ------------------------------------------------------------------------------------------------ |
|
24 // Use this flag to activate mime type checking in adapter |
|
25 // Data with unsupported mime types will be rejected |
|
26 // |
|
27 // #define SUPADAPTER_CHECK_MIME_TYPES |
|
28 #ifdef SUPADAPTER_CHECK_MIME_TYPES |
|
29 |
|
30 #define SUPADAPTER_CHECK_TEXT_MIME_TYPE |
|
31 #define SUPADAPTER_CHECK_IMAGE_MIME_TYPE |
|
32 |
|
33 #endif |
|
34 |
|
35 // ------------------------------------------------------------------------------------------------ |
|
36 #include "supadapter.h" |
|
37 |
|
38 // symbian |
|
39 #ifndef __WINS_DEBUG_TESTING__ |
|
40 #include <implementationproxy.h> // For TImplementationProxy definition |
|
41 #endif |
|
42 #include <fbs.h> |
|
43 #include <f32file.h> |
|
44 #include <imcvcodc.h> |
|
45 // s60 |
|
46 #include <AknUtils.h> |
|
47 #include <sysutil.h> |
|
48 #include <startupdomaincrkeys.h> |
|
49 // tarm |
|
50 //#ifdef __SAP_POLICY_MANAGEMENT |
|
51 #include <DMCert.h> |
|
52 #include <SettingEnforcementInfo.h> |
|
53 #include <PolicyEngineXACML.h> |
|
54 //#endif |
|
55 #include "nsmldmuri.h" |
|
56 #include "TPtrC8I.h" |
|
57 #include "TARMCharConv.h" |
|
58 #include "FileCoderB64.h" |
|
59 #include "debug.h" |
|
60 #include <featmgr.h> |
|
61 #include <utf.h> |
|
62 /** |
|
63 * |
|
64 * Supported MIME types of this adapter |
|
65 * |
|
66 **/ |
|
67 _LIT8(KText, "text/"); |
|
68 _LIT8(KMimeTypeTextPlain, "text/plain"); |
|
69 |
|
70 #ifdef SUPADAPTER_CHECK_TEXT_MIME_TYPE |
|
71 _LIT8(KMimeTypeTextAny, "text/*"); |
|
72 #endif |
|
73 |
|
74 _LIT8(KImage, "image/"); |
|
75 _LIT8(KMimeTypeImageMbm, "image/x-epoc-mbm"); |
|
76 |
|
77 #ifdef SUPADAPTER_CHECK_IMAGE_MIME_TYPE |
|
78 _LIT8(KMimeTypeImageGif, "image/gif"); |
|
79 _LIT8(KMimeTypeImagePng, "image/png"); |
|
80 _LIT8(KMimeTypeImageJpg, "image/jpeg"); |
|
81 _LIT8(KMimeTypeImageAny, "image/*"); |
|
82 #endif |
|
83 |
|
84 // ------------------------------------------------------------------------------------------------ |
|
85 |
|
86 /** |
|
87 * Folder for temporary files |
|
88 **/ |
|
89 _LIT(KTempFilePath, "c:\\system\\temp\\"); |
|
90 |
|
91 // This length value is copied from S60/Startup/StartupUserWelcomeNote.h |
|
92 const TInt KStartupTBufMaxLength( 100 ); |
|
93 |
|
94 // ------------------------------------------------------------------------------------------------ |
|
95 // CSupAdapter* CSupAdapter::NewL( ) |
|
96 // ------------------------------------------------------------------------------------------------ |
|
97 CSupAdapter* CSupAdapter::NewL(MSmlDmCallback* aDmCallback ) |
|
98 { |
|
99 RDEBUG( "CSupAdapter::NewL()" ); |
|
100 |
|
101 CSupAdapter* self = NewLC( aDmCallback ); |
|
102 CleanupStack::Pop(); |
|
103 return self; |
|
104 } |
|
105 |
|
106 // ------------------------------------------------------------------------------------------------ |
|
107 // CSupAdapter* CSupAdapter::NewLC( ) |
|
108 // ------------------------------------------------------------------------------------------------ |
|
109 CSupAdapter* CSupAdapter::NewLC(MSmlDmCallback* aDmCallback ) |
|
110 { |
|
111 RDEBUG( "CSupAdapter::NewLC()" ); |
|
112 |
|
113 CSupAdapter* self = new (ELeave) CSupAdapter(aDmCallback); |
|
114 CleanupStack::PushL(self); |
|
115 self->ConstructL(aDmCallback); |
|
116 return self; |
|
117 } |
|
118 |
|
119 |
|
120 // ------------------------------------------------------------------------------------------------ |
|
121 // CSupAdapter::CSupAdapter() |
|
122 // ------------------------------------------------------------------------------------------------ |
|
123 CSupAdapter::CSupAdapter(TAny* aEcomArguments) |
|
124 : CTARMDmStreamAdapter((MSmlDmCallback*)aEcomArguments) |
|
125 , iUndoImage(0) |
|
126 , iUndoText(0) |
|
127 , iUndoNoteType(-1) |
|
128 { |
|
129 } |
|
130 |
|
131 |
|
132 // ------------------------------------------------------------------------------------------------ |
|
133 // CSupAdapter::~CSupAdapter() |
|
134 // ------------------------------------------------------------------------------------------------ |
|
135 CSupAdapter::~CSupAdapter() |
|
136 { |
|
137 RDEBUG( "CSupAdapter::~CSupAdapter()" ); |
|
138 |
|
139 delete iUndoImage; iUndoImage = 0; |
|
140 delete iUndoText; iUndoText = 0; |
|
141 |
|
142 if( iTemporaryImageFile.Length() > 0 ) |
|
143 { |
|
144 RFs fs; |
|
145 if (fs.Connect()) |
|
146 { |
|
147 fs.Delete( iTemporaryImageFile ); |
|
148 fs.Close(); |
|
149 } |
|
150 iTemporaryImageFile.Zero(); |
|
151 } |
|
152 |
|
153 //#ifdef __SAP_POLICY_MANAGEMENT |
|
154 if(FeatureManager::FeatureSupported(KFeatureIdSapStartupAdapter)) |
|
155 { |
|
156 if(FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement )) |
|
157 { |
|
158 iPR.Close(); |
|
159 iPE.Close(); |
|
160 } |
|
161 |
|
162 } |
|
163 |
|
164 //#endif |
|
165 FeatureManager::UnInitializeLib(); |
|
166 } |
|
167 |
|
168 |
|
169 // ------------------------------------------------------------------------------------------------ |
|
170 // CSupAdapter::ConstructL |
|
171 // ------------------------------------------------------------------------------------------------ |
|
172 void CSupAdapter::ConstructL(MSmlDmCallback *aDmCallback) |
|
173 { |
|
174 RDEBUG( "CSupAdapter::ConstructL()" ); |
|
175 TRAPD( errf, FeatureManager::InitializeLibL() ); |
|
176 if( errf != KErrNone ) |
|
177 { |
|
178 User::Leave(errf); |
|
179 } |
|
180 if(FeatureManager::FeatureSupported(KFeatureIdSapStartupAdapter)) |
|
181 { |
|
182 iCallBack = aDmCallback; |
|
183 |
|
184 //#ifdef __SAP_POLICY_MANAGEMENT |
|
185 if(FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement )) |
|
186 { |
|
187 User::LeaveIfError( iPE.Connect() ); |
|
188 User::LeaveIfError( iPR.Open( iPE ) ); |
|
189 } |
|
190 |
|
191 //#endif |
|
192 |
|
193 iTemporaryImageFile.Zero(); |
|
194 |
|
195 #ifdef __WINS_DEBUG_TEST__ |
|
196 DebugTestsL(); |
|
197 #endif |
|
198 } |
|
199 else |
|
200 { |
|
201 |
|
202 User::Leave( KErrNotSupported ); |
|
203 } |
|
204 } |
|
205 |
|
206 |
|
207 // ------------------------------------------------------------------------------------------------ |
|
208 // CSupAdapter::DDFVersionL() |
|
209 // ------------------------------------------------------------------------------------------------ |
|
210 void CSupAdapter::DDFVersionL(CBufBase& aDDFVersion) |
|
211 { |
|
212 RDEBUG( "CSupAdapter::DDFVersionL()" ); |
|
213 |
|
214 aDDFVersion.InsertL(0,KNSmlSUPDDFVersion); |
|
215 } |
|
216 |
|
217 |
|
218 // ------------------------------------------------------------------------------------------------ |
|
219 // CSupAdapter::DDFStructureL() |
|
220 // |
|
221 // ------------------------------------------------------------------------------------------------ |
|
222 void CSupAdapter::DDFStructureL( MSmlDmDDFObject& aDDF ) |
|
223 { |
|
224 RDEBUG( "CSupAdapter::DDFStructureL()" ); |
|
225 |
|
226 TSmlDmAccessTypes accessTypesGet; |
|
227 accessTypesGet.SetGet(); |
|
228 |
|
229 /* |
|
230 Node: ./Customization |
|
231 This interior node is the common parent to all customization objects. |
|
232 Status: Required |
|
233 Occurs: One |
|
234 Format: Node |
|
235 Access Types: Get |
|
236 Values: N/A |
|
237 */ |
|
238 MSmlDmDDFObject& apps = aDDF.AddChildObjectL(KNSmlCustomizationNodeName); |
|
239 FillNodeInfoL(apps,accessTypesGet,MSmlDmDDFObject::EOne,MSmlDmDDFObject::EPermanent, |
|
240 MSmlDmDDFObject::ENode, KNSmlSUPDescription,KNullDesC8()); |
|
241 |
|
242 /* |
|
243 Node: ./Customization/Startup |
|
244 Startup is a common parent node to nodes customizing startup functionality |
|
245 Status: Required |
|
246 Occurs: One |
|
247 Format: Node |
|
248 Access Types: Get |
|
249 Values: N/A |
|
250 */ |
|
251 MSmlDmDDFObject& groupNode = apps.AddChildObjectL(KNSmlSUPStartupNodeName); |
|
252 FillNodeInfoL(groupNode,accessTypesGet,MSmlDmDDFObject::EOne,MSmlDmDDFObject::EPermanent, |
|
253 MSmlDmDDFObject::ENode,KNSmlSUPStartupNodeDescription,KNullDesC8()); |
|
254 |
|
255 /* |
|
256 Node: ./Customization/Startup/Data |
|
257 Image node stores the Startup image as binary data, and its runtime Type determines the interpretation. |
|
258 · Status: Optional |
|
259 · Occurs: One |
|
260 · Format: bin |
|
261 · Access Types: Replace |
|
262 · Values: N/A |
|
263 */ |
|
264 TSmlDmAccessTypes accessTypesReplace; |
|
265 accessTypesReplace.SetReplace(); |
|
266 |
|
267 MSmlDmDDFObject& imageNode = groupNode.AddChildObjectL(KNSmlSUPWelcomeDataNodeName); |
|
268 FillNodeInfoL(imageNode,accessTypesReplace,MSmlDmDDFObject::EZeroOrOne,MSmlDmDDFObject::EPermanent, |
|
269 MSmlDmDDFObject::EBin,KNSmlSUPWelcomeDataNodeDescription,KNSmlSUPTextPlain()); |
|
270 imageNode.AddDFTypeMimeTypeL(KMimeTypeImageMbm); |
|
271 |
|
272 /* |
|
273 Node: ./Customization/Startup/Text |
|
274 Text node stores the Startup text as text, and its runtime Type determines the interpretation. |
|
275 · Status: Optional |
|
276 · Occurs: One |
|
277 · Format: Chr |
|
278 · Access Types: Get, Replace |
|
279 · Values: N/A |
|
280 */ |
|
281 TSmlDmAccessTypes accessTypesGetReplace; |
|
282 accessTypesGetReplace.SetGet(); |
|
283 accessTypesGetReplace.SetReplace(); |
|
284 |
|
285 MSmlDmDDFObject& textNode = groupNode.AddChildObjectL(KNSmlSUPWelcomeTextNodeName); |
|
286 FillNodeInfoL(textNode,accessTypesGetReplace,MSmlDmDDFObject::EZeroOrOne,MSmlDmDDFObject::EPermanent, |
|
287 MSmlDmDDFObject::EChr,KNSmlSUPWelcomeTextNodeDescription,KNSmlSUPTextPlain()); |
|
288 } |
|
289 |
|
290 |
|
291 // ------------------------------------------------------------------------------------------------ |
|
292 // CSupAdapter::UpdateLeafObjectL() |
|
293 // ------------------------------------------------------------------------------------------------ |
|
294 void CSupAdapter::UpdateLeafObjectL( CSmlDmAdapter::TError& aStatus, const TDesC8& aURI, |
|
295 const TDesC8& /*aLUID*/, const TDesC8& aObject, const TDesC8& aType ) |
|
296 { |
|
297 RDEBUG( "CSupAdapter::UpdateLeafObjectL()" ); |
|
298 |
|
299 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
300 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash( aURI ); |
|
301 CSupAdapter::TSupNodeIdentifier identifier = GetNodeIdentifier( uriPtrc ); |
|
302 #else |
|
303 CSupAdapter::TSupNodeIdentifier identifier = GetNodeIdentifier( aURI ); |
|
304 #endif |
|
305 |
|
306 TStartupAdapterLeafType type; |
|
307 |
|
308 switch( identifier ) |
|
309 { |
|
310 case ESupNodeWelcomeText: |
|
311 { |
|
312 HBufC16* source = CTARMCharConv::ConvertFromUtf8LC( aObject ); |
|
313 TInt sourceLength = source->Length(); |
|
314 TInt destLength = KStartupTBufMaxLength<sourceLength?KStartupTBufMaxLength:sourceLength; |
|
315 TPtrC16 sourcePtr( source->Ptr(), destLength ); |
|
316 |
|
317 aStatus = CSmlDmAdapter::EOk; |
|
318 SetStartupTextL(aStatus, sourcePtr); |
|
319 CleanupStack::PopAndDestroy( source ); |
|
320 } |
|
321 break; |
|
322 case ESupNodeWelcomeData: |
|
323 type = GetObjectType( aType ); |
|
324 switch(type) |
|
325 { |
|
326 case CSupAdapter::EImage: |
|
327 aStatus = CSmlDmAdapter::EOk; |
|
328 SetStartupImageL(aStatus, aObject, aType); |
|
329 break; |
|
330 |
|
331 case CSupAdapter::EUnknown: |
|
332 aStatus = CSmlDmAdapter::EInvalidObject; |
|
333 break; |
|
334 } |
|
335 break; |
|
336 default: |
|
337 aStatus = CSmlDmAdapter::EError; |
|
338 } |
|
339 } |
|
340 |
|
341 |
|
342 // ------------------------------------------------------------------------------------------------ |
|
343 // CSupAdapter::_UpdateLeafObjectL() |
|
344 // ------------------------------------------------------------------------------------------------ |
|
345 void CSupAdapter::_UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType, TInt aStatusRef ) |
|
346 { |
|
347 RDEBUG8_3( "CSupAdapter::_UpdateLeafObjectL() (%S) (%S)", &aURI, &aType ); |
|
348 |
|
349 TBuf8<KStartupTBufMaxLength> mimeType; |
|
350 CopyAndTrimMimeType(mimeType, aType); |
|
351 |
|
352 //#ifdef __SAP_POLICY_MANAGEMENT |
|
353 if(FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement )) |
|
354 { |
|
355 User::LeaveIfError( CheckPolicyL() ); |
|
356 } |
|
357 //#endif |
|
358 |
|
359 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
360 |
|
361 TRAPD( |
|
362 reason, |
|
363 // NOTE! UpdateLeafObjectL removes the "./" from the beginning |
|
364 UpdateLeafObjectL( status, aURI, aLUID, aObject, mimeType ) ); |
|
365 |
|
366 if( KErrNone != reason ) |
|
367 { |
|
368 status = CSmlDmAdapter::EError; |
|
369 } |
|
370 |
|
371 iCallBack->SetStatusL(aStatusRef, status); |
|
372 } |
|
373 |
|
374 |
|
375 // ------------------------------------------------------------------------------------------------ |
|
376 // CSupAdapter::_UpdateLeafObjectL() |
|
377 // ------------------------------------------------------------------------------------------------ |
|
378 void CSupAdapter::_UpdateLeafObjectL( const TDesC8& /*aURI*/, const TDesC8& /*aLUID*/, RWriteStream*& /*aStream*/, const TDesC8& /*aType*/, TInt aStatusRef ) |
|
379 { |
|
380 RDEBUG( "CSupAdapter::_UpdateLeafObjectL() (stream)" ); |
|
381 |
|
382 CSmlDmAdapter::TError status = CSmlDmAdapter::EError; |
|
383 iCallBack->SetStatusL(aStatusRef, status); |
|
384 } |
|
385 |
|
386 |
|
387 // ------------------------------------------------------------------------------------------------ |
|
388 // CSupAdapter::_DeleteObjectL |
|
389 // ------------------------------------------------------------------------------------------------ |
|
390 void CSupAdapter::_DeleteObjectL( const TDesC8& /*aURI*/, const TDesC8& /*aLUID*/, TInt aStatusRef ) |
|
391 { |
|
392 RDEBUG( "CSupAdapter::_DeleteObjectL()" ); |
|
393 |
|
394 CSmlDmAdapter::TError status = CSmlDmAdapter::EError; |
|
395 iCallBack->SetStatusL(aStatusRef, status); |
|
396 } |
|
397 |
|
398 |
|
399 // ------------------------------------------------------------------------------------------------ |
|
400 // CSupAdapter::_ExecuteCommandL |
|
401 // ------------------------------------------------------------------------------------------------ |
|
402 void CSupAdapter::_ExecuteCommandL( const TDesC8& /*aURI*/, const TDesC8& /*aLUID*/, const TDesC8& /*aArgument*/, const TDesC8& /*aType*/, TInt aStatusRef ) |
|
403 { |
|
404 RDEBUG( "CSupAdapter::_ExecuteCommandL()" ); |
|
405 |
|
406 CSmlDmAdapter::TError status = CSmlDmAdapter::EError; |
|
407 iCallBack->SetStatusL(aStatusRef, status); |
|
408 } |
|
409 |
|
410 |
|
411 // ------------------------------------------------------------------------------------------------ |
|
412 // CSupAdapter::_ExecuteCommandL |
|
413 // ------------------------------------------------------------------------------------------------ |
|
414 void CSupAdapter::_ExecuteCommandL( const TDesC8& /*aURI*/, const TDesC8& /*aLUID*/, RWriteStream*& /*aStream*/, const TDesC8& /*aType*/, TInt aStatusRef) |
|
415 { |
|
416 RDEBUG( "CSupAdapter::_ExecuteCommandL() (stream)" ); |
|
417 |
|
418 CSmlDmAdapter::TError status = CSmlDmAdapter::EError; |
|
419 iCallBack->SetStatusL(aStatusRef, status); |
|
420 } |
|
421 |
|
422 |
|
423 // ------------------------------------------------------------------------------------------------ |
|
424 // CSupAdapter::_CopyCommandL |
|
425 // ------------------------------------------------------------------------------------------------ |
|
426 void CSupAdapter::_CopyCommandL( const TDesC8& /*aTargetURI*/, const TDesC8& /*aTargetLUID*/, const TDesC8& /*aSourceURI*/, const TDesC8& /*aSourceLUID*/, const TDesC8& /*aType*/, TInt aStatusRef) |
|
427 { |
|
428 RDEBUG( "CSupAdapter::_CopyCommandL()" ); |
|
429 |
|
430 CSmlDmAdapter::TError status = CSmlDmAdapter::EError; |
|
431 iCallBack->SetStatusL(aStatusRef, status); |
|
432 } |
|
433 |
|
434 |
|
435 // ------------------------------------------------------------------------------------------------ |
|
436 // CSupAdapter::StartAtomicL |
|
437 // ------------------------------------------------------------------------------------------------ |
|
438 void CSupAdapter::StartAtomicL() |
|
439 { |
|
440 RDEBUG( "CSupAdapter::StartAtomicL()" ); |
|
441 |
|
442 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
443 |
|
444 delete iUndoImage; iUndoImage = 0; |
|
445 delete iUndoText; iUndoText = 0; |
|
446 iUndoNoteType = -1; |
|
447 |
|
448 // Copy startup image & text |
|
449 TInt imageSize; |
|
450 iUndoImage = GetStartupImageL(status, KMimeTypeImageMbm, imageSize); |
|
451 iUndoText = GetStartupTextL(status, KMimeTypeTextPlain); |
|
452 } |
|
453 |
|
454 // ------------------------------------------------------------------------------------------------ |
|
455 // CSupAdapter::CommitAtomicL |
|
456 // ------------------------------------------------------------------------------------------------ |
|
457 void CSupAdapter::CommitAtomicL() |
|
458 { |
|
459 RDEBUG( "CSupAdapter::CommitAtomicL()" ); |
|
460 |
|
461 delete iUndoImage; iUndoImage = 0; |
|
462 delete iUndoText; iUndoText = 0; |
|
463 iUndoNoteType = -1; |
|
464 } |
|
465 |
|
466 // ------------------------------------------------------------------------------------------------ |
|
467 // CSupAdapter::RollbackAtomicL |
|
468 // ------------------------------------------------------------------------------------------------ |
|
469 void CSupAdapter::RollbackAtomicL() |
|
470 { |
|
471 RDEBUG( "CSupAdapter::RollbackAtomicL()" ); |
|
472 |
|
473 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
474 |
|
475 if(iUndoImage != 0) |
|
476 { |
|
477 SetStartupImageL(status, iUndoImage->Ptr(0), KMimeTypeImageMbm); |
|
478 |
|
479 if(status != CSmlDmAdapter::EOk) |
|
480 { |
|
481 status = CSmlDmAdapter::ERollbackFailed; |
|
482 } |
|
483 |
|
484 delete iUndoImage; iUndoImage = 0; |
|
485 } |
|
486 |
|
487 if(iUndoText != 0) |
|
488 { |
|
489 HBufC16* source = CTARMCharConv::ConvertFromUtf8LC( iUndoText->Ptr( 0 ) ); |
|
490 TInt sourceLength = source->Length(); |
|
491 TInt destLength = KStartupTBufMaxLength<sourceLength?KStartupTBufMaxLength:sourceLength; |
|
492 TPtrC16 sourcePtr( source->Ptr(), destLength ); |
|
493 |
|
494 SetStartupTextL(status, sourcePtr); |
|
495 CleanupStack::PopAndDestroy( source ); |
|
496 |
|
497 if(status != CSmlDmAdapter::EOk) |
|
498 { |
|
499 status = CSmlDmAdapter::ERollbackFailed; |
|
500 } |
|
501 |
|
502 delete iUndoText; iUndoText = 0; |
|
503 } |
|
504 |
|
505 if(iUndoNoteType != -1) |
|
506 { |
|
507 RUISettingsSrv uiSrv; |
|
508 User::LeaveIfError( uiSrv.Connect() ); |
|
509 CleanupClosePushL( uiSrv ); |
|
510 |
|
511 User::LeaveIfError( uiSrv.SetStartupNoteType( iUndoNoteType ) ); |
|
512 |
|
513 CleanupStack::PopAndDestroy( &uiSrv ); |
|
514 |
|
515 iUndoNoteType = -1; |
|
516 } |
|
517 |
|
518 |
|
519 iCallBack->SetStatusL(0, status); |
|
520 } |
|
521 |
|
522 // ----------------------------------------------------------------------------- |
|
523 // CSupAdapter::StreamType |
|
524 // |
|
525 // ----------------------------------------------------------------------------- |
|
526 // |
|
527 CTARMDmStreamAdapter::TAdapterStreamType CSupAdapter::StreamType( const TDesC8& aURI ) |
|
528 { |
|
529 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
530 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash( aURI ); |
|
531 CSupAdapter::TSupNodeIdentifier identifier = GetNodeIdentifier( uriPtrc ); |
|
532 #else |
|
533 CSupAdapter::TSupNodeIdentifier identifier = GetNodeIdentifier( aURI ); |
|
534 #endif |
|
535 |
|
536 switch( identifier ) |
|
537 { |
|
538 case ESupNodeWelcomeData: |
|
539 return CTARMDmStreamAdapter::EStreamToBuffer; |
|
540 |
|
541 default: |
|
542 return CTARMDmStreamAdapter::EStreamToNone; |
|
543 }; |
|
544 } |
|
545 |
|
546 // ------------------------------------------------------------------------------------------------ |
|
547 // CSupAdapter::StreamingSupport |
|
548 // ------------------------------------------------------------------------------------------------ |
|
549 TBool CSupAdapter::StreamingSupport( TInt& aItemSize ) |
|
550 { |
|
551 RDEBUG( "CSupAdapter::StreamingSupport()" ); |
|
552 aItemSize = 1024; // Large images are streamed |
|
553 return ETrue; |
|
554 } |
|
555 |
|
556 // ------------------------------------------------------------------------------------------------ |
|
557 // CSupAdapter::CompleteOutstandingCmdsL |
|
558 // ------------------------------------------------------------------------------------------------ |
|
559 void CSupAdapter::CompleteOutstandingCmdsL() |
|
560 { |
|
561 RDEBUG( "CSupAdapter::CompleteOutstandingCmdsL()" ); |
|
562 } |
|
563 |
|
564 // ------------------------------------------------------------------------------------------------ |
|
565 // CSupAdapter::FetchLeafObjectL |
|
566 // ------------------------------------------------------------------------------------------------ |
|
567 CSmlDmAdapter::TError CSupAdapter::FetchLeafObjectL( const TDesC8& aURI, const TDesC8& /*aLUID*/, TDes8& aNewMime, CBufFlat* object, TInt &aUncodedSize ) |
|
568 { |
|
569 RDEBUG( "CSupAdapter::FetchLeafObjectL() begin:" ); |
|
570 |
|
571 TBuf8<KStartupTBufMaxLength> mimeType; |
|
572 CopyAndTrimMimeType(mimeType, aNewMime); |
|
573 |
|
574 //#ifdef __SAP_POLICY_MANAGEMENT |
|
575 if(FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement )) |
|
576 { |
|
577 User::LeaveIfError( CheckPolicyL() ); |
|
578 } |
|
579 //#endif |
|
580 |
|
581 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
582 TStartupAdapterLeafType type; |
|
583 |
|
584 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
585 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash( aURI ); |
|
586 CSupAdapter::TSupNodeIdentifier identifier = GetNodeIdentifier( uriPtrc ); |
|
587 #else |
|
588 CSupAdapter::TSupNodeIdentifier identifier = GetNodeIdentifier( aURI ); |
|
589 #endif |
|
590 |
|
591 switch( identifier ) |
|
592 { |
|
593 case ESupNodeCustomization: |
|
594 case ESupNodeStartup: |
|
595 // No actions, leave object empty |
|
596 break; |
|
597 case ESupNodeWelcomeData: |
|
598 status = CSmlDmAdapter::EError; |
|
599 break; |
|
600 case ESupNodeWelcomeText: |
|
601 CBufFlat *object2 = GetStartupTextL(status, mimeType); |
|
602 CleanupStack::PushL(object2); |
|
603 |
|
604 object->InsertL(0, object2->Ptr(0)); |
|
605 aUncodedSize = object->Size(); |
|
606 |
|
607 aNewMime.Copy( KMimeTypeTextPlain ); |
|
608 |
|
609 CleanupStack::PopAndDestroy(object2); |
|
610 |
|
611 break; |
|
612 case CSupAdapter::ESupNodeNotUsedAndAlwaysLast: |
|
613 default: |
|
614 |
|
615 status = CSmlDmAdapter::EError; |
|
616 break; |
|
617 }; |
|
618 RDEBUG( "CSupAdapter::FetchLeafObjectL() End:" ); |
|
619 return status; |
|
620 } |
|
621 |
|
622 // ------------------------------------------------------------------------------------------------ |
|
623 // CSupAdapter::_FetchLeafObjectL |
|
624 // ------------------------------------------------------------------------------------------------ |
|
625 void CSupAdapter::_FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef, TInt aStatusRef ) |
|
626 { |
|
627 RDEBUG( "CSupAdapter::_FetchLeafObjectL()" ); |
|
628 |
|
629 TBuf8<KStartupTBufMaxLength> mimeType; |
|
630 CopyAndTrimMimeType(mimeType, aType); |
|
631 |
|
632 CBufFlat *object = CBufFlat::NewL(128); |
|
633 CleanupStack::PushL( object ); |
|
634 |
|
635 TInt uncodedSize; |
|
636 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
637 |
|
638 TRAPD( |
|
639 reason, |
|
640 // note, FetchLeafObjectL will parse off the "./" from aURI, SymbianConvergency |
|
641 status = FetchLeafObjectL( aURI, aLUID, mimeType, object, uncodedSize ) ); |
|
642 |
|
643 if( KErrNone != reason ) |
|
644 { |
|
645 status = CSmlDmAdapter::EError; |
|
646 } |
|
647 |
|
648 iCallBack->SetStatusL(aStatusRef, status); |
|
649 |
|
650 if( status == CSmlDmAdapter::EOk) |
|
651 { |
|
652 object->Compress(); |
|
653 iCallBack->SetResultsL( aResultsRef, *object, mimeType ); |
|
654 } |
|
655 |
|
656 CleanupStack::PopAndDestroy( object ); |
|
657 } |
|
658 |
|
659 // ------------------------------------------------------------------------------------------------ |
|
660 // CSupAdapter::_FetchLeafObjectSizeL |
|
661 // ------------------------------------------------------------------------------------------------ |
|
662 void CSupAdapter::_FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef, TInt aStatusRef ) |
|
663 { |
|
664 RDEBUG("CSupAdapter::_FetchLeafObjectSizeL()"); |
|
665 |
|
666 TBuf8<KStartupTBufMaxLength> mimeType; |
|
667 CopyAndTrimMimeType(mimeType, aType); |
|
668 |
|
669 CBufFlat *object = CBufFlat::NewL(128); |
|
670 CleanupStack::PushL( object ); |
|
671 |
|
672 TInt uncodedSize; |
|
673 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
674 |
|
675 TRAPD( |
|
676 reason, |
|
677 // NOTE! FetchLeafObjectL will parse off the "./" from the aURI <-> SymbianConveergency |
|
678 status = FetchLeafObjectL( aURI, aLUID, mimeType, object, uncodedSize ) ); |
|
679 |
|
680 if( KErrNone != reason ) |
|
681 { |
|
682 status = CSmlDmAdapter::EError; |
|
683 } |
|
684 |
|
685 iCallBack->SetStatusL(aStatusRef, status); |
|
686 |
|
687 if( status == CSmlDmAdapter::EOk) |
|
688 { |
|
689 TBuf8<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> numBuf; |
|
690 object->Compress(); |
|
691 |
|
692 CBufFlat *object2 = CBufFlat::NewL(128); |
|
693 CleanupStack::PushL( object2 ); |
|
694 |
|
695 numBuf.Num(object->Size()); |
|
696 object2->InsertL(0, numBuf); |
|
697 object2->Compress(); |
|
698 iCallBack->SetResultsL( aResultsRef, *object2, KMimeTypeTextPlain ); |
|
699 |
|
700 CleanupStack::PopAndDestroy( object2 ); |
|
701 } |
|
702 |
|
703 CleanupStack::PopAndDestroy( object ); |
|
704 } |
|
705 |
|
706 // ------------------------------------------------------------------------------------------------ |
|
707 // CSupAdapter::_ChildURIListL |
|
708 // ------------------------------------------------------------------------------------------------ |
|
709 void CSupAdapter::_ChildURIListL( const TDesC8& aURI, const TDesC8& /*aLUID*/, const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, TInt aResultsRef, TInt aStatusRef ) |
|
710 { |
|
711 RDEBUG("CSupAdapter::_ChildURIListL()"); |
|
712 |
|
713 CSmlDmAdapter::TError ret = CSmlDmAdapter::EOk; |
|
714 |
|
715 //#ifdef __SAP_POLICY_MANAGEMENT |
|
716 if(FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement )) |
|
717 { |
|
718 User::LeaveIfError( CheckPolicyL() ); |
|
719 } |
|
720 //#endif |
|
721 |
|
722 CBufBase *currentList = CBufFlat::NewL(128); |
|
723 CleanupStack::PushL(currentList); |
|
724 |
|
725 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
726 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash( aURI ); |
|
727 CSupAdapter::TSupNodeIdentifier identifier = GetNodeIdentifier( uriPtrc ); |
|
728 #else |
|
729 CSupAdapter::TSupNodeIdentifier identifier = GetNodeIdentifier( aURI ); |
|
730 #endif |
|
731 |
|
732 switch( identifier ) |
|
733 { |
|
734 case ESupNodeCustomization: |
|
735 currentList->InsertL(0,KNSmlSUPStartup8()); |
|
736 break; |
|
737 |
|
738 case ESupNodeStartup: |
|
739 currentList->InsertL(currentList->Size(),KNSmlSUPWelcomeDataNodeName()); |
|
740 currentList->InsertL(currentList->Size(),KNSmlSUPWelcomeTextNodeName()); |
|
741 break; |
|
742 |
|
743 case ESupNodeWelcomeData: |
|
744 case ESupNodeWelcomeText: |
|
745 // Empty |
|
746 break; |
|
747 |
|
748 default: |
|
749 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
750 if( uriPtrc.Length() == 0 ) |
|
751 #else |
|
752 if( aURI.Length() == 0 ) |
|
753 #endif |
|
754 { |
|
755 currentList->InsertL(0,KNSmlCustomizationNodeName8()); |
|
756 } |
|
757 else |
|
758 { |
|
759 ret = CSmlDmAdapter::ENotFound; |
|
760 } |
|
761 break; |
|
762 } |
|
763 |
|
764 iCallBack->SetStatusL(aStatusRef, ret); |
|
765 |
|
766 if( ret == CSmlDmAdapter::EOk ) |
|
767 { |
|
768 iCallBack->SetResultsL(aResultsRef, *currentList, KNSmlSUPTextPlain); |
|
769 } |
|
770 |
|
771 CleanupStack::PopAndDestroy( currentList ); |
|
772 |
|
773 } |
|
774 |
|
775 // ------------------------------------------------------------------------------------------------ |
|
776 // CSupAdapter::_AddNodeObjectL |
|
777 // ------------------------------------------------------------------------------------------------ |
|
778 void CSupAdapter::_AddNodeObjectL( const TDesC8& /*aURI*/, const TDesC8& /*aParentLUID*/, TInt aStatusRef ) |
|
779 { |
|
780 RDEBUG("CSupAdapter::_AddNodeObjectL()"); |
|
781 |
|
782 CSmlDmAdapter::TError ret = CSmlDmAdapter::EError; |
|
783 iCallBack->SetStatusL(aStatusRef, ret); |
|
784 } |
|
785 |
|
786 #ifndef __WINS_DEBUG_TESTING__ |
|
787 // ------------------------------------------------------------------------------------------------ |
|
788 // |
|
789 // ------------------------------------------------------------------------------------------------ |
|
790 const TImplementationProxy ImplementationTable[] = |
|
791 { |
|
792 { {KNSmlDMSUPAdapterImplUid}, (TProxyNewLPtr)CSupAdapter::NewL } |
|
793 }; |
|
794 |
|
795 // ------------------------------------------------------------------------------------------------ |
|
796 // ImplementationGroupProxy |
|
797 // ------------------------------------------------------------------------------------------------ |
|
798 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
799 { |
|
800 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
801 return ImplementationTable; |
|
802 } |
|
803 #endif |
|
804 |
|
805 // ------------------------------------------------------------------------------------- |
|
806 // CSupAdapter::FillNodeInfoL() |
|
807 // Fills the node info in ddf structure |
|
808 // ------------------------------------------------------------------------------------- |
|
809 void CSupAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode,TSmlDmAccessTypes aAccTypes, |
|
810 MSmlDmDDFObject::TOccurence aOccurrence, MSmlDmDDFObject::TScope aScope, |
|
811 MSmlDmDDFObject::TDFFormat aFormat,const TDesC8& aDescription,const TDesC8& aMimeType) |
|
812 { |
|
813 RDEBUG("CSupAdapter::FillNodeInfoL()"); |
|
814 |
|
815 aNode.SetAccessTypesL(aAccTypes); |
|
816 aNode.SetOccurenceL(aOccurrence); |
|
817 aNode.SetScopeL(aScope); |
|
818 aNode.SetDFFormatL(aFormat); |
|
819 aNode.SetDescriptionL(aDescription); |
|
820 if(aMimeType.Length() > 0) |
|
821 { |
|
822 aNode.AddDFTypeMimeTypeL(aMimeType); |
|
823 } |
|
824 } |
|
825 |
|
826 // ------------------------------------------------------------------------------------- |
|
827 // CSupAdapter::IsSupportedImageType() |
|
828 // Checks whether the given mime type is supported image format |
|
829 // ------------------------------------------------------------------------------------- |
|
830 CSupAdapter::TStartupAdapterLeafType CSupAdapter::GetObjectType(const TDesC8& aMime) |
|
831 { |
|
832 RDEBUG("CSupAdapter::GetObjectType()"); |
|
833 /* |
|
834 if(IsSupportedTextType(aMime)) |
|
835 { |
|
836 return CSupAdapter::EText; |
|
837 } |
|
838 */ |
|
839 if(IsSupportedImageType(aMime)) |
|
840 { |
|
841 return CSupAdapter::EImage; |
|
842 } |
|
843 |
|
844 return CSupAdapter::EUnknown; |
|
845 } |
|
846 |
|
847 // ------------------------------------------------------------------------------------- |
|
848 // CSupAdapter::IsSupportedImageType() |
|
849 // Checks whether the given mime type is supported image format |
|
850 // ------------------------------------------------------------------------------------- |
|
851 TBool CSupAdapter::IsSupportedImageType(const TDesC8& aMime) |
|
852 { |
|
853 RDEBUG("CSupAdapter::IsSupportedImageType()"); |
|
854 |
|
855 TBuf8<KStartupTBufMaxLength> mimeType; |
|
856 CopyAndTrimMimeType(mimeType, aMime); |
|
857 |
|
858 #ifdef SUPADAPTER_CHECK_IMAGE_MIME_TYPE |
|
859 |
|
860 if( |
|
861 mimeType == KMimeTypeImageJpg || |
|
862 mimeType == KMimeTypeImageGif || |
|
863 mimeType == KMimeTypeImagePng || |
|
864 mimeType == KMimeTypeImageAny |
|
865 ) |
|
866 { |
|
867 return ETrue; |
|
868 } |
|
869 |
|
870 return EFalse; |
|
871 |
|
872 #else |
|
873 |
|
874 TDesC8 KImageDesC8 = (TDesC8&)KImage; |
|
875 return mimeType.Left(KImageDesC8.Length()) == KImage; |
|
876 |
|
877 #endif |
|
878 } |
|
879 |
|
880 // ------------------------------------------------------------------------------------- |
|
881 // CSupAdapter::IsSupportedTextType() |
|
882 // Checks whether the given mime type is supported text format |
|
883 // ------------------------------------------------------------------------------------- |
|
884 TBool CSupAdapter::IsSupportedTextType(const TDesC8& aMime) |
|
885 { |
|
886 RDEBUG("CSupAdapter::IsSupportedTextType()"); |
|
887 |
|
888 TBuf8<KStartupTBufMaxLength> mimeType; |
|
889 CopyAndTrimMimeType(mimeType, aMime); |
|
890 |
|
891 #ifdef SUPADAPTER_CHECK_TEXT_MIME_TYPE |
|
892 |
|
893 if( |
|
894 mimeType == KMimeTypeTextPlain || |
|
895 mimeType == KMimeTypeTextAny |
|
896 ) |
|
897 { |
|
898 return ETrue; |
|
899 } |
|
900 |
|
901 return EFalse; |
|
902 |
|
903 #else |
|
904 |
|
905 TDesC8 KTextDesC8 = (TDesC8&)KText; |
|
906 return mimeType.Left(KTextDesC8.Length()) == KText; |
|
907 |
|
908 #endif |
|
909 } |
|
910 |
|
911 // ------------------------------------------------------------------------------------- |
|
912 // CSupAdapter::SetStartupTextL() |
|
913 // Sets and activates startup text |
|
914 // ------------------------------------------------------------------------------------- |
|
915 void CSupAdapter::SetStartupTextL(CSmlDmAdapter::TError& aStatus, const TDesC16& aText) |
|
916 { |
|
917 RDEBUG("CSupAdapter::SetStartupTextL()"); |
|
918 |
|
919 RUISettingsSrv uiSrv; |
|
920 User::LeaveIfError( uiSrv.Connect() ); |
|
921 CleanupClosePushL( uiSrv ); |
|
922 |
|
923 if( (KErrNone == uiSrv.SetStartupText( aText )) && |
|
924 (KErrNone == uiSrv.SetStartupNoteType( ETextWelcomeNote ))) |
|
925 { |
|
926 // status remains the same |
|
927 } |
|
928 else |
|
929 { |
|
930 aStatus = CSmlDmAdapter::EError; |
|
931 } |
|
932 |
|
933 CleanupStack::PopAndDestroy( &uiSrv ); |
|
934 } |
|
935 |
|
936 // ------------------------------------------------------------------------------------- |
|
937 // CSupAdapter::SetStartupImageL() |
|
938 // Sets and activates startup image |
|
939 // ------------------------------------------------------------------------------------- |
|
940 void CSupAdapter::SetStartupImageL(CSmlDmAdapter::TError& aStatus, const TDesC8& aObject, const TDesC8& /*aType*/) |
|
941 { |
|
942 RDEBUG("CSupAdapter::SetStartupImageL()"); |
|
943 |
|
944 // |
|
945 // Write file to a temp file |
|
946 // |
|
947 RFs fileSession; |
|
948 RFile file; |
|
949 |
|
950 User::LeaveIfError( fileSession.Connect() ); |
|
951 CleanupClosePushL( fileSession ); |
|
952 |
|
953 // |
|
954 // Delete previous temp file |
|
955 // |
|
956 if( iTemporaryImageFile.Length() > 0 ) |
|
957 { |
|
958 fileSession.Delete( iTemporaryImageFile ); |
|
959 iTemporaryImageFile.Zero(); |
|
960 } |
|
961 |
|
962 User::LeaveIfError( file.Temp( fileSession, KTempFilePath, iTemporaryImageFile, EFileWrite ) ); |
|
963 CleanupClosePushL( file ); |
|
964 |
|
965 // |
|
966 // Decoce from base 64 and write to file |
|
967 // |
|
968 TImCodecB64 B64Coder; |
|
969 HBufC8 *target = HBufC8::NewLC( ( aObject.Length() * 3 ) / 4 + 16 ); |
|
970 TPtr8 targetPtr( target->Des() ); |
|
971 TBool decodeResult = TFileCoderB64::CheckB64Encode( aObject ); |
|
972 if( decodeResult ) |
|
973 { |
|
974 // use decoded data |
|
975 B64Coder.Decode( aObject, targetPtr ); |
|
976 User::LeaveIfError( file.Write( targetPtr ) ); |
|
977 } |
|
978 else |
|
979 { |
|
980 // use original data |
|
981 User::LeaveIfError( file.Write ( aObject ) ); |
|
982 } |
|
983 |
|
984 file.Flush(); |
|
985 CleanupStack::PopAndDestroy(target); |
|
986 |
|
987 // Close file |
|
988 CleanupStack::PopAndDestroy( &file ); |
|
989 |
|
990 // Close fileSession |
|
991 CleanupStack::PopAndDestroy( &fileSession ); |
|
992 |
|
993 // |
|
994 // Set startup image |
|
995 // |
|
996 RUISettingsSrv uiSrv; |
|
997 User::LeaveIfError( uiSrv.Connect() ); |
|
998 CleanupClosePushL( uiSrv ); |
|
999 |
|
1000 if( (KErrNone == uiSrv.SetStartupImage( iTemporaryImageFile )) && |
|
1001 (KErrNone == uiSrv.SetStartupNoteType( EImageWelcomeNote ))) |
|
1002 { |
|
1003 // status remains the same |
|
1004 } |
|
1005 else |
|
1006 { |
|
1007 aStatus = CSmlDmAdapter::EError; |
|
1008 } |
|
1009 |
|
1010 CleanupStack::PopAndDestroy( &uiSrv ); |
|
1011 } |
|
1012 |
|
1013 // ------------------------------------------------------------------------------------- |
|
1014 // CSupAdapter::GetStartupTextL() |
|
1015 // Currently returns only plain text |
|
1016 // ------------------------------------------------------------------------------------- |
|
1017 CBufFlat* CSupAdapter::GetStartupTextL(CSmlDmAdapter::TError& /*aStatus*/, const TDesC8& /*aType*/) |
|
1018 { |
|
1019 RDEBUG("CSupAdapter::GetStartupTextL()"); |
|
1020 |
|
1021 CBufFlat* object = CBufFlat::NewL(128); |
|
1022 |
|
1023 RUISettingsSrv uiSrv; |
|
1024 User::LeaveIfError( uiSrv.Connect() ); |
|
1025 CleanupClosePushL( uiSrv ); |
|
1026 |
|
1027 HBufC* text16 = uiSrv.GetStartupTextL(); |
|
1028 CleanupStack::PushL( text16 ); |
|
1029 |
|
1030 HBufC8* text8 = CTARMCharConv::ConvertToUtf8LC( *text16 ); |
|
1031 |
|
1032 object->InsertL( 0, *text8 ); |
|
1033 |
|
1034 CleanupStack::PopAndDestroy( text8 ); |
|
1035 CleanupStack::PopAndDestroy( text16 ); |
|
1036 CleanupStack::PopAndDestroy( &uiSrv ); |
|
1037 |
|
1038 return object; |
|
1039 } |
|
1040 |
|
1041 // ------------------------------------------------------------------------------------- |
|
1042 // CSupAdapter::GetStartupImageL() |
|
1043 // Currently returns only plain text |
|
1044 // ------------------------------------------------------------------------------------- |
|
1045 CBufFlat* CSupAdapter::GetStartupImageL(CSmlDmAdapter::TError& aStatus, const TDesC8& /*aType*/, TInt &aImageSize) |
|
1046 { |
|
1047 RDEBUG("CSupAdapter::GetStartupImageL()"); |
|
1048 |
|
1049 TBuf<KMaxFileName> imageLocation; |
|
1050 TBuf8<KMaxFileName> imageLocation8; |
|
1051 CBufFlat* object = 0; |
|
1052 |
|
1053 // First, get image location in the file system |
|
1054 // |
|
1055 RUISettingsSrv uiSrv; |
|
1056 User::LeaveIfError( uiSrv.Connect() ); |
|
1057 CleanupClosePushL( uiSrv ); |
|
1058 |
|
1059 User::LeaveIfError( uiSrv.GetStartupImagePath( imageLocation ) ); |
|
1060 |
|
1061 CleanupStack::PopAndDestroy( &uiSrv ); |
|
1062 |
|
1063 // |
|
1064 // Then, create base64 encoded flat buffer of the image |
|
1065 // |
|
1066 imageLocation8.Copy(imageLocation); |
|
1067 |
|
1068 if(imageLocation8.Length() > 0) |
|
1069 { |
|
1070 // |
|
1071 // Load image into memory |
|
1072 // |
|
1073 RFs fileSession; |
|
1074 RFile file; |
|
1075 |
|
1076 User::LeaveIfError( fileSession.Connect() ); |
|
1077 CleanupClosePushL( fileSession ); |
|
1078 |
|
1079 TInt err = file.Open ( fileSession, imageLocation, EFileRead ); |
|
1080 |
|
1081 if ( err == KErrNone ) |
|
1082 { |
|
1083 CleanupClosePushL( file ); |
|
1084 TInt size( 0 ); |
|
1085 |
|
1086 err = file.Size( size ); |
|
1087 if ( err == KErrNone ) |
|
1088 { |
|
1089 HBufC8 *data = HBufC8::NewLC( size ); |
|
1090 TPtr8 ptr( data->Des() ); |
|
1091 err = file.Read( ptr ); |
|
1092 |
|
1093 TImCodecB64 B64Coder; |
|
1094 HBufC8 *target = HBufC8::NewLC( ( size * 4 ) / 3 + 16 ); |
|
1095 TPtr8 targetPtr( target->Des() ); |
|
1096 |
|
1097 B64Coder.Encode( *data, targetPtr ); |
|
1098 |
|
1099 object = CBufFlat::NewL(targetPtr.Length()); |
|
1100 object->InsertL( 0, targetPtr ); |
|
1101 |
|
1102 CleanupStack::PopAndDestroy(target); |
|
1103 CleanupStack::PopAndDestroy(data); |
|
1104 } |
|
1105 |
|
1106 file.Size(aImageSize); |
|
1107 |
|
1108 // Close file |
|
1109 CleanupStack::PopAndDestroy( &file ); |
|
1110 } |
|
1111 else if ( err == KErrNotFound || err == KErrPathNotFound ) |
|
1112 { |
|
1113 RDEBUG("CSupAdapter::GetStartupImageL(): No image file"); |
|
1114 |
|
1115 // Remains ok : aStatus = CSmlDmAdapter::EOk; |
|
1116 } |
|
1117 else |
|
1118 { |
|
1119 aStatus = CSmlDmAdapter::EError; |
|
1120 } |
|
1121 |
|
1122 // Close fileSession |
|
1123 CleanupStack::PopAndDestroy( &fileSession ); |
|
1124 |
|
1125 } |
|
1126 else |
|
1127 { |
|
1128 |
|
1129 // Remains ok: aStatus = CSmlDmAdapter::EOk; |
|
1130 object = CBufFlat::NewL(0); |
|
1131 } |
|
1132 |
|
1133 return object; |
|
1134 } |
|
1135 |
|
1136 // ------------------------------------------------------------------------------------- |
|
1137 // CSupAdapter::CopyAndTrimMimeType() |
|
1138 // ------------------------------------------------------------------------------------- |
|
1139 void CSupAdapter::CopyAndTrimMimeType(TDes8& aNewMime, const TDesC8& aType) |
|
1140 { |
|
1141 RDEBUG("CSupAdapter::CopyAndTrimMimeType()"); |
|
1142 |
|
1143 if(aNewMime.MaxLength() < aType.Length()) |
|
1144 { |
|
1145 aNewMime.Copy( aType.Left(aNewMime.MaxLength()) ); |
|
1146 } |
|
1147 else |
|
1148 { |
|
1149 aNewMime.Copy( aType ); |
|
1150 } |
|
1151 aNewMime.TrimAll(); |
|
1152 aNewMime.LowerCase(); |
|
1153 |
|
1154 TInt pos; |
|
1155 while(( pos = aNewMime.Locate(' ') ) != KErrNotFound) |
|
1156 { |
|
1157 aNewMime.Delete(pos, 1); |
|
1158 } |
|
1159 RDEBUG8_2("CSupAdapter::CopyAndTrimMimeType() end (%S)", &aNewMime); |
|
1160 } |
|
1161 |
|
1162 // ------------------------------------------------------------------------------------- |
|
1163 // CSupAdapter::GetFetchTypeL() |
|
1164 // ------------------------------------------------------------------------------------- |
|
1165 CSupAdapter::TStartupAdapterLeafType CSupAdapter::GetFetchTypeL(CSmlDmAdapter::TError& aStatus, const TDesC8& aType) |
|
1166 { |
|
1167 RDEBUG("CSupAdapter::GetFetchTypeL()"); |
|
1168 |
|
1169 TBuf8<KStartupTBufMaxLength> mimeType; |
|
1170 CopyAndTrimMimeType(mimeType, aType); |
|
1171 |
|
1172 TStartupAdapterLeafType type = CSupAdapter::EUnknown; |
|
1173 |
|
1174 TBool validMimeType = ETrue; |
|
1175 |
|
1176 if(mimeType == KMimeTypeImageMbm) |
|
1177 { |
|
1178 type = CSupAdapter::EImage; |
|
1179 } |
|
1180 else |
|
1181 if(mimeType == KMimeTypeTextPlain) |
|
1182 { |
|
1183 type = CSupAdapter::EText; |
|
1184 } |
|
1185 else |
|
1186 if(mimeType.Length() > 0) |
|
1187 { |
|
1188 validMimeType = EFalse; |
|
1189 } |
|
1190 else |
|
1191 { |
|
1192 validMimeType = ETrue; |
|
1193 } |
|
1194 |
|
1195 if(validMimeType) |
|
1196 { |
|
1197 if(type == CSupAdapter::EUnknown) |
|
1198 { |
|
1199 type = GetSelectedTypeL(aStatus); |
|
1200 |
|
1201 if(aStatus != CSupAdapter::EOk) |
|
1202 { |
|
1203 aStatus = CSmlDmAdapter::EError; |
|
1204 } |
|
1205 } |
|
1206 } |
|
1207 else |
|
1208 { |
|
1209 aStatus = CSmlDmAdapter::EError; |
|
1210 } |
|
1211 |
|
1212 return type; |
|
1213 } |
|
1214 |
|
1215 // ------------------------------------------------------------------------------------- |
|
1216 // CTcAdapter::GetNodeIdentifier |
|
1217 // ------------------------------------------------------------------------------------- |
|
1218 CSupAdapter::TSupNodeIdentifier CSupAdapter::GetNodeIdentifier(const TDesC8& aURI) |
|
1219 { |
|
1220 RDEBUG("CSupAdapter::GetNodeIdentifier()"); |
|
1221 |
|
1222 // NOTE! This code expects that the aURI starts without "./" so with Symbian Convergency |
|
1223 // make sure that the code that calls this function parses the "./" from the beginning of |
|
1224 // the string! |
|
1225 |
|
1226 TInt numOfSegs = NSmlDmURI::NumOfURISegs( aURI ); |
|
1227 if( numOfSegs == 0 ) |
|
1228 { |
|
1229 return CSupAdapter::ESupNodeNotUsedAndAlwaysLast; |
|
1230 } |
|
1231 |
|
1232 TPtrC8I seg1 = NSmlDmURI::URISeg( aURI, 0 ); |
|
1233 |
|
1234 if(seg1 == KNSmlCustomizationNodeName) |
|
1235 { |
|
1236 if(numOfSegs == 1) |
|
1237 { |
|
1238 return CSupAdapter::ESupNodeCustomization; |
|
1239 } |
|
1240 else |
|
1241 { |
|
1242 // At least 2 segments |
|
1243 TPtrC8I seg2 = NSmlDmURI::URISeg( aURI, 1 ); |
|
1244 |
|
1245 if(seg2 == KNSmlSUPStartupNodeName) |
|
1246 { |
|
1247 if(numOfSegs == 2) |
|
1248 { |
|
1249 return CSupAdapter::ESupNodeStartup; |
|
1250 } |
|
1251 else |
|
1252 { |
|
1253 // At least 3 segments |
|
1254 TPtrC8I seg3 = NSmlDmURI::URISeg( aURI, 2 ); |
|
1255 |
|
1256 if(numOfSegs == 3) |
|
1257 { |
|
1258 if(seg3 == KNSmlSUPWelcomeDataNodeName) |
|
1259 { |
|
1260 return CSupAdapter::ESupNodeWelcomeData; |
|
1261 } |
|
1262 else if(seg3 == KNSmlSUPWelcomeTextNodeName) |
|
1263 { |
|
1264 return CSupAdapter::ESupNodeWelcomeText; |
|
1265 } |
|
1266 else |
|
1267 { |
|
1268 return CSupAdapter::ESupNodeNotUsedAndAlwaysLast; |
|
1269 } |
|
1270 } |
|
1271 else |
|
1272 { |
|
1273 return CSupAdapter::ESupNodeNotUsedAndAlwaysLast; |
|
1274 } |
|
1275 } |
|
1276 } |
|
1277 else |
|
1278 { |
|
1279 return CSupAdapter::ESupNodeNotUsedAndAlwaysLast; |
|
1280 } |
|
1281 } |
|
1282 } |
|
1283 else |
|
1284 { |
|
1285 return CSupAdapter::ESupNodeNotUsedAndAlwaysLast; |
|
1286 } |
|
1287 |
|
1288 // Note: do not return anything here |
|
1289 } |
|
1290 |
|
1291 // ------------------------------------------------------------------------------------- |
|
1292 // CSupAdapter::GetSelectedTypeL() |
|
1293 // ------------------------------------------------------------------------------------- |
|
1294 CSupAdapter::TStartupAdapterLeafType CSupAdapter::GetSelectedTypeL(CSmlDmAdapter::TError& /*aStatus*/) |
|
1295 { |
|
1296 RDEBUG("CSupAdapter::GetSelectedTypeL()"); |
|
1297 |
|
1298 TStartupAdapterLeafType retVal = CSupAdapter::EUnknown; |
|
1299 TInt type = ETextWelcomeNote; |
|
1300 |
|
1301 RUISettingsSrv uiSrv; |
|
1302 User::LeaveIfError( uiSrv.Connect() ); |
|
1303 CleanupClosePushL( uiSrv ); |
|
1304 |
|
1305 User::LeaveIfError( uiSrv.GetStartupNoteType( type ) ); |
|
1306 |
|
1307 CleanupStack::PopAndDestroy( &uiSrv ); |
|
1308 |
|
1309 switch(type) |
|
1310 { |
|
1311 case ETextWelcomeNote: |
|
1312 retVal = CSupAdapter::EText; |
|
1313 break; |
|
1314 |
|
1315 case EImageWelcomeNote: |
|
1316 retVal = CSupAdapter::EImage; |
|
1317 break; |
|
1318 } |
|
1319 |
|
1320 return retVal; |
|
1321 } |
|
1322 |
|
1323 // ------------------------------------------------------------------------------------- |
|
1324 // CSupAdapter::CheckPolicyL |
|
1325 // ------------------------------------------------------------------------------------- |
|
1326 //#ifdef __SAP_POLICY_MANAGEMENT |
|
1327 |
|
1328 TInt CSupAdapter::CheckPolicyL() |
|
1329 { |
|
1330 |
|
1331 if(!FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement )) |
|
1332 { |
|
1333 User::Leave(KErrNotSupported); |
|
1334 } |
|
1335 |
|
1336 |
|
1337 TInt result( KErrNone ); |
|
1338 |
|
1339 #ifdef __WINS__ |
|
1340 |
|
1341 return result; |
|
1342 |
|
1343 #else |
|
1344 RDEBUG("CSupAdapter::CheckPolicyL() ask if enforcement is set"); |
|
1345 CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL(); |
|
1346 CleanupStack::PushL(info); |
|
1347 TBool enfed(EFalse); |
|
1348 User::LeaveIfError(info->EnforcementActive(ECustomization, enfed)); |
|
1349 CleanupStack::PopAndDestroy(info); |
|
1350 |
|
1351 RDEBUG_2("CSupAdapter::CheckPolicyL() enforcement: (%d)", enfed); |
|
1352 |
|
1353 if( enfed ) |
|
1354 { |
|
1355 RDMCert dmcert; |
|
1356 TCertInfo ci; |
|
1357 dmcert.Get( ci ); |
|
1358 |
|
1359 // Policy Engine Request |
|
1360 TRequestContext context; |
|
1361 TResponse response; |
|
1362 context.AddSubjectAttributeL( |
|
1363 PolicyEngineXACML::KTrustedSubject, |
|
1364 ci |
|
1365 ); |
|
1366 context.AddResourceAttributeL( |
|
1367 PolicyEngineXACML::KResourceId, |
|
1368 PolicyEngineXACML::KCustomizationManagement, |
|
1369 PolicyEngineXACML::KStringDataType |
|
1370 ); |
|
1371 |
|
1372 User::LeaveIfError( iPR.MakeRequest( context, response ) ); |
|
1373 TResponseValue resp = response.GetResponseValue(); |
|
1374 switch( resp ) |
|
1375 { |
|
1376 case EResponsePermit: |
|
1377 break; |
|
1378 case EResponseDeny: |
|
1379 case EResponseIndeterminate: |
|
1380 case EResponseNotApplicable: |
|
1381 default: |
|
1382 result = KErrAccessDenied; |
|
1383 } |
|
1384 } |
|
1385 |
|
1386 #endif |
|
1387 RDEBUG_2("CSupAdapter::CheckPolicyL() end: response (%d)", result); |
|
1388 return result; |
|
1389 |
|
1390 } |
|
1391 //#endif |
|
1392 |
|
1393 // ----------------------------------------------------------------------------- |
|
1394 // CSupAdapter::PolicyRequestResourceL |
|
1395 // ----------------------------------------------------------------------------- |
|
1396 // |
|
1397 //#ifdef __SAP_POLICY_MANAGEMENT |
|
1398 TPtrC8 CSupAdapter::PolicyRequestResourceL( const TDesC8& /*aURI*/ ) |
|
1399 { |
|
1400 |
|
1401 if(!FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement )) |
|
1402 { |
|
1403 User::Leave(KErrNotSupported); |
|
1404 |
|
1405 } |
|
1406 RDEBUG("CSupAdapter::PolicyRequestResourceL()"); |
|
1407 |
|
1408 return PolicyEngineXACML::KCustomizationManagement(); |
|
1409 } |
|
1410 //#endif |
|
1411 |
|
1412 #ifdef __WINS__ |
|
1413 |
|
1414 // ------------------------------------------------------------------------------------- |
|
1415 // CSupAdapter::DebugTestsL() |
|
1416 // ------------------------------------------------------------------------------------- |
|
1417 void CSupAdapter::DebugTestsL() |
|
1418 { |
|
1419 RDEBUG("CSupAdapter::DebugTestsL()"); |
|
1420 |
|
1421 TBuf8<1024> buffer; |
|
1422 |
|
1423 ASSERT(NSmlDmURI::URISeg(_L8("1/2/3"), 0) == _L8("1")); |
|
1424 ASSERT(NSmlDmURI::URISeg(_L8("1/2/3"), 1) == _L8("2")); |
|
1425 ASSERT(NSmlDmURI::URISeg(_L8("1/2/3"), 2) == _L8("3")); |
|
1426 ASSERT(NSmlDmURI::URISeg(_L8("1/2/3"), 3) == _L8("")); |
|
1427 ASSERT(NSmlDmURI::URISeg(_L8("1/2/3"), 4) == _L8("")); |
|
1428 ASSERT(NSmlDmURI::URISeg(_L8("1/2/3"), 5) == _L8("")); |
|
1429 ASSERT(NSmlDmURI::URISeg(_L8("1/2/3"), -1) == _L8("")); |
|
1430 |
|
1431 ASSERT(NSmlDmURI::URISeg(_L8("yksi /kaksi / kolme"), 0) == _L8("yksi ")); |
|
1432 ASSERT(NSmlDmURI::URISeg(_L8("yksi /kaksi / kolme"), 1) == _L8("kaksi ")); |
|
1433 ASSERT(NSmlDmURI::URISeg(_L8("yksi /kaksi / kolme"), 2) == _L8(" kolme")); |
|
1434 ASSERT(NSmlDmURI::URISeg(_L8("yksi /kaksi / kolme"), 3) == _L8("")); |
|
1435 ASSERT(NSmlDmURI::URISeg(_L8("yksi /kaksi / kolme"), 4) == _L8("")); |
|
1436 ASSERT(NSmlDmURI::URISeg(_L8("yksi /kaksi / kolme"), 5) == _L8("")); |
|
1437 ASSERT(NSmlDmURI::URISeg(_L8("yksi /kaksi / kolme"), -1) == _L8("")); |
|
1438 |
|
1439 // |
|
1440 // Text conversions |
|
1441 // |
|
1442 _LIT16(KText, "abcdefghijklmnopqrstuvxyz1234567890_:;-.,'*!#¤%&/()=?`+´^~¨<>|§½@£${[]}\\\""); |
|
1443 |
|
1444 HBufC8 *utf8Text = CTARMCharConv::ConvertToUtf8LC( KText() ); |
|
1445 HBufC16 *unicodeText = CTARMCharConv::ConvertFromUtf8LC( *utf8Text ); |
|
1446 ASSERT( unicodeText->Des().Compare( KText() ) == 0 ); |
|
1447 CleanupStack::PopAndDestroy( unicodeText ); |
|
1448 CleanupStack::PopAndDestroy( utf8Text ); |
|
1449 |
|
1450 // |
|
1451 // Valid mime types |
|
1452 // |
|
1453 ASSERT(IsSupportedTextType(_L8("text/"))); |
|
1454 ASSERT(IsSupportedTextType(_L8("text/plain"))); |
|
1455 ASSERT(IsSupportedTextType(_L8("TeXt/PlaiN"))); |
|
1456 ASSERT(IsSupportedTextType(_L8("TEXT/jepulis"))); |
|
1457 ASSERT(IsSupportedTextType(_L8("text/köök"))); |
|
1458 ASSERT(IsSupportedTextType(_L8("TEXT/,.,.,."))); |
|
1459 ASSERT(IsSupportedTextType(_L8(" text/plain "))); |
|
1460 |
|
1461 ASSERT(IsSupportedImageType(_L8("image/*"))); |
|
1462 ASSERT(IsSupportedImageType(_L8("ImaGe/PnG"))); |
|
1463 ASSERT(IsSupportedImageType(_L8("IMAGE/jepulis"))); |
|
1464 ASSERT(IsSupportedImageType(_L8("image/köök"))); |
|
1465 ASSERT(IsSupportedImageType(_L8("IMAGE/,.,.,."))); |
|
1466 ASSERT(IsSupportedImageType(_L8(" IMage/jpeg "))); |
|
1467 |
|
1468 ASSERT(IsSupportedTextType(_L8("text /plain"))); |
|
1469 ASSERT(IsSupportedTextType(_L8("text / plain"))); |
|
1470 ASSERT(IsSupportedTextType(_L8("t e x t/jepulis"))); |
|
1471 |
|
1472 // |
|
1473 // Invalid mime types |
|
1474 // |
|
1475 ASSERT(!IsSupportedTextType(_L8("text"))); |
|
1476 ASSERT(!IsSupportedTextType(_L8("a text/plain"))); |
|
1477 ASSERT(!IsSupportedTextType(_L8("_text/plain"))); |
|
1478 ASSERT(!IsSupportedTextType(_L8("\"text/plain\""))); |
|
1479 |
|
1480 // |
|
1481 // Get/Set startup text |
|
1482 // |
|
1483 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
1484 CBufBase *object, *object2; |
|
1485 |
|
1486 // Get startup text |
|
1487 object = GetStartupTextL(status, _L8("text/")); |
|
1488 ASSERT(object != 0); |
|
1489 ASSERT(status == CSmlDmAdapter::EOk); |
|
1490 delete object; |
|
1491 |
|
1492 // Set startup text |
|
1493 _LIT16(KStartupText1, "Startup text: Päivää!"); |
|
1494 _LIT16(KStartupText2, "Startup text: Päivää!"); |
|
1495 |
|
1496 SetStartupTextL(status, KStartupText1()); |
|
1497 ASSERT(status == CSmlDmAdapter::EOk); |
|
1498 |
|
1499 // Get startup text |
|
1500 object = GetStartupTextL(status, buffer); |
|
1501 ASSERT(object != 0); |
|
1502 ASSERT(status == CSmlDmAdapter::EOk); |
|
1503 CleanupStack::PushL( object ); |
|
1504 |
|
1505 HBufC16* source = CTARMCharConv::ConvertFromUtf8LC( object->Ptr( 0 ) ); |
|
1506 TInt sourceLength = source->Length(); |
|
1507 TInt destLength = KStartupTBufMaxLength<sourceLength?KStartupTBufMaxLength:sourceLength; |
|
1508 TPtrC16 sourcePtr( source->Ptr(), destLength ); |
|
1509 ASSERT( sourcePtr == KStartupText2 ); |
|
1510 CleanupStack::PopAndDestroy( source ); |
|
1511 |
|
1512 CleanupStack::PopAndDestroy( object ); |
|
1513 |
|
1514 // |
|
1515 // Set/Get startup image |
|
1516 // |
|
1517 TUint8 jpeg[773] = |
|
1518 { |
|
1519 0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2c, |
|
1520 0x01,0x2c,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x08,0x06,0x06,0x07,0x06,0x05,0x08, |
|
1521 0x07,0x07,0x07,0x09,0x09,0x08,0x0a,0x0c,0x14,0x0d,0x0c,0x0b,0x0b,0x0c,0x19,0x12, |
|
1522 0x13,0x0f,0x14,0x1d,0x1a,0x1f,0x1e,0x1d,0x1a,0x1c,0x1c,0x20,0x24,0x2e,0x27,0x20, |
|
1523 0x22,0x2c,0x23,0x1c,0x1c,0x28,0x37,0x29,0x2c,0x30,0x31,0x34,0x34,0x34,0x1f,0x27, |
|
1524 0x39,0x3d,0x38,0x32,0x3c,0x2e,0x33,0x34,0x32,0xff,0xdb,0x00,0x43,0x01,0x09,0x09, |
|
1525 0x09,0x0c,0x0b,0x0c,0x18,0x0d,0x0d,0x18,0x32,0x21,0x1c,0x21,0x32,0x32,0x32,0x32, |
|
1526 0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32, |
|
1527 0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32, |
|
1528 0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0xff,0xc0, |
|
1529 0x00,0x11,0x08,0x00,0x14,0x00,0x14,0x03,0x01,0x22,0x00,0x02,0x11,0x01,0x03,0x11, |
|
1530 0x01,0xff,0xc4,0x00,0x1f,0x00,0x00,0x01,0x05,0x01,0x01,0x01,0x01,0x01,0x01,0x00, |
|
1531 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, |
|
1532 0x0a,0x0b,0xff,0xc4,0x00,0xb5,0x10,0x00,0x02,0x01,0x03,0x03,0x02,0x04,0x03,0x05, |
|
1533 0x05,0x04,0x04,0x00,0x00,0x01,0x7d,0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21, |
|
1534 0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08,0x23, |
|
1535 0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17, |
|
1536 0x18,0x19,0x1a,0x25,0x26,0x27,0x28,0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a, |
|
1537 0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a, |
|
1538 0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a, |
|
1539 0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99, |
|
1540 0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7, |
|
1541 0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5, |
|
1542 0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1, |
|
1543 0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xff,0xc4,0x00,0x1f,0x01,0x00,0x03, |
|
1544 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
|
1545 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0xff,0xc4,0x00,0xb5,0x11,0x00, |
|
1546 0x02,0x01,0x02,0x04,0x04,0x03,0x04,0x07,0x05,0x04,0x04,0x00,0x01,0x02,0x77,0x00, |
|
1547 0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13, |
|
1548 0x22,0x32,0x81,0x08,0x14,0x42,0x91,0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15, |
|
1549 0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26,0x27, |
|
1550 0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49, |
|
1551 0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69, |
|
1552 0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87,0x88, |
|
1553 0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6, |
|
1554 0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4, |
|
1555 0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe2, |
|
1556 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9, |
|
1557 0xfa,0xff,0xda,0x00,0x0c,0x03,0x01,0x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xf7, |
|
1558 0x7b,0xfb,0xeb,0x7d,0x33,0x4e,0xb9,0xbf,0xbc,0x93,0xcb,0xb5,0xb5,0x89,0xe6,0x99, |
|
1559 0xf6,0x93,0xb5,0x14,0x12,0xc7,0x03,0x93,0x80,0x0f,0x4a,0x8f,0x4b,0xd4,0xa1,0xd5, |
|
1560 0xac,0x16,0xee,0x15,0x91,0x01,0x77,0x8d,0xe3,0x90,0x00,0xd1,0xc8,0x8e,0x51,0xd0, |
|
1561 0xe0,0x91,0x95,0x65,0x65,0xc8,0x24,0x1c,0x64,0x12,0x30,0x6a,0x9f,0x89,0x34,0x9b, |
|
1562 0x8d,0x73,0x4e,0x8f,0x4d,0x8a,0xe7,0xec,0xf6,0xb3,0x4a,0x05,0xe3,0xae,0x3c,0xcf, |
|
1563 0x28,0x02,0x76,0xa0,0x65,0x65,0x6d,0xce,0x11,0x59,0x5c,0x15,0x28,0x5c,0x11,0xcd, |
|
1564 0x47,0xa0,0x68,0xb7,0x7a,0x1d,0xc5,0xfc,0x4f,0x7f,0x25,0xe5,0x9d,0xc3,0x8b,0x84, |
|
1565 0x79,0xc2,0x09,0x56,0x66,0x2d,0xe6,0x8d,0xb1,0xa2,0x22,0xa1,0xc2,0x30,0xc0,0xc9, |
|
1566 0x76,0x91,0x8e,0x49,0xa0,0x0d,0xca,0x28,0xa2,0x80,0x0a,0x28,0xa2,0x80,0x0a,0x28, |
|
1567 0xa2,0x80,0x3f,0xff,0xd9 |
|
1568 }; |
|
1569 TPtrC8 jpeg_Ptr8(jpeg, 773); |
|
1570 |
|
1571 // Encode JPEG |
|
1572 TImCodecB64 B64Coder; |
|
1573 HBufC8 *target = HBufC8::NewLC( ( 773 * 4 ) / 3 + 16 ); |
|
1574 TPtr8 targetPtr( target->Des() ); |
|
1575 B64Coder.Encode( jpeg_Ptr8, targetPtr ); |
|
1576 |
|
1577 // Set image X |
|
1578 SetStartupImageL(status,targetPtr,KMimeTypeImageMbm); |
|
1579 ASSERT(status == CSmlDmAdapter::EOk); |
|
1580 |
|
1581 // Get image Y1 (returns encoded MBM) |
|
1582 TInt imageSize; |
|
1583 object = GetStartupImageL(status,KMimeTypeImageMbm,imageSize); |
|
1584 ASSERT(status == CSmlDmAdapter::EOk); |
|
1585 CleanupStack::PushL( object ); |
|
1586 |
|
1587 // Set image Y1 |
|
1588 SetStartupImageL(status,object->Ptr(0),KMimeTypeImageMbm); |
|
1589 ASSERT(status == CSmlDmAdapter::EOk); |
|
1590 |
|
1591 // Get image Y2 |
|
1592 object2 = GetStartupImageL(status,KMimeTypeImageMbm,imageSize); |
|
1593 ASSERT(status == CSmlDmAdapter::EOk); |
|
1594 |
|
1595 // Assert Y1 == Y2 |
|
1596 ASSERT(object->Ptr(0) == object2->Ptr(0)); |
|
1597 |
|
1598 CleanupStack::PopAndDestroy( object ); |
|
1599 delete object2; |
|
1600 CleanupStack::PopAndDestroy(target); |
|
1601 |
|
1602 // |
|
1603 // Other methods, GetFetchTypeL |
|
1604 // |
|
1605 status = CSmlDmAdapter::EOk; |
|
1606 |
|
1607 // OK cases |
|
1608 GetFetchTypeL(status, _L8("")); |
|
1609 ASSERT(status == CSmlDmAdapter::EOk); |
|
1610 GetFetchTypeL(status, _L8("text/plain")); |
|
1611 ASSERT(status == CSmlDmAdapter::EOk); |
|
1612 GetFetchTypeL(status, _L8("image/x-epoc-mbm")); |
|
1613 ASSERT(status == CSmlDmAdapter::EOk); |
|
1614 |
|
1615 // Fail cases |
|
1616 GetFetchTypeL(status, _L8(" t e x t / ")); |
|
1617 ASSERT(status != CSmlDmAdapter::EOk); status = CSmlDmAdapter::EOk; |
|
1618 GetFetchTypeL(status, _L8("ima ge /")); |
|
1619 ASSERT(status != CSmlDmAdapter::EOk); status = CSmlDmAdapter::EOk; |
|
1620 GetFetchTypeL(status, _L8("text/")); |
|
1621 ASSERT(status != CSmlDmAdapter::EOk); status = CSmlDmAdapter::EOk; |
|
1622 GetFetchTypeL(status, _L8("text/")); |
|
1623 ASSERT(status != CSmlDmAdapter::EOk); status = CSmlDmAdapter::EOk; |
|
1624 GetFetchTypeL(status, _L8("video/")); |
|
1625 ASSERT(status != CSmlDmAdapter::EOk); status = CSmlDmAdapter::EOk; |
|
1626 GetFetchTypeL(status, _L8("*")); |
|
1627 ASSERT(status != CSmlDmAdapter::EOk); status = CSmlDmAdapter::EOk; |
|
1628 GetFetchTypeL(status, _L8("text/")); |
|
1629 ASSERT(status != CSmlDmAdapter::EOk); status = CSmlDmAdapter::EOk; |
|
1630 GetFetchTypeL(status, _L8("image/")); |
|
1631 ASSERT(status != CSmlDmAdapter::EOk); status = CSmlDmAdapter::EOk; |
|
1632 } |
|
1633 #endif |
|
1634 |
|
1635 |
|