13 * |
13 * |
14 * Description: This file implements class CFSNotificationHandlerBase. |
14 * Description: This file implements class CFSNotificationHandlerBase. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 #include <centralrepository.h> |
19 //<cmail> |
19 //<cmail> |
20 #include "emailtrace.h" |
20 #include "emailtrace.h" |
21 #include "cfsmailclient.h" |
21 #include "cfsmailclient.h" |
22 //</cmail> |
22 //</cmail> |
23 |
23 |
24 #include "fsnotificationhandlermgr.h" |
24 #include "fsnotificationhandlermgr.h" |
25 #include "fsnotificationhandlerbase.h" |
25 #include "fsnotificationhandlerbase.h" |
26 #include "cmailhandlerpluginpanic.h" |
26 #include "cmailhandlerpluginpanic.h" |
|
27 #include "commonemailcrkeys.h" |
|
28 #include "FreestyleEmailCenRepKeys.h" |
|
29 #include "FreestyleEmailuiConstants.h" |
27 |
30 |
28 |
31 |
29 // ======== MEMBER FUNCTIONS ======== |
32 // ======== MEMBER FUNCTIONS ======== |
30 |
33 |
31 CFSNotificationHandlerBase::CFSNotificationHandlerBase( |
34 CFSNotificationHandlerBase::CFSNotificationHandlerBase( |
252 // moving of messages and changing message status has no |
257 // moving of messages and changing message status has no |
253 // effect on the notification. |
258 // effect on the notification. |
254 } |
259 } |
255 } |
260 } |
256 |
261 |
257 |
262 void CFSNotificationHandlerBase::MailIndicatorHandlingL(TFSMailMsgId aMailbox) |
|
263 { |
|
264 /** |
|
265 * There is always a pair of keys for one mailbox |
|
266 * 1st keys is the plugin id (numberOfMailboxes*2-1) |
|
267 * 2nd is the mailboxId (numberOfMailboxes*2) |
|
268 */ |
|
269 TInt numberOfMailboxes(0); |
|
270 CRepository* emailRepository = CRepository::NewL( KFreestyleEmailCenRep ); |
|
271 CleanupStack::PushL(emailRepository); |
|
272 emailRepository->Get(KNumberOfMailboxesWithNewEmails, numberOfMailboxes); |
|
273 CRepository* commonEmailRepository = CRepository::NewL( KCmailDataRepository ); |
|
274 CleanupStack::PushL(commonEmailRepository); |
|
275 if(numberOfMailboxes != 0) |
|
276 { |
|
277 RArray<TInt> repositoryIds; |
|
278 CleanupClosePushL(repositoryIds); |
|
279 TInt tmp(0); |
|
280 for(TInt i = 1 ; i <= numberOfMailboxes * 2; i++ ) |
|
281 { |
|
282 emailRepository->Get(KNumberOfMailboxesWithNewEmails+i, tmp); |
|
283 repositoryIds.Append(tmp); |
|
284 } |
|
285 TInt index = repositoryIds.Find(static_cast<TInt>(aMailbox.Id())); |
|
286 // If it is we delete it from the array |
|
287 if(index != KErrNotFound ) |
|
288 { |
|
289 //unless it is the last item, then we don't have to do anything |
|
290 if(index != (repositoryIds.Count()-1)) |
|
291 { |
|
292 repositoryIds.Remove(index); |
|
293 repositoryIds.Remove(index-1); |
|
294 // Rearrange the mailbox/mailplugin ids |
|
295 // in the repository |
|
296 for(TInt j = 0; j < repositoryIds.Count(); j++) |
|
297 { |
|
298 emailRepository->Set(KNumberOfMailboxesWithNewEmails + 1 + j, repositoryIds.operator [](j)); |
|
299 } |
|
300 // And write the current mailbox/plugin ids back to repository as the last items |
|
301 emailRepository->Set(KNumberOfMailboxesWithNewEmails + ( numberOfMailboxes * 2 - 1 ), static_cast<TInt>(aMailbox.PluginId().iUid)); |
|
302 emailRepository->Set(KNumberOfMailboxesWithNewEmails + ( numberOfMailboxes * 2 ),static_cast<TInt>(aMailbox.Id()) ); |
|
303 commonEmailRepository->Set(KCmailNewEmailDisplayText,MailClient().GetMailBoxByUidL(aMailbox)->GetName()); |
|
304 } |
|
305 } |
|
306 else |
|
307 { |
|
308 //Create keys with right values and update the number of mailboxes |
|
309 numberOfMailboxes += 1; |
|
310 emailRepository->Set(KNumberOfMailboxesWithNewEmails, numberOfMailboxes); |
|
311 emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2 - 1), static_cast<TInt>(aMailbox.PluginId().iUid)); |
|
312 emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2), static_cast<TInt>(aMailbox.Id())); |
|
313 commonEmailRepository->Set(KCmailNewEmailDisplayText,MailClient().GetMailBoxByUidL(aMailbox)->GetName()); |
|
314 } |
|
315 repositoryIds.Reset(); |
|
316 CleanupStack::PopAndDestroy();//repositoryIds |
|
317 } |
|
318 else |
|
319 { |
|
320 //Create keys with right values and pudate the number of mailboxes |
|
321 numberOfMailboxes += 1; |
|
322 emailRepository->Set(KNumberOfMailboxesWithNewEmails, numberOfMailboxes); |
|
323 emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2 - 1), static_cast<TInt>(aMailbox.PluginId().iUid)); |
|
324 emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2), static_cast<TInt>(aMailbox.Id())); |
|
325 commonEmailRepository->Set(KCmailNewEmailDisplayText,MailClient().GetMailBoxByUidL(aMailbox)->GetName()); |
|
326 } |
|
327 CleanupStack::PopAndDestroy(2);// emailRepository, CommonEmailRepository |
|
328 TurnNotificationOn(); |
|
329 } |
258 |
330 |
259 CFSMailMessage* CFSNotificationHandlerBase::NewestMsgInFolderL( |
331 CFSMailMessage* CFSNotificationHandlerBase::NewestMsgInFolderL( |
260 /*const*/ CFSMailFolder& aFolder ) const |
332 /*const*/ CFSMailFolder& aFolder ) const |
261 { |
333 { |
262 FUNC_LOG; |
334 FUNC_LOG; |