~ubuntu-branches/ubuntu/trusty/psqlodbc/trusty-proposed

« back to all changes in this revision

Viewing changes to dlg_wingui.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2011-04-05 14:48:23 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110405144823-n77supsa1hjj0ik6
Tags: 1:09.00.0200-1
* New upstream release.
* Fix installing {A,W}/usr/lib/odbc.  Closes: #618210.
* Convert to 3.0 (quilt).
* Remove psqlodbc-580878.diff: implemented upstream.
* Remove psqlodbc-585476.diff: was caused by #519006 which is now closed.
* Update description, suggested by Martin Eberhard Schauer.
  Closes: #565611.
* New maintainer.  Closes: #472818.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 *);
35
35
 
 
36
static struct {
 
37
        int     ids;
 
38
        const char * const      modestr;
 
39
} modetab[] = {
 
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}
 
46
        };
 
47
static int      dspcount_bylevel[] = {1, 4, 6};
 
48
 
36
49
void
37
50
SetDlgStuff(HWND hdlg, const ConnInfo *ci)
38
51
{
39
52
        char    buff[MEDIUM_REGISTRY_LEN + 1];
40
53
        BOOL    libpq_exist = FALSE;
 
54
        int     i, dsplevel, selidx, dspcount;
41
55
 
42
56
        /*
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);
54
68
 
 
69
        dsplevel = 0;
55
70
        libpq_exist = SSLLIB_check();
56
71
mylog("libpq_exist=%d\n", libpq_exist);
57
72
        if (libpq_exist)
 
73
        {
58
74
                ShowWindow(GetDlgItem(hdlg, IDC_NOTICE_USER), SW_HIDE);
 
75
                if (ssl_verify_available())
 
76
                        dsplevel = 2;
 
77
                else
 
78
                        dsplevel = 1;
 
79
        }
59
80
        else
60
81
        {
61
82
mylog("SendMessage CTL_COLOR\n");
62
83
                SendMessage(GetDlgItem(hdlg, IDC_NOTICE_USER), WM_CTLCOLOR, 0, 0);
63
 
        }
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")))
67
 
        {
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);
74
 
        }
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);
81
 
        else
82
 
                LoadString(GetWindowInstance(hdlg), IDS_SSLREQUEST_DISABLE, buff, MEDIUM_REGISTRY_LEN);
83
 
 
84
 
        SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_SELECTSTRING, -1, (WPARAM) ((LPSTR) buff));
 
84
#ifdef  USE_SSPI
 
85
                dsplevel = 1;
 
86
#endif /* USE_SSPI */
 
87
        }
 
88
 
 
89
        selidx = -1;
 
90
        for (i = 0; i < sizeof(modetab) / sizeof(modetab[0]); i++)
 
91
        {
 
92
                if (!stricmp(ci->sslmode, modetab[i].modestr))
 
93
                {
 
94
                        selidx = i;
 
95
                        break;
 
96
                }
 
97
        }
 
98
        for (i = dsplevel; i < sizeof(dspcount_bylevel) / sizeof(int); i++)
 
99
        {
 
100
                if (selidx < dspcount_bylevel[i])
 
101
                        break;
 
102
                dsplevel++;
 
103
        }
 
104
        
 
105
        dspcount = dspcount_bylevel[dsplevel];
 
106
        for (i = 0; i < dspcount; i++)
 
107
        {
 
108
                LoadString(GetWindowInstance(hdlg), modetab[i].ids, buff, MEDIUM_REGISTRY_LEN);
 
109
                SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_ADDSTRING, 0, (WPARAM) buff);
 
110
        }
 
111
 
 
112
        SendDlgItemMessage(hdlg, IDC_SSLMODE, CB_SETCURSEL, selidx, (WPARAM) 0);
85
113
}
86
114
 
87
115
 
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);
101
 
        switch (sslposition)
102
 
        {
103
 
                case 1: strncpy(ci->sslmode, "prefer", sizeof(ci->sslmode));
104
 
                        break;
105
 
                case 2: strncpy(ci->sslmode, "allow", sizeof(ci->sslmode));
106
 
                        break;
107
 
                case 3: strncpy(ci->sslmode, "require", sizeof(ci->sslmode));
108
 
                        break;
109
 
                default:strncpy(ci->sslmode, "disable", sizeof(ci->sslmode));
110
 
                        break;
111
 
        }
 
129
        strncpy_null(ci->sslmode, modetab[sslposition].modestr, sizeof(ci->sslmode));
112
130
}
113
131
 
114
132
 
336
354
        HMODULE hmodule;
337
355
        FARPROC proc;
338
356
#endif /* _HANDLE_ENLIST_IN_DTC_ */
 
357
        char logdir[PATH_MAX];
339
358
 
340
359
        switch (wMsg)
341
360
        {
348
367
#ifndef MY_LOG
349
368
                        EnableWindow(GetDlgItem(hdlg, DRV_DEBUG), FALSE);
350
369
#endif /* MY_LOG */
 
370
                        getLogDir(logdir, sizeof(logdir));
 
371
                        SetDlgItemText(hdlg, DS_LOGDIR, logdir);
351
372
#ifdef _HANDLE_ENLIST_IN_DTC_
352
373
                        hmodule = DtcProc("GetMsdtclog", &proc);
353
374
                        if (proc)
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);
377
400
                                        if (proc)
503
526
                        CheckDlgButton(hdlg, DS_READONLY, atoi(ci->onlyread));
504
527
 
505
528
                        /* Protocol */
506
 
                        enable = (ci->sslmode[0] == 'd' || ci->username[0] == '\0');
 
529
                        enable = (ci->sslmode[0] == SSLLBYTE_DISABLE || ci->username[0] == '\0');
507
530
                        EnableWindow(GetDlgItem(hdlg, DS_PG62), enable);
508
531
                        EnableWindow(GetDlgItem(hdlg, DS_PG63), enable);
509
532
                        EnableWindow(GetDlgItem(hdlg, DS_PG64), enable);
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);
570
594
 
 
595
#if     defined(NOT_USE_LIBPQ) && !defined(USE_SSPI) && !defined(USE_GSS)
 
596
                        EnableWindow(GetDlgItem(hdlg, DS_GSSAUTHUSEGSSAPI), FALSE);
 
597
#endif
571
598
                        EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), atoi(ci->show_oid_column));
572
599
 
573
600
                        /* Datasource Connection Settings */
639
666
                                        ci->use_server_side_prepare = IsDlgButtonChecked(hdlg, DS_SERVERSIDEPREPARE);
640
667
                                        ci->bytea_as_longvarbinary = IsDlgButtonChecked(hdlg, DS_BYTEAASLONGVARBINARY);
641
668
                                        /*ci->lower_case_identifier = IsDlgButtonChecked(hdlg, DS_LOWERCASEIDENTIFIER);*/
 
669
                                        ci->gssauth_use_gssapi = IsDlgButtonChecked(hdlg, DS_GSSAUTHUSEGSSAPI);
642
670
 
643
671
                                        /* OID Options */
644
672
                                        sprintf(ci->fake_oid_index, "%d", IsDlgButtonChecked(hdlg, DS_FAKEOIDINDEX));