VirtualBox

Changeset 34714 in vbox


Ignore:
Timestamp:
Dec 3, 2010 10:19:31 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
68517
Message:

ExtPackManager: Added API for opening a tarball prior to installation (does not work yet).

Location:
trunk/src/VBox/Main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ExtPackManagerImpl.cpp

    r34711 r34714  
    6464*   Structures and Typedefs                                                    *
    6565*******************************************************************************/
    66 /**
    67  * Private extension pack data.
    68  */
    69 struct ExtPack::Data
     66struct ExtPackBaseData
    7067{
    7168public:
     
    7976    /** Why it is unusable. */
    8077    Utf8Str             strWhyUnusable;
    81 
     78};
     79
     80/**
     81 * Private extension pack data.
     82 */
     83struct ExtPackFile::Data : public ExtPackBaseData
     84{
     85public:
     86    /** The path to the tarball. */
     87    Utf8Str             strExtPackFile;
     88    /** The file handle of the extension pack file. */
     89    RTFILE              hExtPackFile;
     90};
     91
     92/**
     93 * Private extension pack data.
     94 */
     95struct ExtPack::Data : public ExtPackBaseData
     96{
     97public:
    8298    /** Where the extension pack is located. */
    8399    Utf8Str             strExtPackPath;
     
    128144    VBOXEXTPACKCTX      enmContext;
    129145};
     146
     147
     148DEFINE_EMPTY_CTOR_DTOR(ExtPackFile)
     149
     150/**
     151 * Called by ComObjPtr::createObject when creating the object.
     152 *
     153 * Just initialize the basic object state, do the rest in initWithDir().
     154 *
     155 * @returns S_OK.
     156 */
     157HRESULT ExtPackFile::FinalConstruct()
     158{
     159    m = NULL;
     160    return S_OK;
     161}
     162
     163/**
     164 * Initializes the extension pack by reading its file.
     165 *
     166 * @returns COM status code.
     167 * @param   a_pszFile       The path to the extension pack file.
     168 */
     169HRESULT ExtPackFile::initWithFile(const char *a_pszFile)
     170{
     171    AutoInitSpan autoInitSpan(this);
     172    AssertReturn(autoInitSpan.isOk(), E_FAIL);
     173
     174    /*
     175     * Allocate + initialize our private data.
     176     */
     177    m = new ExtPackFile::Data;
     178    m->Desc.strName                 = NULL;
     179    RT_ZERO(m->ObjInfoDesc);
     180    m->fUsable                      = false;
     181    m->strWhyUnusable               = tr("ExtPack::init failed");
     182    m->strExtPackFile               = a_pszFile;
     183
     184    /*
     185     * Probe the extension pack (this code is shared with refresh()).
     186     */
     187
     188    autoInitSpan.setSucceeded();
     189    return S_OK;
     190}
     191
     192/**
     193 * COM cruft.
     194 */
     195void ExtPackFile::FinalRelease()
     196{
     197    uninit();
     198}
     199
     200/**
     201 * Do the actual cleanup.
     202 */
     203void ExtPackFile::uninit()
     204{
     205    /* Enclose the state transition Ready->InUninit->NotReady */
     206    AutoUninitSpan autoUninitSpan(this);
     207    if (!autoUninitSpan.uninitDone() && m != NULL)
     208    {
     209        VBoxExtPackFreeDesc(&m->Desc);
     210
     211        delete m;
     212        m = NULL;
     213    }
     214}
     215
     216STDMETHODIMP ExtPackFile::COMGETTER(Name)(BSTR *a_pbstrName)
     217{
     218    CheckComArgOutPointerValid(a_pbstrName);
     219
     220    AutoCaller autoCaller(this);
     221    HRESULT hrc = autoCaller.rc();
     222    if (SUCCEEDED(hrc))
     223    {
     224        Bstr str(m->Desc.strName);
     225        str.cloneTo(a_pbstrName);
     226    }
     227    return hrc;
     228}
     229
     230STDMETHODIMP ExtPackFile::COMGETTER(Description)(BSTR *a_pbstrDescription)
     231{
     232    CheckComArgOutPointerValid(a_pbstrDescription);
     233
     234    AutoCaller autoCaller(this);
     235    HRESULT hrc = autoCaller.rc();
     236    if (SUCCEEDED(hrc))
     237    {
     238        Bstr str(m->Desc.strDescription);
     239        str.cloneTo(a_pbstrDescription);
     240    }
     241    return hrc;
     242}
     243
     244STDMETHODIMP ExtPackFile::COMGETTER(Version)(BSTR *a_pbstrVersion)
     245{
     246    CheckComArgOutPointerValid(a_pbstrVersion);
     247
     248    AutoCaller autoCaller(this);
     249    HRESULT hrc = autoCaller.rc();
     250    if (SUCCEEDED(hrc))
     251    {
     252        Bstr str(m->Desc.strVersion);
     253        str.cloneTo(a_pbstrVersion);
     254    }
     255    return hrc;
     256}
     257
     258STDMETHODIMP ExtPackFile::COMGETTER(Revision)(ULONG *a_puRevision)
     259{
     260    CheckComArgOutPointerValid(a_puRevision);
     261
     262    AutoCaller autoCaller(this);
     263    HRESULT hrc = autoCaller.rc();
     264    if (SUCCEEDED(hrc))
     265        *a_puRevision = m->Desc.uRevision;
     266    return hrc;
     267}
     268
     269STDMETHODIMP ExtPackFile::COMGETTER(VRDEModule)(BSTR *a_pbstrVrdeModule)
     270{
     271    CheckComArgOutPointerValid(a_pbstrVrdeModule);
     272
     273    AutoCaller autoCaller(this);
     274    HRESULT hrc = autoCaller.rc();
     275    if (SUCCEEDED(hrc))
     276    {
     277        Bstr str(m->Desc.strVrdeModule);
     278        str.cloneTo(a_pbstrVrdeModule);
     279    }
     280    return hrc;
     281}
     282
     283STDMETHODIMP ExtPackFile::COMGETTER(PlugIns)(ComSafeArrayOut(IExtPackPlugIn *, a_paPlugIns))
     284{
     285    /** @todo implement plug-ins. */
     286#ifdef VBOX_WITH_XPCOM
     287    NOREF(a_paPlugIns);
     288    NOREF(a_paPlugInsSize);
     289#endif
     290    ReturnComNotImplemented();
     291}
     292
     293STDMETHODIMP ExtPackFile::COMGETTER(Usable)(BOOL *a_pfUsable)
     294{
     295    CheckComArgOutPointerValid(a_pfUsable);
     296
     297    AutoCaller autoCaller(this);
     298    HRESULT hrc = autoCaller.rc();
     299    if (SUCCEEDED(hrc))
     300        *a_pfUsable = m->fUsable;
     301    return hrc;
     302}
     303
     304STDMETHODIMP ExtPackFile::COMGETTER(WhyUnusable)(BSTR *a_pbstrWhy)
     305{
     306    CheckComArgOutPointerValid(a_pbstrWhy);
     307
     308    AutoCaller autoCaller(this);
     309    HRESULT hrc = autoCaller.rc();
     310    if (SUCCEEDED(hrc))
     311        m->strWhyUnusable.cloneTo(a_pbstrWhy);
     312    return hrc;
     313}
     314
     315STDMETHODIMP ExtPackFile::COMGETTER(FilePath)(BSTR *a_pbstrPath)
     316{
     317    CheckComArgOutPointerValid(a_pbstrPath);
     318
     319    AutoCaller autoCaller(this);
     320    HRESULT hrc = autoCaller.rc();
     321    if (SUCCEEDED(hrc))
     322        m->strExtPackFile.cloneTo(a_pbstrPath);
     323    return hrc;
     324}
     325
     326STDMETHODIMP ExtPackFile::Install(void)
     327{
     328    return E_NOTIMPL;
     329}
     330
     331
     332
    130333
    131334
     
    13241527}
    13251528
     1529STDMETHODIMP ExtPackManager::OpenExtPackFile(IN_BSTR a_bstrTarball, IExtPackFile **a_ppExtPackFile)
     1530{
     1531    CheckComArgNotNull(a_bstrTarball);
     1532    CheckComArgOutPointerValid(a_ppExtPackFile);
     1533    Utf8Str strTarball(a_bstrTarball);
     1534    AssertReturn(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON, E_UNEXPECTED);
     1535
     1536    return E_NOTIMPL;
     1537}
     1538
    13261539STDMETHODIMP ExtPackManager::Install(IN_BSTR a_bstrTarball, BSTR *a_pbstrName)
    13271540{
     
    13291542    CheckComArgOutPointerValid(a_pbstrName);
    13301543    Utf8Str strTarball(a_bstrTarball);
    1331     Assert(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON);
     1544    AssertReturn(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON, E_UNEXPECTED);
    13321545
    13331546    AutoCaller autoCaller(this);
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r34709 r34714  
    1433414334
    1433514335  <interface
    14336     name="IExtPack" extends="$unknown"
    14337     uuid="94564309-5966-419a-81cc-4aec0b6dbd4d"
     14336    name="IExtPackBase" extends="$unknown"
     14337    uuid="58304368-f78a-418c-8fec-d9e4e588d797"
    1433814338    wsmap="suppress"
    1433914339    >
     
    1436714367    <attribute name="usable" type="boolean" readonly="yes">
    1436814368      <desc>
    14369         Indicates whether the extension pack is usable or not.  An
    14370         extension pack that is not compatible with the current VirtualBox
    14371         version will be flagged as not usable.
     14369        Indicates whether the extension pack is usable or not.
     14370
     14371        There are a number of reasons why an extension pack might be unusable,
     14372        typical examples would be broken installation/file or that it is
     14373        incompatible with the current VirtualBox version.
    1437214374      </desc>
    1437314375    </attribute>
     
    1437814380      </desc>
    1437914381    </attribute>
     14382  </interface>
     14383
     14384  <interface
     14385    name="IExtPack" extends="IExtPackBase"
     14386    uuid="60f0c30f-c773-4d3e-9580-3ffa47c24e95"
     14387    wsmap="suppress"
     14388    >
     14389    <desc>
     14390      Interface for querying information about an extension pack as well as
     14391      accessing COM objects within it.
     14392    </desc>
    1438014393    <method name="queryObject">
    1438114394      <desc>
     
    1439414407
    1439514408  <interface
     14409    name="IExtPackFile" extends="IExtPackBase"
     14410    uuid="58509cab-f905-4acb-8087-ba0ab80d8038"
     14411    wsmap="suppress"
     14412    >
     14413    <desc>
     14414      Extension pack file (aka tarball, .vbox-extpack) representation returned
     14415      by IExtPackManager::openExtPackFile.  This provides the base extension
     14416      pack information with the addition of the file name.  It also provides an
     14417      alternative to IExtPackManager::install.
     14418    </desc>
     14419    <attribute name="filePath" type="wstring" readonly="yes">
     14420      <desc>
     14421        The path to the extension pack file.
     14422      </desc>
     14423    </attribute>
     14424
     14425    <method name="install">
     14426      <desc>
     14427        Install the extension pack.
     14428      </desc>
     14429    </method>
     14430  </interface>
     14431
     14432  <interface
    1439614433    name="IExtPackManager" extends="$unknown"
    14397     uuid="bc386406-2637-454b-8d55-021f9e20445a"
     14434    uuid="8104df65-74d6-4e33-b374-50aa062b4afd"
    1439814435    wsmap="suppress"
    1439914436    >
     
    1442714464    </method>
    1442814465
     14466    <method name="openExtPackFile">
     14467      <desc>
     14468        Attempts to open an extension pack file in preparation for
     14469        installation.
     14470      </desc>
     14471      <param name="path" type="wstring" dir="in">
     14472        <desc>The path of the extension pack tarball.</desc>
     14473      </param>
     14474      <param name="file" type="IExtPackFile" dir="return">
     14475        <desc>The interface of the extension pack file object.</desc>
     14476      </param>
     14477    </method>
     14478
    1442914479    <method name="install">
     14480      <desc>
     14481        Please use openExtPackFile + IExtPackFile::install instead of this
     14482        interface.   This will be removed later in the beta cycle.
     14483      </desc>
    1443014484      <param name="path" type="wstring" dir="in">
    1443114485        <desc>The path of the extension pack tarball.</desc>
     
    1446314517        <desc>The name of the frontend or component.</desc>
    1446414518      </param>
    14465       <param name="plugInModules" type="wstring" dir="out" safearray="yes">
     14519      <param name="plugInModules" type="wstring" dir="return" safearray="yes">
    1446614520        <desc>Array containing the plug-in modules (full paths).</desc>
    1446714521      </param>
  • trunk/src/VBox/Main/include/ExtPackManagerImpl.h

    r34579 r34714  
    2323#include <iprt/fs.h>
    2424
    25 
    2625/**
    27  * An extension pack.
    28  *
    29  * This
    30  */
    31 class ATL_NO_VTABLE ExtPack :
     26 * An extension pack file.
     27 */
     28class ATL_NO_VTABLE ExtPackFile :
    3229    public VirtualBoxBase,
    33     VBOX_SCRIPTABLE_IMPL(IExtPack)
     30    VBOX_SCRIPTABLE_IMPL(IExtPackFile)
    3431{
    3532public:
    3633    /** @name COM and internal init/term/mapping cruft.
    3734     * @{ */
    38     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPack, IExtPack)
    39     DECLARE_NOT_AGGREGATABLE(ExtPack)
     35    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPackFile, IExtPackFile)
     36    DECLARE_NOT_AGGREGATABLE(ExtPackFile)
    4037    DECLARE_PROTECT_FINAL_CONSTRUCT()
    41     BEGIN_COM_MAP(ExtPack)
     38    BEGIN_COM_MAP(ExtPackFile)
    4239        COM_INTERFACE_ENTRY(ISupportErrorInfo)
    43         COM_INTERFACE_ENTRY(IExtPack)
     40        COM_INTERFACE_ENTRY(IExtPackFile)
     41        COM_INTERFACE_ENTRY(IExtPackBase)
    4442        COM_INTERFACE_ENTRY(IDispatch)
    4543    END_COM_MAP()
    46     DECLARE_EMPTY_CTOR_DTOR(ExtPack)
     44    DECLARE_EMPTY_CTOR_DTOR(ExtPackFile)
    4745
    4846    HRESULT     FinalConstruct();
    4947    void        FinalRelease();
    50     HRESULT     initWithDir(VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir);
     48    HRESULT     initWithFile(const char *a_pszFile);
    5149    void        uninit();
    5250    /** @}  */
    5351
    54     /** @name IExtPack interfaces
     52    /** @name IExtPackBase interfaces
    5553     * @{ */
    5654    STDMETHOD(COMGETTER(Name))(BSTR *a_pbstrName);
     
    6260    STDMETHOD(COMGETTER(Usable))(BOOL *a_pfUsable);
    6361    STDMETHOD(COMGETTER(WhyUnusable))(BSTR *a_pbstrWhy);
     62    /** @}  */
     63
     64    /** @name IExtPackFile interfaces
     65     * @{ */
     66    STDMETHOD(COMGETTER(FilePath))(BSTR *a_pbstrPath);
     67    STDMETHOD(Install)(void);
     68    /** @}  */
     69
     70private:
     71    struct Data;
     72    /** Pointer to the private instance. */
     73    Data *m;
     74
     75    friend class ExtPackManager;
     76};
     77
     78
     79/**
     80 * An installed extension pack.
     81 */
     82class ATL_NO_VTABLE ExtPack :
     83    public VirtualBoxBase,
     84    VBOX_SCRIPTABLE_IMPL(IExtPack)
     85{
     86public:
     87    /** @name COM and internal init/term/mapping cruft.
     88     * @{ */
     89    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ExtPack, IExtPack)
     90    DECLARE_NOT_AGGREGATABLE(ExtPack)
     91    DECLARE_PROTECT_FINAL_CONSTRUCT()
     92    BEGIN_COM_MAP(ExtPack)
     93        COM_INTERFACE_ENTRY(ISupportErrorInfo)
     94        COM_INTERFACE_ENTRY(IExtPack)
     95        COM_INTERFACE_ENTRY(IExtPackBase)
     96        COM_INTERFACE_ENTRY(IDispatch)
     97    END_COM_MAP()
     98    DECLARE_EMPTY_CTOR_DTOR(ExtPack)
     99
     100    HRESULT     FinalConstruct();
     101    void        FinalRelease();
     102    HRESULT     initWithDir(VBOXEXTPACKCTX a_enmContext, const char *a_pszName, const char *a_pszDir);
     103    void        uninit();
     104    /** @}  */
     105
     106    /** @name IExtPackBase interfaces
     107     * @{ */
     108    STDMETHOD(COMGETTER(Name))(BSTR *a_pbstrName);
     109    STDMETHOD(COMGETTER(Description))(BSTR *a_pbstrDescription);
     110    STDMETHOD(COMGETTER(Version))(BSTR *a_pbstrVersion);
     111    STDMETHOD(COMGETTER(Revision))(ULONG *a_puRevision);
     112    STDMETHOD(COMGETTER(VRDEModule))(BSTR *a_pbstrVrdeModule);
     113    STDMETHOD(COMGETTER(PlugIns))(ComSafeArrayOut(IExtPackPlugIn *, a_paPlugIns));
     114    STDMETHOD(COMGETTER(Usable))(BOOL *a_pfUsable);
     115    STDMETHOD(COMGETTER(WhyUnusable))(BSTR *a_pbstrWhy);
     116    /** @}  */
     117
     118    /** @name IExtPack interfaces
     119     * @{ */
    64120    STDMETHOD(QueryObject)(IN_BSTR a_bstrObjectId, IUnknown **a_ppUnknown);
    65121    /** @}  */
     
    138194    STDMETHOD(COMGETTER(InstalledExtPacks))(ComSafeArrayOut(IExtPack *, a_paExtPacks));
    139195    STDMETHOD(Find)(IN_BSTR a_bstrName, IExtPack **a_pExtPack);
     196    STDMETHOD(OpenExtPackFile)(IN_BSTR a_bstrTarball, IExtPackFile **a_ppExtPackFile);
    140197    STDMETHOD(Install)(IN_BSTR a_bstrTarball, BSTR *a_pbstrName);
    141198    STDMETHOD(Uninstall)(IN_BSTR a_bstrName, BOOL a_fForcedRemoval);
  • trunk/src/VBox/Main/xpcom/module.cpp

    r34647 r34714  
    7777NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VRDEServerInfo, IVRDEServerInfo)
    7878#ifdef VBOX_WITH_EXTPACK
     79NS_DECL_CLASSINFO(ExtPackFile)
     80NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ExtPackFile, IExtPack)
    7981NS_DECL_CLASSINFO(ExtPack)
    8082NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ExtPack, IExtPack)
  • trunk/src/VBox/Main/xpcom/server.cpp

    r34587 r34714  
    207207
    208208#ifdef VBOX_WITH_EXTPACK
     209NS_DECL_CLASSINFO(ExtPackFile)
     210NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ExtPackFile, IExtPackFile)
     211
    209212NS_DECL_CLASSINFO(ExtPack)
    210213NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ExtPack, IExtPack)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette