13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 #include <usif/scr/scr.h> |
|
19 #include <usif/scr/scrcommon.h> |
|
20 #include <usif/scr/screntries.h> |
|
21 #include <apgcli.h> // RApaSession |
|
22 #include <apgupdate.h> // TApaAppUpdateInfo |
|
23 |
18 #include "daemonbehaviour.h" |
24 #include "daemonbehaviour.h" |
19 #include "swispubsubdefs.h" |
25 #include "swispubsubdefs.h" |
20 #include "recsisx.h" |
26 #include "recsisx.h" |
21 #include "sisregistrywritablesession.h" |
27 #include "sisregistrywritablesession.h" |
22 #include "SWInstDebug.h" |
28 #include "SWInstDebug.h" |
23 #include "sisregistryentry.h" |
29 #include "sisregistryentry.h" |
24 |
30 |
25 |
31 using namespace Swi; |
26 namespace Swi |
32 |
27 { |
33 // ----------------------------------------------------------------------- |
|
34 // CDaemonBehaviour::NewL |
|
35 // ----------------------------------------------------------------------- |
|
36 // |
|
37 CDaemonBehaviour* CDaemonBehaviour::NewL( CProgramStatus& aMainStatus ) |
|
38 { |
|
39 CDaemonBehaviour* self = NewLC( aMainStatus ); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------- |
|
45 // CDaemonBehaviour::NewLC |
|
46 // ----------------------------------------------------------------------- |
|
47 // |
|
48 CDaemonBehaviour* CDaemonBehaviour::NewLC( CProgramStatus& aMainStatus ) |
|
49 { |
|
50 CDaemonBehaviour* self = new (ELeave) CDaemonBehaviour; |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL( aMainStatus ); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------- |
|
57 // CDaemonBehaviour::ConstructL |
|
58 // ----------------------------------------------------------------------- |
|
59 // |
|
60 void CDaemonBehaviour::ConstructL( CProgramStatus& aMainStatus ) |
|
61 { |
|
62 User::LeaveIfError(iFs.Connect()); |
|
63 User::LeaveIfError(iFs.ShareProtected()); |
|
64 |
28 // For uninstaller |
65 // For uninstaller |
29 CDaemonBehaviour* CDaemonBehaviour::NewL( CProgramStatus& aMainStatus ) |
66 iSisInstaller = CSisInstaller::NewL( this, aMainStatus ); |
30 { |
67 // Create plugin |
31 CDaemonBehaviour* self = NewLC( aMainStatus ); |
68 TRAP_IGNORE( iSwiDaemonPlugin = CSwiDaemonPlugin::NewL() ); |
32 CleanupStack::Pop(self); |
69 } |
33 return self; |
70 |
|
71 // ----------------------------------------------------------------------- |
|
72 // CDaemonBehaviour::~CDaemonBehaviour |
|
73 // ----------------------------------------------------------------------- |
|
74 // |
|
75 CDaemonBehaviour::~CDaemonBehaviour() |
|
76 { |
|
77 if ( iSwiDaemonPlugin ) |
|
78 { |
|
79 delete iSwiDaemonPlugin; |
|
80 REComSession::FinalClose(); |
|
81 } |
|
82 delete iSisInstaller; |
|
83 iSisInstaller = NULL; |
|
84 iFs.Close(); |
|
85 iDriveArray.Close(); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------- |
|
89 // CDaemonBehaviour::StartupL |
|
90 // ----------------------------------------------------------------------- |
|
91 // |
|
92 TBool CDaemonBehaviour::StartupL() |
|
93 { |
|
94 // Return state of Startup |
|
95 return ETrue; |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------- |
|
99 // CDaemonBehaviour::MediaChangeL |
|
100 // ----------------------------------------------------------------------- |
|
101 // |
|
102 void CDaemonBehaviour::MediaChangeL(TInt aDrive, TChangeType aChangeType) |
|
103 { |
|
104 FLOG_1( _L("Daemon: MediaChangeL: Media change %d"), aDrive ); |
|
105 RSisRegistryWritableSession registrySession; |
|
106 |
|
107 User::LeaveIfError( registrySession.Connect() ); |
|
108 CleanupClosePushL( registrySession ); |
|
109 |
|
110 |
|
111 if ( aChangeType==EMediaInserted ) |
|
112 { |
|
113 FLOG( _L("Daemon: MediaChangeL: Media inserted") ); |
|
114 TInt err = KErrNone; |
|
115 // Notify SCR and AppArc for media change. |
|
116 TRAP( err, UpdateComponentStatusL( aChangeType, aDrive ) ); |
|
117 FLOG_1( _L("Daemon: UpdateComponentStatusL err = %d"), err ); |
|
118 |
|
119 // We need call sis registry since this call will |
|
120 // activate sis registry to clean uninstalled components |
|
121 // from inserted media. |
|
122 registrySession.AddDriveL( aDrive ); |
|
123 |
|
124 // Scan directory on the card and run pre-installed through SWIS |
|
125 FLOG( _L("Daemon: MediaChangeL: Process preinstalled files") ); |
|
126 ProcessPreinstalledFilesL( aDrive ); |
|
127 FLOG_1( _L("Daemon: MediaChangeL: StartInstalling drive: %d"), aDrive ); |
|
128 iSisInstaller->StartInstallingL(); |
|
129 |
|
130 // Add inserted media drive to drive array. |
|
131 if ( iDriveArray.Find(aDrive) == KErrNotFound ) |
|
132 { |
|
133 iDriveArray.AppendL(aDrive); |
|
134 } |
34 } |
135 } |
35 |
136 else if (aChangeType==EMediaRemoved) |
36 CDaemonBehaviour* CDaemonBehaviour::NewLC( CProgramStatus& aMainStatus ) |
137 { |
37 { |
138 FLOG( _L("Daemon: MediaChangeL: Media removed") ); |
38 CDaemonBehaviour* self = new (ELeave) CDaemonBehaviour; |
139 TInt err = KErrNone; |
39 CleanupStack::PushL(self); |
140 // Notify SCR and AppArc for media change. |
40 self->ConstructL( aMainStatus ); |
141 TRAP( err, UpdateComponentStatusL( aChangeType, aDrive ) ); |
41 return self; |
142 FLOG_1( _L("Daemon: UpdateComponentStatusL err = %d"), err ); |
|
143 |
|
144 // Get Installer state. |
|
145 TBool installerRunning = iSisInstaller->IsInstalling(); |
|
146 FLOG_1( _L("Daemon: MediaChangeL: IsInstalling = %d"), installerRunning ); |
|
147 |
|
148 FLOG( _L("Daemon: MediaChangeL: Cancel install process") ); |
|
149 // Cancel all requests for install |
|
150 iSisInstaller->Cancel(); |
|
151 |
|
152 // Notify plugin |
|
153 if( iSwiDaemonPlugin ) |
|
154 { |
|
155 TInt index = iDriveArray.Find(aDrive); |
|
156 iSwiDaemonPlugin->MediaRemoved(index); |
|
157 } |
|
158 |
|
159 // Get index of removed drive from array |
|
160 TInt index = iDriveArray.Find(aDrive); |
|
161 |
|
162 if ( index > KErrNotFound ) |
|
163 { |
|
164 iDriveArray.Remove(index); |
|
165 iDriveArray.Compress(); |
|
166 } |
|
167 |
|
168 // Continue installing from other drives if needed. |
|
169 if ( installerRunning ) |
|
170 { |
|
171 FLOG( _L("Daemon: MediaChangeL: Continue installing other drives") ); |
|
172 // Get count of inserted drives. |
|
173 TInt count = iDriveArray.Count(); |
|
174 FLOG_1( _L("Daemon: Drive count = %d"), count ); |
|
175 if ( count ) |
|
176 { |
|
177 // Find packages for other drives. |
|
178 for(index = 0; index < count; index++ ) |
|
179 { |
|
180 ProcessPreinstalledFilesL(iDriveArray[index]); |
|
181 } |
|
182 // Start installing. |
|
183 FLOG( _L("Daemon: MediaChangeL: StartInstallingL") ); |
|
184 iSisInstaller->StartInstallingL(); |
|
185 } |
|
186 } |
42 } |
187 } |
43 |
188 |
44 void CDaemonBehaviour::ConstructL( CProgramStatus& aMainStatus ) |
189 CleanupStack::PopAndDestroy(®istrySession); |
45 { |
190 } |
46 User::LeaveIfError(iFs.Connect()); |
191 |
47 User::LeaveIfError(iFs.ShareProtected()); |
192 // ----------------------------------------------------------------------- |
|
193 // CDaemonBehaviour::ProcessPreinstalledFilesL |
|
194 // ----------------------------------------------------------------------- |
|
195 // |
|
196 void CDaemonBehaviour::ProcessPreinstalledFilesL(TInt aDrive) |
|
197 { |
|
198 FLOG_1( _L("Daemon: ProcessPreinstalledFilesL: Drive index: %d"), |
|
199 aDrive ); |
|
200 _LIT( KDaemonPrivatePath,":\\private\\10202dce\\" ); |
|
201 |
|
202 // For uninstaller |
|
203 // Set on installing mode. |
|
204 iGeneralProcessStatus = EStateInstalling; |
|
205 FLOG_1( _L("[CDaemonBehaviour] iGeneralProcessStatus = %d"), |
|
206 iGeneralProcessStatus ); |
|
207 |
|
208 ProcessPreinstalledFilesL(aDrive, KDaemonPrivatePath); |
|
209 iStartNotified = EFalse; |
|
210 iDrive = aDrive; |
|
211 FLOG( _L("Daemon: ProcessPreInstalledFilesL END") ); |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------- |
|
215 // CDaemonBehaviour::ProcessPreinstalledFilesL |
|
216 // ----------------------------------------------------------------------- |
|
217 // |
|
218 void CDaemonBehaviour::ProcessPreinstalledFilesL(TInt aDrive, const TDesC& aDirectory) |
|
219 { |
|
220 TPath preInstalledPath; |
|
221 TChar drive; |
|
222 RFs::DriveToChar(aDrive, drive); |
|
223 preInstalledPath.Append(drive); |
|
224 preInstalledPath.Append(aDirectory); |
|
225 |
|
226 FLOG_1( _L("Daemon: ProcessPreInstalledFilesL Getting dir %S"), &preInstalledPath ); |
|
227 CDir* dir = NULL; |
|
228 TInt err = iFs.GetDir( preInstalledPath, KEntryAttNormal, ESortNone, dir ); |
|
229 if ( err != KErrNone && err != KErrPathNotFound ) |
|
230 { |
|
231 FLOG_1( _L("Daemon: ProcessPreInstalledFilesL GetDir with error %d"), err ); |
|
232 User::Leave(err); |
|
233 } |
|
234 if(dir) |
|
235 { |
|
236 // dir will only exist if GetDir succeeded |
|
237 CleanupStack::PushL(dir); |
|
238 for(TInt i = 0; i < dir->Count(); i++) |
|
239 { |
|
240 const TEntry &entry = (*dir)[i]; |
|
241 if(!entry.IsDir()) |
|
242 { |
|
243 TFileName fileName(preInstalledPath); |
|
244 fileName.Append(entry.iName); |
|
245 // Add files to sis installer. |
|
246 iSisInstaller->AddFileToInstallL(fileName); |
|
247 } |
|
248 } |
|
249 CleanupStack::PopAndDestroy(dir); |
|
250 } |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------- |
|
254 // CDaemonBehaviour::GetProcessStatus |
|
255 // ----------------------------------------------------------------------- |
|
256 // |
|
257 TInt& CDaemonBehaviour::GetProcessStatus() |
|
258 { |
|
259 return iGeneralProcessStatus; |
|
260 } |
|
261 |
|
262 // ----------------------------------------------------------------------- |
|
263 // CDaemonBehaviour::SetProcessStatus |
|
264 // ----------------------------------------------------------------------- |
|
265 // |
|
266 void CDaemonBehaviour::SetProcessStatus( TInt aStatus ) |
|
267 { |
|
268 iGeneralProcessStatus = aStatus; |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------- |
|
272 // CDaemonBehaviour::DoNotifyMediaProcessingComplete |
|
273 // ----------------------------------------------------------------------- |
|
274 // |
|
275 void CDaemonBehaviour::DoNotifyMediaProcessingComplete() |
|
276 { |
|
277 if ( iSwiDaemonPlugin && iStartNotified ) |
|
278 { |
|
279 iSwiDaemonPlugin->MediaProcessingComplete(); |
|
280 } |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------- |
|
284 // CDaemonBehaviour::IsPlugin |
|
285 // ----------------------------------------------------------------------- |
|
286 // |
|
287 // For plugin support |
|
288 TBool CDaemonBehaviour::IsPlugin() |
|
289 { |
|
290 if ( iSwiDaemonPlugin ) |
|
291 { |
|
292 return ETrue; |
|
293 } |
|
294 return EFalse; |
|
295 } |
|
296 |
|
297 // ----------------------------------------------------------------------- |
|
298 // CDaemonBehaviour::NotifyPlugin |
|
299 // ----------------------------------------------------------------------- |
|
300 // |
|
301 // For plugin support |
|
302 void CDaemonBehaviour::NotifyPlugin() |
|
303 { |
|
304 FLOG( _L("Daemon: NotifyPlugin")); |
|
305 if ( !iStartNotified ) |
|
306 { |
|
307 FLOG_1( _L("Daemon: MediaProcessingStart for drive = %d"), iDrive ); |
|
308 iSwiDaemonPlugin->MediaProcessingStart( iDrive ); |
|
309 iStartNotified = ETrue; |
|
310 } |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------- |
|
314 // CDaemonBehaviour::RequestPluginInstall |
|
315 // ----------------------------------------------------------------------- |
|
316 // |
|
317 void CDaemonBehaviour::RequestPluginInstall( TDesC& aSisFile ) |
|
318 { |
|
319 // Note We will open file in here but that is only because |
|
320 // plug-in interface has been designed this way. Original |
|
321 // Symbian SWI daemon did use RApaLsSession for installing |
|
322 // and thus RFile was open already. |
|
323 // Since current SWI Daemon does use SWI API it doesn't |
|
324 // open files and thus we need to open the file in here. |
|
325 FLOG( _L("Daemon: RequestPluginInstall ")); |
|
326 |
|
327 RFile file; |
|
328 User::LeaveIfError( file.Open( |
|
329 iFs, aSisFile, EFileRead | EFileShareReadersOnly ) ); |
|
330 CleanupClosePushL( file ); |
|
331 |
|
332 iSwiDaemonPlugin->RequestInstall( file ); |
|
333 |
|
334 // close file, original SWI Daemon do not leave file open. |
|
335 CleanupStack::PopAndDestroy( &file ); |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------- |
|
339 // CDaemonBehaviour::UpdateComponentStatusL |
|
340 // ----------------------------------------------------------------------- |
|
341 // |
|
342 void CDaemonBehaviour::UpdateComponentStatusL( TChangeType aChangeType, |
|
343 TInt aDrive ) |
|
344 { |
|
345 FLOG( _L("Daemon: UpdateComponentStatus") ); |
|
346 |
|
347 Usif::RSoftwareComponentRegistry scrServer; |
|
348 User::LeaveIfError( scrServer.Connect() ); |
|
349 CleanupClosePushL( scrServer ); |
|
350 |
|
351 // Filter all other component types except sisx. |
|
352 Usif::CComponentFilter* filter = Usif::CComponentFilter::NewLC(); |
|
353 filter->SetSoftwareTypeL( Usif::KSoftwareTypeNative ); |
48 |
354 |
49 // For uninstaller |
355 RArray<Usif::TComponentId> componentIdList; |
50 iSisInstaller = CSisInstaller::NewL( this, aMainStatus ); |
356 CleanupClosePushL( componentIdList ); |
51 // Create plugin |
357 |
52 TRAP_IGNORE( iSwiDaemonPlugin = CSwiDaemonPlugin::NewL() ); |
358 // Get list of all native (sisx) installed packages. |
53 } |
359 scrServer.GetComponentIdsL( componentIdList, filter ); |
54 |
360 FLOG_1( _L("Daemon: componentIdList count: %d"),componentIdList.Count() ); |
55 CDaemonBehaviour::~CDaemonBehaviour() |
361 |
56 { |
362 if ( componentIdList.Count() ) |
57 if ( iSwiDaemonPlugin ) |
363 { |
58 { |
364 RArray<TApaAppUpdateInfo> appInfoArray; |
59 delete iSwiDaemonPlugin; |
365 CleanupClosePushL( appInfoArray ); |
60 REComSession::FinalClose(); |
366 FLOG_1( _L("Daemon: target drive: %d"), aDrive ); |
61 } |
367 |
62 delete iSisInstaller; |
368 #ifdef _DEBUG |
63 iSisInstaller = NULL; |
369 TChar targetDrive; |
64 iFs.Close(); |
370 iFs.DriveToChar( aDrive, targetDrive ); |
|
371 HBufC* tarceBuf = HBufC::NewL( 16 ); |
|
372 TPtr bufPtr = tarceBuf->Des(); |
|
373 bufPtr.Append( targetDrive ); |
|
374 FLOG_1( _L("Daemon: target drive: %S"), &bufPtr ); |
|
375 delete tarceBuf; |
|
376 #endif |
|
377 |
|
378 FLOG( _L("Daemon: Check all SCR native components") ); |
|
379 // Check all components in SCR. If media is removed/inserted |
|
380 // change status flag in SCR and in AppArc. |
|
381 for ( TInt index=0; index < componentIdList.Count(); index++ ) |
|
382 { |
|
383 Usif::TComponentId componentId( componentIdList[index] ); |
|
384 FLOG_1( _L("Daemon: componentId: %d"), componentId ); |
|
385 |
|
386 // Check that package is not in ROM. If package is in rom |
|
387 // it can not be removed/not present. |
|
388 TBool inRom = scrServer.IsComponentOnReadOnlyDriveL( componentId ); |
|
389 FLOG_1( _L("Daemon: IsComponentOnReadOnlyDriveL: %d"), inRom ); |
|
390 |
|
391 if ( !inRom ) |
|
392 { |
|
393 UpdateStatusL( scrServer, |
|
394 componentId, |
|
395 aChangeType, |
|
396 aDrive, |
|
397 appInfoArray ); |
|
398 } |
|
399 } // for loop |
|
400 |
|
401 FLOG_1( _L("Daemon: appInfoArray.Count = %d"), appInfoArray.Count() ); |
|
402 // Check do we have updated some application info. |
|
403 if ( appInfoArray.Count() ) |
|
404 { |
|
405 // Update AppArc list after we have all application |
|
406 // uids/status in array. |
|
407 FLOG( _L("Daemon: Update AppArc") ); |
|
408 RApaLsSession appArcSession; |
|
409 TInt err = appArcSession.Connect(); |
|
410 FLOG_1( _L("Daemon: appArcSession.Connect err = %d"), err ); |
|
411 if ( !err ) |
|
412 { |
|
413 CleanupClosePushL( appArcSession ); |
|
414 FLOG( _L("Daemon: UpdateAppListL") ); |
|
415 appArcSession.UpdateAppListL( appInfoArray ); |
|
416 CleanupStack::PopAndDestroy(); // appArcSession |
|
417 } |
|
418 } |
|
419 CleanupStack::PopAndDestroy( &appInfoArray ); |
|
420 } // if componentList.Count() |
|
421 |
|
422 CleanupStack::PopAndDestroy( &componentIdList ); //componentIDList.Close(); |
|
423 CleanupStack::PopAndDestroy( filter ); |
|
424 CleanupStack::PopAndDestroy( &scrServer ); |
|
425 FLOG( _L("Daemon: UpdateComponentStatus END") ); |
|
426 } |
|
427 |
|
428 // ----------------------------------------------------------------------- |
|
429 // CDaemonBehaviour::UpdateStatusL |
|
430 // ----------------------------------------------------------------------- |
|
431 // |
|
432 void CDaemonBehaviour::UpdateStatusL( |
|
433 Usif::RSoftwareComponentRegistry& aScrServer, |
|
434 Usif::TComponentId aComponentId, |
|
435 TChangeType aChangeType, |
|
436 TInt aTargetDrive, |
|
437 RArray<TApaAppUpdateInfo>& aAppInfoArray ) |
|
438 { |
|
439 FLOG( _L("Daemon: CDaemonBehaviour::UpdateStatusL start") ); |
|
440 |
|
441 Usif::CComponentEntry* entry = Usif::CComponentEntry::NewL(); |
|
442 CleanupStack::PushL( entry ); |
|
443 |
|
444 TInt err = KErrNone; |
|
445 TRAP( err, aScrServer.GetComponentL( aComponentId, |
|
446 *entry, |
|
447 Usif::KUnspecifiedLocale ) ); |
|
448 FLOG_1( _L("Daemon: GetComponentL TRAP err = %d"), err ); |
|
449 |
|
450 // If we get error let's not stop the loop. |
|
451 if ( !err ) |
|
452 { |
|
453 TBool isInTargetDrive = EFalse; |
|
454 // Get all component drives. |
|
455 TDriveList driveList; |
|
456 driveList = entry->InstalledDrives(); |
|
457 |
|
458 FLOG( _L("Daemon: Check all drives for this component") ); |
|
459 // Go through all drives which have files for this component. |
|
460 for ( TInt i = 0; i < KMaxDrives; i++ ) |
|
461 { |
|
462 if ( driveList[i] != 0 ) |
|
463 { |
|
464 FLOG_1( _L("Daemon: Found drive: %d"), i ); |
65 |
465 |
66 #ifdef RD_MULTIPLE_DRIVE |
466 if ( aTargetDrive == i ) |
67 iDriveArray.Close(); |
|
68 #endif |
|
69 } |
|
70 |
|
71 // from MDaemonBehaviour |
|
72 TBool CDaemonBehaviour::StartupL() |
|
73 { |
|
74 // Return state of Startup |
|
75 return ETrue; |
|
76 } |
|
77 |
|
78 void CDaemonBehaviour::MediaChangeL(TInt aDrive, TChangeType aChangeType) |
|
79 { |
|
80 FLOG_1( _L("Daemon: Media change %d"), aDrive ); |
|
81 RSisRegistryWritableSession registrySession; |
|
82 |
|
83 User::LeaveIfError(registrySession.Connect()); |
|
84 CleanupClosePushL(registrySession); |
|
85 |
|
86 if (aChangeType==EMediaInserted) |
|
87 { |
|
88 FLOG( _L("Daemon: Media inserted") ); |
|
89 FLOG( _L("Daemon: Media change: Update sis registry") ); |
|
90 // notify IAR |
|
91 // Error ou1cimx1#212652 |
|
92 // Note SWI Daemon needs to notify sis registry from |
|
93 // media change. Otherwice registry is not updated |
|
94 // and e.g. IsPresentL function will give false results. |
|
95 // Note also that this function should be called before |
|
96 // ProcessPreinstalledFilesL in SWI Daemon. |
|
97 registrySession.AddDriveL(aDrive); |
|
98 |
|
99 // Scan directory on the card and run pre-installed through SWIS |
|
100 FLOG( _L("Daemon: Media change: Process preinstalled files") ); |
|
101 ProcessPreinstalledFilesL(aDrive); |
|
102 |
|
103 #ifdef RD_MULTIPLE_DRIVE |
|
104 // Add inserted media drive to drive array. |
|
105 if ( iDriveArray.Find(aDrive) == KErrNotFound ) |
|
106 { |
|
107 iDriveArray.AppendL(aDrive); |
|
108 } |
|
109 #endif |
|
110 } |
|
111 else if (aChangeType==EMediaRemoved) |
|
112 { |
|
113 FLOG( _L("Daemon: Media removed") ); |
|
114 |
|
115 #ifdef RD_MULTIPLE_DRIVE |
|
116 // Get Installer state. |
|
117 TBool installerRunning = iSisInstaller->IsInstalling(); |
|
118 #endif |
|
119 |
|
120 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
121 // notify IAR |
|
122 // Note SWI Daemon need to notify sis registry from |
|
123 // media change. |
|
124 registrySession.RemoveDriveL(aDrive); |
|
125 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
126 |
|
127 // Cancel all requests for install |
|
128 iSisInstaller->Cancel(); |
|
129 |
|
130 #ifdef RD_MULTIPLE_DRIVE |
|
131 // Notify plugin |
|
132 if(iSwiDaemonPlugin) |
|
133 { |
|
134 TInt index = iDriveArray.Find(aDrive); |
|
135 iSwiDaemonPlugin->MediaRemoved(index); |
|
136 } |
|
137 #else |
|
138 // Notify plugin |
|
139 if(iSwiDaemonPlugin) |
|
140 { |
|
141 iSwiDaemonPlugin->MediaRemoved(aDrive); |
|
142 } |
|
143 #endif //RD_MULTIPLE_DRIVE |
|
144 |
|
145 #ifdef RD_MULTIPLE_DRIVE |
|
146 // Get index of removed drive from array |
|
147 TInt index = iDriveArray.Find(aDrive); |
|
148 |
|
149 if ( index > KErrNotFound ) |
|
150 { |
|
151 iDriveArray.Remove(index); |
|
152 iDriveArray.Compress(); |
|
153 } |
|
154 |
|
155 // Continue installing from other drives if needed. |
|
156 if ( installerRunning ) |
|
157 { |
|
158 // Get count of inserted drives. |
|
159 TInt count = iDriveArray.Count(); |
|
160 |
|
161 if ( count ) |
|
162 { |
|
163 for(index = 0; index < count; index++ ) |
|
164 { |
|
165 ProcessPreinstalledFilesL(iDriveArray[index]); |
|
166 iSisInstaller->StartInstallingL(); |
|
167 } |
|
168 } |
|
169 } |
|
170 #endif |
|
171 } |
|
172 |
|
173 CleanupStack::PopAndDestroy(®istrySession); |
|
174 } |
|
175 |
|
176 void CDaemonBehaviour::ProcessPreinstalledFilesL(TInt aDrive) |
|
177 { |
|
178 _LIT(KDaemonPrivatePath,":\\private\\10202dce\\"); |
|
179 |
|
180 #ifndef RD_MULTIPLE_DRIVE |
|
181 iSisInstaller->Cancel(); |
|
182 #endif |
|
183 // For uninstaller |
|
184 // Set on installing mode. |
|
185 iGeneralProcessStatus = EStateInstalling; |
|
186 FLOG_1( _L("[CDaemonBehaviour] iGeneralProcessStatus = %d"), |
|
187 iGeneralProcessStatus ); |
|
188 |
|
189 ProcessPreinstalledFilesL(aDrive, KDaemonPrivatePath); |
|
190 iStartNotified = EFalse; |
|
191 iDrive = aDrive; |
|
192 iSisInstaller->StartInstallingL(); |
|
193 } |
|
194 |
|
195 void CDaemonBehaviour::ProcessPreinstalledFilesL(TInt aDrive, const TDesC& aDirectory) |
|
196 { |
|
197 FLOG( _L("Daemon: ProcessPreInstalledFilesL") ); |
|
198 TPath preInstalledPath; |
|
199 TChar drive; |
|
200 RFs::DriveToChar(aDrive, drive); |
|
201 preInstalledPath.Append(drive); |
|
202 preInstalledPath.Append(aDirectory); |
|
203 |
|
204 FLOG_1( _L("Daemon: ProcessPreInstalledFilesL Getting dir %S"), &preInstalledPath ); |
|
205 CDir* dir = NULL; |
|
206 TInt err = iFs.GetDir(preInstalledPath, KEntryAttNormal, ESortNone, dir); |
|
207 if (err != KErrNone && err != KErrPathNotFound) |
|
208 { |
|
209 FLOG_1( _L("Daemon: ProcessPreInstalledFilesL GetDir with error %d"), err ); |
|
210 User::Leave(err); |
|
211 } |
|
212 if(dir) |
|
213 { |
|
214 // dir will only exist if GetDir succeeded |
|
215 CleanupStack::PushL(dir); |
|
216 for(TInt i = 0; i < dir->Count(); i++) |
|
217 { |
|
218 const TEntry &entry = (*dir)[i]; |
|
219 if(!entry.IsDir()) |
|
220 { |
467 { |
221 TFileName fileName(preInstalledPath); |
468 // Ok we have files in this target drive. |
222 fileName.Append(entry.iName); |
469 isInTargetDrive = ETrue; |
223 iSisInstaller->AddFileToInstallL(fileName); |
470 FLOG( _L("Daemon: Component has files in target drive") ); |
224 } |
471 } |
225 } |
472 } |
226 CleanupStack::PopAndDestroy(dir); |
473 } // for |
227 } |
474 |
228 } |
475 // Check if component or part of it is in the media. |
229 |
476 if ( isInTargetDrive ) |
230 // For uninstaller |
|
231 TInt& CDaemonBehaviour::GetProcessStatus() |
|
232 { |
|
233 return iGeneralProcessStatus; |
|
234 } |
|
235 |
|
236 // For uninstaller |
|
237 void CDaemonBehaviour::SetProcessStatus( TInt aStatus ) |
|
238 { |
|
239 iGeneralProcessStatus = aStatus; |
|
240 } |
|
241 |
|
242 // For plugin support |
|
243 void CDaemonBehaviour::DoNotifyMediaProcessingComplete() |
|
244 { |
|
245 if ( iSwiDaemonPlugin && iStartNotified ) |
|
246 { |
477 { |
247 iSwiDaemonPlugin->MediaProcessingComplete(); |
478 // We need to update applications status to AppArc when |
248 } |
479 // there is some media change. AppArc needs application |
249 } |
480 // UID (not package UID) so we need to get all app. UIDs |
250 |
481 // from the package and set them to present or not present. |
251 // For plugin support |
482 |
252 TBool CDaemonBehaviour::IsPlugin() |
483 FLOG( _L("Daemon: Create application status for AppArc") ); |
253 { |
484 FLOG( _L("Daemon: Get applications UIDs from SCR") ); |
254 if ( iSwiDaemonPlugin ) |
485 RArray<TUid> appUidArray; |
255 { |
486 CleanupClosePushL( appUidArray ); |
256 return ETrue; |
487 |
257 } |
488 TRAP( err, aScrServer.GetAppUidsForComponentL( aComponentId, appUidArray ) ); |
258 return EFalse; |
489 FLOG_1( _L("Daemon: GetAppUidsForComponentL TRAP err = %d"), err ); |
259 } |
490 FLOG_1( _L("Daemon: UID array count = %d"), appUidArray.Count() ); |
260 |
491 |
261 // For plugin support |
492 for (TInt index = 0; index < appUidArray.Count(); index++) |
262 void CDaemonBehaviour::NotifyPlugin() |
493 { |
263 { |
494 FLOG_1( _L("Daemon: Add app UID = 0x%x"), |
264 FLOG( _L("Daemon: NotifyPlugin")); |
495 appUidArray[index].iUid ); |
265 if ( !iStartNotified ) |
|
266 { |
|
267 FLOG_1( _L("Daemon: MediaProcessingStart for drive = %d"), iDrive ); |
|
268 iSwiDaemonPlugin->MediaProcessingStart( iDrive ); |
|
269 iStartNotified = ETrue; |
|
270 } |
|
271 } |
|
272 |
|
273 // For plugin support |
|
274 void CDaemonBehaviour::RequestPluginInstall( TDesC& aSisFile ) |
|
275 { |
|
276 // Note We will open file in here but that is only because |
|
277 // plug-in interface has been designed this way. Original |
|
278 // Symbian SWI daemon did use RApaLsSession for installing |
|
279 // and thus RFile was open already. |
|
280 // Since current SWI Daemon does use SWI API it doesn't |
|
281 // open files and thus we need to open the file in here. |
|
282 FLOG( _L("Daemon: RequestPluginInstall ")); |
|
283 |
496 |
284 RFile file; |
497 TApaAppUpdateInfo appInfo; |
285 User::LeaveIfError( file.Open( |
498 appInfo.iAppUid = appUidArray[index]; |
286 iFs, aSisFile, EFileRead | EFileShareReadersOnly ) ); |
499 |
287 CleanupClosePushL( file ); |
500 if ( aChangeType == EMediaInserted ) |
288 |
501 { |
289 iSwiDaemonPlugin->RequestInstall( file ); |
502 appInfo.iAction = TApaAppUpdateInfo::EAppPresent; |
290 |
503 FLOG( _L("Daemon: Set app = EAppPresent") ); |
291 // close file, original SWI Daemon do not leave file open. |
504 } |
292 CleanupStack::PopAndDestroy( &file ); |
505 else |
293 } |
506 { |
294 |
507 appInfo.iAction = TApaAppUpdateInfo::EAppNotPresent; |
295 } // namespace Swi |
508 FLOG( _L("Daemon: Set app = EAppNotPresent") ); |
|
509 } |
|
510 |
|
511 aAppInfoArray.Append( appInfo ); |
|
512 } |
|
513 CleanupStack::PopAndDestroy(&appUidArray); |
|
514 // Set do not work, it will leave. |
|
515 /* |
|
516 FLOG( _L("Daemon: Set component status to SCR") ); |
|
517 // Update component flag to SCR. |
|
518 if ( aChangeType == EMediaInserted ) |
|
519 { |
|
520 FLOG( _L("Daemon: Set component present = TRUE") ); |
|
521 TRAP( err, aScrServer.SetIsComponentPresentL( aComponentId, ETrue ) ); |
|
522 } |
|
523 else if ( aChangeType==EMediaRemoved ) |
|
524 { |
|
525 FLOG( _L("Daemon: Set component present = FALSE") ); |
|
526 TRAP( err, aScrServer.SetIsComponentPresentL( aComponentId, EFalse ) ); |
|
527 } |
|
528 FLOG_1( _L("Daemon: SetIsComponentPresentL TRAP err = %d"), err ); |
|
529 */ |
|
530 } // if isInTargetDrive |
|
531 } // if err |
|
532 |
|
533 CleanupStack::PopAndDestroy( entry ); |
|
534 entry = NULL; |
|
535 |
|
536 FLOG( _L("Daemon: CDaemonBehaviour::UpdateStatusL end") ); |
|
537 } |
|
538 |
296 //EOF |
539 //EOF |