ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp
changeset 23 2dc6caa42ec3
parent 20 ecc8def7944a
child 44 c2d07d913565
equal deleted inserted replaced
20:ecc8def7944a 23:2dc6caa42ec3
   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 )
   521     event.iArg1 = aArg1;
   524     event.iArg1 = aArg1;
   522     event.iArg2 = aArg2;
   525     event.iArg2 = aArg2;
   523     event.iArg3 = aArg3;
   526     event.iArg3 = aArg3;
   524 
   527 
   525     RPointerArray<MFSMailEventObserver> observers;
   528     RPointerArray<MFSMailEventObserver> observers;
       
   529     CleanupClosePushL( observers );
   526 
   530 
   527     if( aEvent == TFSEventNewMailbox ||
   531     if( aEvent == TFSEventNewMailbox ||
   528         aEvent == TFSEventMailboxRenamed ||
   532         aEvent == TFSEventMailboxRenamed ||
   529         aEvent == TFSEventMailboxDeleted )
   533         aEvent == TFSEventMailboxDeleted )
   530         {
   534         {
   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;
   672                     }
   690                     }
   673                 }
   691                 }
   674 
   692 
   675             // set entries array pointer
   693             // set entries array pointer
   676             RArray<TFSMailMsgId> array(KEventGranularity);
   694             RArray<TFSMailMsgId> array(KEventGranularity);
       
   695             CleanupClosePushL( array );
   677 
   696 
   678             FillFSMessageArray(
   697             FillFSMessageArray(
   679                 array,
   698                 array,
   680                 static_cast<const CMsvEntrySelection*>(aArg1),
   699                 static_cast<const CMsvEntrySelection*>(aArg1),
   681                 tNew.iMtm.iUid );
   700                 tNew.iMtm.iUid );
   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                 }
   743         TAny* arg3=NULL;
   763         TAny* arg3=NULL;
   744 
   764 
   745         TFSMailEvent event( TFSMailboxUnavailable );
   765         TFSMailEvent event( TFSMailboxUnavailable );
   746 
   766 
   747         RArray<TFSMailMsgId> array(KEventGranularity);
   767         RArray<TFSMailMsgId> array(KEventGranularity);
       
   768         CleanupClosePushL( array );
   748         FillFSMessageArray(
   769         FillFSMessageArray(
   749             array,
   770             array,
   750             static_cast<const CMsvEntrySelection*>(aArg1),
   771             static_cast<const CMsvEntrySelection*>(aArg1),
   751             tMoved.iMtm.iUid );
   772             tMoved.iMtm.iUid );
   752 
   773 
   786             mbox,
   807             mbox,
   787             arg1,
   808             arg1,
   788             arg2,
   809             arg2,
   789             arg3 );
   810             arg3 );
   790 
   811 
   791         array.Close();
   812         CleanupStack::PopAndDestroy( &array );
   792         // set null to prevent later usage in framework side
   813         // set null to prevent later usage in framework side
   793         // causes kern exec 3 panic...
   814         // causes kern exec 3 panic...
   794         arg1 = arg2 = arg3 = NULL;
   815         arg1 = arg2 = arg3 = NULL;
   795         }
   816         }
   796     }
   817     }
   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                 }
   925                     arg1,
   946                     arg1,
   926                     arg2,
   947                     arg2,
   927                     arg3 );
   948                     arg3 );
   928                 }
   949                 }
   929 
   950 
   930             array.Close();
   951             CleanupStack::PopAndDestroy( &array );
   931             }
   952             }
   932         else if ( tEntry.iMtm.iUid == KSenduiMtmSmtpUidValue )
   953         else if ( tEntry.iMtm.iUid == KSenduiMtmSmtpUidValue )
   933             {
   954             {
   934             // seems that case when deleding from draft, symbian
   955             // seems that case when deleding from draft, symbian
   935             // sends event that contains some child part's id of
   956             // sends event that contains some child part's id of
   968                 // Should be panic at this point?
   989                 // Should be panic at this point?
   969                 return;
   990                 return;
   970                 }
   991                 }
   971 
   992 
   972             RArray<TFSMailMsgId> array(1);
   993             RArray<TFSMailMsgId> array(1);
       
   994             CleanupClosePushL( array );
   973             array.Append( msg );
   995             array.Append( msg );
   974             arg1 = &array;
   996             arg1 = &array;
   975             arg2 = &parent;
   997             arg2 = &parent;
   976             event = TFSEventMailDeleted;
   998             event = TFSEventMailDeleted;
   977             SendDelayedEventL(
   999             SendDelayedEventL(
   978                 event,
  1000                 event,
   979                 mbox,
  1001                 mbox,
   980                 arg1,
  1002                 arg1,
   981                 arg2,
  1003                 arg2,
   982                 arg3 );
  1004                 arg3 );
   983             array.Close();
  1005             CleanupStack::PopAndDestroy( &array );
   984             }
  1006             }
   985         else
  1007         else
   986             {
  1008             {
   987             //deletion happened under some other service that IPS.
  1009             //deletion happened under some other service that IPS.
   988             return;
  1010             return;
  1001     FUNC_LOG;
  1023     FUNC_LOG;
  1002     TAny* arg1=NULL;
  1024     TAny* arg1=NULL;
  1003     TAny* arg2=NULL;
  1025     TAny* arg2=NULL;
  1004     TAny* arg3=NULL;
  1026     TAny* arg3=NULL;
  1005 
  1027 
       
  1028     TInt errorCode( KErrNone ); // <qmail>
       
  1029 
  1006     TUid uId;
  1030     TUid uId;
  1007     TMsvEntry tChanged;
  1031     TMsvEntry tChanged;
  1008     if ( !IsEventFromIpsSourceL( aArg1, uId, tChanged ) )
  1032     if ( !IsEventFromIpsSourceL( aArg1, uId, tChanged ) )
  1009         {
  1033         {
  1010         return;
  1034         return;
  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>
  1715 //    TSSMailSyncState state = PasswordNotVerified;
  1756 //    TSSMailSyncState state = PasswordNotVerified;
  1716 //
  1757 //
  1717 //    SendDelayedEventL( event, aMailboxId, &state, NULL , NULL );
  1758 //    SendDelayedEventL( event, aMailboxId, &state, NULL , NULL );
  1718 //    }
  1759 //    }
  1719 // </qmail>
  1760 // </qmail>
       
  1761 
       
  1762 // End of File
       
  1763