33
33
static int driver_optionsDraw(HWND, const ConnInfo *, int src, BOOL enable);
34
34
static int driver_options_update(HWND hdlg, ConnInfo *ci, const char *);
38
const char * const modestr;
40
{IDS_SSLREQUEST_DISABLE, SSLMODE_DISABLE}
41
, {IDS_SSLREQUEST_ALLOW, SSLMODE_ALLOW}
42
, {IDS_SSLREQUEST_PREFER, SSLMODE_PREFER}
43
, {IDS_SSLREQUEST_REQUIRE, SSLMODE_REQUIRE}
44
, {IDS_SSLREQUEST_VERIFY_CA, SSLMODE_VERIFY_CA}
45
, {IDS_SSLREQUEST_VERIFY_FULL, SSLMODE_VERIFY_FULL}
47
static int dspcount_bylevel[] = {1, 4, 6};
37
50
SetDlgStuff(HWND hdlg, const ConnInfo *ci)
39
52
char buff[MEDIUM_REGISTRY_LEN + 1];
40
53
BOOL libpq_exist = FALSE;
54
int i, dsplevel, selidx, dspcount;
43
57
* If driver attribute NOT present, then set the datasource name and
52
66
SetDlgItemText(hdlg, IDC_PASSWORD, ci->password);
53
67
SetDlgItemText(hdlg, IDC_PORT, ci->port);
55
70
libpq_exist = SSLLIB_check();
56
71
mylog("libpq_exist=%d\n", libpq_exist);
58
74
ShowWindow(GetDlgItem(hdlg, IDC_NOTICE_USER), SW_HIDE);
75
if (ssl_verify_available())
61
82
mylog("SendMessage CTL_COLOR\n");
62
83
SendMessage(GetDlgItem(hdlg, IDC_NOTICE_USER), WM_CTLCOLOR, 0, 0);
64
LoadString(GetWindowInstance(hdlg), IDS_SSLREQUEST_DISABLE, buff, MEDIUM_REGISTRY_LEN);
65
SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_ADDSTRING, 0, (WPARAM) buff);
66
if (libpq_exist || (ci->sslmode[0] && stricmp(ci->sslmode, "disable")))
68
LoadString(GetWindowInstance(hdlg), IDS_SSLREQUEST_PREFER, buff, MEDIUM_REGISTRY_LEN);
69
SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_ADDSTRING, 0, (WPARAM) buff);
70
LoadString(GetWindowInstance(hdlg), IDS_SSLREQUEST_ALLOW, buff, MEDIUM_REGISTRY_LEN);
71
SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_ADDSTRING, 0, (WPARAM) buff);
72
LoadString(GetWindowInstance(hdlg), IDS_SSLREQUEST_REQUIRE, buff, MEDIUM_REGISTRY_LEN);
73
SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_ADDSTRING, 0, (WPARAM) buff);
75
if (!stricmp(ci->sslmode, "allow"))
76
LoadString(GetWindowInstance(hdlg), IDS_SSLREQUEST_ALLOW, buff, MEDIUM_REGISTRY_LEN);
77
else if (!stricmp(ci->sslmode, "require"))
78
LoadString(GetWindowInstance(hdlg), IDS_SSLREQUEST_REQUIRE, buff, MEDIUM_REGISTRY_LEN);
79
else if (!stricmp(ci->sslmode, "prefer"))
80
LoadString(GetWindowInstance(hdlg), IDS_SSLREQUEST_PREFER, buff, MEDIUM_REGISTRY_LEN);
82
LoadString(GetWindowInstance(hdlg), IDS_SSLREQUEST_DISABLE, buff, MEDIUM_REGISTRY_LEN);
84
SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_SELECTSTRING, -1, (WPARAM) ((LPSTR) buff));
90
for (i = 0; i < sizeof(modetab) / sizeof(modetab[0]); i++)
92
if (!stricmp(ci->sslmode, modetab[i].modestr))
98
for (i = dsplevel; i < sizeof(dspcount_bylevel) / sizeof(int); i++)
100
if (selidx < dspcount_bylevel[i])
105
dspcount = dspcount_bylevel[dsplevel];
106
for (i = 0; i < dspcount; i++)
108
LoadString(GetWindowInstance(hdlg), modetab[i].ids, buff, MEDIUM_REGISTRY_LEN);
109
SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_ADDSTRING, 0, (WPARAM) buff);
112
SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_SETCURSEL, selidx, (WPARAM) 0);
98
126
GetDlgItemText(hdlg, IDC_PASSWORD, ci->password, sizeof(ci->password));
99
127
GetDlgItemText(hdlg, IDC_PORT, ci->port, sizeof(ci->port));
100
128
sslposition = (int)(DWORD)SendMessage(GetDlgItem(hdlg, IDC_SSLMODE), CB_GETCURSEL, 0L, 0L);
103
case 1: strncpy(ci->sslmode, "prefer", sizeof(ci->sslmode));
105
case 2: strncpy(ci->sslmode, "allow", sizeof(ci->sslmode));
107
case 3: strncpy(ci->sslmode, "require", sizeof(ci->sslmode));
109
default:strncpy(ci->sslmode, "disable", sizeof(ci->sslmode));
129
strncpy_null(ci->sslmode, modetab[sslposition].modestr, sizeof(ci->sslmode));
372
393
globals.debug = IsDlgButtonChecked(hdlg, DRV_DEBUG);
373
394
if (writeDriverCommoninfo(ODBCINST_INI, NULL, &globals) < 0)
374
395
MessageBox(hdlg, "Sorry, impossible to update the values\nWrite permission seems to be needed", "Update Error", MB_ICONEXCLAMATION | MB_OK);
396
GetDlgItemText(hdlg, DS_LOGDIR, logdir, sizeof(logdir));
397
setLogDir(logdir[0] ? logdir : NULL);
375
398
#ifdef _HANDLE_ENLIST_IN_DTC_
376
399
hmodule = DtcProc("SetMsdtclog", &proc);
567
590
CheckDlgButton(hdlg, DS_SERVERSIDEPREPARE, ci->use_server_side_prepare);
568
591
CheckDlgButton(hdlg, DS_BYTEAASLONGVARBINARY, ci->bytea_as_longvarbinary);
569
592
/*CheckDlgButton(hdlg, DS_LOWERCASEIDENTIFIER, ci->lower_case_identifier);*/
593
CheckDlgButton(hdlg, DS_GSSAUTHUSEGSSAPI, ci->gssauth_use_gssapi);
595
#if defined(NOT_USE_LIBPQ) && !defined(USE_SSPI) && !defined(USE_GSS)
596
EnableWindow(GetDlgItem(hdlg, DS_GSSAUTHUSEGSSAPI), FALSE);
571
598
EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), atoi(ci->show_oid_column));
573
600
/* Datasource Connection Settings */