epoc32/include/cacheman.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#if !defined (__CACHEMAN_H__)
williamr@2
    17
#define __CACHEMAN_H__
williamr@2
    18
williamr@2
    19
#include <mentact.h>
williamr@2
    20
#include <msvstd.h>
williamr@2
    21
#include <msvapi.h>
williamr@2
    22
williamr@2
    23
_LIT(KMiutWildCard, "*.*");
williamr@2
    24
williamr@2
    25
class CImFinder : public CMsgActive
williamr@2
    26
/**
williamr@2
    27
@internalComponent
williamr@2
    28
@released
williamr@2
    29
*/
williamr@2
    30
	{
williamr@2
    31
public:
williamr@2
    32
	IMPORT_C void FindFirstL(TMsvId aRootEntry, TRequestStatus &aStatus);
williamr@2
    33
	IMPORT_C ~CImFinder();
williamr@2
    34
	IMPORT_C virtual void FindNextL(TRequestStatus &aStatus);
williamr@2
    35
	void FindFirstL(const CMsvEntrySelection& aInitialSelection, TRequestStatus &aStatus);
williamr@2
    36
williamr@2
    37
	class CImEntryStack : public CBase
williamr@2
    38
		{
williamr@2
    39
	public:
williamr@2
    40
		static CImEntryStack* NewL();
williamr@2
    41
		~CImEntryStack();
williamr@2
    42
		inline void PushL(TMsvId aId);
williamr@2
    43
		inline TMsvId PopL();
williamr@2
    44
		inline TBool Empty() const;
williamr@2
    45
		inline void Reset();
williamr@2
    46
williamr@2
    47
	private:
williamr@2
    48
		void ConstructL();
williamr@2
    49
williamr@2
    50
		CMsvEntrySelection* iFolders;
williamr@2
    51
		};
williamr@2
    52
williamr@2
    53
protected:
williamr@2
    54
	void ConstructL();
williamr@2
    55
	CImFinder(CMsvEntry& aEntry);
williamr@2
    56
williamr@2
    57
private:
williamr@2
    58
	void DoRunL();
williamr@2
    59
williamr@2
    60
	virtual void AddChildEntriesL() = 0;
williamr@2
    61
	virtual TBool IsRequiredEntryType(TUid aEntryType) const = 0;
williamr@2
    62
williamr@2
    63
protected:
williamr@2
    64
	CImEntryStack* iEntryStack;
williamr@2
    65
	CMsvEntry& iCurrentEntry;
williamr@2
    66
williamr@2
    67
private:
williamr@2
    68
	enum TImmfState
williamr@2
    69
		{
williamr@2
    70
		EImmfEntryFound,
williamr@2
    71
		EImmfFindingEntry,
williamr@2
    72
		EImmfNothingFound
williamr@2
    73
		};
williamr@2
    74
williamr@2
    75
	TImmfState iState;
williamr@2
    76
	};
williamr@2
    77
williamr@2
    78
williamr@2
    79
class CImMessageFinder : public CImFinder
williamr@2
    80
/**
williamr@2
    81
@internalComponent
williamr@2
    82
@released
williamr@2
    83
*/
williamr@2
    84
	{
williamr@2
    85
public:
williamr@2
    86
	IMPORT_C static CImMessageFinder* NewL(CMsvEntry& aEntry);
williamr@2
    87
	IMPORT_C static CImMessageFinder* NewLC(CMsvEntry& aEntry);
williamr@2
    88
	
williamr@2
    89
protected:
williamr@2
    90
	virtual void AddChildEntriesL();
williamr@2
    91
	virtual TBool IsRequiredEntryType(TUid aEntryType) const;
williamr@2
    92
williamr@2
    93
	CImMessageFinder(CMsvEntry& aEntry);
williamr@2
    94
	};
williamr@2
    95
williamr@2
    96
williamr@2
    97
class CImEntryFinder : public CImFinder
williamr@2
    98
/**
williamr@2
    99
@internalComponent
williamr@2
   100
@released
williamr@2
   101
*/
williamr@2
   102
	{
williamr@2
   103
public:
williamr@2
   104
	IMPORT_C static CImEntryFinder* NewL(CMsvEntry& aEntry);
williamr@2
   105
	IMPORT_C static CImEntryFinder* NewLC(CMsvEntry& aEntry);
williamr@2
   106
	
williamr@2
   107
protected:
williamr@2
   108
	virtual void AddChildEntriesL();
williamr@2
   109
	virtual TBool IsRequiredEntryType(TUid aEntryType) const;
williamr@2
   110
williamr@2
   111
	CImEntryFinder(CMsvEntry& aEntry);
williamr@2
   112
	};
williamr@2
   113
williamr@2
   114
williamr@2
   115
class CImMessageCounter : public CImFinder
williamr@2
   116
