|
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 // CImapFolder header |
|
15 // |
|
16 // |
|
17 |
|
18 #if !defined(__CIMAPFOLDER_H__) |
|
19 #define __CIMAPFOLDER_H__ |
|
20 |
|
21 #include <f32file.h> |
|
22 #include <mentact.h> |
|
23 #include <msventry.h> |
|
24 #include "cimapsyncmanager.h" // forward declaration is not possible because of embedded enum |
|
25 #include "cimapfetchresponse.h" |
|
26 |
|
27 // Forward declarations |
|
28 class CImapSession; |
|
29 class CImapFolderIndex; |
|
30 class CImapFolderInfo; |
|
31 class CImConvertCharconv; |
|
32 class CCnvCharacterSetConverter; |
|
33 class CImConvertHeader; |
|
34 |
|
35 // Modes updating Seen flag |
|
36 enum TSeenFlagUpdateMode |
|
37 { |
|
38 EClearSeenFlag=0, |
|
39 ESetSeenFlag |
|
40 }; |
|
41 |
|
42 //cached TMsvEntry data |
|
43 class TMsvCacheData |
|
44 /** |
|
45 @internalComponent |
|
46 @prototype |
|
47 */ |
|
48 { |
|
49 public: |
|
50 TBool iOrphan; |
|
51 TUint32 iUid; |
|
52 }; |
|
53 |
|
54 class CImapFolder : public CMsgActive, public MImapFetchStructureObserver |
|
55 /** |
|
56 The IMAP Folder Component shall encapsulate a folder on the IMAP service. |
|
57 Folder objects shall be created for subscribed folders, and will contain information about the remote folder |
|
58 and the local mirror of that folder that allows the IMAP Server MTM to determine if the folders require synchronisation. |
|
59 @internalComponent |
|
60 @prototype |
|
61 */ |
|
62 { |
|
63 public: |
|
64 ~CImapFolder(); |
|
65 // Class contructors |
|
66 IMPORT_C static CImapFolder* NewLC(CImapSyncManager& aSyncMan, CMsvServerEntry& aServerEntry, TMsvEmailEntry& aEmailEntry, CImapSettings& aImapSettings, const TDesC& aFullFolderPath); |
|
67 IMPORT_C static CImapFolder* NewL(CImapSyncManager& aSyncMan, CMsvServerEntry& aServerEntry, TMsvEmailEntry& aEmailEntry, CImapSettings& aImapSettings, const TDesC& aFullFolderPath); |
|
68 IMPORT_C static void DoQuoteL(HBufC16*& aBuffer); |
|
69 |
|
70 // Mirror folder tree of remote server |
|
71 IMPORT_C TBool Changed(CImapSession& aSession); |
|
72 IMPORT_C void SynchroniseL(TRequestStatus& aStatus, CImapSession& aSession, TBool aNewOnly, TInt aDeleteOption); |
|
73 IMPORT_C void SyncDeletesL(TRequestStatus& aStatus, CImapSession& aSession); |
|
74 IMPORT_C void SelectL(TRequestStatus& aStatus, CImapSession& aSession, TBool aSelectInbox = ETrue ); |
|
75 IMPORT_C void ExamineL(TRequestStatus& aStatus, CImapSession& aSession); |
|
76 IMPORT_C void UpdateSessionFolderInfoL(CImapSession& aSession); |
|
77 |
|
78 // Get Mailbox name and Id |
|
79 IMPORT_C TDesC& FullFolderPathL(); |
|
80 IMPORT_C TMsvId MailboxId(); |
|
81 |
|
82 IMPORT_C void DeleteMessageL(const TMsvId aMessage); |
|
83 |
|
84 IMPORT_C void AppendSetSeenL(const TUint32 aMessage); |
|
85 IMPORT_C void AppendClearSeenL(const TUint32 aMessage); |
|
86 |
|
87 void SetFullFolderPathL(const TDesC& aFullFolderPath); |
|
88 void SetParentId(TMsvId aParentId); |
|
89 |
|
90 void OnFetchLD(CImapFetchResponse* aImapFetchResponse); |
|
91 void OnFetchCommit(); |
|
92 |
|
93 IMPORT_C HBufC16* MakePathL(const TBool aIncludeLeaf); |
|
94 |
|
95 // Getting the progress updates |
|
96 IMPORT_C void Progress(TImap4SyncProgress& aProgress); |
|
97 |
|
98 // Returns selection of messages to auto-fetch |
|
99 IMPORT_C TInt GetFetchMessageChildrenL(CMsvEntrySelection& aSelection); |
|
100 |
|
101 void SetFolderMatched(TBool aFolderMatched); |
|
102 TBool FolderMatched(); |
|
103 |
|
104 static TInt CompareByFolderName(const CImapFolder& aFirst, const CImapFolder& aSecond); |
|
105 |
|
106 private: |
|
107 CImapFolder(CImapSyncManager& aSyncMan,CMsvServerEntry& aServerEntry, CImapSettings& aImapSettings); |
|
108 void ConstructL(CMsvServerEntry& aServerEntry, TMsvEmailEntry& aEmailEntry, const TDesC& aFullFolderPath); |
|
109 void DoRunL(); |
|
110 void DoCancel(); |
|
111 void DoComplete(TInt& aStatus); |
|
112 void CompleteSelf(); |
|
113 |
|
114 TBool CheckAndProgressMessageSyncL(); |
|
115 TInt GetSyncThreshold(); |
|
116 void CheckMessagesInRangeL(TInt aSyncThreshold); |
|
117 TBool CreateAndSendUIDSearchStringL(TRequestStatus& aStatus); |
|
118 void CheckForMissingMessagesUidsL(); |
|
119 |
|
120 void SetEntryL(const TMsvId aId); |
|
121 void ChangeEntryL(const TMsvEntry& aEntry); |
|
122 void ChangeEntryBulkL(const TMsvEntry& aEntry); |
|
123 |
|
124 void SynchroniseNewL(); |
|
125 void SynchroniseRangeL(const TUint32 aLowUid, const TUint32 aHighUid); |
|
126 void ClearChangeCounts(); |
|
127 |
|
128 void GetChildrenL(CMsvEntrySelection& aSelection); |
|
129 void GetMessageChildrenL(const TMsvId aFolder, CMsvEntrySelection* aChildren); |
|
130 void SyncCompleteL(); |
|
131 void ResetSubscriptionFlagsL(const TMsvId aFolder); |
|
132 void MakeSortedFolderIndexL(TBool aUseCachedEntryData); |
|
133 TBool ProcessSeenFlagsL(TSeenFlagUpdateMode aUpdateMode); |
|
134 void SetMessageFlagsL(TMsvEmailEntry& aEntry, CImapBodyStructure* aBodyStructure); |
|
135 void GetFlagsForBodyStructurePart(CImapBodyStructure* aBodyStructure, |
|
136 TBool& aHasAttachments, TBool& aHasHtml, |
|
137 TBool& aAfterRelated, TBool& aAfterAlternative, |
|
138 TBool& aHtmlAfterAltRel, TBool& aHasICalendar, |
|
139 TBool& aHasVCalendar, TInt& aSize); |
|
140 void ClearNewFlagsIfRequiredL(); |
|
141 |
|
142 private: |
|
143 // External data objects owned by the object creator |
|
144 CImapSyncManager& iSyncManager; |
|
145 CMsvServerEntry& iServerEntry; |
|
146 CImapSettings& iImapSettings; |
|
147 CImapSession* iSavedSession; |
|
148 |
|
149 // Folder data members |
|
150 TMsvId iMailboxId; |
|
151 TInt iMailboxSize; |
|
152 TInt iMailboxRecent; |
|
153 RBuf iFullFolderPath; |
|
154 |
|
155 // Progress and Sync states |
|
156 CImapSyncManager::TSynchroniseState iSyncState; |
|
157 CImapSyncManager::TSynchroniseState iNextAction; |
|
158 TBool iSyncDoSingleStep; |
|
159 |
|
160 // Synchronisation process objects |
|
161 RArray<TMsvCacheData>* iCachedEntryData; |
|
162 CMsvEntrySelection* iSelection; |
|
163 CImapFolderInfo* iSessionFolderInfo; |
|
164 CImapFolderIndex* iFolderIndex; |
|
165 RArray<TUint> iMatchingMessageIds; |
|
166 RArray<TUint> iDeletedMessageIds; |
|
167 RArray<TUint> iMissingMessageIds; |
|
168 |
|
169 // List of messages to have Seen FLAG set or clear |
|
170 RArray<TUint>* iSetSeenList; |
|
171 RArray<TUint>* iClearSeenList; |
|
172 |
|
173 // Flags and data members to manage the sync process |
|
174 RArrayMessageFlagInfo iMessageFlagInfoArray; |
|
175 TBool iSomeUnread; |
|
176 TInt iHeadersFetched; |
|
177 TInt iOrphanedMessages; |
|
178 TInt iRemoteMessagesDeleteTagged; |
|
179 TInt iMsgsDone; |
|
180 TInt iMsgsToDo; |
|
181 TInt iFolderPosition; |
|
182 TInt iSyncLimit; |
|
183 TInt iHighestUid; |
|
184 TInt iMissingUidLow; |
|
185 TInt iMissingUidHigh; |
|
186 TInt iDeleteOption; |
|
187 TBool iFlagChangedOnly; |
|
188 |
|
189 // Character set conversion |
|
190 CImConvertHeader& iHeaderConverter; |
|
191 |
|
192 // General flag used by operations to indicate that this folder has been |
|
193 // matched against some other list of folders |
|
194 TBool iFolderMatched; |
|
195 }; |
|
196 |
|
197 #endif // __CIMAPFOLDER_H__ |