2002-05-14 23:50:56 +02:00
|
|
|
/*
|
|
|
|
* ClassFactory implementation for comcat.dll
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 John K. Hohm
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2002-12-23 02:39:35 +01:00
|
|
|
#include "comcat_private.h"
|
2002-05-14 23:50:56 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
|
|
|
|
static ULONG WINAPI COMCAT_IClassFactory_AddRef(LPCLASSFACTORY iface);
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_IClassFactory_QueryInterface (also IUnknown)
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_IClassFactory_QueryInterface(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
|
2002-05-14 23:50:56 +02:00
|
|
|
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
|
|
|
|
|
|
|
|
if (This == NULL || ppvObj == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IClassFactory))
|
|
|
|
{
|
|
|
|
*ppvObj = (LPVOID)iface;
|
|
|
|
COMCAT_IClassFactory_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_IClassFactory_AddRef (also IUnknown)
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI COMCAT_IClassFactory_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
|
2005-01-10 13:25:29 +01:00
|
|
|
ULONG ref;
|
|
|
|
|
2002-05-14 23:50:56 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (This == NULL) return E_POINTER;
|
|
|
|
|
2005-01-10 13:25:29 +01:00
|
|
|
ref = InterlockedIncrement(&This->ref);
|
|
|
|
if (ref == 1) {
|
2002-05-14 23:50:56 +02:00
|
|
|
InterlockedIncrement(&dll_ref);
|
|
|
|
}
|
2005-01-10 13:25:29 +01:00
|
|
|
return ref;
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_IClassFactory_Release (also IUnknown)
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI COMCAT_IClassFactory_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
|
2005-01-10 13:25:29 +01:00
|
|
|
ULONG ref;
|
|
|
|
|
2002-05-14 23:50:56 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (This == NULL) return E_POINTER;
|
|
|
|
|
2005-01-10 13:25:29 +01:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if (ref == 0) {
|
2002-05-14 23:50:56 +02:00
|
|
|
InterlockedDecrement(&dll_ref);
|
|
|
|
}
|
2005-01-10 13:25:29 +01:00
|
|
|
return ref;
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_IClassFactory_CreateInstance
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_IClassFactory_CreateInstance(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pUnkOuter,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
|
2002-05-14 23:50:56 +02:00
|
|
|
HRESULT res;
|
|
|
|
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
|
|
|
|
|
|
|
|
if (This == NULL || ppvObj == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
/* Don't support aggregation (Windows doesn't) */
|
|
|
|
if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
res = IUnknown_QueryInterface((LPUNKNOWN)&COMCAT_ComCatMgr, riid, ppvObj);
|
|
|
|
if (SUCCEEDED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_IClassFactory_LockServer
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_IClassFactory_LockServer(
|
|
|
|
LPCLASSFACTORY iface,
|
|
|
|
BOOL fLock)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (fLock != FALSE) {
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
} else {
|
|
|
|
IClassFactory_Release(iface);
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* IClassFactory_Vtbl
|
|
|
|
*/
|
2004-08-13 01:00:51 +02:00
|
|
|
static IClassFactoryVtbl IClassFactory_Vtbl =
|
2002-05-14 23:50:56 +02:00
|
|
|
{
|
|
|
|
COMCAT_IClassFactory_QueryInterface,
|
|
|
|
COMCAT_IClassFactory_AddRef,
|
|
|
|
COMCAT_IClassFactory_Release,
|
|
|
|
COMCAT_IClassFactory_CreateInstance,
|
|
|
|
COMCAT_IClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* static ClassFactory instance
|
|
|
|
*/
|
|
|
|
ClassFactoryImpl COMCAT_ClassFactory = { &IClassFactory_Vtbl, 0 };
|