29 |
29 |
30 /*! |
30 /*! |
31 Constructor |
31 Constructor |
32 */ |
32 */ |
33 NmUiEngine::NmUiEngine() |
33 NmUiEngine::NmUiEngine() |
34 :mMailboxListModel(NULL), |
34 : mMailboxListModel(NULL), |
35 mMessageListModel(NULL), |
35 mMessageListModel(NULL), |
36 mSendOperation(NULL) |
36 mMessageSearchListModel(NULL), |
|
37 mSendOperation(NULL) |
37 { |
38 { |
38 mPluginFactory = NmDataPluginFactory::instance(); |
39 mPluginFactory = NmDataPluginFactory::instance(); |
39 mDataManager = new NmDataManager(); |
40 mDataManager = new NmDataManager(); |
|
41 // Connect to the plugins to receive change notifications |
|
42 QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances(); |
|
43 for (int i(0); i < dataPlugins->count(); i++) { |
|
44 QObject *plugin = (*dataPlugins)[i]; |
|
45 if (plugin) { |
|
46 // connet mailbox events |
|
47 QObject::connect(plugin, SIGNAL(mailboxEvent(NmMailboxEvent, const QList<NmId> &)), |
|
48 this, SLOT(handleMailboxEvent(NmMailboxEvent, const QList<NmId> &)), |
|
49 Qt::UniqueConnection); |
|
50 // connect message events |
|
51 QObject::connect(plugin, |
|
52 SIGNAL(messageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)), |
|
53 this, SLOT(handleMessageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)), |
|
54 Qt::UniqueConnection); |
|
55 // connect connection events |
|
56 QObject::connect(plugin, |
|
57 SIGNAL(connectionEvent(NmConnectState, const NmId &, const int)), |
|
58 this, |
|
59 SLOT(handleConnectEvent(NmConnectState, const NmId &, const int)), |
|
60 Qt::UniqueConnection); |
|
61 // do the subscriptions also |
|
62 NmDataPluginInterface *pluginInterface = mPluginFactory->interfaceInstance(plugin); |
|
63 if (pluginInterface) { |
|
64 QList<NmId> mailboxIdList; |
|
65 pluginInterface->listMailboxIds(mailboxIdList); |
|
66 for (int j(0); j < mailboxIdList.count(); j++) { |
|
67 pluginInterface->subscribeMailboxEvents(mailboxIdList[j]); |
|
68 } |
|
69 mailboxIdList.clear(); |
|
70 } |
|
71 } |
|
72 } |
40 } |
73 } |
41 |
74 |
42 |
75 |
43 /*! |
76 /*! |
44 Destructor |
77 Destructor |
45 */ |
78 */ |
46 NmUiEngine::~NmUiEngine() |
79 NmUiEngine::~NmUiEngine() |
47 { |
80 { |
|
81 if (mMessageSearchListModel) { |
|
82 delete mMessageSearchListModel; |
|
83 mMessageSearchListModel = NULL; |
|
84 } |
|
85 |
48 if (mMessageListModel) { |
86 if (mMessageListModel) { |
49 delete mMessageListModel; |
87 delete mMessageListModel; |
50 mMessageListModel = NULL; |
88 mMessageListModel = NULL; |
51 } |
89 } |
52 if (mMailboxListModel) { |
90 if (mMailboxListModel) { |
53 delete mMailboxListModel; |
91 delete mMailboxListModel; |
54 mMailboxListModel = NULL; |
92 mMailboxListModel = NULL; |
55 } |
93 } |
|
94 // do the unsubscriptions |
|
95 QList<NmId> mailboxIdList; |
|
96 mDataManager->listMailboxIds(mailboxIdList); |
|
97 for (int i(0); i < mailboxIdList.count(); i++) { |
|
98 NmId id = mailboxIdList[i]; |
|
99 NmDataPluginInterface *pluginInterface = mPluginFactory->interfaceInstance(id); |
|
100 if (pluginInterface) { |
|
101 pluginInterface->unsubscribeMailboxEvents(id); |
|
102 } |
|
103 } |
|
104 mailboxIdList.clear(); |
56 NmDataPluginFactory::releaseInstance(mPluginFactory); |
105 NmDataPluginFactory::releaseInstance(mPluginFactory); |
57 delete mDataManager; |
106 delete mDataManager; |
58 |
107 if (mSendOperation && mSendOperation->isRunning()) { |
59 while (!mOperations.isEmpty()) { |
108 mSendOperation->cancelOperation(); |
60 delete mOperations.takeLast(); |
109 } |
61 } |
|
62 |
|
63 delete mSendOperation; |
|
64 } |
110 } |
65 |
111 |
66 /*! |
112 /*! |
67 |
113 |
68 */ |
114 */ |
158 Qt::UniqueConnection ); |
204 Qt::UniqueConnection ); |
159 |
205 |
160 QObject::connect( |
206 QObject::connect( |
161 plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
207 plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
162 this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
208 this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent &)), |
163 Qt::UniqueConnection); |
209 Qt::UniqueConnection); |
164 |
210 // no need for mailbox event subscription here, already done in constructor |
165 QObject::connect(plugin, |
|
166 SIGNAL(connectionEvent(NmConnectState, const NmId &)), |
|
167 this, |
|
168 SIGNAL(connectionEvent(NmConnectState, const NmId &)), |
|
169 Qt::UniqueConnection); |
|
170 |
|
171 // Start to listen mailbox events |
|
172 NmDataPluginInterface *pluginInterface = mPluginFactory->interfaceInstance(plugin); |
|
173 if (pluginInterface) { |
|
174 pluginInterface->subscribeMailboxEvents(mailboxId); |
|
175 } |
|
176 } |
211 } |
177 QList<NmMessageEnvelope*> messageEnvelopeList; |
212 QList<NmMessageEnvelope*> messageEnvelopeList; |
178 mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList); |
213 mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList); |
179 mMessageListModel->refresh(mailboxId, folderId, messageEnvelopeList); |
214 mMessageListModel->refresh(mailboxId, folderId, messageEnvelopeList); |
180 while (!messageEnvelopeList.isEmpty()) { |
215 while (!messageEnvelopeList.isEmpty()) { |
181 delete messageEnvelopeList.takeFirst(); |
216 delete messageEnvelopeList.takeFirst(); |
182 } |
217 } |
183 return *mMessageListModel; |
218 return *mMessageListModel; |
184 } |
219 } |
185 |
220 |
186 /*! |
221 |
187 |
222 /*! |
188 */ |
223 Returns a reference of the message search list model. If the model does not |
189 void NmUiEngine::releaseMessageListModel(const NmId &mailboxId) |
224 exist yet, one is constructed. |
190 { |
225 |
191 // Stop listening mailbox events |
226 \param sourceModel The source model for the search list model. |
192 NmDataPluginInterface *pluginInterface = mPluginFactory->interfaceInstance(mailboxId); |
227 |
193 if (pluginInterface) { |
228 \return The message search list model. |
194 pluginInterface->unsubscribeMailboxEvents(mailboxId); |
229 */ |
195 } |
230 NmMessageSearchListModel &NmUiEngine::messageSearchListModel( |
196 } |
231 QAbstractItemModel *sourceModel) |
|
232 { |
|
233 if (!mMessageSearchListModel) { |
|
234 mMessageSearchListModel = new NmMessageSearchListModel(); |
|
235 } |
|
236 |
|
237 mMessageSearchListModel->setSourceModel(sourceModel); |
|
238 return *mMessageSearchListModel; |
|
239 } |
|
240 |
197 |
241 |
198 /*! |
242 /*! |
199 Get the identifier of the standard folder of a type \a folderType |
243 Get the identifier of the standard folder of a type \a folderType |
200 from the mailbox \a mailboxId. |
244 from the mailbox \a mailboxId. |
201 */ |
245 */ |
228 } |
272 } |
229 |
273 |
230 /*! |
274 /*! |
231 |
275 |
232 */ |
276 */ |
233 NmOperation *NmUiEngine::fetchMessage( const NmId &mailboxId, |
277 QPointer<NmOperation> NmUiEngine::fetchMessage( const NmId &mailboxId, |
234 const NmId &folderId, |
278 const NmId &folderId, |
235 const NmId &messageId ) |
279 const NmId &messageId ) |
236 { |
280 { |
237 NmOperation *value(NULL); |
281 NMLOG("NmUiEngine::fetchMessage() <---"); |
|
282 QPointer<NmOperation> value(NULL); |
238 NmDataPluginInterface *plugin = |
283 NmDataPluginInterface *plugin = |
239 mPluginFactory->interfaceInstance(mailboxId); |
284 mPluginFactory->interfaceInstance(mailboxId); |
240 if (plugin) { |
285 if (plugin) { |
241 value = plugin->fetchMessage(mailboxId, folderId, messageId); |
286 value = plugin->fetchMessage(mailboxId, folderId, messageId); |
242 } |
287 } |
244 } |
289 } |
245 |
290 |
246 /*! |
291 /*! |
247 |
292 |
248 */ |
293 */ |
249 NmOperation *NmUiEngine::fetchMessagePart( |
294 QPointer<NmOperation> NmUiEngine::fetchMessagePart( |
250 const NmId &mailboxId, |
295 const NmId &mailboxId, |
251 const NmId &folderId, |
296 const NmId &folderId, |
252 const NmId &messageId, |
297 const NmId &messageId, |
253 const NmId &messagePartId) |
298 const NmId &messagePartId) |
254 { |
299 { |
255 NmOperation *value(NULL); |
300 NMLOG("NmUiEngine::fetchMessagePart() <---"); |
|
301 QPointer<NmOperation> value(NULL); |
256 NmDataPluginInterface *plugin = |
302 NmDataPluginInterface *plugin = |
257 mPluginFactory->interfaceInstance(mailboxId); |
303 mPluginFactory->interfaceInstance(mailboxId); |
258 if (plugin) { |
304 if (plugin) { |
259 value = plugin->fetchMessagePart(mailboxId, folderId, messageId, messagePartId); |
305 value = plugin->fetchMessagePart(mailboxId, folderId, messageId, messagePartId); |
260 } |
306 } |
313 return result; |
359 return result; |
314 } |
360 } |
315 |
361 |
316 /*! |
362 /*! |
317 Sets envelope property given in argument. |
363 Sets envelope property given in argument. |
318 Ownership of operation object is transferred to the caller. |
364 Operation is automatically deleted after completion or cancelling. |
319 */ |
365 */ |
320 |
366 QPointer<NmStoreEnvelopesOperation> NmUiEngine::setEnvelopes( |
321 NmStoreEnvelopesOperation *NmUiEngine::setEnvelopes( |
|
322 const NmId &mailboxId, |
367 const NmId &mailboxId, |
323 const NmId &folderId, |
368 const NmId &folderId, |
324 NmEnvelopeProperties property, |
369 NmEnvelopeProperties property, |
325 const QList<const NmMessageEnvelope*> &envelopeList) |
370 const QList<const NmMessageEnvelope*> &envelopeList) |
326 { |
371 { |
327 NMLOG("NmUiEngine::setEnvelopes() <---"); |
372 NMLOG("NmUiEngine::setEnvelopes() <---"); |
328 NmStoreEnvelopesOperation *operation(NULL); |
373 QPointer<NmStoreEnvelopesOperation> operation(NULL); |
329 if (mMessageListModel && envelopeList.count()) { |
374 if (mMessageListModel && envelopeList.count()) { |
330 QList<NmId> messageIdList; |
375 QList<NmId> messageIdList; |
331 |
376 |
332 for (int i(0); i < envelopeList.count(); i++){ |
377 for (int i(0); i < envelopeList.count(); i++){ |
333 messageIdList.append(envelopeList[i]->id()); |
378 messageIdList.append(envelopeList[i]->messageId()); |
334 } |
379 } |
335 mMessageListModel->setEnvelopeProperties( |
380 mMessageListModel->setEnvelopeProperties( |
336 property, messageIdList); |
381 property, messageIdList); |
337 // Store new envelopes to plugin |
382 // Store new envelopes to plugin |
338 NmDataPluginInterface *plugin = |
383 NmDataPluginInterface *plugin = |
372 } |
416 } |
373 |
417 |
374 |
418 |
375 /*! |
419 /*! |
376 Creates a new message (into Drafts-folder). |
420 Creates a new message (into Drafts-folder). |
377 Ownership of operation object is transferred to the caller. |
421 Operation is automatically deleted after completion or cancelling. |
378 */ |
422 */ |
379 NmMessageCreationOperation *NmUiEngine::createNewMessage(const NmId &mailboxId) |
423 QPointer<NmMessageCreationOperation> NmUiEngine::createNewMessage(const NmId &mailboxId) |
380 { |
424 { |
381 NmMessageCreationOperation *value(NULL); |
425 NMLOG("NmUiEngine::createNewMessage() <---"); |
|
426 QPointer<NmMessageCreationOperation> value(NULL); |
382 NmDataPluginInterface *plugin = |
427 NmDataPluginInterface *plugin = |
383 mPluginFactory->interfaceInstance(mailboxId); |
428 mPluginFactory->interfaceInstance(mailboxId); |
384 if (plugin) { |
429 if (plugin) { |
385 value = plugin->createNewMessage(mailboxId); |
430 value = plugin->createNewMessage(mailboxId); |
386 } |
431 } |
387 return value; |
432 return value; |
388 } |
433 } |
389 |
434 |
390 /*! |
435 /*! |
391 Creates a new forward message (into Drafts-folder). |
436 Creates a new forward message (into Drafts-folder). |
392 Ownership of operation object is transferred to the caller. |
437 Operation is automatically deleted after completion or cancelling. |
393 */ |
438 */ |
394 NmMessageCreationOperation *NmUiEngine::createForwardMessage( |
439 QPointer<NmMessageCreationOperation> NmUiEngine::createForwardMessage( |
395 const NmId &mailboxId, |
440 const NmId &mailboxId, |
396 const NmId &originalMessageId) |
441 const NmId &originalMessageId) |
397 { |
442 { |
398 NmMessageCreationOperation *value(NULL); |
443 NMLOG("NmUiEngine::createForwardMessage() <---"); |
|
444 QPointer<NmMessageCreationOperation> value(NULL); |
399 NmDataPluginInterface *plugin = |
445 NmDataPluginInterface *plugin = |
400 mPluginFactory->interfaceInstance(mailboxId); |
446 mPluginFactory->interfaceInstance(mailboxId); |
401 if (plugin) { |
447 if (plugin) { |
402 value = plugin->createForwardMessage(mailboxId, originalMessageId); |
448 value = plugin->createForwardMessage(mailboxId, originalMessageId); |
403 } |
449 } |
404 return value; |
450 return value; |
405 } |
451 } |
406 |
452 |
407 /*! |
453 /*! |
408 Creates a new reply message (into Drafts-folder). |
454 Creates a new reply message (into Drafts-folder). |
409 Ownership of operation object is transferred to the caller. |
455 Operation is automatically deleted after completion or cancelling. |
410 */ |
456 */ |
411 NmMessageCreationOperation *NmUiEngine::createReplyMessage( |
457 QPointer<NmMessageCreationOperation> NmUiEngine::createReplyMessage( |
412 const NmId &mailboxId, |
458 const NmId &mailboxId, |
413 const NmId &originalMessageId, |
459 const NmId &originalMessageId, |
414 bool replyAll) |
460 bool replyAll) |
415 { |
461 { |
416 NmMessageCreationOperation *value(NULL); |
462 NMLOG("NmUiEngine::createReplyMessage() <---"); |
|
463 QPointer<NmMessageCreationOperation> value(NULL); |
417 NmDataPluginInterface *plugin = |
464 NmDataPluginInterface *plugin = |
418 mPluginFactory->interfaceInstance(mailboxId); |
465 mPluginFactory->interfaceInstance(mailboxId); |
419 if (plugin) { |
466 if (plugin) { |
420 value = plugin->createReplyMessage(mailboxId, originalMessageId, replyAll); |
467 value = plugin->createReplyMessage(mailboxId, originalMessageId, replyAll); |
421 } |
468 } |
495 result = plugin->removeMessage(mailboxId, folderId, messageId); |
542 result = plugin->removeMessage(mailboxId, folderId, messageId); |
496 } |
543 } |
497 return result; |
544 return result; |
498 } |
545 } |
499 |
546 |
500 /*! |
|
501 Takes ownership of an operation and connects to |
|
502 it's completion signal |
|
503 */ |
|
504 void NmUiEngine::storeOperation(NmOperation *op) |
|
505 { |
|
506 mOperations.append(op); |
|
507 connect( |
|
508 op, |
|
509 SIGNAL(operationCompleted(int)), |
|
510 this, |
|
511 SLOT(handleCompletedOperation())); |
|
512 } |
|
513 |
547 |
514 /*! |
548 /*! |
515 Sends the given message. |
549 Sends the given message. |
516 */ |
550 */ |
517 void NmUiEngine::sendMessage(NmMessage *message, const QList<NmOperation *> &preliminaryOperations) |
551 void NmUiEngine::sendMessage(NmMessage *message, const QList<NmOperation *> &preliminaryOperations) |
518 { |
552 { |
519 //First trigger message storing |
553 //First trigger message storing |
520 if (message) { |
554 if (message) { |
521 NmDataPluginInterface *plugin = |
555 NmDataPluginInterface *plugin = |
522 mPluginFactory->interfaceInstance(message->mailboxId()); |
556 mPluginFactory->interfaceInstance(message->envelope().mailboxId()); |
523 |
557 |
524 if (plugin) { |
558 if (plugin) { |
525 // to be on the safer side: |
559 // to be on the safer side: |
526 // we shouldn't even be here if mSendOperation != NULL |
560 // we shouldn't even be here if mSendOperation != NULL |
527 delete mSendOperation; |
561 if (mSendOperation && mSendOperation->isRunning()) { |
528 mSendOperation = NULL; |
562 mSendOperation->cancelOperation(); |
|
563 } |
529 // ownership of message changes |
564 // ownership of message changes |
530 mSendOperation = plugin->sendMessage(message); |
565 mSendOperation = plugin->sendMessage(message); |
531 // don't put this to mOperations as we need to handle this |
566 // don't put this to mOperations as we need to handle this |
532 // operation separately |
567 // operation separately |
533 if (mSendOperation) { |
568 if (mSendOperation) { |
534 foreach (NmOperation *op, preliminaryOperations) { |
569 for (int i(0); i < preliminaryOperations.count(); i++ ) { |
535 // ownership is transferred |
570 QPointer<NmOperation> op = preliminaryOperations[i]; |
536 mSendOperation->addPreliminaryOperation(op); |
571 mSendOperation->addPreliminaryOperation(op); |
537 } |
572 } |
538 |
573 |
539 connect(mSendOperation, |
574 connect(mSendOperation, |
540 SIGNAL(operationCompleted(int)), |
575 SIGNAL(operationCompleted(int)), |
571 return message; |
606 return message; |
572 } |
607 } |
573 |
608 |
574 /*! |
609 /*! |
575 Add file attachment into given message. Return the operation object for |
610 Add file attachment into given message. Return the operation object for |
576 observing/cancelling. Ownership of operation object is transferred to the caller. |
611 observing/cancelling. Operation is automatically deleted after completion or cancelling. |
577 */ |
612 */ |
578 NmAddAttachmentsOperation *NmUiEngine::addAttachments( |
613 QPointer<NmAddAttachmentsOperation> NmUiEngine::addAttachments( |
579 const NmMessage &message, |
614 const NmMessage &message, |
580 const QList<QString> &fileList) |
615 const QList<QString> &fileList) |
581 { |
616 { |
582 NmDataPluginInterface *plugin = |
617 NMLOG("NmUiEngine::addAttachments() <---"); |
583 mPluginFactory->interfaceInstance(message.mailboxId()); |
618 NmDataPluginInterface *plugin = |
|
619 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
584 |
620 |
585 NmAddAttachmentsOperation *ret(NULL); |
621 QPointer<NmAddAttachmentsOperation> ret(NULL); |
586 |
|
587 if (plugin) { |
622 if (plugin) { |
588 ret = plugin->addAttachments(message, fileList); |
623 ret = plugin->addAttachments(message, fileList); |
589 } |
624 } |
590 |
|
591 return ret; |
625 return ret; |
592 } |
626 } |
593 |
627 |
594 /*! |
628 /*! |
595 Remove attached file from given message. Return the operation object for |
629 Remove attached file from given message. Return the operation object for |
596 observing/cancelling. Ownership of operation object is transferred to the caller. |
630 observing/cancelling. Operation is automatically deleted after completion or cancelling. |
597 */ |
631 */ |
598 NmOperation *NmUiEngine::removeAttachment( |
632 QPointer<NmOperation> NmUiEngine::removeAttachment( |
599 const NmMessage &message, |
633 const NmMessage &message, |
600 const NmId &attachmentPartId) |
634 const NmId &attachmentPartId) |
601 { |
635 { |
602 NmDataPluginInterface *plugin = |
636 NMLOG("NmUiEngine::removeAttachments() <---"); |
603 mPluginFactory->interfaceInstance(message.mailboxId()); |
637 NmDataPluginInterface *plugin = |
|
638 mPluginFactory->interfaceInstance(message.envelope().mailboxId()); |
604 |
639 |
605 NmOperation *ret(NULL); |
640 QPointer<NmOperation> ret(NULL); |
606 |
|
607 if (plugin) { |
641 if (plugin) { |
608 ret = plugin->removeAttachment(message, attachmentPartId); |
642 ret = plugin->removeAttachment(message, attachmentPartId); |
609 } |
643 } |
610 |
|
611 return ret; |
644 return ret; |
612 } |
645 } |
613 |
646 |
614 /*! |
647 /*! |
615 Ownership of operation object is transferred to the caller. |
648 Operation is automatically deleted after completion or cancelling. |
616 */ |
649 */ |
617 NmCheckOutboxOperation *NmUiEngine::checkOutbox(const NmId &mailboxId) |
650 QPointer<NmCheckOutboxOperation> NmUiEngine::checkOutbox(const NmId &mailboxId) |
618 { |
651 { |
619 NmDataPluginInterface *plugin = |
652 NMLOG("NmUiEngine::checkOutbox() <---"); |
620 mPluginFactory->interfaceInstance(mailboxId); |
653 NmDataPluginInterface *plugin = |
621 |
654 mPluginFactory->interfaceInstance(mailboxId); |
622 NmCheckOutboxOperation *ret(NULL); |
655 |
623 |
656 QPointer<NmCheckOutboxOperation> ret(NULL); |
624 if (plugin) { |
657 if (plugin) { |
625 ret = plugin->checkOutbox(mailboxId); |
658 ret = plugin->checkOutbox(mailboxId); |
626 } |
659 } |
627 |
|
628 return ret; |
660 return ret; |
629 } |
661 } |
630 |
662 |
631 /*! |
663 /*! |
632 Returns the current sync state of the mailbox |
664 Returns the current sync state of the mailbox |
656 else { |
688 else { |
657 return Disconnected; |
689 return Disconnected; |
658 } |
690 } |
659 } |
691 } |
660 |
692 |
661 /*! |
693 |
662 * deletes completed operations |
694 /*! |
663 * |
695 Starts the search. |
664 */ |
696 |
665 void NmUiEngine::handleCompletedOperation() |
697 \param mailboxId The ID of the mailbox to search from. |
666 { |
698 \param searchStrings The strings to search with. |
667 NMLOG("NmUiEngine::handleCompletedOperation() <---"); |
699 |
668 int count = mOperations.count(); |
700 \return A possible error code. |
|
701 */ |
|
702 int NmUiEngine::search(const NmId &mailboxId, |
|
703 const QStringList &searchStrings) |
|
704 { |
|
705 // Get the plugin instance. |
|
706 QObject *pluginInstance = mPluginFactory->pluginInstance(mailboxId); |
|
707 |
|
708 if (pluginInstance) { |
|
709 // Make sure the required signals are connected. |
|
710 connect(pluginInstance, SIGNAL(matchFound(const NmId &)), |
|
711 this, SIGNAL(matchFound(const NmId &)), Qt::UniqueConnection); |
|
712 connect(pluginInstance, SIGNAL(matchFound(const NmId &)), |
|
713 mMessageSearchListModel, SLOT(addSearchResult(const NmId &)), |
|
714 Qt::UniqueConnection); |
|
715 connect(pluginInstance, SIGNAL(searchComplete()), |
|
716 this, SIGNAL(searchComplete()), Qt::UniqueConnection); |
|
717 } |
|
718 |
|
719 int retVal(NmNoError); |
|
720 |
|
721 // Get the plugin interface. |
|
722 NmDataPluginInterface *pluginInterface = |
|
723 mPluginFactory->interfaceInstance(mailboxId); |
|
724 |
|
725 if (pluginInterface) { |
|
726 // Start the search. |
|
727 retVal = pluginInterface->search(mailboxId, searchStrings); |
|
728 } |
669 |
729 |
670 QObject *sender = this->sender(); |
730 return retVal; |
671 |
731 } |
672 for(int i(0); i < count; i++){ |
732 |
673 if (mOperations[i] == sender){ |
733 |
674 delete mOperations.takeAt(i); |
734 /*! |
675 } |
735 Cancels the search operation if one is ongoing. |
676 } |
736 |
677 NMLOG("NmUiEngine::handleCompletedOperation() --->"); |
737 \param mailboxId The ID of the mailbox running the search. |
678 } |
738 |
679 |
739 \return A possible error code. |
|
740 */ |
|
741 int NmUiEngine::cancelSearch(const NmId &mailboxId) |
|
742 { |
|
743 int retVal(NmNoError); |
|
744 |
|
745 // Get the plugin interface. |
|
746 NmDataPluginInterface *pluginInterface = |
|
747 mPluginFactory->interfaceInstance(mailboxId); |
|
748 |
|
749 if (pluginInterface) { |
|
750 // Cancel the search. |
|
751 retVal = pluginInterface->cancelSearch(mailboxId); |
|
752 } |
|
753 return retVal; |
|
754 } |
|
755 |
|
756 /*! |
|
757 Cancels the search operation if one is ongoing. |
|
758 |
|
759 \param mailboxId The ID of the mailbox containing the folder |
|
760 |
|
761 \param folderId The ID of the folder |
|
762 |
|
763 \return Folder type |
|
764 */ |
|
765 NmFolderType NmUiEngine::folderTypeById(NmId mailboxId, NmId folderId) |
|
766 { |
|
767 NmFolderType folderType(NmFolderOther); |
|
768 if (standardFolderId(mailboxId,NmFolderInbox)==folderId){ |
|
769 folderType=NmFolderInbox; |
|
770 } |
|
771 else if (standardFolderId(mailboxId,NmFolderOutbox)==folderId){ |
|
772 folderType=NmFolderOutbox; |
|
773 } |
|
774 else if (standardFolderId(mailboxId,NmFolderDrafts)==folderId){ |
|
775 folderType=NmFolderDrafts; |
|
776 } |
|
777 else if (standardFolderId(mailboxId,NmFolderSent)==folderId){ |
|
778 folderType=NmFolderSent; |
|
779 } |
|
780 else if (standardFolderId(mailboxId,NmFolderDeleted)==folderId){ |
|
781 folderType=NmFolderDeleted; |
|
782 } |
|
783 return folderType; |
|
784 } |
680 /*! |
785 /*! |
681 Handle completed send operation. |
786 Handle completed send operation. |
682 */ |
787 */ |
683 void NmUiEngine::handleCompletedSendOperation() |
788 void NmUiEngine::handleCompletedSendOperation() |
684 { |
789 { |
685 // Let the callback method finish until cleaning the operation. |
790 NMLOG("NmUiEngine::handleCompletedSendOperation()"); |
686 QTimer::singleShot(1, this, SLOT(cleanupSendOperation())); |
|
687 emit sendOperationCompleted(); |
791 emit sendOperationCompleted(); |
688 } |
|
689 |
|
690 /*! |
|
691 Cleanup the send operation |
|
692 */ |
|
693 void NmUiEngine::cleanupSendOperation() |
|
694 { |
|
695 delete mSendOperation; |
|
696 mSendOperation = NULL; |
|
697 // delete the sent messages from the store if necessary |
|
698 // ... |
|
699 } |
792 } |
700 |
793 |
701 /*! |
794 /*! |
702 Handles synch operation related events |
795 Handles synch operation related events |
703 */ |
796 */ |
712 |
805 |
713 // signal for handling sync state icons |
806 // signal for handling sync state icons |
714 emit syncStateEvent(syncState, event.mMailboxId); |
807 emit syncStateEvent(syncState, event.mMailboxId); |
715 } |
808 } |
716 |
809 |
717 |
810 /*! |
|
811 Emits signals based on message events coming from plugins. |
|
812 Currently only NmMessageDeleted is handled. |
|
813 */ |
|
814 void NmUiEngine::handleMessageEvent(NmMessageEvent event, |
|
815 const NmId &folderId, |
|
816 const QList<NmId> &messageIds, |
|
817 const NmId& mailboxId) |
|
818 { |
|
819 switch (event) { |
|
820 case NmMessageDeleted: |
|
821 { |
|
822 for (int i(0); i < messageIds.count(); i++) { |
|
823 emit messageDeleted(mailboxId, folderId, messageIds[i]); |
|
824 } |
|
825 break; |
|
826 } |
|
827 default: |
|
828 break; |
|
829 } |
|
830 } |
|
831 |
|
832 /*! |
|
833 Emits signals based on mailbox events coming from plugins. |
|
834 Currently only NmMailboxDeleted is handled. |
|
835 */ |
|
836 void NmUiEngine::handleMailboxEvent(NmMailboxEvent event, |
|
837 const QList<NmId> &mailboxIds) |
|
838 { |
|
839 switch (event) { |
|
840 case NmMailboxDeleted: |
|
841 { |
|
842 for (int i(0); i < mailboxIds.count(); i++) { |
|
843 emit mailboxDeleted(mailboxIds[i]); |
|
844 } |
|
845 break; |
|
846 } |
|
847 default: |
|
848 break; |
|
849 } |
|
850 } |
|
851 |
|
852 /*! |
|
853 receives events when going online, and offline. |
|
854 */ |
|
855 void NmUiEngine::handleConnectEvent(NmConnectState connectState, const NmId &mailboxId, const int errorCode) |
|
856 { |
|
857 // signal for connection state icon handling |
|
858 emit connectionEvent(connectState, mailboxId); |
|
859 |
|
860 // in case going offline w/ error, emit signal to UI |
|
861 if ( connectState == Disconnected && errorCode!= NmNoError ) { |
|
862 NmOperationCompletionEvent event={NoOp, errorCode, mailboxId, 0, 0}; |
|
863 emit operationCompleted(event); |
|
864 } |
|
865 } |