author | hgs |
Fri, 23 Jul 2010 19:09:50 +0300 | |
changeset 56 | 15bc1d5d6267 |
parent 51 | d845db10c0d4 |
child 62 | a8c646b56683 |
permissions | -rw-r--r-- |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
51 | 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: Mail agent is responsible of monitoring mail accounts. It activates |
|
15 |
* and deactivates indicator depending on received events. Mail agent is |
|
16 |
* also responsible of monitoring silence mode, playing alert tone and vibrating |
|
17 |
* phone when new mail is received. |
|
18 |
* |
|
19 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
|
43 | 21 |
#include "emailtrace.h" |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include "nmmailagentheaders.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include "nmmailagent.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
|
44 | 25 |
#include <xqaiwdeclplat.h> |
26 |
#include <xqapplicationmanager.h> |
|
27 |
#include <xqaiwrequest.h> |
|
28 |
||
29 |
#include <xqsettingsmanager.h> |
|
30 |
#include <xqcentralrepositoryutils.h> |
|
43 | 31 |
#include <xqsystemtoneservice.h> |
48 | 32 |
#include <xqsettingskey.h> |
33 |
#include <ProfileEngineInternalCRKeys.h> |
|
43 | 34 |
|
51 | 35 |
// CONSTANTS |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
36 |
const int NmAgentIndicatorNotSet = -1; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
37 |
const int NmAgentAlertToneTimer = 60000; // 60s |
44 | 38 |
const int NmAgentDefaultVibraDuration = 1000; // 1 second |
47 | 39 |
static const quint32 NmRepositoryId = 0x2002C326; |
43 | 40 |
static const QString NmMailboxIndicatorType = "com.nokia.nmail.indicatorplugin_%1/1.0"; |
41 |
static const QString NmSendIndicatorName = "com.nokia.nmail.indicatorplugin.send/1.0"; |
|
42 |
static const QString NmUnreadIndicatorName = "com.nokia.nmail.indicatorplugin.unread/1.0"; |
|
48 | 43 |
const XQCentralRepositorySettingsKey NmSilenceModeKey(KCRUidProfileEngine.iUid, KProEngSilenceMode); |
44 |
const int NmSilenceModeOn = 1; |
|
45 |
||
46 |
/*! |
|
47 |
Helper method for finding out if XQSettingsKey and XQCentralRepositorySettingsKey points to |
|
48 |
same key. |
|
49 |
||
51 | 50 |
\param settingKey XQSettingsKey |
51 |
\param cenrepSettingKey XQCentralRepositorySettingsKey |
|
52 |
\return <code>true</code> if target, uid and key matches otherwise returns <code>false</code> |
|
53 |
*/ |
|
48 | 54 |
bool keysEqual(const XQSettingsKey& settingKey, const XQCentralRepositorySettingsKey& cenrepSettingKey) |
55 |
{ |
|
56 |
return ((settingKey.target() == cenrepSettingKey.target()) && |
|
51 | 57 |
(settingKey.uid() == cenrepSettingKey.uid()) && |
58 |
(settingKey.key() == cenrepSettingKey.key())); |
|
48 | 59 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
|
51 | 62 |
|
63 |
/*! |
|
64 |
\class NmMailboxInfo |
|
65 |
||
66 |
\brief Main class for storing mailbox data. |
|
67 |
*/ |
|
68 |
NmMailboxInfo::NmMailboxInfo() |
|
69 |
: mId(0), |
|
70 |
mIndicatorIndex(NmAgentIndicatorNotSet), |
|
71 |
mInboxFolderId(0), |
|
72 |
mOutboxFolderId(0), |
|
73 |
mSyncState(SyncComplete), |
|
74 |
mConnectState(Disconnected), |
|
75 |
mInboxCreatedMessages(0), |
|
76 |
mInboxChangedMessages(0), |
|
77 |
mInboxDeletedMessages(0), |
|
78 |
mOutboxMails(0), |
|
79 |
mActive(false), |
|
80 |
mInboxActive(false) |
|
81 |
{ |
|
56 | 82 |
NM_FUNCTION; |
51 | 83 |
} |
84 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
\class NmMailAgent |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
87 |
|
51 | 88 |
\brief Main class for receiving email events. Activates and deactivates indicator. |
89 |
*/ |
|
90 |
NmMailAgent::NmMailAgent() : |
|
91 |
mIndicator(NULL), |
|
92 |
mSystemTone(NULL), |
|
93 |
mPluginFactory(NULL), |
|
94 |
mVibra(NULL), |
|
95 |
mAlertToneAllowed(true), |
|
96 |
mLastOutboxCount(0), |
|
97 |
mUnreadIndicatorActive(false), |
|
98 |
mSettingManager(NULL), |
|
99 |
mSilenceMode(NmSilenceModeOn) // by default silent mode is on |
|
100 |
{ |
|
56 | 101 |
NM_FUNCTION; |
51 | 102 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
103 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
104 |
/*! |
51 | 105 |
Delayed start. |
106 |
*/ |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
107 |
void NmMailAgent::delayedStart() |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
108 |
{ |
43 | 109 |
NM_FUNCTION; |
110 |
||
51 | 111 |
if (!init()) { |
112 |
// Initialisation failed. Quit the agent. |
|
113 |
QCoreApplication::exit(1); |
|
114 |
} |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
115 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
116 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
117 |
/*! |
51 | 118 |
Initialise the agent. |
119 |
||
120 |
\return true if succesfully started. |
|
121 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
bool NmMailAgent::init() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
{ |
43 | 124 |
NM_FUNCTION; |
125 |
||
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
126 |
mPluginFactory = NmDataPluginFactory::instance(); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
127 |
if (!mPluginFactory) { |
43 | 128 |
NM_ERROR(1,"NmMailAgent::init(): PluginFactory not created"); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
129 |
return false; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
|
48 | 132 |
// Check status of silent mode. |
133 |
delete mSettingManager; |
|
134 |
mSettingManager = NULL; |
|
135 |
mSettingManager = new XQSettingsManager(); |
|
136 |
QVariant silenceMode = mSettingManager->readItemValue(NmSilenceModeKey, |
|
137 |
XQSettingsManager::TypeInt); |
|
138 |
mSilenceMode = silenceMode.toInt(); |
|
139 |
||
140 |
// Start monitoring silence mode key. |
|
141 |
bool monitoring(mSettingManager->startMonitoring(NmSilenceModeKey, XQSettingsManager::TypeInt)); |
|
142 |
monitoring &= connect(mSettingManager, |
|
51 | 143 |
SIGNAL(valueChanged(const XQSettingsKey &, const QVariant &)), |
48 | 144 |
this, |
51 | 145 |
SLOT(valueChanged(const XQSettingsKey &, const QVariant &)), |
48 | 146 |
Qt::UniqueConnection); |
147 |
||
148 |
// If silence mode monitoring can't be started, then change silence mode on to be sure |
|
149 |
// that no tone is played if silence mode is turned on at somepoint. |
|
150 |
if (!monitoring) { |
|
151 |
mSilenceMode = NmSilenceModeOn; |
|
152 |
} |
|
153 |
||
154 |
delete mSystemTone; |
|
155 |
mSystemTone = NULL; |
|
47 | 156 |
mSystemTone = new XQSystemToneService(); |
157 |
||
48 | 158 |
delete mIndicator; |
159 |
mIndicator = NULL; |
|
43 | 160 |
mIndicator = new HbIndicator(); |
51 | 161 |
connect(mIndicator,SIGNAL(userActivated(const QString &, const QVariantMap &)), |
162 |
this, SLOT(indicatorActivated(const QString &, const QVariantMap &))); |
|
43 | 163 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
164 |
QList<QObject*> *plugins = mPluginFactory->pluginInstances(); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
165 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
166 |
foreach (QObject *plugin, *plugins) { |
51 | 167 |
if (plugin) { |
168 |
// Start listening events |
|
169 |
connect(plugin, SIGNAL(mailboxEvent(NmMailboxEvent, const QList<NmId> &)), |
|
170 |
this, SLOT(handleMailboxEvent(NmMailboxEvent, const QList<NmId> &)), |
|
171 |
Qt::UniqueConnection); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
172 |
|
51 | 173 |
connect(plugin, SIGNAL(messageEvent( |
174 |
NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)), |
|
175 |
this, SLOT(handleMessageEvent( |
|
176 |
NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)), |
|
177 |
Qt::UniqueConnection); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
178 |
|
51 | 179 |
connect(plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
180 |
this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
|
181 |
Qt::UniqueConnection); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
182 |
|
51 | 183 |
connect(plugin, SIGNAL(connectionEvent(NmConnectState, const NmId, int)), |
184 |
this, SLOT(handleConnectionEvent(NmConnectState, const NmId, int)), |
|
185 |
Qt::UniqueConnection); |
|
186 |
} |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
187 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
188 |
|
44 | 189 |
// Construct the vibra interface instance. |
48 | 190 |
delete mVibra; |
191 |
mVibra = NULL; |
|
44 | 192 |
TRAP_IGNORE(mVibra = CHWRMVibra::NewL()); |
193 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
194 |
// load all current mailboxes |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
195 |
initMailboxStatus(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
196 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
197 |
return true; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
198 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
199 |
|
51 | 200 |
/*! |
201 |
Destructor of NmMailAgent. |
|
202 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
203 |
NmMailAgent::~NmMailAgent() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
204 |
{ |
43 | 205 |
NM_FUNCTION; |
206 |
||
51 | 207 |
delete mIndicator; |
44 | 208 |
delete mVibra; |
47 | 209 |
delete mSystemTone; |
48 | 210 |
if (mSettingManager) { |
211 |
mSettingManager->stopMonitoring(NmSilenceModeKey); |
|
212 |
delete mSettingManager; |
|
213 |
} |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
214 |
qDeleteAll(mMailboxes); |
44 | 215 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
216 |
NmDataPluginFactory::releaseInstance(mPluginFactory); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
217 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
218 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
219 |
/*! |
51 | 220 |
Initialize the mailbox list with the current state. |
221 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
222 |
void NmMailAgent::initMailboxStatus() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
223 |
{ |
43 | 224 |
NM_FUNCTION; |
225 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
226 |
QList<NmMailbox*> mailboxes; |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
227 |
QList<QObject*> *plugins = mPluginFactory->pluginInstances(); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
228 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
229 |
foreach(QObject* pluginObject, *plugins) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
230 |
NmDataPluginInterface *plugin = |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
231 |
mPluginFactory->interfaceInstance(pluginObject); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
232 |
if (plugin) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
233 |
plugin->listMailboxes(mailboxes); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
234 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
235 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
236 |
// Add the indicators |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
237 |
// Must be made in reverse order to show them properly in |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
238 |
// HbIndicator menu |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
239 |
QListIterator<NmMailbox *> i(mailboxes); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
240 |
i.toBack(); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
241 |
while (i.hasPrevious()) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
242 |
const NmMailbox *mailbox = i.previous(); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
243 |
if (mailbox) { |
51 | 244 |
NmMailboxInfo *mailboxInfo = createMailboxInfo(*mailbox, plugin); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
245 |
if (mailboxInfo) { |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
246 |
bool activate = updateUnreadCount(mailbox->id(), *mailboxInfo); |
44 | 247 |
bool wasActive = isMailboxActive(mailbox->id()); |
248 |
if (activate) { |
|
51 | 249 |
if (!wasActive) { |
44 | 250 |
// do not activate the mailbox if it was left as hidden last time |
251 |
activate = false; |
|
252 |
} |
|
253 |
else { |
|
254 |
// otherwise, activate the mailbox and show inbox state |
|
255 |
mailboxInfo->mInboxActive = true; |
|
256 |
} |
|
257 |
} |
|
258 |
||
51 | 259 |
mailboxInfo->mOutboxMails = getOutboxCount(mailbox->id(), |
260 |
mailboxInfo->mOutboxFolderId); |
|
44 | 261 |
if (mailboxInfo->mOutboxMails > 0 && wasActive) { |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
262 |
activate = true; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
263 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
264 |
|
51 | 265 |
// Create indicator for visible mailboxes |
266 |
updateMailboxState(mailbox->id(), activate, false); |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
267 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
268 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
269 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
270 |
qDeleteAll(mailboxes); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
271 |
} |
44 | 272 |
updateUnreadIndicator(); |
43 | 273 |
updateSendIndicator(); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
274 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
275 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
276 |
/*! |
51 | 277 |
Get mailbox unread count in inbox folder. |
278 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
279 |
\param mailboxId id of the mailbox |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
280 |
\param mailboxInfo contains the list of unread messages |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
281 |
\return true if new unread mails was found |
51 | 282 |
*/ |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
283 |
bool NmMailAgent::updateUnreadCount(const NmId &mailboxId, NmMailboxInfo &mailboxInfo) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
284 |
{ |
43 | 285 |
NM_FUNCTION; |
286 |
||
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
287 |
int newUnreadMessages(0); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
288 |
NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
289 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
290 |
if (plugin) { |
51 | 291 |
NmId inboxId = mailboxInfo.mInboxFolderId.id(); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
292 |
|
51 | 293 |
// Inbox folder ID may be still unknown |
294 |
if (inboxId == 0) { |
|
295 |
mailboxInfo.mInboxFolderId = plugin->getStandardFolderId(mailboxId, NmFolderInbox); |
|
296 |
inboxId = mailboxInfo.mInboxFolderId.id(); |
|
297 |
} |
|
298 |
||
299 |
// get list of messages in inbox |
|
300 |
QList<NmMessageEnvelope*> messageList; |
|
301 |
plugin->listMessages(mailboxId, inboxId, messageList); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
302 |
|
51 | 303 |
QList<NmId> newUnreadMessageIdList; |
304 |
foreach (const NmMessageEnvelope* envelope, messageList) { |
|
305 |
// if the message is not read, it is "unread" |
|
306 |
if (!envelope->isRead()) { |
|
307 |
quint64 messageId = envelope->messageId().id(); |
|
308 |
newUnreadMessageIdList.append(envelope->messageId()); |
|
309 |
bool found(false); |
|
310 |
// Iterate through all known ids. If the id can't be found the mail is new. |
|
311 |
foreach (const NmId id, mailboxInfo.mUnreadMailIdList) { |
|
312 |
if (id.id() == messageId) { |
|
313 |
found = true; |
|
314 |
break; |
|
315 |
} |
|
316 |
} |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
317 |
|
51 | 318 |
if (!found) { |
319 |
newUnreadMessages++; |
|
320 |
} |
|
321 |
} |
|
322 |
} |
|
323 |
qDeleteAll(messageList); |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
324 |
|
51 | 325 |
// Save updated list of unread message IDs |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
326 |
mailboxInfo.mUnreadMailIdList = newUnreadMessageIdList; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
327 |
} |
43 | 328 |
NM_COMMENT(QString("NmMailAgent::getUnreadCount(): count=%1, new=%2"). |
329 |
arg(mailboxInfo.mUnreadMailIdList.count()).arg(newUnreadMessages)); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
330 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
331 |
return (newUnreadMessages > 0); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
332 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
333 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
334 |
/*! |
51 | 335 |
Get mailbox count in outbox folder. |
336 |
||
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
337 |
\param mailboxId id of the mailbox |
51 | 338 |
\param outboxId Outbox folder Id |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
339 |
\return number of mails in the outbox |
51 | 340 |
*/ |
341 |
int NmMailAgent::getOutboxCount(const NmId &mailboxId, const NmId &outboxId) |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
342 |
{ |
43 | 343 |
NM_FUNCTION; |
344 |
||
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
345 |
int count(0); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
346 |
NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
347 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
348 |
if (plugin) { |
51 | 349 |
// get list of messages in outbox |
350 |
QList<NmMessageEnvelope*> messageList; |
|
351 |
plugin->listMessages(mailboxId, outboxId, messageList); |
|
352 |
count = messageList.count(); |
|
353 |
qDeleteAll(messageList); |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
354 |
} |
43 | 355 |
NM_COMMENT(QString("NmMailAgent::getOutboxCount(): count=%1").arg(count)); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
356 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
357 |
return count; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
358 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
359 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
360 |
/*! |
51 | 361 |
Get list of unread counts in active mailboxes. |
362 |
||
43 | 363 |
\returns total number of unread mails |
51 | 364 |
*/ |
43 | 365 |
int NmMailAgent::getTotalUnreadCount() const |
366 |
{ |
|
48 | 367 |
NM_FUNCTION; |
368 |
||
43 | 369 |
int unreads = 0; |
370 |
foreach (const NmMailboxInfo *mailbox, mMailboxes) { |
|
44 | 371 |
if (mailbox->mActive && mailbox->mInboxActive) { |
43 | 372 |
unreads += mailbox->mUnreadMailIdList.count(); |
373 |
} |
|
374 |
} |
|
375 |
return unreads; |
|
376 |
} |
|
377 |
||
378 |
/*! |
|
51 | 379 |
Update the "@" indicator state according to unread state. |
380 |
||
43 | 381 |
\return true if the indicator was activated |
51 | 382 |
*/ |
43 | 383 |
bool NmMailAgent::updateUnreadIndicator() |
384 |
{ |
|
48 | 385 |
NM_FUNCTION; |
386 |
||
43 | 387 |
int unreads = getTotalUnreadCount(); |
388 |
return updateUnreadIndicator(unreads>0); |
|
389 |
} |
|
390 |
||
391 |
/*! |
|
51 | 392 |
Update the mailbox visibility and status. |
393 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
394 |
\param mailboxId id of the mailbox |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
395 |
\param active visibility state of the mailbox |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
396 |
\param refreshAlways true when the indicator should be always updated |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
397 |
\return true if the mailbox state was changed |
51 | 398 |
*/ |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
399 |
bool NmMailAgent::updateMailboxState(const NmId &mailboxId, |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
400 |
bool active, bool refreshAlways) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
401 |
{ |
43 | 402 |
NM_FUNCTION; |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
403 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
404 |
NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
405 |
bool changed = false; |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
406 |
if (mailboxInfo->mActive != active || |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
407 |
refreshAlways) { |
47 | 408 |
|
51 | 409 |
// store the new state to permanent storage |
44 | 410 |
storeMailboxActive(mailboxId, active); |
47 | 411 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
412 |
mailboxInfo->mActive = active; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
413 |
changed = true; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
414 |
if (active) { |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
415 |
// Mailbox is not yet assigned to any indicator |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
416 |
if (mailboxInfo->mIndicatorIndex < 0) { |
43 | 417 |
mailboxInfo->mIndicatorIndex = getFreeIndicatorIndex(); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
418 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
419 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
420 |
updateIndicator(true,*mailboxInfo); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
421 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
422 |
else { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
423 |
// Indicator not anymore active. Release it. |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
424 |
if (mailboxInfo->mIndicatorIndex>=0) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
425 |
updateIndicator(false,*mailboxInfo); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
426 |
mailboxInfo->mIndicatorIndex = NmAgentIndicatorNotSet; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
427 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
428 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
429 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
430 |
return changed; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
431 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
432 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
433 |
/*! |
51 | 434 |
Updates indicator status. |
435 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
436 |
\param mailboxIndex index of the item shown in indicator menu |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
437 |
\param active indicator visibility state |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
438 |
\param mailboxInfo information of the mailbox |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
439 |
\return true if indicator was updated with no errors |
51 | 440 |
*/ |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
441 |
bool NmMailAgent::updateIndicator(bool active, |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
442 |
const NmMailboxInfo& mailboxInfo) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
443 |
{ |
43 | 444 |
NM_FUNCTION; |
445 |
NM_COMMENT(QString("NmMailAgent::updateIndicator(): index=%1, active=%2"). |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
446 |
arg(mailboxInfo.mIndicatorIndex).arg(active)); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
447 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
448 |
bool ok = false; |
43 | 449 |
QString name = QString(NmMailboxIndicatorType). |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
450 |
arg(mailboxInfo.mIndicatorIndex); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
451 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
452 |
QList<QVariant> list; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
453 |
list.append(mailboxInfo.mId.id()); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
454 |
list.append(mailboxInfo.mName); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
455 |
list.append(mailboxInfo.mUnreadMailIdList.count()); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
456 |
list.append(mailboxInfo.mSyncState); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
457 |
list.append(mailboxInfo.mConnectState); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
458 |
list.append(mailboxInfo.mOutboxMails); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
459 |
list.append(mailboxInfo.mIconName); |
43 | 460 |
list.append(mLastOutboxCount); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
461 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
462 |
if (active) { |
43 | 463 |
ok = mIndicator->activate(name,list); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
464 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
465 |
else { |
43 | 466 |
ok = mIndicator->deactivate(name,list); |
467 |
} |
|
468 |
||
469 |
updateUnreadIndicator(); |
|
470 |
||
471 |
return ok; |
|
472 |
} |
|
473 |
||
474 |
/*! |
|
51 | 475 |
Update the unread indicator state. |
476 |
||
477 |
\param active if true unread indicator is activated otherwise deactivated |
|
43 | 478 |
\return true if the indicator was activated |
51 | 479 |
*/ |
43 | 480 |
bool NmMailAgent::updateUnreadIndicator(bool active) |
481 |
{ |
|
482 |
NM_FUNCTION; |
|
48 | 483 |
|
43 | 484 |
bool activated = false; |
44 | 485 |
if (active != mUnreadIndicatorActive) { |
486 |
if (active) { |
|
487 |
mIndicator->activate(NmUnreadIndicatorName); |
|
43 | 488 |
activated = true; |
489 |
} |
|
44 | 490 |
else { |
491 |
mIndicator->deactivate(NmUnreadIndicatorName); |
|
492 |
} |
|
493 |
mUnreadIndicatorActive = active; |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
494 |
} |
44 | 495 |
|
43 | 496 |
return activated; |
497 |
} |
|
498 |
||
499 |
/*! |
|
51 | 500 |
Opens inbox view to specific mailbox. |
501 |
||
502 |
\param mailboxId Id of mailbox |
|
43 | 503 |
\return true if inbox is succesfully opened |
51 | 504 |
*/ |
43 | 505 |
bool NmMailAgent::launchMailbox(quint64 mailboxId) |
506 |
{ |
|
507 |
NM_FUNCTION; |
|
508 |
||
47 | 509 |
bool ok(false); |
44 | 510 |
XQApplicationManager appManager; |
511 |
XQAiwRequest *request = appManager.create( |
|
512 |
XQI_EMAIL_INBOX_VIEW, XQOP_EMAIL_INBOX_VIEW, false); |
|
47 | 513 |
// Instance might be NULL if the service is not available. |
514 |
if (request) { |
|
515 |
QList<QVariant> list; |
|
516 |
list.append(QVariant(mailboxId)); |
|
517 |
request->setArguments(list); |
|
518 |
ok = request->send(); |
|
519 |
NM_COMMENT(QString("Launch ok=%1 error=%2").arg(ok).arg(request->lastError())); |
|
520 |
delete request; |
|
521 |
} |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
522 |
return ok; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
523 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
524 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
525 |
/*! |
51 | 526 |
Handles message created event. |
527 |
||
528 |
\param folderId Id of the folder that includes the message |
|
529 |
\param messageIds Message ids that are checked |
|
530 |
\param mailboxId Id of the mailbox that includes the message |
|
531 |
\param updateNeeded Set to <code>true</code> if update needed otherwise not touched |
|
532 |
\param activate Set to <code>true</code> if activation needed otherwise not touched |
|
533 |
*/ |
|
534 |
void NmMailAgent::handleMessageCreatedEvent(const NmId &folderId, const QList<NmId> &messageIds, |
|
535 |
const NmId &mailboxId, bool &updateNeeded, bool &activate) |
|
536 |
{ |
|
537 |
NM_FUNCTION; |
|
538 |
||
539 |
// Check the new messages to make the indicator appear earlier |
|
540 |
NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); |
|
541 |
||
542 |
// Inbox folder ID may be still unknown |
|
543 |
if (mailboxInfo->mInboxFolderId.id() == 0) { |
|
544 |
NmDataPluginInterface *plugin = |
|
545 |
mPluginFactory->interfaceInstance(mailboxId); |
|
546 |
||
547 |
if (plugin) { |
|
548 |
mailboxInfo->mInboxFolderId = |
|
549 |
plugin->getStandardFolderId(mailboxId, NmFolderInbox); |
|
550 |
} |
|
551 |
} |
|
552 |
||
553 |
if (folderId == mailboxInfo->mInboxFolderId) { |
|
554 |
foreach (NmId messageId, messageIds) { |
|
555 |
bool messageUnread = false; |
|
556 |
||
557 |
// Check the message if we can either play a tone or if the "@" is |
|
558 |
// not visible at the moment |
|
559 |
if (mAlertToneAllowed || !mUnreadIndicatorActive) { |
|
560 |
if (getMessageUnreadInfo(folderId, messageId, mailboxId, messageUnread)) { |
|
561 |
if (messageUnread) { |
|
562 |
mailboxInfo->mUnreadMailIdList.append(messageId); |
|
563 |
mailboxInfo->mInboxActive = true; |
|
564 |
updateMailboxState(mailboxId, true, false); |
|
565 |
||
566 |
// make the "@" appear immediatelly |
|
567 |
updateUnreadIndicator(true); |
|
568 |
||
569 |
// Play the tone as well |
|
570 |
playAlertTone(); |
|
571 |
} |
|
572 |
} |
|
573 |
} |
|
574 |
} |
|
575 |
} |
|
576 |
||
577 |
if (folderId==mailboxInfo->mInboxFolderId) { |
|
578 |
mailboxInfo->mInboxCreatedMessages += messageIds.count(); |
|
579 |
} |
|
580 |
||
581 |
// When created a new mail in the outbox, we are in sending state |
|
582 |
if (mailboxInfo->mOutboxFolderId == folderId) { |
|
583 |
// The first mail created in the outbox |
|
584 |
if (mailboxInfo->mOutboxMails <= 0) { |
|
585 |
NM_COMMENT("NmMailAgent: first mail in outbox"); |
|
586 |
} |
|
587 |
// Always activate the indicator |
|
588 |
activate = true; |
|
589 |
updateNeeded = true; |
|
590 |
||
591 |
mailboxInfo->mOutboxMails += messageIds.count(); |
|
592 |
updateSendIndicator(); |
|
593 |
} |
|
594 |
} |
|
595 |
||
596 |
||
597 |
/*! |
|
598 |
Handles message changed event. |
|
599 |
\sa updateUnreadCount |
|
600 |
||
601 |
\param folderId Id of the folder that includes the message |
|
56 | 602 |
\param messageIds Message ids that are checked |
51 | 603 |
\param mailboxId Id of the mailbox that includes the message |
604 |
\param updateNeeded Set to <code>true</code> if update needed otherwise not touched |
|
605 |
\param activate Set result value of updateUnreadCount method |
|
606 |
*/ |
|
56 | 607 |
void NmMailAgent::handleMessageChangedEvent(const NmId &folderId, |
608 |
const QList<NmId> &messageIds, |
|
609 |
const NmId &mailboxId, |
|
51 | 610 |
bool &updateNeeded, bool &activate) |
611 |
{ |
|
612 |
NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); |
|
613 |
||
56 | 614 |
// we are interested only about changes in the inbox |
51 | 615 |
if (folderId == mailboxInfo->mInboxFolderId) { |
616 |
mailboxInfo->mInboxChangedMessages++; |
|
617 |
||
56 | 618 |
// If not currently syncronizing the mailbox, this may mean |
619 |
// that a message was read/unread |
|
620 |
if (mailboxInfo && mailboxInfo->mSyncState == SyncComplete) { |
|
621 |
// If there was no unread mails in the list, do nothing |
|
622 |
int oldCount(mailboxInfo->mUnreadMailIdList.count()); |
|
623 |
if (oldCount>0) { |
|
624 |
// Check how many messages were unread earlier |
|
625 |
int unreadMessages = 0; |
|
626 |
foreach (NmId messageId, messageIds) { |
|
627 |
if (mailboxInfo->mUnreadMailIdList.indexOf(messageId)>=0) { |
|
628 |
unreadMessages++; |
|
629 |
} |
|
630 |
} |
|
51 | 631 |
|
56 | 632 |
// Could lead the count drop to 0 => mailbox will be hidden |
633 |
if (unreadMessages > 0) { |
|
634 |
// check the unread status again |
|
635 |
activate = updateUnreadCount(mailboxId, *mailboxInfo); |
|
636 |
||
637 |
// no more unread mails in the inbox |
|
638 |
if (mailboxInfo->mUnreadMailIdList.count()==0) { |
|
639 |
NM_COMMENT("NmMailAgent:handleMessageChangedEvent - no more unread msgs"); |
|
640 |
updateNeeded = true; |
|
641 |
} |
|
642 |
} |
|
643 |
} |
|
51 | 644 |
} |
645 |
} |
|
646 |
} |
|
647 |
||
648 |
/*! |
|
649 |
Handles message deleted event. |
|
650 |
||
651 |
\param folderId Id of the folder that includes the message |
|
652 |
\param messageIds Message ids that are checked |
|
653 |
\param mailboxId Id of the mailbox that includes the message |
|
654 |
\param updateNeeded Set to <code>true</code> if update needed otherwise not touched |
|
655 |
\param activate Set to <code>true</code> if activation needed otherwise not touched |
|
656 |
*/ |
|
657 |
void NmMailAgent::handleMessageDeletedEvent(const NmId &folderId, const QList<NmId> &messageIds, |
|
658 |
const NmId &mailboxId, bool &updateNeeded, bool &activate) |
|
659 |
{ |
|
660 |
NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); |
|
661 |
||
662 |
if (folderId == mailboxInfo->mInboxFolderId) { |
|
663 |
mailboxInfo->mInboxDeletedMessages++; |
|
664 |
} |
|
665 |
||
666 |
// Deleted mails from the outbox |
|
667 |
if (mailboxInfo->mOutboxFolderId == folderId) { |
|
668 |
mailboxInfo->mOutboxMails -= messageIds.count(); |
|
669 |
||
670 |
// Sanity check for the outbox count |
|
671 |
if (mailboxInfo->mOutboxMails < 0) { |
|
672 |
mailboxInfo->mOutboxMails = 0; |
|
673 |
} |
|
674 |
||
675 |
// The last mail was now deleted |
|
676 |
if (mailboxInfo->mOutboxMails == 0) { |
|
677 |
NM_COMMENT("NmMailAgent: last mail deleted from outbox"); |
|
678 |
updateNeeded = true; |
|
679 |
||
680 |
// Keep it active if there is unread mails and inbox is still active |
|
681 |
if (mailboxInfo->mInboxActive && |
|
682 |
mailboxInfo->mUnreadMailIdList.count() > 0) { |
|
683 |
activate = true; |
|
684 |
} |
|
685 |
} |
|
686 |
else { |
|
687 |
// Also update the indicator status if it is already shown |
|
688 |
if (mailboxInfo->mActive) { |
|
689 |
activate = true; |
|
690 |
updateNeeded = true; |
|
691 |
} |
|
692 |
} |
|
693 |
updateSendIndicator(); |
|
694 |
} |
|
695 |
} |
|
696 |
||
697 |
/*! |
|
698 |
Get next free indicator index, starting from 0. |
|
699 |
||
700 |
\return index of the indicator that is available |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
701 |
*/ |
43 | 702 |
int NmMailAgent::getFreeIndicatorIndex() |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
703 |
{ |
43 | 704 |
NM_FUNCTION; |
705 |
||
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
706 |
int index = 0; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
707 |
bool found(false); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
708 |
do { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
709 |
found = false; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
710 |
foreach (NmMailboxInfo *mailbox, mMailboxes) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
711 |
if (mailbox->mIndicatorIndex == index && |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
712 |
mailbox->mActive) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
713 |
found = true; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
714 |
index++; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
715 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
716 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
717 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
718 |
while( found ); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
719 |
return index; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
720 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
721 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
722 |
/*! |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
723 |
Received from NmFrameworkAdapter mailboxEvent signal |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
724 |
\sa NmFrameworkAdapter |
51 | 725 |
|
726 |
\param event Mailbox event type |
|
727 |
\param mailboxIds Mailbox ids that are checked |
|
728 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
729 |
void NmMailAgent::handleMailboxEvent(NmMailboxEvent event, const QList<NmId> &mailboxIds) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
730 |
{ |
43 | 731 |
NM_FUNCTION; |
732 |
NM_COMMENT(QString("NmMailAgent::handleMailboxEvent(): event=%1").arg(event)); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
733 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
734 |
switch(event) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
735 |
case NmMailboxCreated: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
736 |
foreach (NmId mailboxId, mailboxIds) { |
51 | 737 |
NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); // create a new mailbox if needed |
738 |
if (!mailboxInfo) { |
|
739 |
// Unable to initialise the mailbox. Try again later. |
|
740 |
NM_COMMENT("Cannot initialise mailbox"); |
|
56 | 741 |
|
51 | 742 |
qRegisterMetaType<NmId>("NmId"); |
743 |
QMetaObject::invokeMethod(this, "delayedMailboxCreated", |
|
744 |
Qt::QueuedConnection, Q_ARG(NmId,mailboxId)); |
|
745 |
} |
|
47 | 746 |
|
44 | 747 |
// make sure the mailbox activity data is reseted |
748 |
deleteStoredMailboxActivity(mailboxId); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
749 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
750 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
751 |
case NmMailboxChanged: |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
752 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
753 |
// Mailbox name may have been changed |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
754 |
foreach (NmId mailboxId, mailboxIds) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
755 |
NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
756 |
NmMailbox *mailbox(NULL); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
757 |
NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
758 |
if (plugin) { |
51 | 759 |
plugin->getMailboxById(mailboxId,mailbox); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
760 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
761 |
if (mailbox && mailboxInfo) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
762 |
if(mailbox->name() != mailboxInfo->mName) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
763 |
mailboxInfo->mName = mailbox->name(); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
764 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
765 |
if (mailboxInfo->mActive) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
766 |
// Update the status of the mailbox |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
767 |
updateMailboxState(mailboxId, true, true); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
768 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
769 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
770 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
771 |
delete mailbox; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
772 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
773 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
774 |
case NmMailboxDeleted: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
775 |
foreach (NmId mailboxId, mailboxIds) { |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
776 |
// Will hide also the indicator |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
777 |
removeMailboxInfo(mailboxId); |
47 | 778 |
|
44 | 779 |
// make sure the mailbox activity data is deleted |
780 |
deleteStoredMailboxActivity(mailboxId); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
781 |
} |
43 | 782 |
updateUnreadIndicator(); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
783 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
784 |
default: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
785 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
786 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
787 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
788 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
789 |
/*! |
56 | 790 |
Called when mailbox is initialised with a delay. This may happen at least when |
51 | 791 |
NmMailboxCreated event is received. |
56 | 792 |
|
51 | 793 |
\param mailboxId id of the mailbox |
43 | 794 |
*/ |
51 | 795 |
void NmMailAgent::delayedMailboxCreated(const NmId mailboxId) |
796 |
{ |
|
797 |
NM_FUNCTION; |
|
798 |
||
799 |
// create and subscribe to the mailbox, if not done earlier |
|
800 |
getMailboxInfo(mailboxId); |
|
801 |
} |
|
802 |
||
803 |
/*! |
|
804 |
Map the type name to mailbox info. |
|
805 |
||
806 |
\param type Indicator type name |
|
807 |
\return NULL if no mailbox match the type |
|
808 |
*/ |
|
43 | 809 |
NmMailboxInfo *NmMailAgent::getMailboxByType(const QString &type) |
810 |
{ |
|
48 | 811 |
NM_FUNCTION; |
812 |
||
51 | 813 |
NmMailboxInfo *foundMailbox = NULL; |
43 | 814 |
foreach (NmMailboxInfo *mailbox, mMailboxes) { |
815 |
// mailbox is shown in indicators |
|
816 |
if (mailbox->mIndicatorIndex >= 0 && mailbox->mActive) { |
|
817 |
QString typeName = QString(NmMailboxIndicatorType).arg(mailbox->mIndicatorIndex); |
|
818 |
||
819 |
// type names match(!) |
|
51 | 820 |
if (type == typeName) { |
821 |
foundMailbox = mailbox; |
|
822 |
break; |
|
43 | 823 |
} |
824 |
} |
|
825 |
} |
|
51 | 826 |
return foundMailbox; |
43 | 827 |
} |
828 |
||
829 |
/*! |
|
830 |
Called when indicator is clicked from the indicator menu |
|
831 |
- indicator will be hide from the menu |
|
832 |
- mailbox will be launched |
|
51 | 833 |
|
834 |
\param type Indicator type name |
|
835 |
\param data Data sent by indicator |
|
836 |
*/ |
|
43 | 837 |
void NmMailAgent::indicatorActivated(const QString &type, const QVariantMap &data) |
838 |
{ |
|
839 |
NM_FUNCTION; |
|
840 |
Q_UNUSED(data); |
|
47 | 841 |
|
43 | 842 |
// map the indicator type to mailbox |
843 |
NmMailboxInfo *info = getMailboxByType(type); |
|
844 |
if (info) { |
|
845 |
info->mActive = false; // indicator is no longer active |
|
44 | 846 |
info->mInboxActive = false; // also inbox does not activate the indicator |
847 |
storeMailboxActive(info->mId, false); |
|
43 | 848 |
updateUnreadIndicator(); |
849 |
||
850 |
launchMailbox(info->mId.id()); |
|
851 |
} |
|
852 |
} |
|
853 |
||
854 |
/*! |
|
48 | 855 |
Called when cenrep key value has been changed. |
856 |
- only silence mode key handled |
|
857 |
||
51 | 858 |
\param key changed key |
859 |
\param value value for a key |
|
860 |
*/ |
|
861 |
void NmMailAgent::valueChanged(const XQSettingsKey &key, const QVariant &value) |
|
48 | 862 |
{ |
863 |
NM_FUNCTION; |
|
864 |
||
865 |
if(keysEqual(key, NmSilenceModeKey)) { |
|
866 |
mSilenceMode = value.toInt(); |
|
867 |
} |
|
868 |
} |
|
869 |
||
870 |
/*! |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
871 |
Received from NmFrameworkAdapter messageEvent signal |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
872 |
\sa NmFrameworkAdapter |
51 | 873 |
|
874 |
\param event Message event |
|
875 |
\param folderId Folder Id |
|
876 |
\param messageIds List of message Ids |
|
877 |
\param mailboxId Id of the mailbox |
|
878 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
879 |
void NmMailAgent::handleMessageEvent( |
51 | 880 |
NmMessageEvent event, |
881 |
const NmId &folderId, |
|
882 |
const QList<NmId> &messageIds, |
|
883 |
const NmId &mailboxId) |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
884 |
{ |
43 | 885 |
NM_FUNCTION; |
886 |
NM_COMMENT(QString("NmMailAgent::handleMessageEvent(): event=%1, id=%2"). |
|
887 |
arg(event).arg(mailboxId.id())); |
|
888 |
||
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
889 |
bool updateNeeded = false; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
890 |
bool activate = false; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
891 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
892 |
switch (event) { |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
893 |
case NmMessageCreated: { |
51 | 894 |
handleMessageCreatedEvent(folderId, messageIds, mailboxId, updateNeeded, activate); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
895 |
break; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
896 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
897 |
case NmMessageChanged: { |
56 | 898 |
handleMessageChangedEvent(folderId, messageIds, mailboxId, updateNeeded, activate); |
51 | 899 |
break; |
900 |
} |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
901 |
case NmMessageDeleted: { |
51 | 902 |
handleMessageDeletedEvent(folderId, messageIds, mailboxId, updateNeeded, activate); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
903 |
break; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
904 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
905 |
default: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
906 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
907 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
908 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
909 |
if (updateNeeded) { |
43 | 910 |
updateUnreadIndicator(); |
911 |
||
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
912 |
NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
913 |
updateMailboxState(mailboxId, |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
914 |
activate, true /* force refresh */); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
915 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
916 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
917 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
918 |
/*! |
51 | 919 |
Received from NmFrameworkAdapter syncStateEvent signal. |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
920 |
\sa NmFrameworkAdapter |
51 | 921 |
|
922 |
\param state state of synchronization |
|
923 |
\param event Information related to asynchronous operation |
|
924 |
||
925 |
*/ |
|
926 |
void NmMailAgent::handleSyncStateEvent(NmSyncState state, const NmOperationCompletionEvent &event) |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
927 |
{ |
43 | 928 |
NM_FUNCTION; |
929 |
NM_COMMENT(QString("NmMailAgent::handleSyncStateEvent(): state=%1, id=%2"). |
|
930 |
arg(state).arg(event.mMailboxId.id())); |
|
931 |
||
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
932 |
NmMailboxInfo *info = getMailboxInfo(event.mMailboxId); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
933 |
if (info) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
934 |
info->mSyncState = state; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
935 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
936 |
if (state==Synchronizing) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
937 |
// Reset counters when sync is started |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
938 |
info->mInboxCreatedMessages = 0; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
939 |
info->mInboxChangedMessages = 0; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
940 |
info->mInboxDeletedMessages = 0; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
941 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
942 |
else if (state==SyncComplete) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
943 |
// Check the unread status here again |
51 | 944 |
bool updateMailbox = updateUnreadCount(event.mMailboxId, *info); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
945 |
int oldOutboxCount = info->mOutboxMails; |
51 | 946 |
info->mOutboxMails = getOutboxCount(event.mMailboxId, info->mOutboxFolderId); |
947 |
int unreadMailCount(info->mUnreadMailIdList.count()); |
|
948 |
if (info->mOutboxMails > oldOutboxCount || unreadMailCount == 0) { |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
949 |
// new mails in outbox |
51 | 950 |
updateMailbox = true; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
951 |
} |
51 | 952 |
bool active = unreadMailCount || info->mOutboxMails; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
953 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
954 |
// Refresh the indicator if messages created or changed |
43 | 955 |
NM_COMMENT(QString("NmMailAgent::handleSyncStateEvent(): " |
956 |
"created=%1, changed=%2, deleted=%3"). |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
957 |
arg(info->mInboxCreatedMessages). |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
958 |
arg(info->mInboxChangedMessages). |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
959 |
arg(info->mInboxDeletedMessages)); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
960 |
bool refresh = (info->mInboxCreatedMessages > 0) || (info->mInboxChangedMessages > 0); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
961 |
|
43 | 962 |
updateUnreadIndicator(); |
963 |
||
51 | 964 |
if (updateMailbox) { |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
965 |
updateMailboxState(event.mMailboxId, active, refresh); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
966 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
967 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
968 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
969 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
970 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
971 |
/*! |
51 | 972 |
Received from NmFrameworkAdapter connectionState signal. |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
973 |
\sa NmFrameworkAdapter |
51 | 974 |
|
975 |
\param state Connection state |
|
976 |
\param mailboxId Id of the mailbox |
|
977 |
\parma errorcode Error code |
|
978 |
*/ |
|
40 | 979 |
void NmMailAgent::handleConnectionEvent(NmConnectState state, const NmId mailboxId, int errorcode) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
980 |
{ |
43 | 981 |
NM_FUNCTION; |
982 |
NM_COMMENT(QString("NmMailAgent::handleConnectionEvent(): state=%1, id=%2"). |
|
983 |
arg(state).arg(mailboxId.id())); |
|
984 |
Q_UNUSED(errorcode); |
|
985 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
986 |
NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
987 |
if (mailboxInfo) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
988 |
// Connecting, Connected, Disconnecting, Disconnected |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
989 |
mailboxInfo->mConnectState = state; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
990 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
991 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
992 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
993 |
/*! |
51 | 994 |
Remove a mailbox info entry. |
995 |
||
996 |
\param id Id of the mailbox |
|
997 |
\return true if mailbox info was found. |
|
998 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
999 |
bool NmMailAgent::removeMailboxInfo(const NmId &id) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1000 |
{ |
43 | 1001 |
NM_FUNCTION; |
1002 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1003 |
bool found = false; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1004 |
foreach (NmMailboxInfo *mailbox, mMailboxes) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1005 |
if (mailbox->mId == id) { |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1006 |
// Hide the indicator too |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1007 |
if(mailbox->mIndicatorIndex>=0) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1008 |
updateIndicator(false,*mailbox); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1009 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1010 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1011 |
found = true; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1012 |
mMailboxes.removeAll(mailbox); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1013 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1014 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1015 |
return found; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1016 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1017 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1018 |
/*! |
51 | 1019 |
Create a new mailbox info entry. |
1020 |
||
1021 |
\param id Id of the mailbox |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1022 |
\return new mailbox info object |
51 | 1023 |
*/ |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1024 |
NmMailboxInfo *NmMailAgent::createMailboxInfo(const NmId &id) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1025 |
{ |
43 | 1026 |
NM_FUNCTION; |
1027 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1028 |
// get information of the mailbox |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1029 |
NmMailbox *mailbox = NULL; |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1030 |
NmMailboxInfo *info = NULL; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1031 |
NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(id); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1032 |
if (plugin) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1033 |
plugin->getMailboxById(id, mailbox); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1034 |
if (mailbox) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1035 |
info = createMailboxInfo(*mailbox,plugin); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1036 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1037 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1038 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1039 |
return info; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1040 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1041 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1042 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1043 |
Create a new mailbox info with given parameters |
51 | 1044 |
|
1045 |
\param mailbox Mailbox which mailbox info will be created |
|
1046 |
\param plugin Interface to access email data |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1047 |
\return new mailbox info object |
51 | 1048 |
*/ |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1049 |
NmMailboxInfo *NmMailAgent::createMailboxInfo(const NmMailbox &mailbox, NmDataPluginInterface *plugin) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1050 |
{ |
43 | 1051 |
NM_FUNCTION; |
1052 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1053 |
NmMailboxInfo *mailboxInfo = new NmMailboxInfo(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1054 |
mailboxInfo->mId = mailbox.id(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1055 |
mailboxInfo->mName = mailbox.name(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1056 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1057 |
mMailboxes.append(mailboxInfo); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1058 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1059 |
// Subscribe to get all mailbox events |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1060 |
plugin->subscribeMailboxEvents(mailboxInfo->mId); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1061 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1062 |
// get inbox folder ID. It might be still unknown (=0). |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1063 |
mailboxInfo->mInboxFolderId = plugin->getStandardFolderId( |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1064 |
mailbox.id(), NmFolderInbox ); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1065 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1066 |
// get outbox folder ID |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1067 |
mailboxInfo->mOutboxFolderId = plugin->getStandardFolderId( |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1068 |
mailbox.id(), NmFolderOutbox ); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1069 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1070 |
// Get branded mailbox icon |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1071 |
NmMailbox mailbox2( mailbox ); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1072 |
QString domainName = mailbox2.address().address(); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1073 |
EmailMailboxInfo emailMailboxInfo; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1074 |
mailboxInfo->mIconName = |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1075 |
emailMailboxInfo.mailboxIcon(domainName); |
40 | 1076 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1077 |
return mailboxInfo; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1078 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1079 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1080 |
/*! |
51 | 1081 |
Return mailbox info class with mailbox id. If no class is found, |
1082 |
create a new instance with given id. |
|
1083 |
||
1084 |
\param id Id of the mailbox |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1085 |
\return mailbox info object |
51 | 1086 |
*/ |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1087 |
NmMailboxInfo *NmMailAgent::getMailboxInfo(const NmId &id) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1088 |
{ |
43 | 1089 |
NM_FUNCTION; |
1090 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1091 |
foreach (NmMailboxInfo *mailbox, mMailboxes) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1092 |
if (mailbox->mId == id) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1093 |
return mailbox; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1094 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1095 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1096 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1097 |
// Not found. Create a new mailbox info. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1098 |
return createMailboxInfo(id); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1099 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1100 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1101 |
/*! |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1102 |
Finds out if the message is unread. |
51 | 1103 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1104 |
\param folderId the id of the folder that includes the message |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1105 |
\param messageIds the message ids that are checked |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1106 |
\param mailboxId the id of the mailbox that includes the message |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1107 |
\param unreadMessage true if there was unread messages |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1108 |
\return true if info fetching was successful |
51 | 1109 |
*/ |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1110 |
bool NmMailAgent::getMessageUnreadInfo(const NmId &folderId, |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1111 |
const NmId &messageId, const NmId &mailboxId, bool &unreadMessage) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1112 |
{ |
43 | 1113 |
NM_FUNCTION; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1114 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1115 |
NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId); |
51 | 1116 |
bool ok(false); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1117 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1118 |
if (plugin) { |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1119 |
NmMessage *message=NULL; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1120 |
plugin->getMessageById(mailboxId, folderId, messageId, message); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1121 |
if (message) { |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1122 |
ok = true; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1123 |
NmMessageEnvelope envelope = message->envelope(); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1124 |
if (!envelope.isRead()) { |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1125 |
unreadMessage = true; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1126 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1127 |
delete message; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1128 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1129 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1130 |
return ok; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1131 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1132 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1133 |
/*! |
51 | 1134 |
Plays email alert tone when new messages arrive. |
1135 |
||
43 | 1136 |
\returns true if the tone was played |
51 | 1137 |
*/ |
43 | 1138 |
bool NmMailAgent::playAlertTone() |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1139 |
{ |
43 | 1140 |
NM_FUNCTION; |
51 | 1141 |
bool played(false); |
43 | 1142 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1143 |
if (mAlertToneAllowed) { |
48 | 1144 |
// Play tone only if system tone service is available and |
1145 |
// phone is not in silence mode. |
|
1146 |
if (mSystemTone && !mSilenceMode) { |
|
47 | 1147 |
mSystemTone->playTone(XQSystemToneService::EmailAlertTone); |
1148 |
} |
|
1149 |
||
44 | 1150 |
// Execute the vibra effect. |
1151 |
if (mVibra) { |
|
1152 |
TRAP_IGNORE(mVibra->StartVibraL(NmAgentDefaultVibraDuration)); |
|
1153 |
} |
|
47 | 1154 |
|
43 | 1155 |
// play alert only once per minute |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1156 |
mAlertToneAllowed = false; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1157 |
QTimer::singleShot(NmAgentAlertToneTimer, this, SLOT(enableAlertTone())); |
51 | 1158 |
played = true; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1159 |
} |
44 | 1160 |
|
51 | 1161 |
return played; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1162 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1163 |
|
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1164 |
/*! |
51 | 1165 |
Allows alert tune to be played again. |
1166 |
*/ |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1167 |
void NmMailAgent::enableAlertTone() |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1168 |
{ |
43 | 1169 |
NM_FUNCTION; |
1170 |
||
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1171 |
mAlertToneAllowed = true; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1172 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
1173 |
|
43 | 1174 |
/*! |
51 | 1175 |
Update send indicator according to outbox state. |
1176 |
*/ |
|
43 | 1177 |
void NmMailAgent::updateSendIndicator() |
1178 |
{ |
|
48 | 1179 |
NM_FUNCTION; |
1180 |
||
43 | 1181 |
// Get number of mails in outboxes |
51 | 1182 |
int outboxMails(0); |
43 | 1183 |
foreach (NmMailboxInfo *mailboxInfo, mMailboxes) { |
1184 |
outboxMails += mailboxInfo->mOutboxMails; |
|
1185 |
} |
|
1186 |
||
1187 |
if( outboxMails == 0 ) { |
|
1188 |
mIndicator->deactivate(NmSendIndicatorName); |
|
1189 |
} |
|
1190 |
else if (outboxMails > mLastOutboxCount) { |
|
1191 |
// New mails detected in outbox |
|
1192 |
||
51 | 1193 |
// indicator will disappear automatically after a delay |
43 | 1194 |
mIndicator->activate(NmSendIndicatorName); |
51 | 1195 |
} |
43 | 1196 |
|
51 | 1197 |
mLastOutboxCount = outboxMails; |
43 | 1198 |
} |
1199 |
||
44 | 1200 |
/*! |
51 | 1201 |
Store the mailbox active information to permanent storage. |
1202 |
||
1203 |
\param mailboxId Id of the mailbox |
|
44 | 1204 |
\param active true if the mailbox is active |
51 | 1205 |
*/ |
44 | 1206 |
void NmMailAgent::storeMailboxActive(const NmId &mailboxId, bool active) |
1207 |
{ |
|
48 | 1208 |
NM_FUNCTION; |
1209 |
||
1210 |
if (mSettingManager) { |
|
1211 |
XQCentralRepositorySettingsKey key(NmRepositoryId, mailboxId.id()); |
|
1212 |
XQCentralRepositoryUtils utils(*mSettingManager); |
|
47 | 1213 |
|
48 | 1214 |
if (active) { |
1215 |
// when mailbox is active, key can be deleted |
|
1216 |
utils.deleteKey(key); |
|
1217 |
} |
|
1218 |
else { |
|
1219 |
utils.createKey(key,(int)active); |
|
1220 |
} |
|
44 | 1221 |
} |
1222 |
} |
|
1223 |
||
1224 |
/*! |
|
47 | 1225 |
Get the mailbox activity state. |
51 | 1226 |
|
44 | 1227 |
\param mailboxId id of the mailbox |
1228 |
\return true if the mailbox is active or no information was stored earlier |
|
51 | 1229 |
*/ |
44 | 1230 |
bool NmMailAgent::isMailboxActive(const NmId &mailboxId) |
1231 |
{ |
|
48 | 1232 |
NM_FUNCTION; |
1233 |
||
1234 |
bool mailboxActive(true); |
|
1235 |
if (mSettingManager) { |
|
1236 |
XQCentralRepositorySettingsKey key(NmRepositoryId, mailboxId.id()); |
|
1237 |
QVariant value = mSettingManager->readItemValue(key, XQSettingsManager::TypeInt); |
|
1238 |
if (value.isValid()) { |
|
1239 |
NM_COMMENT(QString("NmMailAgent::isMailboxActive - value=%1").arg(value.toInt())); |
|
1240 |
mailboxActive = value.toInt(); |
|
1241 |
} |
|
44 | 1242 |
} |
48 | 1243 |
return mailboxActive; |
44 | 1244 |
} |
1245 |
||
1246 |
/*! |
|
51 | 1247 |
Delete all stored activity information for the mailbox id. |
1248 |
||
44 | 1249 |
\param mailboxId id of the mailbox |
51 | 1250 |
*/ |
44 | 1251 |
void NmMailAgent::deleteStoredMailboxActivity(const NmId &mailboxId) |
1252 |
{ |
|
48 | 1253 |
NM_FUNCTION; |
1254 |
||
44 | 1255 |
// deactivation delete the key too |
51 | 1256 |
storeMailboxActive(mailboxId, false); |
44 | 1257 |
} |
1258 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1259 |
// End of file |