13 * |
13 * |
14 * Description: Metadata main server class* |
14 * Description: Metadata main server class* |
15 */ |
15 */ |
16 |
16 |
17 // INCLUDE FILES |
17 // INCLUDE FILES |
|
18 #include <f32file.h> |
18 #include "mdsserver.h" |
19 #include "mdsserver.h" |
19 #include "mdscommoninternal.h" |
20 #include "mdscommoninternal.h" |
20 #include "mdsserversession.h" |
21 #include "mdsserversession.h" |
21 #include "mdsdbconnectionpool.h" |
22 #include "mdsdbconnectionpool.h" |
22 #include "mdssqldbmaintenance.h" |
23 #include "mdssqldbmaintenance.h" |
28 #include "mdsmanipulationengine.h" |
29 #include "mdsmanipulationengine.h" |
29 #include "mdsclausebuffer.h" |
30 #include "mdsclausebuffer.h" |
30 #include "mdebackuprestorewatcher.h" |
31 #include "mdebackuprestorewatcher.h" |
31 #include "mdsschema.h" |
32 #include "mdsschema.h" |
32 #include "mdcserializationbuffer.h" |
33 #include "mdcserializationbuffer.h" |
33 #include <f32file.h> |
|
34 |
34 |
35 __DEFINE_LOGGER |
35 __DEFINE_LOGGER |
36 |
36 |
37 const TInt64 KDiskSpaceGarbageCollectorThreshold = 1024*1024; // 1 MB |
37 const TInt64 KDiskSpaceGarbageCollectorThreshold = 1024*1024; // 1 MB |
38 const TInt64 KDiskFullThreshold = 1024*50; // 50 kB |
38 const TInt64 KDiskFullThreshold = 1024*50; // 50 kB |
287 variables.AppendL( TColumn( EMdEObjectFlagNotPresent ) ); |
287 variables.AppendL( TColumn( EMdEObjectFlagNotPresent ) ); |
288 variables.AppendL( TColumn( KMemoryCardKey ) ); |
288 variables.AppendL( TColumn( KMemoryCardKey ) ); |
289 variables.AppendL( TColumn( KMemoryCardLimit ) ); |
289 variables.AppendL( TColumn( KMemoryCardLimit ) ); |
290 variables.AppendL( TColumn( KObjectCleanupLimit ) ); |
290 variables.AppendL( TColumn( KObjectCleanupLimit ) ); |
291 |
291 |
292 TInt rowCount = iDefaultDBConnection->ExecuteL( clause->ConstBufferL(), variables ); |
292 const TInt rowCount = iDefaultDBConnection->ExecuteL( clause->ConstBufferL(), variables ); |
293 |
293 |
294 CleanupStack::PopAndDestroy( 2, clause ); // variables, clause |
294 CleanupStack::PopAndDestroy( 2, clause ); // variables, clause |
295 } |
295 } |
296 |
296 |
297 |
297 |
542 TInt CMdSServer::SetHarvestingPrioritizationChunkL( const RMessagePtr2 aMessage, TInt aParam ) |
542 TInt CMdSServer::SetHarvestingPrioritizationChunkL( const RMessagePtr2 aMessage, TInt aParam ) |
543 { |
543 { |
544 // if there happens to be old chunk, close it |
544 // if there happens to be old chunk, close it |
545 iHarvestingPrioritizationChunk.Close(); |
545 iHarvestingPrioritizationChunk.Close(); |
546 |
546 |
547 TInt error = iHarvestingPrioritizationChunk.Open( aMessage, aParam, EFalse ); |
547 const TInt error = iHarvestingPrioritizationChunk.Open( aMessage, aParam, EFalse ); |
548 |
548 |
549 if( error != KErrNone ) |
549 if( error != KErrNone ) |
550 { |
550 { |
551 return error; |
551 return error; |
552 } |
552 } |
571 { |
571 { |
572 if( iHarvestingPrioritizationObserver.IsNull() ) |
572 if( iHarvestingPrioritizationObserver.IsNull() ) |
573 { |
573 { |
574 iHarvestingPrioritizationLocked = EFalse; |
574 iHarvestingPrioritizationLocked = EFalse; |
575 |
575 |
|
576 iClientThread.Close(); |
576 iHarvestingPrioritizationObserver = aMessage; |
577 iHarvestingPrioritizationObserver = aMessage; |
|
578 iHarvestingPrioritizationObserver.Client( iClientThread ); |
577 |
579 |
578 // reserve space for harvesting prioritization URI count |
580 // reserve space for harvesting prioritization URI count |
579 iHarvestingPrioritizationLimit = CMdCSerializationBuffer::KRequiredSizeForTInt32; |
581 iHarvestingPrioritizationLimit = CMdCSerializationBuffer::KRequiredSizeForTInt32; |
580 iHarvestingPrioritizationUriCount = 0; |
582 iHarvestingPrioritizationUriCount = 0; |
581 |
583 |
582 return KErrNone; |
584 return KErrNone; |
583 } |
585 } |
584 else |
586 else |
585 { |
587 { |
586 RThread clientThread; |
588 TExitType exitType = iClientThread.ExitType(); |
587 iHarvestingPrioritizationObserver.Client( clientThread ); |
|
588 TExitType exitType = clientThread.ExitType(); |
|
589 clientThread.Close(); |
|
590 if( EExitPending != exitType ) |
589 if( EExitPending != exitType ) |
591 { |
590 { |
592 iHarvestingPrioritizationLocked = EFalse; |
591 iHarvestingPrioritizationLocked = EFalse; |
593 |
592 |
|
593 iClientThread.Close(); |
594 iHarvestingPrioritizationObserver = aMessage; |
594 iHarvestingPrioritizationObserver = aMessage; |
|
595 iHarvestingPrioritizationObserver.Client( iClientThread ); |
595 |
596 |
596 // reserve space for harvesting prioritization URI count |
597 // reserve space for harvesting prioritization URI count |
597 iHarvestingPrioritizationLimit = CMdCSerializationBuffer::KRequiredSizeForTInt32; |
598 iHarvestingPrioritizationLimit = CMdCSerializationBuffer::KRequiredSizeForTInt32; |
598 iHarvestingPrioritizationUriCount = 0; |
599 iHarvestingPrioritizationUriCount = 0; |
599 |
600 |
705 |
706 |
706 void CMdSServer::NotifyHarvestingPrioritizationObserver( TInt aStatus ) const |
707 void CMdSServer::NotifyHarvestingPrioritizationObserver( TInt aStatus ) const |
707 { |
708 { |
708 if( !iHarvestingPrioritizationObserver.IsNull() ) |
709 if( !iHarvestingPrioritizationObserver.IsNull() ) |
709 { |
710 { |
710 RThread clientThread; |
711 TExitType exitType = iClientThread.ExitType(); |
711 iHarvestingPrioritizationObserver.Client( clientThread ); |
|
712 TExitType exitType = clientThread.ExitType(); |
|
713 if( EExitPending == exitType ) |
712 if( EExitPending == exitType ) |
714 { |
713 { |
715 iHarvestingPrioritizationObserver.Complete( aStatus ); |
714 iHarvestingPrioritizationObserver.Complete( aStatus ); |
716 } |
715 } |
717 clientThread.Close(); |
|
718 } |
716 } |
719 } |
717 } |
720 |
718 |
721 TInt CMdSServer::RunError( TInt aError ) |
719 TInt CMdSServer::RunError( TInt aError ) |
722 { |
720 { |
851 RFs fs; |
849 RFs fs; |
852 User::LeaveIfError( fs.Connect() ); |
850 User::LeaveIfError( fs.Connect() ); |
853 CleanupClosePushL( fs ); |
851 CleanupClosePushL( fs ); |
854 |
852 |
855 RFileReadStream tmpFile; |
853 RFileReadStream tmpFile; |
856 TInt err( KErrNone ); |
|
857 TBuf<KMaxFileName> privatePath; |
854 TBuf<KMaxFileName> privatePath; |
858 TBuf<KMaxFileName> schema; |
855 TBuf<KMaxFileName> schema; |
859 TBuf<KMaxFileName> defaultImportProfile; |
856 TBuf<KMaxFileName> defaultImportProfile; |
860 TBuf<KMaxFileName> backupRegistration; |
857 TBuf<KMaxFileName> backupRegistration; |
861 |
858 |
870 backupRegistration.Copy( privatePath ); |
867 backupRegistration.Copy( privatePath ); |
871 backupRegistration.Append( KBackupRegistration ); |
868 backupRegistration.Append( KBackupRegistration ); |
872 |
869 |
873 CFileMan* fileMan = CFileMan::NewL( fs ); |
870 CFileMan* fileMan = CFileMan::NewL( fs ); |
874 CleanupStack::PushL( fileMan); |
871 CleanupStack::PushL( fileMan); |
875 |
872 |
876 err = tmpFile.Open( fs, schema, EFileRead | EFileShareAny ); |
873 TInt err = tmpFile.Open( fs, schema, EFileRead | EFileShareAny ); |
877 __LOG1( ELogAlways, "open schema.mde %d", err ); |
874 __LOG1( ELogAlways, "open schema.mde %d", err ); |
878 tmpFile.Close(); |
875 tmpFile.Close(); |
879 if ( err != KErrNone ) |
876 if ( err != KErrNone ) |
880 { |
877 { |
881 if ( err == KErrNotFound ) |
878 if ( err == KErrNotFound ) |