email/imap4mtm/imapprotocolcontroller/inc/cimapopbackgroundsync.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __CIMAPOPBACKGROUNDSYNC_H__
       
    17 #define __CIMAPOPBACKGROUNDSYNC_H__
       
    18 
       
    19 class CActive;
       
    20 class CImapFolder;
       
    21 class CImapSyncManager;
       
    22 class CImapSession;
       
    23 class MImapOpBackgroundSyncObserver;
       
    24 class CImapSettings;
       
    25 class CImapCompoundSyncService;
       
    26 class CMsvServerEntry;
       
    27 class TImap4CompoundProgress;
       
    28 class CImapMailStore;
       
    29 class CImapOfflineControl;
       
    30 class CMsvEntrySelection;
       
    31 
       
    32 /**
       
    33 The CImapOpBackgroundSync class encapsulates the management of performing
       
    34 a background synchronisation operation. It utilises CImapCompoundBase
       
    35 derived operation classes to perform the necessary asynchronous operations
       
    36 and reports completion or errors via the MImapOpBackgroundSyncObserver
       
    37 API, a reference to an instance of which is passed on construction.
       
    38 
       
    39 @internalTechnology
       
    40 @prototype
       
    41 */
       
    42 class CImapOpBackgroundSync : public CActive
       
    43 	{
       
    44 private:
       
    45 	enum TBackgroundSyncState 
       
    46 		{
       
    47 		ENotInUse,
       
    48 		EStartingSync,
       
    49 		ESynchronising,
       
    50 		ECancelRecoveringSession,
       
    51 		ECancelRefreshingSyncManager,
       
    52 		EFinished
       
    53 		};
       
    54 
       
    55 public:
       
    56 	virtual ~CImapOpBackgroundSync( );
       
    57 	
       
    58 	static CImapOpBackgroundSync* NewL( MImapOpBackgroundSyncObserver& aBackgroundSyncObserver,
       
    59 										CMsvServerEntry& aServerEntry,
       
    60 										CImapSyncManager& aSyncMan,
       
    61 										CImapSettings& aImapSettings,
       
    62 										CImapMailStore& aImapMailStore,
       
    63 										CImapOfflineControl& aImapOfflineControl );
       
    64 
       
    65 	void StartSync(CImapSession& aSession);
       
    66 	void CancelAndCleanup();
       
    67 	
       
    68 	void Progress(TImap4CompoundProgress& aCompoundProgress);
       
    69 	
       
    70 	// Support for Bearer Mobility
       
    71 	void  CancelForMigrate();
       
    72 	void  StopForMigrate();
       
    73 	void  ResumeOperationL(CImapSession& aSession);
       
    74 	TBool IsSuspendedForMigrate();
       
    75 	
       
    76 	// Support for sync using download rules.
       
    77 	void RemoveFromSelectionL(CMsvEntrySelection& aDeleteSel);
       
    78 
       
    79 private:
       
    80 	CImapOpBackgroundSync( MImapOpBackgroundSyncObserver& aBackgroundSyncObserver, 
       
    81 						   CMsvServerEntry& aServerEntry,
       
    82 						   CImapSyncManager& aSyncMan, 
       
    83 						   CImapSettings& aImapSettings,
       
    84 						   CImapMailStore& aImapMailStore,
       
    85 						   CImapOfflineControl& aImapOfflineControl );
       
    86 	void ConstructL();
       
    87 	
       
    88 	// from CActive
       
    89 	virtual void RunL();
       
    90 	virtual TInt RunError(TInt aError);
       
    91 	virtual void DoCancel();
       
    92 
       
    93 private:
       
    94 	
       
    95 	// background sync-op migration states:
       
    96 	enum TImapBgMigrateState
       
    97 		{
       
    98 		ENotMigrating,				// normal state
       
    99 		ECancellingForMigrate,      // intermediate state
       
   100 		EStoppingForMigrate,		// stop requested...
       
   101 		ESuspendedForMigrate        // waiting to be restarted
       
   102 		};
       
   103 		
       
   104 	MImapOpBackgroundSyncObserver& iBackgroundSyncObserver;
       
   105 	CImapSession* iSession;
       
   106 	CMsvServerEntry& iEntry;
       
   107 	CImapSyncManager& iSyncMan;
       
   108 	CImapSettings& iImapSettings;
       
   109 	CImapMailStore& iImapMailStore;
       
   110 	CImapOfflineControl& iImapOfflineControl; 
       
   111 	CImapCompoundSyncService* iCompoundSync;
       
   112 
       
   113 	TBackgroundSyncState iState;
       
   114 	TImapBgMigrateState  iMigrateState;
       
   115 	};
       
   116 
       
   117 #endif	//__CIMAPOPBACKGROUNDSYNC_H__