|
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 __CIMAPCOMPOUNDBASE_H__ |
|
17 #define __CIMAPCOMPOUNDBASE_H__ |
|
18 |
|
19 #include <mentact.h> |
|
20 #include <msvstd.h> |
|
21 #include <imapset.h> |
|
22 |
|
23 class CImapSession; |
|
24 class CImapSettings; |
|
25 class CImapSyncManager; |
|
26 class CMsvServerEntry; |
|
27 class TImap4CompoundProgress; |
|
28 |
|
29 // Operation step identifiers |
|
30 enum TCompoundStep |
|
31 { |
|
32 EFinished = 0, |
|
33 ESelectSourceMailboxRW = 1, |
|
34 ESelectSourceMailboxRO = 2, |
|
35 ESelectDestinationMailboxRW = 3, |
|
36 ESelectDestinationMailboxRO = 4, |
|
37 EFetchMessage = 5, |
|
38 ECopyMessage = 6, |
|
39 EAppendMessage = 7, |
|
40 EDeleteMessage = 8, |
|
41 EDeleteLocalMessage = 9, |
|
42 EDeleteAllMessages = 10, |
|
43 ENewSyncFolder = 11, |
|
44 ESyncFolder = 12, |
|
45 EInboxDuplicateMove = 13, |
|
46 EInboxDuplicateCopy = 14, |
|
47 ECloseFolder = 15, |
|
48 EDeleteFolder = 16, |
|
49 ECreate = 17, |
|
50 ERename = 18, |
|
51 ECreateSession = 19, |
|
52 EStartBackgroundSyncOp = 20, |
|
53 ESelectInboxRW = 21, |
|
54 EFetchMessageInitialise = 22, |
|
55 ELocalCopyComplete = 23, |
|
56 EExpunge = 24, |
|
57 ESetSourceMailbox = 25, |
|
58 ESyncTree = 26, |
|
59 ESyncService = 27, |
|
60 EDeleteLocalFolder = 28, |
|
61 EDisconnect = 29, |
|
62 ESetSource = 30, |
|
63 EProcessRenameResponse = 31, |
|
64 ECreateLocal = 32, |
|
65 ESyncSubscriptions = 33, |
|
66 EInboxDoneOps = 34, |
|
67 EFolderDoneOps = 35, |
|
68 EFolderCheckPendingOPs = 36, |
|
69 EInboxCheckPendingOps = 37, |
|
70 EInboxSync = 38, |
|
71 EInboxEarlyDeletes = 39, |
|
72 EFolderEarlyDeletes = 40, |
|
73 EInboxEarlyExpunge = 41, |
|
74 EFolderEarlyExpunge = 42, |
|
75 EInboxLateDeletes = 43, |
|
76 EFolderLateDeletes = 44, |
|
77 EInboxLateExpunge = 45, |
|
78 EFolderLateExpunge = 46, |
|
79 EProcessFetchFlags = 47, |
|
80 ESelectSyncFolder = 48, |
|
81 ECheckDestinationMailbox = 49, |
|
82 ESelectFolderAfterClose = 50, |
|
83 ESuspendedForMigrate = 51, |
|
84 ESyncInboxAutoFetch = 52, |
|
85 ESyncFolderAutoFetchCheck = 53, |
|
86 ESyncFolderAutoFetch = 54, |
|
87 ECheckFolderExists = 55, |
|
88 EProcessFolderCheck = 56, |
|
89 EUpdateFlag = 57 |
|
90 }; |
|
91 |
|
92 /** |
|
93 @internalTechnology |
|
94 @prototype |
|
95 */ |
|
96 class CImapCompoundBase : public CMsgActive |
|
97 { |
|
98 |
|
99 public: |
|
100 ~CImapCompoundBase(); |
|
101 |
|
102 virtual void StartOperation(TRequestStatus& aStatus, CImapSession& aSession) = 0; |
|
103 virtual void Progress(TImap4CompoundProgress& aCompoundProgress) = 0; |
|
104 virtual void StopForMigrate(); |
|
105 void CancelForMigrate(); |
|
106 virtual void ResumeOperationL(TRequestStatus& aStatus, CImapSession& aSession) = 0; |
|
107 TBool Suspended(); |
|
108 |
|
109 |
|
110 |
|
111 protected: |
|
112 CImapCompoundBase(CImapSyncManager& aSyncManager, CMsvServerEntry& aServerEntry, CImapSettings& aImapSettings); |
|
113 void DoRunL(); |
|
114 virtual TBool DoRunLoopL() = 0; |
|
115 virtual void DoComplete(TInt& aErr); |
|
116 |
|
117 TInt ProcessSessionError(); |
|
118 virtual TInt ProcessNegativeServerResponse() = 0; |
|
119 |
|
120 // utility methods: |
|
121 TInt CheckSelectionL(const CMsvEntrySelection& aSelection, CMsvEntrySelection* aLocalCopy, const TBool aMessages, const TBool aParts, const TBool aFolders, const TBool aIsInService); |
|
122 TInt CalculateDownloadSizeL(const CMsvEntrySelection& aSelection); |
|
123 TMsvId FindFolderL(const TMsvId aMessage); |
|
124 void SetEntryL(const TMsvId aId); |
|
125 void CompleteSelf(); |
|
126 void SetCurrentStep(); |
|
127 void MessageErrorL(const TMsvId aMessageId, const TInt aError); |
|
128 |
|
129 protected: |
|
130 CImapSession* iSession; // not owned by this class |
|
131 CImapSyncManager& iSyncManager; |
|
132 |
|
133 CMsvServerEntry& iServerEntry; |
|
134 CImapSettings& iImapSettings; |
|
135 |
|
136 TCompoundStep iCurrentStep; |
|
137 TCompoundStep iNextStep; |
|
138 |
|
139 TInt iProgressErrorCode; // Is set when an error occur. |
|
140 TBool iStopForMigrate; // set if stop for migrate requested |
|
141 TBool iCancelForMigrate; // set if cancelling for migrate |
|
142 |
|
143 TImap4GenericProgress::TImap4GenericProgressState iProgressState; |
|
144 TImap4SyncProgress::TImap4SyncProgressState iSyncProgressState; |
|
145 }; |
|
146 |
|
147 #endif // __CIMAPCOMPOUNDBASE_H__ |