60 _LIT( KUninstallParameter, "IMS_UNINSTALL" ); |
60 _LIT( KUninstallParameter, "IMS_UNINSTALL" ); |
61 _LIT( KImsUninstaller, "IMS Uninstaller" ); |
61 _LIT( KImsUninstaller, "IMS Uninstaller" ); |
62 _LIT( KUpgradeDetectionFile, "c:\\System\\EsIms\\canary.txt" ); |
62 _LIT( KUpgradeDetectionFile, "c:\\System\\EsIms\\canary.txt" ); |
63 |
63 |
64 |
64 |
65 //const TChar KColon(':'); |
65 |
66 |
66 |
67 // SID list |
67 // SID list |
68 // This is the list of secure Ids that are allowed to use the message store. This list must be terminated |
68 // This is the list of secure Ids that are allowed to use the message store. This list must be terminated |
69 // with zero. |
69 // with zero. |
70 |
70 |
378 // FUNCTION: AddSession |
378 // FUNCTION: AddSession |
379 // A new session is being created |
379 // A new session is being created |
380 // Cancel the shutdown timer if it was running |
380 // Cancel the shutdown timer if it was running |
381 // ========================================================================== |
381 // ========================================================================== |
382 void CMessageStoreServer::AddSession( CMessageStoreSession* aSession ) |
382 void CMessageStoreServer::AddSession( CMessageStoreSession* aSession ) |
383 { |
383 { |
384 __LOG_ENTER( "AddSession" ) |
384 __LOG_ENTER( "AddSession" ) |
385 iSessions.Append( aSession ); |
385 iSessions.Append( aSession ); |
386 |
386 |
387 // A sesssion was added, so the shutdown timer can be stopped. |
387 // notify new session of current state |
388 // iShutdown->Stop(); |
388 TMsgStoreEvent event; |
389 __LOG_EXIT |
389 event.iType = EMsgStoreAvailable; |
390 } // end AddSession |
390 event.iId = KMsgStoreInvalidId; |
|
391 event.iParentId = KMsgStoreInvalidId; |
|
392 event.iOtherId = KMsgStoreInvalidId; |
|
393 event.iFlags = KMsgStoreFlagsNotFound; |
|
394 |
|
395 if ( iLockedByBackupRestore || iLockedByPointSec ) |
|
396 { |
|
397 event.iType = EMsgStoreUnavailable; |
|
398 } |
|
399 |
|
400 aSession->SendEventToObserver( event ); |
|
401 |
|
402 // A sesssion was added, so the shutdown timer can be stopped. |
|
403 // iShutdown->Stop(); |
|
404 |
|
405 __LOG_EXIT |
|
406 } // end AddSession |
391 |
407 |
392 // ========================================================================== |
408 // ========================================================================== |
393 // FUNCTION: DropSession |
409 // FUNCTION: DropSession |
394 // A session is being destroyed |
410 // A session is being destroyed |
395 // Start the shutdown timer if it is the last session. |
411 // Start the shutdown timer if it is the last session. |
428 // ========================================================================== |
444 // ========================================================================== |
429 // FUNCTION: CreateContainerStoreL |
445 // FUNCTION: CreateContainerStoreL |
430 // ========================================================================== |
446 // ========================================================================== |
431 void CMessageStoreServer::CreateContainerStoreL() |
447 void CMessageStoreServer::CreateContainerStoreL() |
432 { |
448 { |
|
449 __LOG_ENTER( "CreateContainerStoreL" ) |
|
450 |
433 TDriveNumber drive( EDriveC ); |
451 TDriveNumber drive( EDriveC ); |
434 iMessageStore = CContainerStore::NewL( KDbFilename, |
452 iMessageStore = CContainerStore::NewL( KDbFilename, |
435 drive, |
453 drive, |
436 *this, |
454 *this, |
437 *iShutdown, |
455 *iShutdown, |
438 Priority() - 1); // lower than server |
456 Priority() - 1); // lower than server |
439 |
457 |
440 |
458 |
|
459 __LOG_EXIT |
441 } // end CreateContainerStoreL |
460 } // end CreateContainerStoreL |
442 |
461 |
443 |
462 |
444 // ========================================================================== |
463 // ========================================================================== |
445 // FUNCTION: MessageStoreL |
464 // FUNCTION: MessageStoreL |
880 // FUNCTION: BackupOrRestoreInProgress |
899 // FUNCTION: BackupOrRestoreInProgress |
881 // ========================================================================== |
900 // ========================================================================== |
882 void CMessageStoreServer::BackupOrRestoreInProgress( TBool /*aIsARestore*/ ) |
901 void CMessageStoreServer::BackupOrRestoreInProgress( TBool /*aIsARestore*/ ) |
883 { |
902 { |
884 __LOG_ENTER( "BackupOrRestoreInProgress" ); |
903 __LOG_ENTER( "BackupOrRestoreInProgress" ); |
885 |
904 |
886 SendSystemLockMessage( EMsgStoreBackupOrRestoreInProgress ); |
905 if ( !iLockedByBackupRestore ) |
887 |
906 { |
888 if ( !iLockedByPointSec ) |
907 iLockedByBackupRestore = ETrue; |
889 { |
908 SendSystemLockMessage( EMsgStoreBackupOrRestoreInProgress ); |
890 LockSystem(); |
909 LockSystem(); |
891 } |
910 } |
892 |
911 |
893 __LOG_EXIT |
912 __LOG_EXIT |
894 } // end BackupOrRestoreInProgress |
913 } // end BackupOrRestoreInProgress |
898 // ========================================================================== |
917 // ========================================================================== |
899 void CMessageStoreServer::BackupOrRestoreCompleted() |
918 void CMessageStoreServer::BackupOrRestoreCompleted() |
900 { |
919 { |
901 __LOG_ENTER( "BackupOrRestoreCompleted" ); |
920 __LOG_ENTER( "BackupOrRestoreCompleted" ); |
902 |
921 |
903 SendSystemLockMessage( EMsgStoreBackupOrRestoreCompleted ); |
922 if ( iLockedByBackupRestore ) |
904 |
923 { |
905 if ( !iLockedByPointSec ) |
924 iLockedByBackupRestore = EFalse; |
906 { |
925 SendSystemLockMessage( EMsgStoreBackupOrRestoreCompleted ); |
907 TRAP_IGNORE( UnlockSystemL() ); |
926 TRAP_IGNORE( UnlockSystemL() ); |
908 } |
927 } |
909 |
928 |
910 __LOG_EXIT |
929 __LOG_EXIT |
911 } // end BackupOrRestoreCompleted |
930 } // end BackupOrRestoreCompleted |
936 __LOG_ENTER( "PointSecLockEnded" ); |
952 __LOG_ENTER( "PointSecLockEnded" ); |
937 if ( iLockedByPointSec ) |
953 if ( iLockedByPointSec ) |
938 { |
954 { |
939 iLockedByPointSec = EFalse; |
955 iLockedByPointSec = EFalse; |
940 SendSystemLockMessage( EMsgStorePointSecLockEnded ); |
956 SendSystemLockMessage( EMsgStorePointSecLockEnded ); |
941 if ( !iLockedByBackupRestore ) |
957 TRAP_IGNORE( UnlockSystemL() ); |
942 { |
958 } |
943 TRAP_IGNORE( UnlockSystemL() ); |
959 __LOG_EXIT |
|
960 } |
|
961 |
|
962 // ========================================================================== |
|
963 // FUNCTION: LockSystem |
|
964 // ========================================================================== |
|
965 void CMessageStoreServer::LockSystem() |
|
966 { |
|
967 __LOG_ENTER( "LockSystem" ); |
|
968 |
|
969 if ( iMessageStore ) |
|
970 { |
|
971 SendSystemLockMessage( EMsgStoreUnavailable ); |
|
972 |
|
973 for( TInt i = 0; i < iSessions.Count(); i++ ) |
|
974 { |
|
975 iSessions[i]->ContainerStoreUnavailable(); |
|
976 } // end if |
|
977 |
|
978 delete iMessageStore; |
|
979 iMessageStore = NULL; |
|
980 } |
|
981 |
|
982 __LOG_EXIT |
|
983 } |
|
984 |
|
985 // ========================================================================== |
|
986 // FUNCTION: UnlockSystemL |
|
987 // ========================================================================== |
|
988 void CMessageStoreServer::UnlockSystemL() |
|
989 { |
|
990 __LOG_ENTER( "UnlockSystemL" ); |
|
991 |
|
992 if ( ( !iLockedByBackupRestore ) |
|
993 && ( !iLockedByPointSec ) ) |
|
994 { |
|
995 TRAPD( result, |
|
996 CreateContainerStoreL(); CreatePredefinedFoldersIfNeededL(); ); |
|
997 |
|
998 if( result != KErrNone ) |
|
999 { |
|
1000 __LOG_WRITE_ERROR( "failed to recreate message store after system lock" ) |
|
1001 |
|
1002 // The server is in a very bad state. Shut down the server immediately. |
|
1003 iShutdown->ShutDownNow(); |
944 } |
1004 } |
945 } |
1005 else if ( ( !iLockedByBackupRestore ) |
946 __LOG_EXIT |
1006 && ( !iLockedByPointSec ) ) |
947 } |
1007 { |
948 |
1008 SendSystemLockMessage( EMsgStoreAvailable ); |
949 // ========================================================================== |
1009 |
950 // FUNCTION: LockSystem |
1010 for( TInt i = 0; i < iSessions.Count(); i++ ) |
951 // ========================================================================== |
1011 { |
952 void CMessageStoreServer::LockSystem() |
1012 iSessions[i]->ContainerStoreAvailable(); |
953 { |
1013 } // end if |
954 __LOG_ENTER( "LockSystem" ); |
1014 |
955 |
1015 if( iWipeAfterBackupRestore ) |
956 for( TInt i = 0; i < iSessions.Count(); i++ ) |
1016 { |
957 { |
1017 iWipeAfterBackupRestore = EFalse; |
958 iSessions[i]->ContainerStoreUnavailable(); |
1018 WipeEverythingL(); |
959 } // end if |
1019 } // end if |
960 |
1020 |
961 delete iMessageStore; |
|
962 iMessageStore = NULL; |
|
963 |
|
964 __LOG_EXIT |
|
965 } |
|
966 |
|
967 // ========================================================================== |
|
968 // FUNCTION: UnlockSystemL |
|
969 // ========================================================================== |
|
970 void CMessageStoreServer::UnlockSystemL() |
|
971 { |
|
972 __LOG_ENTER( "UnlockSystemL" ); |
|
973 |
|
974 TRAPD( result, |
|
975 CreateContainerStoreL(); CreatePredefinedFoldersIfNeededL(); ); |
|
976 |
|
977 if( result != 0 ) |
|
978 { |
|
979 __LOG_WRITE_ERROR( "failed to recreate message store after system lock" ) |
|
980 |
|
981 // The server is in a very bad state. Shut down the server immediately. |
|
982 iShutdown->ShutDownNow(); |
|
983 } |
|
984 else if ( ( !iLockedByBackupRestore ) |
|
985 && ( !iLockedByPointSec ) ) |
|
986 { |
|
987 |
|
988 for( TInt i = 0; i < iSessions.Count(); i++ ) |
|
989 { |
|
990 iSessions[i]->ContainerStoreAvailable(); |
|
991 } // end if |
1021 } // end if |
992 |
|
993 if( iWipeAfterBackupRestore ) |
|
994 { |
|
995 iWipeAfterBackupRestore = EFalse; |
|
996 WipeEverythingL(); |
|
997 } // end if |
|
998 |
|
999 } // end if |
1022 } // end if |
1000 |
1023 |
1001 __LOG_EXIT |
1024 __LOG_EXIT |
1002 } |
1025 } |
1003 |
1026 |