VirtualBox

Changeset 51556 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jun 5, 2014 2:38:31 PM (11 years ago)
Author:
vboxsync
Message:

DnD: Added support for dynamically managing formats on the host.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r51551 r51556  
    1039310393
    1039410394  <interface
    10395     name="IDnDSource" extends="$unknown"
    10396     uuid="6bdc3f97-f6df-4357-b252-5fa16e0c1e24"
     10395    name="IDnDBase" extends="$unknown"
     10396    uuid="b15cf9ca-4078-4786-a1be-af773a36e19f"
     10397    wsmap="managed"
     10398    >
     10399    <desc>Base abstract interface for drag'n drop.</desc>
     10400
     10401    <method name="isFormatSupported" >
     10402      <desc>
     10403        Checks if a specific drag'n drop MIME / Content-type format is supported.
     10404      </desc>
     10405      <param name="format" type="wstring" dir="in">
     10406        <desc>Format to check for.</desc>
     10407      </param>
     10408      <param name="supported" type="boolean" dir="return">
     10409        <desc>Returns @c true if the specified format is supported, @c false if not.</desc>
     10410      </param>
     10411    </method>
     10412
     10413    <method name="addFormats" >
     10414      <desc>
     10415        Adds MIME / Content-type formats to the supported formats.
     10416      </desc>
     10417      <param name="formats" type="wstring" safearray="yes" dir="in">
     10418        <desc>Collection of formats to add.</desc>
     10419      </param>
     10420    </method>
     10421
     10422    <method name="removeFormats" >
     10423      <desc>
     10424        Removes MIME / Content-type formats from the supported formats.
     10425      </desc>
     10426      <param name="formats" type="wstring" safearray="yes" dir="in">
     10427        <desc>Collection of formats to remove.</desc>
     10428      </param>
     10429    </method>
     10430
     10431    <attribute name="formats" type="wstring" safearray="yes" readonly="yes">
     10432      <desc>Returns all supported drag'n drop formats.</desc>
     10433    </attribute>
     10434
     10435  </interface>
     10436
     10437  <interface
     10438    name="IDnDSource" extends="IDnDBase"
     10439    uuid="b69c400d-be63-4255-898a-e706d66b1637"
    1039710440    wsmap="managed"
    1039810441    >
     
    1047310516
    1047410517  <interface
    10475     name="IDnDTarget" extends="$unknown"
    10476     uuid="50862c12-7618-4542-a7c7-6a21de2644f7"
     10518    name="IDnDTarget" extends="IDnDBase"
     10519    uuid="2366c45c-4633-41a1-9fa6-0ef9f244434c"
    1047710520    wsmap="managed"
    1047810521    >
  • trunk/src/VBox/Main/include/GuestDirectoryImpl.h

    r51321 r51556  
    6464     * @{ */
    6565    /** @}  */
    66      HRESULT close();
    67      HRESULT read(ComPtr<IFsObjInfo> &aObjInfo);
     66    HRESULT close();
     67    HRESULT read(ComPtr<IFsObjInfo> &aObjInfo);
    6868
    6969    struct Data
  • trunk/src/VBox/Main/include/GuestDnDPrivate.h

    r51476 r51556  
    139139    int                        hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const;
    140140    GuestDnDResponse          *response(void) { return m_pResponse; }
    141     std::vector<com::Utf8Str>  supportedFormats(void) const { return m_strSupportedFormats; }
     141    std::vector<com::Utf8Str>  defaultFormats(void) const { return m_strDefaultFormats; }
    142142    /** @}  */
    143143
     
    163163    /** @name Singleton properties.
    164164     * @{ */
    165     /** List of supported MIME types (formats). */
    166     std::vector<com::Utf8Str>  m_strSupportedFormats;
     165    /** List of supported default MIME/Content-type formats. */
     166    std::vector<com::Utf8Str>  m_strDefaultFormats;
    167167    /** Pointer to guest implementation. */
    168168    const ComObjPtr<Guest>     m_pGuest;
     
    192192#define GuestDnDInst() GuestDnD::getInstance()
    193193
     194/**
     195 * IDnDBase class implementation for sharing code between
     196 * IGuestDnDSource and IGuestDnDTarget implementation.
     197 */
     198class GuestDnDBase
     199{
     200protected:
     201
     202    GuestDnDBase(void);
     203
     204protected:
     205
     206    /** Shared IDnDBase method implementations.
     207     * @{ */
     208    HRESULT isFormatSupported(const com::Utf8Str &aFormat, BOOL *aSupported);
     209    HRESULT getFormats(std::vector<com::Utf8Str> &aFormats);
     210    HRESULT addFormats(const std::vector<com::Utf8Str> &aFormats);
     211    HRESULT removeFormats(const std::vector<com::Utf8Str> &aFormats);
     212    /** @}  */
     213
     214protected:
     215
     216    /** @name Attributes.
     217     * @{ */
     218    /** Pointer to guest implementation. */
     219    const ComObjPtr<Guest>     m_pGuest;
     220    /** List of supported MIME/Content-type formats. */
     221    std::vector<com::Utf8Str>  m_strFormats;
     222    /** @}  */
     223};
     224
    194225#endif /* ____H_GUESTDNDPRIVATE */
    195226
  • trunk/src/VBox/Main/include/GuestDnDSourceImpl.h

    r51476 r51556  
    2323
    2424class ATL_NO_VTABLE GuestDnDSource :
    25     public GuestDnDSourceWrap
     25    public GuestDnDSourceWrap,
     26    protected GuestDnDBase
    2627{
    2728public:
     
    3940private:
    4041
    41     /** Wrapped @name IDnDSource methods.
     42    /** Private wrapped @name IDnDBase methods.
     43     * @{ */
     44    HRESULT isFormatSupported(const com::Utf8Str &aFormat, BOOL *aSupported);
     45    HRESULT getFormats(std::vector<com::Utf8Str> &aFormats);
     46    HRESULT addFormats(const std::vector<com::Utf8Str> &aFormats);
     47    HRESULT removeFormats(const std::vector<com::Utf8Str> &aFormats);
     48    /** @}  */
     49
     50    /** Private wrapped @name IDnDSource methods.
    4251     * @{ */
    4352    HRESULT dragIsPending(ULONG uScreenId, std::vector<com::Utf8Str> &aFormats, std::vector<DnDAction_T> &aAllowedActions, DnDAction_T *aDefaultAction);
  • trunk/src/VBox/Main/include/GuestDnDTargetImpl.h

    r51476 r51556  
    2323
    2424class ATL_NO_VTABLE GuestDnDTarget :
    25     public GuestDnDTargetWrap
     25    public GuestDnDTargetWrap,
     26    protected GuestDnDBase
    2627{
    2728public:
     
    3940private:
    4041
    41     /** Wrapped @name IDnDTarget methods.
     42    /** Private wrapped @name IDnDBase methods.
     43     * @{ */
     44    HRESULT isFormatSupported(const com::Utf8Str &aFormat, BOOL *aSupported);
     45    HRESULT getFormats(std::vector<com::Utf8Str> &aFormats);
     46    HRESULT addFormats(const std::vector<com::Utf8Str> &aFormats);
     47    HRESULT removeFormats(const std::vector<com::Utf8Str> &aFormats);
     48    /** @}  */
     49
     50    /** Private wrapped @name IDnDTarget methods.
    4251     * @{ */
    4352    HRESULT enter(ULONG aScreenId, ULONG ax, ULONG aY, DnDAction_T aDefaultAction, const std::vector<DnDAction_T> &aAllowedActions, const std::vector<com::Utf8Str> &aFormats, DnDAction_T *aResultAction);
  • trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp

    r51529 r51556  
    449449    m_pResponse = new GuestDnDResponse(pGuest);
    450450
    451     /* List of supported MIME types.
    452      * Note: If you add something here, make sure you test it with all supported guest OSes!
    453      ** @todo Make this MIME list configurable / extendable (by extra data?). Currently
    454      *        this is done hardcoded on every guest platform (*NIX/Windows).
    455      */
    456     const com::Utf8Str arrEntries[] = {
    457         "text/uri-list",
    458         /* Text */
    459         "text/plain;charset=utf-8",
    460         "UTF8_STRING",
    461         "text/plain",
    462         "TEXT",
    463         "STRING",
    464         /* OpenOffice formats */
    465         "application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"",
    466         "application/x-openoffice-drawing;windows_formatname=\"Drawing Format\"",
    467     };
    468 
     451    /* List of supported default MIME types. */
     452    const com::Utf8Str arrEntries[] = { VBOX_DND_FORMATS_DEFAULT };
    469453    for (size_t i = 0; i < RT_ELEMENTS(arrEntries); i++)
    470         m_strSupportedFormats.push_back(arrEntries[0]);
     454        m_strDefaultFormats.push_back(arrEntries[i]);
    471455}
    472456
     
    841825# endif /* VBOX_WITH_DRAG_AND_DROP_GH */
    842826
     827///////////////////////////////////////////////////////////////////////////////
     828
     829GuestDnDBase::GuestDnDBase(void)
     830{
     831    m_strFormats = GuestDnDInst()->defaultFormats();
     832}
     833
     834HRESULT GuestDnDBase::isFormatSupported(const com::Utf8Str &aFormat, BOOL *aSupported)
     835{
     836    *aSupported = std::find(m_strFormats.begin(),
     837                            m_strFormats.end(), aFormat) != m_strFormats.end()
     838                ? TRUE : FALSE;
     839    return S_OK;
     840}
     841
     842HRESULT GuestDnDBase::getFormats(std::vector<com::Utf8Str> &aFormats)
     843{
     844    aFormats = m_strFormats;
     845
     846    return S_OK;
     847}
     848
     849HRESULT GuestDnDBase::addFormats(const std::vector<com::Utf8Str> &aFormats)
     850{
     851    for (size_t i = 0; i < aFormats.size(); ++i)
     852    {
     853        Utf8Str strFormat = aFormats.at(i);
     854        if (std::find(m_strFormats.begin(),
     855                      m_strFormats.end(), strFormat) == m_strFormats.end())
     856        {
     857            m_strFormats.push_back(strFormat);
     858        }
     859    }
     860
     861    return S_OK;
     862}
     863
     864HRESULT GuestDnDBase::removeFormats(const std::vector<com::Utf8Str> &aFormats)
     865{
     866    for (size_t i = 0; i < aFormats.size(); ++i)
     867    {
     868        Utf8Str strFormat = aFormats.at(i);
     869        std::vector<com::Utf8Str>::iterator itFormat = std::find(m_strFormats.begin(),
     870                                                                 m_strFormats.end(), strFormat);
     871        if (itFormat != m_strFormats.end())
     872            m_strFormats.erase(itFormat);
     873    }
     874
     875    return S_OK;
     876}
     877
    843878#endif /* VBOX_WITH_DRAG_AND_DROP */
    844879
  • trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp

    r51489 r51556  
    9292}
    9393
    94 // implementation of wrapped private getters/setters for attributes
     94// implementation of wrapped IDnDBase methods.
     95/////////////////////////////////////////////////////////////////////////////
     96
     97HRESULT GuestDnDSource::isFormatSupported(const com::Utf8Str &aFormat,
     98                                          BOOL *aSupported)
     99{
     100#if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH)
     101    ReturnComNotImplemented();
     102#else /* VBOX_WITH_DRAG_AND_DROP */
     103
     104    return GuestDnDBase::isFormatSupported(aFormat, aSupported);
     105#endif /* VBOX_WITH_DRAG_AND_DROP */
     106}
     107
     108HRESULT GuestDnDSource::getFormats(std::vector<com::Utf8Str> &aFormats)
     109{
     110#if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH)
     111    ReturnComNotImplemented();
     112#else /* VBOX_WITH_DRAG_AND_DROP */
     113
     114    return GuestDnDBase::getFormats(aFormats);
     115#endif /* VBOX_WITH_DRAG_AND_DROP */
     116}
     117
     118HRESULT GuestDnDSource::addFormats(const std::vector<com::Utf8Str> &aFormats)
     119{
     120#if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH)
     121    ReturnComNotImplemented();
     122#else /* VBOX_WITH_DRAG_AND_DROP */
     123
     124    return GuestDnDBase::addFormats(aFormats);
     125#endif /* VBOX_WITH_DRAG_AND_DROP */
     126}
     127
     128HRESULT GuestDnDSource::removeFormats(const std::vector<com::Utf8Str> &aFormats)
     129{
     130#if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH)
     131    ReturnComNotImplemented();
     132#else /* VBOX_WITH_DRAG_AND_DROP */
     133
     134    return GuestDnDBase::removeFormats(aFormats);
     135#endif /* VBOX_WITH_DRAG_AND_DROP */
     136}
     137
     138// implementation of wrapped IDnDTarget methods.
    95139/////////////////////////////////////////////////////////////////////////////
    96140
     
    135179                defaultAction = GuestDnD::toMainAction(pResp->defAction());
    136180
    137                 GuestDnD::toFormatVector(GuestDnDInst()->supportedFormats(),
    138                                          pResp->format(), aFormats);
     181                GuestDnD::toFormatVector(m_strFormats, pResp->format(), aFormats);
    139182                GuestDnD::toMainActions(pResp->allActions(), aAllowedActions);
    140183            }
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r51489 r51556  
    2626#include "AutoCaller.h"
    2727
     28#include <algorithm> /* For std::find(). */
    2829#include <iprt/cpp/utils.h> /* For unconst(). */
    2930
     
    9091}
    9192
    92 // implementation of wrapped private getters/setters for attributes
     93// implementation of wrapped IDnDBase methods.
     94/////////////////////////////////////////////////////////////////////////////
     95
     96HRESULT GuestDnDTarget::isFormatSupported(const com::Utf8Str &aFormat,
     97                                          BOOL *aSupported)
     98{
     99#if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH)
     100    ReturnComNotImplemented();
     101#else /* VBOX_WITH_DRAG_AND_DROP */
     102
     103    return GuestDnDBase::isFormatSupported(aFormat, aSupported);
     104#endif /* VBOX_WITH_DRAG_AND_DROP */
     105}
     106
     107HRESULT GuestDnDTarget::getFormats(std::vector<com::Utf8Str> &aFormats)
     108{
     109#if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH)
     110    ReturnComNotImplemented();
     111#else /* VBOX_WITH_DRAG_AND_DROP */
     112
     113    return GuestDnDBase::getFormats(aFormats);
     114#endif /* VBOX_WITH_DRAG_AND_DROP */
     115}
     116
     117HRESULT GuestDnDTarget::addFormats(const std::vector<com::Utf8Str> &aFormats)
     118{
     119#if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH)
     120    ReturnComNotImplemented();
     121#else /* VBOX_WITH_DRAG_AND_DROP */
     122
     123    return GuestDnDBase::addFormats(aFormats);
     124#endif /* VBOX_WITH_DRAG_AND_DROP */
     125}
     126
     127HRESULT GuestDnDTarget::removeFormats(const std::vector<com::Utf8Str> &aFormats)
     128{
     129#if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH)
     130    ReturnComNotImplemented();
     131#else /* VBOX_WITH_DRAG_AND_DROP */
     132
     133    return GuestDnDBase::removeFormats(aFormats);
     134#endif /* VBOX_WITH_DRAG_AND_DROP */
     135}
     136
     137// implementation of wrapped IDnDTarget methods.
    93138/////////////////////////////////////////////////////////////////////////////
    94139
     
    127172
    128173    /* Make a flat data string out of the supported format list. */
    129     Utf8Str strFormats = GuestDnD::toFormatString(GuestDnDInst()->supportedFormats(),
    130                                                   aFormats);
     174    Utf8Str strFormats = GuestDnD::toFormatString(m_strFormats, aFormats);
    131175    /* If there is no valid supported format, ignore this request. */
    132176    if (strFormats.isEmpty())
     
    195239
    196240    /* Make a flat data string out of the supported format list. */
    197     RTCString strFormats = GuestDnD::toFormatString(GuestDnDInst()->supportedFormats(),
    198                                                     aFormats);
     241    RTCString strFormats = GuestDnD::toFormatString(m_strFormats, aFormats);
    199242    /* If there is no valid supported format, ignore this request. */
    200243    if (strFormats.isEmpty())
     
    288331
    289332    /* Make a flat data string out of the supported format list. */
    290     Utf8Str strFormats = GuestDnD::toFormatString(GuestDnDInst()->supportedFormats(),
    291                                                   aFormats);
     333    Utf8Str strFormats = GuestDnD::toFormatString(m_strFormats, aFormats);
    292334    /* If there is no valid supported format, ignore this request. */
    293335    if (strFormats.isEmpty())
Note: See TracChangeset for help on using the changeset viewer.

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