ReactOS  0.4.15-dev-439-g292f67a
factory.c
Go to the documentation of this file.
1 /*
2  * ClassFactory implementation for OBJSEL.dll
3  *
4  * Copyright (C) 2002 John K. Hohm
5  * Copyright (C) 2002 Robert Shearman
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 
22 #include "objsel_private.h"
23 
24 #include "wine/debug.h"
25 
27 
28 
30 {
31  return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
32 }
33 
34 /**********************************************************************
35  * OBJSEL_IClassFactory_QueryInterface (also IUnknown)
36  */
38  LPCLASSFACTORY iface,
39  REFIID riid,
40  LPVOID *ppvObj)
41 {
42  TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
43 
44  if (ppvObj == NULL) return E_POINTER;
45 
46  if (IsEqualGUID(riid, &IID_IUnknown) ||
48  {
49  *ppvObj = iface;
50  IClassFactory_AddRef(iface);
51  return S_OK;
52  }
53  else if (IsEqualGUID(riid, &IID_IDsObjectPicker))
54  {
55  return IClassFactory_CreateInstance(iface, NULL, riid, ppvObj);
56  }
57 
58  FIXME("- no interface IID: %s\n", debugstr_guid(riid));
59  return E_NOINTERFACE;
60 }
61 
62 
63 /**********************************************************************
64  * OBJSEL_IClassFactory_AddRef (also IUnknown)
65  */
66 static ULONG WINAPI OBJSEL_IClassFactory_AddRef(LPCLASSFACTORY iface)
67 {
69  ULONG ref;
70 
71  TRACE("\n");
72 
73  if (This == NULL) return E_POINTER;
74 
75  ref = InterlockedIncrement(&This->ref);
76 
77  if (ref == 1)
78  {
80  }
81 
82  return ref;
83 }
84 
85 
86 /**********************************************************************
87  * OBJSEL_IClassFactory_Release (also IUnknown)
88  */
89 static ULONG WINAPI OBJSEL_IClassFactory_Release(LPCLASSFACTORY iface)
90 {
92  ULONG ref;
93 
94  TRACE("\n");
95 
96  if (This == NULL) return E_POINTER;
97 
98  ref = InterlockedDecrement(&This->ref);
99 
100  if (ref == 0)
101  {
103  }
104 
105  return ref;
106 }
107 
108 
109 /**********************************************************************
110  * OBJSEL_IClassFactory_CreateInstance
111  */
113  LPCLASSFACTORY iface,
114  LPUNKNOWN pUnkOuter,
115  REFIID riid,
116  LPVOID *ppvObj)
117 {
118  TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
119 
120  if (ppvObj == NULL) return E_POINTER;
121 
122  /* Don't support aggregation (Windows doesn't) */
123  if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
124 
125  if (IsEqualGUID(&IID_IDsObjectPicker, riid))
126  {
127  return OBJSEL_IDsObjectPicker_Create(ppvObj);
128  }
129 
131 }
132 
133 
134 /**********************************************************************
135  * OBJSEL_IClassFactory_LockServer
136  */
138  LPCLASSFACTORY iface,
139  BOOL fLock)
140 {
141  TRACE("\n");
142 
143  if (fLock)
144  IClassFactory_AddRef(iface);
145  else
146  IClassFactory_Release(iface);
147  return S_OK;
148 }
149 
150 
151 /**********************************************************************
152  * IClassFactory_Vtbl
153  */
154 static IClassFactoryVtbl IClassFactory_Vtbl =
155 {
161 };
162 
163 
164 /**********************************************************************
165  * static ClassFactory instance
166  */
167 
static ULONG WINAPI OBJSEL_IClassFactory_AddRef(LPCLASSFACTORY iface)
Definition: factory.c:66
static HRESULT WINAPI OBJSEL_IClassFactory_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj)
Definition: factory.c:112
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
DECLSPEC_HIDDEN LONG dll_refs
Definition: devenum_main.c:28
REFIID riid
Definition: precomp.h:44
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
Definition: send.c:48
static HRESULT WINAPI OBJSEL_IClassFactory_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
Definition: factory.c:37
unsigned int BOOL
Definition: ntddk_ex.h:94
static LPUNKNOWN
Definition: ndr_ole.c:49
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
static ClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: factory.c:29
ClassFactoryImpl OBJSEL_ClassFactory
Definition: factory.c:168
static ULONG WINAPI OBJSEL_IClassFactory_Release(LPCLASSFACTORY iface)
Definition: factory.c:89
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:6
HRESULT WINAPI OBJSEL_IDsObjectPicker_Create(LPVOID *ppvObj)
Definition: objsel.c:220
#define InterlockedDecrement
Definition: armddk.h:52
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
static IClassFactoryVtbl IClassFactory_Vtbl
Definition: factory.c:154
static HRESULT WINAPI OBJSEL_IClassFactory_LockServer(LPCLASSFACTORY iface, BOOL fLock)
Definition: factory.c:137
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
WINE_DEFAULT_DEBUG_CHANNEL(avifile)
unsigned int ULONG
Definition: retypes.h:1
#define E_POINTER
Definition: winerror.h:2365
const GUID IID_IClassFactory