|
1 /* |
|
2 * Copyright (c) 2007-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: Handels IAD self update and starting the IAD process |
|
15 * after self update. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include <apgcli.h> // RApaLsSession |
|
22 #include <apacmdln.h> // CApaCommandLine |
|
23 #include <apgtask.h> |
|
24 #include <apgwgnam.h> |
|
25 #include <e32std.h> |
|
26 #include <ecom/ecom.h> |
|
27 #include <swi/sisregistrysession.h> |
|
28 #include <swi/sisregistryentry.h> |
|
29 #include <catalogsuids.h> |
|
30 |
|
31 #include "iaupdatermngr.h" |
|
32 #include "iaupdaterinstaller.h" |
|
33 #include "iaupdaterdialog.h" |
|
34 #include "iaupdaterdefs.h" |
|
35 |
|
36 #include "iaupdaterfilelistfile.h" |
|
37 #include "iaupdaterfilelist.h" |
|
38 #include "iaupdaterfileinfo.h" |
|
39 #include "iaupdaterresultsfile.h" |
|
40 #include "iaupdaterresult.h" |
|
41 #include "iaupdateridentifier.h" |
|
42 |
|
43 #include "iaupdatedebug.h" |
|
44 |
|
45 |
|
46 // ======== LOCAL FUNCTIONS ======== |
|
47 |
|
48 // ======== MEMBER FUNCTIONS ======== |
|
49 |
|
50 |
|
51 // Maximum time (in microseconds) that ECOM is waited. |
|
52 const TInt KMaxEcomWait( 3000000 ); |
|
53 |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CIAUpdaterMngr::NewL() |
|
57 // |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CIAUpdaterMngr* CIAUpdaterMngr::NewL() |
|
61 { |
|
62 CIAUpdaterMngr* self = CIAUpdaterMngr::NewLC(); |
|
63 CleanupStack::Pop( self ); |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CIAUpdaterMngr::NewLC() |
|
70 // |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CIAUpdaterMngr* CIAUpdaterMngr::NewLC() |
|
74 { |
|
75 CIAUpdaterMngr* self = new (ELeave) CIAUpdaterMngr; |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL(); |
|
78 return self; |
|
79 } |
|
80 |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CIAUpdaterMngr::ConstructL() |
|
84 // |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CIAUpdaterMngr::ConstructL() |
|
88 { |
|
89 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterMngr::ConstructL start"); |
|
90 iResultsFile = CIAUpdaterResultsFile::NewL(); |
|
91 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterMngr::ConstructL end"); |
|
92 } |
|
93 |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CIAUpdaterMngr::~CIAUpdater() |
|
97 // |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 CIAUpdaterMngr::~CIAUpdaterMngr() |
|
101 { |
|
102 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterMngr::~CIAUpdaterMngr start"); |
|
103 delete iIAInstaller; |
|
104 delete iResultsFile; |
|
105 iWsSession.Close(); |
|
106 iFs.Close(); |
|
107 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterMngr::~CIAUpdaterMngr end"); |
|
108 } |
|
109 |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CIAUpdaterMngr::ProcessInstallingL() |
|
113 // |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CIAUpdaterMngr::ProcessInstallingL( TIAUpdaterStartParams& aStartParams ) |
|
117 { |
|
118 IAUPDATE_TRACE("[IAUpdater] ProcessInstallingL"); |
|
119 |
|
120 // Reset member variables |
|
121 iInstallError = KErrNone; |
|
122 iEcomPluginInstalled = EFalse; |
|
123 |
|
124 |
|
125 // Initialize the results file for operations |
|
126 |
|
127 // Just in case there would be some old information left. |
|
128 iResultsFile->Reset(); |
|
129 // Set the results file path. |
|
130 iResultsFile->SetFilePathL( aStartParams.iResultFilePath ); |
|
131 |
|
132 |
|
133 // Start actual operations. |
|
134 |
|
135 // Get the file info data from the file. |
|
136 CIAUpdaterFileListFile* listFile( CIAUpdaterFileListFile::NewLC() ); |
|
137 |
|
138 // The correct path was given in the starting parameters. |
|
139 // Set this path. So, the object can read its data from the correct file. |
|
140 IAUPDATE_TRACE_1("[IAUpdater] ProcessInstallingL set path: %S", |
|
141 &aStartParams.iInitFilePath); |
|
142 listFile->SetFilePathL( aStartParams.iInitFilePath ); |
|
143 |
|
144 // Read data from the defined file. |
|
145 listFile->ReadDataL(); |
|
146 |
|
147 // Remove the file, because all the information from the list file |
|
148 // is now available in the lisFile object. Then, it will not be reused |
|
149 // if this operation leaves and iaupdate is restarted later. |
|
150 IAUPDATE_TRACE_1("[IAUpdater] ProcessInstallingL fileRemove: %S", |
|
151 &listFile->FilePath()); |
|
152 User::LeaveIfError( listFile->RemoveFile() ); |
|
153 IAUPDATE_TRACE("[IAUpdater] File removed."); |
|
154 |
|
155 // Now, get the info that is required for the dialog. |
|
156 // Notice, that we keep the index value to constant. |
|
157 // This application supposes that all the installable |
|
158 // bundles are part of the one same packet. So, indexing |
|
159 // is not changed. |
|
160 TInt KIndex( listFile->PckgStartIndex() ); |
|
161 const TInt KTotalCount( listFile->TotalPckgCount() ); |
|
162 // Check if the dialogs should be shown |
|
163 const TBool KSilent( listFile->Silent() ); |
|
164 |
|
165 TInt count( listFile->FileList().Count() ); |
|
166 TBool showing( EFalse ); |
|
167 User::LeaveIfError( iFs.Connect() ); |
|
168 User::LeaveIfError( iWsSession.Connect( iFs ) ); |
|
169 CIAUpdaterDialog* dialogs( CIAUpdaterDialog::NewLC( iFs, *this ) ); |
|
170 if ( count > 0 ) |
|
171 { |
|
172 TInt nameIndex( 0 ); |
|
173 for ( TInt i = 0; i < count; ++i ) |
|
174 { |
|
175 IAUPDATE_TRACE_1("[IAUpdater] FileList: %d", i); |
|
176 iCurrentFileList = listFile->FileList()[ i ]; |
|
177 |
|
178 if ( iInstallError == KErrNone ) |
|
179 { |
|
180 IAUPDATE_TRACE("[IAUpdater] No errors. Continue install."); |
|
181 if ( !KSilent && i == nameIndex ) |
|
182 { |
|
183 IAUPDATE_TRACE("[IAUpdater] Show dialog"); |
|
184 // If the dialog should be shown, then use the constant values for the |
|
185 // indexing and total count. |
|
186 // Search for the bundle name. Hidden names are not shown, so the first |
|
187 // not hidden name will be shown. Notice, that here we think that the name |
|
188 // that describes also the hidden items is non hidden item after those hidden |
|
189 // items. |
|
190 for ( TInt j = nameIndex; j < count; ++j ) |
|
191 { |
|
192 IAUPDATE_TRACE_1("[IAUpdater] nameIndex: %d", j); |
|
193 CIAUpdaterFileList* list( listFile->FileList()[ j ] ); |
|
194 if ( !list->Hidden() |
|
195 || j + 1 == count && !showing ) |
|
196 { |
|
197 if ( !KSilent && showing ) |
|
198 { |
|
199 IAUPDATE_TRACE("[IAUpdater] Cancel waiting note"); |
|
200 // Stop showing wait note before starting new note. |
|
201 dialogs->CancelWaitingNoteL(); |
|
202 showing = EFalse; |
|
203 } |
|
204 |
|
205 // Show dialog if the item is not hidden or |
|
206 // if all the items are hidden and no dialog is showing, then show |
|
207 // the last one. |
|
208 // The last item is always thought as non hidden because it is the main item. |
|
209 // All other items before it are items that the main item depends on. |
|
210 // Show waiting note because we are starting the install operation |
|
211 IAUPDATE_TRACE_1("[IAUpdater] Show new waiting note: %S", |
|
212 &list->BundleName()); |
|
213 dialogs-> |
|
214 ShowWaitingNoteL( list->BundleName(), |
|
215 KIndex, KTotalCount ); |
|
216 nameIndex = j + 1; |
|
217 showing = ETrue; |
|
218 break; |
|
219 } |
|
220 } |
|
221 } |
|
222 |
|
223 // Delete old installer. So, the new installer will be configured |
|
224 // with correct values. |
|
225 delete iIAInstaller; |
|
226 iIAInstaller = NULL; |
|
227 iIAInstaller = CIAUpdaterInstaller::NewL( iFs, *this ); |
|
228 ProcessSISFilesL( *iCurrentFileList ); |
|
229 |
|
230 // Notice, that this is synchronous installation that will wait until the |
|
231 // active install operation has finished its job. |
|
232 // Uses, CActiveSchedulerWait. |
|
233 // So, be cautious about nested loops. |
|
234 iIAInstaller->StartInstallingL(); |
|
235 } |
|
236 else if ( iInstallError == KErrCancel ) |
|
237 { |
|
238 // Because cancel occurred during the last install, |
|
239 // cancel installation of other items. |
|
240 // Set error code as KErrCancel for remaining items. |
|
241 // Setting of these parameters is so quick operation, |
|
242 // that do not show separate dialogs for this after |
|
243 // the possible shown dialog is closed below. |
|
244 IAUPDATE_TRACE("[IAUpdater] Cancel occurred. So, do not try to install."); |
|
245 SetProcessParametersL( KErrCancel ); |
|
246 } |
|
247 else |
|
248 { |
|
249 // Because an error occurred during the last install, |
|
250 // abort installation of other items. |
|
251 // Set error code as KErrAbort for remaining items. |
|
252 // Setting of these parameters is so quick operation, |
|
253 // that do not show separate dialogs for this after |
|
254 // the possible shown dialog is closed below. |
|
255 IAUPDATE_TRACE("[IAUpdater] Error occurred. So, do not try to install."); |
|
256 SetProcessParametersL( KErrAbort ); |
|
257 } |
|
258 } |
|
259 |
|
260 IAUPDATE_TRACE("[IAUpdater] Finished installation."); |
|
261 |
|
262 if ( iEcomPluginInstalled ) |
|
263 { |
|
264 IAUPDATE_TRACE("[IAUpdater] Wait for the ECOM."); |
|
265 // Ecom plugin was installed during the update flow. |
|
266 // Wait for the ECOM to finish indexing of its plugins. |
|
267 EcomWaiterL(); |
|
268 } |
|
269 |
|
270 } |
|
271 |
|
272 |
|
273 // Increase the index by one for the result. |
|
274 // Notice, that here the index may become as great as KTotalCount but |
|
275 // it is up to the user of the results to check this later. |
|
276 iResultsFile->SetPckgStartIndex( KIndex + 1 ); |
|
277 iResultsFile->SetTotalPckgCount( KTotalCount ); |
|
278 |
|
279 // Look at is there iaupdate instance running |
|
280 // |
|
281 TApaTaskList tasklist( iWsSession ); |
|
282 TApaTask task = tasklist.FindApp( TUid::Uid( IAUpdaterDefs::KIADUpdateUid3 ) ); |
|
283 |
|
284 |
|
285 |
|
286 IAUPDATE_TRACE("[IAUpdater] Final process checks"); |
|
287 |
|
288 // Result data is not written if user exit (end key pressed) and |
|
289 // there is not iaupdate running |
|
290 if ( !iUserExit || task.Exists() ) |
|
291 { |
|
292 IAUPDATE_TRACE("[IAUpdater] Write results file data"); |
|
293 iResultsFile->WriteDataL(); |
|
294 } |
|
295 |
|
296 // Iaupdate is restarted only when there is not running instance. |
|
297 // When user exit (end key pressed) new iaupdate is not launched |
|
298 if ( !iUserExit && !task.Exists() ) |
|
299 { |
|
300 IAUPDATE_TRACE("[IAUpdater] Start IAUpdate UI process"); |
|
301 StartIADProcessesL(); |
|
302 } |
|
303 |
|
304 if ( !KSilent && showing ) |
|
305 { |
|
306 IAUPDATE_TRACE("[IAUpdater] Stop showing dialog."); |
|
307 // Stop showing wait note because we have finished this installation. |
|
308 TRAP_IGNORE( dialogs->CancelWaitingNoteL() ); |
|
309 CleanupStack::PopAndDestroy( dialogs ); |
|
310 } |
|
311 |
|
312 CleanupStack::PopAndDestroy( listFile ); |
|
313 listFile = NULL; |
|
314 |
|
315 if ( iUserExit ) |
|
316 { |
|
317 IAUPDATE_TRACE("[IAUpdater] User exit"); |
|
318 User::Leave( IAUpdaterDefs::KIAUpdaterShutdownRequest ); |
|
319 } |
|
320 |
|
321 |
|
322 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterMngr::ProcessInstallingL end"); |
|
323 } |
|
324 |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CIAUpdaterMngr::UserCancel |
|
328 // |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 void CIAUpdaterMngr::UserCancel() |
|
332 { |
|
333 IAUPDATE_TRACE("[IAUpdater] UserCancel() start"); |
|
334 if ( iIAInstaller ) |
|
335 { |
|
336 iIAInstaller->CancelOperation(); |
|
337 } |
|
338 IAUPDATE_TRACE("[IAUpdater] UserCancel() end"); |
|
339 } |
|
340 |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CIAUpdaterMngr::UserExit() |
|
344 // |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 void CIAUpdaterMngr::UserExit() |
|
348 { |
|
349 IAUPDATE_TRACE("[IAUpdater] UserExit() start"); |
|
350 if ( iIAInstaller ) |
|
351 { |
|
352 iIAInstaller->CancelOperation(); |
|
353 iUserExit = ETrue; |
|
354 } |
|
355 IAUPDATE_TRACE("[IAUpdater] UserExit() end"); |
|
356 } |
|
357 |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // CIAUpdaterMngr::ProcessSISFilesL() |
|
361 // |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 void CIAUpdaterMngr::ProcessSISFilesL( CIAUpdaterFileList& aList ) |
|
365 { |
|
366 IAUPDATE_TRACE("[IAUpdater] ProcessSISFilesL start"); |
|
367 |
|
368 TInt count( aList.FileInfos().Count() ); |
|
369 for ( TInt i = 0; i < count; ++i ) |
|
370 { |
|
371 CIAUpdaterFileInfo* info( aList.FileInfos()[ i ] ); |
|
372 const TDesC& sisFileName( info->FilePath() ); |
|
373 iIAInstaller->AddFileToInstallL( sisFileName ); |
|
374 } |
|
375 |
|
376 IAUPDATE_TRACE("[IAUpdater] ProcessSISFilesL end"); |
|
377 } |
|
378 |
|
379 |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // CIAUpdaterMngr::SetProcessParametersL |
|
383 // Set installation return parameters for IAD process. |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 void CIAUpdaterMngr::SetProcessParametersL( TInt aErr ) |
|
387 { |
|
388 IAUPDATE_TRACE_1("[IAUpdater] SetProcessParametersL start: %d", aErr); |
|
389 |
|
390 if ( aErr == KErrNone ) |
|
391 { |
|
392 IAUPDATE_TRACE("[IAUpdater] Installation was success"); |
|
393 // Because self update related item was successfully installed, |
|
394 // make sure that the IAD is closed. In certain cases, the |
|
395 // installer may not close the IAD. For example, if only |
|
396 // NCD Engine is updated but IAD is not, or, if original |
|
397 // IAD was in ROM but new update is installed into another |
|
398 // drive. |
|
399 CloseIADProcessesL(); |
|
400 |
|
401 // Check if the installed package should be thought as |
|
402 // an ecom plugin. The UID value is used for the checking. |
|
403 if ( IsEcomPlugin( iCurrentFileList->Identifier().Uid() ) ) |
|
404 { |
|
405 IAUPDATE_TRACE("[IAUpdater] ECOM plugin was installed."); |
|
406 iEcomPluginInstalled = ETrue; |
|
407 } |
|
408 } |
|
409 else |
|
410 { |
|
411 IAUPDATE_TRACE_1("[IAUpdater] SetProcessParametersL error: %d", aErr); |
|
412 // Set the error value to the member variable. |
|
413 // So, the manager will know, that it will not try to install |
|
414 // any other items after this. |
|
415 iInstallError = aErr; |
|
416 } |
|
417 |
|
418 CIAUpdaterResult* result( CIAUpdaterResult::NewLC() ); |
|
419 CIAUpdaterIdentifier& resultIdentifier( result->Identifier() ); |
|
420 CIAUpdaterIdentifier& currentIdentifier( iCurrentFileList->Identifier() ); |
|
421 resultIdentifier.SetIdL( currentIdentifier.Id() ); |
|
422 resultIdentifier.SetNamespaceL( currentIdentifier.Namespace() ); |
|
423 resultIdentifier.SetUid( currentIdentifier.Uid() ); |
|
424 result->SetErrorCode( aErr ); |
|
425 result->SetHidden( iCurrentFileList->Hidden() ); |
|
426 iResultsFile->Results().AppendL( result ); |
|
427 // Ownership of the result was transferred to the array. |
|
428 CleanupStack::Pop( result ); |
|
429 |
|
430 IAUPDATE_TRACE("[IAUpdater] SetProcessParametersL end"); |
|
431 } |
|
432 |
|
433 |
|
434 // ----------------------------------------------------------------------------- |
|
435 // CIAUpdaterMngr::StartIADProcessesL() |
|
436 // Start IAD process after installation. |
|
437 // ----------------------------------------------------------------------------- |
|
438 // |
|
439 void CIAUpdaterMngr::StartIADProcessesL() |
|
440 { |
|
441 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterMngr::StartIADProcessesL start"); |
|
442 // Apparc is not always up-to-date just after installation |
|
443 // To guarantee that just installed iaupdate.exe will be launched |
|
444 // it's checked that RApaLsSession is up-to-date before launching iupdatelancher.exe |
|
445 |
|
446 |
|
447 TFileName fullNameOfIaupdate; |
|
448 InstalledIAUpdateL( fullNameOfIaupdate ); |
|
449 |
|
450 RApaLsSession apa; |
|
451 User::LeaveIfError( apa.Connect() ); |
|
452 CleanupClosePushL(apa); |
|
453 |
|
454 TBool foundInApparc = EFalse; |
|
455 TApaAppInfo info; |
|
456 // trying with 0.5 seconds intervals max. 10 seconds. |
|
457 for( TInt i = 0; !foundInApparc && i < 21 ; i++) |
|
458 { |
|
459 if ( i > 0 ) |
|
460 { |
|
461 User::After( 500000 ); |
|
462 } |
|
463 User::LeaveIfError( apa.GetAppInfo( info, TUid::Uid( IAUpdaterDefs::KIADUpdateUid3 ) ) ); |
|
464 if ( info.iFullName.CompareF ( fullNameOfIaupdate ) == 0 ) |
|
465 { |
|
466 foundInApparc = ETrue; |
|
467 } |
|
468 } |
|
469 CleanupStack::PopAndDestroy( &apa ); |
|
470 |
|
471 RProcess process; |
|
472 User::LeaveIfError( |
|
473 process.Create( IAUpdaterDefs::KIAUpdateLauncherExe, KNullDesC ) ); |
|
474 process.Resume(); |
|
475 process.Close(); |
|
476 |
|
477 User::LeaveIfError( |
|
478 process.Create( IAUpdaterDefs::KIAUpdateBgCheckerExe, KNullDesC ) ); |
|
479 process.Resume(); |
|
480 process.Close(); |
|
481 |
|
482 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterMngr::StartIADProcessesL end"); |
|
483 } |
|
484 |
|
485 |
|
486 // ----------------------------------------------------------------------------- |
|
487 // CIAUpdaterMngr::CloseIADProcessesL() |
|
488 // Close IAD process after one successfull installation. |
|
489 // ----------------------------------------------------------------------------- |
|
490 // |
|
491 void CIAUpdaterMngr::CloseIADProcessesL() |
|
492 { |
|
493 IAUPDATE_TRACE("[IAUpdater] CloseIADProcessesL start"); |
|
494 |
|
495 //close background checker |
|
496 |
|
497 TBool continueScanning = ETrue; |
|
498 TFindProcess findProcess; |
|
499 // : add search pattern to optimizing |
|
500 TFullName fullName; |
|
501 while( continueScanning ) |
|
502 { |
|
503 if ( findProcess.Next( fullName ) == KErrNone ) |
|
504 { |
|
505 RProcess process; |
|
506 User::LeaveIfError( process.Open( findProcess ) ); |
|
507 TUid sid( process.SecureId() ); |
|
508 if ( sid == IAUpdaterDefs::KUidIABgChecker && process.ExitType() == EExitPending ) |
|
509 { |
|
510 process.Kill( KErrNone ); |
|
511 continueScanning = EFalse; |
|
512 } |
|
513 process.Close(); |
|
514 } |
|
515 else |
|
516 { |
|
517 continueScanning = EFalse; |
|
518 } |
|
519 } |
|
520 |
|
521 //close IAD launcher |
|
522 TInt wgId=0; |
|
523 CApaWindowGroupName* wgName = CApaWindowGroupName::NewL( iWsSession ); |
|
524 CleanupStack::PushL( wgName ); |
|
525 TUid launcherUid( TUid::Uid( IAUpdaterDefs::KIADUpdateLauncherUid3 ) ); |
|
526 CApaWindowGroupName::FindByAppUid( launcherUid, iWsSession, wgId ); |
|
527 if ( wgId != KErrNotFound ) |
|
528 { |
|
529 IAUPDATE_TRACE_1("[IAUpdater] IAD process found, wgId = %d", wgId ); |
|
530 wgName->ConstructFromWgIdL( wgId ); |
|
531 TApaTask task( iWsSession ); |
|
532 task.SetWgId( wgId ); |
|
533 RThread thread; |
|
534 User::LeaveIfError( thread.Open( task.ThreadId() ) ); |
|
535 CleanupClosePushL(thread); |
|
536 |
|
537 RProcess process; |
|
538 User::LeaveIfError( thread.Process( process ) ); |
|
539 CleanupClosePushL( process ); |
|
540 |
|
541 TRequestStatus processStatus; |
|
542 process.Logon( processStatus ); |
|
543 |
|
544 // IAD launcher application should response to shutdown event, so just wait for it |
|
545 task.SendSystemEvent( EApaSystemEventShutdown ); |
|
546 IAUPDATE_TRACE("[IAUpdater] Closing IAD launcher"); |
|
547 User::WaitForRequest( processStatus ); |
|
548 IAUPDATE_TRACE("[IAUpdater] IAD launcher closed"); |
|
549 CleanupStack::PopAndDestroy( &process ); |
|
550 CleanupStack::PopAndDestroy( &thread ); |
|
551 } |
|
552 CleanupStack::PopAndDestroy(wgName); |
|
553 wgName = NULL; |
|
554 |
|
555 //close all processes of IAD |
|
556 wgId=0; |
|
557 wgName = CApaWindowGroupName::NewL( iWsSession ); |
|
558 CleanupStack::PushL( wgName ); |
|
559 TUid iadUid( TUid::Uid( IAUpdaterDefs::KIADUpdateUid3 ) ); |
|
560 CApaWindowGroupName::FindByAppUid( iadUid, iWsSession, wgId ); |
|
561 while (wgId != KErrNotFound ) |
|
562 { |
|
563 IAUPDATE_TRACE_1("[IAUpdater] IAD process found, wgId = %d", wgId ); |
|
564 wgName->ConstructFromWgIdL( wgId ); |
|
565 TApaTask task( iWsSession ); |
|
566 task.SetWgId( wgId ); |
|
567 RThread thread; |
|
568 User::LeaveIfError( thread.Open( task.ThreadId() ) ); |
|
569 CleanupClosePushL(thread); |
|
570 |
|
571 RProcess process; |
|
572 User::LeaveIfError( thread.Process( process ) ); |
|
573 CleanupClosePushL( process ); |
|
574 |
|
575 TRequestStatus processStatus; |
|
576 process.Logon( processStatus ); |
|
577 |
|
578 // IAD application should response to shutdown event, so just wait for it |
|
579 task.SendSystemEvent( EApaSystemEventShutdown ); |
|
580 IAUPDATE_TRACE("[IAUpdater] Closing IAD"); |
|
581 User::WaitForRequest( processStatus ); |
|
582 IAUPDATE_TRACE("[IAUpdater] IAD closed"); |
|
583 CleanupStack::PopAndDestroy( &process ); |
|
584 CleanupStack::PopAndDestroy( &thread ); |
|
585 |
|
586 // See if there's still an instance of IAD running. |
|
587 CApaWindowGroupName::FindByAppUid( iadUid, iWsSession, wgId ); |
|
588 } |
|
589 CleanupStack::PopAndDestroy(wgName); |
|
590 |
|
591 IAUPDATE_TRACE("[IAUpdater] CloseIADProcessesL end"); |
|
592 } |
|
593 |
|
594 |
|
595 // ----------------------------------------------------------------------------- |
|
596 // CIAUpdaterMngr::EcomWaiter() |
|
597 // Wait until the ECOM has updated its index list. |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 void CIAUpdaterMngr::EcomWaiterL() const |
|
601 { |
|
602 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterMngr::EcomWaiter() begin"); |
|
603 |
|
604 const TTimeIntervalMicroSeconds32 KWaitTime( KMaxEcomWait ); |
|
605 |
|
606 REComSession& session( REComSession::OpenL() ); |
|
607 CleanupClosePushL( session ); |
|
608 |
|
609 IAUPDATE_TRACE("[IAUpdater] Create timer"); |
|
610 RTimer timer; |
|
611 CleanupClosePushL( timer ); |
|
612 timer.CreateLocal(); |
|
613 |
|
614 IAUPDATE_TRACE("[IAUpdater] Start timer"); |
|
615 TRequestStatus timerStatus( KErrNone ); |
|
616 timer.After( timerStatus, KWaitTime ); |
|
617 |
|
618 IAUPDATE_TRACE("[IAUpdater] Call notifier"); |
|
619 TRequestStatus ecomStatus( KErrNone ); |
|
620 session.NotifyOnChange( ecomStatus ); |
|
621 |
|
622 // Wait for the first request to complete |
|
623 IAUPDATE_TRACE("[IAUpdater] Wait first"); |
|
624 User::WaitForRequest( ecomStatus, timerStatus ); |
|
625 |
|
626 IAUPDATE_TRACE_2("[IAUpdater] Continue after waitforrequest: %d, %d", |
|
627 ecomStatus.Int(), timerStatus.Int()); |
|
628 |
|
629 // These are synchronous operations. |
|
630 // So, no need to use WaitForRequest after these. |
|
631 // It does not hurt to call cancel to completed operation. |
|
632 // So, no need to check which one was completed. |
|
633 session.CancelNotifyOnChange( ecomStatus ); |
|
634 timer.Cancel(); |
|
635 |
|
636 // Notice, that in this debug text another status should always imply |
|
637 // that cancel operation is done. And, another will give the result of the |
|
638 // completed operation. |
|
639 IAUPDATE_TRACE_2("[IAUpdater] Continue after second waitforrequest: %d, %d", |
|
640 ecomStatus.Int(), timerStatus.Int()); |
|
641 |
|
642 CleanupStack::PopAndDestroy( &timer ); |
|
643 CleanupStack::PopAndDestroy( &session ); |
|
644 |
|
645 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterMngr::EcomWaiter() end"); |
|
646 } |
|
647 |
|
648 |
|
649 // ----------------------------------------------------------------------------- |
|
650 // CIAUpdaterMngr::IsEcomPlugin() |
|
651 // Compares the given UID to the known ECOM plug-in installation package UIDs. |
|
652 // ----------------------------------------------------------------------------- |
|
653 // |
|
654 TBool CIAUpdaterMngr::IsEcomPlugin( const TUid& aUid ) const |
|
655 { |
|
656 IAUPDATE_TRACE_1("[IAUpdater] CIAUpdaterMngr::IsEcomPlugin() begin: %d", |
|
657 aUid.iUid); |
|
658 |
|
659 TBool isEcomPlugin( EFalse ); |
|
660 |
|
661 switch ( aUid.iUid ) |
|
662 { |
|
663 // Part of these NCD UIDs are not exactly ECOM plugins themselves |
|
664 // but they are most likely part of the package that contains |
|
665 // a plugin. So, if any of these matches. Then just think |
|
666 // the package as ECOM plugin. |
|
667 case KCatalogsServerUid: |
|
668 case KNcdProviderUid: |
|
669 case KCatalogsEngineUid: |
|
670 case KCatalogsEngineInterfaceUid: |
|
671 case KCatalogsEngineImplementationUid: |
|
672 IAUPDATE_TRACE("[IAUpdater] ECOM plugin."); |
|
673 isEcomPlugin = ETrue; |
|
674 break; |
|
675 |
|
676 default: |
|
677 IAUPDATE_TRACE("[IAUpdater] Not ECOM plugin."); |
|
678 break; |
|
679 } |
|
680 |
|
681 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterMngr::IsEcomPlugin() end"); |
|
682 |
|
683 return isEcomPlugin; |
|
684 } |
|
685 |
|
686 // ----------------------------------------------------------------------------- |
|
687 // CIAUpdaterMngr::InstalledIAUpdateL |
|
688 // |
|
689 // ----------------------------------------------------------------------------- |
|
690 // |
|
691 void CIAUpdaterMngr::InstalledIAUpdateL( TFileName& aFullName ) const |
|
692 { |
|
693 Swi::RSisRegistrySession registrySession; |
|
694 Swi::RSisRegistryEntry entry; |
|
695 User::LeaveIfError( registrySession.Connect() ); |
|
696 CleanupClosePushL( registrySession ); |
|
697 TInt exeFound = EFalse; |
|
698 if ( entry.Open( registrySession, TUid::Uid( IAUpdaterDefs::KIADUpdateUid3 ) ) == KErrNone ) |
|
699 { |
|
700 CleanupClosePushL( entry ); |
|
701 RPointerArray<HBufC> files; |
|
702 entry.FilesL( files ); |
|
703 for( TInt i = 0; !exeFound && i < files.Count(); i++) |
|
704 { |
|
705 TFileName fullName = *files[i]; |
|
706 TParse parse; |
|
707 parse.Set( fullName, NULL, NULL); |
|
708 if ( parse.NameAndExt().CompareF( IAUpdaterDefs::KIAUpdateExe() ) == 0 ) |
|
709 { |
|
710 aFullName = fullName; |
|
711 exeFound = ETrue; |
|
712 } |
|
713 } |
|
714 files.ResetAndDestroy(); |
|
715 CleanupStack::PopAndDestroy( &entry ); |
|
716 } |
|
717 CleanupStack::PopAndDestroy( ®istrySession ); |
|
718 } |
|
719 |
|
720 //EOF |