18 |
18 |
19 #include "emailtrace.h" |
19 #include "emailtrace.h" |
20 #include <e32base.h> |
20 #include <e32base.h> |
21 // CRepository |
21 // CRepository |
22 #include <centralrepository.h> |
22 #include <centralrepository.h> |
|
23 #include <connect/sbdefs.h> |
23 |
24 |
24 // Email Framework APIs |
25 // Email Framework APIs |
25 //<cmail> |
26 //<cmail> |
26 #include "cfsmailcommon.h" |
27 #include "cfsmailcommon.h" |
27 #include "cfsmailclient.h" |
28 #include "cfsmailclient.h" |
57 CMailCpsSettings::~CMailCpsSettings() |
58 CMailCpsSettings::~CMailCpsSettings() |
58 { |
59 { |
59 FUNC_LOG; |
60 FUNC_LOG; |
60 Cancel(); |
61 Cancel(); |
61 iMailboxArray.Close(); |
62 iMailboxArray.Close(); |
|
63 delete iBackupRestoreSubscriber; |
62 delete iCenRep; |
64 delete iCenRep; |
63 } |
65 } |
64 |
66 |
65 // --------------------------------------------------------------------------- |
67 // --------------------------------------------------------------------------- |
66 // CMailCpsSettings::CMailCpsSettings |
68 // CMailCpsSettings::CMailCpsSettings |
68 // |
70 // |
69 CMailCpsSettings::CMailCpsSettings( CFSMailClient& aMailClient ) : |
71 CMailCpsSettings::CMailCpsSettings( CFSMailClient& aMailClient ) : |
70 CActive( EPriorityStandard ), |
72 CActive( EPriorityStandard ), |
71 iMailClient( aMailClient ), |
73 iMailClient( aMailClient ), |
72 iCenRep( NULL ), |
74 iCenRep( NULL ), |
73 iConfigData( 0 ) |
75 iConfigData( 0 ), |
|
76 iRestoreStarted( EFalse ), |
|
77 iBackupOngoing( EFalse ) |
74 { |
78 { |
75 FUNC_LOG; |
79 FUNC_LOG; |
76 CActiveScheduler::Add( this ); |
80 CActiveScheduler::Add( this ); |
77 } |
81 } |
78 |
82 |
85 FUNC_LOG; |
89 FUNC_LOG; |
86 // In case there is no repository available, following call will leave |
90 // In case there is no repository available, following call will leave |
87 // Trapping is done by MailServer infrastructure, not by CPS handler |
91 // Trapping is done by MailServer infrastructure, not by CPS handler |
88 // In practice, this is fatal to cps handling, and widget won't work |
92 // In practice, this is fatal to cps handling, and widget won't work |
89 iCenRep = CRepository::NewL( KCRUidCmailWidget ); |
93 iCenRep = CRepository::NewL( KCRUidCmailWidget ); |
|
94 iBackupRestoreSubscriber = CPSSubscriber::NewL( |
|
95 *this, KUidSystemCategory, conn::KUidBackupRestoreKey ); |
|
96 iBackupRestoreSubscriber->Subscribe(); |
90 LoadSettingsL(); // mailboxes etc. user changeable data |
97 LoadSettingsL(); // mailboxes etc. user changeable data |
91 LoadConfigurationL(); // internal configuration data |
98 LoadConfigurationL(); // internal configuration data |
92 } |
99 } |
93 |
100 |
94 // --------------------------------------------------------------------------- |
101 // --------------------------------------------------------------------------- |
96 // --------------------------------------------------------------------------- |
103 // --------------------------------------------------------------------------- |
97 // |
104 // |
98 void CMailCpsSettings::RunL() |
105 void CMailCpsSettings::RunL() |
99 { |
106 { |
100 FUNC_LOG; |
107 FUNC_LOG; |
101 StartObservingL(); |
108 if ( !BackupOrRestoreMode() ) |
102 LoadSettingsL(); // mailboxes etc. user changeable data |
109 { |
103 LoadConfigurationL(); // internal configuration data |
110 StartObservingL(); |
104 iObserver->SettingsChangedCallback(); |
111 LoadSettingsL(); // mailboxes etc. user changeable data |
|
112 LoadConfigurationL(); // internal configuration data |
|
113 iObserver->SettingsChangedCallback(); |
|
114 } |
105 } |
115 } |
106 |
116 |
107 // --------------------------------------------------------------------------- |
117 // --------------------------------------------------------------------------- |
108 // CMailCpsSettings::DoCancel |
118 // CMailCpsSettings::DoCancel |
109 // --------------------------------------------------------------------------- |
119 // --------------------------------------------------------------------------- |
346 TInt CMailCpsSettings::ResolveMailbox( const TInt aMailboxId, TFSMailMsgId& aMsg ) |
356 TInt CMailCpsSettings::ResolveMailbox( const TInt aMailboxId, TFSMailMsgId& aMsg ) |
347 { |
357 { |
348 FUNC_LOG; |
358 FUNC_LOG; |
349 RPointerArray<CFSMailBox> mailboxarray; |
359 RPointerArray<CFSMailBox> mailboxarray; |
350 TInt err = iMailClient.ListMailBoxes( TFSMailMsgId(), mailboxarray ); |
360 TInt err = iMailClient.ListMailBoxes( TFSMailMsgId(), mailboxarray ); |
351 INFO_1("CMailCpsSettings::ResolveMailbox():: ListMailBoxes() returns %d", err); |
361 INFO_1("CMAIL CMailCpsSettings::ResolveMailbox():: ListMailBoxes() returns %d", err); |
352 if( !err ) // KErrNone = 0 |
362 if( !err ) // KErrNone = 0 |
353 { |
363 { |
354 err = KErrNotFound; |
364 err = KErrNotFound; |
355 aMsg.SetId( aMailboxId ); |
365 aMsg.SetId( aMailboxId ); |
356 const TInt iiMax( mailboxarray.Count() ); |
366 const TInt iiMax( mailboxarray.Count() ); |
912 } |
922 } |
913 |
923 |
914 return ret; |
924 return ret; |
915 } |
925 } |
916 |
926 |
917 |
927 // --------------------------------------------------------------------------- |
918 |
928 // CMailCpsSettings::HandlePropertyChangedL |
919 |
929 // --------------------------------------------------------------------------- |
|
930 // |
|
931 void CMailCpsSettings::HandlePropertyChangedL( const TUid& aCategory, TInt aKey ) |
|
932 { |
|
933 FUNC_LOG; |
|
934 |
|
935 if ( aCategory == KUidSystemCategory && aKey == conn::KUidBackupRestoreKey ) |
|
936 { |
|
937 TInt keyVal = 0; |
|
938 const TInt error = RProperty::Get( KUidSystemCategory, conn::KUidBackupRestoreKey, keyVal ); |
|
939 if( error == KErrNone ) |
|
940 { |
|
941 const conn::TBURPartType partType = |
|
942 static_cast< conn::TBURPartType >( keyVal & conn::KBURPartTypeMask ); |
|
943 |
|
944 if ( keyVal != 0 ) |
|
945 { |
|
946 switch( partType ) |
|
947 { |
|
948 case conn::EBURRestoreFull: |
|
949 case conn::EBURRestorePartial: |
|
950 iRestoreStarted = ETrue; |
|
951 break; |
|
952 case conn::EBURBackupFull: |
|
953 case conn::EBURBackupPartial: |
|
954 iBackupOngoing = ETrue; |
|
955 break; |
|
956 case conn::EBURUnset: |
|
957 case conn::EBURNormal: |
|
958 default: |
|
959 iBackupOngoing = EFalse; |
|
960 break; |
|
961 } |
|
962 } |
|
963 } |
|
964 } |
|
965 } |
|
966 |
|
967 // ---------------------------------------------------------------------------- |
|
968 // CMailCpsHandler::BackupOrRestoreMode() |
|
969 // Check if phone is in backup/restore mode |
|
970 // ---------------------------------------------------------------------------- |
|
971 // |
|
972 TBool CMailCpsSettings::BackupOrRestoreMode() |
|
973 { |
|
974 FUNC_LOG; |
|
975 |
|
976 TBool backupOrRestore = EFalse; |
|
977 |
|
978 if ( iRestoreStarted || iBackupOngoing ) |
|
979 { |
|
980 backupOrRestore = ETrue; |
|
981 } |
|
982 return backupOrRestore; |
|
983 } |