40 mSendOperation(NULL), |
40 mSendOperation(NULL), |
41 mRemoveDraftOperation(NULL), |
41 mRemoveDraftOperation(NULL), |
42 mSaveDraftOperation(NULL), |
42 mSaveDraftOperation(NULL), |
43 mDraftMessage(NULL) |
43 mDraftMessage(NULL) |
44 { |
44 { |
45 NM_FUNCTION; |
|
46 |
|
47 mPluginFactory = NmDataPluginFactory::instance(); |
45 mPluginFactory = NmDataPluginFactory::instance(); |
48 mDataManager = new NmDataManager(); |
46 mDataManager = new NmDataManager(); |
49 // Connect to the plugins to receive change notifications |
47 // Connect to the plugins to receive change notifications |
50 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
48 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
51 for (int i(0); i < dataPlugins->count(); i++) { |
49 for (int i(0); i < dataPlugins->count(); i++) { |
198 Returns a list model populated with the mailbox and top level folder objects. The model is |
190 Returns a list model populated with the mailbox and top level folder objects. The model is |
199 updated dynamically. The ownership of the model object is not moved to the caller. |
191 updated dynamically. The ownership of the model object is not moved to the caller. |
200 */ |
192 */ |
201 NmMailboxListModel &NmUiEngine::mailboxListModel() |
193 NmMailboxListModel &NmUiEngine::mailboxListModel() |
202 { |
194 { |
203 NM_FUNCTION; |
|
204 |
|
205 if (!mMailboxListModel) { |
195 if (!mMailboxListModel) { |
206 refreshMailboxListModel(); // creates the model too |
196 refreshMailboxListModel(); // creates the model too |
207 } |
197 } |
208 |
198 |
209 return *mMailboxListModel; |
199 return *mMailboxListModel; |
213 Populate the list model with the mailbox and top level folder objects. The model is |
203 Populate the list model with the mailbox and top level folder objects. The model is |
214 updated dynamically. Creates the model if needed. |
204 updated dynamically. Creates the model if needed. |
215 */ |
205 */ |
216 void NmUiEngine::refreshMailboxListModel() |
206 void NmUiEngine::refreshMailboxListModel() |
217 { |
207 { |
218 NM_FUNCTION; |
|
219 |
|
220 if (!mMailboxListModel) { |
208 if (!mMailboxListModel) { |
221 mMailboxListModel = new NmMailboxListModel(*mDataManager); |
209 mMailboxListModel = new NmMailboxListModel(*mDataManager); |
222 |
210 |
223 // Connect the model to the plugins to receive change notifications |
211 // Connect the model to the plugins to receive change notifications |
224 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
212 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
248 object is not moved to the caller. |
236 object is not moved to the caller. |
249 */ |
237 */ |
250 NmMessageListModel &NmUiEngine::messageListModel(const NmId &mailboxId, |
238 NmMessageListModel &NmUiEngine::messageListModel(const NmId &mailboxId, |
251 const NmId &folderId) |
239 const NmId &folderId) |
252 { |
240 { |
253 NM_FUNCTION; |
|
254 |
|
255 QObject *plugin = mPluginFactory->pluginInstance(mailboxId); |
241 QObject *plugin = mPluginFactory->pluginInstance(mailboxId); |
256 bool isInbox(false); |
242 bool isInbox(false); |
257 if (standardFolderId(mailboxId,NmFolderInbox)==folderId){ |
243 if (standardFolderId(mailboxId,NmFolderInbox)==folderId){ |
258 isInbox=true; |
244 isInbox=true; |
259 } |
245 } |
265 const NmId &, const QList<NmId> &, const NmId&)), Qt::UniqueConnection ); |
251 const NmId &, const QList<NmId> &, const NmId&)), Qt::UniqueConnection ); |
266 // Create inbox list model only once when entering to inbox for the first time |
252 // Create inbox list model only once when entering to inbox for the first time |
267 // or re-create inbox list model when mailbox has changed |
253 // or re-create inbox list model when mailbox has changed |
268 if ((!mInboxListModel&&isInbox)|| |
254 if ((!mInboxListModel&&isInbox)|| |
269 (mInboxListModel&&isInbox&&mailboxId!=mInboxListModel->currentMailboxId())){ |
255 (mInboxListModel&&isInbox&&mailboxId!=mInboxListModel->currentMailboxId())){ |
270 // Delete previous model and set to NULL. Deleting model will also |
256 createMessageListModel(&mInboxListModel, mailboxId, folderId); |
271 // delete all items in model. |
|
272 if (mInboxListModel){ |
|
273 delete mInboxListModel; |
|
274 mInboxListModel=NULL; |
|
275 } |
|
276 // Create new inbox model |
|
277 mInboxListModel = new NmMessageListModel(*mDataManager); |
|
278 // Initial fill up of inbox list model, otherwise updated in the background |
|
279 QList<NmMessageEnvelope*> messageEnvelopeList; |
|
280 mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList); |
|
281 mInboxListModel->refresh(mailboxId, folderId, messageEnvelopeList); |
|
282 |
|
283 while (!messageEnvelopeList.isEmpty()) { |
|
284 delete messageEnvelopeList.takeFirst(); |
|
285 } |
|
286 } |
257 } |
287 // Selected folder is not inbox folder for the mailbox |
258 // Selected folder is not inbox folder for the mailbox |
288 else if (!isInbox){ |
259 else if (!isInbox){ |
289 // Recreate model for other folders when needed, previous model |
260 // Recreate model for other folders when needed, previous model |
290 // items are deleted from the memory with the old model |
261 // items are deleted from the memory with the old model |
291 if (mMessageListModel){ |
262 createMessageListModel(&mMessageListModel, mailboxId, folderId); |
292 delete mMessageListModel; |
|
293 mMessageListModel=NULL; |
|
294 } |
|
295 mMessageListModel = new NmMessageListModel(*mDataManager); |
|
296 |
|
297 // Fill up other model |
|
298 QList<NmMessageEnvelope*> messageEnvelopeList; |
|
299 mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList); |
|
300 mMessageListModel->refresh(mailboxId, folderId, messageEnvelopeList); |
|
301 |
|
302 while (!messageEnvelopeList.isEmpty()) { |
|
303 delete messageEnvelopeList.takeFirst(); |
|
304 } |
|
305 } |
263 } |
306 } |
264 } |
307 |
265 |
308 // Connect sync state changed |
266 // Connect sync state changed |
309 if (plugin){ |
267 if (plugin){ |
374 */ |
330 */ |
375 NmId NmUiEngine::standardFolderId( |
331 NmId NmUiEngine::standardFolderId( |
376 const NmId &mailboxId, |
332 const NmId &mailboxId, |
377 NmFolderType folderType) |
333 NmFolderType folderType) |
378 { |
334 { |
379 NM_FUNCTION; |
|
380 |
|
381 NmId value; |
335 NmId value; |
382 if (folderType != NmFolderOther) { |
336 if (folderType != NmFolderOther) { |
383 NmDataPluginInterface *plugin = |
337 NmDataPluginInterface *plugin = |
384 mPluginFactory->interfaceInstance(mailboxId); |
338 mPluginFactory->interfaceInstance(mailboxId); |
385 if(plugin) { |
339 if(plugin) { |
409 */ |
361 */ |
410 QPointer<NmOperation> NmUiEngine::fetchMessage( const NmId &mailboxId, |
362 QPointer<NmOperation> NmUiEngine::fetchMessage( const NmId &mailboxId, |
411 const NmId &folderId, |
363 const NmId &folderId, |
412 const NmId &messageId ) |
364 const NmId &messageId ) |
413 { |
365 { |
414 NM_FUNCTION; |
|
415 |
|
416 QPointer<NmOperation> value(NULL); |
366 QPointer<NmOperation> value(NULL); |
417 NmDataPluginInterface *plugin = |
367 NmDataPluginInterface *plugin = |
418 mPluginFactory->interfaceInstance(mailboxId); |
368 mPluginFactory->interfaceInstance(mailboxId); |
419 if (plugin) { |
369 if (plugin) { |
420 value = plugin->fetchMessage(mailboxId, folderId, messageId); |
370 value = plugin->fetchMessage(mailboxId, folderId, messageId); |
429 const NmId &mailboxId, |
379 const NmId &mailboxId, |
430 const NmId &folderId, |
380 const NmId &folderId, |
431 const NmId &messageId, |
381 const NmId &messageId, |
432 const NmId &messagePartId) |
382 const NmId &messagePartId) |
433 { |
383 { |
434 NM_FUNCTION; |
|
435 |
|
436 QPointer<NmOperation> value(NULL); |
384 QPointer<NmOperation> value(NULL); |
437 NmDataPluginInterface *plugin = |
385 NmDataPluginInterface *plugin = |
438 mPluginFactory->interfaceInstance(mailboxId); |
386 mPluginFactory->interfaceInstance(mailboxId); |
439 if (plugin) { |
387 if (plugin) { |
440 value = plugin->fetchMessagePart(mailboxId, folderId, messageId, messagePartId); |
388 value = plugin->fetchMessagePart(mailboxId, folderId, messageId, messagePartId); |
449 const NmId &mailboxId, |
397 const NmId &mailboxId, |
450 const NmId &folderId, |
398 const NmId &folderId, |
451 const NmId &messageId, |
399 const NmId &messageId, |
452 const QList<NmId> &messagePartIds) |
400 const QList<NmId> &messagePartIds) |
453 { |
401 { |
454 NM_FUNCTION; |
|
455 |
|
456 QPointer<NmOperation> value(NULL); |
402 QPointer<NmOperation> value(NULL); |
457 NmDataPluginInterface *plugin = |
403 NmDataPluginInterface *plugin = |
458 mPluginFactory->interfaceInstance(mailboxId); |
404 mPluginFactory->interfaceInstance(mailboxId); |
459 if (plugin) { |
405 if (plugin) { |
460 value = plugin->fetchMessageParts(mailboxId, folderId, messageId, messagePartIds); |
406 value = plugin->fetchMessageParts(mailboxId, folderId, messageId, messagePartIds); |
469 const NmId &mailboxId, |
415 const NmId &mailboxId, |
470 const NmId &folderId, |
416 const NmId &folderId, |
471 const NmId &messageId, |
417 const NmId &messageId, |
472 const NmId &messagePartId) |
418 const NmId &messagePartId) |
473 { |
419 { |
474 NM_FUNCTION; |
|
475 |
|
476 NmDataPluginInterface *plugin = |
420 NmDataPluginInterface *plugin = |
477 mPluginFactory->interfaceInstance(mailboxId); |
421 mPluginFactory->interfaceInstance(mailboxId); |
478 if (plugin) { |
422 if (plugin) { |
479 return plugin->messagePartFile(mailboxId, folderId, messageId, messagePartId); |
423 return plugin->messagePartFile(mailboxId, folderId, messageId, messagePartId); |
480 } |
424 } |
490 const NmId &mailboxId, |
434 const NmId &mailboxId, |
491 const NmId &folderId, |
435 const NmId &folderId, |
492 const NmId &messageId, |
436 const NmId &messageId, |
493 NmMessagePart &messagePart) |
437 NmMessagePart &messagePart) |
494 { |
438 { |
495 NM_FUNCTION; |
|
496 |
|
497 return mDataManager->contentToMessagePart(mailboxId, folderId, messageId, messagePart); |
439 return mDataManager->contentToMessagePart(mailboxId, folderId, messageId, messagePart); |
498 } |
440 } |
499 |
441 |
500 |
442 |
501 /*! |
443 /*! |
510 int NmUiEngine::deleteMessages(const NmId &mailboxId, |
452 int NmUiEngine::deleteMessages(const NmId &mailboxId, |
511 const NmId &folderId, |
453 const NmId &folderId, |
512 const QList<NmId> &messageIdList) |
454 const QList<NmId> &messageIdList) |
513 { |
455 { |
514 NM_FUNCTION; |
456 NM_FUNCTION; |
515 |
457 |
516 int result(NmNotFoundError); |
458 int result(NmNotFoundError); |
517 |
459 |
518 bool isInbox(false); |
460 bool isInbox(false); |
519 if (standardFolderId(mailboxId,NmFolderInbox)==folderId){ |
461 if (standardFolderId(mailboxId,NmFolderInbox)==folderId){ |
520 isInbox=true; |
462 isInbox=true; |
539 mPluginFactory->interfaceInstance(mailboxId); |
481 mPluginFactory->interfaceInstance(mailboxId); |
540 |
482 |
541 if (plugin) { |
483 if (plugin) { |
542 result = plugin->deleteMessages(mailboxId, folderId, messageIdList); |
484 result = plugin->deleteMessages(mailboxId, folderId, messageIdList); |
543 } |
485 } |
544 |
486 |
545 return result; |
487 // Because the asynchronous delete operation may take some time to |
|
488 // finish, we will not wait for the NmMessageDeleted events from the |
|
489 // protocol plugin. Instead, handleMessageEvent() is invoked directly. |
|
490 // This causes the viewer to exit even though the asychronous delete |
|
491 // operation would take a bit longer to finish. |
|
492 handleMessageEvent(NmMessageDeleted,folderId,messageIdList,mailboxId); |
|
493 |
|
494 return result; |
546 } |
495 } |
547 |
496 |
548 |
497 |
549 /*! |
498 /*! |
550 Sets the envelope property for the given envelopes. |
499 Sets the envelope property for the given envelopes. |
561 const NmId &mailboxId, |
510 const NmId &mailboxId, |
562 const NmId &folderId, |
511 const NmId &folderId, |
563 NmEnvelopeProperties property, |
512 NmEnvelopeProperties property, |
564 const QList<const NmMessageEnvelope*> &envelopeList) |
513 const QList<const NmMessageEnvelope*> &envelopeList) |
565 { |
514 { |
566 NM_FUNCTION; |
|
567 |
|
568 QPointer<NmStoreEnvelopesOperation> operation(NULL); |
515 QPointer<NmStoreEnvelopesOperation> operation(NULL); |
569 NmMessageListModel *theMessageListModel = mMessageListModel; |
516 NmMessageListModel *theMessageListModel = mMessageListModel; |
570 |
517 |
571 if (!theMessageListModel) { |
518 if (!theMessageListModel) { |
572 theMessageListModel = &messageListModel(mailboxId, folderId); |
519 theMessageListModel = &messageListModel(mailboxId, folderId); |
630 Creates a new message (into Drafts-folder). |
577 Creates a new message (into Drafts-folder). |
631 Operation is automatically deleted after completion or cancelling. |
578 Operation is automatically deleted after completion or cancelling. |
632 */ |
579 */ |
633 QPointer<NmMessageCreationOperation> NmUiEngine::createNewMessage(const NmId &mailboxId) |
580 QPointer<NmMessageCreationOperation> NmUiEngine::createNewMessage(const NmId &mailboxId) |
634 { |
581 { |
635 NM_FUNCTION; |
|
636 |
|
637 QPointer<NmMessageCreationOperation> value(NULL); |
582 QPointer<NmMessageCreationOperation> value(NULL); |
638 NmDataPluginInterface *plugin = |
583 NmDataPluginInterface *plugin = |
639 mPluginFactory->interfaceInstance(mailboxId); |
584 mPluginFactory->interfaceInstance(mailboxId); |
640 if (plugin) { |
585 if (plugin) { |
641 value = plugin->createNewMessage(mailboxId); |
586 value = plugin->createNewMessage(mailboxId); |
649 */ |
594 */ |
650 QPointer<NmMessageCreationOperation> NmUiEngine::createForwardMessage( |
595 QPointer<NmMessageCreationOperation> NmUiEngine::createForwardMessage( |
651 const NmId &mailboxId, |
596 const NmId &mailboxId, |
652 const NmId &originalMessageId) |
597 const NmId &originalMessageId) |
653 { |
598 { |
654 NM_FUNCTION; |
|
655 |
|
656 QPointer<NmMessageCreationOperation> value(NULL); |
599 QPointer<NmMessageCreationOperation> value(NULL); |
657 NmDataPluginInterface *plugin = |
600 NmDataPluginInterface *plugin = |
658 mPluginFactory->interfaceInstance(mailboxId); |
601 mPluginFactory->interfaceInstance(mailboxId); |
659 if (plugin) { |
602 if (plugin) { |
660 value = plugin->createForwardMessage(mailboxId, originalMessageId); |
603 value = plugin->createForwardMessage(mailboxId, originalMessageId); |
669 QPointer<NmMessageCreationOperation> NmUiEngine::createReplyMessage( |
612 QPointer<NmMessageCreationOperation> NmUiEngine::createReplyMessage( |
670 const NmId &mailboxId, |
613 const NmId &mailboxId, |
671 const NmId &originalMessageId, |
614 const NmId &originalMessageId, |
672 bool replyAll) |
615 bool replyAll) |
673 { |
616 { |
|
617 QPointer<NmMessageCreationOperation> value(NULL); |
|
618 NmDataPluginInterface *plugin = |
|
619 mPluginFactory->interfaceInstance(mailboxId); |
|
620 if (plugin) { |
|
621 value = plugin->createReplyMessage(mailboxId, originalMessageId, replyAll); |
|
622 } |
|
623 return value; |
|
624 } |
|
625 |
|
626 /*! |
|
627 Saves a message (into message store). |
|
628 */ |
|
629 int NmUiEngine::saveMessage(const NmMessage &message) |
|
630 { |
674 NM_FUNCTION; |
631 NM_FUNCTION; |
675 |
632 |
676 QPointer<NmMessageCreationOperation> value(NULL); |
|
677 NmDataPluginInterface *plugin = |
|
678 mPluginFactory->interfaceInstance(mailboxId); |
|
679 if (plugin) { |
|
680 value = plugin->createReplyMessage(mailboxId, originalMessageId, replyAll); |
|
681 } |
|
682 return value; |
|
683 } |
|
684 |
|
685 /*! |
|
686 Saves a message (into message store). |
|
687 */ |
|
688 int NmUiEngine::saveMessage(const NmMessage &message) |
|
689 { |
|
690 NM_FUNCTION; |
|
691 |
|
692 const NmId &mailboxId = message.envelope().mailboxId(); |
633 const NmId &mailboxId = message.envelope().mailboxId(); |
693 int ret(NmNotFoundError); |
634 int ret(NmNotFoundError); |
694 NmDataPluginInterface *plugin = |
635 NmDataPluginInterface *plugin = |
695 mPluginFactory->interfaceInstance(mailboxId); |
636 mPluginFactory->interfaceInstance(mailboxId); |
696 if (plugin) { |
637 if (plugin) { |
758 const NmId &mailboxId, |
693 const NmId &mailboxId, |
759 const NmId &folderId, |
694 const NmId &folderId, |
760 const NmId &messageId) |
695 const NmId &messageId) |
761 { |
696 { |
762 NM_FUNCTION; |
697 NM_FUNCTION; |
763 |
698 |
764 int result(NmNotFoundError); |
699 int result(NmNotFoundError); |
765 NmDataPluginInterface *plugin = |
700 NmDataPluginInterface *plugin = |
766 mPluginFactory->interfaceInstance(mailboxId); |
701 mPluginFactory->interfaceInstance(mailboxId); |
767 if (plugin) { |
702 if (plugin) { |
768 result = plugin->removeMessage(mailboxId, folderId, messageId); |
703 result = plugin->removeMessage(mailboxId, folderId, messageId); |
852 Sends the given message. |
787 Sends the given message. |
853 */ |
788 */ |
854 void NmUiEngine::sendMessage(NmMessage *message, const QList<NmOperation *> &preliminaryOperations) |
789 void NmUiEngine::sendMessage(NmMessage *message, const QList<NmOperation *> &preliminaryOperations) |
855 { |
790 { |
856 NM_FUNCTION; |
791 NM_FUNCTION; |
857 |
792 |
858 //First trigger message storing |
793 //First trigger message storing |
859 if (message) { |
794 if (message) { |
860 NmDataPluginInterface *plugin = |
795 NmDataPluginInterface *plugin = |
861 mPluginFactory->interfaceInstance(message->envelope().mailboxId()); |
796 mPluginFactory->interfaceInstance(message->envelope().mailboxId()); |
862 |
797 |
921 */ |
852 */ |
922 QPointer<NmAddAttachmentsOperation> NmUiEngine::addAttachments( |
853 QPointer<NmAddAttachmentsOperation> NmUiEngine::addAttachments( |
923 const NmMessage &message, |
854 const NmMessage &message, |
924 const QList<QString> &fileList) |
855 const QList<QString> &fileList) |
925 { |
856 { |
926 NM_FUNCTION; |
|
927 |
|
928 NmDataPluginInterface *plugin = |
857 NmDataPluginInterface *plugin = |
929 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
858 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
930 |
859 |
931 QPointer<NmAddAttachmentsOperation> ret(NULL); |
860 QPointer<NmAddAttachmentsOperation> ret(NULL); |
932 if (plugin) { |
861 if (plugin) { |
941 */ |
870 */ |
942 QPointer<NmOperation> NmUiEngine::removeAttachment( |
871 QPointer<NmOperation> NmUiEngine::removeAttachment( |
943 const NmMessage &message, |
872 const NmMessage &message, |
944 const NmId &attachmentPartId) |
873 const NmId &attachmentPartId) |
945 { |
874 { |
946 NM_FUNCTION; |
|
947 |
|
948 NmDataPluginInterface *plugin = |
875 NmDataPluginInterface *plugin = |
949 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
876 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
950 |
877 |
951 QPointer<NmOperation> ret(NULL); |
878 QPointer<NmOperation> ret(NULL); |
952 if (plugin) { |
879 if (plugin) { |
1000 */ |
923 */ |
1001 int NmUiEngine::search(const NmId &mailboxId, |
924 int NmUiEngine::search(const NmId &mailboxId, |
1002 const QStringList &searchStrings) |
925 const QStringList &searchStrings) |
1003 { |
926 { |
1004 NM_FUNCTION; |
927 NM_FUNCTION; |
1005 |
928 |
1006 // Get the plugin instance. |
929 // Get the plugin instance. |
1007 QObject *pluginInstance = mPluginFactory->pluginInstance(mailboxId); |
930 QObject *pluginInstance = mPluginFactory->pluginInstance(mailboxId); |
1008 |
931 |
1009 if (pluginInstance) { |
932 if (pluginInstance) { |
1010 // Make sure the required signals are connected. |
933 // Make sure the required signals are connected. |
1043 |
966 |
1044 \return A possible error code. |
967 \return A possible error code. |
1045 */ |
968 */ |
1046 int NmUiEngine::cancelSearch(const NmId &mailboxId) |
969 int NmUiEngine::cancelSearch(const NmId &mailboxId) |
1047 { |
970 { |
1048 NM_FUNCTION; |
|
1049 |
|
1050 int retVal(NmNoError); |
971 int retVal(NmNoError); |
1051 |
972 |
1052 // Get the plugin interface. |
973 // Get the plugin interface. |
1053 NmDataPluginInterface *pluginInterface = |
974 NmDataPluginInterface *pluginInterface = |
1054 mPluginFactory->interfaceInstance(mailboxId); |
975 mPluginFactory->interfaceInstance(mailboxId); |
1082 \param mailboxId Id of active mailbox, 0 if application is closed. |
1001 \param mailboxId Id of active mailbox, 0 if application is closed. |
1083 \param folderId Id of active folder, 0 if application is closed. |
1002 \param folderId Id of active folder, 0 if application is closed. |
1084 */ |
1003 */ |
1085 void NmUiEngine::updateActiveFolder(const NmId &mailboxId, const NmId &folderId) |
1004 void NmUiEngine::updateActiveFolder(const NmId &mailboxId, const NmId &folderId) |
1086 { |
1005 { |
1087 NM_FUNCTION; |
|
1088 |
|
1089 NmApplicationStateInterface *interface = |
1006 NmApplicationStateInterface *interface = |
1090 mPluginFactory->applicationStateInterfaceInstance(mailboxId); |
1007 mPluginFactory->applicationStateInterfaceInstance(mailboxId); |
1091 if (interface) { |
1008 if (interface) { |
1092 interface->updateActiveFolder(mailboxId, folderId); |
1009 interface->updateActiveFolder(mailboxId, folderId); |
1093 } |
1010 } |
1096 /*! |
1013 /*! |
1097 Handle completed send operation. |
1014 Handle completed send operation. |
1098 */ |
1015 */ |
1099 void NmUiEngine::handleCompletedSendOperation() |
1016 void NmUiEngine::handleCompletedSendOperation() |
1100 { |
1017 { |
1101 NM_FUNCTION; |
|
1102 |
|
1103 emit sendOperationCompleted(); |
1018 emit sendOperationCompleted(); |
1104 } |
1019 } |
1105 |
1020 |
1106 /*! |
1021 /*! |
1107 Handle completed remove draft operation. |
1022 Handle completed remove draft operation. |
1108 */ |
1023 */ |
1109 void NmUiEngine::handleCompletedRemoveDraftOperation() |
1024 void NmUiEngine::handleCompletedRemoveDraftOperation() |
1110 { |
1025 { |
1111 NM_FUNCTION; |
|
1112 |
|
1113 // draft message deletion observing not yet implemented... |
1026 // draft message deletion observing not yet implemented... |
1114 } |
1027 } |
1115 |
1028 |
1116 /*! |
1029 /*! |
1117 Handle completed save draft operation. |
1030 Handle completed save draft operation. |
1118 */ |
1031 */ |
1119 void NmUiEngine::handleCompletedSaveDraftOperation() |
1032 void NmUiEngine::handleCompletedSaveDraftOperation() |
1120 { |
1033 { |
1121 NM_FUNCTION; |
|
1122 |
|
1123 // delete message object since it's not needed anymore |
1034 // delete message object since it's not needed anymore |
1124 if(mDraftMessage) { |
1035 if(mDraftMessage) { |
1125 delete mDraftMessage; |
1036 delete mDraftMessage; |
1126 mDraftMessage = NULL; |
1037 mDraftMessage = NULL; |
1127 } |
1038 } |
1130 /*! |
1041 /*! |
1131 Handles synch operation related events |
1042 Handles synch operation related events |
1132 */ |
1043 */ |
1133 void NmUiEngine::handleSyncStateEvent(NmSyncState syncState, const NmOperationCompletionEvent &event) |
1044 void NmUiEngine::handleSyncStateEvent(NmSyncState syncState, const NmOperationCompletionEvent &event) |
1134 { |
1045 { |
1135 NM_FUNCTION; |
|
1136 |
|
1137 if ( syncState == SyncComplete ) { |
1046 if ( syncState == SyncComplete ) { |
1138 // signal for reporting about (sync) operation completion status |
1047 // signal for reporting about (sync) operation completion status |
1139 emit operationCompleted(event); |
1048 emit operationCompleted(event); |
1140 |
1049 |
1141 enableSyncIndicator(false); |
1050 enableSyncIndicator(false); |
1169 \param mailboxId The mailbox id whose signature is asked. |
1076 \param mailboxId The mailbox id whose signature is asked. |
1170 \param signature The reference to the signature string pointer. NULL if no signature. |
1077 \param signature The reference to the signature string pointer. NULL if no signature. |
1171 */ |
1078 */ |
1172 int NmUiEngine::getSignature(const NmId &mailboxId, QString *&signature) |
1079 int NmUiEngine::getSignature(const NmId &mailboxId, QString *&signature) |
1173 { |
1080 { |
1174 NM_FUNCTION; |
|
1175 |
|
1176 int retVal(NmNoError); |
1081 int retVal(NmNoError); |
1177 |
1082 |
1178 // Get the plugin interface. |
1083 // Get the plugin interface. |
1179 NmDataPluginInterface *pluginInterface = |
1084 NmDataPluginInterface *pluginInterface = |
1180 mPluginFactory->interfaceInstance(mailboxId); |
1085 mPluginFactory->interfaceInstance(mailboxId); |
1193 void NmUiEngine::handleMessageEvent(NmMessageEvent event, |
1098 void NmUiEngine::handleMessageEvent(NmMessageEvent event, |
1194 const NmId &folderId, |
1099 const NmId &folderId, |
1195 const QList<NmId> &messageIds, |
1100 const QList<NmId> &messageIds, |
1196 const NmId& mailboxId) |
1101 const NmId& mailboxId) |
1197 { |
1102 { |
1198 NM_FUNCTION; |
|
1199 |
|
1200 switch (event) { |
1103 switch (event) { |
1201 case NmMessageDeleted: |
1104 case NmMessageDeleted: |
1202 { |
1105 { |
1203 for (int i(0); i < messageIds.count(); i++) { |
1106 for (int i(0); i < messageIds.count(); i++) { |
1204 emit messageDeleted(mailboxId, folderId, messageIds[i]); |
1107 emit messageDeleted(mailboxId, folderId, messageIds[i]); |
1215 Currently only NmMailboxDeleted is handled. |
1118 Currently only NmMailboxDeleted is handled. |
1216 */ |
1119 */ |
1217 void NmUiEngine::handleMailboxEvent(NmMailboxEvent event, |
1120 void NmUiEngine::handleMailboxEvent(NmMailboxEvent event, |
1218 const QList<NmId> &mailboxIds) |
1121 const QList<NmId> &mailboxIds) |
1219 { |
1122 { |
1220 NM_FUNCTION; |
|
1221 |
|
1222 switch (event) { |
1123 switch (event) { |
1223 case NmMailboxDeleted: |
1124 case NmMailboxDeleted: |
1224 { |
1125 { |
1225 for (int i(0); i < mailboxIds.count(); i++) { |
1126 for (int i(0); i < mailboxIds.count(); i++) { |
1226 emit mailboxDeleted(mailboxIds[i]); |
1127 emit mailboxDeleted(mailboxIds[i]); |
1239 \param mailboxId Id of active mailbox, 0 if application is closed. |
1140 \param mailboxId Id of active mailbox, 0 if application is closed. |
1240 */ |
1141 */ |
1241 void NmUiEngine::handleFolderEvent(NmFolderEvent event, |
1142 void NmUiEngine::handleFolderEvent(NmFolderEvent event, |
1242 const QList<NmId> &folderIds, const NmId &mailboxId) |
1143 const QList<NmId> &folderIds, const NmId &mailboxId) |
1243 { |
1144 { |
1244 NM_FUNCTION; |
|
1245 |
|
1246 switch (event) { |
1145 switch (event) { |
1247 case NmFolderIsDeleted: |
1146 case NmFolderIsDeleted: |
1248 handleFolderDeletedEvent(folderIds, mailboxId); |
1147 handleFolderDeletedEvent(folderIds, mailboxId); |
1249 break; |
1148 break; |
1250 case NmFolderIsCreated: |
1149 case NmFolderIsCreated: |
1258 Handles folder deletion from plugins. |
1157 Handles folder deletion from plugins. |
1259 */ |
1158 */ |
1260 void NmUiEngine::handleFolderDeletedEvent(const QList<NmId> &folderIds, |
1159 void NmUiEngine::handleFolderDeletedEvent(const QList<NmId> &folderIds, |
1261 const NmId &mailboxId) |
1160 const NmId &mailboxId) |
1262 { |
1161 { |
1263 NM_FUNCTION; |
|
1264 |
|
1265 NmId folderId(0); |
1162 NmId folderId(0); |
1266 |
1163 |
1267 for (int i(0); i < folderIds.count(); i++) { |
1164 for (int i(0); i < folderIds.count(); i++) { |
1268 folderId = folderIds[i]; |
1165 folderId = folderIds[i]; |
1269 if (mInboxListModel){ |
1166 if (mInboxListModel){ |
1325 void NmUiEngine::messageEventForListModel(NmMessageEvent event, |
1219 void NmUiEngine::messageEventForListModel(NmMessageEvent event, |
1326 const NmId &folderId, |
1220 const NmId &folderId, |
1327 const QList<NmId> &messageIds, |
1221 const QList<NmId> &messageIds, |
1328 const NmId& mailboxId) |
1222 const NmId& mailboxId) |
1329 { |
1223 { |
1330 NM_FUNCTION; |
|
1331 |
|
1332 // Forward event to both list models. Models will take care of checking |
1224 // Forward event to both list models. Models will take care of checking |
1333 // whether event really belongs to current mailbox & folder |
1225 // whether event really belongs to current mailbox & folder |
1334 if (mInboxListModel){ |
1226 if (mInboxListModel){ |
1335 mInboxListModel->handleMessageEvent(event, folderId, |
1227 mInboxListModel->handleMessageEvent(event, folderId, |
1336 messageIds, mailboxId); |
1228 messageIds, mailboxId); |
1344 /*! |
1236 /*! |
1345 receives events when going online, and offline. |
1237 receives events when going online, and offline. |
1346 */ |
1238 */ |
1347 void NmUiEngine::handleConnectEvent(NmConnectState connectState, const NmId &mailboxId, const int errorCode) |
1239 void NmUiEngine::handleConnectEvent(NmConnectState connectState, const NmId &mailboxId, const int errorCode) |
1348 { |
1240 { |
1349 NM_FUNCTION; |
|
1350 |
|
1351 // signal for connection state icon handling |
1241 // signal for connection state icon handling |
1352 emit connectionEvent(connectState, mailboxId); |
1242 emit connectionEvent(connectState, mailboxId); |
1353 |
1243 |
1354 // in case going offline w/ error, emit signal to UI |
1244 // in case going offline w/ error, emit signal to UI |
1355 if ( connectState == Disconnected && errorCode!= NmNoError ) { |
1245 if ( connectState == Disconnected && errorCode!= NmNoError ) { |
1356 NmOperationCompletionEvent event={NoOp, errorCode, mailboxId, 0, 0}; |
1246 NmOperationCompletionEvent event={NoOp, errorCode, mailboxId, 0, 0}; |
1357 emit operationCompleted(event); |
1247 emit operationCompleted(event); |
1358 } |
1248 } |
1359 } |
1249 } |
|
1250 |
|
1251 /*! |
|
1252 Create message list mode |
|
1253 */ |
|
1254 void NmUiEngine::createMessageListModel( |
|
1255 NmMessageListModel **model, |
|
1256 const NmId &mailboxId, |
|
1257 const NmId &folderId) |
|
1258 { |
|
1259 // Delete previous model and set to NULL. Deleting model will also |
|
1260 // delete all items in model. |
|
1261 if (*model){ |
|
1262 delete *model; |
|
1263 *model=NULL; |
|
1264 } |
|
1265 // Create new list model |
|
1266 *model = new NmMessageListModel(*mDataManager); |
|
1267 // Initial fill up of the list model, otherwise updated in the background |
|
1268 QList<NmMessageEnvelope*> messageEnvelopeList; |
|
1269 mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList); |
|
1270 (*model)->refresh(mailboxId, folderId, messageEnvelopeList); |
|
1271 |
|
1272 while (!messageEnvelopeList.isEmpty()) { |
|
1273 delete messageEnvelopeList.takeFirst(); |
|
1274 } |
|
1275 } |