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) 2008 - 2009 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: Class to handle content publishing for widget |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#ifndef __CMAILCPSHANDLER_H__ |
|
20 |
#define __CMAILCPSHANDLER_H__ |
|
21 |
||
22 |
#include <aknappui.h> |
|
23 |
#include <memailobserverlistener.h> // base class |
|
24 |
#include <AknGlobalNote.h> |
|
25 |
||
26 |
// FSMailServer classes (base classes and callback interfaces) |
|
27 |
#include "fsnotificationhandlerbase.h" |
|
28 |
#include "fsnotificationhandlernotifierinitiator.h" |
|
29 |
#include "fsnotificationhandlernotifierinitiatorobserver.h" |
|
30 |
// Member classes |
|
31 |
#include "cmailcpssettings.h" // MMailCpsSettingsCallback |
|
32 |
||
33 |
class CMailCpsIf; |
|
34 |
class CFSMailBox; |
|
35 |
class CMailMailboxDetails; |
|
36 |
class CMailCpsSettings; |
|
37 |
class CMailExternalAccount; |
|
38 |
class CMailPluginProxy; |
|
39 |
class CEmailObserverPlugin; |
|
40 |
class CMailCpsUpdateHelper; |
|
41 |
||
42 |
/** |
|
43 |
* CMail ContentPublishingService Handler class |
|
44 |
* Class implementing a handler functionality towards rest of the MailServer |
|
45 |
* |
|
46 |
* @lib fsmailserver.exe |
|
47 |
* @since S60 v5.1 |
|
48 |
*/ |
|
49 |
NONSHARABLE_CLASS( CMailCpsHandler ) : |
|
50 |
public CFSNotificationHandlerBase, |
|
51 |
public MMailCpsSettingsCallback, |
|
52 |
public EmailInterface::MEmailObserverListener |
|
53 |
{ |
|
54 |
public: |
|
55 |
||
56 |
/** |
|
57 |
* Two-phased constructor. |
|
58 |
* @param aOwner Owner and manager of this handler. |
|
59 |
*/ |
|
60 |
static CMailCpsHandler* NewL( MFSNotificationHandlerMgr& aOwner ); |
|
61 |
||
62 |
/** |
|
63 |
* Destructor. |
|
64 |
*/ |
|
65 |
virtual ~CMailCpsHandler(); |
|
66 |
||
67 |
/** |
|
68 |
* From MMailCpsSettingsCallback |
|
69 |
*/ |
|
70 |
virtual void SettingsChangedCallback(); |
|
71 |
||
72 |
/** |
|
73 |
* |
|
74 |
*/ |
|
75 |
void SetUpdateNeeded( const TFSMailMsgId aMailbox ); |
|
76 |
||
77 |
/** |
|
78 |
* Wraps all "Update*" methods |
|
79 |
*/ |
|
80 |
void UpdateFullL(); |
|
81 |
||
82 |
/** |
|
83 |
* Method that actually does the full update. |
|
84 |
* Used by CMailCpsUpdateHelper. |
|
85 |
*/ |
|
86 |
void DoUpdateFullL(); |
|
87 |
||
88 |
/** |
|
89 |
* |
|
90 |
*/ |
|
91 |
void UpdateMailboxesL(TInt aInstance, const TDesC& aContentId); |
|
92 |
||
93 |
/** |
|
94 |
* |
|
95 |
*/ |
|
96 |
void LaunchWidgetSettingsL( const TDesC& aContentId ); |
|
97 |
||
98 |
/** |
|
99 |
* |
|
100 |
*/ |
|
101 |
void LaunchEmailUIL( const TDesC& aContentId ); |
|
102 |
||
103 |
/** |
|
104 |
* |
|
105 |
*/ |
|
106 |
void LaunchEmailWizardL( const TDesC& aContentId ); |
|
107 |
/** |
|
108 |
* Launches an application based on the given contentId |
|
109 |
* This method is for external (3rd party) accounts |
|
110 |
* @param aContentId specifies the widget that was pressed by the user |
|
111 |
*/ |
|
112 |
void LaunchExtAppL( const TDesC& aContentId ); |
|
113 |
||
114 |
/** |
|
115 |
* |
|
116 |
*/ |
|
117 |
void DissociateWidgetFromSettingL( const TDesC& aContentId ); |
|
118 |
||
119 |
/** |
|
120 |
* Return total number of mailboxes (native+3rd party) in the system |
|
121 |
*/ |
|
122 |
TInt TotalMailboxCountL(); |
|
123 |
||
124 |
/** |
|
125 |
* Return total number of native mailboxes in the system |
|
126 |
*/ |
|
127 |
TInt TotalIntMailboxCount(); |
|
128 |
||
129 |
/** |
|
130 |
* Return total number of 3rd party mailboxes in the system |
|
131 |
*/ |
|
132 |
TInt TotalExtMailboxCountL(); |
|
133 |
||
134 |
/** |
|
135 |
* Gets correct localised format for time (or date) string |
|
136 |
*/ |
|
137 |
static HBufC* GetMessageTimeStringL( TTime aMessageTime ); |
|
138 |
||
139 |
// From MEmailObserverListener |
|
140 |
void EmailObserverEvent( EmailInterface::MEmailData& aData ); |
|
141 |
||
142 |
/** |
|
143 |
* |
|
144 |
*/ |
|
145 |
void SetWaitingForNewMailbox( const TDesC& aContentId ); |
|
146 |
||
147 |
/** |
|
148 |
* |
|
149 |
*/ |
|
150 |
void CleanWaitingForNewMailbox(); |
|
151 |
||
152 |
/** |
|
153 |
* |
|
154 |
*/ |
|
155 |
void SetWaitingForNewWidget( const TFSMailMsgId aMailbox ); |
|
156 |
||
157 |
/** |
|
158 |
* |
|
159 |
*/ |
|
160 |
void CleanWaitingForNewWidget(); |
|
161 |
||
162 |
/** |
|
163 |
* |
|
164 |
*/ |
|
165 |
TFSMailMsgId WaitingForNewWidget(); |
|
166 |
||
167 |
/** |
|
168 |
* |
|
169 |
*/ |
|
170 |
void AssociateWidgetToSetting( const TDesC& aContentId, |
|
171 |
const TFSMailMsgId aMailbox ); |
|
172 |
||
173 |
/** |
|
174 |
* |
|
175 |
*/ |
|
176 |
TBool Associated( const TDesC& aContentId ); |
|
177 |
||
178 |
/** |
|
179 |
* |
|
180 |
*/ |
|
181 |
void DisplayHSPageFullNoteL(); |
|
182 |
||
183 |
/** |
|
184 |
* get count of unread messages in inbox |
|
185 |
* @param aMailbox mailbox id |
|
186 |
*/ |
|
187 |
TInt GetUnreadCountL( TFSMailMsgId aMailbox); |
|
188 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
189 |
/** |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
190 |
* |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
191 |
*/ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
192 |
TInt GetWidgetSetupBrandIconVariant(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
193 |
|
64 | 194 |
protected: |
195 |
/** |
|
196 |
* From CFSNotificationHandlerBase |
|
197 |
* see baseclass for details |
|
198 |
*/ |
|
199 |
virtual TBool CapabilitiesToContinueL( |
|
200 |
TFSMailEvent aEvent, |
|
201 |
TFSMailMsgId aMailbox, |
|
202 |
TAny* aParam1, |
|
203 |
TAny* aParam2, |
|
204 |
TAny* aParam3 ) const; |
|
205 |
||
206 |
/** |
|
207 |
* From CFSNotificationHandlerBase |
|
208 |
* see baseclass for details |
|
209 |
*/ |
|
210 |
virtual void HandleEventL( |
|
211 |
TFSMailEvent aEvent, |
|
212 |
TFSMailMsgId aMailbox, |
|
213 |
TAny* aParam1, |
|
214 |
TAny* aParam2, |
|
215 |
TAny* aParam3 ); |
|
216 |
||
217 |
private: |
|
218 |
/** |
|
219 |
* Constructor |
|
220 |
* @param aOwner reference to owning class. CpsHandler is just one of |
|
221 |
* the handlers running in MailServer process. |
|
222 |
*/ |
|
223 |
CMailCpsHandler( MFSNotificationHandlerMgr& aOwner ); |
|
224 |
void ConstructL(); |
|
225 |
||
226 |
// Initialization methods |
|
227 |
/** |
|
228 |
* Resets everything |
|
229 |
*/ |
|
230 |
void Reset(); |
|
231 |
||
232 |
/** |
|
233 |
* Initializes native accounts |
|
234 |
*/ |
|
235 |
void InitializeL(); |
|
236 |
||
237 |
/** |
|
238 |
* Initializes external accounts |
|
239 |
*/ |
|
240 |
void InitializeExternalAccountsL(); |
|
241 |
||
242 |
// Creation methods |
|
243 |
/** |
|
244 |
* Creates an instance of mailboxdetails based on parameters |
|
245 |
* @param aMailbox mailbox |
|
246 |
* @return pointer to instance of CMailMailboxDetails. |
|
247 |
* Caller gets ownership of the returned object. |
|
248 |
*/ |
|
249 |
CMailMailboxDetails* CreateMailboxDetailsL( CFSMailBox& aMailbox ); |
|
250 |
||
251 |
/** |
|
252 |
* Finds mailbox details instance from the local array |
|
253 |
* @param aMailbox mailbox id |
|
254 |
* @return pointer to instance of CMailMailboxDetails |
|
255 |
*/ |
|
256 |
CMailMailboxDetails* FindMailboxDetails( TFSMailMsgId aMailbox ); |
|
257 |
||
258 |
/** |
|
259 |
* |
|
260 |
*/ |
|
261 |
void CMailCpsHandler::UpdateMailboxNameL( const TInt aMailBoxNumber, |
|
262 |
const TInt aWidgetInstance, |
|
263 |
const TInt aRowNumber ); |
|
264 |
||
265 |
/** |
|
266 |
* Handles publishing of message details |
|
267 |
*/ |
|
268 |
void UpdateMessagesL( const TInt aMailBoxNumber, |
|
269 |
const TInt aWidgetInstance, |
|
270 |
const TInt aMessageNumber, |
|
271 |
const TInt aFirstRow ); |
|
272 |
||
273 |
/** |
|
274 |
* |
|
275 |
*/ |
|
276 |
void UpdateEmptyMessagesL( const TInt aWidgetInstance, |
|
277 |
const TInt aFirstRow ); |
|
278 |
||
279 |
/** |
|
280 |
* Handles publishing of mailbox icon |
|
281 |
*/ |
|
282 |
void UpdateMailBoxIconL( const TInt aMailBoxNumber, |
|
283 |
const TInt aWidgetInstance, |
|
284 |
const TInt aRowNumber ); |
|
285 |
||
286 |
/** |
|
287 |
* Handles publishing of unseen icon |
|
288 |
*/ |
|
289 |
void UpdateIndicatorIconL( const TInt aMailBoxNumber, |
|
290 |
const TInt aWidgetInstance, |
|
291 |
const TInt aRowNumber ); |
|
292 |
||
293 |
// Event handling subroutines |
|
294 |
/** |
|
295 |
* handles new mailbox event |
|
296 |
* @param aMailbox mailbox id |
|
297 |
*/ |
|
298 |
void HandleNewMailboxEventL( const TFSMailMsgId aMailbox ); |
|
299 |
||
300 |
/** |
|
301 |
* Handles mailbox renamed event. |
|
302 |
* @param aMailbox mailbox id |
|
303 |
*/ |
|
304 |
void HandleMailboxRenamedEventL( const TFSMailMsgId aMailbox ); |
|
305 |
||
306 |
/** |
|
307 |
* handles mailbox deleted event |
|
308 |
* @param aMailbox mailbox id |
|
309 |
*/ |
|
310 |
void HandleMailboxDeletedEventL( const TFSMailMsgId aMailbox ); |
|
311 |
||
312 |
/** |
|
313 |
* handles new mail event |
|
314 |
* @param aMailbox mailbox id |
|
315 |
* @param aParam1 contains event specific parameters |
|
316 |
* @param aParam2 contains event specific parameters |
|
317 |
*/ |
|
318 |
void HandleNewMailEventL( TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2 ); |
|
319 |
||
320 |
/** |
|
321 |
* handles mail deleted event |
|
322 |
* @param aMailbox mailbox id |
|
323 |
* @param aParam1 contains event specific parameters |
|
324 |
* @param aParam2 contains event specific parameters |
|
325 |
*/ |
|
326 |
void HandleMailDeletedEventL( TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2 ); |
|
327 |
||
328 |
/** |
|
329 |
* get count of unseen messages in inbox |
|
330 |
* @param aMailbox mailbox id |
|
331 |
*/ |
|
332 |
TInt GetUnseenCountL( TFSMailMsgId aMailbox); |
|
333 |
||
334 |
/** |
|
335 |
* Tells if outbox is empty |
|
336 |
* @param aMailbox mailbox id |
|
337 |
*/ |
|
338 |
TBool IsOutboxEmptyL( TFSMailMsgId aMailbox); |
|
339 |
||
340 |
/** |
|
341 |
* From CFSNotificationHandlerBase |
|
342 |
* Not used |
|
343 |
*/ |
|
344 |
virtual void TurnNotificationOn(); |
|
345 |
||
346 |
/** |
|
347 |
* From CFSNotificationHandlerBase |
|
348 |
* Not used |
|
349 |
*/ |
|
350 |
virtual void TurnNotificationOff(); |
|
351 |
||
352 |
/** |
|
353 |
* |
|
354 |
*/ |
|
355 |
TInt GetMailIcon( CFSMailMessage* aMsg ); |
|
356 |
||
357 |
/** |
|
358 |
* |
|
359 |
*/ |
|
360 |
TInt GetUnreadMsgIcon( CFSMailMessage* aMsg ); |
|
361 |
||
362 |
/** |
|
363 |
* |
|
364 |
*/ |
|
365 |
TInt GetReadMsgIcon( CFSMailMessage* aMsg ); |
|
366 |
||
367 |
/** |
|
368 |
* |
|
369 |
*/ |
|
370 |
TInt GetUnreadCalMsgIcon( CFSMailMessage* aMsg ); |
|
371 |
||
372 |
/** |
|
373 |
* |
|
374 |
*/ |
|
375 |
TInt GetReadCalMsgIcon( CFSMailMessage* aMsg ); |
|
376 |
||
377 |
/** |
|
378 |
* |
|
379 |
*/ |
|
380 |
TBool IsValidDisplayName(const TDesC& aDisplayName); |
|
381 |
||
382 |
/** |
|
383 |
* |
|
384 |
*/ |
|
385 |
void PublishMessageL( TInt aWidgetInstance, CFSMailMessage& aMessage, |
|
386 |
const TDesC& aSenderName, |
|
387 |
const TDesC& aSubject, |
|
388 |
const TDesC& aTime, TInt aFirstRow); |
|
389 |
||
390 |
/** |
|
391 |
* Checks if the given message is already know/published |
|
392 |
* @param aMailbox specifies the mailboxdetails object where duplicate is searched from |
|
393 |
* @param aMsgId Id of the new message |
|
394 |
* @return ETrue if duplicate, EFalse if new message |
|
395 |
*/ |
|
396 |
TBool IsDuplicate( const CMailMailboxDetails& aMailbox, const TFSMailMsgId& aMsgId ); |
|
397 |
||
398 |
// |
|
399 |
// Private methods related to 3rd party email widget publishers |
|
400 |
// |
|
401 |
/** |
|
402 |
* Removes all plugin proxies (and plugins) that are not listed in aAccounts |
|
403 |
* @param aAccounts up-to-date list of external (3rd party) email accounts |
|
404 |
* that are specified in settings |
|
405 |
*/ |
|
406 |
void RemoveUnusedPluginsL( RPointerArray<CMailExternalAccount>& aAccounts ); |
|
407 |
||
408 |
/** |
|
409 |
* Goes through the array of external accounts and instantiates (newly added) |
|
410 |
* 3rd party plugins |
|
411 |
* @param aAccounts up-to-date list of external (3rd party) email accounts |
|
412 |
* that are specified in settings |
|
413 |
*/ |
|
414 |
void AddNewPluginsL( RPointerArray<CMailExternalAccount>& aAccounts ); |
|
415 |
||
416 |
/** |
|
417 |
* Goes through the array of existing 3rd party plugin (proxies) and |
|
418 |
* lets them take the accounts given in the param array. |
|
419 |
* Plugin proxies also update the widget data. |
|
420 |
* @param aAccounts up-to-date list of external (3rd party) email accounts |
|
421 |
* that are specified in settings |
|
422 |
*/ |
|
423 |
void SelectAndUpdateExtAccountsL( RPointerArray<CMailExternalAccount>& aAccounts ); |
|
424 |
||
425 |
/** |
|
426 |
* Checks whether aAccounts array has entries relating to plugin with id aPluginId |
|
427 |
* @param aPluginId 3rd party plugin identifier (implementation uid) |
|
428 |
* @param aAccounts array of 3rd party email account information |
|
429 |
* @return true or false |
|
430 |
*/ |
|
431 |
TBool IsPluginInArray( const TInt aPluginId, RPointerArray<CMailExternalAccount>& aAccounts ); |
|
432 |
||
433 |
/** |
|
434 |
* Checks whether aPlugins array has entries relating to plugin with id aPluginId |
|
435 |
* @param aPluginId 3rd party plugin identifier (implementation uid) |
|
436 |
* @param aPlugins array of plugin proxies |
|
437 |
* @return true or false |
|
438 |
*/ |
|
439 |
TBool IsPluginInArray( const TInt aPluginId, RPointerArray<CMailPluginProxy>& aPlugins ); |
|
440 |
||
441 |
/** |
|
442 |
* Goes through iExternalPlugins array and finds correct entry |
|
443 |
* @param aContentId specifying a widget/account |
|
444 |
* @return correct plugin proxy instance pointer (ownership not transferred) |
|
445 |
* if not found, NULL is retuned |
|
446 |
*/ |
|
447 |
CMailPluginProxy* GetExtPluginL( const TDesC& aContentId ); |
|
448 |
||
449 |
private: // data |
|
450 |
CEikonEnv* iEnv; |
|
451 |
// pointer to liw wrapper that handles actual publishing |
|
452 |
CMailCpsIf* iLiwIf; |
|
453 |
// pointer to settings class that handles settings loading and observing logic |
|
454 |
CMailCpsSettings* iSettings; |
|
455 |
// local cache of mailbox details |
|
456 |
RPointerArray<CMailMailboxDetails> iAccountsArray; |
|
457 |
// array of plugin proxies. One plugin proxy handles one 3rd party plugin and its accounts |
|
458 |
RPointerArray<CMailPluginProxy> iExternalPlugins; |
|
459 |
// tells if email wizard is started from widget and it is still running |
|
460 |
// and to which widget next added account is added. |
|
461 |
HBufC* iWaitingForNewMailbox; |
|
462 |
// |
|
463 |
TFSMailMsgId iWaitingForNewWidget; |
|
464 |
// |
|
465 |
CAknGlobalNote* iQuery; |
|
466 |
// Helper for limiting rate of updates to Homescreen widget |
|
467 |
CMailCpsUpdateHelper* iUpdateHelper; |
|
468 |
}; |
|
469 |
||
470 |
//----------------------------------------------------------------------------- |
|
471 |
//----------------------------------------------------------------------------- |
|
472 |
||
473 |
// Helper class for limiting rate of updates to Homescreen widget |
|
474 |
||
475 |
// Don't make widget updates more often than this delay (milliseconds) |
|
476 |
#define KMailCpsHandlerUpdateDelay 1000 |
|
477 |
||
478 |
class CMailCpsUpdateHelper : public CTimer |
|
479 |
{ |
|
480 |
public: |
|
481 |
static CMailCpsUpdateHelper* NewLC( CMailCpsHandler *aHandler ); |
|
482 |
static CMailCpsUpdateHelper* NewL( CMailCpsHandler *aHandler ); |
|
483 |
||
484 |
virtual ~CMailCpsUpdateHelper(); |
|
485 |
||
486 |
// Notify that Homescreen widget(s) should be updated |
|
487 |
void UpdateL(); |
|
488 |
||
489 |
protected: |
|
490 |
void ConstructL(); |
|
491 |
virtual void RunL(); |
|
492 |
TInt RunError( TInt aError ); |
|
493 |
||
494 |
private: |
|
495 |
CMailCpsUpdateHelper( CMailCpsHandler *aHandler ); |
|
496 |
||
497 |
// Performs the update, resets the timer, etc. |
|
498 |
void DoUpdateL(); |
|
499 |
||
500 |
// Handler to use to do updates (not owned) |
|
501 |
CMailCpsHandler *iCpsHandler; |
|
502 |
// Whether or not an update is pending |
|
503 |
TBool iPending; |
|
504 |
}; |
|
505 |
||
506 |
||
507 |
#endif //__CMAILCPSHANDLER_H__ |