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