|
1 /* |
|
2 * Copyright (c) 2009 - 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "nmuiengineheaders.h" |
|
20 |
|
21 /*! |
|
22 \class NmUiEngine |
|
23 \brief NmUiEngine provides a controller-type services for the email UI. |
|
24 |
|
25 */ |
|
26 |
|
27 NmUiEngine *NmUiEngine::mInstance; |
|
28 int NmUiEngine::mReferenceCount; |
|
29 |
|
30 const QString syncIndicatorName = "com.nokia.nmail.indicatorplugin.sync/1.0"; |
|
31 |
|
32 /*! |
|
33 Constructor |
|
34 */ |
|
35 NmUiEngine::NmUiEngine() |
|
36 : mMailboxListModel(NULL), |
|
37 mInboxListModel(NULL), |
|
38 mMessageListModel(NULL), |
|
39 mMessageSearchListModel(NULL), |
|
40 mSendOperation(NULL), |
|
41 mRemoveDraftOperation(NULL), |
|
42 mSaveDraftOperation(NULL), |
|
43 mDraftMessage(NULL) |
|
44 { |
|
45 NM_FUNCTION; |
|
46 |
|
47 mPluginFactory = NmDataPluginFactory::instance(); |
|
48 mDataManager = new NmDataManager(); |
|
49 // Connect to the plugins to receive change notifications |
|
50 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
|
51 for (int i(0); i < dataPlugins->count(); i++) { |
|
52 QObject *plugin = (*dataPlugins)[i]; |
|
53 if (plugin) { |
|
54 // connet mailbox events |
|
55 QObject::connect(plugin, SIGNAL(mailboxEvent(NmMailboxEvent, const QList<NmId> &)), |
|
56 this, SLOT(handleMailboxEvent(NmMailboxEvent, const QList<NmId> &)), |
|
57 Qt::UniqueConnection); |
|
58 // connect message events |
|
59 QObject::connect(plugin, |
|
60 SIGNAL(messageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)), |
|
61 this, SLOT(handleMessageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)), |
|
62 Qt::UniqueConnection); |
|
63 // connect connection events |
|
64 QObject::connect(plugin, |
|
65 SIGNAL(connectionEvent(NmConnectState, const NmId &, const int)), |
|
66 this, |
|
67 SLOT(handleConnectEvent(NmConnectState, const NmId &, const int)), |
|
68 Qt::UniqueConnection); |
|
69 // do the subscriptions also |
|
70 NmDataPluginInterface *pluginInterface = mPluginFactory->interfaceInstance(plugin); |
|
71 if (pluginInterface) { |
|
72 QList<NmId> mailboxIdList; |
|
73 pluginInterface->listMailboxIds(mailboxIdList); |
|
74 for (int j(0); j < mailboxIdList.count(); j++) { |
|
75 pluginInterface->subscribeMailboxEvents(mailboxIdList[j]); |
|
76 } |
|
77 mailboxIdList.clear(); |
|
78 } |
|
79 } |
|
80 } |
|
81 } |
|
82 |
|
83 |
|
84 /*! |
|
85 Class destructor. |
|
86 */ |
|
87 NmUiEngine::~NmUiEngine() |
|
88 { |
|
89 NM_FUNCTION; |
|
90 |
|
91 enableSyncIndicator(false); |
|
92 |
|
93 if (mMessageSearchListModel) { |
|
94 delete mMessageSearchListModel; |
|
95 mMessageSearchListModel = NULL; |
|
96 } |
|
97 |
|
98 if (mInboxListModel) { |
|
99 delete mInboxListModel; |
|
100 mInboxListModel = NULL; |
|
101 } |
|
102 |
|
103 if (mMessageListModel) { |
|
104 delete mMessageListModel; |
|
105 mMessageListModel = NULL; |
|
106 } |
|
107 |
|
108 if (mMailboxListModel) { |
|
109 delete mMailboxListModel; |
|
110 mMailboxListModel = NULL; |
|
111 } |
|
112 |
|
113 // Do the unsubscriptions. |
|
114 QList<NmId> mailboxIdList; |
|
115 mDataManager->listMailboxIds(mailboxIdList); |
|
116 |
|
117 for (int i(0); i < mailboxIdList.count(); i++) { |
|
118 NmId id = mailboxIdList[i]; |
|
119 NmDataPluginInterface *pluginInterface = |
|
120 mPluginFactory->interfaceInstance(id); |
|
121 |
|
122 if (pluginInterface) { |
|
123 pluginInterface->unsubscribeMailboxEvents(id); |
|
124 } |
|
125 } |
|
126 |
|
127 mailboxIdList.clear(); |
|
128 |
|
129 NmDataPluginFactory::releaseInstance(mPluginFactory); |
|
130 |
|
131 delete mDataManager; |
|
132 |
|
133 // Cancel all operations. |
|
134 if (mSendOperation && mSendOperation->isRunning()) { |
|
135 mSendOperation->cancelOperation(); |
|
136 } |
|
137 |
|
138 if (mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) { |
|
139 mRemoveDraftOperation->cancelOperation(); |
|
140 } |
|
141 |
|
142 if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) { |
|
143 mSaveDraftOperation->cancelOperation(); |
|
144 } |
|
145 |
|
146 // Call processEvents() to ensure that the cancelled operations get the time |
|
147 // they need to destroy themselves. |
|
148 qApp->processEvents(); |
|
149 |
|
150 if(mDraftMessage) { |
|
151 delete mDraftMessage; |
|
152 mDraftMessage = NULL; |
|
153 } |
|
154 } |
|
155 |
|
156 |
|
157 /*! |
|
158 |
|
159 */ |
|
160 NmUiEngine *NmUiEngine::instance() |
|
161 { |
|
162 NM_FUNCTION; |
|
163 |
|
164 if (!mInstance) { |
|
165 mInstance = new NmUiEngine(); |
|
166 } |
|
167 mReferenceCount++; |
|
168 return mInstance; |
|
169 } |
|
170 |
|
171 /*! |
|
172 |
|
173 */ |
|
174 void NmUiEngine::releaseInstance(NmUiEngine *&instance) |
|
175 { |
|
176 NM_FUNCTION; |
|
177 |
|
178 //can't have passed out instances if we don't have any |
|
179 if (mInstance) { |
|
180 if(instance == mInstance) { |
|
181 instance = NULL; |
|
182 mReferenceCount--; |
|
183 } |
|
184 if (0 >= mReferenceCount) { |
|
185 delete mInstance; |
|
186 mInstance = NULL; |
|
187 } |
|
188 } |
|
189 } |
|
190 |
|
191 /*! |
|
192 Returns a list model populated with the mailbox and top level folder objects. The model is |
|
193 updated dynamically. The ownership of the model object is not moved to the caller. |
|
194 */ |
|
195 NmMailboxListModel &NmUiEngine::mailboxListModel() |
|
196 { |
|
197 NM_FUNCTION; |
|
198 |
|
199 if (!mMailboxListModel) { |
|
200 refreshMailboxListModel(); // creates the model too |
|
201 } |
|
202 |
|
203 return *mMailboxListModel; |
|
204 } |
|
205 |
|
206 /*! |
|
207 Populate the list model with the mailbox and top level folder objects. The model is |
|
208 updated dynamically. Creates the model if needed. |
|
209 */ |
|
210 void NmUiEngine::refreshMailboxListModel() |
|
211 { |
|
212 NM_FUNCTION; |
|
213 |
|
214 if (!mMailboxListModel) { |
|
215 mMailboxListModel = new NmMailboxListModel(*mDataManager); |
|
216 |
|
217 // Connect the model to the plugins to receive change notifications |
|
218 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
|
219 for (int i = 0; i < dataPlugins->count(); i++) { |
|
220 QObject *plugin = (*dataPlugins)[i]; |
|
221 if (plugin) { |
|
222 connect(plugin, SIGNAL(mailboxEvent(NmMailboxEvent, const QList<NmId> &)), |
|
223 mMailboxListModel, SLOT(handleMailboxEvent(NmMailboxEvent, const QList<NmId> &))); |
|
224 } |
|
225 } |
|
226 } else { |
|
227 mMailboxListModel->clear(); |
|
228 } |
|
229 |
|
230 QList<NmMailbox*> mailboxList; |
|
231 mDataManager->listMailboxes(mailboxList); |
|
232 mMailboxListModel->refresh(mailboxList); |
|
233 while (!mailboxList.isEmpty()) { |
|
234 delete mailboxList.takeFirst(); |
|
235 } |
|
236 } |
|
237 |
|
238 |
|
239 /*! |
|
240 Returns a message list model for a folder identified by \a mailboxId and |
|
241 \a folderId. The model is updated dynamically. The ownership of the model |
|
242 object is not moved to the caller. |
|
243 */ |
|
244 NmMessageListModel &NmUiEngine::messageListModel(const NmId &mailboxId, |
|
245 const NmId &folderId) |
|
246 { |
|
247 NM_FUNCTION; |
|
248 |
|
249 QObject *plugin = mPluginFactory->pluginInstance(mailboxId); |
|
250 bool isInbox(false); |
|
251 if (standardFolderId(mailboxId,NmFolderInbox)==folderId){ |
|
252 isInbox=true; |
|
253 } |
|
254 if (plugin) { |
|
255 // Connect plugin message events to handler slot messageEventForListModel |
|
256 QObject::connect(plugin, SIGNAL(messageEvent(NmMessageEvent, const NmId &, |
|
257 const QList<NmId> &, const NmId&)), |
|
258 this, SLOT(messageEventForListModel(NmMessageEvent, |
|
259 const NmId &, const QList<NmId> &, const NmId&)), Qt::UniqueConnection ); |
|
260 // Create inbox list model only once when entering to inbox for the first time |
|
261 // or re-create inbox list model when mailbox has changed |
|
262 if ((!mInboxListModel&&isInbox)|| |
|
263 (mInboxListModel&&isInbox&&mailboxId!=mInboxListModel->currentMailboxId())){ |
|
264 // Delete previous model and set to NULL. Deleting model will also |
|
265 // delete all items in model. |
|
266 if (mInboxListModel){ |
|
267 delete mInboxListModel; |
|
268 mInboxListModel=NULL; |
|
269 } |
|
270 // Create new inbox model |
|
271 mInboxListModel = new NmMessageListModel(*mDataManager); |
|
272 // Initial fill up of inbox list model, otherwise updated in the background |
|
273 QList<NmMessageEnvelope*> messageEnvelopeList; |
|
274 mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList); |
|
275 mInboxListModel->refresh(mailboxId, folderId, messageEnvelopeList); |
|
276 |
|
277 while (!messageEnvelopeList.isEmpty()) { |
|
278 delete messageEnvelopeList.takeFirst(); |
|
279 } |
|
280 } |
|
281 // Selected folder is not inbox folder for the mailbox |
|
282 else if (!isInbox){ |
|
283 // Recreate model for other folders when needed, previous model |
|
284 // items are deleted from the memory with the old model |
|
285 if (mMessageListModel){ |
|
286 delete mMessageListModel; |
|
287 mMessageListModel=NULL; |
|
288 } |
|
289 mMessageListModel = new NmMessageListModel(*mDataManager); |
|
290 |
|
291 // Fill up other model |
|
292 QList<NmMessageEnvelope*> messageEnvelopeList; |
|
293 mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList); |
|
294 mMessageListModel->refresh(mailboxId, folderId, messageEnvelopeList); |
|
295 |
|
296 while (!messageEnvelopeList.isEmpty()) { |
|
297 delete messageEnvelopeList.takeFirst(); |
|
298 } |
|
299 } |
|
300 } |
|
301 |
|
302 // Connect sync state changed |
|
303 if (plugin){ |
|
304 QObject::connect( |
|
305 plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
|
306 this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
|
307 Qt::UniqueConnection); |
|
308 } |
|
309 NmMessageListModel* ret(NULL); |
|
310 if (isInbox){ |
|
311 ret = mInboxListModel; |
|
312 // Inbox list model is queried, other model is not |
|
313 // needed anymore and memory should be freeded |
|
314 if (mMessageListModel){ |
|
315 delete mMessageListModel; |
|
316 mMessageListModel=NULL; |
|
317 } |
|
318 } |
|
319 else { |
|
320 ret = mMessageListModel; |
|
321 } |
|
322 return *ret; |
|
323 } |
|
324 |
|
325 |
|
326 /*! |
|
327 Returns a message list model used in the search view. |
|
328 |
|
329 \param mailboxId The ID of the mailbox to search messages from. |
|
330 |
|
331 \return A message list model. |
|
332 */ |
|
333 NmMessageListModel &NmUiEngine::messageListModelForSearch(const NmId &mailboxId) |
|
334 { |
|
335 NM_FUNCTION; |
|
336 |
|
337 Q_UNUSED(mailboxId); |
|
338 |
|
339 if (!mMessageSearchListModel) { |
|
340 mMessageSearchListModel = new NmMessageListModel(*mDataManager); |
|
341 mMessageSearchListModel->setIgnoreFolderIds(true); |
|
342 } |
|
343 else { |
|
344 mMessageSearchListModel->clear(); |
|
345 } |
|
346 |
|
347 QObject *plugin = mPluginFactory->pluginInstance(mailboxId); |
|
348 |
|
349 if (plugin) { |
|
350 QObject::connect(plugin, |
|
351 SIGNAL(messageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)), |
|
352 mMessageSearchListModel, |
|
353 SLOT(handleMessageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)), |
|
354 Qt::UniqueConnection); |
|
355 } |
|
356 |
|
357 // Refresh to set the mailbox ID. |
|
358 QList<NmMessageEnvelope*> messageEnvelopeList; |
|
359 mMessageSearchListModel->refresh(mailboxId, 0, messageEnvelopeList); |
|
360 |
|
361 return *mMessageSearchListModel; |
|
362 } |
|
363 |
|
364 |
|
365 /*! |
|
366 Get the identifier of the standard folder of a type \a folderType |
|
367 from the mailbox \a mailboxId. |
|
368 */ |
|
369 NmId NmUiEngine::standardFolderId( |
|
370 const NmId &mailboxId, |
|
371 NmFolderType folderType) |
|
372 { |
|
373 NM_FUNCTION; |
|
374 |
|
375 NmId value; |
|
376 if (folderType != NmFolderOther) { |
|
377 NmDataPluginInterface *plugin = |
|
378 mPluginFactory->interfaceInstance(mailboxId); |
|
379 if(plugin) { |
|
380 value = plugin->getStandardFolderId(mailboxId, folderType); |
|
381 } |
|
382 } |
|
383 return value; |
|
384 } |
|
385 |
|
386 /*! |
|
387 Returns a message identified by \a mailboxId, \a folderId and \amessageId. |
|
388 The ownership of the object is moved to the caller. |
|
389 Returns null pointer if the message is not found. |
|
390 */ |
|
391 NmMessage *NmUiEngine::message(const NmId &mailboxId, |
|
392 const NmId &folderId, |
|
393 const NmId &messageId) |
|
394 { |
|
395 NM_FUNCTION; |
|
396 |
|
397 NmMessage *message = mDataManager->message(mailboxId, folderId, messageId); |
|
398 return message; |
|
399 } |
|
400 |
|
401 /*! |
|
402 |
|
403 */ |
|
404 QPointer<NmOperation> NmUiEngine::fetchMessage( const NmId &mailboxId, |
|
405 const NmId &folderId, |
|
406 const NmId &messageId ) |
|
407 { |
|
408 NM_FUNCTION; |
|
409 |
|
410 QPointer<NmOperation> value(NULL); |
|
411 NmDataPluginInterface *plugin = |
|
412 mPluginFactory->interfaceInstance(mailboxId); |
|
413 if (plugin) { |
|
414 value = plugin->fetchMessage(mailboxId, folderId, messageId); |
|
415 } |
|
416 return value; |
|
417 } |
|
418 |
|
419 /*! |
|
420 |
|
421 */ |
|
422 QPointer<NmOperation> NmUiEngine::fetchMessagePart( |
|
423 const NmId &mailboxId, |
|
424 const NmId &folderId, |
|
425 const NmId &messageId, |
|
426 const NmId &messagePartId) |
|
427 { |
|
428 NM_FUNCTION; |
|
429 |
|
430 QPointer<NmOperation> value(NULL); |
|
431 NmDataPluginInterface *plugin = |
|
432 mPluginFactory->interfaceInstance(mailboxId); |
|
433 if (plugin) { |
|
434 value = plugin->fetchMessagePart(mailboxId, folderId, messageId, messagePartId); |
|
435 } |
|
436 return value; |
|
437 } |
|
438 |
|
439 /*! |
|
440 |
|
441 */ |
|
442 QPointer<NmOperation> NmUiEngine::fetchMessageParts( |
|
443 const NmId &mailboxId, |
|
444 const NmId &folderId, |
|
445 const NmId &messageId, |
|
446 const QList<NmId> &messagePartIds) |
|
447 { |
|
448 NM_FUNCTION; |
|
449 |
|
450 QPointer<NmOperation> value(NULL); |
|
451 NmDataPluginInterface *plugin = |
|
452 mPluginFactory->interfaceInstance(mailboxId); |
|
453 if (plugin) { |
|
454 value = plugin->fetchMessageParts(mailboxId, folderId, messageId, messagePartIds); |
|
455 } |
|
456 return value; |
|
457 } |
|
458 |
|
459 /*! |
|
460 |
|
461 */ |
|
462 XQSharableFile NmUiEngine::messagePartFile( |
|
463 const NmId &mailboxId, |
|
464 const NmId &folderId, |
|
465 const NmId &messageId, |
|
466 const NmId &messagePartId) |
|
467 { |
|
468 NM_FUNCTION; |
|
469 |
|
470 NmDataPluginInterface *plugin = |
|
471 mPluginFactory->interfaceInstance(mailboxId); |
|
472 if (plugin) { |
|
473 return plugin->messagePartFile(mailboxId, folderId, messageId, messagePartId); |
|
474 } |
|
475 else { |
|
476 // empty file handle |
|
477 return XQSharableFile(); |
|
478 } |
|
479 } |
|
480 /*! |
|
481 Get content to message part |
|
482 */ |
|
483 int NmUiEngine::contentToMessagePart( |
|
484 const NmId &mailboxId, |
|
485 const NmId &folderId, |
|
486 const NmId &messageId, |
|
487 NmMessagePart &messagePart) |
|
488 { |
|
489 NM_FUNCTION; |
|
490 |
|
491 return mDataManager->contentToMessagePart(mailboxId, folderId, messageId, messagePart); |
|
492 } |
|
493 |
|
494 |
|
495 /*! |
|
496 Deletes messages from the model and forwards the call to plugin. |
|
497 |
|
498 \param mailboxId The ID of the mailbox which contains the deleted message(s). |
|
499 \param folderId The ID of the folder which contains the deleted message(s). |
|
500 \param messageIdList A list containing the IDs of the message to be deleted. |
|
501 |
|
502 \return A possible error code (returned by the plugin). |
|
503 */ |
|
504 int NmUiEngine::deleteMessages(const NmId &mailboxId, |
|
505 const NmId &folderId, |
|
506 const QList<NmId> &messageIdList) |
|
507 { |
|
508 NM_FUNCTION; |
|
509 |
|
510 int result(NmNotFoundError); |
|
511 |
|
512 bool isInbox(false); |
|
513 if (standardFolderId(mailboxId,NmFolderInbox)==folderId){ |
|
514 isInbox=true; |
|
515 } |
|
516 if (isInbox&&mInboxListModel){ |
|
517 mInboxListModel->handleMessageEvent(NmMessageDeleted, folderId, |
|
518 messageIdList, mailboxId); |
|
519 } |
|
520 else if (mMessageListModel) { |
|
521 mMessageListModel->handleMessageEvent(NmMessageDeleted, folderId, |
|
522 messageIdList, mailboxId); |
|
523 } |
|
524 |
|
525 // If the search list model exists and contains message, remove the |
|
526 // message from it too. |
|
527 if (mMessageSearchListModel && mMessageSearchListModel->rowCount()) { |
|
528 mMessageSearchListModel->handleMessageEvent(NmMessageDeleted, folderId, |
|
529 messageIdList, mailboxId); |
|
530 } |
|
531 |
|
532 NmDataPluginInterface *plugin = |
|
533 mPluginFactory->interfaceInstance(mailboxId); |
|
534 |
|
535 if (plugin) { |
|
536 result = plugin->deleteMessages(mailboxId, folderId, messageIdList); |
|
537 } |
|
538 |
|
539 return result; |
|
540 } |
|
541 |
|
542 |
|
543 /*! |
|
544 Sets the envelope property for the given envelopes. |
|
545 The operation is automatically deleted after the completion or cancelling. |
|
546 |
|
547 \param mailboxId The ID of the mailbox containing the envelope(s). |
|
548 \param folderId The ID of the folder containing the envelope(s). |
|
549 \param property The property to set. |
|
550 \param envelopeList The list containing the envelopes. |
|
551 |
|
552 \return The constructed operation. |
|
553 */ |
|
554 QPointer<NmStoreEnvelopesOperation> NmUiEngine::setEnvelopes( |
|
555 const NmId &mailboxId, |
|
556 const NmId &folderId, |
|
557 NmEnvelopeProperties property, |
|
558 const QList<const NmMessageEnvelope*> &envelopeList) |
|
559 { |
|
560 NM_FUNCTION; |
|
561 |
|
562 QPointer<NmStoreEnvelopesOperation> operation(NULL); |
|
563 NmMessageListModel *theMessageListModel = mMessageListModel; |
|
564 |
|
565 if (!theMessageListModel) { |
|
566 theMessageListModel = &messageListModel(mailboxId, folderId); |
|
567 } |
|
568 |
|
569 if (theMessageListModel && envelopeList.count()) { |
|
570 QList<NmId> messageIdList; |
|
571 |
|
572 for (int i(0); i < envelopeList.count(); i++){ |
|
573 messageIdList.append(envelopeList[i]->messageId()); |
|
574 } |
|
575 |
|
576 theMessageListModel->setEnvelopeProperties(property, messageIdList); |
|
577 |
|
578 if (mMessageSearchListModel && mMessageSearchListModel->rowCount()) { |
|
579 // Update the envelopes in the search list model as well. |
|
580 mMessageSearchListModel->setEnvelopeProperties(property, |
|
581 messageIdList); |
|
582 } |
|
583 |
|
584 // Store the new envelopes to plugin. |
|
585 NmDataPluginInterface *plugin = |
|
586 mPluginFactory->interfaceInstance(mailboxId); |
|
587 |
|
588 if (plugin) { |
|
589 operation = |
|
590 plugin->storeEnvelopes(mailboxId, folderId, envelopeList); |
|
591 } |
|
592 |
|
593 messageIdList.clear(); |
|
594 } |
|
595 |
|
596 return operation; |
|
597 } |
|
598 |
|
599 |
|
600 /*! |
|
601 Returns a mailbox meta data object from model with the ID \a mailboxId. |
|
602 Ownership of the return value is not moved to the caller. |
|
603 Returns NULL if the mailbox is not found. |
|
604 */ |
|
605 NmMailboxMetaData *NmUiEngine::mailboxById(const NmId &mailboxId) |
|
606 { |
|
607 NmMailboxMetaData *meta(NULL); |
|
608 if (mMailboxListModel) { |
|
609 for (int i(0); i < mMailboxListModel->rowCount(); i++) { |
|
610 QModelIndex index = mMailboxListModel->index(i,0); |
|
611 NmMailboxMetaData *mailbox = |
|
612 mMailboxListModel->data(index, Qt::DisplayRole).value<NmMailboxMetaData*>(); |
|
613 if (mailbox && mailbox->id() == mailboxId) { |
|
614 meta = mailbox; |
|
615 break; |
|
616 } |
|
617 } |
|
618 } |
|
619 return meta; |
|
620 } |
|
621 |
|
622 |
|
623 /*! |
|
624 Creates a new message (into Drafts-folder). |
|
625 Operation is automatically deleted after completion or cancelling. |
|
626 */ |
|
627 QPointer<NmMessageCreationOperation> NmUiEngine::createNewMessage(const NmId &mailboxId) |
|
628 { |
|
629 NM_FUNCTION; |
|
630 |
|
631 QPointer<NmMessageCreationOperation> value(NULL); |
|
632 NmDataPluginInterface *plugin = |
|
633 mPluginFactory->interfaceInstance(mailboxId); |
|
634 if (plugin) { |
|
635 value = plugin->createNewMessage(mailboxId); |
|
636 } |
|
637 return value; |
|
638 } |
|
639 |
|
640 /*! |
|
641 Creates a new forward message (into Drafts-folder). |
|
642 Operation is automatically deleted after completion or cancelling. |
|
643 */ |
|
644 QPointer<NmMessageCreationOperation> NmUiEngine::createForwardMessage( |
|
645 const NmId &mailboxId, |
|
646 const NmId &originalMessageId) |
|
647 { |
|
648 NM_FUNCTION; |
|
649 |
|
650 QPointer<NmMessageCreationOperation> value(NULL); |
|
651 NmDataPluginInterface *plugin = |
|
652 mPluginFactory->interfaceInstance(mailboxId); |
|
653 if (plugin) { |
|
654 value = plugin->createForwardMessage(mailboxId, originalMessageId); |
|
655 } |
|
656 return value; |
|
657 } |
|
658 |
|
659 /*! |
|
660 Creates a new reply message (into Drafts-folder). |
|
661 Operation is automatically deleted after completion or cancelling. |
|
662 */ |
|
663 QPointer<NmMessageCreationOperation> NmUiEngine::createReplyMessage( |
|
664 const NmId &mailboxId, |
|
665 const NmId &originalMessageId, |
|
666 bool replyAll) |
|
667 { |
|
668 NM_FUNCTION; |
|
669 |
|
670 QPointer<NmMessageCreationOperation> value(NULL); |
|
671 NmDataPluginInterface *plugin = |
|
672 mPluginFactory->interfaceInstance(mailboxId); |
|
673 if (plugin) { |
|
674 value = plugin->createReplyMessage(mailboxId, originalMessageId, replyAll); |
|
675 } |
|
676 return value; |
|
677 } |
|
678 |
|
679 /*! |
|
680 Saves a message (into message store). |
|
681 */ |
|
682 int NmUiEngine::saveMessage(const NmMessage &message) |
|
683 { |
|
684 NM_FUNCTION; |
|
685 |
|
686 const NmId &mailboxId = message.envelope().mailboxId(); |
|
687 int ret(NmNotFoundError); |
|
688 NmDataPluginInterface *plugin = |
|
689 mPluginFactory->interfaceInstance(mailboxId); |
|
690 if (plugin) { |
|
691 ret = plugin->saveMessage(message); |
|
692 } |
|
693 return ret; |
|
694 } |
|
695 |
|
696 /*! |
|
697 Refreshes mailbox. |
|
698 */ |
|
699 int NmUiEngine::refreshMailbox(const NmId &mailboxId ) |
|
700 { |
|
701 NM_FUNCTION; |
|
702 |
|
703 int ret(NmNotFoundError); |
|
704 NmDataPluginInterface *plugin = |
|
705 mPluginFactory->interfaceInstance(mailboxId); |
|
706 if (plugin) { |
|
707 ret = plugin->refreshMailbox(mailboxId); |
|
708 if (NmNoError == ret) { |
|
709 enableSyncIndicator(true); |
|
710 } |
|
711 } |
|
712 return ret; |
|
713 } |
|
714 |
|
715 /*! |
|
716 Online mailbox. |
|
717 */ |
|
718 int NmUiEngine::goOnline(const NmId &mailboxId ) |
|
719 { |
|
720 NM_FUNCTION; |
|
721 |
|
722 int ret(NmNotFoundError); |
|
723 NmDataPluginInterface *plugin = |
|
724 mPluginFactory->interfaceInstance(mailboxId); |
|
725 if (plugin) { |
|
726 ret = plugin->goOnline(mailboxId); |
|
727 } |
|
728 return ret; |
|
729 } |
|
730 |
|
731 /*! |
|
732 Offline mailbox. |
|
733 */ |
|
734 int NmUiEngine::goOffline(const NmId &mailboxId ) |
|
735 { |
|
736 NM_FUNCTION; |
|
737 |
|
738 int ret(NmNotFoundError); |
|
739 NmDataPluginInterface *plugin = |
|
740 mPluginFactory->interfaceInstance(mailboxId); |
|
741 if (plugin) { |
|
742 ret = plugin->goOffline(mailboxId); |
|
743 } |
|
744 return ret; |
|
745 } |
|
746 |
|
747 /*! |
|
748 Removes message from given mailbox and folder |
|
749 - routes call to plugin |
|
750 */ |
|
751 int NmUiEngine::removeMessage( |
|
752 const NmId &mailboxId, |
|
753 const NmId &folderId, |
|
754 const NmId &messageId) |
|
755 { |
|
756 NM_FUNCTION; |
|
757 |
|
758 int result(NmNotFoundError); |
|
759 NmDataPluginInterface *plugin = |
|
760 mPluginFactory->interfaceInstance(mailboxId); |
|
761 if (plugin) { |
|
762 result = plugin->removeMessage(mailboxId, folderId, messageId); |
|
763 } |
|
764 return result; |
|
765 } |
|
766 |
|
767 |
|
768 /*! |
|
769 Handles draft message deletion after editor has closed, takes ownership of message. |
|
770 */ |
|
771 void NmUiEngine::removeDraftMessage(NmMessage *message) |
|
772 { |
|
773 NM_FUNCTION; |
|
774 |
|
775 if (message) { |
|
776 NmDataPluginInterface *plugin = |
|
777 mPluginFactory->interfaceInstance(message->envelope().mailboxId()); |
|
778 |
|
779 if (plugin) { |
|
780 // to be on the safer side: |
|
781 // we shouldn't even be here if mRemoveDraftOperation != NULL |
|
782 if (mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) { |
|
783 mRemoveDraftOperation->cancelOperation(); |
|
784 } |
|
785 // ownership of message changes |
|
786 mRemoveDraftOperation = plugin->removeDraftMessage(message); |
|
787 |
|
788 if (mRemoveDraftOperation) { |
|
789 connect(mRemoveDraftOperation, |
|
790 SIGNAL(operationCompleted(int)), |
|
791 this, |
|
792 SLOT(handleCompletedRemoveDraftOperation())); |
|
793 } |
|
794 } |
|
795 } |
|
796 } |
|
797 |
|
798 /*! |
|
799 Handles draft message saving after editor has closed, takes ownership of message. |
|
800 */ |
|
801 void NmUiEngine::saveDraftMessage(NmMessage *message, |
|
802 const QList<NmOperation*> &preliminaryOperations) |
|
803 { |
|
804 NM_FUNCTION; |
|
805 |
|
806 if (message) { |
|
807 NmDataPluginInterface *plugin = |
|
808 mPluginFactory->interfaceInstance(message->envelope().mailboxId()); |
|
809 |
|
810 if (plugin) { |
|
811 // to be on the safer side: |
|
812 // we shouldn't even be here if mSaveDraftOperation != NULL |
|
813 if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) { |
|
814 mSaveDraftOperation->cancelOperation(); |
|
815 } |
|
816 |
|
817 mSaveDraftOperation = plugin->saveMessageWithSubparts(*message); |
|
818 |
|
819 if (mSaveDraftOperation) { |
|
820 // Ownership of message changes but saveMessageWithSubparts operation only makes a |
|
821 // copy so we handle the msg object deletion in engine. mDraftMessage is deleted |
|
822 // in handleCompletedSaveDraftOperation once operation finishes. |
|
823 if(mDraftMessage) { |
|
824 delete mDraftMessage; |
|
825 mDraftMessage = NULL; |
|
826 } |
|
827 mDraftMessage = message; |
|
828 message = NULL; |
|
829 |
|
830 for (int i(0); i < preliminaryOperations.count(); i++ ) { |
|
831 QPointer<NmOperation> op = preliminaryOperations[i]; |
|
832 mSaveDraftOperation->addPreliminaryOperation(op); |
|
833 } |
|
834 |
|
835 connect(mSaveDraftOperation, |
|
836 SIGNAL(operationCompleted(int)), |
|
837 this, |
|
838 SLOT(handleCompletedSaveDraftOperation())); |
|
839 |
|
840 } |
|
841 } |
|
842 } |
|
843 } |
|
844 |
|
845 /*! |
|
846 Sends the given message. |
|
847 */ |
|
848 void NmUiEngine::sendMessage(NmMessage *message, const QList<NmOperation *> &preliminaryOperations) |
|
849 { |
|
850 NM_FUNCTION; |
|
851 |
|
852 //First trigger message storing |
|
853 if (message) { |
|
854 NmDataPluginInterface *plugin = |
|
855 mPluginFactory->interfaceInstance(message->envelope().mailboxId()); |
|
856 |
|
857 if (plugin) { |
|
858 // to be on the safer side: |
|
859 // we shouldn't even be here if mSendOperation != NULL |
|
860 if (mSendOperation && mSendOperation->isRunning()) { |
|
861 mSendOperation->cancelOperation(); |
|
862 } |
|
863 // ownership of message changes |
|
864 mSendOperation = plugin->sendMessage(message); |
|
865 // don't put this to mOperations as we need to handle this |
|
866 // operation separately |
|
867 if (mSendOperation) { |
|
868 for (int i(0); i < preliminaryOperations.count(); i++ ) { |
|
869 QPointer<NmOperation> op = preliminaryOperations[i]; |
|
870 mSendOperation->addPreliminaryOperation(op); |
|
871 } |
|
872 |
|
873 connect(mSendOperation, |
|
874 SIGNAL(operationCompleted(int)), |
|
875 this, |
|
876 SLOT(handleCompletedSendOperation())); |
|
877 } |
|
878 } |
|
879 } |
|
880 } |
|
881 |
|
882 /*! |
|
883 Is sending operation in progress. |
|
884 */ |
|
885 bool NmUiEngine::isSendingMessage() const |
|
886 { |
|
887 NM_FUNCTION; |
|
888 |
|
889 int ret(false); |
|
890 if (mSendOperation && mSendOperation->isRunning()) { |
|
891 ret = true; |
|
892 } |
|
893 return ret; |
|
894 } |
|
895 |
|
896 /*! |
|
897 Returns a pointer to the message that is being sent. Returns NULL if not sending. |
|
898 */ |
|
899 const NmMessage *NmUiEngine::messageBeingSent() const |
|
900 { |
|
901 NM_FUNCTION; |
|
902 |
|
903 const NmMessage *message = NULL; |
|
904 |
|
905 if (mSendOperation != NULL) { |
|
906 message = mSendOperation->getMessage(); |
|
907 } |
|
908 |
|
909 return message; |
|
910 } |
|
911 |
|
912 /*! |
|
913 Add file attachment into given message. Return the operation object for |
|
914 observing/cancelling. Operation is automatically deleted after completion or cancelling. |
|
915 */ |
|
916 QPointer<NmAddAttachmentsOperation> NmUiEngine::addAttachments( |
|
917 const NmMessage &message, |
|
918 const QList<QString> &fileList) |
|
919 { |
|
920 NM_FUNCTION; |
|
921 |
|
922 NmDataPluginInterface *plugin = |
|
923 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
|
924 |
|
925 QPointer<NmAddAttachmentsOperation> ret(NULL); |
|
926 if (plugin) { |
|
927 ret = plugin->addAttachments(message, fileList); |
|
928 } |
|
929 return ret; |
|
930 } |
|
931 |
|
932 /*! |
|
933 Remove attached file from given message. Return the operation object for |
|
934 observing/cancelling. Operation is automatically deleted after completion or cancelling. |
|
935 */ |
|
936 QPointer<NmOperation> NmUiEngine::removeAttachment( |
|
937 const NmMessage &message, |
|
938 const NmId &attachmentPartId) |
|
939 { |
|
940 NM_FUNCTION; |
|
941 |
|
942 NmDataPluginInterface *plugin = |
|
943 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
|
944 |
|
945 QPointer<NmOperation> ret(NULL); |
|
946 if (plugin) { |
|
947 ret = plugin->removeAttachment(message, attachmentPartId); |
|
948 } |
|
949 return ret; |
|
950 } |
|
951 |
|
952 /*! |
|
953 Returns the current sync state of the mailbox |
|
954 */ |
|
955 NmSyncState NmUiEngine::syncState(const NmId& mailboxId) |
|
956 { |
|
957 NM_FUNCTION; |
|
958 |
|
959 NmDataPluginInterface *plugin = |
|
960 mPluginFactory->interfaceInstance(mailboxId); |
|
961 if (plugin) { |
|
962 return plugin->syncState(mailboxId); |
|
963 } |
|
964 else { |
|
965 return SyncComplete; |
|
966 } |
|
967 } |
|
968 |
|
969 /*! |
|
970 Returns the current connection state of the mailbox |
|
971 */ |
|
972 NmConnectState NmUiEngine::connectionState(const NmId& mailboxId) |
|
973 { |
|
974 NM_FUNCTION; |
|
975 |
|
976 NmDataPluginInterface *plugin = |
|
977 mPluginFactory->interfaceInstance(mailboxId); |
|
978 if (plugin) { |
|
979 return plugin->connectionState(mailboxId); |
|
980 } |
|
981 else { |
|
982 return Disconnected; |
|
983 } |
|
984 } |
|
985 |
|
986 |
|
987 /*! |
|
988 Starts the search. |
|
989 |
|
990 \param mailboxId The ID of the mailbox to search from. |
|
991 \param searchStrings The strings to search with. |
|
992 |
|
993 \return A possible error code. |
|
994 */ |
|
995 int NmUiEngine::search(const NmId &mailboxId, |
|
996 const QStringList &searchStrings) |
|
997 { |
|
998 NM_FUNCTION; |
|
999 |
|
1000 // Get the plugin instance. |
|
1001 QObject *pluginInstance = mPluginFactory->pluginInstance(mailboxId); |
|
1002 |
|
1003 if (pluginInstance) { |
|
1004 // Make sure the required signals are connected. |
|
1005 connect(pluginInstance, SIGNAL(matchFound(const NmId &, const NmId &)), |
|
1006 this, SIGNAL(matchFound(const NmId &, const NmId &)), |
|
1007 Qt::UniqueConnection); |
|
1008 |
|
1009 connect(pluginInstance, SIGNAL(matchFound(const NmId &, const NmId &)), |
|
1010 this, SLOT(handleMatchFound(const NmId &, const NmId &)), |
|
1011 Qt::UniqueConnection); |
|
1012 |
|
1013 connect(pluginInstance, SIGNAL(searchComplete()), |
|
1014 this, SIGNAL(searchComplete()), |
|
1015 Qt::UniqueConnection); |
|
1016 } |
|
1017 |
|
1018 int retVal(NmNoError); |
|
1019 |
|
1020 // Get the plugin interface. |
|
1021 NmDataPluginInterface *pluginInterface = |
|
1022 mPluginFactory->interfaceInstance(mailboxId); |
|
1023 |
|
1024 if (pluginInterface) { |
|
1025 // Start the search. |
|
1026 retVal = pluginInterface->search(mailboxId, searchStrings); |
|
1027 } |
|
1028 |
|
1029 return retVal; |
|
1030 } |
|
1031 |
|
1032 |
|
1033 /*! |
|
1034 Cancels the search operation if one is ongoing. |
|
1035 |
|
1036 \param mailboxId The ID of the mailbox running the search. |
|
1037 |
|
1038 \return A possible error code. |
|
1039 */ |
|
1040 int NmUiEngine::cancelSearch(const NmId &mailboxId) |
|
1041 { |
|
1042 NM_FUNCTION; |
|
1043 |
|
1044 int retVal(NmNoError); |
|
1045 |
|
1046 // Get the plugin interface. |
|
1047 NmDataPluginInterface *pluginInterface = |
|
1048 mPluginFactory->interfaceInstance(mailboxId); |
|
1049 |
|
1050 if (pluginInterface) { |
|
1051 // Cancel the search. |
|
1052 retVal = pluginInterface->cancelSearch(mailboxId); |
|
1053 } |
|
1054 return retVal; |
|
1055 } |
|
1056 |
|
1057 /*! |
|
1058 Get mailbox folder type by folder id |
|
1059 \param mailboxId id of the mailbox |
|
1060 \param folderId id of the folder |
|
1061 \return Folder type |
|
1062 */ |
|
1063 NmFolderType NmUiEngine::folderTypeById(NmId mailboxId, NmId folderId) |
|
1064 { |
|
1065 NM_FUNCTION; |
|
1066 |
|
1067 NmFolderType ret(NmFolderInbox); |
|
1068 if (mDataManager){ |
|
1069 ret = mDataManager->folderTypeById(mailboxId,folderId); |
|
1070 } |
|
1071 return ret; |
|
1072 } |
|
1073 |
|
1074 /*! |
|
1075 Indicates application state information to protocol plugin |
|
1076 \param mailboxId Id of active mailbox, 0 if application is closed. |
|
1077 \param folderId Id of active folder, 0 if application is closed. |
|
1078 */ |
|
1079 void NmUiEngine::updateActiveFolder(const NmId &mailboxId, const NmId &folderId) |
|
1080 { |
|
1081 NM_FUNCTION; |
|
1082 |
|
1083 NmApplicationStateInterface *interface = |
|
1084 mPluginFactory->applicationStateInterfaceInstance(mailboxId); |
|
1085 if (interface) { |
|
1086 interface->updateActiveFolder(mailboxId, folderId); |
|
1087 } |
|
1088 } |
|
1089 |
|
1090 /*! |
|
1091 Handle completed send operation. |
|
1092 */ |
|
1093 void NmUiEngine::handleCompletedSendOperation() |
|
1094 { |
|
1095 NM_FUNCTION; |
|
1096 |
|
1097 emit sendOperationCompleted(); |
|
1098 } |
|
1099 |
|
1100 /*! |
|
1101 Handle completed remove draft operation. |
|
1102 */ |
|
1103 void NmUiEngine::handleCompletedRemoveDraftOperation() |
|
1104 { |
|
1105 NM_FUNCTION; |
|
1106 |
|
1107 // draft message deletion observing not yet implemented... |
|
1108 } |
|
1109 |
|
1110 /*! |
|
1111 Handle completed save draft operation. |
|
1112 */ |
|
1113 void NmUiEngine::handleCompletedSaveDraftOperation() |
|
1114 { |
|
1115 NM_FUNCTION; |
|
1116 |
|
1117 // delete message object since it's not needed anymore |
|
1118 if(mDraftMessage) { |
|
1119 delete mDraftMessage; |
|
1120 mDraftMessage = NULL; |
|
1121 } |
|
1122 } |
|
1123 |
|
1124 /*! |
|
1125 Handles synch operation related events |
|
1126 */ |
|
1127 void NmUiEngine::handleSyncStateEvent(NmSyncState syncState, const NmOperationCompletionEvent &event) |
|
1128 { |
|
1129 NM_FUNCTION; |
|
1130 |
|
1131 if ( syncState == SyncComplete ) { |
|
1132 // signal for reporting about (sync) operation completion status |
|
1133 emit operationCompleted(event); |
|
1134 |
|
1135 enableSyncIndicator(false); |
|
1136 } |
|
1137 |
|
1138 // signal for handling sync state icons |
|
1139 emit syncStateEvent(syncState, event.mMailboxId); |
|
1140 } |
|
1141 |
|
1142 /*! |
|
1143 Enable or disable sync indicator |
|
1144 |
|
1145 \param enabled true if indicator is enabled, false if disabled |
|
1146 */ |
|
1147 void NmUiEngine::enableSyncIndicator(bool enabled) |
|
1148 { |
|
1149 NM_FUNCTION; |
|
1150 |
|
1151 HbIndicator indicator; |
|
1152 if (enabled) { |
|
1153 indicator.activate(syncIndicatorName, QVariant()); |
|
1154 } |
|
1155 else { |
|
1156 indicator.deactivate(syncIndicatorName, QVariant()); |
|
1157 } |
|
1158 } |
|
1159 |
|
1160 /*! |
|
1161 Gets the signature for the given mailbox. |
|
1162 |
|
1163 \param mailboxId The mailbox id whose signature is asked. |
|
1164 \param signature The reference to the signature string pointer. NULL if no signature. |
|
1165 */ |
|
1166 int NmUiEngine::getSignature(const NmId &mailboxId, QString *&signature) |
|
1167 { |
|
1168 NM_FUNCTION; |
|
1169 |
|
1170 int retVal(NmNoError); |
|
1171 |
|
1172 // Get the plugin interface. |
|
1173 NmDataPluginInterface *pluginInterface = |
|
1174 mPluginFactory->interfaceInstance(mailboxId); |
|
1175 |
|
1176 if (pluginInterface) { |
|
1177 retVal = pluginInterface->getSignature(mailboxId, signature); |
|
1178 } |
|
1179 |
|
1180 return retVal; |
|
1181 } |
|
1182 |
|
1183 /*! |
|
1184 Emits signals based on message events coming from plugins. |
|
1185 Currently only NmMessageDeleted is handled. |
|
1186 */ |
|
1187 void NmUiEngine::handleMessageEvent(NmMessageEvent event, |
|
1188 const NmId &folderId, |
|
1189 const QList<NmId> &messageIds, |
|
1190 const NmId& mailboxId) |
|
1191 { |
|
1192 NM_FUNCTION; |
|
1193 |
|
1194 switch (event) { |
|
1195 case NmMessageDeleted: |
|
1196 { |
|
1197 for (int i(0); i < messageIds.count(); i++) { |
|
1198 emit messageDeleted(mailboxId, folderId, messageIds[i]); |
|
1199 } |
|
1200 break; |
|
1201 } |
|
1202 default: |
|
1203 break; |
|
1204 } |
|
1205 } |
|
1206 |
|
1207 /*! |
|
1208 Emits signals based on mailbox events coming from plugins. |
|
1209 Currently only NmMailboxDeleted is handled. |
|
1210 */ |
|
1211 void NmUiEngine::handleMailboxEvent(NmMailboxEvent event, |
|
1212 const QList<NmId> &mailboxIds) |
|
1213 { |
|
1214 NM_FUNCTION; |
|
1215 |
|
1216 switch (event) { |
|
1217 case NmMailboxDeleted: |
|
1218 { |
|
1219 for (int i(0); i < mailboxIds.count(); i++) { |
|
1220 emit mailboxDeleted(mailboxIds[i]); |
|
1221 } |
|
1222 break; |
|
1223 } |
|
1224 default: |
|
1225 break; |
|
1226 } |
|
1227 } |
|
1228 |
|
1229 |
|
1230 /*! |
|
1231 Adds the found message into the search model. |
|
1232 |
|
1233 \param messageId The ID of the found message. |
|
1234 \param folderId The ID of the folder where the message is located. |
|
1235 */ |
|
1236 void NmUiEngine::handleMatchFound(const NmId &messageId, const NmId &folderId) |
|
1237 { |
|
1238 NM_FUNCTION; |
|
1239 |
|
1240 if (!mMessageSearchListModel) { |
|
1241 // No search list model! |
|
1242 return; |
|
1243 } |
|
1244 |
|
1245 // Resolve the folder type. |
|
1246 NmId mailboxId = mMessageSearchListModel->currentMailboxId(); |
|
1247 NmFolderType folderType = folderTypeById(mailboxId, folderId); |
|
1248 |
|
1249 // Do not display matches from outbox or draft folders. |
|
1250 if (folderType != NmFolderOutbox && folderType != NmFolderDrafts) { |
|
1251 // Add the found message into the search model. |
|
1252 QList<NmId> messageIdList; |
|
1253 messageIdList.append(messageId); |
|
1254 |
|
1255 mMessageSearchListModel->handleMessageEvent(NmMessageFound, folderId, |
|
1256 messageIdList, mailboxId); |
|
1257 } |
|
1258 } |
|
1259 |
|
1260 /*! |
|
1261 Function sens events from plugin to both models. Inbox model for |
|
1262 active mailbox is always alove whereas mMessageListModel can represent |
|
1263 other folder in the device (sent, outbox, drafts, etc.) |
|
1264 */ |
|
1265 void NmUiEngine::messageEventForListModel(NmMessageEvent event, |
|
1266 const NmId &folderId, |
|
1267 const QList<NmId> &messageIds, |
|
1268 const NmId& mailboxId) |
|
1269 { |
|
1270 NM_FUNCTION; |
|
1271 |
|
1272 // Forward event to both list models. Models will take care of checking |
|
1273 // whether event really belongs to current mailbox & folder |
|
1274 if (mInboxListModel){ |
|
1275 mInboxListModel->handleMessageEvent(event, folderId, |
|
1276 messageIds, mailboxId); |
|
1277 } |
|
1278 if (mMessageListModel){ |
|
1279 mMessageListModel->handleMessageEvent(event, folderId, |
|
1280 messageIds, mailboxId); |
|
1281 } |
|
1282 } |
|
1283 |
|
1284 /*! |
|
1285 receives events when going online, and offline. |
|
1286 */ |
|
1287 void NmUiEngine::handleConnectEvent(NmConnectState connectState, const NmId &mailboxId, const int errorCode) |
|
1288 { |
|
1289 NM_FUNCTION; |
|
1290 |
|
1291 // signal for connection state icon handling |
|
1292 emit connectionEvent(connectState, mailboxId); |
|
1293 |
|
1294 // in case going offline w/ error, emit signal to UI |
|
1295 if ( connectState == Disconnected && errorCode!= NmNoError ) { |
|
1296 NmOperationCompletionEvent event={NoOp, errorCode, mailboxId, 0, 0}; |
|
1297 emit operationCompleted(event); |
|
1298 } |
|
1299 } |