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@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.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@4
|
14 |
// CACHEMAN.H
|
williamr@2
|
15 |
//
|
williamr@4
|
16 |
/**
|
williamr@4
|
17 |
* @file
|
williamr@4
|
18 |
* @publishedAll
|
williamr@4
|
19 |
* @released
|
williamr@4
|
20 |
*/
|
williamr@2
|
21 |
#if !defined (__CACHEMAN_H__)
|
williamr@2
|
22 |
#define __CACHEMAN_H__
|
williamr@2
|
23 |
|
williamr@2
|
24 |
#include <mentact.h>
|
williamr@2
|
25 |
#include <msvstd.h>
|
williamr@2
|
26 |
#include <msvapi.h>
|
williamr@4
|
27 |
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
|
williamr@4
|
28 |
#include <cimprunemessage.h>
|
williamr@4
|
29 |
#include "cimfinder.h"
|
williamr@4
|
30 |
#endif
|
williamr@2
|
31 |
|
williamr@4
|
32 |
class CImMessageFinder;
|
williamr@4
|
33 |
class CImMessageCounter;
|
williamr@2
|
34 |
|
williamr@2
|
35 |
struct TImCacheManagerProgress
|
williamr@2
|
36 |
/** Holds progress of a cache management cleanup operation.
|
williamr@2
|
37 |
|
williamr@2
|
38 |
@see CImCacheManager::ProgressL()
|
williamr@2
|
39 |
@publishedAll
|
williamr@2
|
40 |
@released
|
williamr@2
|
41 |
*/
|
williamr@2
|
42 |
{
|
williamr@2
|
43 |
public:
|
williamr@2
|
44 |
/** Total number of messages to process.
|
williamr@2
|
45 |
|
williamr@2
|
46 |
Note that, immediately after a CImCacheManager object is started, the progress
|
williamr@2
|
47 |
operation may return 1 for iTotalMessages and 0 for iMessagesProcessed, regardless
|
williamr@2
|
48 |
of the total number of messages. This is because the counter for the iTotalMessages
|
williamr@2
|
49 |
operates asynchronously and may not have counted all of the messages at that
|
williamr@2
|
50 |
time. */
|
williamr@2
|
51 |
TInt iTotalMessages;
|
williamr@2
|
52 |
/** Number of messages processed so far. */
|
williamr@2
|
53 |
TInt iMessagesProcessed;
|
williamr@2
|
54 |
};
|
williamr@2
|
55 |
|
williamr@2
|
56 |
class CImCacheManager : public CMsvOperation
|
williamr@2
|
57 |
/** Provides management of the local cache of messages in remote mailboxes.
|
williamr@2
|
58 |
|
williamr@2
|
59 |
A mailbox that is being used in disconnected mode allows the user access to
|
williamr@2
|
60 |
message data by opening the message directly from the remote mailbox. If the
|
williamr@2
|
61 |
required message has been downloaded previously, then it will not necessarily
|
williamr@2
|
62 |
need to be downloaded again. This functionality is achieved by preserving
|
williamr@2
|
63 |
the message data locally, under the remote service entry. The preserved message
|
williamr@2
|
64 |
data acts as a cache to allow the user access to the message without the need
|
williamr@2
|
65 |
for it to be downloaded every time.
|
williamr@2
|
66 |
|
williamr@2
|
67 |
The cache management functionality is required to reduce the amount of memory
|
williamr@2
|
68 |
that is consumed by the message cache. CImCacheManager provides a mechanism
|
williamr@2
|
69 |
for asynchronously traversing a message tree and for removing text and attachment
|
williamr@2
|
70 |
data from messages. Deleting more message data will free up more memory but
|
williamr@2
|
71 |
there is a higher chance that a user will need to download a message for a
|
williamr@2
|
72 |
second time.
|
williamr@2
|
73 |
|
williamr@2
|
74 |
CImCacheManager is an abstract base class, which can be specialised to implement
|
williamr@2
|
75 |
a filter (Filter()) that decides if data for a message shoulded be deleted:
|
williamr@2
|
76 |
for example, deletion could be restricted to 'all read messages over a week
|
williamr@2
|
77 |
old,' or, 'all read messages, over 20K in size which are also over a day old.'
|
williamr@2
|
78 |
@publishedAll
|
williamr@2
|
79 |
@released
|
williamr@2
|
80 |
*/
|
williamr@2
|
81 |
{
|
williamr@2
|
82 |
public:
|
williamr@2
|
83 |
IMPORT_C void StartL(TMsvId aRootEntry, TRequestStatus &aStatus);
|
williamr@2
|
84 |
IMPORT_C void StartL(const CMsvEntrySelection& aSelection, TRequestStatus &aStatus);
|
williamr@2
|
85 |
IMPORT_C ~CImCacheManager();
|
williamr@2
|
86 |
IMPORT_C const TDesC8& ProgressL();
|
williamr@2
|
87 |
IMPORT_C void DoCancel();
|
williamr@2
|
88 |
|
williamr@2
|
89 |
protected:
|
williamr@2
|
90 |
IMPORT_C void ConstructL();
|
williamr@2
|
91 |
IMPORT_C CImCacheManager(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus);
|
williamr@2
|
92 |
|
williamr@2
|
93 |
IMPORT_C void RunL();
|
williamr@2
|
94 |
|
williamr@2
|
95 |
private:
|
williamr@2
|
96 |
// Override this function to filter the currently selected message (iCurrentEntry).
|
williamr@2
|
97 |
// Return TRUE if the current entry is to be pruned.
|
williamr@2
|
98 |
/** Tests if cache cleanup should be performed on a message entry.
|
williamr@2
|
99 |
|
williamr@2
|
100 |
After StartL() has been called, this is called once for each message entry.
|
williamr@2
|
101 |
It should return true if the body text and attachment data belonging to the
|
williamr@2
|
102 |
current message, as held in iCurrentEntry, should be deleted, or false if
|
williamr@2
|
103 |
the message should be left unchanged.
|
williamr@2
|
104 |
|
williamr@2
|
105 |
This function must be implemented in any classes derived from CImCacheManager.
|
williamr@2
|
106 |
|
williamr@2
|
107 |
@return True to clean the entry, false to leave it unchanged */
|
williamr@2
|
108 |
virtual TBool Filter() const = 0;
|
williamr@2
|
109 |
|
williamr@2
|
110 |
void DoRunL();
|
williamr@2
|
111 |
|
williamr@2
|
112 |
// Remove the store from the currently selected entry
|
williamr@2
|
113 |
inline void PruneMessageL();
|
williamr@2
|
114 |
|
williamr@2
|
115 |
protected:
|
williamr@2
|
116 |
/** Message entry currently being processed. */
|
williamr@2
|
117 |
CMsvEntry* iCurrentEntry;
|
williamr@2
|
118 |
|
williamr@2
|
119 |
private:
|
williamr@2
|
120 |
CMsvSession& iSession;
|
williamr@2
|
121 |
CImMessageFinder* iMessageFinder;
|
williamr@2
|
122 |
CImMessageCounter* iMessageCounter;
|
williamr@2
|
123 |
CMsvOperation* iDeleteOperation;
|
williamr@2
|
124 |
|
williamr@2
|
125 |
TImCacheManagerProgress iProgress;
|
williamr@2
|
126 |
TRequestStatus* iReport;
|
williamr@2
|
127 |
|
williamr@2
|
128 |
enum TImcmState
|
williamr@2
|
129 |
{
|
williamr@2
|
130 |
EImcmLookingForMessage,
|
williamr@2
|
131 |
EImcmPruningMessages,
|
williamr@2
|
132 |
EImcmCountingMessages,
|
williamr@2
|
133 |
EImcmSkippingPrune
|
williamr@2
|
134 |
};
|
williamr@2
|
135 |
|
williamr@2
|
136 |
TMsvId iRootEntry;
|
williamr@2
|
137 |
TImcmState iState;
|
williamr@2
|
138 |
TPckgBuf<TImCacheManagerProgress> iProgressBuf;
|
williamr@2
|
139 |
|
williamr@2
|
140 |
CMsvEntrySelection* iMessagesToPrune;
|
williamr@2
|
141 |
};
|
williamr@2
|
142 |
|
williamr@2
|
143 |
#endif
|