msado15: Add IConnectionPointContainer stub to _Connection.
[wine.git] / dlls / msado15 / main.c
blob770a02fc59d17789a789b221c7460498c11a8f23
1 /*
2 * Copyright 2019 Hans Leidekker for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include "windef.h"
21 #include "winbase.h"
22 #define COBJMACROS
23 #include "objbase.h"
24 #include "rpcproxy.h"
25 #include "msado15_backcompat.h"
27 #include "wine/debug.h"
28 #include "wine/heap.h"
30 #include "msado15_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(msado15);
34 static HINSTANCE hinstance;
36 BOOL WINAPI DllMain( HINSTANCE dll, DWORD reason, LPVOID reserved )
38 switch (reason)
40 case DLL_PROCESS_ATTACH:
41 hinstance = dll;
42 DisableThreadLibraryCalls( dll );
43 break;
45 return TRUE;
48 typedef HRESULT (*fnCreateInstance)( void **obj );
50 struct msadocf
52 IClassFactory IClassFactory_iface;
53 fnCreateInstance pfnCreateInstance;
56 static inline struct msadocf *impl_from_IClassFactory( IClassFactory *iface )
58 return CONTAINING_RECORD( iface, struct msadocf, IClassFactory_iface );
61 static HRESULT WINAPI msadocf_QueryInterface( IClassFactory *iface, REFIID riid, void **obj )
63 if (IsEqualGUID( riid, &IID_IUnknown ) || IsEqualGUID( riid, &IID_IClassFactory ))
65 IClassFactory_AddRef( iface );
66 *obj = iface;
67 return S_OK;
69 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
70 return E_NOINTERFACE;
73 static ULONG WINAPI msadocf_AddRef( IClassFactory *iface )
75 return 2;
78 static ULONG WINAPI msadocf_Release( IClassFactory *iface )
80 return 1;
83 static HRESULT WINAPI msadocf_CreateInstance( IClassFactory *iface, LPUNKNOWN outer, REFIID riid, void **obj )
85 struct msadocf *cf = impl_from_IClassFactory( iface );
86 IUnknown *unknown;
87 HRESULT hr;
89 TRACE( "%p, %s, %p\n", outer, debugstr_guid(riid), obj );
91 *obj = NULL;
92 if (outer)
93 return CLASS_E_NOAGGREGATION;
95 hr = cf->pfnCreateInstance( (void **)&unknown );
96 if (FAILED(hr))
97 return hr;
99 hr = IUnknown_QueryInterface( unknown, riid, obj );
100 IUnknown_Release( unknown );
101 return hr;
104 static HRESULT WINAPI msadocf_LockServer( IClassFactory *iface, BOOL dolock )
106 FIXME( "%p, %d\n", iface, dolock );
107 return S_OK;
110 static const struct IClassFactoryVtbl msadocf_vtbl =
112 msadocf_QueryInterface,
113 msadocf_AddRef,
114 msadocf_Release,
115 msadocf_CreateInstance,
116 msadocf_LockServer
119 static struct msadocf command_cf = { { &msadocf_vtbl }, Command_create };
120 static struct msadocf connection_cf = { { &msadocf_vtbl }, Connection_create };
121 static struct msadocf recordset_cf = { { &msadocf_vtbl }, Recordset_create };
122 static struct msadocf stream_cf = { { &msadocf_vtbl }, Stream_create };
124 /***********************************************************************
125 * DllGetClassObject
127 HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID iid, void **obj )
129 IClassFactory *cf = NULL;
131 TRACE( "%s, %s, %p\n", debugstr_guid(clsid), debugstr_guid(iid), obj );
133 if (IsEqualGUID( clsid, &CLSID_Connection ))
135 cf = &connection_cf.IClassFactory_iface;
137 else if (IsEqualGUID( clsid, &CLSID_Recordset ))
139 cf = &recordset_cf.IClassFactory_iface;
141 else if (IsEqualGUID( clsid, &CLSID_Stream ))
143 cf = &stream_cf.IClassFactory_iface;
145 else if (IsEqualGUID( clsid, &CLSID_Command ))
147 cf = &command_cf.IClassFactory_iface;
149 if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
150 return IClassFactory_QueryInterface( cf, iid, obj );
153 /******************************************************************
154 * DllCanUnloadNow
156 HRESULT WINAPI DllCanUnloadNow(void)
158 return S_FALSE;
161 /***********************************************************************
162 * DllRegisterServer
164 HRESULT WINAPI DllRegisterServer( void )
166 return __wine_register_resources( hinstance );
169 /***********************************************************************
170 * DllUnregisterServer
172 HRESULT WINAPI DllUnregisterServer( void )
174 return __wine_unregister_resources( hinstance );