Commit 026c7fc6 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

objsel: Merge factory.c into objsel.c.

A separate file for the class factory is not justified.
parent 39ccd719
......@@ -2,7 +2,6 @@ MODULE = objsel.dll
IMPORTS = strmiids uuid ole32 advapi32
C_SRCS = \
factory.c \
objsel.c
IDL_SRCS = objsel_classes.idl
......
/*
* ClassFactory implementation for OBJSEL.dll
*
* Copyright (C) 2002 John K. Hohm
* Copyright (C) 2002 Robert Shearman
*
* 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
*/
#include "objsel_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(objsel);
static inline ClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
}
/**********************************************************************
* OBJSEL_IClassFactory_QueryInterface (also IUnknown)
*/
static HRESULT WINAPI OBJSEL_IClassFactory_QueryInterface(
LPCLASSFACTORY iface,
REFIID riid,
LPVOID *ppvObj)
{
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (ppvObj == NULL) return E_POINTER;
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IClassFactory))
{
*ppvObj = iface;
IClassFactory_AddRef(iface);
return S_OK;
}
else if (IsEqualGUID(riid, &IID_IDsObjectPicker))
{
return IClassFactory_CreateInstance(iface, NULL, riid, ppvObj);
}
FIXME("- no interface IID: %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
/**********************************************************************
* OBJSEL_IClassFactory_AddRef (also IUnknown)
*/
static ULONG WINAPI OBJSEL_IClassFactory_AddRef(LPCLASSFACTORY iface)
{
ClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("\n");
if (This == NULL) return E_POINTER;
return InterlockedIncrement(&This->ref);
}
/**********************************************************************
* OBJSEL_IClassFactory_Release (also IUnknown)
*/
static ULONG WINAPI OBJSEL_IClassFactory_Release(LPCLASSFACTORY iface)
{
ClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("\n");
if (This == NULL) return E_POINTER;
return InterlockedDecrement(&This->ref);
}
/**********************************************************************
* OBJSEL_IClassFactory_CreateInstance
*/
static HRESULT WINAPI OBJSEL_IClassFactory_CreateInstance(
LPCLASSFACTORY iface,
LPUNKNOWN pUnkOuter,
REFIID riid,
LPVOID *ppvObj)
{
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (ppvObj == NULL) return E_POINTER;
/* Don't support aggregation (Windows doesn't) */
if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
if (IsEqualGUID(&IID_IDsObjectPicker, riid))
{
return OBJSEL_IDsObjectPicker_Create(ppvObj);
}
return CLASS_E_CLASSNOTAVAILABLE;
}
/**********************************************************************
* OBJSEL_IClassFactory_LockServer
*/
static HRESULT WINAPI OBJSEL_IClassFactory_LockServer(
LPCLASSFACTORY iface,
BOOL fLock)
{
TRACE("\n");
if (fLock)
IClassFactory_AddRef(iface);
else
IClassFactory_Release(iface);
return S_OK;
}
/**********************************************************************
* IClassFactory_Vtbl
*/
static IClassFactoryVtbl IClassFactory_Vtbl =
{
OBJSEL_IClassFactory_QueryInterface,
OBJSEL_IClassFactory_AddRef,
OBJSEL_IClassFactory_Release,
OBJSEL_IClassFactory_CreateInstance,
OBJSEL_IClassFactory_LockServer
};
/**********************************************************************
* static ClassFactory instance
*/
ClassFactoryImpl OBJSEL_ClassFactory = { { &IClassFactory_Vtbl }, 0 };
/*
* Object Picker Dialog
*
* Copyright (C) 2002 John K. Hohm
* Copyright (C) 2002 Robert Shearman
* Copyright 2005 Thomas Weidenmueller <w3seek@reactos.com>
*
* This library is free software; you can redistribute it and/or
......@@ -18,28 +20,19 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "objsel_private.h"
#define COBJMACROS
#include "objidl.h"
#include "objsel.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(objsel);
/***********************************************************************
* DllGetClassObject (OBJSEL.@)
*/
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
typedef struct
{
TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
*ppv = NULL;
if (IsEqualGUID(rclsid, &CLSID_DsObjectPicker))
return IClassFactory_QueryInterface(&OBJSEL_ClassFactory.IClassFactory_iface, iid, ppv);
FIXME("CLSID: %s, IID: %s\n", debugstr_guid(rclsid), debugstr_guid(iid));
return CLASS_E_CLASSNOTAVAILABLE;
}
IDsObjectPicker IDsObjectPicker_iface;
LONG ref;
} IDsObjectPickerImpl;
/**********************************************************************
* OBJSEL_IDsObjectPicker_Destroy (also IUnknown)
......@@ -156,10 +149,7 @@ static IDsObjectPickerVtbl IDsObjectPicker_Vtbl =
};
/**********************************************************************
* OBJSEL_IDsObjectPicker_Create
*/
HRESULT WINAPI OBJSEL_IDsObjectPicker_Create(LPVOID *ppvObj)
static HRESULT object_picker_create(void **ppvObj)
{
IDsObjectPickerImpl *Instance = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
......@@ -175,3 +165,124 @@ HRESULT WINAPI OBJSEL_IDsObjectPicker_Create(LPVOID *ppvObj)
else
return E_OUTOFMEMORY;
}
struct class_factory
{
IClassFactory IClassFactory_iface;
LONG ref;
};
static struct class_factory *impl_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, struct class_factory, IClassFactory_iface);
}
static HRESULT WINAPI class_factory_QueryInterface(IClassFactory *iface, REFIID iid, void **out)
{
TRACE("iid %s, out %p.\n", debugstr_guid(iid), out);
if (!out)
return E_POINTER;
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory))
{
*out = iface;
IClassFactory_AddRef(iface);
return S_OK;
}
else if (IsEqualGUID(iid, &IID_IDsObjectPicker))
{
return IClassFactory_CreateInstance(iface, NULL, iid, out);
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
return E_NOINTERFACE;
}
static ULONG WINAPI class_factory_AddRef(IClassFactory *iface)
{
struct class_factory *factory = impl_from_IClassFactory(iface);
TRACE("\n");
if (!factory)
return E_POINTER;
return InterlockedIncrement(&factory->ref);
}
static ULONG WINAPI class_factory_Release(IClassFactory *iface)
{
struct class_factory *factory = impl_from_IClassFactory(iface);
TRACE("\n");
if (!factory)
return E_POINTER;
return InterlockedDecrement(&factory->ref);
}
static HRESULT WINAPI class_factory_CreateInstance(IClassFactory *iface,
IUnknown *outer, REFIID iid, void **out)
{
TRACE("outer %p, iid %s, out %p.\n", outer, debugstr_guid(iid), out);
if (!out)
return E_POINTER;
if (outer)
return CLASS_E_NOAGGREGATION;
if (IsEqualGUID(&IID_IDsObjectPicker, iid))
return object_picker_create(out);
return CLASS_E_CLASSNOTAVAILABLE;
}
static HRESULT WINAPI class_factory_LockServer(IClassFactory *iface, BOOL lock)
{
TRACE("lock %d.\n", lock);
if (lock)
IClassFactory_AddRef(iface);
else
IClassFactory_Release(iface);
return S_OK;
}
static IClassFactoryVtbl class_factory_vtbl =
{
class_factory_QueryInterface,
class_factory_AddRef,
class_factory_Release,
class_factory_CreateInstance,
class_factory_LockServer
};
static struct class_factory class_factory = {{&class_factory_vtbl}, 0};
/***********************************************************************
* DllGetClassObject (OBJSEL.@)
*/
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out)
{
TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid), debugstr_guid(iid), out);
*out = NULL;
if (IsEqualGUID(clsid, &CLSID_DsObjectPicker))
return IClassFactory_QueryInterface(&class_factory.IClassFactory_iface, iid, out);
FIXME("%s not available, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid));
return CLASS_E_CLASSNOTAVAILABLE;
}
/*
* Object Picker Dialog Includes
*
* Copyright 2005 Thomas Weidenmueller <w3seek@reactos.com>
*
* 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
*/
#define COBJMACROS
#include "objidl.h"
#include "objsel.h"
/**********************************************************************
* ClassFactory declaration for objsel.dll
*/
typedef struct
{
IClassFactory IClassFactory_iface;
LONG ref;
} ClassFactoryImpl;
typedef struct
{
IDsObjectPicker IDsObjectPicker_iface;
LONG ref;
} IDsObjectPickerImpl;
HRESULT WINAPI OBJSEL_IDsObjectPicker_Create(LPVOID *ppvObj) DECLSPEC_HIDDEN;
extern ClassFactoryImpl OBJSEL_ClassFactory DECLSPEC_HIDDEN;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment