Implement CryptRegisterOIDFunction and CryptSIPAddProvider.
[wine] / dlls / dmloader / dmloader_main.c
1 /* DirectMusicLoader Main
2  *
3  * Copyright (C) 2003 Rok Mandeljc
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
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
13  * GNU Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include "dmloader_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
23
24 typedef struct
25 {
26     /* IUnknown fields */
27     ICOM_VFIELD(IClassFactory);
28     DWORD                       ref;
29 } IClassFactoryImpl;
30
31 /******************************************************************
32  *              DirectMusicLoader ClassFactory
33  */
34 static HRESULT WINAPI LoaderCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
35 {
36         ICOM_THIS(IClassFactoryImpl,iface);
37
38         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
39         return E_NOINTERFACE;
40 }
41
42 static ULONG WINAPI LoaderCF_AddRef(LPCLASSFACTORY iface)
43 {
44         ICOM_THIS(IClassFactoryImpl,iface);
45         return ++(This->ref);
46 }
47
48 static ULONG WINAPI LoaderCF_Release(LPCLASSFACTORY iface)
49 {
50         ICOM_THIS(IClassFactoryImpl,iface);
51         /* static class, won't be  freed */
52         return --(This->ref);
53 }
54
55 static HRESULT WINAPI LoaderCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
56 {
57         ICOM_THIS(IClassFactoryImpl,iface);
58
59         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
60         if (IsEqualIID (&IID_IDirectMusicLoader, riid) ||
61             IsEqualIID (&IID_IDirectMusicLoader8, riid)) {
62           return DMUSIC_CreateDirectMusicLoader(riid, (LPDIRECTMUSICLOADER8*) ppobj, pOuter);
63         }
64         
65         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
66         return E_NOINTERFACE;
67 }
68
69 static HRESULT WINAPI LoaderCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
70 {
71         ICOM_THIS(IClassFactoryImpl,iface);
72         FIXME("(%p)->(%d),stub!\n", This, dolock);
73         return S_OK;
74 }
75
76 static ICOM_VTABLE(IClassFactory) LoaderCF_Vtbl = {
77         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
78         LoaderCF_QueryInterface,
79         LoaderCF_AddRef,
80         LoaderCF_Release,
81         LoaderCF_CreateInstance,
82         LoaderCF_LockServer
83 };
84
85 static IClassFactoryImpl Loader_CF = {&LoaderCF_Vtbl, 1 };
86
87 /******************************************************************
88  *              DirectMusicContainer ClassFactory
89  */
90 static HRESULT WINAPI ContainerCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
91 {
92         ICOM_THIS(IClassFactoryImpl,iface);
93
94         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
95         return E_NOINTERFACE;
96 }
97
98 static ULONG WINAPI ContainerCF_AddRef(LPCLASSFACTORY iface)
99 {
100         ICOM_THIS(IClassFactoryImpl,iface);
101         return ++(This->ref);
102 }
103
104 static ULONG WINAPI ContainerCF_Release(LPCLASSFACTORY iface)
105 {
106         ICOM_THIS(IClassFactoryImpl,iface);
107         /* static class, won't be  freed */
108         return --(This->ref);
109 }
110
111 static HRESULT WINAPI ContainerCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
112 {
113         ICOM_THIS(IClassFactoryImpl,iface);
114
115         TRACE ("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
116         if (IsEqualIID (riid, &IID_IDirectMusicContainer)) {
117           return DMUSIC_CreateDirectMusicContainer (riid, (LPDIRECTMUSICCONTAINER*) ppobj, pOuter);
118         } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
119                 return DMUSIC_CreateDirectMusicContainerObject (riid, (LPDIRECTMUSICOBJECT*) ppobj, pOuter);
120         }
121         
122         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
123         return E_NOINTERFACE;
124 }
125
126 static HRESULT WINAPI ContainerCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
127 {
128         ICOM_THIS(IClassFactoryImpl,iface);
129         FIXME("(%p)->(%d),stub!\n", This, dolock);
130         return S_OK;
131 }
132
133 static ICOM_VTABLE(IClassFactory) ContainerCF_Vtbl = {
134         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
135         ContainerCF_QueryInterface,
136         ContainerCF_AddRef,
137         ContainerCF_Release,
138         ContainerCF_CreateInstance,
139         ContainerCF_LockServer
140 };
141
142 static IClassFactoryImpl Container_CF = {&ContainerCF_Vtbl, 1 };
143
144 /******************************************************************
145  *              DllMain
146  *
147  *
148  */
149 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
150 {
151         if (fdwReason == DLL_PROCESS_ATTACH)
152         {
153             DisableThreadLibraryCalls(hinstDLL);
154                 /* FIXME: Initialisation */
155         }
156         else if (fdwReason == DLL_PROCESS_DETACH)
157         {
158                 /* FIXME: Cleanup */
159         }
160
161         return TRUE;
162 }
163
164
165 /******************************************************************
166  *              DllCanUnloadNow (DMLOADER.1)
167  *
168  *
169  */
170 HRESULT WINAPI DMLOADER_DllCanUnloadNow(void)
171 {
172     FIXME("(void): stub\n");
173
174     return S_FALSE;
175 }
176
177
178 /******************************************************************
179  *              DllGetClassObject (DMLOADER.2)
180  *
181  *
182  */
183 HRESULT WINAPI DMLOADER_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
184 {
185     TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
186     if (IsEqualCLSID (rclsid, &CLSID_DirectMusicLoader) && IsEqualIID (riid, &IID_IClassFactory)) {
187                 *ppv = (LPVOID) &Loader_CF;
188                 IClassFactory_AddRef((IClassFactory*)*ppv);
189                 return S_OK;
190         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicContainer) && IsEqualIID (riid, &IID_IClassFactory)) {
191                 *ppv = (LPVOID) &Container_CF;
192                 IClassFactory_AddRef((IClassFactory*)*ppv);
193                 return S_OK;
194         }
195         
196     WARN("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
197     return CLASS_E_CLASSNOTAVAILABLE;
198 }