dragdrophelper.c 7.47 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 *	file system folder
 *
 *	Copyright 1997			Marcus Meissner
 *	Copyright 1998, 1999, 2002	Juergen Schmied
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 21
 */

22
#include <stdarg.h>
23 24
#include <string.h>

25 26
#define COBJMACROS

27
#include "windef.h"
28 29
#include "winbase.h"
#include "winreg.h"
30 31
#include "wingdi.h"
#include "winuser.h"
32

33 34
#include "objbase.h"
#include "ole2.h"
35
#include "shlguid.h"
36
#include "shlobj.h"
37 38 39 40 41 42 43 44 45 46

#include "wine/debug.h"
#include "debughlp.h"

WINE_DEFAULT_DEBUG_CHANNEL (shell);

/***********************************************************************
*   IDropTargetHelper implementation
*/

47 48
typedef struct
{
49
    IDropTargetHelper IDropTargetHelper_iface;
50
    IDragSourceHelper2 IDragSourceHelper2_iface;
Mike McCormack's avatar
Mike McCormack committed
51
    LONG ref;
52 53 54 55 56 57
} dragdrophelper;

static inline dragdrophelper *impl_from_IDropTargetHelper(IDropTargetHelper *iface)
{
    return CONTAINING_RECORD(iface, dragdrophelper, IDropTargetHelper_iface);
}
58

59
static inline dragdrophelper *impl_from_IDragSourceHelper2(IDragSourceHelper2 *iface)
60
{
61
    return CONTAINING_RECORD(iface, dragdrophelper, IDragSourceHelper2_iface);
62
}
63 64 65 66 67 68

/**************************************************************************
 *	IDropTargetHelper_fnQueryInterface
 */
static HRESULT WINAPI IDropTargetHelper_fnQueryInterface (IDropTargetHelper * iface, REFIID riid, LPVOID * ppvObj)
{
69
    dragdrophelper *This = impl_from_IDropTargetHelper(iface);
70 71 72 73 74

    TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);

    *ppvObj = NULL;

75 76 77 78
    if (IsEqualIID (riid, &IID_IUnknown) || IsEqualIID (riid, &IID_IDropTargetHelper))
    {
        *ppvObj = &This->IDropTargetHelper_iface;
    }
79
    else if (IsEqualIID (riid, &IID_IDragSourceHelper) || IsEqualIID (riid, &IID_IDragSourceHelper2))
80
    {
81
        *ppvObj = &This->IDragSourceHelper2_iface;
82 83 84 85 86 87 88
    }

    if (*ppvObj) {
	IUnknown_AddRef ((IUnknown *) (*ppvObj));
	TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
	return S_OK;
    }
89
    FIXME ("%s: E_NOINTERFACE\n", shdebugstr_guid (riid));
90 91 92 93 94
    return E_NOINTERFACE;
}

static ULONG WINAPI IDropTargetHelper_fnAddRef (IDropTargetHelper * iface)
{
95
    dragdrophelper *This = impl_from_IDropTargetHelper(iface);
96
    ULONG refCount = InterlockedIncrement(&This->ref);
97

98
    TRACE ("(%p)->(count=%lu)\n", This, refCount - 1);
99

100
    return refCount;
101 102 103 104
}

static ULONG WINAPI IDropTargetHelper_fnRelease (IDropTargetHelper * iface)
{
105
    dragdrophelper *This = impl_from_IDropTargetHelper(iface);
106
    ULONG refCount = InterlockedDecrement(&This->ref);
107

108
    TRACE ("(%p)->(count=%lu)\n", This, refCount + 1);
109

110
    if (!refCount) {
111 112
        TRACE ("-- destroying (%p)\n", This);
        LocalFree (This);
113
        return 0;
114
    }
115
    return refCount;
116 117 118 119 120 121 122 123 124
}

static HRESULT WINAPI IDropTargetHelper_fnDragEnter (
        IDropTargetHelper * iface,
	HWND hwndTarget,
	IDataObject* pDataObject,
	POINT* ppt,
	DWORD dwEffect)
{
125
    dragdrophelper *This = impl_from_IDropTargetHelper(iface);
126
    FIXME ("(%p)->(%p %p %p 0x%08lx)\n", This,hwndTarget, pDataObject, ppt, dwEffect);
127 128 129 130 131
    return E_NOTIMPL;
}

