|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // CACHEMAN.H |
|
15 // |
|
16 /** |
|
17 * @file |
|
18 * @publishedAll |
|
19 * @released |
|
20 */ |
|
21 #if !defined (__CACHEMAN_H__) |
|
22 #define __CACHEMAN_H__ |
|
23 |
|
24 #include <mentact.h> |
|
25 #include <msvstd.h> |
|
26 #include <msvapi.h> |
|
27 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
28 #include <cimprunemessage.h> |
|
29 #include "cimfinder.h" |
|
30 #endif |
|
31 |
|
32 class CImMessageFinder; |
|
33 class CImMessageCounter; |
|
34 |
|
35 struct TImCacheManagerProgress |
|
36 /** Holds progress of a cache management cleanup operation. |
|
37 |
|
38 @see CImCacheManager::ProgressL() |
|
39 @publishedAll |
|
40 @released |
|
41 */ |
|
42 { |
|
43 public: |
|
44 /** Total number of messages to process. |
|
45 |
|
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 |
|
50 time. */ |
|
51 TInt iTotalMessages; |
|
52 /** Number of messages processed so far. */ |
|
53 TInt iMessagesProcessed; |
|
54 }; |
|
55 |
|
56 class CImCacheManager : public CMsvOperation |
|
57 /** Provides management of the local cache of messages in remote mailboxes. |
|
58 |
|
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. |
|
66 |
|
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 |
|
72 second time. |
|
73 |
|
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.' |
|
78 @publishedAll |
|
79 @released |
|
80 */ |
|
81 { |
|
82 public: |
|
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(); |
|
88 |
|
89 protected: |
|
90 IMPORT_C void ConstructL(); |
|
91 IMPORT_C CImCacheManager(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus); |
|
92 |
|
93 IMPORT_C void RunL(); |
|
94 |
|
95 private: |
|
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. |
|
99 |
|
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. |
|
104 |
|
105 This function must be implemented in any classes derived from CImCacheManager. |
|
106 |
|
107 @return True to clean the entry, false to leave it unchanged */ |
|
108 virtual TBool Filter() const = 0; |
|
109 |
|
110 void DoRunL(); |
|
111 |
|
112 // Remove the store from the currently selected entry |
|
113 inline void PruneMessageL(); |
|
114 |
|
115 protected: |
|
116 /** Message entry currently being processed. */ |
|
117 CMsvEntry* iCurrentEntry; |
|
118 |
|
119 private: |
|
120 CMsvSession& iSession; |
|
121 CImMessageFinder* iMessageFinder; |
|
122 CImMessageCounter* iMessageCounter; |
|
123 CMsvOperation* iDeleteOperation; |
|
124 |
|
125 TImCacheManagerProgress iProgress; |
|
126 TRequestStatus* iReport; |
|
127 |
|
128 enum TImcmState |
|
129 { |
|
130 EImcmLookingForMessage, |
|
131 EImcmPruningMessages, |
|
132 EImcmCountingMessages, |
|
133 EImcmSkippingPrune |
|
134 }; |
|
135 |
|
136 TMsvId iRootEntry; |
|
137 TImcmState iState; |
|
138 TPckgBuf<TImCacheManagerProgress> iProgressBuf; |
|
139 |
|
140 CMsvEntrySelection* iMessagesToPrune; |
|
141 }; |
|
142 |
|
143 #endif |