38 */ |
38 */ |
39 NmFrameworkAdapter::NmFrameworkAdapter() |
39 NmFrameworkAdapter::NmFrameworkAdapter() |
40 : mFSfw(NULL), |
40 : mFSfw(NULL), |
41 mSearchObserver(NULL), |
41 mSearchObserver(NULL), |
42 mCurrentMailBox(NULL), |
42 mCurrentMailBox(NULL), |
43 mEmailExtension(NULL) |
43 mStateExtension(NULL) |
44 { |
44 { |
45 NM_FUNCTION; |
45 NM_FUNCTION; |
46 |
46 |
47 // get s60 email framework |
47 // get s60 email framework |
48 TRAP_IGNORE(mFSfw = CFSMailClient::NewL()); |
48 TRAP_IGNORE(mFSfw = CFSMailClient::NewL()); |
57 */ |
57 */ |
58 NmFrameworkAdapter::~NmFrameworkAdapter() |
58 NmFrameworkAdapter::~NmFrameworkAdapter() |
59 { |
59 { |
60 NM_FUNCTION; |
60 NM_FUNCTION; |
61 |
61 |
62 if (mCurrentMailBox && mEmailExtension) { |
|
63 mCurrentMailBox->ReleaseExtension( mEmailExtension ); |
|
64 } |
|
65 delete mCurrentMailBox; |
62 delete mCurrentMailBox; |
66 mCurrentMailBox = NULL; |
63 mCurrentMailBox = NULL; |
67 |
64 |
68 mEmailExtension = NULL; |
65 mStateExtension = NULL; |
69 |
66 |
70 if (mSearchObserver) { |
67 if (mSearchObserver) { |
71 delete mSearchObserver; |
68 delete mSearchObserver; |
72 mSearchObserver = NULL; |
69 mSearchObserver = NULL; |
73 } |
70 } |
683 */ |
680 */ |
684 void NmFrameworkAdapter::doUpdateActiveFolderL( |
681 void NmFrameworkAdapter::doUpdateActiveFolderL( |
685 const NmId &mailboxId, const NmId &folderId) |
682 const NmId &mailboxId, const NmId &folderId) |
686 { |
683 { |
687 if ((mFSfw) && (!mCurrentMailBox || mCurrentMailBox->GetId()!=mailboxId)) { |
684 if ((mFSfw) && (!mCurrentMailBox || mCurrentMailBox->GetId()!=mailboxId)) { |
688 mEmailExtension = NULL; |
|
689 delete mCurrentMailBox; |
685 delete mCurrentMailBox; |
690 mCurrentMailBox = NULL; |
686 mCurrentMailBox = NULL; |
691 mCurrentMailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
687 mCurrentMailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
692 } |
688 } |
693 CEmailExtension *extension = getEMailStateExtensionL(); |
689 CEmailExtension *extension = getEMailStateExtensionL(); |
694 CMailboxStateExtension *boxExtension = |
690 CMailboxStateExtension *stateExtension = |
695 static_cast<CMailboxStateExtension*>(extension); |
691 static_cast<CMailboxStateExtension*>(extension); |
696 if (boxExtension) { |
692 if (stateExtension) { |
697 boxExtension->NotifyActiveFolderChanged(mailboxId, folderId); |
693 stateExtension->NotifyActiveFolderChanged(mailboxId, folderId); |
698 } |
694 } |
699 } |
695 } |
700 |
696 |
701 /*! |
697 /*! |
702 function to process updateActiveFolder. This method may leave. |
698 function to process updateActiveFolder. This method may leave. |
703 */ |
699 */ |
704 CEmailExtension* NmFrameworkAdapter::getEMailStateExtensionL() |
700 CEmailExtension* NmFrameworkAdapter::getEMailStateExtensionL() |
705 { |
701 { |
706 if (!mEmailExtension && mCurrentMailBox) { |
702 if (!mStateExtension && mCurrentMailBox) { |
707 mEmailExtension = |
703 // This extension is owned and deleted by the plugin, so no need to |
708 mCurrentMailBox->ExtensionL(KEmailMailboxStateExtensionUid); |
704 // use release unless the extension will be relocated into extensionbase. |
|
705 mStateExtension = mCurrentMailBox->ExtensionL(KEmailMailboxStateExtensionUid); |
709 } |
706 } |
710 return mEmailExtension; |
707 return mStateExtension; |
711 } |
708 } |
712 |
709 |
713 /*! |
710 /*! |
714 Starts an asynchronous search for messages with the given search strings. |
711 Starts an asynchronous search for messages with the given search strings. |
715 |
712 |
1346 TRAPD(error, removeMessageL(mailboxId, folderId, messageId)); |
1343 TRAPD(error, removeMessageL(mailboxId, folderId, messageId)); |
1347 return error; |
1344 return error; |
1348 } |
1345 } |
1349 |
1346 |
1350 /*! |
1347 /*! |
|
1348 Copy messages between folders from specific mailbox. |
|
1349 |
|
1350 \param mailboxId Id of the mailbox containing messages. |
|
1351 \param messageIds The list of source message Ids. |
|
1352 \param newMessages The list of destination message Ids. |
|
1353 \param sourceFolderId Id of source folder. |
|
1354 \param destinationFolderId Id of destination folder. |
|
1355 */ |
|
1356 int NmFrameworkAdapter::copyMessages( |
|
1357 const NmId &mailboxId, |
|
1358 const QList<quint64>& messageIds, |
|
1359 const NmId& sourceFolderId, |
|
1360 const NmId& destinationFolderId) |
|
1361 { |
|
1362 NM_FUNCTION; |
|
1363 TRAPD(error, copyMessagesL(mailboxId, messageIds, sourceFolderId, destinationFolderId)); |
|
1364 return error; |
|
1365 } |
|
1366 |
|
1367 /*! |
1351 Subscribe to events from a mailbox. |
1368 Subscribe to events from a mailbox. |
1352 |
1369 |
1353 \param mailboxId Id of the mailbox. |
1370 \param mailboxId Id of the mailbox. |
1354 */ |
1371 */ |
1355 void NmFrameworkAdapter::subscribeMailboxEvents(const NmId& mailboxId) |
1372 void NmFrameworkAdapter::subscribeMailboxEvents(const NmId& mailboxId) |
1407 folder->RemoveMessageL(TFSMailMsgId(messageId)); |
1424 folder->RemoveMessageL(TFSMailMsgId(messageId)); |
1408 } |
1425 } |
1409 CleanupStack::PopAndDestroy(folder); |
1426 CleanupStack::PopAndDestroy(folder); |
1410 } |
1427 } |
1411 |
1428 |
|
1429 /*! |
|
1430 Leaving version of copyMessages |
|
1431 */ |
|
1432 void NmFrameworkAdapter::copyMessagesL( |
|
1433 const NmId &mailboxId, |
|
1434 const QList<quint64>& messageIds, |
|
1435 const NmId& sourceFolderId, |
|
1436 const NmId& destinationFolderId) |
|
1437 { |
|
1438 NM_FUNCTION; |
|
1439 |
|
1440 RArray<TFSMailMsgId> messages; |
|
1441 RArray<TFSMailMsgId> copiedMessages; |
|
1442 |
|
1443 CleanupClosePushL(messages); |
|
1444 CleanupClosePushL(copiedMessages); |
|
1445 |
|
1446 for (TInt i = 0; i < messageIds.count(); i++) { |
|
1447 NmId tmpId(messageIds[i]); |
|
1448 messages.AppendL(TFSMailMsgId(tmpId)); |
|
1449 } |
|
1450 |
|
1451 CFSMailBox* mailBox = NULL; |
|
1452 mailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
|
1453 if (mailBox) { |
|
1454 mailBox->CopyMessagesL(messages, copiedMessages, |
|
1455 TFSMailMsgId(sourceFolderId), |
|
1456 TFSMailMsgId(destinationFolderId)); |
|
1457 delete mailBox; |
|
1458 } |
|
1459 |
|
1460 CleanupStack::PopAndDestroy(2,&messages); |
|
1461 } |
1412 |
1462 |
1413 /*! |
1463 /*! |
1414 Sends the given message. |
1464 Sends the given message. |
1415 */ |
1465 */ |
1416 QPointer<NmMessageSendingOperation> NmFrameworkAdapter::sendMessage( |
1466 QPointer<NmMessageSendingOperation> NmFrameworkAdapter::sendMessage( |