47
|
1 |
/*
|
|
2 |
* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Implementation of applicationmanagement components
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <centralrepository.h>
|
|
20 |
#include <s32mem.h>
|
|
21 |
#include <s32file.h>
|
|
22 |
#include <e32des8.h>
|
|
23 |
#ifndef __SERIES60_30__
|
|
24 |
#include "AMAppHideUtil.h"
|
|
25 |
#endif
|
|
26 |
#include "debug.h"
|
|
27 |
#include "amprivateCRKeys.h"
|
|
28 |
#include "amstorage.h"
|
|
29 |
#include "AMDeploymentComponent.h"
|
|
30 |
|
|
31 |
using namespace NApplicationManagement;
|
|
32 |
|
|
33 |
// CONSTANTS
|
|
34 |
|
|
35 |
|
|
36 |
/***************************************************
|
|
37 |
// RComponentIdArray
|
|
38 |
***************************************************/
|
|
39 |
|
|
40 |
void RComponentIdArray::SetListL(const TDesC8& aChilds)
|
|
41 |
{
|
|
42 |
#ifdef _DEBUG
|
|
43 |
HBufC *b = HBufC::NewLC(aChilds.Length() );
|
|
44 |
TPtr p(b->Des() );
|
|
45 |
p.Copy(aChilds);
|
|
46 |
RDEBUG_2( "RComponentIdArray::SetListL: Setting list from: '%S'", &p);
|
|
47 |
CleanupStack::PopAndDestroy(b);
|
|
48 |
#endif
|
|
49 |
|
|
50 |
RDesReadStream buf(aChilds);
|
|
51 |
//TInt size( buf.Source()->TellL( MStreamBuf::ERead ).SizeL() );
|
|
52 |
TInt left(aChilds.Length() );
|
|
53 |
const TInt KSize(sizeof(TUint32));
|
|
54 |
while (left > 0)
|
|
55 |
{
|
|
56 |
TUint32 val(buf.ReadUint32L() );
|
|
57 |
#ifdef _DEBUG
|
|
58 |
RDEBUG_2( "RComponentIdArray::SetListL: Appending id: '%d'", val);
|
|
59 |
#endif
|
|
60 |
Append(val);
|
|
61 |
left -= KSize;
|
|
62 |
}
|
|
63 |
buf.Close();
|
|
64 |
}
|
|
65 |
|
|
66 |
void RComponentIdArray::RemoveByValue(TUint32 aValue)
|
|
67 |
{
|
|
68 |
TInt ind(Find(aValue) );
|
|
69 |
Remove(ind);
|
|
70 |
}
|
|
71 |
|
|
72 |
void RComponentIdArray::GetListLC(HBufC8 *&aChilds, TInt &aLength)
|
|
73 |
{
|
|
74 |
ASSERT( aChilds == NULL );
|
|
75 |
TInt c(Count() );
|
|
76 |
if (c > 0)
|
|
77 |
{
|
|
78 |
aLength = c * sizeof(TUint32);
|
|
79 |
aChilds = HBufC8::NewLC(aLength);
|
|
80 |
TPtr8 p(aChilds->Des() );
|
|
81 |
RDesWriteStream stream(p);
|
|
82 |
CleanupClosePushL(stream);
|
|
83 |
TInt i( 0);
|
|
84 |
do
|
|
85 |
{
|
|
86 |
stream.WriteUint32L(operator[](i) );
|
|
87 |
}
|
|
88 |
while ( ++i < c);
|
|
89 |
stream.CommitL();
|
|
90 |
CleanupStack::PopAndDestroy( &stream);
|
|
91 |
}
|
|
92 |
else
|
|
93 |
{
|
|
94 |
aChilds = KNullDesC8().AllocLC();
|
|
95 |
aLength = 0;
|
|
96 |
}
|
|
97 |
}
|
|
98 |
|
|
99 |
/*
|
|
100 |
void TCertInfoPckg::ExternalizeL(RWriteStream& aStream) const
|
|
101 |
{
|
|
102 |
aStream << iId;
|
|
103 |
TPckgBuf<TCertInfo>::ExternalizeL( aStream );
|
|
104 |
}
|
|
105 |
|
|
106 |
void TCertInfoPckg::InternalizeL(RReadStream& aStream)
|
|
107 |
{
|
|
108 |
|
|
109 |
}
|
|
110 |
*/
|
|
111 |
|
|
112 |
void RCertArray::ExternalizeL(RWriteStream& aStream) const
|
|
113 |
{
|
|
114 |
TInt c(Count() );
|
|
115 |
aStream.WriteInt32L(c);
|
|
116 |
for (TInt i( 0); i < c; i++)
|
|
117 |
{
|
|
118 |
aStream.WriteInt32L(i);
|
|
119 |
aStream << (*(operator[](i)));
|
|
120 |
}
|
|
121 |
}
|
|
122 |
|
|
123 |
void RCertArray::InternalizeL(RReadStream& aStream)
|
|
124 |
{
|
|
125 |
TInt c(aStream.ReadInt32L() );
|
|
126 |
for (TInt i( 0); i < c; i++)
|
|
127 |
{
|
|
128 |
TCertInfoPckg *pkg = new ( ELeave ) TCertInfoPckg;
|
|
129 |
RDEBUG_2( "RCertArray::InternalizeL - allocated TCertInfoPckg 0x%X", reinterpret_cast<TUint>( pkg ) );
|
|
130 |
CleanupStack::PushL(pkg);
|
|
131 |
TInt idx(aStream.ReadInt32L() );
|
|
132 |
aStream >> (*pkg);
|
|
133 |
Append(pkg);
|
|
134 |
CleanupStack::Pop(pkg);
|
|
135 |
}
|
|
136 |
}
|
|
137 |
|
|
138 |
TInt RCertArray::FindByValue(const TCertInfoPckg &aPckg)
|
|
139 |
{
|
|
140 |
TInt c(Count() );
|
|
141 |
for (TInt i( 0); i < c; i++)
|
|
142 |
{
|
|
143 |
if (operator[](i)->Compare(aPckg) == 0)
|
|
144 |
{
|
|
145 |
return i;
|
|
146 |
}
|
|
147 |
}
|
|
148 |
return KErrNotFound;
|
|
149 |
}
|
|
150 |
|
|
151 |
/***************************************************
|
|
152 |
// CDeliveryComponentStorage
|
|
153 |
***************************************************/
|
|
154 |
|
|
155 |
CDeliveryComponentStorage::CDeliveryComponentStorage()
|
|
156 |
{
|
|
157 |
|
|
158 |
}
|
|
159 |
|
|
160 |
void CDeliveryComponentStorage::ConstructL()
|
|
161 |
{
|
|
162 |
#ifndef __SERIES60_30__
|
|
163 |
iHidder = CAMAppHideUtil::NewL();
|
|
164 |
#endif
|
|
165 |
LoadCertsL();
|
|
166 |
TRAPD( erx, iRepository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) )
|
|
167 |
;
|
|
168 |
if (erx != KErrNone)
|
|
169 |
{
|
|
170 |
RDEBUG_2( "CDeliveryComponentStorage::ConstructL() ERROR CentRep not initialized: Check deployment! %d", erx );
|
|
171 |
User::Leave(erx);
|
|
172 |
}
|
|
173 |
TInt err(iRepository->Get(KNextIdKey, iNextId) );
|
|
174 |
if (err == KErrNotFound)
|
|
175 |
{
|
|
176 |
iNextId = KMinIdValue;
|
|
177 |
User::LeaveIfError(iRepository->Create(KNextIdKey, iNextId) );
|
|
178 |
}
|
|
179 |
else
|
|
180 |
{
|
|
181 |
User::LeaveIfError(err);
|
|
182 |
}
|
|
183 |
LoadComponentsL();
|
|
184 |
}
|
|
185 |
|
|
186 |
void CDeliveryComponentStorage::LoadCertsL()
|
|
187 |
{
|
|
188 |
RFs fs;
|
|
189 |
User::LeaveIfError(fs.Connect() );
|
|
190 |
CleanupClosePushL(fs);
|
|
191 |
TInt e(fs.CreatePrivatePath(KDefaultDrive) );
|
|
192 |
|
|
193 |
User::LeaveIfError(e);
|
|
194 |
TBuf<64> privatePath;
|
|
195 |
User::LeaveIfError(fs.PrivatePath(privatePath) );
|
|
196 |
|
|
197 |
TInt privPathLength(privatePath.Length() );
|
|
198 |
_LIT( KCertFile, "amcerts.dat");
|
|
199 |
HBufC *afile = HBufC::NewLC(privPathLength + KCertFile().Length());
|
|
200 |
*afile = privatePath;
|
|
201 |
afile->Des().Append(KCertFile);
|
|
202 |
RFileReadStream certFile;
|
|
203 |
TInt err(certFile.Open(fs, *afile, EFileRead) );
|
|
204 |
if (err == KErrNone)
|
|
205 |
{
|
|
206 |
CleanupClosePushL(certFile);
|
|
207 |
iCertificates.InternalizeL(certFile);
|
|
208 |
CleanupStack::PopAndDestroy( &certFile);
|
|
209 |
}
|
|
210 |
else
|
|
211 |
if (err == KErrNotFound)
|
|
212 |
{
|
|
213 |
|
|
214 |
}
|
|
215 |
else
|
|
216 |
{
|
|
217 |
User::Leave(err);
|
|
218 |
}
|
|
219 |
CleanupStack::PopAndDestroy(afile);
|
|
220 |
CleanupStack::PopAndDestroy( &fs);
|
|
221 |
}
|
|
222 |
|
|
223 |
CDeliveryComponentStorage* CDeliveryComponentStorage::NewLC()
|
|
224 |
{
|
|
225 |
CDeliveryComponentStorage *self = new ( ELeave ) CDeliveryComponentStorage( );
|
|
226 |
CleanupStack::PushL(self) ;
|
|
227 |
self->ConstructL() ;
|
|
228 |
return self;
|
|
229 |
}
|
|
230 |
|
|
231 |
CDeliveryComponentStorage* CDeliveryComponentStorage::NewL()
|
|
232 |
{
|
|
233 |
CDeliveryComponentStorage *self = NewLC();
|
|
234 |
CleanupStack::Pop(self) ;
|
|
235 |
return self;
|
|
236 |
}
|
|
237 |
|
|
238 |
TInt CDeliveryComponentStorage::NextKey()
|
|
239 |
{
|
|
240 |
TInt oldNext(iNextId++);
|
|
241 |
iRepository->Set(KNextIdKey, iNextId);
|
|
242 |
return oldNext;
|
|
243 |
}
|
|
244 |
|
|
245 |
CDeliveryComponentStorage::~CDeliveryComponentStorage()
|
|
246 |
{
|
|
247 |
RDEBUG_3( "CDeliveryComponentStorage::~CDeliveryComponentStorage 0x%X - 0x%X", reinterpret_cast<TUint>(this),
|
|
248 |
reinterpret_cast<TUint>(this)+sizeof( CDeliveryComponentStorage ) );
|
|
249 |
delete iRepository;
|
|
250 |
iRepository = NULL;
|
|
251 |
iComponents.ResetAndDestroy();
|
|
252 |
iComponentIds.Close();
|
|
253 |
TRAPD( err,CloseCertificatesL() )
|
|
254 |
;
|
|
255 |
if (err != KErrNone)
|
|
256 |
{
|
|
257 |
RDEBUG_2( "CDeliveryComponentStorage::~CDeliveryComponentStorage: ERROR Failed to close certificate storage properly: %d", err);
|
|
258 |
}
|
|
259 |
#ifndef __SERIES60_30__
|
|
260 |
delete iHidder;
|
|
261 |
iHidder = NULL;
|
|
262 |
#endif
|
|
263 |
}
|
|
264 |
|
|
265 |
void CDeliveryComponentStorage::CloseCertificatesL()
|
|
266 |
{
|
|
267 |
RFs fs;
|
|
268 |
User::LeaveIfError(fs.Connect() );
|
|
269 |
CleanupClosePushL(fs);
|
|
270 |
TInt e(fs.CreatePrivatePath(KDefaultDrive) );
|
|
271 |
|
|
272 |
User::LeaveIfError(e);
|
|
273 |
TBuf<64> privatePath;
|
|
274 |
User::LeaveIfError(fs.PrivatePath(privatePath) );
|
|
275 |
|
|
276 |
TInt privPathLength(privatePath.Length() );
|
|
277 |
_LIT( KCertFile, "amcerts.dat");
|
|
278 |
HBufC *afile = HBufC::NewLC(privPathLength + KCertFile().Length());
|
|
279 |
*afile = privatePath;
|
|
280 |
afile->Des().Append(KCertFile);
|
|
281 |
RFileWriteStream certFile;
|
|
282 |
|
|
283 |
TInt err(certFile.Replace(fs, *afile, EFileWrite) );
|
|
284 |
if (err == KErrNone)
|
|
285 |
{
|
|
286 |
CleanupClosePushL(certFile);
|
|
287 |
iCertificates.ExternalizeL(certFile);
|
|
288 |
CleanupStack::PopAndDestroy( &certFile);
|
|
289 |
}
|
|
290 |
else
|
|
291 |
if (err == KErrNotFound)
|
|
292 |
{
|
|
293 |
|
|
294 |
}
|
|
295 |
else
|
|
296 |
{
|
|
297 |
User::Leave(err);
|
|
298 |
}
|
|
299 |
CleanupStack::PopAndDestroy(afile);
|
|
300 |
CleanupStack::PopAndDestroy( &fs);
|
|
301 |
iCertificates.ResetAndDestroy();
|
|
302 |
}
|
|
303 |
|
|
304 |
const RComponentIdArray &CDeliveryComponentStorage::GetComponentIds() const
|
|
305 |
{
|
|
306 |
return iComponentIds;
|
|
307 |
}
|
|
308 |
|
|
309 |
void CDeliveryComponentStorage::GetStateChangeComponentIdsL(
|
|
310 |
RComponentIdArray &aArray)
|
|
311 |
{
|
|
312 |
RDEBUG_2( "CDeliveryComponentStorage::GetStateChangeComponentIdsL %d dcs", iComponentIds.Count());
|
|
313 |
aArray.Reset();
|
|
314 |
TInt c(iComponentIds.Count() );
|
|
315 |
for (TInt i( 0); i < c; i++)
|
|
316 |
{
|
|
317 |
CDeploymentComponent &compo = ComponentL(iComponentIds[i]);
|
|
318 |
if (compo.OldState() != EDCSNone)
|
|
319 |
{
|
|
320 |
aArray.Append(iComponentIds[i]);
|
|
321 |
}
|
|
322 |
}
|
|
323 |
RDEBUG( "CDeliveryComponentStorage::GetStateChangeComponentIdsL end");
|
|
324 |
}
|
|
325 |
|
|
326 |
void CDeliveryComponentStorage::StateChangedL(TUint32 aInternalId)
|
|
327 |
{
|
|
328 |
RDEBUG_2( "CDeliveryComponentStorage::StateChangedL id %d", aInternalId);
|
|
329 |
CDeploymentComponent &compo = ComponentL(aInternalId);
|
|
330 |
compo.StateChangeComplete();
|
|
331 |
UpdateL(compo);
|
|
332 |
}
|
|
333 |
|
|
334 |
void CDeliveryComponentStorage::LoadComponentsL()
|
|
335 |
{
|
|
336 |
TInt length( 0);
|
|
337 |
TInt err(iRepository->Get(KIdListLengthKey, length) );
|
|
338 |
if (err == KErrNotFound)
|
|
339 |
{
|
|
340 |
length = 0;
|
|
341 |
User::LeaveIfError(iRepository->Create(KIdListLengthKey, length) );
|
|
342 |
}
|
|
343 |
else
|
|
344 |
{
|
|
345 |
User::LeaveIfError(err);
|
|
346 |
}
|
|
347 |
HBufC8 *listbuf = HBufC8::NewLC(length) ;
|
|
348 |
TPtr8 ptr(listbuf->Des() );
|
|
349 |
err = iRepository->Get(KIdListKey, ptr) ;
|
|
350 |
if (err == KErrNotFound)
|
|
351 |
{
|
|
352 |
err = iRepository->Create(KIdListKey, KNullDesC8);
|
|
353 |
}
|
|
354 |
else
|
|
355 |
{
|
|
356 |
|
|
357 |
}
|
|
358 |
User::LeaveIfError(err);
|
|
359 |
TRAPD(code, iComponentIds.SetListL( ptr ))
|
|
360 |
;
|
|
361 |
if (code != KErrEof)
|
|
362 |
{
|
|
363 |
User::LeaveIfError(code);
|
|
364 |
}
|
|
365 |
|
|
366 |
CleanupStack::PopAndDestroy(listbuf);
|
|
367 |
#ifndef __SERIES60_30__
|
|
368 |
TInt i(iComponentIds.Count() );
|
|
369 |
//iHidder->Reset();
|
|
370 |
while ( --i >= 0)
|
|
371 |
{
|
|
372 |
CDeploymentComponent &comp = ComponentL(iComponentIds[i]);
|
|
373 |
if (comp.State() == EDCSInactive)
|
|
374 |
{
|
|
375 |
iHidder->AddUidL(comp.Uid());
|
|
376 |
}
|
|
377 |
else
|
|
378 |
if (comp.State() == EDCSActive)
|
|
379 |
{
|
|
380 |
iHidder->RemoveUidL(comp.Uid() );
|
|
381 |
}
|
|
382 |
}
|
|
383 |
iHidder->PersistUidsL();
|
|
384 |
#endif
|
|
385 |
|
|
386 |
}
|
|
387 |
|
|
388 |
CDeploymentComponent *CDeliveryComponentStorage::NewComponentL(
|
|
389 |
const TDeploymentComponentState &aState, const TDCUserId &aUserId,
|
|
390 |
const TCertInfo *aCertInfo/* = NULL */)
|
|
391 |
{
|
|
392 |
CDeploymentComponent *newc = CDeploymentComponent::NewLC(NextKey(),
|
|
393 |
aUserId);
|
|
394 |
if (aCertInfo != NULL)
|
|
395 |
{
|
|
396 |
TCertInfoPckg *p = new( ELeave ) TCertInfoPckg(*aCertInfo);
|
|
397 |
RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - allocated TCertInfoPckg 0x%X", reinterpret_cast<TUint>( p ) );
|
|
398 |
|
|
399 |
TInt idx(iCertificates.FindByValue(*p) );
|
|
400 |
if (idx == KErrNotFound)
|
|
401 |
{
|
|
402 |
RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - TCertInfoPckg NOT found 0x%X", reinterpret_cast<TUint>( p ) );
|
62
|
403 |
TRAPD(err,iCertificates.AppendL(p));
|
|
404 |
if(err != KErrNone)
|
|
405 |
{
|
|
406 |
delete p;
|
|
407 |
p = NULL;
|
|
408 |
User::Leave( err );
|
|
409 |
}
|
|
410 |
else
|
|
411 |
{
|
|
412 |
idx = iCertificates.Count() - 1;
|
|
413 |
}
|
47
|
414 |
}
|
|
415 |
else
|
|
416 |
{
|
|
417 |
RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - TCertInfoPckg found at %d, deleting temporary", idx );
|
|
418 |
delete p;
|
|
419 |
p = NULL;
|
|
420 |
}
|
|
421 |
if (idx >= 0)
|
|
422 |
{
|
|
423 |
RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - TCertInfoPckg found 0x%X", reinterpret_cast<TUint>( p ) );
|
|
424 |
newc->SetOwner(idx);
|
|
425 |
}
|
|
426 |
else
|
|
427 |
{
|
|
428 |
RDEBUG_3( "CDeliveryComponentStorage::NewComponentL - WARNING Could not add certificate 0x%X: %d", reinterpret_cast<TUint>( p ), idx );
|
|
429 |
|
|
430 |
}
|
|
431 |
}
|
|
432 |
newc->SetState(aState);
|
|
433 |
newc->SetStatusNode(EIdle);
|
|
434 |
UpdateL( *newc);
|
62
|
435 |
iComponents.AppendL(newc);
|
|
436 |
iComponentIds.AppendL(newc->InternalId() );
|
47
|
437 |
RDEBUG_2( "CDeliveryComponentStorage::NewComponentL -Internal ID is %d, ", newc->InternalId() );
|
|
438 |
PersistStateL();
|
|
439 |
CleanupStack::Pop(newc);
|
|
440 |
return newc;
|
|
441 |
}
|
|
442 |
|
|
443 |
void CDeliveryComponentStorage::UpdateL(
|
|
444 |
const CDeploymentComponent &aComponent)
|
|
445 |
{
|
|
446 |
aComponent.PersistL( *iRepository) ;
|
|
447 |
|
|
448 |
#ifndef __SERIES60_30__
|
|
449 |
if (aComponent.State() == EDCSInactive)
|
|
450 |
{
|
|
451 |
iHidder->AddUidL(aComponent.Uid(), ETrue);
|
|
452 |
}
|
|
453 |
else
|
|
454 |
{
|
|
455 |
iHidder->RemoveUidL(aComponent.Uid(), ETrue);
|
|
456 |
}
|
|
457 |
#endif
|
|
458 |
}
|
|
459 |
|
|
460 |
void CDeliveryComponentStorage::PersistStateL()
|
|
461 |
{
|
|
462 |
TInt length( 0);
|
|
463 |
HBufC8 *buf= NULL;
|
|
464 |
iComponentIds.GetListLC(buf, length);
|
|
465 |
User::LeaveIfError(iRepository->Set(KIdListLengthKey, length) );
|
|
466 |
User::LeaveIfError(iRepository->Set(KIdListKey, *buf) );
|
|
467 |
CleanupStack::PopAndDestroy(buf);
|
|
468 |
}
|
|
469 |
|
|
470 |
void CDeliveryComponentStorage::RemoveL(TUint32 aInternalId)
|
|
471 |
{
|
|
472 |
RDEBUG_2("CDeliveryComponentStorage::RemoveL - Remove id: (%d)", aInternalId );
|
|
473 |
TInt count(iComponents.Count() );
|
|
474 |
for (TInt i( 0); i < count; i++)
|
|
475 |
{
|
|
476 |
CDeploymentComponent *el = iComponents[i];
|
|
477 |
if (aInternalId == el->iInternalId)
|
|
478 |
{
|
|
479 |
#ifndef __SERIES60_30__
|
|
480 |
iHidder->RemoveUidL(el->Uid(), ETrue);
|
|
481 |
#endif
|
|
482 |
iComponents.Remove(i);
|
|
483 |
iComponentIds.RemoveByValue(aInternalId);
|
|
484 |
el->DestroyL( *iRepository);
|
|
485 |
delete el;
|
|
486 |
RDEBUG_2("CDeliveryComponentStorage::RemoveL - Removed id: (%d)", aInternalId );
|
|
487 |
PersistStateL();
|
|
488 |
break;
|
|
489 |
}
|
|
490 |
}
|
|
491 |
}
|
|
492 |
|
|
493 |
CDeploymentComponent &CDeliveryComponentStorage::ComponentL(
|
|
494 |
TUint32 aInternalId)
|
|
495 |
{
|
|
496 |
CDeploymentComponent *resp= NULL;
|
|
497 |
TInt count(iComponents.Count() );
|
|
498 |
for (TInt i( 0); i < count; i++)
|
|
499 |
{
|
|
500 |
CDeploymentComponent *el = iComponents[i];
|
|
501 |
if (aInternalId == el->iInternalId)
|
|
502 |
{
|
|
503 |
resp = el;
|
|
504 |
break;
|
|
505 |
}
|
|
506 |
}
|
|
507 |
if (resp == NULL)
|
|
508 |
{
|
|
509 |
TBuf8< NCentralRepositoryConstants::KMaxBinaryLength> buf;
|
|
510 |
TInt err(iRepository->Get(aInternalId, buf) );
|
|
511 |
User::LeaveIfError(err) ;
|
|
512 |
resp = LoadComponentL(aInternalId, buf) ;
|
62
|
513 |
iComponents.AppendL(resp);
|
47
|
514 |
}
|
|
515 |
if (resp == NULL)
|
|
516 |
{
|
|
517 |
User::Leave(KErrNotFound);
|
|
518 |
}
|
|
519 |
return *resp;
|
|
520 |
}
|
|
521 |
|
|
522 |
CDeploymentComponent *CDeliveryComponentStorage::LoadComponentL(
|
|
523 |
TInt aInternalId, const TDesC8 &aBuffer) const
|
|
524 |
{
|
|
525 |
CDeploymentComponent *res = CDeploymentComponent::LoadL(aInternalId,
|
|
526 |
aBuffer);
|
|
527 |
#ifdef _DEBUG
|
|
528 |
if (res)
|
|
529 |
{
|
|
530 |
RDEBUG8_4( "CDeliveryComponentStorage::LoadComponentL - loaded component state %d, internalid %d, and userid: %S", res->State(), res->InternalId(),&res->UserId() );
|
|
531 |
}
|
|
532 |
else
|
|
533 |
{
|
|
534 |
RDEBUG( "CDeliveryComponentStorage::LoadComponentL - WARNING failed to load component" );
|
|
535 |
}
|
|
536 |
#endif
|
|
537 |
return res;
|
|
538 |
}
|
|
539 |
void CDeliveryComponentStorage::CheckForDuplicateNodesInDeployedL(
|
|
540 |
CDeploymentComponent &aComponent)
|
|
541 |
{
|
|
542 |
TInt CompIdsCount(iComponentIds.Count() );
|
|
543 |
RDEBUG8_2("CheckForDuplicateNodesInDeployedL: CompIdsCount-> (%d)", CompIdsCount );
|
|
544 |
RDEBUG8_2("CheckForDuplicateNodesInDeployedL: aComponent UserID is %S", &(aComponent.UserId()));
|
|
545 |
for (TInt i( 0); i < CompIdsCount; i++)
|
|
546 |
{
|
|
547 |
CDeploymentComponent &compo = ComponentL(iComponentIds[i]);
|
|
548 |
RDEBUG8_2("CheckForDuplicateNodesInDeployedL: compo UserID is %S", &(compo.UserId()));
|
|
549 |
if (&aComponent != &compo)
|
|
550 |
{
|
|
551 |
if (((compo.State()== EDCSActive) || (compo.State()== EDCSInactive))
|
|
552 |
&&(compo.UserId() == aComponent.UserId()))
|
|
553 |
{
|
|
554 |
(aComponent.iUserId).Append(*IntToDes8LC(aComponent.iInternalId));
|
|
555 |
CleanupStack::PopAndDestroy();
|
|
556 |
break;
|
|
557 |
}
|
|
558 |
}
|
|
559 |
}
|
|
560 |
}
|
|
561 |
|
|
562 |
HBufC8* CDeliveryComponentStorage::IntToDes8LC(const TInt aLuid)
|
|
563 |
{
|
|
564 |
HBufC8* buf = HBufC8::NewLC( 10); //10 = max length of 32bit integer
|
|
565 |
TPtr8 ptrBuf = buf->Des();
|
|
566 |
ptrBuf.Num(aLuid);
|
|
567 |
return buf;
|
|
568 |
}
|
|
569 |
|
|
570 |
void CDeliveryComponentStorage::InstalledL(CDeploymentComponent &aComponent)
|
|
571 |
{
|
|
572 |
CheckForDuplicateNodesInDeployedL(aComponent);
|
|
573 |
aComponent.SetState(EDCSActive);
|
|
574 |
// set state to IDLE
|
|
575 |
aComponent.SetStatusNode(EIdle);
|
|
576 |
UpdateL(aComponent);
|
|
577 |
}
|
|
578 |
|
|
579 |
void CDeliveryComponentStorage::DeactivateL(CDeploymentComponent &aComponent)
|
|
580 |
{
|
|
581 |
/* :
|
|
582 |
* set state to InActivate in progress
|
|
583 |
* use TRAP instead of leaving.
|
|
584 |
*/
|
|
585 |
aComponent.SetStatusNode(EDeployed_DeactivateProgress);
|
|
586 |
//User::LeaveIfError(aComponent.SetState(EDCSInactive) );
|
|
587 |
TInt err = aComponent.SetState(EDCSInactive);
|
|
588 |
if (err == KErrNone)
|
|
589 |
{
|
|
590 |
TRAP(err,UpdateL(aComponent));
|
|
591 |
}
|
|
592 |
//UpdateL(aComponent);
|
|
593 |
/*:
|
|
594 |
* if error set state to InActivate failed or else set to Idle
|
|
595 |
* call userleaveiferror()
|
|
596 |
*/
|
|
597 |
if (err == KErrNone)
|
|
598 |
{
|
|
599 |
aComponent.SetStatusNode(EIdle);
|
|
600 |
}
|
|
601 |
else
|
|
602 |
{
|
|
603 |
aComponent.SetStatusNode(EDeployed_DeactivateFailed);
|
|
604 |
}
|
|
605 |
User::LeaveIfError(err);
|
|
606 |
}
|
|
607 |
|
|
608 |
void CDeliveryComponentStorage::SetDeploymentComponentState(CDeploymentComponent &aComponent,TDeploymentComponentState aState)
|
|
609 |
{
|
|
610 |
aComponent.SetState( aState );
|
|
611 |
TRAP_IGNORE(UpdateL( aComponent ));
|
|
612 |
}
|
|
613 |
|
|
614 |
void CDeliveryComponentStorage::ActivateL(CDeploymentComponent &aComponent)
|
|
615 |
{
|
|
616 |
/* :
|
|
617 |
* set state to Activate in progress
|
|
618 |
* use TRAP instead of leaving.
|
|
619 |
*/
|
|
620 |
aComponent.SetStatusNode(EDeployed_ActivateProgress);
|
|
621 |
TInt err = aComponent.SetState(EDCSActive);
|
|
622 |
//UpdateL( aComponent );
|
|
623 |
if (err == KErrNone)
|
|
624 |
{
|
|
625 |
TRAP(err,UpdateL(aComponent));
|
|
626 |
}
|
|
627 |
/*:
|
|
628 |
* if error set state to InActivate failed or else set to Idle
|
|
629 |
* call userleaveiferror()
|
|
630 |
*/
|
|
631 |
if (err == KErrNone)
|
|
632 |
{
|
|
633 |
aComponent.SetStatusNode(EIdle);
|
|
634 |
}
|
|
635 |
else
|
|
636 |
{
|
|
637 |
aComponent.SetStatusNode(EDeployed_ActivateFailed);
|
|
638 |
}
|
|
639 |
User::LeaveIfError(err);
|
|
640 |
}
|
|
641 |
|
|
642 |
/*void CDeliveryComponentStorage::UninstalledL( CDeploymentComponent &aComponent )
|
|
643 |
{
|
|
644 |
aComponent.SetState( EDCSInactive );
|
|
645 |
UpdateL( aComponent );
|
|
646 |
}
|
|
647 |
|
|
648 |
void CDeliveryComponentStorage::ResetL()
|
|
649 |
{
|
|
650 |
}
|
|
651 |
*/
|
|
652 |
// End of File
|