- Timestamp:
- Aug 22, 2018 12:51:23 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/ExtPack/ExtPack.h
r68828 r73825 190 190 const char *pszPluginLibrary)); 191 191 192 /** 193 * Creates an IProgress object instance for a long running extension 194 * pack provided API operation which is executed asynchronously. 195 * 196 * This implicitly creates a cancellable progress object, since anything 197 * else is user unfriendly. You need to design your code to handle 198 * cancellation with reasonable response time. 199 * 200 * @returns COM status code. 201 * @param pHlp Pointer to this helper structure. 202 * @param pInitiator Pointer to the initiating object. 203 * @param pcszDescription Description of the overall task. 204 * @param cOperations Number of operations for this task. 205 * @param uTotalOperationsWeight Overall weight for the entire task. 206 * @param pcszFirstOperationDescription Description of the first operation. 207 * @param uFirstOperationWeight Weight for the first operation. 208 * @param ppProgressOut Output parameter for the IProgress object reference. 209 */ 210 DECLR3CALLBACKMEMBER(uint32_t, pfnCreateProgress,(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IUnknown) *pInitiator, 211 const char *pcszDescription, uint32_t cOperations, 212 uint32_t uTotalOperationsWeight, const char *pcszFirstOperationDescription, 213 uint32_t uFirstOperationWeight, VBOXEXTPACK_IF_CS(IProgress) **ppProgressOut)); 214 215 /** 216 * Checks if the Progress object is marked as canceled. 217 * 218 * @returns COM status code. 219 * @param pHlp Pointer to this helper structure. 220 * @param pProgress Pointer to the IProgress object reference returned 221 * by pfnCreateProgress. 222 * @param pfCanceled @c true if canceled, @c false otherwise. 223 */ 224 DECLR3CALLBACKMEMBER(uint32_t, pfnGetCanceledProgress,(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 225 bool *pfCanceled)); 226 227 /** 228 * Updates the percentage value of the current operation of the 229 * Progress object. 230 * 231 * @returns COM status code. 232 * @param pHlp Pointer to this helper structure. 233 * @param pProgress Pointer to the IProgress object reference returned 234 * by pfnCreateProgress. 235 * @param uPercent Result of the overall task. 236 */ 237 DECLR3CALLBACKMEMBER(uint32_t, pfnUpdateProgress,(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 238 uint32_t uPercent)); 239 240 /** 241 * Signals that the current operation is successfully completed and 242 * advances to the next operation. The operation percentage is reset 243 * to 0. 244 * 245 * If the operation count is exceeded this returns an error. 246 * 247 * @returns COM status code. 248 * @param pHlp Pointer to this helper structure. 249 * @param pProgress Pointer to the IProgress object reference returned 250 * by pfnCreateProgress. 251 * @param pcszNextOperationDescription Description of the next operation. 252 * @param uNextOperationWeight Weight for the next operation. 253 */ 254 DECLR3CALLBACKMEMBER(uint32_t, pfnNextOperationProgress,(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 255 const char *pcszNextOperationDescription, 256 uint32_t uNextOperationWeight)); 257 258 /** 259 * Marks the whole task as complete and sets the result code. 260 * 261 * If the result code indicates a failure then this method will store 262 * the currently set COM error info from the current thread in the 263 * the errorInfo attribute of this Progress object instance. If there 264 * is no error information available then an error is returned. 265 * 266 * If the result code indicates success then the task is terminated, 267 * without paying attention to the current operation being the last. 268 * 269 * Note that this must be called only once for the given Progress 270 * object. Subsequent calls will return errors. 271 * 272 * @returns COM status code. 273 * @param pHlp Pointer to this helper structure. 274 * @param pProgress Pointer to the IProgress object reference returned 275 * by pfnCreateProgress. 276 * @param uResultCode Result of the overall task. 277 */ 278 DECLR3CALLBACKMEMBER(uint32_t, pfnCompleteProgress,(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 279 uint32_t uResultCode)); 280 192 281 DECLR3CALLBACKMEMBER(int, pfnReserved1,(PCVBOXEXTPACKHLP pHlp)); /**< Reserved for minor structure revisions. */ 193 282 DECLR3CALLBACKMEMBER(int, pfnReserved2,(PCVBOXEXTPACKHLP pHlp)); /**< Reserved for minor structure revisions. */ … … 201 290 } VBOXEXTPACKHLP; 202 291 /** Current version of the VBOXEXTPACKHLP structure. */ 203 #define VBOXEXTPACKHLP_VERSION RT_MAKE_U32( 2, 1)292 #define VBOXEXTPACKHLP_VERSION RT_MAKE_U32(3, 0) 204 293 205 294 -
trunk/src/VBox/Main/include/ExtPackManagerImpl.h
r73716 r73825 103 103 HRESULT FinalConstruct(); 104 104 void FinalRelease(); 105 HRESULT initWithDir(V BOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir);105 HRESULT initWithDir(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir); 106 106 void uninit(); 107 107 RTMEMEF_NEW_AND_DELETE_OPERATORS(); … … 151 151 static DECLCALLBACK(int) i_hlpLoadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary); 152 152 static DECLCALLBACK(int) i_hlpUnloadVDPlugin(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, const char *pszPluginLibrary); 153 static DECLCALLBACK(uint32_t) i_hlpCreateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IUnknown) *pInitiator, 154 const char *pcszDescription, uint32_t cOperations, 155 uint32_t uTotalOperationsWeight, const char *pcszFirstOperationDescription, 156 uint32_t uFirstOperationWeight, VBOXEXTPACK_IF_CS(IProgress) **ppProgressOut); 157 static DECLCALLBACK(uint32_t) i_hlpGetCanceledProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 158 bool *pfCanceled); 159 static DECLCALLBACK(uint32_t) i_hlpUpdateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 160 uint32_t uPercent); 161 static DECLCALLBACK(uint32_t) i_hlpNextOperationProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 162 const char *pcszNextOperationDescription, 163 uint32_t uNextOperationWeight); 164 static DECLCALLBACK(uint32_t) i_hlpCompleteProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 165 uint32_t uResultCode); 153 166 static DECLCALLBACK(int) i_hlpReservedN(PCVBOXEXTPACKHLP pHlp); 154 167 /** @} */ -
trunk/src/VBox/Main/src-all/ExtPackManagerImpl.cpp
r73716 r73825 143 143 /** Set if we've made the pfnVirtualBoxReady or pfnConsoleReady call. */ 144 144 bool fMadeReadyCall; 145 #ifndef VBOX_COM_INPROC 146 /** Pointer to the VirtualBox object so we can create a progress object. */ 147 VirtualBox *pVirtualBox; 148 #endif 145 149 146 150 RTMEMEF_NEW_AND_DELETE_OPERATORS(); … … 720 724 * 721 725 * @returns COM status code. 726 * @param a_pVirtualBox The VirtualBox object. 722 727 * @param a_enmContext The context we're in. 723 728 * @param a_pszName The name of the extension pack. This is also the … … 726 731 * @param a_pszDir The extension pack directory name. 727 732 */ 728 HRESULT ExtPack::initWithDir(V BOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir)733 HRESULT ExtPack::initWithDir(VirtualBox *a_pVirtualBox, VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir) 729 734 { 730 735 AutoInitSpan autoInitSpan(this); … … 744 749 /* pfnLoadVDPlugin = */ ExtPack::i_hlpLoadVDPlugin, 745 750 /* pfnUnloadVDPlugin = */ ExtPack::i_hlpUnloadVDPlugin, 751 /* pfnCreateProgress = */ ExtPack::i_hlpCreateProgress, 752 /* pfnGetCanceledProgress = */ ExtPack::i_hlpGetCanceledProgress, 753 /* pfnUpdateProgress = */ ExtPack::i_hlpUpdateProgress, 754 /* pfnNextOperationProgress = */ ExtPack::i_hlpNextOperationProgress, 755 /* pfnCompleteProgress = */ ExtPack::i_hlpCompleteProgress, 746 756 /* pfnReserved1 = */ ExtPack::i_hlpReservedN, 747 757 /* pfnReserved2 = */ ExtPack::i_hlpReservedN, … … 774 784 m->enmContext = a_enmContext; 775 785 m->fMadeReadyCall = false; 786 #ifndef VBOX_COM_INPROC 787 m->pVirtualBox = a_pVirtualBox; 788 #else 789 RT_NOREF(a_pVirtualBox); 790 #endif 776 791 777 792 /* … … 1723 1738 } 1724 1739 1740 /*static*/ DECLCALLBACK(uint32_t) 1741 ExtPack::i_hlpCreateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IUnknown) *pInitiator, 1742 const char *pcszDescription, uint32_t cOperations, 1743 uint32_t uTotalOperationsWeight, const char *pcszFirstOperationDescription, 1744 uint32_t uFirstOperationWeight, VBOXEXTPACK_IF_CS(IProgress) **ppProgressOut) 1745 { 1746 /* 1747 * Validate the input and get our bearings. 1748 */ 1749 AssertPtrReturn(pcszDescription, E_INVALIDARG); 1750 AssertReturn(cOperations >= 1, E_INVALIDARG); 1751 AssertReturn(uTotalOperationsWeight >= 1, E_INVALIDARG); 1752 AssertPtrReturn(pcszFirstOperationDescription, E_INVALIDARG); 1753 AssertReturn(uFirstOperationWeight >= 1, E_INVALIDARG); 1754 AssertPtrReturn(ppProgressOut, E_INVALIDARG); 1755 1756 AssertPtrReturn(pHlp, VERR_INVALID_POINTER); 1757 AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER); 1758 #ifndef VBOX_COM_INPROC 1759 ExtPack::Data *m = RT_FROM_CPP_MEMBER(pHlp, Data, Hlp); 1760 #endif 1761 1762 ComObjPtr<Progress> pProgress; 1763 HRESULT hrc = pProgress.createObject(); 1764 if (FAILED(hrc)) 1765 return hrc; 1766 hrc = pProgress->init( 1767 #ifndef VBOX_COM_INPROC 1768 m->pVirtualBox, 1769 #endif 1770 pInitiator, pcszDescription, TRUE /* aCancelable */, 1771 cOperations, uTotalOperationsWeight, 1772 pcszFirstOperationDescription, uFirstOperationWeight); 1773 if (FAILED(hrc)) 1774 return hrc; 1775 1776 return pProgress.queryInterfaceTo(ppProgressOut); 1777 } 1778 1779 /*static*/ DECLCALLBACK(uint32_t) 1780 ExtPack::i_hlpGetCanceledProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 1781 bool *pfCanceled) 1782 { 1783 /* 1784 * Validate the input and get our bearings. 1785 */ 1786 AssertPtrReturn(pProgress, E_INVALIDARG); 1787 AssertPtrReturn(pfCanceled, E_INVALIDARG); 1788 1789 AssertPtrReturn(pHlp, VERR_INVALID_POINTER); 1790 AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER); 1791 1792 BOOL fCanceled = FALSE; 1793 HRESULT hrc = pProgress->GetCanceled(&fCanceled); 1794 *pfCanceled = !!fCanceled; 1795 return hrc; 1796 } 1797 1798 /*static*/ DECLCALLBACK(uint32_t) 1799 ExtPack::i_hlpUpdateProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 1800 uint32_t uPercent) 1801 { 1802 /* 1803 * Validate the input and get our bearings. 1804 */ 1805 AssertPtrReturn(pProgress, E_INVALIDARG); 1806 AssertReturn(uPercent <= 100, E_INVALIDARG); 1807 1808 AssertPtrReturn(pHlp, VERR_INVALID_POINTER); 1809 AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER); 1810 1811 return pProgress->SetCurrentOperationProgress(uPercent); 1812 } 1813 1814 /*static*/ DECLCALLBACK(uint32_t) 1815 ExtPack::i_hlpNextOperationProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 1816 const char *pcszNextOperationDescription, 1817 uint32_t uNextOperationWeight) 1818 { 1819 /* 1820 * Validate the input and get our bearings. 1821 */ 1822 AssertPtrReturn(pProgress, E_INVALIDARG); 1823 AssertPtrReturn(pcszNextOperationDescription, E_INVALIDARG); 1824 AssertReturn(uNextOperationWeight >= 1, E_INVALIDARG); 1825 1826 AssertPtrReturn(pHlp, VERR_INVALID_POINTER); 1827 AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER); 1828 1829 return pProgress->SetNextOperation(Bstr(pcszNextOperationDescription).raw(), uNextOperationWeight); 1830 } 1831 1832 /*static*/ DECLCALLBACK(uint32_t) 1833 ExtPack::i_hlpCompleteProgress(PCVBOXEXTPACKHLP pHlp, VBOXEXTPACK_IF_CS(IProgress) *pProgress, 1834 uint32_t uResultCode) 1835 { 1836 /* 1837 * Validate the input and get our bearings. 1838 */ 1839 AssertPtrReturn(pProgress, E_INVALIDARG); 1840 1841 AssertPtrReturn(pHlp, VERR_INVALID_POINTER); 1842 AssertReturn(pHlp->u32Version == VBOXEXTPACKHLP_VERSION, VERR_INVALID_POINTER); 1843 1844 Progress *pProgressInt = static_cast<Progress *>(pProgress); 1845 return pProgressInt->i_notifyComplete(uResultCode); 1846 } 1847 1725 1848 /*static*/ DECLCALLBACK(int) 1726 1849 ExtPack::i_hlpReservedN(PCVBOXEXTPACKHLP pHlp) … … 2005 2128 HRESULT hrc2 = NewExtPack.createObject(); 2006 2129 if (SUCCEEDED(hrc2)) 2007 hrc2 = NewExtPack->initWithDir(a_ enmContext, pstrName->c_str(), szExtPackDir);2130 hrc2 = NewExtPack->initWithDir(a_pVirtualBox, a_enmContext, pstrName->c_str(), szExtPackDir); 2008 2131 delete pstrName; 2009 2132 if (SUCCEEDED(hrc2)) … … 2590 2713 hrc = ptrNewExtPack.createObject(); 2591 2714 if (SUCCEEDED(hrc)) 2592 hrc = ptrNewExtPack->initWithDir(m-> enmContext, a_pszName, szDir);2715 hrc = ptrNewExtPack->initWithDir(m->pVirtualBox, m->enmContext, a_pszName, szDir); 2593 2716 if (SUCCEEDED(hrc)) 2594 2717 {
Note:
See TracChangeset
for help on using the changeset viewer.