ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp
changeset 76 38bf5461e270
parent 68 83cc6bae1de8
equal deleted inserted replaced
74:6c59112cfd31 76:38bf5461e270
   371     iMBoxObservers.AppendL( observer );
   371     iMBoxObservers.AppendL( observer );
   372     CleanupStack::Pop( observer );
   372     CleanupStack::Pop( observer );
   373     AppendSettingsObserverL( aMailboxId, aKey );
   373     AppendSettingsObserverL( aMailboxId, aKey );
   374     //at the moment we won't support syncstate events for IMAP alwaysonline.
   374     //at the moment we won't support syncstate events for IMAP alwaysonline.
   375     //because of imap idle. we can't extract usefull syncstate changes when it is in use.
   375     //because of imap idle. we can't extract usefull syncstate changes when it is in use.
   376    /* if ( iBasePlugin.MtmId().iUid != KSenduiMtmImap4UidValue )
   376    /* if ( iBasePlugin.MtmId() != KUidMsgTypeIMAP4 )
   377         {
   377         {
   378         AppendSyncStateObserverL( aMailboxId );
   378         AppendSyncStateObserverL( aMailboxId );
   379         }*/
   379         }*/
   380     if( aMailboxId.PluginId() == KIpsPlgImap4PluginUid )
   380     if( aMailboxId.PluginId() == KIpsPlgImap4PluginUid )
   381         {
   381         {
   445              aEntry.iType.iUid > KUidMsvAttachmentEntryValue )
   445              aEntry.iType.iUid > KUidMsvAttachmentEntryValue )
   446          {
   446          {
   447          ret = EFalse;
   447          ret = EFalse;
   448          }
   448          }
   449 
   449 
   450     if ( !ret && aEntry.iMtm.iUid == KSenduiMtmSmtpUidValue )
   450     if ( !ret && aEntry.iMtm == KUidMsgTypeSMTP )
   451         {
   451         {
   452         ret = ETrue;
   452         ret = ETrue;
   453         }
   453         }
   454 
   454 
   455 
   455 
   462     TMsvId aId, TUint aMtmUid )
   462     TMsvId aId, TUint aMtmUid )
   463     {
   463     {
   464     FUNC_LOG;
   464     FUNC_LOG;
   465     TFSMailMsgId id;
   465     TFSMailMsgId id;
   466     id.SetId( aId );
   466     id.SetId( aId );
   467     if ( aMtmUid == KSenduiMtmImap4UidValue )
   467     if ( aMtmUid == KUidMsgTypeIMAP4.iUid )
   468         {
   468         {
   469         id.SetPluginId( KIpsPlgImap4PluginUid );
   469         id.SetPluginId( KIpsPlgImap4PluginUid );
   470         }
   470         }
   471     else if ( aMtmUid == KSenduiMtmPop3UidValue )
   471     else if ( aMtmUid == KUidMsgTypePOP3.iUid )
   472         {
   472         {
   473         id.SetPluginId( KIpsPlgPop3PluginUid );
   473         id.SetPluginId( KIpsPlgPop3PluginUid );
   474         }
   474         }
   475     else if ( aMtmUid == KSenduiMtmSmtpUidValue )
   475     else if ( aMtmUid == KUidMsgTypeSMTP.iUid )
   476         {
   476         {
   477         // set plugin id to this plugin
   477         // set plugin id to this plugin
   478         id.SetPluginId( TUid::Uid(iPluginId) );
   478         id.SetPluginId( TUid::Uid(iPluginId) );
   479         }
   479         }
   480     return id;
   480     return id;
   568         User::Leave( KErrNotReady );
   568         User::Leave( KErrNotReady );
   569         }
   569         }
   570     CMsvEntry* root = iSession->GetEntryL( KMsvRootIndexEntryIdValue );
   570     CMsvEntry* root = iSession->GetEntryL( KMsvRootIndexEntryIdValue );
   571     CleanupStack::PushL( root );
   571     CleanupStack::PushL( root );
   572 
   572 
   573     CMsvEntrySelection* pop = root->ChildrenWithMtmL( KSenduiMtmPop3Uid );
   573     CMsvEntrySelection* pop = root->ChildrenWithMtmL( KUidMsgTypePOP3 );
   574     CleanupStack::PushL( pop );
   574     CleanupStack::PushL( pop );
   575 
   575 
   576     CMsvEntrySelection* imap = root->ChildrenWithMtmL( KSenduiMtmImap4Uid );
   576     CMsvEntrySelection* imap = root->ChildrenWithMtmL( KUidMsgTypeIMAP4 );
   577     CleanupStack::PushL( imap );
   577     CleanupStack::PushL( imap );
   578 
   578 
   579     TInt count = pop->Count();
   579     TInt count = pop->Count();
   580     TMsvEntry tEntry;
   580     TMsvEntry tEntry;
   581     TMsvId service;
   581     TMsvId service;
   727             SendDelayedEventL( event, mbox,
   727             SendDelayedEventL( event, mbox,
   728                 arg1, arg2 , arg3 );
   728                 arg1, arg2 , arg3 );
   729 
   729 
   730             CleanupStack::PopAndDestroy( &array );
   730             CleanupStack::PopAndDestroy( &array );
   731 
   731 
   732             if( tNew.iMtm.iUid == KSenduiMtmImap4UidValue )
   732             if( tNew.iMtm == KUidMsgTypeIMAP4 )
   733                 {
   733                 {
   734                 SetFolderIdToArrayL( tNew.Id() );
   734                 SetFolderIdToArrayL( tNew.Id() );
   735                 }
   735                 }
   736             }
   736             }
   737         else//attachment
   737         else//attachment
   785             event = TFSEventFoldersMoved;
   785             event = TFSEventFoldersMoved;
   786             }
   786             }
   787 
   787 
   788         TFSMailMsgId mbox;
   788         TFSMailMsgId mbox;
   789         // solve mailbox.
   789         // solve mailbox.
   790         if ( tMoved.iMtm.iUid == KSenduiMtmSmtpUidValue )
   790         if ( tMoved.iMtm == KUidMsgTypeSMTP )
   791             {
   791             {
   792             TMsvEntry serv;
   792             TMsvEntry serv;
   793             TMsvId service;
   793             TMsvId service;
   794             iSession->GetEntry( tMoved.iServiceId, service, serv );
   794             iSession->GetEntry( tMoved.iServiceId, service, serv );
   795             //get correct imap/pop service to tEntry
   795             //get correct imap/pop service to tEntry
   907             TFSMailMsgId mbox(iPluginId, tEntry.iServiceId );
   907             TFSMailMsgId mbox(iPluginId, tEntry.iServiceId );
   908             RArray<TFSMailMsgId> array( KEventGranularity );
   908             RArray<TFSMailMsgId> array( KEventGranularity );
   909             CleanupClosePushL( array );
   909             CleanupClosePushL( array );
   910             TFSMailMsgId parentId( iPluginId, tEntry.Id() );
   910             TFSMailMsgId parentId( iPluginId, tEntry.Id() );
   911 
   911 
   912             if ( tEntry.iMtm.iUid == KSenduiMtmImap4UidValue )
   912             if ( tEntry.iMtm == KUidMsgTypeIMAP4 )
   913                 {
   913                 {
   914                 isFolderId = MatchFolderIdFound( deletedId );
   914                 isFolderId = MatchFolderIdFound( deletedId );
   915                 }
   915                 }
   916             if( !isFolderId )
   916             if( !isFolderId )
   917                 {
   917                 {
   947                     arg3 );
   947                     arg3 );
   948                 }
   948                 }
   949 
   949 
   950             CleanupStack::PopAndDestroy( &array );
   950             CleanupStack::PopAndDestroy( &array );
   951             }
   951             }
   952         else if ( tEntry.iMtm.iUid == KSenduiMtmSmtpUidValue )
   952         else if ( tEntry.iMtm == KUidMsgTypeSMTP )
   953             {
   953             {
   954             // seems that case when deleding from draft, symbian
   954             // seems that case when deleding from draft, symbian
   955             // sends event that contains some child part's id of
   955             // sends event that contains some child part's id of
   956             // correct deleted mail. So append parents id to array
   956             // correct deleted mail. So append parents id to array
   957             TFSMailMsgId msg;
   957             TFSMailMsgId msg;
   958             msg.SetId( tEntry.Id() );
   958             msg.SetId( tEntry.Id() );
       
   959             // <qmail> In case where child is attachment do not append parent id.
   959             TFSMailMsgId parent;
   960             TFSMailMsgId parent;
   960             parent.SetId( tEntry.Parent() );
   961             if (!tEntry.Attachment())
       
   962                 {
       
   963                 parent.SetId( tEntry.Parent() );        
       
   964                 }
       
   965             // </qmail>
       
   966             
   961             if( !iSession )
   967             if( !iSession )
   962                 {
   968                 {
   963                 User::Leave( KErrNotReady );
   969                 User::Leave( KErrNotReady );
   964                 }
   970                 }
   965             //re-load smtp service to tEntry
   971             //re-load smtp service to tEntry
   969 
   975 
   970             TFSMailMsgId mbox;
   976             TFSMailMsgId mbox;
   971             mbox.SetId( tEntry.Id() );
   977             mbox.SetId( tEntry.Id() );
   972 
   978 
   973             // set plugin id to msg, parent and mbox
   979             // set plugin id to msg, parent and mbox
   974             if ( tEntry.iMtm.iUid == KSenduiMtmImap4UidValue )
   980             if ( tEntry.iMtm == KUidMsgTypeIMAP4 )
   975         		{
   981         		{
   976         		parent.SetPluginId( KIpsPlgImap4PluginUid );
   982                 // <qmail>
       
   983                 if (!tEntry.Attachment())
       
   984                     {
       
   985                     parent.SetPluginId( KIpsPlgImap4PluginUid );
       
   986                     }
       
   987                 // </qmail>
   977         		msg.SetPluginId( KIpsPlgImap4PluginUid );
   988         		msg.SetPluginId( KIpsPlgImap4PluginUid );
   978         		mbox.SetPluginId( KIpsPlgImap4PluginUid );
   989         		mbox.SetPluginId( KIpsPlgImap4PluginUid );
   979         		}
   990         		}
   980     		else if ( tEntry.iMtm.iUid == KSenduiMtmPop3UidValue )
   991     		else if ( tEntry.iMtm == KUidMsgTypePOP3 )
   981         		{
   992         		{
   982         		parent.SetPluginId( KIpsPlgPop3PluginUid );
   993                 // <qmail>
       
   994                 if (!tEntry.Attachment())
       
   995                     {
       
   996                     parent.SetPluginId( KIpsPlgPop3PluginUid );
       
   997                     }
       
   998                 // </qmail>
   983         		msg.SetPluginId( KIpsPlgPop3PluginUid );
   999         		msg.SetPluginId( KIpsPlgPop3PluginUid );
   984         		mbox.SetPluginId( KIpsPlgPop3PluginUid );
  1000         		mbox.SetPluginId( KIpsPlgPop3PluginUid );
   985         		}
  1001         		}
   986             else
  1002             else
   987                 {
  1003                 {
   991 
  1007 
   992             RArray<TFSMailMsgId> array(1);
  1008             RArray<TFSMailMsgId> array(1);
   993             CleanupClosePushL( array );
  1009             CleanupClosePushL( array );
   994             array.AppendL( msg );
  1010             array.AppendL( msg );
   995             arg1 = &array;
  1011             arg1 = &array;
   996             arg2 = &parent;
  1012             // <qmail>
       
  1013             if (!tEntry.Attachment())
       
  1014                 {
       
  1015                 arg2 = &parent;
       
  1016                 }
       
  1017             // </qmail>
   997             event = TFSEventMailDeleted;
  1018             event = TFSEventMailDeleted;
   998             SendDelayedEventL(
  1019             SendDelayedEventL(
   999                 event,
  1020                 event,
  1000                 mbox,
  1021                 mbox,
  1001                 arg1,
  1022                 arg1,
  1069         arg1 = &array;
  1090         arg1 = &array;
  1070 
  1091 
  1071         TFSMailMsgId id = SymId2FsId( *(static_cast<TMsvId*>(aArg2)), tChanged.iMtm.iUid );
  1092         TFSMailMsgId id = SymId2FsId( *(static_cast<TMsvId*>(aArg2)), tChanged.iMtm.iUid );
  1072         arg2 = &id;
  1093         arg2 = &id;
  1073 
  1094 
  1074         if ( tChanged.iMtm.iUid == KSenduiMtmImap4UidValue )
  1095         if ( tChanged.iMtm == KUidMsgTypeIMAP4 )
  1075             {
  1096             {
  1076             TMsvEmailEntry eml( tChanged );
  1097             TMsvEmailEntry eml( tChanged );
  1077             TInt index = iImapFolderIds.Find(tChanged.Id());
  1098             TInt index = iImapFolderIds.Find(tChanged.Id());
  1078             if ( eml.LocalSubscription() && index == KErrNotFound )
  1099             if ( eml.LocalSubscription() && index == KErrNotFound )
  1079                 {
  1100                 {
  1116     // send event only if we found correct one
  1137     // send event only if we found correct one
  1117     if ( event != KErrNotFound )
  1138     if ( event != KErrNotFound )
  1118         {
  1139         {
  1119         TFSMailMsgId mbox;
  1140         TFSMailMsgId mbox;
  1120         // solve mailbox.
  1141         // solve mailbox.
  1121         if ( tChanged.iMtm.iUid == KSenduiMtmSmtpUidValue )
  1142         if ( tChanged.iMtm == KUidMsgTypeSMTP )
  1122             {
  1143             {
  1123             TMsvEntry serv;
  1144             TMsvEntry serv;
  1124             TMsvId service;
  1145             TMsvId service;
  1125             if( !iSession )
  1146             if( !iSession )
  1126                 {
  1147                 {
  1209 
  1230 
  1210 // ---------------------------------------------------------------------------
  1231 // ---------------------------------------------------------------------------
  1211 // ---------------------------------------------------------------------------
  1232 // ---------------------------------------------------------------------------
  1212 TUid CIpsPlgEventHandler::MtmId() const
  1233 TUid CIpsPlgEventHandler::MtmId() const
  1213     {
  1234     {
  1214     TUid ret = KSenduiMtmImap4Uid;
  1235     TUid ret = KUidMsgTypeIMAP4;
  1215     if ( iBasePlugin.MtmId().iUid == KIpsPlgPop3PluginUidValue )
  1236     if ( iBasePlugin.MtmId().iUid == KIpsPlgPop3PluginUidValue )
  1216         {
  1237         {
  1217         ret = KSenduiMtmPop3Uid;
  1238         ret = KUidMsgTypePOP3;
  1218         }
  1239         }
  1219     return ret;
  1240     return ret;
  1220     }
  1241     }
  1221 //</cmail>
  1242 //</cmail>
  1222 // ----------------------------------------------------------------------------
  1243 // ----------------------------------------------------------------------------
  1400 // ----------------------------------------------------------------------------
  1421 // ----------------------------------------------------------------------------
  1401 // ----------------------------------------------------------------------------
  1422 // ----------------------------------------------------------------------------
  1402 TBool CIpsPlgEventHandler::AccountExistsL( const TMsvEntry& aEntry )
  1423 TBool CIpsPlgEventHandler::AccountExistsL( const TMsvEntry& aEntry )
  1403     {
  1424     {
  1404     FUNC_LOG;
  1425     FUNC_LOG;
  1405     if ( !(aEntry.iMtm.iUid == KSenduiMtmImap4UidValue
  1426     if ( !(aEntry.iMtm == KUidMsgTypeIMAP4
  1406         || aEntry.iMtm.iUid == KSenduiMtmPop3UidValue) )
  1427         || aEntry.iMtm == KUidMsgTypePOP3) )
  1407         {
  1428         {
  1408         // check only imap and pop
  1429         // check only imap and pop
  1409         return ETrue;
  1430         return ETrue;
  1410         }
  1431         }
  1411 
  1432 
  1438         // stop recursion
  1459         // stop recursion
  1439         return;
  1460         return;
  1440         }
  1461         }
  1441 
  1462 
  1442     // only pop or imap types are alloved beyond this point
  1463     // only pop or imap types are alloved beyond this point
  1443     __ASSERT_DEBUG( ( aParent.iMtm.iUid == KSenduiMtmImap4UidValue ||
  1464     __ASSERT_DEBUG( ( aParent.iMtm == KUidMsgTypeIMAP4 ||
  1444             aParent.iMtm.iUid == KSenduiMtmPop3UidValue ),
  1465             aParent.iMtm == KUidMsgTypePOP3 ),
  1445         User::Panic( KIpsPlgEventHandlerPanic, KErrGeneral ) );
  1466         User::Panic( KIpsPlgEventHandlerPanic, KErrGeneral ) );
  1446 
  1467 
  1447     TBool doRecursion = EFalse;
  1468     TBool doRecursion = EFalse;
  1448 
  1469 
  1449     if ( aParent.iMtm.iUid == KSenduiMtmImap4UidValue )
  1470     if ( aParent.iMtm == KUidMsgTypeIMAP4 )
  1450         {
  1471         {
  1451         if ( aParent.iType.iUid == KUidMsvServiceEntryValue )
  1472         if ( aParent.iType.iUid == KUidMsvServiceEntryValue )
  1452             {
  1473             {
  1453             // return in case of service / root entries to avoid
  1474             // return in case of service / root entries to avoid
  1454             // forever recursion
  1475             // forever recursion