2 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "wine/debug.h"
30 #include "avifile_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(avifile);
35 IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj);
36 static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface);
37 static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface);
38 static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj);
39 static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock);
41 static ICOM_VTABLE(IClassFactory) iclassfact =
43 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
44 IClassFactory_fnQueryInterface,
45 IClassFactory_fnAddRef,
46 IClassFactory_fnRelease,
47 IClassFactory_fnCreateInstance,
48 IClassFactory_fnLockServer
54 ICOM_VFIELD(IClassFactory);
58 static IClassFactoryImpl AVIFILE_GlobalCF = {&iclassfact, 0 };
63 IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
65 ICOM_THIS(IClassFactoryImpl,iface);
67 TRACE("(%p)->(%p,%p)\n",This,riid,ppobj);
68 if ( ( IsEqualGUID( &IID_IUnknown, riid ) ) ||
69 ( IsEqualGUID( &IID_IClassFactory, riid ) ) )
72 IClassFactory_AddRef(iface);
79 static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
81 ICOM_THIS(IClassFactoryImpl,iface);
83 TRACE("(%p)->()\n",This);
84 if ( (This->ref) == 0 )
85 AVIFILE_data.dwClassObjRef ++;
90 static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
92 ICOM_THIS(IClassFactoryImpl,iface);
94 TRACE("(%p)->()\n",This);
95 if ( (--(This->ref)) > 0 )
98 AVIFILE_data.dwClassObjRef --;
102 static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj)
104 /*ICOM_THIS(IClassFactoryImpl,iface);*/
107 if ( pOuter != NULL )
110 if ( IsEqualGUID( &IID_IAVIFile, riid ) )
111 return AVIFILE_CreateIAVIFile(ppobj);
112 if ( IsEqualGUID( &IID_IAVIStream, riid ) )
113 return AVIFILE_CreateIAVIStream(ppobj);
115 return E_NOINTERFACE;
118 static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock)
120 ICOM_THIS(IClassFactoryImpl,iface);
123 FIXME("(%p)->(%d),stub!\n",This,dolock);
125 hr = IClassFactory_AddRef(iface);
127 hr = IClassFactory_Release(iface);
133 /***********************************************************************
134 * DllGetClassObject (AVIFIL32.@)
136 HRESULT WINAPI AVIFILE_DllGetClassObject(const CLSID* pclsid,const IID* piid,void** ppv)
139 if ( IsEqualCLSID( &IID_IClassFactory, piid ) )
141 *ppv = (LPVOID)&AVIFILE_GlobalCF;
142 IClassFactory_AddRef((IClassFactory*)*ppv);
146 return CLASS_E_CLASSNOTAVAILABLE;
149 /*****************************************************************************
150 * DllCanUnloadNow (AVIFIL32.@)
152 DWORD WINAPI AVIFILE_DllCanUnloadNow(void)
154 return ( AVIFILE_data.dwClassObjRef == 0 ) ? S_OK : S_FALSE;