2003-09-16 00:10:48 +02:00
|
|
|
/*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-09-16 00:10:48 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-09-16 00:10:48 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "shlobj.h"
|
|
|
|
#include "shell32_main.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(pidl);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IFileSystemBindData implementation
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2005-06-06 21:50:35 +02:00
|
|
|
const IFileSystemBindDataVtbl *lpVtbl;
|
2005-07-03 14:03:35 +02:00
|
|
|
LONG ref;
|
2005-02-23 16:41:39 +01:00
|
|
|
WIN32_FIND_DATAW findFile;
|
2003-09-16 00:10:48 +02:00
|
|
|
} IFileSystemBindDataImpl;
|
|
|
|
|
2005-02-23 16:41:39 +01:00
|
|
|
static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(IFileSystemBindData *, REFIID, LPVOID*);
|
|
|
|
static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *);
|
|
|
|
static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *);
|
|
|
|
static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *, WIN32_FIND_DATAW *);
|
|
|
|
static HRESULT WINAPI IFileSystemBindData_fnSetFindData(IFileSystemBindData *, const WIN32_FIND_DATAW *);
|
2003-09-16 00:10:48 +02:00
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IFileSystemBindDataVtbl sbvt =
|
2003-09-16 00:10:48 +02:00
|
|
|
{
|
|
|
|
IFileSystemBindData_fnQueryInterface,
|
|
|
|
IFileSystemBindData_fnAddRef,
|
|
|
|
IFileSystemBindData_fnRelease,
|
|
|
|
IFileSystemBindData_fnSetFindData,
|
2004-06-30 20:13:09 +02:00
|
|
|
IFileSystemBindData_fnGetFindData,
|
2003-09-16 00:10:48 +02:00
|
|
|
};
|
|
|
|
|
2005-02-23 16:41:39 +01:00
|
|
|
static const WCHAR wFileSystemBindData[] = {
|
|
|
|
'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d','D','a','t','a',0};
|
2003-09-16 00:10:48 +02:00
|
|
|
|
2003-09-17 06:17:33 +02:00
|
|
|
HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV)
|
2003-09-16 00:10:48 +02:00
|
|
|
{
|
2005-02-23 16:41:39 +01:00
|
|
|
IFileSystemBindDataImpl *sb;
|
|
|
|
HRESULT ret = E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
TRACE("%p, %p\n", pfd, ppV);
|
|
|
|
|
|
|
|
if (!ppV)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppV = NULL;
|
|
|
|
|
|
|
|
sb = 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, (LPOLESTR)wFileSystemBindData, (LPUNKNOWN)sb);
|
|
|
|
|
|
|
|
IFileSystemBindData_Release((IFileSystemBindData*)sb);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
HeapFree(GetProcessHeap(), 0, sb);
|
|
|
|
return ret;
|
2003-09-16 00:10:48 +02:00
|
|
|
}
|
|
|
|
|
2005-02-23 16:41:39 +01:00
|
|
|
static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(
|
|
|
|
IFileSystemBindData *iface, REFIID riid, LPVOID *ppV)
|
2003-09-16 00:10:48 +02:00
|
|
|
{
|
2005-02-23 16:41:39 +01:00
|
|
|
IFileSystemBindDataImpl *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;
|
2003-09-16 00:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface)
|
|
|
|
{
|
2005-02-23 16:41:39 +01:00
|
|
|
IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
|
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%i)\n", This, refCount - 1);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2005-02-23 16:41:39 +01:00
|
|
|
return refCount;
|
2003-09-16 00:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface)
|
|
|
|
{
|
2005-02-23 16:41:39 +01:00
|
|
|
IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
|
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%i)\n", This, refCount + 1);
|
2005-02-23 16:41:39 +01:00
|
|
|
|
|
|
|
if (!refCount)
|
|
|
|
{
|
|
|
|
TRACE(" destroying ISFBindPidl(%p)\n",This);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return refCount;
|
2003-09-16 00:10:48 +02:00
|
|
|
}
|
|
|
|
|
2005-02-23 16:41:39 +01:00
|
|
|
static HRESULT WINAPI IFileSystemBindData_fnGetFindData(
|
|
|
|
IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)
|
2003-09-16 00:10:48 +02:00
|
|
|
{
|
2005-02-23 16:41:39 +01:00
|
|
|
IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
|
|
|
|
TRACE("(%p), %p\n", This, pfd);
|
2003-09-16 00:10:48 +02:00
|
|
|
|
2005-02-23 16:41:39 +01:00
|
|
|
if (!pfd)
|
|
|
|
return E_INVALIDARG;
|
2003-09-16 00:10:48 +02:00
|
|
|
|
2008-03-17 22:36:59 +01:00
|
|
|
*pfd = This->findFile;
|
2005-02-23 16:41:39 +01:00
|
|
|
return NOERROR;
|
2003-09-16 00:10:48 +02:00
|
|
|
}
|
|
|
|
|
2005-02-23 16:41:39 +01:00
|
|
|
static HRESULT WINAPI IFileSystemBindData_fnSetFindData(
|
|
|
|
IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd)
|
2003-09-16 00:10:48 +02:00
|
|
|
{
|
2005-02-23 16:41:39 +01:00
|
|
|
IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
|
|
|
|
TRACE("(%p), %p\n", This, pfd);
|
|
|
|
|
|
|
|
if (pfd)
|
2008-03-17 22:36:59 +01:00
|
|
|
This->findFile = *pfd;
|
2005-02-23 16:41:39 +01:00
|
|
|
else
|
|
|
|
memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW));
|
|
|
|
return NOERROR;
|
2003-09-16 00:10:48 +02:00
|
|
|
}
|