emailuis/nmframeworkadapter/src/nmfwaforwardmessagecreationoperation.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 27 May 2010 12:43:55 +0300
changeset 27 9ba4404ef423
parent 20 ecc8def7944a
child 30 759dc5235cdb
permissions -rw-r--r--
Revision: 201019 Kit: 2010121

/*
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description:
 *
 */

#include "nmframeworkadapterheaders.h"

NmFwaForwardMessageCreationOperation::NmFwaForwardMessageCreationOperation(
    const NmId &mailboxId,
    const NmId &originalMessageId,
    CFSMailClient &mailClient) :
    NmFwaMessageCreationOperation(mailboxId, mailClient),
    mOriginalMessageId(originalMessageId)
{
}

NmFwaForwardMessageCreationOperation::~NmFwaForwardMessageCreationOperation()
{
}

void NmFwaForwardMessageCreationOperation::doRunAsyncOperation()
{
    const TFSMailMsgId mailMsgId(mMailboxId.pluginId32(), mMailboxId.id32());

    CFSMailBox *mailBox = NULL;
    TRAP_IGNORE(mailBox = mMailClient.GetMailBoxByUidL(mailMsgId));
    
    if (mailBox) {
        TRAPD(err, mRequestId = mailBox->CreateForwardMessageL(mOriginalMessageId, *this));

        if (err == KErrFSMailPluginNotSupported) {
            CFSMailMessage *fsMessage = mailBox->CreateForwardMessage(mOriginalMessageId);
 
            mMessage = fsMessage->GetNmMessage();
            
            delete fsMessage;
            fsMessage = NULL;
            
            completeOperation(NmNoError);
        }
        else if (err != KErrNone) {
            completeOperation(NmGeneralError);
        }
        
        delete mailBox;
        mailBox = NULL;
    }
    else {
        completeOperation(NmNotFoundError);
    }
}