emailuis/nmframeworkadapter/src/nmframeworkadapter.cpp
changeset 43 99bcbff212ad
parent 40 2c62ef3caffd
child 47 f83bd4ae1fe3
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    36 /*!
    36 /*!
    37     Constructor
    37     Constructor
    38 */
    38 */
    39 NmFrameworkAdapter::NmFrameworkAdapter()
    39 NmFrameworkAdapter::NmFrameworkAdapter()
    40 : mFSfw(NULL),
    40 : mFSfw(NULL),
    41   mSearchObserver(NULL)
    41   mSearchObserver(NULL),
    42 {
    42   mCurrentMailBox(NULL),
    43     NMLOG("NmFrameworkAdapter::NmFrameworkAdapter() <---");
    43   mEmailExtension(NULL)
    44 
    44 {
       
    45     NM_FUNCTION;
       
    46     
    45     // get s60 email framework
    47     // get s60 email framework
    46     TRAP_IGNORE(mFSfw = CFSMailClient::NewL());
    48     TRAP_IGNORE(mFSfw = CFSMailClient::NewL());
    47 
    49 
    48     if (mFSfw) {
    50     if (mFSfw) {
    49         TRAP_IGNORE(mFSfw->AddObserverL(*this));
    51         TRAP_IGNORE(mFSfw->AddObserverL(*this));
    50     }
    52     }
    51 
       
    52     NMLOG("NmFrameworkAdapter::NmFrameworkAdapter() --->");
       
    53 }
    53 }
    54 
    54 
    55 /*!
    55 /*!
    56     Destructor
    56     Destructor
    57 */
    57 */
    58 NmFrameworkAdapter::~NmFrameworkAdapter()
    58 NmFrameworkAdapter::~NmFrameworkAdapter()
    59 {
    59 {
       
    60     NM_FUNCTION;
       
    61     
       
    62     if (mCurrentMailBox && mEmailExtension) {
       
    63         mCurrentMailBox->ReleaseExtension( mEmailExtension );
       
    64     }
       
    65     delete mCurrentMailBox;
       
    66     mCurrentMailBox = NULL;
       
    67     
       
    68     mEmailExtension = NULL;    
       
    69     
    60     if (mSearchObserver) {
    70     if (mSearchObserver) {
    61         delete mSearchObserver;
    71         delete mSearchObserver;
    62         mSearchObserver = NULL;
    72         mSearchObserver = NULL;
    63     }
    73     }
    64 
    74 
    77 
    87 
    78     \return Error code.
    88     \return Error code.
    79  */
    89  */
    80 int NmFrameworkAdapter::listMailboxIds(QList<NmId>& mailboxIdList)
    90 int NmFrameworkAdapter::listMailboxIds(QList<NmId>& mailboxIdList)
    81 {
    91 {
       
    92     NM_FUNCTION;
       
    93     
    82     QList<NmMailbox*> mailboxList;
    94     QList<NmMailbox*> mailboxList;
    83     int ret = listMailboxes(mailboxList);
    95     int ret = listMailboxes(mailboxList);
    84 
    96 
    85     if ( ret == NmNoError ) {
    97     if ( ret == NmNoError ) {
    86         QListIterator<NmMailbox*> iterator(mailboxList);
    98         QListIterator<NmMailbox*> iterator(mailboxList);
   101 
   113 
   102     \return Error code.
   114     \return Error code.
   103  */
   115  */
   104 int NmFrameworkAdapter::listMailboxes(QList<NmMailbox*>& mailboxList)
   116 int NmFrameworkAdapter::listMailboxes(QList<NmMailbox*>& mailboxList)
   105 {
   117 {
       
   118     NM_FUNCTION;
       
   119     
   106     // get list of mailboxes from all plugins
   120     // get list of mailboxes from all plugins
   107     TFSMailMsgId id;
   121     TFSMailMsgId id;
   108     id.SetNullId();
   122     id.SetNullId();
   109     RPointerArray<CFSMailBox> mailBoxes;
   123     RPointerArray<CFSMailBox> mailBoxes;
   110 
   124 
   137 
   151 
   138     \return Error code.
   152     \return Error code.
   139  */
   153  */
   140 int NmFrameworkAdapter::getMailboxById(const NmId& id, NmMailbox*& mailbox)
   154 int NmFrameworkAdapter::getMailboxById(const NmId& id, NmMailbox*& mailbox)
   141 {
   155 {
       
   156     NM_FUNCTION;
       
   157     
   142     const TFSMailMsgId mailMsgId(id.pluginId32(), id.id32());
   158     const TFSMailMsgId mailMsgId(id.pluginId32(), id.id32());
   143     CFSMailBox *box(NULL);
   159     CFSMailBox *box(NULL);
   144     TRAPD(err, box = mFSfw->GetMailBoxByUidL(mailMsgId));
   160     TRAPD(err, box = mFSfw->GetMailBoxByUidL(mailMsgId));
   145     if (err == KErrNone && box) {
   161     if (err == KErrNone && box) {
   146         mailbox = box->GetNmMailbox();
   162         mailbox = box->GetNmMailbox();
   157 
   173 
   158     \return Error code.
   174     \return Error code.
   159  */
   175  */
   160 int NmFrameworkAdapter::deleteMailboxById(const NmId& /*id*/)
   176 int NmFrameworkAdapter::deleteMailboxById(const NmId& /*id*/)
   161 {
   177 {
       
   178     NM_FUNCTION;
       
   179     
   162     return 0;
   180     return 0;
   163 }
   181 }
   164 
   182 
   165 /*!
   183 /*!
   166     Returns folder
   184     Returns folder
   171 
   189 
   172     \return Error code.
   190     \return Error code.
   173  */
   191  */
   174 int NmFrameworkAdapter::getFolderById( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder )
   192 int NmFrameworkAdapter::getFolderById( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder )
   175     {
   193     {
       
   194     NM_FUNCTION;
       
   195     
   176     TRAPD(err, getFolderByIdL( mailboxId, folderId, folder ) );
   196     TRAPD(err, getFolderByIdL( mailboxId, folderId, folder ) );
   177     return err;
   197     return err;
   178     }
   198     }
   179 
   199 
   180 /*!
   200 /*!
   181     Leaving version of getFolderById function
   201     Leaving version of getFolderById function
   182  */
   202  */
   183 void NmFrameworkAdapter::getFolderByIdL( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder )
   203 void NmFrameworkAdapter::getFolderByIdL( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder )
   184     {
   204     {
       
   205     NM_FUNCTION;
       
   206     
   185     CFSMailFolder* fsFolder(NULL);
   207     CFSMailFolder* fsFolder(NULL);
   186 	if (mFSfw)
   208 	if (mFSfw)
   187 		{
   209 		{
   188     	fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); 
   210     	fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); 
   189     	if (fsFolder)
   211     	if (fsFolder)
   215     const NmId& mailboxId,
   237     const NmId& mailboxId,
   216     const NmId& folderId,
   238     const NmId& folderId,
   217     const NmId& messageId,
   239     const NmId& messageId,
   218     NmMessage*& message)
   240     NmMessage*& message)
   219 {
   241 {
       
   242     NM_FUNCTION;
       
   243     
   220     TRAPD(err, getMessageByIdL(mailboxId,folderId,messageId,message));
   244     TRAPD(err, getMessageByIdL(mailboxId,folderId,messageId,message));
   221     return err;
   245     return err;
   222 }
   246 }
   223 
   247 
   224 /*!
   248 /*!
   228     const NmId& mailboxId,
   252     const NmId& mailboxId,
   229     const NmId& folderId,
   253     const NmId& folderId,
   230     const NmId& messageId,
   254     const NmId& messageId,
   231     NmMessage*& message)
   255     NmMessage*& message)
   232 {
   256 {
       
   257     NM_FUNCTION;
       
   258     
   233     // select message details to be listed
   259     // select message details to be listed
   234     TFSMailDetails details(EFSMsgDataStructure);
   260     TFSMailDetails details(EFSMsgDataStructure);
   235 
   261 
   236     CFSMailMessage* newMessage(NULL);
   262     CFSMailMessage* newMessage(NULL);
   237     newMessage = mFSfw->GetMessageByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId),
   263     newMessage = mFSfw->GetMessageByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId),
   260  */
   286  */
   261 int NmFrameworkAdapter::listFolders(
   287 int NmFrameworkAdapter::listFolders(
   262     const NmId& mailboxId,
   288     const NmId& mailboxId,
   263     QList<NmFolder*>& folderList)
   289     QList<NmFolder*>& folderList)
   264 {
   290 {
       
   291     NM_FUNCTION;
       
   292     
   265     CFSMailBox* currentMailbox = NULL;
   293     CFSMailBox* currentMailbox = NULL;
   266     TRAPD (err, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId));
   294     TRAPD (err, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId));
   267     if (KErrNone == err) {
   295     if (KErrNone == err) {
   268         RPointerArray<CFSMailFolder> folders = currentMailbox->ListFolders();
   296         RPointerArray<CFSMailFolder> folders = currentMailbox->ListFolders();
   269         for (int i = 0; i < folders.Count(); i++) {
   297         for (int i = 0; i < folders.Count(); i++) {
   288 void NmFrameworkAdapter::getMessagesFromFolderL(
   316 void NmFrameworkAdapter::getMessagesFromFolderL(
   289      CFSMailFolder *folder,
   317      CFSMailFolder *folder,
   290      QList<NmMessageEnvelope*> &messageEnvelopeList,
   318      QList<NmMessageEnvelope*> &messageEnvelopeList,
   291      const int maxEnvelopeCount)
   319      const int maxEnvelopeCount)
   292 {
   320 {
       
   321     NM_FUNCTION;
       
   322     
   293     if (!folder || maxEnvelopeCount < 1) {
   323     if (!folder || maxEnvelopeCount < 1) {
   294         return;
   324         return;
   295     }
   325     }
   296 
   326 
   297     int blockSize = NmListMessagesBlock;
   327     int blockSize = NmListMessagesBlock;
   372 int NmFrameworkAdapter::listMessages(
   402 int NmFrameworkAdapter::listMessages(
   373 	const NmId &mailboxId,
   403 	const NmId &mailboxId,
   374     const NmId &folderId,
   404     const NmId &folderId,
   375     QList<NmMessageEnvelope*> &messageEnvelopeList)
   405     QList<NmMessageEnvelope*> &messageEnvelopeList)
   376 {
   406 {
       
   407     NM_FUNCTION;
       
   408     
   377     TRAPD(err, listMessagesL(mailboxId,folderId,messageEnvelopeList, NmMaxItemsInMessageList));
   409     TRAPD(err, listMessagesL(mailboxId,folderId,messageEnvelopeList, NmMaxItemsInMessageList));
   378     return err;
   410     return err;
   379 }
   411 }
   380 
   412 
   381 
   413 
   395         const NmId& mailboxId,
   427         const NmId& mailboxId,
   396         const NmId& folderId,
   428         const NmId& folderId,
   397         QList<NmMessageEnvelope*> &messageEnvelopeList,
   429         QList<NmMessageEnvelope*> &messageEnvelopeList,
   398         const int maxAmountOfEnvelopes)
   430         const int maxAmountOfEnvelopes)
   399 {
   431 {
       
   432     NM_FUNCTION;
       
   433     
   400     TInt err = KErrNone;
   434     TInt err = KErrNone;
   401     TRAP(err, listMessagesL(mailboxId,folderId, messageEnvelopeList,maxAmountOfEnvelopes) );
   435     TRAP(err, listMessagesL(mailboxId,folderId, messageEnvelopeList,maxAmountOfEnvelopes) );
   402     return err;
   436     return err;
   403 }
   437 }
   404 
   438 
   411         const NmId &mailboxId,
   445         const NmId &mailboxId,
   412         const NmId &folderId,
   446         const NmId &folderId,
   413         QList<NmMessageEnvelope*> &messageEnvelopeList,
   447         QList<NmMessageEnvelope*> &messageEnvelopeList,
   414         const int maxAmountOfEnvelopes)
   448         const int maxAmountOfEnvelopes)
   415 {
   449 {
       
   450     NM_FUNCTION;
       
   451     
   416     // If we are requesting 0 or less mails, we can just return.
   452     // If we are requesting 0 or less mails, we can just return.
   417     if (maxAmountOfEnvelopes <= 0) {
   453     if (maxAmountOfEnvelopes <= 0) {
   418         return;
   454         return;
   419     }
   455     }
   420 
   456 
   454     const NmId &mailboxId,
   490     const NmId &mailboxId,
   455     const NmId &folderId,
   491     const NmId &folderId,
   456     QList<NmMessage*> &messageList,
   492     QList<NmMessage*> &messageList,
   457     const int maxAmountOfMessages)
   493     const int maxAmountOfMessages)
   458 {
   494 {
       
   495     NM_FUNCTION;
       
   496     
   459     TRAPD(err, listMessagesL(mailboxId,folderId,messageList, maxAmountOfMessages));
   497     TRAPD(err, listMessagesL(mailboxId,folderId,messageList, maxAmountOfMessages));
   460     return err;
   498     return err;
   461 }
   499 }
   462 
   500 
   463 
   501 
   468         const NmId &mailboxId,
   506         const NmId &mailboxId,
   469         const NmId &folderId,
   507         const NmId &folderId,
   470         QList<NmMessage*> &messageList,
   508         QList<NmMessage*> &messageList,
   471         const int maxAmountOfEnvelopes)
   509         const int maxAmountOfEnvelopes)
   472 {
   510 {
       
   511     NM_FUNCTION;
       
   512     
   473     CFSMailBox * currentMailbox(NULL);
   513     CFSMailBox * currentMailbox(NULL);
   474     CFSMailFolder* folder(NULL);
   514     CFSMailFolder* folder(NULL);
   475 
   515 
   476     //If we are requesting 0 or less mails so we can return
   516     //If we are requesting 0 or less mails so we can return
   477     if( maxAmountOfEnvelopes <= 0)
   517     if( maxAmountOfEnvelopes <= 0)
   573     \return A possible error code.
   613     \return A possible error code.
   574 */
   614 */
   575 int NmFrameworkAdapter::search(const NmId &mailboxId,
   615 int NmFrameworkAdapter::search(const NmId &mailboxId,
   576                                const QStringList &searchStrings)
   616                                const QStringList &searchStrings)
   577 {
   617 {
       
   618     NM_FUNCTION;
       
   619     
   578     if (!mSearchObserver) {
   620     if (!mSearchObserver) {
   579         mSearchObserver = new NmMailboxSearchObserver();
   621         mSearchObserver = new NmMailboxSearchObserver();
   580     }
   622     }
   581 
   623 
   582     // Set connections for forwarding the signals emitted by the search
   624     // Set connections for forwarding the signals emitted by the search
   599 
   641 
   600     \return A possible error code.
   642     \return A possible error code.
   601 */
   643 */
   602 int NmFrameworkAdapter::cancelSearch(const NmId &mailboxId)
   644 int NmFrameworkAdapter::cancelSearch(const NmId &mailboxId)
   603 {
   645 {
       
   646     NM_FUNCTION;
       
   647     
   604     // Get the mailbox with the given ID.
   648     // Get the mailbox with the given ID.
   605     CFSMailBox *mailbox(NULL);
   649     CFSMailBox *mailbox(NULL);
   606     TRAPD(err, mailbox = mFSfw->GetMailBoxByUidL(mailboxId));
   650     TRAPD(err, mailbox = mFSfw->GetMailBoxByUidL(mailboxId));
   607 
   651 
   608     if (err == KErrNone && mailbox) {
   652     if (err == KErrNone && mailbox) {
   615 /*!
   659 /*!
   616     Indicates application state information to protocol plugins
   660     Indicates application state information to protocol plugins
   617     \param mailboxId Id of active mailbox, 0 if application is closed.
   661     \param mailboxId Id of active mailbox, 0 if application is closed.
   618     \param folderId Id of active folder, 0 if application is closed.
   662     \param folderId Id of active folder, 0 if application is closed.
   619 */
   663 */
   620 void NmFrameworkAdapter::updateActiveFolder(const NmId &mailboxId, const NmId &folderId)
   664 void NmFrameworkAdapter::updateActiveFolder(
   621 {
   665     const NmId &mailboxId, const NmId &folderId)
   622 	  // TODO ExtensionL from CFSMailClient & state update
   666 {
   623     Q_UNUSED(mailboxId);
   667     TRAP_IGNORE(doUpdateActiveFolderL(mailboxId, folderId));
   624     Q_UNUSED(folderId);
   668 }
       
   669 
       
   670 /*!
       
   671    Removes draft message asynchronously
       
   672  */
       
   673 QPointer<NmOperation> NmFrameworkAdapter::removeDraftMessage(NmMessage *message)
       
   674 {
       
   675     NM_FUNCTION;
       
   676     
       
   677     QPointer<NmOperation> oper = new NmFwaRemoveDraftMessageOperation(*this, message, *mFSfw);
       
   678     return oper;
       
   679 }
       
   680 
       
   681 /*!
       
   682    function to process updateActiveFolder. This method may leave.
       
   683  */
       
   684 void NmFrameworkAdapter::doUpdateActiveFolderL(
       
   685     const NmId &mailboxId, const NmId &folderId)
       
   686 {
       
   687     if ((mFSfw) && (!mCurrentMailBox || mCurrentMailBox->GetId()!=mailboxId)) {
       
   688         mEmailExtension = NULL;        
       
   689         delete mCurrentMailBox;
       
   690         mCurrentMailBox = NULL;
       
   691         mCurrentMailBox = mFSfw->GetMailBoxByUidL(mailboxId);
       
   692         }
       
   693     CEmailExtension *extension = getEMailStateExtensionL();
       
   694     CMailboxStateExtension *boxExtension = 
       
   695         static_cast<CMailboxStateExtension*>(extension);        
       
   696     if (boxExtension) {
       
   697         boxExtension->NotifyActiveFolderChanged(mailboxId, folderId);    
       
   698     }
       
   699 }
       
   700 
       
   701 /*!
       
   702    function to process updateActiveFolder. This method may leave.
       
   703  */
       
   704 CEmailExtension* NmFrameworkAdapter::getEMailStateExtensionL()
       
   705 {      
       
   706     if (!mEmailExtension && mCurrentMailBox) {
       
   707         mEmailExtension = 
       
   708             mCurrentMailBox->ExtensionL(KEmailMailboxStateExtensionUid);
       
   709     }    
       
   710     return mEmailExtension;
   625 }
   711 }
   626 
   712 
   627 /*!
   713 /*!
   628     Starts an asynchronous search for messages with the given search strings.
   714     Starts an asynchronous search for messages with the given search strings.
   629 
   715 
   636 void NmFrameworkAdapter::searchL(const NmId &mailboxId,
   722 void NmFrameworkAdapter::searchL(const NmId &mailboxId,
   637                                  const QList<NmId> &folderIds,
   723                                  const QList<NmId> &folderIds,
   638                                  const QStringList &searchStrings,
   724                                  const QStringList &searchStrings,
   639                                  NmMailboxSearchObserver &searchObserver)
   725                                  NmMailboxSearchObserver &searchObserver)
   640 {
   726 {
       
   727     NM_FUNCTION;
       
   728     
   641     // CFSMailBox has no support for search using folder IDs.
   729     // CFSMailBox has no support for search using folder IDs.
   642     Q_UNUSED(folderIds); 
   730     Q_UNUSED(folderIds); 
   643 
   731 
   644     // Get the mailbox with the given ID.
   732     // Get the mailbox with the given ID.
   645     CFSMailBox *mailbox(NULL);
   733     CFSMailBox *mailbox(NULL);
   683 QPointer<NmOperation> NmFrameworkAdapter::fetchMessage(
   771 QPointer<NmOperation> NmFrameworkAdapter::fetchMessage(
   684     const NmId &mailboxId,
   772     const NmId &mailboxId,
   685     const NmId &folderId,
   773     const NmId &folderId,
   686     const NmId &messageId )
   774     const NmId &messageId )
   687 {
   775 {
       
   776     NM_FUNCTION;
       
   777     
   688     NmOperation *oper = new NmFwaMessageFetchingOperation(mailboxId, folderId, messageId, *mFSfw);
   778     NmOperation *oper = new NmFwaMessageFetchingOperation(mailboxId, folderId, messageId, *mFSfw);
   689     return oper;
   779     return oper;
   690 }
   780 }
   691 
   781 
   692 /*!
   782 /*!
   703     const NmId &mailboxId,
   793     const NmId &mailboxId,
   704     const NmId &folderId,
   794     const NmId &folderId,
   705     const NmId &messageId,
   795     const NmId &messageId,
   706     const NmId &messagePartId)
   796     const NmId &messagePartId)
   707 {
   797 {
       
   798     NM_FUNCTION;
       
   799     
   708     QPointer<NmOperation> oper = new NmFwaMessagePartFetchingOperation(
   800     QPointer<NmOperation> oper = new NmFwaMessagePartFetchingOperation(
   709             mailboxId, folderId, messageId, messagePartId, *mFSfw);
   801             mailboxId, folderId, messageId, messagePartId, *mFSfw);
   710     return oper;
   802     return oper;
   711 }
   803 }
   712 
   804 
   724     const NmId &mailboxId,
   816     const NmId &mailboxId,
   725     const NmId &folderId,
   817     const NmId &folderId,
   726     const NmId &messageId,
   818     const NmId &messageId,
   727     const QList<NmId> &messagePartIds)
   819     const QList<NmId> &messagePartIds)
   728 {
   820 {
       
   821     NM_FUNCTION;
       
   822     
   729     QPointer<NmOperation> oper = new NmFwaMessagePartsFetchingOperation(
   823     QPointer<NmOperation> oper = new NmFwaMessagePartsFetchingOperation(
   730             mailboxId, folderId, messageId, messagePartIds, *mFSfw);
   824             mailboxId, folderId, messageId, messagePartIds, *mFSfw);
   731     return oper;  
   825     return oper;  
   732 }
   826 }
   733 
   827 
   745         const NmId &mailboxId,
   839         const NmId &mailboxId,
   746         const NmId &folderId,
   840         const NmId &folderId,
   747         const NmId &messageId,
   841         const NmId &messageId,
   748         const NmId &messagePartId)
   842         const NmId &messagePartId)
   749 {
   843 {
       
   844     NM_FUNCTION;
       
   845     
   750     XQSharableFile retFile;
   846     XQSharableFile retFile;
   751     TFSMailDetails details(EFSMsgDataEnvelope);
   847     TFSMailDetails details(EFSMsgDataEnvelope);
   752     TFSMailMsgId fsMboxId(mailboxId);
   848     TFSMailMsgId fsMboxId(mailboxId);
   753     TFSMailMsgId fsFolderId(folderId);
   849     TFSMailMsgId fsFolderId(folderId);
   754     TFSMailMsgId fsMsgId(messageId);
   850     TFSMailMsgId fsMsgId(messageId);
   781  */
   877  */
   782 NmId NmFrameworkAdapter::getStandardFolderId(
   878 NmId NmFrameworkAdapter::getStandardFolderId(
   783     const NmId& mailboxId,
   879     const NmId& mailboxId,
   784     NmFolderType folderType )
   880     NmFolderType folderType )
   785 {
   881 {
       
   882     NM_FUNCTION;
       
   883     
   786     TFSMailMsgId folderId;
   884     TFSMailMsgId folderId;
   787     NmId resultId(0);
   885     NmId resultId(0);
   788     CFSMailBox * currentMailbox(NULL);
   886     CFSMailBox * currentMailbox(NULL);
   789 
   887 
   790     TRAPD(error, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId) );
   888     TRAPD(error, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId) );
   830     \param mailboxId Id of the mailbox.
   928     \param mailboxId Id of the mailbox.
   831     \return Async request id or error code.
   929     \return Async request id or error code.
   832  */
   930  */
   833 int NmFrameworkAdapter::refreshMailbox(NmId mailboxId)
   931 int NmFrameworkAdapter::refreshMailbox(NmId mailboxId)
   834 {
   932 {
       
   933     NM_FUNCTION;
       
   934     
   835     TRAPD(err, RefreshMailboxL(mailboxId)); // return value not used
   935     TRAPD(err, RefreshMailboxL(mailboxId)); // return value not used
   836     return ( err == KErrNone ) ? NmNoError : NmGeneralError;
   936     return ( err == KErrNone ) ? NmNoError : NmGeneralError;
   837 }
   937 }
   838 
   938 
   839 /*!
   939 /*!
   842     \param mailboxId Id of the mailbox.
   942     \param mailboxId Id of the mailbox.
   843     \return Async request id or error code.
   943     \return Async request id or error code.
   844  */
   944  */
   845 int NmFrameworkAdapter::goOnline(const NmId& mailboxId)
   945 int NmFrameworkAdapter::goOnline(const NmId& mailboxId)
   846 {
   946 {
       
   947     NM_FUNCTION;
       
   948     
   847     TRAPD(err, GoOnlineL(mailboxId)); // return value not used
   949     TRAPD(err, GoOnlineL(mailboxId)); // return value not used
   848     return ( err == KErrNone ) ? NmNoError : NmGeneralError;
   950     return ( err == KErrNone ) ? NmNoError : NmGeneralError;
   849 }
   951 }
   850 
   952 
   851 /*!
   953 /*!
   854     \param mailboxId Id of the mailbox.
   956     \param mailboxId Id of the mailbox.
   855     \return Async request id or error code.
   957     \return Async request id or error code.
   856  */
   958  */
   857 int NmFrameworkAdapter::goOffline(const NmId& mailboxId)
   959 int NmFrameworkAdapter::goOffline(const NmId& mailboxId)
   858 {
   960 {
       
   961     NM_FUNCTION;
       
   962     
   859     TRAPD(err, GoOfflineL(mailboxId)); // return value not used
   963     TRAPD(err, GoOfflineL(mailboxId)); // return value not used
   860     return ( err == KErrNone ) ? NmNoError : NmGeneralError;
   964     return ( err == KErrNone ) ? NmNoError : NmGeneralError;
   861 }
   965 }
   862 
   966 
   863 /*!
   967 /*!
   876     const NmId &mailboxId,
   980     const NmId &mailboxId,
   877     const NmId &folderId,
   981     const NmId &folderId,
   878     const NmId &messageId,
   982     const NmId &messageId,
   879     NmMessagePart &messagePart)
   983     NmMessagePart &messagePart)
   880 {
   984 {
       
   985     NM_FUNCTION;
       
   986     
   881     TRAPD(err, contentToMessagePartL(mailboxId,folderId,messageId,messagePart));
   987     TRAPD(err, contentToMessagePartL(mailboxId,folderId,messageId,messagePart));
   882     return err;
   988     return err;
   883 }
   989 }
   884 
   990 
   885 /*!
   991 /*!
   889     const NmId &mailboxId,
   995     const NmId &mailboxId,
   890     const NmId &folderId,
   996     const NmId &folderId,
   891     const NmId &messageId,
   997     const NmId &messageId,
   892     NmMessagePart &messagePart)
   998     NmMessagePart &messagePart)
   893 {
   999 {
       
  1000     NM_FUNCTION;
       
  1001     
   894     CFSMailMessagePart* cfsPart = CFSMailMessagePart::NewLC(messageId,messagePart);
  1002     CFSMailMessagePart* cfsPart = CFSMailMessagePart::NewLC(messageId,messagePart);
   895     cfsPart->SetMailBoxId(TFSMailMsgId(mailboxId));
  1003     cfsPart->SetMailBoxId(TFSMailMsgId(mailboxId));
   896     cfsPart->SetFolderId(TFSMailMsgId(folderId));
  1004     cfsPart->SetFolderId(TFSMailMsgId(folderId));
   897     QString contentType = messagePart.contentType();
  1005     QString contentType = messagePart.contentType();
   898 
  1006 
   963 int NmFrameworkAdapter::deleteMessages(
  1071 int NmFrameworkAdapter::deleteMessages(
   964 	const NmId &mailboxId,
  1072 	const NmId &mailboxId,
   965 	const NmId &folderId,
  1073 	const NmId &folderId,
   966 	const QList<NmId> &messageIdList)
  1074 	const QList<NmId> &messageIdList)
   967 {
  1075 {
       
  1076     NM_FUNCTION;
       
  1077     
   968     TInt err = NmNoError;
  1078     TInt err = NmNoError;
   969     RArray<TFSMailMsgId> messageIds;
  1079     RArray<TFSMailMsgId> messageIds;
   970     for (TInt i=0; i<messageIdList.size(); i++) {
  1080     for (TInt i=0; i<messageIdList.size(); i++) {
   971         err = messageIds.Append(TFSMailMsgId(messageIdList[i]));
  1081         err = messageIds.Append(TFSMailMsgId(messageIdList[i]));
   972         if (err!=NmNoError) {
  1082         if (err!=NmNoError) {
   993 QPointer<NmStoreEnvelopesOperation> NmFrameworkAdapter::storeEnvelopes(
  1103 QPointer<NmStoreEnvelopesOperation> NmFrameworkAdapter::storeEnvelopes(
   994 	const NmId &mailboxId,
  1104 	const NmId &mailboxId,
   995 	const NmId &folderId,
  1105 	const NmId &folderId,
   996 	const QList<const NmMessageEnvelope*> &envelopeList)
  1106 	const QList<const NmMessageEnvelope*> &envelopeList)
   997 {
  1107 {
       
  1108     NM_FUNCTION;
       
  1109     
   998     Q_UNUSED(folderId);
  1110     Q_UNUSED(folderId);
   999     NMLOG("NmFrameworkAdapter::storeEnvelopes() <---");
       
  1000 
  1111 
  1001     QPointer<NmStoreEnvelopesOperation> operation(NULL);
  1112     QPointer<NmStoreEnvelopesOperation> operation(NULL);
  1002     RPointerArray<CFSMailMessage> envelopeMessages;
  1113     RPointerArray<CFSMailMessage> envelopeMessages;
  1003 
  1114 
  1004     int count = envelopeList.count();
  1115     int count = envelopeList.count();
  1011                 mailboxId,
  1122                 mailboxId,
  1012                 envelopeMessages,
  1123                 envelopeMessages,
  1013                 *mFSfw);
  1124                 *mFSfw);
  1014         }
  1125         }
  1015 
  1126 
  1016     NMLOG("NmFrameworkAdapter::storeEnvelopes() --->");
       
  1017     return operation;
  1127     return operation;
  1018 }
  1128 }
  1019 
  1129 
  1020 /*!
  1130 /*!
  1021     Creates a new message into the drafts folder a mailbox.
  1131     Creates a new message into the drafts folder a mailbox.
  1024 
  1134 
  1025     \return NmMessageCreationOperation
  1135     \return NmMessageCreationOperation
  1026  */
  1136  */
  1027 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createNewMessage(const NmId &mailboxId)
  1137 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createNewMessage(const NmId &mailboxId)
  1028 {
  1138 {
       
  1139     NM_FUNCTION;
       
  1140     
  1029     QPointer<NmMessageCreationOperation> oper =
  1141     QPointer<NmMessageCreationOperation> oper =
  1030         new NmFwaMessageCreationOperation(mailboxId, *mFSfw);
  1142         new NmFwaMessageCreationOperation(mailboxId, *mFSfw);
  1031     return oper;
  1143     return oper;
  1032 }
  1144 }
  1033 
  1145 
  1041  */
  1153  */
  1042 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createForwardMessage(
  1154 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createForwardMessage(
  1043     const NmId &mailboxId,
  1155     const NmId &mailboxId,
  1044     const NmId &originalMessageId)
  1156     const NmId &originalMessageId)
  1045 {
  1157 {
       
  1158     NM_FUNCTION;
       
  1159     
  1046     QPointer<NmMessageCreationOperation> oper =
  1160     QPointer<NmMessageCreationOperation> oper =
  1047         new NmFwaForwardMessageCreationOperation(mailboxId, originalMessageId, *mFSfw);
  1161         new NmFwaForwardMessageCreationOperation(mailboxId, originalMessageId, *mFSfw);
  1048     return oper;
  1162     return oper;
  1049 }
  1163 }
  1050 
  1164 
  1060 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createReplyMessage(
  1174 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createReplyMessage(
  1061     const NmId &mailboxId,
  1175     const NmId &mailboxId,
  1062     const NmId &originalMessageId,
  1176     const NmId &originalMessageId,
  1063     const bool replyAll)
  1177     const bool replyAll)
  1064 {
  1178 {
       
  1179     NM_FUNCTION;
       
  1180     
  1065     QPointer<NmMessageCreationOperation> oper =
  1181     QPointer<NmMessageCreationOperation> oper =
  1066         new NmFwaReplyMessageCreationOperation(mailboxId, originalMessageId, replyAll, *mFSfw);
  1182         new NmFwaReplyMessageCreationOperation(mailboxId, originalMessageId, replyAll, *mFSfw);
  1067     return oper;
  1183     return oper;
  1068 }
  1184 }
  1069 
  1185 
  1070 /*!
  1186 /*!
  1071     Not implemented yet.
  1187     Not implemented yet.
  1072  */
  1188  */
  1073 int NmFrameworkAdapter::saveMessage(const NmMessage &message)
  1189 int NmFrameworkAdapter::saveMessage(const NmMessage &message)
  1074 {
  1190 {
       
  1191     NM_FUNCTION;
       
  1192     
  1075     Q_UNUSED(message);
  1193     Q_UNUSED(message);
  1076     return NmNoError;
  1194     return NmNoError;
  1077 }
  1195 }
  1078 
  1196 
  1079 /*!
  1197 /*!
  1080     Store asynchronously message with its parts.
  1198     Store asynchronously message with its parts.
  1081  */
  1199  */
  1082 QPointer<NmOperation> NmFrameworkAdapter::saveMessageWithSubparts(const NmMessage &message)
  1200 QPointer<NmOperation> NmFrameworkAdapter::saveMessageWithSubparts(const NmMessage &message)
  1083 {
  1201 {
       
  1202     NM_FUNCTION;
       
  1203     
  1084     CFSMailMessage * cfsMessage = NULL;
  1204     CFSMailMessage * cfsMessage = NULL;
  1085     QPointer<NmOperation> oper(NULL);
  1205     QPointer<NmOperation> oper(NULL);
  1086 
  1206 
  1087     int err = KErrNone;
  1207     int err = KErrNone;
  1088     TRAP(err, cfsMessage = CFSMailMessage::NewL(message));
  1208     TRAP(err, cfsMessage = CFSMailMessage::NewL(message));
  1104     TFSMailMsgId mailbox,
  1224     TFSMailMsgId mailbox,
  1105     TAny* param1,
  1225     TAny* param1,
  1106     TAny* param2,
  1226     TAny* param2,
  1107     TAny* param3)
  1227     TAny* param3)
  1108 {
  1228 {
       
  1229     NM_FUNCTION;
       
  1230     
  1109     switch (aEvent) {
  1231     switch (aEvent) {
  1110         // Mailbox related events:
  1232         // Mailbox related events:
  1111         case TFSEventNewMailbox:
  1233         case TFSEventNewMailbox:
  1112             handleMailboxEvent(mailbox, NmMailboxCreated);
  1234             handleMailboxEvent(mailbox, NmMailboxCreated);
  1113             break;
  1235             break;
  1217 int NmFrameworkAdapter::removeMessage(
  1339 int NmFrameworkAdapter::removeMessage(
  1218     const NmId& mailboxId,
  1340     const NmId& mailboxId,
  1219     const NmId& folderId,
  1341     const NmId& folderId,
  1220     const NmId& messageId)
  1342     const NmId& messageId)
  1221 {
  1343 {
       
  1344     NM_FUNCTION;
       
  1345     
  1222     TRAPD(error, removeMessageL(mailboxId, folderId, messageId));
  1346     TRAPD(error, removeMessageL(mailboxId, folderId, messageId));
  1223     return error;
  1347     return error;
  1224 }
  1348 }
  1225 
  1349 
  1226 /*!
  1350 /*!
  1228 
  1352 
  1229     \param mailboxId Id of the mailbox.
  1353     \param mailboxId Id of the mailbox.
  1230 */
  1354 */
  1231 void NmFrameworkAdapter::subscribeMailboxEvents(const NmId& mailboxId)
  1355 void NmFrameworkAdapter::subscribeMailboxEvents(const NmId& mailboxId)
  1232 {
  1356 {
       
  1357     NM_FUNCTION;
       
  1358     
  1233     TRAP_IGNORE(mFSfw->SubscribeMailboxEventsL(mailboxId, *this));
  1359     TRAP_IGNORE(mFSfw->SubscribeMailboxEventsL(mailboxId, *this));
  1234 }
  1360 }
  1235 
  1361 
  1236 /*!
  1362 /*!
  1237     Unsubscribe to events from a mailbox.
  1363     Unsubscribe to events from a mailbox.
  1238 
  1364 
  1239     \param mailboxId Id of the mailbox.
  1365     \param mailboxId Id of the mailbox.
  1240 */
  1366 */
  1241 void NmFrameworkAdapter::unsubscribeMailboxEvents(const NmId& mailboxId)
  1367 void NmFrameworkAdapter::unsubscribeMailboxEvents(const NmId& mailboxId)
  1242 {
  1368 {
       
  1369     NM_FUNCTION;
       
  1370     
  1243     mFSfw->UnsubscribeMailboxEvents(mailboxId, *this);
  1371     mFSfw->UnsubscribeMailboxEvents(mailboxId, *this);
  1244 }
  1372 }
  1245 
  1373 
  1246 NmId NmFrameworkAdapter::getMailboxIdByMailMsgId(TFSMailMsgId mailbox)
  1374 NmId NmFrameworkAdapter::getMailboxIdByMailMsgId(TFSMailMsgId mailbox)
  1247 {
  1375 {
       
  1376     NM_FUNCTION;
       
  1377     
  1248     NmId nmId(0);
  1378     NmId nmId(0);
  1249 
  1379 
  1250     QList<NmId> mailboxIds;
  1380     QList<NmId> mailboxIds;
  1251     listMailboxIds(mailboxIds);
  1381     listMailboxIds(mailboxIds);
  1252 
  1382 
  1267 void NmFrameworkAdapter::removeMessageL(
  1397 void NmFrameworkAdapter::removeMessageL(
  1268     const NmId& mailboxId,
  1398     const NmId& mailboxId,
  1269     const NmId& folderId,
  1399     const NmId& folderId,
  1270     const NmId& messageId)
  1400     const NmId& messageId)
  1271 {
  1401 {
       
  1402     NM_FUNCTION;
       
  1403     
  1272     CFSMailFolder* folder = mFSfw->GetFolderByUidL( TFSMailMsgId(mailboxId), TFSMailMsgId(folderId));
  1404     CFSMailFolder* folder = mFSfw->GetFolderByUidL( TFSMailMsgId(mailboxId), TFSMailMsgId(folderId));
  1273     CleanupStack::PushL(folder);
  1405     CleanupStack::PushL(folder);
  1274     if ( folder ) {
  1406     if ( folder ) {
  1275         folder->RemoveMessageL(TFSMailMsgId(messageId));
  1407         folder->RemoveMessageL(TFSMailMsgId(messageId));
  1276     }
  1408     }
  1282    Sends the given message.
  1414    Sends the given message.
  1283  */
  1415  */
  1284 QPointer<NmMessageSendingOperation> NmFrameworkAdapter::sendMessage(
  1416 QPointer<NmMessageSendingOperation> NmFrameworkAdapter::sendMessage(
  1285     NmMessage *message)
  1417     NmMessage *message)
  1286 {
  1418 {
       
  1419     NM_FUNCTION;
       
  1420     
  1287     QPointer<NmMessageSendingOperation>oper = new NmFwaMessageSendingOperation(*this, message, *mFSfw);
  1421     QPointer<NmMessageSendingOperation>oper = new NmFwaMessageSendingOperation(*this, message, *mFSfw);
  1288 	return oper;
  1422 	return oper;
  1289 }
  1423 }
  1290 
  1424 
  1291 /*!
  1425 /*!
  1293  */
  1427  */
  1294 QPointer<NmAddAttachmentsOperation> NmFrameworkAdapter::addAttachments(
  1428 QPointer<NmAddAttachmentsOperation> NmFrameworkAdapter::addAttachments(
  1295     const NmMessage &message,
  1429     const NmMessage &message,
  1296     const QList<QString> &fileList)
  1430     const QList<QString> &fileList)
  1297 {
  1431 {
       
  1432     NM_FUNCTION;
       
  1433     
  1298     QPointer<NmAddAttachmentsOperation>oper = new NmFwaAddAttachmentsOperation(message, fileList, *mFSfw);
  1434     QPointer<NmAddAttachmentsOperation>oper = new NmFwaAddAttachmentsOperation(message, fileList, *mFSfw);
  1299     return oper;
  1435     return oper;
  1300 }
  1436 }
  1301 
  1437 
  1302 /*!
  1438 /*!
  1304  */
  1440  */
  1305 QPointer<NmOperation> NmFrameworkAdapter::removeAttachment(
  1441 QPointer<NmOperation> NmFrameworkAdapter::removeAttachment(
  1306     const NmMessage &message,
  1442     const NmMessage &message,
  1307     const NmId &attachmentPartId)
  1443     const NmId &attachmentPartId)
  1308 {
  1444 {
       
  1445     NM_FUNCTION;
       
  1446     
  1309     QPointer<NmOperation> oper = new NmFwaRemoveAttachmentOperation(message, attachmentPartId, *mFSfw);
  1447     QPointer<NmOperation> oper = new NmFwaRemoveAttachmentOperation(message, attachmentPartId, *mFSfw);
  1310     return oper;
  1448     return oper;
  1311 }
  1449 }
  1312 
  1450 
  1313 /*!
  1451 /*!
  1314    Checks outbox for messages
       
  1315  */
       
  1316 QPointer<NmCheckOutboxOperation> NmFrameworkAdapter::checkOutbox(const NmId& mailboxId)
       
  1317 {
       
  1318     QPointer<NmCheckOutboxOperation> oper =
       
  1319         new NmFwaCheckOutboxOperation(mailboxId, *mFSfw);
       
  1320 
       
  1321     return oper;
       
  1322 }
       
  1323 
       
  1324 /*!
       
  1325     Returns the current sync state of the given mailbox
  1452     Returns the current sync state of the given mailbox
  1326  */
  1453  */
  1327 NmSyncState NmFrameworkAdapter::syncState(const NmId& mailboxId) const
  1454 NmSyncState NmFrameworkAdapter::syncState(const NmId& mailboxId) const
  1328 {
  1455 {
       
  1456     NM_FUNCTION;
       
  1457     
  1329    CFSMailBox* mailBox = NULL;
  1458    CFSMailBox* mailBox = NULL;
  1330    TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) );
  1459    TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) );
  1331    if (KErrNone == err && mailBox) {
  1460    if (KErrNone == err && mailBox) {
  1332        TSSMailSyncState syncState = mailBox->CurrentSyncState();
  1461        TSSMailSyncState syncState = mailBox->CurrentSyncState();
  1333        delete mailBox;
  1462        delete mailBox;
  1346 /*!
  1475 /*!
  1347     Returns the current connection state of the given mailbox
  1476     Returns the current connection state of the given mailbox
  1348  */
  1477  */
  1349 NmConnectState NmFrameworkAdapter::connectionState(const NmId& mailboxId) const
  1478 NmConnectState NmFrameworkAdapter::connectionState(const NmId& mailboxId) const
  1350 {
  1479 {
       
  1480     NM_FUNCTION;
       
  1481     
  1351     CFSMailBox* mailBox = NULL;
  1482     CFSMailBox* mailBox = NULL;
  1352     TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) );
  1483     TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) );
  1353     if (KErrNone == err && mailBox) {
  1484     if (KErrNone == err && mailBox) {
  1354         TFSMailBoxStatus status = mailBox->GetMailBoxStatus();
  1485         TFSMailBoxStatus status = mailBox->GetMailBoxStatus();
  1355         delete mailBox;
  1486         delete mailBox;
  1370    Call to this must be trapped
  1501    Call to this must be trapped
  1371  */
  1502  */
  1372 CFSMailMessage* NmFrameworkAdapter::mailMessageFromEnvelopeL(
  1503 CFSMailMessage* NmFrameworkAdapter::mailMessageFromEnvelopeL(
  1373     const NmMessageEnvelope& envelope)
  1504     const NmMessageEnvelope& envelope)
  1374 {
  1505 {
       
  1506     NM_FUNCTION;
       
  1507     
  1375     NmMessage* nmMessage = new(ELeave) NmMessage( envelope );
  1508     NmMessage* nmMessage = new(ELeave) NmMessage( envelope );
  1376     CFSMailMessage* message = CFSMailMessage::NewL( *nmMessage );
  1509     CFSMailMessage* message = CFSMailMessage::NewL( *nmMessage );
  1377     delete nmMessage;
  1510     delete nmMessage;
  1378     nmMessage = NULL;
  1511     nmMessage = NULL;
  1379     return message;
  1512     return message;
  1385  */
  1518  */
  1386 void NmFrameworkAdapter::childrenToNmMessagePartL(
  1519 void NmFrameworkAdapter::childrenToNmMessagePartL(
  1387         CFSMailMessagePart *cfsParent,
  1520         CFSMailMessagePart *cfsParent,
  1388         NmMessagePart *nmParent)
  1521         NmMessagePart *nmParent)
  1389 {
  1522 {
       
  1523     NM_FUNCTION;
       
  1524     
  1390     User::LeaveIfNull(cfsParent);
  1525     User::LeaveIfNull(cfsParent);
  1391     User::LeaveIfNull(nmParent);
  1526     User::LeaveIfNull(nmParent);
  1392 
  1527 
  1393     RPointerArray<CFSMailMessagePart> parts;
  1528     RPointerArray<CFSMailMessagePart> parts;
  1394     cfsParent->ChildPartsL(parts);
  1529     cfsParent->ChildPartsL(parts);
  1408 /*!
  1543 /*!
  1409    Leaving Refresh function
  1544    Leaving Refresh function
  1410  */
  1545  */
  1411 int NmFrameworkAdapter::RefreshMailboxL(NmId mailboxId)
  1546 int NmFrameworkAdapter::RefreshMailboxL(NmId mailboxId)
  1412 {
  1547 {
       
  1548     NM_FUNCTION;
       
  1549     
  1413     int result(KErrNotFound);
  1550     int result(KErrNotFound);
  1414     CFSMailBox *currentMailbox(NULL);
  1551     CFSMailBox *currentMailbox(NULL);
  1415     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
  1552     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
  1416     if(currentMailbox) {
  1553     if(currentMailbox) {
  1417         CleanupStack::PushL(currentMailbox);
  1554         CleanupStack::PushL(currentMailbox);
  1425 /*!
  1562 /*!
  1426    Leaving Go Online function
  1563    Leaving Go Online function
  1427  */
  1564  */
  1428 int NmFrameworkAdapter::GoOnlineL(const NmId& mailboxId)
  1565 int NmFrameworkAdapter::GoOnlineL(const NmId& mailboxId)
  1429 {
  1566 {
       
  1567     NM_FUNCTION;
       
  1568     
  1430     int result(KErrNotFound);
  1569     int result(KErrNotFound);
  1431     CFSMailBox *currentMailbox(NULL);
  1570     CFSMailBox *currentMailbox(NULL);
  1432     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
  1571     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
  1433     if(currentMailbox) {
  1572     if(currentMailbox) {
  1434         CleanupStack::PushL(currentMailbox);
  1573         CleanupStack::PushL(currentMailbox);
  1442 /*!
  1581 /*!
  1443    Leaving Go Offline function
  1582    Leaving Go Offline function
  1444  */
  1583  */
  1445 int NmFrameworkAdapter::GoOfflineL(const NmId& mailboxId)
  1584 int NmFrameworkAdapter::GoOfflineL(const NmId& mailboxId)
  1446 {
  1585 {
       
  1586     NM_FUNCTION;
       
  1587     
  1447 	int result(KErrNotFound);
  1588 	int result(KErrNotFound);
  1448     CFSMailBox *currentMailbox(NULL);
  1589     CFSMailBox *currentMailbox(NULL);
  1449     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
  1590     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
  1450     if(currentMailbox) {
  1591     if(currentMailbox) {
  1451         CleanupStack::PushL(currentMailbox);
  1592         CleanupStack::PushL(currentMailbox);
  1459 /*!
  1600 /*!
  1460    handles mailbox related events
  1601    handles mailbox related events
  1461  */
  1602  */
  1462 void NmFrameworkAdapter::handleMailboxEvent( TFSMailMsgId mailbox, NmMailboxEvent event)
  1603 void NmFrameworkAdapter::handleMailboxEvent( TFSMailMsgId mailbox, NmMailboxEvent event)
  1463 {
  1604 {
       
  1605     NM_FUNCTION;
       
  1606     
  1464     QList<NmId> mailboxIds;
  1607     QList<NmId> mailboxIds;
  1465     NmId nmId;
  1608     NmId nmId;
  1466     if (event == NmMailboxDeleted) {
  1609     if (event == NmMailboxDeleted) {
  1467 		nmId = mailbox.GetNmId();
  1610 		nmId = mailbox.GetNmId();
  1468     } else {
  1611     } else {
  1479     TAny* param1,
  1622     TAny* param1,
  1480     TAny* param2,
  1623     TAny* param2,
  1481     NmMessageEvent event,
  1624     NmMessageEvent event,
  1482     TFSMailMsgId mailbox)
  1625     TFSMailMsgId mailbox)
  1483 {
  1626 {
       
  1627     NM_FUNCTION;
       
  1628     
  1484     NmId nmMsgId(0);
  1629     NmId nmMsgId(0);
  1485     QList<NmId> messageIds;
  1630     QList<NmId> messageIds;
  1486     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
  1631     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
  1487     TFSMailMsgId* fsFolderId = reinterpret_cast<TFSMailMsgId*> (param2);
  1632     TFSMailMsgId* fsFolderId = reinterpret_cast<TFSMailMsgId*> (param2);
  1488     NmId folderId = fsFolderId->GetNmId();
  1633     NmId folderId = fsFolderId->GetNmId();
  1499 /*!
  1644 /*!
  1500    function to handle mailmoved event
  1645    function to handle mailmoved event
  1501  */
  1646  */
  1502 void NmFrameworkAdapter::handleMailMoved(TAny* param1,TAny* param2,TAny* param3, TFSMailMsgId mailbox)
  1647 void NmFrameworkAdapter::handleMailMoved(TAny* param1,TAny* param2,TAny* param3, TFSMailMsgId mailbox)
  1503 {
  1648 {
       
  1649     NM_FUNCTION;
       
  1650     
  1504     NmId nmMsgId(0);
  1651     NmId nmMsgId(0);
  1505     QList<NmId> messageIds;
  1652     QList<NmId> messageIds;
  1506     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
  1653     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
  1507     TFSMailMsgId* fsFromFolderId = reinterpret_cast<TFSMailMsgId*> (param3);
  1654     TFSMailMsgId* fsFromFolderId = reinterpret_cast<TFSMailMsgId*> (param3);
  1508     NmId fromFolderId = fsFromFolderId->GetNmId();
  1655     NmId fromFolderId = fsFromFolderId->GetNmId();
  1524 /*!
  1671 /*!
  1525    function to handle mailcopied event
  1672    function to handle mailcopied event
  1526  */
  1673  */
  1527 void NmFrameworkAdapter::handleMailCopied(TAny* param1,TAny* param2, TFSMailMsgId mailbox)
  1674 void NmFrameworkAdapter::handleMailCopied(TAny* param1,TAny* param2, TFSMailMsgId mailbox)
  1528 {
  1675 {
       
  1676     NM_FUNCTION;
       
  1677     
  1529     NmId nmMsgId(0);
  1678     NmId nmMsgId(0);
  1530     QList<NmId> messageIds;
  1679     QList<NmId> messageIds;
  1531     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
  1680     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
  1532     TFSMailMsgId* fsToFolderId = reinterpret_cast<TFSMailMsgId*> (param2);
  1681     TFSMailMsgId* fsToFolderId = reinterpret_cast<TFSMailMsgId*> (param2);
  1533     NmId toFolderId = fsToFolderId->GetNmId();
  1682     NmId toFolderId = fsToFolderId->GetNmId();
  1542     emit messageEvent(NmMessageCreated, toFolderId, messageIds, mailbox.GetNmId());
  1691     emit messageEvent(NmMessageCreated, toFolderId, messageIds, mailbox.GetNmId());
  1543 }
  1692 }
  1544 
  1693 
  1545 void NmFrameworkAdapter::handleSyncstateEvent(TAny* param1, TFSMailMsgId mailbox)
  1694 void NmFrameworkAdapter::handleSyncstateEvent(TAny* param1, TFSMailMsgId mailbox)
  1546 {
  1695 {
       
  1696     NM_FUNCTION;
       
  1697     
  1547     TSSMailSyncState* state = static_cast<TSSMailSyncState*>( param1 );
  1698     TSSMailSyncState* state = static_cast<TSSMailSyncState*>( param1 );
  1548     NmOperationCompletionEvent event;
  1699     NmOperationCompletionEvent event;
  1549     event.mMailboxId = NmConverter::mailMsgIdToNmId(mailbox);
  1700     event.mMailboxId = NmConverter::mailMsgIdToNmId(mailbox);
  1550     event.mOperationType = Synch;
  1701     event.mOperationType = Synch;
  1551 
  1702