ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp
branchRCL_3
changeset 24 d189ee25cf9d
parent 16 b5fbb9b25d57
child 25 3533d4323edc
equal deleted inserted replaced
23:dcf0eedfc1a3 24:d189ee25cf9d
   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     iConnOpCallbacks.Close();
   108 // <qmail> iConnOpCallbacks, iSettingsApi members removed
   109     delete iSettingsApi;
       
   110     iImapFolderIds.Close();
   109     iImapFolderIds.Close();
   111     }
   110     }
   112 
   111 
   113 // ---------------------------------------------------------------------------
   112 // ---------------------------------------------------------------------------
   114 // ---------------------------------------------------------------------------
   113 // ---------------------------------------------------------------------------
   117     :iBasePlugin( aBasePlugin ),
   116     :iBasePlugin( aBasePlugin ),
   118     iMBoxObservers( KEventGranularity ),
   117     iMBoxObservers( KEventGranularity ),
   119     iIPSAccounts( KEventGranularity ),
   118     iIPSAccounts( KEventGranularity ),
   120     iIPSSettingsObservers( KEventGranularity ),
   119     iIPSSettingsObservers( KEventGranularity ),
   121     iIsConnected( EFalse ),
   120     iIsConnected( EFalse ),
   122     iPropertyObservers( KEventGranularity ),
   121     iPropertyObservers( KEventGranularity )
   123     iConnOpCallbacks( KEventGranularity )
       
   124     {
   122     {
   125     FUNC_LOG;
   123     FUNC_LOG;
   126     }
   124     }
   127 
   125 
   128 // ---------------------------------------------------------------------------
   126 // ---------------------------------------------------------------------------
   129 // ---------------------------------------------------------------------------
   127 // ---------------------------------------------------------------------------
   130 void CIpsPlgEventHandler::ConstructL( )
   128 void CIpsPlgEventHandler::ConstructL( )
   131     {
   129     {
   132     FUNC_LOG;
   130     FUNC_LOG;
   133     iCenRep = CRepository::NewL( KCRUidExtendedSettingsUid );
   131 // <qmail>
       
   132     // commented out from qmail when extented settings 
       
   133     // cen rep not exist in environment
       
   134     //iCenRep = CRepository::NewL( KCRUidExtendedSettingsUid );
       
   135 // </qmail>
   134     iPluginId = iBasePlugin.PluginId();
   136     iPluginId = iBasePlugin.PluginId();
   135     RegisterPropertyObserverL( this );
   137     RegisterPropertyObserverL( this );
   136     }
   138     }
   137 
   139 
   138 // ----------------------------------------------------------------------------
   140 // ----------------------------------------------------------------------------
   139 // ----------------------------------------------------------------------------
   141 // ----------------------------------------------------------------------------
   140 void CIpsPlgEventHandler::CompleteConstructL( CMsvSession* aSession )
   142 void CIpsPlgEventHandler::CompleteConstructL( CMsvSession* aSession )
   141     {
   143     {
   142     FUNC_LOG;
   144     FUNC_LOG;
   143     iSession = aSession;
   145     iSession = aSession;
   144     iSettingsApi = CIpsSetDataApi::NewL( *iSession );
   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 );
   150     for ( TInt i = 0; i < iMBoxObservers.Count(); i++ )
   152     for ( TInt i = 0; i < iMBoxObservers.Count(); i++ )
   151         {
   153         {
   152         TMsvId mboxId = iMBoxObservers[i]->iMBoxId.Id();
   154         TMsvId mboxId = iMBoxObservers[i]->iMBoxId.Id();
   153         if ( mboxes.Find(mboxId) == KErrNotFound )
   155         if ( mboxes.Find(mboxId) == KErrNotFound )
   154             {
   156             {
   155             mboxes.Append( mboxId );
   157             mboxes.AppendL( mboxId );
   156             }
   158             }
   157         }
   159         }
   158 
   160 
   159     for ( TInt i = 0; i < mboxes.Count(); i++ )
   161     for ( TInt i = 0; i < mboxes.Count(); i++ )
   160         {
   162         {
   202     return error;
   204     return error;
   203     }
   205     }
   204 
   206 
   205 // ----------------------------------------------------------------------------
   207 // ----------------------------------------------------------------------------
   206 // ----------------------------------------------------------------------------
   208 // ----------------------------------------------------------------------------
   207 TInt CIpsPlgEventHandler::RegisterPropertyObserverL(
   209 void CIpsPlgEventHandler::RegisterPropertyObserverL(
   208         MIpsPlgPropertyObserver* aObserver )
   210         MIpsPlgPropertyObserver* aObserver )
   209     {
   211     {
   210     FUNC_LOG;
   212     FUNC_LOG;
   211     if ( !aObserver )
   213     if ( !aObserver )
   212         {
   214         {
   217         {
   219         {
   218         iPropertyWatcher = CIpsPlgPropertyWatcher::NewL(
   220         iPropertyWatcher = CIpsPlgPropertyWatcher::NewL(
   219                 CActive::EPriorityIdle, *this );
   221                 CActive::EPriorityIdle, *this );
   220         }
   222         }
   221 
   223 
   222     return iPropertyObservers.Append( aObserver );
   224     iPropertyObservers.AppendL( aObserver );
   223     }
   225     }
   224 
   226 
   225 // ----------------------------------------------------------------------------
   227 // ----------------------------------------------------------------------------
   226 // ----------------------------------------------------------------------------
   228 // ----------------------------------------------------------------------------
   227 void CIpsPlgEventHandler::UnRegisterPropertyObserver(
   229 void CIpsPlgEventHandler::UnRegisterPropertyObserver(
   247 // ----------------------------------------------------------------------------
   249 // ----------------------------------------------------------------------------
   248 void CIpsPlgEventHandler::NotifyPropertyEventL(
   250 void CIpsPlgEventHandler::NotifyPropertyEventL(
   249         TIpsPlgPropertyEvent aEvent )
   251         TIpsPlgPropertyEvent aEvent )
   250     {
   252     {
   251     FUNC_LOG;
   253     FUNC_LOG;
   252     TBool doNotify = ETrue;
   254     INFO_1("pluginid == 0x%x", iPluginId);
       
   255    //<qmail> not used: TBool doNotify = ETrue;
   253     switch ( aEvent.iEvent )
   256     switch ( aEvent.iEvent )
   254         {
   257         {
   255         case KIpsSosEmailSyncStarted:
   258         case KIpsSosEmailSyncStarted:
   256             SignalStartSyncL( TFSMailMsgId( aEvent.iPluginId,
   259             SignalStartSyncL( TFSMailMsgId( aEvent.iPluginId,
   257                     aEvent.iMailbox ) );
   260                     aEvent.iMailbox ) );
   263                 }
   266                 }
   264             break;
   267             break;
   265         default:
   268         default:
   266             break;
   269             break;
   267         }
   270         }
   268 
   271     // <qmail> removed doNotify bool below
   269     for ( TInt i = 0; doNotify && i < iPropertyObservers.Count(); i++ )
   272     for ( TInt i = 0; i < iPropertyObservers.Count(); i++ )
   270         {
   273         {
   271         TRAP_IGNORE( iPropertyObservers[i]->HandlePropertyEventL(
   274         TRAP_IGNORE( iPropertyObservers[i]->HandlePropertyEventL(
   272                 aEvent.iEvent,  aEvent.iMailbox,
   275                 aEvent.iEvent,  aEvent.iMailbox,
   273                 aEvent.iPluginId, aEvent.iError ) );
   276                 aEvent.iPluginId, aEvent.iError ) );
   274         }
   277         }
   487     return SymId2FsId( aEntry.Id(), aEntry.iMtm.iUid );
   490     return SymId2FsId( aEntry.Id(), aEntry.iMtm.iUid );
   488     }
   491     }
   489 
   492 
   490 // ---------------------------------------------------------------------------
   493 // ---------------------------------------------------------------------------
   491 // ---------------------------------------------------------------------------
   494 // ---------------------------------------------------------------------------
   492 inline void CIpsPlgEventHandler::FillFSMessageArray(
   495 inline void CIpsPlgEventHandler::FillFSMessageArrayL(
   493     RArray<TFSMailMsgId>& aFSArray,
   496     RArray<TFSMailMsgId>& aFSArray,
   494     const CMsvEntrySelection* aSelection,
   497     const CMsvEntrySelection* aSelection,
   495     TUint aMtmUid )
   498     TUint aMtmUid )
   496     {
   499     {
   497     FUNC_LOG;
   500     FUNC_LOG;
   499     __ASSERT_DEBUG( ( aFSArray.Count() == 0 ),
   502     __ASSERT_DEBUG( ( aFSArray.Count() == 0 ),
   500         User::Panic( KIpsPlgEventHandlerPanic, KErrGeneral ) );
   503         User::Panic( KIpsPlgEventHandlerPanic, KErrGeneral ) );
   501 
   504 
   502     for ( TInt i = 0; i < aSelection->Count(); i++ )
   505     for ( TInt i = 0; i < aSelection->Count(); i++ )
   503         {
   506         {
   504         aFSArray.Append( SymId2FsId(aSelection->At(i), aMtmUid) );
   507         aFSArray.AppendL( SymId2FsId(aSelection->At(i), aMtmUid) );
   505         }
   508         }
   506     }
   509     }
   507 
   510 
   508 // ----------------------------------------------------------------------------
   511 // ----------------------------------------------------------------------------
   509 // ----------------------------------------------------------------------------
   512 // ----------------------------------------------------------------------------
   656         
   659         
   657         
   660         
   658         if ( type == KUidMsvMessageEntry && !isMarkedAsDeleted )
   661         if ( type == KUidMsvMessageEntry && !isMarkedAsDeleted )
   659             {
   662             {
   660             TMsvId* parent = static_cast<TMsvId*>(aArg2);
   663             TMsvId* parent = static_cast<TMsvId*>(aArg2);
       
   664             // NOTE: assumed that event contains only one new message
   661             event = TFSEventNewMail;
   665             event = TFSEventNewMail;
   662             TFSMailMsgId mbox;
   666             TFSMailMsgId mbox;
   663 
   667 
   664             if ( tNew.iServiceId == KMsvLocalServiceIndexEntryIdValue
   668             if ( tNew.iServiceId == KMsvLocalServiceIndexEntryIdValue
   665                 || tNew.Parent() == KMsvDraftEntryIdValue )
   669                 || tNew.Parent() == KMsvDraftEntryIdValue )
   688 
   692 
   689             // set entries array pointer
   693             // set entries array pointer
   690             RArray<TFSMailMsgId> array(KEventGranularity);
   694             RArray<TFSMailMsgId> array(KEventGranularity);
   691             CleanupClosePushL( array );
   695             CleanupClosePushL( array );
   692 
   696 
   693             FillFSMessageArray(
   697             FillFSMessageArrayL(
   694                 array,
   698                 array,
   695                 static_cast<const CMsvEntrySelection*>(aArg1),
   699                 static_cast<const CMsvEntrySelection*>(aArg1),
   696                 tNew.iMtm.iUid );
   700                 tNew.iMtm.iUid );
   697             arg1 = static_cast<TAny*>(&array);
   701             arg1 = static_cast<TAny*>(&array);
   698 
   702 
   711             mbox = SymId2FsId( tNew.iServiceId, tNew.iMtm.iUid );
   715             mbox = SymId2FsId( tNew.iServiceId, tNew.iMtm.iUid );
   712 
   716 
   713             // set entries array pointer
   717             // set entries array pointer
   714             RArray<TFSMailMsgId> array(1);
   718             RArray<TFSMailMsgId> array(1);
   715             CleanupClosePushL( array );
   719             CleanupClosePushL( array );
   716             array.Append( SymId2FsId( tNew ) );
   720             array.AppendL( SymId2FsId( tNew ) );
   717             arg1 = &array;
   721             arg1 = &array;
   718 
   722 
   719             // set parent pointer
   723             // set parent pointer
   720             TMsvId* parent = static_cast<TMsvId*>(aArg2);
   724             TMsvId* parent = static_cast<TMsvId*>(aArg2);
   721             TFSMailMsgId tfsid( iPluginId, *parent);
   725             TFSMailMsgId tfsid( iPluginId, *parent);
   760 
   764 
   761         TFSMailEvent event( TFSMailboxUnavailable );
   765         TFSMailEvent event( TFSMailboxUnavailable );
   762 
   766 
   763         RArray<TFSMailMsgId> array(KEventGranularity);
   767         RArray<TFSMailMsgId> array(KEventGranularity);
   764         CleanupClosePushL( array );
   768         CleanupClosePushL( array );
   765         FillFSMessageArray(
   769         FillFSMessageArrayL(
   766             array,
   770             array,
   767             static_cast<const CMsvEntrySelection*>(aArg1),
   771             static_cast<const CMsvEntrySelection*>(aArg1),
   768             tMoved.iMtm.iUid );
   772             tMoved.iMtm.iUid );
   769 
   773 
   770         arg1 = &array;
   774         arg1 = &array;
   929                         arg3 );
   933                         arg3 );
   930                     }
   934                     }
   931                 }
   935                 }
   932             else
   936             else
   933                 {
   937                 {
   934                 array.Append( SymId2FsId(deletedId, tEntry.iMtm.iUid) );
   938                 array.AppendL( SymId2FsId(deletedId, tEntry.iMtm.iUid) );
   935                 arg1 = &array;
   939                 arg1 = &array;
   936                 arg2 = &parentId;
   940                 arg2 = &parentId;
   937 
   941 
   938                 event = TFSEventFoldersDeleted;
   942                 event = TFSEventFoldersDeleted;
   939                 SendDelayedEventL(
   943                 SendDelayedEventL(
   986                 return;
   990                 return;
   987                 }
   991                 }
   988 
   992 
   989             RArray<TFSMailMsgId> array(1);
   993             RArray<TFSMailMsgId> array(1);
   990             CleanupClosePushL( array );
   994             CleanupClosePushL( array );
   991             array.Append( msg );
   995             array.AppendL( msg );
   992             arg1 = &array;
   996             arg1 = &array;
   993             arg2 = &parent;
   997             arg2 = &parent;
   994             event = TFSEventMailDeleted;
   998             event = TFSEventMailDeleted;
   995             SendDelayedEventL(
   999             SendDelayedEventL(
   996                 event,
  1000                 event,
  1019     FUNC_LOG;
  1023     FUNC_LOG;
  1020     TAny* arg1=NULL;
  1024     TAny* arg1=NULL;
  1021     TAny* arg2=NULL;
  1025     TAny* arg2=NULL;
  1022     TAny* arg3=NULL;
  1026     TAny* arg3=NULL;
  1023 
  1027 
       
  1028     TInt errorCode( KErrNone ); // <qmail>
       
  1029 
  1024     TUid uId;
  1030     TUid uId;
  1025     TMsvEntry tChanged;
  1031     TMsvEntry tChanged;
  1026     if ( !IsEventFromIpsSourceL( aArg1, uId, tChanged ) )
  1032     if ( !IsEventFromIpsSourceL( aArg1, uId, tChanged ) )
  1027         {
  1033         {
  1028         return;
  1034         return;
  1029         }
  1035         }
  1030     else if ( tChanged.iMtm.iUid == KSenduiMtmSmtpUidValue )
  1036 //<Qmail>
  1031         {
  1037     
  1032         // do not send entry changed events from draft messages
  1038 //</Qmail>
  1033         // mess up draft email
       
  1034         return;
       
  1035         }
       
  1036 
       
  1037     TFSMailEvent event = static_cast<TFSMailEvent>( KErrNotFound );
  1039     TFSMailEvent event = static_cast<TFSMailEvent>( KErrNotFound );
  1038 
  1040 
  1039     RArray<TFSMailMsgId> array(1);
  1041     RArray<TFSMailMsgId> array(1);
  1040     CleanupClosePushL( array );
  1042     CleanupClosePushL( array );
  1041 
  1043 
  1050             {
  1052             {
  1051             event = TFSEventMailChanged;
  1053             event = TFSEventMailChanged;
  1052             }
  1054             }
  1053 
  1055 
  1054         // message entry
  1056         // message entry
  1055         array.Append( SymId2FsId( tChanged )  );
  1057         array.AppendL( SymId2FsId( tChanged )  );
  1056         arg1 = &array;
  1058         arg1 = &array;
  1057 
  1059 
  1058         // parent entry
  1060         // parent entry
  1059         TFSMailMsgId id = SymId2FsId( *(static_cast<TMsvId*>(aArg2)), tChanged.iMtm.iUid );
  1061         TFSMailMsgId id = SymId2FsId( *(static_cast<TMsvId*>(aArg2)), tChanged.iMtm.iUid );
  1060         arg2 = &id;
  1062         arg2 = &id;
  1062         }
  1064         }
  1063     else if ( tChanged.iType == KUidMsvFolderEntry )
  1065     else if ( tChanged.iType == KUidMsvFolderEntry )
  1064         {
  1066         {
  1065         event = TFSEventFolderChanged;
  1067         event = TFSEventFolderChanged;
  1066 
  1068 
  1067         array.Append( SymId2FsId( tChanged ) );
  1069         array.AppendL( SymId2FsId( tChanged ) );
  1068         arg1 = &array;
  1070         arg1 = &array;
  1069 
  1071 
  1070         TFSMailMsgId id = SymId2FsId( *(static_cast<TMsvId*>(aArg2)), tChanged.iMtm.iUid );
  1072         TFSMailMsgId id = SymId2FsId( *(static_cast<TMsvId*>(aArg2)), tChanged.iMtm.iUid );
  1071         arg2 = &id;
  1073         arg2 = &id;
  1072 
  1074 
  1074             {
  1076             {
  1075             TMsvEmailEntry eml( tChanged );
  1077             TMsvEmailEntry eml( tChanged );
  1076             TInt index = iImapFolderIds.Find(tChanged.Id());
  1078             TInt index = iImapFolderIds.Find(tChanged.Id());
  1077             if ( eml.LocalSubscription() && index == KErrNotFound )
  1079             if ( eml.LocalSubscription() && index == KErrNotFound )
  1078                 {
  1080                 {
  1079                 iImapFolderIds.Append( tChanged.Id() );
  1081                 iImapFolderIds.AppendL( tChanged.Id() );
  1080                 }
  1082                 }
  1081             else if ( !eml.LocalSubscription() && index != KErrNotFound )
  1083             else if ( !eml.LocalSubscription() && index != KErrNotFound )
  1082                 {
  1084                 {
  1083                 iImapFolderIds.Remove( index );
  1085                 iImapFolderIds.Remove( index );
  1084                 }
  1086                 }
  1091             {
  1093             {
  1092             event = TFSEventMailboxOnline;
  1094             event = TFSEventMailboxOnline;
  1093             }
  1095             }
  1094         else
  1096         else
  1095             {
  1097             {
       
  1098             // <qmail> add error code
  1096             event = TFSEventMailboxOffline;
  1099             event = TFSEventMailboxOffline;
       
  1100             const CMsvEntrySelection* selection = static_cast<CMsvEntrySelection*>( aArg1 );
       
  1101             TFSMailMsgId mailboxId( iPluginId, selection->At(0) );
       
  1102 
       
  1103             if ( !(iBasePlugin.HasOperations( mailboxId )) && iBasePlugin.ActivityTimerL( mailboxId ).IsActive() )
       
  1104                 {
       
  1105                 // considering this disconnection event as unexpected
       
  1106                 errorCode = KErrDisconnected;
       
  1107                 arg1 = &errorCode;
       
  1108                 }
       
  1109             // </qmail>
  1097             }
  1110             }
  1098         }
  1111         }
  1099     else if( IsAccountNameChangeL( aArg1, aArg2 ) )
  1112     else if( IsAccountNameChangeL( aArg1, aArg2 ) )
  1100         {
  1113         {
  1101         event = TFSEventMailboxRenamed;
  1114         event = TFSEventMailboxRenamed;
  1194 
  1207 
  1195 // ---------------------------------------------------------------------------
  1208 // ---------------------------------------------------------------------------
  1196 // ---------------------------------------------------------------------------
  1209 // ---------------------------------------------------------------------------
  1197 TUid CIpsPlgEventHandler::MtmId() const
  1210 TUid CIpsPlgEventHandler::MtmId() const
  1198     {
  1211     {
  1199     return iBasePlugin.MtmId();
  1212     TUid ret = KSenduiMtmImap4Uid;
       
  1213     if ( iBasePlugin.MtmId().iUid == KIpsPlgPop3PluginUidValue )
       
  1214         {
       
  1215         ret = KSenduiMtmPop3Uid;
       
  1216         }
       
  1217     return ret;
  1200     }
  1218     }
  1201 //</cmail>
  1219 //</cmail>
  1202 // ----------------------------------------------------------------------------
  1220 // ----------------------------------------------------------------------------
  1203 // ----------------------------------------------------------------------------    
  1221 // ----------------------------------------------------------------------------    
  1204 TBool CIpsPlgEventHandler::IsConnectionChangeL( TAny* aArg1, TAny* aArg2 )
  1222 TBool CIpsPlgEventHandler::IsConnectionChangeL( TAny* aArg1, TAny* aArg2 )
  1322             break;
  1340             break;
  1323             }
  1341             }
  1324         }
  1342         }
  1325 
  1343 
  1326     RPointerArray<MFSMailEventObserver> observers;
  1344     RPointerArray<MFSMailEventObserver> observers;
  1327     CleanupClosePushL( observers );  // not owning classes
       
  1328     MailboxObserversL( aAccount, observers );
  1345     MailboxObserversL( aAccount, observers );
  1329 
  1346 
  1330     if ( find != KErrNotFound )
  1347     if ( find != KErrNotFound )
  1331         {
  1348         {
  1332         iIPSSettingsObservers[find]->SetKeyAndActivateL( aSettingKey, observers );
  1349         iIPSSettingsObservers[find]->SetKeyAndActivateL( aSettingKey, observers );
  1333         }
  1350         }
  1334     else
  1351     else
  1335         {
  1352         {
  1336         CIpsPlgSettingsObserver* obs =
  1353 // <qmail>
       
  1354         // commented out from qmail when extented settings 
       
  1355         // cen rep not exist in environment
       
  1356         /*CIpsPlgSettingsObserver* obs =
  1337             CIpsPlgSettingsObserver::NewL( aAccount, *iCenRep, *this );
  1357             CIpsPlgSettingsObserver::NewL( aAccount, *iCenRep, *this );
  1338         obs->SetKeyAndActivateL( aSettingKey, observers );
  1358         obs->SetKeyAndActivateL( aSettingKey, observers );
  1339         iIPSSettingsObservers.AppendL( obs );
  1359         iIPSSettingsObservers.AppendL( obs );*/
  1340         }
  1360 // </qmail>
  1341     CleanupStack::PopAndDestroy( &observers );
  1361         }
       
  1362     observers.Close();
  1342     }
  1363     }
  1343 
  1364 
  1344 // ----------------------------------------------------------------------------
  1365 // ----------------------------------------------------------------------------
  1345 // ----------------------------------------------------------------------------
  1366 // ----------------------------------------------------------------------------
  1346 void CIpsPlgEventHandler::RemoveSettingsObserver( TFSMailMsgId aMailboxId )
  1367 void CIpsPlgEventHandler::RemoveSettingsObserver( TFSMailMsgId aMailboxId )
  1459         {
  1480         {
  1460         aFSParent.SetPluginId( TUid::Uid( iPluginId ) );
  1481         aFSParent.SetPluginId( TUid::Uid( iPluginId ) );
  1461         aFSParent.SetId( aParent.Id() );
  1482         aFSParent.SetId( aParent.Id() );
  1462         for ( TInt i = 0; i < aDeletedIds.Count(); i++ )
  1483         for ( TInt i = 0; i < aDeletedIds.Count(); i++ )
  1463             {
  1484             {
  1464             aFSDeletedArray.Append(
  1485             aFSDeletedArray.AppendL(
  1465                     TFSMailMsgId( iPluginId, aDeletedIds.At(i) ) );
  1486                     TFSMailMsgId( iPluginId, aDeletedIds.At(i) ) );
  1466             }
  1487             }
  1467         }
  1488         }
  1468     else
  1489     else
  1469         {
  1490         {
  1486 // ----------------------------------------------------------------------------
  1507 // ----------------------------------------------------------------------------
  1487 // ----------------------------------------------------------------------------
  1508 // ----------------------------------------------------------------------------
  1488 void CIpsPlgEventHandler::SignalStartSyncL( const TFSMailMsgId& aAccount )
  1509 void CIpsPlgEventHandler::SignalStartSyncL( const TFSMailMsgId& aAccount )
  1489     {
  1510     {
  1490     FUNC_LOG;
  1511     FUNC_LOG;
  1491     TFSMailEvent event = TFSEventMailboxSyncStateChanged;
  1512     // <qmail> no need to create event variable here
  1492     TSSMailSyncState state = StartingSync;
  1513     //    TFSMailEvent event = TFSEventMailboxSyncStateChanged;
  1493 
  1514     // <qmail> renamed variable
  1494     SaveSyncStatusL( aAccount.Id(), TInt( state ) );
  1515     TSSMailSyncState syncState( StartingSync );
       
  1516 
       
  1517     // <qmail> remove SaveSyncStatusL as it does nothing
       
  1518     // SaveSyncStatusL( aAccount.Id(), TInt( syncState ) );
  1495 
  1519 
  1496     SendDelayedEventL(
  1520     SendDelayedEventL(
  1497         event,
  1521         TFSEventMailboxSyncStateChanged,
  1498         aAccount,
  1522         aAccount,
  1499         &state,
  1523         &syncState,
  1500         NULL,
  1524         NULL,
  1501         NULL );
  1525         NULL );
  1502     }
  1526     }
  1503 
  1527 
  1504 // ----------------------------------------------------------------------------
  1528 // ----------------------------------------------------------------------------
  1505 // ----------------------------------------------------------------------------
  1529 // ----------------------------------------------------------------------------
  1506 void CIpsPlgEventHandler::SignalSyncCompletedL(
  1530 void CIpsPlgEventHandler::SignalSyncCompletedL( const TFSMailMsgId& aAccount, TInt aError )
  1507     const TFSMailMsgId& aAccount,
  1531     {
  1508     TInt aError )
  1532     FUNC_LOG;
  1509     {
  1533     // <qmail> no need to create event variable here
  1510     FUNC_LOG;
  1534     //    TFSMailEvent event = TFSEventMailboxSyncStateChanged;
  1511     TFSMailEvent event = TFSEventMailboxSyncStateChanged;
  1535     // <qmail> renamed variable, and setting value in new func
  1512 
  1536     TSSMailSyncState syncState = ConvertCompletionCode( aError );
  1513     TSSMailSyncState state = FinishedSuccessfully;
  1537 
  1514 
  1538     // <qmail> remove SaveSyncStatusL as it does nothing
  1515     if ( aError == KErrCancel )
  1539     //    SaveSyncStatusL( aAccount.Id(), TInt( syncState ) );
  1516         {
       
  1517         state = SyncCancelled;
       
  1518         }
       
  1519     else if ( aError != KErrNone && aError != KErrCancel )
       
  1520         {
       
  1521         state = SyncError;
       
  1522         }
       
  1523 
       
  1524     SaveSyncStatusL( aAccount.Id(), TInt( state ) );
       
  1525 
  1540 
  1526     SendDelayedEventL(
  1541     SendDelayedEventL(
  1527         event,
  1542         TFSEventMailboxSyncStateChanged,
  1528         aAccount,
  1543         aAccount,
  1529         &state,
  1544         &syncState,
  1530         NULL,
  1545         NULL,
  1531         NULL );
  1546         NULL );
  1532     }
  1547     }
  1533 
  1548 
  1534 // ----------------------------------------------------------------------------
  1549 // <qmail> new function
  1535 // ----------------------------------------------------------------------------
  1550 // ----------------------------------------------------------------------------
  1536 void CIpsPlgEventHandler::SignalMailboxOfflineStateL(
  1551 // ----------------------------------------------------------------------------
  1537     const TFSMailMsgId& aAccount )
  1552 TSSMailSyncState CIpsPlgEventHandler::ConvertCompletionCode( TInt aCompletionCode )
  1538     {
  1553     {
  1539     FUNC_LOG;
  1554     FUNC_LOG;
  1540     SendDelayedEventL(
  1555     INFO_1("completioncode == %d", aCompletionCode);
  1541         TFSEventMailboxOffline,
  1556     switch ( aCompletionCode )
  1542         aAccount,
  1557         {
  1543         NULL,
  1558         case KErrNone:
  1544         NULL,
  1559             return FinishedSuccessfully;
  1545         NULL );
  1560         case KErrCancel:
  1546     }
  1561             return SyncCancelled;
       
  1562         case KErrImapBadLogon:
       
  1563         case KPop3InvalidUser:
       
  1564         case KPop3InvalidLogin:
       
  1565         case KPop3InvalidApopLogin:
       
  1566             return PasswordNotVerified;
       
  1567         case -5120: // (DndTimedOut) wrong server name in settings
       
  1568         case KErrHostUnreach: // wrong port number
       
  1569             return ServerConnectionError;
       
  1570         case KErrTimedOut:
       
  1571         default:
       
  1572             return SyncError;
       
  1573         }
       
  1574     }
       
  1575 // </qmail>
       
  1576 
       
  1577 //<qmail> not used at all
       
  1578 // ----------------------------------------------------------------------------
       
  1579 // ----------------------------------------------------------------------------
       
  1580 //void CIpsPlgEventHandler::SignalMailboxOfflineStateL(
       
  1581 //    const TFSMailMsgId& aAccount )
       
  1582 //    {
       
  1583 //    FUNC_LOG;
       
  1584 //    SendDelayedEventL(
       
  1585 //        TFSEventMailboxOffline,
       
  1586 //        aAccount,
       
  1587 //        NULL,
       
  1588 //        NULL,
       
  1589 //        NULL );
       
  1590 //    }
       
  1591 // </qmail>
  1547 
  1592 
  1548 // ----------------------------------------------------------------------------
  1593 // ----------------------------------------------------------------------------
  1549 // ----------------------------------------------------------------------------
  1594 // ----------------------------------------------------------------------------
  1550 void CIpsPlgEventHandler::SettingsChangedL( TFSMailMsgId /*aAccount*/ )
  1595 void CIpsPlgEventHandler::SettingsChangedL( TFSMailMsgId /*aAccount*/ )
  1551     {
  1596     {
  1552     FUNC_LOG;
  1597     FUNC_LOG;
  1553     }
  1598     }
  1554 
  1599 
  1555 // ----------------------------------------------------------------------------
  1600 //<qmail> not used at all
  1556 // ----------------------------------------------------------------------------
  1601 // ----------------------------------------------------------------------------
  1557 void CIpsPlgEventHandler::SaveSyncStatusL( TMsvId aMailboxId, TInt aState )
  1602 // ----------------------------------------------------------------------------
  1558     {
  1603 //void CIpsPlgEventHandler::SaveSyncStatusL( TMsvId aMailboxId, TInt /*aState*/ )
  1559     FUNC_LOG;
  1604 //    {
  1560     TMsvEntry tEntry;
  1605 //    FUNC_LOG;
  1561     TMsvId service;
  1606 //    TMsvEntry tEntry;
  1562     if( !iSession )
  1607 //    TMsvId service;
  1563         {
  1608 //    if( !iSession )
  1564         User::Leave( KErrNotReady );
  1609 //        {
  1565         }
  1610 //        User::Leave( KErrNotReady );
  1566     TInt err = iSession->GetEntry( aMailboxId, service, tEntry );
  1611 //        }
  1567 
  1612 //    TInt err = iSession->GetEntry( aMailboxId, service, tEntry );
  1568     if( err == KErrNone )
  1613 //
  1569         {
  1614 //    if( err == KErrNone )
  1570         iSettingsApi->SaveSyncStatusL( tEntry, aState );
  1615 //        {
  1571         }
  1616 //        }
  1572     }
  1617 //    }
       
  1618 // </qmail>
  1573 
  1619 
  1574 // ----------------------------------------------------------------------------
  1620 // ----------------------------------------------------------------------------
  1575 // ----------------------------------------------------------------------------
  1621 // ----------------------------------------------------------------------------
  1576 void CIpsPlgEventHandler::HandlePropertyEventL(
  1622 void CIpsPlgEventHandler::HandlePropertyEventL(
  1577         TInt aEvent,
  1623     TInt aEvent,
  1578         TInt aMailbox,
  1624     TInt aMailbox,
  1579         TInt aPluginId,
  1625     TInt /*aPluginId*/,
  1580         TInt /*aError*/ )
  1626     TInt /*aError*/ )
  1581     {
  1627     {
  1582     FUNC_LOG;
  1628     FUNC_LOG;
  1583     RProcess process;
  1629 //  <qmail> remove these events 
  1584 
  1630 //    RProcess process;
  1585     // only email server should handle login notifications
  1631 //    if ( aEvent == EIPSSosPswErr && process.SecureId() == FREESTYLE_FSSERVER_SID )
  1586     if (( aEvent == EIPSSosPswErr || aEvent == EIPSSosSmtpPswErr ) &&
  1632 //        {
  1587           process.SecureId() == FREESTYLE_FSSERVER_SID &&
  1633 //        TFSMailMsgId mbox = SymId2FsId( aMailbox,
  1588           iQueryPassState == EReady &&
  1634 //                        iBasePlugin.MtmId().iUid );
  1589           iBasePlugin.PluginId() == aPluginId )
  1635 //        TFSMailEvent event = TFSEventException;
  1590         {
  1636 //        TFsEmailNotifierSystemMessageType msg = EFsEmailNotifErrLoginUnsuccesfull;
  1591         TFSMailMsgId mbox = SymId2FsId( aMailbox, iBasePlugin.MtmId().iUid );
  1637 //        SendDelayedEventL( event, mbox, &msg, NULL , (MFSMailExceptionEventCallback*)this );
  1592 
  1638 //        }
  1593         // keep information about type of mail we`re setting the password
  1639 //    else if ( aEvent == EIPSSosCredientialsSet || aEvent == EIPSSosCredientialsCancelled )
  1594         iIncomingPass = ( aEvent == EIPSSosPswErr ? ETrue : EFalse );
  1640 //        {
  1595         iQueryPassState = ENotificationRequest;
  1641 //        if ( iConnOpCallback )
  1596 
  1642 //            {
  1597         TFSMailEvent event = TFSEventException;
  1643 //            iConnOpCallback->CredientialsSetL( aEvent );
  1598         TFsEmailNotifierSystemMessageType msg = EFsEmailNotifErrLoginUnsuccesfull;
  1644 //
  1599         SendDelayedEventL( event, mbox, &msg, NULL, (MFSMailExceptionEventCallback*)this );
  1645 //            //Set to null after we have used this.
  1600         }
  1646 //            //don't delete, we don't own this.
  1601     else if ( aEvent == EIPSSosCredientialsSet || aEvent == EIPSSosCredientialsCancelled )
  1647 //            iConnOpCallback=NULL;
  1602         {
  1648 //            }
  1603         // if this handler invoked query user pass
  1649 //        //if password was changed, we need to send settings changed event also.
  1604         if ( iQueryPassState == EBusy )
  1650 //        if( aEvent == EIPSSosCredientialsSet )
  1605             {
  1651 //            {
  1606             iQueryPassState = ERequestResponding;
  1652 //            TFSMailMsgId mbox = SymId2FsId( aMailbox,
  1607             // run callbacks
  1653 //                    iBasePlugin.MtmId().iUid );
  1608             for ( TInt i = 0; i < iConnOpCallbacks.Count(); i++ )
  1654 //            TFSMailEvent event = TFSEventMailboxSettingsChanged;
  1609                 iConnOpCallbacks[i]->CredientialsSetL( aEvent );
  1655 //            SendDelayedEventL( event, mbox, NULL, NULL , NULL );
  1610 
  1656 //            }
  1611             iConnOpCallbacks.Reset();
  1657 //        }
  1612             // now handler is ready for another query user pass
  1658 //    else
  1613             iQueryPassState = EReady;
  1659 // </qmail>
  1614             }
  1660     if ( aEvent == EIPSSosSettingsChanged )
  1615 
       
  1616         //if password was changed, we need to send settings changed event also.
       
  1617         if( aEvent == EIPSSosCredientialsSet )
       
  1618             {
       
  1619             TFSMailMsgId mbox = SymId2FsId( aMailbox,
       
  1620                     iBasePlugin.MtmId().iUid );
       
  1621             TFSMailEvent event = TFSEventMailboxSettingsChanged;
       
  1622             SendDelayedEventL( event, mbox, NULL, NULL , NULL );
       
  1623             }
       
  1624         }
       
  1625     else if ( aEvent == EIPSSosSettingsChanged )
       
  1626         {
  1661         {
  1627         TFSMailMsgId mbox = SymId2FsId( aMailbox,
  1662         TFSMailMsgId mbox = SymId2FsId( aMailbox,
  1628                 iBasePlugin.MtmId().iUid );
  1663                 iBasePlugin.MtmId().iUid );
  1629         TFSMailEvent event = TFSEventMailboxSettingsChanged;
  1664         TFSMailEvent event = TFSEventMailboxSettingsChanged;
  1630         SendDelayedEventL( event, mbox, NULL, NULL , NULL );
  1665         SendDelayedEventL( event, mbox, NULL, NULL , NULL );
  1631         }
  1666         }
  1632     }
  1667 
  1633 
  1668 // <qmail> no need for KIpsSosEmailSyncCompleted event handling here,
  1634 // ----------------------------------------------------------------------------
  1669 // because it has just been sent in NotifyPropertyEventL()
  1635 // ----------------------------------------------------------------------------
  1670     }
  1636 TBool CIpsPlgEventHandler::QueryUsrPassL(
  1671 
  1637     TMsvId aMbox,
  1672 // <qmail> removing unused functions
  1638     MIpsPlgConnectOpCallback* aCallback/*=NULL*/,
  1673 // ----------------------------------------------------------------------------
  1639     TBool aIncoming/*=ETrue*/ )
  1674 // ----------------------------------------------------------------------------
  1640     {
  1675 //void CIpsPlgEventHandler::QueryUsrPassL( TMsvId aMbox, MIpsPlgConnectOpCallback* aCallback )
  1641     FUNC_LOG;
  1676 //    {
  1642 
  1677 //    FUNC_LOG;
  1643     ASSERT( iConnOpCallbacks.Find( aCallback ) == KErrNotFound );
  1678 //    iConnOpCallback = aCallback;//can be null, doesn't matter.
  1644     if ( aCallback )
  1679 //    SetNewPropertyEvent( aMbox, EIPSSosPswErr, 0 );
  1645         iConnOpCallbacks.Append( aCallback );
  1680 //    }
  1646 
  1681 
  1647     // set or re-set property event
  1682 // ----------------------------------------------------------------------------
  1648     SetNewPropertyEvent( aMbox, (aIncoming ? EIPSSosPswErr : EIPSSosSmtpPswErr), 0 );
  1683 // ----------------------------------------------------------------------------
  1649 
  1684 //void CIpsPlgEventHandler::SignalCredientialsSetL( TInt aMailboxId, TBool aCancelled )
  1650     // only one query at a time allowed
  1685 //    {
  1651     if ( iQueryPassState != EReady )
  1686 //    FUNC_LOG;
  1652         {
  1687 //    TInt event = EIPSSosCredientialsSet;
  1653         return EFalse;
  1688 //    if ( aCancelled )
  1654         }
  1689 //        {
  1655 
  1690 //        event = EIPSSosCredientialsCancelled;
  1656     // update state
  1691 //        }
  1657     iQueryPassState = EBusy;
  1692 //
  1658 
  1693 //    SetNewPropertyEvent( aMailboxId, event, 0 );
  1659     return ETrue;
  1694 //    }
  1660     }
  1695 // </qmail>
  1661 
       
  1662 // ----------------------------------------------------------------------------
       
  1663 // ----------------------------------------------------------------------------
       
  1664 TBool CIpsPlgEventHandler::IncomingPass() const
       
  1665     {
       
  1666     return iIncomingPass;
       
  1667     }
       
  1668 
       
  1669 // ----------------------------------------------------------------------------
       
  1670 // ----------------------------------------------------------------------------
       
  1671 void CIpsPlgEventHandler::SignalCredientialsSetL( TInt aMailboxId, TBool aCancelled )
       
  1672     {
       
  1673     FUNC_LOG;
       
  1674     if ( iQueryPassState == EPasswordRequest )
       
  1675         {
       
  1676         iQueryPassState = EReady;
       
  1677         iIncomingPass = ETrue;
       
  1678         }
       
  1679 
       
  1680     TInt event = EIPSSosCredientialsSet;
       
  1681     if ( aCancelled )
       
  1682         {
       
  1683         event = EIPSSosCredientialsCancelled;
       
  1684         }
       
  1685 
       
  1686     SetNewPropertyEvent( aMailboxId, event, 0 );
       
  1687     }
       
  1688 
  1696 
  1689 // ----------------------------------------------------------------------------
  1697 // ----------------------------------------------------------------------------
  1690 // ----------------------------------------------------------------------------
  1698 // ----------------------------------------------------------------------------
  1691 void CIpsPlgEventHandler::SetFolderIdToArrayL( TMsvId aNewId )
  1699 void CIpsPlgEventHandler::SetFolderIdToArrayL( TMsvId aNewId )
  1692     {
  1700     {
  1723     return match;
  1731     return match;
  1724     }
  1732     }
  1725 
  1733 
  1726 // ----------------------------------------------------------------------------
  1734 // ----------------------------------------------------------------------------
  1727 // ----------------------------------------------------------------------------
  1735 // ----------------------------------------------------------------------------
  1728 void CIpsPlgEventHandler::CollectSubscribedFoldersL( TMsvId aMailboxId )
  1736 void CIpsPlgEventHandler::CollectSubscribedFoldersL( TMsvId /*aMailboxId*/ )
  1729     {
  1737     {
  1730     FUNC_LOG;
  1738     FUNC_LOG;
  1731     if ( iSession )
  1739 // <qmail> code removed as it does nothing; keeping the func as it probably will be needed
  1732         {
  1740     }
  1733         iSettingsApi->GetSubscribedImapFoldersL( aMailboxId, iImapFolderIds );
  1741 
  1734         }
  1742 // <qmail> not needed
  1735     }
  1743 // ----------------------------------------------------------------------------
  1736 
  1744 // ----------------------------------------------------------------------------
  1737 // ----------------------------------------------------------------------------
  1745 //void CIpsPlgEventHandler::ExceptionEventCallbackL(
  1738 // ----------------------------------------------------------------------------
  1746 //        TFSMailMsgId aMailboxId,
  1739 void CIpsPlgEventHandler::ExceptionEventCallbackL(
  1747 //        TInt /*aEventType*/,
  1740         TFSMailMsgId aMailboxId,
  1748 //        TBool /*aResponse*/ )
  1741         TInt aEventType,
  1749 //    {
  1742         TBool /*aResponse*/ )
  1750 //    FUNC_LOG;
  1743     {
  1751 //    TFSMailEvent event = TFSEventMailboxSyncStateChanged;
  1744     FUNC_LOG;
  1752 //    TSSMailSyncState state = PasswordNotVerified;
  1745 
  1753 //
  1746     if ( aEventType == EFsEmailNotifErrLoginUnsuccesfull &&
  1754 //    SendDelayedEventL( event, aMailboxId, &state, NULL , NULL );
  1747          iQueryPassState == ENotificationRequest )
  1755 //    }
  1748         {
  1756 // </qmail>
  1749         iQueryPassState = EPasswordRequest;
       
  1750         TFSMailEvent event = TFSEventMailboxSyncStateChanged;
       
  1751         TSSMailSyncState state = PasswordNotVerified;
       
  1752 
       
  1753         SendDelayedEventL( event, aMailboxId, &state, NULL, NULL );
       
  1754         }
       
  1755     }
       
  1756 
  1757 
  1757 // End of File
  1758 // End of File
  1758 
  1759