oleaut32: Rewrite RollUdate to be easier to change and to support more conversions.
[wine] / dlls / msdaps / main.c
1 /*
2  * msdaps initialisation.
3  *
4  * Copyright 2010 Huw Davies
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 #include <stdarg.h>
21 #include <string.h>
22
23 #define COBJMACROS
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winerror.h"
32 #include "objbase.h"
33 #include "oleauto.h"
34 #include "oledb.h"
35
36 #include "row_server.h"
37
38 #include "wine/debug.h"
39
40 WINE_DEFAULT_DEBUG_CHANNEL(oledb);
41
42 extern BOOL WINAPI msdaps_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
43 extern HRESULT WINAPI msdaps_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN;
44 extern HRESULT WINAPI msdaps_DllCanUnloadNow(void) DECLSPEC_HIDDEN;
45
46 /*****************************************************************************
47  *              DllMain
48  */
49 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
50 {
51     return msdaps_DllMain(instance, reason, reserved);
52 }
53
54
55 /******************************************************************************
56  * ClassFactory
57  */
58 typedef struct
59 {
60     const IClassFactoryVtbl *lpVtbl;
61     HRESULT (*create_object)( IUnknown*, LPVOID* );
62 } cf;
63
64 static HRESULT WINAPI CF_QueryInterface(IClassFactory *iface, REFIID riid, void **obj)
65 {
66     cf *This = (cf *)iface;
67
68     TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), obj);
69
70     if( IsEqualCLSID( riid, &IID_IUnknown ) ||
71         IsEqualCLSID( riid, &IID_IClassFactory ) )
72     {
73         IClassFactory_AddRef( iface );
74         *obj = iface;
75         return S_OK;
76     }
77     return E_NOINTERFACE;
78 }
79
80 static ULONG WINAPI CF_AddRef(IClassFactory *iface)
81 {
82     return 2;
83 }
84
85 static ULONG WINAPI CF_Release(IClassFactory *iface)
86 {
87     return 1;
88 }
89
90 static HRESULT WINAPI CF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **obj)
91 {
92     cf *This = (cf *)iface;
93     IUnknown *unk = NULL;
94     HRESULT r;
95
96     TRACE("(%p, %p, %s, %p)\n", This, pOuter, debugstr_guid(riid), obj);
97
98     r = This->create_object( pOuter, (void **) &unk );
99     if (SUCCEEDED(r))
100     {
101         r = IUnknown_QueryInterface( unk, riid, obj );
102         IUnknown_Release( unk );
103     }
104     return r;
105 }
106
107 static HRESULT WINAPI CF_LockServer(IClassFactory *iface, BOOL dolock)
108 {
109     FIXME("(%p, %d): stub\n", iface, dolock);
110     return S_OK;
111 }
112
113 static const IClassFactoryVtbl CF_Vtbl =
114 {
115     CF_QueryInterface,
116     CF_AddRef,
117     CF_Release,
118     CF_CreateInstance,
119     CF_LockServer
120 };
121
122 static cf row_server_cf = { &CF_Vtbl, create_row_server };
123 static cf row_proxy_cf  = { &CF_Vtbl, create_row_marshal };
124 static cf rowset_server_cf = { &CF_Vtbl, create_rowset_server };
125 static cf rowset_proxy_cf  = { &CF_Vtbl, create_rowset_marshal };
126
127 /***********************************************************************
128  *              DllGetClassObject
129  */
130 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *obj)
131 {
132     TRACE("(%s, %s, %p)\n", debugstr_guid(clsid), debugstr_guid(iid), obj);
133
134     if (IsEqualCLSID(clsid, &CLSID_wine_row_server))
135     {
136         *obj = &row_server_cf;
137         return S_OK;
138     }
139
140     if (IsEqualCLSID(clsid, &CLSID_wine_row_proxy))
141     {
142         *obj = &row_proxy_cf;
143         return S_OK;
144     }
145
146     if (IsEqualCLSID(clsid, &CLSID_wine_rowset_server))
147     {
148         *obj = &rowset_server_cf;
149         return S_OK;
150     }
151
152     if (IsEqualCLSID(clsid, &CLSID_wine_rowset_proxy))
153     {
154         *obj = &rowset_proxy_cf;
155         return S_OK;
156     }
157
158     return msdaps_DllGetClassObject(clsid, iid, obj);
159 }
160
161 /***********************************************************************
162  *              DllCanUnloadNow
163  */
164 HRESULT WINAPI DllCanUnloadNow(void)
165 {
166     return msdaps_DllCanUnloadNow();
167 }