2011-05-15 15:55:49 +00: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
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "precomp.h"
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(pidl);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IFileSystemBindData implementation
|
|
|
|
*/
|
|
|
|
class IFileSystemBindDataImpl :
|
2011-09-08 22:43:43 +00:00
|
|
|
public CComObjectRootEx<CComMultiThreadModelNoCS>,
|
|
|
|
public IFileSystemBindData
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
WIN32_FIND_DATAW findFile;
|
|
|
|
public:
|
2011-09-08 22:43:43 +00:00
|
|
|
IFileSystemBindDataImpl();
|
|
|
|
~IFileSystemBindDataImpl();
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
// *** IFileSystemBindData methods ***
|
|
|
|
virtual HRESULT STDMETHODCALLTYPE SetFindData(const WIN32_FIND_DATAW *pfd);
|
|
|
|
virtual HRESULT STDMETHODCALLTYPE GetFindData(WIN32_FIND_DATAW *pfd);
|
|
|
|
|
|
|
|
DECLARE_NOT_AGGREGATABLE(IFileSystemBindDataImpl)
|
|
|
|
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
|
|
|
|
|
|
|
BEGIN_COM_MAP(IFileSystemBindDataImpl)
|
2011-09-08 22:43:43 +00:00
|
|
|
COM_INTERFACE_ENTRY_IID(IID_IFileSystemBindData, IFileSystemBindData)
|
2011-05-15 15:55:49 +00:00
|
|
|
END_COM_MAP()
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV)
|
|
|
|
{
|
2011-09-08 22:43:43 +00:00
|
|
|
CComPtr<IFileSystemBindData> fileSystemBindData;
|
|
|
|
CComPtr<IBindCtx> bindContext;
|
|
|
|
BIND_OPTS bindOpts;
|
|
|
|
HRESULT hResult;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
TRACE("%p, %p\n", pfd, ppV);
|
|
|
|
|
|
|
|
if (ppV == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppV = NULL;
|
|
|
|
|
2013-11-11 16:42:16 +00:00
|
|
|
hResult = IFileSystemBindDataImpl::_CreatorClass::CreateInstance(NULL, IID_PPV_ARG(IFileSystemBindData, &fileSystemBindData));
|
2011-09-08 22:43:43 +00:00
|
|
|
if (FAILED(hResult))
|
|
|
|
return hResult;
|
2011-05-15 15:55:49 +00:00
|
|
|
hResult = fileSystemBindData->SetFindData(pfd);
|
2011-09-08 22:43:43 +00:00
|
|
|
if (FAILED(hResult))
|
|
|
|
return hResult;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-08 22:43:43 +00:00
|
|
|
hResult = CreateBindCtx(0, &bindContext);
|
|
|
|
if (FAILED(hResult))
|
|
|
|
return hResult;
|
2011-05-15 15:55:49 +00:00
|
|
|
bindOpts.cbStruct = sizeof(BIND_OPTS);
|
|
|
|
bindOpts.grfFlags = 0;
|
|
|
|
bindOpts.grfMode = STGM_CREATE;
|
|
|
|
bindOpts.dwTickCountDeadline = 0;
|
|
|
|
hResult = bindContext->SetBindOptions(&bindOpts);
|
2011-09-08 22:43:43 +00:00
|
|
|
if (FAILED(hResult))
|
|
|
|
return hResult;
|
2013-11-24 21:42:28 +00:00
|
|
|
hResult = bindContext->RegisterObjectParam((LPOLESTR)STR_FILE_SYS_BIND_DATA, fileSystemBindData);
|
2011-09-08 22:43:43 +00:00
|
|
|
if (FAILED(hResult))
|
|
|
|
return hResult;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-08 22:43:43 +00:00
|
|
|
*ppV = bindContext.Detach();
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI FileSystemBindData_GetFindData(LPBC pbc, WIN32_FIND_DATAW *pfd)
|
|
|
|
{
|
2011-09-08 22:43:43 +00:00
|
|
|
CComPtr<IUnknown> pUnk;
|
|
|
|
CComPtr<IFileSystemBindData> pfsbd;
|
|
|
|
HRESULT ret;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
TRACE("%p, %p\n", pbc, pfd);
|
|
|
|
|
|
|
|
if (!pfd)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2013-11-24 21:42:28 +00:00
|
|
|
ret = pbc->GetObjectParam((LPOLESTR)STR_FILE_SYS_BIND_DATA, &pUnk);
|
2011-05-15 15:55:49 +00:00
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
2013-11-11 16:42:16 +00:00
|
|
|
ret = pUnk->QueryInterface(IID_PPV_ARG(IFileSystemBindData, &pfsbd));
|
2011-05-15 15:55:49 +00:00
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
ret = pfsbd->GetFindData(pfd);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI FileSystemBindData_SetFindData(LPBC pbc, const WIN32_FIND_DATAW *pfd)
|
|
|
|
{
|
2011-09-08 22:43:43 +00:00
|
|
|
CComPtr<IUnknown> pUnk;
|
|
|
|
CComPtr<IFileSystemBindData> pfsbd;
|
|
|
|
HRESULT ret;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
TRACE("%p, %p\n", pbc, pfd);
|
|
|
|
|
2013-11-24 21:42:28 +00:00
|
|
|
ret = pbc->GetObjectParam((LPOLESTR)STR_FILE_SYS_BIND_DATA, &pUnk);
|
2011-05-15 15:55:49 +00:00
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
2013-11-11 16:42:16 +00:00
|
|
|
ret = pUnk->QueryInterface(IID_PPV_ARG(IFileSystemBindData, &pfsbd));
|
2011-05-15 15:55:49 +00:00
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
ret = pfsbd->SetFindData(pfd);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
IFileSystemBindDataImpl::IFileSystemBindDataImpl()
|
|
|
|
{
|
2011-09-08 22:43:43 +00:00
|
|
|
memset(&findFile, 0, sizeof(WIN32_FIND_DATAW));
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IFileSystemBindDataImpl::~IFileSystemBindDataImpl()
|
|
|
|
{
|
2011-09-08 22:43:43 +00:00
|
|
|
TRACE(" destroying ISFBindPidl(%p)\n", this);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IFileSystemBindDataImpl::GetFindData(WIN32_FIND_DATAW *pfd)
|
|
|
|
{
|
|
|
|
TRACE("(%p), %p\n", this, pfd);
|
|
|
|
|
|
|
|
if (!pfd)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
memcpy(pfd, &findFile, sizeof(WIN32_FIND_DATAW));
|
2013-11-03 12:03:54 +00:00
|
|
|
return S_OK;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IFileSystemBindDataImpl::SetFindData(const WIN32_FIND_DATAW *pfd)
|
|
|
|
{
|
|
|
|
TRACE("(%p), %p\n", this, pfd);
|
|
|
|
|
|
|
|
if (pfd)
|
|
|
|
memcpy(&findFile, pfd, sizeof(WIN32_FIND_DATAW));
|
|
|
|
else
|
|
|
|
memset(&findFile, 0, sizeof(WIN32_FIND_DATAW));
|
2013-11-03 12:03:54 +00:00
|
|
|
return S_OK;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|