17 |
17 |
18 #include "daemon.h" |
18 #include "daemon.h" |
19 #include "drivewatcher.h" |
19 #include "drivewatcher.h" |
20 #include "SWInstDebug.h" |
20 #include "SWInstDebug.h" |
21 #include "securitypolicy.h" |
21 #include "securitypolicy.h" |
22 |
22 #include "sisregistrysession.h" |
23 //#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
24 #include <e32property.h> |
|
25 #include <connect/sbdefs.h> |
|
26 #include "../../../../installationservices/swtransactionservices/inc/stsrecovery.h" |
|
27 #include "swiobserverclient.h" |
|
28 //#else |
|
29 //#include "sisregistrysession.h" |
|
30 //#endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
31 |
23 |
32 namespace Swi |
24 namespace Swi |
33 { |
25 { |
34 // CDaemon |
26 // CDaemon |
35 |
27 |
36 // ----------------------------------------------------------------------- |
|
37 // |
|
38 // ----------------------------------------------------------------------- |
|
39 // |
|
40 /*static*/ CDaemon* CDaemon::NewL(MDaemonBehaviour& aBehaviour) |
28 /*static*/ CDaemon* CDaemon::NewL(MDaemonBehaviour& aBehaviour) |
41 { |
29 { |
42 CDaemon* self=NewLC(aBehaviour); |
30 CDaemon* self=NewLC(aBehaviour); |
43 CleanupStack::Pop(self); |
31 CleanupStack::Pop(self); |
44 return self; |
32 return self; |
45 } |
33 } |
46 |
34 |
47 // ----------------------------------------------------------------------- |
|
48 // |
|
49 // ----------------------------------------------------------------------- |
|
50 // |
|
51 /*static*/ CDaemon* CDaemon::NewLC(MDaemonBehaviour& aBehaviour) |
35 /*static*/ CDaemon* CDaemon::NewLC(MDaemonBehaviour& aBehaviour) |
52 { |
36 { |
53 CDaemon* self=new(ELeave) CDaemon(aBehaviour); |
37 CDaemon* self=new(ELeave) CDaemon(aBehaviour); |
54 CleanupStack::PushL(self); |
38 CleanupStack::PushL(self); |
55 self->ConstructL(); |
39 self->ConstructL(); |
56 return self; |
40 return self; |
57 } |
41 } |
58 |
42 |
59 // ----------------------------------------------------------------------- |
|
60 // |
|
61 // ----------------------------------------------------------------------- |
|
62 // |
|
63 CDaemon::~CDaemon() |
43 CDaemon::~CDaemon() |
64 { |
44 { |
65 iPolicyLockFile.Close(); |
45 iPolicyLockFile.Close(); |
66 |
46 |
67 iWatchers.ResetAndDestroy(); |
47 iWatchers.ResetAndDestroy(); |
68 iFs.Close(); |
48 iFs.Close(); |
69 } |
49 } |
70 |
50 |
71 // ----------------------------------------------------------------------- |
|
72 // |
|
73 // ----------------------------------------------------------------------- |
|
74 // |
|
75 CDaemon::CDaemon(MDaemonBehaviour& aBehaviour) |
51 CDaemon::CDaemon(MDaemonBehaviour& aBehaviour) |
76 : iBehaviour(aBehaviour) |
52 : iBehaviour(aBehaviour) |
77 { |
53 { |
78 } |
54 } |
79 |
55 |
80 // ----------------------------------------------------------------------- |
|
81 // |
|
82 // ----------------------------------------------------------------------- |
|
83 // |
|
84 void CDaemon::ConstructL() |
56 void CDaemon::ConstructL() |
85 { |
57 { |
86 User::LeaveIfError(iFs.Connect()); |
58 User::LeaveIfError(iFs.Connect()); |
87 |
59 |
88 LockSensitiveFiles(); |
60 LockSensitiveFiles(); |
90 |
62 |
91 iBehaviour.StartupL(); |
63 iBehaviour.StartupL(); |
92 StartWatchersL(); |
64 StartWatchersL(); |
93 } |
65 } |
94 |
66 |
95 // ----------------------------------------------------------------------- |
|
96 // |
|
97 // ----------------------------------------------------------------------- |
|
98 // |
|
99 void CDaemon::StartWatchersL() |
67 void CDaemon::StartWatchersL() |
100 { |
68 { |
101 FLOG( _L("Daemon: Start watchers") ); |
69 FLOG( _L("Daemon: Start watchers") ); |
102 RFs fs; |
70 RFs fs; |
103 User::LeaveIfError(fs.Connect()); |
71 User::LeaveIfError(fs.Connect()); |
182 } |
150 } |
183 CleanupStack::PopAndDestroy(&fs); |
151 CleanupStack::PopAndDestroy(&fs); |
184 } // StartWatchersL() |
152 } // StartWatchersL() |
185 |
153 |
186 |
154 |
187 // ----------------------------------------------------------------------- |
|
188 // |
|
189 // ----------------------------------------------------------------------- |
|
190 // |
|
191 void CDaemon::LockSensitiveFiles() |
155 void CDaemon::LockSensitiveFiles() |
192 { |
156 { |
193 TInt err = iPolicyLockFile.Open( |
157 TInt err = iPolicyLockFile.Open( |
194 iFs, |
158 iFs, |
195 KSwisPolicyFile, |
159 KSwisPolicyFile, |
196 EFileShareReadersOnly | EFileRead); |
160 EFileShareReadersOnly | EFileRead); |
197 |
161 |
198 FLOG_1( _L("Daemon: Policy file lock error = %d."), err ); |
162 FLOG_1( _L("Daemon: Policy file lock error = %d."), err ); |
199 } |
163 } |
200 |
164 |
201 //#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
202 |
|
203 // ----------------------------------------------------------------------- |
|
204 // |
|
205 // ----------------------------------------------------------------------- |
|
206 // |
|
207 void CDaemon::StartRecoveryL() |
|
208 { |
|
209 FLOG( _L("Daemon: StartRecoveryL: Check to see if a recovery is needed.") ); |
|
210 |
|
211 // Check to see if a backup is in progress... |
|
212 TInt backup = 0; |
|
213 User::LeaveIfError( RProperty::Get( KUidSystemCategory, conn::KUidBackupRestoreKey,backup ) ); |
|
214 |
|
215 // if no backup or restore is in progress... |
|
216 if( backup == conn::EBURUnset || ( backup == ( conn::EBURNormal | conn::ENoBackup ) ) ) |
|
217 { |
|
218 // no recovery attempt is made during backup/restore as recovery may seriously affect |
|
219 // the file system, which might impact backup/restore, recovery will be made at next bootup |
|
220 Usif::RStsRecoverySession stsRecoverySession; |
|
221 // A recovery failure should not affect Daemon start up. |
|
222 TRAPD( err, stsRecoverySession.RollbackAllPendingL() ); |
|
223 if( err != KErrNone ) |
|
224 { |
|
225 FLOG_1( _L("CDaemon::StartRecoveryL() - STS server failed to recover transactions. Error code: %d"), err ); |
|
226 } |
|
227 // Start SWI Observer so that it can process the log files left from the previous session. |
|
228 RSwiObserverSession swiObserver; |
|
229 swiObserver.ProcessLogsL( iFs ); |
|
230 swiObserver.Close(); |
|
231 } |
|
232 } |
|
233 |
|
234 /* |
|
235 //#else |
|
236 |
165 |
237 void CDaemon::StartRecoveryL() |
166 void CDaemon::StartRecoveryL() |
238 { |
167 { |
239 FLOG( _L("Daemon: StartRecoveryL: Check to see if a recovery is needed.") ); |
168 FLOG( _L("Daemon: StartRecoveryL: Check to see if a recovery is needed.") ); |
240 RSisRegistrySession registrySession; |
169 RSisRegistrySession registrySession; |