|
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: Application Management DM Adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 |
|
21 1. Remember the applications managed by Corporate Admin Role certificate |
|
22 1.1 They must be removed during rfs |
|
23 1.2 Others must be left as is (applications at least must be left) |
|
24 |
|
25 */ |
|
26 |
|
27 /* |
|
28 |
|
29 ./SCM -+-> Inventory -+--> Deployed ---> <X> * ---+--> ID |
|
30 | | | |
|
31 | | |--> Name ? |
|
32 | | | |
|
33 | | |--> Version ? |
|
34 | | | |
|
35 | | |--> StateValue ? |
|
36 | | | |
|
37 | | |--> EnvType ? X |
|
38 | | | |
|
39 | | |--> Operations ---+-> Activate ? |
|
40 | | | | |
|
41 | | | |-> Deactivate ? |
|
42 | | | | |
|
43 | | | |-> Remove ? |
|
44 | | | | |
|
45 | | | |-> Ext ? X |
|
46 | | | |
|
47 | | |--> Ext ? X |
|
48 | | |
|
49 | +--> Delivered ---> <X> * --+--> ID |
|
50 | | |
|
51 | |--> Data |
|
52 | | |
|
53 | |--> Name ? |
|
54 | | |
|
55 | |--> Version ? |
|
56 | | |
|
57 | |--> InstallOpts ? |
|
58 | | |
|
59 | |--> Descriptor ? |
|
60 | | |
|
61 | |--> EnvType ? X |
|
62 | | |
|
63 | |--> ContentType ? X |
|
64 | | |
|
65 | |--> Operations ---+-> Install ? |
|
66 | | | |
|
67 | | |-> Update ? |
|
68 | | | |
|
69 | | |-> InstallAndActivate ? |
|
70 | | | |
|
71 | | |-> UpdateAndActivate ? |
|
72 | | | |
|
73 | | |-> Remove ? |
|
74 | | | |
|
75 | | |-> Ext ? |
|
76 | | |
|
77 | |--> Ext ? |
|
78 | |
|
79 | |
|
80 +-> Download --> <X> * ---+-> ID |
|
81 | | |
|
82 | |-> URI |
|
83 | | |
|
84 | |-> Name ? |
|
85 | | |
|
86 | |-> Version ? |
|
87 | | |
|
88 | |-> InstallOpts ? X |
|
89 | | |
|
90 | |-> ConRef ? X |
|
91 | | |
|
92 | |-> Status ? |
|
93 | | |
|
94 | |-> EnvType ? X |
|
95 | | |
|
96 | |-> ContentType ? X |
|
97 | | |
|
98 | |--> Operations ----+-> Download ? |
|
99 | | | |
|
100 | | |-> DownloadAndInstall ? X |
|
101 | | | |
|
102 | | |-> DownloadAndInstallAndActivate ? X |
|
103 | | | |
|
104 | | |-> DownloadAndUpdate ? X |
|
105 | | | |
|
106 | | |-> DownloadAndUpdateAndActivate ? X |
|
107 | | | |
|
108 | | |-> Ext ? |
|
109 | | |
|
110 | |--> Ext ? |
|
111 | |
|
112 |--> Ext -> LastError (Debug Only) ? |
|
113 |
|
114 */ |
|
115 |
|
116 #define __AM_CHECKSTATE_CHANGES // uncomment to enable dynamic acl |
|
117 #include <badesca.h> |
|
118 #include <fbs.h> |
|
119 #include <s32file.h> |
|
120 #include "amadapter.h" |
|
121 #include <implementationproxy.h> // For TImplementationProxy definition |
|
122 #include <f32file.h> |
|
123 #include "nsmldmuri.h" |
|
124 #include "nsmldmiapmatcher.h" |
|
125 #include "debug.h" |
|
126 |
|
127 #include <centralrepository.h> |
|
128 #include "aminstalloptions.h" |
|
129 #include <featmgr.h> |
|
130 #include "amprivateCRKeys.h" |
|
131 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
132 #include <dmtreenode.h> |
|
133 #include <devman.h> |
|
134 #include "nsmldmuri.h" |
|
135 |
|
136 // Constants |
|
137 _LIT8( KDeployedURI, "./SCM/Inventory/Deployed/" ); |
|
138 _LIT8( KDeliveredURI, "./SCM/Inventory/Delivered/" ); |
|
139 _LIT8( KDownloadURI, "./SCM/Download/" ); |
|
140 #else |
|
141 #include <nsmldmuri.h> |
|
142 |
|
143 // Constants |
|
144 _LIT8( KDeployedURI, "SCM/Inventory/Deployed/" ); |
|
145 _LIT8( KDeliveredURI, "SCM/Inventory/Delivered/" ); |
|
146 _LIT8( KDownloadURI, "SCM/Download/" ); |
|
147 #endif |
|
148 |
|
149 #ifdef __NSML_DEBUG__ |
|
150 #pragma message("NSml Debugging is ON!") |
|
151 #else |
|
152 #endif |
|
153 |
|
154 |
|
155 using namespace NApplicationManagement; |
|
156 |
|
157 |
|
158 |
|
159 _LIT8( KAMStateValueActive, "Active" ); |
|
160 _LIT8( KAMStateValueInactive, "Inactive" ); |
|
161 |
|
162 |
|
163 _LIT8( KSisxMimeType, "x-epoc/x-sisx-app" ); |
|
164 _LIT8( KSisMimeType, "application/vnd.symbian.install" ); |
|
165 _LIT8( KPipMimeType, "application/x-pip" ); |
|
166 _LIT8( KJadMIMEType, "text/vnd.sun.j2me.app-descriptor" ); |
|
167 _LIT8( KJarMIMEType, "application/java-archive" ); |
|
168 _LIT8( KJavaMIMEType, "application/java" ); |
|
169 |
|
170 _LIT8( KInstallOptsMimeType, "text/xml" ); |
|
171 |
|
172 |
|
173 |
|
174 const TUint8 KNSmlDMAMSeparatorDef = 0x2f; //forward slash |
|
175 #ifdef __AM_LASTERROR_NODE |
|
176 |
|
177 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
178 _LIT8( KAMLastErrorURI, "./SCM/Ext/LastError" ); |
|
179 #else |
|
180 _LIT8( KAMLastErrorURI, "SCM/Ext/LastError" ); |
|
181 #endif |
|
182 _LIT8( KStdError, "Error %d" ); |
|
183 |
|
184 #define MAPERROR(x,y,z) DefaultMapError(x,y,z) |
|
185 #else |
|
186 |
|
187 #define MAPERROR(x,y,z) DefaultMapError(x,y) |
|
188 #endif |
|
189 |
|
190 |
|
191 // ------------------------------------------------------------------------------------------------ |
|
192 // CAmAdapter* CAmAdapter::NewL( ) |
|
193 // ------------------------------------------------------------------------------------------------ |
|
194 CAmAdapter* CAmAdapter::NewL( MSmlDmCallback* aDmCallback ) |
|
195 { |
|
196 RDEBUG("CAmAdapter::NewL(): begin"); |
|
197 |
|
198 CAmAdapter* self = NewLC( aDmCallback ); |
|
199 CleanupStack::Pop(); |
|
200 return self; |
|
201 } |
|
202 |
|
203 // ------------------------------------------------------------------------------------------------ |
|
204 // CAmAdapter* CAmAdapter::NewLC( ) |
|
205 // ------------------------------------------------------------------------------------------------ |
|
206 CAmAdapter* CAmAdapter::NewLC( MSmlDmCallback* aDmCallback ) |
|
207 { |
|
208 CAmAdapter* self = new( ELeave ) CAmAdapter( aDmCallback ); |
|
209 CleanupStack::PushL( self ); |
|
210 self->ConstructL(); |
|
211 return self; |
|
212 } |
|
213 |
|
214 |
|
215 // ------------------------------------------------------------------------------------------------ |
|
216 // CAmAdapter::CAmAdapter() |
|
217 // ------------------------------------------------------------------------------------------------ |
|
218 CAmAdapter::CAmAdapter( TAny* aEcomArguments ) |
|
219 : CSmlDmAdapter( aEcomArguments ), iSessionOpened ( EFalse ), iBuffer( 8 ), |
|
220 iInAtomic( EFalse ), iUpdated( EFalse ), iIsStreamedContent( EFalse ) |
|
221 { |
|
222 } |
|
223 |
|
224 |
|
225 // ------------------------------------------------------------------------------------------------ |
|
226 // CAmAdapter::~CAmAdapter() |
|
227 // ------------------------------------------------------------------------------------------------ |
|
228 CAmAdapter::~CAmAdapter() |
|
229 { |
|
230 RDEBUG( "CAmAdapter::~CAmAdapter" ); |
|
231 iDbSession.Close(); |
|
232 iManagement.Close(); // make sure we're closed |
|
233 iSessionOpened = EFalse ; |
|
234 iBuffer.Close(); |
|
235 |
|
236 CloseStreaming(); // Ensures that no streams are left open and that the temporary file is removed |
|
237 |
|
238 delete iStreamedURI; |
|
239 delete iStreamedLuid; |
|
240 delete iStreamedType; |
|
241 |
|
242 #ifdef __AM_LASTERROR_NODE |
|
243 delete iLastError; |
|
244 #endif |
|
245 |
|
246 |
|
247 if(iUriDel) |
|
248 delete iUriDel; |
|
249 RDEBUG( "CAmAdapter::~CAmAdapter end" ); |
|
250 } |
|
251 |
|
252 // ------------------------------------------------------------------------------------------------ |
|
253 // CAmAdapter::DDFVersionL() |
|
254 // ------------------------------------------------------------------------------------------------ |
|
255 void CAmAdapter::DDFVersionL( CBufBase& aDDFVersion ) |
|
256 { |
|
257 aDDFVersion.InsertL( 0, KAMDDFVersion ); |
|
258 } |
|
259 |
|
260 |
|
261 // ------------------------------------------------------------------------------------------------ |
|
262 // CAmAdapter::DDFStructureL() |
|
263 // |
|
264 // ------------------------------------------------------------------------------------------------ |
|
265 void CAmAdapter::DDFStructureL( MSmlDmDDFObject& aDDF ) |
|
266 { |
|
267 RDEBUG( "CAmAdapter::DDFStructureL(): begin" ); |
|
268 |
|
269 TSmlDmAccessTypes accessTypesGet; |
|
270 accessTypesGet.SetGet(); |
|
271 |
|
272 TSmlDmAccessTypes accessTypesExec; |
|
273 accessTypesExec.SetExec(); |
|
274 |
|
275 TSmlDmAccessTypes accessTypesExecReplace = accessTypesExec; |
|
276 accessTypesExecReplace.SetReplace(); |
|
277 |
|
278 TSmlDmAccessTypes accessTypesGetAdd = accessTypesGet; |
|
279 accessTypesGetAdd.SetAdd(); |
|
280 |
|
281 TSmlDmAccessTypes accessTypesGetReplace = accessTypesGet; |
|
282 accessTypesGetReplace.SetGet(); |
|
283 |
|
284 TSmlDmAccessTypes accessTypesGetAddReplace = accessTypesGetAdd; |
|
285 accessTypesGetAddReplace.SetReplace(); |
|
286 |
|
287 TSmlDmAccessTypes accessTypesGetAddReplaceDelete = accessTypesGetAddReplace; |
|
288 accessTypesGetAddReplaceDelete.SetDelete(); |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 /* |
|
294 Node: ./SCM |
|
295 AM node is the common parent to all application management functionality nodes. |
|
296 Support: Mandatory |
|
297 Occurs: One |
|
298 Format: Node |
|
299 Access Types: Get |
|
300 Values: N/A |
|
301 */ |
|
302 //MSmlDmDDFObject& root = aDDF.AddChildObjectGroupL(); |
|
303 MSmlDmDDFObject& am = aDDF.AddChildObjectL( KAMNodeName ); |
|
304 FillNodeInfoL( am, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
305 MSmlDmDDFObject::ENode, KAMNodeDescription ); |
|
306 |
|
307 /* |
|
308 Node: ./SCM/Inventory |
|
309 This node is start node to application inventory. |
|
310 Support: Mandatory |
|
311 Occurs: One |
|
312 Format: Node |
|
313 Access Types: Get |
|
314 Values: N/A |
|
315 */ |
|
316 MSmlDmDDFObject& inv = am.AddChildObjectL( KAMInventoryNodeName ); |
|
317 FillNodeInfoL( inv, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
318 MSmlDmDDFObject::ENode, KAMInventoryNodeDescription ); |
|
319 |
|
320 /* |
|
321 Node: ./SCM/Inventory/Delivered |
|
322 This is node under which applications that are delivered but not installed are found. |
|
323 Support: Mandatory |
|
324 Occurs: One |
|
325 Format: Node |
|
326 Access Types: Get, Add |
|
327 Values: N/A |
|
328 */ |
|
329 MSmlDmDDFObject& del = inv.AddChildObjectL( KAMDeliveredNodeName ); |
|
330 FillNodeInfoL( del, accessTypesGetAdd, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
331 MSmlDmDDFObject::ENode, KAMDeliveredNodeDescription ); |
|
332 |
|
333 |
|
334 /* |
|
335 Node: ./SCM/Inventory/Deployed |
|
336 This is a node under which active applications are found. |
|
337 The child node descriptions are same as Delivered sibling node, except that <X> cannot be created, data node does not exist and there's no InstallOpts leaf. |
|
338 Support: Mandatory |
|
339 Occurs: One |
|
340 Format: Node |
|
341 Access Types: Get |
|
342 Values: N/A |
|
343 */ |
|
344 |
|
345 MSmlDmDDFObject& ac = inv.AddChildObjectL( KAMDeployedNodeName ); |
|
346 FillNodeInfoL( ac, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
347 MSmlDmDDFObject::ENode, KAMDeployedNodeDescription ); |
|
348 |
|
349 /* |
|
350 Node: ./SCM/Inventory/Delivered/<X> |
|
351 This dynamic node is placeholder applications that are in Delivered state. |
|
352 Support: Mandatory |
|
353 Occurs: ZeroOrMore |
|
354 Format: Node |
|
355 Access Types: Get, Add, Replace, Delete |
|
356 Values: N/A |
|
357 */ |
|
358 MSmlDmDDFObject& deldyna = del.AddChildObjectGroupL(); |
|
359 FillNodeInfoL( deldyna, accessTypesGetAddReplaceDelete, MSmlDmDDFObject::EZeroOrMore, |
|
360 MSmlDmDDFObject::EDynamic, |
|
361 MSmlDmDDFObject::ENode, KAMDeliveredDynaNodeDescription ); |
|
362 |
|
363 /* |
|
364 Node: ./SCM/Inventory/Delivered/<X>/ID |
|
365 This leaf node holds an identifier for an application. |
|
366 Support: Mandatory |
|
367 Occurs: One |
|
368 Format: Chr |
|
369 Access Types: Get |
|
370 Values: N/A |
|
371 */ |
|
372 MSmlDmDDFObject& delid = deldyna.AddChildObjectL( KAMIDNodeName ); |
|
373 FillNodeInfoL( delid, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
374 MSmlDmDDFObject::EChr, KAMIDNodeDescription ); |
|
375 |
|
376 /* |
|
377 Node: ./SCM/Inventory/Delivered/<X>/Name |
|
378 This leaf node holds name of an application. |
|
379 Support: Mandatory |
|
380 Occurs: One |
|
381 Format: Chr |
|
382 Access Types: Get ( + Add, Replace access within Delivered node only) |
|
383 Values: N/A |
|
384 */ |
|
385 MSmlDmDDFObject& delname = deldyna.AddChildObjectL( KAMNameNodeName ); |
|
386 FillNodeInfoL( delname, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
387 MSmlDmDDFObject::EChr, KAMNameNodeDescription ); |
|
388 |
|
389 /* |
|
390 Node: ./SCM/Inventory/Delivered/<X>/Version |
|
391 This leaf node holds the version of an application. |
|
392 Support: Mandatory |
|
393 Occurs: One |
|
394 Format: Chr |
|
395 Access Types: Get ( + Add, Replace access within Delivered node only) |
|
396 Values: N/A |
|
397 */ |
|
398 MSmlDmDDFObject& delver = deldyna.AddChildObjectL( KAMVersionNodeName ); |
|
399 FillNodeInfoL( delver, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
400 MSmlDmDDFObject::EChr, KAMVersionNodeDescription ); |
|
401 |
|
402 |
|
403 /* |
|
404 Node: ./SCM/Inventory/Delivered/<X>/Data |
|
405 This leaf node holds the data of an application. |
|
406 Support: Mandatory |
|
407 Occurs: One |
|
408 Format: Bin |
|
409 Access Types: Add, Get, Replace |
|
410 Values: N/A |
|
411 */ |
|
412 MSmlDmDDFObject& delda = deldyna.AddChildObjectL( KAMDataNodeName ); |
|
413 FillNodeInfoNoDefaultMimeL( delda, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
414 MSmlDmDDFObject::EBin, KAMDataNodeDescription ); |
|
415 |
|
416 delda.AddDFTypeMimeTypeL( KSisxMimeType ); |
|
417 delda.AddDFTypeMimeTypeL( KSisMimeType ); |
|
418 delda.AddDFTypeMimeTypeL( KPipMimeType ); |
|
419 |
|
420 FeatureManager::InitializeLibL(); |
|
421 if( FeatureManager::FeatureSupported(KFeatureIdJavaMIDP20) ) |
|
422 { |
|
423 delda.AddDFTypeMimeTypeL( KJadMIMEType ); |
|
424 delda.AddDFTypeMimeTypeL( KJarMIMEType ); |
|
425 delda.AddDFTypeMimeTypeL( KJavaMIMEType); |
|
426 } |
|
427 |
|
428 FeatureManager::UnInitializeLib(); |
|
429 |
|
430 |
|
431 |
|
432 /* |
|
433 Node: ./SCM/Inventory/Delivered/<X>/Descriptor |
|
434 This leaf node holds the possible metadata of an application. Descriptor can be for example such a data that is required by the actual data in the Data leaf, but for some reason they cannot be bundled into same package. An example is Java JAR and JAD file combination, in which JAD file could be placed in MetaData and JAR in Data leaf. |
|
435 Support: Optional |
|
436 Occurs: One |
|
437 Format: Bin |
|
438 Access Types: Add, Get, Replace |
|
439 Values: N/A |
|
440 */ |
|
441 MSmlDmDDFObject& delmd = deldyna.AddChildObjectL( KAMDescriptorNodeName ); |
|
442 FillNodeInfoL( delmd, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
443 MSmlDmDDFObject::EBin, KAMDescriptorNodeDescription ); |
|
444 |
|
445 /* |
|
446 Node: ./SCM/Inventory/Delivered/<X>/InstallOpts |
|
447 This is a node that holds the installation options of an application. |
|
448 |
|
449 Support: Optional |
|
450 Occurs: ZeroOrOne |
|
451 Format: Xml |
|
452 Access Types: Get, Replace |
|
453 Values: N/A |
|
454 */ |
|
455 MSmlDmDDFObject& delio = deldyna.AddChildObjectL( KAMInstallOptsNodeName ); |
|
456 FillNodeInfoNoDefaultMimeL( delio, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
457 MSmlDmDDFObject::EXml, KAMInstallOptsNodeDescription ); |
|
458 delio.AddDFTypeMimeTypeL( KInstallOptsMimeType ); |
|
459 |
|
460 /* |
|
461 Node: ./SCM/Inventory/Delivered/<X>/Operations |
|
462 This is a node that allows vendors to extend functionality. |
|
463 Support: Optional |
|
464 Occurs: One |
|
465 Format: Node |
|
466 Access Types: Get, Replace, Add, Delete |
|
467 Values: N/A |
|
468 */ |
|
469 MSmlDmDDFObject& delop = deldyna.AddChildObjectL( KAMOperationsNodeName ); |
|
470 FillNodeInfoL( delop, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
471 MSmlDmDDFObject::ENode, KAMOperationsNodeDescription ); |
|
472 |
|
473 /* |
|
474 Node: ./SCM/Inventory/Delivered/<X>/Operations/Install |
|
475 Exec command causes device to install a delivered application. The data inside |
|
476 exec command refers to the application to be installed. |
|
477 Support: Mandatory |
|
478 Occurs: One |
|
479 Format: Node |
|
480 Access Types: Exec, Replace |
|
481 Values: N/A |
|
482 */ |
|
483 MSmlDmDDFObject& loinst = delop.AddChildObjectL( KAMInstallNodeName ); |
|
484 FillNodeInfoL( loinst, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
485 MSmlDmDDFObject::ENode, KAMInstallNodeDescription ); |
|
486 |
|
487 /* |
|
488 Node: ./SCM/Inventory/Delivered/<X>/Operations/InstallAndActivate |
|
489 Exec command causes device to install a delivered application. The data inside |
|
490 exec command refers to the application to be installed. |
|
491 Support: Mandatory |
|
492 Occurs: One |
|
493 Format: Node |
|
494 Access Types: Exec, Replace |
|
495 Values: N/A |
|
496 */ |
|
497 MSmlDmDDFObject& loinstact = delop.AddChildObjectL( KAMInstallAndActivateNodeName ); |
|
498 FillNodeInfoL( loinstact, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
499 MSmlDmDDFObject::ENode, KAMInstallAndActivateNodeDescription ); |
|
500 |
|
501 /* |
|
502 Node: ./SCM/Inventory/Delivered/<X>/Operations/Update |
|
503 Exec command causes device to update an application. The data inside exec command |
|
504 refers to the application to be updated. |
|
505 In practice the flow is so that: |
|
506 1. Admin puts a new data with same ID in inventory/delivered or inventory/download. |
|
507 2. Admin deactivates existing component with same ID. |
|
508 3. Server executes update with item data targeting to the ID. |
|
509 So actually update needs at least three "high level" commands; add data for update, |
|
510 deactivate old, do the update. |
|
511 |
|
512 Support: Optional |
|
513 Occurs: One |
|
514 Format: Node |
|
515 Access Types: Exec, Replace |
|
516 Values: N/A |
|
517 |
|
518 */ |
|
519 MSmlDmDDFObject& loupd = delop.AddChildObjectL( KAMUpdateNodeName ); |
|
520 FillNodeInfoL( loupd, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
521 MSmlDmDDFObject::ENode, KAMUpdateNodeDescription ); |
|
522 |
|
523 /* |
|
524 Node: ./SCM/Inventory/Delivered/<X>/Operations/UpdateAndActivate |
|
525 Exec command causes device to update an application and activate it. The data inside exec command refers to the application to be updated. |
|
526 In practice the flow is so that: |
|
527 1. Admin puts a new data with same ID in inventory/delivered or inventory/download. |
|
528 2. Admin deactivates existing component with same ID. |
|
529 3. Server executes update with item data targeting to the ID. |
|
530 So actually update needs at least three "high level" commands; add data for update, deactivate old, do the update. |
|
531 |
|
532 Support: Optional |
|
533 Occurs: One |
|
534 Format: Node |
|
535 Access Types: Exec, Replace |
|
536 Values: N/A |
|
537 */ |
|
538 MSmlDmDDFObject& loupda = delop.AddChildObjectL( KAMUpdateAndActivateNodeName ); |
|
539 FillNodeInfoL( loupda, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
540 MSmlDmDDFObject::ENode, KAMUpdateAndActivateNodeDescription ); |
|
541 |
|
542 /* |
|
543 Node: ./SCM/Inventory/Delivered/<X>/Operations/Remove |
|
544 Exec command causes device to remove an application. The data inside exec command refers to the application to be removed. The application must be in Inactive state in order for remove to be successful. |
|
545 Support: Mandatory |
|
546 Occurs: One |
|
547 Format: Node |
|
548 Access Types: Exec, Replace |
|
549 Values: N/A |
|
550 */ |
|
551 MSmlDmDDFObject& lorem = delop.AddChildObjectL( KAMRemoveNodeName ); |
|
552 FillNodeInfoL( lorem, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
553 MSmlDmDDFObject::ENode, KAMRemoveNodeDescription ); |
|
554 |
|
555 |
|
556 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= |
|
557 DEPLOYED |
|
558 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ |
|
559 |
|
560 |
|
561 /* |
|
562 Node: ./SCM/Inventory/Deployed/<X> |
|
563 This dynamic node is placeholder applications that are in Inactive state. |
|
564 Support: Mandatory |
|
565 Occurs: ZeroOrMore |
|
566 Format: Node |
|
567 Access Types: Get, Replace |
|
568 Values: N/A |
|
569 */ |
|
570 MSmlDmDDFObject& depldyna = ac.AddChildObjectGroupL(); |
|
571 FillNodeInfoL( depldyna, accessTypesGetReplace, MSmlDmDDFObject::EZeroOrMore, MSmlDmDDFObject::EDynamic, |
|
572 MSmlDmDDFObject::ENode, KAMDeployedDynaNodeDescription ); |
|
573 |
|
574 /* |
|
575 Node: ./SCM/Inventory/Deployed/<X>/ID |
|
576 This leaf node holds an identifier for an application. This cannot be changed. |
|
577 Support: Mandatory |
|
578 Occurs: One |
|
579 Format: Chr |
|
580 Access Types: Get |
|
581 Values: N/A |
|
582 */ |
|
583 MSmlDmDDFObject& deplid = depldyna.AddChildObjectL( KAMIDNodeName ); |
|
584 FillNodeInfoL( deplid, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
585 MSmlDmDDFObject::EChr, KAMIDNodeDescription ); |
|
586 |
|
587 /* |
|
588 Node: ./SCM/Inventory/Deployed/<X>/Name |
|
589 This leaf node holds name of an application. |
|
590 Support: Mandatory |
|
591 Occurs: One |
|
592 Format: Chr |
|
593 Access Types: Get, Add, Replace |
|
594 Values: N/A |
|
595 */ |
|
596 MSmlDmDDFObject& deplname = depldyna.AddChildObjectL( KAMNameNodeName ); |
|
597 FillNodeInfoL( deplname, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
598 MSmlDmDDFObject::EChr, KAMNameNodeDescription ); |
|
599 |
|
600 /* |
|
601 Node: ./SCM/Inventory/Deployed/<X>/Version |
|
602 This leaf node holds the version of an application. |
|
603 Support: Mandatory |
|
604 Occurs: One |
|
605 Format: Chr |
|
606 Access Types: Get, Add, Replace |
|
607 Values: N/A |
|
608 */ |
|
609 MSmlDmDDFObject& deplver = depldyna.AddChildObjectL( KAMVersionNodeName ); |
|
610 FillNodeInfoL( deplver, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
611 MSmlDmDDFObject::EChr, KAMVersionNodeDescription ); |
|
612 |
|
613 /* |
|
614 Node: ./SCM/Inventory/Deployed/<X>/StateValue |
|
615 This leaf node holds state value of an application. |
|
616 Support: ? |
|
617 Occurs: One |
|
618 Format: Chr |
|
619 Access Types: Get |
|
620 Values: N/A |
|
621 */ |
|
622 MSmlDmDDFObject& deplstate = depldyna.AddChildObjectL( KAMStateValueNodeName ); |
|
623 FillNodeInfoL( deplstate, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
624 MSmlDmDDFObject::EChr, KAMStateValueNodeDescription ); |
|
625 |
|
626 |
|
627 |
|
628 /* |
|
629 Node: ./SCM/Inventory/Deployed/<X>/Operations |
|
630 This is a node that allows vendors to extend functionality. |
|
631 Support: Optional |
|
632 Occurs: One |
|
633 Format: Node |
|
634 Access Types: Get, Replace, Add, Delete |
|
635 Values: N/A |
|
636 |
|
637 */ |
|
638 MSmlDmDDFObject& deplop = depldyna.AddChildObjectL( KAMOperationsNodeName ); |
|
639 FillNodeInfoL( deplop, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
640 MSmlDmDDFObject::ENode, KAMOperationsNodeDescription ); |
|
641 |
|
642 |
|
643 |
|
644 /* |
|
645 Node: ./SCM/Inventory/Deployed/<X>/Operations/Remove |
|
646 Exec command causes device to remove an application. The data inside exec command |
|
647 refers to the application to be removed. The application must be in Inactive state |
|
648 in order for remove to be successful. |
|
649 Support: Mandatory |
|
650 Occurs: One |
|
651 Format: Node |
|
652 Access Types: Exec, Replace |
|
653 Values: N/A |
|
654 */ |
|
655 MSmlDmDDFObject& deplrem = deplop.AddChildObjectL( KAMRemoveNodeName ); |
|
656 FillNodeInfoL( deplrem, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
657 MSmlDmDDFObject::ENode, KAMRemoveNodeDescription ); |
|
658 |
|
659 /* |
|
660 Node: ./SCM/Inventory/Deployed/<X>/Operations/Activate |
|
661 Exec command causes device to activate an application. |
|
662 Support: Mandatory |
|
663 Occurs: One |
|
664 Format: Node |
|
665 Access Types: Exec, Replace |
|
666 Values: N/A |
|
667 */ |
|
668 MSmlDmDDFObject& deplac = deplop.AddChildObjectL( KAMActivateNodeName ); |
|
669 FillNodeInfoL( deplac, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
670 MSmlDmDDFObject::ENode, KAMActivateNodeDescription ); |
|
671 |
|
672 /* |
|
673 Node: ./SCM/Inventory/Deployed/<X>/Operations/Deactivate |
|
674 Exec command causes device to deactivate an application. |
|
675 Support: Mandatory |
|
676 Occurs: One |
|
677 Format: Node |
|
678 Access Types: Exec, Replace |
|
679 Values: N/A |
|
680 */ |
|
681 MSmlDmDDFObject& depldeac = deplop.AddChildObjectL( KAMDeActivateNodeName ); |
|
682 FillNodeInfoL( depldeac, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
683 MSmlDmDDFObject::ENode, KAMDeActivateNodeDescription ); |
|
684 |
|
685 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= |
|
686 DOWNLOAD |
|
687 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ |
|
688 |
|
689 /* |
|
690 Node: ./SCM/Download |
|
691 This node is a root node for application download functionality. In practice download |
|
692 works so that admin adds nodes under this node, and they are automatically moved to |
|
693 Inventory/Delivered when the download has been finished. Running get command targeting |
|
694 to this node returns a list of pending downloads. |
|
695 Support: Mandatory |
|
696 Occurs: One |
|
697 Format: Node |
|
698 Access Types: Get, Add, Replace |
|
699 Values: N/A |
|
700 */ |
|
701 MSmlDmDDFObject& dow = am.AddChildObjectL( KAMDownloadNodeName ); |
|
702 FillNodeInfoL( dow, accessTypesGetAddReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
703 MSmlDmDDFObject::ENode, KAMDownloadNodeDescription ); |
|
704 |
|
705 |
|
706 /* |
|
707 Node: ./SCM/Download/<X> |
|
708 This node is a placeholder for identifier of an application that is to be downloaded. |
|
709 Support: Mandatory |
|
710 Occurs: One |
|
711 Format: Node |
|
712 Access Types: Get, Add, Replace, Delete |
|
713 Values: N/A |
|
714 */ |
|
715 MSmlDmDDFObject& dowdyna = dow.AddChildObjectGroupL(); |
|
716 FillNodeInfoL( dowdyna, accessTypesGetAddReplaceDelete, MSmlDmDDFObject::EZeroOrMore, MSmlDmDDFObject::EDynamic, |
|
717 MSmlDmDDFObject::ENode, KAMDownloadDynaNodeDescription ); |
|
718 |
|
719 |
|
720 /* |
|
721 Node: ./SCM/Download/<X>/ID |
|
722 This leaf node holds an identifier for an application. |
|
723 Support: Mandatory |
|
724 Occurs: One |
|
725 Format: Chr |
|
726 Access Types: Get |
|
727 Values: N/A |
|
728 */ |
|
729 MSmlDmDDFObject& dowid = dowdyna.AddChildObjectL( KAMIDNodeName ); |
|
730 FillNodeInfoL( dowid, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
731 MSmlDmDDFObject::EChr, KAMIDNodeDescription ); |
|
732 |
|
733 /* |
|
734 Node: ./SCM/Download/<X>/Name |
|
735 This leaf node holds name of an application. |
|
736 Support: Mandatory |
|
737 Occurs: One |
|
738 Format: Chr |
|
739 Access Types: Add, Get, Replace |
|
740 Values: N/A |
|
741 */ |
|
742 MSmlDmDDFObject& downame = dowdyna.AddChildObjectL( KAMNameNodeName ); |
|
743 FillNodeInfoL( downame, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
744 MSmlDmDDFObject::EChr, KAMNameNodeDescription ); |
|
745 |
|
746 /* |
|
747 Node: ./SCM/Download/<X>/Version |
|
748 This leaf node holds the version of an application. |
|
749 Support: Mandatory |
|
750 Occurs: One |
|
751 Format: Chr |
|
752 Access Types: Add, Get, Replace |
|
753 Values: N/A |
|
754 */ |
|
755 MSmlDmDDFObject& dowver = dowdyna.AddChildObjectL( KAMVersionNodeName ); |
|
756 FillNodeInfoL( dowver, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
757 MSmlDmDDFObject::EChr, KAMVersionNodeDescription ); |
|
758 |
|
759 /* |
|
760 Node: ./SCM/Download/<X>/URI |
|
761 This leaf node holds the URL from which the application should be downloaded. |
|
762 Support: Mandatory |
|
763 Occurs: One |
|
764 Format: Chr |
|
765 Access Types: Add, Get, Replace |
|
766 Values: N/A |
|
767 */ |
|
768 MSmlDmDDFObject& dowuri = dowdyna.AddChildObjectL( KAMURINodeName ); |
|
769 FillNodeInfoL( dowuri, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
770 MSmlDmDDFObject::EChr, KAMURINodeDescription ); |
|
771 |
|
772 /* |
|
773 Node: ./SCM/Download/<X>/Status |
|
774 This leaf node holds the status of the download. The client updates the node value. The values are typically error codes of download protocol. Initially after the URI leaf is filled, this will get value 100, and will be replaced by one. |
|
775 Support: Optional |
|
776 Occurs: One |
|
777 Format: Chr |
|
778 Access Types: Get |
|
779 Values: N/A |
|
780 */ |
|
781 MSmlDmDDFObject& dowstat = dowdyna.AddChildObjectL( KAMStatusNodeName ); |
|
782 FillNodeInfoL( dowstat, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
783 MSmlDmDDFObject::EChr, KAMStatusNodeDescription ); |
|
784 |
|
785 /* |
|
786 Node: ./SCM/Download/<X>/InstallOpts |
|
787 This is a node that holds the installation options of an application. |
|
788 |
|
789 Support: Optional |
|
790 Occurs: ZeroOrOne |
|
791 Format: Xml |
|
792 Access Types: Add, Get, Replace |
|
793 Values: N/A |
|
794 */ |
|
795 MSmlDmDDFObject& dowio = dowdyna.AddChildObjectL( KAMInstallOptsNodeName ); |
|
796 FillNodeInfoNoDefaultMimeL( dowio, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
797 MSmlDmDDFObject::EXml, KAMInstallOptsNodeDescription ); |
|
798 dowio.AddDFTypeMimeTypeL( KInstallOptsMimeType ); |
|
799 |
|
800 /* |
|
801 Node: ./SCM/Download/<X>/ConRef |
|
802 This is a node that holds the installation options of an application. |
|
803 |
|
804 Support: Optional |
|
805 Occurs: ZeroOrOne |
|
806 Format: Xml |
|
807 Access Types: Add, Get, Replace |
|
808 Values: N/A |
|
809 */ |
|
810 MSmlDmDDFObject& dowcr = dowdyna.AddChildObjectL( KAMConRefNodeName ); |
|
811 FillNodeInfoL( dowcr, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent, |
|
812 MSmlDmDDFObject::EChr, KAMConRefNodeDescription ); |
|
813 |
|
814 /* |
|
815 Node: ./SCM/Download/<X>/Operations |
|
816 This is a node that holds the operation nodes. |
|
817 Support: Optional |
|
818 Occurs: One |
|
819 Format: Node |
|
820 Access Types: Get, Replace, Add, Delete |
|
821 Values: N/A |
|
822 |
|
823 */ |
|
824 MSmlDmDDFObject& dowop = dowdyna.AddChildObjectL( KAMOperationsNodeName ); |
|
825 FillNodeInfoL( dowop, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
826 MSmlDmDDFObject::ENode, KAMOperationsNodeDescription ); |
|
827 |
|
828 /* |
|
829 Node: ./SCM/Download/<X>/Operations/Download |
|
830 Exec command causes device to download an application. The dynamic node specifies the application to be downloaded. |
|
831 Support: Mandatory |
|
832 Occurs: One |
|
833 Format: Node |
|
834 Access Types: Exec |
|
835 Values: N/A |
|
836 */ |
|
837 MSmlDmDDFObject& dowdown = dowop.AddChildObjectL( KAMDownloadOperationNodeName ); |
|
838 FillNodeInfoL( dowdown, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
839 MSmlDmDDFObject::ENode, KAMDownloadOperationNodeDescription ); |
|
840 |
|
841 /* |
|
842 Node: ./SCM/Download/<X>/Operations/DownloadAndInstall |
|
843 Exec command causes device to download and install an application. The dynamic node specifies the application to be downloaded. |
|
844 Support: Mandatory |
|
845 Occurs: One |
|
846 Format: Node |
|
847 Access Types: Exec |
|
848 Values: N/A |
|
849 */ |
|
850 MSmlDmDDFObject& dowdowni = dowop.AddChildObjectL( KAMDownloadAndInstallNodeName ); |
|
851 FillNodeInfoL( dowdowni, accessTypesExec, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
852 MSmlDmDDFObject::ENode, KAMDownloadAndInstallOperationNodeDescription ); |
|
853 |
|
854 /* |
|
855 Node: ./SCM/Download/<X>/Operations/DownloadAndInstallAndActivate |
|
856 Exec command causes device to download and install and activate an application. The dynamic node specifies the application to be downloaded. |
|
857 Support: Mandatory |
|
858 Occurs: One |
|
859 Format: Node |
|
860 Access Types: Exec |
|
861 Values: N/A |
|
862 */ |
|
863 MSmlDmDDFObject& dowdownia = dowop.AddChildObjectL( KAMDownloadAndInstallAndActivateNodeName ); |
|
864 FillNodeInfoL( dowdownia, accessTypesExec, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
865 MSmlDmDDFObject::ENode, KAMDownloadAndInstallAndActivateNodeDescription ); |
|
866 |
|
867 /* |
|
868 Node: ./SCM/Download/<X>/Operations/DownloadAndUpdate |
|
869 Exec command causes device to download and update an application. The dynamic node specifies the application to be downloaded. |
|
870 Support: Mandatory |
|
871 Occurs: One |
|
872 Format: Node |
|
873 Access Types: Exec |
|
874 Values: N/A |
|
875 */ |
|
876 MSmlDmDDFObject& dowdownu = dowop.AddChildObjectL( KAMDownloadAndUpdateNodeName ); |
|
877 FillNodeInfoL( dowdownu, accessTypesExec, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
878 MSmlDmDDFObject::ENode, KAMDownloadAndUpdateNodeDescription ); |
|
879 |
|
880 /* |
|
881 Node: ./SCM/Download/<X>/Operations/DownloadAndUpdateAndActivate |
|
882 Exec command causes device to download and install and activate an application. The dynamic node specifies the application to be downloaded. |
|
883 Support: Mandatory |
|
884 Occurs: One |
|
885 Format: Node |
|
886 Access Types: Exec |
|
887 Values: N/A |
|
888 */ |
|
889 MSmlDmDDFObject& dowdownua = dowop.AddChildObjectL( KAMDownloadAndUpdateAndActivateNodeName ); |
|
890 FillNodeInfoL( dowdownua, accessTypesExec, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
891 MSmlDmDDFObject::ENode, KAMDownloadAndUpdateAndActivateNodeName ); |
|
892 |
|
893 |
|
894 #ifdef __AM_LASTERROR_NODE |
|
895 MSmlDmDDFObject& amext = am.AddChildObjectL( KAMExtNodeName ); |
|
896 FillNodeInfoL( amext, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
897 MSmlDmDDFObject::ENode, KAMExtNodeDescription ); |
|
898 |
|
899 MSmlDmDDFObject& amerr = amext.AddChildObjectL( KAMLastErrorNodeName ); |
|
900 FillNodeInfoL( amerr, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent, |
|
901 MSmlDmDDFObject::EChr, KAMLastErrorDescription ); |
|
902 #endif |
|
903 |
|
904 if (GetAdapterValue() == KAMSCMAdapter) |
|
905 { |
|
906 CheckStateChangesL(); |
|
907 SetAdapterValue(KAMDefaultValue); |
|
908 } |
|
909 RDEBUG( "CAmAdapter::DDFStructureL(): end" ); |
|
910 } |
|
911 |
|
912 // ------------------------------------------------------------------------------------------------ |
|
913 // CAmAdapter::SessionL() |
|
914 // ------------------------------------------------------------------------------------------------ |
|
915 RApplicationManagement &CAmAdapter::SessionL() |
|
916 { |
|
917 if ( !iSessionOpened ) |
|
918 { |
|
919 TCertInfo info ; |
|
920 |
|
921 const TUid KCentralRepositoryUid = |
|
922 { |
|
923 0x10207843 |
|
924 }; |
|
925 const TInt KCertKey = 0x01; |
|
926 CRepository *re = NULL; |
|
927 TRAPD( errx, re = CRepository::NewL ( KCentralRepositoryUid ) ); |
|
928 if (errx == KErrNone && re) |
|
929 { |
|
930 TPckg<TCertInfo> pcert( info ); |
|
931 errx = re->Get( KCertKey, pcert ) ; |
|
932 |
|
933 RDEBUG_2("aCertInfo.iFingerprint.Length() is %u",info.iFingerprint.Length() ); |
|
934 if ( errx == KErrNone ) |
|
935 { |
|
936 RDEBUG("CAmAdapter::SessionL() errx == KErrNone"); |
|
937 } |
|
938 else |
|
939 { |
|
940 if ( errx != KErrNotFound ) |
|
941 { |
|
942 RDEBUG("CAmAdapter::SessionL() errx != KErrNotFound"); |
|
943 } |
|
944 else |
|
945 { |
|
946 RDEBUG("CAmAdapter::SessionL() errx == KErrNotFound"); |
|
947 } |
|
948 |
|
949 } |
|
950 delete re ; |
|
951 } |
|
952 |
|
953 if ( errx == KErrNotFound || !iCertRequired) |
|
954 { |
|
955 RDEBUG("CAmAdapter::SessionL() calling iManagement.Connect()"); |
|
956 User::LeaveIfError( iManagement.Connect() ); |
|
957 iSessionOpened = ETrue; |
|
958 iTrustAdded = EFalse; |
|
959 } |
|
960 else |
|
961 { |
|
962 RDEBUG("CAmAdapter::SessionL() calling iManagement.Connect( info )"); |
|
963 User::LeaveIfError( iManagement.Connect( info ) ); |
|
964 iSessionOpened = ETrue; |
|
965 iTrustAdded = ETrue; |
|
966 } |
|
967 } |
|
968 return iManagement; |
|
969 } |
|
970 |
|
971 // ------------------------------------------------------------------------------------------------ |
|
972 // CAmAdapter::UpdateLeafObjectL() |
|
973 // ------------------------------------------------------------------------------------------------ |
|
974 void CAmAdapter::UpdateLeafObjectL( |
|
975 const TDesC8& aURI, |
|
976 const TDesC8& aLUID, |
|
977 const TDesC8& aObject, |
|
978 const TDesC8& aType, |
|
979 TInt aStatusRef ) |
|
980 { |
|
981 RDEBUG8_4("CAmAdapter::UpdateLeafObjectL(): begin, '%S', '%S' '%S'", &aURI, &aLUID, &aType ); |
|
982 |
|
983 MSmlDmAdapter::TError status = EOk; |
|
984 SetAdapterValue(KAMSCMAdapter); |
|
985 _UpdateLeafObjectL( aURI, aLUID, aObject, aType, aStatusRef, status); |
|
986 |
|
987 SetStatusL( aStatusRef, status ); |
|
988 if ( status == EOk ) |
|
989 { |
|
990 if ( iInAtomic ) |
|
991 { |
|
992 iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) ); |
|
993 } |
|
994 } |
|
995 RDEBUG_2("CAmAdapter::UpdateLeafObjectL(): end (%d)", status); |
|
996 } |
|
997 |
|
998 // ------------------------------------------------------------------------------------------------ |
|
999 // CAmAdapter::UpdateLeafObjectL() |
|
1000 // ------------------------------------------------------------------------------------------------ |
|
1001 void CAmAdapter::_UpdateLeafObjectL( |
|
1002 const TDesC8& aURI, |
|
1003 const TDesC8& aLUID, |
|
1004 const TDesC8& aObject, |
|
1005 const TDesC8& aType, |
|
1006 TInt /*aStatusRef*/, |
|
1007 MSmlDmAdapter::TError& aStatus ) |
|
1008 { |
|
1009 RDEBUG("CAmAdapter::_UpdateLeafObjectL(): begin"); |
|
1010 |
|
1011 CheckStateChangesL(); |
|
1012 |
|
1013 TError status( EError ); |
|
1014 |
|
1015 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
1016 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash( aURI ); |
|
1017 TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) ); |
|
1018 TPtrC8 mapping( NSmlDmURI::LastURISeg( uriPtrc ) ); |
|
1019 TPtrC8 parent( NSmlDmURI::RemoveLastSeg( uriPtrc ) ); |
|
1020 #else |
|
1021 TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) ); |
|
1022 TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) ); |
|
1023 TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) ); |
|
1024 #endif |
|
1025 |
|
1026 if (mapping == KAMNameNodeName) |
|
1027 { |
|
1028 if (aObject.Size() > KDeploymentComponentNameMaxLength) |
|
1029 { |
|
1030 aStatus = ETooLargeObject; |
|
1031 return ; |
|
1032 } |
|
1033 } |
|
1034 else if (mapping == KAMVersionNodeName) |
|
1035 { |
|
1036 if (aObject.Size() > KDeploymentComponentVersionMaxLength) |
|
1037 { |
|
1038 aStatus = ETooLargeObject; |
|
1039 return ; |
|
1040 } |
|
1041 } |
|
1042 else if(mapping == KAMConRefNodeName) |
|
1043 { |
|
1044 if (aObject.Size() > KMaxConRef) |
|
1045 { |
|
1046 aStatus = ETooLargeObject; |
|
1047 return ; |
|
1048 } |
|
1049 } |
|
1050 |
|
1051 TPtrC8 grandParent( NSmlDmURI::RemoveLastSeg( parent ) ); |
|
1052 TPtrC8 grandParentMapping( NSmlDmURI::LastURISeg( grandParent ) ); |
|
1053 RApplicationManagement &session = SessionL(); |
|
1054 TDeploymentComponentState state( EDCSNone ) ; |
|
1055 if ( numSeqs == 4 || numSeqs == 5 ) |
|
1056 { |
|
1057 if ( numSeqs == 4 ) |
|
1058 { |
|
1059 state = EDCSDownload; |
|
1060 } |
|
1061 else |
|
1062 { |
|
1063 if ( grandParentMapping == KAMDeliveredNodeName ) |
|
1064 { |
|
1065 state = EDCSDelivered; |
|
1066 } |
|
1067 else if ( grandParentMapping == KAMDeployedNodeName ) |
|
1068 { |
|
1069 state = EDCSActive; |
|
1070 } |
|
1071 else |
|
1072 { |
|
1073 RDEBUG8_3( "CAmAdapter::UpdateLeafObjectL(): ILLEGAL LEVEL %d NODE %S", numSeqs, &aURI ); |
|
1074 User::Leave( KErrArgument ); |
|
1075 } |
|
1076 } |
|
1077 } |
|
1078 else |
|
1079 { |
|
1080 RDEBUG8_3("CAmAdapter::UpdateLeafObjectL(): ILLEGAL LEVEL %d NODE %S", numSeqs, &aURI ); |
|
1081 } |
|
1082 if ( state == EDCSDelivered || state == EDCSDownload ||state == EDCSActive ||state == EDCSInactive ) |
|
1083 { |
|
1084 if ( aLUID != KNullDesC8 ) |
|
1085 { |
|
1086 TInt iluid ( DesToIntL( aLUID ) ); |
|
1087 TDeploymentComponent comp ; |
|
1088 TInt err( session.DeploymentComponent( iluid, comp ) ); |
|
1089 if ( err == KErrNone ) |
|
1090 { |
|
1091 TDeplCompAttrType fl( UpdateFlagFromMapping( mapping ) ); |
|
1092 |
|
1093 if ( mapping == KAMDataNodeName || mapping == KAMDescriptorNodeName ) |
|
1094 { |
|
1095 TInt erx(KErrNone); |
|
1096 |
|
1097 if ( iIsStreamedContent ) |
|
1098 { |
|
1099 CloseStreaming(); |
|
1100 TRAP( erx, session.UpdateDeploymentComponentStreamedDataL( iluid, fl, aType ) ); |
|
1101 } |
|
1102 else |
|
1103 { |
|
1104 // |
|
1105 TRAP( erx, session.UpdateDeploymentComponentDataL( iluid, fl, aObject, aType ) ); |
|
1106 } |
|
1107 MAPERROR( erx, status, _L8("Update Delivered Data or metadata %d") ); |
|
1108 } |
|
1109 else |
|
1110 { |
|
1111 if ( fl != EDCNone ) |
|
1112 { |
|
1113 TPtrC8 obj; |
|
1114 TAMInstallOptions opts; |
|
1115 TAMInstallOptionsPckg optsb( opts ); |
|
1116 TPckgBuf<TInt> iap; |
|
1117 if ( fl == EDCInstallOptions ) |
|
1118 { |
|
1119 InstallOptionsParser::ParseOptionsL( aObject, opts ); |
|
1120 if ( opts.iIAP == -1 && opts.iConRef != KNullDesC8() ) |
|
1121 { |
|
1122 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
1123 |
|
1124 //CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() ); |
|
1125 //opts.iIAP = iapfinder->IAPIdFromURIL( opts.iConRef ); |
|
1126 //CleanupStack::PopAndDestroy( iapfinder ); |
|
1127 CArrayFix<TSmlDmMappingInfo>* mapArray = new CArrayFixFlat<TSmlDmMappingInfo>(4); |
|
1128 CleanupStack::PushL(mapArray); |
|
1129 |
|
1130 Callback().GetMappingInfoListL( KNSmlDMMMSSlashIAPUri,*mapArray ); |
|
1131 |
|
1132 TInt iap = KErrNotFound; |
|
1133 TSmlDmMappingInfo mapInfo; |
|
1134 |
|
1135 for(TInt i = 0;i<mapArray->Count();i++) |
|
1136 { |
|
1137 if(LastURISeg(opts.iConRef)==mapArray->At(i).iURISeg) |
|
1138 { |
|
1139 iap=DesToInt(mapArray->At(i).iURISegLUID); |
|
1140 break; |
|
1141 } |
|
1142 } |
|
1143 opts.iIAP = iap; |
|
1144 mapArray->Reset(); |
|
1145 CleanupStack::PopAndDestroy(); //mapArray |
|
1146 |
|
1147 #else |
|
1148 CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() ); |
|
1149 opts.iIAP = iapfinder->IAPIdFromURIL( opts.iConRef ); |
|
1150 CleanupStack::PopAndDestroy( iapfinder ); |
|
1151 #endif |
|
1152 } |
|
1153 obj.Set( optsb ); |
|
1154 } |
|
1155 else if ( fl == EDCConRef ) |
|
1156 { |
|
1157 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
1158 |
|
1159 //CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() ); |
|
1160 //TInt i( iapfinder->IAPIdFromURIL( aObject ) ); |
|
1161 //CleanupStack::PopAndDestroy( iapfinder ); |
|
1162 //iap() = i; |
|
1163 CArrayFix<TSmlDmMappingInfo>* mapArray = new CArrayFixFlat<TSmlDmMappingInfo>(4); |
|
1164 CleanupStack::PushL(mapArray); |
|
1165 |
|
1166 Callback().GetMappingInfoListL( KNSmlDMMMSSlashIAPUri,*mapArray ); |
|
1167 |
|
1168 TInt iapValue = KErrNotFound; |
|
1169 TSmlDmMappingInfo mapInfo; |
|
1170 |
|
1171 for(TInt i = 0;i<mapArray->Count();i++) |
|
1172 { |
|
1173 if(LastURISeg(opts.iConRef)==mapArray->At(i).iURISeg) |
|
1174 { |
|
1175 iapValue=DesToInt(mapArray->At(i).iURISegLUID); |
|
1176 break; |
|
1177 } |
|
1178 } |
|
1179 iap() = iapValue; |
|
1180 mapArray->Reset(); |
|
1181 CleanupStack::PopAndDestroy(); //mapArray |
|
1182 |
|
1183 #else |
|
1184 CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() ); |
|
1185 TInt i( iapfinder->IAPIdFromURIL( aObject ) ); |
|
1186 CleanupStack::PopAndDestroy( iapfinder ); |
|
1187 iap() = i; |
|
1188 #endif |
|
1189 obj.Set( iap ); |
|
1190 } |
|
1191 else |
|
1192 { |
|
1193 obj.Set( aObject ); |
|
1194 } |
|
1195 TRAPD( erx, session.UpdateDeploymentComponentL( iluid, fl, obj ) ); |
|
1196 MAPERROR( erx, status, _L8("Update some attribute %d") ); |
|
1197 } |
|
1198 else |
|
1199 { |
|
1200 status = ENotFound; |
|
1201 RDEBUG( "CAmAdapter::UpdateLeafObjectL(): Unknown Target leaf" ); |
|
1202 } |
|
1203 } |
|
1204 } |
|
1205 else |
|
1206 { |
|
1207 RDEBUG_3( "CAmAdapter::UpdateLeafObjectL(): FAILED TO GET COMPONENT OF ID %d: %d" , iluid, err ); |
|
1208 status = ENotFound; |
|
1209 } |
|
1210 } |
|
1211 else |
|
1212 { |
|
1213 RDEBUG8_2( "CAmAdapter::UpdateLeafObjectL(): Faild to get luid allocation and find buffered for '%S'", &parent ); |
|
1214 status = ENotFound; |
|
1215 } |
|
1216 } |
|
1217 else |
|
1218 { |
|
1219 RDEBUG8_2( "CAmAdapter::UpdateLeafObjectL(): WARNING Tried to update illegal state leaf! '%S'", &grandParentMapping ); |
|
1220 } |
|
1221 |
|
1222 aStatus = status; |
|
1223 |
|
1224 RDEBUG("CAmAdapter::_UpdateLeafObjectL(): end"); |
|
1225 } |
|
1226 |
|
1227 // ------------------------------------------------------------------------------------------------ |
|
1228 // CAmAdapter::UpdateLeafObjectL |
|
1229 // ------------------------------------------------------------------------------------------------ |
|
1230 void CAmAdapter::UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, |
|
1231 RWriteStream*& aStream, const TDesC8& aType, |
|
1232 TInt aStatusRef ) |
|
1233 { |
|
1234 RDEBUG8_4("CAmAdapter::UpdateLeafObjectL() aStream: begin, '%S', '%S' '%S'", &aURI, &aLUID, &aType ); |
|
1235 |
|
1236 TError status( CSmlDmAdapter::EOk ); |
|
1237 |
|
1238 if(iStreamedURI) |
|
1239 { |
|
1240 delete iStreamedURI; |
|
1241 iStreamedURI = NULL; |
|
1242 } |
|
1243 iStreamedURI = aURI.AllocL(); |
|
1244 |
|
1245 if(iStreamedLuid) |
|
1246 { |
|
1247 delete iStreamedLuid; |
|
1248 iStreamedLuid = NULL; |
|
1249 } |
|
1250 iStreamedLuid = aLUID.AllocL(); |
|
1251 |
|
1252 if(iStreamedType) |
|
1253 { |
|
1254 delete iStreamedType; |
|
1255 iStreamedType = NULL; |
|
1256 } |
|
1257 iStreamedType = aType.AllocL(); |
|
1258 |
|
1259 if(!iStreamOpen) |
|
1260 { |
|
1261 RApplicationManagement &session = SessionL(); |
|
1262 TDeplCompAttrType attrType; |
|
1263 TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) ); |
|
1264 TDeplCompAttrType fl( UpdateFlagFromMapping( mapping ) ); |
|
1265 if ( mapping == KAMDataNodeName ) |
|
1266 { |
|
1267 attrType = EDCData; |
|
1268 } |
|
1269 else if( mapping == KAMDescriptorNodeName ) |
|
1270 { |
|
1271 attrType = EDCMetaData; |
|
1272 } |
|
1273 else |
|
1274 { |
|
1275 RDEBUG8_2("CAmAdapter::UpdateLeafObjectL(): Unknown mapping: (%S)", &mapping); |
|
1276 status = CSmlDmAdapter::EError; |
|
1277 } |
|
1278 |
|
1279 if( status == CSmlDmAdapter::EOk ) |
|
1280 { |
|
1281 TInt iluid ( DesToIntL( aLUID ) ); |
|
1282 session.DeploymentComponentTempInstFileL( iluid, iStreamFile, attrType ); |
|
1283 iStream.Attach( iStreamFile ); |
|
1284 aStream = &iStream; |
|
1285 iStreamOpen = ETrue; |
|
1286 iIsStreamedContent = ETrue; |
|
1287 } |
|
1288 } |
|
1289 if ( !iInAtomic ) |
|
1290 { |
|
1291 iStatusRef = aStatusRef; |
|
1292 Callback().SetStatusL( aStatusRef, status ); |
|
1293 } |
|
1294 else |
|
1295 { |
|
1296 iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) ); |
|
1297 } |
|
1298 |
|
1299 RDEBUG("CAmAdapter::UpdateLeafObjectL() aStream : end"); |
|
1300 } |
|
1301 |
|
1302 // ------------------------------------------------------------------------------------------------ |
|
1303 // CAmAdapter::UpdateFlagFromMapping( const TDesC8& aMapping ) |
|
1304 // ------------------------------------------------------------------------------------------------ |
|
1305 TDeplCompAttrType CAmAdapter::UpdateFlagFromMapping( const TDesC8& aMapping ) |
|
1306 { |
|
1307 |
|
1308 TDeplCompAttrType res ; |
|
1309 if ( aMapping == KAMIDNodeName ) |
|
1310 { |
|
1311 res = EDCId; |
|
1312 } |
|
1313 else if ( aMapping == KAMNameNodeName ) |
|
1314 { |
|
1315 res = EDCName; |
|
1316 } |
|
1317 else if ( aMapping == KAMVersionNodeName ) |
|
1318 { |
|
1319 res = EDCVersion; |
|
1320 } |
|
1321 else if ( aMapping == KAMStateValueNodeName ) |
|
1322 { |
|
1323 res = EDCStateValue; |
|
1324 } |
|
1325 else if ( aMapping == KAMInstallOptsNodeName ) |
|
1326 { |
|
1327 res = EDCInstallOptions; |
|
1328 } |
|
1329 else if ( aMapping == KAMDescriptorNodeName ) |
|
1330 { |
|
1331 res = EDCMetaData; |
|
1332 } |
|
1333 else if ( aMapping == KAMDataNodeName ) |
|
1334 { |
|
1335 res = EDCData; |
|
1336 } |
|
1337 else if( aMapping == KAMURINodeName ) |
|
1338 { |
|
1339 res = EDCDownloadURI; |
|
1340 } |
|
1341 else if ( aMapping == KAMStatusNodeName ) |
|
1342 { |
|
1343 res = EDCStatus; |
|
1344 } |
|
1345 else if ( aMapping == KAMConRefNodeName ) |
|
1346 { |
|
1347 res = EDCConRef; |
|
1348 } |
|
1349 else |
|
1350 { |
|
1351 //User::Leave( KErrArgument ); |
|
1352 res = EDCNone; |
|
1353 } |
|
1354 return res; |
|
1355 } |
|
1356 |
|
1357 // ------------------------------------------------------------------------------------------------ |
|
1358 // CAmAdapter::GetLuidForUserIdL( const TDesC8 &aUserId, |
|
1359 // const TDeploymentComponentState aState ) |
|
1360 // ------------------------------------------------------------------------------------------------ |
|
1361 TUint32 CAmAdapter::GetLuidForUserIdL( const TDesC8 &aUserId, const TDeploymentComponentState aState ) |
|
1362 { |
|
1363 TUint32 ret( 0 ); |
|
1364 if ( aState != EDCSNone ) |
|
1365 { |
|
1366 RElementIdArray array; |
|
1367 TInt err( SessionL().DeploymentComponentIdsL( array, aState ) ); |
|
1368 if ( err == KErrNone ) |
|
1369 { |
|
1370 CleanupClosePushL( array ); |
|
1371 TInt count( array.Count() ); |
|
1372 for( TInt i( 0 ); i < count && ret == 0; i++ ) |
|
1373 { |
|
1374 TUint32 el = array[i]; |
|
1375 TDCUserId dc; |
|
1376 SessionL().DeploymentComponentUserIdL( el, dc ); |
|
1377 if ( dc == aUserId ) |
|
1378 { |
|
1379 ret = el; |
|
1380 } |
|
1381 } |
|
1382 CleanupStack::PopAndDestroy( &array ); |
|
1383 } |
|
1384 else |
|
1385 { |
|
1386 } |
|
1387 } |
|
1388 return ret; |
|
1389 } |
|
1390 |
|
1391 // ------------------------------------------------------------------------------------------------ |
|
1392 // CAmAdapter::GetLuid2L( const TDesC8 &aDMLuid, const TDesC8 &aUserId, |
|
1393 // const TDeploymentComponentState aState, TError &aStatus ) |
|
1394 // ------------------------------------------------------------------------------------------------ |
|
1395 TUint32 CAmAdapter::GetLuid2L( const TDesC8 &aDMLuid, const TDesC8 &aUserId, |
|
1396 const TDeploymentComponentState aState, TError &aStatus ) |
|
1397 { |
|
1398 TUint32 ret( GetLuidL(aDMLuid, aUserId, aState ) ); |
|
1399 if ( (TInt32)ret <= 0 ) |
|
1400 { |
|
1401 aStatus = ENotFound; |
|
1402 } |
|
1403 return ret; |
|
1404 } |
|
1405 |
|
1406 // ------------------------------------------------------------------------------------------------ |
|
1407 // CAmAdapter::GetLuidL( const TDesC8 &aDMLuid, const TDesC8 &aUserId, |
|
1408 // const TDeploymentComponentState aState ) |
|
1409 // ------------------------------------------------------------------------------------------------ |
|
1410 TUint32 CAmAdapter::GetLuidL( const TDesC8 &aDMLuid, const TDesC8 &aUserId, |
|
1411 const TDeploymentComponentState aState ) |
|
1412 { |
|
1413 TUint32 ret( 0 ); |
|
1414 if ( aDMLuid == KNullDesC8 ) |
|
1415 { |
|
1416 ret = GetLuidForUserIdL( aUserId, aState ); |
|
1417 } |
|
1418 else |
|
1419 { |
|
1420 ret = DesToIntL( aDMLuid ) ; |
|
1421 } |
|
1422 |
|
1423 return ret; |
|
1424 } |
|
1425 |
|
1426 // ------------------------------------------------------------------------------------------------ |
|
1427 // CAmAdapter::DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID ) |
|
1428 // ------------------------------------------------------------------------------------------------ |
|
1429 void CAmAdapter::DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TInt aStatusRef ) |
|
1430 { |
|
1431 |
|
1432 RDEBUG8_4("CAmAdapter::DeleteObjectL(): begin (%S, %S, %d)" , &aURI, &aLUID, aStatusRef ); |
|
1433 SetAdapterValue(KAMSCMAdapter); |
|
1434 CheckStateChangesL(); |
|
1435 |
|
1436 TError ret( EError ); |
|
1437 |
|
1438 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
1439 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
1440 TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) ); |
|
1441 TPtrC8 mapping( NSmlDmURI::LastURISeg( uriPtrc ) ); |
|
1442 #else |
|
1443 TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) ); |
|
1444 TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) ); |
|
1445 #endif |
|
1446 |
|
1447 switch ( cnt ) |
|
1448 { |
|
1449 case 3: |
|
1450 case 4: |
|
1451 { |
|
1452 |
|
1453 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
1454 TPtrC8 which( NSmlDmURI::URISeg( uriPtrc, cnt == 4 ? 3 : 2 ) ); |
|
1455 #else |
|
1456 TPtrC8 which( NSmlDmURI::URISeg( aURI, cnt == 4 ? 3 : 2 ) ); |
|
1457 #endif |
|
1458 if ( which == KAMDeliveredNodeName || which == KAMDownloadNodeName ) |
|
1459 { |
|
1460 TUint32 luid( GetLuidL( aLUID, mapping, (which == KAMDeliveredNodeName ? EDCSDelivered : EDCSDownload) ) ); |
|
1461 if ( luid > 0 ) |
|
1462 { |
|
1463 TRAPD( err, SessionL().RemoveL( luid ) ); |
|
1464 if ( err == KErrNone || err == KErrNotFound ) |
|
1465 { |
|
1466 ret = EOk; |
|
1467 Callback().SetMappingL( aURI, KNullDesC8 ); |
|
1468 if ( err == KErrNone && iInAtomic ) |
|
1469 { |
|
1470 iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) ); |
|
1471 } |
|
1472 } |
|
1473 else |
|
1474 { |
|
1475 MAPERROR( err, ret, _L8("Delete %d") ); |
|
1476 } |
|
1477 } |
|
1478 else |
|
1479 { |
|
1480 RDEBUG( "CAmAdapter::DeleteObjectL(): WARNING Object not found" ); |
|
1481 ret = ENotFound; |
|
1482 } |
|
1483 } |
|
1484 else |
|
1485 { |
|
1486 RDEBUG8_2( "CAmAdapter::DeleteObjectL(): ERROR Removing node %S is not supported", &aURI ); |
|
1487 } |
|
1488 break; |
|
1489 } |
|
1490 default: |
|
1491 { |
|
1492 RDEBUG8_3( "CAmAdapter::DeleteObjectL(): ILLEGAL LEVEL %d NODE %S", cnt, &aURI ); |
|
1493 break; |
|
1494 } |
|
1495 } |
|
1496 SetStatusL( aStatusRef, ret ); |
|
1497 RDEBUG( "CAmAdapter::DeleteObjectL(): end" ); |
|
1498 } |
|
1499 |
|
1500 |
|
1501 // ------------------------------------------------------------------------------------------------ |
|
1502 // CAmAdapter::DeactivateIfInactive( const TUint aLuidi, const TDeploymentComponentState aTargetState ) |
|
1503 // ------------------------------------------------------------------------------------------------ |
|
1504 void CAmAdapter::DeactivateIfInactive( const TUint aLuidi, const TDeploymentComponentState aTargetState ) |
|
1505 { |
|
1506 if ( aTargetState == EDCSInactive ) |
|
1507 { |
|
1508 RDEBUG( "CAmAdapter::DeactivateIfInactive(): deactivating!" ); |
|
1509 TRAPD( derr, iManagement.DeactivateL( aLuidi ) ); |
|
1510 if ( derr != KErrNone ) |
|
1511 { |
|
1512 RDEBUG_2("CAmAdapter::DeactivateIfInactive(): ERROR deactivating failed %d", derr ); |
|
1513 } |
|
1514 } |
|
1515 } |
|
1516 |
|
1517 void CAmAdapter::InstallL( |
|
1518 TUint aLuidi, |
|
1519 const TDesC8& aURI, |
|
1520 const TDesC8& aLUID, |
|
1521 const TDeploymentComponentState aTargetState, |
|
1522 TError &aRet |
|
1523 ) |
|
1524 { |
|
1525 |
|
1526 |
|
1527 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
1528 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
1529 #else |
|
1530 //nothing |
|
1531 #endif |
|
1532 |
|
1533 TRAPD( err, SessionL().InstallL( aLuidi, aTargetState ) ); |
|
1534 if ( err == KErrNone ) |
|
1535 { |
|
1536 // Dont Update the mappings in client to reflect new |
|
1537 // position in the management tree ( Inactive or Active..) |
|
1538 RDEBUG( "CAmAdapter::InstallL(): Install success!" ); |
|
1539 |
|
1540 //TPtrC8 aclmapping( URISegsUpTo( aURI, 4) ); |
|
1541 //SetMappingL( aclmapping, aTargetState, aLUID); |
|
1542 //iManagement.StateChangeComplete( aLuidi ); |
|
1543 |
|
1544 |
|
1545 |
|
1546 DeactivateIfInactive( aLuidi, aTargetState ); |
|
1547 aRet = EOk; |
|
1548 } |
|
1549 else |
|
1550 { |
|
1551 RDEBUG_2( "CAmAdapter::InstallL(): INSTALL FAILED '%d'" , err); |
|
1552 MAPERROR( err, aRet, _L8("Install %d") ); |
|
1553 } |
|
1554 } |
|
1555 |
|
1556 |
|
1557 // ------------------------------------------------------------------------------------------------ |
|
1558 // CAmAdapter::DefaultMapError( const TInt aErr, TError &aRet ) |
|
1559 // ------------------------------------------------------------------------------------------------ |
|
1560 void CAmAdapter::DefaultMapError( const TInt aErr, TError &aRet, const TDesC8& |
|
1561 #ifdef __AM_LASTERROR_NODE |
|
1562 aDes |
|
1563 #endif |
|
1564 ) |
|
1565 { |
|
1566 if ( aErr == KErrNone ) |
|
1567 { |
|
1568 aRet = EOk; |
|
1569 } |
|
1570 else if ( aErr == KErrNotFound ) |
|
1571 { |
|
1572 aRet = ENotFound; |
|
1573 } |
|
1574 else if ( aErr == KErrArgument ) |
|
1575 { |
|
1576 aRet = EInvalidObject ; |
|
1577 } |
|
1578 else if( aErr == KErrAlreadyExists ) |
|
1579 { |
|
1580 aRet = EAlreadyExists; |
|
1581 } |
|
1582 else |
|
1583 { |
|
1584 aRet = EError; |
|
1585 } |
|
1586 #ifdef __AM_LASTERROR_NODE |
|
1587 TInt err = KErrNone; |
|
1588 TRAP( err, SetErrorL( aDes, aErr ) ); |
|
1589 #endif |
|
1590 } |
|
1591 |
|
1592 #ifdef __AM_LASTERROR_NODE |
|
1593 void CAmAdapter::SetErrorL( const TDesC8& aDes, const TInt aErr ) |
|
1594 { |
|
1595 if ( aDes != KNullDesC8 ) |
|
1596 { |
|
1597 SetLastErrorL( aDes, aErr ); |
|
1598 } |
|
1599 else |
|
1600 { |
|
1601 SetLastErrorL(KStdError, aErr); |
|
1602 } |
|
1603 } |
|
1604 #endif |
|
1605 |
|
1606 |
|
1607 // ------------------------------------------------------------------------------------------------ |
|
1608 // CAmAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aArgument, |
|
1609 // const TDesC8& aType, |
|
1610 // TInt aStatusRef ) |
|
1611 // ------------------------------------------------------------------------------------------------ |
|
1612 TDownloadTarget CAmAdapter::DownloadTargetL( const TDesC8& aCommand ) |
|
1613 { |
|
1614 if ( aCommand == KAMDownloadOperationNodeName ) |
|
1615 { |
|
1616 return EDeliver; |
|
1617 } |
|
1618 else if ( aCommand == KAMDownloadAndInstallNodeName ) |
|
1619 { |
|
1620 return EInstall; |
|
1621 } |
|
1622 else if ( aCommand == KAMDownloadAndInstallAndActivateNodeName ) |
|
1623 { |
|
1624 return EInstallAndActivate; |
|
1625 } |
|
1626 else if ( aCommand == KAMDownloadAndUpdateNodeName ) |
|
1627 { |
|
1628 return EUpdate; |
|
1629 } |
|
1630 else if ( aCommand == KAMDownloadAndUpdateAndActivateNodeName ) |
|
1631 { |
|
1632 return EUpdateAndActivate; |
|
1633 } |
|
1634 |
|
1635 RDEBUG8_2( "CAmAdapter::DownloadTargetL(): ASKED OPERATION NOT SUPPORTED Download '%S'", &aCommand ); |
|
1636 User::Leave( KErrArgument ); |
|
1637 // NOTE! will not ever come here! Only to get rid of compiler warning !! |
|
1638 return EDeliver; |
|
1639 } |
|
1640 |
|
1641 // ------------------------------------------------------------------------------------------------ |
|
1642 // CAmAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aArgument, |
|
1643 // const TDesC8& aType, |
|
1644 // TInt aStatusRef ) |
|
1645 // ------------------------------------------------------------------------------------------------ |
|
1646 void CAmAdapter::ExecuteCommandL( const TDesC8& aURI, |
|
1647 const TDesC8& aLUID, |
|
1648 const TDesC8& /*aArgument*/, |
|
1649 const TDesC8& /*aType*/, |
|
1650 TInt aStatusRef ) |
|
1651 { |
|
1652 |
|
1653 |
|
1654 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
1655 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
1656 #else |
|
1657 //nothing |
|
1658 #endif |
|
1659 |
|
1660 RDEBUG8_3("CAmAdapter::ExecuteCommandL(): begin, '%S', '%S'", &aURI, &aLUID ); |
|
1661 SetAdapterValue(KAMSCMAdapter); |
|
1662 CheckStateChangesL(); |
|
1663 TError ret( EError ); |
|
1664 |
|
1665 if( aLUID == KNullDesC8 ) |
|
1666 { |
|
1667 RDEBUG("CAmAdapter::ExecuteCommandL(): WARNING no valid luid provided" ); |
|
1668 } |
|
1669 |
|
1670 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
1671 TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) ); |
|
1672 #else |
|
1673 TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) ); |
|
1674 #endif |
|
1675 |
|
1676 TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) ); |
|
1677 |
|
1678 const TInt KDownloadMappingURILoc = 3; |
|
1679 switch ( cnt ) |
|
1680 { |
|
1681 case 5: |
|
1682 { |
|
1683 TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KDownloadMappingURILoc), EDCSDownload ) ) ; |
|
1684 |
|
1685 // Track the Newly added delivered node to make sure that this reference |
|
1686 // of delivered node is removed from Tree DB. |
|
1687 // This delivered node is removed only if Execute command is successful |
|
1688 // by either adding Install, Install& activate etc. |
|
1689 // This Fix would be applicable in case of DM 1.2. |
|
1690 |
|
1691 |
|
1692 |
|
1693 TPtrC8 urival(URISegsUpTo(aURI, KDownloadMappingURILoc)); |
|
1694 |
|
1695 if(iUriDel) |
|
1696 { |
|
1697 delete iUriDel; |
|
1698 iUriDel = NULL; |
|
1699 } |
|
1700 |
|
1701 |
|
1702 |
|
1703 iUriDel = urival.AllocL(); |
|
1704 |
|
1705 RDEBUG_2("CAmAdapter::ExecuteCommandL(): luid is %d", iluid ); |
|
1706 if ( iluid > 0 ) |
|
1707 { |
|
1708 TDownloadTarget target = DownloadTargetL( mapping ); |
|
1709 |
|
1710 TRAPD( errx, SessionL().StartDownloadL( iluid, target ) ); |
|
1711 |
|
1712 |
|
1713 /*if(target == EInstall || target == EInstallAndActivate || target == EUpdate || target == EUpdateAndActivate) |
|
1714 { |
|
1715 TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, *iUriDel, ETrue ) ); |
|
1716 }*/ |
|
1717 if ( errx == KErrNone ) |
|
1718 { |
|
1719 RDEBUG( "CAmAdapter::ExecuteCommandL(): StartDownloadL Successful " ); |
|
1720 ret = EOk; |
|
1721 } |
|
1722 else |
|
1723 { |
|
1724 RDEBUG_2( "CAmAdapter::ExecuteCommandL(): StartDownloadL FAILED '%d'", errx ); |
|
1725 if ( errx == KErrNotFound ) |
|
1726 { |
|
1727 ret = ENotFound; |
|
1728 } |
|
1729 else if ( errx == KErrArgument ) |
|
1730 { |
|
1731 ret = EInvalidObject ; |
|
1732 } |
|
1733 else |
|
1734 { |
|
1735 ret = EError; |
|
1736 } |
|
1737 } |
|
1738 |
|
1739 } |
|
1740 else |
|
1741 { |
|
1742 ret = ENotFound; |
|
1743 RDEBUG( "CAmAdapter::ExecuteCommandL(): case 5 Not found node" ); |
|
1744 } |
|
1745 break; |
|
1746 } |
|
1747 case 6: |
|
1748 { |
|
1749 const TInt KInventoryMappingURILoc = 4 ; |
|
1750 |
|
1751 |
|
1752 // Track the Newly added delivered node to make sure that this reference |
|
1753 // of delivered node is removed from Tree DB. |
|
1754 // This delivered node is removed only if Execute command is successful |
|
1755 // by either adding Install, Install& activate etc. |
|
1756 // This Fix would be applicable in case of DM 1.2. |
|
1757 |
|
1758 |
|
1759 TPtrC8 urival(URISegsUpTo(aURI, KInventoryMappingURILoc)); |
|
1760 |
|
1761 if(iUriDel) |
|
1762 { |
|
1763 delete iUriDel; |
|
1764 iUriDel = NULL; |
|
1765 } |
|
1766 |
|
1767 |
|
1768 |
|
1769 iUriDel = urival.AllocL(); |
|
1770 |
|
1771 if ( mapping == KAMInstallNodeName || mapping == KAMInstallAndActivateNodeName ) |
|
1772 { |
|
1773 TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSDelivered ) ) ; |
|
1774 if( iluid > 0 ) |
|
1775 { |
|
1776 TDeploymentComponentState targetstate = ((mapping == KAMInstallNodeName) ? EDCSInactive : EDCSActive); |
|
1777 InstallL( iluid, aURI, aLUID, targetstate, ret ); |
|
1778 |
|
1779 //TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, *iUriDel, iluid ) ); |
|
1780 } |
|
1781 else |
|
1782 { |
|
1783 ret = ENotFound; |
|
1784 RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 install Not found node" ); |
|
1785 } |
|
1786 } |
|
1787 else if ( mapping == KAMRemoveNodeName ) |
|
1788 { |
|
1789 TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSDelivered ) ) ; |
|
1790 if ( (TInt32)iluid <= 0 ) |
|
1791 { |
|
1792 iluid = GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSActive ) ; |
|
1793 if ( (TInt32)iluid <= 0 ) |
|
1794 { |
|
1795 iluid = GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSInactive ) ; |
|
1796 } |
|
1797 } |
|
1798 if( iluid > 0 ) |
|
1799 { |
|
1800 TRAPD( err, SessionL().RemoveL( iluid ) ); |
|
1801 if ( err == KErrNone ) |
|
1802 { |
|
1803 RDEBUG( "CAmAdapter::ExecuteCommandL(): Remove success!" ); |
|
1804 TPtrC8 aclmapping( URISegsUpTo( aURI, 4) ); |
|
1805 |
|
1806 // "Nullify" the mapping for argument |
|
1807 DirectSetMappingL( aclmapping, KNullDesC8 ); |
|
1808 ret = EOk; |
|
1809 if ( iInAtomic ) |
|
1810 { |
|
1811 iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) ); |
|
1812 } |
|
1813 } |
|
1814 else |
|
1815 { |
|
1816 RDEBUG_2( "CAmAdapter::ExecuteCommandL(): Remove FAILED '%d'", err); |
|
1817 |
|
1818 MAPERROR( err, ret, _L8("Execute Remove %d") ); |
|
1819 } |
|
1820 } |
|
1821 else |
|
1822 { |
|
1823 ret = ENotFound; |
|
1824 RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 remove Not found node" ); |
|
1825 } |
|
1826 } |
|
1827 else if ( mapping == KAMUpdateNodeName ) |
|
1828 { |
|
1829 RDEBUG8_2( "CAmAdapter::ExecuteCommandL(): Update: '%S'", &mapping ); |
|
1830 TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSDelivered ) ) ; |
|
1831 if( iluid > 0 ) |
|
1832 { |
|
1833 UpdateL( iluid, aURI, aLUID, EDCSInactive, ret ); |
|
1834 //TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, *iUriDel, iluid ) ); |
|
1835 } |
|
1836 else |
|
1837 { |
|
1838 ret = ENotFound; |
|
1839 RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 Update Not found node" ); |
|
1840 } |
|
1841 } |
|
1842 else if ( mapping == KAMUpdateAndActivateNodeName ) |
|
1843 { |
|
1844 RDEBUG8_2( "CAmAdapter::ExecuteCommandL(): UpdateAndActivate: '%S'", &mapping ); |
|
1845 TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSDelivered ) ) ; |
|
1846 if( iluid > 0 ) |
|
1847 { |
|
1848 UpdateL( iluid, aURI, aLUID, EDCSActive, ret ); |
|
1849 //TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, *iUriDel, iluid ) ); |
|
1850 } |
|
1851 else |
|
1852 { |
|
1853 ret = ENotFound; |
|
1854 RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 UpdateAndActivate Not found node" ); |
|
1855 } |
|
1856 } |
|
1857 else if ( mapping == KAMActivateNodeName ) |
|
1858 { |
|
1859 //DBG_ARGS8( "CAmAdapter::ExecuteCommandL(): Activating " ); |
|
1860 TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSActive ) ); |
|
1861 if ( (TInt32)iluid <= 0 ) |
|
1862 { |
|
1863 iluid = GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSInactive ) ; |
|
1864 } |
|
1865 if( iluid > 0 ) |
|
1866 { |
|
1867 TRAPD( erx, SessionL().ActivateL( iluid ) ); |
|
1868 |
|
1869 MAPERROR( erx, ret, _L8("Activate %d") ); |
|
1870 } |
|
1871 else |
|
1872 { |
|
1873 ret = ENotFound; |
|
1874 RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 Activate Not found node" ); |
|
1875 } |
|
1876 } |
|
1877 else if ( mapping == KAMDeActivateNodeName ) |
|
1878 { |
|
1879 //DBG_ARGS8( "CAmAdapter::ExecuteCommandL(): Inactivating " ); |
|
1880 TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSActive ) ); |
|
1881 if ( (TInt32)iluid <= 0 ) |
|
1882 { |
|
1883 iluid = GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSInactive ) ; |
|
1884 } |
|
1885 if( iluid > 0 ) |
|
1886 { |
|
1887 TRAPD( erx, SessionL().DeactivateL( iluid ) ); |
|
1888 |
|
1889 MAPERROR( erx, ret,_L8("Dectivate %d") ); |
|
1890 } |
|
1891 else |
|
1892 { |
|
1893 ret = ENotFound; |
|
1894 RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 DeActivate Not found node" ); |
|
1895 } |
|
1896 } |
|
1897 else |
|
1898 { |
|
1899 RDEBUG8_2( "CAmAdapter::ExecuteCommandL(): ASKED NOT SUPPORTED OPERATION '%S'", &mapping ); |
|
1900 User::Leave( KErrArgument ); |
|
1901 } |
|
1902 break; |
|
1903 } |
|
1904 |
|
1905 default: |
|
1906 { |
|
1907 RDEBUG8_3( "CAmAdapter::ExecuteCommandL(): ILLEGAL LEVEL %d NODE %S", cnt, &aURI ); |
|
1908 User::Leave( KErrArgument ); |
|
1909 break; |
|
1910 } |
|
1911 } |
|
1912 SetStatusL( aStatusRef, ret ) ; |
|
1913 } |
|
1914 |
|
1915 |
|
1916 |
|
1917 // ------------------------------------------------------------------------------------------------ |
|
1918 // CAmAdapter::UpdateL( |
|
1919 // const TUint aLuidi, |
|
1920 // const TDesC8& aURI, |
|
1921 // const TDesC8& aSourceLUID, |
|
1922 // const TDeploymentComponentState aTargetState, |
|
1923 // TError &aRet |
|
1924 // ------------------------------------------------------------------------------------------------ |
|
1925 void CAmAdapter::UpdateL( |
|
1926 const TUint aLuidi, |
|
1927 const TDesC8& aURI, |
|
1928 const TDesC8& aSourceLUID, |
|
1929 const TDeploymentComponentState aTargetState, |
|
1930 TError &aRet |
|
1931 ) |
|
1932 { |
|
1933 |
|
1934 |
|
1935 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
1936 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
1937 #else |
|
1938 //nothing |
|
1939 #endif |
|
1940 |
|
1941 CBufBase *delivered = CBufFlat::NewL( 128 ); |
|
1942 CleanupStack::PushL( delivered ); |
|
1943 |
|
1944 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
1945 TPtrC8 aclmapping( NSmlDmURI::URISeg( uriPtrc, 4 ) ); |
|
1946 #else |
|
1947 TPtrC8 aclmapping( NSmlDmURI::URISeg( aURI, 4 ) ); |
|
1948 #endif |
|
1949 |
|
1950 |
|
1951 HBufC8 *targetURI = HBufC8::NewLC( KDeployedURI().Length() + aclmapping.Length() ); |
|
1952 |
|
1953 TPtr8 targetPtr( targetURI->Des() ); |
|
1954 targetPtr.Copy( KDeployedURI ); |
|
1955 targetPtr.Append( aclmapping ); |
|
1956 |
|
1957 HBufC8 *deployed = Callback().GetLuidAllocL( targetPtr ) ; |
|
1958 CleanupStack::PushL( deployed ); |
|
1959 |
|
1960 //DBG_ARGS8( "CAmAdapter::UpdateL(): Updating '%S' luid: '%S'" ), &targetPtr, &(*deployed)); |
|
1961 if ( *deployed == KNullDesC8 ) |
|
1962 { |
|
1963 //DBG_ARGS8( "CAmAdapter::UpdateL(): Failed to find to update target '%S'" ), &targetPtr ); |
|
1964 aRet = EError; |
|
1965 } |
|
1966 else |
|
1967 { |
|
1968 // Found delivered & active or inactive components! Do update! |
|
1969 TInt depluid( DesToIntL( *deployed ) ); |
|
1970 TRAPD( erx, SessionL().UpdateL( aLuidi, depluid ) ); |
|
1971 MAPERROR( erx, aRet,_L8("Update %d") ); |
|
1972 if ( erx == KErrNone ) |
|
1973 { |
|
1974 //SetMappingLC( aclmapping, aTargetState, aSourceLUID, targetURI ); |
|
1975 DeactivateIfInactive( aLuidi, aTargetState ); |
|
1976 } |
|
1977 } |
|
1978 CleanupStack::PopAndDestroy( deployed ) ; |
|
1979 CleanupStack::PopAndDestroy( targetURI ) ; |
|
1980 CleanupStack::PopAndDestroy( delivered ) ; |
|
1981 } |
|
1982 |
|
1983 |
|
1984 // ------------------------------------------------------------------------------------------------ |
|
1985 // CAmAdapter::CheckStateL( const TDeploymentComponent &aComp, const TDesC8& aURI |
|
1986 // ------------------------------------------------------------------------------------------------ |
|
1987 TBool CAmAdapter::CheckStateL( const TDeploymentComponent &aComp, const TDesC8& aURI ) |
|
1988 { |
|
1989 // Scenarios like "./SCM/Download/Node1/Operations/Install" NumOfURISegs won't work. |
|
1990 |
|
1991 TBool ret; |
|
1992 if ((aComp.iState == EDCSDelivered) || (aComp.iState == EDCSActive) || ( aComp.iState == EDCSInactive) || (aComp.iState == EDCSDownload)) |
|
1993 { |
|
1994 // Check for map & __TARM_SYMBIAN_CONVERGENCY also ? |
|
1995 ret = ETrue; |
|
1996 } |
|
1997 else |
|
1998 ret = EFalse; |
|
1999 return ret; |
|
2000 #if 0 |
|
2001 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2002 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
2003 TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) ) ; |
|
2004 #else |
|
2005 TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) ) ; |
|
2006 #endif |
|
2007 |
|
2008 TBool ret( EFalse ); |
|
2009 //TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) ) ; |
|
2010 if ( cnt == 4 ) |
|
2011 { |
|
2012 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2013 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
2014 TPtrC8 map( NSmlDmURI::URISeg( uriPtrc, 3 ) ); |
|
2015 #else |
|
2016 TPtrC8 map( NSmlDmURI::URISeg( aURI, 3 ) ); |
|
2017 #endif |
|
2018 switch ( aComp.iState ) |
|
2019 { |
|
2020 case EDCSDelivered: |
|
2021 ret = (map == KAMDeliveredNodeName); |
|
2022 break; |
|
2023 case EDCSActive: |
|
2024 case EDCSInactive: |
|
2025 ret = (map == KAMDeployedNodeName); |
|
2026 break; |
|
2027 default: |
|
2028 ret = EFalse; |
|
2029 break; |
|
2030 } |
|
2031 } |
|
2032 else if ( cnt == 3 ) |
|
2033 { |
|
2034 if ( NSmlDmURI::URISeg( aURI, 2 ) == KAMDownloadNodeName && aComp.iState == EDCSDownload) |
|
2035 { |
|
2036 ret = ETrue; |
|
2037 } |
|
2038 } |
|
2039 return ret; |
|
2040 #endif |
|
2041 } |
|
2042 |
|
2043 |
|
2044 // ------------------------------------------------------------------------------------------------ |
|
2045 // CAmAdapter::StateL( const TDeploymentComponent &aComp, const TDesC8& aURI |
|
2046 // ------------------------------------------------------------------------------------------------ |
|
2047 TDeploymentComponentState CAmAdapter::StateL( const TDesC8& aURI ) |
|
2048 { |
|
2049 |
|
2050 |
|
2051 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2052 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
2053 #else |
|
2054 //nothing |
|
2055 #endif |
|
2056 |
|
2057 TDeploymentComponentState ret( EDCSNone ); |
|
2058 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2059 TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) ) ; |
|
2060 #else |
|
2061 TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) ) ; |
|
2062 #endif |
|
2063 if ( cnt > 2) |
|
2064 { |
|
2065 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2066 TPtrC8 map( NSmlDmURI::URISeg( uriPtrc, 2 ) ); |
|
2067 #else |
|
2068 TPtrC8 map( NSmlDmURI::URISeg( aURI, 2 ) ); |
|
2069 #endif |
|
2070 if ( map == KAMInventoryNodeName ) |
|
2071 { |
|
2072 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2073 TPtrC8 map( NSmlDmURI::URISeg( uriPtrc, 2 ) ); |
|
2074 #else |
|
2075 TPtrC8 map( NSmlDmURI::URISeg( aURI, 2 ) ); |
|
2076 #endif |
|
2077 map.Set( NSmlDmURI::URISeg( aURI, 3 ) ); |
|
2078 if ( map == KAMDeployedNodeName ) |
|
2079 { |
|
2080 |
|
2081 } |
|
2082 else if ( map == KAMDeliveredNodeName ) |
|
2083 { |
|
2084 ret = EDCSDelivered; |
|
2085 } |
|
2086 else |
|
2087 { |
|
2088 User::Leave( KErrArgument ); |
|
2089 } |
|
2090 } |
|
2091 else if( map == KAMDownloadNodeName ) |
|
2092 { |
|
2093 ret = EDCSDownload; |
|
2094 } |
|
2095 else |
|
2096 { |
|
2097 User::Leave( KErrArgument ); |
|
2098 } |
|
2099 } |
|
2100 return ret; |
|
2101 } |
|
2102 |
|
2103 |
|
2104 // ------------------------------------------------------------------------------------------------ |
|
2105 // CAmAdapter::CheckStateL( const TDesC8& aURI, const TDesC8& aLUID ) |
|
2106 // ------------------------------------------------------------------------------------------------ |
|
2107 TBool CAmAdapter::CheckStateL( const TDesC8& aURI, const TDesC8& aLUID ) |
|
2108 { |
|
2109 |
|
2110 |
|
2111 TUint32 iluid( DesToIntL( aLUID ) ); |
|
2112 TDeploymentComponent comp ; |
|
2113 TInt err( SessionL().DeploymentComponent( iluid, comp ) ); |
|
2114 TBool ret( EFalse ); |
|
2115 if ( err == KErrNone ) |
|
2116 { |
|
2117 ret = CheckStateL( comp, aURI ); |
|
2118 } |
|
2119 return ret; |
|
2120 } |
|
2121 |
|
2122 // ------------------------------------------------------------------------------------------------ |
|
2123 // CAmAdapter::InstallOptionsDataL(const TUint32 iluid, const TDeplCompAttrType& aDataType, |
|
2124 // CBufBase &aBuf, CBufBase *aRaw/*= NULL*/) |
|
2125 // ------------------------------------------------------------------------------------------------ |
|
2126 void CAmAdapter::InstallOptionsDataL(const TUint32 iluid, const TDeplCompAttrType& aDataType, |
|
2127 CBufBase &aBuf, CBufBase *aRaw/*= NULL*/) |
|
2128 { |
|
2129 TAMInstallOptionsPckgBuf iop; |
|
2130 TBool pushed( EFalse ); |
|
2131 if ( !aRaw ) |
|
2132 { |
|
2133 aRaw = CBufFlat::NewL(32); |
|
2134 CleanupStack::PushL( aRaw ); |
|
2135 pushed = ETrue; |
|
2136 SessionL().DeploymentComponentDataL( iluid, aDataType, *aRaw ); |
|
2137 } |
|
2138 |
|
2139 iop.Copy( aRaw->Ptr( 0 ) ); |
|
2140 if ( pushed ) |
|
2141 { |
|
2142 CleanupStack::PopAndDestroy( aRaw ); |
|
2143 } |
|
2144 InstallOptionsParser::SerializeOptionsL( iop(), aBuf); |
|
2145 } |
|
2146 |
|
2147 |
|
2148 // ------------------------------------------------------------------------------------------------ |
|
2149 // CAmAdapter::GetComponentDataL( const TDesC8& parent, const TDesC8& mapping, |
|
2150 // const TUint32 iluid, CBufBase *currentList, CBufBase *currentMime, TError &status ) |
|
2151 // ------------------------------------------------------------------------------------------------ |
|
2152 void CAmAdapter::GetComponentDataL( const TDesC8& parent, const TDesC8& mapping, |
|
2153 const TUint32 iluid, CBufBase ¤tList, CBufBase ¤tMime, TError &status ) |
|
2154 { |
|
2155 TDeploymentComponent comp ; |
|
2156 TInt err( SessionL().DeploymentComponent( iluid, comp ) ); |
|
2157 if ( err == KErrNone ) |
|
2158 { |
|
2159 RDEBUG_3( "CAmAdapter::GetComponentDataL(): DeploymentComponent response: %d, state: %d", err, comp.iState ); |
|
2160 if ( CheckStateL( comp, parent ) ) |
|
2161 { |
|
2162 if ( mapping == KAMIDNodeName ) |
|
2163 { |
|
2164 currentList.InsertL( 0, comp.iId ); |
|
2165 status = EOk; |
|
2166 } |
|
2167 else if ( mapping == KAMNameNodeName ) |
|
2168 { |
|
2169 currentList.InsertL( 0, comp.iName ); |
|
2170 status = EOk; |
|
2171 } |
|
2172 else if ( mapping == KAMVersionNodeName ) |
|
2173 { |
|
2174 currentList.InsertL( 0, comp.iVersion ); |
|
2175 status = EOk; |
|
2176 } |
|
2177 else |
|
2178 { |
|
2179 TDeplCompAttrType dataType( UpdateFlagFromMapping( mapping ) ); |
|
2180 if ( comp.iState == EDCSDownload ) |
|
2181 { |
|
2182 if ( dataType == EDCDownloadURI || dataType == EDCStatus) |
|
2183 { |
|
2184 SessionL().DeploymentComponentDataL( iluid, dataType, currentList ); |
|
2185 status = EOk ; |
|
2186 } |
|
2187 else if ( dataType == EDCInstallOptions ) |
|
2188 { |
|
2189 InstallOptionsDataL( iluid, dataType, currentList ); |
|
2190 status = EOk; |
|
2191 } |
|
2192 else if ( dataType == EDCConRef ) |
|
2193 { |
|
2194 CBufBase *b = CBufFlat::NewL(4); |
|
2195 CleanupStack::PushL( b ); |
|
2196 SessionL().DeploymentComponentDataL( iluid, dataType, *b); |
|
2197 TPckgBuf<TInt> iap; |
|
2198 iap.Copy( b->Ptr( 0 ) ); |
|
2199 CleanupStack::PopAndDestroy( b ); |
|
2200 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2201 |
|
2202 CArrayFix<TSmlDmMappingInfo>* mapArray = new CArrayFixFlat<TSmlDmMappingInfo>(4); |
|
2203 CleanupStack::PushL(mapArray); |
|
2204 |
|
2205 Callback().GetMappingInfoListL( KNSmlDMMMSSlashIAPUri,*mapArray ); |
|
2206 |
|
2207 //TInt iap = KErrNotFound; |
|
2208 TSmlDmMappingInfo mapInfo; |
|
2209 HBufC8 * uri = NULL; |
|
2210 TPtr8 tempURI(uri->Des()); |
|
2211 |
|
2212 for(TInt i = 0;i<mapArray->Count();i++) |
|
2213 { |
|
2214 if(iap()==DesToInt(mapArray->At(i).iURISegLUID)) |
|
2215 { |
|
2216 tempURI=mapArray->At(i).iURISeg; |
|
2217 } |
|
2218 |
|
2219 } |
|
2220 mapArray->Reset(); |
|
2221 CleanupStack::PopAndDestroy(); //mapArray |
|
2222 if ( uri != NULL ) |
|
2223 { |
|
2224 CleanupStack::PushL( uri ) ; |
|
2225 currentList.InsertL( 0, *uri ); |
|
2226 CleanupStack::PopAndDestroy( uri ) ; |
|
2227 } |
|
2228 |
|
2229 #else |
|
2230 |
|
2231 CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() ); |
|
2232 HBufC8 * uri = iapfinder->URIFromIAPIdL( iap() ) ; |
|
2233 CleanupStack::PopAndDestroy( iapfinder ); |
|
2234 if ( uri != NULL ) |
|
2235 { |
|
2236 CleanupStack::PushL( uri ) ; |
|
2237 currentList.InsertL( 0, *uri ); |
|
2238 CleanupStack::PopAndDestroy( uri ) ; |
|
2239 } |
|
2240 |
|
2241 #endif |
|
2242 status = EOk; |
|
2243 } |
|
2244 else |
|
2245 { |
|
2246 RDEBUG8_2( "CAmAdapter::GetComponentDataL(): ASKED NOT SUPPORTED LEAF '%S'", &mapping ); |
|
2247 } |
|
2248 } |
|
2249 else if ( comp.iState == EDCSDelivered ) |
|
2250 { |
|
2251 if ( dataType == EDCData || dataType == EDCMetaData || dataType == EDCInstallOptions) |
|
2252 { |
|
2253 CBufBase *raw = CBufFlat::NewL( 128 ); |
|
2254 CleanupStack::PushL( raw ); |
|
2255 SessionL().DeploymentComponentDataL( iluid, dataType, *raw ); |
|
2256 TPtrC8 source( raw->Ptr(0) ); |
|
2257 if ( source.Length() > 0 ) |
|
2258 { |
|
2259 if ( dataType == EDCData ) |
|
2260 { |
|
2261 currentList.InsertL( 0, source ); |
|
2262 SessionL().DeploymentComponentDataL( iluid, EDCDataMime, currentMime ); |
|
2263 |
|
2264 } |
|
2265 else if ( dataType == EDCInstallOptions ) |
|
2266 { |
|
2267 InstallOptionsDataL( iluid, dataType, currentList, raw ); |
|
2268 } |
|
2269 else |
|
2270 { |
|
2271 currentList.InsertL( 0, source ); |
|
2272 SessionL().DeploymentComponentDataL( iluid, EDCMetaDataMime, currentMime ); |
|
2273 } |
|
2274 } |
|
2275 else |
|
2276 { |
|
2277 // 0 data length... |
|
2278 } |
|
2279 status = EOk; |
|
2280 CleanupStack::PopAndDestroy( raw ); |
|
2281 RDEBUG8_2( "CAmAdapter::GetComponentDataL(): DeploymentComponentDataL called '%S'", &mapping ); |
|
2282 } |
|
2283 } |
|
2284 else if ( dataType == EDCStateValue ) |
|
2285 { |
|
2286 if ( comp.iState == EDCSActive ) |
|
2287 { |
|
2288 currentList.InsertL( 0, KAMStateValueActive() ); |
|
2289 } |
|
2290 else |
|
2291 { |
|
2292 currentList.InsertL( 0, KAMStateValueInactive() ); |
|
2293 } |
|
2294 status = EOk; |
|
2295 } |
|
2296 else |
|
2297 { |
|
2298 RDEBUG8_2( "CAmAdapter::GetComponentDataL(): ERROR ASKED NOT SUPPORTED LEAF '%S'", &mapping ); |
|
2299 } |
|
2300 } |
|
2301 } |
|
2302 else |
|
2303 { |
|
2304 RDEBUG8_3( "CAmAdapter::GetComponentDataL(): WARNING Asked illegal state leaf '%S', %d", &mapping, comp.iState ); |
|
2305 status = ENotFound; |
|
2306 } |
|
2307 } |
|
2308 else |
|
2309 { |
|
2310 RDEBUG_3( "CAmAdapter::GetComponentDataL(): ERROR FAILED TO GET COMPOMENT OF ID %d: %d", iluid, err ); |
|
2311 MAPERROR( err, status,_L8("Get Component %d") ); |
|
2312 } |
|
2313 } |
|
2314 |
|
2315 // ------------------------------------------------------------------------------------------------ |
|
2316 // CAmAdapter::GetLeafLuidL(const TDesC8 &aURI, const TDesC8 & aParentMapping ) |
|
2317 // ------------------------------------------------------------------------------------------------ |
|
2318 TInt CAmAdapter::GetLeafLuidL(const TDesC8 &aURI, const TDesC8 & aParentMapping ) |
|
2319 { |
|
2320 |
|
2321 |
|
2322 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2323 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
2324 TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) ); |
|
2325 #else |
|
2326 TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) ); |
|
2327 #endif |
|
2328 |
|
2329 TUint32 iluid( 0 ); |
|
2330 //TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) ); |
|
2331 |
|
2332 switch ( numSeqs ) |
|
2333 { |
|
2334 case 4: // must be a download leaf |
|
2335 { |
|
2336 iluid = GetLuidForUserIdL( aParentMapping, EDCSDownload ) ; |
|
2337 break; |
|
2338 } |
|
2339 case 5: // download operation or delivered or deployed leaf |
|
2340 { |
|
2341 if ( URISegsUpTo( aURI, 2, ETrue ) == KDownloadURI ) |
|
2342 { |
|
2343 RDEBUG8_2( "CAmAdapter::GetLeafLuidL(): WARNING download operation leaf '%S'", &aURI ); |
|
2344 //status = EOk; |
|
2345 } |
|
2346 else |
|
2347 { |
|
2348 TPtrC8 start( URISegsUpTo( aURI, 3, ETrue ) ); |
|
2349 if ( start == KDeliveredURI ) |
|
2350 { |
|
2351 iluid = GetLuidForUserIdL( aParentMapping, EDCSDelivered ) ; |
|
2352 } |
|
2353 else if ( start == KDeployedURI ) |
|
2354 { |
|
2355 iluid = GetLuidForUserIdL( aParentMapping, EDCSActive ) ; |
|
2356 if( (TInt32)iluid <= 0 ) |
|
2357 { |
|
2358 iluid = GetLuidForUserIdL( aParentMapping, EDCSInactive ) ; |
|
2359 } |
|
2360 } |
|
2361 else |
|
2362 { |
|
2363 RDEBUG8_2( "CAmAdapter::GetLeafLuidL(): WARNING strange uri '%S'", &aURI ); |
|
2364 } |
|
2365 } |
|
2366 break; |
|
2367 } |
|
2368 case 6: // delivered or deployed operation leaf |
|
2369 { |
|
2370 //iluid = GetLuidForUserIdL( parentMapping, EDCSDownload ) ; |
|
2371 //status = EOk; |
|
2372 RDEBUG8_2( "CAmAdapter::GetLeafLuidL(): WARNING delivered or deployed operation leaf '%S'", &aURI ); |
|
2373 break; |
|
2374 } |
|
2375 default: // illegal uri |
|
2376 { |
|
2377 RDEBUG8_2( "CAmAdapter::GetLeafLuidL(): ERROR requested luid of illegal URI '%S'", &aURI ); |
|
2378 break; |
|
2379 } |
|
2380 } |
|
2381 return iluid; |
|
2382 } |
|
2383 |
|
2384 // ------------------------------------------------------------------------------------------------ |
|
2385 // CAmAdapter::FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType, |
|
2386 // CBufBase& aObject ) |
|
2387 // ------------------------------------------------------------------------------------------------ |
|
2388 void CAmAdapter::FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType, |
|
2389 const TInt aResultsRef, TInt aStatusRef ) |
|
2390 { |
|
2391 |
|
2392 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2393 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
2394 #else |
|
2395 //Nothing |
|
2396 #endif |
|
2397 |
|
2398 |
|
2399 RDEBUG8_4("CAmAdapter::FetchLeafObjectL('%S', '%S', '%S'): begin", &aURI, &aLUID, &aType ); |
|
2400 SetAdapterValue(KAMSCMAdapter); |
|
2401 CheckStateChangesL(); |
|
2402 TError status( EError ); |
|
2403 |
|
2404 CBufBase *currentList = CBufFlat::NewL( 128 ); |
|
2405 CleanupStack::PushL( currentList ); |
|
2406 |
|
2407 CBufBase *currentMime = CBufFlat::NewL( 128 ); |
|
2408 CleanupStack::PushL( currentMime ); |
|
2409 |
|
2410 TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) ); |
|
2411 TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) ); |
|
2412 TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) ); |
|
2413 |
|
2414 HBufC8 *luid = NULL; |
|
2415 if ( aLUID != KNullDesC8 ) |
|
2416 { |
|
2417 luid = aLUID.AllocLC(); |
|
2418 } |
|
2419 else |
|
2420 { // try if we find it from download path |
|
2421 TBuf8<256> down; |
|
2422 down = KDownloadURI; |
|
2423 down.Append ( parentMapping ); |
|
2424 luid = Callback().GetLuidAllocL( down ); |
|
2425 CleanupStack::PushL( luid ); |
|
2426 if ( *luid != KNullDesC8 ) |
|
2427 { |
|
2428 // make it to found next time |
|
2429 DirectSetMappingL( parent, *luid ); |
|
2430 MoveAclL( down, parent ); |
|
2431 |
|
2432 // remove old |
|
2433 DirectSetMappingL( down, KNullDesC8 ); |
|
2434 } |
|
2435 } |
|
2436 if ( *luid != KNullDesC8 ) |
|
2437 { |
|
2438 TUint32 iluid ( DesToIntL( *luid ) ); |
|
2439 RDEBUG8_2( "CAmAdapter::FetchLeafObjectL(): Luid is : %d", iluid ); |
|
2440 GetComponentDataL( parent, mapping, iluid, *currentList, *currentMime, status ); |
|
2441 } |
|
2442 else |
|
2443 { |
|
2444 TUint32 iluid( GetLeafLuidL( aURI, parentMapping ) ); |
|
2445 if ( iluid > 0 ) |
|
2446 { |
|
2447 HBufC8 *l = IntToDes8LC( iluid ); |
|
2448 DirectSetMappingL( parent, *l ); |
|
2449 CleanupStack::PopAndDestroy( l ); |
|
2450 GetComponentDataL( parent, mapping, iluid, *currentList, *currentMime, status ); |
|
2451 } |
|
2452 else |
|
2453 { |
|
2454 RDEBUG8_2( "CAmAdapter::FetchLeafObjectL(): WARNING Faild to get luid allocation for '%S'", &parent ); |
|
2455 if ( aLUID == KNullDesC8 ) |
|
2456 { |
|
2457 #ifdef __AM_LASTERROR_NODE |
|
2458 if ( aURI == KAMLastErrorURI ) |
|
2459 { |
|
2460 const TDesC8& error= LastError(); |
|
2461 RDEBUG8_2( "CAmAdapter::FetchLeafObjectL(): Returning last error '%S'", &error ); |
|
2462 currentList->InsertL(0, error ); |
|
2463 status = EOk; |
|
2464 } |
|
2465 else |
|
2466 { |
|
2467 status = ENotFound; |
|
2468 } |
|
2469 #else |
|
2470 status = ENotFound ; |
|
2471 #endif |
|
2472 } |
|
2473 } |
|
2474 } |
|
2475 |
|
2476 SetStatusL( aStatusRef, status ); |
|
2477 if( status == EOk ) |
|
2478 { |
|
2479 if ( iInAtomic ) |
|
2480 { |
|
2481 iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) ); |
|
2482 } |
|
2483 Callback().SetResultsL( aResultsRef, *currentList, |
|
2484 ( (currentMime->Size() > 0) ? currentMime->Ptr(0) : aType ) ); |
|
2485 } |
|
2486 CleanupStack::PopAndDestroy( luid ); |
|
2487 CleanupStack::PopAndDestroy( currentMime ); //currentMime |
|
2488 CleanupStack::PopAndDestroy( currentList ); //currentList |
|
2489 RDEBUG("CAmAdapter::FetchLeafObjectL: end" ); |
|
2490 } |
|
2491 |
|
2492 |
|
2493 // ------------------------------------------------------------------------------------------------ |
|
2494 // CAmAdapter::IdListL( TDeploymentComponentState aState, |
|
2495 // CBufBase *aCurrentList, TBool aAppend /* = EFalse */) |
|
2496 // ------------------------------------------------------------------------------------------------ |
|
2497 CAmAdapter::TError CAmAdapter::IdListL( |
|
2498 TDeploymentComponentState aState, |
|
2499 CBufBase &aCurrentList, TBool aAppend /* = EFalse */) |
|
2500 { |
|
2501 CAmAdapter::TError ret( CAmAdapter::EError ); |
|
2502 RElementIdArray array; |
|
2503 TPtrC8 uriStart; |
|
2504 TBuf8<256> uri; |
|
2505 switch ( aState ) |
|
2506 { |
|
2507 case EDCSDelivered: |
|
2508 uriStart.Set( KDeliveredURI ); |
|
2509 break; |
|
2510 case EDCSActive: |
|
2511 case EDCSInactive: |
|
2512 uriStart.Set( KDeployedURI ) ; |
|
2513 break; |
|
2514 case EDCSDownload: |
|
2515 uriStart.Set( KDownloadURI ) ; |
|
2516 break; |
|
2517 default: |
|
2518 break; |
|
2519 |
|
2520 } |
|
2521 TInt err( SessionL().DeploymentComponentIdsL( array, aState ) ); |
|
2522 if ( err == KErrNone ) |
|
2523 { |
|
2524 TInt count( array.Count() ); |
|
2525 if ( count && aAppend && aCurrentList.Size() ) |
|
2526 { |
|
2527 aCurrentList.InsertL( aCurrentList.Size(), KAMSeparator8 ); |
|
2528 } |
|
2529 for( TInt i( 0 ); i < count; i++ ) |
|
2530 { |
|
2531 TUint32 el = array[i]; |
|
2532 TDCUserId dc; |
|
2533 SessionL().DeploymentComponentUserIdL( el, dc ); |
|
2534 |
|
2535 if ( uriStart == KNullDesC8() ) |
|
2536 { |
|
2537 TDeploymentComponent comp ; |
|
2538 err = SessionL().DeploymentComponent( el, comp ) ; |
|
2539 if ( err == KErrNone ) |
|
2540 { |
|
2541 switch ( comp.iState ) |
|
2542 { |
|
2543 case EDCSDelivered: |
|
2544 uriStart.Set( KDeliveredURI ); |
|
2545 break; |
|
2546 case EDCSActive: |
|
2547 case EDCSInactive: |
|
2548 uriStart.Set( KDeployedURI ) ; |
|
2549 break; |
|
2550 case EDCSDownload: |
|
2551 uriStart.Set( KDownloadURI ) ; |
|
2552 break; |
|
2553 default: |
|
2554 break; |
|
2555 } |
|
2556 } |
|
2557 } |
|
2558 if ( uriStart != KNullDesC8() ) |
|
2559 { |
|
2560 uri.Copy( uriStart ); |
|
2561 uri.Append( dc ); |
|
2562 HBufC8 *luid = DirectGetLuidAllocLC( uri ); //Callback().GetLuidAllocL( uri ); |
|
2563 if ( KNullDesC8() == *luid ) |
|
2564 { |
|
2565 RDEBUG8_3( "CAmAdapter::IdListL(): WARNING updating lost luid of '%S' %d", &uri, el ); |
|
2566 HBufC8 *l = IntToDes8LC( el ); |
|
2567 if ( *luid == *l ) |
|
2568 { |
|
2569 RDEBUG( "CAmAdapter::IdListL(): WARNING CANCEL (not really updating, they're the same already" ); |
|
2570 } |
|
2571 else |
|
2572 { |
|
2573 DirectSetMappingL( uri, *l ); |
|
2574 } |
|
2575 CleanupStack::PopAndDestroy( l ); |
|
2576 } |
|
2577 CleanupStack::PopAndDestroy( luid ); |
|
2578 |
|
2579 } |
|
2580 else |
|
2581 { |
|
2582 RDEBUG_2( "CAmAdapter::IdListL(): WARNING failed to get component state of id %d, cannot check mappings ", el ); |
|
2583 } |
|
2584 aCurrentList.InsertL( aCurrentList.Size(), dc); |
|
2585 if ( i + 1 < count ) |
|
2586 { |
|
2587 aCurrentList.InsertL( aCurrentList.Size(), KAMSeparator8 ); |
|
2588 } |
|
2589 } |
|
2590 ret = EOk; |
|
2591 } |
|
2592 else |
|
2593 { |
|
2594 RDEBUG_2( "CAmAdapter::IdListL(): Error %d", err ); |
|
2595 } |
|
2596 array.Reset(); |
|
2597 return ret; |
|
2598 } |
|
2599 |
|
2600 // ------------------------------------------------------------------------------------------------ |
|
2601 // CAmAdapter::ChildURIListL( const TDesC8& aURI, const TDesC8& aParentLUID, |
|
2602 // const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, const TInt aResultsRef, |
|
2603 // TInt aStatusRef ); |
|
2604 // ------------------------------------------------------------------------------------------------ |
|
2605 void CAmAdapter::ChildURIListL( const TDesC8& aURI, const TDesC8& aParentLUID, |
|
2606 const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, const TInt aResultsRef, |
|
2607 TInt aStatusRef ) |
|
2608 { |
|
2609 |
|
2610 |
|
2611 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2612 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
2613 #else |
|
2614 //Nothing |
|
2615 #endif |
|
2616 |
|
2617 RDEBUG8_3 ( "CAmAdapter::ChildURIListL(): begin ('%S', '%S')" , &aURI, &aParentLUID ); |
|
2618 CheckStateChangesL(); |
|
2619 |
|
2620 TError ret( EError ); |
|
2621 |
|
2622 CBufBase *currentList = CBufFlat::NewL( 128 ); |
|
2623 CleanupStack::PushL( currentList ); |
|
2624 |
|
2625 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2626 TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) ); |
|
2627 #else |
|
2628 TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) ); |
|
2629 #endif |
|
2630 |
|
2631 TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) ); |
|
2632 if ( numSeqs == 1 ) |
|
2633 { |
|
2634 currentList->InsertL( 0, KAMRootChilds ); |
|
2635 ret = EOk; |
|
2636 } |
|
2637 else if ( numSeqs == 2 ) |
|
2638 { |
|
2639 if ( mapping == KAMInventoryNodeName) |
|
2640 { |
|
2641 currentList->InsertL( 0, KAMInventoryChilds ); |
|
2642 ret = EOk; |
|
2643 } |
|
2644 else if ( mapping == KAMDownloadNodeName ) |
|
2645 { |
|
2646 RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level 2 NODE %S", &aURI ); |
|
2647 TDeploymentComponentState state ( EDCSDownload ); |
|
2648 ret = IdListL( state, *currentList ); |
|
2649 } |
|
2650 else |
|
2651 { |
|
2652 RDEBUG8_2( "CAmAdapter::ChildURIListL(): ILLEGAL LEVEL 2 NODE %S", &aURI ); |
|
2653 User::Leave( KErrArgument ); |
|
2654 } |
|
2655 } |
|
2656 else if ( numSeqs == 3 ) |
|
2657 { |
|
2658 if ( mapping == KAMDeliveredNodeName ) |
|
2659 { |
|
2660 RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level 3 NODE %S", &aURI ); |
|
2661 TDeploymentComponentState state ( EDCSDelivered ); |
|
2662 ret = IdListL( state, *currentList ); |
|
2663 } |
|
2664 else if ( mapping == KAMDeployedNodeName ) |
|
2665 { |
|
2666 TDeploymentComponentState state ( EDCSActive ); |
|
2667 ret = IdListL( state, *currentList ); |
|
2668 if ( ret == EOk ) |
|
2669 { |
|
2670 state = EDCSInactive ; |
|
2671 ret = IdListL( state, *currentList, ETrue ); |
|
2672 } |
|
2673 } |
|
2674 else |
|
2675 { |
|
2676 if ( aParentLUID != KNullDesC8 ) |
|
2677 { |
|
2678 if ( CheckStateL( aURI, aParentLUID ) ) |
|
2679 { |
|
2680 TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) ); |
|
2681 TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) ); |
|
2682 if ( parentMapping == KAMDownloadNodeName ) |
|
2683 { |
|
2684 currentList->InsertL( 0, KAMDownloadDynaChilds ); |
|
2685 ret = EOk; |
|
2686 } |
|
2687 else |
|
2688 { |
|
2689 RDEBUG8_2( "CAmAdapter::ChildURIListL(): ILLEGAL LEVEL 3 NODE %S", &aURI ); |
|
2690 User::Leave( KErrArgument ); |
|
2691 } |
|
2692 } |
|
2693 else |
|
2694 { |
|
2695 RDEBUG8_2( "CAmAdapter::ChildURIListL(): DC has changed state %S", &aURI ); |
|
2696 ret = ENotFound; |
|
2697 } |
|
2698 } |
|
2699 else |
|
2700 { |
|
2701 RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level3 Node not found %S", &aURI ); |
|
2702 ret = ENotFound; |
|
2703 } |
|
2704 } |
|
2705 } |
|
2706 else if ( numSeqs == 4 ) |
|
2707 { |
|
2708 TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) ); |
|
2709 TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) ); |
|
2710 if ( aParentLUID == KNullDesC8 ) |
|
2711 { |
|
2712 RDEBUG8_2( "CAmAdapter::ChildURIListL(): WARNING possibly a illegal level 4 node %S", &aURI ); |
|
2713 ret = ENotFound; |
|
2714 } |
|
2715 |
|
2716 if ( parentMapping == KAMDeliveredNodeName ) |
|
2717 { |
|
2718 if ( GetLuid2L( aParentLUID, mapping, EDCSDelivered, ret ) > 0 ) |
|
2719 { |
|
2720 currentList->InsertL( 0, KAMInventoryDeliveredDynaChilds ); |
|
2721 ret = EOk; |
|
2722 } |
|
2723 } |
|
2724 else if ( parentMapping == KAMDeployedNodeName ) |
|
2725 { |
|
2726 if ( GetLuid2L( aParentLUID, mapping, EDCSActive, ret ) > 0 ) |
|
2727 { |
|
2728 currentList->InsertL( 0, KAMInventoryDynaChilds ); |
|
2729 ret = EOk; |
|
2730 } |
|
2731 else if ( GetLuid2L( aParentLUID, mapping, EDCSInactive, ret ) > 0 ) |
|
2732 { |
|
2733 currentList->InsertL( 0, KAMInventoryDynaChilds ); |
|
2734 ret = EOk; |
|
2735 } |
|
2736 } |
|
2737 else if ( mapping == KAMOperationsNodeName ) |
|
2738 { |
|
2739 if ( GetLuid2L( aParentLUID, parentMapping, EDCSDownload, ret ) > 0 ) |
|
2740 { |
|
2741 if ( CheckStateL( aURI, aParentLUID ) ) |
|
2742 { |
|
2743 currentList->InsertL( 0, KAMDownloadOperationChilds ); |
|
2744 ret = EOk; |
|
2745 } |
|
2746 else |
|
2747 { |
|
2748 RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level3 operations DC changed state '%S'", &aURI ); |
|
2749 ret = ENotFound; |
|
2750 } |
|
2751 } |
|
2752 } |
|
2753 else |
|
2754 { |
|
2755 RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level4 Node not found '%S'", &aURI ); |
|
2756 ret = ENotFound; |
|
2757 } |
|
2758 } |
|
2759 else if ( numSeqs == 5 ) |
|
2760 { |
|
2761 if ( aParentLUID == KNullDesC8 ) |
|
2762 { |
|
2763 RDEBUG8_2( "CAmAdapter::ChildURIListL(): WARNING possibly a illegal level 5 node %S", &aURI ); |
|
2764 ret = ENotFound; |
|
2765 } |
|
2766 if ( mapping == KAMOperationsNodeName ) |
|
2767 { |
|
2768 TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) ); |
|
2769 TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) ); |
|
2770 TPtrC8 gparent( NSmlDmURI::RemoveLastSeg( parent ) ); |
|
2771 TPtrC8 gparentMapping( NSmlDmURI::LastURISeg( gparent ) ); |
|
2772 if ( gparentMapping == KAMDeliveredNodeName ) |
|
2773 { |
|
2774 if ( GetLuid2L( aParentLUID, parentMapping, EDCSDelivered, ret ) > 0 ) |
|
2775 { |
|
2776 currentList->InsertL( 0, KAMDeliveredOperationChilds ); |
|
2777 ret = EOk; |
|
2778 } |
|
2779 } |
|
2780 else if ( gparentMapping == KAMDeployedNodeName ) |
|
2781 { |
|
2782 if ( GetLuid2L( aParentLUID, parentMapping, EDCSActive, ret ) > 0 ) |
|
2783 { |
|
2784 currentList->InsertL( 0, KAMDeployedOperationChilds ); |
|
2785 ret = EOk; |
|
2786 } |
|
2787 else if ( GetLuid2L( aParentLUID, parentMapping, EDCSInactive, ret ) > 0 ) |
|
2788 { |
|
2789 currentList->InsertL( 0, KAMDeployedOperationChilds ); |
|
2790 ret = EOk; |
|
2791 } |
|
2792 } |
|
2793 else |
|
2794 { |
|
2795 RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level5 Node not found wrong parent '%S'", &aURI ); |
|
2796 ret = ENotFound; |
|
2797 } |
|
2798 } |
|
2799 else |
|
2800 { |
|
2801 RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level5 Node not found '%S'", &aURI ); |
|
2802 ret = ENotFound; |
|
2803 } |
|
2804 } |
|
2805 else |
|
2806 { |
|
2807 RDEBUG8_3( "CAmAdapter::ChildURIListL(): ILLEGAL LEVEL %d NODE %S", numSeqs, &aURI ); |
|
2808 ret = EError; |
|
2809 } |
|
2810 |
|
2811 SetStatusL( aStatusRef, ret ); |
|
2812 |
|
2813 if( ret == EOk ) |
|
2814 { |
|
2815 if ( iInAtomic ) |
|
2816 { |
|
2817 iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) ); |
|
2818 } |
|
2819 Callback().SetResultsL( aResultsRef, *currentList, KNullDesC8 ); |
|
2820 } |
|
2821 CleanupStack::PopAndDestroy(); //currentList |
|
2822 } |
|
2823 |
|
2824 |
|
2825 // ------------------------------------------------------------------------------------------------ |
|
2826 // CAmAdapter::DeliverOrDownloadL( const TDesC8 &aUserId, const TDesC8 &aURI, TInt aCnt, |
|
2827 // const TDesC8 &aParentMapping, MSmlDmAdapter::TError &aStatus ) |
|
2828 // ------------------------------------------------------------------------------------------------ |
|
2829 void CAmAdapter::DeliverOrDownloadL( const TDesC8 &aUserId, const TDesC8 &aURI, TInt aCnt, |
|
2830 const TDesC8 &aParentMapping, MSmlDmAdapter::TError &aStatus ) |
|
2831 { |
|
2832 |
|
2833 |
|
2834 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2835 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
2836 #else |
|
2837 //Nothing |
|
2838 #endif |
|
2839 |
|
2840 switch ( aCnt ) |
|
2841 { |
|
2842 case 3: |
|
2843 { |
|
2844 if ( aParentMapping == KAMDownloadNodeName ) |
|
2845 { |
|
2846 TUint32 luid( SessionL().DownloadL( aUserId ) ); |
|
2847 Callback().SetMappingL( aURI, *IntToDes8LC( luid ) ); |
|
2848 CleanupStack::PopAndDestroy(); |
|
2849 aStatus = EOk; |
|
2850 } |
|
2851 else |
|
2852 { |
|
2853 RDEBUG( "CAmAdapter::DeliverOrDownloadL(): ERROR Illegal parent"); |
|
2854 } |
|
2855 break; |
|
2856 } |
|
2857 case 4: |
|
2858 { |
|
2859 if ( aParentMapping == KAMDeliveredNodeName ) |
|
2860 { |
|
2861 TUint32 luid( SessionL().DeliverL( aUserId ) ); |
|
2862 Callback().SetMappingL( aURI, *IntToDes8LC( luid ) ); |
|
2863 CleanupStack::PopAndDestroy(); |
|
2864 aStatus = EOk; |
|
2865 } |
|
2866 else |
|
2867 { |
|
2868 RDEBUG( "CAmAdapter::DeliverOrDownloadL(): ERROR Illegal parent"); |
|
2869 } |
|
2870 break; |
|
2871 } |
|
2872 default: |
|
2873 { |
|
2874 RDEBUG( "CAmAdapter::DeliverOrDownloadL(): ERROR Illegal URI"); |
|
2875 break; |
|
2876 } |
|
2877 } |
|
2878 } |
|
2879 |
|
2880 |
|
2881 // ------------------------------------------------------------------------------------------------ |
|
2882 // CAmAdapter::AddNodeObjectL( const TDesC8& aURI, const TDesC& aParentLUID ) |
|
2883 // ------------------------------------------------------------------------------------------------ |
|
2884 void CAmAdapter::AddNodeObjectL( const TDesC8& aURI, const TDesC8& aParentLUID, TInt aStatusRef ) |
|
2885 { |
|
2886 |
|
2887 |
|
2888 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
2889 TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI); |
|
2890 TPtrC8 mapping( NSmlDmURI::LastURISeg( uriPtrc ) ); |
|
2891 TPtrC8 parent( NSmlDmURI::RemoveLastSeg( uriPtrc ) ); |
|
2892 TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) ); |
|
2893 TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) ); |
|
2894 #else |
|
2895 TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) ); |
|
2896 TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) ); |
|
2897 TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) ); |
|
2898 TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) ); |
|
2899 #endif |
|
2900 |
|
2901 RDEBUG8_3( "CAmAdapter::AddNodeObjectL(): begin '%S', '%S'", &aURI, &aParentLUID ); |
|
2902 SetAdapterValue(KAMSCMAdapter); |
|
2903 CheckStateChangesL(); |
|
2904 TError status ( EError ); |
|
2905 // TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) ); |
|
2906 // TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) ); |
|
2907 // TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) ); |
|
2908 // TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) ); |
|
2909 TUint32 iluid( GetLuidL( aParentLUID, mapping, (parentMapping == KAMDeliveredNodeName ? EDCSDelivered : ( parentMapping == KAMDownloadNodeName ? EDCSDownload : EDCSNone ) ) ) ) ; |
|
2910 if( !iluid && parentMapping == KAMDownloadNodeName ) |
|
2911 { |
|
2912 // This is added for avoiding duplicate node creation in Delivered/Download only. |
|
2913 iluid = GetLuidL( aParentLUID, mapping, EDCSDelivered ); |
|
2914 } |
|
2915 if ( iluid == 0 ) |
|
2916 { |
|
2917 // Not found, add it ... |
|
2918 DeliverOrDownloadL( mapping, aURI, cnt, parentMapping, status ); |
|
2919 } |
|
2920 else |
|
2921 { |
|
2922 RDEBUG_2( "CAmAdapter::AddNodeObjectL(): WARNING May Already exists '%d'", iluid ); |
|
2923 TDeploymentComponent comp ; |
|
2924 TInt err( SessionL().DeploymentComponent( iluid, comp ) ); |
|
2925 if ( err == KErrNone ) |
|
2926 { |
|
2927 RDEBUG_2( "CAmAdapter::AddNodeObjectL(): ERROR Already exists '%d'", iluid ); |
|
2928 if ( comp.iState == StateL( aURI ) ) |
|
2929 { |
|
2930 RDEBUG( "CAmAdapter::AddNodeObjectL(): (state is ok) " ); |
|
2931 } |
|
2932 else |
|
2933 { |
|
2934 RDEBUG( "CAmAdapter::AddNodeObjectL(): (state is NOK) " ); |
|
2935 } |
|
2936 status = EAlreadyExists; |
|
2937 } |
|
2938 else |
|
2939 { |
|
2940 if ( err == KErrNotFound ) |
|
2941 { |
|
2942 RDEBUG_2( "CAmAdapter::AddNodeObjectL(): WARNING Already exists but not found '%d'", iluid ); |
|
2943 DeliverOrDownloadL( mapping, aURI, cnt, parentMapping, status ); |
|
2944 } |
|
2945 else |
|
2946 { |
|
2947 |
|
2948 RDEBUG_2( "CAmAdapter::AddNodeObjectL(): ERROR May exists, but failed to fetch get one? '%d'", err ); |
|
2949 } |
|
2950 } |
|
2951 } |
|
2952 if ( status == EOk ) |
|
2953 { |
|
2954 if ( iInAtomic ) |
|
2955 { |
|
2956 iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) ); |
|
2957 } |
|
2958 } |
|
2959 |
|
2960 |
|
2961 |
|
2962 SetStatusL( aStatusRef, status ); |
|
2963 RDEBUG( "CAmAdapter::AddNodeObject(): end" ); |
|
2964 } |
|
2965 |
|
2966 |
|
2967 |
|
2968 |
|
2969 // ------------------------------------------------------------------------------------------------ |
|
2970 // CAmAdapter::GetSizeL( const TDesC8& aURI, const TDesC& aParentLUID ) |
|
2971 // ------------------------------------------------------------------------------------------------ |
|
2972 TInt CAmAdapter::GetSizeL( const TDeplCompAttrType aDataType, const TInt aLuid, TError &aRet ) |
|
2973 { |
|
2974 TInt size( 0 ); |
|
2975 if ( aDataType == EDCStateValue ) |
|
2976 { |
|
2977 TDeploymentComponent comp; |
|
2978 TInt err( SessionL().DeploymentComponent( aLuid, comp ) ); |
|
2979 if ( err == KErrNone ) |
|
2980 { |
|
2981 if ( comp.iState == EDCSActive ) |
|
2982 { |
|
2983 size = KAMStateValueActive().Length(); |
|
2984 } |
|
2985 else |
|
2986 { |
|
2987 size = KAMStateValueInactive().Length() ; |
|
2988 } |
|
2989 aRet = EOk; |
|
2990 } |
|
2991 } |
|
2992 else |
|
2993 { |
|
2994 size = SessionL().DeploymentComponentDataSizeL( aLuid, aDataType ); |
|
2995 aRet = EOk; |
|
2996 } |
|
2997 return size; |
|
2998 } |
|
2999 |
|
3000 |
|
3001 // ------------------------------------------------------------------------------------------------ |
|
3002 // CAmAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC& aParentLUID ) |
|
3003 // ------------------------------------------------------------------------------------------------ |
|
3004 void CAmAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, |
|
3005 const TDesC8& aType, TInt aResultsRef, |
|
3006 TInt aStatusRef ) |
|
3007 { |
|
3008 |
|
3009 |
|
3010 |
|
3011 RDEBUG8_4("CAmAdapter::FetchLeafObjectSizeL('%S', '%S', '%S'): begin", &aURI, &aLUID, &aType ); |
|
3012 CheckStateChangesL(); |
|
3013 TError status( EError ); |
|
3014 CBufBase *currentList = CBufFlat::NewL( 128 ); |
|
3015 CleanupStack::PushL( currentList ); |
|
3016 |
|
3017 TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) ); |
|
3018 TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) ); |
|
3019 TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) ); |
|
3020 TInt size( 0 ); |
|
3021 HBufC8 *luid = NULL; |
|
3022 if ( aLUID != KNullDesC8 ) |
|
3023 { |
|
3024 luid = aLUID.AllocLC(); |
|
3025 } |
|
3026 else |
|
3027 { // try if we find it from download path |
|
3028 TBuf8<256> down; |
|
3029 down = KDownloadURI; |
|
3030 down.Append ( parentMapping ); |
|
3031 luid = Callback().GetLuidAllocL( down ); |
|
3032 CleanupStack::PushL( luid ); |
|
3033 if ( *luid != KNullDesC8 ) |
|
3034 { |
|
3035 // make it to found next time |
|
3036 DirectSetMappingL( parent, *luid ); |
|
3037 MoveAclL( down, parent ); |
|
3038 |
|
3039 // remove old |
|
3040 DirectSetMappingL( down, KNullDesC8 ); |
|
3041 } |
|
3042 } |
|
3043 TDeplCompAttrType dataType( UpdateFlagFromMapping( mapping ) ); |
|
3044 if ( *luid != KNullDesC8 ) |
|
3045 { |
|
3046 TUint32 iluid ( DesToIntL( *luid ) ); |
|
3047 RDEBUG_2( "CAmAdapter::FetchLeafObjectSizeL(): Luid is : %d", iluid ); |
|
3048 size = GetSizeL( dataType, iluid, status ); |
|
3049 } |
|
3050 else |
|
3051 { |
|
3052 TUint32 iluid( GetLeafLuidL( aURI, parentMapping ) ); |
|
3053 if ( iluid > 0 ) |
|
3054 { |
|
3055 HBufC8 *l = IntToDes8LC( iluid ); |
|
3056 DirectSetMappingL( parent, *l ); |
|
3057 CleanupStack::PopAndDestroy( l ); |
|
3058 size = GetSizeL( dataType, iluid, status ); |
|
3059 } |
|
3060 else |
|
3061 { |
|
3062 RDEBUG8_2( "CAmAdapter::FetchLeafObjectSizeL(): WARNING Faild to get luid allocation for '%S'", &parent ); |
|
3063 if ( aLUID == KNullDesC8 ) |
|
3064 { |
|
3065 status = ENotFound ; |
|
3066 } |
|
3067 } |
|
3068 } |
|
3069 SetStatusL( aStatusRef, status ); |
|
3070 if( status == EOk && size > 0 ) |
|
3071 { |
|
3072 HBufC8 *hsize = IntToDes8LC( size ); |
|
3073 currentList->InsertL( 0, *hsize ); |
|
3074 if ( iInAtomic ) |
|
3075 { |
|
3076 iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) ); |
|
3077 } |
|
3078 Callback().SetResultsL( aResultsRef, *currentList, aType ); |
|
3079 CleanupStack::PopAndDestroy( hsize ); |
|
3080 } |
|
3081 CleanupStack::PopAndDestroy( luid ); |
|
3082 CleanupStack::PopAndDestroy( currentList ); //currentList |
|
3083 } |
|
3084 |
|
3085 |
|
3086 // ------------------------------------------------------------------------------------------------ |
|
3087 // CAmAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC& aParentLUID ) |
|
3088 // ------------------------------------------------------------------------------------------------ |
|
3089 void CAmAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, const TDesC8& /*aLUID*/, |
|
3090 RWriteStream*& /*aStream*/, const TDesC8& /*aType*/, |
|
3091 TInt /*aStatusRef*/ ) |
|
3092 { |
|
3093 RDEBUG("CAmAdapter::ExecuteCommandL(stream): begin (NOT SUPPORTED)"); |
|
3094 User::Leave( KErrNotSupported ); |
|
3095 } |
|
3096 |
|
3097 |
|
3098 // ------------------------------------------------------------------------------------------------ |
|
3099 // CAmAdapter::CopyCommandL( const TDesC8& aURI, const TDesC& aParentLUID ) |
|
3100 // ------------------------------------------------------------------------------------------------ |
|
3101 void CAmAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/, const TDesC8& /*aTargetLUID*/, |
|
3102 const TDesC8& /*aSourceURI*/, const TDesC8& /*aSourceLUID*/, |
|
3103 const TDesC8& /*aType*/, TInt aStatusRef ) |
|
3104 { |
|
3105 RDEBUG("CAmAdapter::CopyCommandL(): begin (NOT SUPPORTED)"); |
|
3106 SetStatusL( aStatusRef, EError ); |
|
3107 |
|
3108 } |
|
3109 |
|
3110 |
|
3111 // ------------------------------------------------------------------------------------------------ |
|
3112 // CAmAdapter::StartAtomicL( ) |
|
3113 // ------------------------------------------------------------------------------------------------ |
|
3114 void CAmAdapter::StartAtomicL() |
|
3115 { |
|
3116 RDEBUG("CAmAdapter::StartAtomicL(): begin (NOT properly SUPPORTED)"); |
|
3117 iInAtomic = ETrue ; |
|
3118 } |
|
3119 |
|
3120 |
|
3121 // ------------------------------------------------------------------------------------------------ |
|
3122 // CAmAdapter::CommitAtomicL( ) |
|
3123 // ------------------------------------------------------------------------------------------------ |
|
3124 void CAmAdapter::CommitAtomicL() |
|
3125 { |
|
3126 RDEBUG("CAmAdapter::CommitAtomicL(): begin (NOT SUPPORTED)"); |
|
3127 iInAtomic = EFalse ; // the initial statuses are already set |
|
3128 } |
|
3129 |
|
3130 |
|
3131 // ------------------------------------------------------------------------------------------------ |
|
3132 // CAmAdapter::RollbackAtomicL( ) |
|
3133 // ------------------------------------------------------------------------------------------------ |
|
3134 void CAmAdapter::RollbackAtomicL() |
|
3135 { |
|
3136 RDEBUG("CAmAdapter::RollbackAtomicL(): begin (NOT properly SUPPORTED)"); |
|
3137 TInt count( iBuffer.Count() ); |
|
3138 for ( TInt i( 0 ); i < count; i++ ) |
|
3139 { |
|
3140 TAMCommandBufferElement &pm( iBuffer[i] ); |
|
3141 SetStatusL( pm.iStatusRef, ERollbackFailed ); |
|
3142 } |
|
3143 } |
|
3144 |
|
3145 |
|
3146 // ------------------------------------------------------------------------------------------------ |
|
3147 // CAmAdapter::StreamingSupport( ) |
|
3148 // ------------------------------------------------------------------------------------------------ |
|
3149 TBool CAmAdapter::StreamingSupport( TInt& aItemSize ) |
|
3150 { |
|
3151 RDEBUG("CAmAdapter::StreamingSupport(): begin"); |
|
3152 aItemSize = 1024; |
|
3153 RDEBUG("CAmAdapter::StreamingSupport(): end"); |
|
3154 return ETrue; |
|
3155 } |
|
3156 |
|
3157 |
|
3158 // ------------------------------------------------------------------------------------------------ |
|
3159 // CAmAdapter::StreamCommittedL( ) |
|
3160 // ------------------------------------------------------------------------------------------------ |
|
3161 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3162 void CAmAdapter::StreamCommittedL( RWriteStream& /*aStream*/ ) |
|
3163 #else |
|
3164 void CAmAdapter::StreamCommittedL() |
|
3165 #endif |
|
3166 { |
|
3167 RDEBUG("CAmAdapter::StreamCommittedL(): begin"); |
|
3168 |
|
3169 if(iStreamOpen) |
|
3170 { |
|
3171 iStream.CommitL(); |
|
3172 } |
|
3173 |
|
3174 MSmlDmAdapter::TError status = EOk; |
|
3175 |
|
3176 TRAPD( err, _UpdateLeafObjectL( *iStreamedURI, *iStreamedLuid, KNullDesC8(), *iStreamedType, iStatusRef, status ) ); |
|
3177 |
|
3178 if(err != KErrNone) |
|
3179 { |
|
3180 RDEBUG_2("CAmAdapter::StreamCommittedL(): _UpdateLeafObjectL returned error (%d)", err); |
|
3181 } |
|
3182 |
|
3183 iIsStreamedContent = EFalse; |
|
3184 iStreamOpen = EFalse; |
|
3185 |
|
3186 Callback().SetStatusL( iStatusRef, status ); |
|
3187 |
|
3188 RDEBUG("CAmAdapter::StreamCommittedL(): end"); |
|
3189 } |
|
3190 |
|
3191 // ------------------------------------------------------------------------------------------------ |
|
3192 // CAmAdapter::CloseStreaming( ) |
|
3193 // ------------------------------------------------------------------------------------------------ |
|
3194 void CAmAdapter::CloseStreaming() |
|
3195 { |
|
3196 if( iStreamOpen ) |
|
3197 { |
|
3198 RDEBUG("CAmAdapter::CloseStreaming(): closing"); |
|
3199 iStreamFile.Close(); // !!! Closing this will also close the iStreamRFs because it is adopted from server |
|
3200 iStreamOpen = EFalse; |
|
3201 } |
|
3202 } |
|
3203 |
|
3204 |
|
3205 // ------------------------------------------------------------------------------------------------ |
|
3206 // CAmAdapter::CompleteOutstandingCmdsL() |
|
3207 // ------------------------------------------------------------------------------------------------ |
|
3208 void CAmAdapter::CompleteOutstandingCmdsL() |
|
3209 { |
|
3210 RDEBUG("CAmAdapter::CompleteOutstandingCmdsL(): begin"); |
|
3211 /* iManagement.Close(); |
|
3212 iSessionOpened = EFalse ;*/ |
|
3213 iBuffer.Reset(); |
|
3214 RDEBUG("CAmAdapter::CompleteOutstandingCmdsL(): Management session closed"); |
|
3215 } |
|
3216 |
|
3217 |
|
3218 |
|
3219 // ------------------ |
|
3220 // |
|
3221 // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
3222 const TImplementationProxy ImplementationTable[] = |
|
3223 { |
|
3224 // |
|
3225 IMPLEMENTATION_PROXY_ENTRY( KAMAdapterImplUid, CAmAdapter::NewL ) |
|
3226 }; |
|
3227 |
|
3228 // ------------------------------------------------------------------------------------------------ |
|
3229 // |
|
3230 // ------------------------------------------------------------------------------------------------ |
|
3231 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
3232 { |
|
3233 aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
3234 return ImplementationTable; |
|
3235 } |
|
3236 |
|
3237 |
|
3238 // ------------------------------------------------------------------------------------------------ |
|
3239 // |
|
3240 // ------------------------------------------------------------------------------------------------ |
|
3241 TInt CAmAdapter::DesToIntL( const TDesC8& aLuid ) |
|
3242 { |
|
3243 TLex8 lex( aLuid ); |
|
3244 TInt value = 0; |
|
3245 User::LeaveIfError( lex.Val( value ) ); |
|
3246 return value; |
|
3247 } |
|
3248 |
|
3249 |
|
3250 // ------------------------------------------------------------------------------------------------ |
|
3251 // |
|
3252 // ------------------------------------------------------------------------------------------------ |
|
3253 HBufC8* CAmAdapter::IntToDes8LC( const TInt aLuid ) |
|
3254 { |
|
3255 HBufC8* buf = HBufC8::NewLC( 10 ); //10 = max length of 32bit integer |
|
3256 TPtr8 ptrBuf = buf->Des(); |
|
3257 ptrBuf.Num( aLuid ); |
|
3258 return buf; |
|
3259 } |
|
3260 |
|
3261 |
|
3262 |
|
3263 // ------------------------------------------------------------------------------------------------ |
|
3264 // |
|
3265 // ------------------------------------------------------------------------------------------------ |
|
3266 void CAmAdapter::ConstructL() |
|
3267 { |
|
3268 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3269 iDbSession.ConnectL(); |
|
3270 #else |
|
3271 User::LeaveIfError( iDbSession.Connect()); |
|
3272 #endif |
|
3273 } |
|
3274 |
|
3275 // ------------------------------------------------------------------------------------------------ |
|
3276 // CAmAdapter::SetStatusL( TInt aStatusRef, MSmlDmAdapter::TError aErrorCode ) |
|
3277 // ------------------------------------------------------------------------------------------------ |
|
3278 void CAmAdapter::SetStatusL( TInt aStatusRef, |
|
3279 MSmlDmAdapter::TError aErrorCode ) |
|
3280 { |
|
3281 RDEBUG_3("CAmAdapter::SetStatusL( %d, %d )", aStatusRef, aErrorCode ); |
|
3282 Callback().SetStatusL( aStatusRef, aErrorCode ); |
|
3283 } |
|
3284 |
|
3285 // ------------------------------------------------------------------------------------------------ |
|
3286 // CAmAdapter::SetResultsL( TInt aResultsRef, CBufBase& aObject, const TDesC8& aType ) |
|
3287 // ------------------------------------------------------------------------------------------------ |
|
3288 void CAmAdapter::SetResultsL( TInt aResultsRef, CBufBase& aObject, |
|
3289 const TDesC8& aType ) |
|
3290 { |
|
3291 Callback().SetResultsL( aResultsRef, aObject, aType ); |
|
3292 |
|
3293 } |
|
3294 |
|
3295 // ------------------------------------------------------------------------------------- |
|
3296 // CAmAdapter::FillNodeInfoL() |
|
3297 // Fills the node info in ddf structure |
|
3298 // ------------------------------------------------------------------------------------- |
|
3299 void CAmAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode,TSmlDmAccessTypes aAccTypes, |
|
3300 MSmlDmDDFObject::TOccurence aOccurrence, MSmlDmDDFObject::TScope aScope, |
|
3301 MSmlDmDDFObject::TDFFormat aFormat,const TDesC8& aDescription) |
|
3302 { |
|
3303 FillNodeInfoNoDefaultMimeL( aNode, aAccTypes, aOccurrence, aScope, aFormat, aDescription ); |
|
3304 if(aFormat!=MSmlDmDDFObject::ENode) |
|
3305 { |
|
3306 aNode.AddDFTypeMimeTypeL(KAMTextPlain); |
|
3307 } |
|
3308 |
|
3309 } |
|
3310 |
|
3311 |
|
3312 // ------------------------------------------------------------------------------------- |
|
3313 // CAmAdapter::FillNodeInfoNoDefaultMimeL() |
|
3314 // Fills the node info in ddf structure, without default mime type |
|
3315 // ------------------------------------------------------------------------------------- |
|
3316 void CAmAdapter::FillNodeInfoNoDefaultMimeL( MSmlDmDDFObject& aNode,TSmlDmAccessTypes aAccTypes, |
|
3317 MSmlDmDDFObject::TOccurence aOccurrence, MSmlDmDDFObject::TScope aScope, |
|
3318 MSmlDmDDFObject::TDFFormat aFormat,const TDesC8& aDescription) |
|
3319 { |
|
3320 aNode.SetAccessTypesL(aAccTypes); |
|
3321 aNode.SetOccurenceL(aOccurrence); |
|
3322 aNode.SetScopeL(aScope); |
|
3323 aNode.SetDFFormatL(aFormat); |
|
3324 |
|
3325 aNode.SetDescriptionL(aDescription); |
|
3326 } |
|
3327 |
|
3328 // ------------------------------------------------------------------------------------- |
|
3329 // CAmAdapter::CheckStateChangesInternalL() |
|
3330 // Updates the changed DC states to DM client mappings and ACLs |
|
3331 // ------------------------------------------------------------------------------------- |
|
3332 void CAmAdapter::CheckStateChangesInternalL() |
|
3333 { |
|
3334 |
|
3335 |
|
3336 #ifdef __AM_CHECKSTATE_CHANGES |
|
3337 RDEBUG( "CAmAdapter::CheckStateChangesLInternal(): begin" ); |
|
3338 if ( !iUpdated ) |
|
3339 { |
|
3340 RDEBUG( "CAmAdapter::CheckStateChangesLInternal(): !iUpdated" ); |
|
3341 RElementIdArray arr; |
|
3342 CleanupClosePushL( arr ); |
|
3343 TInt err( SessionL().StateChangingDCIdsL( arr ) ); |
|
3344 if ( err == KErrNone ) |
|
3345 { |
|
3346 TInt c( arr.Count() ); |
|
3347 for( TInt i( 0 ); i < c; i++ ) |
|
3348 { |
|
3349 TDeploymentComponent comp ; |
|
3350 err = iManagement.DeploymentComponent( arr[i], comp ); |
|
3351 if ( err == KErrNone ) |
|
3352 { |
|
3353 TDCUserId dc; |
|
3354 SessionL().DeploymentComponentUserIdL( arr[i], dc ); |
|
3355 const TInt KNSmlDmMaxUriLength = 256; |
|
3356 HBufC8 *uri = HBufC8::NewLC( KNSmlDmMaxUriLength ); |
|
3357 TPtr8 puri( uri->Des() ); |
|
3358 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3359 RDmTreeNode uriNode; |
|
3360 CleanupClosePushL(uriNode); |
|
3361 |
|
3362 RBuf8 acl; |
|
3363 acl.CreateL(128); |
|
3364 CleanupClosePushL(acl); |
|
3365 |
|
3366 HBufC8 *newUri = HBufC8::NewLC( KNSmlDmMaxUriLength ); |
|
3367 TPtr8 pnewUri( newUri->Des() ); |
|
3368 |
|
3369 RDmTreeNode newUriNode; |
|
3370 CleanupClosePushL(newUriNode); |
|
3371 #else |
|
3372 CBufBase* acl = CBufFlat::NewL( 128 ); |
|
3373 CleanupStack::PushL( acl ); |
|
3374 |
|
3375 HBufC8 *newUri = HBufC8::NewLC( KNSmlDmMaxUriLength ); |
|
3376 TPtr8 pnewUri( newUri->Des() ); |
|
3377 |
|
3378 #endif |
|
3379 |
|
3380 switch ( comp.iOldState ) |
|
3381 { |
|
3382 case EDCSDelivered: |
|
3383 { |
|
3384 RDEBUG( "CAmAdapter::CheckStateChangesLInternal(): Old State = EDCSDelivered" ); |
|
3385 puri.Copy( KDeliveredURI() ); |
|
3386 puri.Append( dc ); |
|
3387 |
|
3388 HBufC8 *luid = DirectGetLuidAllocLC( puri ); |
|
3389 |
|
3390 if ( *luid == KNullDesC8 ) |
|
3391 { |
|
3392 // try if we find it from download path |
|
3393 puri.Zero(); |
|
3394 puri.Copy( KDownloadURI() ); |
|
3395 puri.Append( dc ); |
|
3396 luid = DirectGetLuidAllocLC( puri ); |
|
3397 } |
|
3398 |
|
3399 // check if the luid is still null |
|
3400 |
|
3401 if ( *luid != KNullDesC8 ) |
|
3402 { |
|
3403 // "Nullify" the old mapping |
|
3404 //DirectSetMappingL( puri, KNullDesC8 ); |
|
3405 DirectRemoveMappingL(puri); |
|
3406 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3407 iDbSession.OpenNodeL(puri, uriNode, RDmTree::EReadOnly); |
|
3408 uriNode.DmPropertyL( DevMan::EACL, acl ); |
|
3409 #else |
|
3410 err = iDbSession.GetAclL(puri, *acl, EFalse ); // no need for inherited |
|
3411 #endif |
|
3412 // Determine new uri |
|
3413 switch( comp.iState ) |
|
3414 { |
|
3415 case EDCSActive: |
|
3416 case EDCSInactive: // both have same node |
|
3417 { |
|
3418 pnewUri.Copy( KDeployedURI() ); |
|
3419 pnewUri.Append( dc ); |
|
3420 DirectSetMappingL( pnewUri, *luid ); |
|
3421 if ( err == KErrNone ) |
|
3422 { |
|
3423 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3424 iDbSession.OpenNodeL(pnewUri, newUriNode, RDmTree::EReadOnly); |
|
3425 uriNode.RemoveDmPropertyL( DevMan::EACL ); |
|
3426 newUriNode.SetDmPropertyL( DevMan::EACL, acl ); |
|
3427 #else |
|
3428 err = iDbSession.DeleteAclL( puri ); |
|
3429 |
|
3430 err = iDbSession.UpdateAclL( pnewUri, acl->Ptr( 0 ) ); |
|
3431 #endif |
|
3432 } |
|
3433 else |
|
3434 { |
|
3435 RDEBUG_2("CAmAdapter::CheckStateChangesL: ERROR Failed to get acl from %d ", err ); |
|
3436 } |
|
3437 iManagement.StateChangeComplete( arr[i] ); |
|
3438 break; |
|
3439 } |
|
3440 default: |
|
3441 { |
|
3442 |
|
3443 RDEBUG_2("CAmAdapter::CheckStateChangesL: WARNING Illegal state change from delivered to %d ", comp.iState ); |
|
3444 |
|
3445 break; |
|
3446 } |
|
3447 } |
|
3448 } |
|
3449 else |
|
3450 { |
|
3451 // probably moved already |
|
3452 iManagement.StateChangeComplete( arr[i] ); |
|
3453 } |
|
3454 |
|
3455 CleanupStack::PopAndDestroy( luid ); |
|
3456 break; |
|
3457 } |
|
3458 case EDCSDownload: |
|
3459 { |
|
3460 RDEBUG( "CAmAdapter::CheckStateChangesLInternal(): Old State = EDCSDownload" ); |
|
3461 puri.Copy( KDownloadURI() ); |
|
3462 puri.Append( dc ); |
|
3463 HBufC8 *luid = DirectGetLuidAllocLC( puri ); //Callback().GetLuidAllocL( puri ); |
|
3464 //CleanupStack::PushL( luid ); |
|
3465 if ( *luid == KNullDesC8 ) |
|
3466 { // probably moved already |
|
3467 CleanupStack::PopAndDestroy( luid ); |
|
3468 puri.Copy( KDeliveredURI() ); |
|
3469 puri.Append( dc ); |
|
3470 luid = DirectGetLuidAllocLC( puri ); //Callback().GetLuidAllocL( puri ); |
|
3471 if ( *luid == KNullDesC8 ) |
|
3472 { // probably moved already |
|
3473 |
|
3474 iManagement.StateChangeComplete( arr[i] ); |
|
3475 |
|
3476 } |
|
3477 } |
|
3478 else |
|
3479 { |
|
3480 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3481 iDbSession.OpenNodeL(puri, uriNode, RDmTree::EReadOnly); |
|
3482 uriNode.DmPropertyL( DevMan::EACL, acl ); |
|
3483 #else |
|
3484 err = iDbSession.GetAclL(puri, *acl, EFalse ); // no need for inherited |
|
3485 #endif |
|
3486 // "Nullify" the old mapping |
|
3487 //DirectSetMappingL( puri, KNullDesC8 ); |
|
3488 DirectRemoveMappingL(puri); |
|
3489 switch( comp.iState ) |
|
3490 { |
|
3491 case EDCSActive: |
|
3492 case EDCSInactive: // both have same node |
|
3493 { |
|
3494 pnewUri.Copy( KDeployedURI() ); |
|
3495 pnewUri.Append( dc ); |
|
3496 DirectSetMappingL( pnewUri, *luid ); |
|
3497 if ( err == KErrNone ) |
|
3498 { |
|
3499 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3500 iDbSession.OpenNodeL(pnewUri, newUriNode, RDmTree::EReadOnly); |
|
3501 uriNode.RemoveDmPropertyL( DevMan::EACL ); |
|
3502 newUriNode.SetDmPropertyL( DevMan::EACL, acl ); |
|
3503 #else |
|
3504 err = iDbSession.DeleteAclL( puri ); |
|
3505 err = iDbSession.UpdateAclL( pnewUri, acl->Ptr( 0 ) ); |
|
3506 #endif |
|
3507 } |
|
3508 else |
|
3509 { |
|
3510 RDEBUG_2("CAmAdapter::CheckStateChangesL: ERROR Failed to get acl from %d ", err ); |
|
3511 } |
|
3512 iManagement.StateChangeComplete( arr[i] ); |
|
3513 break; |
|
3514 } |
|
3515 case EDCSDelivered: |
|
3516 { |
|
3517 RDEBUG( "CAmAdapter::CheckStateChangesLInternal(): Current State = EDCSDelivered" ); |
|
3518 pnewUri.Copy( KDeliveredURI() ); |
|
3519 pnewUri.Append( dc ); |
|
3520 DirectSetMappingL( pnewUri, *luid ); |
|
3521 if ( err == KErrNone ) |
|
3522 { |
|
3523 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3524 iDbSession.OpenNodeL(pnewUri, newUriNode, RDmTree::EReadOnly); |
|
3525 uriNode.RemoveDmPropertyL( DevMan::EACL ); |
|
3526 newUriNode.SetDmPropertyL( DevMan::EACL, acl ); |
|
3527 #else |
|
3528 |
|
3529 err = iDbSession.DeleteAclL( puri ); |
|
3530 err = iDbSession.UpdateAclL( pnewUri, acl->Ptr( 0 ) ); |
|
3531 #endif |
|
3532 } |
|
3533 else |
|
3534 { |
|
3535 RDEBUG_2("CAmAdapter::CheckStateChangesL: ERROR Failed to get acl from %d ", err ); |
|
3536 } |
|
3537 iManagement.StateChangeComplete( arr[i] ); |
|
3538 break; |
|
3539 } |
|
3540 default: |
|
3541 { |
|
3542 |
|
3543 RDEBUG_2("CAmAdapter::CheckStateChangesL: WARNING Illegal state change from delivered to %d ", comp.iState ); |
|
3544 break; |
|
3545 } |
|
3546 } |
|
3547 |
|
3548 } |
|
3549 CleanupStack::PopAndDestroy( luid ); |
|
3550 break; |
|
3551 } |
|
3552 case EDCSActive: |
|
3553 case EDCSInactive: // these both are in same node |
|
3554 { |
|
3555 if (comp.iState == EDCSDelete) |
|
3556 { |
|
3557 puri.Copy( KDeployedURI()); |
|
3558 puri.Append( dc ); |
|
3559 HBufC8 *bufLuid = DirectGetLuidAllocLC( puri ); |
|
3560 TUint32 luid = DesToIntL( *bufLuid ) ; |
|
3561 TRAPD(err,SessionL().RemoveL( luid )); |
|
3562 if ( err == KErrNone || err == KErrNotFound ) |
|
3563 {} |
|
3564 DirectRemoveMappingL(puri); |
|
3565 iManagement.StateChangeComplete( arr[i] ); |
|
3566 CleanupStack::PopAndDestroy(bufLuid); |
|
3567 RDEBUG("CAmAdapter::CheckStateChangesL:DirectRemoveMappingL for comp with istate EDCSDelete " ); |
|
3568 break; |
|
3569 } |
|
3570 RDEBUG_3("CAmAdapter::CheckStateChangesL: No need to move anything in change from %d to %d ", comp.iOldState, comp.iState ); |
|
3571 iManagement.StateChangeComplete( arr[i] ); |
|
3572 break; |
|
3573 } |
|
3574 } |
|
3575 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3576 CleanupStack::PopAndDestroy( &newUriNode ); |
|
3577 CleanupStack::PopAndDestroy( newUri ); |
|
3578 CleanupStack::PopAndDestroy( &uriNode ); |
|
3579 CleanupStack::PopAndDestroy( &acl ); |
|
3580 CleanupStack::PopAndDestroy( uri ); |
|
3581 #else |
|
3582 CleanupStack::PopAndDestroy( newUri ); |
|
3583 CleanupStack::PopAndDestroy( acl ); |
|
3584 CleanupStack::PopAndDestroy( uri ); |
|
3585 #endif |
|
3586 } |
|
3587 else |
|
3588 { |
|
3589 RDEBUG_2("CAmAdapter::CheckStateChangesL: ERROR Failed to get component: %d ", err ); |
|
3590 } |
|
3591 } |
|
3592 iUpdated = ETrue; |
|
3593 } |
|
3594 else |
|
3595 { |
|
3596 RDEBUG_2("CAmAdapter::CheckStateChangesL: ERROR Failed to get state change dcs: %d ", err ); |
|
3597 } |
|
3598 CleanupStack::PopAndDestroy( &arr ); |
|
3599 } |
|
3600 else |
|
3601 { |
|
3602 RDEBUG("CAmAdapter::CheckStateChangesL: Already updated! "); |
|
3603 } |
|
3604 RDEBUG( "CAmAdapter::CheckStateChangesL(): end" ); |
|
3605 #else |
|
3606 DBG_ARGS8( "CAmAdapter::CheckStateChangesL(): disabled" ); |
|
3607 #endif |
|
3608 } |
|
3609 |
|
3610 |
|
3611 // ------------------------------------------------------------------------------------- |
|
3612 // CAmAdapter::CheckStateChangesL() |
|
3613 // Updates acl and mapping trees to match state changes |
|
3614 // ------------------------------------------------------------------------------------- |
|
3615 void CAmAdapter::CheckStateChangesL() |
|
3616 { |
|
3617 iCertRequired = EFalse ; |
|
3618 RDEBUG( "CAmAdapter::CheckStateChangesL(): iCertRequired = EFalse" ); |
|
3619 TRAPD( err, CheckStateChangesInternalL() ); |
|
3620 if ( err != KErrNone ) |
|
3621 { |
|
3622 RDEBUG_2("CAmAdapter::CheckStateChangesL(): warning failed to check state changes %d", err ); |
|
3623 } |
|
3624 iCertRequired = ETrue ; |
|
3625 RDEBUG( "CAmAdapter::CheckStateChangesL(): iCertRequired = ETrue" ); |
|
3626 if ( !iTrustAdded ) |
|
3627 { |
|
3628 RDEBUG( "CAmAdapter::CheckStateChangesL(): Adding Trust Closing Session" ); |
|
3629 iManagement.Close(); |
|
3630 iSessionOpened = EFalse; |
|
3631 RApplicationManagement &session = SessionL(); |
|
3632 RDEBUG( "CAmAdapter::CheckStateChangesL(): Adding Trust new session started" ); |
|
3633 } |
|
3634 } |
|
3635 |
|
3636 |
|
3637 // ------------------------------------------------------------------------------------- |
|
3638 // CAmAdapter::URISegsUpTo(const TDesC8& aURI, TInt aUpTo) |
|
3639 // ------------------------------------------------------------------------------------- |
|
3640 TPtrC8 CAmAdapter::URISegsUpTo( const TDesC8& aURI, TInt aUpTo, TBool aInclKeno/*=EFalse*/) |
|
3641 { |
|
3642 |
|
3643 |
|
3644 |
|
3645 TPtrC8 ret; |
|
3646 TInt numOfURISegs( 0 ); |
|
3647 for( TInt i( 0 ); i < aURI.Length() && ret.Ptr() == NULL; i++ ) |
|
3648 { |
|
3649 if( aURI[i] == KNSmlDMUriSeparator ) |
|
3650 { |
|
3651 numOfURISegs++; |
|
3652 if( aUpTo == numOfURISegs ) |
|
3653 { |
|
3654 if( aInclKeno && aURI.Length() > i+1) |
|
3655 { |
|
3656 ret.Set( aURI.Left( i + 1 ) ); |
|
3657 } |
|
3658 else |
|
3659 { |
|
3660 ret.Set( aURI.Left( i ) ); |
|
3661 } |
|
3662 } |
|
3663 } |
|
3664 } |
|
3665 return ret; |
|
3666 } |
|
3667 |
|
3668 |
|
3669 // ------------------------------------------------------------------------------------- |
|
3670 // CAmAdapter::DirectGetLuidAllocLC( const TDesC8 &aURI ) |
|
3671 // ------------------------------------------------------------------------------------- |
|
3672 HBufC8 *CAmAdapter::DirectGetLuidAllocLC( const TDesC8 &aURI ) |
|
3673 { |
|
3674 |
|
3675 |
|
3676 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3677 HBufC8 *ret = Callback().GetLuidAllocL( aURI ); |
|
3678 #else |
|
3679 HBufC8* ret = iDbSession.GetLuidAllocL( KAMAdapterImplUid, aURI ); |
|
3680 #endif |
|
3681 |
|
3682 CleanupStack::PushL( ret ); |
|
3683 return ret; |
|
3684 } |
|
3685 |
|
3686 |
|
3687 // ------------------------------------------------------------------------------------- |
|
3688 // CAmAdapter::DirectSetMappingL( const TDesC8 &aURI, const TDesC8 &aLUID ) |
|
3689 // ------------------------------------------------------------------------------------- |
|
3690 TInt CAmAdapter::DirectSetMappingL( const TDesC8 &aURI, const TDesC8 &aLUID ) |
|
3691 { |
|
3692 |
|
3693 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3694 TRAPD( err, Callback().SetMappingL( aURI, aLUID ) ); |
|
3695 #else |
|
3696 TInt err( iDbSession.AddMappingInfoL( KAMAdapterImplUid, aURI, aLUID ) ); |
|
3697 #endif |
|
3698 return err; |
|
3699 } |
|
3700 |
|
3701 // ------------------------------------------------------------------------------------- |
|
3702 // CAmAdapter::DirectRemoveMappingL( const TDesC8 &aURI ) |
|
3703 // ------------------------------------------------------------------------------------- |
|
3704 TInt CAmAdapter::DirectRemoveMappingL( const TDesC8 &aURI ) |
|
3705 { |
|
3706 |
|
3707 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3708 TRAPD( err, Callback().SetMappingL( aURI, aLUID ) ); |
|
3709 #else |
|
3710 TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, aURI, ETrue ) ); |
|
3711 #endif |
|
3712 return err; |
|
3713 } |
|
3714 |
|
3715 // ------------------------------------------------------------------------------------- |
|
3716 // CAmAdapter::MoveAclL( const TDesC8 &aFrom, const TDesC8 &aTo ) |
|
3717 // ------------------------------------------------------------------------------------- |
|
3718 void CAmAdapter::MoveAclL( const TDesC8 &aFrom, const TDesC8 &aTo ) |
|
3719 { |
|
3720 |
|
3721 #ifdef __TARM_SYMBIAN_CONVERGENCY |
|
3722 RDmTreeNode from; |
|
3723 CleanupClosePushL(from); |
|
3724 |
|
3725 RDmTreeNode to; |
|
3726 CleanupClosePushL(to); |
|
3727 |
|
3728 RBuf8 acl; |
|
3729 acl.CreateL(128); |
|
3730 CleanupClosePushL(acl); |
|
3731 |
|
3732 iDbSession.OpenNodeL(aFrom, from, RDmTree::EReadOnly); |
|
3733 TRAPD( err, from.DmPropertyL( DevMan::EACL, acl ) ); |
|
3734 if ( err == KErrNone ) |
|
3735 { |
|
3736 iDbSession.OpenNodeL(aTo, to, RDmTree::EReadOnly); |
|
3737 from.RemoveDmPropertyL( DevMan::EACL ); |
|
3738 to.SetDmPropertyL( DevMan::EACL, acl ); |
|
3739 } |
|
3740 CleanupStack::PopAndDestroy( 3, &from ); |
|
3741 #else |
|
3742 CBufBase *acl = CBufFlat::NewL( 128 ); |
|
3743 CleanupStack::PushL( acl ); |
|
3744 TInt err (iDbSession.GetAclL(aFrom, *acl, EFalse ) ); // no need for inherited |
|
3745 if ( err == KErrNone ) |
|
3746 { |
|
3747 err = iDbSession.DeleteAclL( aFrom ); |
|
3748 err = iDbSession.UpdateAclL( aTo, acl->Ptr( 0 ) ); |
|
3749 } |
|
3750 CleanupStack::PopAndDestroy( acl ); |
|
3751 #endif |
|
3752 } |
|
3753 |
|
3754 |
|
3755 // ------------------------------------------------------------------------------------- |
|
3756 // CAmAdapter::SetMappingL( const TDesC8 &aOriginalURI, |
|
3757 // const TDeploymentComponentState aTargetState, const TDesC8 &aLUID ) |
|
3758 // ------------------------------------------------------------------------------------- |
|
3759 void CAmAdapter::SetMappingL( const TDesC8 &aOriginalURI, |
|
3760 const TDeploymentComponentState aTargetState, const TDesC8 &aLUID ) |
|
3761 { |
|
3762 |
|
3763 |
|
3764 HBufC8 * targeturi = NULL; |
|
3765 SetMappingLC( aOriginalURI, aTargetState, aLUID, targeturi ); |
|
3766 CleanupStack::PopAndDestroy( targeturi ); |
|
3767 } |
|
3768 |
|
3769 |
|
3770 // ------------------------------------------------------------------------------------- |
|
3771 // CAmAdapter::SetMappingLC( const TDesC8 &aOriginalURI, |
|
3772 // const TDeploymentComponentState aTargetState, const TDesC8 &aLUID, |
|
3773 // HBufC8 *&aNewUri ) |
|
3774 // ------------------------------------------------------------------------------------- |
|
3775 void CAmAdapter::SetMappingLC( const TDesC8 &aOriginalURI, |
|
3776 const TDeploymentComponentState aTargetState, const TDesC8 &aLUID, HBufC8 *&aNewUri ) |
|
3777 { |
|
3778 |
|
3779 |
|
3780 // "Nullify" the mapping for argument |
|
3781 DirectSetMappingL( aOriginalURI, KNullDesC8 ); |
|
3782 |
|
3783 // Determine new uri for aArgument |
|
3784 TPtrC8 puri; |
|
3785 if ( aNewUri == NULL ) |
|
3786 { |
|
3787 TPtrC8 argMapping( NSmlDmURI::LastURISeg( aOriginalURI ) ); |
|
3788 TPtrC8 target; |
|
3789 if ( aTargetState == EDCSInactive || aTargetState == EDCSActive ) |
|
3790 { |
|
3791 target.Set( KDeployedURI() ); |
|
3792 } |
|
3793 else if ( aTargetState == EDCSDelivered ) |
|
3794 { |
|
3795 target.Set( KDeliveredURI() ); |
|
3796 } |
|
3797 else |
|
3798 { |
|
3799 |
|
3800 User::Leave( KErrArgument ); |
|
3801 } |
|
3802 |
|
3803 aNewUri = HBufC8::NewLC( target.Length() + argMapping.Length() ); |
|
3804 TPtr8 p( aNewUri->Des() ); |
|
3805 p.Copy( target ); |
|
3806 p.Append( argMapping ); |
|
3807 puri.Set( p ); |
|
3808 } |
|
3809 else |
|
3810 { |
|
3811 puri.Set( *aNewUri ); |
|
3812 } |
|
3813 DirectSetMappingL( puri, aLUID ); |
|
3814 MoveAclL( aOriginalURI, puri ); |
|
3815 } |
|
3816 |
|
3817 |
|
3818 #ifdef __AM_LASTERROR_NODE |
|
3819 // ------------------------------------------------------------------------------------------------ |
|
3820 // CAmAdapter::SetLastErrorL( const TDesC8& aLastError, const TInt aError ) |
|
3821 // ------------------------------------------------------------------------------------------------ |
|
3822 void CAmAdapter::SetLastErrorL( const TDesC8& aLastError, const TInt aError ) |
|
3823 { |
|
3824 if ( iLastError ) |
|
3825 { |
|
3826 TPtrC8 p(*iLastError); |
|
3827 RDEBUG8_2( "CAmAdapter::SetLastErrorL: clearing last error %S", &p); |
|
3828 delete iLastError; |
|
3829 iLastError = NULL; |
|
3830 } |
|
3831 iLastError = HBufC8::NewL( aLastError.Length() + 10); |
|
3832 iLastError->Des().Format( aLastError, aError ); |
|
3833 } |
|
3834 |
|
3835 const TDesC8& CAmAdapter::LastError() |
|
3836 { |
|
3837 return iLastError == NULL ? KNullDesC8() : *iLastError; |
|
3838 } |
|
3839 |
|
3840 #endif |
|
3841 |
|
3842 TPtrC8 CAmAdapter::LastURISeg(const TDesC8& aURI) |
|
3843 { |
|
3844 TInt i; |
|
3845 for(i=aURI.Length()-1;i>=0;i--) |
|
3846 { |
|
3847 if(aURI[i]==KNSmlDMAMSeparatorDef) |
|
3848 { |
|
3849 break; |
|
3850 } |
|
3851 } |
|
3852 if(i==0) |
|
3853 { |
|
3854 return aURI; |
|
3855 } |
|
3856 else |
|
3857 { |
|
3858 return aURI.Mid(i+1); |
|
3859 } |
|
3860 } |
|
3861 |
|
3862 TInt CAmAdapter::DesToInt(const TDesC8& aLuid) |
|
3863 { |
|
3864 TLex8 lex(aLuid); |
|
3865 TInt value = 0; |
|
3866 lex.Val(value); |
|
3867 return value; |
|
3868 } |
|
3869 TInt CAmAdapter::GetAdapterValue() |
|
3870 { |
|
3871 TInt adapterValue; |
|
3872 CRepository *repository = NULL; |
|
3873 TRAPD( err, repository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) ); |
|
3874 if (err == KErrNone) |
|
3875 { |
|
3876 err = repository->Get(KAMAdapterValue, adapterValue); |
|
3877 } |
|
3878 delete repository; |
|
3879 repository = NULL; |
|
3880 return adapterValue; |
|
3881 } |
|
3882 |
|
3883 void CAmAdapter::SetAdapterValue(TInt aAdapterValue) |
|
3884 { |
|
3885 |
|
3886 CRepository *repository = NULL; |
|
3887 TRAPD( err, repository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) ); |
|
3888 if (err == KErrNone) |
|
3889 { |
|
3890 err = repository->Set(KAMAdapterValue, aAdapterValue); |
|
3891 } |
|
3892 delete repository; |
|
3893 repository = NULL; |
|
3894 } |
|
3895 |
|
3896 // End of File |
|
3897 |