ipsservices/ipssosplugin/src/ipsplgsosbaseplugin.cpp
changeset 44 c2d07d913565
parent 43 99bcbff212ad
child 62 a8c646b56683
equal deleted inserted replaced
43:99bcbff212ad 44:c2d07d913565
    23 // <qmail>
    23 // <qmail>
    24 #include "ipsplgsosbaseplugin.hrh"
    24 #include "ipsplgsosbaseplugin.hrh"
    25 #include "ipsplgmailstoreroperation.h"
    25 #include "ipsplgmailstoreroperation.h"
    26 #include "ipsplgmessagepartstoreroperation.h"
    26 #include "ipsplgmessagepartstoreroperation.h"
    27 #include "BasePlugin.h" 
    27 #include "BasePlugin.h" 
       
    28 //<Qmail>
       
    29 #include "ipssosextendedsettingsmanager.h"
       
    30 #include "ipssettingkeys.h"
       
    31 //</Qmail>
    28 //</qmail>
    32 //</qmail>
    29 
    33 
    30 // <cmail> S60 UID update
       
    31 #define FREESTYLE_EMAIL_UI_SID 0x200255BA
    34 #define FREESTYLE_EMAIL_UI_SID 0x200255BA
    32 // </cmail> S60 UID update
       
    33 
    35 
    34 const TInt KOpGranularity = 2;
    36 const TInt KOpGranularity = 2;
    35 
    37 
    36 // <qmail> remove unused literals
    38 // <qmail> remove unused literals
    37 
    39 
    38 #ifdef __WINS__
    40 #ifdef __WINS__
    39 _LIT( KEmulatorIMEI, "123456789012345" );
    41 _LIT( KEmulatorIMEI, "123456789012345" );
    40 #endif // __WINS__
    42 #endif // __WINS__
    41 
    43 
       
    44 //<Qmail>
       
    45 // ----------------------------------------------------------------------------
       
    46 // ----------------------------------------------------------------------------
       
    47 void CIpsPlgSosBasePlugin::ActiveFolderChanged(
       
    48         const TFSMailMsgId& aActiveMailboxId,
       
    49         const TFSMailMsgId& aActiveFolderId)
       
    50     {
       
    51     TRAP_IGNORE( HandleActiveFolderChangeL(aActiveMailboxId,aActiveFolderId) );
       
    52     }
       
    53 
       
    54 
       
    55 // ----------------------------------------------------------------------------
       
    56 // ----------------------------------------------------------------------------
       
    57 CEmailExtension* CIpsPlgSosBasePlugin::ExtensionL( const TUid& aInterfaceUid )
       
    58     {
       
    59     if(aInterfaceUid != KEmailMailboxStateExtensionUid)
       
    60         {
       
    61         User::Leave(KErrNotSupported);
       
    62         }
       
    63     
       
    64     return iStateExtension;
       
    65     }
       
    66 //</Qmail>
    42 // ----------------------------------------------------------------------------
    67 // ----------------------------------------------------------------------------
    43 // ----------------------------------------------------------------------------
    68 // ----------------------------------------------------------------------------
    44 // <qmail> iSettingsApi removed
    69 // <qmail> iSettingsApi removed
    45 CIpsPlgSosBasePlugin::CIpsPlgSosBasePlugin( const TUint aFSPluginId ) :
    70 CIpsPlgSosBasePlugin::CIpsPlgSosBasePlugin( const TUint aFSPluginId ) :
    46     iFSPluginId( aFSPluginId ),
    71     iFSPluginId( aFSPluginId ),
    75     delete iMruList;
   100     delete iMruList;
    76     if ( iEventHandler )
   101     if ( iEventHandler )
    77         {
   102         {
    78         iEventHandler->UnRegisterPropertyObserver( iSyncStateHandler );
   103         iEventHandler->UnRegisterPropertyObserver( iSyncStateHandler );
    79         }
   104         }
       
   105     delete iStateExtension;
    80     delete iEventHandler;
   106     delete iEventHandler;
    81     delete iCachedEntry;
   107     delete iCachedEntry;
    82     delete iCachedEmailMessage;
   108     delete iCachedEmailMessage;
    83     delete iMsgMapper;
   109     delete iMsgMapper;
    84     delete iSearch;
   110     delete iSearch;
    90 // ----------------------------------------------------------------------------
   116 // ----------------------------------------------------------------------------
    91 // ----------------------------------------------------------------------------
   117 // ----------------------------------------------------------------------------
    92 void CIpsPlgSosBasePlugin::BaseConstructL()
   118 void CIpsPlgSosBasePlugin::BaseConstructL()
    93     {
   119     {
    94     FUNC_LOG;
   120     FUNC_LOG;
       
   121     iStateExtension = CIpsStateExtension::NewL(*this);
    95     iEventHandler = CIpsPlgEventHandler::NewL( *this );
   122     iEventHandler = CIpsPlgEventHandler::NewL( *this );
    96     iSession = CMsvSession::OpenAsyncL( *iEventHandler );
   123     iSession = CMsvSession::OpenAsyncL( *iEventHandler );
    97     iMsgMapper = CIpsPlgMsgMapper::NewL( *iSession, *this );
   124     iMsgMapper = CIpsPlgMsgMapper::NewL( *iSession, *this );
    98     iSmtpService = CIpsPlgSmtpService::NewL( *iSession, *this );
   125     iSmtpService = CIpsPlgSmtpService::NewL( *iSession, *this );
    99     iMruList = CIpsPlgMruList::NewL( );
   126     iMruList = CIpsPlgMruList::NewL( );
  2454             ret = ETrue;
  2481             ret = ETrue;
  2455             }
  2482             }
  2456         }
  2483         }
  2457     return ret;
  2484     return ret;
  2458     }
  2485     }
       
  2486 //</Qmail>
       
  2487 //<Qmail>
       
  2488 // ---------------------------------------------------------------------------
       
  2489 // CIpsPlgImap4Plugin::HandleActiveFolderChangeL
       
  2490 // ---------------------------------------------------------------------------
       
  2491 //
       
  2492 void CIpsPlgSosBasePlugin::HandleActiveFolderChangeL(
       
  2493         const TFSMailMsgId& aActiveMailboxId,
       
  2494         const TFSMailMsgId& aActiveFolderId)
       
  2495     {
       
  2496     TMsvId service;
       
  2497     TMsvEntry folder;
       
  2498     iSession->GetEntry( aActiveFolderId.Id(), service, folder );
       
  2499     
       
  2500     
       
  2501     //currently, no actions unless this is inbox
       
  2502     //also, if id is '0', it means inbox before first sync...it doesn't really exist yet
       
  2503     if( folder.iDetails.CompareF( KIpsPlgInbox ) == 0 || folder.Id() == 0 )
       
  2504         {
       
  2505         //folder is inbox
       
  2506         if ( iSyncStateHandler->GetMailboxIpsState( aActiveMailboxId.Id() )
       
  2507                     == KIpsSosEmailSyncStarted )
       
  2508             {
       
  2509             //we won't do anything if sync is already started
       
  2510             return;
       
  2511             }
       
  2512         
       
  2513         //check are we in polling mode
       
  2514         NmIpsSosExtendedSettingsManager* eMgr= 
       
  2515                 new NmIpsSosExtendedSettingsManager(aActiveMailboxId.Id());
       
  2516         
       
  2517         QVariant value;
       
  2518         bool ok = eMgr->readSetting(IpsServices::ReceptionActiveProfile, value);
       
  2519         delete eMgr;
       
  2520         
       
  2521         if ( ok )
       
  2522             {
       
  2523             TInt profile = value.toInt();
       
  2524             if ( profile != IpsServices::EmailSyncProfileManualFetch )
       
  2525                 {
       
  2526                 // let's sync
       
  2527                 GoOnlineL(aActiveMailboxId);
       
  2528                 }
       
  2529             }        
       
  2530         }        
       
  2531     }
  2459 // </qmail>
  2532 // </qmail>