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 "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #if !defined (__CACHEMAN_H__)
22 #define __CACHEMAN_H__
27 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
28 #include <cimprunemessage.h>
29 #include "cimfinder.h"
32 class CImMessageFinder;
33 class CImMessageCounter;
35 struct TImCacheManagerProgress
36 /** Holds progress of a cache management cleanup operation.
38 @see CImCacheManager::ProgressL()
44 /** Total number of messages to process.
46 Note that, immediately after a CImCacheManager object is started, the progress
47 operation may return 1 for iTotalMessages and 0 for iMessagesProcessed, regardless
48 of the total number of messages. This is because the counter for the iTotalMessages
49 operates asynchronously and may not have counted all of the messages at that
52 /** Number of messages processed so far. */
53 TInt iMessagesProcessed;
56 class CImCacheManager : public CMsvOperation
57 /** Provides management of the local cache of messages in remote mailboxes.
59 A mailbox that is being used in disconnected mode allows the user access to
60 message data by opening the message directly from the remote mailbox. If the
61 required message has been downloaded previously, then it will not necessarily
62 need to be downloaded again. This functionality is achieved by preserving
63 the message data locally, under the remote service entry. The preserved message
64 data acts as a cache to allow the user access to the message without the need
65 for it to be downloaded every time.
67 The cache management functionality is required to reduce the amount of memory
68 that is consumed by the message cache. CImCacheManager provides a mechanism
69 for asynchronously traversing a message tree and for removing text and attachment
70 data from messages. Deleting more message data will free up more memory but
71 there is a higher chance that a user will need to download a message for a
74 CImCacheManager is an abstract base class, which can be specialised to implement
75 a filter (Filter()) that decides if data for a message shoulded be deleted:
76 for example, deletion could be restricted to 'all read messages over a week
77 old,' or, 'all read messages, over 20K in size which are also over a day old.'
83 IMPORT_C void StartL(TMsvId aRootEntry, TRequestStatus &aStatus);
84 IMPORT_C void StartL(const CMsvEntrySelection& aSelection, TRequestStatus &aStatus);
85 IMPORT_C ~CImCacheManager();
86 IMPORT_C const TDesC8& ProgressL();
87 IMPORT_C void DoCancel();
90 IMPORT_C void ConstructL();
91 IMPORT_C CImCacheManager(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus);
96 // Override this function to filter the currently selected message (iCurrentEntry).
97 // Return TRUE if the current entry is to be pruned.
98 /** Tests if cache cleanup should be performed on a message entry.
100 After StartL() has been called, this is called once for each message entry.
101 It should return true if the body text and attachment data belonging to the
102 current message, as held in iCurrentEntry, should be deleted, or false if
103 the message should be left unchanged.
105 This function must be implemented in any classes derived from CImCacheManager.
107 @return True to clean the entry, false to leave it unchanged */
108 virtual TBool Filter() const = 0;
112 // Remove the store from the currently selected entry
113 inline void PruneMessageL();
116 /** Message entry currently being processed. */
117 CMsvEntry* iCurrentEntry;
120 CMsvSession& iSession;
121 CImMessageFinder* iMessageFinder;
122 CImMessageCounter* iMessageCounter;
123 CMsvOperation* iDeleteOperation;
125 TImCacheManagerProgress iProgress;
126 TRequestStatus* iReport;
130 EImcmLookingForMessage,
131 EImcmPruningMessages,
132 EImcmCountingMessages,
138 TPckgBuf<TImCacheManagerProgress> iProgressBuf;
140 CMsvEntrySelection* iMessagesToPrune;