|
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 #include <cmailhandlerplugin.mbg> |
|
19 #include <ecom/ecom.h> |
|
20 #include <StringLoader.h> |
|
21 #include <emailwidget.rsg> |
|
22 #include <AknUtils.h> |
|
23 #include <apgcli.h> |
|
24 |
|
25 #include "emailtrace.h" |
|
26 #include "CFSMailClient.h" |
|
27 #include "CFSMailBox.h" |
|
28 #include "CFSMailFolder.h" |
|
29 #include "cmailcpshandler.h" |
|
30 #include "cmailcpssettings.h" |
|
31 #include "cmailcpsif.h" |
|
32 #include "cmailmessagedetails.h" |
|
33 #include "cmailmailboxdetails.h" |
|
34 #include "cmailcpsifconsts.h" |
|
35 #include "FreestyleEmailUiConstants.h" |
|
36 |
|
37 // --------------------------------------------------------- |
|
38 // CMailCpsHandler::CMailCpsHandler |
|
39 // --------------------------------------------------------- |
|
40 // |
|
41 CMailCpsHandler::CMailCpsHandler( MFSNotificationHandlerMgr& aOwner ) : CFSNotificationHandlerBase( aOwner ) |
|
42 { |
|
43 FUNC_LOG; |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------- |
|
47 // CMailCpsHandler::NewL |
|
48 // --------------------------------------------------------- |
|
49 // |
|
50 CMailCpsHandler* CMailCpsHandler::NewL( MFSNotificationHandlerMgr& aOwner ) |
|
51 { |
|
52 FUNC_LOG; |
|
53 CMailCpsHandler* self = new(ELeave) CMailCpsHandler( aOwner ); |
|
54 CleanupStack::PushL(self); |
|
55 self->ConstructL(); |
|
56 CleanupStack::Pop( self ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // CMailCpsHandler::ConstructL |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 void CMailCpsHandler::ConstructL() |
|
65 { |
|
66 FUNC_LOG; |
|
67 |
|
68 CFSNotificationHandlerBase::ConstructL(); |
|
69 |
|
70 iEnv = CEikonEnv::Static( ); |
|
71 |
|
72 SetObserving( ETrue ); |
|
73 |
|
74 // Instantiate helper classes |
|
75 // Leaves if ContentPublishing service not found |
|
76 iLiwIf = CMailCpsIf::NewL(this); |
|
77 // Leaves if CenRep file not found |
|
78 iSettings = CMailCpsSettings::NewL( MailClient() ); |
|
79 |
|
80 InitializeL(); |
|
81 |
|
82 iSettings->StartObservingL( this ); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CMailCpsHandler::~CMailCpsHandler |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 CMailCpsHandler::~CMailCpsHandler() |
|
90 { |
|
91 FUNC_LOG; |
|
92 delete iLiwIf; |
|
93 delete iSettings; |
|
94 iAccountsArray.ResetAndDestroy(); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // CMailCpsHandler::Reset |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 void CMailCpsHandler::Reset() |
|
102 { |
|
103 FUNC_LOG; |
|
104 iAccountsArray.ResetAndDestroy(); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------- |
|
108 // CMailCpsHandler::InitializeL |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 void CMailCpsHandler::InitializeL() |
|
112 { |
|
113 FUNC_LOG; |
|
114 // Get current configuration from settings interface, |
|
115 // and pass it on to actual publisher interface |
|
116 iLiwIf->SetConfiguration( iSettings->Configuration() ); |
|
117 |
|
118 const TInt iiMax( iSettings->Mailboxes().Count() ); |
|
119 for ( TInt ii = 0; ii < iiMax; ii++ ) |
|
120 { |
|
121 CFSMailBox* mailbox( NULL ); |
|
122 mailbox = MailClient().GetMailBoxByUidL( iSettings->Mailboxes()[ii] ); |
|
123 |
|
124 TInt id(0); |
|
125 if (mailbox) |
|
126 { |
|
127 id = mailbox->GetId().Id(); |
|
128 } |
|
129 if ( !id ) |
|
130 { |
|
131 // Remove box from settings |
|
132 iSettings->RemoveMailboxL( ii ); |
|
133 // Array indexing changes now since one item was deleted |
|
134 ii--; |
|
135 } |
|
136 else |
|
137 { |
|
138 CleanupStack::PushL( mailbox ); |
|
139 CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox ); |
|
140 CleanupStack::PushL( mailboxDetails ); |
|
141 TBuf<KMaxDescLen> cid; |
|
142 iSettings->GetContentId(id, cid); |
|
143 mailboxDetails->SetWidgetInstance(cid); |
|
144 iAccountsArray.AppendL( mailboxDetails ); |
|
145 CleanupStack::Pop( mailboxDetails ); |
|
146 CleanupStack::PopAndDestroy( mailbox ); |
|
147 } |
|
148 } |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------- |
|
152 // CMailCpsHandler::CreateMailboxDetailsL |
|
153 // --------------------------------------------------------- |
|
154 // |
|
155 CMailMailboxDetails* CMailCpsHandler::CreateMailboxDetailsL( CFSMailBox& aMailbox ) |
|
156 { |
|
157 FUNC_LOG; |
|
158 // Create instance to return |
|
159 CMailMailboxDetails* details = |
|
160 CMailMailboxDetails::NewL( aMailbox.GetId(), aMailbox.GetName() ); |
|
161 return details; |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------- |
|
165 // CMailCpsHandler::SettingsChangedCallback |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 void CMailCpsHandler::SettingsChangedCallback() |
|
169 { |
|
170 FUNC_LOG; |
|
171 Reset(); |
|
172 // Trying to keep callback interface non-leaving |
|
173 TRAP_IGNORE( InitializeL() ); |
|
174 // Update widget contents after settings change |
|
175 TRAP_IGNORE( UpdateFullL() ); |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------- |
|
179 // CMailCpsHandler::UpdateFullL |
|
180 // --------------------------------------------------------- |
|
181 // |
|
182 void CMailCpsHandler::UpdateFullL() |
|
183 { |
|
184 FUNC_LOG; |
|
185 for (TInt instance = 0; instance < iLiwIf->GetWidgetInstanceCount(); instance++) |
|
186 { |
|
187 if ( iLiwIf->AllowedToPublish(instance) ) |
|
188 { |
|
189 UpdateMailboxesL(instance, iLiwIf->iInstIdList[instance]->Des()); |
|
190 } |
|
191 } |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------- |
|
195 // CMailCpsHandler::UpdateMailboxesL |
|
196 // --------------------------------------------------------- |
|
197 // |
|
198 void CMailCpsHandler::UpdateMailboxesL(TInt aInstance, const TDesC& aContentId) |
|
199 { |
|
200 FUNC_LOG; |
|
201 TInt row(1); // start from first row |
|
202 TInt mailbox(0); |
|
203 |
|
204 for ( mailbox = 0; mailbox < iAccountsArray.Count(); mailbox++ ) |
|
205 { |
|
206 TInt compare = aContentId.Compare(*iAccountsArray[mailbox]->iWidgetInstance); |
|
207 if (!compare) |
|
208 { |
|
209 break; |
|
210 } |
|
211 } |
|
212 |
|
213 // Update fields from left to right |
|
214 UpdateMailBoxIconL( mailbox, aInstance, row ); |
|
215 UpdateMailboxNameL( mailbox, aInstance, row ); |
|
216 UpdateIndicatorIconL( mailbox, aInstance, row ); |
|
217 row++; |
|
218 UpdateMessagesL( mailbox, aInstance, 1, row); |
|
219 row++; |
|
220 UpdateMessagesL( mailbox, aInstance, 2, row); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------- |
|
224 // CMailCpsHandler::UpdateMailboxNameL |
|
225 // --------------------------------------------------------- |
|
226 // |
|
227 void CMailCpsHandler::UpdateMailboxNameL( const TInt aMailBoxNumber, |
|
228 const TInt aWidgetInstance, |
|
229 const TInt aRowNumber ) |
|
230 { |
|
231 FUNC_LOG; |
|
232 TFSMailMsgId mailBoxId; |
|
233 TFSMailMsgId folderId; |
|
234 TBool mailBoxFound(EFalse); |
|
235 if ( aMailBoxNumber < iAccountsArray.Count() ) |
|
236 { |
|
237 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
|
238 CFSMailBox* mailbox( NULL ); |
|
239 mailbox = MailClient().GetMailBoxByUidL( mailBoxId ); |
|
240 |
|
241 if(mailbox) |
|
242 { |
|
243 mailBoxFound = ETrue; |
|
244 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) ); |
|
245 delete mailbox; |
|
246 |
|
247 TBuf<KMaxDescLen> accountName; |
|
248 accountName.Append(*iAccountsArray[aMailBoxNumber]->iMailboxName); |
|
249 |
|
250 TInt unreadCount(GetUnreadCountL(iAccountsArray[aMailBoxNumber]->iMailboxId)); |
|
251 if ( unreadCount > 0 ) |
|
252 { |
|
253 // Use localisation format when displaying also unread messages |
|
254 |
|
255 // Arrays must be used when loc string contains indexed parameters |
|
256 CDesCArrayFlat* strings = new CDesCArrayFlat( 1 ); |
|
257 CleanupStack::PushL( strings ); |
|
258 strings->AppendL( accountName ); // replace "%0U" with mailbox name |
|
259 |
|
260 CArrayFix<TInt>* ints = new(ELeave) CArrayFixFlat<TInt>( 1 ); |
|
261 CleanupStack::PushL( ints ); |
|
262 ints->AppendL( unreadCount ); // replace "%1N" with number of unread messages |
|
263 |
|
264 HBufC* mailboxAndCount = StringLoader::LoadLC( R_EMAILWIDGET_TEXT_MAILBOX_AND_MAILCOUNT, |
|
265 *strings, |
|
266 *ints ); |
|
267 |
|
268 iLiwIf->PublishActiveMailboxNameL( |
|
269 aWidgetInstance, |
|
270 aRowNumber, *mailboxAndCount, |
|
271 iAccountsArray.Count(), |
|
272 mailBoxId, folderId); |
|
273 |
|
274 CleanupStack::PopAndDestroy(mailboxAndCount); |
|
275 CleanupStack::PopAndDestroy(ints); |
|
276 CleanupStack::PopAndDestroy(strings); |
|
277 } |
|
278 else |
|
279 { |
|
280 // show only mailbox name |
|
281 |
|
282 iLiwIf->PublishActiveMailboxNameL( |
|
283 aWidgetInstance, |
|
284 aRowNumber, accountName, |
|
285 iAccountsArray.Count(), |
|
286 mailBoxId, folderId); |
|
287 } |
|
288 } |
|
289 } |
|
290 else if(!mailBoxFound) |
|
291 { |
|
292 // Publishing empty descriptor for rows that should not contain |
|
293 // anything on widget UI. |
|
294 iLiwIf->PublishActiveMailboxNameL( aWidgetInstance, |
|
295 aRowNumber, |
|
296 KNullDesC, |
|
297 NULL, |
|
298 mailBoxId, |
|
299 folderId ); |
|
300 } |
|
301 } |
|
302 |
|
303 |
|
304 // --------------------------------------------------------- |
|
305 // CMailCpsHandler::UpdateMessagesL |
|
306 // --------------------------------------------------------- |
|
307 // |
|
308 void CMailCpsHandler::UpdateMessagesL( const TInt aMailBoxNumber, |
|
309 const TInt aWidgetInstance, |
|
310 const TInt aMessageNumber, |
|
311 const TInt aRow ) |
|
312 { |
|
313 FUNC_LOG; |
|
314 |
|
315 TBool mailBoxFound(EFalse); |
|
316 if ( aMailBoxNumber < iAccountsArray.Count() ) |
|
317 { |
|
318 TFSMailMsgId mailBoxId; |
|
319 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
|
320 |
|
321 CFSMailBox* mailbox( NULL ); |
|
322 mailbox = MailClient().GetMailBoxByUidL( mailBoxId ); |
|
323 if(mailbox) |
|
324 { |
|
325 mailBoxFound = ETrue; |
|
326 TFSMailMsgId parentFolder( mailbox->GetStandardFolderId( EFSInbox ) ); |
|
327 // Check that folder is correct |
|
328 CFSMailFolder* folder = MailClient().GetFolderByUidL( mailBoxId, parentFolder ); |
|
329 if ( !folder ) |
|
330 { |
|
331 return; |
|
332 } |
|
333 CleanupStack::PushL( folder ); |
|
334 |
|
335 TInt msgCount = folder->GetMessageCount(); |
|
336 if(msgCount<1) |
|
337 { |
|
338 UpdateEmptyMessagesL( aWidgetInstance, aRow ); |
|
339 CleanupStack::PopAndDestroy( folder ); |
|
340 return; |
|
341 } |
|
342 |
|
343 folder->SetFolderType(EFSInbox); |
|
344 |
|
345 // Update folder if provided, otherwise use current folder |
|
346 RPointerArray<CFSMailMessage> folderMessages(1); |
|
347 CleanupClosePushL( folderMessages ); |
|
348 |
|
349 TFSMailDetails details( EFSMsgDataEnvelope ); |
|
350 RArray<TFSMailSortCriteria> sorting; |
|
351 CleanupClosePushL( sorting ); |
|
352 |
|
353 TFSMailSortCriteria sortCriteria; |
|
354 sortCriteria.iField = EFSMailSortByDate; |
|
355 sortCriteria.iOrder = EFSMailDescending; |
|
356 sorting.Append( sortCriteria ); |
|
357 // List all or maximum number of messages |
|
358 MFSMailIterator* iterator = folder->ListMessagesL( details, sorting ); |
|
359 CleanupDeletePushL( iterator ); // standard CleanupStack::PushL does not work with non-C-class pointer |
|
360 |
|
361 TFSMailMsgId dummy; |
|
362 iterator->NextL( dummy, aMessageNumber, folderMessages); |
|
363 TInt count (folderMessages.Count()); |
|
364 if(!count) |
|
365 { |
|
366 UpdateEmptyMessagesL( aWidgetInstance, aRow ); |
|
367 |
|
368 CleanupStack::PopAndDestroy( iterator ); |
|
369 CleanupStack::PopAndDestroy( &sorting ); |
|
370 CleanupStack::PopAndDestroy( &folderMessages ); |
|
371 CleanupStack::PopAndDestroy( folder ); |
|
372 |
|
373 return; |
|
374 } |
|
375 TFSMailMsgId msgId = folderMessages[aMessageNumber - 1]->GetMessageId(); |
|
376 |
|
377 CFSMailMessage* msg( NULL ); |
|
378 msg = MailClient().GetMessageByUidL( mailBoxId, parentFolder, msgId, EFSMsgDataEnvelope ); |
|
379 CleanupDeletePushL( msg ); |
|
380 |
|
381 // Get sender information |
|
382 TBuf<KMaxDescLen> sender( NULL ); |
|
383 CFSMailAddress* fromAddress = msg->GetSender(); |
|
384 if ( fromAddress ) |
|
385 { |
|
386 if ( IsValidDisplayName(fromAddress->GetDisplayName()) ) |
|
387 { |
|
388 sender.Append(fromAddress->GetDisplayName()); |
|
389 } |
|
390 else |
|
391 { |
|
392 sender.Append(fromAddress->GetEmailAddress()); |
|
393 } |
|
394 } |
|
395 |
|
396 // Get message time and format it correctly |
|
397 TTime msgTime = msg->GetDate(); |
|
398 HBufC* timeString( NULL ); |
|
399 timeString = GetMessageTimeStringL( msgTime ); |
|
400 CleanupDeletePushL( timeString ); |
|
401 |
|
402 // Publish message details |
|
403 PublishMessageL( aWidgetInstance, |
|
404 *msg, |
|
405 sender, |
|
406 *timeString, |
|
407 aRow ); |
|
408 |
|
409 CleanupStack::PopAndDestroy( timeString ); |
|
410 CleanupStack::PopAndDestroy( msg ); |
|
411 CleanupStack::PopAndDestroy( iterator ); |
|
412 CleanupStack::PopAndDestroy( &sorting ); |
|
413 CleanupStack::PopAndDestroy( &folderMessages ); |
|
414 CleanupStack::PopAndDestroy( folder ); |
|
415 } |
|
416 } |
|
417 else if(!mailBoxFound) |
|
418 { |
|
419 UpdateEmptyMessagesL( aWidgetInstance, aRow ); |
|
420 } |
|
421 } |
|
422 |
|
423 |
|
424 // --------------------------------------------------------- |
|
425 // CMailCpsHandler::GetMessageTimeStringL |
|
426 // --------------------------------------------------------- |
|
427 // |
|
428 HBufC* CMailCpsHandler::GetMessageTimeStringL( TTime aMessageTime ) |
|
429 { |
|
430 FUNC_LOG; |
|
431 |
|
432 // Get current local time |
|
433 TTime currentTime; |
|
434 currentTime.HomeTime(); |
|
435 |
|
436 // Get universal time offset and add it to message time |
|
437 TLocale locale; |
|
438 TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() ); |
|
439 aMessageTime += universalTimeOffset; |
|
440 |
|
441 // If daylight saving is on, add one hour offset to message time |
|
442 if ( locale.QueryHomeHasDaylightSavingOn() ) |
|
443 { |
|
444 TTimeIntervalHours daylightSaving( 1 ); |
|
445 aMessageTime += daylightSaving; |
|
446 } |
|
447 |
|
448 // Get datetime objects and compare dates |
|
449 TDateTime currentDate = currentTime.DateTime(); |
|
450 TDateTime messageDate = aMessageTime.DateTime(); |
|
451 HBufC* formatString( NULL ); |
|
452 |
|
453 if ( currentDate.Year() == messageDate.Year() |
|
454 && currentDate.Month() == messageDate.Month() |
|
455 && currentDate.Day() == messageDate.Day()) |
|
456 { |
|
457 // Message arrived today |
|
458 formatString = StringLoader::LoadLC( R_QTN_TIME_USUAL_WITH_ZERO ); |
|
459 } |
|
460 else |
|
461 { |
|
462 // Message arrived earlier than today |
|
463 formatString = StringLoader::LoadLC( R_QTN_DATE_WITHOUT_YEAR_WITH_ZERO ); |
|
464 } |
|
465 |
|
466 // Format time string using chosen time or date formatString |
|
467 TBuf<KMaxShortDateFormatSpec*2> timeString; |
|
468 TRAP_IGNORE( aMessageTime.FormatL( timeString, formatString->Des() ) ); |
|
469 CleanupStack::PopAndDestroy( formatString ); |
|
470 // If format fails, result is empty |
|
471 |
|
472 HBufC* result = timeString.Alloc(); |
|
473 TPtr ptr = result->Des(); |
|
474 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
475 return result; |
|
476 } |
|
477 |
|
478 |
|
479 // --------------------------------------------------------- |
|
480 // CMailCpsHandler::PublishMessageL |
|
481 // |
|
482 // --------------------------------------------------------- |
|
483 // |
|
484 void CMailCpsHandler::PublishMessageL( TInt aWidgetInstance, CFSMailMessage& aMessage, |
|
485 const TDesC& aSenderName, const TDesC& aTime, TInt aRow ) |
|
486 { |
|
487 FUNC_LOG; |
|
488 |
|
489 TFSMailMsgId msgId( aMessage.GetMessageId() ); |
|
490 |
|
491 iLiwIf->PublishMailboxIconL( aWidgetInstance, aRow, GetMailIcon( &aMessage ), msgId ); |
|
492 iLiwIf->PublishMailDetailL( aWidgetInstance, aRow, aSenderName, ESender ); |
|
493 iLiwIf->PublishMailDetailL( aWidgetInstance, aRow, aTime, ETime ); |
|
494 } |
|
495 |
|
496 // --------------------------------------------------------- |
|
497 // CMailCpsHandler::UpdateEmptyMessagesL |
|
498 // |
|
499 // --------------------------------------------------------- |
|
500 // |
|
501 void CMailCpsHandler::UpdateEmptyMessagesL( const TInt aWidgetInstance, |
|
502 const TInt aRow ) |
|
503 { |
|
504 FUNC_LOG; |
|
505 |
|
506 TFSMailMsgId mailBoxId; // id not essential here |
|
507 |
|
508 iLiwIf->PublishMailDetailL( |
|
509 aWidgetInstance, |
|
510 aRow, |
|
511 KNullDes, |
|
512 ESender); |
|
513 |
|
514 iLiwIf->PublishMailboxIconL( |
|
515 aWidgetInstance, |
|
516 aRow, |
|
517 KNullIcon, |
|
518 mailBoxId); |
|
519 |
|
520 iLiwIf->PublishMailDetailL( |
|
521 aWidgetInstance, |
|
522 aRow, |
|
523 KNullDes, |
|
524 ETime); |
|
525 } |
|
526 /* |
|
527 // --------------------------------------------------------- |
|
528 // CMailCpsHandler::UpdateConnectStateL |
|
529 // --------------------------------------------------------- |
|
530 // |
|
531 void CMailCpsHandler::UpdateConnectStateL( const TInt aMailBoxNumber, const TInt aRowNumber ) |
|
532 { |
|
533 FUNC_LOG; |
|
534 if ( aMailBoxNumber < iAccountsArray.Count() ) |
|
535 { |
|
536 TFSMailMsgId mailBoxId; |
|
537 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
|
538 CFSMailBox* mailbox( NULL ); |
|
539 mailbox = MailClient().GetMailBoxByUidL( mailBoxId ); |
|
540 if(mailbox) |
|
541 { |
|
542 iLiwIf->PublishConnectIconL(mailbox->GetMailBoxStatus(), aRowNumber); |
|
543 } |
|
544 } |
|
545 else |
|
546 { |
|
547 iLiwIf->PublishConnectIconL( EFSMailBoxOffline, aRowNumber ); |
|
548 } |
|
549 } |
|
550 */ |
|
551 // --------------------------------------------------------- |
|
552 // CMailCpsHandler::UpdateMailBoxIconL |
|
553 // --------------------------------------------------------- |
|
554 // |
|
555 void CMailCpsHandler::UpdateMailBoxIconL( const TInt aMailBoxNumber, |
|
556 const TInt aWidgetInstance, |
|
557 const TInt aRowNumber ) |
|
558 { |
|
559 FUNC_LOG; |
|
560 |
|
561 TFSMailMsgId mailBoxId; // id required only for getting branded mailbox icon |
|
562 |
|
563 if ( aMailBoxNumber < iAccountsArray.Count() ) |
|
564 { |
|
565 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
|
566 iLiwIf->PublishMailboxIconL( aWidgetInstance, |
|
567 aRowNumber, |
|
568 EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account, |
|
569 mailBoxId); |
|
570 } |
|
571 else |
|
572 { |
|
573 iLiwIf->PublishMailboxIconL( aWidgetInstance, aRowNumber, KNullIcon, mailBoxId); |
|
574 } |
|
575 } |
|
576 |
|
577 // --------------------------------------------------------- |
|
578 // CMailCpsHandler::UpdateIndicatorIconL |
|
579 // --------------------------------------------------------- |
|
580 // |
|
581 void CMailCpsHandler::UpdateIndicatorIconL( const TInt aMailBoxNumber, |
|
582 const TInt aWidgetInstance, |
|
583 const TInt aRowNumber ) |
|
584 |
|
585 { |
|
586 FUNC_LOG; |
|
587 |
|
588 if ( aMailBoxNumber < iAccountsArray.Count() ) |
|
589 { |
|
590 TFSMailMsgId mailBoxId; |
|
591 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
|
592 |
|
593 if ( GetUnseenCountL(mailBoxId) > 0 ) |
|
594 { |
|
595 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
|
596 aRowNumber, |
|
597 EMbmCmailhandlerpluginQgn_indi_ai_eplg_unread ); |
|
598 } |
|
599 |
|
600 else if( !IsOutboxEmptyL(mailBoxId) ) |
|
601 { |
|
602 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
|
603 aRowNumber, |
|
604 EMbmCmailhandlerpluginQgn_prop_mce_outbox_small); |
|
605 } |
|
606 else |
|
607 { |
|
608 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
|
609 aRowNumber, |
|
610 KNullIcon); |
|
611 } |
|
612 } |
|
613 else |
|
614 { |
|
615 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
|
616 aRowNumber, |
|
617 KNullIcon); |
|
618 } |
|
619 } |
|
620 |
|
621 /* |
|
622 // --------------------------------------------------------- |
|
623 // CMailCpsHandler::ClearMessageTimeL |
|
624 // --------------------------------------------------------- |
|
625 // |
|
626 void CMailCpsHandler::ClearMessageTimeL( const TInt aRowNumber ) |
|
627 { |
|
628 FUNC_LOG; |
|
629 |
|
630 iLiwIf->PublishMailDetailL( |
|
631 aRowNumber, |
|
632 KNullDes, |
|
633 ETime); |
|
634 } |
|
635 */ |
|
636 |
|
637 // --------------------------------------------------------- |
|
638 // CMailCpsHandler::CapabilitiesToContinueL |
|
639 // --------------------------------------------------------- |
|
640 // |
|
641 TBool CMailCpsHandler::CapabilitiesToContinueL( |
|
642 TFSMailEvent /*aEvent*/, |
|
643 TFSMailMsgId /*aMailbox*/, |
|
644 TAny* /*aParam1*/, |
|
645 TAny* /*aParam2*/, |
|
646 TAny* /*aParam3*/ ) const |
|
647 { |
|
648 FUNC_LOG; |
|
649 // Inherited from baseclass, not used |
|
650 return ETrue; |
|
651 } |
|
652 |
|
653 // --------------------------------------------------------- |
|
654 // CMailCpsHandler::FindMailboxDetails |
|
655 // --------------------------------------------------------- |
|
656 // |
|
657 CMailMailboxDetails* CMailCpsHandler::FindMailboxDetails( TFSMailMsgId aMailbox ) |
|
658 { |
|
659 FUNC_LOG; |
|
660 const TInt iiMax( iAccountsArray.Count() ); |
|
661 for ( TInt ii = 0; ii < iiMax; ii++ ) |
|
662 { |
|
663 if ( iAccountsArray[ii]->iMailboxId == aMailbox ) |
|
664 { |
|
665 return iAccountsArray[ii]; |
|
666 } |
|
667 } |
|
668 // mailbox id not found from local cache, returning NULL |
|
669 return NULL; |
|
670 } |
|
671 |
|
672 // --------------------------------------------------------- |
|
673 // CMailCpsHandler::HandleEventL |
|
674 // --------------------------------------------------------- |
|
675 // |
|
676 void CMailCpsHandler::HandleEventL( |
|
677 TFSMailEvent aEvent, |
|
678 TFSMailMsgId aMailbox, |
|
679 TAny* aParam1, |
|
680 TAny* aParam2, |
|
681 TAny* /*aParam3*/ ) |
|
682 { |
|
683 FUNC_LOG; |
|
684 |
|
685 // Is the mailbox in our list |
|
686 switch ( aEvent ) |
|
687 { |
|
688 case TFSEventNewMailbox: |
|
689 { |
|
690 // HandleNewMailboxEventL( aMailbox ); |
|
691 break; |
|
692 } |
|
693 case TFSEventMailboxDeleted: |
|
694 { |
|
695 HandleMailboxDeletedEventL( aMailbox ); |
|
696 break; |
|
697 } |
|
698 case TFSEventMailboxSettingsChanged: |
|
699 { |
|
700 // HandleMailboxDeletedEventL( aMailbox ); |
|
701 // HandleNewMailboxEventL( aMailbox ); |
|
702 break; |
|
703 } |
|
704 case TFSEventNewMail: |
|
705 { |
|
706 HandleNewMailEventL( aMailbox, aParam1, aParam2 ); |
|
707 break; |
|
708 } |
|
709 case TFSEventMailDeleted: |
|
710 { |
|
711 HandleMailDeletedEventL( aMailbox, aParam1, aParam2 ); |
|
712 break; |
|
713 } |
|
714 case TFSEventMailChanged: |
|
715 { |
|
716 HandleMailChangedEventL( aMailbox, aParam1, aParam2 ); |
|
717 break; |
|
718 } |
|
719 case TFSEventNewFolder: |
|
720 { |
|
721 HandleNewFolderEventL( aMailbox, aParam1, aParam2 ); |
|
722 break; |
|
723 } |
|
724 default: |
|
725 { |
|
726 break; |
|
727 } |
|
728 } |
|
729 UpdateFullL(); |
|
730 } |
|
731 |
|
732 // --------------------------------------------------------- |
|
733 // CMailCpsHandler::HandleNewMailboxEventL |
|
734 // --------------------------------------------------------- |
|
735 // |
|
736 void CMailCpsHandler::HandleNewMailboxEventL( const TFSMailMsgId aMailbox ) |
|
737 { |
|
738 FUNC_LOG; |
|
739 |
|
740 // Check that max mailbox count is not already reached |
|
741 const TInt iiMax( iAccountsArray.Count() ); |
|
742 if( iiMax >= iSettings->MaxMailboxCount() ) |
|
743 { |
|
744 return; |
|
745 } |
|
746 |
|
747 // Check that mailbox is not already in widget |
|
748 for ( TInt ii = 0; ii < iiMax; ii++ ) |
|
749 { |
|
750 if( iAccountsArray[ii]->iMailboxId.Id() == aMailbox.Id() ) |
|
751 { |
|
752 return; |
|
753 } |
|
754 } |
|
755 |
|
756 CFSMailBox* mailbox( NULL ); |
|
757 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
|
758 if ( !mailbox ) |
|
759 { |
|
760 return; // nothing that could be done |
|
761 } |
|
762 else |
|
763 { |
|
764 CleanupStack::PushL( mailbox ); |
|
765 CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox ); |
|
766 CleanupStack::PushL( mailboxDetails ); |
|
767 iAccountsArray.AppendL( mailboxDetails ); |
|
768 CleanupStack::Pop( mailboxDetails ); |
|
769 CleanupStack::PopAndDestroy( mailbox ); |
|
770 } |
|
771 |
|
772 iSettings->AddMailboxL( aMailbox ); |
|
773 } |
|
774 |
|
775 // --------------------------------------------------------- |
|
776 // CMailCpsHandler::HandleMailboxDeletedEventL |
|
777 // --------------------------------------------------------- |
|
778 // |
|
779 void CMailCpsHandler::HandleMailboxDeletedEventL( const TFSMailMsgId aMailbox ) |
|
780 { |
|
781 FUNC_LOG; |
|
782 |
|
783 // Look from local cache |
|
784 const TInt iiMax( iAccountsArray.Count() ); |
|
785 for ( TInt ii = 0; ii < iiMax; ii++ ) |
|
786 { |
|
787 if( iAccountsArray[ii]->iMailboxId.Id() == aMailbox.Id() ) |
|
788 { |
|
789 CMailMailboxDetails* tmp = iAccountsArray[ii]; |
|
790 iAccountsArray.Remove( ii ); |
|
791 delete tmp; |
|
792 tmp = NULL; |
|
793 |
|
794 // Remove from cenrep |
|
795 iSettings->RemoveMailboxL( aMailbox ); |
|
796 break; |
|
797 } |
|
798 } |
|
799 } |
|
800 |
|
801 // --------------------------------------------------------- |
|
802 // CMailCpsHandler::HandleNewMailEventL |
|
803 // --------------------------------------------------------- |
|
804 // |
|
805 void CMailCpsHandler::HandleNewMailEventL( |
|
806 TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2 ) |
|
807 { |
|
808 FUNC_LOG; |
|
809 // Basic assertions |
|
810 if ( !aParam1 || !aParam2 ) |
|
811 { |
|
812 User::Leave( KErrArgument ); |
|
813 } |
|
814 |
|
815 // Find mailbox instance from array |
|
816 CMailMailboxDetails* mailbox = FindMailboxDetails( aMailbox ); |
|
817 if ( !mailbox ) |
|
818 { |
|
819 return; |
|
820 } |
|
821 |
|
822 // typecast param2 |
|
823 TFSMailMsgId* parentFolder = static_cast<TFSMailMsgId*>( aParam2 ); |
|
824 |
|
825 // Check that folder is correct |
|
826 CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, *parentFolder ); |
|
827 if ( !folder ) |
|
828 { |
|
829 User::Leave( KErrNotFound ); |
|
830 } |
|
831 CleanupStack::PushL( folder ); |
|
832 if ( folder->GetFolderType() != EFSInbox ) |
|
833 { |
|
834 CleanupStack::PopAndDestroy( folder ); |
|
835 return; |
|
836 } |
|
837 CleanupStack::PopAndDestroy( folder ); |
|
838 |
|
839 // typecast param1 |
|
840 RArray<TFSMailMsgId>* newEntries( |
|
841 static_cast< RArray<TFSMailMsgId>* >( aParam1 ) ); |
|
842 CleanupClosePushL( *newEntries ); |
|
843 const TInt iiMax( newEntries->Count() ); |
|
844 if ( iiMax == 0 ) |
|
845 { |
|
846 User::Leave( KErrArgument ); |
|
847 } |
|
848 |
|
849 // Loop through message array |
|
850 TFSMailMsgId msgId; |
|
851 CFSMailMessage* msg( NULL ); |
|
852 for ( TInt ii = 0; ii < iiMax; ii++ ) |
|
853 { |
|
854 msgId = (*newEntries)[ii]; |
|
855 |
|
856 msg = MailClient().GetMessageByUidL( |
|
857 aMailbox, *parentFolder, (*newEntries)[ii], EFSMsgDataEnvelope ); |
|
858 if ( !msg ) |
|
859 { |
|
860 User::Leave( KErrNotFound ); |
|
861 } |
|
862 CleanupStack::PushL( msg ); |
|
863 |
|
864 // Check if message read |
|
865 if ( !MsgIsUnread( *msg ) ) |
|
866 { |
|
867 // Ignore already read messages |
|
868 CleanupStack::PopAndDestroy( msg ); |
|
869 continue; |
|
870 } |
|
871 |
|
872 // Check if message is duplicate |
|
873 if ( IsDuplicate( *mailbox, msgId ) ) |
|
874 { |
|
875 // Ignore already known messages |
|
876 CleanupStack::PopAndDestroy( msg ); |
|
877 continue; |
|
878 } |
|
879 |
|
880 CMailMessageDetails* messageDetails = CMailMessageDetails::NewL( |
|
881 msg->GetMessageId(), |
|
882 mailbox, |
|
883 msg->GetSender()->GetEmailAddress(), |
|
884 msg->GetSubject(), |
|
885 msg->GetDate() ); |
|
886 CleanupStack::PopAndDestroy( msg ); |
|
887 CleanupStack::PushL( messageDetails ); |
|
888 |
|
889 // Place message to array |
|
890 mailbox->iMessageDetailsArray.AppendL( messageDetails ); |
|
891 CleanupStack::Pop( messageDetails ); |
|
892 } |
|
893 CleanupStack::PopAndDestroy( newEntries ); |
|
894 } |
|
895 |
|
896 // --------------------------------------------------------- |
|
897 // CMailCpsHandler::HandleMailDeletedEventL |
|
898 // --------------------------------------------------------- |
|
899 // |
|
900 void CMailCpsHandler::HandleMailDeletedEventL( |
|
901 TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2 ) |
|
902 { |
|
903 FUNC_LOG; |
|
904 // Basic assertions |
|
905 if ( !aParam1 || !aParam2 ) |
|
906 { |
|
907 User::Leave( KErrArgument ); |
|
908 } |
|
909 // Typecast parameters |
|
910 RArray<TFSMailMsgId>* entries( |
|
911 static_cast< RArray<TFSMailMsgId>* >( aParam1 ) ); |
|
912 CleanupClosePushL( *entries ); |
|
913 if ( entries->Count() == 0 ) |
|
914 { |
|
915 User::Leave( KErrArgument ); |
|
916 } |
|
917 |
|
918 // Find correct mailbox |
|
919 CMailMailboxDetails* mailbox = FindMailboxDetails( aMailbox ); |
|
920 if ( !mailbox ) |
|
921 { |
|
922 //<Cmail> |
|
923 CleanupStack::PopAndDestroy( entries ); |
|
924 //<Cmail> |
|
925 return; |
|
926 } |
|
927 |
|
928 const TInt iiMax( entries->Count() ); |
|
929 const TInt jjMax( mailbox->iMessageDetailsArray.Count() ); |
|
930 // Loop through entries in the array |
|
931 for ( TInt ii = 0; ii < iiMax; ii++ ) |
|
932 { |
|
933 // Loop through messages in the local cache |
|
934 for ( TInt jj = 0; jj < jjMax; jj++ ) |
|
935 { |
|
936 if ( mailbox->iMessageDetailsArray[jj]->iMsgId.Id() == |
|
937 (*entries)[ii].Id() ) |
|
938 { |
|
939 CMailMessageDetails* details = mailbox->iMessageDetailsArray[jj]; |
|
940 delete details; |
|
941 details = NULL; |
|
942 mailbox->iMessageDetailsArray.Remove(jj); |
|
943 break; // breaks out from the inner loop and starts new outer loop if necessary |
|
944 } |
|
945 else |
|
946 { |
|
947 } |
|
948 } |
|
949 } |
|
950 |
|
951 CleanupStack::PopAndDestroy( entries ); |
|
952 } |
|
953 |
|
954 // --------------------------------------------------------- |
|
955 // CMailCpsHandler::HandleMailChangedEventL |
|
956 // --------------------------------------------------------- |
|
957 // |
|
958 void CMailCpsHandler::HandleMailChangedEventL( |
|
959 TFSMailMsgId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/ ) |
|
960 { |
|
961 FUNC_LOG; |
|
962 } |
|
963 |
|
964 // --------------------------------------------------------- |
|
965 // CMailCpsHandler::HandleNewFolderEventL |
|
966 // --------------------------------------------------------- |
|
967 // |
|
968 void CMailCpsHandler::HandleNewFolderEventL( |
|
969 TFSMailMsgId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/ ) |
|
970 { |
|
971 FUNC_LOG; |
|
972 } |
|
973 |
|
974 // --------------------------------------------------------- |
|
975 // CMailCpsHandler::GetUnreadCountL |
|
976 // --------------------------------------------------------- |
|
977 // |
|
978 TInt CMailCpsHandler::GetUnreadCountL(TFSMailMsgId aMailbox) |
|
979 { |
|
980 FUNC_LOG; |
|
981 CFSMailBox* mailbox( NULL ); |
|
982 TInt unread (0); |
|
983 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
|
984 if(mailbox) |
|
985 { |
|
986 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) ); |
|
987 // Check that folder is correct |
|
988 CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId ); |
|
989 if ( !folder ) |
|
990 { |
|
991 return KErrNotFound; |
|
992 } |
|
993 CleanupStack::PushL( folder ); |
|
994 |
|
995 unread = folder->GetUnreadCount(); |
|
996 |
|
997 CleanupStack::PopAndDestroy( folder ); |
|
998 |
|
999 if (unread > KMaxUnreadCount) |
|
1000 { |
|
1001 unread = KMaxUnreadCount; |
|
1002 } |
|
1003 } |
|
1004 |
|
1005 return unread; |
|
1006 } |
|
1007 |
|
1008 // --------------------------------------------------------- |
|
1009 // CMailCpsHandler::GetUnseenCountL |
|
1010 // --------------------------------------------------------- |
|
1011 // |
|
1012 TInt CMailCpsHandler::GetUnseenCountL(TFSMailMsgId aMailbox) |
|
1013 { |
|
1014 FUNC_LOG; |
|
1015 CFSMailBox* mailbox( NULL ); |
|
1016 TInt unseen (0); |
|
1017 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
|
1018 if(mailbox) |
|
1019 { |
|
1020 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) ); |
|
1021 // Check that folder is correct |
|
1022 CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId ); |
|
1023 if ( !folder ) |
|
1024 { |
|
1025 return KErrNotFound; |
|
1026 } |
|
1027 CleanupStack::PushL( folder ); |
|
1028 |
|
1029 unseen = folder->GetUnseenCount(); |
|
1030 |
|
1031 CleanupStack::PopAndDestroy( folder ); |
|
1032 |
|
1033 if (unseen > KMaxUnreadCount) |
|
1034 { |
|
1035 unseen = KMaxUnreadCount; |
|
1036 } |
|
1037 } |
|
1038 |
|
1039 return unseen; |
|
1040 } |
|
1041 |
|
1042 // --------------------------------------------------------- |
|
1043 // CMailCpsHandler::IsOutboxEmptyL |
|
1044 // --------------------------------------------------------- |
|
1045 // |
|
1046 TBool CMailCpsHandler::IsOutboxEmptyL(TFSMailMsgId aMailbox) |
|
1047 { |
|
1048 FUNC_LOG; |
|
1049 CFSMailBox* mailbox( NULL ); |
|
1050 TBool ret(ETrue); |
|
1051 TInt msgCount(0); |
|
1052 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
|
1053 if(mailbox) |
|
1054 { |
|
1055 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSOutbox ) ); |
|
1056 // Check that folder is correct |
|
1057 CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId ); |
|
1058 if ( !folder ) |
|
1059 { |
|
1060 return KErrNotFound; |
|
1061 } |
|
1062 CleanupStack::PushL( folder ); |
|
1063 |
|
1064 msgCount = folder->GetMessageCount(); |
|
1065 |
|
1066 if ( msgCount<1 ) |
|
1067 { |
|
1068 CleanupStack::PopAndDestroy( folder ); |
|
1069 return ret; |
|
1070 } |
|
1071 |
|
1072 TFSMailDetails details( EFSMsgDataEnvelope ); |
|
1073 RArray<TFSMailSortCriteria> sorting; |
|
1074 CleanupClosePushL( sorting ); |
|
1075 TFSMailSortCriteria sortCriteria; |
|
1076 sortCriteria.iField = EFSMailDontCare; |
|
1077 sortCriteria.iOrder = EFSMailDescending; |
|
1078 sorting.Append( sortCriteria ); |
|
1079 // List all or maximum number of messages |
|
1080 MFSMailIterator* iterator = folder->ListMessagesL( details, sorting ); |
|
1081 CleanupStack::PopAndDestroy( &sorting ); |
|
1082 CleanupDeletePushL( iterator ); |
|
1083 |
|
1084 RPointerArray<CFSMailMessage> messages; |
|
1085 CleanupClosePushL( messages ); |
|
1086 TInt amount( msgCount ); |
|
1087 iterator->NextL( TFSMailMsgId(), amount, messages ); |
|
1088 |
|
1089 for (TInt i = 0; i < msgCount; i++) |
|
1090 { |
|
1091 TFSMailMsgId msgId = messages[0]->GetMessageId(); |
|
1092 CFSMailMessage* msg( NULL ); |
|
1093 msg = MailClient().GetMessageByUidL( aMailbox, folderId, msgId, EFSMsgDataEnvelope ); |
|
1094 CleanupDeletePushL( msg ); |
|
1095 TFSMailMsgId mailboxId = msg->GetMailBoxId(); |
|
1096 CleanupStack::PopAndDestroy( msg ); |
|
1097 |
|
1098 if (mailboxId == aMailbox) |
|
1099 { |
|
1100 ret = EFalse; |
|
1101 break; |
|
1102 } |
|
1103 } |
|
1104 |
|
1105 CleanupStack::PopAndDestroy( &messages ); |
|
1106 CleanupStack::PopAndDestroy( iterator ); |
|
1107 CleanupStack::PopAndDestroy( folder ); |
|
1108 } |
|
1109 |
|
1110 return ret; |
|
1111 } |
|
1112 |
|
1113 // --------------------------------------------------------- |
|
1114 // CMailCpsHandler::TurnNotificationOn |
|
1115 // --------------------------------------------------------- |
|
1116 // |
|
1117 void CMailCpsHandler::TurnNotificationOn() |
|
1118 { |
|
1119 FUNC_LOG; |
|
1120 } |
|
1121 |
|
1122 // --------------------------------------------------------- |
|
1123 // CMailCpsHandler::TurnNotificationOff |
|
1124 // --------------------------------------------------------- |
|
1125 // |
|
1126 void CMailCpsHandler::TurnNotificationOff() |
|
1127 { |
|
1128 FUNC_LOG; |
|
1129 } |
|
1130 |
|
1131 // --------------------------------------------------------------------------- |
|
1132 // CMailCpsHandler::GetMailIcon |
|
1133 // --------------------------------------------------------------------------- |
|
1134 // |
|
1135 TInt CMailCpsHandler::GetMailIcon( CFSMailMessage* aMsg ) |
|
1136 { |
|
1137 FUNC_LOG; |
|
1138 TInt ret(EMbmCmailhandlerpluginQgn_indi_cmail_unread); |
|
1139 if (aMsg->IsFlagSet( EFSMsgFlag_Read )) |
|
1140 { |
|
1141 ret = GetReadMsgIcon(aMsg); |
|
1142 } |
|
1143 else |
|
1144 { |
|
1145 ret = GetUnreadMsgIcon(aMsg); |
|
1146 } |
|
1147 |
|
1148 return ret; |
|
1149 } |
|
1150 |
|
1151 // ----------------------------------------------------------------------------- |
|
1152 // CMailCpsHandler::GetUnreadMsgIcon |
|
1153 // ----------------------------------------------------------------------------- |
|
1154 TInt CMailCpsHandler::GetUnreadMsgIcon( CFSMailMessage* aMsg ) |
|
1155 { |
|
1156 FUNC_LOG; |
|
1157 TInt icon(EMbmCmailhandlerpluginQgn_indi_cmail_unread); |
|
1158 |
|
1159 // Unread calendar invitation |
|
1160 if ( aMsg->IsFlagSet( EFSMsgFlag_CalendarMsg )) |
|
1161 { |
|
1162 icon = GetUnreadCalMsgIcon( aMsg ); |
|
1163 } |
|
1164 else // Normal message icons |
|
1165 { |
|
1166 // Check whether msg has attachment or not |
|
1167 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments )) // Has attachments |
|
1168 { |
|
1169 if ( aMsg->IsFlagSet( EFSMsgFlag_Important )) // High priority, has attachments |
|
1170 { |
|
1171 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1172 { |
|
1173 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_replied_attach_high_prio; |
|
1174 } |
|
1175 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1176 { |
|
1177 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_forwarded_attach_high_prio; |
|
1178 } |
|
1179 else |
|
1180 { |
|
1181 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_attach_high_prio; |
|
1182 } |
|
1183 } |
|
1184 else if ( aMsg->IsFlagSet( EFSMsgFlag_Low ) ) // Low priority, has attachments |
|
1185 { |
|
1186 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1187 { |
|
1188 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_replied_attach_low_prio; |
|
1189 } |
|
1190 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1191 { |
|
1192 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_forwarded_attach_low_prio; |
|
1193 } |
|
1194 else |
|
1195 { |
|
1196 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_attach_low_prio; |
|
1197 } |
|
1198 } |
|
1199 else // Normal priority, has attachments |
|
1200 { |
|
1201 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1202 { |
|
1203 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_replied_attach; |
|
1204 } |
|
1205 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1206 { |
|
1207 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_forwarded_attach; |
|
1208 } |
|
1209 else |
|
1210 { |
|
1211 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_attach; |
|
1212 } |
|
1213 } |
|
1214 } |
|
1215 |
|
1216 else // No attachments |
|
1217 { |
|
1218 if ( aMsg->IsFlagSet( EFSMsgFlag_Important )) // High priority, no attachments |
|
1219 { |
|
1220 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1221 { |
|
1222 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_replied_high_prio; |
|
1223 } |
|
1224 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1225 { |
|
1226 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_forwarded_high_prio; |
|
1227 } |
|
1228 else |
|
1229 { |
|
1230 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_high_prio; |
|
1231 } |
|
1232 } |
|
1233 else if ( aMsg->IsFlagSet( EFSMsgFlag_Low ) ) // Low priority, no attachments |
|
1234 { |
|
1235 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1236 { |
|
1237 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_replied_low_prio; |
|
1238 } |
|
1239 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1240 { |
|
1241 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_forwarded_low_prio; |
|
1242 } |
|
1243 else |
|
1244 { |
|
1245 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_low_prio; |
|
1246 } |
|
1247 } |
|
1248 else // Normal priority, no attachments |
|
1249 { |
|
1250 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1251 { |
|
1252 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_replied; |
|
1253 } |
|
1254 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1255 { |
|
1256 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_forwarded; |
|
1257 } |
|
1258 } |
|
1259 } |
|
1260 } |
|
1261 return icon; |
|
1262 } |
|
1263 |
|
1264 // ----------------------------------------------------------------------------- |
|
1265 // CMailCpsHandler::GetReadMsgIcon |
|
1266 // ----------------------------------------------------------------------------- |
|
1267 TInt CMailCpsHandler::GetReadMsgIcon( CFSMailMessage* aMsg ) |
|
1268 { |
|
1269 FUNC_LOG; |
|
1270 TInt icon(EMbmCmailhandlerpluginQgn_indi_cmail_read); |
|
1271 |
|
1272 if ( aMsg->IsFlagSet( EFSMsgFlag_CalendarMsg )) |
|
1273 { |
|
1274 icon = GetReadCalMsgIcon( aMsg ); |
|
1275 } |
|
1276 else // Normal message icons |
|
1277 { |
|
1278 // Check whether msg has attachment or not |
|
1279 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments )) // Has attachments |
|
1280 { |
|
1281 if ( aMsg->IsFlagSet( EFSMsgFlag_Important )) // High priority, has attachments |
|
1282 { |
|
1283 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1284 { |
|
1285 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_replied_attach_high_prio; |
|
1286 } |
|
1287 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1288 { |
|
1289 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_forwarded_attach_high_prio; |
|
1290 } |
|
1291 else |
|
1292 { |
|
1293 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_attach_high_prio; |
|
1294 } |
|
1295 } |
|
1296 else if ( aMsg->IsFlagSet( EFSMsgFlag_Low ) ) // Low priority, has attachments |
|
1297 { |
|
1298 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1299 { |
|
1300 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_replied_attach_low_prio; |
|
1301 } |
|
1302 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1303 { |
|
1304 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_forwarded_attach_low_prio; |
|
1305 } |
|
1306 else |
|
1307 { |
|
1308 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_attach_low_prio; |
|
1309 } |
|
1310 } |
|
1311 else // Normal priority, has attachments |
|
1312 { |
|
1313 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1314 { |
|
1315 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_replied_attach; |
|
1316 } |
|
1317 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1318 { |
|
1319 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_forwarded_attach; |
|
1320 } |
|
1321 else |
|
1322 { |
|
1323 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_attach; |
|
1324 } |
|
1325 } |
|
1326 } |
|
1327 else // No attachments |
|
1328 { |
|
1329 if ( aMsg->IsFlagSet( EFSMsgFlag_Important )) // High priority, no attachments |
|
1330 { |
|
1331 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1332 { |
|
1333 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_replied_high_prio; |
|
1334 } |
|
1335 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1336 { |
|
1337 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_forwarded_high_prio; |
|
1338 } |
|
1339 else |
|
1340 { |
|
1341 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_high_prio; |
|
1342 } |
|
1343 } |
|
1344 else if ( aMsg->IsFlagSet( EFSMsgFlag_Low ) ) // Low priority, no attachments |
|
1345 { |
|
1346 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1347 { |
|
1348 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_replied_low_prio; |
|
1349 } |
|
1350 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1351 { |
|
1352 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_forwarded_low_prio; |
|
1353 } |
|
1354 else |
|
1355 { |
|
1356 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_low_prio; |
|
1357 } |
|
1358 } |
|
1359 else // Normal priority, no attachments |
|
1360 { |
|
1361 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
|
1362 { |
|
1363 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_replied; |
|
1364 } |
|
1365 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
|
1366 { |
|
1367 icon = EMbmCmailhandlerpluginQgn_indi_cmail_read_forwarded; |
|
1368 } |
|
1369 } |
|
1370 } |
|
1371 } |
|
1372 return icon; |
|
1373 } |
|
1374 |
|
1375 // ----------------------------------------------------------------------------- |
|
1376 // CMailCpsHandler::GetUnreadCalMsgIcon |
|
1377 // ----------------------------------------------------------------------------- |
|
1378 TInt CMailCpsHandler::GetUnreadCalMsgIcon( CFSMailMessage* aMsg ) |
|
1379 { |
|
1380 FUNC_LOG; |
|
1381 TInt icon(0); |
|
1382 |
|
1383 if ( aMsg->IsFlagSet( EFSMsgFlag_Important ) ) |
|
1384 { |
|
1385 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
|
1386 { |
|
1387 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_attachments_high_prio ; |
|
1388 } |
|
1389 else |
|
1390 { |
|
1391 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_high_prio; |
|
1392 } |
|
1393 } |
|
1394 else if ( aMsg->IsFlagSet( EFSMsgFlag_Low ) ) |
|
1395 { |
|
1396 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
|
1397 { |
|
1398 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_attachments_low_prio; |
|
1399 } |
|
1400 else |
|
1401 { |
|
1402 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_low_prio; |
|
1403 } |
|
1404 } |
|
1405 else |
|
1406 { |
|
1407 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
|
1408 { |
|
1409 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_attachments; |
|
1410 } |
|
1411 else |
|
1412 { |
|
1413 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread; |
|
1414 } |
|
1415 } |
|
1416 |
|
1417 return icon; |
|
1418 } |
|
1419 |
|
1420 // ----------------------------------------------------------------------------- |
|
1421 // CMailCpsHandler::GetReadCalMsgIcon |
|
1422 // ----------------------------------------------------------------------------- |
|
1423 TInt CMailCpsHandler::GetReadCalMsgIcon( CFSMailMessage* aMsg ) |
|
1424 { |
|
1425 FUNC_LOG; |
|
1426 TInt icon(0); |
|
1427 |
|
1428 if ( aMsg->IsFlagSet( EFSMsgFlag_Important ) ) |
|
1429 { |
|
1430 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
|
1431 { |
|
1432 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_attachments_high_prio ; |
|
1433 } |
|
1434 else |
|
1435 { |
|
1436 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_high_prio; |
|
1437 } |
|
1438 } |
|
1439 else if ( aMsg->IsFlagSet( EFSMsgFlag_Low ) ) |
|
1440 { |
|
1441 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
|
1442 { |
|
1443 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_attachments_low_prio; |
|
1444 } |
|
1445 else |
|
1446 { |
|
1447 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_low_prio; |
|
1448 } |
|
1449 } |
|
1450 else |
|
1451 { |
|
1452 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
|
1453 { |
|
1454 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_attachments; |
|
1455 } |
|
1456 else |
|
1457 { |
|
1458 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read; |
|
1459 } |
|
1460 } |
|
1461 |
|
1462 return icon; |
|
1463 } |
|
1464 |
|
1465 // ----------------------------------------------------------------------------- |
|
1466 // CMailCpsHandler::IsValidDisplayName |
|
1467 // ----------------------------------------------------------------------------- |
|
1468 TBool CMailCpsHandler::IsValidDisplayName(const TDesC& aDisplayName) |
|
1469 { |
|
1470 FUNC_LOG; |
|
1471 TInt length(aDisplayName.Length()); |
|
1472 |
|
1473 if (length == 0) |
|
1474 { |
|
1475 return EFalse; |
|
1476 } |
|
1477 |
|
1478 // If displayname is in <xxx(at)yyyyy.zzz> format use e-mail address instead of display name. |
|
1479 if ((aDisplayName.Find(KLessThan) == 0) && |
|
1480 (aDisplayName.Right(1).Find(KGreaterThan) == 0) && |
|
1481 (aDisplayName.Find(KAt)) && |
|
1482 (aDisplayName.Find(KDot))) |
|
1483 { |
|
1484 return EFalse; |
|
1485 } |
|
1486 |
|
1487 return ETrue; |
|
1488 } |
|
1489 |
|
1490 // ----------------------------------------------------------------------------- |
|
1491 // CMailCpsHandler::IsDuplicate |
|
1492 // ----------------------------------------------------------------------------- |
|
1493 TBool CMailCpsHandler::IsDuplicate( const CMailMailboxDetails& aMailbox, const TFSMailMsgId& aMsgId ) |
|
1494 { |
|
1495 FUNC_LOG; |
|
1496 TBool isDuplicate( EFalse ); |
|
1497 const TInt size( aMailbox.iMessageDetailsArray.Count() ); |
|
1498 for ( TInt jj = 0; jj < size; jj++ ) |
|
1499 { |
|
1500 if ( aMailbox.iMessageDetailsArray[jj]->iMsgId.Id() == aMsgId.Id() ) |
|
1501 { |
|
1502 isDuplicate = ETrue; |
|
1503 } |
|
1504 } |
|
1505 return isDuplicate; |
|
1506 } |
|
1507 |
|
1508 // ----------------------------------------------------------------------------- |
|
1509 // CMailCpsHandler::LaunchWidgetSettingsL() |
|
1510 // ----------------------------------------------------------------------------- |
|
1511 // |
|
1512 void CMailCpsHandler::LaunchWidgetSettingsL( const TDesC& aContentId ) |
|
1513 { |
|
1514 FUNC_LOG; |
|
1515 |
|
1516 RApaLsSession appArcSession; |
|
1517 CleanupClosePushL( appArcSession ); |
|
1518 User::LeaveIfError( appArcSession.Connect( ) ); |
|
1519 TApaAppInfo appInfo; |
|
1520 appArcSession.GetAppInfo( appInfo, KUidEMWSettings ); |
|
1521 |
|
1522 TPtrC fullFileName; |
|
1523 TPtrC arguments; |
|
1524 |
|
1525 fullFileName.Set( appInfo.iFullName ); |
|
1526 arguments.Set( aContentId ); |
|
1527 |
|
1528 TParse fileName; |
|
1529 User::LeaveIfError(fileName.Set(fullFileName, NULL, NULL)); |
|
1530 |
|
1531 RProcess process; |
|
1532 process.Create(fileName.FullName(), arguments ); |
|
1533 CApaCommandLine* commandLine = CApaCommandLine::NewLC(); |
|
1534 commandLine->SetDocumentNameL(KNullDesC); |
|
1535 commandLine->SetExecutableNameL(fullFileName); |
|
1536 commandLine->SetCommandL( EApaCommandRun ); |
|
1537 commandLine->SetProcessEnvironmentL(process); |
|
1538 CleanupStack::PopAndDestroy(commandLine); |
|
1539 |
|
1540 process.Resume(); |
|
1541 process.Close(); |
|
1542 |
|
1543 CleanupStack::PopAndDestroy(&appArcSession); |
|
1544 } |
|
1545 |
|
1546 // ----------------------------------------------------------------------------- |
|
1547 // CMailCpsHandler::LaunchEmailUIL() |
|
1548 // ----------------------------------------------------------------------------- |
|
1549 // |
|
1550 void CMailCpsHandler::LaunchEmailUIL( const TDesC& aContentId ) |
|
1551 { |
|
1552 FUNC_LOG; |
|
1553 |
|
1554 TUid mailBoxUid; |
|
1555 mailBoxUid.iUid = iSettings->GetMailboxUidByContentId(aContentId); |
|
1556 TFSMailMsgId mailBoxId; |
|
1557 mailBoxId.SetId(mailBoxUid.iUid); |
|
1558 TUid pluginUid; |
|
1559 pluginUid.iUid = iSettings->GetPluginUidByContentId(aContentId); |
|
1560 mailBoxId.SetPluginId(pluginUid); |
|
1561 CFSMailBox* mailBox = MailClient().GetMailBoxByUidL( mailBoxId ); |
|
1562 CleanupStack::PushL( mailBox ); |
|
1563 if ( mailBox ) |
|
1564 { |
|
1565 TFSMailMsgId inboxFolderId = mailBox->GetStandardFolderId( EFSInbox ); |
|
1566 |
|
1567 TMailListActivationData tmp; |
|
1568 tmp.iFolderId = inboxFolderId; |
|
1569 tmp.iMailBoxId = mailBoxId; |
|
1570 const TPckgBuf<TMailListActivationData> pkgOut( tmp ); |
|
1571 iEnv->EikAppUi()->ActivateViewL( TVwsViewId(KUidEmailUi, KMailListId), |
|
1572 KStartListWithFolderId, |
|
1573 pkgOut); |
|
1574 } |
|
1575 CleanupStack::PopAndDestroy( mailBox ); |
|
1576 } |
|
1577 |
|
1578 // ----------------------------------------------------------------------------- |
|
1579 // CMailCpsHandler::LaunchEmailUIL() |
|
1580 // ----------------------------------------------------------------------------- |
|
1581 // |
|
1582 void CMailCpsHandler::LaunchEmailWizardL() |
|
1583 { |
|
1584 FUNC_LOG; |
|
1585 TUid viewUid(KNullUid); |
|
1586 iEnv->EikAppUi()->ActivateViewL( TVwsViewId(KUidWizardApp, KUidEmailWizardView), |
|
1587 viewUid, |
|
1588 KNullDesC8); |
|
1589 } |
|
1590 // --------------------------------------------------------------------------- |
|
1591 // CMailCpsHandler::AssociateWidget |
|
1592 // --------------------------------------------------------------------------- |
|
1593 // |
|
1594 TBool CMailCpsHandler::AssociateWidgetToSetting( const TDesC& aContentId ) |
|
1595 { |
|
1596 FUNC_LOG; |
|
1597 return iSettings->AssociateWidgetToSetting( aContentId ); |
|
1598 } |
|
1599 |
|
1600 // --------------------------------------------------------------------------- |
|
1601 // CMailCpsHandler::DissociateWidget |
|
1602 // --------------------------------------------------------------------------- |
|
1603 // |
|
1604 void CMailCpsHandler::DissociateWidgetFromSetting( const TDesC& aContentId ) |
|
1605 { |
|
1606 FUNC_LOG; |
|
1607 iSettings->DissociateWidgetFromSetting( aContentId ); |
|
1608 } |
|
1609 |
|
1610 // --------------------------------------------------------------------------- |
|
1611 // CMailCpsHandler::GetMailboxCount |
|
1612 // --------------------------------------------------------------------------- |
|
1613 // |
|
1614 TInt CMailCpsHandler::GetMailboxCount() |
|
1615 { |
|
1616 FUNC_LOG; |
|
1617 return iSettings->GetTotalMailboxCount(); |
|
1618 } |