emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp
branchRCL_3
changeset 12 f5907b1a1053
parent 8 e1b6206813b4
child 13 0396474f30f5
--- a/emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp	Fri Feb 19 22:37:30 2010 +0200
+++ b/emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp	Fri Mar 12 15:41:14 2010 +0200
@@ -47,8 +47,6 @@
 
 _LIT8( KNullDescriptor8, "" );
 
-// To support biggest free drive, we have to get rid of hard-coded C: drive
-//const TDriveNumber KDbDriveNumber = EDriveC;
 
 _LIT( KDbFilename, "message_store.db" );
 
@@ -62,8 +60,7 @@
 _LIT( KUninstallParameter, "IMS_UNINSTALL" );
 _LIT( KImsUninstaller, "IMS Uninstaller" );
 _LIT( KUpgradeDetectionFile, "c:\\System\\EsIms\\canary.txt" );
-_LIT16( KDriveToUseFile, "db_drive.cfg" );
-//_LIT( KMsgStorePrivateDir, "c:\\Private\\200029e1\\" );
+
 
 //const TChar KColon(':');
 
@@ -269,7 +266,6 @@
   
   iLockedByBackupRestore = EFalse;
   iLockedByPointSec = EFalse;
-  iLockedByDriveMonitor = EFalse;
   
   } // end constructor
 
@@ -295,8 +291,6 @@
     //must check if PointSec has locked the system or not,
     //only create the container store if PointSec is NOT locked.
     
