4 * Copyright (C) 2002 John K. Hohm
5 * Copyright (C) 2002 Robert Shearman
6 * Copyright 2005 Thomas Weidenmueller <w3seek@reactos.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(objsel
);
33 IDsObjectPicker IDsObjectPicker_iface
;
35 } IDsObjectPickerImpl
;
37 /**********************************************************************
38 * OBJSEL_IDsObjectPicker_Destroy (also IUnknown)
40 static VOID
OBJSEL_IDsObjectPicker_Destroy(IDsObjectPickerImpl
*This
)
42 HeapFree(GetProcessHeap(),
48 static inline IDsObjectPickerImpl
*impl_from_IDsObjectPicker(IDsObjectPicker
*iface
)
50 return CONTAINING_RECORD(iface
, IDsObjectPickerImpl
, IDsObjectPicker_iface
);
53 /**********************************************************************
54 * OBJSEL_IDsObjectPicker_AddRef (also IUnknown)
56 static ULONG WINAPI
OBJSEL_IDsObjectPicker_AddRef(IDsObjectPicker
* iface
)
58 IDsObjectPickerImpl
*This
= impl_from_IDsObjectPicker(iface
);
62 return InterlockedIncrement(&This
->ref
);
66 /**********************************************************************
67 * OBJSEL_IDsObjectPicker_Release (also IUnknown)
69 static ULONG WINAPI
OBJSEL_IDsObjectPicker_Release(IDsObjectPicker
* iface
)
71 IDsObjectPickerImpl
*This
= impl_from_IDsObjectPicker(iface
);
76 ref
= InterlockedDecrement(&This
->ref
);
79 OBJSEL_IDsObjectPicker_Destroy(This
);
85 /**********************************************************************
86 * OBJSEL_IDsObjectPicker_QueryInterface (also IUnknown)
88 static HRESULT WINAPI
OBJSEL_IDsObjectPicker_QueryInterface(
89 IDsObjectPicker
* iface
,
93 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid
));
95 if (ppvObj
== NULL
) return E_POINTER
;
97 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
98 IsEqualGUID(riid
, &IID_IDsObjectPicker
))
101 OBJSEL_IDsObjectPicker_AddRef(iface
);
105 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
106 return E_NOINTERFACE
;
110 /**********************************************************************
111 * OBJSEL_IDsObjectPicker_Initialize
113 static HRESULT WINAPI
OBJSEL_IDsObjectPicker_Initialize(
114 IDsObjectPicker
* iface
,
115 PDSOP_INIT_INFO pInitInfo
)
122 /**********************************************************************
123 * OBJSEL_IDsObjectPicker_InvokeDialog
125 static HRESULT WINAPI
OBJSEL_IDsObjectPicker_InvokeDialog(
126 IDsObjectPicker
* iface
,
128 IDataObject
** ppdoSelections
)
135 /**********************************************************************
136 * IDsObjectPicker_Vtbl
138 static IDsObjectPickerVtbl IDsObjectPicker_Vtbl
=
140 OBJSEL_IDsObjectPicker_QueryInterface
,
141 OBJSEL_IDsObjectPicker_AddRef
,
142 OBJSEL_IDsObjectPicker_Release
,
143 OBJSEL_IDsObjectPicker_Initialize
,
144 OBJSEL_IDsObjectPicker_InvokeDialog
148 static HRESULT
object_picker_create(void **ppvObj
)
150 IDsObjectPickerImpl
*Instance
= HeapAlloc(GetProcessHeap(),
152 sizeof(IDsObjectPickerImpl
));
153 if (Instance
!= NULL
)
155 Instance
->IDsObjectPicker_iface
.lpVtbl
= &IDsObjectPicker_Vtbl
;
156 OBJSEL_IDsObjectPicker_AddRef(&Instance
->IDsObjectPicker_iface
);
162 return E_OUTOFMEMORY
;
168 IClassFactory IClassFactory_iface
;
173 static struct class_factory
*impl_from_IClassFactory(IClassFactory
*iface
)
175 return CONTAINING_RECORD(iface
, struct class_factory
, IClassFactory_iface
);
179 static HRESULT WINAPI
class_factory_QueryInterface(IClassFactory
*iface
, REFIID iid
, void **out
)
181 TRACE("iid %s, out %p.\n", debugstr_guid(iid
), out
);
186 if (IsEqualGUID(iid
, &IID_IUnknown
) || IsEqualGUID(iid
, &IID_IClassFactory
))
189 IClassFactory_AddRef(iface
);
193 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
194 return E_NOINTERFACE
;
198 static ULONG WINAPI
class_factory_AddRef(IClassFactory
*iface
)
200 struct class_factory
*factory
= impl_from_IClassFactory(iface
);
204 return InterlockedIncrement(&factory
->ref
);
208 static ULONG WINAPI
class_factory_Release(IClassFactory
*iface
)
210 struct class_factory
*factory
= impl_from_IClassFactory(iface
);
214 return InterlockedDecrement(&factory
->ref
);
218 static HRESULT WINAPI
class_factory_CreateInstance(IClassFactory
*iface
,
219 IUnknown
*outer
, REFIID iid
, void **out
)
221 TRACE("outer %p, iid %s, out %p.\n", outer
, debugstr_guid(iid
), out
);
227 return CLASS_E_NOAGGREGATION
;
229 if (IsEqualGUID(&IID_IDsObjectPicker
, iid
))
230 return object_picker_create(out
);
232 return CLASS_E_CLASSNOTAVAILABLE
;
236 static HRESULT WINAPI
class_factory_LockServer(IClassFactory
*iface
, BOOL lock
)
238 TRACE("lock %d.\n", lock
);
241 IClassFactory_AddRef(iface
);
243 IClassFactory_Release(iface
);
248 static IClassFactoryVtbl class_factory_vtbl
=
250 class_factory_QueryInterface
,
251 class_factory_AddRef
,
252 class_factory_Release
,
253 class_factory_CreateInstance
,
254 class_factory_LockServer
258 static struct class_factory class_factory
= {{&class_factory_vtbl
}, 0};
260 /***********************************************************************
261 * DllGetClassObject (OBJSEL.@)
263 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, void **out
)
265 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid
), debugstr_guid(iid
), out
);
269 if (IsEqualGUID(clsid
, &CLSID_DsObjectPicker
))
270 return IClassFactory_QueryInterface(&class_factory
.IClassFactory_iface
, iid
, out
);
272 FIXME("%s not available, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid
));
273 return CLASS_E_CLASSNOTAVAILABLE
;