1 | /* $Id: ProgressProxyImpl.h 29934 2010-06-01 06:39:21Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IProgress implementation for Machine::openRemoteSession in VBoxSVC.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2010 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_PROGRESSPROXYIMPL
|
---|
19 | #define ____H_PROGRESSPROXYIMPL
|
---|
20 |
|
---|
21 | #include "ProgressImpl.h"
|
---|
22 | #include "AutoCaller.h"
|
---|
23 |
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * The ProgressProxy class allows proxying the important Progress calls and
|
---|
27 | * attributes to a different IProgress object for a period of time.
|
---|
28 | */
|
---|
29 | class ATL_NO_VTABLE ProgressProxy :
|
---|
30 | //public com::SupportErrorInfoDerived<Progress, ProgressProxy, IProgress>,
|
---|
31 | public Progress,
|
---|
32 | public VirtualBoxSupportTranslation<ProgressProxy>
|
---|
33 | {
|
---|
34 | public:
|
---|
35 | VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(ProgressProxy)
|
---|
36 | DECLARE_NOT_AGGREGATABLE(ProgressProxy)
|
---|
37 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
38 |
|
---|
39 | BEGIN_COM_MAP(ProgressProxy)
|
---|
40 | COM_INTERFACE_ENTRY (ISupportErrorInfo)
|
---|
41 | COM_INTERFACE_ENTRY (IProgress)
|
---|
42 | COM_INTERFACE_ENTRY2(IDispatch, IProgress)
|
---|
43 | END_COM_MAP()
|
---|
44 |
|
---|
45 | HRESULT FinalConstruct();
|
---|
46 | void FinalRelease();
|
---|
47 | HRESULT init(
|
---|
48 | #if !defined (VBOX_COM_INPROC)
|
---|
49 | VirtualBox *pParent,
|
---|
50 | #endif
|
---|
51 | IUnknown *pInitiator,
|
---|
52 | CBSTR bstrDescription,
|
---|
53 | BOOL fCancelable);
|
---|
54 | HRESULT init(
|
---|
55 | #if !defined (VBOX_COM_INPROC)
|
---|
56 | VirtualBox *pParent,
|
---|
57 | #endif
|
---|
58 | IUnknown *pInitiator,
|
---|
59 | CBSTR bstrDescription,
|
---|
60 | BOOL fCancelable,
|
---|
61 | ULONG cOtherProgressObjects,
|
---|
62 | ULONG uTotalOperationsWeight,
|
---|
63 | CBSTR bstrFirstOperationDescription,
|
---|
64 | ULONG uFirstOperationWeight,
|
---|
65 | OUT_GUID pId = NULL);
|
---|
66 | void uninit();
|
---|
67 |
|
---|
68 | // IProgress properties
|
---|
69 | STDMETHOD(COMGETTER(Percent))(ULONG *aPercent);
|
---|
70 | STDMETHOD(COMGETTER(Completed))(BOOL *aCompleted);
|
---|
71 | STDMETHOD(COMGETTER(Canceled))(BOOL *aCanceled);
|
---|
72 | STDMETHOD(COMGETTER(ResultCode))(LONG *aResultCode);
|
---|
73 | STDMETHOD(COMGETTER(ErrorInfo))(IVirtualBoxErrorInfo **aErrorInfo);
|
---|
74 | STDMETHOD(COMGETTER(OperationPercent))(ULONG *aOperationPercent);
|
---|
75 | STDMETHOD(COMSETTER(Timeout))(ULONG aTimeout);
|
---|
76 | STDMETHOD(COMGETTER(Timeout))(ULONG *aTimeout);
|
---|
77 |
|
---|
78 | // IProgress methods
|
---|
79 | STDMETHOD(WaitForCompletion)(LONG aTimeout);
|
---|
80 | STDMETHOD(WaitForOperationCompletion)(ULONG aOperation, LONG aTimeout);
|
---|
81 | STDMETHOD(Cancel)();
|
---|
82 | STDMETHOD(SetCurrentOperationProgress)(ULONG aPercent);
|
---|
83 | STDMETHOD(SetNextOperation)(IN_BSTR bstrNextOperationDescription, ULONG ulNextOperationsWeight);
|
---|
84 |
|
---|
85 | // public methods only for internal purposes
|
---|
86 |
|
---|
87 | HRESULT setResultCode(HRESULT aResultCode);
|
---|
88 | HRESULT notifyComplete(HRESULT aResultCode);
|
---|
89 | HRESULT notifyComplete(HRESULT aResultCode,
|
---|
90 | const GUID &aIID,
|
---|
91 | const Bstr &aComponent,
|
---|
92 | const char *aText, ...);
|
---|
93 | bool notifyPointOfNoReturn(void);
|
---|
94 | bool setOtherProgressObject(IProgress *pOtherProgress, ULONG uOperationWeight);
|
---|
95 | bool clearOtherProgressObject(const char *pszLastOperationDescription, ULONG uLastOperationWeight);
|
---|
96 |
|
---|
97 | /** For com::SupportErrorInfoImpl. */
|
---|
98 | static const char *ComponentName() { return "ProgressProxy"; }
|
---|
99 |
|
---|
100 | protected:
|
---|
101 | void clearOtherProgressObjectInternal(bool fEarly);
|
---|
102 | void copyProgressInfo(IProgress *pOtherProgress, bool fEarly);
|
---|
103 |
|
---|
104 | private:
|
---|
105 | /** The other progress object. This can be NULL. */
|
---|
106 | ComPtr<IProgress> mptrOtherProgress;
|
---|
107 | /** The number of other progress objects expected. */
|
---|
108 | ULONG mcOtherProgressObjects;
|
---|
109 | /** The current other progress object. */
|
---|
110 | ULONG miCurOtherProgressObject;
|
---|
111 |
|
---|
112 | };
|
---|
113 |
|
---|
114 | #endif /* !____H_PROGRESSPROXYIMPL */
|
---|
115 |
|
---|