/**
williamr@2
   117
@internalComponent
williamr@2
   118
@released
williamr@2
   119
*/
williamr@2
   120
	{
williamr@2
   121
public:
williamr@2
   122
	IMPORT_C static CImMessageCounter* NewL(CMsvEntry& aEntry);
williamr@2
   123
	IMPORT_C static CImMessageCounter* NewLC(CMsvEntry& aEntry);
williamr@2
   124
	IMPORT_C TInt Count();
williamr@2
   125
	
williamr@2
   126
protected:
williamr@2
   127
	virtual void AddChildEntriesL();
williamr@2
   128
	virtual TBool IsRequiredEntryType(TUid aEntryType) const;
williamr@2
   129
williamr@2
   130
	CImMessageCounter(CMsvEntry& aEntry);
williamr@2
   131
williamr@2
   132
private:
williamr@2
   133
	TInt iCount;
williamr@2
   134
	};
williamr@2
   135
williamr@2
   136
williamr@2
   137
class CImPruneMessage : public CMsgActive
williamr@2
   138
/** Deletes the body text and attachment data from an individually specified message. 
williamr@2
   139
williamr@2
   140
Example uses of this class are:
williamr@2
   141
williamr@2
   142
1. to cleanup after a populating operation has failed
williamr@2
   143
williamr@2
   144
2. to remove body text and attachment data from remote messages, while preserving 
williamr@2
   145
the message structure 
williamr@2
   146
@publishedPartner 
williamr@2
   147
@released
williamr@2
   148
*/
williamr@2
   149
	{
williamr@2
   150
public:
williamr@2
   151
	IMPORT_C static CImPruneMessage* NewL(CMsvEntry& aEntry, RFs& aFs);
williamr@2
   152
	IMPORT_C static CImPruneMessage* NewLC(CMsvEntry& aEntry, RFs& aFs);
williamr@2
   153
williamr@2
   154
	IMPORT_C void StartL(TMsvId aMessageEntry, TRequestStatus &aStatus);
williamr@2
   155
	~CImPruneMessage();
williamr@2
   156
	
williamr@2
   157
private:
williamr@2
   158
	CImPruneMessage(CMsvEntry& aEntry, RFs& aFs);
williamr@2
   159
	void ConstructL();
williamr@2
   160
	void DoRunL();
williamr@2
   161
	void DoComplete(TInt& );
williamr@2
   162
	void DoCancel();
williamr@2
   163
	void PruneEntryL();
williamr@2
   164
	void ResetStoreL();
williamr@2
   165
williamr@2
   166
private:
williamr@2
   167
	enum TImPruningState
williamr@2
   168
		{
williamr@2
   169
		EImPruneUpdatingEntry,
williamr@2
   170
		EImPruneUpdatingFirstEntry,
williamr@2
   171
		EImPruneFindingEntry,
williamr@2
   172
		EImPruneFindFirstEntry,
williamr@2
   173
		EImPruneFindNextEntry
williamr@2
   174
		};
williamr@2
   175
williamr@2
   176
	TImPruningState iState;
williamr@2
   177
williamr@2
   178
	CMsvEntry& iCurrentEntry;
williamr@2
   179
	RFs& iFs;
williamr@2
   180
	CImEntryFinder* iEntryFinder;
williamr@2
   181
	CFileMan* iFileManager;
williamr@2
   182
	TMsvId iRootEntryId;
williamr@2
   183
	CMsvOperation* iChangeOperation;
williamr@2
   184
	CMsvStore* iStore;
williamr@2
   185
	};
williamr@2
   186
williamr@2
   187
struct TImCacheManagerProgress
williamr@2
   188
/** Holds progress of a cache management cleanup operation.
williamr@2
   189
williamr@2
   190
@see CImCacheManager::ProgressL() 
williamr@2
   191
@publishedAll
williamr@2
   192
@released
williamr@2
   193
*/
williamr@2
   194
	{
williamr@2
   195
public:
williamr@2
   196
	/** Total number of messages to process.
williamr@2
   197
	
williamr@2
   198
	Note that, immediately after a CImCacheManager object is started, the progress 
williamr@2
   199
	operation may return 1 for iTotalMessages and 0 for iMessagesProcessed, regardless 
williamr@2
   200
	of the total number of messages. This is because the counter for the iTotalMessages 
williamr@2
   201
	operates asynchronously and may not have counted all of the messages at that 
williamr@2
   202
	time. */
williamr@2
   203
	TInt iTotalMessages;
williamr@2
   204
	/** Number of messages processed so far. */
williamr@2
   205
	TInt iMessagesProcessed;
williamr@2
   206
	};
williamr@2
   207
williamr@2
   208
class CImCacheManager : public CMsvOperation
williamr@2
   209
