|
1 // Copyright (c) 1998-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 // CImImap4Synchronise header |
|
15 // |
|
16 // |
|
17 |
|
18 #if !defined(__IMAPSYNC_H__) |
|
19 #define __IMAPSYNC_H__ |
|
20 |
|
21 #include <mentact.h> |
|
22 #include <msventry.h> |
|
23 #include <imapset.h> |
|
24 |
|
25 // Forward declarations |
|
26 class CImImap4Session; |
|
27 class CImImap4FolderSync; |
|
28 class CImap4OffLineControl; |
|
29 class CImap4Utils; |
|
30 |
|
31 // List of folders to be synchronised |
|
32 class TImImap4SyncList |
|
33 /** |
|
34 @internalComponent |
|
35 @released |
|
36 */ |
|
37 { |
|
38 public: |
|
39 TMsvId iFolder; |
|
40 TTime iLastSync; |
|
41 TBool iNotSelectable; |
|
42 }; |
|
43 |
|
44 class CImImap4Synchronise : public CMsgActive |
|
45 /** |
|
46 @internalComponent |
|
47 @released |
|
48 */ |
|
49 { |
|
50 public: |
|
51 // States |
|
52 enum TSynchroniseState |
|
53 { |
|
54 ESyncStateIdle=1, |
|
55 EInboxSelect, |
|
56 EInboxPendingOps, |
|
57 EInboxSync, |
|
58 ESynchroniseFolderTree, // this must be in the correct place |
|
59 ECheckRemoteSubscription, |
|
60 EProcessRemoteSubscription, |
|
61 EUpdateRemoteSubscription, |
|
62 EFolderSelect, |
|
63 EFolderPendingOps, |
|
64 EFolderSynchronise, |
|
65 EInboxEarlyDeletes, |
|
66 EFolderEarlyDeletes, |
|
67 EFolderEarlyExpunge, |
|
68 EEndSelectInbox, |
|
69 EInboxLateExpunge, |
|
70 EFolderLateDeletes, |
|
71 EFolderLateExpunge, |
|
72 EInboxLogMessage, |
|
73 EFolderLogMessage, |
|
74 EStartIdle, |
|
75 ESynchronise, |
|
76 ESynchroniseTree, |
|
77 ESynchroniseDeletes |
|
78 }; |
|
79 |
|
80 public: |
|
81 ~CImImap4Synchronise(); |
|
82 static CImImap4Synchronise* NewLC(CImImap4Session *aSession); |
|
83 static CImImap4Synchronise* NewL(CImImap4Session *aSession); |
|
84 void ConstructL(CImImap4Session *aSession); |
|
85 |
|
86 // Mirror folder tree of remote server |
|
87 void SynchroniseL(TRequestStatus& aStatus, TMsvId aRoot, TBool aNewInvisible, TBool aPerformDeletes, TBool aConnectAndSync = EFalse); |
|
88 void SynchroniseDeletesL(TRequestStatus& aStatus, TMsvId aServiceId); |
|
89 void SynchroniseTreeL(TRequestStatus& aStatus, TMsvId aServiceId, TBool aNewFoldersAreInvisible); |
|
90 |
|
91 // Set serverentry to use |
|
92 void SetEntry(CMsvServerEntry* aEntry); |
|
93 |
|
94 // set OffLineControl to use |
|
95 void SetOffLineControl(CImap4OffLineControl *aOffLine); |
|
96 void SetUtils(CImap4Utils *aUtils); |
|
97 |
|
98 // Progress |
|
99 TImap4SyncProgress Progress(); |
|
100 |
|
101 private: |
|
102 CImImap4Synchronise(); |
|
103 void DoRunL(); |
|
104 void DoCancel(); |
|
105 void DoComplete(TInt& aStatus); |
|
106 |
|
107 // once round the state machine, returns whether to go round again |
|
108 TBool DoRunLoopL(); |
|
109 |
|
110 // do the appropriate offline operation |
|
111 void DoOpL(const CImOffLineOperation& aOp); |
|
112 |
|
113 // finish up the op just done (send log message, append delete |
|
114 // etc.) |
|
115 void DonePendingOpL(); |
|
116 |
|
117 // process the next one in the outstanding ops list. Returns ETrue |
|
118 // if finished |
|
119 TBool NextPendingOpL(); |
|
120 |
|
121 // process pending deletes of the type given in the given |
|
122 // folder. Returns ETrue if any items were deleted |
|
123 TBool MatchDeleteOp(const CImOffLineOperation& aOp , TBool aMoveDeletesOnly ); |
|
124 TBool ProcessPendingDeleteOpsL( TMsvId aFolder, TBool aMoveDeletesOnly ); |
|
125 TBool ProcessPendingDeleteOpsListL( TBool aMoveDeletesOnly ); |
|
126 |
|
127 // Add folders to 'to do' list according to prevailing strategy |
|
128 void AddLocalFoldersL(const TMsvId aFolder); |
|
129 |
|
130 // helper function for AddLocalFolders |
|
131 void AddIfNotThereL(TMsvId aFolder, CArrayFix<TImImap4SyncList>* aFolderList); |
|
132 |
|
133 // Sort to-do list |
|
134 void SortFolderListL(); |
|
135 |
|
136 // Set entry, leave if error (not related to setentry() which sets iEntry) |
|
137 void SetEntryL(const TMsvId aId); |
|
138 |
|
139 // Change entry, leave if error |
|
140 void ChangeEntryL(const TMsvEntry& aEntry); |
|
141 |
|
142 // Change entry in bulk mode (i.e. no index file commit), leave if error |
|
143 void ChangeEntryBulkL(const TMsvEntry& aEntry); |
|
144 |
|
145 // Get children, leave if error |
|
146 void GetChildrenL(CMsvEntrySelection& aSelection); |
|
147 |
|
148 // make aId and its parents visible |
|
149 void MakeVisibleL(TMsvId aId); |
|
150 |
|
151 // get the offlineOpArray from the id and set up iOutstandingOps and Folder |
|
152 TBool RefreshOutstandingOpsL(TMsvId aId); |
|
153 |
|
154 void ResetStats(); |
|
155 void GetInboxL(); |
|
156 |
|
157 private: |
|
158 // IMAP4 session to use |
|
159 CImImap4Session* iSession; |
|
160 |
|
161 // Folder tree synchronisation |
|
162 CImImap4FolderSync* iFolderSync; |
|
163 |
|
164 // Compound operation used for multi-step IMAP operations |
|
165 CImImap4Compound* iCompound; |
|
166 |
|
167 // Synchronisation state |
|
168 TSynchroniseState iState; |
|
169 TMsvId iServiceId; |
|
170 TMsvId iFolderId; |
|
171 TMsvId iInbox; |
|
172 TBool iNewFoldersAreInvisible; |
|
173 TBool iPerformDeletes; |
|
174 |
|
175 // Folders to synchronise |
|
176 TFolderSyncType iSynchroniseStrategy; |
|
177 TFolderSubscribeType iSubscribeStrategy; |
|
178 CArrayFix<TImImap4SyncList>* iFolderList; |
|
179 // temporary list of folders to be added to iFolderList at end |
|
180 CArrayFix<TImImap4SyncList>* iFolderListDest; |
|
181 |
|
182 // List of folders to subscribe or unsubscribe from |
|
183 CArrayFix<TMsvId>* iSubscribeList; |
|
184 CArrayFix<TMsvId>* iUnsubscribeList; |
|
185 |
|
186 // List of outstanding operations on inbox/other folder |
|
187 CImOffLineOperationArray* iOutstandingOps; |
|
188 // current folder p=being processed |
|
189 TMsvId iOutstandingOpsFolder; |
|
190 |
|
191 // list of ids that need to be deleted because they were the |
|
192 // source of a move |
|
193 CArrayFix<TMsvId>* iOutstandingMoveTypeDeletes; |
|
194 CArrayFix<TMsvId>* iOutstandingLocalDeletes; |
|
195 |
|
196 // source id of current operation if it was a move and so should |
|
197 // be deleted afterwards |
|
198 TMsvId iMovedId; |
|
199 |
|
200 // shadow id of current operation - to be deleted when op finishes |
|
201 TMsvId iShadowId; |
|
202 |
|
203 // Access to message database |
|
204 CMsvServerEntry* iEntry; |
|
205 |
|
206 // Timer for new mail check |
|
207 RTimer iCheckMailbox; |
|
208 |
|
209 // Current request status |
|
210 TRequestStatus* iRequestStatus; |
|
211 |
|
212 // pointer to offline control object held by MTM |
|
213 CImap4OffLineControl* iOffLineControl; |
|
214 |
|
215 TImap4SyncProgress iProgress; |
|
216 |
|
217 CImap4Utils* iUtils; |
|
218 |
|
219 TBool iIdleBeforeCommand; |
|
220 |
|
221 // Flag to indicate Pending Operation/s are done on folder, need to sync Inbox |
|
222 TBool iPendingOpOnFolder; |
|
223 |
|
224 }; |
|
225 |
|
226 #endif |