|
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 // FSMailServer classes (base classes and callback interfaces) |
|
24 #include "fsnotificationhandlerbase.h" |
|
25 #include "fsnotificationhandlernotifierinitiator.h" |
|
26 #include "fsnotificationhandlernotifierinitiatorobserver.h" |
|
27 // Member classes |
|
28 #include "cmailcpssettings.h" // MMailCpsSettingsCallback |
|
29 |
|
30 class CMailCpsIf; |
|
31 class CFSMailBox; |
|
32 class CMailMailboxDetails; |
|
33 class CMailCpsSettings; |
|
34 |
|
35 /** |
|
36 * CMail ContentPublishingService Handler class |
|
37 * Class implementing a handler functionality towards rest of the MailServer |
|
38 * |
|
39 * @lib fsmailserver.exe |
|
40 * @since S60 v5.1 |
|
41 */ |
|
42 NONSHARABLE_CLASS( CMailCpsHandler ) : |
|
43 public CFSNotificationHandlerBase, |
|
44 public MMailCpsSettingsCallback |
|
45 { |
|
46 public: |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 * @param aOwner Owner and manager of this handler. |
|
51 */ |
|
52 static CMailCpsHandler* NewL( MFSNotificationHandlerMgr& aOwner ); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 virtual ~CMailCpsHandler(); |
|
58 |
|
59 /** |
|
60 * From MMailCpsSettingsCallback |
|
61 */ |
|
62 virtual void SettingsChangedCallback(); |
|
63 |
|
64 /** |
|
65 * Wraps all "Update*" methods |
|
66 */ |
|
67 void UpdateFullL(); |
|
68 |
|
69 /** |
|
70 * |
|
71 */ |
|
72 void UpdateMailboxesL(TInt aInstance, const TDesC& aContentId); |
|
73 |
|
74 /** |
|
75 * |
|
76 */ |
|
77 void LaunchWidgetSettingsL( const TDesC& aContentId ); |
|
78 |
|
79 /** |
|
80 * |
|
81 */ |
|
82 void LaunchEmailUIL( const TDesC& aContentId ); |
|
83 |
|
84 /** |
|
85 * |
|
86 */ |
|
87 void LaunchEmailWizardL(); |
|
88 /** |
|
89 * |
|
90 */ |
|
91 TBool AssociateWidgetToSetting( const TDesC& aContentId ); |
|
92 |
|
93 /** |
|
94 * |
|
95 */ |
|
96 void DissociateWidgetFromSetting( const TDesC& aContentId ); |
|
97 |
|
98 /** |
|
99 * |
|
100 */ |
|
101 TInt GetMailboxCount(); |
|
102 |
|
103 protected: |
|
104 /** |
|
105 * From CFSNotificationHandlerBase |
|
106 * see baseclass for details |
|
107 */ |
|
108 virtual TBool CapabilitiesToContinueL( |
|
109 TFSMailEvent aEvent, |
|
110 TFSMailMsgId aMailbox, |
|
111 TAny* aParam1, |
|
112 TAny* aParam2, |
|
113 TAny* aParam3 ) const; |
|
114 |
|
115 /** |
|
116 * From CFSNotificationHandlerBase |
|
117 * see baseclass for details |
|
118 */ |
|
119 virtual void HandleEventL( |
|
120 TFSMailEvent aEvent, |
|
121 TFSMailMsgId aMailbox, |
|
122 TAny* aParam1, |
|
123 TAny* aParam2, |
|
124 TAny* aParam3 ); |
|
125 |
|
126 private: |
|
127 /** |
|
128 * Constructor |
|
129 * @param aOwner reference to owning class. CpsHandler is just one of |
|
130 * the handlers running in MailServer process. |
|
131 */ |
|
132 CMailCpsHandler( MFSNotificationHandlerMgr& aOwner ); |
|
133 void ConstructL(); |
|
134 |
|
135 // Initialization methods |
|
136 /** |
|
137 * Resets everything |
|
138 */ |
|
139 void Reset(); |
|
140 |
|
141 /** |
|
142 * Initializes everything |
|
143 */ |
|
144 void InitializeL(); |
|
145 |
|
146 // Creation methods |
|
147 /** |
|
148 * Creates an instance of mailboxdetails based on parameters |
|
149 * @param aMailbox mailbox |
|
150 * @return pointer to instance of CMailMailboxDetails. |
|
151 * Caller gets ownership of the returned object. |
|
152 */ |
|
153 CMailMailboxDetails* CreateMailboxDetailsL( CFSMailBox& aMailbox ); |
|
154 |
|
155 /** |
|
156 * Finds mailbox details instance from the local array |
|
157 * @param aMailbox mailbox id |
|
158 * @return pointer to instance of CMailMailboxDetails |
|
159 */ |
|
160 CMailMailboxDetails* FindMailboxDetails( TFSMailMsgId aMailbox ); |
|
161 |
|
162 /** |
|
163 * |
|
164 */ |
|
165 void CMailCpsHandler::UpdateMailboxNameL( const TInt aMailBoxNumber, |
|
166 const TInt aWidgetInstance, |
|
167 const TInt aRowNumber ); |
|
168 |
|
169 /** |
|
170 * Handles publishing of message details |
|
171 */ |
|
172 void UpdateMessagesL( const TInt aMailBoxNumber, |
|
173 const TInt aWidgetInstance, |
|
174 const TInt aMessageNumber, |
|
175 const TInt aFirstRow ); |
|
176 |
|
177 /** |
|
178 * Gets correct localised format for time (or date) string |
|
179 */ |
|
180 HBufC* GetMessageTimeStringL( TTime aMessageTime ); |
|
181 |
|
182 /** |
|
183 * |
|
184 */ |
|
185 void UpdateEmptyMessagesL( const TInt aWidgetInstance, |
|
186 const TInt aFirstRow ); |
|
187 |
|
188 /** |
|
189 * Handles publishing of connection state icon |
|
190 */ |
|
191 void UpdateConnectStateL( const TInt aMailBoxNumber, const TInt aRowNumber ); |
|
192 |
|
193 /** |
|
194 * Handles publishing of mailbox icon |
|
195 */ |
|
196 void UpdateMailBoxIconL( const TInt aMailBoxNumber, |
|
197 const TInt aWidgetInstance, |
|
198 const TInt aRowNumber ); |
|
199 |
|
200 /** |
|
201 * Handles publishing of unseen icon |
|
202 */ |
|
203 void UpdateIndicatorIconL( const TInt aMailBoxNumber, |
|
204 const TInt aWidgetInstance, |
|
205 const TInt aRowNumber ); |
|
206 |
|
207 /** |
|
208 * Handles publishing of empty message time string |
|
209 */ |
|
210 // void ClearMessageTimeL( const TInt aRowNumber ); |
|
211 |
|
212 // Event handling subroutines |
|
213 /** |
|
214 * handles new mailbox event |
|
215 * @param aMailbox mailbox id |
|
216 */ |
|
217 void HandleNewMailboxEventL( const TFSMailMsgId aMailbox ); |
|
218 |
|
219 /** |
|
220 * handles mailbox deleted event |
|
221 * @param aMailbox mailbox id |
|
222 */ |
|
223 void HandleMailboxDeletedEventL( const TFSMailMsgId aMailbox ); |
|
224 |
|
225 /** |
|
226 * handles new mail event |
|
227 * @param aMailbox mailbox id |
|
228 * @param aParam1 contains event specific parameters |
|
229 * @param aParam2 contains event specific parameters |
|
230 */ |
|
231 void HandleNewMailEventL( TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2 ); |
|
232 |
|
233 /** |
|
234 * handles mail deleted event |
|
235 * @param aMailbox mailbox id |
|
236 * @param aParam1 contains event specific parameters |
|
237 * @param aParam2 contains event specific parameters |
|
238 */ |
|
239 void HandleMailDeletedEventL( TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2 ); |
|
240 |
|
241 /** |
|
242 * handles mail changed event |
|
243 * @param aMailbox mailbox id |
|
244 * @param aParam1 contains event specific parameters |
|
245 * @param aParam2 contains event specific parameters |
|
246 */ |
|
247 void HandleMailChangedEventL( TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2 ); |
|
248 |
|
249 /** |
|
250 * handles new folder event |
|
251 * @param aMailbox mailbox id |
|
252 * @param aParam1 contains event specific parameters |
|
253 * @param aParam2 contains event specific parameters |
|
254 */ |
|
255 void HandleNewFolderEventL( TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2 ); |
|
256 |
|
257 /** |
|
258 * get count of unread messages in inbox |
|
259 * @param aMailbox mailbox id |
|
260 */ |
|
261 TInt GetUnreadCountL( TFSMailMsgId aMailbox); |
|
262 |
|
263 /** |
|
264 * get count of unseen messages in inbox |
|
265 * @param aMailbox mailbox id |
|
266 */ |
|
267 TInt GetUnseenCountL( TFSMailMsgId aMailbox); |
|
268 |
|
269 /** |
|
270 * Tells if outbox is empty |
|
271 * @param aMailbox mailbox id |
|
272 */ |
|
273 TBool IsOutboxEmptyL( TFSMailMsgId aMailbox); |
|
274 |
|
275 /** |
|
276 * From CFSNotificationHandlerBase |
|
277 * Not used |
|
278 */ |
|
279 virtual void TurnNotificationOn(); |
|
280 |
|
281 /** |
|
282 * From CFSNotificationHandlerBase |
|
283 * Not used |
|
284 */ |
|
285 virtual void TurnNotificationOff(); |
|
286 |
|
287 /** |
|
288 * |
|
289 */ |
|
290 TInt GetMailIcon( CFSMailMessage* aMsg ); |
|
291 |
|
292 /** |
|
293 * |
|
294 */ |
|
295 TInt GetUnreadMsgIcon( CFSMailMessage* aMsg ); |
|
296 |
|
297 /** |
|
298 * |
|
299 */ |
|
300 TInt GetReadMsgIcon( CFSMailMessage* aMsg ); |
|
301 |
|
302 /** |
|
303 * |
|
304 */ |
|
305 TInt GetUnreadCalMsgIcon( CFSMailMessage* aMsg ); |
|
306 |
|
307 /** |
|
308 * |
|
309 */ |
|
310 TInt GetReadCalMsgIcon( CFSMailMessage* aMsg ); |
|
311 |
|
312 /** |
|
313 * |
|
314 */ |
|
315 TBool IsValidDisplayName(const TDesC& aDisplayName); |
|
316 |
|
317 /** |
|
318 * |
|
319 */ |
|
320 void PublishMessageL( TInt aWidgetInstance, CFSMailMessage& aMessage, |
|
321 const TDesC& aSenderName, const TDesC& aTime, TInt aFirstRow); |
|
322 |
|
323 /** |
|
324 * Checks if the given message is already know/published |
|
325 * @param aMailbox specifies the mailboxdetails object where duplicate is searched from |
|
326 * @param aMsgId Id of the new message |
|
327 * @return ETrue if duplicate, EFalse if new message |
|
328 */ |
|
329 TBool IsDuplicate( const CMailMailboxDetails& aMailbox, const TFSMailMsgId& aMsgId ); |
|
330 |
|
331 private: // data |
|
332 CEikonEnv* iEnv; |
|
333 // pointer to liw wrapper that handles actual publishing |
|
334 CMailCpsIf* iLiwIf; |
|
335 // pointer to settings class that handles settings loading and observing logic |
|
336 CMailCpsSettings* iSettings; |
|
337 // local cache of mailbox details |
|
338 RPointerArray<CMailMailboxDetails> iAccountsArray; |
|
339 }; |
|
340 |
|
341 #endif //__CMAILCPSHANDLER_H__ |