|
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 // imapsyncmanager.h |
|
15 // CImapSyncManager header |
|
16 // |
|
17 // |
|
18 |
|
19 #if !defined(__IMAPSYNCMANAGER_H__) |
|
20 #define __IMAPSYNCMANAGER_H__ |
|
21 |
|
22 #include <mentact.h> |
|
23 #include <msventry.h> |
|
24 #include <imapset.h> |
|
25 #include "cimapsettings.h" |
|
26 #include "cimapofflinecontrol.h" |
|
27 #include "cimapsession.h" |
|
28 |
|
29 // Forward declarations |
|
30 class CImapFolder; |
|
31 class CImapOpSyncFolderTree; |
|
32 class CImapOpSyncSubs; |
|
33 class TImap4Progress; |
|
34 class CImapSession; |
|
35 class TImap4SyncProgress; |
|
36 |
|
37 class CImapSyncManager : public CMsgActive |
|
38 /** |
|
39 @internalComponent |
|
40 @prototype |
|
41 */ |
|
42 { |
|
43 public: |
|
44 // States |
|
45 enum TSynchroniseState |
|
46 { |
|
47 ESyncStateIdle=1, |
|
48 EInboxSelect, |
|
49 EFolderExpunge, |
|
50 EInboxPendingOps, |
|
51 EInboxSync, |
|
52 ESynchroniseFolderTree, |
|
53 ECheckRemoteSubscription, |
|
54 EProcessRemoteSubscription, |
|
55 EUpdateRemoteSubscription, |
|
56 EFolderSelect, |
|
57 EFolderPendingOps, |
|
58 EFolderSynchronise, |
|
59 EInboxEarlyDeletes, |
|
60 EFolderEarlyDeletes, |
|
61 EFolderEarlyExpunge, |
|
62 EEndSelectInbox, |
|
63 EEndInboxSync, |
|
64 ESyncFlags, |
|
65 EEndSyncFlags, |
|
66 ESyncProcessSeenFlagsAndComplete, |
|
67 EInboxLateExpunge, |
|
68 EFolderLateDeletes, |
|
69 EFolderLateExpunge, |
|
70 EInboxLogMessage, |
|
71 EFolderLogMessage, |
|
72 EStartIdle, |
|
73 ESynchronise, |
|
74 ESynchroniseTree, |
|
75 EEndSynchroniseTree, |
|
76 ESynchroniseDeletes, |
|
77 ENotSyncing, |
|
78 ESyncOld, |
|
79 ESyncNew, |
|
80 ESyncFetchingMessage, |
|
81 ESyncSearch, |
|
82 ESyncListOld, |
|
83 ESyncListNew, |
|
84 EGettingStructure, |
|
85 EEndSingleSyncStep, |
|
86 EFolderLocalExpunge, |
|
87 EFolderClose, |
|
88 EFolderReSelect |
|
89 }; |
|
90 |
|
91 enum TImapProgress |
|
92 { |
|
93 /** Disconnected. */ |
|
94 EDisconnected, |
|
95 /** Connecting. */ |
|
96 EConnecting, |
|
97 /** Idle. */ |
|
98 EIdle, |
|
99 /** Selecting the folder to use. */ |
|
100 ESelecting, |
|
101 /** Fetching messages to mirror server. */ |
|
102 EFetching, |
|
103 /** Appending local messages to remote server. */ |
|
104 EAppending, |
|
105 /** Copying local messages to local or within service. */ |
|
106 ECopying, |
|
107 /** Deleting an item, including expunging a folder. */ |
|
108 EDeleting, |
|
109 /** Synchronising folder after an operation. */ |
|
110 ESyncing, |
|
111 /** Disconnecting. */ |
|
112 EDisconnecting, |
|
113 /** Sync already in progress. */ |
|
114 EBusy, |
|
115 /** CImImap4GetMail move operation in progress. */ |
|
116 EMoving, |
|
117 /** CImImap4GetMail copy new mail operation in progress. */ |
|
118 ECopyNewMail, |
|
119 /** CImImap4GetMail move new mail operation in progress. */ |
|
120 EMoveNewMail, |
|
121 /** CImImap4GetMail copy selected messages operation in progress. */ |
|
122 ECopyMailSelection, |
|
123 /** CImImap4GetMail move selected messages operation in progress. */ |
|
124 EMoveMailSelection, |
|
125 /** CImImap4GetMail copy all messages operation in progress. */ |
|
126 ECopyAllMail, |
|
127 /** CImImap4GetMail move all messages operation in progress. */ |
|
128 EMoveAllMail, |
|
129 /** CImImap4GetMail populate new messages operation in progress. */ |
|
130 EPopulateNewMail, |
|
131 /** CImImap4GetMail populate all messages operation in progress. */ |
|
132 EPopulateAllMail, |
|
133 /** CImImap4GetMail populate selected messages operation in progress. */ |
|
134 EPopulateMailSelection |
|
135 }; |
|
136 |
|
137 // Class contructors and destructor |
|
138 IMPORT_C static CImapSyncManager* NewLC(CMsvServerEntry& aEntry, CImapSettings& aImapSettings); |
|
139 IMPORT_C static CImapSyncManager* NewL(CMsvServerEntry& aEntry, CImapSettings& aImapSettings); |
|
140 ~CImapSyncManager(); |
|
141 |
|
142 // Mirror folder tree of remote server |
|
143 IMPORT_C void SynchroniseDeletesL(TRequestStatus& aStatus, CImapSession& aSession); |
|
144 |
|
145 IMPORT_C void SynchroniseInboxL(TRequestStatus& aStatus, CImapSession& aSession); |
|
146 IMPORT_C void SynchroniseFolderTreeL(TRequestStatus& aStatus, CImapSession& aSession); |
|
147 IMPORT_C void SynchroniseFolderSubscriptionsL(TRequestStatus& aStatus, CImapSession& aSession); |
|
148 IMPORT_C void SynchroniseSubscribedFoldersL(TRequestStatus& aStatus, CImapSession& aSession, TMsvId& aFolderId); |
|
149 |
|
150 // Folders methods |
|
151 // Default aAddToSubscribedList is set to ETrue to subscribe. |
|
152 // Only in one case EFalse is passed, ie. while creating new remote Imap folder. |
|
153 IMPORT_C CImapFolder* GetFolderL(TMsvId aMsvId, TBool aAddToSubscribedList=ETrue); |
|
154 IMPORT_C CImapFolder* GetTempFolderL(TMsvId aMsvId); |
|
155 IMPORT_C CImapFolder* Inbox(); |
|
156 IMPORT_C void DeleteFolderContentsL(TMsvId aDeleteFolderId); |
|
157 IMPORT_C void RemoveFolderL(TMsvId aMsvId); |
|
158 IMPORT_C void RenameLocalL(TMsvId aFolderId, const TDesC& aNewName); |
|
159 IMPORT_C CImapFolder* GetSubscribedFolder(TInt32 aFolderId, TInt32& aNumSubscribedFolders); |
|
160 |
|
161 void AddSubscribedFolderFromInfoL(CImapListFolderInfo* aFolderInfo, TInt aLogId); |
|
162 void CreateLocalFolderListL(); |
|
163 TMsvId FindAndSetFolderL(const TPtrC& aFullPath, TChar& aHierarchySeperator); |
|
164 RArray<TUint>* GetUnSubscribedFolderToDoList(); |
|
165 RArray<TUint>* GetSubscribedFolderToDoList(); |
|
166 |
|
167 // Getting the progress updates |
|
168 IMPORT_C void Progress(TImap4SyncProgress& aProgress); |
|
169 IMPORT_C void NextSubscribedFoldersL(TMsvId& aFolderId); |
|
170 |
|
171 TBool InboxClearNewFlags(); |
|
172 TBool NonInboxClearNewFlags(); |
|
173 IMPORT_C void ResetInboxClearNewFlags(); |
|
174 IMPORT_C void ResetNonInboxClearNewFlags(); |
|
175 TBool EntryIsInbox(const TMsvEntry& aEntry); |
|
176 |
|
177 IMPORT_C void CancelForMigrate(); |
|
178 |
|
179 private: |
|
180 // construction |
|
181 CImapSyncManager(CMsvServerEntry& aEntry, CImapSettings& aImapSettings); |
|
182 void ConstructL(); |
|
183 |
|
184 // CMsgActive stuff |
|
185 void DoRunL(); |
|
186 void DoCancel(); |
|
187 void DoComplete(TInt& aErr); |
|
188 void CompleteSelf(); |
|
189 |
|
190 // error handling |
|
191 TInt ProcessSessionError(); |
|
192 void ProcessNegativeServerResponse(TInt& errCode); |
|
193 |
|
194 // internal stuff |
|
195 void SetEntryL(const TMsvId aId); |
|
196 void ChangeEntryL(const TMsvEntry& aEntry); |
|
197 void ChangeEntryBulkL(const TMsvEntry& aEntry); |
|
198 void GetChildrenL(CMsvEntrySelection& aSelection); |
|
199 void AddIfNotThereL(TMsvId aFolder); |
|
200 void AddLocalFoldersL(const TMsvId aFolder); |
|
201 void GetInboxL(); |
|
202 CImapFolder* GetFolderFromList(TMsvId aMsvId); |
|
203 |
|
204 private: |
|
205 // Imap server and settings members objects owned by the class creator |
|
206 CMsvServerEntry& iServerEntry; |
|
207 CImapSettings& iImapSettings; |
|
208 CImapSession* iSession; |
|
209 |
|
210 // Sync operations member objects |
|
211 CImapOpSyncFolderTree* iFolderTreeSync; |
|
212 CImapOpSyncSubs* iSyncSubs; |
|
213 CImapFolder* iInbox; |
|
214 TInt iSyncFolderCounter; |
|
215 TBool iSyncDoSingleStep; |
|
216 |
|
217 // Pointer to list of folders |
|
218 RPointerArray<CImapFolder> iFolderList; |
|
219 |
|
220 // List of folders to subscribe or unsubscribe from |
|
221 RArray<TUint>* iSubscribeList; |
|
222 RArray<TUint>* iUnsubscribeList; |
|
223 |
|
224 // Service status settings |
|
225 TMsvId iServiceId; |
|
226 TBool iPerformDeletes; |
|
227 TBool iNewFoldersAreInvisible; |
|
228 TBool iIdleBeforeCommand; |
|
229 TFolderSyncType iSynchroniseStrategy; |
|
230 TFolderSubscribeType iSubscribeStrategy; |
|
231 TRequestStatus* iRequestStatus; |
|
232 TSynchroniseState iSyncState; |
|
233 TSynchroniseState iNextSyncAction; |
|
234 TInt iFoldersToDo; |
|
235 TInt iFoldersDone; |
|
236 TInt iFoldersNotFound; |
|
237 TInt iErrorCode; |
|
238 TImap4SyncProgress::TImap4SyncProgressState iSyncProgressState; |
|
239 |
|
240 TBool iInboxClearNewFlags; |
|
241 TBool iNonInboxClearNewFlags; |
|
242 }; |
|
243 |
|
244 #endif // __IMAPSYNCMANAGER_H__ |