ipsservices/ipssosaoplugin/src/IpsSosAOImapPopLogic.cpp
branchRCL_3
changeset 64 3533d4323edc
parent 63 d189ee25cf9d
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOImapPopLogic.cpp	Tue Aug 31 15:04:17 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOImapPopLogic.cpp	Wed Sep 01 12:28:57 2010 +0100
@@ -16,7 +16,25 @@
 *
 */
 
-#include "ipssosaopluginheaders.h"
+
+#include "emailtrace.h"
+#include <AlwaysOnlineManagerClient.h>
+#include <SendUiConsts.h>
+#include <msvids.h>
+#include <msvuids.h>
+
+// becuase of RD_IPS_AO_PLUGIN flag, can be removed
+// when flag is removed
+#include "ipsplgsosbaseplugin.hrh"
+
+#include "IpsSosAOImapPopLogic.h"
+#include "IpsSosAOMboxLogic.h"
+#include "IpsSosAOEMNResolver.h"
+#include "ipssetdataapi.h"
+
+
+
+#include "ipsplgcommon.h"
 
 //const TInt KAOSmtpStartDelaySeconds = 310;
 const TInt KIpsSosAOImapPopLogicDefGra = 1;
@@ -42,9 +60,7 @@
     iMailboxLogics.ResetAndDestroy();
    // iActiveEvents.ResetAndDestroy();
     delete iEmnResolver;
-	//<QMail>
-
-	//</QMail>
+    delete iDataApi;
     }
 
 // ----------------------------------------------------------------------------
@@ -68,9 +84,7 @@
     {
     FUNC_LOG;
     iEmnResolver = CIpsSosAOEMNResolver::NewL();
-	//<QMail>
-
-	//</QMail>
+    iDataApi = CIpsSetDataApi::NewL( iSession );
     }
 
 // ----------------------------------------------------------------------------
@@ -202,6 +216,9 @@
             result = KErrNotSupported;
             break;
         }
+   
+    
+    // </cmail>
     return result;
     }
 
@@ -209,6 +226,7 @@
 // ----------------------------------------------------------------------------
 // 
 void CIpsSosAOImapPopLogic::HandleMsvSessionEventL(
+// <cmail> RD_IPS_AO_PLUGIN flag removed
      MMsvSessionObserver::TMsvSessionEvent aEvent, 
      TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/ )
     {
@@ -220,7 +238,7 @@
         case MMsvSessionObserver::EMsvEntriesChanged:
             {
             TMsvId parent = (*(TMsvId*) (aArg2));
-            //we check that parent is the root. if not, it cannot be an 
+            //we check that parent is the root. if not, it cannot be a 
             //event from service, thus can't be from connection change..
             if ( parent == KMsvRootIndexEntryId )
                 {
@@ -244,20 +262,14 @@
             }
             break;
         case MMsvSessionObserver::EMsvEntriesDeleted:
-            {
-            TMsvId parent = (*(TMsvId*) (aArg2));
-            //we check that parent is the root. if not, it cannot be an 
-            //event indicating deleted mailbox entry
-            if ( parent == KMsvRootIndexEntryId )
-                {
-                RemoveOrphanLogicsL();
-                }
-            }
-            break;
+            // NOTE: if mailbox is deleted somewhere else than ips plugin
+            // in here need to put logic for removing corresponding 
+            // mailboxlogic object
         case MMsvSessionObserver::EMsvEntriesMoved:
         default:
             break;
         };
+    // </cmail>
     }
 
 // ----------------------------------------------------------------------------
@@ -325,13 +337,14 @@
         if ( index != KErrNotFound )
             {
             CIpsSosAOMBoxLogic* logic = iMailboxLogics[index];
-            
+            //<cmail>
 			if ( !logic->FirstEMNReceived() )
                 {
                 logic->SetFirstEMNReceived();
                 }
             if ( !iNoNWOpsAllowed && 
                  !logic->IsMailboxRoamingStoppedL() )
+            //</cmail>
                 {
                 SendCommandToSpecificMailboxL( 
                     logic->GetMailboxId(), // faulty CS warning
@@ -339,11 +352,17 @@
                 }
             else
                 {
-                logic->SetEmnReceivedFlagL( ETrue );                
+                //<cmail>
+                logic->SetEmnReceivedFlagL( ETrue );
+                //</cmail>
                 }
             logic = NULL;
             }
-
+/*<cmail>
+        else
+            {
+            }
+</cmail>*/
         }
     }
 
