makefiles: Don't use standard libs for programs that specify -nodefaultlibs.
[wine/zf.git] / dlls / oledb32 / dslocator.c
blob8a7f2d134c861832c069244d05ecce65d544157d
1 /* Data Links
3 * Copyright 2013 Alistair Leslie-Hughes
5 * This library 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 library 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 library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <string.h>
22 #define COBJMACROS
23 #define NONAMELESSUNION
25 #include "windef.h"
26 #include "winbase.h"
27 #include "objbase.h"
28 #include "oleauto.h"
29 #include "winerror.h"
30 #include "oledb.h"
31 #include "oledberr.h"
32 #include "msdasc.h"
33 #include "prsht.h"
34 #include "commctrl.h"
36 #include "oledb_private.h"
37 #include "resource.h"
39 #include "wine/debug.h"
40 #include "wine/heap.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(oledb);
44 struct datasource
46 CLSID clsid;
47 IDBProperties *provider;
48 DBPROPINFOSET *propinfoset;
49 WCHAR *description;
52 static struct datasource *create_datasource(WCHAR *guid)
54 struct datasource *data = heap_alloc_zero(sizeof(struct datasource));
55 if (data)
57 CLSIDFromString(guid, &data->clsid);
60 return data;
63 static void destroy_datasource(struct datasource *data)
65 if (data->propinfoset)
67 ULONG i;
69 for (i = 0; i < data->propinfoset->cPropertyInfos; i++)
70 VariantClear(&data->propinfoset->rgPropertyInfos[i].vValues);
72 CoTaskMemFree(data->propinfoset->rgPropertyInfos);
73 CoTaskMemFree(data->propinfoset);
75 if (data->description)
76 CoTaskMemFree(data->description);
78 if (data->provider)
79 IDBProperties_Release(data->provider);
81 heap_free(data);
84 static BOOL initialize_datasource(struct datasource *data)
86 HRESULT hr;
87 DBPROPIDSET propidset;
88 ULONG infocount;
90 hr = CoCreateInstance(&data->clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IDBProperties, (void**)&data->provider);
91 if (FAILED(hr))
93 WARN("Datasource cannot be created (0x%08x)\n", hr);
94 return FALSE;
97 propidset.rgPropertyIDs = NULL;
98 propidset.cPropertyIDs = 0;
99 propidset.guidPropertySet = DBPROPSET_DBINITALL;
101 hr = IDBProperties_GetPropertyInfo(data->provider, 1, &propidset, &infocount, &data->propinfoset, &data->description);
102 if (FAILED(hr))
104 WARN("Failed to get DB Properties (0x%08x)\n", hr);
106 IDBProperties_Release(data->provider);
107 data->provider = NULL;
108 return FALSE;
111 return TRUE;
114 typedef struct DSLocatorImpl
116 IDataSourceLocator IDataSourceLocator_iface;
117 IDataInitialize IDataInitialize_iface;
118 LONG ref;
120 HWND hwnd;
121 } DSLocatorImpl;
123 static inline DSLocatorImpl *impl_from_IDataSourceLocator( IDataSourceLocator *iface )
125 return CONTAINING_RECORD(iface, DSLocatorImpl, IDataSourceLocator_iface);
128 static inline DSLocatorImpl *impl_from_IDataInitialize(IDataInitialize *iface)
130 return CONTAINING_RECORD(iface, DSLocatorImpl, IDataInitialize_iface);
133 static HRESULT WINAPI dslocator_QueryInterface(IDataSourceLocator *iface, REFIID riid, void **ppvoid)
135 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
136 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid),ppvoid);
138 *ppvoid = NULL;
140 if (IsEqualIID(riid, &IID_IUnknown) ||
141 IsEqualIID(riid, &IID_IDispatch) ||
142 IsEqualIID(riid, &IID_IDataSourceLocator))
144 *ppvoid = &This->IDataSourceLocator_iface;
146 else if (IsEqualIID(riid, &IID_IDataInitialize))
148 *ppvoid = &This->IDataInitialize_iface;
150 else if (IsEqualIID(riid, &IID_IRunnableObject))
152 TRACE("IID_IRunnableObject returning NULL\n");
153 return E_NOINTERFACE;
155 else if (IsEqualIID(riid, &IID_IProvideClassInfo))
157 TRACE("IID_IProvideClassInfo returning NULL\n");
158 return E_NOINTERFACE;
160 else if (IsEqualIID(riid, &IID_IMarshal))
162 TRACE("IID_IMarshal returning NULL\n");
163 return E_NOINTERFACE;
165 else if (IsEqualIID(riid, &IID_IRpcOptions))
167 TRACE("IID_IRpcOptions returning NULL\n");
168 return E_NOINTERFACE;
171 if(*ppvoid)
173 IUnknown_AddRef( (IUnknown*)*ppvoid );
174 return S_OK;
177 FIXME("interface %s not implemented\n", debugstr_guid(riid));
178 return E_NOINTERFACE;
181 static ULONG WINAPI dslocator_AddRef(IDataSourceLocator *iface)
183 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
184 TRACE("(%p)->%u\n",This,This->ref);
185 return InterlockedIncrement(&This->ref);
188 static ULONG WINAPI dslocator_Release(IDataSourceLocator *iface)
190 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
191 ULONG ref = InterlockedDecrement(&This->ref);
193 TRACE("(%p)->%u\n",This,ref+1);
195 if (!ref)
197 heap_free(This);
200 return ref;
203 static HRESULT WINAPI dslocator_GetTypeInfoCount(IDataSourceLocator *iface, UINT *pctinfo)
205 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
207 FIXME("(%p)->()\n", This);
209 return E_NOTIMPL;
212 static HRESULT WINAPI dslocator_GetTypeInfo(IDataSourceLocator *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
214 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
216 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
218 return E_NOTIMPL;
221 static HRESULT WINAPI dslocator_GetIDsOfNames(IDataSourceLocator *iface, REFIID riid, LPOLESTR *rgszNames,
222 UINT cNames, LCID lcid, DISPID *rgDispId)
224 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
226 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
228 return E_NOTIMPL;
231 static HRESULT WINAPI dslocator_Invoke(IDataSourceLocator *iface, DISPID dispIdMember, REFIID riid,
232 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
234 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
236 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
237 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
239 return E_NOTIMPL;
242 static HRESULT WINAPI dslocator_get_hWnd(IDataSourceLocator *iface, COMPATIBLE_LONG *phwndParent)
244 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
246 TRACE("(%p)->(%p)\n",This, phwndParent);
248 *phwndParent = (COMPATIBLE_LONG)This->hwnd;
250 return S_OK;
253 static HRESULT WINAPI dslocator_put_hWnd(IDataSourceLocator *iface, COMPATIBLE_LONG hwndParent)
255 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
257 TRACE("(%p)->(%p)\n",This, (HWND)hwndParent);
259 This->hwnd = (HWND)hwndParent;
261 return S_OK;
264 static void create_connections_columns(HWND lv)
266 RECT rc;
267 WCHAR buf[256];
268 LVCOLUMNW column;
270 SendMessageW(lv, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);
271 GetWindowRect(lv, &rc);
272 LoadStringW(instance, IDS_COL_PROVIDER, buf, ARRAY_SIZE(buf));
273 column.mask = LVCF_WIDTH | LVCF_TEXT;
274 column.cx = (rc.right - rc.left) - 5;
275 column.pszText = buf;
276 SendMessageW(lv, LVM_INSERTCOLUMNW, 0, (LPARAM)&column);
279 static void add_connections_providers(HWND lv)
281 static const WCHAR oledbprov[] = {'\\','O','L','E',' ','D','B',' ','P','r','o','v','i','d','e','r',0};
282 LONG res;
283 HKEY key = NULL, subkey;
284 DWORD index = 0;
285 LONG next_key;
286 WCHAR provider[MAX_PATH];
287 WCHAR guidkey[MAX_PATH];
288 LONG size;
290 res = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_READ, &key);
291 if (res == ERROR_FILE_NOT_FOUND)
292 return;
294 next_key = RegEnumKeyW(key, index, provider, MAX_PATH);
295 while (next_key == ERROR_SUCCESS)
297 WCHAR description[MAX_PATH];
299 lstrcpyW(guidkey, provider);
300 lstrcatW(guidkey, oledbprov);
302 res = RegOpenKeyW(key, guidkey, &subkey);
303 if (res == ERROR_SUCCESS)
305 TRACE("Found %s\n", debugstr_w(guidkey));
307 size = MAX_PATH;
308 res = RegQueryValueW(subkey, NULL, description, &size);
309 if (res == ERROR_SUCCESS)
311 LVITEMW item;
312 struct datasource *data;
314 data = create_datasource(guidkey);
316 item.mask = LVIF_TEXT | LVIF_PARAM;
317 item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0);
318 item.iSubItem = 0;
319 item.pszText = description;
320 item.lParam = (LPARAM)data;
322 SendMessageW(lv, LVM_INSERTITEMW, 0, (LPARAM)&item);
324 RegCloseKey(subkey);
327 index++;
328 next_key = RegEnumKeyW(key, index, provider, MAX_PATH);
331 RegCloseKey(key);
334 static LRESULT CALLBACK data_link_properties_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
336 TRACE("(%p, %08x, %08lx, %08lx)\n", hwnd, msg, wp, lp);
338 switch (msg)
340 case WM_INITDIALOG:
342 HWND btn, lv = GetDlgItem(hwnd, IDC_LST_CONNECTIONS);
343 create_connections_columns(lv);
344 add_connections_providers(lv);
346 btn = GetDlgItem(GetParent(hwnd), IDOK);
347 EnableWindow(btn, FALSE);
349 break;
351 case WM_DESTROY:
353 HWND lv = GetDlgItem(hwnd, IDC_LST_CONNECTIONS);
354 LVITEMA item;
356 item.iItem = 0;
357 item.iSubItem = 0;
358 item.mask = LVIF_PARAM;
360 while(ListView_GetItemA(lv, &item))
362 destroy_datasource( (struct datasource *)item.lParam);
363 item.iItem++;
365 break;
367 case WM_NOTIFY:
369 NMHDR *hdr = ((LPNMHDR)lp);
370 switch(hdr->code)
372 case PSN_KILLACTIVE:
374 LVITEMA item;
376 * FIXME: This needs to replace the connection page based off the selection.
377 * We only care about the ODBC for now which is the default.
380 HWND lv = GetDlgItem(hwnd, IDC_LST_CONNECTIONS);
381 if (!SendMessageW(lv, LVM_GETSELECTEDCOUNT, 0, 0))
383 WCHAR title[256], msg[256];
385 LoadStringW(instance, IDS_PROVIDER_TITLE, title, ARRAY_SIZE(title));
386 LoadStringW(instance, IDS_PROVIDER_ERROR, msg, ARRAY_SIZE(msg));
387 MessageBoxW(hwnd, msg, title, MB_OK | MB_ICONEXCLAMATION);
388 SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, TRUE);
389 return TRUE;
392 item.iItem = 0;
393 item.iSubItem = 0;
394 item.stateMask = LVIS_SELECTED;
395 item.mask = LVIF_PARAM | LVIF_STATE;
397 if(ListView_GetItemA(lv, &item))
399 if(!initialize_datasource( (struct datasource*)item.lParam))
401 WCHAR title[256], msg[256];
402 LoadStringW(instance, IDS_PROVIDER_TITLE, title, ARRAY_SIZE(title));
403 LoadStringW(instance, IDS_PROVIDER_NOT_AVAIL, msg, ARRAY_SIZE(msg));
404 MessageBoxW(hwnd, msg, title, MB_OK | MB_ICONEXCLAMATION);
405 SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, TRUE);
406 return TRUE;
409 else
410 ERR("Failed to get selected item\n");
412 return FALSE;
416 break;
418 case WM_COMMAND:
420 if (LOWORD(wp) == IDC_BTN_NEXT)
421 SendMessageW(GetParent(hwnd), PSM_SETCURSEL, 1, 0);
422 break;
424 default:
425 break;
427 return 0;
430 static void connection_fill_odbc_list(HWND parent)
432 LONG res;
433 HKEY key;
434 DWORD index = 0;
435 WCHAR name[MAX_PATH];
436 DWORD nameLen;
438 HWND combo = GetDlgItem(parent, IDC_CBO_NAMES);
439 if (!combo)
440 return;
442 res = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\ODBC\\ODBC.INI\\ODBC Data Sources", 0, KEY_READ, &key);
443 if (res == ERROR_FILE_NOT_FOUND)
444 return;
446 SendMessageW (combo, CB_RESETCONTENT, 0, 0);
448 for(;; index++)
450 nameLen = MAX_PATH;
451 if (RegEnumValueW(key, index, name, &nameLen, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
452 break;
454 SendMessageW(combo, CB_ADDSTRING, 0, (LPARAM)name);
457 RegCloseKey(key);
460 static void connection_initialize_controls(HWND parent)
462 HWND hwnd = GetDlgItem(parent, IDC_RDO_SRC_NAME);
463 if (hwnd)
464 SendMessageA(hwnd, BM_SETCHECK, BST_CHECKED, 0);
467 static void connection_toggle_controls(HWND parent)
469 BOOL checked = TRUE;
470 HWND hwnd = GetDlgItem(parent, IDC_RDO_SRC_NAME);
471 if (hwnd)
472 checked = SendMessageA(hwnd, BM_GETCHECK, 0, 0);
474 EnableWindow(GetDlgItem(parent, IDC_CBO_NAMES), checked);
475 EnableWindow(GetDlgItem(parent, IDC_BTN_REFRESH), checked);
477 EnableWindow(GetDlgItem(parent, IDC_LBL_CONNECTION), !checked);
478 EnableWindow(GetDlgItem(parent, IDC_EDT_CONNECTION), !checked);
479 EnableWindow(GetDlgItem(parent, IDC_BTN_BUILD), !checked);
482 static LRESULT CALLBACK data_link_connection_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
484 TRACE("(%p, %08x, %08lx, %08lx)\n", hwnd, msg, wp, lp);
486 switch (msg)
488 case WM_INITDIALOG:
490 connection_initialize_controls(hwnd);
491 connection_fill_odbc_list(hwnd);
492 connection_toggle_controls(hwnd);
493 break;
495 case WM_COMMAND:
497 switch LOWORD(wp)
499 case IDC_RDO_SRC_NAME:
500 case IDC_BTN_CONNECTION:
501 connection_toggle_controls(hwnd);
502 break;
503 case IDC_BTN_REFRESH:
504 connection_fill_odbc_list(hwnd);
505 break;
506 case IDC_BTN_BUILD:
507 case IDC_BTN_TEST:
508 /* TODO: Implement dialogs */
509 MessageBoxA(hwnd, "Not implemented yet.", "Error", MB_OK | MB_ICONEXCLAMATION);
510 break;
513 break;
515 default:
516 break;
518 return 0;
521 static void advanced_fill_permission_list(HWND parent)
523 LVITEMW item;
524 LVCOLUMNW column;
525 RECT rc;
526 int resources[] = {IDS_PERM_READ, IDS_PERM_READWRITE, IDS_PERM_SHAREDENYNONE,
527 IDS_PERM_SHAREDENYREAD, IDS_PERM_SHAREDENYWRITE, IDS_PERM_SHAREEXCLUSIVE,
528 IDS_PERM_WRITE};
529 int i;
530 WCHAR buf[256];
531 HWND lv = GetDlgItem(parent, IDC_LST_PERMISSIONS);
532 if (!lv)
533 return;
535 SendMessageW(lv, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_CHECKBOXES);
536 GetWindowRect(lv, &rc);
537 column.mask = LVCF_WIDTH | LVCF_FMT;
538 column.fmt = LVCFMT_FIXED_WIDTH;
539 column.cx = (rc.right - rc.left) - 25;
540 column.pszText = buf;
541 SendMessageW(lv, LVM_INSERTCOLUMNW, 0, (LPARAM)&column);
543 for(i =0; i < ARRAY_SIZE(resources); i++)
545 item.mask = LVIF_TEXT;
546 item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0);
547 item.iSubItem = 0;
548 LoadStringW(instance, resources[i], buf, ARRAY_SIZE(buf));
549 item.pszText = buf;
550 SendMessageW(lv, LVM_INSERTITEMW, 0, (LPARAM)&item);
554 static LRESULT CALLBACK data_link_advanced_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
556 TRACE("(%p, %08x, %08lx, %08lx)\n", hwnd, msg, wp, lp);
558 switch (msg)
560 case WM_INITDIALOG:
562 EnableWindow(GetDlgItem(hwnd, IDC_LBL_LEVEL), FALSE);
563 EnableWindow(GetDlgItem(hwnd, IDC_CBO_LEVEL), FALSE);
564 EnableWindow(GetDlgItem(hwnd, IDC_LBL_PROTECTION), FALSE);
565 EnableWindow(GetDlgItem(hwnd, IDC_CBO_PROTECTION), FALSE);
567 advanced_fill_permission_list(hwnd);
569 break;
571 default:
572 break;
574 return 0;
577 static void create_page_all_columns(HWND lv)
579 RECT rc;
580 WCHAR buf[256];
581 LVCOLUMNW column;
583 SendMessageW(lv, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);
584 GetWindowRect(lv, &rc);
585 LoadStringW(instance, IDS_COL_NAME, buf, ARRAY_SIZE(buf));
586 column.mask = LVCF_WIDTH | LVCF_TEXT;
587 column.cx = (rc.right / 2);
588 column.pszText = buf;
589 SendMessageW(lv, LVM_INSERTCOLUMNW, 0, (LPARAM)&column);
591 LoadStringW(instance, IDS_COL_VALUE, buf, ARRAY_SIZE(buf));
592 column.mask = LVCF_WIDTH | LVCF_TEXT;
593 column.cx = (rc.right / 2);
594 column.pszText = buf;
595 SendMessageW(lv, LVM_INSERTCOLUMNW, 0, (LPARAM)&column);
598 static LRESULT CALLBACK data_link_all_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
600 TRACE("(%p, %08x, %08lx, %08lx)\n", hwnd, msg, wp, lp);
602 switch (msg)
604 case WM_INITDIALOG:
606 HWND lv = GetDlgItem(hwnd, IDC_LST_PROPERTIES);
607 create_page_all_columns(lv);
608 break;
610 case WM_COMMAND:
612 if (LOWORD(wp) == IDC_BTN_EDIT)
614 /* TODO: Implement Connection dialog */
615 MessageBoxA(hwnd, "Not implemented yet.", "Error", MB_OK | MB_ICONEXCLAMATION);
620 return 0;
623 static HRESULT WINAPI dslocator_PromptNew(IDataSourceLocator *iface, IDispatch **connection)
625 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
626 PROPSHEETHEADERW hdr;
627 PROPSHEETPAGEW pages[4];
628 INT_PTR ret;
630 FIXME("(%p, %p) Semi-stub\n", iface, connection);
632 if(!connection)
633 return E_INVALIDARG;
635 *connection = NULL;
637 memset(&pages, 0, sizeof(pages));
639 pages[0].dwSize = sizeof(PROPSHEETPAGEW);
640 pages[0].hInstance = instance;
641 pages[0].u.pszTemplate = MAKEINTRESOURCEW(IDD_PROVIDER);
642 pages[0].pfnDlgProc = data_link_properties_dlg_proc;
644 pages[1].dwSize = sizeof(PROPSHEETPAGEW);
645 pages[1].hInstance = instance;
646 pages[1].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONNECTION);
647 pages[1].pfnDlgProc = data_link_connection_dlg_proc;
649 pages[2].dwSize = sizeof(PROPSHEETPAGEW);
650 pages[2].hInstance = instance;
651 pages[2].u.pszTemplate = MAKEINTRESOURCEW(IDD_ADVANCED);
652 pages[2].pfnDlgProc = data_link_advanced_dlg_proc;
654 pages[3].dwSize = sizeof(pages[0]);
655 pages[3].hInstance = instance;
656 pages[3].u.pszTemplate = MAKEINTRESOURCEW(IDD_ALL);
657 pages[3].pfnDlgProc = data_link_all_dlg_proc;
659 memset(&hdr, 0, sizeof(hdr));
660 hdr.dwSize = sizeof(hdr);
661 hdr.hwndParent = This->hwnd;
662 hdr.dwFlags = PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE;
663 hdr.hInstance = instance;
664 hdr.pszCaption = MAKEINTRESOURCEW(IDS_PROPSHEET_TITLE);
665 hdr.u3.ppsp = pages;
666 hdr.nPages = ARRAY_SIZE(pages);
667 ret = PropertySheetW(&hdr);
669 return ret ? S_OK : S_FALSE;
672 static HRESULT WINAPI dslocator_PromptEdit(IDataSourceLocator *iface, IDispatch **ppADOConnection, VARIANT_BOOL *success)
674 DSLocatorImpl *This = impl_from_IDataSourceLocator(iface);
676 FIXME("(%p)->(%p %p)\n",This, ppADOConnection, success);
678 return E_NOTIMPL;
681 static const IDataSourceLocatorVtbl DSLocatorVtbl =
683 dslocator_QueryInterface,
684 dslocator_AddRef,
685 dslocator_Release,
686 dslocator_GetTypeInfoCount,
687 dslocator_GetTypeInfo,
688 dslocator_GetIDsOfNames,
689 dslocator_Invoke,
690 dslocator_get_hWnd,
691 dslocator_put_hWnd,
692 dslocator_PromptNew,
693 dslocator_PromptEdit
696 static HRESULT WINAPI datainitialize_QueryInterface(IDataInitialize *iface, REFIID riid, void **obj)
698 DSLocatorImpl *This = impl_from_IDataInitialize(iface);
699 return IDataSourceLocator_QueryInterface(&This->IDataSourceLocator_iface, riid, obj);
702 static ULONG WINAPI datainitialize_AddRef(IDataInitialize *iface)
704 DSLocatorImpl *This = impl_from_IDataInitialize(iface);
705 return IDataSourceLocator_AddRef(&This->IDataSourceLocator_iface);
708 static ULONG WINAPI datainitialize_Release(IDataInitialize *iface)
710 DSLocatorImpl *This = impl_from_IDataInitialize(iface);
711 return IDataSourceLocator_Release(&This->IDataSourceLocator_iface);
714 static HRESULT WINAPI datainitialize_GetDataSource(IDataInitialize *iface,
715 IUnknown *outer, DWORD context, LPWSTR initstring, REFIID riid, IUnknown **datasource)
717 TRACE("(%p)->(%p %#x %s %s %p)\n", iface, outer, context, debugstr_w(initstring), debugstr_guid(riid),
718 datasource);
720 return get_data_source(outer, context, initstring, riid, datasource);
723 static HRESULT WINAPI datainitialize_GetInitializationString(IDataInitialize *iface, IUnknown *datasource,
724 boolean include_password, LPWSTR *initstring)
726 FIXME("(%p)->(%d %p): stub\n", iface, include_password, initstring);
727 return E_NOTIMPL;
730 static HRESULT WINAPI datainitialize_CreateDBInstance(IDataInitialize *iface, REFCLSID prov, IUnknown *outer,
731 DWORD clsctx, LPWSTR reserved, REFIID riid, IUnknown **datasource)
733 FIXME("(%p)->(%s %p %#x %p %s %p): stub\n", iface, debugstr_guid(prov), outer, clsctx, reserved,
734 debugstr_guid(riid), datasource);
735 return E_NOTIMPL;
738 static HRESULT WINAPI datainitialize_CreateDBInstanceEx(IDataInitialize *iface, REFCLSID prov, IUnknown *outer,
739 DWORD clsctx, LPWSTR reserved, COSERVERINFO *server_info, DWORD cmq, MULTI_QI *results)
741 FIXME("(%p)->(%s %p %#x %p %p %u %p): stub\n", iface, debugstr_guid(prov), outer, clsctx, reserved,
742 server_info, cmq, results);
743 return E_NOTIMPL;
746 static HRESULT WINAPI datainitialize_LoadStringFromStorage(IDataInitialize *iface, LPWSTR filename, LPWSTR *initstring)
748 FIXME("(%p)->(%s %p): stub\n", iface, debugstr_w(filename), initstring);
749 return E_NOTIMPL;
752 static HRESULT WINAPI datainitialize_WriteStringToStorage(IDataInitialize *iface, LPWSTR filename, LPWSTR initstring,
753 DWORD disposition)
755 FIXME("(%p)->(%s %s %#x): stub\n", iface, debugstr_w(filename), debugstr_w(initstring), disposition);
756 return E_NOTIMPL;
759 static const IDataInitializeVtbl ds_datainitialize_vtbl =
761 datainitialize_QueryInterface,
762 datainitialize_AddRef,
763 datainitialize_Release,
764 datainitialize_GetDataSource,
765 datainitialize_GetInitializationString,
766 datainitialize_CreateDBInstance,
767 datainitialize_CreateDBInstanceEx,
768 datainitialize_LoadStringFromStorage,
769 datainitialize_WriteStringToStorage,
772 HRESULT create_dslocator(IUnknown *outer, void **obj)
774 DSLocatorImpl *This;
776 TRACE("(%p, %p)\n", outer, obj);
778 *obj = NULL;
780 if(outer) return CLASS_E_NOAGGREGATION;
782 This = heap_alloc(sizeof(*This));
783 if(!This) return E_OUTOFMEMORY;
785 This->IDataSourceLocator_iface.lpVtbl = &DSLocatorVtbl;
786 This->IDataInitialize_iface.lpVtbl = &ds_datainitialize_vtbl;
787 This->ref = 1;
788 This->hwnd = 0;
790 *obj = &This->IDataSourceLocator_iface;
792 return S_OK;