emailuis/nmframeworkadapter/src/nmfwastoreenvelopesoperation.cpp
changeset 18 578830873419
child 20 ecc8def7944a
equal deleted inserted replaced
4:e7aa27f58ae1 18:578830873419
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include "nmfwastoreenvelopesoperation.h"
       
    19 #include "nmframeworkadapterheaders.h"
       
    20 
       
    21 NmFwaStoreEnvelopesOperation::NmFwaStoreEnvelopesOperation(
       
    22         const NmId &mailboxId,
       
    23         RPointerArray<CFSMailMessage> messages,
       
    24         CFSMailClient &mailClient) :
       
    25         mMailboxId(mailboxId),
       
    26         mMailClient(mailClient),
       
    27         mRequestId(0)
       
    28 {
       
    29     mMessages = messages;
       
    30 }
       
    31 
       
    32 NmFwaStoreEnvelopesOperation::~NmFwaStoreEnvelopesOperation()
       
    33 {
       
    34     NMLOG("NmFwaStoreEnvelopesOperation::~NmFwaStoreEnvelopesOperation() <---");
       
    35     mMessages.ResetAndDestroy();
       
    36     NMLOG("NmFwaStoreEnvelopesOperation::~NmFwaStoreEnvelopesOperation() --->");
       
    37 }
       
    38 
       
    39 void NmFwaStoreEnvelopesOperation::runAsyncOperation()
       
    40 {
       
    41     NMLOG("NmFwaStoreEnvelopesOperation::runAsyncOperation() <---");
       
    42     const TFSMailMsgId mailboxId(mMailboxId.pluginId32(), mMailboxId.id32());
       
    43     CFSMailBox *mailbox(NULL);
       
    44     TRAP_IGNORE( mailbox = mMailClient.GetMailBoxByUidL(mailboxId) );
       
    45     // no possibility to leave; no need for CleanupStack
       
    46     if ( mailbox && mMessages.Count() ) {
       
    47         TRAPD(err, mRequestId = mailbox->UpdateMessageFlagsL( mailboxId, mMessages, *this ));
       
    48         if (err != KErrNone) {
       
    49             completeOperation(NmGeneralError);
       
    50         }
       
    51     }
       
    52     else {
       
    53         completeOperation(NmNotFoundError);
       
    54     }
       
    55     // cleanup
       
    56     if (mailbox) {
       
    57         delete mailbox;
       
    58         mailbox = NULL;
       
    59     }
       
    60     NMLOG("NmFwaStoreEnvelopesOperation::runAsyncOperation() --->");
       
    61 }
       
    62 
       
    63 void NmFwaStoreEnvelopesOperation::doCancelOperation()
       
    64 {
       
    65     NMLOG("NmFwaStoreEnvelopesOperation::doCancelOperation() <---");
       
    66     TRAP_IGNORE(mMailClient.CancelL(mRequestId));
       
    67     NMLOG("NmFwaStoreEnvelopesOperation::doCancelOperation() --->");
       
    68 }
       
    69 
       
    70 /**
       
    71  * asynchronous request response message
       
    72  *
       
    73  * @param aEvent plugin event description
       
    74  * @param aRequestId request id of asyncronous operation
       
    75  */
       
    76 void NmFwaStoreEnvelopesOperation::RequestResponseL(TFSProgress aEvent, TInt aRequestId)
       
    77 {
       
    78     NMLOG("NmFwaStoreEnvelopesOperation::RequestResponseL() <---");
       
    79     if (aRequestId == mRequestId) {
       
    80         if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete && aEvent.iParam) {
       
    81             completeOperation(NmNoError);
       
    82         }
       
    83         else if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestCancelled) {
       
    84             operationCancelled();
       
    85         }
       
    86         else {
       
    87             completeOperation(NmGeneralError);
       
    88         }
       
    89     }
       
    90     NMLOG("NmFwaStoreEnvelopesOperation::RequestResponseL() --->");
       
    91 }