ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp
branchRCL_3
changeset 8 e1b6206813b4
parent 0 8466d47a6819
child 16 b5fbb9b25d57
equal deleted inserted replaced
4:e7aa27f58ae1 8:e1b6206813b4
   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     delete iSettingsApi;
   109     delete iSettingsApi;
   109     iImapFolderIds.Close();
   110     iImapFolderIds.Close();
   110     }
   111     }
   111 
   112 
   112 // ---------------------------------------------------------------------------
   113 // ---------------------------------------------------------------------------
   116     :iBasePlugin( aBasePlugin ),
   117     :iBasePlugin( aBasePlugin ),
   117     iMBoxObservers( KEventGranularity ),
   118     iMBoxObservers( KEventGranularity ),
   118     iIPSAccounts( KEventGranularity ),
   119     iIPSAccounts( KEventGranularity ),
   119     iIPSSettingsObservers( KEventGranularity ),
   120     iIPSSettingsObservers( KEventGranularity ),
   120     iIsConnected( EFalse ),
   121     iIsConnected( EFalse ),
   121     iPropertyObservers( KEventGranularity )
   122     iPropertyObservers( KEventGranularity ),
       
   123     iConnOpCallbacks( KEventGranularity )
   122     {
   124     {
   123     FUNC_LOG;
   125     FUNC_LOG;
   124     }
   126     }
   125 
   127 
   126 // ---------------------------------------------------------------------------
   128 // ---------------------------------------------------------------------------
  1576 // ----------------------------------------------------------------------------
  1578 // ----------------------------------------------------------------------------
  1577 // ----------------------------------------------------------------------------
  1579 // ----------------------------------------------------------------------------
  1578 void CIpsPlgEventHandler::HandlePropertyEventL(
  1580 void CIpsPlgEventHandler::HandlePropertyEventL(
  1579         TInt aEvent,
  1581         TInt aEvent,
  1580         TInt aMailbox,
  1582         TInt aMailbox,
  1581         TInt /*aPluginId*/,
  1583         TInt aPluginId,
  1582         TInt aError )
  1584         TInt /*aError*/ )
  1583     {
  1585     {
  1584     FUNC_LOG;
  1586     FUNC_LOG;
  1585     RProcess process;
  1587     RProcess process;
  1586     if ( aEvent == EIPSSosPswErr && process.SecureId() == FREESTYLE_FSSERVER_SID )
  1588 
  1587         {
  1589     // only email server should handle login notifications
  1588         TFSMailMsgId mbox = SymId2FsId( aMailbox,
  1590     if (( aEvent == EIPSSosPswErr || aEvent == EIPSSosSmtpPswErr ) &&
  1589                         iBasePlugin.MtmId().iUid );
  1591           process.SecureId() == FREESTYLE_FSSERVER_SID &&
       
  1592           iQueryPassState == EReady &&
       
  1593           iBasePlugin.PluginId() == aPluginId )
       
  1594         {
       
  1595         TFSMailMsgId mbox = SymId2FsId( aMailbox, iBasePlugin.MtmId().iUid );
       
  1596 
       
  1597         // keep information about type of mail we`re setting the password
       
  1598         iIncomingPass = ( aEvent == EIPSSosPswErr ? ETrue : EFalse );
       
  1599         iQueryPassState = ENotificationRequest;
       
  1600 
  1590         TFSMailEvent event = TFSEventException;
  1601         TFSMailEvent event = TFSEventException;
  1591         TFsEmailNotifierSystemMessageType msg = EFsEmailNotifErrLoginUnsuccesfull;
  1602         TFsEmailNotifierSystemMessageType msg = EFsEmailNotifErrLoginUnsuccesfull;
  1592         SendDelayedEventL( event, mbox, &msg, NULL , (MFSMailExceptionEventCallback*)this );
  1603         SendDelayedEventL( event, mbox, &msg, NULL, (MFSMailExceptionEventCallback*)this );
  1593         }
  1604         }
  1594     else if ( aEvent == EIPSSosCredientialsSet || aEvent == EIPSSosCredientialsCancelled )
  1605     else if ( aEvent == EIPSSosCredientialsSet || aEvent == EIPSSosCredientialsCancelled )
  1595         {
  1606         {
  1596         if ( iConnOpCallback )
  1607         // if this handler invoked query user pass
  1597             {
  1608         if ( iQueryPassState == EBusy )
  1598             iConnOpCallback->CredientialsSetL( aEvent );
  1609             {
  1599 
  1610             iQueryPassState = ERequestResponding;
  1600             //Set to null after we have used this.
  1611             // run callbacks
  1601             //don't delete, we don't own this.
  1612             for ( TInt i = 0; i < iConnOpCallbacks.Count(); i++ )
  1602             iConnOpCallback=NULL;
  1613                 iConnOpCallbacks[i]->CredientialsSetL( aEvent );
  1603             }
  1614 
       
  1615             iConnOpCallbacks.Reset();
       
  1616             // now handler is ready for another query user pass
       
  1617             iQueryPassState = EReady;
       
  1618             }
       
  1619 
  1604         //if password was changed, we need to send settings changed event also.
  1620         //if password was changed, we need to send settings changed event also.
  1605         if( aEvent == EIPSSosCredientialsSet )
  1621         if( aEvent == EIPSSosCredientialsSet )
  1606             {
  1622             {
  1607             TFSMailMsgId mbox = SymId2FsId( aMailbox,
  1623             TFSMailMsgId mbox = SymId2FsId( aMailbox,
  1608                     iBasePlugin.MtmId().iUid );
  1624                     iBasePlugin.MtmId().iUid );
  1615         TFSMailMsgId mbox = SymId2FsId( aMailbox,
  1631         TFSMailMsgId mbox = SymId2FsId( aMailbox,
  1616                 iBasePlugin.MtmId().iUid );
  1632                 iBasePlugin.MtmId().iUid );
  1617         TFSMailEvent event = TFSEventMailboxSettingsChanged;
  1633         TFSMailEvent event = TFSEventMailboxSettingsChanged;
  1618         SendDelayedEventL( event, mbox, NULL, NULL , NULL );
  1634         SendDelayedEventL( event, mbox, NULL, NULL , NULL );
  1619         }
  1635         }
  1620     else if ( aEvent == KIpsSosEmailSyncCompleted &&
  1636     }
  1621             aError == KErrImapBadLogon )
  1637 
  1622         {
  1638 // ----------------------------------------------------------------------------
  1623         TFSMailMsgId mbox = SymId2FsId( aMailbox,
  1639 // ----------------------------------------------------------------------------
  1624                         iBasePlugin.MtmId().iUid );
  1640 TBool CIpsPlgEventHandler::QueryUsrPassL(
  1625         TFSMailEvent event = TFSEventException;
  1641     TMsvId aMbox,
  1626         TFsEmailNotifierSystemMessageType msg = EFsEmailNotifErrLoginUnsuccesfull;
  1642     MIpsPlgConnectOpCallback* aCallback/*=NULL*/,
  1627         SendDelayedEventL( event, mbox, &msg, NULL , this );
  1643     TBool aIncoming/*=ETrue*/ )
  1628         }
  1644     {
  1629     }
  1645     FUNC_LOG;
  1630 
  1646 
  1631 // ----------------------------------------------------------------------------
  1647     ASSERT( iConnOpCallbacks.Find( aCallback ) == KErrNotFound );
  1632 // ----------------------------------------------------------------------------
  1648     if ( aCallback )
  1633 void CIpsPlgEventHandler::QueryUsrPassL( TMsvId aMbox, MIpsPlgConnectOpCallback* aCallback )
  1649         iConnOpCallbacks.Append( aCallback );
  1634     {
  1650 
  1635     FUNC_LOG;
  1651     // set or re-set property event
  1636     iConnOpCallback = aCallback;//can be null, doesn't matter.
  1652     SetNewPropertyEvent( aMbox, (aIncoming ? EIPSSosPswErr : EIPSSosSmtpPswErr), 0 );
  1637     SetNewPropertyEvent( aMbox, EIPSSosPswErr, 0 );
  1653 
       
  1654     // only one query at a time allowed
       
  1655     if ( iQueryPassState != EReady )
       
  1656         {
       
  1657         return EFalse;
       
  1658         }
       
  1659 
       
  1660     // update state
       
  1661     iQueryPassState = EBusy;
       
  1662 
       
  1663     return ETrue;
       
  1664     }
       
  1665 
       
  1666 // ----------------------------------------------------------------------------
       
  1667 // ----------------------------------------------------------------------------
       
  1668 TBool CIpsPlgEventHandler::IncomingPass() const
       
  1669     {
       
  1670     return iIncomingPass;
  1638     }
  1671     }
  1639 
  1672 
  1640 // ----------------------------------------------------------------------------
  1673 // ----------------------------------------------------------------------------
  1641 // ----------------------------------------------------------------------------
  1674 // ----------------------------------------------------------------------------
  1642 void CIpsPlgEventHandler::SignalCredientialsSetL( TInt aMailboxId, TBool aCancelled )
  1675 void CIpsPlgEventHandler::SignalCredientialsSetL( TInt aMailboxId, TBool aCancelled )
  1643     {
  1676     {
  1644     FUNC_LOG;
  1677     FUNC_LOG;
       
  1678     if ( iQueryPassState == EPasswordRequest )
       
  1679         {
       
  1680         iQueryPassState = EReady;
       
  1681         iIncomingPass = ETrue;
       
  1682         }
       
  1683 
  1645     TInt event = EIPSSosCredientialsSet;
  1684     TInt event = EIPSSosCredientialsSet;
  1646     if ( aCancelled )
  1685     if ( aCancelled )
  1647         {
  1686         {
  1648         event = EIPSSosCredientialsCancelled;
  1687         event = EIPSSosCredientialsCancelled;
  1649         }
  1688         }
  1701 
  1740 
  1702 // ----------------------------------------------------------------------------
  1741 // ----------------------------------------------------------------------------
  1703 // ----------------------------------------------------------------------------
  1742 // ----------------------------------------------------------------------------
  1704 void CIpsPlgEventHandler::ExceptionEventCallbackL(
  1743 void CIpsPlgEventHandler::ExceptionEventCallbackL(
  1705         TFSMailMsgId aMailboxId,
  1744         TFSMailMsgId aMailboxId,
  1706         TInt /*aEventType*/,
  1745         TInt aEventType,
  1707         TBool /*aResponse*/ )
  1746         TBool /*aResponse*/ )
  1708     {
  1747     {
  1709     FUNC_LOG;
  1748     FUNC_LOG;
  1710     TFSMailEvent event = TFSEventMailboxSyncStateChanged;
  1749 
  1711     TSSMailSyncState state = PasswordNotVerified;
  1750     if ( aEventType == EFsEmailNotifErrLoginUnsuccesfull &&
  1712 
  1751          iQueryPassState == ENotificationRequest )
  1713     SendDelayedEventL( event, aMailboxId, &state, NULL , NULL );
  1752         {
       
  1753         iQueryPassState = EPasswordRequest;
       
  1754         TFSMailEvent event = TFSEventMailboxSyncStateChanged;
       
  1755         TSSMailSyncState state = PasswordNotVerified;
       
  1756 
       
  1757         SendDelayedEventL( event, aMailboxId, &state, NULL, NULL );
       
  1758         }
  1714     }
  1759     }
  1715 
  1760 
  1716 // End of File
  1761 // End of File
  1717 
  1762