ipsservices/ipssosplugin/src/ipsplgsosbaseplugin.cpp
changeset 44 c2d07d913565
parent 43 99bcbff212ad
child 62 a8c646b56683
--- a/ipsservices/ipssosplugin/src/ipsplgsosbaseplugin.cpp	Fri May 28 13:56:43 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgsosbaseplugin.cpp	Thu Jun 10 16:14:05 2010 +0300
@@ -25,11 +25,13 @@
 #include "ipsplgmailstoreroperation.h"
 #include "ipsplgmessagepartstoreroperation.h"
 #include "BasePlugin.h" 
+//<Qmail>
+#include "ipssosextendedsettingsmanager.h"
+#include "ipssettingkeys.h"
+//</Qmail>
 //</qmail>
 
-// <cmail> S60 UID update
 #define FREESTYLE_EMAIL_UI_SID 0x200255BA
-// </cmail> S60 UID update
 
 const TInt KOpGranularity = 2;
 
@@ -39,6 +41,29 @@
 _LIT( KEmulatorIMEI, "123456789012345" );
 #endif // __WINS__
 
+//<Qmail>
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsPlgSosBasePlugin::ActiveFolderChanged(
+        const TFSMailMsgId& aActiveMailboxId,
+        const TFSMailMsgId& aActiveFolderId)
+    {
+    TRAP_IGNORE( HandleActiveFolderChangeL(aActiveMailboxId,aActiveFolderId) );
+    }
+
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+CEmailExtension* CIpsPlgSosBasePlugin::ExtensionL( const TUid& aInterfaceUid )
+    {
+    if(aInterfaceUid != KEmailMailboxStateExtensionUid)
+        {
+        User::Leave(KErrNotSupported);
+        }
+    
+    return iStateExtension;
+    }
+//</Qmail>
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // <qmail> iSettingsApi removed
@@ -77,6 +102,7 @@
         {
         iEventHandler->UnRegisterPropertyObserver( iSyncStateHandler );
         }
+    delete iStateExtension;
     delete iEventHandler;
     delete iCachedEntry;
     delete iCachedEmailMessage;
@@ -92,6 +118,7 @@
 void CIpsPlgSosBasePlugin::BaseConstructL()
     {
     FUNC_LOG;
+    iStateExtension = CIpsStateExtension::NewL(*this);
     iEventHandler = CIpsPlgEventHandler::NewL( *this );
     iSession = CMsvSession::OpenAsyncL( *iEventHandler );
     iMsgMapper = CIpsPlgMsgMapper::NewL( *iSession, *this );
@@ -2456,4 +2483,50 @@
         }
     return ret;
     }
+//</Qmail>
+//<Qmail>
+// ---------------------------------------------------------------------------
+// CIpsPlgImap4Plugin::HandleActiveFolderChangeL
+// ---------------------------------------------------------------------------
+//
+void CIpsPlgSosBasePlugin::HandleActiveFolderChangeL(
+        const TFSMailMsgId& aActiveMailboxId,
+        const TFSMailMsgId& aActiveFolderId)
+    {
+    TMsvId service;
+    TMsvEntry folder;
+    iSession->GetEntry( aActiveFolderId.Id(), service, folder );
+    
+    
+    //currently, no actions unless this is inbox
+    //also, if id is '0', it means inbox before first sync...it doesn't really exist yet
+    if( folder.iDetails.CompareF( KIpsPlgInbox ) == 0 || folder.Id() == 0 )
+        {
+        //folder is inbox
+        if ( iSyncStateHandler->GetMailboxIpsState( aActiveMailboxId.Id() )
+                    == KIpsSosEmailSyncStarted )
+            {
+            //we won't do anything if sync is already started
+            return;
+            }
+        
+        //check are we in polling mode
+        NmIpsSosExtendedSettingsManager* eMgr= 
+                new NmIpsSosExtendedSettingsManager(aActiveMailboxId.Id());
+        
+        QVariant value;
+        bool ok = eMgr->readSetting(IpsServices::ReceptionActiveProfile, value);
+        delete eMgr;
+        
+        if ( ok )
+            {
+            TInt profile = value.toInt();
+            if ( profile != IpsServices::EmailSyncProfileManualFetch )
+                {
+                // let's sync
+                GoOnlineL(aActiveMailboxId);
+                }
+            }        
+        }        
+    }
 // </qmail>