103 } |
103 } |
104 delete iCenRep; |
104 delete iCenRep; |
105 iIPSSettingsObservers.ResetAndDestroy(); |
105 iIPSSettingsObservers.ResetAndDestroy(); |
106 iIPSSettingsObservers.Close(); |
106 iIPSSettingsObservers.Close(); |
107 iPropertyObservers.Close(); |
107 iPropertyObservers.Close(); |
|
108 // <qmail> iConnOpCallbacks, iSettingsApi members removed |
108 iImapFolderIds.Close(); |
109 iImapFolderIds.Close(); |
109 } |
110 } |
110 |
111 |
111 // --------------------------------------------------------------------------- |
112 // --------------------------------------------------------------------------- |
112 // --------------------------------------------------------------------------- |
113 // --------------------------------------------------------------------------- |
125 // --------------------------------------------------------------------------- |
126 // --------------------------------------------------------------------------- |
126 // --------------------------------------------------------------------------- |
127 // --------------------------------------------------------------------------- |
127 void CIpsPlgEventHandler::ConstructL( ) |
128 void CIpsPlgEventHandler::ConstructL( ) |
128 { |
129 { |
129 FUNC_LOG; |
130 FUNC_LOG; |
130 // <qmail> |
131 // <qmail> |
131 // commented out from qmail when extented settings |
132 // commented out from qmail when extented settings |
132 // cen rep not exist in environment |
133 // cen rep not exist in environment |
133 //iCenRep = CRepository::NewL( KCRUidExtendedSettingsUid ); |
134 //iCenRep = CRepository::NewL( KCRUidExtendedSettingsUid ); |
134 // </qmail> |
135 // </qmail> |
135 iPluginId = iBasePlugin.PluginId(); |
136 iPluginId = iBasePlugin.PluginId(); |
136 RegisterPropertyObserverL( this ); |
137 RegisterPropertyObserverL( this ); |
137 } |
138 } |
138 |
139 |
139 // ---------------------------------------------------------------------------- |
140 // ---------------------------------------------------------------------------- |
140 // ---------------------------------------------------------------------------- |
141 // ---------------------------------------------------------------------------- |
141 void CIpsPlgEventHandler::CompleteConstructL( CMsvSession* aSession ) |
142 void CIpsPlgEventHandler::CompleteConstructL( CMsvSession* aSession ) |
142 { |
143 { |
143 FUNC_LOG; |
144 FUNC_LOG; |
144 iSession = aSession; |
145 iSession = aSession; |
|
146 // <qmail> iSettingsApi member removed |
145 |
147 |
146 // this collects all folderids to array from mailboxes that |
148 // this collects all folderids to array from mailboxes that |
147 // have registered observers, this is need to do here because |
149 // have registered observers, this is need to do here because |
148 // observers might be registered before calling complete construct |
150 // observers might be registered before calling complete construct |
149 RArray<TMsvId> mboxes( KEventGranularity ); |
151 RArray<TMsvId> mboxes( KEventGranularity ); |
243 |
245 |
244 } |
246 } |
245 |
247 |
246 // ---------------------------------------------------------------------------- |
248 // ---------------------------------------------------------------------------- |
247 // ---------------------------------------------------------------------------- |
249 // ---------------------------------------------------------------------------- |
248 void CIpsPlgEventHandler::NotifyPropertyEventL( TIpsPlgPropertyEvent aEvent ) |
250 void CIpsPlgEventHandler::NotifyPropertyEventL( |
|
251 TIpsPlgPropertyEvent aEvent ) |
249 { |
252 { |
250 FUNC_LOG; |
253 FUNC_LOG; |
251 INFO_1("pluginid == 0x%x", iPluginId); |
254 INFO_1("pluginid == 0x%x", iPluginId); |
252 //<qmail> not used: TBool doNotify = ETrue; |
255 //<qmail> not used: TBool doNotify = ETrue; |
253 switch ( aEvent.iEvent ) |
256 switch ( aEvent.iEvent ) |
541 //other events go to mailbox specific observers |
545 //other events go to mailbox specific observers |
542 MailboxObserversL( aMailbox, observers ); |
546 MailboxObserversL( aMailbox, observers ); |
543 } |
547 } |
544 for( TInt i = 0; i < observers.Count(); ++i ) |
548 for( TInt i = 0; i < observers.Count(); ++i ) |
545 { |
549 { |
546 observers[i]->EventL( |
550 // ignore leave so that other observers get event even if |
|
551 // one leaves |
|
552 TRAP_IGNORE(observers[i]->EventL( |
547 event.iEvent, |
553 event.iEvent, |
548 event.iAccountId, |
554 event.iAccountId, |
549 event.iArg1, |
555 event.iArg1, |
550 event.iArg2, |
556 event.iArg2, |
551 event.iArg3 ); |
557 event.iArg3 )); |
552 } |
558 } |
553 observers.Close(); |
559 CleanupStack::PopAndDestroy( &observers ); |
554 } |
560 } |
555 |
561 |
556 // ---------------------------------------------------------------------------- |
562 // ---------------------------------------------------------------------------- |
557 // ---------------------------------------------------------------------------- |
563 // ---------------------------------------------------------------------------- |
558 void CIpsPlgEventHandler::IPSAccountsL() |
564 void CIpsPlgEventHandler::IPSAccountsL() |
638 tNew.iDetails, |
644 tNew.iDetails, |
639 mbox ) ); |
645 mbox ) ); |
640 SendDelayedEventL( event, mbox, |
646 SendDelayedEventL( event, mbox, |
641 arg1, arg2 , arg3 ); |
647 arg1, arg2 , arg3 ); |
642 } |
648 } |
643 if ( type == KUidMsvMessageEntry ) |
649 |
|
650 // discard any new mail events if message is marked as deleted in imap |
|
651 const TMsvEmailEntry& emlEntry(tNew); |
|
652 TBool isMarkedAsDeleted = EFalse; |
|
653 if ( mbox.PluginId() == KIpsPlgImap4PluginUid |
|
654 && (EDisconnectedDeleteOperation == emlEntry.DisconnectedOperation() |
|
655 || emlEntry.DeletedIMAP4Flag()) ) |
|
656 { |
|
657 isMarkedAsDeleted = ETrue; |
|
658 } |
|
659 |
|
660 |
|
661 if ( type == KUidMsvMessageEntry && !isMarkedAsDeleted ) |
644 { |
662 { |
645 TMsvId* parent = static_cast<TMsvId*>(aArg2); |
663 TMsvId* parent = static_cast<TMsvId*>(aArg2); |
646 // NOTE: assumed that event contains only one new message |
664 // NOTE: assumed that event contains only one new message |
647 event = TFSEventNewMail; |
665 event = TFSEventNewMail; |
648 TFSMailMsgId mbox; |
666 TFSMailMsgId mbox; |
686 TFSMailMsgId tfsid( iPluginId, *parent); |
705 TFSMailMsgId tfsid( iPluginId, *parent); |
687 arg2 = static_cast<TAny*>(&tfsid); |
706 arg2 = static_cast<TAny*>(&tfsid); |
688 |
707 |
689 SendDelayedEventL( event, mbox, |
708 SendDelayedEventL( event, mbox, |
690 arg1, arg2 , arg3 ); |
709 arg1, arg2 , arg3 ); |
691 array.Close(); |
710 CleanupStack::PopAndDestroy( &array ); |
692 } |
711 } |
693 else if ( type == KUidMsvFolderEntry ) |
712 else if ( type == KUidMsvFolderEntry ) |
694 { |
713 { |
695 event = TFSEventNewFolder; |
714 event = TFSEventNewFolder; |
696 mbox = SymId2FsId( tNew.iServiceId, tNew.iMtm.iUid ); |
715 mbox = SymId2FsId( tNew.iServiceId, tNew.iMtm.iUid ); |
697 |
716 |
698 // set entries array pointer |
717 // set entries array pointer |
699 RArray<TFSMailMsgId> array(1); |
718 RArray<TFSMailMsgId> array(1); |
|
719 CleanupClosePushL( array ); |
700 array.Append( SymId2FsId( tNew ) ); |
720 array.Append( SymId2FsId( tNew ) ); |
701 arg1 = &array; |
721 arg1 = &array; |
702 |
722 |
703 // set parent pointer |
723 // set parent pointer |
704 TMsvId* parent = static_cast<TMsvId*>(aArg2); |
724 TMsvId* parent = static_cast<TMsvId*>(aArg2); |
706 arg2 = static_cast<TAny*>(&tfsid); |
726 arg2 = static_cast<TAny*>(&tfsid); |
707 |
727 |
708 SendDelayedEventL( event, mbox, |
728 SendDelayedEventL( event, mbox, |
709 arg1, arg2 , arg3 ); |
729 arg1, arg2 , arg3 ); |
710 |
730 |
711 array.Close(); |
731 CleanupStack::PopAndDestroy( &array ); |
712 |
732 |
713 if( tNew.iMtm.iUid == KSenduiMtmImap4UidValue ) |
733 if( tNew.iMtm.iUid == KSenduiMtmImap4UidValue ) |
714 { |
734 { |
715 SetFolderIdToArrayL( tNew.Id() ); |
735 SetFolderIdToArrayL( tNew.Id() ); |
716 } |
736 } |
884 } |
905 } |
885 |
906 |
886 // message in remote folder (inbox) |
907 // message in remote folder (inbox) |
887 TFSMailMsgId mbox(iPluginId, tEntry.iServiceId ); |
908 TFSMailMsgId mbox(iPluginId, tEntry.iServiceId ); |
888 RArray<TFSMailMsgId> array( KEventGranularity ); |
909 RArray<TFSMailMsgId> array( KEventGranularity ); |
|
910 CleanupClosePushL( array ); |
889 TFSMailMsgId parentId( iPluginId, tEntry.Id() ); |
911 TFSMailMsgId parentId( iPluginId, tEntry.Id() ); |
890 |
|
891 |
912 |
892 if ( tEntry.iMtm.iUid == KSenduiMtmImap4UidValue ) |
913 if ( tEntry.iMtm.iUid == KSenduiMtmImap4UidValue ) |
893 { |
914 { |
894 isFolderId = MatchFolderIdFound( deletedId ); |
915 isFolderId = MatchFolderIdFound( deletedId ); |
895 } |
916 } |
1017 } |
1041 } |
1018 |
1042 |
1019 TFSMailEvent event = static_cast<TFSMailEvent>( KErrNotFound ); |
1043 TFSMailEvent event = static_cast<TFSMailEvent>( KErrNotFound ); |
1020 |
1044 |
1021 RArray<TFSMailMsgId> array(1); |
1045 RArray<TFSMailMsgId> array(1); |
|
1046 CleanupClosePushL( array ); |
1022 |
1047 |
1023 if ( tChanged.iType == KUidMsvMessageEntry ) |
1048 if ( tChanged.iType == KUidMsvMessageEntry ) |
1024 { |
1049 { |
1025 TMsvEmailEntry emailEntry(tChanged); |
1050 TMsvEmailEntry emailEntry(tChanged); |
1026 if( emailEntry.DeletedIMAP4Flag() /*|| tChanged.Deleted()*/ ) |
1051 if( emailEntry.DeletedIMAP4Flag() /*|| tChanged.Deleted()*/ ) |
1072 { |
1097 { |
1073 event = TFSEventMailboxOnline; |
1098 event = TFSEventMailboxOnline; |
1074 } |
1099 } |
1075 else |
1100 else |
1076 { |
1101 { |
|
1102 // <qmail> add error code |
1077 event = TFSEventMailboxOffline; |
1103 event = TFSEventMailboxOffline; |
|
1104 const CMsvEntrySelection* selection = static_cast<CMsvEntrySelection*>( aArg1 ); |
|
1105 TFSMailMsgId mailboxId( iPluginId, selection->At(0) ); |
|
1106 |
|
1107 if ( !(iBasePlugin.HasOperations( mailboxId )) && iBasePlugin.ActivityTimerL( mailboxId ).IsActive() ) |
|
1108 { |
|
1109 // considering this disconnection event as unexpected |
|
1110 errorCode = KErrDisconnected; |
|
1111 arg1 = &errorCode; |
|
1112 } |
|
1113 // </qmail> |
1078 } |
1114 } |
1079 } |
1115 } |
1080 else if( IsAccountNameChangeL( aArg1, aArg2 ) ) |
1116 else if( IsAccountNameChangeL( aArg1, aArg2 ) ) |
1081 { |
1117 { |
1082 event = TFSEventMailboxRenamed; |
1118 event = TFSEventMailboxRenamed; |
1106 } |
1142 } |
1107 |
1143 |
1108 SendDelayedEventL( event, |
1144 SendDelayedEventL( event, |
1109 mbox, arg1, arg2, arg3 ); |
1145 mbox, arg1, arg2, arg3 ); |
1110 } |
1146 } |
1111 array.Close(); |
1147 CleanupStack::PopAndDestroy( &array ); |
1112 // set null to prevent later usage in framework side |
1148 // set null to prevent later usage in framework side |
1113 // causes kern exec 3 panic... |
1149 // causes kern exec 3 panic... |
1114 arg1 = arg2 = arg3 = NULL; |
1150 arg1 = arg2 = arg3 = NULL; |
1115 } |
1151 } |
1116 //<cmail> |
1152 //<cmail> |
1316 { |
1352 { |
1317 iIPSSettingsObservers[find]->SetKeyAndActivateL( aSettingKey, observers ); |
1353 iIPSSettingsObservers[find]->SetKeyAndActivateL( aSettingKey, observers ); |
1318 } |
1354 } |
1319 else |
1355 else |
1320 { |
1356 { |
1321 // <qmail> |
1357 // <qmail> |
1322 // commented out from qmail when extented settings |
1358 // commented out from qmail when extented settings |
1323 // cen rep not exist in environment |
1359 // cen rep not exist in environment |
1324 /*CIpsPlgSettingsObserver* obs = |
1360 /*CIpsPlgSettingsObserver* obs = |
1325 CIpsPlgSettingsObserver::NewL( aAccount, *iCenRep, *this ); |
1361 CIpsPlgSettingsObserver::NewL( aAccount, *iCenRep, *this ); |
1326 obs->SetKeyAndActivateL( aSettingKey, observers ); |
1362 obs->SetKeyAndActivateL( aSettingKey, observers ); |
1327 iIPSSettingsObservers.AppendL( obs );*/ |
1363 iIPSSettingsObservers.AppendL( obs );*/ |
1328 // </qmail> |
1364 // </qmail> |
1329 } |
1365 } |
1330 observers.Close(); |
1366 observers.Close(); |
1331 } |
1367 } |
1332 |
1368 |
1333 // ---------------------------------------------------------------------------- |
1369 // ---------------------------------------------------------------------------- |
1518 // ---------------------------------------------------------------------------- |
1554 // ---------------------------------------------------------------------------- |
1519 // ---------------------------------------------------------------------------- |
1555 // ---------------------------------------------------------------------------- |
1520 TSSMailSyncState CIpsPlgEventHandler::ConvertCompletionCode( TInt aCompletionCode ) |
1556 TSSMailSyncState CIpsPlgEventHandler::ConvertCompletionCode( TInt aCompletionCode ) |
1521 { |
1557 { |
1522 FUNC_LOG; |
1558 FUNC_LOG; |
|
1559 INFO_1("completioncode == %d", aCompletionCode); |
1523 switch ( aCompletionCode ) |
1560 switch ( aCompletionCode ) |
1524 { |
1561 { |
1525 case KErrNone: |
1562 case KErrNone: |
1526 return FinishedSuccessfully; |
1563 return FinishedSuccessfully; |
1527 case KErrCancel: |
1564 case KErrCancel: |
1529 case KErrImapBadLogon: |
1566 case KErrImapBadLogon: |
1530 case KPop3InvalidUser: |
1567 case KPop3InvalidUser: |
1531 case KPop3InvalidLogin: |
1568 case KPop3InvalidLogin: |
1532 case KPop3InvalidApopLogin: |
1569 case KPop3InvalidApopLogin: |
1533 return PasswordNotVerified; |
1570 return PasswordNotVerified; |
|
1571 case -5120: // (DndTimedOut) wrong server name in settings |
|
1572 case KErrHostUnreach: // wrong port number |
|
1573 return ServerConnectionError; |
|
1574 case KErrTimedOut: |
1534 default: |
1575 default: |
1535 return SyncError; |
1576 return SyncError; |
1536 } |
1577 } |
1537 } |
1578 } |
1538 // </qmail> |
1579 // </qmail> |