58 self->ConstructL( aMainStatus ); // For uninstaller |
60 self->ConstructL( aMainStatus ); // For uninstaller |
59 CleanupStack::Pop(self); |
61 CleanupStack::Pop(self); |
60 return self; |
62 return self; |
61 } |
63 } |
62 |
64 |
|
65 // ----------------------------------------------------------------------- |
63 // Install Request constructor |
66 // Install Request constructor |
64 |
67 // ----------------------------------------------------------------------- |
|
68 // |
65 CSisInstaller::CSisInstaller( MDaemonInstallBehaviour* aDaemonBehaviour ) |
69 CSisInstaller::CSisInstaller( MDaemonInstallBehaviour* aDaemonBehaviour ) |
66 : CActive(CActive::EPriorityStandard), |
70 : CActive(CActive::EPriorityStandard), |
67 iDaemonBehaviour( aDaemonBehaviour ), |
71 iDaemonBehaviour( aDaemonBehaviour ), |
68 iState(EDSisInstallerStateIdle), |
72 iState(EDSisInstallerStateIdle), |
69 iFileIndex(0), |
73 iFileIndex(0), |
70 iInstallErr( KErrNone ) |
74 iInstallErr( KErrNone ) |
71 { |
75 { |
72 CActiveScheduler::Add(this); |
76 CActiveScheduler::Add(this); |
73 #ifdef RD_MULTIPLE_DRIVE |
77 iInstallerState = EDSisInstallerStateIdle; |
74 iInstallerState = EDSisInstallerStateIdle; |
|
75 #endif |
|
76 } |
78 } |
77 |
79 |
78 // Install Request destructor |
80 // ----------------------------------------------------------------------- |
79 |
81 // Destructor |
|
82 // ----------------------------------------------------------------------- |
|
83 // |
80 CSisInstaller::~CSisInstaller() |
84 CSisInstaller::~CSisInstaller() |
81 { |
85 { |
|
86 FLOG( _L("Daemon: CSisInstaller::~CSisInstaller") ); |
82 Cancel(); |
87 Cancel(); |
83 iTimer.Close(); |
88 iTimer.Close(); |
84 iFilesToInstall.ResetAndDestroy(); |
89 iFilesToInstall.ResetAndDestroy(); |
85 iFilesToInstall.Close(); |
90 iFilesToInstall.Close(); |
86 delete iInstallLauncher; |
91 delete iInstallLauncher; |
87 delete iDialogs; |
92 delete iDialogs; |
88 iFs.Close(); |
|
89 iApaSession.Close(); |
|
90 delete iPreviouslyInstalledAppsCache; |
93 delete iPreviouslyInstalledAppsCache; |
91 delete iInstallationFailedAppsCache; |
94 delete iInstallationFailedAppsCache; |
92 delete iShutdownWatcher; |
95 delete iShutdownWatcher; |
|
96 |
|
97 if ( iFileOpen ) |
|
98 { |
|
99 iSisFileHandle.Close(); |
|
100 } |
|
101 |
|
102 iFs.Close(); |
|
103 iApaSession.Close(); |
93 } |
104 } |
94 |
105 |
|
106 // ----------------------------------------------------------------------- |
95 // 2nd phase construction |
107 // 2nd phase construction |
96 |
108 // ----------------------------------------------------------------------- |
|
109 // |
97 void CSisInstaller::ConstructL( CProgramStatus& aMainStatus ) |
110 void CSisInstaller::ConstructL( CProgramStatus& aMainStatus ) |
98 { |
111 { |
99 User::LeaveIfError( iTimer.CreateLocal() ); |
112 User::LeaveIfError( iTimer.CreateLocal() ); |
100 User::LeaveIfError( iFs.Connect() ); |
113 User::LeaveIfError( iFs.Connect() ); |
101 User::LeaveIfError( iApaSession.Connect() ); |
114 User::LeaveIfError( iApaSession.Connect() ); |
102 iFs.ShareProtected(); |
115 iFs.ShareProtected(); |
103 iDialogs = CDialogWrapper::NewL( iFs ); |
116 iDialogs = CDialogWrapper::NewL( iFs ); |
104 iPreviouslyInstalledAppsCache = CPreviouslyInstalledAppsCache::NewL(); |
117 iPreviouslyInstalledAppsCache = CPreviouslyInstalledAppsCache::NewL(); |
105 iInstallationFailedAppsCache = CInstallationFailedAppsCache::NewL(); |
118 iInstallationFailedAppsCache = CInstallationFailedAppsCache::NewL(); |
106 iShutdownWatcher = CShutdownWatcher::NewL( *this ); |
119 iShutdownWatcher = CShutdownWatcher::NewL( *this ); |
107 iShutdownWatcher->Start(); |
120 iShutdownWatcher->Start(); |
|
121 iPercentValue = 0; |
|
122 |
108 // For uninstaller |
123 // For uninstaller |
109 // SisInstaller do not own this so do not delete. |
124 // SisInstaller do not own this so do not delete. |
110 iProgramStatus = &aMainStatus; |
125 iProgramStatus = &aMainStatus; |
111 iUpdateCache = ETrue; |
126 iUpdateCache = ETrue; |
|
127 iFileOpen = EFalse; |
|
128 iInstallLauncher = NULL; |
112 } |
129 } |
113 |
130 |
|
131 // ----------------------------------------------------------------------- |
|
132 // CSisInstaller::AddFileToInstallL |
114 // Set the location of all sis files and the list of them |
133 // Set the location of all sis files and the list of them |
115 // also take ownership of the pointers to memory |
134 // also take ownership of the pointers to memory |
116 |
135 // ----------------------------------------------------------------------- |
|
136 // |
117 void CSisInstaller::AddFileToInstallL(const TDesC& aFileName) |
137 void CSisInstaller::AddFileToInstallL(const TDesC& aFileName) |
118 { |
138 { |
119 HBufC* fileName = aFileName.AllocLC(); |
139 HBufC* fileName = aFileName.AllocLC(); |
120 iFilesToInstall.AppendL( fileName ); |
140 iFilesToInstall.AppendL( fileName ); |
121 CleanupStack::Pop( fileName ); |
141 CleanupStack::Pop( fileName ); |
122 } |
142 } |
123 |
143 |
|
144 |
|
145 // ----------------------------------------------------------------------- |
|
146 // CSisInstaller::StartInstallingL |
124 // Start the request to process the Sisx file |
147 // Start the request to process the Sisx file |
125 |
148 // ----------------------------------------------------------------------- |
|
149 // |
126 void CSisInstaller::StartInstallingL() |
150 void CSisInstaller::StartInstallingL() |
127 { |
151 { |
128 FLOG( _L("Daemon: StartInstallingL") ); |
152 FLOG( _L("Daemon: StartInstallingL") ); |
129 |
153 |
130 if(!iFilesToInstall.Count()) |
154 if( !iFilesToInstall.Count() ) |
131 { |
155 { |
132 // For uninstaller |
156 // For uninstaller |
133 // Check state, if installing change it to idle. |
157 // Check state, if installing change it to idle. |
134 if ( EStateInstalling == iProgramStatus->GetProgramStatus() ) |
158 if ( EStateInstalling == iProgramStatus->GetProgramStatus() ) |
135 { |
159 { |
136 FLOG( _L("Daemon: StartInstallingL: Set EStateIdle") ); |
160 FLOG( _L("Daemon: StartInstallingL: Set EStateIdle") ); |
137 iProgramStatus->SetProgramStatusToIdle(); |
161 iProgramStatus->SetProgramStatusToIdle(); |
138 } |
162 } |
139 |
163 FLOG( _L("Daemon: StartInstallingL: User::Leave(KErrAbort)") ); |
140 User::Leave(KErrAbort); |
164 User::Leave(KErrAbort); |
141 } |
165 } |
142 |
166 |
143 // For uninstaller |
167 // For uninstaller |
144 // Check state. If idle chage it to installing, but if installing |
168 // Check state. If idle chage it to installing, but if installing |
145 // or uninstalling do nothing. |
169 // or uninstalling do nothing. |
146 if ( EStateIdle == iProgramStatus->GetProgramStatus() ) |
170 if ( EStateIdle == iProgramStatus->GetProgramStatus() ) |
147 { |
171 { |
148 FLOG( _L("Daemon: StartInstallingL: Set EStateInstalling") ); |
172 FLOG( _L("Daemon: StartInstallingL: Set EStateInstalling") ); |
149 iProgramStatus->SetProgramStatus( EStateInstalling ); |
173 iProgramStatus->SetProgramStatus( EStateInstalling ); |
150 } |
174 } |
151 FLOG_1( _L("[CSisInstaller] ConstructL iGeneralProcessStatus = %d"), |
175 |
152 iGeneralProcessStatus ); |
176 FLOG_1( _L("Daemon: iGeneralProcessStatus: %d"), iGeneralProcessStatus ); |
|
177 FLOG_1( _L("Daemon: iInstallLauncher: 0x%x"),iInstallLauncher ); |
153 |
178 |
154 if ( !iInstallLauncher ) |
179 if ( iInstallLauncher == NULL ) |
155 { |
180 { |
156 iInstallLauncher = CSilentLauncher::NewL( iFs ); |
181 FLOG( _L("Daemon: Create iInstallLauncher") ); |
|
182 iInstallLauncher = CSilentLauncher::NewL( iFs ); |
|
183 |
|
184 // Update cache so we do not try to start install for |
|
185 // components which are installed. This is done always |
|
186 // when new install session is started (e.g. after mmc insert). |
|
187 FLOG( _L("Daemon: StartInstallingL: Update installed cache") ); |
|
188 TRAP_IGNORE( iPreviouslyInstalledAppsCache->UpdateAllL() ); |
|
189 TRAP_IGNORE( iPreviouslyInstalledAppsCache->FlushToDiskL() ); |
157 } |
190 } |
158 |
191 |
159 if ( iState == EDSisInstallerStateIdle ) |
192 if ( iState == EDSisInstallerStateIdle ) |
160 { |
193 { |
161 // Reset the error |
194 // Reset the error |
162 iInstallErr = KErrNone; |
195 iInstallErr = KErrNone; |
163 CompleteSelf(); |
196 CompleteSelf(); |
164 } |
197 } |
165 } |
198 } |
166 |
199 |
167 #ifdef RD_MULTIPLE_DRIVE |
200 // ----------------------------------------------------------------------- |
|
201 // CSisInstaller::IsInstalling |
168 // Returns state of Installer. |
202 // Returns state of Installer. |
169 |
203 // ----------------------------------------------------------------------- |
|
204 // |
170 TBool CSisInstaller::IsInstalling() |
205 TBool CSisInstaller::IsInstalling() |
171 { |
206 { |
172 if ( iInstallerState == EDSisInstallerStateCompleted ) |
207 if ( iInstallerState == EDSisInstallerStateCompleted ) |
173 { |
208 { |
174 return EFalse; |
209 return EFalse; |
217 FLOG( _L("Daemon: DoCancel: Set EStateIdle") ); |
261 FLOG( _L("Daemon: DoCancel: Set EStateIdle") ); |
218 iProgramStatus->SetProgramStatusToIdle(); |
262 iProgramStatus->SetProgramStatusToIdle(); |
219 } |
263 } |
220 } |
264 } |
221 |
265 |
222 // When the software installer has changed state |
266 // ----------------------------------------------------------------------- |
223 // attemp to install a sisx file |
267 // CSisInstaller::RunL |
224 |
268 // When the software installer has changed state attemp to install a |
|
269 // sisx file |
|
270 // ----------------------------------------------------------------------- |
|
271 // |
225 void CSisInstaller::RunL() |
272 void CSisInstaller::RunL() |
226 { |
273 { |
227 FLOG_2( _L("Daemon: Installer RunL status:%d, state:%d"), iStatus.Int(), iState ); |
274 FLOG_1( _L("Daemon: Installer RunL status:%d"), iStatus.Int() ); |
|
275 FLOG_1( _L("Daemon: Installer RunL state:%d"), iState ); |
228 |
276 |
229 // For uninstaller |
277 // For uninstaller |
230 // Check that uninstaller is not running. |
278 // Check that uninstaller is not running. |
231 if ( EStateUninstalling == iProgramStatus->GetProgramStatus() ) |
279 if ( EStateUninstalling == iProgramStatus->GetProgramStatus() ) |
232 { |
280 { |
233 // If uninstaller is running already let's wait. |
281 // If uninstaller is running already let's wait. |
234 FLOG( _L("Daemon: RunL: EStateUninstalling -> wait") ); |
282 FLOG( _L("Daemon: RunL: EStateUninstalling -> wait") ); |
235 TTimeIntervalMicroSeconds32 time( KWaitUninstallerTime ); |
283 TTimeIntervalMicroSeconds32 time( KWaitUninstallerTime ); |
236 iTimer.After(iStatus,time); |
284 iTimer.After(iStatus,time); |
237 // Set to idle, installer has not yet started. |
285 // Set to idle, installer has not yet started. |
238 iState = EDSisInstallerStateIdle; |
286 iState = EDSisInstallerStateIdle; |
239 #ifdef RD_MULTIPLE_DRIVE |
287 iInstallerState = iState; |
240 iInstallerState = iState; |
|
241 #endif |
|
242 SetActive(); |
288 SetActive(); |
243 } |
289 } |
244 else |
290 else |
245 { |
291 { |
246 // Ok uninstaller is in idle, run installing. |
292 // Ok uninstaller is in idle, run installing. |
250 switch (iState) |
296 switch (iState) |
251 { |
297 { |
252 // Reached when installation is completed |
298 // Reached when installation is completed |
253 case EDSisInstallerStateInstalling: |
299 case EDSisInstallerStateInstalling: |
254 FLOG( _L("Daemon: RunL: EDSisInstallerStateInstalling") ); |
300 FLOG( _L("Daemon: RunL: EDSisInstallerStateInstalling") ); |
255 FLOG_1( _L("Daemon: Installation completed with %d"), iStatus.Int() ); |
301 FLOG_1( _L("Daemon: Installation completed with %d"), |
256 // Installation is completed, check result |
302 iStatus.Int() ); |
257 |
303 |
|
304 // Installation is completed, check result |
258 if ( iStatus.Int() == SwiUI::KSWInstErrBusy ) |
305 if ( iStatus.Int() == SwiUI::KSWInstErrBusy ) |
259 { |
306 { |
260 FLOG( _L("Daemon: RunL: iStatus: KSWInstErrBusy") ); |
307 FLOG( _L("Daemon: RunL: iStatus: KSWInstErrBusy") ); |
261 // User might be installing something, wait before retrying |
308 // User might be installing something, wait before retrying |
262 TTimeIntervalMicroSeconds32 time( KInstallRetryWaitTime ); |
309 TTimeIntervalMicroSeconds32 time( KInstallRetryWaitTime ); |
263 iTimer.After(iStatus,time); |
310 iTimer.After(iStatus,time); |
264 iState = EDSisInstallerStateInstallerBusy; |
311 iState = EDSisInstallerStateInstallerBusy; |
265 #ifdef RD_MULTIPLE_DRIVE |
312 iInstallerState = iState; |
266 iInstallerState = iState; |
|
267 #endif |
|
268 SetActive(); |
313 SetActive(); |
269 break; |
314 break; |
270 } |
315 } |
271 else if ( (iStatus.Int() == SwiUI::KSWInstErrSecurityFailure && iInstallErr == KErrNone) || |
316 else if ( (iStatus.Int() == SwiUI::KSWInstErrSecurityFailure && |
272 (iStatus.Int() != KErrNone && iStatus.Int() != SwiUI::KSWInstErrSecurityFailure) ) |
317 iInstallErr == KErrNone) || |
273 { |
318 (iStatus.Int() != KErrNone && |
274 FLOG( _L("Daemon: RunL: iStatus: KSWInstErrSecurityFailure or error") ); |
319 iStatus.Int() != SwiUI::KSWInstErrSecurityFailure) ) |
|
320 { |
|
321 FLOG( _L("Daemon: RunL: iStatus: error of sec. failure") ); |
275 iInstallErr = iStatus.Int(); |
322 iInstallErr = iStatus.Int(); |
|
323 } |
|
324 |
|
325 // Close current sisx except if installer engine is busy. |
|
326 // If installer is busy we will try again later. |
|
327 if ( iStatus.Int() != SwiUI::KSWInstErrBusy ) |
|
328 { |
|
329 if ( iFileOpen ) |
|
330 { |
|
331 FLOG_1( _L("Daemon: RunL: Close File: %S"), &iSisFile ); |
|
332 iSisFileHandle.Close(); |
|
333 iFileOpen = EFalse; |
|
334 } |
276 } |
335 } |
277 |
336 |
278 // Catch all installation error from SwiUI and update cache. |
337 // Catch all installation error from SwiUI and update cache. |
279 if ( iStatus.Int() != KErrNone ) |
338 if ( iStatus.Int() != KErrNone ) |
280 { |
339 { |
281 FLOG( _L("Daemon: RunL: Installation error.") ); |
340 FLOG( _L("Daemon: RunL: Installation error.") ); |
282 if ( iCurrentPackageId != TUid::Uid( NULL ) ) |
341 if ( iCurrentPackageId != TUid::Uid( NULL ) ) |
283 { |
342 { |
284 FLOG( _L("Daemon: RunL: Add UID to cache.") ); |
343 FLOG( _L("Daemon: RunL: Add UID to cache.") ); |
285 iInstallationFailedAppsCache->AddPackageUID( iCurrentPackageId ); |
344 iInstallationFailedAppsCache->AddPackageUID( |
|
345 iCurrentPackageId ); |
286 // Clear current UID |
346 // Clear current UID |
287 iCurrentPackageId = TUid::Null(); |
347 iCurrentPackageId = TUid::Null(); |
288 } |
348 } |
289 } |
349 } |
290 else |
350 else |
291 { |
351 { |
292 FLOG( _L("Daemon: RunL: Installation OK.") ); |
352 FLOG( _L("Daemon: RunL: Installation OK.") ); |
293 if ( iCurrentPackageId != TUid::Uid( NULL ) ) |
353 if ( iCurrentPackageId != TUid::Uid( NULL ) ) |
294 { |
354 { |
295 FLOG( _L("Daemon: RunL: Add UID to cache.") ); |
355 FLOG( _L("Daemon: RunL: Add UID to cache.") ); |
296 iPreviouslyInstalledAppsCache->UpdateAddL( iCurrentPackageId ); |
356 iPreviouslyInstalledAppsCache->UpdateAddL( |
|
357 iCurrentPackageId ); |
297 // Clear current UID |
358 // Clear current UID |
298 iCurrentPackageId = TUid::Null(); |
359 iCurrentPackageId = TUid::Null(); |
299 } |
360 } |
300 } |
361 } |
301 |
362 |
302 // Check if we have more to install |
363 // Check if we have more to install |
303 if ( iFileIndex < iFilesToInstall.Count() ) |
364 if ( iFileIndex < iFilesToInstall.Count() ) |
304 { |
365 { |
305 // Kick of the next installation |
366 // Kick of the next installation |
306 iState = EDSisInstallerStateIdle; |
367 iState = EDSisInstallerStateIdle; |
307 #ifdef RD_MULTIPLE_DRIVE |
368 iInstallerState = iState; |
308 iInstallerState = iState; |
|
309 #endif |
|
310 |
|
311 CompleteSelf(); |
369 CompleteSelf(); |
312 } |
370 } |
313 else |
371 else |
314 { |
372 { |
315 // Note that this will also signal plugin that |
373 // Note that this will also signal plugin that |
334 // InstallationCompleted will set this ETrue again. |
402 // InstallationCompleted will set this ETrue again. |
335 iUpdateCache = EFalse; |
403 iUpdateCache = EFalse; |
336 } |
404 } |
337 |
405 |
338 if ( iFileIndex < iFilesToInstall.Count() ) |
406 if ( iFileIndex < iFilesToInstall.Count() ) |
339 { |
407 { |
|
408 // Let's calc. values before index is updated. |
|
409 CalcPercentValue(); |
|
410 |
|
411 // Get next sisx package from array. |
340 iSisFile.Copy( *iFilesToInstall[iFileIndex] ); |
412 iSisFile.Copy( *iFilesToInstall[iFileIndex] ); |
341 ++iFileIndex; |
413 ++iFileIndex; |
342 |
414 |
343 // No need to install if the package has been installed |
415 FLOG_1( _L("Daemon: RunL: Open File: %S"), &iSisFile ); |
344 // some time in the past |
416 TInt err = KErrNone; |
345 if ( IsValidPackageL( iSisFile ) && NeedsInstallingL( iSisFile ) ) |
417 // Let's open the file in here bacause IsValidPackageL |
346 { |
418 // needs to open the file anyway. |
|
419 err = iSisFileHandle.Open( |
|
420 iFs, |
|
421 iSisFile, |
|
422 EFileRead | EFileShareReadersOnly ); |
|
423 |
|
424 if ( err ) |
|
425 { |
|
426 FLOG_1( _L("Daemon: File open ERROR = %d"), err ); |
|
427 iFileOpen = EFalse; |
|
428 } |
|
429 else |
|
430 { |
|
431 iFileOpen = ETrue; |
|
432 } |
|
433 |
|
434 if ( iFileOpen && IsValidPackageL() && |
|
435 NeedsInstallingL( iSisFile ) ) |
|
436 { |
347 // If there is plugin for SWI Daemon then let's us it. |
437 // If there is plugin for SWI Daemon then let's us it. |
348 // Daemon will give all files to plug-in which will |
438 // Daemon will give all files to plug-in which will |
349 // handle installation. There is not feedback so SWI |
439 // handle installation. There is not feedback so SWI |
350 // Daemon will not wait plug-in. |
440 // Daemon will not wait plug-in. |
351 if ( iDaemonBehaviour->IsPlugin() ) |
441 if ( iDaemonBehaviour->IsPlugin() ) |
352 { |
442 { |
353 // Notify plug-in if not yet done. |
443 // Notify plug-in if not yet done. |
354 iDaemonBehaviour->NotifyPlugin(); |
444 iDaemonBehaviour->NotifyPlugin(); |
355 FLOG_1( _L("Daemon: Use plugin to install: %S"), &iSisFile ); |
445 FLOG_1( _L("Daemon: Use plugin to install: %S"), |
356 TRAP_IGNORE( iDaemonBehaviour->RequestPluginInstall( iSisFile ) ); |
446 &iSisFile ); |
|
447 TRAP_IGNORE( iDaemonBehaviour->RequestPluginInstall( |
|
448 iSisFile ) ); |
357 |
449 |
358 // Let's continue to give all packages to plug-in. |
450 // Let's continue to give all packages to plug-in. |
359 // Note that we do not have iStatus as this is not async. call |
451 // Note that we do not have iStatus as this is not |
360 // so we can not use EDSisInstallerStateInstalling state. |
452 // async. call so we can not use |
361 iState = EDSisInstallerStateIdle; |
453 // EDSisInstallerStateInstalling state. |
362 #ifdef RD_MULTIPLE_DRIVE |
454 iState = EDSisInstallerStateIdle; |
363 iInstallerState = iState; |
455 iInstallerState = iState; |
364 #endif |
456 |
365 // Plugin interface is not asyncronous. We need to |
457 // Plugin interface is not asyncronous. We need to |
366 // complete self to get all packages to plugin. |
458 // complete self to get all packages to plugin. |
367 CompleteSelf(); |
459 CompleteSelf(); |
368 } |
460 } |
369 else |
461 else |
370 { |
462 { |
371 FLOG_1( _L("Daemon: Kick off the install for %S"), &iSisFile ); |
463 // Start also the universal indicator. |
372 iInstallLauncher->InstallL( iSisFile, iStatus ); |
464 TRAP_IGNORE( iDialogs->ActivateIndicatorL( iPercentValue ) ); |
373 iDialogs->ShowWaitingNoteL(); |
465 // Start to show progress dialog. Dialog is shown |
374 iState = EDSisInstallerStateInstalling; |
466 // only 3 sec. |
375 #ifdef RD_MULTIPLE_DRIVE |
467 TRAP_IGNORE( iDialogs->ShowWaitingNoteL() ); |
376 iInstallerState = iState; |
468 |
377 #endif |
469 FLOG_1( _L("Daemon: Start install for %S"), &iSisFile ); |
378 SetActive(); |
470 |
|
471 iInstallLauncher->InstallL( iSisFileHandle, |
|
472 iSisFile, |
|
473 iStatus ); |
|
474 |
|
475 iState = EDSisInstallerStateInstalling; |
|
476 iInstallerState = iState; |
|
477 SetActive(); |
379 } |
478 } |
380 } |
479 } |
381 else |
480 else |
382 { |
481 { |
383 FLOG_1( _L("Daemon: No need to install %S"), &iSisFile ); |
482 FLOG_1( _L("Daemon: NOT INSTALLING: %S"), &iSisFile ); |
384 iState = EDSisInstallerStateIdle; |
483 iState = EDSisInstallerStateIdle; |
385 #ifdef RD_MULTIPLE_DRIVE |
484 iInstallerState = iState; |
386 iInstallerState = iState; |
|
387 #endif |
|
388 // Clear current pkg UID |
485 // Clear current pkg UID |
389 iCurrentPackageId = TUid::Null(); |
486 iCurrentPackageId = TUid::Null(); |
390 |
|
391 CompleteSelf(); |
487 CompleteSelf(); |
392 } |
488 } |
393 } |
489 } |
394 else |
490 else |
395 { |
491 { |
400 } |
496 } |
401 } |
497 } |
402 break; |
498 break; |
403 |
499 |
404 case EDSisInstallerStateInstallerBusy: |
500 case EDSisInstallerStateInstallerBusy: |
|
501 { |
405 // Try to install the file again |
502 // Try to install the file again |
406 FLOG( _L("Daemon: RunL: EDSisInstallerStateInstallerBusy") ); |
503 FLOG( _L("Daemon: RunL: EDSisInstallerStateInstallerBusy") ); |
407 FLOG_1( _L("Daemon: Kick off the install for %S"), &iSisFile ); |
504 |
408 iInstallLauncher->InstallL( iSisFile, iStatus ); |
505 // If file is not open, try to open it. |
409 iState = EDSisInstallerStateInstalling; |
506 if ( !iFileOpen ) |
410 #ifdef RD_MULTIPLE_DRIVE |
507 { |
411 iInstallerState = iState; |
508 FLOG( _L("Daemon: RunL: Error file not open !") ); |
412 #endif |
509 FLOG_1( _L("Daemon: Open File: %S"), &iSisFile ); |
413 |
510 |
414 SetActive(); |
511 TInt err = iSisFileHandle.Open( |
|
512 iFs, |
|
513 iSisFile, |
|
514 EFileRead | EFileShareReadersOnly ); |
|
515 |
|
516 if ( err ) |
|
517 { |
|
518 FLOG_1( _L("Daemon: File open ERROR = %d"), err ); |
|
519 iFileOpen = EFalse; |
|
520 } |
|
521 else |
|
522 { |
|
523 FLOG( _L("Daemon: RunL: File open") ); |
|
524 iFileOpen = ETrue; |
|
525 } |
|
526 } |
|
527 |
|
528 if ( iFileOpen ) |
|
529 { |
|
530 FLOG_1( _L("Daemon: Try install again for: %S"), &iSisFile ); |
|
531 iInstallLauncher->InstallL( iSisFileHandle, |
|
532 iSisFile, |
|
533 iStatus ); |
|
534 |
|
535 iState = EDSisInstallerStateInstalling; |
|
536 iInstallerState = iState; |
|
537 SetActive(); |
|
538 } |
|
539 else |
|
540 { |
|
541 // If we cannot open the sis file let's continue |
|
542 // and install rest of the packages. |
|
543 // We can try to install this next time in boot |
|
544 // or when media is mounted. |
|
545 iState = EDSisInstallerStateIdle; |
|
546 iInstallerState = iState; |
|
547 CompleteSelf(); |
|
548 } |
|
549 } |
415 break; |
550 break; |
416 |
551 |
417 // Active object in unknown state |
552 // Active object in unknown state |
418 default: |
553 default: |
419 User::Panic(KMCSisInstaller,KErrNotSupported); |
554 User::Panic(KMCSisInstaller,KErrNotSupported); |
420 break; |
555 break; |
421 } |
556 } |
422 } // else for uninstaller |
557 } // else for uninstaller |
|
558 FLOG( _L("Daemon: RunL END") ); |
423 } |
559 } |
424 |
560 |
|
561 // ----------------------------------------------------------------------- |
|
562 // CSisInstaller::RunError |
425 // If RunL leaves then ignore errors |
563 // If RunL leaves then ignore errors |
426 |
564 // ----------------------------------------------------------------------- |
|
565 // |
427 TInt CSisInstaller::RunError(TInt aError) |
566 TInt CSisInstaller::RunError(TInt aError) |
428 { |
567 { |
429 FLOG_1( _L("Daemon: Installer RunL error %d"), aError ); |
568 FLOG_1( _L("Daemon: Installer Run error %d"), aError ); |
430 TInt err( KErrNone ); |
569 TInt err( KErrNone ); |
431 InstallationCompleted( aError ); |
570 InstallationCompleted( aError ); |
432 return err; |
571 return err; |
433 } |
572 } |
434 |
573 |
|
574 // ----------------------------------------------------------------------- |
|
575 // CSisInstaller::NotifyShuttingDown |
|
576 // ----------------------------------------------------------------------- |
|
577 // |
435 void CSisInstaller::NotifyShuttingDown() |
578 void CSisInstaller::NotifyShuttingDown() |
436 { |
579 { |
437 // System is closing down, we need to stop installations and save |
580 // System is closing down, we need to stop installations and save |
438 // the lists of previously installed apps and failed installations. |
581 // the lists of previously installed apps and failed installations. |
439 // Application server receives EApaSystemEventShutdown event that |
582 // Application server receives EApaSystemEventShutdown event that |
440 // closes it down. |
583 // closes it down. |
441 Cancel(); |
584 Cancel(); |
442 } |
585 } |
443 |
586 |
|
587 // ----------------------------------------------------------------------- |
|
588 // CSisInstaller::InstallationCompleted |
|
589 // ----------------------------------------------------------------------- |
|
590 // |
444 void CSisInstaller::InstallationCompleted( TInt aResult ) |
591 void CSisInstaller::InstallationCompleted( TInt aResult ) |
445 { |
592 { |
|
593 // Let's update universal indicator ones more. |
|
594 iDialogs->ActivateIndicatorL( 100 ); |
|
595 |
446 FLOG_1( _L("Daemon: InstallationCompleted with result = %d"), aResult ); |
596 FLOG_1( _L("Daemon: InstallationCompleted with result = %d"), aResult ); |
447 iState = EDSisInstallerStateIdle; |
597 iState = EDSisInstallerStateIdle; |
448 iInstallErr = KErrNone; |
598 iInstallErr = KErrNone; |
|
599 FLOG( _L("Daemon: InstallationCompleted: Delete iInstallLauncher") ); |
449 delete iInstallLauncher; |
600 delete iInstallLauncher; |
450 iInstallLauncher = NULL; |
601 iInstallLauncher = NULL; |
451 // We need to update cache again in RunL if plug-in is loaded. |
602 // We need to update cache again in RunL if plug-in is loaded. |
452 // It may be that plug-in does install packages after cache is updated. |
603 // It may be that plug-in does install packages after cache is updated. |
453 iUpdateCache = ETrue; |
604 iUpdateCache = ETrue; |
454 |
605 |
455 #ifdef RD_MULTIPLE_DRIVE |
|
456 // If all files are installed set status to completed. |
606 // If all files are installed set status to completed. |
457 if ( iFileIndex >= iFilesToInstall.Count() ) |
607 if ( iFileIndex >= iFilesToInstall.Count() ) |
458 { |
608 { |
459 iInstallerState = EDSisInstallerStateCompleted; |
609 iInstallerState = EDSisInstallerStateCompleted; |
460 } |
610 } |
461 #endif |
611 |
462 |
612 // Make sure that current file is closed before exit. |
463 TRAP_IGNORE( iDialogs->CancelWaitingNoteL() ); |
613 // File may be open if this is called from RunError/DoCancel etc. |
464 |
614 if ( iFileOpen ) |
|
615 { |
|
616 FLOG( _L("Daemon: InstallationCompleted: File open - Close it !!!") ); |
|
617 iSisFileHandle.Close(); |
|
618 iFileOpen = EFalse; |
|
619 } |
|
620 |
|
621 // Make sure that progress note is closed. |
|
622 TRAP_IGNORE( iDialogs->CancelWaitingNote() ); |
|
623 // Close the universal indicator. |
|
624 iDialogs->CancelIndicatorL(); |
|
625 |
465 if ( aResult != KErrNone && |
626 if ( aResult != KErrNone && |
466 iSisFile.Length() > 0 && |
627 iSisFile.Length() > 0 && |
467 IsMediaPresent( TChar( iSisFile[0] ) ) ) |
628 IsMediaPresent( TChar( iSisFile[0] ) ) ) |
468 { |
629 { |
469 if ( aResult == SwiUI::KSWInstErrSecurityFailure ) |
630 if ( aResult == SwiUI::KSWInstErrSecurityFailure ) |
515 |
674 |
516 HBufC8* controller = content->ReadControllerL(); |
675 HBufC8* controller = content->ReadControllerL(); |
517 CleanupStack::PushL( controller ); |
676 CleanupStack::PushL( controller ); |
518 |
677 |
519 // Code to read UID |
678 // Code to read UID |
520 |
|
521 CDesDataProvider* controllerProvider= CDesDataProvider::NewLC(*controller); |
679 CDesDataProvider* controllerProvider= CDesDataProvider::NewLC(*controller); |
522 CController* controllerObject = NULL; |
680 CController* controllerObject = NULL; |
523 controllerObject = CController::NewL(*controllerProvider); |
681 controllerObject = CController::NewL(*controllerProvider); |
524 CleanupStack::PushL(controllerObject); |
682 CleanupStack::PushL(controllerObject); |
525 |
683 |
526 TUid packageId = controllerObject->Info().Uid().Uid(); |
684 TUid packageId = controllerObject->Info().Uid().Uid(); |
527 |
685 |
528 CleanupStack::PopAndDestroy(controllerObject); |
686 CleanupStack::PopAndDestroy( controllerObject ); |
529 CleanupStack::PopAndDestroy(controllerProvider); |
687 CleanupStack::PopAndDestroy( controllerProvider ); |
530 |
688 |
531 FLOG_1( _L("Daemon: NeedsInstallingL: Is UID installed = 0x%x"), packageId.iUid ); |
689 // Check if sw is installed previously. |
532 result = !iPreviouslyInstalledAppsCache->HasBeenPreviouslyInstalled(packageId); |
690 // Note if UID is found sw will not be installed even if user |
533 FLOG_1( _L("Daemon: NeedsInstallingL: Has been installed (cache) = %d"), !result ); |
691 // has uninstall it bacause cache is not updated from SCR. |
|
692 FLOG_1( _L("Daemon: Is UID installed = 0x%x"), packageId.iUid ); |
|
693 needsInstalling = !iPreviouslyInstalledAppsCache-> |
|
694 HasBeenPreviouslyInstalled(packageId); |
|
695 FLOG_1( _L("Daemon: Has been installed (cache) = %d"), !needsInstalling ); |
534 |
696 |
535 if (result) |
697 // No need to check rom stubs in here anymore. |
536 { |
698 // Note 1: SWI Daemon policy has been that RU packages are not installed |
|
699 // from removable media. |
|
700 // Note 2: UpdateAllL will add all pkg uids in cache (PreviouslyInstalled), |
|
701 // so rom upgrades are not installed since uid is found from the cache. |
|
702 // Note 3: Install params do not allow RU to be installed. So SWI will |
|
703 // reject RU (rom upgrade) package anyway. |
|
704 |
|
705 /* |
|
706 // Note! this code has been wrong. No need to check stubs since |
|
707 // policy do not allow RU updates and SWI will reject the install. |
|
708 if ( !needsInstalling ) |
|
709 { |
537 RSisRegistrySession registry; |
710 RSisRegistrySession registry; |
538 User::LeaveIfError( registry.Connect() ); |
711 User::LeaveIfError( registry.Connect() ); |
539 CleanupClosePushL( registry ); |
712 CleanupClosePushL( registry ); |
540 result = !registry.IsInstalledL( packageId ); |
713 result = !registry.IsInstalledL( packageId ); |
541 |
714 |
546 { |
719 { |
547 RSisRegistryEntry entry; |
720 RSisRegistryEntry entry; |
548 User::LeaveIfError( entry.Open( registry, packageId ) ); |
721 User::LeaveIfError( entry.Open( registry, packageId ) ); |
549 CleanupClosePushL( entry ); |
722 CleanupClosePushL( entry ); |
550 |
723 |
551 result = entry.IsInRomL(); |
724 needsInstalling = entry.IsInRomL(); |
552 |
725 |
553 FLOG_1( _L("Daemon: NeedsInstallingL: Is in ROM = %d"), result ); |
726 FLOG_1( _L("Daemon: NeedsInstallingL: Is in ROM = %d"), needsInstalling ); |
554 CleanupStack::PopAndDestroy( &entry ); |
727 CleanupStack::PopAndDestroy( &entry ); |
555 } |
728 } |
556 CleanupStack::PopAndDestroy( ®istry ); |
729 CleanupStack::PopAndDestroy( ®istry ); |
557 } |
730 } |
558 |
731 */ |
|
732 |
559 // Check that previous install attempt did not fail. |
733 // Check that previous install attempt did not fail. |
560 if (result) |
734 if ( needsInstalling ) |
561 { |
735 { |
562 result = !iInstallationFailedAppsCache->HasPreviousInstallationFailed( packageId ); |
736 needsInstalling = !iInstallationFailedAppsCache-> |
563 FLOG_1( _L("Daemon: NeedsInstallingL: Has failed (cache) = %d"), !result ); |
737 HasPreviousInstallationFailed( packageId ); |
|
738 FLOG_1( _L("Daemon: Has failed (cache) = %d"), !needsInstalling ); |
564 } |
739 } |
565 |
740 |
566 // Update pkg ID. ID is added to cache after installation. |
741 // Update pkg ID. ID is added to cache after installation. |
567 if (result) |
742 if ( needsInstalling ) |
568 { |
743 { |
569 iCurrentPackageId = packageId; |
744 iCurrentPackageId = packageId; |
570 } |
745 } |
571 |
746 |
|
747 // fileProvider, content, controller |
572 CleanupStack::PopAndDestroy( 3 ); |
748 CleanupStack::PopAndDestroy( 3 ); |
573 |
749 |
574 return result; |
750 FLOG_1( _L("Daemon: NeedsInstallingL = %d"), needsInstalling ); |
|
751 return needsInstalling; |
575 } |
752 } |
576 |
753 |
|
754 // ----------------------------------------------------------------------- |
|
755 // CSisInstaller::IsMediaPresent |
|
756 // ----------------------------------------------------------------------- |
|
757 // |
577 TBool CSisInstaller::IsMediaPresent( TChar aDrive ) |
758 TBool CSisInstaller::IsMediaPresent( TChar aDrive ) |
578 { |
759 { |
579 TInt drive( 0 ); |
760 TInt drive( 0 ); |
580 TInt err = iFs.CharToDrive( aDrive, drive ); |
761 TInt err = iFs.CharToDrive( aDrive, drive ); |
581 if ( err == KErrNone ) |
762 if ( err == KErrNone ) |
593 FLOG( _L("Daemon: Drive no present") ); |
774 FLOG( _L("Daemon: Drive no present") ); |
594 return EFalse; |
775 return EFalse; |
595 } |
776 } |
596 } |
777 } |
597 |
778 |
598 TBool CSisInstaller::IsValidPackageL( const TDesC& aPackageName ) |
779 // ----------------------------------------------------------------------- |
599 { |
780 // CSisInstaller::IsValidPackageL |
600 TBool result( EFalse ); |
781 // ----------------------------------------------------------------------- |
601 |
782 // |
602 RFile file; |
783 TBool CSisInstaller::IsValidPackageL() |
|
784 { |
|
785 TBool result( EFalse ); |
|
786 |
|
787 if ( !iFileOpen ) |
|
788 { |
|
789 FLOG( _L("Daemon: IsValidPackageL: ERROR FILE NOT OPEN") ); |
|
790 return result; |
|
791 } |
|
792 |
603 TUid appUid; |
793 TUid appUid; |
604 TDataType dataType; |
794 TDataType dataType; |
605 User::LeaveIfError( file.Open( iFs, aPackageName, EFileRead ) ); |
795 |
606 iApaSession.AppForDocument( file, appUid, dataType ); |
796 iApaSession.AppForDocument( iSisFileHandle, appUid, dataType ); |
607 file.Close(); |
|
608 |
797 |
609 if ( dataType.Des8() == SwiUI::KSisxMimeType ) |
798 if ( dataType.Des8() == SwiUI::KSisxMimeType ) |
610 { |
799 { |
611 result = ETrue; |
800 result = ETrue; |
612 } |
801 } |
613 |
802 |
|
803 FLOG_1( _L("Daemon: IsValidPackageL = %d"), result ); |
614 return result; |
804 return result; |
615 } |
805 } |
616 |
806 |
|
807 // ----------------------------------------------------------------------- |
|
808 // CSisInstaller::CalcPrecentValue |
|
809 // ----------------------------------------------------------------------- |
|
810 // |
|
811 void CSisInstaller::CalcPercentValue() |
|
812 { |
|
813 FLOG( _L("Daemon: CSisInstaller::CalcPercentValue") ); |
|
814 FLOG_1( _L("Daemon: iFileIndex = %d"), iFileIndex ); |
|
815 // Let's calculate indicator value for UI now. |
|
816 TInt sisxFileCount = iFilesToInstall.Count(); |
|
817 FLOG_1( _L("Daemon: iFilesToInstall.Count = %d"), sisxFileCount ); |
|
818 iPercentValue = 0; |
|
819 |
|
820 // Note! if iFileIndex is zero, no package is installed bacause |
|
821 // installation process starts after this function. |
|
822 if ( iFileIndex && sisxFileCount ) |
|
823 { |
|
824 // Let's calculate new precent value after some |
|
825 // package is installed. |
|
826 if ( iFileIndex <= sisxFileCount ) |
|
827 { |
|
828 TReal32 realFileIndex = iFileIndex; |
|
829 TReal32 realFileCount = sisxFileCount; |
|
830 iPercentValue = (realFileIndex/realFileCount)*100; |
|
831 } |
|
832 else |
|
833 { |
|
834 // Most probably all is installed if index is bigger then |
|
835 // filen count. Let's not show over 100% to user. |
|
836 // This may happend after last package is processed since |
|
837 // index counter is updated before install starts. |
|
838 iPercentValue = 100; |
|
839 } |
|
840 } |
|
841 FLOG_1( _L("Daemon: CalcPercentValue value = %d"), (TInt)iPercentValue ); |
|
842 } |
|
843 |
617 //EOF |
844 //EOF |
618 |
845 |
619 |
846 |
620 |
847 |
621 |
848 |