ipsservices/ipssosaoplugin/src/IpsSosAOImapPopLogic.cpp
changeset 76 38bf5461e270
parent 68 83cc6bae1de8
equal deleted inserted replaced
74:6c59112cfd31 76:38bf5461e270
   217         case MMsvSessionObserver::EMsvEntriesCreated:
   217         case MMsvSessionObserver::EMsvEntriesCreated:
   218             handleEntriesCreatedL(aArg1);
   218             handleEntriesCreatedL(aArg1);
   219             break;
   219             break;
   220         case MMsvSessionObserver::EMsvEntriesChanged:
   220         case MMsvSessionObserver::EMsvEntriesChanged:
   221             {
   221             {
   222             TMsvId parent = (*(TMsvId*) (aArg2));
   222             handleEntriesChangedL(aArg1, aArg2);
   223             //we check that parent is the root. if not, it cannot be an 
   223             }
   224             //event from service, thus can't be from connection change..
   224             break;
   225             if ( parent == KMsvRootIndexEntryId )
   225         case MMsvSessionObserver::EMsvEntriesDeleted:
   226                 {
   226             {
   227                 const CMsvEntrySelection* selection = 
   227             if (aArg2) 
   228                     static_cast<CMsvEntrySelection*>( aArg1 );
   228                 {
   229                 
   229                 TMsvId parent = (*(TMsvId*) (aArg2));
   230                 TMsvEntry tEntry;
   230                 //we check that parent is the root. if not, it cannot be an 
   231                 TMsvId service;
   231                 //event indicating deleted mailbox entry
   232                 if ( selection->Count() )
   232                 if ( parent == KMsvRootIndexEntryId )
   233                     {
   233                     {
   234                     iSession.GetEntry( selection->At(0), service, tEntry );
   234                     RemoveOrphanLogicsL();
   235                     }
   235                     }
   236                 
       
   237                 if ( !tEntry.Connected() )
       
   238                     {
       
   239                     SendCommandToSpecificMailboxL( 
       
   240                             tEntry.Id(), 
       
   241                             CIpsSosAOMBoxLogic::ECommandClearDoNotDisconnect );
       
   242                     }
       
   243                 }
       
   244             }
       
   245             break;
       
   246         case MMsvSessionObserver::EMsvEntriesDeleted:
       
   247             {
       
   248             TMsvId parent = (*(TMsvId*) (aArg2));
       
   249             //we check that parent is the root. if not, it cannot be an 
       
   250             //event indicating deleted mailbox entry
       
   251             if ( parent == KMsvRootIndexEntryId )
       
   252                 {
       
   253                 RemoveOrphanLogicsL();
       
   254                 }
   236                 }
   255             }
   237             }
   256             break;
   238             break;
   257         case MMsvSessionObserver::EMsvEntriesMoved:
   239         case MMsvSessionObserver::EMsvEntriesMoved:
   258         default:
   240         default:
   354     {
   336     {
   355     FUNC_LOG;
   337     FUNC_LOG;
   356     CMsvEntry* cEntry = iSession.GetEntryL( KMsvRootIndexEntryId );
   338     CMsvEntry* cEntry = iSession.GetEntryL( KMsvRootIndexEntryId );
   357     CleanupStack::PushL( cEntry );
   339     CleanupStack::PushL( cEntry );
   358     
   340     
   359     CMsvEntrySelection* childEntries = cEntry->ChildrenWithMtmL( KSenduiMtmPop3Uid );
   341     CMsvEntrySelection* childEntries = cEntry->ChildrenWithMtmL( KUidMsgTypePOP3 );
   360     CleanupStack::PushL( childEntries );
   342     CleanupStack::PushL( childEntries );
   361     UpdateLogicArrayL( *childEntries );
   343     UpdateLogicArrayL( *childEntries );
   362     CleanupStack::PopAndDestroy( childEntries );
   344     CleanupStack::PopAndDestroy( childEntries );
   363     
   345     
   364     childEntries = cEntry->ChildrenWithMtmL( KSenduiMtmImap4Uid );
   346     childEntries = cEntry->ChildrenWithMtmL( KUidMsgTypeIMAP4 );
   365     CleanupStack::PushL( childEntries );
   347     CleanupStack::PushL( childEntries );
   366     UpdateLogicArrayL( *childEntries );
   348     UpdateLogicArrayL( *childEntries );
   367     CleanupStack::PopAndDestroy( childEntries );
   349     CleanupStack::PopAndDestroy( childEntries );
   368     CleanupStack::PopAndDestroy( cEntry );
   350     CleanupStack::PopAndDestroy( cEntry );
   369     }
   351     }
   489 void CIpsSosAOImapPopLogic::RemoveOrphanLogicsL()
   471 void CIpsSosAOImapPopLogic::RemoveOrphanLogicsL()
   490     {
   472     {
   491     CMsvEntry* cEntry = iSession.GetEntryL( KMsvRootIndexEntryId );
   473     CMsvEntry* cEntry = iSession.GetEntryL( KMsvRootIndexEntryId );
   492     CleanupStack::PushL( cEntry );
   474     CleanupStack::PushL( cEntry );
   493     
   475     
   494     CMsvEntrySelection* popEntries = cEntry->ChildrenWithMtmL( KSenduiMtmPop3Uid );
   476     CMsvEntrySelection* popEntries = cEntry->ChildrenWithMtmL( KUidMsgTypePOP3 );
   495     CleanupStack::PushL( popEntries );
   477     CleanupStack::PushL( popEntries );
   496     
   478     
   497     CMsvEntrySelection* imapEntries = cEntry->ChildrenWithMtmL( KSenduiMtmImap4Uid );
   479     CMsvEntrySelection* imapEntries = cEntry->ChildrenWithMtmL( KUidMsgTypeIMAP4 );
   498     CleanupStack::PushL( imapEntries );
   480     CleanupStack::PushL( imapEntries );
   499         
   481         
   500         
   482         
   501     TInt count = iMailboxLogics.Count();
   483     TInt count = iMailboxLogics.Count();
   502     
   484     
   515 // ----------------------------------------------------------------------------
   497 // ----------------------------------------------------------------------------
   516 // ----------------------------------------------------------------------------
   498 // ----------------------------------------------------------------------------
   517 void CIpsSosAOImapPopLogic::handleEntriesCreatedL(const TAny* aArg1)
   499 void CIpsSosAOImapPopLogic::handleEntriesCreatedL(const TAny* aArg1)
   518     {
   500     {
   519     FUNC_LOG;
   501     FUNC_LOG;
   520     TMsvEntry entry;
   502     if (aArg1)
   521     getFirstEntryFromSelectionL(static_cast<const CMsvEntrySelection*>(aArg1), entry);
   503         {
   522 
   504         TMsvEntry entry;
   523     if( entry.iMtm==KSenduiMtmImap4Uid || entry.iMtm==KSenduiMtmPop3Uid)
   505         getFirstEntryFromSelectionL(static_cast<const CMsvEntrySelection*>(aArg1), entry);
   524         {
   506     
   525         // handling imap4 or pop3 entry
   507         if( entry.iMtm == KUidMsgTypeIMAP4 || entry.iMtm == KUidMsgTypePOP3 )
   526         if(entry.iType.iUid==KUidMsvServiceEntryValue)
   508             {
   527             {
   509             // handling imap4 or pop3 entry
   528             // new mailbox has been created, starting sync for it
   510             if ( entry.iType.iUid == KUidMsvServiceEntryValue )
   529             User::After(KMailboxCreatedTimeout); // sleep for 0.5 sec; guarantees that mailbox is fully set up, and message server ready to serve it
   511                 {
   530             RefreshMailboxListL();
   512                 // new mailbox has been created, starting sync for it
   531             SendCommandToSpecificMailboxL( entry.Id(), CIpsSosAOMBoxLogic::ECommandStart );
   513                 User::After(KMailboxCreatedTimeout); // sleep for 0.5 sec; guarantees that mailbox is fully set up, and message server ready to serve it
   532             SendCommandToSpecificMailboxL( entry.Id(), CIpsSosAOMBoxLogic::ECommandStartSync );
   514                 RefreshMailboxListL();
   533             }
   515                 SendCommandToSpecificMailboxL( entry.Id(), CIpsSosAOMBoxLogic::ECommandStart );
       
   516                 SendCommandToSpecificMailboxL( entry.Id(), CIpsSosAOMBoxLogic::ECommandStartSync );
       
   517                 }
       
   518             }
       
   519         }
       
   520     }
       
   521 
       
   522 // ----------------------------------------------------------------------------
       
   523 // ----------------------------------------------------------------------------
       
   524 void CIpsSosAOImapPopLogic::handleEntriesChangedL(const TAny* aArg1, TAny* aArg2)
       
   525     {
       
   526     if (aArg1 && aArg2) 
       
   527         {
       
   528         TMsvId parent = (*(TMsvId*) (aArg2));
       
   529         //we check that parent is the root. if not, it cannot be an 
       
   530         //event from service, thus can't be from connection change..
       
   531         if ( parent == KMsvRootIndexEntryId )
       
   532             {
       
   533             TMsvEntry entry;
       
   534             getFirstEntryFromSelectionL(static_cast<const CMsvEntrySelection*>(aArg1), entry);
       
   535             if ( !entry.Connected() )
       
   536                 {
       
   537                 SendCommandToSpecificMailboxL( 
       
   538                         entry.Id(), 
       
   539                         CIpsSosAOMBoxLogic::ECommandClearDoNotDisconnect );
       
   540                 }
       
   541             } 
   534         }
   542         }
   535     }
   543     }
   536 
   544 
   537 // ----------------------------------------------------------------------------
   545 // ----------------------------------------------------------------------------
   538 // ----------------------------------------------------------------------------
   546 // ----------------------------------------------------------------------------