/** Provides management of the local cache of messages in remote mailboxes.
williamr@2
   210
williamr@2
   211
A mailbox that is being used in disconnected mode allows the user access to 
williamr@2
   212
message data by opening the message directly from the remote mailbox. If the 
williamr@2
   213
required message has been downloaded previously, then it will not necessarily 
williamr@2
   214
need to be downloaded again. This functionality is achieved by preserving 
williamr@2
   215
the message data locally, under the remote service entry. The preserved message 
williamr@2
   216
data acts as a cache to allow the user access to the message without the need 
williamr@2
   217
for it to be downloaded every time. 
williamr@2
   218
williamr@2
   219
The cache management functionality is required to reduce the amount of memory 
williamr@2
   220
that is consumed by the message cache. CImCacheManager provides a mechanism 
williamr@2
   221
for asynchronously traversing a message tree and for removing text and attachment 
williamr@2
   222
data from messages. Deleting more message data will free up more memory but 
williamr@2
   223
there is a higher chance that a user will need to download a message for a 
williamr@2
   224
second time. 
williamr@2
   225
williamr@2
   226
CImCacheManager is an abstract base class, which can be specialised to implement 
williamr@2
   227
a filter (Filter()) that decides if data for a message shoulded be deleted: 
williamr@2
   228
for example, deletion could be restricted to 'all read messages over a week 
williamr@2
   229
old,' or, 'all read messages, over 20K in size which are also over a day old.' 
williamr@2
   230
@publishedAll
williamr@2
   231
@released
williamr@2
   232
*/
williamr@2
   233
	{
williamr@2
   234
public:
williamr@2
   235
	IMPORT_C void StartL(TMsvId aRootEntry, TRequestStatus &aStatus);
williamr@2
   236
	IMPORT_C void StartL(const CMsvEntrySelection& aSelection, TRequestStatus &aStatus);
williamr@2
   237
	IMPORT_C ~CImCacheManager();
williamr@2
   238
	IMPORT_C const TDesC8& ProgressL();
williamr@2
   239
	IMPORT_C void DoCancel();
williamr@2
   240
williamr@2
   241
protected:
williamr@2
   242
	IMPORT_C void ConstructL();
williamr@2
   243
	IMPORT_C CImCacheManager(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus);
williamr@2
   244
williamr@2
   245
	IMPORT_C void RunL();
williamr@2
   246
williamr@2
   247
private:
williamr@2
   248
	// Override this function to filter the currently selected message (iCurrentEntry).
williamr@2
   249
	// Return TRUE if the current entry is to be pruned.
williamr@2
   250
	/** Tests if cache cleanup should be performed on a message entry.
williamr@2
   251
	
williamr@2
   252
	After StartL() has been called, this is called once for each message entry. 
williamr@2
   253
	It should return true if the body text and attachment data belonging to the 
williamr@2
   254
	current message, as held in iCurrentEntry, should be deleted, or false if 
williamr@2
   255
	the message should be left unchanged.
williamr@2
   256
	
williamr@2
   257
	This function must be implemented in any classes derived from CImCacheManager.
williamr@2
   258
	
williamr@2
   259
	@return True to clean the entry, false to leave it unchanged */
williamr@2
   260
	virtual TBool Filter() const = 0;
williamr@2
   261
williamr@2
   262
	void DoRunL();
williamr@2
   263
williamr@2
   264
	// Remove the store from the currently selected entry
williamr@2
   265
	inline void PruneMessageL();
williamr@2
   266
	
williamr@2
   267
protected:
williamr@2
   268
	/** Message entry currently being processed. */
williamr@2
   269
	CMsvEntry* iCurrentEntry;
williamr@2
   270
williamr@2
   271
private:
williamr@2
   272
	CMsvSession& iSession;
williamr@2
   273
	CImMessageFinder* iMessageFinder;
williamr@2
   274
	CImMessageCounter* iMessageCounter;
williamr@2
   275
	CMsvOperation* iDeleteOperation;
williamr@2
   276
williamr@2
   277
	TImCacheManagerProgress iProgress;
williamr@2
   278
	TRequestStatus* iReport;
williamr@2
   279
williamr@2
   280
	enum TImcmState
williamr@2
   281
		{
williamr@2
   282
		EImcmLookingForMessage,
williamr@2
   283
		EImcmPruningMessages,
williamr@2
   284
		EImcmCountingMessages,
williamr@2
   285
		EImcmSkippingPrune
williamr@2
   286
		};
williamr@2
   287
williamr@2
   288
	TMsvId iRootEntry;
williamr@2
   289
	TImcmState iState;
williamr@2
   290
	TPckgBuf<TImCacheManagerProgress> iProgressBuf;
williamr@2
   291
williamr@2
   292
	CMsvEntrySelection* iMessagesToPrune;
williamr@2
   293
	};
williamr@2
   294
williamr@2
   295
#endif