Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/oledb32/Makefile.in | 1 + dlls/oledb32/dslocator.c | 133 +++++++++++++++++++++++++++++++++-- dlls/oledb32/main.c | 2 +- dlls/oledb32/oledb_private.h | 2 + dlls/oledb32/resource.h | 24 +++++++ dlls/oledb32/version.rc | 21 ++++++ 6 files changed, 178 insertions(+), 5 deletions(-) create mode 100644 dlls/oledb32/resource.h
diff --git a/dlls/oledb32/Makefile.in b/dlls/oledb32/Makefile.in index b55a66c5db..33cc312ee3 100644 --- a/dlls/oledb32/Makefile.in +++ b/dlls/oledb32/Makefile.in @@ -1,5 +1,6 @@ MODULE = oledb32.dll IMPORTS = uuid oleaut32 ole32 user32 advapi32 +DELAYIMPORTS = comctl32
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/oledb32/dslocator.c b/dlls/oledb32/dslocator.c index d397e47aa5..0a31a99130 100644 --- a/dlls/oledb32/dslocator.c +++ b/dlls/oledb32/dslocator.c @@ -20,6 +20,7 @@ #include <string.h>
#define COBJMACROS +#define NONAMELESSUNION
#include "windef.h" #include "winbase.h" @@ -29,8 +30,11 @@ #include "oledb.h" #include "oledberr.h" #include "msdasc.h" +#include "prsht.h" +#include "commctrl.h"
#include "oledb_private.h" +#include "resource.h"
#include "wine/debug.h" #include "wine/heap.h" @@ -188,13 +192,134 @@ static HRESULT WINAPI dslocator_put_hWnd(IDataSourceLocator *iface, COMPATIBLE_L return S_OK; }
-static HRESULT WINAPI dslocator_PromptNew(IDataSourceLocator *iface, IDispatch **ppADOConnection) +static void create_connections_columns(HWND lv) { - DSLocatorImpl *This = impl_from_IDataSourceLocator(iface); + RECT rc; + WCHAR buf[256]; + LVCOLUMNW column; + + SendMessageW(lv, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT); + GetWindowRect(lv, &rc); + LoadStringW(instance, IDS_COL_PROVIDER, buf, ARRAY_SIZE(buf)); + column.mask = LVCF_WIDTH | LVCF_TEXT; + column.cx = (rc.right - rc.left) - 5; + column.pszText = buf; + SendMessageW(lv, LVM_INSERTCOLUMNW, 0, (LPARAM)&column); +} + +static void add_connectons_providers(HWND lv) +{ + static const WCHAR oledbprov[] = {'\','O','L','E',' ','D','B',' ','P','r','o','v','i','d','e','r',0}; + LONG res; + HKEY key = NULL, subkey; + DWORD index = 0; + LONG next_key; + WCHAR provider[MAX_PATH]; + WCHAR guidkey[MAX_PATH]; + LONG size; + + res = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_READ, &key); + if (res == ERROR_FILE_NOT_FOUND) + return; + + next_key = RegEnumKeyW(key, index, provider, MAX_PATH); + while (next_key == ERROR_SUCCESS) + { + WCHAR description[MAX_PATH]; + + lstrcpyW(guidkey, provider); + lstrcatW(guidkey, oledbprov); + + res = RegOpenKeyW(key, guidkey, &subkey); + if (res == ERROR_SUCCESS) + { + TRACE("Found %s\n", debugstr_w(guidkey)); + + size = MAX_PATH; + res = RegQueryValueW(subkey, NULL, description, &size); + if (res == ERROR_SUCCESS) + { + LVITEMW item; + item.mask = LVIF_TEXT; + item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); + item.iSubItem = 0; + item.pszText = description; + SendMessageW(lv, LVM_INSERTITEMW, 0, (LPARAM)&item); + /* TODO - Add ProgID to item data */ + } + RegCloseKey(subkey); + } + + index++; + next_key = RegEnumKeyW(key, index, provider, MAX_PATH); + }
- FIXME("(%p)->(%p)\n",This, ppADOConnection); + RegCloseKey(key); +}
- return E_NOTIMPL; +static LRESULT CALLBACK data_link_properties_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) +{ + TRACE("(%p, %08x, %08lx, %08lx)\n", hwnd, msg, wp, lp); + + switch (msg) + { + case WM_INITDIALOG: + { + HWND btn, lv = GetDlgItem(hwnd, IDC_LST_CONNECTIONS); + create_connections_columns(lv); + add_connectons_providers(lv); + + btn = GetDlgItem(GetParent(hwnd), IDOK); + EnableWindow(btn, FALSE); + + break; + } + case WM_COMMAND: + { + if (LOWORD(wp) == IDC_BTN_NEXT) + { + /* TODO: Implement Connection dialog */ + MessageBoxA(hwnd, "Not implemented yet.", "Error", MB_OK | MB_ICONEXCLAMATION); + } + break; + } + default: + break; + } + return 0; +} + +static HRESULT WINAPI dslocator_PromptNew(IDataSourceLocator *iface, IDispatch **connection) +{ + DSLocatorImpl *This = impl_from_IDataSourceLocator(iface); + PROPSHEETHEADERW hdr; + PROPSHEETPAGEW page; + INT_PTR ret; + + FIXME("(%p, %p) Semi-stub\n", iface, connection); + + if(!connection) + return E_INVALIDARG; + + *connection = NULL; + + memset(&page, 0, sizeof(PROPSHEETPAGEW)); + page.dwSize = sizeof(page); + page.hInstance = instance; + page.u.pszTemplate = MAKEINTRESOURCEW(IDD_PROVIDER); + page.pfnDlgProc = data_link_properties_dlg_proc; + + memset(&hdr, 0, sizeof(hdr)); + hdr.dwSize = sizeof(hdr); + hdr.hwndParent = This->hwnd; + hdr.dwFlags = PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE; + hdr.hInstance = instance; + hdr.pszCaption = MAKEINTRESOURCEW(IDS_PROPSHEET_TITLE); + hdr.u3.ppsp = &page; + hdr.nPages = 1; + ret = PropertySheetW(&hdr); + + return ret ? S_OK : S_FALSE; }
static HRESULT WINAPI dslocator_PromptEdit(IDataSourceLocator *iface, IDispatch **ppADOConnection, VARIANT_BOOL *success) diff --git a/dlls/oledb32/main.c b/dlls/oledb32/main.c index f28e57a3f3..9c8c7f231b 100644 --- a/dlls/oledb32/main.c +++ b/dlls/oledb32/main.c @@ -36,7 +36,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(oledb);
-static HINSTANCE instance; +HINSTANCE instance;
DEFINE_GUID(CSLID_MSDAER, 0xc8b522cf,0x5cf3,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
diff --git a/dlls/oledb32/oledb_private.h b/dlls/oledb32/oledb_private.h index 4e285b5460..fee0318de1 100644 --- a/dlls/oledb32/oledb_private.h +++ b/dlls/oledb32/oledb_private.h @@ -26,6 +26,8 @@ HRESULT create_dslocator(IUnknown *outer, void **obj) DECLSPEC_HIDDEN; HRESULT get_data_source(IUnknown *outer, DWORD clsctx, LPWSTR initstring, REFIID riid, IUnknown **datasource) DECLSPEC_HIDDEN;
+extern HINSTANCE instance; + static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t size) { return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size); diff --git a/dlls/oledb32/resource.h b/dlls/oledb32/resource.h new file mode 100644 index 0000000000..df88a10829 --- /dev/null +++ b/dlls/oledb32/resource.h @@ -0,0 +1,24 @@ +/* + * Copyright 2019 Alistair Leslie-Hughes + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define IDD_PROVIDER 1000 +#define IDC_BTN_NEXT 1001 +#define IDC_LST_CONNECTIONS 1002 + +#define IDS_PROPSHEET_TITLE 2000 +#define IDS_COL_PROVIDER 2001 diff --git a/dlls/oledb32/version.rc b/dlls/oledb32/version.rc index e082acccae..23bbee543d 100644 --- a/dlls/oledb32/version.rc +++ b/dlls/oledb32/version.rc @@ -15,6 +15,9 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#pragma makedep po + +#include "resource.h"
#define WINE_FILEDESCRIPTION_STR "Wine oledb" #define WINE_FILENAME_STR "oledb32.dll" @@ -24,3 +27,21 @@ #define WINE_PRODUCTVERSION_STR "2.81.1117.0"
#include "wine/wine_common_ver.rc" + +LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT + +STRINGTABLE +{ + IDS_PROPSHEET_TITLE "Data Link Properties" + IDS_COL_PROVIDER "OLE DB Provider(s)" +} + +IDD_PROVIDER DIALOG 0, 0, 227, 225 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Provider" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Select the data you want to connect to:",-1,8,7,206,8 + CONTROL "List1",IDC_LST_CONNECTIONS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,14,20,206,162 + PUSHBUTTON "&Next >>",IDC_BTN_NEXT,170,194,50,14 +END