emailuis/nmframeworkadapter/src/nmframeworkadapter.cpp
changeset 59 16ed8d08d0b1
parent 54 997a02608b3a
child 62 a8c646b56683
equal deleted inserted replaced
54:997a02608b3a 59:16ed8d08d0b1
   111     \return Error code.
   111     \return Error code.
   112  */
   112  */
   113 int NmFrameworkAdapter::listMailboxes(QList<NmMailbox*>& mailboxList)
   113 int NmFrameworkAdapter::listMailboxes(QList<NmMailbox*>& mailboxList)
   114 {
   114 {
   115     NM_FUNCTION;
   115     NM_FUNCTION;
   116     
   116 
   117     // get list of mailboxes from all plugins
   117     // get list of mailboxes from all plugins
   118     TFSMailMsgId id;
   118     TFSMailMsgId id;
   119     id.SetNullId();
   119     id.SetNullId();
   120     RPointerArray<CFSMailBox> mailBoxes;
   120     RPointerArray<CFSMailBox> mailBoxes;
   121 
   121 
   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;
   235     const NmId& folderId,
   235     const NmId& folderId,
   236     const NmId& messageId,
   236     const NmId& messageId,
   237     NmMessage*& message)
   237     NmMessage*& message)
   238 {
   238 {
   239     NM_FUNCTION;
   239     NM_FUNCTION;
   240     
   240 
   241     TRAPD(err, getMessageByIdL(mailboxId,folderId,messageId,message));
   241     TRAPD(err, getMessageByIdL(mailboxId,folderId,messageId,message));
   242     return err;
   242     return err;
   243 }
   243 }
   244 
   244 
   245 /*!
   245 /*!
   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++) {
   314      CFSMailFolder *folder,
   314      CFSMailFolder *folder,
   315      QList<NmMessageEnvelope*> &messageEnvelopeList,
   315      QList<NmMessageEnvelope*> &messageEnvelopeList,
   316      const int maxEnvelopeCount)
   316      const int maxEnvelopeCount)
   317 {
   317 {
   318     NM_FUNCTION;
   318     NM_FUNCTION;
   319     
   319 
   320     if (!folder || maxEnvelopeCount < 1) {
   320     if (!folder || maxEnvelopeCount < 1) {
   321         return;
   321         return;
   322     }
   322     }
   323 
   323 
   324     int blockSize = NmListMessagesBlock;
   324     int blockSize = NmListMessagesBlock;
   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) {
   380         CleanupStack::Pop(iterator);
   380         CleanupStack::Pop(iterator);
   381         delete iterator;
   381         delete iterator;
   382         iterator = NULL;
   382         iterator = NULL;
   383     }
   383     }
   384 
   384 
   385     CleanupStack::PopAndDestroy(); // sorting  
   385     CleanupStack::PopAndDestroy(); // sorting
   386 }
   386 }
   387 
   387 
   388 
   388 
   389 /*!
   389 /*!
   390     Returns list of envelopes from the backend for specific mailbox and folder.
   390     Returns list of envelopes from the backend for specific mailbox and folder.
   400 	const NmId &mailboxId,
   400 	const NmId &mailboxId,
   401     const NmId &folderId,
   401     const NmId &folderId,
   402     QList<NmMessageEnvelope*> &messageEnvelopeList)
   402     QList<NmMessageEnvelope*> &messageEnvelopeList)
   403 {
   403 {
   404     NM_FUNCTION;
   404     NM_FUNCTION;
   405     
   405 
   406     TRAPD(err, listMessagesL(mailboxId,folderId,messageEnvelopeList, NmMaxItemsInMessageList));
   406     TRAPD(err, listMessagesL(mailboxId,folderId,messageEnvelopeList, NmMaxItemsInMessageList));
   407     return err;
   407     return err;
   408 }
   408 }
   409 
   409 
   410 
   410 
   425         const NmId& folderId,
   425         const NmId& folderId,
   426         QList<NmMessageEnvelope*> &messageEnvelopeList,
   426         QList<NmMessageEnvelope*> &messageEnvelopeList,
   427         const int maxAmountOfEnvelopes)
   427         const int maxAmountOfEnvelopes)
   428 {
   428 {
   429     NM_FUNCTION;
   429     NM_FUNCTION;
   430     
   430 
   431     TInt err = KErrNone;
   431     TInt err = KErrNone;
   432     TRAP(err, listMessagesL(mailboxId,folderId, messageEnvelopeList,maxAmountOfEnvelopes) );
   432     TRAP(err, listMessagesL(mailboxId,folderId, messageEnvelopeList,maxAmountOfEnvelopes) );
   433     return err;
   433     return err;
   434 }
   434 }
   435 
   435 
   443         const NmId &folderId,
   443         const NmId &folderId,
   444         QList<NmMessageEnvelope*> &messageEnvelopeList,
   444         QList<NmMessageEnvelope*> &messageEnvelopeList,
   445         const int maxAmountOfEnvelopes)
   445         const int maxAmountOfEnvelopes)
   446 {
   446 {
   447     NM_FUNCTION;
   447     NM_FUNCTION;
   448     
   448 
   449     // If we are requesting 0 or less mails, we can just return.
   449     // If we are requesting 0 or less mails, we can just return.
   450     if (maxAmountOfEnvelopes <= 0) {
   450     if (maxAmountOfEnvelopes <= 0) {
   451         return;
   451         return;
   452     }
   452     }
   453 
   453 
   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,
   488     const NmId &folderId,
   488     const NmId &folderId,
   489     QList<NmMessage*> &messageList,
   489     QList<NmMessage*> &messageList,
   490     const int maxAmountOfMessages)
   490     const int maxAmountOfMessages)
   491 {
   491 {
   492     NM_FUNCTION;
   492     NM_FUNCTION;
   493     
   493 
   494     TRAPD(err, listMessagesL(mailboxId,folderId,messageList, maxAmountOfMessages));
   494     TRAPD(err, listMessagesL(mailboxId,folderId,messageList, maxAmountOfMessages));
   495     return err;
   495     return err;
   496 }
   496 }
   497 
   497 
   498 
   498 
   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)
   525         if(maxAmountOfEnvelopes < NmListMessagesBlock)
   525         if(maxAmountOfEnvelopes < NmListMessagesBlock)
   526             {
   526             {
   527             blockSize = maxAmountOfEnvelopes;
   527             blockSize = maxAmountOfEnvelopes;
   528             }
   528             }
   529         }
   529         }
   530    
   530 
   531     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
   531     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
   532     if (!currentMailbox) {
   532     if (!currentMailbox) {
   533         User::Leave(KErrNotFound);
   533         User::Leave(KErrNotFound);
   534     }
   534     }
   535     CleanupStack::PushL(currentMailbox);
   535     CleanupStack::PushL(currentMailbox);
   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);
   583                                              *plainTextPart);
   583                                              *plainTextPart);
   584                     }
   584                     }
   585                     messageList.append(newMessage);
   585                     messageList.append(newMessage);
   586                 }
   586                 }
   587             }
   587             }
   588             
   588 
   589             CleanupStack::PopAndDestroy( &messages );
   589             CleanupStack::PopAndDestroy( &messages );
   590             CleanupStack::Pop(iterator);
   590             CleanupStack::Pop(iterator);
   591             delete iterator;
   591             delete iterator;
   592             iterator = NULL;
   592             iterator = NULL;
   593         }
   593         }
   611 */
   611 */
   612 int NmFrameworkAdapter::search(const NmId &mailboxId,
   612 int NmFrameworkAdapter::search(const NmId &mailboxId,
   613                                const QStringList &searchStrings)
   613                                const QStringList &searchStrings)
   614 {
   614 {
   615     NM_FUNCTION;
   615     NM_FUNCTION;
   616     
   616 
   617     if (!mSearchObserver) {
   617     if (!mSearchObserver) {
   618         mSearchObserver = new NmMailboxSearchObserver();
   618         mSearchObserver = new NmMailboxSearchObserver();
   619     }
   619     }
   620 
   620 
   621     // Set connections for forwarding the signals emitted by the search
   621     // Set connections for forwarding the signals emitted by the search
   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 
   769     const NmId &mailboxId,
   768     const NmId &mailboxId,
   770     const NmId &folderId,
   769     const NmId &folderId,
   771     const NmId &messageId )
   770     const NmId &messageId )
   772 {
   771 {
   773     NM_FUNCTION;
   772     NM_FUNCTION;
   774     
   773 
   775     NmOperation *oper = new NmFwaMessageFetchingOperation(mailboxId, folderId, messageId, *mFSfw);
   774     NmOperation *oper = new NmFwaMessageFetchingOperation(mailboxId, folderId, messageId, *mFSfw);
   776     return oper;
   775     return oper;
   777 }
   776 }
   778 
   777 
   779 /*!
   778 /*!
   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) );
   978     const NmId &folderId,
   977     const NmId &folderId,
   979     const NmId &messageId,
   978     const NmId &messageId,
   980     NmMessagePart &messagePart)
   979     NmMessagePart &messagePart)
   981 {
   980 {
   982     NM_FUNCTION;
   981     NM_FUNCTION;
   983     
   982 
   984     TRAPD(err, contentToMessagePartL(mailboxId,folderId,messageId,messagePart));
   983     TRAPD(err, contentToMessagePartL(mailboxId,folderId,messageId,messagePart));
   985     return err;
   984     return err;
   986 }
   985 }
   987 
   986 
   988 /*!
   987 /*!
   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) {
  1101 	const NmId &mailboxId,
  1100 	const NmId &mailboxId,
  1102 	const NmId &folderId,
  1101 	const NmId &folderId,
  1103 	const QList<const NmMessageEnvelope*> &envelopeList)
  1102 	const QList<const NmMessageEnvelope*> &envelopeList)
  1104 {
  1103 {
  1105     NM_FUNCTION;
  1104     NM_FUNCTION;
  1106     
  1105 
  1107     Q_UNUSED(folderId);
  1106     Q_UNUSED(folderId);
  1108 
  1107 
  1109     QPointer<NmStoreEnvelopesOperation> operation(NULL);
  1108     QPointer<NmStoreEnvelopesOperation> operation(NULL);
  1110     RPointerArray<CFSMailMessage> envelopeMessages;
  1109     RPointerArray<CFSMailMessage> envelopeMessages;
  1111 
  1110 
  1132     \return NmMessageCreationOperation
  1131     \return NmMessageCreationOperation
  1133  */
  1132  */
  1134 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createNewMessage(const NmId &mailboxId)
  1133 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createNewMessage(const NmId &mailboxId)
  1135 {
  1134 {
  1136     NM_FUNCTION;
  1135     NM_FUNCTION;
  1137     
  1136 
  1138     QPointer<NmMessageCreationOperation> oper =
  1137     QPointer<NmMessageCreationOperation> oper =
  1139         new NmFwaMessageCreationOperation(mailboxId, *mFSfw);
  1138         new NmFwaMessageCreationOperation(mailboxId, *mFSfw);
  1140     return oper;
  1139     return oper;
  1141 }
  1140 }
  1142 
  1141 
  1151 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createForwardMessage(
  1150 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createForwardMessage(
  1152     const NmId &mailboxId,
  1151     const NmId &mailboxId,
  1153     const NmId &originalMessageId)
  1152     const NmId &originalMessageId)
  1154 {
  1153 {
  1155     NM_FUNCTION;
  1154     NM_FUNCTION;
  1156     
  1155 
  1157     QPointer<NmMessageCreationOperation> oper =
  1156     QPointer<NmMessageCreationOperation> oper =
  1158         new NmFwaForwardMessageCreationOperation(mailboxId, originalMessageId, *mFSfw);
  1157         new NmFwaForwardMessageCreationOperation(mailboxId, originalMessageId, *mFSfw);
  1159     return oper;
  1158     return oper;
  1160 }
  1159 }
  1161 
  1160 
  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));
  1222     TAny* param1,
  1221     TAny* param1,
  1223     TAny* param2,
  1222     TAny* param2,
  1224     TAny* param3)
  1223     TAny* param3)
  1225 {
  1224 {
  1226     NM_FUNCTION;
  1225     NM_FUNCTION;
  1227     
  1226 
  1228     switch (aEvent) {
  1227     switch (aEvent) {
  1229         // Mailbox related events:
  1228         // Mailbox related events:
  1230         case TFSEventNewMailbox:
  1229         case TFSEventNewMailbox:
  1231             handleMailboxEvent(mailbox, NmMailboxCreated);
  1230             handleMailboxEvent(mailbox, NmMailboxCreated);
  1232             break;
  1231             break;
  1337     const NmId& mailboxId,
  1336     const NmId& mailboxId,
  1338     const NmId& folderId,
  1337     const NmId& folderId,
  1339     const NmId& messageId)
  1338     const NmId& messageId)
  1340 {
  1339 {
  1341     NM_FUNCTION;
  1340     NM_FUNCTION;
  1342     
  1341 
  1343     TRAPD(error, removeMessageL(mailboxId, folderId, messageId));
  1342     TRAPD(error, removeMessageL(mailboxId, folderId, messageId));
  1344     return error;
  1343     return error;
  1345 }
  1344 }
  1346 
  1345 
  1347 /*!
  1346 /*!
  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 /*!
  1478 QPointer<NmAddAttachmentsOperation> NmFrameworkAdapter::addAttachments(
  1477 QPointer<NmAddAttachmentsOperation> NmFrameworkAdapter::addAttachments(
  1479     const NmMessage &message,
  1478     const NmMessage &message,
  1480     const QList<QString> &fileList)
  1479     const QList<QString> &fileList)
  1481 {
  1480 {
  1482     NM_FUNCTION;
  1481     NM_FUNCTION;
  1483     
  1482 
  1484     QPointer<NmAddAttachmentsOperation>oper = new NmFwaAddAttachmentsOperation(message, fileList, *mFSfw);
  1483     QPointer<NmAddAttachmentsOperation>oper = new NmFwaAddAttachmentsOperation(message, fileList, *mFSfw);
  1485     return oper;
  1484     return oper;
  1486 }
  1485 }
  1487 
  1486 
  1488 /*!
  1487 /*!
  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;
  1552  */
  1551  */
  1553 CFSMailMessage* NmFrameworkAdapter::mailMessageFromEnvelopeL(
  1552 CFSMailMessage* NmFrameworkAdapter::mailMessageFromEnvelopeL(
  1554     const NmMessageEnvelope& envelope)
  1553     const NmMessageEnvelope& envelope)
  1555 {
  1554 {
  1556     NM_FUNCTION;
  1555     NM_FUNCTION;
  1557     
  1556 
  1558     NmMessage* nmMessage = new(ELeave) NmMessage( envelope );
  1557     NmMessage* nmMessage = new(ELeave) NmMessage( envelope );
  1559     CFSMailMessage* message = CFSMailMessage::NewL( *nmMessage );
  1558     CFSMailMessage* message = CFSMailMessage::NewL( *nmMessage );
  1560     delete nmMessage;
  1559     delete nmMessage;
  1561     nmMessage = NULL;
  1560     nmMessage = NULL;
  1562     return message;
  1561     return message;
  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);
  1673     TAny* param2,
  1674     TAny* param2,
  1674     NmMessageEvent event,
  1675     NmMessageEvent event,
  1675     TFSMailMsgId mailbox)
  1676     TFSMailMsgId mailbox)
  1676 {
  1677 {
  1677     NM_FUNCTION;
  1678     NM_FUNCTION;
  1678     
  1679 
  1679     NmId nmMsgId(0);
  1680     NmId nmMsgId(0);
  1680     QList<NmId> messageIds;
  1681     QList<NmId> messageIds;
  1681     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
  1682     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
  1682     TFSMailMsgId* fsFolderId = reinterpret_cast<TFSMailMsgId*> (param2);
  1683     TFSMailMsgId* fsFolderId = reinterpret_cast<TFSMailMsgId*> (param2);
  1683     NmId folderId = fsFolderId->GetNmId();
  1684     NmId folderId = fsFolderId->GetNmId();
  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();