qasf: Build without -DWINE_NO_LONG_TYPES.
[wine.git] / dlls / itss / itss.c
blob6d41ef38c3857166fb2d7f38343bbf0e40842057
1 /*
2 * ITSS Class Factory
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2004 Mike McCormack
7 * see http://bonedaddy.net/pabs3/hhm/#chmspec
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include <stdarg.h>
26 #include <stdio.h>
28 #define COBJMACROS
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winuser.h"
33 #include "winreg.h"
34 #include "ole2.h"
35 #include "rpcproxy.h"
36 #include "advpub.h"
38 #include "wine/debug.h"
40 #include "itsstor.h"
42 #include "initguid.h"
43 #include "wine/itss.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(itss);
47 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
49 LONG dll_count = 0;
51 /******************************************************************************
52 * ITSS ClassFactory
54 typedef struct {
55 IClassFactory IClassFactory_iface;
56 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
57 } IClassFactoryImpl;
59 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
61 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
64 static HRESULT WINAPI
65 ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
67 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
69 if (IsEqualGUID(riid, &IID_IUnknown) ||
70 IsEqualGUID(riid, &IID_IClassFactory))
72 IClassFactory_AddRef(iface);
73 *ppobj = &This->IClassFactory_iface;
74 return S_OK;
77 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
78 return E_NOINTERFACE;
81 static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
83 ITSS_LockModule();
84 return 2;
87 static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
89 ITSS_UnlockModule();
90 return 1;
94 static HRESULT WINAPI ITSSCF_CreateInstance(IClassFactory *iface, IUnknown *outer,
95 REFIID riid, void **ppv)
97 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
98 IUnknown *unk;
99 HRESULT hres;
101 TRACE("(%p)->(%p %s %p)\n", This, outer, debugstr_guid(riid), ppv);
103 if(outer && !IsEqualGUID(riid, &IID_IUnknown)) {
104 *ppv = NULL;
105 return CLASS_E_NOAGGREGATION;
108 hres = This->pfnCreateInstance(outer, (void**)&unk);
109 if(FAILED(hres)) {
110 *ppv = NULL;
111 return hres;
114 if(!IsEqualGUID(riid, &IID_IUnknown)) {
115 hres = IUnknown_QueryInterface(unk, riid, ppv);
116 IUnknown_Release(unk);
117 }else {
118 *ppv = unk;
120 return hres;
123 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
125 TRACE("(%p)->(%d)\n", iface, dolock);
127 if (dolock)
128 ITSS_LockModule();
129 else
130 ITSS_UnlockModule();
132 return S_OK;
135 static const IClassFactoryVtbl ITSSCF_Vtbl =
137 ITSSCF_QueryInterface,
138 ITSSCF_AddRef,
139 ITSSCF_Release,
140 ITSSCF_CreateInstance,
141 ITSSCF_LockServer
144 static const IClassFactoryImpl ITStorage_factory = { { &ITSSCF_Vtbl }, ITSS_create };
145 static const IClassFactoryImpl MSITStore_factory = { { &ITSSCF_Vtbl }, ITS_IParseDisplayName_create };
146 static const IClassFactoryImpl ITSProtocol_factory = { { &ITSSCF_Vtbl }, ITSProtocol_create };
148 /***********************************************************************
149 * DllGetClassObject (ITSS.@)
151 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
153 const IClassFactoryImpl *factory;
155 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
157 if (IsEqualGUID(&CLSID_ITStorage, rclsid))
158 factory = &ITStorage_factory;
159 else if (IsEqualGUID(&CLSID_MSITStore, rclsid))
160 factory = &MSITStore_factory;
161 else if (IsEqualGUID(&CLSID_ITSProtocol, rclsid))
162 factory = &ITSProtocol_factory;
163 else
165 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
166 return CLASS_E_CLASSNOTAVAILABLE;
169 return IUnknown_QueryInterface( (IUnknown*) factory, iid, ppv );
172 /*****************************************************************************/
174 typedef struct {
175 IITStorage IITStorage_iface;
176 LONG ref;
177 } ITStorageImpl;
179 static inline ITStorageImpl *impl_from_IITStorage(IITStorage *iface)
181 return CONTAINING_RECORD(iface, ITStorageImpl, IITStorage_iface);
185 static HRESULT WINAPI ITStorageImpl_QueryInterface(
186 IITStorage* iface,
187 REFIID riid,
188 void** ppvObject)
190 ITStorageImpl *This = impl_from_IITStorage(iface);
191 if (IsEqualGUID(riid, &IID_IUnknown)
192 || IsEqualGUID(riid, &IID_IITStorage))
194 IITStorage_AddRef(iface);
195 *ppvObject = iface;
196 return S_OK;
199 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
200 return E_NOINTERFACE;
203 static ULONG WINAPI ITStorageImpl_AddRef(
204 IITStorage* iface)
206 ITStorageImpl *This = impl_from_IITStorage(iface);
207 TRACE("%p\n", This);
208 return InterlockedIncrement(&This->ref);
211 static ULONG WINAPI ITStorageImpl_Release(
212 IITStorage* iface)
214 ITStorageImpl *This = impl_from_IITStorage(iface);
215 ULONG ref = InterlockedDecrement(&This->ref);
217 if (ref == 0) {
218 HeapFree(GetProcessHeap(), 0, This);
219 ITSS_UnlockModule();
222 return ref;
225 static HRESULT WINAPI ITStorageImpl_StgCreateDocfile(
226 IITStorage* iface,
227 const WCHAR* pwcsName,
228 DWORD grfMode,
229 DWORD reserved,
230 IStorage** ppstgOpen)
232 ITStorageImpl *This = impl_from_IITStorage(iface);
234 TRACE("%p %s %u %u %p\n", This,
235 debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
237 return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
238 0, reserved, ppstgOpen);
241 static HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(
242 IITStorage* iface,
243 ILockBytes* plkbyt,
244 DWORD grfMode,
245 DWORD reserved,
246 IStorage** ppstgOpen)
248 ITStorageImpl *This = impl_from_IITStorage(iface);
249 FIXME("%p\n", This);
250 return E_NOTIMPL;
253 static HRESULT WINAPI ITStorageImpl_StgIsStorageFile(
254 IITStorage* iface,
255 const WCHAR* pwcsName)
257 ITStorageImpl *This = impl_from_IITStorage(iface);
258 FIXME("%p\n", This);
259 return E_NOTIMPL;
262 static HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(
263 IITStorage* iface,
264 ILockBytes* plkbyt)
266 ITStorageImpl *This = impl_from_IITStorage(iface);
267 FIXME("%p\n", This);
268 return E_NOTIMPL;
271 static HRESULT WINAPI ITStorageImpl_StgOpenStorage(
272 IITStorage* iface,
273 const WCHAR* pwcsName,
274 IStorage* pstgPriority,
275 DWORD grfMode,
276 SNB snbExclude,
277 DWORD reserved,
278 IStorage** ppstgOpen)
280 ITStorageImpl *This = impl_from_IITStorage(iface);
282 TRACE("%p %s %p %d %p\n", This, debugstr_w( pwcsName ),
283 pstgPriority, grfMode, snbExclude );
285 return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
286 snbExclude, reserved, ppstgOpen);
289 static HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(
290 IITStorage* iface,
291 ILockBytes* plkbyt,
292 IStorage* pStgPriority,
293 DWORD grfMode,
294 SNB snbExclude,
295 DWORD reserved,
296 IStorage** ppstgOpen)
298 ITStorageImpl *This = impl_from_IITStorage(iface);
299 FIXME("%p\n", This);
300 return E_NOTIMPL;
303 static HRESULT WINAPI ITStorageImpl_StgSetTimes(
304 IITStorage* iface,
305 const WCHAR* lpszName,
306 const FILETIME* pctime,
307 const FILETIME* patime,
308 const FILETIME* pmtime)
310 ITStorageImpl *This = impl_from_IITStorage(iface);
311 FIXME("%p\n", This);
312 return E_NOTIMPL;
315 static HRESULT WINAPI ITStorageImpl_SetControlData(
316 IITStorage* iface,
317 PITS_Control_Data pControlData)
319 ITStorageImpl *This = impl_from_IITStorage(iface);
320 FIXME("%p\n", This);
321 return E_NOTIMPL;
324 static HRESULT WINAPI ITStorageImpl_DefaultControlData(
325 IITStorage* iface,
326 PITS_Control_Data* ppControlData)
328 ITStorageImpl *This = impl_from_IITStorage(iface);
329 FIXME("%p\n", This);
330 return E_NOTIMPL;
333 static HRESULT WINAPI ITStorageImpl_Compact(
334 IITStorage* iface,
335 const WCHAR* pwcsName,
336 ECompactionLev iLev)
338 ITStorageImpl *This = impl_from_IITStorage(iface);
339 FIXME("%p\n", This);
340 return E_NOTIMPL;
343 static const IITStorageVtbl ITStorageImpl_Vtbl =
345 ITStorageImpl_QueryInterface,
346 ITStorageImpl_AddRef,
347 ITStorageImpl_Release,
348 ITStorageImpl_StgCreateDocfile,
349 ITStorageImpl_StgCreateDocfileOnILockBytes,
350 ITStorageImpl_StgIsStorageFile,
351 ITStorageImpl_StgIsStorageILockBytes,
352 ITStorageImpl_StgOpenStorage,
353 ITStorageImpl_StgOpenStorageOnILockBytes,
354 ITStorageImpl_StgSetTimes,
355 ITStorageImpl_SetControlData,
356 ITStorageImpl_DefaultControlData,
357 ITStorageImpl_Compact,
360 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
362 ITStorageImpl *its;
364 if( pUnkOuter )
365 return CLASS_E_NOAGGREGATION;
367 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
368 its->IITStorage_iface.lpVtbl = &ITStorageImpl_Vtbl;
369 its->ref = 1;
371 TRACE("-> %p\n", its);
372 *ppObj = its;
374 ITSS_LockModule();
375 return S_OK;
378 /*****************************************************************************/
380 HRESULT WINAPI DllCanUnloadNow(void)
382 TRACE("dll_count = %u\n", dll_count);
383 return dll_count ? S_FALSE : S_OK;