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