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 <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
|
|
|
|
{
|
2010-12-07 11:10:00 +01:00
|
|
|
IFileSystemBindData IFileSystemBindData_iface;
|
|
|
|
LONG ref;
|
2005-02-23 16:41:39 +01:00
|
|
|
WIN32_FIND_DATAW findFile;
|
2012-01-12 22:14:14 +01:00
|
|
|
} FileSystemBindData;
|
2003-09-16 00:10:48 +02:00
|
|
|
|
2012-01-12 22:14:14 +01:00
|
|
|
static inline FileSystemBindData *impl_from_IFileSystemBindData(IFileSystemBindData *iface)
|
2010-12-07 11:10:00 +01:00
|
|
|
{
|
2012-01-12 22:14:14 +01:00
|
|
|
return CONTAINING_RECORD(iface, FileSystemBindData, IFileSystemBindData_iface);
|
2010-12-07 11:10:00 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 22:14:14 +01:00
|
|
|
static HRESULT WINAPI FileSystemBindData_QueryInterface(
|
|
|
|
IFileSystemBindData *iface, REFIID riid, LPVOID *ppV)
|
2003-09-16 00:10:48 +02:00
|
|
|
{
|
2012-01-12 22:14:14 +01:00
|
|
|
FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
|
2005-02-23 16:41:39 +01:00
|
|
|
|
2012-01-12 22:14:14 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppV);
|
2005-02-23 16:41:39 +01:00
|
|
|
|
|
|
|
*ppV = NULL;
|
|
|
|
|
2012-01-12 22:14:14 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IFileSystemBindData))
|
2005-02-23 16:41:39 +01:00
|
|
|
{
|
2012-01-12 22:14:14 +01:00
|
|
|
*ppV = &This->IFileSystemBindData_iface;
|
2005-02-23 16:41:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*ppV)
|
|
|
|
{
|
2012-01-12 22:14:14 +01:00
|
|
|
IFileSystemBindData_AddRef(iface);
|
2005-02-23 16:41:39 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-01-12 22:14:14 +01:00
|
|
|
static ULONG WINAPI FileSystemBindData_AddRef(IFileSystemBindData *iface)
|
2003-09-16 00:10:48 +02:00
|
|
|
{
|
2012-01-12 22:14:14 +01:00
|
|
|
FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%u)\n", This, ref);
|
|
|
|
return ref;
|
2003-09-16 00:10:48 +02:00
|
|
|
}
|
|
|
|
|
2012-01-12 22:14:14 +01:00
|
|
|
static ULONG WINAPI FileSystemBindData_Release(IFileSystemBindData *iface)
|
2003-09-16 00:10:48 +02:00
|
|
|
{
|
2012-01-12 22:14:14 +01:00
|
|
|
FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2010-12-07 11:10:00 +01:00
|
|
|
|
2012-01-12 22:14:14 +01:00
|
|
|
TRACE("(%p)->(%u)\n", This, ref);
|
2005-02-23 16:41:39 +01:00
|
|
|
|
2012-01-12 22:14:14 +01:00
|
|
|
if (!ref)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(This);
|
2012-01-12 22:14:14 +01:00
|
|
|
|
|
|
|
return ref;
|
2003-09-16 00:10:48 +02:00
|
|
|
}
|
|
|
|
|
2012-01-12 22:14:14 +01:00
|
|
|
static HRESULT WINAPI FileSystemBindData_GetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)
|
2003-09-16 00:10:48 +02:00
|
|
|
{
|
2012-01-12 22:14:14 +01:00
|
|
|
FileSystemBindData *This = impl_from_IFileSystemBindData(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;
|
2012-01-08 01:31:54 +01:00
|
|
|
return S_OK;
|
2003-09-16 00:10:48 +02:00
|
|
|
}
|
|
|
|
|
2012-01-12 22:14:14 +01:00
|
|
|
static HRESULT WINAPI FileSystemBindData_SetFindData(IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd)
|
2003-09-16 00:10:48 +02:00
|
|
|
{
|
2012-01-12 22:14:14 +01:00
|
|
|
FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pfd);
|
2005-02-23 16:41:39 +01:00
|
|
|
|
|
|
|
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));
|
2012-01-08 01:31:54 +01:00
|
|
|
return S_OK;
|
2003-09-16 00:10:48 +02:00
|
|
|
}
|
2012-01-12 22:14:14 +01:00
|
|
|
|
|
|
|
static const IFileSystemBindDataVtbl FileSystemBindDataVtbl = {
|
|
|
|
FileSystemBindData_QueryInterface,
|
|
|
|
FileSystemBindData_AddRef,
|
|
|
|
FileSystemBindData_Release,
|
|
|
|
FileSystemBindData_SetFindData,
|
|
|
|
FileSystemBindData_GetFindData,
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *find_data, LPBC *ppV)
|
|
|
|
{
|
|
|
|
FileSystemBindData *This;
|
|
|
|
HRESULT ret;
|
|
|
|
|
|
|
|
TRACE("(%p %p)\n", find_data, ppV);
|
|
|
|
|
|
|
|
if (!ppV)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppV = NULL;
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
This = heap_alloc(sizeof(*This));
|
2012-01-12 22:14:14 +01:00
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->IFileSystemBindData_iface.lpVtbl = &FileSystemBindDataVtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
IFileSystemBindData_SetFindData(&This->IFileSystemBindData_iface, find_data);
|
|
|
|
|
|
|
|
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);
|
2021-09-20 12:58:52 +02:00
|
|
|
IBindCtx_RegisterObjectParam(*ppV, (WCHAR*)L"File System Bind Data", (IUnknown*)&This->IFileSystemBindData_iface);
|
2012-01-12 22:14:14 +01:00
|
|
|
|
|
|
|
IFileSystemBindData_Release(&This->IFileSystemBindData_iface);
|
|
|
|
}
|
|
|
|
else
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(This);
|
2012-01-12 22:14:14 +01:00
|
|
|
return ret;
|
|
|
|
}
|