author | Simon Howkins <simonh@symbian.org> |
Thu, 25 Nov 2010 12:13:04 +0000 | |
branch | RCL_3 |
changeset 83 | 31a5fbf5db1d |
parent 80 | 726fba06891a |
permissions | -rw-r--r-- |
64 | 1 |
/* |
2 |
* Copyright (c) Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: Header for notification handling base class |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#ifndef __FSNOTIFICATIONHANDLERBASE_H__ |
|
20 |
#define __FSNOTIFICATIONHANDLERBASE_H__ |
|
21 |
||
22 |
#include <e32base.h> |
|
23 |
//<cmail> |
|
24 |
#include "mfsmaileventobserver.h" |
|
25 |
//</cmail> |
|
26 |
||
27 |
class CFSMailClient; |
|
28 |
class CFSMailFolder; |
|
29 |
class CFSMailMessage; |
|
30 |
class MFSNotificationHandlerMgr; |
|
31 |
class CFSNotificationHandlerHSConnection; |
|
32 |
class TFSMailMsgId; |
|
33 |
||
34 |
||
35 |
class TNewMailInfo |
|
36 |
{ |
|
37 |
public: |
|
38 |
inline TNewMailInfo( TFSMailMsgId aMsgId, |
|
39 |
TFSMailMsgId aMailBoxId, |
|
40 |
TFSMailMsgId aParentFolderId) |
|
41 |
: iMsgId( aMsgId ), iMailBox( aMailBoxId ), iParentFolderId( aParentFolderId) |
|
42 |
{ } |
|
43 |
||
44 |
TFSMailMsgId iMsgId; |
|
45 |
TFSMailMsgId iMailBox; |
|
46 |
TFSMailMsgId iParentFolderId; |
|
47 |
}; |
|
48 |
||
49 |
class MFSTimerObserver |
|
50 |
{ |
|
51 |
public: |
|
52 |
||
53 |
/** |
|
54 |
* TODO document me |
|
55 |
*/ |
|
56 |
virtual void TimerExpiredL() = 0; |
|
57 |
||
58 |
}; |
|
59 |
||
60 |
class CNewMailNotificationTimer : public CTimer |
|
61 |
{ |
|
62 |
public: |
|
63 |
||
64 |
static CNewMailNotificationTimer* NewL( |
|
65 |
MFSTimerObserver& aObserver ); |
|
66 |
static CNewMailNotificationTimer* NewLC( |
|
67 |
MFSTimerObserver& aObserver ); |
|
68 |
||
69 |
/** |
|
70 |
* Destructor. |
|
71 |
*/ |
|
72 |
virtual ~CNewMailNotificationTimer(); |
|
73 |
||
74 |
||
75 |
protected: |
|
76 |
||
77 |
/** |
|
78 |
* Constructor. |
|
79 |
* |
|
80 |
* @since S60 ?S60_version |
|
81 |
* @param aObserver Observer of this timer. |
|
82 |
*/ |
|
83 |
CNewMailNotificationTimer( |
|
84 |
MFSTimerObserver& aObserver ); |
|
85 |
void ConstructL(); |
|
86 |
||
87 |
// from base class CActive |
|
88 |
virtual void DoCancel(); |
|
89 |
virtual void RunL(); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
90 |
virtual TInt RunError( TInt aError ); |
64 | 91 |
|
92 |
private: |
|
93 |
||
94 |
||
95 |
||
96 |
private: // data |
|
97 |
||
98 |
/** |
|
99 |
* Observer and user of this timer. |
|
100 |
*/ |
|
101 |
MFSTimerObserver& iObserver; |
|
102 |
||
103 |
}; |
|
104 |
||
105 |
/** |
|
106 |
* A base class for notification handlers that need timer services. |
|
107 |
* |
|
108 |
* @code |
|
109 |
* ?good_class_usage_example(s) |
|
110 |
* @endcode |
|
111 |
* |
|
112 |
* @lib ?library |
|
113 |
* @since S60 ?S60_version *** for example, S60 v3.0 |
|
114 |
*/ |
|
115 |
class CFSNotificationHandlerBase : public CBase, public MFSMailEventObserver, public MFSTimerObserver |
|
116 |
{ |
|
117 |
public: |
|
118 |
||
119 |
/** |
|
120 |
* Two-phased constructor. |
|
121 |
* @param aOwner Owner and manager of this handler. |
|
122 |
*/ |
|
123 |
static CFSNotificationHandlerBase* NewL( TInt aHandlerUid, MFSNotificationHandlerMgr& aOwner ); |
|
124 |
||
125 |
public: |
|
126 |
||
127 |
/** |
|
128 |
* Function that returns a reference to the mail client which |
|
129 |
* is used to access email framework. |
|
130 |
* |
|
131 |
* @since S60 ?S60_version |
|
132 |
* @return Reference to framework object. |
|
133 |
*/ |
|
134 |
CFSMailClient& MailClient() const; |
|
135 |
||
136 |
// from base class MFSMailEventObserver |
|
137 |
||
138 |
/** |
|
139 |
* Function that is used to inform the handler of a new event. |
|
140 |
* Default implementation checks whether the startup is complete |
|
141 |
* and therefore the object of this class is observing |
|
142 |
* events. |
|
143 |
* Also checks whether for example the mailbox has capabilities |
|
144 |
* so that the event handling is in this handler is possible. This |
|
145 |
* is checked by calling CapabilitiesToContinueL function which |
|
146 |
* should return ETrue whether the capabilities indicate that |
|
147 |
* the notification handling should be continued. |
|
148 |
* If notification handling is continued then call for HandleEventL |
|
149 |
* is made. |
|
150 |
* |
|
151 |
* This function is not necessarily called by the framework and |
|
152 |
* thus an instance of this class does not necessarily act as a |
|
153 |
* direct observer for the framework but for example for a |
|
154 |
* manager class. |
|
155 |
* |
|
156 |
* @see MFSMailEventObserver::EventL |
|
157 |
*/ |
|
158 |
virtual void EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox, |
|
159 |
TAny* aParam1, TAny* aParam2, TAny* aParam3 ); |
|
160 |
||
161 |
/** |
|
162 |
* Destructor. |
|
163 |
*/ |
|
164 |
virtual ~CFSNotificationHandlerBase(); |
|
165 |
||
166 |
||
167 |
protected: |
|
168 |
||
169 |
/** |
|
170 |
* Constructor. |
|
171 |
* |
|
172 |
* @since S60 ?S60_version |
|
173 |
* @param aOwner Owner and manager of this handler. |
|
174 |
*/ |
|
175 |
CFSNotificationHandlerBase( MFSNotificationHandlerMgr& aOwner ); |
|
176 |
||
177 |
void ConstructL(); |
|
178 |
||
179 |
/** |
|
180 |
* Getter for information whether the handler is observing events |
|
181 |
* |
|
182 |
* @since S60 ?S60_version |
|
183 |
* @return Whether handler is observing or not |
|
184 |
*/ |
|
185 |
TBool Observing() const; |
|
186 |
||
187 |
/** |
|
188 |
* Function that goes through messages identified by the |
|
189 |
* message ids given in the parameter array and checks |
|
190 |
* if any of them is such that it causes a notification. |
|
191 |
* In this default implementation it is checked if any of the |
|
192 |
* messages is unread and that it is the newest of unread messages |
|
193 |
* in the folder. |
|
194 |
* |
|
195 |
* @since S60 ?S60_version |
|
196 |
* @param aMailboxId Mailbox which contains the messages |
|
197 |
* checked here. |
|
198 |
* @param aParentFolderId Folder that contains the messages |
|
199 |
* checked here. |
|
200 |
* @param aMsgIdList List of message identifiers identifying |
|
201 |
* the messages that should be checked |
|
202 |
* for newest unread message. |
|
203 |
* @return Boolean value to indicate whether newest unread |
|
204 |
* messages was found among the identified messages. |
|
205 |
*/ |
|
206 |
virtual TBool MessagesCauseNotificationL( TFSMailMsgId aMailboxId, |
|
207 |
TFSMailMsgId aParentFolderId, |
|
208 |
const RArray<TFSMailMsgId>& aMsgIdList ); |
|
209 |
||
210 |
||
211 |
/** |
|
212 |
* Function that checks whether the given message is unread |
|
213 |
* or not. |
|
214 |
* |
|
215 |
* @since S60 ?S60_version |
|
216 |
* @param aMessage Message which is checked. |
|
217 |
* @return Boolean indicating whether the message was unread |
|
218 |
* or not. ETrue means unread. |
|
219 |
*/ |
|
220 |
TBool MsgIsUnread( /*const*/ CFSMailMessage& aMessage ) const; |
|
221 |
||
222 |
protected: |
|
223 |
||
224 |
/** |
|
225 |
* Function that returns a reference to the Home Screen connection |
|
226 |
* which is used to access Home Screen status. |
|
227 |
* |
|
228 |
* @since S60 ?S60_version |
|
229 |
* @return Pointer to Home Screen connection. Ownership is not |
|
230 |
* transferred. NULL is returned if the connection |
|
231 |
* cannot be provided. |
|
232 |
*/ |
|
233 |
CFSNotificationHandlerHSConnection* HSConnection() const; |
|
234 |
||
235 |
/** |
|
236 |
* Setter for information whether the handler is observing events. |
|
237 |
* |
|
238 |
* @since S60 ?S60_version |
|
239 |
* @param aNewValue New value for observing info |
|
240 |
*/ |
|
241 |
void SetObserving( TBool aNewValue ); |
|
242 |
||
243 |
/** |
|
244 |
* Function that is used to check desired capabilities. |
|
245 |
* Default implementation of this function checks that the mailbox |
|
246 |
* does not have EFSMBoxCapaNewEmailNotifications capability. If it |
|
247 |
* has then EFalse is returned. |
|
248 |
* |
|
249 |
* @see EventL for parameters. |
|
250 |
* |
|
251 |
* @since S60 ?S60_version |
|
252 |
*/ |
|
253 |
virtual TBool CapabilitiesToContinueL( |
|
254 |
TFSMailEvent aEvent, |
|
255 |
TFSMailMsgId aMailbox, |
|
256 |
TAny* aParam1, |
|
257 |
TAny* aParam2, |
|
258 |
TAny* aParam3 ) const; |
|
259 |
||
260 |
/** |
|
261 |
* Function that does the actual event handling. This class provides |
|
262 |
* a default implementation for the function. Sets notification on |
|
263 |
* if the messages cause MessagesCauseNotification() to return |
|
264 |
* ETrue. |
|
265 |
* |
|
266 |
* @see EventL for parameters. |
|
267 |
* |
|
268 |
* @since S60 ?S60_version |
|
269 |
*/ |
|
270 |
virtual void HandleEventL( |
|
271 |
TFSMailEvent aEvent, |
|
272 |
TFSMailMsgId aMailbox, |
|
273 |
TAny* aParam1, |
|
274 |
TAny* aParam2, |
|
275 |
TAny* aParam3 ); |
|
276 |
||
277 |
||
278 |
/** |
|
279 |
* Function that gets the newest message from the given |
|
280 |
* folder. |
|
281 |
* |
|
282 |
* @since S60 ?S60_version |
|
283 |
* @param aFolder Folder where from the newest message |
|
284 |
* is searched. |
|
285 |
* @return Pointer to newest message in the folder. If |
|
286 |
* no messages are found, leaves with KErrNotFound. |
|
287 |
*/ |
|
288 |
CFSMailMessage* NewestMsgInFolderL( |
|
289 |
/*const*/ CFSMailFolder& aFolder ) const; |
|
290 |
||
291 |
||
292 |
private: |
|
293 |
||
294 |
/** |
|
295 |
* Function that sets the notification of the derived class on. |
|
296 |
* |
|
297 |
* @since S60 ?S60_version |
|
298 |
*/ |
|
299 |
virtual void TurnNotificationOn() = 0; |
|
300 |
||
301 |
/** |
|
302 |
* Function that sets the notification of the derived class off. |
|
303 |
* |
|
304 |
* @since S60 ?S60_version |
|
305 |
*/ |
|
306 |
virtual void TurnNotificationOff() = 0; |
|
307 |
||
308 |
// from TODO |
|
309 |
virtual void TimerExpiredL(); |
|
310 |
||
311 |
protected: // data |
|
312 |
||
313 |
/** |
|
314 |
* Owner and manager of the instance of this handler class. |
|
315 |
*/ |
|
316 |
MFSNotificationHandlerMgr& iOwner; |
|
317 |
||
318 |
private: // data |
|
319 |
||
320 |
/** |
|
321 |
* Boolean to inform whether we are currently observing |
|
322 |
* the mail framework |
|
323 |
* Used for example in the startup to prevent callbacks before |
|
324 |
* the object is fully initialized. |
|
325 |
*/ |
|
326 |
TBool iObserving; |
|
327 |
||
328 |
// Destructor key for the ECOM plugin |
|
329 |
TUid iDestructorKey; |
|
330 |
||
331 |
RArray<TNewMailInfo> iNewInboxEntries; |
|
332 |
||
333 |
CNewMailNotificationTimer* iTimer; |
|
334 |
}; |
|
335 |
||
336 |
#include "fsnotificationhandlerbase.inl" |
|
337 |
||
338 |
#endif //__FSNOTIFICATIONHANDLERBASE_H__ |