ipsservices/ipssosaoplugin/src/IpsSosAOImapPopLogic.cpp
changeset 43 99bcbff212ad
parent 23 2dc6caa42ec3
child 57 ae34e1715e21
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    21 #include <AlwaysOnlineManagerClient.h>
    21 #include <AlwaysOnlineManagerClient.h>
    22 #include <SendUiConsts.h>
    22 #include <SendUiConsts.h>
    23 #include <msvids.h>
    23 #include <msvids.h>
    24 #include <msvuids.h>
    24 #include <msvuids.h>
    25 
    25 
       
    26 
    26 // becuase of RD_IPS_AO_PLUGIN flag, can be removed
    27 // becuase of RD_IPS_AO_PLUGIN flag, can be removed
    27 // when flag is removed
    28 // when flag is removed
    28 #include "ipsplgsosbaseplugin.hrh"
    29 #include "ipsplgsosbaseplugin.hrh"
    29 
    30 
    30 #include "IpsSosAOImapPopLogic.h"
    31 #include "IpsSosAOImapPopLogic.h"
    31 #include "IpsSosAOMboxLogic.h"
    32 #include "IpsSosAOMboxLogic.h"
    32 #include "IpsSosAOEMNResolver.h"
    33 #include "IpsSosAOEMNResolver.h"
    33 //<QMail>
    34 //<QMail>
       
    35 
    34 #include "IpsSosAOSettingsHandler.h"
    36 #include "IpsSosAOSettingsHandler.h"
       
    37 #include "IpsSosAoExtendedSettingsManager.h"
    35 //</QMail>
    38 //</QMail>
    36 
    39 
    37 
    40 
    38 
    41 
    39 #include "ipsplgcommon.h"
    42 #include "ipsplgcommon.h"
   238         case MMsvSessionObserver::EMsvEntriesCreated:
   241         case MMsvSessionObserver::EMsvEntriesCreated:
   239             break;
   242             break;
   240         case MMsvSessionObserver::EMsvEntriesChanged:
   243         case MMsvSessionObserver::EMsvEntriesChanged:
   241             {
   244             {
   242             TMsvId parent = (*(TMsvId*) (aArg2));
   245             TMsvId parent = (*(TMsvId*) (aArg2));
   243             //we check that parent is the root. if not, it cannot be a 
   246             //we check that parent is the root. if not, it cannot be an 
   244             //event from service, thus can't be from connection change..
   247             //event from service, thus can't be from connection change..
   245             if ( parent == KMsvRootIndexEntryId )
   248             if ( parent == KMsvRootIndexEntryId )
   246                 {
   249                 {
   247                 const CMsvEntrySelection* selection = 
   250                 const CMsvEntrySelection* selection = 
   248                     static_cast<CMsvEntrySelection*>( aArg1 );
   251                     static_cast<CMsvEntrySelection*>( aArg1 );
   262                     }
   265                     }
   263                 }
   266                 }
   264             }
   267             }
   265             break;
   268             break;
   266         case MMsvSessionObserver::EMsvEntriesDeleted:
   269         case MMsvSessionObserver::EMsvEntriesDeleted:
   267             // NOTE: if mailbox is deleted somewhere else than ips plugin
   270             {
   268             // in here need to put logic for removing corresponding 
   271             TMsvId parent = (*(TMsvId*) (aArg2));
   269             // mailboxlogic object
   272             //we check that parent is the root. if not, it cannot be an 
       
   273             //event indicating deleted mailbox entry
       
   274             if ( parent == KMsvRootIndexEntryId )
       
   275                 {
       
   276                 RemoveOrphanLogicsL();
       
   277                 }
       
   278             }
       
   279             break;
   270         case MMsvSessionObserver::EMsvEntriesMoved:
   280         case MMsvSessionObserver::EMsvEntriesMoved:
   271         default:
   281         default:
   272             break;
   282             break;
   273         };
   283         };
   274     }
   284     }
   427             }
   437             }
   428         
   438         
   429         CleanupStack::PopAndDestroy(settings);
   439         CleanupStack::PopAndDestroy(settings);
   430 		//</QMail>
   440 		//</QMail>
   431         }
   441         }
       
   442     
       
   443     //finally, check for orphans ( mailbox has been deleted )
       
   444     RemoveOrphanLogicsL();
   432     }
   445     }
   433 
   446 
   434 // ----------------------------------------------------------------------------
   447 // ----------------------------------------------------------------------------
   435 // ----------------------------------------------------------------------------
   448 // ----------------------------------------------------------------------------
   436 //
   449 //
   491             }
   504             }
   492         }
   505         }
   493     return index;
   506     return index;
   494     }
   507     }
   495 
   508 
       
   509 // ----------------------------------------------------------------------------
       
   510 // ----------------------------------------------------------------------------
       
   511 //
       
   512 void CIpsSosAOImapPopLogic::RemoveOrphanLogicsL()
       
   513     {
       
   514     CMsvEntry* cEntry = iSession.GetEntryL( KMsvRootIndexEntryId );
       
   515     CleanupStack::PushL( cEntry );
       
   516     
       
   517     CMsvEntrySelection* popEntries = cEntry->ChildrenWithMtmL( KSenduiMtmPop3Uid );
       
   518     CleanupStack::PushL( popEntries );
       
   519     
       
   520     CMsvEntrySelection* imapEntries = cEntry->ChildrenWithMtmL( KSenduiMtmImap4Uid );
       
   521     CleanupStack::PushL( imapEntries );
       
   522         
       
   523         
       
   524     TInt count = iMailboxLogics.Count();
       
   525     
       
   526     for(TInt i=count-1; i>-1;i--)
       
   527         {
       
   528         if( popEntries->Find(iMailboxLogics[i]->GetMailboxId()) == KErrNotFound &&
       
   529             imapEntries->Find(iMailboxLogics[i]->GetMailboxId()) == KErrNotFound)
       
   530             {
       
   531             StopAndRemoveMailboxL( iMailboxLogics[i]->GetMailboxId() );
       
   532             }
       
   533         }
       
   534     
       
   535     CleanupStack::PopAndDestroy( 3, cEntry );
       
   536     }
   496 // End of file
   537 // End of file
   497 
   538