ipsservices/ipssosplugin/inc/ipsplgimap4fetchattachmentop.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 03 May 2010 12:23:15 +0300
changeset 20 ecc8def7944a
parent 18 578830873419
child 23 2dc6caa42ec3
permissions -rw-r--r--
Revision: 201015 Kit: 201018

/*
* 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:  IMAP4 attachment fetch operation
*
*/

#ifndef IPSPLGIMAP4FETCHATTACHMENTOP_H
#define IPSPLGIMAP4FETCHATTACHMENTOP_H

class CIpsPlgImap4FetchAttachmentOp;

/**
* CIpsFetchProgReport
* helper class for the operation
* implements a timer which initiates periodical progress updating
*/
NONSHARABLE_CLASS ( CIpsFetchProgReport ) : public CActive
    {
public:
    /**
    * @param aAttaOp (callback) reference to fetch operation that created us
    */
    static CIpsFetchProgReport* NewL( CIpsPlgImap4FetchAttachmentOp& aAttaOp );

    virtual ~CIpsFetchProgReport();

protected: // From CActive
    virtual void DoCancel();
    virtual void RunL();

private:
    CIpsFetchProgReport( CIpsPlgImap4FetchAttachmentOp& aAttaOp );
    void ConstructL();
    void AdjustTimer();

private: // members
    RTimer iTimer;
    // reference to our "parent" op
    CIpsPlgImap4FetchAttachmentOp& iAttaOp; 
    };

/**
* class CIpsPlgImap4FetchAttachmentOp
* fetches messageparts
*/
NONSHARABLE_CLASS ( CIpsPlgImap4FetchAttachmentOp ) :
    public CIpsPlgOnlineOperation
    {
public:

    /**
    * NewL()
    * @param CMsvSession& client/server session to MsvServer
    * @param aObserverRequestStatus operation's observer's status
    * @param aService serviceId of this mailbox
    * @param aActivityTimer mailbox specific activity timer
    * @param aSelection selection of message part ids, ownership moves
    * @param aFSMailBoxId specifies mailbox
    * @param aFSOperationObserver observes the progress of this operation
    * @param aFSRequestId identifier for this instance of operation, assigned by the client
    * @return CIpsPlgImap4FetchAttachmentOp* self pointer
    */
    static CIpsPlgImap4FetchAttachmentOp* NewL(
        CMsvSession& aMsvSession,
        TRequestStatus& aObserverRequestStatus,
        TMsvId aService,
        CIpsPlgTimerOperation& aActivityTimer,
        const CMsvEntrySelection* aSelection,
        TFSMailMsgId aFSMailBoxId,
        MFSMailRequestObserver* aFSOperationObserver,
        TInt aFSRequestId );

    virtual ~CIpsPlgImap4FetchAttachmentOp();

    /**
    * From MsvOperation
    * Gets information on the progress of the operation
    * (see MsvOperation header)
    */
    const TDesC8& ProgressL();

    /**
    * From CIpsPlgBaseOperation
    * For reporting if DoRunL leaves
    */
    const TDesC8& GetErrorProgressL( TInt aError );
    
    TFSProgress GetFSProgressL() const;
    
private:
    CIpsPlgImap4FetchAttachmentOp(
        CMsvSession& aMsvSession,
        TRequestStatus& aObserverRequestStatus,
        TMsvId aService,
        CIpsPlgTimerOperation& aActivityTimer,
        const CMsvEntrySelection* aSelection,
        TFSMailMsgId aFSMailBoxId,
        MFSMailRequestObserver* aFSOperationObserver,
        TInt aFSRequestId );

    void ConstructL();

    void RunL();

    void DoRunL();

    //virtual void DoCancel();

    void Complete();
    
    void DoConnectL();
    
    /**
     * Called periodically by CIpsFetchProgReport during active fetching
     * Leads to sending progress report to plugin's client
     */
    void ReportProgressL();  
    
    // <qmail> new func to this op
    /**
     * Returns operation type
     */
    TIpsOpType IpsOpType() const;
    
protected:
    
    void DoFetchAttachmentL( );
        
private: //Data
    friend class CIpsFetchProgReport;

    // internal state of this statemachine
    enum TFetchState {
        EStateIdle,
        EStateConnecting,
        EStateFetching,
        EStateDisconnecting };
    TFetchState iState;
        
    const CMsvEntrySelection*               iSelection;
    TDesC8*                                 iFetchErrorProgress;
    TPckgBuf<TImap4CompoundProgress>        iProgress;
    CIpsFetchProgReport*                    iProgReport;
    };

#endif // IPSPLGIMAP4FETCHATTACHMENTOP_H