-    // This will be used to monitor the drive where message store db is located.
-    iStoreDriveMonitor = CStoreDriveMonitor::NewL( *this );
     
     if ( iPointsecMonitor->IsServiceAllowed() )
         {
@@ -346,7 +340,6 @@
 CMessageStoreServer::~CMessageStoreServer()
   {
   delete iUpgradePropertyWatcher;
-  delete iStoreDriveMonitor;
   delete iShutdown;
   delete iMessageStore;
   iMessageStore = NULL;
@@ -438,28 +431,12 @@
 void CMessageStoreServer::CreateContainerStoreL()
     {
     TDriveNumber drive( EDriveC );
-    if ( GetDriveL( drive ) == KErrNotFound )
-        {
-        FindBiggestCapacityDriveL( drive );
-        }
-    //set again the drive to be monitored in case is different than previous
-    iStoreDriveMonitor->SetDriveL( drive );
-    
-    if ( iStoreDriveMonitor->IsDrivePresent() )
-        {
     iMessageStore = CContainerStore::NewL( KDbFilename,
                                            drive,
                                            *this,
                                            *iShutdown,
                                            Priority() - 1);  // lower than server
-        }
-    else
-        {
-        iLockedByDriveMonitor = ETrue;
-        }
-    
-    // monitor the message store drive
-    iStoreDriveMonitor->WaitForChange();
+
 
     } // end CreateContainerStoreL
 
@@ -865,7 +842,7 @@
         //       change would have been backwards incompatible.
         
         TDriveNumber drive( EDriveC );
-        if ( GetDriveL( drive ) == KErrNotFound ) drive = EDriveC;
+		
         TInt result = CContainerStore::WipeEverything( KDbFilename,
                                                        drive );
 
@@ -908,7 +885,7 @@
     
     SendSystemLockMessage( EMsgStoreBackupOrRestoreInProgress );
     
-    if (( !iLockedByPointSec ) && ( !iLockedByDriveMonitor ) )
+    if ( !iLockedByPointSec )
         {
         LockSystem();
         }
@@ -925,7 +902,7 @@
   
     SendSystemLockMessage( EMsgStoreBackupOrRestoreCompleted );
       
-    if (( !iLockedByPointSec ) && ( !iLockedByDriveMonitor ) )
+    if ( !iLockedByPointSec )
         {
         TRAP_IGNORE( UnlockSystemL() );
         }
@@ -943,7 +920,7 @@
         {
         iLockedByPointSec = ETrue;
         SendSystemLockMessage( EMsgStorePointSecLockStarted );
-        if (( !iLockedByBackupRestore ) && ( !iLockedByDriveMonitor ) )
+        if ( !iLockedByBackupRestore )
             {
             LockSystem();
             }
@@ -961,7 +938,7 @@
         {
         iLockedByPointSec = EFalse;
         SendSystemLockMessage( EMsgStorePointSecLockEnded );
-        if ( ( !iLockedByBackupRestore ) && ( !iLockedByDriveMonitor ) )
+        if ( !iLockedByBackupRestore )
             {
             TRAP_IGNORE( UnlockSystemL() );
             }
@@ -1005,7 +982,6 @@
         iShutdown->ShutDownNow();
         }
    else if  ( ( !iLockedByBackupRestore ) 
-           && ( !iLockedByDriveMonitor ) 
            && ( !iLockedByPointSec ) )
         {
 
@@ -1025,145 +1001,7 @@
     __LOG_EXIT
     }
     
-// ==========================================================================
-// FUNCTION: FindBiggestCapacityDrive
-//           To locate the internal drive with the biggest available space.
-// ========================================================================== 
-void CMessageStoreServer::FindBiggestCapacityDriveL( TDriveNumber& aDrive )
-    {
-    __LOG_ENTER( "FindBiggestCapacityDrive" );
-    
-    RFs fs;
-    TInt driveToUse( 2 );  // set default drive to C:
-    
-    if( fs.Connect() == KErrNone )
-        {
-        CleanupClosePushL( fs );               //+fs
-        TDriveList driveList;
-        fs.DriveList( driveList );
-        TInt64 highest( 0 );
-        for (TInt i=0; i<KMaxDrives; i++)
-            {
-            if ( driveList[i] != 0 )     // check if drive exits
-                {
-                TDriveInfo driveInfo;
-                fs.Drive( driveInfo, i );
-                TVolumeInfo driveVolume;
-                fs.Volume( driveVolume, i );
-                                            
-                TUint drvStatus( 0 );
-                User::LeaveIfError( DriveInfo::GetDriveStatus( fs, i, drvStatus ) );
-                                            
-                if ( (drvStatus & DriveInfo::EDriveUserVisible) &&
-                     (drvStatus & DriveInfo::EDriveInternal)  && 
-                     (drvStatus & DriveInfo::EDrivePresent) )
-                    {
-                    if (driveVolume.iFree > highest)
-                        {
-                        driveToUse = i;
-                        highest = driveVolume.iFree;
-                        }
-                    }
-                }
-             }             
-                            
-        __LOG_WRITE_FORMAT2_INFO( "Drive #%d to use, free space=%u", driveToUse, highest );
-                                  
-        CleanupStack::PopAndDestroy( &fs );    //-fs
-        } // end if
-    
-    aDrive = static_cast<TDriveNumber>( driveToUse );
-    SetDriveL( aDrive );   // save it
-    
-    __LOG_EXIT
-    }
 
-// ==========================================================================
-// FUNCTION: GetDrive
-//           To find the previously-defined drive to use.   KErrNotFound will
-//           be returned if not config file found
-//
-// Note    : the config file will be loacted in C: drive 
-//           (C:\Private\2000c8d2\db_drive.cfg)
-// ==========================================================================
-TInt CMessageStoreServer::GetDriveL( TDriveNumber& aDrive )
-    {
-    __LOG_ENTER( "GetDrive" );
-    
-    TInt ret( KErrNotFound );
-        
-    RFs fs;
-    if( fs.Connect() == KErrNone )
-        {
-        CleanupClosePushL( fs );               //+fs
-        TFileName fileName;
-        fs.CreatePrivatePath( EDriveC );
-        User::LeaveIfError(fs.PrivatePath( fileName ));
-        fileName.Append( KDriveToUseFile );
-        _LIT( KCDrive, "C:" );
-        fileName.Insert( 0, KCDrive() );
-        __LOG_WRITE_FORMAT1_INFO( "DriveToUse file=%S", &fileName );
-                   
-        if( BaflUtils::FileExists( fs, fileName ) )
-            {
-            RFileReadStream reader;
-            if ( reader.Open( fs, fileName, EFileRead ) == KErrNone )
-          		{
-           		CleanupClosePushL( reader );             //+reader
-           		TUint drive = reader.ReadUint32L();
-           		__LOG_WRITE_FORMAT1_INFO( "previously-defined drive to use : %d", drive );
-                CleanupStack::PopAndDestroy( &reader );  //-reader
-           		aDrive = static_cast<TDriveNumber>( drive );
-           		ret = KErrNone;
-           		}
-            }
-                   
-        CleanupStack::PopAndDestroy( &fs );    //-fs
-        } // end if
-    
-    __LOG_EXIT
-    return ret;
-    }
-
-// ==========================================================================
-// FUNCTION: SetDrive
-//           To write the chosen drive info to the config file.
-//
-// Note    : the config file will be loacted in C: drive 
-//           (C:\Private\2000c8d2\db_drive.cfg)
-// ==========================================================================
-void CMessageStoreServer::SetDriveL( const TDriveNumber aDrive )
-    {
-    __LOG_ENTER( "SetDrive" );
-    
-    TUint drive = static_cast<TUint32>( aDrive );
-        
-    RFs fs;
-    if( fs.Connect() == KErrNone )
-        {
-        CleanupClosePushL( fs );               //+fs
-        TFileName fileName;
-        User::LeaveIfError(fs.PrivatePath( fileName ));
-        fileName.Append( KDriveToUseFile );
-        _LIT( KCDrive, "C:" );
-        fileName.Insert( 0, KCDrive() );
-        __LOG_WRITE_FORMAT1_INFO( "DriveToUse file=%S", &fileName )
-                   
-        RFileWriteStream writer;
-        if ( writer.Replace( fs, fileName, EFileRead ) == KErrNone )
-            {
-         	CleanupClosePushL( writer );             //+writer
-           	writer.WriteUint32L( drive );
-           	writer.CommitL();
-           	__LOG_WRITE_FORMAT1_INFO( "writing chosen drive #%d to file", drive );
-            CleanupStack::PopAndDestroy( &writer );  //-writer
-           	}
-                 
-        CleanupStack::PopAndDestroy( &fs );    //-fs
-        } // end if
-    
-    __LOG_EXIT
-    }
 
 // ==========================================================================
 // FUNCTION: SendSystemLockMessage
@@ -1243,34 +1081,5 @@
 
 #endif
 
-//from MStoreDriveStateObserver
-void CMessageStoreServer::DriveStateChangedL( TBool aState )
-    {
-    __LOG_ENTER( "DriveStateChangedL" );
-    if ( aState )
-        {
-        //drive mounted
-        if ( iLockedByDriveMonitor )
-             {
-             iLockedByDriveMonitor = EFalse;
-             if ( ( !iLockedByBackupRestore ) && ( !iLockedByPointSec ) )
-                 {
-                 UnlockSystemL();
-                 }
-             }
-        }
-    else
-        {
-        //drive unmounted
-        if ( !iLockedByDriveMonitor )
-            {
-            iLockedByDriveMonitor = ETrue;
-            if ( ( !iLockedByBackupRestore ) && ( !iLockedByPointSec ) )
-                {
-                LockSystem();
-                }
-            }
-        }
-    __LOG_EXIT
-    }
 
+