1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
/***************************************************************************
getpassword.cpp - description
-------------------
begin : Tue Aug 5 2003
copyright : (C) 2003 by ARRL
author : Jon Bloom
email : jbloom@arrl.org
revision : $Id$
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "sysconfig.h"
#endif
#include "getpassword.h"
#include "tqsltrace.h"
#include "wxutil.h"
#define GPW_ID_LOW 6400
#define GPW_ID_PW1 GPW_ID_LOW
#define GPW_ID_PW2 GPW_ID_LOW+1
#define GPW_ID_OK GPW_ID_LOW+2
#define GPW_ID_CAN GPW_ID_LOW+3
#define GPW_ID_HELP GPW_ID_LOW+4
#define GPW_ID_OK2 GPW_ID_LOW+5
#define GPW_ID_UN GPW_ID_LOW+6
#define GPW_ID_PW3 GPW_ID_LOW+7
#define GPW_ID_OK3 GPW_ID_LOW+8
#define GPW_ID_CAN2 GPW_ID_LOW+9
#define GPW_ID_HELP2 GPW_ID_LOW+10
BEGIN_EVENT_TABLE(GetPasswordDialog, wxDialog)
EVT_BUTTON(GPW_ID_OK, GetPasswordDialog::OnOk)
EVT_BUTTON(GPW_ID_CAN, GetPasswordDialog::OnCancel)
EVT_BUTTON(GPW_ID_HELP, GetPasswordDialog::OnHelp)
END_EVENT_TABLE()
GetPasswordDialog::GetPasswordDialog(wxWindow *parent, const wxString& title,
const wxString& message, wxHtmlHelpController *help, wxString helpfile)
: wxDialog(parent, -1, title), _help(help), _helpfile(helpfile) {
tqslTrace("GetPassword::GetPasswordDialog", "parent=%lx, title=%s, message=%s", reinterpret_cast<void *>(parent), S(title), S(helpfile));
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxSize sz = getTextSize(this);
int em_w = sz.GetWidth();
wxStaticText *st = new wxStaticText(this, -1, message);
st->Wrap(em_w * 40);
sizer->Add(st, 1, wxALL|wxEXPAND, 10);
_pw = new wxTextCtrl(this, GPW_ID_PW1, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
sizer->Add(_pw, 0, wxLEFT|wxRIGHT|wxEXPAND, 10);
wxBoxSizer *butsizer = new wxBoxSizer(wxHORIZONTAL);
wxButton *okButton = new wxButton(this, GPW_ID_OK, _("OK"));
butsizer->Add(okButton, 0, 0, 0);
okButton->SetDefault();
butsizer->Add(new wxButton(this, GPW_ID_CAN, _("Cancel")), 0, wxLEFT, 20);
if (_help && !_helpfile.IsEmpty())
butsizer->Add(new wxButton(this, GPW_ID_HELP, _("Help")), 0, wxLEFT, 20);
sizer->Add(butsizer, 0, wxALL|wxALIGN_CENTER, 10);
SetAutoLayout(TRUE);
SetSizer(sizer);
sizer->Fit(this);
sizer->SetSizeHints(this);
CentreOnParent();
}
bool
GetPasswordDialog::TransferDataFromWindow() {
tqslTrace("GetPasswordDialog::TransferDataFromWindow", NULL);
_password = _pw->GetValue();
return true;
}
void
GetPasswordDialog::OnOk(wxCommandEvent&) {
tqslTrace("GetPasswordDialog::OnOk", NULL);
if (TransferDataFromWindow())
EndModal(wxID_OK);
}
void
GetPasswordDialog::OnCancel(wxCommandEvent&) {
tqslTrace("GetPasswordDialog::OnCancel", NULL);
EndModal(wxID_CANCEL);
}
void
GetPasswordDialog::OnHelp(wxCommandEvent&) {
tqslTrace("GetPasswordDialog::OnHelp", NULL);
if (_help && !_helpfile.IsEmpty())
_help->Display(_helpfile);
}
BEGIN_EVENT_TABLE(GetNewPasswordDialog, wxDialog)
EVT_TEXT(GPW_ID_PW1, GetNewPasswordDialog::PWChange)
EVT_TEXT(GPW_ID_PW2, GetNewPasswordDialog::PWChange)
EVT_BUTTON(GPW_ID_OK, GetNewPasswordDialog::OnOk)
EVT_BUTTON(GPW_ID_CAN, GetNewPasswordDialog::OnCancel)
EVT_BUTTON(GPW_ID_HELP, GetNewPasswordDialog::OnHelp)
END_EVENT_TABLE()
GetNewPasswordDialog::GetNewPasswordDialog(wxWindow *parent, const wxString& title,
const wxString& message, bool blankok, wxHtmlHelpController *help, wxString helpfile)
: wxDialog(parent, -1, title), _blankok(blankok), _help(help), _helpfile(helpfile) {
tqslTrace("GetNewPasswordDialog::GetNewPasswordDialog", "parent=%lx, title=%s, message=%s, blankok=%d", reinterpret_cast<void *>(parent), S(title), S(message));
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxSize sz = getTextSize(this);
int em_w = sz.GetWidth();
wxStaticText *st = new wxStaticText(this, -1, message);
st->Wrap(em_w * 40);
sizer->Add(st, 1, wxALL|wxEXPAND, 10);
sizer->Add(new wxStaticText(this, -1, _("New passphrase:")), 0, wxLEFT|wxRIGHT, 10);
_pw1 = new wxTextCtrl(this, GPW_ID_PW1, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
sizer->Add(_pw1, 0, wxLEFT|wxRIGHT|wxEXPAND, 10);
sizer->Add(new wxStaticText(this, -1, _("Enter again to confirm:")), 0, wxLEFT|wxRIGHT, 10);
_pw2 = new wxTextCtrl(this, GPW_ID_PW2, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
sizer->Add(_pw2, 0, wxLEFT|wxRIGHT|wxEXPAND, 10);
_pwstatus = new wxStaticText(this, -1, wxT(""));
sizer->Add(_pwstatus, 0, wxALL|wxEXPAND, 10);
wxBoxSizer *butsizer = new wxBoxSizer(wxHORIZONTAL);
_okbut = new wxButton(this, GPW_ID_OK, _("OK"));
_okbut->Enable(_blankok);
butsizer->Add(_okbut, 0, 0, 0);
butsizer->Add(new wxButton(this, GPW_ID_CAN, _("Cancel")), 0, wxLEFT, 20);
if (_help && !_helpfile.IsEmpty())
butsizer->Add(new wxButton(this, GPW_ID_HELP, _("Help")), 0, wxLEFT, 20);
sizer->Add(butsizer, 0, wxALL|wxALIGN_CENTER, 10);
SetAutoLayout(TRUE);
SetSizer(sizer);
sizer->Fit(this);
sizer->SetSizeHints(this);
CentreOnParent();
}
void
GetNewPasswordDialog::PWChange(wxCommandEvent&) {
tqslTrace("GetNewPasswordDialog::PWChange", NULL);
_password = wxT("");
wxString pw1 = _pw1->GetValue();
wxString pw2 = _pw2->GetValue();
if (pw1 != pw2) {
_pwstatus->SetLabel(_("Passphrase entries do not match"));
_okbut->Enable(false);
return;
}
if (!_blankok && pw1.IsEmpty()) {
_pwstatus->SetLabel(wxT(""));
_okbut->Enable(false);
return;
}
_password = pw1;
if (!pw1.IsEmpty())
_pwstatus->SetLabel(_("Passphrase confirmed"));
_okbut->Enable(true);
_okbut->SetDefault();
}
void
GetNewPasswordDialog::OnOk(wxCommandEvent&) {
tqslTrace("GetNewPasswordDialog::OnOk", NULL);
EndModal(wxID_OK);
}
void
GetNewPasswordDialog::OnCancel(wxCommandEvent&) {
tqslTrace("GetNewPasswordDialog::OnCancel", NULL);
EndModal(wxID_CANCEL);
}
void
GetNewPasswordDialog::OnHelp(wxCommandEvent&) {
tqslTrace("GetNewPasswordDialog::OnHelp", NULL);
if (_help && !_helpfile.IsEmpty())
_help->Display(_helpfile);
}
BEGIN_EVENT_TABLE(GetUserAndPasswordDialog, wxDialog)
EVT_BUTTON(GPW_ID_OK3, GetUserAndPasswordDialog::OnOk)
EVT_BUTTON(GPW_ID_CAN2, GetUserAndPasswordDialog::OnCancel)
EVT_BUTTON(GPW_ID_HELP2, GetUserAndPasswordDialog::OnHelp)
END_EVENT_TABLE()
GetUserAndPasswordDialog::GetUserAndPasswordDialog(wxWindow *parent, const wxString& title,
const wxString& message, wxHtmlHelpController *help, wxString helpfile)
: wxDialog(parent, -1, title), _help(help), _helpfile(helpfile) {
tqslTrace("GetUserAndPassword::GetUserAndPasswordDialog", "parent=%lx, title=%s, message=%s", reinterpret_cast<void *>(parent), S(title), S(helpfile));
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxSize sz = getTextSize(this);
int em_w = sz.GetWidth();
wxStaticText *st = new wxStaticText(this, -1, message);
st->Wrap(em_w * 40);
sizer->Add(st, 1, wxALL|wxEXPAND, 10);
wxBoxSizer *userSizer = new wxBoxSizer(wxHORIZONTAL);
userSizer->Add(new wxStaticText(this, -1, _("LoTW Username:")), 0, wxLEFT|wxRIGHT|wxALIGN_CENTRE, 10);
_un = new wxTextCtrl(this, GPW_ID_UN, wxT(""), wxDefaultPosition, wxSize(em_w * 15, -1));
userSizer->Add(_un, 0, wxLEFT|wxRIGHT, 10);
sizer->Add(userSizer);
wxBoxSizer *pwdSizer = new wxBoxSizer(wxHORIZONTAL);
pwdSizer->Add(new wxStaticText(this, -1, _("LoTW Password:")), 0, wxLEFT|wxRIGHT|wxALIGN_CENTRE, 10);
_pw = new wxTextCtrl(this, GPW_ID_PW3, wxT(""), wxDefaultPosition, wxSize(em_w*15, -1), wxTE_PASSWORD);
pwdSizer->Add(_pw, 0, wxLEFT|wxRIGHT, 10);
sizer->Add(pwdSizer);
wxBoxSizer *butsizer = new wxBoxSizer(wxHORIZONTAL);
wxButton *okButton = new wxButton(this, GPW_ID_OK3, _("OK"));
butsizer->Add(okButton, 0, 0, 0);
okButton->SetDefault();
butsizer->Add(new wxButton(this, GPW_ID_CAN2, _("Cancel")), 0, wxLEFT, 200);
if (_help && !_helpfile.IsEmpty())
butsizer->Add(new wxButton(this, GPW_ID_HELP2, _("Help")), 0, wxLEFT, 20);
sizer->Add(butsizer, 0, wxALL|wxALIGN_CENTER, 10);
SetAutoLayout(TRUE);
SetSizer(sizer);
sizer->Fit(this);
sizer->SetSizeHints(this);
CentreOnParent();
}
bool
GetUserAndPasswordDialog::TransferDataFromWindow() {
tqslTrace("GetUserAndPasswordDialog::TransferDataFromWindow", NULL);
_username = _un->GetValue();
_password = _pw->GetValue();
return true;
}
void
GetUserAndPasswordDialog::OnOk(wxCommandEvent&) {
tqslTrace("GetUserAndPasswordDialog::OnOk", NULL);
if (TransferDataFromWindow())
EndModal(wxID_OK);
}
void
GetUserAndPasswordDialog::OnCancel(wxCommandEvent&) {
tqslTrace("GetUserAndPasswordDialog::OnCancel", NULL);
EndModal(wxID_CANCEL);
}
void
GetUserAndPasswordDialog::OnHelp(wxCommandEvent&) {
tqslTrace("GetUserAndPasswordDialog::OnHelp", NULL);
if (_help && !_helpfile.IsEmpty())
_help->Display(_helpfile);
}
|