appinstaller/AppinstUi/Daemon/Src/daemon.cpp
branchRCL_3
changeset 25 7333d7932ef7
parent 0 ba25891c3a9e
child 26 8b7f4e561641
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
    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 #include "sisregistrysession.h"
    22 
       
    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
    23 
    31 
    24 namespace Swi
    32 namespace Swi
    25 {
    33 {
    26 // CDaemon
    34 // CDaemon
    27 
    35 
       
    36 // -----------------------------------------------------------------------
       
    37 //
       
    38 // -----------------------------------------------------------------------
       
    39 //     
    28 /*static*/ CDaemon* CDaemon::NewL(MDaemonBehaviour& aBehaviour)
    40 /*static*/ CDaemon* CDaemon::NewL(MDaemonBehaviour& aBehaviour)
    29     {
    41     {
    30     CDaemon* self=NewLC(aBehaviour);
    42     CDaemon* self=NewLC(aBehaviour);
    31     CleanupStack::Pop(self);
    43     CleanupStack::Pop(self);
    32     return self;
    44     return self;
    33     }
    45     }
    34 
    46 
       
    47 // -----------------------------------------------------------------------
       
    48 //
       
    49 // -----------------------------------------------------------------------
       
    50 //     
    35 /*static*/ CDaemon* CDaemon::NewLC(MDaemonBehaviour& aBehaviour)
    51 /*static*/ CDaemon* CDaemon::NewLC(MDaemonBehaviour& aBehaviour)
    36     {
    52     {
    37     CDaemon* self=new(ELeave) CDaemon(aBehaviour);
    53     CDaemon* self=new(ELeave) CDaemon(aBehaviour);
    38     CleanupStack::PushL(self);
    54     CleanupStack::PushL(self);
    39     self->ConstructL();
    55     self->ConstructL();
    40     return self;
    56     return self;
    41     }
    57     }
    42   
    58 
       
    59 // -----------------------------------------------------------------------
       
    60 //
       
    61 // -----------------------------------------------------------------------
       
    62 //       
    43 CDaemon::~CDaemon()
    63 CDaemon::~CDaemon()
    44     { 
    64     { 
    45     iPolicyLockFile.Close();
    65     iPolicyLockFile.Close();
    46   
    66   
    47     iWatchers.ResetAndDestroy();
    67     iWatchers.ResetAndDestroy();
    48     iFs.Close();
    68     iFs.Close();
    49     }
    69     }
    50 
    70 
       
    71 // -----------------------------------------------------------------------
       
    72 //
       
    73 // -----------------------------------------------------------------------
       
    74 //     
    51 CDaemon::CDaemon(MDaemonBehaviour& aBehaviour)
    75 CDaemon::CDaemon(MDaemonBehaviour& aBehaviour)
    52     : iBehaviour(aBehaviour)
    76     : iBehaviour(aBehaviour)
    53     {
    77     {
    54     }
    78     }
    55 
    79 
       
    80 // -----------------------------------------------------------------------
       
    81 //
       
    82 // -----------------------------------------------------------------------
       
    83 //     
    56 void CDaemon::ConstructL()
    84 void CDaemon::ConstructL()
    57     {
    85     {
    58     User::LeaveIfError(iFs.Connect());
    86     User::LeaveIfError(iFs.Connect());
    59   
    87   
    60     LockSensitiveFiles();
    88     LockSensitiveFiles();
    62   
    90   
    63     iBehaviour.StartupL();
    91     iBehaviour.StartupL();
    64     StartWatchersL();
    92     StartWatchersL();
    65     }
    93     }
    66 
    94 
       
    95 // -----------------------------------------------------------------------
       
    96 //
       
    97 // -----------------------------------------------------------------------
       
    98 //     
    67 void CDaemon::StartWatchersL()
    99 void CDaemon::StartWatchersL()
    68     {
   100     {
    69     FLOG( _L("Daemon: Start watchers") );        
   101     FLOG( _L("Daemon: Start watchers") );        
    70     RFs fs;
   102     RFs fs;
    71     User::LeaveIfError(fs.Connect());
   103     User::LeaveIfError(fs.Connect());
   150         }
   182         }
   151     CleanupStack::PopAndDestroy(&fs);
   183     CleanupStack::PopAndDestroy(&fs);
   152     } // StartWatchersL()
   184     } // StartWatchersL()
   153 
   185 
   154 
   186 
       
   187 // -----------------------------------------------------------------------
       
   188 //
       
   189 // -----------------------------------------------------------------------
       
   190 //     
   155 void CDaemon::LockSensitiveFiles()
   191 void CDaemon::LockSensitiveFiles()
   156     {
   192     {
   157     TInt err = iPolicyLockFile.Open( 
   193     TInt err = iPolicyLockFile.Open( 
   158         iFs, 
   194         iFs, 
   159         KSwisPolicyFile, 
   195         KSwisPolicyFile, 
   160         EFileShareReadersOnly | EFileRead);
   196         EFileShareReadersOnly | EFileRead);
   161   
   197   
   162     FLOG_1( _L("Daemon: Policy file lock error = %d."), err );  
   198     FLOG_1( _L("Daemon: Policy file lock error = %d."), err );  
   163     }
   199     }
   164 
   200 
       
   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
   165   
   236   
   166 void CDaemon::StartRecoveryL()
   237 void CDaemon::StartRecoveryL()
   167     { 
   238     { 
   168     FLOG( _L("Daemon: StartRecoveryL: Check to see if a recovery is needed.") );  
   239     FLOG( _L("Daemon: StartRecoveryL: Check to see if a recovery is needed.") );  
   169     RSisRegistrySession registrySession;
   240     RSisRegistrySession registrySession;
   176     CleanupStack::PopAndDestroy( &registrySession );
   247     CleanupStack::PopAndDestroy( &registrySession );
   177   
   248   
   178     FLOG( _L("Daemon: StartRecoveryL: Recovery check finished.") ); 
   249     FLOG( _L("Daemon: StartRecoveryL: Recovery check finished.") ); 
   179     } // StartRecoveryL()
   250     } // StartRecoveryL()
   180 
   251 
       
   252 #endif  // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   253 */
       
   254 
   181 } // namespace Swi
   255 } // namespace Swi