|
1 /* |
|
2 * Copyright (c) 2008-2009 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: SisxPackageInfo implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2sisxpackageinfo.h" // CAppMngr2SisxPackageInfo |
|
20 #include "appmngr2sisxruntime.h" // KAppMngr2SisxUid |
|
21 #include "appmngr2sisxinfoiterator.h" // CAppMngr2SisxInfoIterator |
|
22 #include "appmngr2sisxunknownlist.h" // CAppMngr2SisxUnknownList |
|
23 #include "appmngr2sisx.hrh" // Icon IDs |
|
24 #include <appmngr2driveutils.h> // TAppMngr2DriveUtils |
|
25 #include <appmngr2debugutils.h> // FLOG macros |
|
26 #include <appmngr2common.hrh> // Command IDs |
|
27 #include <appmngr2.rsg> // Resource IDs |
|
28 #include <eikenv.h> // CEikonEnv |
|
29 |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CAppMngr2SisxPackageInfo::NewL() |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CAppMngr2SisxPackageInfo* CAppMngr2SisxPackageInfo::NewL( |
|
38 CAppMngr2Runtime& aRuntime, const TDesC& aFileName, RFs& aFs ) |
|
39 { |
|
40 CAppMngr2SisxPackageInfo* self = new (ELeave) CAppMngr2SisxPackageInfo( |
|
41 aRuntime, aFs ); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL( aFileName ); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CAppMngr2SisxPackageInfo::~CAppMngr2SisxPackageInfo() |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CAppMngr2SisxPackageInfo::~CAppMngr2SisxPackageInfo() |
|
53 { |
|
54 CancelCommand(); |
|
55 delete iName; |
|
56 delete iDetails; |
|
57 delete iFileName; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CAppMngr2SisxPackageInfo::IconIndex() |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 TInt CAppMngr2SisxPackageInfo::IconIndex() const |
|
65 { |
|
66 return EQgnMenuAmSis; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CAppMngr2SisxPackageInfo::Name() |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 const TDesC& CAppMngr2SisxPackageInfo::Name() const |
|
74 { |
|
75 if( iName ) |
|
76 { |
|
77 return *iName; |
|
78 } |
|
79 return KNullDesC; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CAppMngr2SisxPackageInfo::Details() |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 const TDesC& CAppMngr2SisxPackageInfo::Details() const |
|
87 { |
|
88 if( iDetails ) |
|
89 { |
|
90 return *iDetails; |
|
91 } |
|
92 return KNullDesC; |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CAppMngr2SisxPackageInfo::IndicatorIconIndex() |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 TInt CAppMngr2SisxPackageInfo::IndicatorIconIndex() const |
|
100 { |
|
101 if( IsShowOnTop() ) |
|
102 { |
|
103 return EQgnIndiAmInstNoAdd; |
|
104 } |
|
105 return CAppMngr2InfoBase::IndicatorIconIndex(); |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CAppMngr2SisxPackageInfo::SupportsGenericCommand() |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 TBool CAppMngr2SisxPackageInfo::SupportsGenericCommand( TInt /*aCmdId*/ ) |
|
113 { |
|
114 return ETrue; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CAppMngr2SisxPackageInfo::HandleCommandL() |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 void CAppMngr2SisxPackageInfo::HandleCommandL( TInt aCommandId, TRequestStatus& aStatus ) |
|
122 { |
|
123 FLOG( "CAppMngr2SisxPackageInfo::HandleCommandL( %d )", aCommandId ); |
|
124 switch( aCommandId ) |
|
125 { |
|
126 case EAppMngr2CmdViewDetails: |
|
127 ShowDetailsL(); |
|
128 break; |
|
129 |
|
130 case EAppMngr2CmdInstall: |
|
131 if( !iSWInstLauncher ) |
|
132 { |
|
133 SwiUI::RSWInstLauncher* swInstLauncher = new (ELeave) SwiUI::RSWInstLauncher; |
|
134 CleanupStack::PushL( swInstLauncher ); |
|
135 User::LeaveIfError( swInstLauncher->Connect() ); |
|
136 CleanupStack::Pop( swInstLauncher ); |
|
137 iSWInstLauncher = swInstLauncher; |
|
138 } |
|
139 iSWInstLauncher->Install( aStatus, *iFileName ); |
|
140 return; // async operation started |
|
141 |
|
142 case EAppMngr2CmdRemove: |
|
143 if( ShowDeleteConfirmationQueryL() ) |
|
144 { |
|
145 HandleDeleteL(); |
|
146 } |
|
147 else |
|
148 { |
|
149 User::Leave( KErrCancel ); |
|
150 } |
|
151 break; |
|
152 |
|
153 default: |
|
154 break; |
|
155 } |
|
156 |
|
157 // sync operation done, complete aStatus |
|
158 TRequestStatus* statusPtr = &aStatus; |
|
159 User::RequestComplete( statusPtr, KErrNone ); |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CAppMngr2SisxPackageInfo::HandleCommandResultL() |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 void CAppMngr2SisxPackageInfo::HandleCommandResultL( TInt aStatus ) |
|
167 { |
|
168 FLOG( "CAppMngr2SisxPackageInfo::HandleCommandResultL( %d )", aStatus ); |
|
169 if( iSWInstLauncher ) |
|
170 { |
|
171 iSWInstLauncher->Close(); |
|
172 delete iSWInstLauncher; |
|
173 iSWInstLauncher = NULL; |
|
174 } |
|
175 if( aStatus != SwiUI::KSWInstErrUserCancel && aStatus != KErrCancel ) |
|
176 { |
|
177 User::LeaveIfError( aStatus ); |
|
178 } |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CAppMngr2SisxPackageInfo::CancelCommand() |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 void CAppMngr2SisxPackageInfo::CancelCommand() |
|
186 { |
|
187 FLOG( "CAppMngr2SisxPackageInfo::CancelCommand()" ); |
|
188 if( iSWInstLauncher ) |
|
189 { |
|
190 iSWInstLauncher->CancelAsyncRequest( SwiUI::ERequestUninstall ); |
|
191 iSWInstLauncher->Close(); |
|
192 delete iSWInstLauncher; |
|
193 iSWInstLauncher = NULL; |
|
194 } |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // CAppMngr2SisxPackageInfo::CAppMngr2SisxPackageInfo() |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 CAppMngr2SisxPackageInfo::CAppMngr2SisxPackageInfo( CAppMngr2Runtime& aRuntime, |
|
202 RFs& aFs ) : CAppMngr2PackageInfo( aRuntime, aFs ) |
|
203 { |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CAppMngr2SisxPackageInfo::ConstructL() |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void CAppMngr2SisxPackageInfo::ConstructL( const TDesC& aFileName ) |
|
211 { |
|
212 FLOG( "CAppMngr2SisxPackageInfo::ConstructL( %S )", &aFileName ); |
|
213 CAppMngr2PackageInfo::ConstructL(); // base class |
|
214 |
|
215 TEntry fileEntry; |
|
216 User::LeaveIfError( iFs.Entry( aFileName, fileEntry ) ); |
|
217 |
|
218 if( aFileName.Find( KAppMngr2DaemonPrivateFolder ) != KErrNotFound ) |
|
219 { |
|
220 // untrusted application, display on top of others |
|
221 iShowOnTop = ETrue; |
|
222 |
|
223 // Installer generates untrusted app SISX files using UID names |
|
224 // (e.g. "20001234.SIS"). Get the real package name and use it |
|
225 // as the name of the untrusted application SISX item in UI. |
|
226 TInt drive; |
|
227 User::LeaveIfError( RFs::CharToDrive( aFileName[ 0 ], drive ) ); |
|
228 CAppMngr2SisxUnknownList* unknownList = CAppMngr2SisxUnknownList::NewLC( drive ); |
|
229 |
|
230 TInt index = unknownList->FindPkgWithUIDName( fileEntry.iName ); |
|
231 if( index > 0 && index < unknownList->PkgCount() ) |
|
232 { |
|
233 // display package name instead of UID name |
|
234 Swi::CUninstalledPackageEntry& pkgEntry = unknownList->PkgEntry( index ); |
|
235 iName = pkgEntry.Name().AllocL(); |
|
236 } |
|
237 else |
|
238 { |
|
239 // package name not found, display file name anyway |
|
240 iName = fileEntry.iName.AllocL(); |
|
241 } |
|
242 CleanupStack::PopAndDestroy( unknownList ); |
|
243 |
|
244 iDetails = Runtime().EikonEnv().AllocReadResourceL( R_SWINS_UNIT_UNTRUSTED ); |
|
245 } |
|
246 else |
|
247 { |
|
248 // normal SIS file, use file name |
|
249 iName = fileEntry.iName.AllocL(); |
|
250 iDetails = SizeStringWithUnitsL( fileEntry.iSize ); |
|
251 } |
|
252 FLOG( "CAppMngr2SisxPackageInfo::ConstructL, iName = %S", iName ); |
|
253 FLOG( "CAppMngr2SisxPackageInfo::ConstructL, iDetails = %S", iDetails ); |
|
254 |
|
255 iFileName = aFileName.AllocL(); |
|
256 iLocation = TAppMngr2DriveUtils::LocationFromFileNameL( aFileName, iFs ); |
|
257 iLocationDrive = TDriveUnit( aFileName ); |
|
258 } |
|
259 |
|
260 // --------------------------------------------------------------------------- |
|
261 // CAppMngr2SisxPackageInfo::HandleDeleteL() |
|
262 // --------------------------------------------------------------------------- |
|
263 // |
|
264 void CAppMngr2SisxPackageInfo::HandleDeleteL() |
|
265 { |
|
266 FLOG( "CAppMngr2SisxPackageInfo::HandleDeleteL()" ); |
|
267 // CAppMngr2SisxUnknownList must be used to delete pre-installed SISX files, |
|
268 // which are located in SWI daemon's private folder and that are listed in |
|
269 // the CAppMngr2SisxUnknownList (i.e. in the Swi::UninstalledSisPackages). |
|
270 // These SISX files are applications that have been installed in memory |
|
271 // card (using some other device), and that were not installed in this device |
|
272 // when the memory card was inserted (e.g. because of security reasons). |
|
273 if( iFileName ) |
|
274 { |
|
275 if( iFileName->Find( KAppMngr2PreInstalledPath ) != KErrNotFound ) |
|
276 { |
|
277 TParsePtrC parser( *iFileName ); |
|
278 TInt drive; |
|
279 User::LeaveIfError( RFs::CharToDrive( parser.Drive()[ 0 ], drive ) ); |
|
280 CAppMngr2SisxUnknownList* unknownList = CAppMngr2SisxUnknownList::NewLC( drive ); |
|
281 |
|
282 TInt index = unknownList->FindPkgWithUIDName( parser.NameAndExt() ); |
|
283 if( index >= 0 && index < unknownList->PkgCount() ) |
|
284 { |
|
285 // found in "unknown" list, remove using Swi::UninstalledSisPackages |
|
286 unknownList->RemovePkgL( index ); |
|
287 } |
|
288 else |
|
289 { |
|
290 // some other sisx package, try to delete using RFs |
|
291 User::LeaveIfError( iFs.Delete( *iFileName ) ); |
|
292 } |
|
293 |
|
294 CleanupStack::PopAndDestroy( unknownList ); |
|
295 } |
|
296 else |
|
297 { |
|
298 // normal sisx package, delete using RFs |
|
299 User::LeaveIfError( iFs.Delete( *iFileName ) ); |
|
300 } |
|
301 } |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // CAppMngr2SisxPackageInfo::ShowDetailsL() |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 void CAppMngr2SisxPackageInfo::ShowDetailsL() |
|
309 { |
|
310 FLOG( "CAppMngr2SisxPackageInfo::ShowDetailsL()" ); |
|
311 CAppMngr2SisxInfoIterator* iterator = CAppMngr2SisxInfoIterator::NewL( |
|
312 *this, EAppMngr2StatusNotInstalled ); |
|
313 CleanupStack::PushL( iterator ); |
|
314 SwiUI::CommonUI::CCUIDetailsDialog* details = SwiUI::CommonUI::CCUIDetailsDialog::NewL(); |
|
315 details->ExecuteLD( *iterator ); |
|
316 CleanupStack::PopAndDestroy( iterator ); |
|
317 } |
|
318 |