emailuis/nmframeworkadapter/src/nmfwamessagesendingoperation.cpp
changeset 23 2dc6caa42ec3
parent 20 ecc8def7944a
child 30 759dc5235cdb
equal deleted inserted replaced
20:ecc8def7944a 23:2dc6caa42ec3
    49 /*!
    49 /*!
    50     Destructor
    50     Destructor
    51  */
    51  */
    52 NmFwaMessageSendingOperation::~NmFwaMessageSendingOperation()
    52 NmFwaMessageSendingOperation::~NmFwaMessageSendingOperation()
    53 {
    53 {
    54     delete mSaveOperation;
    54     if (mSaveOperation && mSaveOperation->isRunning()) {
    55 
    55         mSaveOperation->cancelOperation();
       
    56     }
    56     doCancelOperation();
    57     doCancelOperation();
    57     mMailClient.Close(); // decrease ref count
    58     mMailClient.Close(); // decrease ref count
    58     delete mMessage;
    59     delete mMessage;
       
    60     NMLOG("NmFwaMessageSendingOperation::~NmFwaMessageSendingOperation --->");
    59 }
    61 }
    60 
    62 
    61 /*!
    63 /*!
    62     returns pointer to message, ownership is not transferred
    64     returns pointer to message, ownership is not transferred
    63  */
    65  */
   111 {
   113 {
   112     if (mRequestId >= 0) {
   114     if (mRequestId >= 0) {
   113         TRAP_IGNORE(mMailClient.CancelL(mRequestId));
   115         TRAP_IGNORE(mMailClient.CancelL(mRequestId));
   114         mRequestId = NmNotFoundError;
   116         mRequestId = NmNotFoundError;
   115     }
   117     }
       
   118     if (mSaveOperation && mSaveOperation->isRunning()) {
       
   119         mSaveOperation->cancelOperation();
       
   120     }
   116 }
   121 }
   117     
   122     
   118 /*!
   123 /*!
   119     Asynchronous request response message.
   124     Asynchronous request response message.
   120     
   125     
   143     Handle completed store message operation
   148     Handle completed store message operation
   144  */
   149  */
   145 void NmFwaMessageSendingOperation::handleCompletedSaveOperation(int error)
   150 void NmFwaMessageSendingOperation::handleCompletedSaveOperation(int error)
   146 {
   151 {
   147     if (error == NmNoError) {
   152     if (error == NmNoError) {
   148         mTimer->stop();
       
   149         mTimer->start(1);
       
   150         mSaved = true;
   153         mSaved = true;
       
   154         doRunAsyncOperation();
   151     }
   155     }
   152     else {
   156     else {
   153         completeOperation(NmGeneralError);
   157         completeOperation(NmGeneralError);
   154     }
   158     }
   155 }
   159 }
   158     Saves a message with its subparts (into message store).
   162     Saves a message with its subparts (into message store).
   159 */
   163 */
   160 int NmFwaMessageSendingOperation::saveMessageWithSubparts()
   164 int NmFwaMessageSendingOperation::saveMessageWithSubparts()
   161 {
   165 {
   162     int ret = NmNotFoundError;
   166     int ret = NmNotFoundError;
   163     
       
   164     if (mMessage) {
   167     if (mMessage) {
   165         delete mSaveOperation;
   168         if (mSaveOperation && mSaveOperation->isRunning()) {
   166         mSaveOperation = NULL;
   169             mSaveOperation->cancelOperation();
   167         
   170         }
   168         mSaveOperation = mPluginInterface.saveMessageWithSubparts(*mMessage);
   171         mSaveOperation = mPluginInterface.saveMessageWithSubparts(*mMessage);
   169         
   172         
   170         if (mSaveOperation) {
   173         if (mSaveOperation) {
   171             connect(mSaveOperation, SIGNAL(operationCompleted(int)), this,
   174             connect(mSaveOperation, SIGNAL(operationCompleted(int)), this,
   172                 SLOT(handleCompletedSaveOperation(int)));
   175                 SLOT(handleCompletedSaveOperation(int)));
   184 /*!
   187 /*!
   185     Sends the message.
   188     Sends the message.
   186  */
   189  */
   187 int NmFwaMessageSendingOperation::sendMessageL()
   190 int NmFwaMessageSendingOperation::sendMessageL()
   188 {
   191 {
       
   192     NMLOG("NmFwaMessageSendingOperation::sendMessageL");
   189     int ret = NmNotFoundError;
   193     int ret = NmNotFoundError;
   190     
   194     
   191     if (mMessage) {
   195     if (mMessage) {
   192         TFSMailMsgId mailboxId = NmConverter::nmIdToMailMsgId(mMessage->mailboxId());
   196         TFSMailMsgId mailboxId = NmConverter::nmIdToMailMsgId(mMessage->envelope().mailboxId());
   193         CFSMailBox *currentMailbox( NULL );
   197         CFSMailBox *currentMailbox( NULL );
   194         currentMailbox = mMailClient.GetMailBoxByUidL(mailboxId);
   198         currentMailbox = mMailClient.GetMailBoxByUidL(mailboxId);
   195         CleanupStack::PushL(currentMailbox);
   199         CleanupStack::PushL(currentMailbox);
   196         if (!currentMailbox) {
   200         if (!currentMailbox) {
   197             User::Leave( KErrNotFound );
   201             User::Leave( KErrNotFound );