25
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 : Handles mailiindicator updating
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <centralrepository.h>
|
|
20 |
#include <coemain.h> // CCoeEnv
|
|
21 |
#include <coeaui.h> // CCoeAppUi
|
|
22 |
#include "emailtrace.h"
|
|
23 |
|
|
24 |
#include "cfsmailclient.h"
|
|
25 |
#include "FreestyleEmailUiAppui.h"
|
|
26 |
#include "FreestyleEmailUiUtilities.h"
|
|
27 |
#include "FreestyleEmailUiConstants.h"
|
|
28 |
#include "fsemailstatuspaneindicatorhandler.h"
|
|
29 |
#include "commonemailcrkeys.h"
|
|
30 |
#include "freestyleemailcenrepkeys.h"
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
// FUNCTION DEFINITIONS
|
|
36 |
void TFsEmailStatusPaneIndicatorHandler::StatusPaneMailIndicatorHandlingL( TInt aMailBoxId )
|
|
37 |
{
|
|
38 |
FUNC_LOG;
|
|
39 |
//emailindicator control
|
|
40 |
CRepository* emailRepository = CRepository::NewL( KFreestyleEmailCenRep );
|
|
41 |
CleanupStack::PushL(emailRepository);
|
|
42 |
CRepository* commonEmailRepository = CRepository::NewL( KCmailDataRepository );
|
|
43 |
CleanupStack::PushL(commonEmailRepository);
|
|
44 |
TInt numberOfMailboxes(0);
|
|
45 |
|
|
46 |
emailRepository->Get(KNumberOfMailboxesWithNewEmails,numberOfMailboxes);
|
|
47 |
if(numberOfMailboxes > 0)
|
|
48 |
{
|
|
49 |
RArray<TInt> repositoryIds;
|
|
50 |
CleanupClosePushL(repositoryIds);
|
|
51 |
TInt tmp (0); //used to store the mailbox and plugin ids
|
|
52 |
for(TInt i = 1 ; i <= numberOfMailboxes * 2; i++ )
|
|
53 |
{
|
|
54 |
emailRepository->Get(KNumberOfMailboxesWithNewEmails+i, tmp);
|
|
55 |
repositoryIds.Append(tmp);
|
|
56 |
}
|
|
57 |
// Here we check if the current mailbox id is already in the repository:
|
|
58 |
TInt index = repositoryIds.Find(aMailBoxId);
|
|
59 |
|
|
60 |
if(index != KErrNotFound)
|
|
61 |
{
|
|
62 |
repositoryIds.Remove(index);
|
|
63 |
repositoryIds.Remove(index-1);
|
|
64 |
// Rearrange the mailbox/mailplugin ids
|
|
65 |
// in the repository
|
|
66 |
for(TInt j = 0; j < repositoryIds.Count(); j++)
|
|
67 |
{
|
|
68 |
emailRepository->Set(KNumberOfMailboxesWithNewEmails + 1 + j, repositoryIds.operator [](j));
|
|
69 |
}
|
|
70 |
// And delete last two remaining keys, that contains old information:
|
|
71 |
emailRepository->Delete(KNumberOfMailboxesWithNewEmails + ( numberOfMailboxes * 2 - 1 ));
|
|
72 |
emailRepository->Delete(KNumberOfMailboxesWithNewEmails + ( numberOfMailboxes * 2 ));
|
|
73 |
|
|
74 |
// Decrease the number of mailboxes and update the repository:
|
|
75 |
numberOfMailboxes -= 1;
|
|
76 |
emailRepository->Set(KNumberOfMailboxesWithNewEmails,numberOfMailboxes);
|
|
77 |
|
|
78 |
// Finally update the mailbox name to indicator pop-up note if there is still unchecked mailboxes
|
|
79 |
if(numberOfMailboxes > 0)
|
|
80 |
{
|
|
81 |
TInt lastMBoxIdInRepository (0);
|
|
82 |
TInt lastMPluginIdInRepository (0);
|
|
83 |
emailRepository->Get(KNumberOfMailboxesWithNewEmails+(numberOfMailboxes*2), lastMBoxIdInRepository);
|
|
84 |
// Get matching email account.
|
|
85 |
TFSMailMsgId prevMboxId;
|
|
86 |
prevMboxId.SetId(lastMBoxIdInRepository);
|
|
87 |
emailRepository->Get(KNumberOfMailboxesWithNewEmails+(numberOfMailboxes*2-1), lastMPluginIdInRepository);
|
|
88 |
TUid lastMPluginUidInRepository = { lastMPluginIdInRepository };
|
|
89 |
prevMboxId.SetPluginId(lastMPluginUidInRepository);
|
|
90 |
CFreestyleEmailUiAppUi* appUi =
|
|
91 |
static_cast<CFreestyleEmailUiAppUi*>( CCoeEnv::Static()->AppUi() );
|
|
92 |
//Write the name commonEmailRepository
|
|
93 |
CFSMailBox* prevMbox = appUi->GetMailClient()->GetMailBoxByUidL( prevMboxId );
|
|
94 |
if ( prevMbox )
|
|
95 |
{
|
|
96 |
commonEmailRepository->Set( KCmailNewEmailDisplayText, prevMbox->GetName() );
|
|
97 |
delete prevMbox;
|
|
98 |
}
|
|
99 |
}
|
|
100 |
}
|
|
101 |
if(numberOfMailboxes == 0)
|
|
102 |
{
|
|
103 |
// Set email indicator off.. user has checked the new emails in all the mailboxes
|
|
104 |
TFsEmailUiUtility::ToggleEmailIconL(EFalse);
|
|
105 |
}
|
|
106 |
repositoryIds.Reset();
|
|
107 |
CleanupStack::PopAndDestroy();//repositoryIds
|
|
108 |
}
|
|
109 |
CleanupStack::PopAndDestroy(2); //emailRepository, CommonEmailRepository
|
|
110 |
}
|