ProgressProxyImpl.h revision 16ad47ef7a806f45a9b210cea20014b946c4ca2a
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync/* $Id$ */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync/** @file
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * IProgress implementation for Machine::openRemoteSession in VBoxSVC.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync/*
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * Copyright (C) 2006-2010 Oracle Corporation
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync *
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * available from http://www.virtualbox.org. This file is free software;
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * you can redistribute it and/or modify it under the terms of the GNU
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * General Public License (GPL) as published by the Free Software
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync#ifndef ____H_PROGRESSPROXYIMPL
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync#define ____H_PROGRESSPROXYIMPL
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync#include "ProgressImpl.h"
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync#include "AutoCaller.h"
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync/**
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * The ProgressProxy class allows proxying the important Progress calls and
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * attributes to a different IProgress object for a period of time.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncclass ATL_NO_VTABLE ProgressProxy :
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync public com::SupportErrorInfoDerived<Progress, ProgressProxy, IProgress>,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync public VirtualBoxSupportTranslation<ProgressProxy>
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync{
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncpublic:
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(ProgressProxy)
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync DECLARE_NOT_AGGREGATABLE(ProgressProxy)
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync BEGIN_COM_MAP(ProgressProxy)
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync COM_INTERFACE_ENTRY (ISupportErrorInfo)
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync COM_INTERFACE_ENTRY (IProgress)
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync COM_INTERFACE_ENTRY2(IDispatch, IProgress)
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync END_COM_MAP()
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync HRESULT FinalConstruct();
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync void FinalRelease();
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync HRESULT init(
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync#if !defined (VBOX_COM_INPROC)
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync VirtualBox *pParent,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync#endif
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync IUnknown *pInitiator,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync CBSTR bstrDescription,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync BOOL fCancelable);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync HRESULT init(
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync#if !defined (VBOX_COM_INPROC)
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync VirtualBox *pParent,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync#endif
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync IUnknown *pInitiator,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync CBSTR bstrDescription,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync BOOL fCancelable,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync ULONG cOtherProgressObjects,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync ULONG uTotalOperationsWeight,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync CBSTR bstrFirstOperationDescription,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync ULONG uFirstOperationWeight,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync OUT_GUID pId = NULL);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync void uninit();
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync // IProgress properties
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(Percent))(ULONG *aPercent);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(Completed))(BOOL *aCompleted);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(Canceled))(BOOL *aCanceled);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(ResultCode))(LONG *aResultCode);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(ErrorInfo))(IVirtualBoxErrorInfo **aErrorInfo);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(OperationPercent))(ULONG *aOperationPercent);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMSETTER(Timeout))(ULONG aTimeout);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(Timeout))(ULONG *aTimeout);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync // IProgress methods
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(WaitForCompletion)(LONG aTimeout);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(WaitForOperationCompletion)(ULONG aOperation, LONG aTimeout);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(Cancel)();
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(SetCurrentOperationProgress)(ULONG aPercent);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(SetNextOperation)(IN_BSTR bstrNextOperationDescription, ULONG ulNextOperationsWeight);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync // public methods only for internal purposes
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync HRESULT setResultCode(HRESULT aResultCode);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync HRESULT notifyComplete(HRESULT aResultCode);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync HRESULT notifyComplete(HRESULT aResultCode,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync const GUID &aIID,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync const Bstr &aComponent,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync const char *aText, ...);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync bool notifyPointOfNoReturn(void);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync bool setOtherProgressObject(IProgress *pOtherProgress, ULONG uOperationWeight);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync bool clearOtherProgressObject(const char *pszLastOperationDescription, ULONG uLastOperationWeight);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync /** For com::SupportErrorInfoImpl. */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync static const char *ComponentName() { return "ProgressProxy"; }
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncprotected:
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync void clearOtherProgressObjectInternal(bool fEarly);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync void copyProgressInfo(IProgress *pOtherProgress, bool fEarly);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncprivate:
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync /** The other progress object. This can be NULL. */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync ComPtr<IProgress> mptrOtherProgress;
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync /** The number of other progress objects expected. */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync ULONG mcOtherProgressObjects;
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync /** The current other progress object. */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync ULONG miCurOtherProgressObject;
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync};
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync#endif /* !____H_PROGRESSPROXYIMPL */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync