|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of applicationmanagement components |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "AMDownload.h" |
|
19 #include "AMDeploymentComponent.h" |
|
20 #include "debug.h" |
|
21 #include <e32debug.h> |
|
22 #include <s32mem.h> |
|
23 #include <featmgr.h> |
|
24 #include "amprivateCRKeys.h" |
|
25 //#include "aminstalloptions.h" |
|
26 #include <ssl.h> |
|
27 #ifdef __SERIES60_30__ |
|
28 #include <CMenuClient.h> |
|
29 #endif |
|
30 #include "amsmlhelper.h" |
|
31 |
|
32 using namespace NApplicationManagement; |
|
33 |
|
34 _LIT8( KAMDCDataSuffix, "_D.txt"); |
|
35 _LIT8( KAMDCMetaDataSuffix, "_M.txt"); |
|
36 |
|
37 |
|
38 /*************************************************** |
|
39 // CDeploymentComponent |
|
40 ***************************************************/ |
|
41 |
|
42 CDeploymentComponent* CDeploymentComponent::NewLC(TInt aInternalId, |
|
43 const TDCUserId &aUserId) |
|
44 { |
|
45 CDeploymentComponent *self = new ( ELeave ) CDeploymentComponent( aInternalId ); |
|
46 CleanupStack::PushL(self) ; |
|
47 self->ConstructL(aUserId) ; |
|
48 return self; |
|
49 } |
|
50 |
|
51 CDeploymentComponent* CDeploymentComponent::NewL(TInt aInternalId, |
|
52 const TDCUserId &aUserId) |
|
53 { |
|
54 CDeploymentComponent *self = NewLC(aInternalId, aUserId); |
|
55 CleanupStack::Pop(self) ; |
|
56 return self; |
|
57 } |
|
58 |
|
59 CDeploymentComponent* CDeploymentComponent::LoadLC(TInt aInternalId, |
|
60 const TDesC8 &aBuffer) |
|
61 { |
|
62 CDeploymentComponent *self = new ( ELeave ) CDeploymentComponent(aInternalId); |
|
63 CleanupStack::PushL(self) ; |
|
64 self->ConstructLoadL(aBuffer) ; |
|
65 return self; |
|
66 } |
|
67 |
|
68 CDeploymentComponent* CDeploymentComponent::LoadL(TInt aInternalId, |
|
69 const TDesC8 &aBuffer) |
|
70 { |
|
71 CDeploymentComponent *self = LoadLC(aInternalId, aBuffer); |
|
72 CleanupStack::Pop(self) ; |
|
73 return self; |
|
74 } |
|
75 |
|
76 CDeploymentComponent::CDeploymentComponent(TInt aInternalId) : |
|
77 iInternalId(aInternalId), iPkgVersion( 3), iOwner( -1), |
|
78 iOwnerProfile( -1) |
|
79 { |
|
80 iUninstallOpts.iKillApp = SwiUI::EPolicyAllowed; |
|
81 SwiUI::TInstallOptions &opts = iInstallOpts.iOptions; |
|
82 opts.iUpgrade = SwiUI::EPolicyNotAllowed; |
|
83 opts.iOptionalItems = SwiUI::EPolicyNotAllowed; |
|
84 opts.iOCSP = SwiUI::EPolicyNotAllowed; |
|
85 opts.iIgnoreOCSPWarnings = SwiUI::EPolicyNotAllowed; |
|
86 // iIgnoreOtherWarnings = SwiUI::EPolicyNotAllowed; |
|
87 opts.iUntrusted = SwiUI::EPolicyNotAllowed; |
|
88 opts.iPackageInfo = SwiUI::EPolicyNotAllowed; |
|
89 opts.iCapabilities = SwiUI::EPolicyNotAllowed; |
|
90 opts.iKillApp = SwiUI::EPolicyNotAllowed; |
|
91 opts.iOverwrite = SwiUI::EPolicyNotAllowed; |
|
92 opts.iDownload = SwiUI::EPolicyNotAllowed; |
|
93 opts.iDrive = SwiUI::EPolicyNotAllowed; |
|
94 opts.iLang = ELangNone; |
|
95 opts.iUsePhoneLang = EFalse; |
|
96 } |
|
97 |
|
98 CDeploymentComponent::~CDeploymentComponent() |
|
99 { |
|
100 RDEBUG8_3( "CDeploymentComponent::~CDeploymentComponent 0x%X - 0x%X", |
|
101 reinterpret_cast<TUint>(this), reinterpret_cast<TUint>(this)+sizeof( CDeploymentComponent ) ); |
|
102 delete iData; |
|
103 iData = NULL; |
|
104 |
|
105 delete iMetaData; |
|
106 iMetaData = NULL; |
|
107 } |
|
108 |
|
109 CDeploymentComponent &CDeploymentComponent::operator=( const CDeploymentComponent &aData ) |
|
110 { |
|
111 if( &aData != this ) |
|
112 { |
|
113 *iData = aData.Data(); |
|
114 *iMetaData = aData.MetaData(); |
|
115 iId = aData.ComponentId(); |
|
116 iName = aData.ComponentName(); |
|
117 iVersion = aData.iVersion; |
|
118 iState = aData.State(); |
|
119 iInternalId = aData.InternalId(); |
|
120 iUid = aData.Uid(); |
|
121 iUserId = aData.iUserId; |
|
122 iOwner = aData.iOwner; |
|
123 iInstallOpts = aData.InstallOpts(); |
|
124 iPkgID = aData.PkgId(); |
|
125 iDescription = aData.Description(); |
|
126 iPkgIDRef = aData.PkgIDRef(); |
|
127 iPkgType = aData.PkgType(); |
|
128 iRemovableApp = aData.AppRemovable(); |
|
129 iInstallOptsSet = aData.InstallOptsSet(); |
|
130 iPkgVersion = aData.iPkgVersion; |
|
131 iDownloadStatus = aData.iDownloadStatus; |
|
132 iDownloadURI = aData.iDownloadURI; |
|
133 iUninstallOpts = aData.UninstallOpts(); |
|
134 iOwnerProfile = aData.OwnerProfile(); |
|
135 } |
|
136 return *this; |
|
137 } |
|
138 |
|
139 void CDeploymentComponent::PersistL(CRepository &aRepository) const |
|
140 { |
|
141 CBufBase *buf = CBufFlat::NewL( 32); |
|
142 CleanupStack::PushL(buf); |
|
143 TInt length(SerializedFormLength() ); |
|
144 buf->ExpandL(0, length+1); |
|
145 TPtr8 p3(buf->Ptr(0) ); |
|
146 RDesWriteStream stream(p3); |
|
147 TInt len(SerializedFormL(stream) ); |
|
148 TBuf8< NCentralRepositoryConstants::KMaxBinaryLength> tbuf; |
|
149 |
|
150 TInt err(aRepository.Get(iInternalId, tbuf) ); |
|
151 if (err == KErrNotFound) |
|
152 { |
|
153 err = aRepository.Create(iInternalId, buf->Ptr(0) ); |
|
154 RDEBUG_3( "CDeploymentComponent::PersistL: Created %d to centrep with status %d", iInternalId, err ); |
|
155 } |
|
156 else |
|
157 { |
|
158 User::LeaveIfError(err) ; |
|
159 err = aRepository.Set(iInternalId, buf->Ptr(0) ); |
|
160 RDEBUG_3( "CDeploymentComponent::PersistL: Persisted %d to centrep with status %d", iInternalId, err ); |
|
161 } |
|
162 User::LeaveIfError(err) ; |
|
163 CleanupStack::PopAndDestroy(buf); |
|
164 RFs fs; |
|
165 User::LeaveIfError(fs.Connect() ); |
|
166 CleanupClosePushL(fs); |
|
167 iData->PersistL(fs); |
|
168 iMetaData->PersistL(fs); |
|
169 CleanupStack::PopAndDestroy( &fs) ; |
|
170 } |
|
171 |
|
172 void CDeploymentComponent::CopyStateTo(TDeploymentComponent &aInfo) const |
|
173 { |
|
174 aInfo.iId = iId; |
|
175 aInfo.iName = iName; |
|
176 aInfo.iVersion = iVersion; |
|
177 aInfo.iDescription = iDescription; |
|
178 aInfo.iPkgID = iPkgID; |
|
179 aInfo.iPkgIDRef = iPkgIDRef; |
|
180 aInfo.iPkgType = iPkgType; |
|
181 aInfo.iState = iState; |
|
182 aInfo.iOldState = iOldState; |
|
183 } |
|
184 |
|
185 TBool CDeploymentComponent::IsJavaMimeL(const TDesC8& aMime) |
|
186 { |
|
187 |
|
188 FeatureManager::InitializeLibL(); |
|
189 TBool supported = EFalse; |
|
190 |
|
191 if (FeatureManager::FeatureSupported(KFeatureIdJavaMIDP20) ) |
|
192 { |
|
193 supported = ((aMime == SwiUI::KJarMIMEType || aMime |
|
194 == SwiUI::KJadMIMEType || aMime == SwiUI::KJarxMIMEType |
|
195 || aMime == SwiUI::KJavaMIMEType) ? ETrue : EFalse ); |
|
196 } |
|
197 FeatureManager::UnInitializeLib(); |
|
198 |
|
199 return supported; |
|
200 } |
|
201 |
|
202 TBool CDeploymentComponent::IsSisMimeL(const TDesC8& aMime) |
|
203 { |
|
204 |
|
205 |
|
206 TBool supported = EFalse; |
|
207 |
|
208 supported = ((aMime == SwiUI::KSisxMimeType || aMime |
|
209 == SwiUI::KSisMimeType || aMime == SwiUI::KPipMimeType) ? ETrue : EFalse ); |
|
210 |
|
211 return supported; |
|
212 } |
|
213 |
|
214 void CDeploymentComponent::ConstructL(const TDCUserId &aUserId) |
|
215 { |
|
216 iUserId = aUserId; |
|
217 RFs fs; |
|
218 User::LeaveIfError(fs.Connect() ); |
|
219 CleanupClosePushL(fs); |
|
220 TInt e(fs.CreatePrivatePath(KDefaultDrive) ); |
|
221 User::LeaveIfError(e); |
|
222 TBuf<30> privatePath; |
|
223 fs.PrivatePath(privatePath); |
|
224 CleanupStack::PopAndDestroy( &fs); |
|
225 |
|
226 TInt privPathLength(privatePath.Length() ); |
|
227 TBuf8<10> buf; |
|
228 buf.NumFixedWidth(iInternalId, EHex, 10); |
|
229 |
|
230 TBuf8 <30> path; |
|
231 path.Copy(privatePath); |
|
232 HBufC8 *afilename = HBufC8::NewLC(privPathLength + 10 + KAMDCDataSuffix().Length()); |
|
233 *afilename = path; |
|
234 TPtr8 afn(afilename->Des() ); |
|
235 afn.Append(buf); |
|
236 afn.Append(KAMDCDataSuffix) ; |
|
237 iData = CDeploymentComponentData::NewL(CDeploymentComponentData::EData, |
|
238 KNullDesC8, KNullDesC8, afn); |
|
239 |
|
240 afn.Replace(privPathLength + 10, KAMDCMetaDataSuffix().Length(), KAMDCMetaDataSuffix); |
|
241 iMetaData = CDeploymentComponentData::NewL( |
|
242 CDeploymentComponentData::EMetaData, KNullDesC8, KNullDesC8, afn); |
|
243 |
|
244 CleanupStack::PopAndDestroy(afilename); |
|
245 } |
|
246 |
|
247 TInt CDeploymentComponent::SerializedFormLength() const |
|
248 { |
|
249 // 0 1 2 3 4 5 6 7 8 9 10 11 |
|
250 // iUserId , iState, iPkgVer, iUid, iIdLen, iNameLen, iVersLen, iDownState, iOwner, iOldState ,iDownUriLen, iInstallOptsset |
|
251 return (20*4)+iUserId.Length() + iId.Length() + iName.Length() |
|
252 + iVersion.Length() + |
|
253 |
|
254 iMidletName.Length() + iMideltVendorName.Length() |
|
255 + iMidletVersion.Length()+ iDownloadURI.Length() |
|
256 + iDescription.Length()+ iPkgID.Length()+iPkgIDRef.Length() |
|
257 +iPkgType.Length()+ sizeof(iRemovableApp) + iData->SerializedFormLength() |
|
258 + iMetaData->SerializedFormLength() + sizeof(TAMInstallOptions); |
|
259 } |
|
260 |
|
261 TInt CDeploymentComponent::SerializedFormL(RWriteStream &aBuffer) const |
|
262 { |
|
263 #ifdef _DEBUG |
|
264 RDEBUG_2( "Offset before uint: %d", aBuffer.Sink()->TellL( MStreamBuf::EWrite ).Offset() ); |
|
265 #endif |
|
266 |
|
267 aBuffer.WriteUint32L(iPkgVersion); |
|
268 |
|
269 #ifdef _DEBUG |
|
270 RDEBUG_2( "Offset after uint: %d" , aBuffer.Sink()->TellL( MStreamBuf::EWrite ).Offset() ); |
|
271 #endif |
|
272 |
|
273 aBuffer.WriteUint32L(iState); |
|
274 aBuffer.WriteUint32L(iStatus); |
|
275 aBuffer.WriteUint32L(iUid.iUid); |
|
276 aBuffer.WriteUint32L(iUserId.Length() ); |
|
277 aBuffer.WriteL(iUserId); |
|
278 aBuffer.WriteUint32L(iId.Length() ); |
|
279 aBuffer.WriteL(iId); |
|
280 aBuffer.WriteUint32L(iName.Length() ); |
|
281 aBuffer.WriteL(iName); |
|
282 aBuffer.WriteUint32L(iVersion.Length() ); |
|
283 aBuffer.WriteL(iVersion); |
|
284 aBuffer.WriteUint32L(iMidletName.Length() ); |
|
285 aBuffer.WriteL(iMidletName); |
|
286 aBuffer.WriteUint32L(iMideltVendorName.Length() ); |
|
287 aBuffer.WriteL(iMideltVendorName); |
|
288 aBuffer.WriteUint32L(iMidletVersion.Length() ); |
|
289 aBuffer.WriteL(iMidletVersion); |
|
290 aBuffer.WriteInt32L(iDownloadStatus); |
|
291 aBuffer.WriteInt32L(iOwner); |
|
292 aBuffer.WriteUint32L(iOldState); |
|
293 aBuffer.WriteUint32L(iDownloadURI.Length() ); |
|
294 aBuffer.WriteL(iDownloadURI); |
|
295 aBuffer.WriteUint32L(iDescription.Length() ); |
|
296 aBuffer.WriteL(iDescription); |
|
297 aBuffer.WriteUint32L(iPkgID.Length() ); |
|
298 aBuffer.WriteL(iPkgID); |
|
299 aBuffer.WriteUint32L(iPkgIDRef.Length() ); |
|
300 aBuffer.WriteL(iPkgIDRef); |
|
301 aBuffer.WriteUint32L(iPkgType.Length() ); |
|
302 aBuffer.WriteL(iPkgType); |
|
303 aBuffer.WriteUint32L(iRemovableApp); |
|
304 iData->SerializedFormL(aBuffer); |
|
305 iMetaData->SerializedFormL(aBuffer); |
|
306 aBuffer.WriteUint32L(iInstallOptsSet); |
|
307 TPckg<TAMInstallOptions> opts(iInstallOpts); |
|
308 aBuffer.WriteL(opts); |
|
309 return aBuffer.Sink()->TellL( MStreamBuf::EWrite ).Offset(); |
|
310 } |
|
311 |
|
312 void CDeploymentComponent::ConstructLoadL(const TDesC8 &aBuffer) |
|
313 { |
|
314 RDEBUG( "CDeploymentComponent::ConstructLoadL "); |
|
315 TDeploymentComponent aRes; |
|
316 TMimeType aType; |
|
317 |
|
318 RDesReadStream stream(aBuffer); |
|
319 iPkgVersion = stream.ReadUint32L(); |
|
320 |
|
321 iState = static_cast<TDeploymentComponentState>(stream.ReadUint32L() ); |
|
322 iStatus = static_cast<TSCOMOStatusNodeStates>(stream.ReadUint32L() ); |
|
323 iUid.iUid = stream.ReadUint32L(); |
|
324 |
|
325 TUint32 len(stream.ReadUint32L() ); |
|
326 stream.ReadL(iUserId, len); |
|
327 |
|
328 len = stream.ReadUint32L(); |
|
329 stream.ReadL(iId, len); |
|
330 |
|
331 len = stream.ReadUint32L(); |
|
332 stream.ReadL(iName, len); |
|
333 |
|
334 len = stream.ReadUint32L(); |
|
335 stream.ReadL(iVersion, len); |
|
336 |
|
337 len = stream.ReadUint32L(); |
|
338 stream.ReadL(iMidletName, len); |
|
339 |
|
340 len = stream.ReadUint32L(); |
|
341 stream.ReadL(iMideltVendorName, len); |
|
342 |
|
343 len = stream.ReadUint32L(); |
|
344 stream.ReadL(iMidletVersion, len); |
|
345 |
|
346 iDownloadStatus = stream.ReadInt32L(); |
|
347 |
|
348 if (iPkgVersion > 1) |
|
349 { |
|
350 iOwner = stream.ReadInt32L(); |
|
351 } |
|
352 if (iPkgVersion > 2) |
|
353 { |
|
354 iOldState = TDeploymentComponentState(stream.ReadUint32L() ); |
|
355 } |
|
356 |
|
357 len = stream.ReadUint32L() ; |
|
358 stream.ReadL(iDownloadURI, len); |
|
359 |
|
360 len = stream.ReadUint32L(); |
|
361 stream.ReadL(iDescription, len); |
|
362 |
|
363 len = stream.ReadUint32L(); |
|
364 stream.ReadL(iPkgID, len); |
|
365 |
|
366 len = stream.ReadUint32L(); |
|
367 stream.ReadL(iPkgIDRef, len); |
|
368 |
|
369 len = stream.ReadUint32L(); |
|
370 stream.ReadL(iPkgType, len); |
|
371 |
|
372 iRemovableApp = stream.ReadUint32L(); |
|
373 iData = CDeploymentComponentData::LoadL(stream); |
|
374 iMetaData = CDeploymentComponentData::LoadL(stream); |
|
375 |
|
376 //using namespace SwiUI; |
|
377 iInstallOptsSet = stream.ReadUint32L(); |
|
378 TAMInstallOptionsPckg opts(iInstallOpts); |
|
379 stream.ReadL(opts, opts.Length() ); |
|
380 RDEBUG( "CDeploymentComponent::ConstructLoadL end"); |
|
381 } |
|
382 |
|
383 CDeploymentComponentData &CDeploymentComponent::Data() |
|
384 { |
|
385 return *iData; |
|
386 } |
|
387 |
|
388 const CDeploymentComponentData &CDeploymentComponent::Data() const |
|
389 { |
|
390 return *iData; |
|
391 } |
|
392 |
|
393 CDeploymentComponentData &CDeploymentComponent::MetaData() |
|
394 { |
|
395 return *iMetaData; |
|
396 } |
|
397 |
|
398 const CDeploymentComponentData &CDeploymentComponent::MetaData() const |
|
399 { |
|
400 return *iMetaData; |
|
401 } |
|
402 |
|
403 const TAMInstallOptions &CDeploymentComponent::InstallOpts() const |
|
404 { |
|
405 return iInstallOpts; |
|
406 } |
|
407 |
|
408 const SwiUI::TUninstallOptions &CDeploymentComponent::UninstallOpts() const |
|
409 { |
|
410 return iUninstallOpts; |
|
411 } |
|
412 |
|
413 TBool CDeploymentComponent::InstallOptsSet() const |
|
414 { |
|
415 return iInstallOptsSet; |
|
416 } |
|
417 |
|
418 TBool CDeploymentComponent::AppRemovable() const |
|
419 { |
|
420 return iRemovableApp; |
|
421 } |
|
422 |
|
423 void CDeploymentComponent::SetMetaDataL(const TDesC8 &aMimeType) |
|
424 { |
|
425 iMetaData->DataFileName(); |
|
426 iMetaData->SetDataL(aMimeType); |
|
427 } |
|
428 |
|
429 void CDeploymentComponent::SetMetaDataL(const TDesC8 &aMetaData, |
|
430 const TDesC8 &aMimeType) |
|
431 { |
|
432 iMetaData->SetDataL(aMetaData, aMimeType); |
|
433 } |
|
434 |
|
435 void CDeploymentComponent::SetAppRemovableStatus(const TBool &aRemovable) |
|
436 { |
|
437 iRemovableApp = aRemovable; |
|
438 } |
|
439 |
|
440 void CDeploymentComponent::SetInstallOptsL(const TDesC8 &aInstallOpts) |
|
441 { |
|
442 using namespace SwiUI; |
|
443 if (aInstallOpts != KNullDesC8) |
|
444 { |
|
445 RDEBUG8_2( "CDeploymentComponent::SetInstallOptsL: '%S'", &aInstallOpts ); |
|
446 TInt tmpIAP(iInstallOpts.iIAP); |
|
447 TAMInstallOptionsPckg pckg(iInstallOpts); |
|
448 pckg.Copy(aInstallOpts); |
|
449 iInstallOptsSet= ETrue; |
|
450 |
|
451 if (iInstallOpts.iIAP == -1 && tmpIAP > -1) |
|
452 { |
|
453 RDEBUG8_2( "CDeploymentComponent::SetInstallOptsL: using IAPid %d", tmpIAP ); |
|
454 iInstallOpts.iIAP = tmpIAP; |
|
455 } |
|
456 } |
|
457 |
|
458 } |
|
459 |
|
460 void CDeploymentComponent::ResetDataL(RFs &aFs) |
|
461 { |
|
462 iData->ResetData(aFs); |
|
463 iMetaData->ResetData(aFs); |
|
464 } |
|
465 |
|
466 void CDeploymentComponent::SetAttr(TDes8 &aAttr, const TDesC8 &aNewVal) const |
|
467 { |
|
468 if (aNewVal.Length() > aAttr.MaxLength() ) |
|
469 { |
|
470 aAttr = aNewVal.Left(aAttr.MaxLength() ); |
|
471 } |
|
472 else |
|
473 { |
|
474 aAttr = aNewVal; |
|
475 } |
|
476 } |
|
477 |
|
478 void CDeploymentComponent::SetIdL(const TDesC8 &aId) |
|
479 { |
|
480 SetAttr(iId, aId); |
|
481 } |
|
482 |
|
483 void CDeploymentComponent::SetNameL(const TDesC8 &aName) |
|
484 { |
|
485 if (iName != aName) |
|
486 { |
|
487 SetAttr(iName, aName); |
|
488 } |
|
489 } |
|
490 |
|
491 void CDeploymentComponent::SetVersionL(const TDesC8 &aVersion) |
|
492 { |
|
493 SetAttr(iVersion, aVersion); |
|
494 } |
|
495 void CDeploymentComponent::SetMimeTypeL( const TDesC8 &aMimeType ) |
|
496 { |
|
497 iData->SetMimeTypeL(aMimeType); |
|
498 } |
|
499 |
|
500 void CDeploymentComponent::SetDescriptionL(const TDesC8 &aDescription) |
|
501 { |
|
502 SetAttr(iDescription, aDescription); |
|
503 } |
|
504 |
|
505 void CDeploymentComponent::SetPkgIDL(const TDesC8 &aPkgID) |
|
506 { |
|
507 // PkgID and PkgIDRef should be same and Get done on PkgID |
|
508 // when state is in Download or Delivered and PkgIDRef is |
|
509 // returned when state is in Deployed state |
|
510 SetAttr(iPkgID, aPkgID); |
|
511 SetAttr(iPkgIDRef, aPkgID); |
|
512 } |
|
513 |
|
514 void CDeploymentComponent::SetPkgTypeL(const TDesC8 &aPkgType) |
|
515 { |
|
516 |
|
517 SetAttr(iPkgType, aPkgType); |
|
518 |
|
519 } |
|
520 void CDeploymentComponent::SetMidletNameL(const TDesC8 &aMidletName) |
|
521 { |
|
522 SetAttr(iMidletName, aMidletName); |
|
523 } |
|
524 |
|
525 void CDeploymentComponent::SetMidletVendorL(const TDesC8 &aMidletVendor) |
|
526 { |
|
527 SetAttr(iMideltVendorName, aMidletVendor); |
|
528 } |
|
529 |
|
530 void CDeploymentComponent::SetMidletVersionL(const TDesC8 &aMidletVersion) |
|
531 { |
|
532 SetAttr(iMidletVersion, aMidletVersion); |
|
533 } |
|
534 |
|
535 void CDeploymentComponent::SetUid(const TUid aUid) |
|
536 { |
|
537 RDEBUG8_2("CDeploymentComponent::SetUid 0x%x", aUid.iUid ); |
|
538 iUid = aUid; |
|
539 iId.Zero(); |
|
540 if (iUid != TUid::Null() ) |
|
541 { |
|
542 iId.AppendNumFixedWidth(iUid.iUid, EHex, 8); |
|
543 } |
|
544 } |
|
545 |
|
546 void CDeploymentComponent::SetOwnerProfile(TSmlProfileId aOwnerProfile) |
|
547 { |
|
548 iOwnerProfile = aOwnerProfile; |
|
549 } |
|
550 |
|
551 TInt CDeploymentComponent::SetState(const TDeploymentComponentState &aState) |
|
552 { |
|
553 RDEBUG_2( "CDeploymentComponent::SetState - set to state (%d)", aState ); |
|
554 |
|
555 TInt ret(KErrNone); |
|
556 iOldState = iState; |
|
557 iState = aState; |
|
558 #ifdef __SERIES60_30__ |
|
559 if( iState != iOldState && iState != EDCSDownload && iState != EDCSDelivered ) |
|
560 { |
|
561 if ( iUid != TUid::Null() ) |
|
562 { |
|
563 RMenuServSession ses; |
|
564 TBool visible( EFalse ); |
|
565 if ( iState == EDCSActive ) |
|
566 { |
|
567 visible = ETrue; |
|
568 } |
|
569 TRAP( ret, ses.SetApplicationVisibilityL( iUid.iUid, visible ) ); |
|
570 if (ret != KErrNone ) |
|
571 { |
|
572 RDEBUG_2( "CDeploymentComponent::SetState - failed to set visiblity %d", ret ); |
|
573 } |
|
574 else |
|
575 { |
|
576 RDEBUG_2( "CDeploymentComponent::SetState - Set visiblity to %d", visible ); |
|
577 } |
|
578 } |
|
579 else |
|
580 { |
|
581 RDEBUG( "CDeploymentComponent::SetState - No need to set visibility to null uid" ); |
|
582 } |
|
583 |
|
584 } |
|
585 else |
|
586 { |
|
587 RDEBUG( "CDeploymentComponent::SetState - No need to change visibility " ); |
|
588 } |
|
589 #endif |
|
590 return ret; |
|
591 } |
|
592 |
|
593 void CDeploymentComponent::SetStatusNode( |
|
594 const TSCOMOStatusNodeStates &aStatus) const |
|
595 { |
|
596 iStatus = aStatus; |
|
597 CRepository *repository=NULL; |
|
598 |
|
599 TRAPD( erx, repository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) ) |
|
600 ; |
|
601 if (erx!=KErrNone) |
|
602 return; |
|
603 |
|
604 TRAPD(err, PersistL(*repository)) |
|
605 ; |
|
606 |
|
607 delete repository; |
|
608 |
|
609 if (err!=KErrNone) |
|
610 return; |
|
611 |
|
612 } |
|
613 |
|
614 void CDeploymentComponent::Set(const TDeploymentComponent &aInfo) |
|
615 { |
|
616 iId = aInfo.iId; |
|
617 iName = aInfo.iId; |
|
618 iVersion = aInfo.iVersion; |
|
619 iDescription = aInfo.iDescription; |
|
620 iPkgID = aInfo.iPkgID; |
|
621 iPkgIDRef = aInfo.iPkgIDRef; |
|
622 iPkgType = aInfo.iPkgType; |
|
623 } |
|
624 |
|
625 void CDeploymentComponent::SetDownloadURIL(const TDesC8 &aURI) |
|
626 { |
|
627 if (iState == EDCSDownload) |
|
628 { |
|
629 iDownloadURI = aURI; |
|
630 } |
|
631 else |
|
632 { |
|
633 RDEBUG_2( "CDeploymentComponent::SetDownloadURIL: ERROR Illegal state: %d", iState ); |
|
634 User::Leave(KErrNotSupported) ; |
|
635 } |
|
636 } |
|
637 |
|
638 void CDeploymentComponent::SetDownloadTarget( |
|
639 const TDownloadTarget& aDownloadTarget) |
|
640 { |
|
641 RDEBUG_2("CDeploymentComponent::SetDownloadTarget: (%d)", aDownloadTarget); |
|
642 iDownloadTarget = aDownloadTarget; |
|
643 } |
|
644 |
|
645 void CDeploymentComponent::SetDataL(const TDesC8 &aData, |
|
646 const TDesC8 &aMimeType) |
|
647 { |
|
648 iUid = iData->SetDataL(aData, aMimeType); |
|
649 iId.Zero(); |
|
650 if (iUid != TUid::Null() ) |
|
651 { |
|
652 iId.AppendNumFixedWidth(iUid.iUid, EHex, 8); |
|
653 } |
|
654 } |
|
655 |
|
656 void CDeploymentComponent::SetDataL(const TDesC &aFileName, |
|
657 const TDesC8 &aMimeType) |
|
658 { |
|
659 SetUid(iData->SetDataL(aFileName, aMimeType) ); |
|
660 } |
|
661 |
|
662 void CDeploymentComponent::SetDataL(const TDesC8 &aMimeType) |
|
663 { |
|
664 SetUid(iData->SetDataL(aMimeType) ); |
|
665 } |
|
666 |
|
667 // ---------------------------------------------------------------------------------------- |
|
668 // CDeploymentComponent::StatusUpdateL |
|
669 // ---------------------------------------------------------------------------------------- |
|
670 void CDeploymentComponent::StatusUpdateL(TInt aNewStatus) |
|
671 { |
|
672 RDEBUG( "CDeploymentComponent::StatusUpdateL : begin"); |
|
673 RDEBUG_2( "CDeploymentComponent::StatusUpdateL %d", aNewStatus ); |
|
674 |
|
675 if (State() == EDCSDownload) |
|
676 { |
|
677 iDownloadStatus = aNewStatus; |
|
678 RDEBUG_2( "CDeploymentComponent::StatusUpdate: Set status to: %d", iDownloadStatus ); |
|
679 |
|
680 if (DownloadFailed() ) |
|
681 { |
|
682 SetStatusNode(EDownload_DownloadFailed); |
|
683 RDEBUG8_2( "CDeploymentComponent::StatusUpdate: ERROR Failed to download URI: '%S' ", &iDownloadURI ); |
|
684 } |
|
685 |
|
686 if (iCallback) |
|
687 { |
|
688 iCallback->DownloadComplete( this, iDownloadStatus); |
|
689 } |
|
690 } |
|
691 else |
|
692 { |
|
693 RDEBUG_2( "CDeploymentComponent::StatusUpdate: ERROR Illegal state: %d", State() ); |
|
694 } |
|
695 RDEBUG( "CDeploymentComponent::StatusUpdateL : end"); |
|
696 } |
|
697 |
|
698 // ---------------------------------------------------------------------------------------- |
|
699 // CDeploymentComponent::SuccessStatusUpdateL |
|
700 // ---------------------------------------------------------------------------------------- |
|
701 void CDeploymentComponent::SuccessStatusUpdateL(const TDesC &aDlFileName, |
|
702 const TDesC8& aDlMimeType) |
|
703 { |
|
704 RDEBUG( "CDeploymentComponent::SuccessStatusUpdateL : start"); |
|
705 SetDataL(aDlFileName, aDlMimeType); |
|
706 |
|
707 // Set PkgID same as MiME type of downloaded content |
|
708 SetPkgTypeL(aDlMimeType); |
|
709 |
|
710 CDeploymentComponent* conflict( NULL); |
|
711 TBool dlOk(ETrue); |
|
712 if (iUid != TUid::Null() ) |
|
713 { |
|
714 __ASSERT_DEBUG( iCallback, User::Invariant() ); |
|
715 if (iCallback->UidExistsL(iUid, conflict, this) ) |
|
716 { |
|
717 } |
|
718 } |
|
719 else |
|
720 { |
|
721 RDEBUG( "CDeploymentComponent::StatusUpdateL - WARNING cannot detect uid" ); |
|
722 if (IsJavaMimeL(aDlMimeType) ||IsSisMimeL(aDlMimeType) ) |
|
723 { |
|
724 RDEBUG( "CDeploymentComponent::StatusUpdateL - Ignoring prev warning because it's java" ); |
|
725 } |
|
726 else |
|
727 { |
|
728 dlOk = EFalse; |
|
729 //The Operation has been rejected because the device does not support this MIME type. |
|
730 iDownloadStatus = KStatusUnSupportedEnvironment; |
|
731 } |
|
732 } |
|
733 |
|
734 if (dlOk) |
|
735 { |
|
736 /*for Predefined static node, append static node name with Internal ID before |
|
737 * moving to delivered state to avoid duplicates |
|
738 */ |
|
739 TBuf8<256> staticnode; |
|
740 TInt staticnodeenabled = 0; |
|
741 CRepository* cenrep = CRepository::NewLC( KCRUidPrivateApplicationManagementKeys ); |
|
742 cenrep->Get( KAMDownloadPredefinedNode, staticnode ); |
|
743 cenrep->Get( KAMStaticNodeEnabled, staticnodeenabled ); |
|
744 CleanupStack::PopAndDestroy(); //cenrep |
|
745 if (iUserId.Compare(staticnode) == 0 && staticnodeenabled) |
|
746 { |
|
747 iUserId.Append(*IntToDes8LC(iInternalId)); |
|
748 CleanupStack::PopAndDestroy(); // for IntToDes8LC() |
|
749 } |
|
750 |
|
751 //Reset the value of DownloadStatus for success update |
|
752 iDownloadStatus = 0; |
|
753 |
|
754 SetState(EDCSDelivered); |
|
755 SetStatusNode(EIdle); |
|
756 } |
|
757 |
|
758 if (iCallback) |
|
759 { |
|
760 iCallback->DownloadComplete( this, iDownloadStatus); |
|
761 } |
|
762 |
|
763 RDEBUG( "CDeploymentComponent::SuccessStatusUpdateL : end"); |
|
764 } |
|
765 |
|
766 const TSmlProfileId& CDeploymentComponent::OwnerProfile() const |
|
767 { |
|
768 return iOwnerProfile; |
|
769 } |
|
770 |
|
771 const TDesC8& CDeploymentComponent::MimeType() const |
|
772 { |
|
773 if (iMetaData->MimeType().Length() ) |
|
774 { |
|
775 return iMetaData->MimeType(); |
|
776 } |
|
777 return iData->MimeType(); |
|
778 } |
|
779 |
|
780 TBool CDeploymentComponent::DownloadFailed() const // http or symbian error |
|
781 { |
|
782 return (iDownloadStatus >= 400 || iDownloadStatus < 0) ? ETrue : EFalse; |
|
783 } |
|
784 |
|
785 TInt CDeploymentComponent::DownloadStatus() const |
|
786 { |
|
787 return iDownloadStatus; |
|
788 } |
|
789 |
|
790 void CDeploymentComponent::DestroyL(CRepository &aRepository) |
|
791 { |
|
792 TDeploymentComponentState st(State() ); |
|
793 if ( !(st == EDCSActive || st == EDCSInactive)) |
|
794 { |
|
795 RFs fs; |
|
796 User::LeaveIfError(fs.Connect() ); |
|
797 CleanupClosePushL(fs); |
|
798 iMetaData->DestroyL(fs); |
|
799 iData->DestroyL(fs); |
|
800 CleanupStack::PopAndDestroy( &fs) ;// fs |
|
801 } |
|
802 |
|
803 TInt err(aRepository.Delete(iInternalId) ); |
|
804 RDEBUG_3( "CDeploymentComponent::DestroyL: Deleting %d in centrep resulted with status %d", iInternalId, err ); |
|
805 } |
|
806 |
|
807 void CDeploymentComponent::SetOwner(const TInt &aInfo) |
|
808 { |
|
809 iOwner = aInfo; |
|
810 } |
|
811 |
|
812 void CDeploymentComponent::SetIAPL(const TInt aIap) |
|
813 { |
|
814 RDEBUG8_2( "CDeploymentComponent::SetIAPL: %d ", aIap ); |
|
815 iInstallOpts.iIAP = aIap; |
|
816 } |
|
817 |
|
818 TInt CDeploymentComponent::GetIAP() const |
|
819 { |
|
820 return iInstallOpts.iIAP; |
|
821 } |
|
822 HBufC8* CDeploymentComponent::IntToDes8LC(const TInt aLuid) |
|
823 { |
|
824 HBufC8* buf = HBufC8::NewLC( 10); //10 = max length of 32bit integer |
|
825 TPtr8 ptrBuf = buf->Des(); |
|
826 ptrBuf.Num(aLuid); |
|
827 return buf; |
|
828 } |
|
829 |
|
830 // End of File |