Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 // Copyright (c) 1999-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined (__CACHEMAN_H__)
17 #define __CACHEMAN_H__
23 _LIT(KMiutWildCard, "*.*");
25 class CImFinder : public CMsgActive
32 IMPORT_C void FindFirstL(TMsvId aRootEntry, TRequestStatus &aStatus);
33 IMPORT_C ~CImFinder();
34 IMPORT_C virtual void FindNextL(TRequestStatus &aStatus);
35 void FindFirstL(const CMsvEntrySelection& aInitialSelection, TRequestStatus &aStatus);
37 class CImEntryStack : public CBase
40 static CImEntryStack* NewL();
42 inline void PushL(TMsvId aId);
44 inline TBool Empty() const;
50 CMsvEntrySelection* iFolders;
55 CImFinder(CMsvEntry& aEntry);
60 virtual void AddChildEntriesL() = 0;
61 virtual TBool IsRequiredEntryType(TUid aEntryType) const = 0;
64 CImEntryStack* iEntryStack;
65 CMsvEntry& iCurrentEntry;
79 class CImMessageFinder : public CImFinder
86 IMPORT_C static CImMessageFinder* NewL(CMsvEntry& aEntry);
87 IMPORT_C static CImMessageFinder* NewLC(CMsvEntry& aEntry);
90 virtual void AddChildEntriesL();
91 virtual TBool IsRequiredEntryType(TUid aEntryType) const;
93 CImMessageFinder(CMsvEntry& aEntry);
97 class CImEntryFinder : public CImFinder
104 IMPORT_C static CImEntryFinder* NewL(CMsvEntry& aEntry);
105 IMPORT_C static CImEntryFinder* NewLC(CMsvEntry& aEntry);
108 virtual void AddChildEntriesL();
109 virtual TBool IsRequiredEntryType(TUid aEntryType) const;
111 CImEntryFinder(CMsvEntry& aEntry);
115 class CImMessageCounter : public CImFinder
122 IMPORT_C static CImMessageCounter* NewL(CMsvEntry& aEntry);
123 IMPORT_C static CImMessageCounter* NewLC(CMsvEntry& aEntry);
124 IMPORT_C TInt Count();
127 virtual void AddChildEntriesL();
128 virtual TBool IsRequiredEntryType(TUid aEntryType) const;
130 CImMessageCounter(CMsvEntry& aEntry);
137 class CImPruneMessage : public CMsgActive
138 /** Deletes the body text and attachment data from an individually specified message.
140 Example uses of this class are:
142 1. to cleanup after a populating operation has failed
144 2. to remove body text and attachment data from remote messages, while preserving
145 the message structure
151 IMPORT_C static CImPruneMessage* NewL(CMsvEntry& aEntry, RFs& aFs);
152 IMPORT_C static CImPruneMessage* NewLC(CMsvEntry& aEntry, RFs& aFs);
154 IMPORT_C void StartL(TMsvId aMessageEntry, TRequestStatus &aStatus);
158 CImPruneMessage(CMsvEntry& aEntry, RFs& aFs);
161 void DoComplete(TInt& );
169 EImPruneUpdatingEntry,
170 EImPruneUpdatingFirstEntry,
171 EImPruneFindingEntry,
172 EImPruneFindFirstEntry,
173 EImPruneFindNextEntry
176 TImPruningState iState;
178 CMsvEntry& iCurrentEntry;
180 CImEntryFinder* iEntryFinder;
181 CFileMan* iFileManager;
183 CMsvOperation* iChangeOperation;
187 struct TImCacheManagerProgress
188 /** Holds progress of a cache management cleanup operation.
190 @see CImCacheManager::ProgressL()
196 /** Total number of messages to process.
198 Note that, immediately after a CImCacheManager object is started, the progress
199 operation may return 1 for iTotalMessages and 0 for iMessagesProcessed, regardless
200 of the total number of messages. This is because the counter for the iTotalMessages
201 operates asynchronously and may not have counted all of the messages at that
204 /** Number of messages processed so far. */
205 TInt iMessagesProcessed;
208 class CImCacheManager : public CMsvOperation
209 /** Provides management of the local cache of messages in remote mailboxes.
211 A mailbox that is being used in disconnected mode allows the user access to
212 message data by opening the message directly from the remote mailbox. If the
213 required message has been downloaded previously, then it will not necessarily
214 need to be downloaded again. This functionality is achieved by preserving
215 the message data locally, under the remote service entry. The preserved message
216 data acts as a cache to allow the user access to the message without the need
217 for it to be downloaded every time.
219 The cache management functionality is required to reduce the amount of memory
220 that is consumed by the message cache. CImCacheManager provides a mechanism
221 for asynchronously traversing a message tree and for removing text and attachment
222 data from messages. Deleting more message data will free up more memory but
223 there is a higher chance that a user will need to download a message for a
226 CImCacheManager is an abstract base class, which can be specialised to implement
227 a filter (Filter()) that decides if data for a message shoulded be deleted:
228 for example, deletion could be restricted to 'all read messages over a week
229 old,' or, 'all read messages, over 20K in size which are also over a day old.'
235 IMPORT_C void StartL(TMsvId aRootEntry, TRequestStatus &aStatus);
236 IMPORT_C void StartL(const CMsvEntrySelection& aSelection, TRequestStatus &aStatus);
237 IMPORT_C ~CImCacheManager();
238 IMPORT_C const TDesC8& ProgressL();
239 IMPORT_C void DoCancel();
242 IMPORT_C void ConstructL();
243 IMPORT_C CImCacheManager(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus);
245 IMPORT_C void RunL();
248 // Override this function to filter the currently selected message (iCurrentEntry).
249 // Return TRUE if the current entry is to be pruned.
250 /** Tests if cache cleanup should be performed on a message entry.
252 After StartL() has been called, this is called once for each message entry.
253 It should return true if the body text and attachment data belonging to the
254 current message, as held in iCurrentEntry, should be deleted, or false if
255 the message should be left unchanged.
257 This function must be implemented in any classes derived from CImCacheManager.
259 @return True to clean the entry, false to leave it unchanged */
260 virtual TBool Filter() const = 0;
264 // Remove the store from the currently selected entry
265 inline void PruneMessageL();
268 /** Message entry currently being processed. */
269 CMsvEntry* iCurrentEntry;
272 CMsvSession& iSession;
273 CImMessageFinder* iMessageFinder;
274 CImMessageCounter* iMessageCounter;
275 CMsvOperation* iDeleteOperation;
277 TImCacheManagerProgress iProgress;
278 TRequestStatus* iReport;
282 EImcmLookingForMessage,
283 EImcmPruningMessages,
284 EImcmCountingMessages,
290 TPckgBuf<TImCacheManagerProgress> iProgressBuf;
292 CMsvEntrySelection* iMessagesToPrune;