22 #include "SWInstDebug.h" |
22 #include "SWInstDebug.h" |
23 #include "sisregistryentry.h" |
23 #include "sisregistryentry.h" |
24 |
24 |
25 |
25 |
26 namespace Swi |
26 namespace Swi |
27 { |
27 { |
28 // For uninstaller |
28 // For uninstaller |
29 CDaemonBehaviour* CDaemonBehaviour::NewL( CProgramStatus& aMainStatus ) |
29 CDaemonBehaviour* CDaemonBehaviour::NewL( CProgramStatus& aMainStatus ) |
30 { |
30 { |
31 CDaemonBehaviour* self = NewLC( aMainStatus ); |
31 CDaemonBehaviour* self = NewLC( aMainStatus ); |
32 CleanupStack::Pop(self); |
32 CleanupStack::Pop(self); |
33 return self; |
33 return self; |
34 } |
34 } |
35 |
35 |
36 CDaemonBehaviour* CDaemonBehaviour::NewLC( CProgramStatus& aMainStatus ) |
36 CDaemonBehaviour* CDaemonBehaviour::NewLC( CProgramStatus& aMainStatus ) |
37 { |
37 { |
38 CDaemonBehaviour* self = new (ELeave) CDaemonBehaviour; |
38 CDaemonBehaviour* self = new (ELeave) CDaemonBehaviour; |
39 CleanupStack::PushL(self); |
39 CleanupStack::PushL(self); |
40 self->ConstructL( aMainStatus ); |
40 self->ConstructL( aMainStatus ); |
41 return self; |
41 return self; |
42 } |
42 } |
43 |
43 |
44 void CDaemonBehaviour::ConstructL( CProgramStatus& aMainStatus ) |
44 void CDaemonBehaviour::ConstructL( CProgramStatus& aMainStatus ) |
45 { |
45 { |
46 User::LeaveIfError(iFs.Connect()); |
46 User::LeaveIfError(iFs.Connect()); |
47 User::LeaveIfError(iFs.ShareProtected()); |
47 User::LeaveIfError(iFs.ShareProtected()); |
48 |
48 |
49 // For uninstaller |
49 // For uninstaller |
50 iSisInstaller = CSisInstaller::NewL( this, aMainStatus ); |
50 iSisInstaller = CSisInstaller::NewL( this, aMainStatus ); |
51 // Create plugin |
51 // Create plugin |
52 TRAP_IGNORE( iSwiDaemonPlugin = CSwiDaemonPlugin::NewL() ); |
52 TRAP_IGNORE( iSwiDaemonPlugin = CSwiDaemonPlugin::NewL() ); |
53 } |
53 } |
54 |
54 |
55 CDaemonBehaviour::~CDaemonBehaviour() |
55 CDaemonBehaviour::~CDaemonBehaviour() |
56 { |
56 { |
57 if ( iSwiDaemonPlugin ) |
57 if ( iSwiDaemonPlugin ) |
58 { |
58 { |
59 delete iSwiDaemonPlugin; |
59 delete iSwiDaemonPlugin; |
60 REComSession::FinalClose(); |
60 REComSession::FinalClose(); |
61 } |
61 } |
62 delete iSisInstaller; |
62 delete iSisInstaller; |
63 iSisInstaller = NULL; |
63 iSisInstaller = NULL; |
64 iFs.Close(); |
64 iFs.Close(); |
65 |
65 |
66 |
66 #ifdef RD_MULTIPLE_DRIVE |
67 #ifdef RD_MULTIPLE_DRIVE |
67 iDriveArray.Close(); |
68 iDriveArray.Close(); |
68 #endif |
69 #endif |
69 } |
70 } |
70 |
71 |
71 // from MDaemonBehaviour |
72 // from MDaemonBehaviour |
72 TBool CDaemonBehaviour::StartupL() |
73 TBool CDaemonBehaviour::StartupL() |
73 { |
74 { |
74 // Return state of Startup |
75 // Return state of Startup |
75 return ETrue; |
76 return ETrue; |
76 } |
77 } |
|
78 |
77 |
79 void CDaemonBehaviour::MediaChangeL(TInt aDrive, TChangeType aChangeType) |
78 void CDaemonBehaviour::MediaChangeL(TInt aDrive, TChangeType aChangeType) |
80 { |
79 { |
81 FLOG_1( _L("Daemon: Media change %d"), aDrive ); |
80 FLOG_1( _L("Daemon: Media change %d"), aDrive ); |
82 RSisRegistryWritableSession registrySession; |
81 RSisRegistryWritableSession registrySession; |
83 |
82 |
84 User::LeaveIfError(registrySession.Connect()); |
83 User::LeaveIfError(registrySession.Connect()); |
85 CleanupClosePushL(registrySession); |
84 CleanupClosePushL(registrySession); |
86 |
85 |
87 if (aChangeType==EMediaInserted) |
86 if (aChangeType==EMediaInserted) |
88 { |
87 { |
89 FLOG( _L("Daemon: Media inserted") ); |
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 |
90 // Scan directory on the card and run pre-installed through SWIS |
99 // Scan directory on the card and run pre-installed through SWIS |
91 ProcessPreinstalledFilesL(aDrive); |
100 FLOG( _L("Daemon: Media change: Process preinstalled files") ); |
92 |
101 ProcessPreinstalledFilesL(aDrive); |
93 // notify IAR |
102 |
94 registrySession.AddDriveL(aDrive); |
|
95 |
|
96 #ifdef RD_MULTIPLE_DRIVE |
103 #ifdef RD_MULTIPLE_DRIVE |
97 // Add inserted media drive to drive array. |
104 // Add inserted media drive to drive array. |
98 if ( iDriveArray.Find(aDrive) == KErrNotFound ) |
105 if ( iDriveArray.Find(aDrive) == KErrNotFound ) |
99 { |
106 { |
100 iDriveArray.AppendL(aDrive); |
107 iDriveArray.AppendL(aDrive); |
101 } |
108 } |
102 #endif |
109 #endif |
103 } |
110 } |
104 else if (aChangeType==EMediaRemoved) |
111 else if (aChangeType==EMediaRemoved) |
105 { |
112 { |
106 FLOG( _L("Daemon: Media removed") ); |
113 FLOG( _L("Daemon: Media removed") ); |
107 |
114 |
108 #ifdef RD_MULTIPLE_DRIVE |
115 #ifdef RD_MULTIPLE_DRIVE |
109 // Get Installer state. |
116 // Get Installer state. |
110 TBool installerRunning = iSisInstaller->IsInstalling(); |
117 TBool installerRunning = iSisInstaller->IsInstalling(); |
111 #endif |
118 #endif |
112 |
119 |
113 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
120 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
114 // notify IAR |
121 // notify IAR |
|
122 // Note SWI Daemon need to notify sis registry from |
|
123 // media change. |
115 registrySession.RemoveDriveL(aDrive); |
124 registrySession.RemoveDriveL(aDrive); |
116 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
125 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
117 |
126 |
118 // Cancel all requests for install |
127 // Cancel all requests for install |
119 iSisInstaller->Cancel(); |
128 iSisInstaller->Cancel(); |
120 |
129 |
121 #ifdef RD_MULTIPLE_DRIVE |
130 #ifdef RD_MULTIPLE_DRIVE |
122 // Notify plugin |
131 // Notify plugin |
123 if(iSwiDaemonPlugin) |
132 if(iSwiDaemonPlugin) |
124 { |
133 { |
125 TInt index = iDriveArray.Find(aDrive); |
134 TInt index = iDriveArray.Find(aDrive); |
126 iSwiDaemonPlugin->MediaRemoved(index); |
135 iSwiDaemonPlugin->MediaRemoved(index); |
127 } |
136 } |
128 #else |
137 #else |
129 // Notify plugin |
138 // Notify plugin |
130 if(iSwiDaemonPlugin) |
139 if(iSwiDaemonPlugin) |
131 { |
140 { |
132 iSwiDaemonPlugin->MediaRemoved(aDrive); |
141 iSwiDaemonPlugin->MediaRemoved(aDrive); |
133 } |
142 } |
134 #endif //RD_MULTIPLE_DRIVE |
143 #endif //RD_MULTIPLE_DRIVE |
135 |
144 |
136 #ifdef RD_MULTIPLE_DRIVE |
145 #ifdef RD_MULTIPLE_DRIVE |
137 // Get index of removed drive from array |
146 // Get index of removed drive from array |
138 TInt index = iDriveArray.Find(aDrive); |
147 TInt index = iDriveArray.Find(aDrive); |
139 |
148 |
140 if ( index > KErrNotFound ) |
149 if ( index > KErrNotFound ) |
141 { |
150 { |
142 iDriveArray.Remove(index); |
151 iDriveArray.Remove(index); |
143 iDriveArray.Compress(); |
152 iDriveArray.Compress(); |
144 } |
153 } |
145 |
154 |
146 // Continue installing from other drives if needed. |
155 // Continue installing from other drives if needed. |
147 if ( installerRunning ) |
156 if ( installerRunning ) |
148 { |
157 { |
149 // Get count of inserted drives. |
158 // Get count of inserted drives. |
150 TInt count = iDriveArray.Count(); |
159 TInt count = iDriveArray.Count(); |
151 |
160 |
152 if ( count ) |
161 if ( count ) |
153 { |
162 { |
154 for(index = 0; index < count; index++ ) |
163 for(index = 0; index < count; index++ ) |
155 { |
164 { |
156 ProcessPreinstalledFilesL(iDriveArray[index]); |
165 ProcessPreinstalledFilesL(iDriveArray[index]); |
157 iSisInstaller->StartInstallingL(); |
166 iSisInstaller->StartInstallingL(); |
158 } |
167 } |
159 } |
168 } |
160 } |
169 } |
161 #endif |
170 #endif |
162 } |
171 } |
163 CleanupStack::PopAndDestroy(®istrySession); |
172 |
164 } |
173 CleanupStack::PopAndDestroy(®istrySession); |
165 |
174 } |
|
175 |
166 void CDaemonBehaviour::ProcessPreinstalledFilesL(TInt aDrive) |
176 void CDaemonBehaviour::ProcessPreinstalledFilesL(TInt aDrive) |
167 { |
177 { |
168 _LIT(KDaemonPrivatePath,":\\private\\10202dce\\"); |
178 _LIT(KDaemonPrivatePath,":\\private\\10202dce\\"); |
169 |
179 |
170 #ifndef RD_MULTIPLE_DRIVE |
180 #ifndef RD_MULTIPLE_DRIVE |
171 iSisInstaller->Cancel(); |
181 iSisInstaller->Cancel(); |
172 #endif |
182 #endif |
173 // For uninstaller |
183 // For uninstaller |
174 // Set on installing mode. |
184 // Set on installing mode. |
175 iGeneralProcessStatus = EStateInstalling; |
185 iGeneralProcessStatus = EStateInstalling; |
176 FLOG_1( _L("[CDaemonBehaviour] iGeneralProcessStatus = %d"), |
186 FLOG_1( _L("[CDaemonBehaviour] iGeneralProcessStatus = %d"), |
177 iGeneralProcessStatus ); |
187 iGeneralProcessStatus ); |
178 |
188 |
179 ProcessPreinstalledFilesL(aDrive, KDaemonPrivatePath); |
189 ProcessPreinstalledFilesL(aDrive, KDaemonPrivatePath); |
180 iStartNotified = EFalse; |
190 iStartNotified = EFalse; |
181 iDrive = aDrive; |
191 iDrive = aDrive; |
182 iSisInstaller->StartInstallingL(); |
192 iSisInstaller->StartInstallingL(); |
183 } |
193 } |
184 |
194 |
185 void CDaemonBehaviour::ProcessPreinstalledFilesL(TInt aDrive, const TDesC& aDirectory) |
195 void CDaemonBehaviour::ProcessPreinstalledFilesL(TInt aDrive, const TDesC& aDirectory) |
186 { |
196 { |
187 FLOG( _L("Daemon: ProcessPreInstalledFilesL") ); |
197 FLOG( _L("Daemon: ProcessPreInstalledFilesL") ); |
188 TPath preInstalledPath; |
198 TPath preInstalledPath; |
189 TChar drive; |
199 TChar drive; |
190 RFs::DriveToChar(aDrive, drive); |
200 RFs::DriveToChar(aDrive, drive); |
191 preInstalledPath.Append(drive); |
201 preInstalledPath.Append(drive); |
192 preInstalledPath.Append(aDirectory); |
202 preInstalledPath.Append(aDirectory); |
193 |
203 |
194 FLOG_1( _L("Daemon: ProcessPreInstalledFilesL Getting dir %S"), &preInstalledPath ); |
204 FLOG_1( _L("Daemon: ProcessPreInstalledFilesL Getting dir %S"), &preInstalledPath ); |
195 CDir* dir = NULL; |
205 CDir* dir = NULL; |
196 TInt err = iFs.GetDir(preInstalledPath, KEntryAttNormal, ESortNone, dir); |
206 TInt err = iFs.GetDir(preInstalledPath, KEntryAttNormal, ESortNone, dir); |
197 if (err != KErrNone && err != KErrPathNotFound) |
207 if (err != KErrNone && err != KErrPathNotFound) |
198 { |
208 { |
199 FLOG_1( _L("Daemon: ProcessPreInstalledFilesL GetDir with error %d"), err ); |
209 FLOG_1( _L("Daemon: ProcessPreInstalledFilesL GetDir with error %d"), err ); |
200 User::Leave(err); |
210 User::Leave(err); |
201 } |
211 } |