static HRESULT WINAPI IDropTargetHelper_fnDragLeave (IDropTargetHelper * iface)
{
132
    dragdrophelper *This = impl_from_IDropTargetHelper(iface);
133 134 135 136 137 138
    FIXME ("(%p)->()\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI IDropTargetHelper_fnDragOver (IDropTargetHelper * iface, POINT* ppt, DWORD dwEffect)
{
139
    dragdrophelper *This = impl_from_IDropTargetHelper(iface);
140
    FIXME ("(%p)->(%p 0x%08lx)\n", This, ppt, dwEffect);
141 142 143 144 145
    return E_NOTIMPL;
}

static HRESULT WINAPI IDropTargetHelper_fnDrop (IDropTargetHelper * iface, IDataObject* pDataObject, POINT* ppt, DWORD dwEffect)
{
146
    dragdrophelper *This = impl_from_IDropTargetHelper(iface);
147
    FIXME ("(%p)->(%p %p 0x%08lx)\n", This, pDataObject, ppt, dwEffect);
148 149 150 151 152
    return E_NOTIMPL;
}

static HRESULT WINAPI IDropTargetHelper_fnShow (IDropTargetHelper * iface, BOOL fShow)
{
153
    dragdrophelper *This = impl_from_IDropTargetHelper(iface);
154
    FIXME ("(%p)->(%u)\n", This, fShow);
155
    return S_OK;
156 157
}

158
static const IDropTargetHelperVtbl DropTargetHelperVtbl =
159
{
160 161 162 163 164 165 166 167
    IDropTargetHelper_fnQueryInterface,
    IDropTargetHelper_fnAddRef,
    IDropTargetHelper_fnRelease,
    IDropTargetHelper_fnDragEnter,
    IDropTargetHelper_fnDragLeave,
    IDropTargetHelper_fnDragOver,
    IDropTargetHelper_fnDrop,
    IDropTargetHelper_fnShow
168
};
169

170
static HRESULT WINAPI DragSourceHelper2_QueryInterface (IDragSourceHelper2 * iface, REFIID riid, LPVOID * ppv)
171
{
172
    dragdrophelper *This = impl_from_IDragSourceHelper2(iface);
173 174 175
    return IDropTargetHelper_fnQueryInterface(&This->IDropTargetHelper_iface, riid, ppv);
}

176
static ULONG WINAPI DragSourceHelper2_AddRef (IDragSourceHelper2 * iface)
177
{
178
    dragdrophelper *This = impl_from_IDragSourceHelper2(iface);
179 180 181
    return IDropTargetHelper_fnAddRef(&This->IDropTargetHelper_iface);
}

182
static ULONG WINAPI DragSourceHelper2_Release (IDragSourceHelper2 * iface)
183
{
184
    dragdrophelper *This = impl_from_IDragSourceHelper2(iface);
185 186 187
    return IDropTargetHelper_fnRelease(&This->IDropTargetHelper_iface);
}

188
static HRESULT WINAPI DragSourceHelper2_InitializeFromBitmap(IDragSourceHelper2 *iface,
189 190
    SHDRAGIMAGE *dragimage, IDataObject *object)
{
191
    dragdrophelper *This = impl_from_IDragSourceHelper2(iface);
192 193 194 195 196 197

    FIXME("(%p)->(%p, %p): stub\n", This, dragimage, object);

    return E_NOTIMPL;
}

198
static HRESULT WINAPI DragSourceHelper2_InitializeFromWindow(IDragSourceHelper2 *iface, HWND hwnd,
199 200
    POINT *pt, IDataObject *object)
{
201
    dragdrophelper *This = impl_from_IDragSourceHelper2(iface);
202 203 204 205 206 207

    FIXME("(%p)->(%p, %s, %p): stub\n", This, hwnd, wine_dbgstr_point(pt), object);

    return E_NOTIMPL;
}

208
static HRESULT WINAPI DragSourceHelper2_SetFlags(IDragSourceHelper2 *iface, DWORD flags)
209
{
210 211
    dragdrophelper *This = impl_from_IDragSourceHelper2(iface);

212
    FIXME("(%p)->(%08lx): stub\n", This, flags);
213 214 215 216 217 218 219 220 221 222 223 224

    return S_OK;
}

static const IDragSourceHelper2Vtbl DragSourceHelper2Vtbl =
{
    DragSourceHelper2_QueryInterface,
    DragSourceHelper2_AddRef,
    DragSourceHelper2_Release,
    DragSourceHelper2_InitializeFromBitmap,
    DragSourceHelper2_InitializeFromWindow,
    DragSourceHelper2_SetFlags
225 226
};

227 228 229 230 231
/**************************************************************************
*	IDropTargetHelper_Constructor
*/
HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
{
232
    dragdrophelper *dth;
233 234 235 236 237 238 239 240 241
    HRESULT hr;

    TRACE ("outer=%p %s %p\n", pUnkOuter, shdebugstr_guid (riid), ppv);

    if (!ppv)
	return E_POINTER;
    if (pUnkOuter)
	return CLASS_E_NOAGGREGATION;

242
    dth = LocalAlloc (LMEM_ZEROINIT, sizeof (dragdrophelper));
243 244
    if (!dth) return E_OUTOFMEMORY;

245
    dth->IDropTargetHelper_iface.lpVtbl = &DropTargetHelperVtbl;
246
    dth->IDragSourceHelper2_iface.lpVtbl = &DragSourceHelper2Vtbl;
247 248 249 250 251 252 253
    dth->ref = 1;

    hr = IDropTargetHelper_QueryInterface (&dth->IDropTargetHelper_iface, riid, ppv);
    IDropTargetHelper_Release (&dth->IDropTargetHelper_iface);

    return hr;
}