@@ -386,39 +405,32 @@
                 found = ETrue;
                 }
             }
-		//<QMail>
-        CIpsSosAOSettingsHandler* settings = 
-                 CIpsSosAOSettingsHandler::NewL(iSession, mboxId);
-        CleanupStack::PushL(settings);
-         
-        if ( !found  && ( settings->AlwaysOnlineState() 
-                != IpsServices::EMailAoOff || 
-                    settings->EmailNotificationState() 
-                != IpsServices::EMailEmnOff || 
-                    !settings->FirstEmnReceived() )
-                 )
+        
+        CIpsSetDataExtension* extSet = CIpsSetDataExtension::NewLC();
+        TRAPD( error, iDataApi->LoadExtendedSettingsL( 
+                mboxId, *extSet ) );
+        if ( error == KErrNone  )
             {
-            CIpsSosAOMBoxLogic* newLogic = CIpsSosAOMBoxLogic::NewL( 
-                    iSession, mboxId );
-            CleanupStack::PushL( newLogic );
-            iMailboxLogics.AppendL( newLogic );
-            CleanupStack::Pop( newLogic );
+            if ( !found  && ( extSet->AlwaysOnlineState() != EMailAoOff || 
+                    extSet->EmailNotificationState() != EMailEmnOff || 
+                    !extSet->FirstEmnReceived() )
+                     )
+                {
+                CIpsSosAOMBoxLogic* newLogic = CIpsSosAOMBoxLogic::NewL( 
+                        iSession, mboxId );
+                CleanupStack::PushL( newLogic );
+                iMailboxLogics.AppendL( newLogic );
+                CleanupStack::Pop( newLogic );
+                }
+            else if ( found && extSet->AlwaysOnlineState() == EMailAoOff &&
+                    extSet->EmailNotificationState() == EMailEmnOff &&
+                    extSet->FirstEmnReceived() )
+                {
+                StopAndRemoveMailboxL( mboxId );
+                }
             }
-        else if ( found && settings->AlwaysOnlineState() 
-                == IpsServices::EMailAoOff &&
-                    settings->EmailNotificationState() 
-                == IpsServices::EMailEmnOff &&
-                    settings->FirstEmnReceived() )
-            {
-            StopAndRemoveMailboxL( mboxId );
-            }
-        
-        CleanupStack::PopAndDestroy(settings);
-		//</QMail>
+        CleanupStack::PopAndDestroy( extSet );
         }
-    
-    //finally, check for orphans ( mailbox has been deleted )
-    RemoveOrphanLogicsL();
     }
 
 // ----------------------------------------------------------------------------
@@ -483,33 +495,5 @@
     return index;
     }
 
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-//
-void CIpsSosAOImapPopLogic::RemoveOrphanLogicsL()
-    {
-    CMsvEntry* cEntry = iSession.GetEntryL( KMsvRootIndexEntryId );
-    CleanupStack::PushL( cEntry );
-    
-    CMsvEntrySelection* popEntries = cEntry->ChildrenWithMtmL( KSenduiMtmPop3Uid );
-    CleanupStack::PushL( popEntries );
-    
-    CMsvEntrySelection* imapEntries = cEntry->ChildrenWithMtmL( KSenduiMtmImap4Uid );
-    CleanupStack::PushL( imapEntries );
-        
-        
-    TInt count = iMailboxLogics.Count();
-    
-    for(TInt i=count-1; i>-1;i--)
-        {
-        if( popEntries->Find(iMailboxLogics[i]->GetMailboxId()) == KErrNotFound &&
-            imapEntries->Find(iMailboxLogics[i]->GetMailboxId()) == KErrNotFound)
-            {
-            StopAndRemoveMailboxL( iMailboxLogics[i]->GetMailboxId() );
-            }
-        }
-    
-    CleanupStack::PopAndDestroy( 3, cEntry );
-    }
 // End of file