Skip to content

Commit

Permalink
(ODBC-23)Added connection string option PLUGIN_DIR for pointing to c/c
Browse files Browse the repository at this point in the history
plugins directory. Added support of this function to the gui dialog.
  • Loading branch information
lawrinn committed Sep 23, 2015
1 parent 06d8df4 commit 9b4a852
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
58 changes: 56 additions & 2 deletions dsn/odbc_dsn.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/************************************************************************************
Copyright (C) 2013 SkySQL AB
Copyright (C) 2013,2015 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
Expand All @@ -24,6 +24,7 @@
#include <tchar.h>
#include <windowsx.h>
#include <winuser.h>
#include <shlobj.h>
#include "resource.h"
#include <ma_odbc.h>
#include <ma_odbc_setup.h>
Expand Down Expand Up @@ -73,6 +74,7 @@ MADB_DsnMap DsnMap[] = {
{&DsnKeys[12], 2, ckReconnect, 0, 0},
{&DsnKeys[13], 2, ckConnectPrompt, 0, 0},
{&DsnKeys[14], 2, cbCharset, 0, 0},
{&DsnKeys[17], 3, txtPluginDir, 260, 0},
{NULL, 0, 0, 0, 0}
};

Expand Down Expand Up @@ -442,6 +444,56 @@ void MADB_WIN_TestDsn(my_bool ShowSuccess)
}


static int CALLBACK SelectFolderCallbackProc(HWND hwnd,UINT uMsg, LPARAM lParam, LPARAM lpData)
{

if(uMsg == BFFM_INITIALIZED)
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
}

return 0;
}


INT_PTR SelectFolder(HWND ParentWnd, int BoundEditId, const TCHAR *Caption)
{
TCHAR Path[MAX_PATH];
HWND BoundEditWnd= GetDlgItem(ParentWnd, BoundEditId);
BROWSEINFO bi;
LPITEMIDLIST pidl;

Edit_GetText(BoundEditWnd, Path, sizeof(Path));

bi.hwndOwner= ParentWnd;
bi.lpszTitle= Caption;
bi.ulFlags= BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
bi.lpfn= SelectFolderCallbackProc;
bi.lParam= (LPARAM)Path;

pidl= SHBrowseForFolder(&bi);

if (pidl != 0)
{
IMalloc *imalloc= NULL;

SHGetPathFromIDList(pidl, Path);

Edit_SetText(BoundEditWnd, Path);

if (SUCCEEDED(SHGetMalloc(&imalloc)))
{
imalloc->lpVtbl->Free(imalloc, pidl);
imalloc->lpVtbl->Release(imalloc);
}

return TRUE;
}

return FALSE;
}


INT_PTR CALLBACK DialogDSNProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
Expand Down Expand Up @@ -483,7 +535,9 @@ INT_PTR CALLBACK DialogDSNProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
"Warning", MB_OK);
return FALSE;
}
return TRUE;
return TRUE;
case pbPlugindirBrowse:
return SelectFolder(hDlg, txtPluginDir, _T("Select Plugins Directory"));
case rbTCP:
case rbPipe:
if (HIWORD(wParam) == BN_CLICKED)
Expand Down
6 changes: 4 additions & 2 deletions dsn/odbc_dsn.rc
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,16 @@ BEGIN
GROUPBOX "Miscellanous Options",IDC_STATIC,7,7,277,124,0,WS_EX_TRANSPARENT
CONTROL "Ignore schema in column specification",ckIgnoreSchema,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,25,136,10,WS_EX_TRANSPARENT
CONTROL "Allow multiple statements",ckMultiStmt,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,39,97,10,WS_EX_TRANSPARENT
LTEXT "Plugins Directory",IDC_STATIC,15,53,56,8,0,WS_EX_TRANSPARENT
EDITTEXT txtPluginDir,72,53,110,10,ES_AUTOHSCROLL
PUSHBUTTON "Browse",pbPlugindirBrowse,183,51,30,14
// CONTROL "Disable catalog support",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,39,91,10,WS_EX_TRANSPARENT
// CONTROL "Ignore space after function names",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,53,127,10,WS_EX_TRANSPARENT
PUSHBUTTON "Cancel",IDCANCEL,178,149,50,14
PUSHBUTTON "Next >",PB_NEXT,104,149,50,14
PUSHBUTTON "< Previous",PB_PREV,50,149,50,14,WS_DISABLED
PUSHBUTTON "Help",IDCANCEL4,236,149,50,14
CONTROL "Allow multiple statements",ckMultiStmt,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,39,97,10,WS_EX_TRANSPARENT
// CONTROL "Allow multiple statements",ckMultiStmt,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,67,97,10,WS_EX_TRANSPARENT
END

Page_4 DIALOGEX 0, 0, 299, 182
Expand Down
Binary file modified dsn/resource.h
Binary file not shown.
2 changes: 2 additions & 0 deletions ma_dsn.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ MADB_DsnKey DsnKeys[]=
{"CHARSET", offsetof(MADB_Dsn, CharacterSet), DSN_TYPE_COMBO,0,0},
{"OPTIONS", offsetof(MADB_Dsn, Options), DSN_TYPE_INT, 0,0},
{"TRACE", offsetof(MADB_Dsn, TraceFile), DSN_TYPE_STRING, 0, 0},
{"PLUGIN_DIR", offsetof(MADB_Dsn, ConnCPluginsDir), DSN_TYPE_STRING,0,1},
/* Aliases */
{"SERVERNAME", offsetof(MADB_Dsn, ServerName), DSN_TYPE_STRING,0,1},
{"USER", offsetof(MADB_Dsn, UserName), DSN_TYPE_STRING,0,1},
Expand Down Expand Up @@ -76,6 +77,7 @@ void MADB_DSN_Free(MADB_Dsn *Dsn)
MADB_FREE(Dsn->CharacterSet);
MADB_FREE(Dsn->InitCommand);
MADB_FREE(Dsn->TraceFile);
MADB_FREE(Dsn->ConnCPluginsDir);

if (Dsn->FreeMe)
MADB_FREE(Dsn);
Expand Down
1 change: 1 addition & 0 deletions ma_odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ typedef struct st_madb_dsn
my_bool MultiStatements;
/* TRUE means "no prompt" */
my_bool ConnectPrompt;
char * ConnCPluginsDir;
/* --- Internal --- */
int isPrompt;
MADB_DsnKey *Keys;
Expand Down

0 comments on commit 9b4a852

Please sign in to comment.