oledb32: Add IDataInitialize interface support.
[wine/multimedia.git] / dlls / oledb32 / datainit.c
blobaf596fead301d36b0d763be08ac97b00a7aa289d
1 /*
2 * Copyright (C) 2012 Alistair Leslie-Hughes
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
18 #include <stdarg.h>
20 #define COBJMACROS
21 #define NONAMELESSUNION
22 #define NONAMELESSSTRUCT
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winnls.h"
27 #include "ole2.h"
28 #include "msdasc.h"
29 #include "oledberr.h"
31 #include "oledb_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(oledb);
38 typedef struct datainit
40 IDataInitialize IDataInitialize_iface;
42 LONG ref;
43 } datainit;
45 static inline datainit *impl_from_IDataInitialize(IDataInitialize *iface)
47 return CONTAINING_RECORD(iface, datainit, IDataInitialize_iface);
50 static HRESULT WINAPI datainit_QueryInterface(IDataInitialize *iface, REFIID riid, void **obj)
52 datainit *This = impl_from_IDataInitialize(iface);
53 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
55 *obj = NULL;
57 if(IsEqualIID(riid, &IID_IUnknown) ||
58 IsEqualIID(riid, &IID_IDataInitialize))
60 *obj = &This->IDataInitialize_iface;
62 else
64 FIXME("interface %s not implemented\n", debugstr_guid(riid));
65 return E_NOINTERFACE;
68 IDataInitialize_AddRef(iface);
69 return S_OK;
72 static ULONG WINAPI datainit_AddRef(IDataInitialize *iface)
74 datainit *This = impl_from_IDataInitialize(iface);
75 TRACE("(%p)\n", This);
77 return InterlockedIncrement(&This->ref);
80 static ULONG WINAPI datainit_Release(IDataInitialize *iface)
82 datainit *This = impl_from_IDataInitialize(iface);
83 LONG ref;
85 TRACE("(%p)\n", This);
87 ref = InterlockedDecrement(&This->ref);
88 if(ref == 0)
90 HeapFree(GetProcessHeap(), 0, This);
93 return ref;
96 /*** IDataInitialize methods ***/
97 static HRESULT WINAPI datainit_GetDataSource(IDataInitialize *iface, IUnknown *pUnkOuter, DWORD dwClsCtx,
98 LPWSTR pwszInitializationString, REFIID riid, IUnknown **ppDataSource)
100 datainit *This = impl_from_IDataInitialize(iface);
102 FIXME("(%p)->(%p %d %s %s %p)\n", This, pUnkOuter, dwClsCtx, debugstr_w(pwszInitializationString),
103 debugstr_guid(riid), ppDataSource);
105 return E_NOTIMPL;
108 static HRESULT WINAPI datainit_GetInitializationString(IDataInitialize *iface, IUnknown *pDataSource,
109 boolean fIncludePassword, LPWSTR *ppwszInitString)
111 datainit *This = impl_from_IDataInitialize(iface);
113 FIXME("(%p)->(%p %d %p)\n", This, pDataSource, fIncludePassword, ppwszInitString);
115 return E_NOTIMPL;
118 static HRESULT WINAPI datainit_CreateDBInstance(IDataInitialize *iface, REFCLSID clsidProvider,
119 IUnknown *pUnkOuter, DWORD dwClsCtx, LPWSTR pwszReserved, REFIID riid,
120 IUnknown **ppDataSource)
122 datainit *This = impl_from_IDataInitialize(iface);
124 FIXME("(%p)->()\n", This);
126 return E_NOTIMPL;
129 static HRESULT WINAPI datainit_RemoteCreateDBInstanceEx(IDataInitialize *iface, REFCLSID clsidProvider,
130 IUnknown *pUnkOuter, DWORD dwClsCtx, LPWSTR pwszReserved, COSERVERINFO *pServerInfo,
131 DWORD cmq, GUID **rgpIID, IUnknown **rgpItf, HRESULT *rghr)
133 datainit *This = impl_from_IDataInitialize(iface);
135 FIXME("(%p)->()\n", This);
137 return E_NOTIMPL;
140 static HRESULT WINAPI datainit_LoadStringFromStorage(IDataInitialize *iface, LPWSTR pwszFileName,
141 LPWSTR *ppwszInitializationString)
143 datainit *This = impl_from_IDataInitialize(iface);
145 FIXME("(%p)->(%s %p)\n", This, debugstr_w(pwszFileName), ppwszInitializationString);
147 return E_NOTIMPL;
150 static HRESULT WINAPI datainit_WriteStringToStorage(IDataInitialize *iface, LPWSTR pwszFileName,
151 LPWSTR pwszInitializationString, DWORD dwCreationDisposition)
153 datainit *This = impl_from_IDataInitialize(iface);
155 FIXME("(%p)->(%s %s %d)\n", This, debugstr_w(pwszFileName), debugstr_w(pwszInitializationString), dwCreationDisposition);
157 return E_NOTIMPL;
161 static const struct IDataInitializeVtbl datainit_vtbl =
163 datainit_QueryInterface,
164 datainit_AddRef,
165 datainit_Release,
166 datainit_GetDataSource,
167 datainit_GetInitializationString,
168 datainit_CreateDBInstance,
169 datainit_RemoteCreateDBInstanceEx,
170 datainit_LoadStringFromStorage,
171 datainit_WriteStringToStorage
174 HRESULT create_data_init(IUnknown *outer, void **obj)
176 datainit *This;
178 TRACE("(%p)\n", obj);
180 if(outer) return CLASS_E_NOAGGREGATION;
182 *obj = NULL;
184 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
185 if(!This) return E_OUTOFMEMORY;
187 This->IDataInitialize_iface.lpVtbl = &datainit_vtbl;
188 This->ref = 1;
190 *obj = &This->IDataInitialize_iface;
192 return S_OK;