shell32 (part1): IFileSystemBindData implementation
Rolf Kalbermatter
rolf.kalbermatter at citengineering.com
Thu Sep 11 13:51:28 CDT 2003
Changelog
- include/shlobj.h
Add declaration of IFileSystemBindData interface. This could eventually move to
shobjidl.idl as the other non conformant object definitions.
- dlls/shell32/shlfsbind.h
Declaration of some helper functions to use with IFileSystemBindData
- dlls/shell32/shlfsbind.c
IFileSystemBindData implementation
License: X11/LGPL
Rolf Kalbermatter
===================================================================
RCS file: /home/wine/wine/include/shlobj.h,v
retrieving revision 1.74
diff -u -r1.74 shlobj.h
--- include/shlobj.h 9 Sep 2003 19:32:36 -0000 1.74
+++ include/shlobj.h 11 Sep 2003 18:03:23 -0000
@@ -38,7 +38,6 @@
BOOL WINAPI SHGetPathFromIDListW (LPCITEMIDLIST pidl,LPWSTR pszPath);
#define SHGetPathFromIDList WINELIB_NAME_AW(SHGetPathFromIDList)
-
/*****************************************************************************
* Predeclare interfaces
*/
@@ -650,6 +649,84 @@
} DROPFILES, *LPDROPFILES;
#include <poppack.h>
+
+/*****************************************************************************
+ * IFileSystemBindData interface
+ */
+#ifndef __IFileSystemBindData_FWD_DEFINED__
+#define __IFileSystemBindData_FWD_DEFINED__
+typedef struct IFileSystemBindData IFileSystemBindData;
+#endif
+
+typedef IFileSystemBindData *LPFILESYSTEMBINDDATA;
+
+#ifndef __IFileSystemBindData_INTERFACE_DEFINED__
+#define __IFileSystemBindData_INTERFACE_DEFINED__
+
+DEFINE_GUID(IID_IFileSystemBindData, 0x01e18d10, 0x4d8b, 0x11d2, 0x85,0x5d, 0x00,0x60,0x08,0x05,0x93,0x67);
+#if defined(__cplusplus) && !defined(CINTERFACE)
+struct IFileSystemBindData : public IUnknown
+{
+ virtual HRESULT STDMETHODCALLTYPE GetFindData(
+ WIN32_FIND_DATAW* pfd) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetFindData(
+ const WIN32_FIND_DATAW* pfd) = 0;
+
+};
+#else
+typedef struct IFileSystemBindDataVtbl IFileSystemBindDataVtbl;
+struct IFileSystemBindData {
+ const IFileSystemBindDataVtbl* lpVtbl;
+};
+struct IFileSystemBindDataVtbl {
+ ICOM_MSVTABLE_COMPAT_FIELDS
+
+ /*** IUnknown methods ***/
+ HRESULT (STDMETHODCALLTYPE *QueryInterface)(
+ IFileSystemBindData* This,
+ REFIID riid,
+ void** ppvObject);
+
+ ULONG (STDMETHODCALLTYPE *AddRef)(
+ IFileSystemBindData* This);
+
+ ULONG (STDMETHODCALLTYPE *Release)(
+ IFileSystemBindData* This);
+
+ /*** IFileSystemBindData methods ***/
+ HRESULT (STDMETHODCALLTYPE *GetFindData)(
+ IFileSystemBindData* This,
+ WIN32_FIND_DATAW* pfd);
+
+ HRESULT (STDMETHODCALLTYPE *SetFindData)(
+ IFileSystemBindData* This,
+ const WIN32_FIND_DATAW* pfd);
+
+};
+
+/*** IUnknown methods ***/
+#define IFileSystemBindData_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IFileSystemBindData_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IFileSystemBindData_Release(p) (p)->lpVtbl->Release(p)
+/*** IFileSystemBindData methods ***/
+#define IFileSystemBindData_GetFindData(p,a) (p)->lpVtbl->GetFindData(p,a)
+#define IFileSystemBindData_SetFindData(p,a) (p)->lpVtbl->SetFindData(p,a)
+
+#endif
+
+#define IFileSystemBindData_METHODS \
+ ICOM_MSVTABLE_COMPAT_FIELDS \
+ /*** IUnknown methods ***/ \
+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; \
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE; \
+ STDMETHOD_(ULONG,Release)(THIS) PURE; \
+ /*** IFileSystemBindData methods ***/ \
+ STDMETHOD_(HRESULT,GetFindData)(THIS_ WIN32_FIND_DATAW* pfd) PURE; \
+ STDMETHOD_(HRESULT,SetFindData)(THIS_ const WIN32_FIND_DATAW* pfd) PURE;
+
+#endif /* __IFileSystemBindData_INTERFACE_DEFINED__ */
+
#ifdef __cplusplus
} /* extern "C" */
===================================================================
--- /dev/null 2003-03-14 14:07:09.000000000 +0100
+++ dlls/shell32/shlfsbind.h 2003-09-05 22:40:50.000000000 +0200
@@ -0,0 +1,45 @@
+/*
+ * File System Bind Data object to use as parameter for the bind context to
+ * IShellFolder_ParseDisplayName
+ *
+ * Copyright 2003 Rolf Kalbermatter
+ *
+ * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/***********************************************************************
+* FSBindData declarations
+*/
+#ifndef __WINE_SHELL_FS_BINDDATA_H
+#define __WINE_SHELL_FS_BINDDATA_H
+
+#include "shlobj.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* defined(__cplusplus) */
+
+HRESULT WINAPI FileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV);
+
+HRESULT WINAPI FileSystemBindData_GetFindData(LPBC pbc, WIN32_FIND_DATAW *pfd);
+
+HRESULT WINAPI FileSystemBindData_SetFindData(LPBC pbc, const WIN32_FIND_DATAW *pfd);
+
+#ifdef __cplusplus
+extern }
+#endif /* defined(__cplusplus) */
+
+#endif
===================================================================
--- /dev/null 2003-03-14 14:07:09.000000000 +0100
+++ dlls/shell32/shlfsbind.c 2003-09-07 00:35:39.000000000 +0200
@@ -0,0 +1,223 @@
+/*
+ * File System Bind Data object to use as parameter for the bind context to
+ * IShellFolder_ParseDisplayName
+ *
+ * Copyright 2003 Rolf Kalbermatter
+ *
+ * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winuser.h"
+#include "shlobj.h"
+#include "shell32_main.h"
+#include "shlfsbind.h"
+
+#include "debughlp.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(pidl);
+
+/***********************************************************************
+ * IFileSystemBindData implementation
+ */
+typedef struct
+{
+ ICOM_VFIELD(IFileSystemBindData);
+ DWORD ref;
+ WIN32_FIND_DATAW findFile;
+} IFileSystemBindDataImpl;
+
+static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(IFileSystemBindData *iface, REFIID riid, LPVOID* ppvObj);
+static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface);
+static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface);
+static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd);
+static HRESULT WINAPI IFileSystemBindData_fnSetFindData(IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd);
+
+static struct ICOM_VTABLE(IFileSystemBindData) sbvt =
+{
+ ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+ IFileSystemBindData_fnQueryInterface,
+ IFileSystemBindData_fnAddRef,
+ IFileSystemBindData_fnRelease,
+ IFileSystemBindData_fnGetFindData,
+ IFileSystemBindData_fnSetFindData,
+};
+
+static WCHAR wFileSystemBindData[] = {'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d','D','a','t','a',0};
+
+HRESULT WINAPI FileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV)
+{
+ IFileSystemBindDataImpl *sb;
+ HRESULT ret = E_OUTOFMEMORY;
+
+ TRACE("%p, %p", pfd, ppV);
+
+ if (!ppV)
+ return E_INVALIDARG;
+
+ *ppV = NULL;
+
+ sb = (IFileSystemBindDataImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IFileSystemBindDataImpl));
+ if (!sb)
+ return ret;
+
+ sb->lpVtbl = &sbvt;
+ sb->ref = 1;
+ IFileSystemBindData_fnSetFindData((IFileSystemBindData*)sb, pfd);
+
+ ret = CreateBindCtx(0, ppV);
+ if (SUCCEEDED(ret))
+ {
+ BIND_OPTS bindOpts;
+ bindOpts.cbStruct = sizeof(BIND_OPTS);
+ bindOpts.grfFlags = 0;
+ bindOpts.grfMode = STGM_CREATE;
+ bindOpts.dwTickCountDeadline = 0;
+ IBindCtx_SetBindOptions(*ppV, &bindOpts);
+ IBindCtx_RegisterObjectParam(*ppV, wFileSystemBindData, (LPUNKNOWN)sb);
+
+ IFileSystemBindData_Release((IFileSystemBindData*)sb);
+ }
+ else
+ HeapFree(GetProcessHeap(), 0, sb);
+ return ret;
+}
+
+HRESULT WINAPI FileSystemBindData_GetFindData(LPBC pbc, WIN32_FIND_DATAW *pfd)
+{
+ LPUNKNOWN pUnk;
+ IFileSystemBindData *pfsbd = NULL;
+ HRESULT ret;
+
+ TRACE("%p, %p", pbc, pfd);
+
+ if (!pfd)
+ return E_INVALIDARG;
+
+ ret = IBindCtx_GetObjectParam(pbc, wFileSystemBindData, &pUnk);
+ if (SUCCEEDED(ret))
+ {
+ ret = IUnknown_QueryInterface(pUnk, &IID_IFileSystemBindData, (LPVOID *)&pfsbd);
+ if (SUCCEEDED(ret))
+ {
+ ret = IFileSystemBindData_GetFindData(pfsbd, pfd);
+ IFileSystemBindData_Release(pfsbd);
+ }
+ IUnknown_Release(pUnk);
+ }
+ return ret;
+}
+
+HRESULT WINAPI FileSystemBindData_SetFindData(LPBC pbc, const WIN32_FIND_DATAW *pfd)
+{
+ LPUNKNOWN pUnk;
+ IFileSystemBindData *pfsbd = NULL;
+ HRESULT ret;
+
+ TRACE("%p, %p", pbc, pfd);
+
+ ret = IBindCtx_GetObjectParam(pbc, wFileSystemBindData, &pUnk);
+ if (SUCCEEDED(ret))
+ {
+ ret = IUnknown_QueryInterface(pUnk, &IID_IFileSystemBindData, (LPVOID *)&pfsbd);
+ if (SUCCEEDED(ret))
+ {
+ ret = IFileSystemBindData_SetFindData(pfsbd, pfd);
+ IFileSystemBindData_Release(pfsbd);
+ }
+ IUnknown_Release(pUnk);
+ }
+ return ret;}
+
+
+
+static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(IFileSystemBindData *iface, REFIID riid, LPVOID *ppV)
+{
+ ICOM_THIS(IFileSystemBindDataImpl, iface);
+ TRACE("(%p)->(\n\tIID:\t%s, %p)\n", This, debugstr_guid(riid), ppV);
+
+ *ppV = NULL;
+
+ if (IsEqualIID(riid, &IID_IUnknown))
+ {
+ *ppV = This;
+ }
+ else if (IsEqualIID(riid, &IID_IFileSystemBindData))
+ {
+ *ppV = (IFileSystemBindData*)This;
+ }
+
+ if (*ppV)
+ {
+ IUnknown_AddRef((IUnknown*)(*ppV));
+ TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV);
+ return S_OK;
+ }
+ TRACE("-- Interface: E_NOINTERFACE\n");
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface)
+{
+ ICOM_THIS(IFileSystemBindDataImpl, iface);
+ TRACE("(%p)\n", This);
+ return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface)
+{
+ ICOM_THIS(IFileSystemBindDataImpl, iface);
+ TRACE("(%p)\n", This);
+
+ if (!InterlockedDecrement(&This->ref))
+ {
+ TRACE(" destroying ISFBindPidl(%p)\n",This);
+ HeapFree(GetProcessHeap(), 0, This);
+ return 0;
+ }
+ return This->ref;
+}
+
+static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)
+{
+ ICOM_THIS(IFileSystemBindDataImpl, iface);
+ TRACE("(%p), %p\n", This, pfd);
+
+ if (!pfd)
+ return E_INVALIDARG;
+
+ memcpy(pfd, &This->findFile, sizeof(WIN32_FIND_DATAW));
+ return NOERROR;
+}
+
+static HRESULT WINAPI IFileSystemBindData_fnSetFindData(IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd)
+{
+ ICOM_THIS(IFileSystemBindDataImpl, iface);
+ TRACE("(%p), %p\n", This, pfd);
+
+ if (pfd)
+ memcpy(&This->findFile, pfd, sizeof(WIN32_FIND_DATAW));
+ else
+ memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW));
+ return NOERROR;
+}
More information about the wine-patches
mailing list