187 \return Error code. |
187 \return Error code. |
188 */ |
188 */ |
189 int NmFrameworkAdapter::getFolderById( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder ) |
189 int NmFrameworkAdapter::getFolderById( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder ) |
190 { |
190 { |
191 NM_FUNCTION; |
191 NM_FUNCTION; |
192 |
192 |
193 TRAPD(err, getFolderByIdL( mailboxId, folderId, folder ) ); |
193 TRAPD(err, getFolderByIdL( mailboxId, folderId, folder ) ); |
194 return err; |
194 return err; |
195 } |
195 } |
196 |
196 |
197 /*! |
197 /*! |
198 Leaving version of getFolderById function |
198 Leaving version of getFolderById function |
199 */ |
199 */ |
200 void NmFrameworkAdapter::getFolderByIdL( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder ) |
200 void NmFrameworkAdapter::getFolderByIdL( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder ) |
201 { |
201 { |
202 NM_FUNCTION; |
202 NM_FUNCTION; |
203 |
203 |
204 CFSMailFolder* fsFolder(NULL); |
204 CFSMailFolder* fsFolder(NULL); |
205 if (mFSfw) |
205 if (mFSfw) |
206 { |
206 { |
207 fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); |
207 fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); |
208 if (fsFolder) |
208 if (fsFolder) |
209 { |
209 { |
210 folder = fsFolder->GetNmFolder(); |
210 folder = fsFolder->GetNmFolder(); |
211 delete fsFolder; |
211 delete fsFolder; |
212 fsFolder = NULL; |
212 fsFolder = NULL; |
250 const NmId& folderId, |
250 const NmId& folderId, |
251 const NmId& messageId, |
251 const NmId& messageId, |
252 NmMessage*& message) |
252 NmMessage*& message) |
253 { |
253 { |
254 NM_FUNCTION; |
254 NM_FUNCTION; |
255 |
255 |
256 // select message details to be listed |
256 // select message details to be listed |
257 TFSMailDetails details(EFSMsgDataStructure); |
257 TFSMailDetails details(EFSMsgDataStructure); |
258 |
258 |
259 CFSMailMessage* newMessage(NULL); |
259 CFSMailMessage* newMessage(NULL); |
260 newMessage = mFSfw->GetMessageByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId), |
260 newMessage = mFSfw->GetMessageByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId), |
273 } |
273 } |
274 } |
274 } |
275 |
275 |
276 /*! |
276 /*! |
277 Returns list of folders in a mailbox. |
277 Returns list of folders in a mailbox. |
278 |
278 |
279 \param mailboxId Id of the mailbox containing the folder. |
279 \param mailboxId Id of the mailbox containing the folder. |
280 \param folderList Reference to a pointer list to receive pointers to the folders. |
280 \param folderList Reference to a pointer list to receive pointers to the folders. |
281 |
281 |
282 \return Error code. |
282 \return Error code. |
283 */ |
283 */ |
284 int NmFrameworkAdapter::listFolders( |
284 int NmFrameworkAdapter::listFolders( |
285 const NmId& mailboxId, |
285 const NmId& mailboxId, |
286 QList<NmFolder*>& folderList) |
286 QList<NmFolder*>& folderList) |
287 { |
287 { |
288 NM_FUNCTION; |
288 NM_FUNCTION; |
289 |
289 |
290 CFSMailBox* currentMailbox = NULL; |
290 CFSMailBox* currentMailbox = NULL; |
291 TRAPD (err, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
291 TRAPD (err, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
292 if (KErrNone == err) { |
292 if (KErrNone == err) { |
293 RPointerArray<CFSMailFolder> folders = currentMailbox->ListFolders(); |
293 RPointerArray<CFSMailFolder> folders = currentMailbox->ListFolders(); |
294 for (int i = 0; i < folders.Count(); i++) { |
294 for (int i = 0; i < folders.Count(); i++) { |
340 criteria.iField = EFSMailSortByDate; |
340 criteria.iField = EFSMailSortByDate; |
341 criteria.iOrder = EFSMailDescending; |
341 criteria.iOrder = EFSMailDescending; |
342 RArray<TFSMailSortCriteria> sorting; |
342 RArray<TFSMailSortCriteria> sorting; |
343 CleanupClosePushL(sorting); |
343 CleanupClosePushL(sorting); |
344 sorting.Append(criteria); |
344 sorting.Append(criteria); |
345 |
345 |
346 // Get the message list from the backend. |
346 // Get the message list from the backend. |
347 MFSMailIterator* iterator(NULL); |
347 MFSMailIterator* iterator(NULL); |
348 iterator = folder->ListMessagesL(details, sorting); |
348 iterator = folder->ListMessagesL(details, sorting); |
349 |
349 |
350 if (iterator) { |
350 if (iterator) { |
464 folder = mFSfw->GetFolderByUidL(mailbox->GetId(), TFSMailMsgId(folderId)); |
464 folder = mFSfw->GetFolderByUidL(mailbox->GetId(), TFSMailMsgId(folderId)); |
465 |
465 |
466 if (folder) { |
466 if (folder) { |
467 CleanupStack::PushL(folder); |
467 CleanupStack::PushL(folder); |
468 getMessagesFromFolderL(folder, messageEnvelopeList, maxAmountOfEnvelopes); |
468 getMessagesFromFolderL(folder, messageEnvelopeList, maxAmountOfEnvelopes); |
469 CleanupStack::PopAndDestroy(folder); |
469 CleanupStack::PopAndDestroy(folder); |
470 } |
470 } |
471 |
471 |
472 CleanupStack::PopAndDestroy(mailbox); |
472 CleanupStack::PopAndDestroy(mailbox); |
473 } |
473 } |
474 |
474 |
475 |
475 |
476 /*! |
476 /*! |
477 Returns list of messages from the backend for specific mailbox and folder. |
477 Returns list of messages from the backend for specific mailbox and folder. |
478 |
478 |
479 \param mailboxId Id of the mailbox containing the folder. |
479 \param mailboxId Id of the mailbox containing the folder. |
480 \param folderId Folder id. |
480 \param folderId Folder id. |
481 \param messageMetaDataList Reference to pointer list to receive the envelope objects, |
481 \param messageMetaDataList Reference to pointer list to receive the envelope objects, |
504 const NmId &folderId, |
504 const NmId &folderId, |
505 QList<NmMessage*> &messageList, |
505 QList<NmMessage*> &messageList, |
506 const int maxAmountOfEnvelopes) |
506 const int maxAmountOfEnvelopes) |
507 { |
507 { |
508 NM_FUNCTION; |
508 NM_FUNCTION; |
509 |
509 |
510 CFSMailBox * currentMailbox(NULL); |
510 CFSMailBox * currentMailbox(NULL); |
511 CFSMailFolder* folder(NULL); |
511 CFSMailFolder* folder(NULL); |
512 |
512 |
513 //If we are requesting 0 or less mails so we can return |
513 //If we are requesting 0 or less mails so we can return |
514 if( maxAmountOfEnvelopes <= 0) |
514 if( maxAmountOfEnvelopes <= 0) |
566 for ( int i = blockSize; |
566 for ( int i = blockSize; |
567 i < maxLimit && moreMessagesToFollow ; |
567 i < maxLimit && moreMessagesToFollow ; |
568 i += blockSize ) { |
568 i += blockSize ) { |
569 moreMessagesToFollow = iterator->NextL( |
569 moreMessagesToFollow = iterator->NextL( |
570 messages[i-1]->GetMessageId(), blockSize, messages); |
570 messages[i-1]->GetMessageId(), blockSize, messages); |
571 |
571 |
572 } |
572 } |
573 |
573 |
574 //Add all found emails to the result list |
574 //Add all found emails to the result list |
575 for(TInt i=0; i<messages.Count(); i++) { |
575 for(TInt i=0; i<messages.Count(); i++) { |
576 NmMessage* newMessage(NULL); |
576 NmMessage* newMessage(NULL); |
632 |
632 |
633 /*! |
633 /*! |
634 Cancels the search if one is ongoing. |
634 Cancels the search if one is ongoing. |
635 |
635 |
636 \param mailboxId The ID of the mailbox running the search. |
636 \param mailboxId The ID of the mailbox running the search. |
637 |
|
638 |
637 |
639 \return A possible error code. |
638 \return A possible error code. |
640 */ |
639 */ |
641 int NmFrameworkAdapter::cancelSearch(const NmId &mailboxId) |
640 int NmFrameworkAdapter::cancelSearch(const NmId &mailboxId) |
642 { |
641 { |
643 NM_FUNCTION; |
642 NM_FUNCTION; |
644 |
643 |
645 // Get the mailbox with the given ID. |
644 // Get the mailbox with the given ID. |
646 CFSMailBox *mailbox(NULL); |
645 CFSMailBox *mailbox(NULL); |
647 TRAPD(err, mailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
646 TRAPD(err, mailbox = mFSfw->GetMailBoxByUidL(mailboxId)); |
648 |
647 |
649 if (err == KErrNone && mailbox) { |
648 if (err == KErrNone && mailbox) { |
685 delete mCurrentMailBox; |
684 delete mCurrentMailBox; |
686 mCurrentMailBox = NULL; |
685 mCurrentMailBox = NULL; |
687 mCurrentMailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
686 mCurrentMailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
688 } |
687 } |
689 CEmailExtension *extension = getEMailStateExtensionL(); |
688 CEmailExtension *extension = getEMailStateExtensionL(); |
690 CMailboxStateExtension *stateExtension = |
689 CMailboxStateExtension *stateExtension = |
691 static_cast<CMailboxStateExtension*>(extension); |
690 static_cast<CMailboxStateExtension*>(extension); |
692 if (stateExtension) { |
691 if (stateExtension) { |
693 stateExtension->NotifyActiveFolderChanged(mailboxId, folderId); |
692 stateExtension->NotifyActiveFolderChanged(mailboxId, folderId); |
694 } |
693 } |
695 } |
694 } |
696 |
695 |
697 /*! |
696 /*! |
698 function to process updateActiveFolder. This method may leave. |
697 function to process updateActiveFolder. This method may leave. |
699 */ |
698 */ |
700 CEmailExtension* NmFrameworkAdapter::getEMailStateExtensionL() |
699 CEmailExtension* NmFrameworkAdapter::getEMailStateExtensionL() |
701 { |
700 { |
702 if (!mStateExtension && mCurrentMailBox) { |
701 if (!mStateExtension && mCurrentMailBox) { |
703 // This extension is owned and deleted by the plugin, so no need to |
702 // This extension is owned and deleted by the plugin, so no need to |
704 // use release unless the extension will be relocated into extensionbase. |
703 // use release unless the extension will be relocated into extensionbase. |
705 mStateExtension = mCurrentMailBox->ExtensionL(KEmailMailboxStateExtensionUid); |
704 mStateExtension = mCurrentMailBox->ExtensionL(KEmailMailboxStateExtensionUid); |
706 } |
705 } |
707 return mStateExtension; |
706 return mStateExtension; |
708 } |
707 } |
709 |
708 |
710 /*! |
709 /*! |
711 Starts an asynchronous search for messages with the given search strings. |
710 Starts an asynchronous search for messages with the given search strings. |
712 |
711 |
713 \param mailboxId The mailbox to search from. |
712 \param mailboxId The mailbox to search from. |
714 \param folderIds (not used) |
713 \param folderIds (not used) |
715 \param searchStrings The strings to search. |
714 \param searchStrings The strings to search. |
716 \param searchObserver The observer which gets informed about the progress |
715 \param searchObserver The observer which gets informed about the progress |
717 of the search (match found, search complete etc.) |
716 of the search (match found, search complete etc.) |
718 */ |
717 */ |
719 void NmFrameworkAdapter::searchL(const NmId &mailboxId, |
718 void NmFrameworkAdapter::searchL(const NmId &mailboxId, |
720 const QList<NmId> &folderIds, |
719 const QList<NmId> &folderIds, |
721 const QStringList &searchStrings, |
720 const QStringList &searchStrings, |
722 NmMailboxSearchObserver &searchObserver) |
721 NmMailboxSearchObserver &searchObserver) |
723 { |
722 { |
724 NM_FUNCTION; |
723 NM_FUNCTION; |
725 |
724 |
726 // CFSMailBox has no support for search using folder IDs. |
725 // CFSMailBox has no support for search using folder IDs. |
727 Q_UNUSED(folderIds); |
726 Q_UNUSED(folderIds); |
728 |
727 |
729 // Get the mailbox with the given ID. |
728 // Get the mailbox with the given ID. |
730 CFSMailBox *mailbox(NULL); |
729 CFSMailBox *mailbox(NULL); |
731 mailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
730 mailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
732 |
731 |
784 \param messageId Id of message containing the message parts |
783 \param messageId Id of message containing the message parts |
785 \param messagePartId id of message part |
784 \param messagePartId id of message part |
786 |
785 |
787 \return An NmOperation object for the operation, ownership is transferred to caller |
786 \return An NmOperation object for the operation, ownership is transferred to caller |
788 */ |
787 */ |
789 QPointer<NmOperation> NmFrameworkAdapter::fetchMessagePart( |
788 QPointer<NmOperation> NmFrameworkAdapter::fetchMessagePart( |
790 const NmId &mailboxId, |
789 const NmId &mailboxId, |
791 const NmId &folderId, |
790 const NmId &folderId, |
792 const NmId &messageId, |
791 const NmId &messageId, |
793 const NmId &messagePartId) |
792 const NmId &messagePartId) |
794 { |
793 { |
795 NM_FUNCTION; |
794 NM_FUNCTION; |
796 |
795 |
797 QPointer<NmOperation> oper = new NmFwaMessagePartFetchingOperation( |
796 QPointer<NmOperation> oper = new NmFwaMessagePartFetchingOperation( |
798 mailboxId, folderId, messageId, messagePartId, *mFSfw); |
797 mailboxId, folderId, messageId, messagePartId, *mFSfw); |
799 return oper; |
798 return oper; |
800 } |
799 } |
801 |
800 |
807 \param messageId Id of message containing the message parts |
806 \param messageId Id of message containing the message parts |
808 \param messagePartIds ids of message parts |
807 \param messagePartIds ids of message parts |
809 |
808 |
810 \return An NmOperation object for the operation, ownership is transferred to caller |
809 \return An NmOperation object for the operation, ownership is transferred to caller |
811 */ |
810 */ |
812 QPointer<NmOperation> NmFrameworkAdapter::fetchMessageParts( |
811 QPointer<NmOperation> NmFrameworkAdapter::fetchMessageParts( |
813 const NmId &mailboxId, |
812 const NmId &mailboxId, |
814 const NmId &folderId, |
813 const NmId &folderId, |
815 const NmId &messageId, |
814 const NmId &messageId, |
816 const QList<NmId> &messagePartIds) |
815 const QList<NmId> &messagePartIds) |
817 { |
816 { |
818 NM_FUNCTION; |
817 NM_FUNCTION; |
819 |
818 |
820 QPointer<NmOperation> oper = new NmFwaMessagePartsFetchingOperation( |
819 QPointer<NmOperation> oper = new NmFwaMessagePartsFetchingOperation( |
821 mailboxId, folderId, messageId, messagePartIds, *mFSfw); |
820 mailboxId, folderId, messageId, messagePartIds, *mFSfw); |
822 return oper; |
821 return oper; |
823 } |
822 } |
824 |
823 |
825 /*! |
824 /*! |
826 Returns sharable file handle to message part content |
825 Returns sharable file handle to message part content |
827 |
826 |
837 const NmId &folderId, |
836 const NmId &folderId, |
838 const NmId &messageId, |
837 const NmId &messageId, |
839 const NmId &messagePartId) |
838 const NmId &messagePartId) |
840 { |
839 { |
841 NM_FUNCTION; |
840 NM_FUNCTION; |
842 |
841 |
843 XQSharableFile retFile; |
842 XQSharableFile retFile; |
844 TFSMailDetails details(EFSMsgDataEnvelope); |
843 TFSMailDetails details(EFSMsgDataEnvelope); |
845 TFSMailMsgId fsMboxId(mailboxId); |
844 TFSMailMsgId fsMboxId(mailboxId); |
846 TFSMailMsgId fsFolderId(folderId); |
845 TFSMailMsgId fsFolderId(folderId); |
847 TFSMailMsgId fsMsgId(messageId); |
846 TFSMailMsgId fsMsgId(messageId); |
848 TFSMailMsgId fsMsgPartId(messagePartId); |
847 TFSMailMsgId fsMsgPartId(messagePartId); |
849 |
848 |
850 CFSMailMessage* fsMessage = NULL; |
849 CFSMailMessage* fsMessage = NULL; |
851 int error = KErrNone; |
850 int error = KErrNone; |
852 TRAP(error, fsMessage = mFSfw->GetMessageByUidL(fsMboxId, fsFolderId, |
851 TRAP(error, fsMessage = mFSfw->GetMessageByUidL(fsMboxId, fsFolderId, |
853 fsMsgId, details) ); |
852 fsMsgId, details) ); |
854 |
853 |
855 CFSMailMessagePart* fsMessagePart = NULL; |
854 CFSMailMessagePart* fsMessagePart = NULL; |
856 if (fsMessage && error == KErrNone) { |
855 if (fsMessage && error == KErrNone) { |
857 TRAP(error, fsMessagePart = fsMessage->ChildPartL(fsMsgPartId) ); |
856 TRAP(error, fsMessagePart = fsMessage->ChildPartL(fsMsgPartId) ); |
858 |
857 |
859 } |
858 } |
860 if (fsMessagePart && error == KErrNone) { |
859 if (fsMessagePart && error == KErrNone) { |
861 RFile file = fsMessagePart->GetContentFileL(); |
860 RFile file = fsMessagePart->GetContentFileL(); |
862 retFile.setHandle(file); |
861 retFile.setHandle(file); |
863 } |
862 } |
875 NmId NmFrameworkAdapter::getStandardFolderId( |
874 NmId NmFrameworkAdapter::getStandardFolderId( |
876 const NmId& mailboxId, |
875 const NmId& mailboxId, |
877 NmFolderType folderType ) |
876 NmFolderType folderType ) |
878 { |
877 { |
879 NM_FUNCTION; |
878 NM_FUNCTION; |
880 |
879 |
881 TFSMailMsgId folderId; |
880 TFSMailMsgId folderId; |
882 NmId resultId(0); |
881 NmId resultId(0); |
883 CFSMailBox * currentMailbox(NULL); |
882 CFSMailBox * currentMailbox(NULL); |
884 |
883 |
885 TRAPD(error, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId) ); |
884 TRAPD(error, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId) ); |
993 const NmId &folderId, |
992 const NmId &folderId, |
994 const NmId &messageId, |
993 const NmId &messageId, |
995 NmMessagePart &messagePart) |
994 NmMessagePart &messagePart) |
996 { |
995 { |
997 NM_FUNCTION; |
996 NM_FUNCTION; |
998 |
997 |
999 CFSMailMessagePart* cfsPart = CFSMailMessagePart::NewLC(messageId,messagePart); |
998 CFSMailMessagePart* cfsPart = CFSMailMessagePart::NewLC(messageId,messagePart); |
1000 cfsPart->SetMailBoxId(TFSMailMsgId(mailboxId)); |
999 cfsPart->SetMailBoxId(TFSMailMsgId(mailboxId)); |
1001 cfsPart->SetFolderId(TFSMailMsgId(folderId)); |
1000 cfsPart->SetFolderId(TFSMailMsgId(folderId)); |
1002 QString contentType = messagePart.contentType(); |
1001 QString contentType = messagePart.contentType(); |
1003 |
1002 |
1035 QByteArray msgBytes = QByteArray(reinterpret_cast<const char*>(dataPtr.Ptr()), fileSize); |
1034 QByteArray msgBytes = QByteArray(reinterpret_cast<const char*>(dataPtr.Ptr()), fileSize); |
1036 QTextCodec *codec = QTextCodec::codecForName(charset.toAscii()); |
1035 QTextCodec *codec = QTextCodec::codecForName(charset.toAscii()); |
1037 if (!codec) { |
1036 if (!codec) { |
1038 codec = QTextCodec::codecForName("UTF-8"); |
1037 codec = QTextCodec::codecForName("UTF-8"); |
1039 } |
1038 } |
1040 QString encodedStr = codec->toUnicode(msgBytes); |
1039 QString encodedStr = codec->toUnicode(msgBytes); |
1041 messagePart.setTextContent(encodedStr, contentType); |
1040 messagePart.setTextContent(encodedStr, contentType); |
1042 } |
1041 } |
1043 else { |
1042 else { |
1044 messagePart.setBinaryContent(QByteArray( |
1043 messagePart.setBinaryContent(QByteArray( |
1045 reinterpret_cast<const char*>(dataPtr.Ptr()), fileSize), contentType); |
1044 reinterpret_cast<const char*>(dataPtr.Ptr()), fileSize), contentType); |
1046 } |
1045 } |
1069 const NmId &mailboxId, |
1068 const NmId &mailboxId, |
1070 const NmId &folderId, |
1069 const NmId &folderId, |
1071 const QList<NmId> &messageIdList) |
1070 const QList<NmId> &messageIdList) |
1072 { |
1071 { |
1073 NM_FUNCTION; |
1072 NM_FUNCTION; |
1074 |
1073 |
1075 TInt err = NmNoError; |
1074 TInt err = NmNoError; |
1076 RArray<TFSMailMsgId> messageIds; |
1075 RArray<TFSMailMsgId> messageIds; |
1077 for (TInt i=0; i<messageIdList.size(); i++) { |
1076 for (TInt i=0; i<messageIdList.size(); i++) { |
1078 err = messageIds.Append(TFSMailMsgId(messageIdList[i])); |
1077 err = messageIds.Append(TFSMailMsgId(messageIdList[i])); |
1079 if (err!=NmNoError) { |
1078 if (err!=NmNoError) { |
1172 const NmId &mailboxId, |
1171 const NmId &mailboxId, |
1173 const NmId &originalMessageId, |
1172 const NmId &originalMessageId, |
1174 const bool replyAll) |
1173 const bool replyAll) |
1175 { |
1174 { |
1176 NM_FUNCTION; |
1175 NM_FUNCTION; |
1177 |
1176 |
1178 QPointer<NmMessageCreationOperation> oper = |
1177 QPointer<NmMessageCreationOperation> oper = |
1179 new NmFwaReplyMessageCreationOperation(mailboxId, originalMessageId, replyAll, *mFSfw); |
1178 new NmFwaReplyMessageCreationOperation(mailboxId, originalMessageId, replyAll, *mFSfw); |
1180 return oper; |
1179 return oper; |
1181 } |
1180 } |
1182 |
1181 |
1184 Not implemented yet. |
1183 Not implemented yet. |
1185 */ |
1184 */ |
1186 int NmFrameworkAdapter::saveMessage(const NmMessage &message) |
1185 int NmFrameworkAdapter::saveMessage(const NmMessage &message) |
1187 { |
1186 { |
1188 NM_FUNCTION; |
1187 NM_FUNCTION; |
1189 |
1188 |
1190 Q_UNUSED(message); |
1189 Q_UNUSED(message); |
1191 return NmNoError; |
1190 return NmNoError; |
1192 } |
1191 } |
1193 |
1192 |
1194 /*! |
1193 /*! |
1195 Store asynchronously message with its parts. |
1194 Store asynchronously message with its parts. |
1196 */ |
1195 */ |
1197 QPointer<NmOperation> NmFrameworkAdapter::saveMessageWithSubparts(const NmMessage &message) |
1196 QPointer<NmOperation> NmFrameworkAdapter::saveMessageWithSubparts(const NmMessage &message) |
1198 { |
1197 { |
1199 NM_FUNCTION; |
1198 NM_FUNCTION; |
1200 |
1199 |
1201 CFSMailMessage * cfsMessage = NULL; |
1200 CFSMailMessage * cfsMessage = NULL; |
1202 QPointer<NmOperation> oper(NULL); |
1201 QPointer<NmOperation> oper(NULL); |
1203 |
1202 |
1204 int err = KErrNone; |
1203 int err = KErrNone; |
1205 TRAP(err, cfsMessage = CFSMailMessage::NewL(message)); |
1204 TRAP(err, cfsMessage = CFSMailMessage::NewL(message)); |
1415 const NmId& mailboxId, |
1414 const NmId& mailboxId, |
1416 const NmId& folderId, |
1415 const NmId& folderId, |
1417 const NmId& messageId) |
1416 const NmId& messageId) |
1418 { |
1417 { |
1419 NM_FUNCTION; |
1418 NM_FUNCTION; |
1420 |
1419 |
1421 CFSMailFolder* folder = mFSfw->GetFolderByUidL( TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); |
1420 CFSMailFolder* folder = mFSfw->GetFolderByUidL( TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); |
1422 CleanupStack::PushL(folder); |
1421 CleanupStack::PushL(folder); |
1423 if ( folder ) { |
1422 if ( folder ) { |
1424 folder->RemoveMessageL(TFSMailMsgId(messageId)); |
1423 folder->RemoveMessageL(TFSMailMsgId(messageId)); |
1425 } |
1424 } |
1437 { |
1436 { |
1438 NM_FUNCTION; |
1437 NM_FUNCTION; |
1439 |
1438 |
1440 RArray<TFSMailMsgId> messages; |
1439 RArray<TFSMailMsgId> messages; |
1441 RArray<TFSMailMsgId> copiedMessages; |
1440 RArray<TFSMailMsgId> copiedMessages; |
1442 |
1441 |
1443 CleanupClosePushL(messages); |
1442 CleanupClosePushL(messages); |
1444 CleanupClosePushL(copiedMessages); |
1443 CleanupClosePushL(copiedMessages); |
1445 |
1444 |
1446 for (TInt i = 0; i < messageIds.count(); i++) { |
1445 for (TInt i = 0; i < messageIds.count(); i++) { |
1447 NmId tmpId(messageIds[i]); |
1446 NmId tmpId(messageIds[i]); |
1448 messages.AppendL(TFSMailMsgId(tmpId)); |
1447 messages.AppendL(TFSMailMsgId(tmpId)); |
1449 } |
1448 } |
1450 |
1449 |
1451 CFSMailBox* mailBox = NULL; |
1450 CFSMailBox* mailBox = NULL; |
1452 mailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
1451 mailBox = mFSfw->GetMailBoxByUidL(mailboxId); |
1453 if (mailBox) { |
1452 if (mailBox) { |
1454 mailBox->CopyMessagesL(messages, copiedMessages, |
1453 mailBox->CopyMessagesL(messages, copiedMessages, |
1455 TFSMailMsgId(sourceFolderId), |
1454 TFSMailMsgId(sourceFolderId), |
1456 TFSMailMsgId(destinationFolderId)); |
1455 TFSMailMsgId(destinationFolderId)); |
1457 delete mailBox; |
1456 delete mailBox; |
1458 } |
1457 } |
1459 |
1458 |
1460 CleanupStack::PopAndDestroy(2,&messages); |
1459 CleanupStack::PopAndDestroy(2,&messages); |
1461 } |
1460 } |
1462 |
1461 |
1463 /*! |
1462 /*! |
1464 Sends the given message. |
1463 Sends the given message. |
1465 */ |
1464 */ |
1466 QPointer<NmMessageSendingOperation> NmFrameworkAdapter::sendMessage( |
1465 QPointer<NmMessageSendingOperation> NmFrameworkAdapter::sendMessage( |
1467 NmMessage *message) |
1466 NmMessage *message) |
1468 { |
1467 { |
1469 NM_FUNCTION; |
1468 NM_FUNCTION; |
1470 |
1469 |
1471 QPointer<NmMessageSendingOperation>oper = new NmFwaMessageSendingOperation(*this, message, *mFSfw); |
1470 QPointer<NmMessageSendingOperation>oper = new NmFwaMessageSendingOperation(*this, message, *mFSfw); |
1472 return oper; |
1471 return oper; |
1473 } |
1472 } |
1474 |
1473 |
1475 /*! |
1474 /*! |
1491 QPointer<NmOperation> NmFrameworkAdapter::removeAttachment( |
1490 QPointer<NmOperation> NmFrameworkAdapter::removeAttachment( |
1492 const NmMessage &message, |
1491 const NmMessage &message, |
1493 const NmId &attachmentPartId) |
1492 const NmId &attachmentPartId) |
1494 { |
1493 { |
1495 NM_FUNCTION; |
1494 NM_FUNCTION; |
1496 |
1495 |
1497 QPointer<NmOperation> oper = new NmFwaRemoveAttachmentOperation(message, attachmentPartId, *mFSfw); |
1496 QPointer<NmOperation> oper = new NmFwaRemoveAttachmentOperation(message, attachmentPartId, *mFSfw); |
1498 return oper; |
1497 return oper; |
1499 } |
1498 } |
1500 |
1499 |
1501 /*! |
1500 /*! |
1502 Returns the current sync state of the given mailbox |
1501 Returns the current sync state of the given mailbox |
1503 */ |
1502 */ |
1504 NmSyncState NmFrameworkAdapter::syncState(const NmId& mailboxId) const |
1503 NmSyncState NmFrameworkAdapter::syncState(const NmId& mailboxId) const |
1505 { |
1504 { |
1506 NM_FUNCTION; |
1505 NM_FUNCTION; |
1507 |
1506 |
1508 CFSMailBox* mailBox = NULL; |
1507 CFSMailBox* mailBox = NULL; |
1509 TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) ); |
1508 TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) ); |
1510 if (KErrNone == err && mailBox) { |
1509 if (KErrNone == err && mailBox) { |
1511 TSSMailSyncState syncState = mailBox->CurrentSyncState(); |
1510 TSSMailSyncState syncState = mailBox->CurrentSyncState(); |
1512 delete mailBox; |
1511 delete mailBox; |
1526 Returns the current connection state of the given mailbox |
1525 Returns the current connection state of the given mailbox |
1527 */ |
1526 */ |
1528 NmConnectState NmFrameworkAdapter::connectionState(const NmId& mailboxId) const |
1527 NmConnectState NmFrameworkAdapter::connectionState(const NmId& mailboxId) const |
1529 { |
1528 { |
1530 NM_FUNCTION; |
1529 NM_FUNCTION; |
1531 |
1530 |
1532 CFSMailBox* mailBox = NULL; |
1531 CFSMailBox* mailBox = NULL; |
1533 TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) ); |
1532 TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) ); |
1534 if (KErrNone == err && mailBox) { |
1533 if (KErrNone == err && mailBox) { |
1535 TFSMailBoxStatus status = mailBox->GetMailBoxStatus(); |
1534 TFSMailBoxStatus status = mailBox->GetMailBoxStatus(); |
1536 delete mailBox; |
1535 delete mailBox; |
1569 void NmFrameworkAdapter::childrenToNmMessagePartL( |
1568 void NmFrameworkAdapter::childrenToNmMessagePartL( |
1570 CFSMailMessagePart *cfsParent, |
1569 CFSMailMessagePart *cfsParent, |
1571 NmMessagePart *nmParent) |
1570 NmMessagePart *nmParent) |
1572 { |
1571 { |
1573 NM_FUNCTION; |
1572 NM_FUNCTION; |
1574 |
1573 |
1575 User::LeaveIfNull(cfsParent); |
1574 User::LeaveIfNull(cfsParent); |
1576 User::LeaveIfNull(nmParent); |
1575 User::LeaveIfNull(nmParent); |
1577 |
1576 |
1578 RPointerArray<CFSMailMessagePart> parts; |
1577 RPointerArray<CFSMailMessagePart> parts; |
1579 cfsParent->ChildPartsL(parts); |
1578 cfsParent->ChildPartsL(parts); |
1594 Leaving Refresh function |
1593 Leaving Refresh function |
1595 */ |
1594 */ |
1596 int NmFrameworkAdapter::RefreshMailboxL(NmId mailboxId) |
1595 int NmFrameworkAdapter::RefreshMailboxL(NmId mailboxId) |
1597 { |
1596 { |
1598 NM_FUNCTION; |
1597 NM_FUNCTION; |
1599 |
1598 |
1600 int result(KErrNotFound); |
1599 int result(KErrNotFound); |
1601 CFSMailBox *currentMailbox(NULL); |
1600 CFSMailBox *currentMailbox(NULL); |
1602 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1601 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1603 if(currentMailbox) { |
1602 if(currentMailbox) { |
1604 CleanupStack::PushL(currentMailbox); |
1603 CleanupStack::PushL(currentMailbox); |
1613 Leaving Go Online function |
1612 Leaving Go Online function |
1614 */ |
1613 */ |
1615 int NmFrameworkAdapter::GoOnlineL(const NmId& mailboxId) |
1614 int NmFrameworkAdapter::GoOnlineL(const NmId& mailboxId) |
1616 { |
1615 { |
1617 NM_FUNCTION; |
1616 NM_FUNCTION; |
1618 |
1617 |
1619 int result(KErrNotFound); |
1618 int result(KErrNotFound); |
1620 CFSMailBox *currentMailbox(NULL); |
1619 CFSMailBox *currentMailbox(NULL); |
1621 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1620 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1622 if(currentMailbox) { |
1621 if(currentMailbox) { |
1623 CleanupStack::PushL(currentMailbox); |
1622 CleanupStack::PushL(currentMailbox); |
1632 Leaving Go Offline function |
1631 Leaving Go Offline function |
1633 */ |
1632 */ |
1634 int NmFrameworkAdapter::GoOfflineL(const NmId& mailboxId) |
1633 int NmFrameworkAdapter::GoOfflineL(const NmId& mailboxId) |
1635 { |
1634 { |
1636 NM_FUNCTION; |
1635 NM_FUNCTION; |
1637 |
1636 |
1638 int result(KErrNotFound); |
1637 int result(KErrNotFound); |
1639 CFSMailBox *currentMailbox(NULL); |
1638 CFSMailBox *currentMailbox(NULL); |
1640 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1639 currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId); |
1641 if(currentMailbox) { |
1640 if(currentMailbox) { |
1642 CleanupStack::PushL(currentMailbox); |
1641 CleanupStack::PushL(currentMailbox); |
1651 handles mailbox related events |
1650 handles mailbox related events |
1652 */ |
1651 */ |
1653 void NmFrameworkAdapter::handleMailboxEvent( TFSMailMsgId mailbox, NmMailboxEvent event) |
1652 void NmFrameworkAdapter::handleMailboxEvent( TFSMailMsgId mailbox, NmMailboxEvent event) |
1654 { |
1653 { |
1655 NM_FUNCTION; |
1654 NM_FUNCTION; |
1656 |
1655 |
1657 QList<NmId> mailboxIds; |
1656 QList<NmId> mailboxIds; |
1658 NmId nmId; |
1657 NmId nmId; |
1659 if (event == NmMailboxDeleted) { |
1658 if (event == NmMailboxDeleted || |
|
1659 event == NmMailboxCreated || |
|
1660 event == NmMailboxChanged) { |
1660 nmId = mailbox.GetNmId(); |
1661 nmId = mailbox.GetNmId(); |
1661 } else { |
1662 } else { |
1662 nmId = getMailboxIdByMailMsgId(mailbox); |
1663 nmId = getMailboxIdByMailMsgId(mailbox); |
1663 } |
1664 } |
1664 mailboxIds.append(nmId); |
1665 mailboxIds.append(nmId); |
1695 function to handle mailmoved event |
1696 function to handle mailmoved event |
1696 */ |
1697 */ |
1697 void NmFrameworkAdapter::handleMailMoved(TAny* param1,TAny* param2,TAny* param3, TFSMailMsgId mailbox) |
1698 void NmFrameworkAdapter::handleMailMoved(TAny* param1,TAny* param2,TAny* param3, TFSMailMsgId mailbox) |
1698 { |
1699 { |
1699 NM_FUNCTION; |
1700 NM_FUNCTION; |
1700 |
1701 |
1701 NmId nmMsgId(0); |
1702 NmId nmMsgId(0); |
1702 QList<NmId> messageIds; |
1703 QList<NmId> messageIds; |
1703 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
1704 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
1704 TFSMailMsgId* fsFromFolderId = reinterpret_cast<TFSMailMsgId*> (param3); |
1705 TFSMailMsgId* fsFromFolderId = reinterpret_cast<TFSMailMsgId*> (param3); |
1705 NmId fromFolderId = fsFromFolderId->GetNmId(); |
1706 NmId fromFolderId = fsFromFolderId->GetNmId(); |
1722 function to handle mailcopied event |
1723 function to handle mailcopied event |
1723 */ |
1724 */ |
1724 void NmFrameworkAdapter::handleMailCopied(TAny* param1,TAny* param2, TFSMailMsgId mailbox) |
1725 void NmFrameworkAdapter::handleMailCopied(TAny* param1,TAny* param2, TFSMailMsgId mailbox) |
1725 { |
1726 { |
1726 NM_FUNCTION; |
1727 NM_FUNCTION; |
1727 |
1728 |
1728 NmId nmMsgId(0); |
1729 NmId nmMsgId(0); |
1729 QList<NmId> messageIds; |
1730 QList<NmId> messageIds; |
1730 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
1731 RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1); |
1731 TFSMailMsgId* fsToFolderId = reinterpret_cast<TFSMailMsgId*> (param2); |
1732 TFSMailMsgId* fsToFolderId = reinterpret_cast<TFSMailMsgId*> (param2); |
1732 NmId toFolderId = fsToFolderId->GetNmId(); |
1733 NmId toFolderId = fsToFolderId->GetNmId(); |