|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: DM Fota Adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <implementationproxy.h> // For TImplementationProxy definition |
|
23 //#ifdef RD_OMADMAPPUI_UI_EVOLUTION |
|
24 #include <DevManInternalCRKeys.h> |
|
25 //#endif |
|
26 #include <SyncMLClient.h> |
|
27 #include <SyncMLClientDM.h> |
|
28 #include <e32property.h> |
|
29 #include <centralrepository.h> |
|
30 #include "fotaadapterCRKeys.h" |
|
31 #include "NSmlPrivateAPI.h" |
|
32 #include "nsmldmimpluids.h" |
|
33 #include "nsmldmfotaadapter.h" |
|
34 #include "nsmldmconst.h" |
|
35 #include "nsmldebug.h" |
|
36 #include "FotaSrvDebug.h" |
|
37 #include "nsmldmtreedbclient.h" |
|
38 #include <nsmldmconst.h> |
|
39 |
|
40 // =========================== MEMBER FUNCTIONS ============================== |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CNSmlDmFotaAdapter* CNSmlDmFotaAdapter::NewL() |
|
44 // Creates new instance of CNSmlDmFotaEngine and returns a pointer to it. |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CNSmlDmFotaAdapter* CNSmlDmFotaAdapter::NewL( MSmlDmCallback* aDmCallback ) |
|
48 { |
|
49 _DBG_FILE("CNSmlDmFotaAdapter::NewL(): begin"); |
|
50 FLOG(_L("CNSmlDmFotaAdapter::NewL >>")); |
|
51 CNSmlDmFotaAdapter* self = NewLC( aDmCallback ); |
|
52 CleanupStack::Pop( self ); |
|
53 _DBG_FILE("CNSmlDmFotaAdapter::NewL(): end"); |
|
54 FLOG(_L("CNSmlDmFotaAdapter::NewL <<")); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CNSmlDmFotaAdapter* CNSmlDmFotaAdapter::NewLC() |
|
60 // Creates new instance of CNSmlDmFotaEngine and returns a pointer to it. |
|
61 // Leaves the pointer onto the CleanupStack. |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CNSmlDmFotaAdapter* CNSmlDmFotaAdapter::NewLC( MSmlDmCallback* aDmCallback ) |
|
65 { |
|
66 _DBG_FILE("CNSmlDmFotaAdapter::NewLC(): begin"); |
|
67 CNSmlDmFotaAdapter* self = new (ELeave) CNSmlDmFotaAdapter( aDmCallback ); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 _DBG_FILE("CNSmlDmFotaAdapter::NewLC(): end"); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CNSmlDmFotaAdapter::CNSmlDmFotaAdapter() |
|
76 // Constructor. |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 CNSmlDmFotaAdapter::CNSmlDmFotaAdapter( TAny* aEcomArguments ) |
|
80 : CSmlDmAdapter( aEcomArguments ), iPkgId( KNSmlDMFotaNullPkgId ) |
|
81 { |
|
82 _DBG_FILE("CNSmlDmFotaAdapter::CNSmlDmFotaAdapter(): begin"); |
|
83 _DBG_FILE("CNSmlDmFotaAdapter::CNSmlDmFotaAdapter(): end"); |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CNSmlDmFotaAdapter::ConstructL() |
|
88 // Second phase construction. |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CNSmlDmFotaAdapter::ConstructL() |
|
92 { |
|
93 // Check if Fota feature is defined |
|
94 TInt value( 0 ); |
|
95 CRepository * rep = CRepository::NewLC( KCRUidFotaAdapter ); |
|
96 TInt err = rep->Get( KCRFotaAdapterEnabled, value ); |
|
97 CleanupStack::PopAndDestroy( rep ); |
|
98 |
|
99 if ( err != KErrNone || value == 0 ) |
|
100 { |
|
101 User::Leave( KErrNotSupported ); |
|
102 } |
|
103 |
|
104 iFotaDb = CNSmlDmFotaAdapterDb::NewL(); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter() |
|
109 // Destructor. |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter() |
|
113 { |
|
114 _DBG_FILE("CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter(): begin"); |
|
115 FLOG(_L("CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter >>")); |
|
116 |
|
117 if (iFotaEngine.Handle()) |
|
118 iFotaEngine.Close(); |
|
119 |
|
120 delete iFotaDb; |
|
121 FLOG(_L("CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter <<")); |
|
122 _DBG_FILE("CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter(): end"); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CNSmlDmFotaAdapter::DDFVersionL() |
|
127 // Returns the DDF version of the adapter. |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CNSmlDmFotaAdapter::DDFVersionL( CBufBase& aDDFVersion ) |
|
131 { |
|
132 _DBG_FILE("CNSmlDmFotaAdapter::DDFVersionL(TDes& aDDFVersion): begin"); |
|
133 |
|
134 aDDFVersion.InsertL( 0, KNSmlDMFotaDDFVersion ); |
|
135 |
|
136 _DBG_FILE("CNSmlDmFotaAdapter::DDFVersionL(TDes& aDDFVersion): end"); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CNSmlDmFotaAdapter::DDFStructureL() |
|
141 // Builds the DDF structure of adapter. |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CNSmlDmFotaAdapter::DDFStructureL( MSmlDmDDFObject& aDDF ) |
|
145 { |
|
146 _DBG_FILE("CNSmlDmFotaAdapter::DDFStructureL(): begin"); |
|
147 FLOG(_L("CNSmlDmFotaAdapter::DDFStructureL >>")); |
|
148 TSmlDmAccessTypes accessTypes; |
|
149 |
|
150 // fota root |
|
151 MSmlDmDDFObject& FUMO = aDDF.AddChildObjectL( KNSmlDMFotaNode ); |
|
152 accessTypes.SetAdd(); |
|
153 accessTypes.SetGet(); |
|
154 FillNodeInfoL( FUMO, |
|
155 accessTypes, |
|
156 MSmlDmDDFObject::EOne, |
|
157 MSmlDmDDFObject::EPermanent, |
|
158 MSmlDmDDFObject::ENode, |
|
159 KNSmlDMFotaNodeDescription ); |
|
160 |
|
161 accessTypes.Reset(); |
|
162 |
|
163 // run time node <X> |
|
164 MSmlDmDDFObject& rtPkg = FUMO.AddChildObjectGroupL(); |
|
165 rtPkg.AddDFTypeMimeTypeL( KNSmlDMFotaRunTimeMimeType ); |
|
166 accessTypes.SetAdd(); |
|
167 accessTypes.SetDelete(); |
|
168 accessTypes.SetGet(); |
|
169 //accessTypes.SetReplace(); |
|
170 FillNodeInfoL( rtPkg, |
|
171 accessTypes, |
|
172 MSmlDmDDFObject::EZeroOrMore, |
|
173 MSmlDmDDFObject::EDynamic, |
|
174 MSmlDmDDFObject::ENode, |
|
175 KNSmlDMFotaRunTimeNodeDescription ); |
|
176 |
|
177 accessTypes.Reset(); |
|
178 |
|
179 // <X>/PkgName |
|
180 MSmlDmDDFObject& name = rtPkg.AddChildObjectL( KNSmlDMFotaNodeName ); |
|
181 accessTypes.SetAdd(); |
|
182 accessTypes.SetGet(); |
|
183 accessTypes.SetReplace(); |
|
184 FillNodeInfoL( name, |
|
185 accessTypes, |
|
186 MSmlDmDDFObject::EZeroOrOne, |
|
187 MSmlDmDDFObject::EDynamic, |
|
188 MSmlDmDDFObject::EChr, |
|
189 KNSmlDMFotaNodeNameDescription ); |
|
190 |
|
191 // <X>/PkgVersion |
|
192 MSmlDmDDFObject& version = rtPkg.AddChildObjectL( KNSmlDMFotaNodeVersion ); |
|
193 FillNodeInfoL( version, |
|
194 accessTypes, |
|
195 MSmlDmDDFObject::EZeroOrOne, |
|
196 MSmlDmDDFObject::EDynamic, |
|
197 MSmlDmDDFObject::EChr, |
|
198 KNSmlDMFotaNodeVersionDescription ); |
|
199 |
|
200 accessTypes.Reset(); |
|
201 |
|
202 // <X>/Download |
|
203 MSmlDmDDFObject& download = |
|
204 rtPkg.AddChildObjectL( KNSmlDMFotaNodeDownload ); |
|
205 |
|
206 accessTypes.SetGet(); |
|
207 accessTypes.SetExec(); |
|
208 FillNodeInfoL( download, |
|
209 accessTypes, |
|
210 MSmlDmDDFObject::EZeroOrOne, |
|
211 MSmlDmDDFObject::EDynamic, |
|
212 MSmlDmDDFObject::ENode, |
|
213 KNSmlDMFotaNodeDownloadDescription ); |
|
214 |
|
215 accessTypes.Reset(); |
|
216 |
|
217 // <X>/Download/PkgURL |
|
218 MSmlDmDDFObject& dlUrl = |
|
219 download.AddChildObjectL( KNSmlDMFotaNodeDownloadUrl ); |
|
220 |
|
221 accessTypes.SetGet(); |
|
222 accessTypes.SetReplace(); |
|
223 FillNodeInfoL( dlUrl, |
|
224 accessTypes, |
|
225 MSmlDmDDFObject::EOne, |
|
226 MSmlDmDDFObject::EDynamic, |
|
227 MSmlDmDDFObject::EChr, |
|
228 KNSmlDMFotaNodeDownloadUrlDescription ); |
|
229 |
|
230 accessTypes.Reset(); |
|
231 |
|
232 |
|
233 // <X>/DownloadAndUpdate |
|
234 MSmlDmDDFObject& dlAndUpdate = |
|
235 rtPkg.AddChildObjectL( KNSmlDMFotaNodeDownloadAndUpdate ); |
|
236 |
|
237 accessTypes.SetGet(); |
|
238 accessTypes.SetExec(); |
|
239 FillNodeInfoL( dlAndUpdate, |
|
240 accessTypes, |
|
241 MSmlDmDDFObject::EZeroOrOne, |
|
242 MSmlDmDDFObject::EDynamic, |
|
243 MSmlDmDDFObject::ENode, |
|
244 KNSmlDMFotaNodeDownloadAndUpdateDescription ); |
|
245 |
|
246 accessTypes.Reset(); |
|
247 |
|
248 // <X>/DownloadAndUpdate/PkgURL |
|
249 MSmlDmDDFObject& dlAndUpdateUrl = |
|
250 dlAndUpdate.AddChildObjectL( KNSmlDMFotaNodeDownloadAndUpdateUrl ); |
|
251 |
|
252 accessTypes.SetGet(); |
|
253 accessTypes.SetReplace(); |
|
254 FillNodeInfoL( dlAndUpdateUrl, |
|
255 accessTypes, |
|
256 MSmlDmDDFObject::EOne, |
|
257 MSmlDmDDFObject::EDynamic, |
|
258 MSmlDmDDFObject::EChr, |
|
259 KNSmlDMFotaNodeDownloadAndUpdateUrlDescription ); |
|
260 |
|
261 accessTypes.Reset(); |
|
262 |
|
263 // <X>/State |
|
264 MSmlDmDDFObject& state = rtPkg.AddChildObjectL( KNSmlDMFotaNodeState ); |
|
265 accessTypes.SetGet(); |
|
266 FillNodeInfoL( state, |
|
267 accessTypes, |
|
268 MSmlDmDDFObject::EOne, |
|
269 MSmlDmDDFObject::EDynamic, |
|
270 MSmlDmDDFObject::EInt, |
|
271 KNSmlDMFotaNodeStateDescription ); |
|
272 |
|
273 |
|
274 |
|
275 //Check cenrep for predefined node and add if its not in DB |
|
276 CheckAndAddPredefinedNodeL(); |
|
277 |
|
278 // check if there is need to make generic alert(s), |
|
279 // and generate them if there are |
|
280 MakeGenericAlertsL(); |
|
281 |
|
282 |
|
283 // Set ACL for fota root, if not yet set |
|
284 RNSmlDMCallbackSession session; |
|
285 User::LeaveIfError( session.Connect() ); |
|
286 CleanupClosePushL(session); |
|
287 |
|
288 CBufBase* acl=CBufFlat::NewL(10); |
|
289 CleanupStack::PushL( acl ); |
|
290 TInt err = session.GetAclL( KNSmlDMFotaNode,*acl,EFalse ); |
|
291 if ( err == KErrNone) |
|
292 { |
|
293 if( acl->Size() == 0 ) |
|
294 { |
|
295 _LIT8(KACLForAll, "Add=*&Get=*&Delete=*&Exec=*&Replace=*"); |
|
296 session.UpdateAclL( KNSmlDMFotaNode, KACLForAll); |
|
297 } |
|
298 } |
|
299 CleanupStack::PopAndDestroy( acl ); |
|
300 CleanupStack::PopAndDestroy( &session ); |
|
301 |
|
302 _DBG_FILE("CNSmlDmFotaAdapter::DDFStructureL(): end"); |
|
303 FLOG(_L("CNSmlDmFotaAdapter::DDFStructureL <<")); |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // CNSmlDmFotaAdapter::UpdateLeafObjectL() |
|
308 // Updates value of leaf object. |
|
309 // --------------------------------------------------------------------------- |
|
310 // |
|
311 void CNSmlDmFotaAdapter::UpdateLeafObjectL( const TDesC8& aURI, |
|
312 const TDesC8& aLUID, |
|
313 const TDesC8& aObject, |
|
314 const TDesC8& /*aType*/, |
|
315 const TInt aStatusRef ) |
|
316 { |
|
317 _DBG_FILE("CNSmlDmFotaAdapter::UpdateLeafObjectL(): begin"); |
|
318 FLOG(_L("CNSmlDmFotaAdapter::UpdateLeafObjectL >>")); |
|
319 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
320 |
|
321 if ( aLUID.Length() > 0 ) |
|
322 { |
|
323 TInt res = KErrNotFound; |
|
324 TNSmlDmFwObjectId id = DesToInt( aLUID ); |
|
325 |
|
326 TPtrC8 lastSeg = LastURISeg( aURI ); |
|
327 if ( lastSeg == KNSmlDMFotaNodeName ) |
|
328 { |
|
329 res = iFotaDb->SetPkgNameL( aObject, id ); |
|
330 } |
|
331 else if ( lastSeg == KNSmlDMFotaNodeVersion ) |
|
332 { |
|
333 res = iFotaDb->SetPkgVersionL( aObject, id ); |
|
334 } |
|
335 else if ( lastSeg == KNSmlDMFotaNodeDownloadUrl || |
|
336 lastSeg == KNSmlDMFotaNodeDownloadAndUpdateUrl ) |
|
337 { |
|
338 TInt configFlags( KErrNone ); |
|
339 CRepository* centrep = NULL; |
|
340 TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ) ); |
|
341 if ( err == KErrNone && centrep ) |
|
342 { |
|
343 configFlags = 2; //means fota operation |
|
344 centrep->Set( KDevManSessionType, configFlags ); |
|
345 delete centrep; |
|
346 centrep = NULL; |
|
347 } |
|
348 else |
|
349 { |
|
350 User::Leave( err ); |
|
351 } |
|
352 res = iFotaDb->SetPkgUrlL( aObject, id ); |
|
353 } |
|
354 // map error |
|
355 status = MapErrorToStatus( res ); |
|
356 } |
|
357 else |
|
358 { |
|
359 // cannot update, object unknown |
|
360 status = CSmlDmAdapter::ENotFound; |
|
361 } |
|
362 #ifdef __WINS__ |
|
363 TInt pos=-1; |
|
364 pos = aURI.Find(KNSmlDMFotaNodeDownload); |
|
365 |
|
366 if (status == CSmlDmAdapter::EOk && pos != KErrNotFound) |
|
367 { |
|
368 if ( aURI.Find(KNSmlDMFotaNodeDownloadAndUpdate) !=KErrNotFound) |
|
369 ExecuteCommandL(_L8("./FUMO/FWUpdate/DownloadAndUpdate"),aLUID,aObject,_L8(""),status); |
|
370 else |
|
371 ExecuteCommandL(_L8("./FUMO/FWUpdate/Download"),aLUID,aObject,_L8(""),status); |
|
372 } |
|
373 #endif |
|
374 |
|
375 Callback().SetStatusL( aStatusRef, status ); |
|
376 |
|
377 _DBG_FILE("CNSmlDmFotaAdapter::UpdateLeafObjectL(): end"); |
|
378 FLOG(_L("CNSmlDmFotaAdapter::UpdateLeafObjectL <<")); |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // CNSmlDmFotaAdapter::DeleteObjectL() |
|
383 // Deletes a firmware object from Fota database. |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 void CNSmlDmFotaAdapter::DeleteObjectL( const TDesC8& aURI, |
|
387 const TDesC8& aLUID, |
|
388 const TInt aStatusRef ) |
|
389 { |
|
390 _DBG_FILE("CNSmlDmFotaAdapter::DeleteLeafObjectL( ): begin"); |
|
391 FLOG(_L("CNSmlDmFotaAdapter::DeleteObjectL >>")); |
|
392 |
|
393 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
394 |
|
395 if ( ( aURI.Match( KNSmlDMFotaRuntimeMatch ) != KErrNotFound ) && |
|
396 ( aLUID.Length() > 0 ) ) |
|
397 { |
|
398 TBuf8<KMaxFullName> temp; |
|
399 GetPredefinedNodeL(temp); |
|
400 TBuf8<KMaxName> node[4]; |
|
401 TInt location = temp.LocateReverse(','); |
|
402 node[0].Copy(temp.Mid(location+1)); |
|
403 TInt newLocation = (temp.Left(location-1)).LocateReverse(','); |
|
404 node[1].Copy(temp.Mid(newLocation+1,location-(newLocation+1))); |
|
405 location = newLocation; |
|
406 newLocation = (temp.Left(location-1)).LocateReverse(','); |
|
407 node[2].Copy(temp.Mid(newLocation+1,location-(newLocation+1))); |
|
408 node[3].Copy(temp.Mid(0,newLocation )); |
|
409 for(TInt i =0 ; i<4; i++) |
|
410 { |
|
411 if (node[i].Length() && aURI.Find( node[i] ) != KErrNotFound) |
|
412 { |
|
413 status = CSmlDmAdapter::ENotAllowed; |
|
414 Callback().SetStatusL( aStatusRef, status ); |
|
415 return; |
|
416 } |
|
417 } |
|
418 // delete object identified by aLUID |
|
419 TNSmlDmFwObjectId id = DesToInt( aLUID ); |
|
420 TInt res = iFotaDb->DeleteFwObjectL( id ); |
|
421 |
|
422 if ( res == KErrNone ) |
|
423 { |
|
424 // deletion was successful, delete also from Fota Engine |
|
425 FotaEngineL().DeleteUpdatePackage( id ); |
|
426 } |
|
427 else |
|
428 { |
|
429 status = MapErrorToStatus( res ); |
|
430 } |
|
431 } |
|
432 else |
|
433 { |
|
434 // object unknown |
|
435 status = CSmlDmAdapter::ENotFound; |
|
436 } |
|
437 |
|
438 Callback().SetStatusL( aStatusRef, status ); |
|
439 |
|
440 _DBG_FILE("CNSmlDmFotaAdapter::DeleteLeafObjectL( ): end"); |
|
441 FLOG(_L("CNSmlDmFotaAdapter::DeleteObjectL <<")); |
|
442 } |
|
443 |
|
444 // --------------------------------------------------------------------------- |
|
445 // CNSmlDmFotaAdapter::FetchLeafObjectL() |
|
446 // Fetches the values of leaf objects. |
|
447 // --------------------------------------------------------------------------- |
|
448 // |
|
449 void CNSmlDmFotaAdapter::FetchLeafObjectL( const TDesC8& aURI, |
|
450 const TDesC8& aLUID, |
|
451 const TDesC8& aType, |
|
452 const TInt aResultsRef, |
|
453 const TInt aStatusRef ) |
|
454 { |
|
455 _DBG_FILE("CNSmlDmFotaAdapter::FetchLeafObjectL(): begin"); |
|
456 FLOG(_L("CNSmlDmFotaAdapter::FetchLeafObjectL >>")); |
|
457 // buffer for result |
|
458 CBufBase* result = CBufFlat::NewL( KNSmlDMFotaResultBufferExpandSize ); |
|
459 CleanupStack::PushL( result ); |
|
460 |
|
461 // fetch data |
|
462 CSmlDmAdapter::TError status = DoFetchObjectL( aURI, aLUID, *result ); |
|
463 if ( status == CSmlDmAdapter::EOk ) |
|
464 { |
|
465 Callback().SetResultsL( aResultsRef, *result, aType ); |
|
466 } |
|
467 |
|
468 CleanupStack::PopAndDestroy( result ); |
|
469 |
|
470 Callback().SetStatusL( aStatusRef, status ); |
|
471 |
|
472 _DBG_FILE("CNSmlDmFotaAdapter::FetchLeafObjectL(): end"); |
|
473 FLOG(_L("CNSmlDmFotaAdapter::FetchLeafObjectL <<")); |
|
474 } |
|
475 |
|
476 // --------------------------------------------------------------------------- |
|
477 // CNSmlDmFotaAdapter::ChildURIListL() |
|
478 // Returns the list of children of a node. |
|
479 // --------------------------------------------------------------------------- |
|
480 // |
|
481 void CNSmlDmFotaAdapter::ChildURIListL( const TDesC8& aURI, |
|
482 const TDesC8& aLUID, |
|
483 const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, |
|
484 const TInt aResultsRef, |
|
485 const TInt aStatusRef ) |
|
486 { |
|
487 _DBG_FILE("CNSmlDmFotaAdapter::ChildURIListL(): begin"); |
|
488 FLOG(_L("CNSmlDmFotaAdapter::ChildURIListL >>")); |
|
489 |
|
490 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
491 TPtrC8 mimeType( KNullDesC8 ); |
|
492 |
|
493 // buffer for result |
|
494 CBufBase* result = CBufFlat::NewL( KNSmlDMFotaResultBufferExpandSize ); |
|
495 CleanupStack::PushL( result ); |
|
496 |
|
497 TPtrC8 lastSeg = LastURISeg( aURI ); |
|
498 if ( lastSeg == KNSmlDMFotaNodeDownload && aLUID.Length() > 0 ) |
|
499 { |
|
500 // target is ./FUMO/<x>/Download |
|
501 result->InsertL( 0, KNSmlDMFotaNodeDownloadUrl ); |
|
502 } |
|
503 else if ( lastSeg == KNSmlDMFotaNodeDownloadAndUpdate && aLUID.Length() > 0 ) |
|
504 { |
|
505 // target is ./FUMO/<x>/DownloadAndUpdate |
|
506 result->InsertL( 0, KNSmlDMFotaNodeDownloadAndUpdateUrl ); |
|
507 } |
|
508 else if ( ( aURI.Match( KNSmlDMFotaRuntimeMatch ) != KErrNotFound ) |
|
509 && ( TableExistsL( aLUID ) ) ) |
|
510 { |
|
511 // target is ./FUMO/<x> |
|
512 result->InsertL( 0, KNSmlDMFotaRunTimeChildren ); |
|
513 mimeType.Set( KNSmlDMFotaRunTimeMimeType ); |
|
514 } |
|
515 else if ( aURI.Match( KNSmlDMFotaRootMatch ) != KErrNotFound ) |
|
516 { |
|
517 // target is ./FUMO |
|
518 |
|
519 // return the children listed in aPreviousURISegmentList |
|
520 TInt childCount = aPreviousURISegmentList.Count(); |
|
521 for ( TInt i = 0; i < childCount - 1; ++i ) |
|
522 { |
|
523 result->InsertL( result->Size(), aPreviousURISegmentList[i].iURISeg ); |
|
524 result->InsertL( result->Size(), KNSmlDMFotaSeparatorDes ); |
|
525 } |
|
526 |
|
527 if ( childCount ) |
|
528 { |
|
529 // insert last child without separator |
|
530 result->InsertL( result->Size(), |
|
531 aPreviousURISegmentList[ childCount - 1 ].iURISeg ); |
|
532 } |
|
533 |
|
534 } |
|
535 else |
|
536 { |
|
537 // invalid target |
|
538 status = CSmlDmAdapter::ENotFound; |
|
539 } |
|
540 |
|
541 // set result, if it was found |
|
542 if ( status == CSmlDmAdapter::EOk ) |
|
543 { |
|
544 Callback().SetResultsL( aResultsRef, *result, mimeType ); |
|
545 } |
|
546 |
|
547 Callback().SetStatusL( aStatusRef, status ); |
|
548 |
|
549 CleanupStack::PopAndDestroy( result ); |
|
550 |
|
551 _DBG_FILE("CNSmlDmFotaAdapter::ChildURIListL(): end"); |
|
552 FLOG(_L("CNSmlDmFotaAdapter::ChildURIListL <<")); |
|
553 } |
|
554 |
|
555 |
|
556 |
|
557 // --------------------------------------------------------------------------- |
|
558 // CNSmlDmFotaAdapter::TableExistsL(const TDesC8& aLUID) const |
|
559 // Checks if table exists |
|
560 // --------------------------------------------------------------------------- |
|
561 // |
|
562 TBool CNSmlDmFotaAdapter::TableExistsL(const TDesC8& aLUID) const |
|
563 { |
|
564 TBool ret = EFalse; |
|
565 if(aLUID.Length()>0) |
|
566 { |
|
567 TNSmlDmFwObjectId luid = DesToInt( aLUID ); |
|
568 TSmlProfileId profileId = iFotaDb->ProfileIdL(luid); |
|
569 if (profileId!=KErrNotFound) |
|
570 { |
|
571 ret = ETrue; |
|
572 } |
|
573 } |
|
574 return ret; |
|
575 } |
|
576 |
|
577 // |
|
578 // --------------------------------------------------------------------------- |
|
579 // CNSmlDmFotaAdapter::AddNodeObjectL() |
|
580 // Adds new row to firmware object table in Fota database. |
|
581 // --------------------------------------------------------------------------- |
|
582 // |
|
583 void CNSmlDmFotaAdapter::AddNodeObjectL( const TDesC8& aURI, |
|
584 const TDesC8& aParentLUID, |
|
585 const TInt aStatusRef ) |
|
586 { |
|
587 _DBG_FILE("CNSmlDmFotaAdapter::AddNodeObjectL(): begin"); |
|
588 |
|
589 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
590 |
|
591 // Luid specified and it's a valid luid => already exists |
|
592 if ( TableExistsL( aParentLUID ) ) |
|
593 { |
|
594 // the object has already been created and mapping set to DM Framework |
|
595 status = CSmlDmAdapter::EAlreadyExists; |
|
596 } |
|
597 else if ( aURI.Match( KNSmlDMFotaRuntimeMatch ) != KErrNotFound ) |
|
598 { |
|
599 TInt configFlags( KErrNone ); |
|
600 CRepository* centrep = NULL; |
|
601 TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ) ); |
|
602 if ( err == KErrNone && centrep ) |
|
603 { |
|
604 configFlags = 2; //means fota operation |
|
605 centrep->Set( KDevManSessionType, configFlags ); |
|
606 delete centrep; |
|
607 centrep = NULL; |
|
608 } |
|
609 else |
|
610 { |
|
611 User::Leave( err ); |
|
612 } |
|
613 |
|
614 |
|
615 // add new FW object to db |
|
616 TNSmlDmFwObjectId newId = KErrNotFound; |
|
617 TRAP( err, newId = iFotaDb->AddFwObjectL() ); |
|
618 |
|
619 if ( err == KErrNone ) |
|
620 { |
|
621 // added ok |
|
622 TBuf8<KNSmlFwMgmtObjectIntegerLength> newLUID; |
|
623 newLUID.AppendNum( newId ); |
|
624 |
|
625 Callback().SetMappingL( aURI, newLUID ); |
|
626 } |
|
627 else |
|
628 { |
|
629 status = MapErrorToStatus( err ); |
|
630 } |
|
631 |
|
632 } |
|
633 else |
|
634 { |
|
635 // error, invalid uri |
|
636 status = CSmlDmAdapter::ENotFound; |
|
637 } |
|
638 |
|
639 Callback().SetStatusL( aStatusRef, status ); |
|
640 // if(status==CSmlDmAdapter::EOk) |
|
641 // { |
|
642 // TSmlProfileId profId = KErrNotFound; |
|
643 // HBufC8* serverId = NULL; |
|
644 // |
|
645 // GetServerInfoL( profId, serverId ); |
|
646 // |
|
647 // if(serverId) |
|
648 // { |
|
649 // CleanupStack::PushL( serverId ); |
|
650 // |
|
651 // _LIT( KFotaAclAdd, "Add="); |
|
652 // _LIT( KFotaAclGet, "Get="); |
|
653 // _LIT( KFotaAclReplace, "Replace="); |
|
654 // _LIT( KFotaAclDelete, "Delete="); |
|
655 // _LIT( KFotaAclExec, "Exec="); |
|
656 // _LIT( KFotaAclSeparator, "&"); |
|
657 // _LIT( KFotaAclForAll, "*"); |
|
658 // |
|
659 // const TUint length = KFotaAclAdd().Length() + |
|
660 // KFotaAclGet().Length() + |
|
661 // KFotaAclReplace().Length() + |
|
662 // KFotaAclDelete().Length() + |
|
663 // KFotaAclExec().Length() + |
|
664 // serverId->Length()*4 + |
|
665 // 5; /* 4*'&'+ ''*' */ |
|
666 // |
|
667 // HBufC8* acl = HBufC8::NewLC(length); |
|
668 // TPtr8 acltPtr = acl->Des(); |
|
669 // acltPtr.Append(KFotaAclAdd); |
|
670 // acltPtr.Append(*serverId); |
|
671 // acltPtr.Append(KFotaAclSeparator); |
|
672 // |
|
673 // acltPtr.Append(KFotaAclGet); |
|
674 // acltPtr.Append(*serverId); |
|
675 // acltPtr.Append(KFotaAclSeparator); |
|
676 // |
|
677 // acltPtr.Append(KFotaAclReplace); |
|
678 // acltPtr.Append(*serverId); |
|
679 // acltPtr.Append(KFotaAclSeparator); |
|
680 // |
|
681 // acltPtr.Append(KFotaAclDelete); |
|
682 // acltPtr.Append(KFotaAclForAll); |
|
683 // acltPtr.Append(KFotaAclSeparator); |
|
684 // |
|
685 // acltPtr.Append(KFotaAclExec); |
|
686 // acltPtr.Append(*serverId); |
|
687 // |
|
688 // RNSmlDMCallbackSession session; |
|
689 // User::LeaveIfError( session.Connect() ); |
|
690 // CleanupClosePushL(session); |
|
691 // session.UpdateAclL(aURI,*acl); |
|
692 // CleanupStack::PopAndDestroy( &session ); |
|
693 // CleanupStack::PopAndDestroy( acl ); |
|
694 // CleanupStack::PopAndDestroy( serverId ); |
|
695 // } |
|
696 // } |
|
697 |
|
698 _DBG_FILE("CNSmlDmFotaAdapter::AddNodeObjectL(): end"); |
|
699 } |
|
700 |
|
701 // --------------------------------------------------------------------------- |
|
702 // CNSmlDmFotaAdapter::UpdateLeafObjectL() |
|
703 // Updates a leaf object using streaming. In Fota adapter this method is used |
|
704 // only to update PkgData of a firmware object. |
|
705 // --------------------------------------------------------------------------- |
|
706 // |
|
707 void CNSmlDmFotaAdapter::UpdateLeafObjectL( const TDesC8& aURI, |
|
708 const TDesC8& aLUID, |
|
709 RWriteStream*& aStream, |
|
710 const TDesC8& /*aType*/, |
|
711 const TInt aStatusRef ) |
|
712 { |
|
713 _DBG_FILE("CNSmlDmFotaAdapter::UpdateLeafObjectL(stream): begin"); |
|
714 FLOG(_L("CNSmlDmFotaAdapter::UpdateLeafObjectL >>")); |
|
715 CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound; |
|
716 |
|
717 |
|
718 Callback().SetStatusL( aStatusRef, status ); |
|
719 |
|
720 _DBG_FILE("CNSmlDmFotaAdapter::UpdateLeafObjectL(stream): end"); |
|
721 FLOG(_L("CNSmlDmFotaAdapter::UpdateLeafObjectL <<")); |
|
722 } |
|
723 |
|
724 // --------------------------------------------------------------------------- |
|
725 // void CNSmlDmFotaAdapter::FetchLeafObjectSizeL() |
|
726 // Fetches data object and returns its size. |
|
727 // --------------------------------------------------------------------------- |
|
728 // |
|
729 void CNSmlDmFotaAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, |
|
730 const TDesC8& aLUID, |
|
731 const TDesC8& aType, |
|
732 const TInt aResultsRef, |
|
733 const TInt aStatusRef ) |
|
734 { |
|
735 _DBG_FILE("CNSmlDmFotaAdapter::FetchLeafObjectSizeL(): begin"); |
|
736 FLOG(_L("CNSmlDmFotaAdapter::FetchLeafObjectSizeL >>")); |
|
737 // buffer for result |
|
738 CBufBase* result = CBufFlat::NewL( KNSmlDMFotaResultBufferExpandSize ); |
|
739 CleanupStack::PushL( result ); |
|
740 |
|
741 // fetch data |
|
742 CSmlDmAdapter::TError status = DoFetchObjectL( aURI, aLUID, *result ); |
|
743 if ( status == CSmlDmAdapter::EOk ) |
|
744 { |
|
745 // get size and form a string representation |
|
746 TInt size = result->Size(); |
|
747 TBuf8<KNSmlFwMgmtObjectIntegerLength> sizeStr; |
|
748 sizeStr.AppendNum( size ); |
|
749 |
|
750 // insert size to result |
|
751 result->Reset(); |
|
752 result->InsertL( 0, sizeStr ); |
|
753 |
|
754 Callback().SetResultsL( aResultsRef, *result, aType ); |
|
755 } |
|
756 |
|
757 CleanupStack::PopAndDestroy( result ); |
|
758 |
|
759 Callback().SetStatusL( aStatusRef, status ); |
|
760 |
|
761 _DBG_FILE("CNSmlDmFotaAdapter::FetchLeafObjectSizeL(): end"); |
|
762 FLOG(_L("CNSmlDmFotaAdapter::FetchLeafObjectSizeL <<")); |
|
763 } |
|
764 |
|
765 // --------------------------------------------------------------------------- |
|
766 // CNSmlDmFotaAdapter::ExecuteCommandL() |
|
767 // Executes Update, Download or DownloadAndUpdate command depending on aURI. |
|
768 // If aURI does not match to any of these, ENotFound is set as status. |
|
769 // --------------------------------------------------------------------------- |
|
770 // |
|
771 void CNSmlDmFotaAdapter::ExecuteCommandL( const TDesC8& aURI, |
|
772 const TDesC8& aLUID, |
|
773 const TDesC8& aArgument, |
|
774 const TDesC8& /*aType*/, |
|
775 const TInt aStatusRef ) |
|
776 { |
|
777 _DBG_FILE("CNSmlDmFotaAdapter::ExecuteCommandL(): begin"); |
|
778 FLOG(_L("CNSmlDmFotaAdapter::ExecuteCommandL >>")); |
|
779 //#ifdef RD_OMADMAPPUI_UI_EVOLUTION |
|
780 TInt configFlags( 0 ); |
|
781 CRepository* centrep = NULL; |
|
782 TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ) ); |
|
783 if ( centrep ) |
|
784 { |
|
785 centrep->Get( KDevManSessionType, configFlags ); |
|
786 } |
|
787 if ( err != KErrNone ) |
|
788 { |
|
789 User::Leave( err ); |
|
790 } |
|
791 else |
|
792 { |
|
793 configFlags = 1; |
|
794 centrep->Set( KDevManSessionType, configFlags ); |
|
795 } |
|
796 if( centrep ) |
|
797 { |
|
798 delete centrep; |
|
799 } |
|
800 //#endif |
|
801 CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound; |
|
802 |
|
803 if ( aLUID.Length() > 0 ) |
|
804 { |
|
805 TNSmlDmFwObjectId id = DesToInt( aLUID ); |
|
806 |
|
807 // uri should target Update, Download or DownloadAndUpdate |
|
808 TPtrC8 lastSeg = LastURISeg( aURI ); |
|
809 if ( lastSeg == KNSmlDMFotaNodeDownload || |
|
810 lastSeg == KNSmlDMFotaNodeDownloadAndUpdate ) |
|
811 { |
|
812 |
|
813 // save information about the execution and get profile id of |
|
814 // currently running DM session |
|
815 TSmlProfileId profId = 0; |
|
816 TRAPD( err, profId = SaveExecInfoL( aURI, id, aArgument ) ); |
|
817 |
|
818 if ( err == KErrNone ) |
|
819 { |
|
820 if ( lastSeg == KNSmlDMFotaNodeDownload ) |
|
821 { |
|
822 // download |
|
823 status = DoExecDownloadL( id, profId, EFalse ); |
|
824 } |
|
825 else if ( lastSeg == KNSmlDMFotaNodeDownloadAndUpdate ) |
|
826 { |
|
827 // download and update |
|
828 status = DoExecDownloadL( id, profId, ETrue ); |
|
829 } |
|
830 |
|
831 } |
|
832 else |
|
833 { |
|
834 status = MapErrorToStatus( err ); |
|
835 } |
|
836 } |
|
837 |
|
838 } |
|
839 #ifndef __WINS__ |
|
840 Callback().SetStatusL( aStatusRef, status ); |
|
841 #endif |
|
842 _DBG_FILE("CNSmlDmFotaAdapter::ExecuteCommandL(): end"); |
|
843 FLOG(_L("CNSmlDmFotaAdapter::ExecuteCommandL <<")); |
|
844 } |
|
845 |
|
846 // --------------------------------------------------------------------------- |
|
847 // CNSmlDmFotaAdapter::ExecuteCommandL() |
|
848 // Not supported. |
|
849 // --------------------------------------------------------------------------- |
|
850 // |
|
851 void CNSmlDmFotaAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, |
|
852 const TDesC8& /*aLUID*/, |
|
853 RWriteStream*& /*aStream*/, |
|
854 const TDesC8& /*aType*/, |
|
855 const TInt aStatusRef ) |
|
856 { |
|
857 _DBG_FILE("CNSmlDmFotaAdapter::ExecuteCommandL(): begin"); |
|
858 FLOG(_L("CNSmlDmFotaAdapter::ExecuteCommandL >>")); |
|
859 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
860 FLOG(_L("CNSmlDmFotaAdapter::ExecuteCommandL <<")); |
|
861 _DBG_FILE("CNSmlDmFotaAdapter::ExecuteCommandL(): end"); |
|
862 } |
|
863 |
|
864 // --------------------------------------------------------------------------- |
|
865 // CNSmlDmFotaAdapter::CopyCommandL() |
|
866 // Not supported. |
|
867 // --------------------------------------------------------------------------- |
|
868 // |
|
869 void CNSmlDmFotaAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/, |
|
870 const TDesC8& /*aTargetLUID*/, |
|
871 const TDesC8& /*aSourceURI*/, |
|
872 const TDesC8& /*aSourceLUID*/, |
|
873 const TDesC8& /*aType*/, |
|
874 TInt aStatusRef ) |
|
875 { |
|
876 _DBG_FILE("CNSmlDmFotaAdapter::CopyCommandL(): begin"); |
|
877 |
|
878 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
879 |
|
880 _DBG_FILE("CNSmlDmFotaAdapter::CopyCommandL(): end"); |
|
881 } |
|
882 |
|
883 // --------------------------------------------------------------------------- |
|
884 // CNSmlDmFotaAdapter::StartAtomicL() |
|
885 // Not supported. |
|
886 // --------------------------------------------------------------------------- |
|
887 // |
|
888 void CNSmlDmFotaAdapter::StartAtomicL() |
|
889 { |
|
890 _DBG_FILE("CNSmlDmFotaAdapter::StartAtomicL(): begin"); |
|
891 _DBG_FILE("CNSmlDmFotaAdapter::StartAtomicL(): end"); |
|
892 } |
|
893 |
|
894 // --------------------------------------------------------------------------- |
|
895 // CNSmlDmFotaAdapter::CommitAtomicL() |
|
896 // Not supported. |
|
897 // --------------------------------------------------------------------------- |
|
898 // |
|
899 void CNSmlDmFotaAdapter::CommitAtomicL() |
|
900 { |
|
901 _DBG_FILE("CNSmlDmFotaAdapter::CommitAtomicL(): begin"); |
|
902 _DBG_FILE("CNSmlDmFotaAdapter::CommitAtomicL(): end"); |
|
903 } |
|
904 |
|
905 // --------------------------------------------------------------------------- |
|
906 // CNSmlDmFotaAdapter::RollbackAtomicL() |
|
907 // Not supported. |
|
908 // --------------------------------------------------------------------------- |
|
909 // |
|
910 void CNSmlDmFotaAdapter::RollbackAtomicL() |
|
911 { |
|
912 _DBG_FILE("CNSmlDmFotaAdapter::RollbackAtomicL(): begin"); |
|
913 _DBG_FILE("CNSmlDmFotaAdapter::RollbackAtomicL(): end"); |
|
914 } |
|
915 |
|
916 // --------------------------------------------------------------------------- |
|
917 // CNSmlDmFotaAdapter::StreamingSupport() |
|
918 // Returns whether or not streaming is supported in this adapter. |
|
919 // In Fota this method is also used to enquire whether or not a large object |
|
920 // whose size is given in aItemSize fits to disk (OOD check using Fota Engine), |
|
921 // and to acknowledge that Generic Alerts have been sent succesfully to remote |
|
922 // server. If aItemSize is larger that 0, OOD check feature is executed. |
|
923 // If aItemSize equals to KNSmlDMResetGenAlerts, Generic Alerts are marked |
|
924 // sent. Otherwise aItemSize is set to a treshold value, which is used by |
|
925 // DM Host Server to determineif streaming should be used (large object) |
|
926 // or not. |
|
927 // --------------------------------------------------------------------------- |
|
928 // |
|
929 TBool CNSmlDmFotaAdapter::StreamingSupport( TInt& aItemSize ) |
|
930 { |
|
931 _DBG_FILE("CNSmlDmFotaAdapter::StreamingSupport(): begin"); |
|
932 FLOG(_L("CNSmlDmFotaAdapter::StreamingSupport, ITEM = %d >>"), aItemSize); |
|
933 TBool ret (EFalse); |
|
934 if ( aItemSize == KNSmlDMResetGenAlerts ) |
|
935 { |
|
936 // generic alerts have been sent successfully to this server |
|
937 TRAPD( err, MarkGenericAlertsSentL() ); |
|
938 if(err) |
|
939 { |
|
940 _DBG_FILE("CNSmlDmFotaAdapter::StreamingSupport(): error in MarkGenricAlertSentL()"); |
|
941 } |
|
942 ret = ETrue; |
|
943 } |
|
944 |
|
945 _DBG_FILE("CNSmlDmFotaAdapter::StreamingSupport(): end"); |
|
946 FLOG(_L("CNSmlDmFotaAdapter::StreamingSupport <<")); |
|
947 return ret; |
|
948 } |
|
949 |
|
950 // --------------------------------------------------------------------------- |
|
951 // CNSmlDmFotaAdapter::StreamCommittedL() |
|
952 // Notification method used by DM Host Server. All data has been written to |
|
953 // stream successfully and stream has been committed and closed. |
|
954 // --------------------------------------------------------------------------- |
|
955 // |
|
956 void CNSmlDmFotaAdapter::StreamCommittedL() |
|
957 { |
|
958 _DBG_FILE("CNSmlDmFotaAdapter::StreamCommittedL(): begin"); |
|
959 |
|
960 _DBG_FILE("CNSmlDmFotaAdapter::StreamCommittedL(): end"); |
|
961 } |
|
962 |
|
963 // --------------------------------------------------------------------------- |
|
964 // CNSmlDmFotaAdapter::CompleteOutstandingCmdsL() |
|
965 // Not supported. |
|
966 // --------------------------------------------------------------------------- |
|
967 // |
|
968 void CNSmlDmFotaAdapter::CompleteOutstandingCmdsL() |
|
969 { |
|
970 _DBG_FILE("CNSmlDmFotaAdapter::CompleteOutstandingCmdsL(): begin"); |
|
971 _DBG_FILE("CNSmlDmFotaAdapter::CompleteOutstandingCmdsL(): end"); |
|
972 } |
|
973 |
|
974 // --------------------------------------------------------------------------- |
|
975 // CNSmlDmFotaAdapter::DoFetchObjectL() |
|
976 // Fetches the data identified by aURI in FW object aLUID. Writes the data |
|
977 // to aObject and returns status code according to the success of the fetch. |
|
978 // --------------------------------------------------------------------------- |
|
979 // |
|
980 CSmlDmAdapter::TError CNSmlDmFotaAdapter::DoFetchObjectL( const TDesC8& aURI, |
|
981 const TDesC8& aLUID, |
|
982 CBufBase& aObject ) |
|
983 { |
|
984 CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound; |
|
985 |
|
986 if ( aLUID.Length() > 0 ) |
|
987 { |
|
988 HBufC8* data = NULL; |
|
989 TNSmlDmFwObjectId id = DesToInt( aLUID ); |
|
990 |
|
991 // get correct data according to the last segment of the uri |
|
992 TPtrC8 lastSeg = LastURISeg( aURI ); |
|
993 if ( lastSeg == KNSmlDMFotaNodeName ) |
|
994 { |
|
995 data = iFotaDb->PkgNameL( id ); |
|
996 } |
|
997 else if ( lastSeg == KNSmlDMFotaNodeVersion ) |
|
998 { |
|
999 data = iFotaDb->PkgVersionL( id ); |
|
1000 } |
|
1001 else if ( lastSeg == KNSmlDMFotaNodeDownloadUrl || |
|
1002 lastSeg == KNSmlDMFotaNodeDownloadAndUpdateUrl ) |
|
1003 { |
|
1004 data = iFotaDb->PkgUrlL( id ); |
|
1005 } |
|
1006 else if ( lastSeg == KNSmlDMFotaNodeState ) |
|
1007 { |
|
1008 // state is fetched from fota engine |
|
1009 RFotaEngineSession::TState state = FotaEngineL().GetState( id ); |
|
1010 data = HBufC8::NewL( KNSmlFwMgmtObjectIntegerLength ); |
|
1011 data->Des().AppendNum( state ); |
|
1012 } |
|
1013 |
|
1014 // if data is fetched ok, set results |
|
1015 if ( data ) |
|
1016 { |
|
1017 CleanupStack::PushL( data ); |
|
1018 |
|
1019 aObject.InsertL( 0, *data ); |
|
1020 status = CSmlDmAdapter::EOk; |
|
1021 |
|
1022 CleanupStack::PopAndDestroy( data ); |
|
1023 } |
|
1024 } |
|
1025 |
|
1026 return status; |
|
1027 } |
|
1028 |
|
1029 // --------------------------------------------------------------------------- |
|
1030 // CNSmlDmFotaAdapter::DoExecUpdateL() |
|
1031 // Gets needed data for Update from Fota DB and notifies Fota Engine that |
|
1032 // Update should be executed. Returns status according to the success of |
|
1033 // the method. |
|
1034 // --------------------------------------------------------------------------- |
|
1035 // |
|
1036 CSmlDmAdapter::TError CNSmlDmFotaAdapter::DoExecUpdateL( |
|
1037 const TNSmlDmFwObjectId aLUID, |
|
1038 const TSmlProfileId aProfile ) |
|
1039 { |
|
1040 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
1041 |
|
1042 // get needed data from db for fota engine |
|
1043 HBufC8* pkgName = iFotaDb->PkgNameL( aLUID ); |
|
1044 CleanupStack::PushL( pkgName ); |
|
1045 |
|
1046 HBufC8* pkgVersion = iFotaDb->PkgVersionL( aLUID ); |
|
1047 CleanupStack::PushL( pkgVersion ); |
|
1048 |
|
1049 TInt error = KErrNone; |
|
1050 |
|
1051 if ( pkgName && pkgVersion ) |
|
1052 { |
|
1053 // notify fota engine to start update |
|
1054 error = FotaEngineL().Update( aLUID, aProfile, *pkgName, *pkgVersion ); |
|
1055 |
|
1056 // if immediate error occured, set final result to corresponding |
|
1057 // value so that generic alert is not sent |
|
1058 if ( error == KErrNotFound ) |
|
1059 { |
|
1060 // binary update package has not been downloaded yet -> not |
|
1061 // possible to update |
|
1062 status = CSmlDmAdapter::ENotFound; |
|
1063 iFotaDb->SetFinalResultL( KNSmlDMFotaUndefinedError, aLUID ); |
|
1064 } |
|
1065 else if ( error != KErrNone ) |
|
1066 { |
|
1067 // other error |
|
1068 status = CSmlDmAdapter::EError; |
|
1069 iFotaDb->SetFinalResultL( KNSmlDMFotaUndefinedError, aLUID ); |
|
1070 } |
|
1071 } |
|
1072 else |
|
1073 { |
|
1074 // fw object was not found |
|
1075 status = CSmlDmAdapter::ENotFound; |
|
1076 } |
|
1077 |
|
1078 CleanupStack::PopAndDestroy( pkgVersion ); |
|
1079 CleanupStack::PopAndDestroy( pkgName ); |
|
1080 |
|
1081 return status; |
|
1082 } |
|
1083 |
|
1084 // --------------------------------------------------------------------------- |
|
1085 // CNSmlDmFotaAdapter::DoExecDownloadL() |
|
1086 // Gets needed data for Download or DownloadAndUpdate from Fota DB and |
|
1087 // notifies Fota Engine that Download or DownloadAndUpdate should be executed. |
|
1088 // Returns status according to the success of the method. |
|
1089 // --------------------------------------------------------------------------- |
|
1090 // |
|
1091 CSmlDmAdapter::TError CNSmlDmFotaAdapter::DoExecDownloadL( |
|
1092 const TNSmlDmFwObjectId aLUID, |
|
1093 const TSmlProfileId aProfile, |
|
1094 TBool aUpdate ) |
|
1095 { |
|
1096 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
1097 |
|
1098 // get needed data from db for fota engine |
|
1099 HBufC8* url = iFotaDb->PkgUrlL( aLUID ); |
|
1100 CleanupStack::PushL( url ); |
|
1101 |
|
1102 HBufC8* pkgName = iFotaDb->PkgNameL( aLUID ); |
|
1103 CleanupStack::PushL( pkgName ); |
|
1104 |
|
1105 HBufC8* pkgVersion = iFotaDb->PkgVersionL( aLUID ); |
|
1106 CleanupStack::PushL( pkgVersion ); |
|
1107 |
|
1108 TInt error = KErrNone; |
|
1109 |
|
1110 if ( url && pkgName && pkgVersion ) |
|
1111 { |
|
1112 TBool silent (EFalse); |
|
1113 TInt value (ENonSilent); |
|
1114 RProperty::Get(KPSUidNSmlSOSServerKey, KNSmlDMSilentJob, value); |
|
1115 |
|
1116 if (value == ESilent) |
|
1117 { |
|
1118 silent = ETrue; |
|
1119 FLOG(_L("Session type is silent")); |
|
1120 } |
|
1121 if ( aUpdate ) |
|
1122 { |
|
1123 // notify fota engine to start download and update |
|
1124 error = FotaEngineL().DownloadAndUpdate( aLUID, *url, aProfile, *pkgName, *pkgVersion,silent ); |
|
1125 } |
|
1126 else |
|
1127 { |
|
1128 // notify fota engine to start download |
|
1129 error = FotaEngineL().Download( aLUID, *url, aProfile, *pkgName, *pkgVersion, silent ); |
|
1130 } |
|
1131 |
|
1132 // if immediate error occured, set final result to corresponding value so that |
|
1133 // generic alert is not sent |
|
1134 if ( error == KErrArgument ) |
|
1135 { |
|
1136 // url incorrectly formed |
|
1137 status = CSmlDmAdapter::EInvalidObject; |
|
1138 iFotaDb->SetFinalResultL( KNSmlDMFotaBadUrl, aLUID ); |
|
1139 } |
|
1140 else if ( error != KErrNone ) |
|
1141 { |
|
1142 // other error |
|
1143 status = CSmlDmAdapter::EError; |
|
1144 iFotaDb->SetFinalResultL( KNSmlDMFotaUndefinedError, aLUID ); |
|
1145 } |
|
1146 } |
|
1147 else |
|
1148 { |
|
1149 // fw object was not found |
|
1150 status = CSmlDmAdapter::ENotFound; |
|
1151 } |
|
1152 |
|
1153 CleanupStack::PopAndDestroy( pkgVersion ); |
|
1154 CleanupStack::PopAndDestroy( pkgName ); |
|
1155 CleanupStack::PopAndDestroy( url ); |
|
1156 |
|
1157 return status; |
|
1158 } |
|
1159 |
|
1160 // --------------------------------------------------------------------------- |
|
1161 // CNSmlDmFotaAdapter::SaveExecInfoL() |
|
1162 // Saves the values needed when starting an exec command. Returns the saved |
|
1163 // profile id. |
|
1164 // --------------------------------------------------------------------------- |
|
1165 // |
|
1166 TSmlProfileId CNSmlDmFotaAdapter::SaveExecInfoL( const TDesC8& aURI, |
|
1167 const TNSmlDmFwObjectId aLUID, |
|
1168 const TDesC8& aCorrelator ) |
|
1169 { |
|
1170 // set final result (null), uri and correlator to fota db |
|
1171 User::LeaveIfError( iFotaDb->SetFinalResultL( KNSmlFotaNullResult, aLUID ) ); |
|
1172 User::LeaveIfError( iFotaDb->SetMgmtUriL( aURI, aLUID ) ); |
|
1173 User::LeaveIfError( iFotaDb->SetCorrelatorL( aCorrelator, aLUID ) ); |
|
1174 |
|
1175 // fetch profile id and server id of the currently running dm session |
|
1176 TSmlProfileId profId = KErrNotFound; |
|
1177 HBufC8* serverId = NULL; |
|
1178 |
|
1179 GetServerInfoL( profId, serverId ); |
|
1180 CleanupStack::PushL( serverId ); |
|
1181 |
|
1182 // save profile id and server id to fota db |
|
1183 User::LeaveIfError( iFotaDb->SetServerInfoL( profId, *serverId, aLUID ) ); |
|
1184 |
|
1185 CleanupStack::PopAndDestroy( serverId ); |
|
1186 |
|
1187 return profId; |
|
1188 } |
|
1189 |
|
1190 // --------------------------------------------------------------------------- |
|
1191 // CNSmlDmFotaAdapter::GetServerInfoL() |
|
1192 // Fetches profile id and server id of the currently running dm session. |
|
1193 // Data is fetched using Client API and set to the references given as |
|
1194 // parameters. Reallocates server id to aServerId. |
|
1195 // --------------------------------------------------------------------------- |
|
1196 // |
|
1197 void CNSmlDmFotaAdapter::GetServerInfoL( TSmlProfileId& aProfId, |
|
1198 HBufC8*& aServerId ) const |
|
1199 { |
|
1200 // Open session |
|
1201 RSyncMLSession session; |
|
1202 session.OpenL(); |
|
1203 CleanupClosePushL( session ); |
|
1204 |
|
1205 // get current job's id (and usage type) |
|
1206 TSmlJobId jobId = KErrNotFound; |
|
1207 TSmlUsageType type = ESmlDevMan; |
|
1208 session.CurrentJobL( jobId, type ); |
|
1209 |
|
1210 // open currently running job |
|
1211 RSyncMLDevManJob dmJob; |
|
1212 dmJob.OpenL( session, jobId ); |
|
1213 CleanupClosePushL( dmJob ); |
|
1214 |
|
1215 // get job's profile id |
|
1216 aProfId = dmJob.Profile(); |
|
1217 |
|
1218 // open profile using id in read-only mode |
|
1219 RSyncMLDevManProfile dmProf; |
|
1220 dmProf.OpenL( session, aProfId, ESmlOpenRead ); |
|
1221 CleanupClosePushL( dmProf ); |
|
1222 |
|
1223 // get profile's server id |
|
1224 aServerId = dmProf.ServerId().AllocL(); |
|
1225 |
|
1226 // close handles |
|
1227 CleanupStack::PopAndDestroy( &dmProf ); |
|
1228 CleanupStack::PopAndDestroy( &dmJob ); |
|
1229 CleanupStack::PopAndDestroy( &session ); |
|
1230 } |
|
1231 // --------------------------------------------------------------------------- |
|
1232 // CNSmlDmFotaAdapter::CheckAndAddPredefinedNodeL() |
|
1233 // Checks if predefined node for FUMO is in tree if not add to the tree |
|
1234 // --------------------------------------------------------------------------- |
|
1235 // |
|
1236 void CNSmlDmFotaAdapter::CheckAndAddPredefinedNodeL() |
|
1237 { |
|
1238 |
|
1239 TBuf8<KMaxFullName> temp; |
|
1240 GetPredefinedNodeL(temp); |
|
1241 if (temp.Length()) |
|
1242 { |
|
1243 RNSmlDMCallbackSession session; |
|
1244 User::LeaveIfError( session.Connect() ); |
|
1245 CleanupClosePushL(session); |
|
1246 TBuf8<KMaxName> node[4]; |
|
1247 TInt location = temp.LocateReverse(','); |
|
1248 node[0].Copy(temp.Mid(location+1)); |
|
1249 TInt newLocation = (temp.Left(location-1)).LocateReverse(','); |
|
1250 node[1].Copy(temp.Mid(newLocation+1,location-(newLocation+1))); |
|
1251 location = newLocation; |
|
1252 newLocation = (temp.Left(location-1)).LocateReverse(','); |
|
1253 node[2].Copy(temp.Mid(newLocation+1,location-(newLocation+1))); |
|
1254 node[3].Copy(temp.Mid(0,newLocation )); |
|
1255 for(TInt i=0; i<4; i++) |
|
1256 { |
|
1257 TBuf8<KMaxFullName> temp1; |
|
1258 temp1.Zero(); |
|
1259 temp1.Copy(KNSmlDMFotaNode); |
|
1260 temp1.Append(KNSmlDMFotaSeparatorDes); |
|
1261 temp1.Append(node[i]); |
|
1262 HBufC8* luid = session.GetLuidAllocL( KNSmlDMFotaAdapterImplUid,temp1); |
|
1263 CleanupStack::PushL(luid); |
|
1264 if ( luid->Length() > 0 ) |
|
1265 { |
|
1266 CleanupStack::PopAndDestroy( luid ); |
|
1267 CleanupStack::PopAndDestroy( &session ); |
|
1268 return; |
|
1269 } |
|
1270 else |
|
1271 { |
|
1272 // Add the mapping |
|
1273 TNSmlDmFwObjectId newId = KErrNotFound; |
|
1274 TRAPD( err, newId = iFotaDb->AddFwObjectL() ); |
|
1275 |
|
1276 if ( err == KErrNone ) |
|
1277 { |
|
1278 // added ok |
|
1279 TBuf8<KNSmlFwMgmtObjectIntegerLength> newLUID; |
|
1280 newLUID.AppendNum( newId ); |
|
1281 session.AddMappingInfoL(KNSmlDMFotaAdapterImplUid, temp1, newLUID ); |
|
1282 } |
|
1283 } |
|
1284 CleanupStack::PopAndDestroy( luid ); |
|
1285 } |
|
1286 CleanupStack::PopAndDestroy( &session ); |
|
1287 } |
|
1288 } |
|
1289 // --------------------------------------------------------------------------- |
|
1290 // CNSmlDmFotaAdapter::GetPredefinedNodeL() |
|
1291 // Gets predefined node for FUMO from cenrep |
|
1292 // --------------------------------------------------------------------------- |
|
1293 // |
|
1294 void CNSmlDmFotaAdapter::GetPredefinedNodeL(TDes8& aNode) |
|
1295 { |
|
1296 CRepository* centrep( NULL); |
|
1297 aNode.Zero(); |
|
1298 centrep = CRepository::NewLC( TUid::Uid(0x101F9A0A) ); |
|
1299 |
|
1300 if ( centrep ) |
|
1301 { |
|
1302 TFullName temp; |
|
1303 |
|
1304 if (centrep->Get( KDevManFUMOPredefinedNodes, temp )==KErrNone && temp.Length() ) |
|
1305 { |
|
1306 temp.Trim(); |
|
1307 aNode.Copy(temp); |
|
1308 } |
|
1309 CleanupStack::PopAndDestroy(centrep); |
|
1310 } |
|
1311 } |
|
1312 // --------------------------------------------------------------------------- |
|
1313 // CNSmlDmFotaAdapter::MakeGenericAlertsL() |
|
1314 // Checks whether or not there are fw objects whose final result should be |
|
1315 // sent to the remote server which is involved with the current DM session. |
|
1316 // If there are such objects, notifies private api using the data needed for |
|
1317 // generic alert generation. |
|
1318 // --------------------------------------------------------------------------- |
|
1319 // |
|
1320 void CNSmlDmFotaAdapter::MakeGenericAlertsL() |
|
1321 { |
|
1322 FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL >>")); |
|
1323 // search for fw objects that have empty final result |
|
1324 RNSmlDmFwObjectArray ids; |
|
1325 CleanupClosePushL( ids ); |
|
1326 |
|
1327 iFotaDb->GetEmptyFinalResultsL( ids ); |
|
1328 if ( ids.Count() == 0 ) |
|
1329 { |
|
1330 // none found, no need for generic alerts |
|
1331 CleanupStack::PopAndDestroy( &ids ); |
|
1332 FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 1")); |
|
1333 return; |
|
1334 } |
|
1335 |
|
1336 // get information of the remote DM server |
|
1337 TSmlProfileId profId = 0; |
|
1338 HBufC8* serverId = NULL; |
|
1339 GetServerInfoL( profId, serverId ); |
|
1340 CleanupStack::PushL( serverId ); |
|
1341 |
|
1342 // open handle to private api |
|
1343 RNSmlPrivateAPI privateAPI; |
|
1344 FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 2")); |
|
1345 privateAPI.OpenL(); |
|
1346 CleanupClosePushL( privateAPI ); |
|
1347 |
|
1348 // go through all objects in ids |
|
1349 for ( TInt i = 0; i < ids.Count(); ++i ) |
|
1350 { |
|
1351 // check that server ids match. if not, move to next entry |
|
1352 FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 3")); |
|
1353 HBufC8* fwServerId = iFotaDb->ServerIdL( ids[i] ); |
|
1354 CleanupStack::PushL( fwServerId ); |
|
1355 FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 4")); |
|
1356 if ( *serverId == *fwServerId ) |
|
1357 { |
|
1358 // check that mgmt uri is not empty string. if it is, |
|
1359 // move to next entry |
|
1360 HBufC8* fwMgmtUri = iFotaDb->MgmtUriL( ids[i] ); |
|
1361 FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 5")); |
|
1362 CleanupStack::PushL( fwMgmtUri ); |
|
1363 |
|
1364 if ( *fwMgmtUri != KNullDesC8 ) |
|
1365 { |
|
1366 // check that update has reached its final result |
|
1367 FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 6")); |
|
1368 TInt finalResult = FotaEngineL().GetResult( ids[i] ); |
|
1369 |
|
1370 RFotaEngineSession::TState finalState = FotaEngineL().GetState( ids[i] ); |
|
1371 |
|
1372 if ( finalResult != KErrNotFound && finalState != RFotaEngineSession::EStartingUpdate) |
|
1373 { |
|
1374 // get fw object's correlator |
|
1375 HBufC8* fwCorrelator = iFotaDb->CorrelatorL( ids[i] ); |
|
1376 CleanupStack::PushL( fwCorrelator ); |
|
1377 |
|
1378 // add generic alert to dm message |
|
1379 TPtrC8 metaType = GetMetaType( *fwMgmtUri ); |
|
1380 FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 7")); |
|
1381 privateAPI.AddDMGenericAlertRequestL( *fwMgmtUri, metaType, KNSmlDMFotaMetaFormat, finalResult, *fwCorrelator ); |
|
1382 FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 8")); |
|
1383 CleanupStack::PopAndDestroy( fwCorrelator ); |
|
1384 } |
|
1385 } |
|
1386 |
|
1387 CleanupStack::PopAndDestroy( fwMgmtUri ); |
|
1388 } |
|
1389 |
|
1390 CleanupStack::PopAndDestroy( fwServerId ); |
|
1391 } |
|
1392 |
|
1393 CleanupStack::PopAndDestroy( &privateAPI ); |
|
1394 CleanupStack::PopAndDestroy( serverId ); |
|
1395 CleanupStack::PopAndDestroy( &ids ); |
|
1396 FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL <<")); |
|
1397 |
|
1398 } |
|
1399 |
|
1400 // --------------------------------------------------------------------------- |
|
1401 // CNSmlDmFotaAdapter::MarkGenericAlertsSentL() |
|
1402 // Puts a final result value to those fw objects, that are |
|
1403 // associated with current DM session's remote server, have |
|
1404 // been a target to an exec command and the exec command has |
|
1405 // finished. I.e. Generic Alert has been sent to remote server |
|
1406 // reporting the results of these exec commands --> not needed to |
|
1407 // send Generic Alert anymore in next DM session. |
|
1408 // --------------------------------------------------------------------------- |
|
1409 // |
|
1410 void CNSmlDmFotaAdapter::MarkGenericAlertsSentL() |
|
1411 { |
|
1412 |
|
1413 FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL >>")); |
|
1414 |
|
1415 // search for fw objects that have empty final result |
|
1416 RNSmlDmFwObjectArray ids; |
|
1417 CleanupClosePushL( ids ); |
|
1418 |
|
1419 // get information of the remote DM server |
|
1420 TSmlProfileId profId = 0; |
|
1421 HBufC8* serverId = NULL; |
|
1422 GetServerInfoL( profId, serverId ); |
|
1423 CleanupStack::PushL( serverId ); |
|
1424 |
|
1425 FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL 1")); |
|
1426 iFotaDb->GetEmptyFinalResultsL( ids, *serverId ); |
|
1427 |
|
1428 // go through all objects in ids |
|
1429 for ( TInt i = 0; i < ids.Count(); ++i ) |
|
1430 { |
|
1431 // check that update has reached its final result |
|
1432 FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL 2")); |
|
1433 TInt finalResult = FotaEngineL().GetResult( ids[i] ); |
|
1434 if ( finalResult != KErrNotFound ) |
|
1435 { |
|
1436 // set final result thus setting generic alert sent |
|
1437 FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL 3")); |
|
1438 iFotaDb->SetFinalResultL( finalResult, ids[i] ); |
|
1439 |
|
1440 // also notify fota engine, that generic alert has been |
|
1441 // successfully sent, thus enabling possible cleanup |
|
1442 FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL, %d"), ids[i]); |
|
1443 FotaEngineL().GenericAlertSentL( ids[i] ); |
|
1444 } |
|
1445 } |
|
1446 |
|
1447 CleanupStack::PopAndDestroy( serverId ); |
|
1448 CleanupStack::PopAndDestroy( &ids ); |
|
1449 FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL <<")); |
|
1450 } |
|
1451 |
|
1452 // --------------------------------------------------------------------------- |
|
1453 // CNSmlDmFotaAdapter::GetMetaType() |
|
1454 // Determines by the given uri which meta/type should be used in generic |
|
1455 // alert.Returns the correct type, or KNullDesC8 if uri does not match to |
|
1456 // exec targets. |
|
1457 // --------------------------------------------------------------------------- |
|
1458 // |
|
1459 TPtrC8 CNSmlDmFotaAdapter::GetMetaType( const TDesC8& aURI ) const |
|
1460 { |
|
1461 TPtrC8 lastSeg = LastURISeg( aURI ); |
|
1462 |
|
1463 if ( lastSeg == KNSmlDMFotaNodeDownload ) |
|
1464 { |
|
1465 return KNSmlDMFotaDownloadMetaType(); |
|
1466 } |
|
1467 else if ( lastSeg == KNSmlDMFotaNodeDownloadAndUpdate ) |
|
1468 { |
|
1469 return KNSmlDMFotaDownloadAndUpdateMetaType(); |
|
1470 } |
|
1471 |
|
1472 return KNullDesC8(); |
|
1473 } |
|
1474 |
|
1475 // --------------------------------------------------------------------------- |
|
1476 // CNSmlDmFotaAdapter::MapStatusToError() |
|
1477 // Returns a status code corresponding to the system error code given |
|
1478 // as parameter. |
|
1479 // --------------------------------------------------------------------------- |
|
1480 // |
|
1481 CSmlDmAdapter::TError CNSmlDmFotaAdapter::MapErrorToStatus( TInt aError ) const |
|
1482 { |
|
1483 CSmlDmAdapter::TError err = CSmlDmAdapter::EError; |
|
1484 |
|
1485 switch( aError ) |
|
1486 { |
|
1487 case KErrNone: |
|
1488 err = CSmlDmAdapter::EOk; |
|
1489 break; |
|
1490 case KErrNotFound: |
|
1491 err = CSmlDmAdapter::ENotFound; |
|
1492 break; |
|
1493 case KErrDiskFull: |
|
1494 err = CSmlDmAdapter::EDiskFull; |
|
1495 break; |
|
1496 case KErrOverflow: |
|
1497 err = CSmlDmAdapter::ETooLargeObject; |
|
1498 break; |
|
1499 default: |
|
1500 break; |
|
1501 } |
|
1502 |
|
1503 return err; |
|
1504 } |
|
1505 |
|
1506 // --------------------------------------------------------------------------- |
|
1507 // CNSmlDmFotaAdapter::DesToInt() |
|
1508 // Converts a 8 bit descriptor to an integer. |
|
1509 // --------------------------------------------------------------------------- |
|
1510 // |
|
1511 TInt CNSmlDmFotaAdapter::DesToInt( const TDesC8& aLUID ) const |
|
1512 { |
|
1513 TLex8 lex( aLUID ); |
|
1514 TInt value = KErrNotFound; |
|
1515 lex.Val( value ); |
|
1516 |
|
1517 return value; |
|
1518 } |
|
1519 |
|
1520 // --------------------------------------------------------------------------- |
|
1521 // CNSmlDmFotaAdapter::LastURISeg() |
|
1522 // Returns the last segment of the given uri. |
|
1523 // --------------------------------------------------------------------------- |
|
1524 // |
|
1525 TPtrC8 CNSmlDmFotaAdapter::LastURISeg( const TDesC8& aURI ) const |
|
1526 { |
|
1527 TInt pos = aURI.LocateReverse( KNSmlDMFotaSeparatorDes()[0] ); |
|
1528 if( pos == KErrNotFound ) |
|
1529 { |
|
1530 return aURI; |
|
1531 } |
|
1532 else |
|
1533 { |
|
1534 return aURI.Mid( pos + 1 ); |
|
1535 } |
|
1536 } |
|
1537 |
|
1538 // --------------------------------------------------------------------------- |
|
1539 // CNSmlDmFotaAdapter::FillNodeInfoL() |
|
1540 // Fills the DDF node info. |
|
1541 // --------------------------------------------------------------------------- |
|
1542 // |
|
1543 void CNSmlDmFotaAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode, |
|
1544 const TSmlDmAccessTypes& aAccTypes, |
|
1545 MSmlDmDDFObject::TOccurence aOccurrence, |
|
1546 MSmlDmDDFObject::TScope aScope, |
|
1547 MSmlDmDDFObject::TDFFormat aFormat, |
|
1548 const TDesC8& aDescription ) const |
|
1549 { |
|
1550 aNode.SetAccessTypesL( aAccTypes ); |
|
1551 aNode.SetOccurenceL( aOccurrence ); |
|
1552 aNode.SetScopeL( aScope ); |
|
1553 aNode.SetDFFormatL( aFormat ); |
|
1554 |
|
1555 if( aFormat != MSmlDmDDFObject::ENode ) |
|
1556 { |
|
1557 aNode.AddDFTypeMimeTypeL( KNSmlDMFotaTextPlain ); |
|
1558 } |
|
1559 |
|
1560 aNode.SetDescriptionL( aDescription ); |
|
1561 } |
|
1562 |
|
1563 RFotaEngineSession& CNSmlDmFotaAdapter::FotaEngineL() |
|
1564 { |
|
1565 FLOG(_L("CNSmlDmFotaAdapter::FotaEngineL >>")); |
|
1566 if (!iFotaEngine.Handle()) |
|
1567 { |
|
1568 FLOG(_L("Opening fota engine...")); |
|
1569 iFotaEngine.OpenL(); |
|
1570 } |
|
1571 |
|
1572 FLOG(_L("CNSmlDmFotaAdapter::FotaEngineL <<")); |
|
1573 return iFotaEngine; |
|
1574 } |
|
1575 // --------------------------------------------------------------------------- |
|
1576 // TImplementationProxy ImplementationTable[] |
|
1577 // Needed because of ECOM architecture. |
|
1578 // --------------------------------------------------------------------------- |
|
1579 // |
|
1580 #ifndef IMPLEMENTATION_PROXY_ENTRY |
|
1581 #define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr) {{aUid},(aFuncPtr)} |
|
1582 #endif |
|
1583 |
|
1584 const TImplementationProxy ImplementationTable[] = |
|
1585 { |
|
1586 IMPLEMENTATION_PROXY_ENTRY(KNSmlDMFotaAdapterImplUid, CNSmlDmFotaAdapter::NewL) |
|
1587 }; |
|
1588 |
|
1589 |
|
1590 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
1591 |
|
1592 // --------------------------------------------------------------------------- |
|
1593 // ImplementationGroupProxy() |
|
1594 // Needed because of ECOM architecture. |
|
1595 // --------------------------------------------------------------------------- |
|
1596 // |
|
1597 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
1598 { |
|
1599 _DBG_FILE("ImplementationGroupProxy() for CNSmlDmFotaAdapter: begin"); |
|
1600 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
1601 _DBG_FILE("ImplementationGroupProxy() for CNSmlDmFotaAdapter: end"); |
|
1602 return ImplementationTable; |
|
1603 } |
|
1604 |
|
1605 |
|
1606 // End of file |
|
1607 |