1.1 --- a/epoc32/include/cacheman.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/cacheman.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,295 @@
1.4 -cacheman.h
1.5 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#if !defined (__CACHEMAN_H__)
1.21 +#define __CACHEMAN_H__
1.22 +
1.23 +#include <mentact.h>
1.24 +#include <msvstd.h>
1.25 +#include <msvapi.h>
1.26 +
1.27 +_LIT(KMiutWildCard, "*.*");
1.28 +
1.29 +class CImFinder : public CMsgActive
1.30 +/**
1.31 +@internalComponent
1.32 +@released
1.33 +*/
1.34 + {
1.35 +public:
1.36 + IMPORT_C void FindFirstL(TMsvId aRootEntry, TRequestStatus &aStatus);
1.37 + IMPORT_C ~CImFinder();
1.38 + IMPORT_C virtual void FindNextL(TRequestStatus &aStatus);
1.39 + void FindFirstL(const CMsvEntrySelection& aInitialSelection, TRequestStatus &aStatus);
1.40 +
1.41 + class CImEntryStack : public CBase
1.42 + {
1.43 + public:
1.44 + static CImEntryStack* NewL();
1.45 + ~CImEntryStack();
1.46 + inline void PushL(TMsvId aId);
1.47 + inline TMsvId PopL();
1.48 + inline TBool Empty() const;
1.49 + inline void Reset();
1.50 +
1.51 + private:
1.52 + void ConstructL();
1.53 +
1.54 + CMsvEntrySelection* iFolders;
1.55 + };
1.56 +
1.57 +protected:
1.58 + void ConstructL();
1.59 + CImFinder(CMsvEntry& aEntry);
1.60 +
1.61 +private:
1.62 + void DoRunL();
1.63 +
1.64 + virtual void AddChildEntriesL() = 0;
1.65 + virtual TBool IsRequiredEntryType(TUid aEntryType) const = 0;
1.66 +
1.67 +protected:
1.68 + CImEntryStack* iEntryStack;
1.69 + CMsvEntry& iCurrentEntry;
1.70 +
1.71 +private:
1.72 + enum TImmfState
1.73 + {
1.74 + EImmfEntryFound,
1.75 + EImmfFindingEntry,
1.76 + EImmfNothingFound
1.77 + };
1.78 +
1.79 + TImmfState iState;
1.80 + };
1.81 +
1.82 +
1.83 +class CImMessageFinder : public CImFinder
1.84 +/**
1.85 +@internalComponent
1.86 +@released
1.87 +*/
1.88 + {
1.89 +public:
1.90 + IMPORT_C static CImMessageFinder* NewL(CMsvEntry& aEntry);
1.91 + IMPORT_C static CImMessageFinder* NewLC(CMsvEntry& aEntry);
1.92 +
1.93 +protected:
1.94 + virtual void AddChildEntriesL();
1.95 + virtual TBool IsRequiredEntryType(TUid aEntryType) const;
1.96 +
1.97 + CImMessageFinder(CMsvEntry& aEntry);
1.98 + };
1.99 +
1.100 +
1.101 +class CImEntryFinder : public CImFinder
1.102 +/**
1.103 +@internalComponent
1.104 +@released
1.105 +*/
1.106 + {
1.107 +public:
1.108 + IMPORT_C static CImEntryFinder* NewL(CMsvEntry& aEntry);
1.109 + IMPORT_C static CImEntryFinder* NewLC(CMsvEntry& aEntry);
1.110 +
1.111 +protected:
1.112 + virtual void AddChildEntriesL();
1.113 + virtual TBool IsRequiredEntryType(TUid aEntryType) const;
1.114 +
1.115 + CImEntryFinder(CMsvEntry& aEntry);
1.116 + };
1.117 +
1.118 +
1.119 +class CImMessageCounter : public CImFinder
1.120 +/**
1.121 +@internalComponent
1.122 +@released
1.123 +*/
1.124 + {
1.125 +public:
1.126 + IMPORT_C static CImMessageCounter* NewL(CMsvEntry& aEntry);
1.127 + IMPORT_C static CImMessageCounter* NewLC(CMsvEntry& aEntry);
1.128 + IMPORT_C TInt Count();
1.129 +
1.130 +protected:
1.131 + virtual void AddChildEntriesL();
1.132 + virtual TBool IsRequiredEntryType(TUid aEntryType) const;
1.133 +
1.134 + CImMessageCounter(CMsvEntry& aEntry);
1.135 +
1.136 +private:
1.137 + TInt iCount;
1.138 + };
1.139 +
1.140 +
1.141 +class CImPruneMessage : public CMsgActive
1.142 +/** Deletes the body text and attachment data from an individually specified message.
1.143 +
1.144 +Example uses of this class are:
1.145 +
1.146 +1. to cleanup after a populating operation has failed
1.147 +
1.148 +2. to remove body text and attachment data from remote messages, while preserving
1.149 +the message structure
1.150 +@publishedPartner
1.151 +@released
1.152 +*/
1.153 + {
1.154 +public:
1.155 + IMPORT_C static CImPruneMessage* NewL(CMsvEntry& aEntry, RFs& aFs);
1.156 + IMPORT_C static CImPruneMessage* NewLC(CMsvEntry& aEntry, RFs& aFs);
1.157 +
1.158 + IMPORT_C void StartL(TMsvId aMessageEntry, TRequestStatus &aStatus);
1.159 + ~CImPruneMessage();
1.160 +
1.161 +private:
1.162 + CImPruneMessage(CMsvEntry& aEntry, RFs& aFs);
1.163 + void ConstructL();
1.164 + void DoRunL();
1.165 + void DoComplete(TInt& );
1.166 + void DoCancel();
1.167 + void PruneEntryL();
1.168 + void ResetStoreL();
1.169 +
1.170 +private:
1.171 + enum TImPruningState
1.172 + {
1.173 + EImPruneUpdatingEntry,
1.174 + EImPruneUpdatingFirstEntry,
1.175 + EImPruneFindingEntry,
1.176 + EImPruneFindFirstEntry,
1.177 + EImPruneFindNextEntry
1.178 + };
1.179 +
1.180 + TImPruningState iState;
1.181 +
1.182 + CMsvEntry& iCurrentEntry;
1.183 + RFs& iFs;
1.184 + CImEntryFinder* iEntryFinder;
1.185 + CFileMan* iFileManager;
1.186 + TMsvId iRootEntryId;
1.187 + CMsvOperation* iChangeOperation;
1.188 + CMsvStore* iStore;
1.189 + };
1.190 +
1.191 +struct TImCacheManagerProgress
1.192 +/** Holds progress of a cache management cleanup operation.
1.193 +
1.194 +@see CImCacheManager::ProgressL()
1.195 +@publishedAll
1.196 +@released
1.197 +*/
1.198 + {
1.199 +public:
1.200 + /** Total number of messages to process.
1.201 +
1.202 + Note that, immediately after a CImCacheManager object is started, the progress
1.203 + operation may return 1 for iTotalMessages and 0 for iMessagesProcessed, regardless
1.204 + of the total number of messages. This is because the counter for the iTotalMessages
1.205 + operates asynchronously and may not have counted all of the messages at that
1.206 + time. */
1.207 + TInt iTotalMessages;
1.208 + /** Number of messages processed so far. */
1.209 + TInt iMessagesProcessed;
1.210 + };
1.211 +
1.212 +class CImCacheManager : public CMsvOperation
1.213 +/** Provides management of the local cache of messages in remote mailboxes.
1.214 +
1.215 +A mailbox that is being used in disconnected mode allows the user access to
1.216 +message data by opening the message directly from the remote mailbox. If the
1.217 +required message has been downloaded previously, then it will not necessarily
1.218 +need to be downloaded again. This functionality is achieved by preserving
1.219 +the message data locally, under the remote service entry. The preserved message
1.220 +data acts as a cache to allow the user access to the message without the need
1.221 +for it to be downloaded every time.
1.222 +
1.223 +The cache management functionality is required to reduce the amount of memory
1.224 +that is consumed by the message cache. CImCacheManager provides a mechanism
1.225 +for asynchronously traversing a message tree and for removing text and attachment
1.226 +data from messages. Deleting more message data will free up more memory but
1.227 +there is a higher chance that a user will need to download a message for a
1.228 +second time.
1.229 +
1.230 +CImCacheManager is an abstract base class, which can be specialised to implement
1.231 +a filter (Filter()) that decides if data for a message shoulded be deleted:
1.232 +for example, deletion could be restricted to 'all read messages over a week
1.233 +old,' or, 'all read messages, over 20K in size which are also over a day old.'
1.234 +@publishedAll
1.235 +@released
1.236 +*/
1.237 + {
1.238 +public:
1.239 + IMPORT_C void StartL(TMsvId aRootEntry, TRequestStatus &aStatus);
1.240 + IMPORT_C void StartL(const CMsvEntrySelection& aSelection, TRequestStatus &aStatus);
1.241 + IMPORT_C ~CImCacheManager();
1.242 + IMPORT_C const TDesC8& ProgressL();
1.243 + IMPORT_C void DoCancel();
1.244 +
1.245 +protected:
1.246 + IMPORT_C void ConstructL();
1.247 + IMPORT_C CImCacheManager(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus);
1.248 +
1.249 + IMPORT_C void RunL();
1.250 +
1.251 +private:
1.252 + // Override this function to filter the currently selected message (iCurrentEntry).
1.253 + // Return TRUE if the current entry is to be pruned.
1.254 + /** Tests if cache cleanup should be performed on a message entry.
1.255 +
1.256 + After StartL() has been called, this is called once for each message entry.
1.257 + It should return true if the body text and attachment data belonging to the
1.258 + current message, as held in iCurrentEntry, should be deleted, or false if
1.259 + the message should be left unchanged.
1.260 +
1.261 + This function must be implemented in any classes derived from CImCacheManager.
1.262 +
1.263 + @return True to clean the entry, false to leave it unchanged */
1.264 + virtual TBool Filter() const = 0;
1.265 +
1.266 + void DoRunL();
1.267 +
1.268 + // Remove the store from the currently selected entry
1.269 + inline void PruneMessageL();
1.270 +
1.271 +protected:
1.272 + /** Message entry currently being processed. */
1.273 + CMsvEntry* iCurrentEntry;
1.274 +
1.275 +private:
1.276 + CMsvSession& iSession;
1.277 + CImMessageFinder* iMessageFinder;
1.278 + CImMessageCounter* iMessageCounter;
1.279 + CMsvOperation* iDeleteOperation;
1.280 +
1.281 + TImCacheManagerProgress iProgress;
1.282 + TRequestStatus* iReport;
1.283 +
1.284 + enum TImcmState
1.285 + {
1.286 + EImcmLookingForMessage,
1.287 + EImcmPruningMessages,
1.288 + EImcmCountingMessages,
1.289 + EImcmSkippingPrune
1.290 + };
1.291 +
1.292 + TMsvId iRootEntry;
1.293 + TImcmState iState;
1.294 + TPckgBuf<TImCacheManagerProgress> iProgressBuf;
1.295 +
1.296 + CMsvEntrySelection* iMessagesToPrune;
1.297 + };
1.298 +
1.299 +#endif