1 /* DirectMusicBand Main
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dmband_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(dmband
);
26 LONG DMBAND_refCount
= 0;
29 IClassFactory IClassFactory_iface
;
30 HRESULT (*fnCreateInstance
)(REFIID riid
, void **ret_iface
);
33 /******************************************************************
34 * IClassFactory implementation
36 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
38 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
41 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
46 if (IsEqualGUID(&IID_IUnknown
, riid
))
47 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
48 else if (IsEqualGUID(&IID_IClassFactory
, riid
))
49 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
51 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
57 IClassFactory_AddRef(iface
);
61 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
65 return 2; /* non-heap based object */
68 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
70 DMBAND_UnlockModule();
72 return 1; /* non-heap based object */
75 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pUnkOuter
,
76 REFIID riid
, void **ppv
)
78 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
80 TRACE ("(%p, %s, %p)\n", pUnkOuter
, debugstr_dmguid(riid
), ppv
);
84 return CLASS_E_NOAGGREGATION
;
87 return This
->fnCreateInstance(riid
, ppv
);
90 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
92 TRACE("(%d)\n", dolock
);
97 DMBAND_UnlockModule();
102 static const IClassFactoryVtbl classfactory_vtbl
= {
103 ClassFactory_QueryInterface
,
105 ClassFactory_Release
,
106 ClassFactory_CreateInstance
,
107 ClassFactory_LockServer
110 static IClassFactoryImpl Band_CF
= {{&classfactory_vtbl
}, create_dmband
};
111 static IClassFactoryImpl BandTrack_CF
= {{&classfactory_vtbl
}, create_dmbandtrack
};
113 /******************************************************************
114 * DllCanUnloadNow (DMBAND.@)
118 HRESULT WINAPI
DllCanUnloadNow(void)
120 return DMBAND_refCount
!= 0 ? S_FALSE
: S_OK
;
124 /******************************************************************
125 * DllGetClassObject (DMBAND.@)
129 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
131 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid
), debugstr_dmguid(riid
), ppv
);
133 if (IsEqualCLSID(rclsid
, &CLSID_DirectMusicBand
))
134 return IClassFactory_QueryInterface(&Band_CF
.IClassFactory_iface
, riid
, ppv
);
135 else if (IsEqualCLSID(rclsid
, &CLSID_DirectMusicBandTrack
))
136 return IClassFactory_QueryInterface(&BandTrack_CF
.IClassFactory_iface
, riid
, ppv
);
138 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid
), debugstr_dmguid(riid
), ppv
);
139 return CLASS_E_CLASSNOTAVAILABLE
;