ipsservices/ipssosplugin/inc/ipsplgnewchildpartfromfileoperation.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 15:04:17 +0300
branchRCL_3
changeset 63 d189ee25cf9d
permissions -rw-r--r--
Revision: 201033 Kit: 201035

/*
* Copyright (c) 2007-2008 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:  New child part from file operation
*
*/

// <qmail>
#ifndef IPSPLGNEWCHILDPARTFROMFILEOPERATION_H
#define IPSPLGNEWCHILDPARTFROMFILEOPERATION_H

class MFSMailRequestObserver;

NONSHARABLE_CLASS ( CIpsPlgNewChildPartFromFileOperation ): public CIpsPlgBaseOperation
{
public:
    /**
    * Constructor.
    */
    static CIpsPlgNewChildPartFromFileOperation* NewL(
        CMsvSession& aMsvSession,
        TRequestStatus& aObserverRequestStatus,
        const TFSMailMsgId& aMailBoxId,
        const TFSMailMsgId& aMessageId,
        const TDesC& aContentType,
        const TDesC& aFilePath,
        MFSMailRequestObserver& aOperationObserver,
        const TInt aRequestId,
        CIpsPlgMsgMapper *aMsgMapper);

    /**
    * Destructor.
    */
    virtual ~CIpsPlgNewChildPartFromFileOperation();

public: // From CIpsPlgBaseOperation
    
    virtual const TDesC8& ProgressL();
    
    virtual const TDesC8& GetErrorProgressL(TInt aError);

    virtual TFSProgress GetFSProgressL() const;

    TIpsOpType IpsOpType() const;   
    
protected:
    /**
    * Constructor.
    */
    CIpsPlgNewChildPartFromFileOperation(
        CMsvSession& aMsvSession,
        TRequestStatus& aObserverRequestStatus,
        const TFSMailMsgId& aMailBoxId,
        const TFSMailMsgId& aMessageId,
        MFSMailRequestObserver& aOperationObserver,
        const TInt aRequestId);
    
    /**
    * Constructor.
    */
    void ConstructL(CIpsPlgMsgMapper *aMsgMapper,
        const TDesC& aContentType,
        const TDesC& aFilePath);

    /**
    * From CActive
    */
    void RunL();

    /**
    * From CActive
    */
    void DoCancel();

    /**
    * From CActive
    */
    TInt RunError(TInt aError);
    
    void SignalFSObserver(TInt aStatus, CFSMailMessagePart* aMessagePart );

private:
    void GetMessageEntryL( TMsvId aId,
                           CMsvEntry*& aMessageEntry,
                           CImEmailMessage*& aImEmailMessage );
    
    void CleanCachedMessageEntries();

    /*
     * Four different operation steps are needed
     */
    enum TOperationStep
        {
        EInitAttachmentManager,
        EPrepareMsvEntry,
        EPrepareStore,
        EStoreMessagePart
        };
    
    /*
     * Initializes attachment manager asynchronously
     */
    void InitAttachmentManagerL();
    
    /*
     * Prepares Msv entry to be updated asynchronously
     */
    void PrepareMsvEntryL();
    
    /*
     * Prepares message store asynchronously if needed
     */
    void PrepareStoreL();
    
    /*
     * Stores message part and finishes the operation
     */
    void StoreMessagePartL();
    
protected:
    CMsvOperation* iOperation;   // owned
	// <qmail> iBlank, iMailBoxId removed
    TFSMailMsgId iMessageId;
    MFSMailRequestObserver& iOperationObserver;  // not owned
	// <qmail> iRequestId removed
    HBufC* iContentType;
    HBufC* iFilePath;
    CMsvEntry* iCachedEntry;
    CImEmailMessage* iCachedEmailMessage;
    CImEmailMessage* iMessage;
    CMsvEntry* iEntry;
    CIpsPlgMsgMapper* iMsgMapper;
    TMsvId iNewAttachmentId;
    TOperationStep iStep;
    TFSProgress iFSProgress;
};

#endif // IPSPLGNEWCHILDPARTFROMFILEOPERATION_H

// </qmail>