|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Implementation of OMA DM adapter, allows to configure SW Installer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <smldmadapter.h> |
|
20 #include <data_caging_path_literals.hrh> |
|
21 #include <centralrepository.h> |
|
22 #include <SWInstallerInternalCRKeys.h> |
|
23 #include "cswinstadapter.h" |
|
24 |
|
25 _LIT8( KIntType, "int" ); // Leaf inputs |
|
26 _LIT8( KTextType, "text/plain" ); // Leaf inputs |
|
27 _LIT8( KSWInstDMAdapterVersion, "1.0" ); // Adapter version |
|
28 _LIT8( KSWInstRootNode, "SWInstaller" ); // root URI |
|
29 _LIT8( KSWInstRootURI, "SWInstaller" ); |
|
30 _LIT8( KAllowUnsignedNode, "AllowUnsigned" ); // URI postfix |
|
31 _LIT8( KAllowUnsignedURI, "SWInstaller/AllowUnsigned" ); |
|
32 _LIT8( KAllowUnsignedDescription, "This node tells whether unsigned \ |
|
33 applications are allowed to be installed" ); // Description |
|
34 static const TUint32 KSizeOfSettingId = 0x8; // Contanst size declaration |
|
35 |
|
36 |
|
37 // ============================= LOCAL FUNCTIONS ============================= |
|
38 |
|
39 #ifdef _DEBUG |
|
40 #define DEBUG( x ) x |
|
41 #else |
|
42 #define DEBUG( x ) |
|
43 #endif |
|
44 |
|
45 |
|
46 // ============================= MEMBER FUNCTIONS ============================= |
|
47 |
|
48 // ---------------------------------------------------------------------------- |
|
49 // CSWInstAdapter::NewL |
|
50 // Symbian 1st phase contructor |
|
51 // ---------------------------------------------------------------------------- |
|
52 // |
|
53 CSWInstAdapter* CSWInstAdapter::NewL( MSmlDmCallback* aCallback ) |
|
54 { |
|
55 CSWInstAdapter* self = NewLC( aCallback ); |
|
56 CleanupStack::Pop( self ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // CSWInstAdapter::NewLC |
|
62 // Symbian 1st phase contructor. Push object to cleanup-stack |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 CSWInstAdapter* CSWInstAdapter::NewLC( MSmlDmCallback* aCallback ) |
|
66 { |
|
67 CSWInstAdapter* self = new ( ELeave ) CSWInstAdapter( aCallback ); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CSWInstAdapter::CSWInstAdapter() |
|
75 // C++ Constructor |
|
76 // ---------------------------------------------------------------------------- |
|
77 CSWInstAdapter::CSWInstAdapter( TAny* aEcomArguments ) |
|
78 : CSmlDmAdapter::CSmlDmAdapter( aEcomArguments ) |
|
79 { |
|
80 DEBUG( RDebug::Print( _L( "CSWInstAdapter Constructor" ) ) ); |
|
81 } |
|
82 |
|
83 // ---------------------------------------------------------------------------- |
|
84 // CSWInstAdapter::ConstructL |
|
85 // 2nd phase contructor |
|
86 // ---------------------------------------------------------------------------- |
|
87 // |
|
88 void CSWInstAdapter::ConstructL() |
|
89 { |
|
90 DEBUG( RDebug::Print( _L( "CSWInstAdapter::ConstructL" ) ) ); |
|
91 iSettingsCenRep = CRepository::NewL( KCRUidSWInstallerSettings ); |
|
92 iLocalVarCenRep = CRepository::NewL( KCRUidSWInstallerLV ); |
|
93 } |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // CSWInstAdapter::~CSWInstAdapter() |
|
97 // C++ Destructor |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 CSWInstAdapter::~CSWInstAdapter() |
|
101 { |
|
102 DEBUG( RDebug::Print( _L( "CSWInstAdapter Destructor" ) ) ); |
|
103 delete iSettingsCenRep; |
|
104 delete iLocalVarCenRep; |
|
105 } |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // CSWInstAdapter::DDFVersionL |
|
109 // Return DM plug-in version |
|
110 // ---------------------------------------------------------------------------- |
|
111 // |
|
112 void CSWInstAdapter::DDFVersionL( CBufBase& aDDFVersion ) |
|
113 { |
|
114 // Insert version information |
|
115 DEBUG( RDebug::Print( _L( "CSWInstAdapter::DDFVersionL" ) ) ); |
|
116 aDDFVersion.InsertL( 0, KSWInstDMAdapterVersion ); |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CSWInstAdapter::DDFStructureL |
|
121 // Return DM plug-in structure |
|
122 // ---------------------------------------------------------------------------- |
|
123 // |
|
124 void CSWInstAdapter::DDFStructureL( MSmlDmDDFObject& aDDF ) |
|
125 { |
|
126 // Declare accesses |
|
127 DEBUG( RDebug::Print( _L( "CSWInstAdapter::DDFStructureL" ) ) ); |
|
128 TSmlDmAccessTypes accessTypes; |
|
129 accessTypes.SetGet(); |
|
130 |
|
131 // Create root node |
|
132 MSmlDmDDFObject& root = aDDF.AddChildObjectL( KSWInstRootNode ); |
|
133 FillNodeInfoL( root, |
|
134 accessTypes, |
|
135 MSmlDmDDFObject::EPermanent, |
|
136 MSmlDmDDFObject::ENode, |
|
137 MSmlDmDDFObject::EOne, |
|
138 KNullDesC8(), |
|
139 KTextType ); |
|
140 |
|
141 accessTypes.SetReplace(); |
|
142 |
|
143 MSmlDmDDFObject& allowUnsignedNode = root.AddChildObjectL( KAllowUnsignedNode ); |
|
144 FillNodeInfoL( allowUnsignedNode, |
|
145 accessTypes, |
|
146 MSmlDmDDFObject::EPermanent, |
|
147 MSmlDmDDFObject::EChr, |
|
148 MSmlDmDDFObject::EOne, |
|
149 KAllowUnsignedDescription, |
|
150 KTextType ); |
|
151 |
|
152 DEBUG( RDebug::Print( _L( "CSWInstAdapter::DDFStructureL done" ) ) ); |
|
153 } |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // CSWInstAdapter::StreamingSupport |
|
157 // Return streaming support status, set supported item size |
|
158 // ---------------------------------------------------------------------------- |
|
159 // |
|
160 TBool CSWInstAdapter::StreamingSupport( TInt& /* aItemSize */ ) |
|
161 { |
|
162 // Not supported |
|
163 DEBUG( RDebug::Print( _L( "CSWInstAdapter::StreamingSupport" ) ) ); |
|
164 return EFalse; |
|
165 } |
|
166 |
|
167 // ---------------------------------------------------------------------------- |
|
168 // CSWInstAdapter::StreamCommittedL |
|
169 // Commit stream buffer |
|
170 // ---------------------------------------------------------------------------- |
|
171 // |
|
172 void CSWInstAdapter::StreamCommittedL() |
|
173 { |
|
174 DEBUG( RDebug::Print( _L( "CSWInstAdapter::StreamCommitted" ) ) ); |
|
175 // Intentionally left empty |
|
176 } |
|
177 |
|
178 // ---------------------------------------------------------------------------- |
|
179 // CSWInstAdapter::CompleteOutstandingCmdsL |
|
180 // Complete outstanding commands |
|
181 // ---------------------------------------------------------------------------- |
|
182 // |
|
183 void CSWInstAdapter::CompleteOutstandingCmdsL() |
|
184 { |
|
185 DEBUG( RDebug::Print( _L( "CSWInstAdapter::CompleteOutstandingCmdsL" ) ) ); |
|
186 } |
|
187 |
|
188 // ---------------------------------------------------------------------------- |
|
189 // CSWInstAdapter::FillNodeInfoL |
|
190 // Fill node info |
|
191 // ---------------------------------------------------------------------------- |
|
192 // |
|
193 void CSWInstAdapter::FillNodeInfoL( MSmlDmDDFObject& aDDFObject, |
|
194 TSmlDmAccessTypes& aAccessTypes, |
|
195 MSmlDmDDFObject::TScope aScope, |
|
196 MSmlDmDDFObject::TDFFormat aFormat, |
|
197 MSmlDmDDFObject::TOccurence aOccurence, |
|
198 const TDesC8& aDescription, |
|
199 const TDesC8& aMIMEType ) |
|
200 { |
|
201 DEBUG( RDebug::Print( _L( "CSWInstAdapter::FillNodeInfoL" ) ) ); |
|
202 aDDFObject.SetAccessTypesL( aAccessTypes ); |
|
203 aDDFObject.SetScopeL( aScope ); |
|
204 aDDFObject.SetOccurenceL( aOccurence ); |
|
205 aDDFObject.SetDFFormatL( aFormat ); |
|
206 aDDFObject.SetDescriptionL( aDescription ); |
|
207 if ( aFormat != MSmlDmDDFObject::ENode ) |
|
208 { |
|
209 aDDFObject.AddDFTypeMimeTypeL( aMIMEType ); |
|
210 } |
|
211 DEBUG( RDebug::Print( _L( "CSWInstAdapter::FillNodeInfoL done" ) ) ); |
|
212 } |
|
213 |
|
214 // ---------------------------------------------------------------------------- |
|
215 // CSWInstAdapter::CopyCommandL |
|
216 // Copy object |
|
217 // ---------------------------------------------------------------------------- |
|
218 // |
|
219 void CSWInstAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/, |
|
220 const TDesC8& /*aTargetLUID*/, |
|
221 const TDesC8& /*aSourceURI*/, |
|
222 const TDesC8& /*aSourceLUID*/, |
|
223 const TDesC8& /*aType*/, |
|
224 TInt aStatusRef ) |
|
225 { |
|
226 // Not supported |
|
227 DEBUG( RDebug::Print( _L( "CSWInstAdapter::CopyCommandL" ) ) ); |
|
228 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
229 } |
|
230 |
|
231 // ---------------------------------------------------------------------------- |
|
232 // DeleteObjectL |
|
233 // Delete object |
|
234 // ---------------------------------------------------------------------------- |
|
235 // |
|
236 void CSWInstAdapter::DeleteObjectL( const TDesC8& /* aURI */, |
|
237 const TDesC8& /* aLUID */, |
|
238 TInt aStatusRef ) |
|
239 |
|
240 { |
|
241 // Not supported |
|
242 DEBUG( RDebug::Print( _L( "CSWInstAdapter::DeleteObjectL" ) ) ); |
|
243 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
244 } |
|
245 |
|
246 // ---------------------------------------------------------------------------- |
|
247 // CSWInstAdapter::FetchLeafObjectL |
|
248 // Fetch leaf |
|
249 // ---------------------------------------------------------------------------- |
|
250 // |
|
251 void CSWInstAdapter::FetchLeafObjectL( const TDesC8& aURI, |
|
252 const TDesC8& /* aLUID */, |
|
253 const TDesC8& aType, |
|
254 TInt aResultsRef, |
|
255 TInt aStatusRef ) |
|
256 { |
|
257 DEBUG( RDebug::Print( _L( "CSWInstAdapter::FetchLeafObjectL" ) ) ); |
|
258 MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk; |
|
259 |
|
260 if ( aURI.Compare( KAllowUnsignedURI ) == 0 ) |
|
261 { |
|
262 TInt cenRepValue; |
|
263 TInt ret = iLocalVarCenRep->Get( KSWInstallerHideUntrustedIns, cenRepValue ); |
|
264 DEBUG( RDebug::Print( _L("CSWInstAdapter: CenRep ret = %d, val = %d" ), ret, !cenRepValue ) ); |
|
265 if ( ret == KErrNone ) |
|
266 { |
|
267 TBuf8<KSizeOfSettingId> buf; |
|
268 buf.AppendNum( !cenRepValue ); |
|
269 CBufBase* bufBase = CBufFlat::NewL( 1 ); |
|
270 CleanupStack::PushL( bufBase ); |
|
271 bufBase->InsertL( 0, buf ); |
|
272 Callback().SetResultsL( aResultsRef, *bufBase, aType ); |
|
273 CleanupStack::PopAndDestroy( bufBase ); |
|
274 } |
|
275 else |
|
276 { |
|
277 retValue = CSmlDmAdapter::EError; |
|
278 } |
|
279 } |
|
280 else |
|
281 { |
|
282 retValue = CSmlDmAdapter::EError; |
|
283 } |
|
284 // Respond |
|
285 Callback().SetStatusL( aStatusRef, retValue ); |
|
286 DEBUG( RDebug::Print( _L( "CSWInstAdapter::FetchLeafObjectL done" ) ) ); |
|
287 } |
|
288 |
|
289 // ---------------------------------------------------------------------------- |
|
290 // CSWInstAdapter::FetchLeafObjectSizeL |
|
291 // Calculate leaf object size |
|
292 // ---------------------------------------------------------------------------- |
|
293 // |
|
294 void CSWInstAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, |
|
295 const TDesC8& /* aLUID */, |
|
296 const TDesC8& /* aType */, |
|
297 TInt aResultsRef, |
|
298 TInt aStatusRef ) |
|
299 { |
|
300 DEBUG( RDebug::Print( _L( "CSWInstAdapter::FetchLeafObjectSizeL" ) ) ); |
|
301 MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk; |
|
302 |
|
303 if ( aURI.Compare( KAllowUnsignedURI ) == 0 ) |
|
304 { |
|
305 TBuf8<KSizeOfSettingId> buf; |
|
306 CBufBase* bufBase = CBufFlat::NewL( KSizeOfSettingId ); |
|
307 CleanupStack::PushL( bufBase ); |
|
308 buf.AppendNum( sizeof(TInt) ); |
|
309 bufBase->InsertL( 0, buf ); |
|
310 Callback().SetResultsL( aResultsRef, *bufBase, KIntType ); |
|
311 CleanupStack::PopAndDestroy( bufBase ); |
|
312 } |
|
313 else |
|
314 { |
|
315 retValue = CSmlDmAdapter::ENotFound; |
|
316 } |
|
317 // Respond |
|
318 Callback().SetStatusL( aStatusRef, retValue ); |
|
319 DEBUG( RDebug::Print( _L( "CSWInstAdapter::FetchLeafObjectSizeL done" ) ) ); |
|
320 } |
|
321 |
|
322 // ---------------------------------------------------------------------------- |
|
323 // CSWInstAdapter::ChildURIListL |
|
324 // Create child URI list |
|
325 // ---------------------------------------------------------------------------- |
|
326 // |
|
327 void CSWInstAdapter::ChildURIListL( const TDesC8& aURI, |
|
328 const TDesC8& /* aLUID */, |
|
329 const CArrayFix<TSmlDmMappingInfo>& /* aPreviousURISegmentList */, |
|
330 TInt aResultsRef, |
|
331 TInt aStatusRef ) |
|
332 { |
|
333 DEBUG( RDebug::Print( _L( "CSWInstAdapter::ChildURIListL" ) ) ); |
|
334 MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk; |
|
335 |
|
336 if ( aURI.Compare( KSWInstRootURI ) == 0) |
|
337 { |
|
338 CBufBase* buf = CBufFlat::NewL( 1 ); |
|
339 CleanupStack::PushL( buf ); |
|
340 buf->InsertL( 0, KAllowUnsignedNode ); |
|
341 Callback().SetResultsL( aResultsRef, *buf, KNullDesC8 ); |
|
342 CleanupStack::PopAndDestroy( buf ); |
|
343 } |
|
344 else |
|
345 { |
|
346 retValue = CSmlDmAdapter::ENotFound; |
|
347 } |
|
348 |
|
349 // Respond |
|
350 Callback().SetStatusL( aStatusRef, retValue ); |
|
351 DEBUG( RDebug::Print( _L( "CSWInstAdapter::ChildURIListL done" ) ) ); |
|
352 } |
|
353 |
|
354 // ---------------------------------------------------------------------------- |
|
355 // CSWInstAdapter::AddNodeObjectL |
|
356 // Add node |
|
357 // ---------------------------------------------------------------------------- |
|
358 // |
|
359 void CSWInstAdapter::AddNodeObjectL( const TDesC8& /* aURI */, |
|
360 const TDesC8& /* aParentLUID */, |
|
361 TInt aStatusRef ) |
|
362 { |
|
363 // Not supported |
|
364 DEBUG( RDebug::Print( _L( "CSWInstAdapter::AddNodeObjectL" ) ) ); |
|
365 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
366 } |
|
367 |
|
368 // ---------------------------------------------------------------------------- |
|
369 // CSWInstAdapter::ExecuteCommandL |
|
370 // Execute command |
|
371 // ---------------------------------------------------------------------------- |
|
372 // |
|
373 void CSWInstAdapter::ExecuteCommandL( const TDesC8& /* aURI */, |
|
374 const TDesC8& /* aLUID */, |
|
375 const TDesC8& /* aArgument */, |
|
376 const TDesC8& /* aType */, |
|
377 TInt aStatusRef ) |
|
378 { |
|
379 // Not supported |
|
380 DEBUG( RDebug::Print( _L( "CSWInstAdapter::ExecuteCommandL" ) ) ); |
|
381 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
382 } |
|
383 |
|
384 // ---------------------------------------------------------------------------- |
|
385 // CSWInstAdapter::ExecuteCommandL |
|
386 // Execute command, streaming enabled |
|
387 // ---------------------------------------------------------------------------- |
|
388 // |
|
389 void CSWInstAdapter::ExecuteCommandL( const TDesC8& /* aURI */, |
|
390 const TDesC8& /* aLUID */, |
|
391 RWriteStream*& /* aStream */, |
|
392 const TDesC8& /* aType */, |
|
393 TInt aStatusRef ) |
|
394 { |
|
395 // Not supported |
|
396 DEBUG( RDebug::Print( _L( "CSWInstAdapter::ExecuteCommandL (streaming)" ) ) ); |
|
397 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
398 } |
|
399 |
|
400 // ---------------------------------------------------------------------------- |
|
401 // CSWInstAdapter::UpdateLeafObjectL |
|
402 // Update leaf object |
|
403 // ---------------------------------------------------------------------------- |
|
404 // |
|
405 void CSWInstAdapter::UpdateLeafObjectL( const TDesC8& aURI, |
|
406 const TDesC8& /* aLUID */, |
|
407 const TDesC8& aObject, |
|
408 const TDesC8& /* aType */, |
|
409 TInt aStatusRef ) |
|
410 { |
|
411 DEBUG( RDebug::Print( _L( "CSWInstAdapter::UpdateLeafObjectL" ) ) ); |
|
412 MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk; |
|
413 |
|
414 if ( aURI.Compare( KAllowUnsignedURI ) == 0 ) |
|
415 { |
|
416 TLex8 lex( aObject ); |
|
417 TInt value; |
|
418 TInt ret; |
|
419 if ( lex.Val( value ) != KErrNone ) |
|
420 { |
|
421 DEBUG( RDebug::Print( _L( "CSWInstAdapter: lex.Val failed" ) ) ); |
|
422 retValue = CSmlDmAdapter::EInvalidObject; |
|
423 } |
|
424 else |
|
425 { |
|
426 TInt allow = !!value; // make sure it's 0 or 1 |
|
427 TInt hide = !value; |
|
428 ret = iSettingsCenRep->Set( KSWInstallerAllowUntrusted, allow ); |
|
429 DEBUG( RDebug::Print( _L( "CSWInstAdapter: KSWInstallerAllowUntrusted set to %d, ret %d" ), allow, ret ) ); |
|
430 ret |= iLocalVarCenRep->Set( KSWInstallerHideUntrustedIns, hide ); |
|
431 DEBUG( RDebug::Print( _L( "CSWInstAdapter: KSWInstallerHideUntrustedIns set to %d, ret %d" ), hide, ret ) ); |
|
432 if ( ret != KErrNone ) |
|
433 { |
|
434 retValue = CSmlDmAdapter::EError; |
|
435 } |
|
436 } |
|
437 } |
|
438 else |
|
439 { |
|
440 retValue = CSmlDmAdapter::ENotFound; |
|
441 } |
|
442 // Respond |
|
443 Callback().SetStatusL( aStatusRef, retValue ); |
|
444 DEBUG( RDebug::Print( _L( "CSWInstAdapter::UpdateLeafObjectL done" ) ) ); |
|
445 } |
|
446 |
|
447 // ---------------------------------------------------------------------------- |
|
448 // CSWInstAdapter::UpdateLeafObjectL |
|
449 // Update leaf object, streaming enabled |
|
450 // ---------------------------------------------------------------------------- |
|
451 // |
|
452 void CSWInstAdapter::UpdateLeafObjectL( const TDesC8& /* aURI */, |
|
453 const TDesC8& /* aLUID */, |
|
454 RWriteStream*& /* aStream */, |
|
455 const TDesC8& /* aType */, |
|
456 TInt aStatusRef |
|
457 ) |
|
458 { |
|
459 // Not supported |
|
460 DEBUG( RDebug::Print( _L( "CSWInstAdapter::UpdateLeafObjectL (streaming)" ) ) ); |
|
461 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
462 } |
|
463 |
|
464 // ---------------------------------------------------------------------------- |
|
465 // CSWInstAdapter::StartAtomicL |
|
466 // Start atomic |
|
467 // ---------------------------------------------------------------------------- |
|
468 // |
|
469 void CSWInstAdapter::StartAtomicL() |
|
470 { |
|
471 } |
|
472 |
|
473 // ---------------------------------------------------------------------------- |
|
474 // CSWInstAdapter::CommitAtomicL |
|
475 // Commit atomic commands |
|
476 // ---------------------------------------------------------------------------- |
|
477 // |
|
478 void CSWInstAdapter::CommitAtomicL() |
|
479 { |
|
480 } |
|
481 |
|
482 // ---------------------------------------------------------------------------- |
|
483 // CSWInstAdapter::RollbackAtomicL |
|
484 // Lose all modifications after 'StartAtomicL' command |
|
485 // ---------------------------------------------------------------------------- |
|
486 // |
|
487 void CSWInstAdapter::RollbackAtomicL() |
|
488 { |
|
489 } |
|
490 |
|
491 // End of File |