16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync/* $Id$ */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync/** @file
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync * IProgress implementation for Machine::openRemoteSession in VBoxSVC.
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync/*
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2006-2012 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 :
7413b370d1af0fbac98c8ba74551c32e715b3af7vboxsync public Progress
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync{
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsyncpublic:
e07acfb7f2dbb8bb40804024c79fd3139bdb3f24vboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ProgressProxy, IProgress)
e07acfb7f2dbb8bb40804024c79fd3139bdb3f24vboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync DECLARE_NOT_AGGREGATABLE(ProgressProxy)
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync BEGIN_COM_MAP(ProgressProxy)
c7a378ed2fbad681c0b674351d698ef20a368935vboxsync VBOX_DEFAULT_INTERFACE_ENTRIES (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 uTotalOperationsWeight,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync CBSTR bstrFirstOperationDescription,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync ULONG uFirstOperationWeight,
941fd57f76689448d94928ce657a521e215f8671vboxsync ULONG cOtherProgressObjectOperations);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync void uninit();
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync // IProgress properties
941fd57f76689448d94928ce657a521e215f8671vboxsync STDMETHOD(COMGETTER(Cancelable))(BOOL *aCancelable);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(Percent))(ULONG *aPercent);
941fd57f76689448d94928ce657a521e215f8671vboxsync STDMETHOD(COMGETTER(TimeRemaining))(LONG *aTimeRemaining);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(Completed))(BOOL *aCompleted);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(Canceled))(BOOL *aCanceled);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(ResultCode))(LONG *aResultCode);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync STDMETHOD(COMGETTER(ErrorInfo))(IVirtualBoxErrorInfo **aErrorInfo);
941fd57f76689448d94928ce657a521e215f8671vboxsync //STDMETHOD(COMGETTER(OperationCount))(ULONG *aOperationCount); - not necessary
941fd57f76689448d94928ce657a521e215f8671vboxsync STDMETHOD(COMGETTER(Operation))(ULONG *aOperation);
941fd57f76689448d94928ce657a521e215f8671vboxsync STDMETHOD(COMGETTER(OperationDescription))(BSTR *aOperationDescription);
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 notifyComplete(HRESULT aResultCode);
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync HRESULT notifyComplete(HRESULT aResultCode,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync const GUID &aIID,
e07acfb7f2dbb8bb40804024c79fd3139bdb3f24vboxsync const char *pcszComponent,
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync const char *aText, ...);
e07acfb7f2dbb8bb40804024c79fd3139bdb3f24vboxsync bool setOtherProgressObject(IProgress *pOtherProgress);
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;
941fd57f76689448d94928ce657a521e215f8671vboxsync /** Set if the other progress object has multiple operations. */
941fd57f76689448d94928ce657a521e215f8671vboxsync bool mfMultiOperation;
941fd57f76689448d94928ce657a521e215f8671vboxsync /** The weight the other progress object started at. */
941fd57f76689448d94928ce657a521e215f8671vboxsync ULONG muOtherProgressStartWeight;
941fd57f76689448d94928ce657a521e215f8671vboxsync /** The weight of other progress object. */
941fd57f76689448d94928ce657a521e215f8671vboxsync ULONG muOtherProgressWeight;
941fd57f76689448d94928ce657a521e215f8671vboxsync /** The operation number the other progress object started at. */
941fd57f76689448d94928ce657a521e215f8671vboxsync ULONG muOtherProgressStartOperation;
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync};
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync#endif /* !____H_PROGRESSPROXYIMPL */
16ad47ef7a806f45a9b210cea20014b946c4ca2avboxsync