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 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190
|
/***************************************************************************
crqwiz.cpp - description
-------------------
begin : Sat Jun 15 2002
copyright : (C) 2002 by ARRL
author : Jon Bloom
email : jbloom@arrl.org
revision : $Id$
***************************************************************************/
#include "crqwiz.h"
#include <ctype.h>
#include <stdlib.h>
#include <wx/validate.h>
#include <wx/datetime.h>
#include <wx/config.h>
#include <wx/tokenzr.h>
#include <algorithm>
#include <iostream>
#include <string>
#include "dxcc.h"
#include "util.h"
#include "tqslctrls.h"
#include "tqsltrace.h"
#include "winstrdefs.h"
using std::string;
static wxString callTypeChoices[] = {
_("My current personal callsign"),
_("My former personal callsign or a portable modifier for my current callsign"),
_("A primary club callsign"),
_("A secondary club callsign (I have a Callsign Certificate for the primary club callsign)"),
_("A DXpedition, Portable, or holiday operation with multiple operators"),
_("A DXpedition, Portable, or holiday operation where I am the only operator"),
_("An operator that uses me as a QSL manager"),
_("A special event (1x1) callsign"),
_("A special event callsign with multiple operators"),
_("A special event callsign where I am the only operator")
};
CRQWiz::CRQWiz(TQSL_CERT_REQ *crq, tQSL_Cert xcert, wxWindow *parent, wxHtmlHelpController *help,
const wxString& title)
: ExtWizard(parent, help, title), cert(xcert), _crq(crq) {
tqslTrace("CRQWiz::CRQWiz", "crq=%lx, xcert=%lx, title=%s", reinterpret_cast<void *>(cert), reinterpret_cast<void *>(xcert), S(title));
dxcc = -1;
ncerts = 0;
// Get count of valid certificates
tqsl_selectCertificates(NULL, &ncerts, NULL, 0, NULL, NULL, 0);
nprov = 1;
tqsl_getNumProviders(&nprov);
providerPage = new CRQ_ProviderPage(this, _crq);
signPage = new CRQ_SignPage(this, _crq);
introPage = new CRQ_IntroPage(this, _crq);
namePage = new CRQ_NamePage(this, _crq);
emailPage = new CRQ_EmailPage(this, _crq);
pwPage = new CRQ_PasswordPage(this);
typePage = new CRQ_TypePage(this);
if (nprov != 1)
wxWizardPageSimple::Chain(providerPage, introPage);
wxWizardPageSimple::Chain(typePage, namePage);
wxWizardPageSimple::Chain(namePage, emailPage);
wxWizardPageSimple::Chain(emailPage, pwPage);
signIt = true;
if (cert || ncerts == 0)
signIt = false;
if (!cert)
wxWizardPageSimple::Chain(pwPage, signPage);
if (nprov == 1)
_first = introPage;
else
_first = providerPage;
AdjustSize();
CenterOnParent();
}
// Page constructors
BEGIN_EVENT_TABLE(CRQ_ProviderPage, CRQ_Page)
EVT_COMBOBOX(ID_CRQ_PROVIDER, CRQ_ProviderPage::UpdateInfo)
END_EVENT_TABLE()
static bool
prov_cmp(const TQSL_PROVIDER& p1, const TQSL_PROVIDER& p2) {
return strcasecmp(p1.organizationName, p2.organizationName) < 0;
}
CRQ_ProviderPage::CRQ_ProviderPage(CRQWiz *parent, TQSL_CERT_REQ *crq) : CRQ_Page(parent) {
tqslTrace("CRQ_ProviderPage::CRQ_ProviderPage", "parent=%lx, crq=%lx", reinterpret_cast<void *>(parent), reinterpret_cast<void *>(crq));
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxWindowDC dc(this);
dc.SetFont(this->GetFont());
wxCoord textwidth, textheight;
Parent()->maxWidth = 0;
// Find the width of the longest string
for (unsigned int i = 0; i < sizeof callTypeChoices / sizeof callTypeChoices[0]; i++) {
dc.GetTextExtent(wxGetTranslation(callTypeChoices[i]), &textwidth, &textheight);
Parent()->maxWidth = textwidth > Parent()->maxWidth ? textwidth: Parent()->maxWidth;
}
wxCoord em_w, em_h;
dc.GetTextExtent(wxString(wxT("M")), &em_w, &em_h);
if (Parent()->maxWidth < em_w * 40)
Parent()->maxWidth = em_w * 40;
wxString lbl = _("This will create a new Callsign Certificate request file.");
lbl += wxT("\n\n");
lbl += _("Once you supply the requested information and the "
"request file has been created, you must send the "
"request file to the certificate issuer.");
wxStaticText *st = new wxStaticText(this, -1, lbl);
st->SetSize(Parent()->maxWidth + em_w * 2, em_h * 5);
st->Wrap(Parent()->maxWidth + em_w * 3);
sizer->Add(st, 0, wxALL, 10);
sizer->Add(new wxStaticText(this, -1, _("Certificate Issuer:")), 0, wxLEFT|wxRIGHT, 10);
tc_provider = new wxComboBox(this, ID_CRQ_PROVIDER, wxT(""), wxDefaultPosition,
wxDefaultSize, 0, 0, wxCB_DROPDOWN|wxCB_READONLY);
sizer->Add(tc_provider, 0, wxLEFT|wxRIGHT|wxEXPAND, 10);
tc_provider_info = new wxStaticText(this, ID_CRQ_PROVIDER_INFO, wxT(""), wxDefaultPosition,
wxSize(0, em_h*5));
sizer->Add(tc_provider_info, 0, wxALL|wxEXPAND, 10);
int nprov = 0;
if (tqsl_getNumProviders(&nprov))
wxMessageBox(getLocalizedErrorString(), _("Error"), wxOK | wxICON_ERROR, this);
for (int i = 0; i < nprov; i++) {
TQSL_PROVIDER prov;
if (!tqsl_getProvider(i, &prov))
providers.push_back(prov);
}
sort(providers.begin(), providers.end(), prov_cmp);
int selected = -1;
for (int i = 0; i < static_cast<int>(providers.size()); i++) {
tc_provider->Append(wxString::FromUTF8(providers[i].organizationName), reinterpret_cast<void *>(i));
if (crq && !strcmp(providers[i].organizationName, crq->providerName)
&& !strcmp(providers[i].organizationalUnitName, crq->providerUnit)) {
selected = i;
}
}
tc_provider->SetSelection((selected < 0) ? 0 : selected);
if (providers.size() < 2 || selected >= 0)
tc_provider->Enable(false);
DoUpdateInfo();
AdjustPage(sizer, wxT("crq.htm"));
}
void
CRQ_ProviderPage::DoUpdateInfo() {
tqslTrace("CRQ_ProviderPage::DoUpdateInfo", NULL);
int sel = tc_provider->GetSelection();
if (sel >= 0) {
long idx = (long)(tc_provider->GetClientData(sel));
if (idx >=0 && idx < static_cast<int>(providers.size())) {
Parent()->provider = providers[idx];
wxString info;
info = wxString::FromUTF8(Parent()->provider.organizationName);
if (Parent()->provider.organizationalUnitName[0] != 0)
info += wxString(wxT("\n ")) + wxString::FromUTF8(Parent()->provider.organizationalUnitName);
if (Parent()->provider.emailAddress[0] != 0)
info += wxString(wxT("\n")) += _("Email: ") + wxString::FromUTF8(Parent()->provider.emailAddress);
if (Parent()->provider.url[0] != 0)
info += wxString(wxT("\n")) + _("URL: ") + wxString::FromUTF8(Parent()->provider.url);
tc_provider_info->SetLabel(info);
}
}
}
void
CRQ_ProviderPage::UpdateInfo(wxCommandEvent&) {
tqslTrace("CRQ_ProviderPage::UpdateInfo", NULL);
DoUpdateInfo();
}
static wxDateTime::Month mons[] = {
wxDateTime::Inv_Month, wxDateTime::Jan, wxDateTime::Feb, wxDateTime::Mar,
wxDateTime::Apr, wxDateTime::May, wxDateTime::Jun, wxDateTime::Jul,
wxDateTime::Aug, wxDateTime::Sep, wxDateTime::Oct, wxDateTime::Nov,
wxDateTime::Dec };
BEGIN_EVENT_TABLE(CRQ_IntroPage, CRQ_Page)
EVT_TEXT(ID_CRQ_CALL, CRQ_Page::check_valid)
EVT_COMBOBOX(ID_CRQ_DXCC, CRQ_Page::check_valid)
EVT_COMBOBOX(ID_CRQ_QBYEAR, CRQ_Page::check_valid)
EVT_COMBOBOX(ID_CRQ_QBMONTH, CRQ_Page::check_valid)
EVT_COMBOBOX(ID_CRQ_QBDAY, CRQ_Page::check_valid)
EVT_COMBOBOX(ID_CRQ_QEYEAR, CRQ_Page::check_valid)
EVT_COMBOBOX(ID_CRQ_QEMONTH, CRQ_Page::check_valid)
EVT_COMBOBOX(ID_CRQ_QEDAY, CRQ_Page::check_valid)
END_EVENT_TABLE()
CRQ_IntroPage::CRQ_IntroPage(CRQWiz *parent, TQSL_CERT_REQ *crq) : CRQ_Page(parent) {
tqslTrace("CRQ_IntroPage::CRQ_IntroPage", "parent=%lx, crq=%lx", reinterpret_cast<void *>(parent), reinterpret_cast<void *>(crq));
initialized = false;
_parent = parent;
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxStaticText *dst = new wxStaticText(this, -1, _("DXCC entity:"));
wxSize sz = getTextSize(this);
int em_h = sz.GetHeight();
em_w = sz.GetWidth();
wxStaticText *st = new wxStaticText(this, -1, _("Call sign:"), wxDefaultPosition, wxDefaultSize,
wxST_NO_AUTORESIZE|wxALIGN_RIGHT);
st->SetSize(dst->GetSize());
wxBoxSizer *hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->Add(st, 0, wxRIGHT, 5);
wxString cs;
if (crq && crq->callSign)
cs = wxString::FromUTF8(crq->callSign);
tc_call = new wxTextCtrl(this, ID_CRQ_CALL, cs, wxDefaultPosition, wxSize(em_w*15, -1));
hsizer->Add(tc_call, 0, wxEXPAND, 0);
sizer->Add(hsizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 10);
if (crq && crq->callSign)
tc_call->Enable(false);
hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->Add(dst, 0, wxRIGHT, 5);
tc_dxcc = new wxComboBox(this, ID_CRQ_DXCC, wxT(""), wxDefaultPosition,
wxSize(em_w*25, -1), 0, 0, wxCB_DROPDOWN|wxCB_READONLY);
hsizer->Add(tc_dxcc, 1, 0, 0);
sizer->Add(hsizer, 0, wxALL, 10);
DXCC dx;
bool ok = dx.getFirst();
while (ok) {
tc_dxcc->Append(wxString::FromUTF8(dx.name()), reinterpret_cast<void *>(dx.number()));
ok = dx.getNext();
}
const char *ent = "NONE";
if (crq) {
if (dx.getByEntity(crq->dxccEntity)) {
ent = dx.name();
tc_dxcc->Enable(false);
}
}
int i = tc_dxcc->FindString(wxString::FromUTF8(ent));
if (i >= 0)
tc_dxcc->SetSelection(i);
struct {
wxComboBox **cb;
int id;
} boxes[][3] = {
{ {&tc_qsobeginy, ID_CRQ_QBYEAR}, {&tc_qsobeginm, ID_CRQ_QBMONTH}, {&tc_qsobegind, ID_CRQ_QBDAY} },
{ {&tc_qsoendy, ID_CRQ_QEYEAR}, {&tc_qsoendm, ID_CRQ_QEMONTH}, {&tc_qsoendd, ID_CRQ_QEDAY} }
};
int year = wxDateTime::GetCurrentYear() + 1;
int sels[2][3];
int dates[2][3];
if (crq) {
dates[0][0] = crq->qsoNotBefore.year;
dates[0][1] = crq->qsoNotBefore.month;
dates[0][2] = crq->qsoNotBefore.day;
dates[1][0] = crq->qsoNotAfter.year;
dates[1][1] = crq->qsoNotAfter.month;
dates[1][2] = crq->qsoNotAfter.day;
}
wxString label = _("Date of the first QSO you made or will make using this callsign:");
for (int i = 0; i < 2; i++) {
sels[i][0] = sels[i][1] = sels[i][2] = 0;
sizer->Add(new wxStaticText(this, -1, label), 0, wxBOTTOM, 5);
hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->Add(new wxStaticText(this, -1, wxT("Y")), 0, wxLEFT, 20);
*(boxes[i][0].cb) = new wxComboBox(this, boxes[i][0].id, wxT(""), wxDefaultPosition,
wxSize(em_w*8, -1), 0, 0, wxCB_DROPDOWN|wxCB_READONLY);
hsizer->Add(*(boxes[i][0].cb), 0, wxLEFT, 5);
hsizer->Add(new wxStaticText(this, -1, wxT("M")), 0, wxLEFT, 10);
*(boxes[i][1].cb) = new wxComboBox(this, boxes[i][1].id, wxT(""), wxDefaultPosition,
wxSize(em_w*5, -1), 0, 0, wxCB_DROPDOWN|wxCB_READONLY);
hsizer->Add(*(boxes[i][1].cb), 0, wxLEFT, 5);
hsizer->Add(new wxStaticText(this, -1, wxT("D")), 0, wxLEFT, 10);
*(boxes[i][2].cb) = new wxComboBox(this, boxes[i][2].id, wxT(""), wxDefaultPosition,
wxSize(em_w*5, -1), 0, 0, wxCB_DROPDOWN|wxCB_READONLY);
hsizer->Add(*(boxes[i][2].cb), 0, wxLEFT, 5);
int iofst = 0;
if (i > 0) {
iofst++;
for (int j = 0; j < 3; j++)
(*(boxes[i][j].cb))->Append(wxT(""));
}
for (int j = 1945; j <= year; j++) {
wxString s;
s.Printf(wxT("%d"), j);
if (crq && dates[i][0] == j)
sels[i][0] = j - 1945 + iofst;
(*(boxes[i][0].cb))->Append(s);
}
year++;
for (int j = 1; j <= 12; j++) {
wxString s;
s.Printf(wxT("%d"), j);
if (crq && dates[i][1] == j)
sels[i][1] = j - 1 + iofst;
(*(boxes[i][1].cb))->Append(s);
}
for (int j = 1; j <= 31; j++) {
wxString s;
s.Printf(wxT("%d"), j);
if (crq && dates[i][2] == j)
sels[i][2] = j - 1 + iofst;
(*(boxes[i][2].cb))->Append(s);
}
sizer->Add(hsizer, 0, wxLEFT|wxRIGHT, 10);
if (i == 0)
sizer->Add(0, 40);
label = _("Date of the last QSO you made or will make using this callsign:\n(Leave this date blank if this is still your valid callsign.)");
}
if (crq) {
tc_qsobeginy->SetSelection(sels[0][0]);
tc_qsobeginm->SetSelection(sels[0][1]);
tc_qsobegind->SetSelection(sels[0][2]);
wxDateTime now = wxDateTime::Now();
wxDateTime qsoEnd(crq->qsoNotAfter.day, mons[crq->qsoNotAfter.month],
crq->qsoNotAfter.year, 23, 59, 59);
if (qsoEnd < now) {
// Looks like this is a cert for an expired call sign,
// so keep the QSO end date as-is. Otherwise, leave it
// blank so CA can fill it in.
tc_qsoendy->SetSelection(sels[1][0]);
tc_qsoendm->SetSelection(sels[1][1]);
tc_qsoendd->SetSelection(sels[1][2]);
}
}
tc_status = new wxStaticText(this, -1, wxT(""), wxDefaultPosition, wxSize(Parent()->maxWidth, em_h*4));
sizer->Add(tc_status, 0, wxALL|wxEXPAND, 10);
AdjustPage(sizer, wxT("crq0.htm"));
initialized = true;
}
CRQ_Page *
CRQ_IntroPage::GetNext() const {
tqslTrace("CRQ_IntroPage::GetNext", NULL);
if (_parent->cert) { // Renewal
_parent->signIt = false;
return _parent->namePage;
}
if (_parent->dxcc == 0) { // NONE always requires signature
_parent->signIt = true;
return _parent->typePage;
}
if (_parent->ncerts == 0) { // No certs, can't sign.
_parent->signIt = false;
return _parent->namePage;
}
return _parent->typePage;
}
CRQ_Page *
CRQ_IntroPage::GetPrev() const {
tqslTrace("CRQ_IntroPage::GetPrev", NULL);
return _parent->introPage;
}
BEGIN_EVENT_TABLE(CRQ_NamePage, CRQ_Page)
EVT_TEXT(ID_CRQ_NAME, CRQ_Page::check_valid)
EVT_TEXT(ID_CRQ_ADDR1, CRQ_Page::check_valid)
EVT_TEXT(ID_CRQ_CITY, CRQ_Page::check_valid)
END_EVENT_TABLE()
CRQ_NamePage::CRQ_NamePage(CRQWiz *parent, TQSL_CERT_REQ *crq) : CRQ_Page(parent) {
tqslTrace("CRQ_NamePage::CRQ_NamePage", "parent=%lx, crq=%lx", reinterpret_cast<void *>(parent), reinterpret_cast<void *>(crq));
initialized = false;
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
_parent = parent;
wxStaticText *zst = new wxStaticText(this, -1, _("Zip/Postal"));
wxSize sz = getTextSize(this);
int em_w = sz.GetWidth();
int def_w = em_w * 20;
wxStaticText *st = new wxStaticText(this, -1, _("Name"), wxDefaultPosition, wxDefaultSize,
wxST_NO_AUTORESIZE|wxALIGN_RIGHT);
st->SetSize(zst->GetSize());
wxConfig *config = reinterpret_cast<wxConfig *>(wxConfig::Get());
wxString val;
wxBoxSizer *hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->Add(st, 0, wxRIGHT, 5);
wxString s;
if (crq && crq->name)
s = wxString::FromUTF8(crq->name);
else if (config->Read(wxT("Name"), &val))
s = val;
tc_name = new wxTextCtrl(this, ID_CRQ_NAME, s, wxDefaultPosition, wxSize(def_w, -1));
hsizer->Add(tc_name, 1, 0, 0);
sizer->Add(hsizer, 0, wxALL, 10);
tc_name->SetMaxLength(TQSL_CRQ_NAME_MAX);
s = wxT("");
if (crq && crq->address1)
s = wxString::FromUTF8(crq->address1);
else if (config->Read(wxT("Addr1"), &val))
s = val;
hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->Add(new wxStaticText(this, -1, _("Address"), wxDefaultPosition, zst->GetSize(),
wxST_NO_AUTORESIZE|wxALIGN_RIGHT), 0, wxRIGHT, 5);
tc_addr1 = new wxTextCtrl(this, ID_CRQ_ADDR1, s, wxDefaultPosition, wxSize(def_w, -1));
hsizer->Add(tc_addr1, 1, 0, 0);
sizer->Add(hsizer, 0, wxLEFT|wxRIGHT|wxBOTTOM, 10);
tc_addr1->SetMaxLength(TQSL_CRQ_ADDR_MAX);
s = wxT("");
if (crq && crq->address2)
s = wxString::FromUTF8(crq->address2);
else if (config->Read(wxT("Addr2"), &val))
s = val;
hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->Add(new wxStaticText(this, -1, wxT(""), wxDefaultPosition, zst->GetSize(),
wxST_NO_AUTORESIZE|wxALIGN_RIGHT), 0, wxRIGHT, 5);
tc_addr2 = new wxTextCtrl(this, ID_CRQ_ADDR2, s, wxDefaultPosition, wxSize(def_w, -1));
hsizer->Add(tc_addr2, 1, 0, 0);
sizer->Add(hsizer, 0, wxLEFT|wxRIGHT|wxBOTTOM, 10);
tc_addr2->SetMaxLength(TQSL_CRQ_ADDR_MAX);
s = wxT("");
if (crq && crq->city)
s = wxString::FromUTF8(crq->city);
else if (config->Read(wxT("City"), &val))
s = val;
hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->Add(new wxStaticText(this, -1, _("City"), wxDefaultPosition, zst->GetSize(),
wxST_NO_AUTORESIZE|wxALIGN_RIGHT), 0, wxRIGHT, 5);
tc_city = new wxTextCtrl(this, ID_CRQ_CITY, s, wxDefaultPosition, wxSize(def_w, -1));
hsizer->Add(tc_city, 1, 0, 0);
sizer->Add(hsizer, 0, wxLEFT|wxRIGHT|wxBOTTOM, 10);
tc_city->SetMaxLength(TQSL_CRQ_CITY_MAX);
s = wxT("");
if (crq && crq->state)
s = wxString::FromUTF8(crq->state);
else if (config->Read(wxT("State"), &val))
s = val;
hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->Add(new wxStaticText(this, -1, _("State"), wxDefaultPosition, zst->GetSize(),
wxST_NO_AUTORESIZE|wxALIGN_RIGHT), 0, wxRIGHT, 5);
tc_state = new wxTextCtrl(this, ID_CRQ_STATE, s, wxDefaultPosition, wxSize(def_w, -1));
hsizer->Add(tc_state, 1, 0, 0);
sizer->Add(hsizer, 0, wxLEFT|wxRIGHT|wxBOTTOM, 10);
tc_state->SetMaxLength(TQSL_CRQ_STATE_MAX);
s = wxT("");
if (crq && crq->postalCode)
s = wxString::FromUTF8(crq->postalCode);
else if (config->Read(wxT("ZIP"), &val))
s = val;
hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->Add(zst, 0, wxRIGHT, 5);
tc_zip = new wxTextCtrl(this, ID_CRQ_ZIP, s, wxDefaultPosition, wxSize(def_w, -1));
hsizer->Add(tc_zip, 1, 0, 0);
sizer->Add(hsizer, 0, wxLEFT|wxRIGHT|wxBOTTOM, 10);
tc_zip->SetMaxLength(TQSL_CRQ_POSTAL_MAX);
s = wxT("");
if (crq && crq->country)
s = wxString::FromUTF8(crq->country);
else if (config->Read(_("Country"), &val))
s = val;
hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->Add(new wxStaticText(this, -1, _("Country"), wxDefaultPosition, zst->GetSize(),
wxST_NO_AUTORESIZE|wxALIGN_RIGHT), 0, wxRIGHT, 5);
tc_country = new wxTextCtrl(this, ID_CRQ_COUNTRY, s, wxDefaultPosition, wxSize(def_w, -1));
hsizer->Add(tc_country, 1, 0, 0);
sizer->Add(hsizer, 0, wxLEFT|wxRIGHT|wxBOTTOM, 10);
tc_country->SetMaxLength(TQSL_CRQ_COUNTRY_MAX);
tc_status = new wxStaticText(this, -1, wxT(""));
sizer->Add(tc_status, 0, wxALL|wxEXPAND, 10);
AdjustPage(sizer, wxT("crq1.htm"));
initialized = true;
}
CRQ_Page *
CRQ_NamePage::GetNext() const {
tqslTrace("CRQ_NamePage::GetNext", NULL);
return _parent->emailPage;
}
CRQ_Page *
CRQ_NamePage::GetPrev() const {
tqslTrace("CRQ_NamePage::GetPrev", NULL);
if (_parent->ncerts > 0 && _parent->dxcc != 0)
return _parent->typePage;
else
return _parent->introPage;
}
BEGIN_EVENT_TABLE(CRQ_EmailPage, CRQ_Page)
EVT_TEXT(ID_CRQ_EMAIL, CRQ_Page::check_valid)
END_EVENT_TABLE()
CRQ_EmailPage::CRQ_EmailPage(CRQWiz *parent, TQSL_CERT_REQ *crq) : CRQ_Page(parent) {
tqslTrace("CRQ_EmailPage::CRQ_EmailPage", "parent=%lx, crq=%lx", reinterpret_cast<void *>(parent), reinterpret_cast<void *>(crq));
initialized = false;
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxSize sz = getTextSize(this);
int em_w = sz.GetWidth();
wxStaticText *st = new wxStaticText(this, -1, _("Your e-mail address"));
wxConfig *config = reinterpret_cast<wxConfig *>(wxConfig::Get());
wxString val;
wxString s;
if (crq && crq->emailAddress)
s = wxString::FromUTF8(crq->emailAddress);
else if (config->Read(wxT("Email"), &val))
s = val;
sizer->Add(st, 0, wxLEFT|wxRIGHT|wxTOP, 10);
tc_email = new wxTextCtrl(this, ID_CRQ_EMAIL, s, wxDefaultPosition, wxSize(em_w*30, -1));
sizer->Add(tc_email, 0, wxLEFT|wxRIGHT|wxBOTTOM, 10);
tc_email->SetMaxLength(TQSL_CRQ_EMAIL_MAX);
wxStaticText *tc_warn = new wxStaticText(this, -1, _("Note: The e-mail address you provide here is the "
"address to which the issued Certificate will be sent. "
"Make sure it's the correct address!"));
sizer->Add(tc_warn, 0, wxALL, 10);
tc_warn->Wrap(Parent()->maxWidth);
tc_status = new wxStaticText(this, -1, wxT(""));
sizer->Add(tc_status, 0, wxALL|wxEXPAND, 10);
AdjustPage(sizer, wxT("crq2.htm"));
initialized = true;
}
BEGIN_EVENT_TABLE(CRQ_PasswordPage, CRQ_Page)
EVT_TEXT(ID_CRQ_PW1, CRQ_Page::check_valid)
EVT_TEXT(ID_CRQ_PW2, CRQ_Page::check_valid)
END_EVENT_TABLE()
CRQ_PasswordPage::CRQ_PasswordPage(CRQWiz *parent) : CRQ_Page(parent) {
tqslTrace("CRQ_PasswordPage::CRQ_PasswordPage", "parent=%lx", reinterpret_cast<void *>(parent));
initialized = false;
_parent = parent;
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxSize sz = getTextSize(this);
em_w = sz.GetWidth();
em_h = sz.GetHeight();
wxString lbl = _("You may protect this Callsign Certificate using a password. "
"If you are using a computer system that is shared with "
"others, you should specify a password to protect this "
"Callsign Certificate. However, if you are using a computer "
"in a private residence, no password need be specified.");
wxStaticText *st = new wxStaticText(this, -1, lbl);
st->SetSize(Parent()->maxWidth, em_h * 5);
st->Wrap(Parent()->maxWidth);
sizer->Add(st, 0, wxLEFT|wxRIGHT|wxTOP, 10);
fwdPrompt = new wxStaticText(this, -1, _("Leave the password blank and click 'Next' unless you want to use a password."));
fwdPrompt->SetSize(Parent()->maxWidth, em_h * 5);
fwdPrompt->Wrap(Parent()->maxWidth);
sizer->Add(fwdPrompt, 0, wxLEFT|wxRIGHT|wxTOP, 10);
sizer->Add(new wxStaticText(this, -1, _("Password:")),
0, wxLEFT|wxRIGHT|wxTOP, 10);
tc_pw1 = new wxTextCtrl(this, ID_CRQ_PW1, wxT(""), wxDefaultPosition, wxSize(em_w*20, -1), wxTE_PASSWORD);
sizer->Add(tc_pw1, 0, wxLEFT|wxRIGHT, 10);
sizer->Add(new wxStaticText(this, -1, _("Enter the password again for verification:")),
0, wxLEFT|wxRIGHT|wxTOP, 10);
tc_pw2 = new wxTextCtrl(this, ID_CRQ_PW2, wxT(""), wxDefaultPosition, wxSize(em_w*20, -1), wxTE_PASSWORD);
sizer->Add(tc_pw2, 0, wxLEFT|wxRIGHT, 10);
wxStaticText *tc_pwwarn = new wxStaticText(this, -1, _("DO NOT lose the password you choose! "
"You will be unable to use the Certificate without this password!"));
tc_pwwarn->Wrap(em_w * 40);
sizer->Add(tc_pwwarn, 0, wxALL, 10);
tc_status = new wxStaticText(this, -1, wxT(""));
sizer->Add(tc_status, 0, wxALL|wxEXPAND, 10);
AdjustPage(sizer, wxT("crq3.htm"));
initialized = true;
}
CRQ_Page *
CRQ_PasswordPage::GetNext() const {
tqslTrace("CRQ_PasswordPage::GetNext", NULL);
if (_parent->signIt) {
fwdPrompt->SetLabel(_("Leave the password blank and click 'Next' unless you want to use a password."));
fwdPrompt->SetSize(_parent->maxWidth, em_h * 5);
fwdPrompt->Wrap(_parent->maxWidth);
return _parent->signPage;
} else {
fwdPrompt->SetLabel(_("Leave the password blank and click 'Finish' unless you want to use a password."));
fwdPrompt->SetSize(_parent->maxWidth, em_h * 5);
fwdPrompt->Wrap(_parent->maxWidth);
return NULL;
}
}
CRQ_Page *
CRQ_PasswordPage::GetPrev() const {
tqslTrace("CRQ_PasswordPage::GetPrev", NULL);
return _parent->emailPage;
}
BEGIN_EVENT_TABLE(CRQ_SignPage, CRQ_Page)
EVT_TREE_SEL_CHANGED(ID_CRQ_CERT, CRQ_SignPage::CertSelChanged)
EVT_WIZARD_PAGE_CHANGING(wxID_ANY, CRQ_SignPage::OnPageChanging)
END_EVENT_TABLE()
void CRQ_SignPage::CertSelChanged(wxTreeEvent& event) {
tqslTrace("CRQ_SignPage::CertSelChanged", NULL);
if (cert_tree->GetItemData(event.GetItem()))
Parent()->signIt = true;
wxCommandEvent dummy;
check_valid(dummy);
}
BEGIN_EVENT_TABLE(CRQ_TypePage, CRQ_Page)
EVT_RADIOBOX(ID_CRQ_TYPE, CRQ_Page::check_valid)
END_EVENT_TABLE()
CRQ_TypePage::CRQ_TypePage(CRQWiz *parent)
: CRQ_Page(parent) {
tqslTrace("CRQ_TypePage::CRQ_TypePage", "parent=%lx", reinterpret_cast<void *>(parent));
initialized = false;
_parent = parent;
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxArrayString ch;
for (unsigned int i = 0; i < sizeof callTypeChoices / sizeof callTypeChoices[0]; i++) {
wxString wtf = wxGetTranslation(callTypeChoices[i]);
ch.Add(wxGetTranslation(callTypeChoices[i]));
}
certType = new wxRadioBox(this, ID_CRQ_TYPE, _("This Callsign Certificate is for:"), wxDefaultPosition,
wxDefaultSize, ch, 1, wxRA_SPECIFY_COLS);
sizer->Add(certType, 0, wxALL|wxEXPAND, 10);
}
bool
CRQ_TypePage::TransferDataFromWindow() {
bool signThisType[] = {
false, // Current personal
true, // former personal
false, // Primary club
true, // Secondary club
false, // dxpedition multi-op
true, // dxpedition single-op
false, // QSL Manager
true, // 1x1 callsign
false, // spec event multi-op
true // spec event single-op
};
wxString signPrompts[] = {
wxT("sign error"), // Current personal
_("Please select the Callsign Certificate for your current personal callsign to validate your request."), // former personal
_("Please select a Callsign Certificate to validate your request."), // Primary club
_("Please select your club's primary Callsign Certificate to validate your request."), // Secondary club
wxT("sign error"), // dxpedition multi-op
_("Please select the Callsign Certificate for your current personal callsign to validate your request."), // dxpedition single op
wxT("sign error"), // QSL Manager
_("Please select a Callsign Certificate to validate your request."), // 1x1 callsign
wxT("sign error"), // spec event multi-op
_("Please select a Callsign Certificate to validate your request.") // spec event single-op
};
tqslTrace("CRQ_TypePage::TransferDataFromWindow", NULL);
int selected = certType->GetSelection();
if (selected == wxNOT_FOUND || selected > static_cast<int>(sizeof signThisType / sizeof signThisType[0]))
return false;
Parent()->signIt = signThisType[selected];
Parent()->signPrompt = signPrompts[selected];
if (Parent()->dxcc == 0)
Parent()->signIt = true;
return true;
}
CRQ_Page *
CRQ_TypePage::GetPrev() const {
tqslTrace("CRQ_TypePage::GetPrev", NULL);
return _parent->introPage;
}
CRQ_SignPage::CRQ_SignPage(CRQWiz *parent, TQSL_CERT_REQ *crq)
: CRQ_Page(parent) {
tqslTrace("CRQ_SignPage::CRQ_SignPage", "parent=%lx", reinterpret_cast<void *>(parent));
initialized = false;
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxSize sz = getTextSize(this);
int em_h = sz.GetHeight();
em_w = sz.GetWidth();
tc_status = new wxStaticText(this, -1, wxT(""), wxDefaultPosition, wxSize(Parent()->maxWidth, em_h*3));
cert_tree = new CertTree(this, ID_CRQ_CERT, wxDefaultPosition,
wxSize(em_w*30, em_h*10), wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
sizer->Add(cert_tree, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND);
cert_tree->SetBackgroundColour(wxColour(255, 255, 255));
sizer->Add(tc_status, 0, wxALL|wxEXPAND, 10);
// Default to 'signed' unless there's no valid certificates to use for signing.
if (cert_tree->Build(0, &(Parent()->provider)) > 0) {
Parent()->signIt = true;
} else {
Parent()->signIt = false;
cert_tree->Enable(false);
}
AdjustPage(sizer, wxT("crq4.htm"));
initialized = true;
}
void
CRQ_SignPage::refresh() {
tqslTrace("CRQ_SignPage::refresh", NULL);
if (cert_tree->Build(0, &(Parent()->provider)) > 0)
Parent()->signIt = true;
else
Parent()->signIt = false;
}
// Page validation
bool
CRQ_ProviderPage::TransferDataFromWindow() {
// Nothing to validate
return true;
}
const char *
CRQ_IntroPage::validate() {
tqslTrace("CRQ_IntroPage::validate", NULL);
tQSL_Cert *certlist = 0;
int ncert = 0;
if (!initialized)
return 0;
valMsg = wxT("");
wxString val = tc_call->GetValue().MakeUpper();
bool ok = true;
int sel;
const char *dxccname = NULL;
wxString pending = wxConfig::Get()->Read(wxT("RequestPending"));
wxStringTokenizer tkz(pending, wxT(","));
if (val.Len() < 3)
ok = false;
if (ok) {
string call = string(val.ToUTF8());
// Check for invalid characters
if (call.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/") != string::npos)
ok = false;
// Need at least one letter
if (call.find_first_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ") == string::npos)
ok = false;
// Need at least one number
if (call.find_first_of("0123456789") == string::npos)
ok = false;
// Invalid callsign patterns
// Starting with 0, Q, C7, or 4Y
// 1x other than 1A, 1M, 1S
string first = call.substr(0, 1);
string second = call.substr(1, 1);
if (first == "0" || first == "Q" ||
(first == "1" && second != "A" && second != "M" && second != "S"))
ok = false;
}
if (!ok) {
valMsg = _("You must enter a valid call sign.");
goto notok;
}
long old_dxcc;
old_dxcc = Parent()->dxcc;
tQSL_Date oldStartDate;
tQSL_Date oldEndDate;
tQSL_Date startDate;
tQSL_Date endDate;
tqsl_getDXCCStartDate(old_dxcc, &oldStartDate);
tqsl_getDXCCEndDate(old_dxcc, &oldEndDate);
sel = tc_dxcc->GetSelection();
if (sel >= 0)
Parent()->dxcc = (long)(tc_dxcc->GetClientData(sel));
tqsl_getDXCCStartDate(Parent()->dxcc, &startDate);
tqsl_getDXCCEndDate(Parent()->dxcc, &endDate);
if (sel < 0 || Parent()->dxcc < 0) {
valMsg = _("You must select a DXCC entity.");
goto notok;
}
if (Parent()->dxcc != old_dxcc) {
if (tqsl_isDateValid(&startDate) && !tqsl_isDateNull(&startDate) &&
tqsl_compareDates(&Parent()->qsonotbefore, &oldStartDate) == 0) {
tc_qsobeginy->SetSelection(startDate.year - 1945);
tc_qsobeginm->SetSelection(startDate.month - 1);
tc_qsobegind->SetSelection(startDate.day - 1);
}
if ((tqsl_isDateValid(&endDate) || tqsl_isDateNull(&endDate)) &&
tqsl_compareDates(&Parent()->qsonotafter, &oldEndDate) == 0) {
if (tqsl_isDateNull(&endDate)) {
tc_qsoendy->SetSelection(0);
tc_qsoendm->SetSelection(0);
tc_qsoendd->SetSelection(0);
} else {
tc_qsoendy->SetSelection(endDate.year - 1944);
tc_qsoendm->SetSelection(endDate.month);
tc_qsoendd->SetSelection(endDate.day);
}
}
}
Parent()->qsonotbefore.year = strtol(tc_qsobeginy->GetStringSelection().ToUTF8(), NULL, 10);
Parent()->qsonotbefore.month = strtol(tc_qsobeginm->GetStringSelection().ToUTF8(), NULL, 10);
Parent()->qsonotbefore.day = strtol(tc_qsobegind->GetStringSelection().ToUTF8(), NULL, 10);
Parent()->qsonotafter.year = strtol(tc_qsoendy->GetStringSelection().ToUTF8(), NULL, 10);
Parent()->qsonotafter.month = strtol(tc_qsoendm->GetStringSelection().ToUTF8(), NULL, 10);
Parent()->qsonotafter.day = strtol(tc_qsoendd->GetStringSelection().ToUTF8(), NULL, 10);
if (!tqsl_isDateValid(&Parent()->qsonotbefore)) {
valMsg = _("QSO begin date: You must choose proper values for Year, Month and Day.");
goto notok;
}
if (!tqsl_isDateNull(&Parent()->qsonotafter) && !tqsl_isDateValid(&Parent()->qsonotafter)) {
valMsg = _("QSO end date: You must either choose proper values for Year, Month and Day or leave all three blank.");
goto notok;
}
if (tqsl_isDateValid(&Parent()->qsonotbefore) && tqsl_isDateValid(&Parent()->qsonotafter)
&& tqsl_compareDates(&Parent()->qsonotbefore, &Parent()->qsonotafter) > 0) {
valMsg = _("QSO end date cannot be before QSO begin date.");
goto notok;
}
char startStr[50], endStr[50];
tqsl_convertDateToText(&endDate, endStr, sizeof endStr);
if (tqsl_getDXCCEntityName(Parent()->dxcc, &dxccname))
dxccname = "UNKNOWN";
if (!tqsl_isDateValid(&startDate)) {
startDate.year = 1945; startDate.month = 11; startDate.day = 1;
}
tqsl_convertDateToText(&startDate, startStr, sizeof startStr);
if (tqsl_isDateValid(&endDate) && tqsl_isDateNull(&Parent()->qsonotafter)) {
Parent()->qsonotafter = endDate;
if (tqsl_isDateNull(&endDate)) {
tc_qsoendy->SetSelection(0);
tc_qsoendm->SetSelection(0);
tc_qsoendd->SetSelection(0);
} else {
tc_qsoendy->SetSelection(endDate.year - 1944);
tc_qsoendm->SetSelection(endDate.month);
tc_qsoendd->SetSelection(endDate.day);
}
}
if (tqsl_isDateValid(&endDate)) {
tqsl_convertDateToText(&endDate, endStr, sizeof endStr);
} else {
endStr[0] = '\0';
}
if (tqsl_isDateValid(&startDate) && tqsl_compareDates(&Parent()->qsonotbefore, &startDate) < 0) {
valMsg = wxString::Format(_("The date of your first QSO is before the first valid date (%hs) of the selected DXCC Entity %hs"), startStr, dxccname);
goto notok;
}
if (tqsl_isDateValid(&endDate) && tqsl_compareDates(&Parent()->qsonotbefore, &endDate) > 0) {
valMsg = wxString::Format(_("The date of your first QSO is after the last valid date (%hs) of the selected DXCC Entity %hs"), endStr, dxccname);
goto notok;
}
if (tqsl_isDateValid(&startDate) && !tqsl_isDateNull(&Parent()->qsonotafter) && tqsl_compareDates(&Parent()->qsonotafter, &startDate) < 0) {
valMsg = wxString::Format(_("The date of your last QSO is before the first valid date (%hs) of the selected DXCC Entity %hs"), startStr, dxccname);
goto notok;
}
if (tqsl_isDateValid(&endDate) && tqsl_compareDates(&Parent()->qsonotafter, &endDate) > 0) {
valMsg = wxString::Format(_("The date of your last QSO is after the last valid date (%hs) of the selected DXCC Entity %hs"), endStr, dxccname);
goto notok;
}
// Data looks okay, now let's make sure this isn't a duplicate request
// (unless it's a renewal).
val.MakeUpper();
tqsl_selectCertificates(&certlist, &ncert, val.ToUTF8(), Parent()->dxcc, 0,
&(Parent()->provider), TQSL_SELECT_CERT_WITHKEYS);
if (!Parent()->_crq && ncert > 0) {
char cert_before_buf[40], cert_after_buf[40];
for (int i = 0; i < ncert; i++) {
// See if this cert overlaps the user-specified date range
tQSL_Date cert_not_before, cert_not_after;
int cert_dxcc = 0;
tqsl_getCertificateQSONotBeforeDate(certlist[i], &cert_not_before);
tqsl_getCertificateQSONotAfterDate(certlist[i], &cert_not_after);
tqsl_getCertificateDXCCEntity(certlist[i], &cert_dxcc);
if (cert_dxcc == Parent()->dxcc
&& ((tqsl_isDateValid(&Parent()->qsonotafter)
&& !(tqsl_compareDates(&Parent()->qsonotbefore, &cert_not_after) == 1
|| tqsl_compareDates(&Parent()->qsonotafter, &cert_not_before) == -1))
|| (!tqsl_isDateValid(&Parent()->qsonotafter)
&& !(tqsl_compareDates(&Parent()->qsonotbefore, &cert_not_after) == 1)))) {
ok = false; // Overlap!
tqsl_convertDateToText(&cert_not_before, cert_before_buf, sizeof cert_before_buf);
tqsl_convertDateToText(&cert_not_after, cert_after_buf, sizeof cert_after_buf);
}
}
tqsl_freeCertificateList(certlist, ncert);
if (ok == false) {
DXCC dxcc;
dxcc.getByEntity(Parent()->dxcc);
// TRANSLATORS: first argument is callsign (%s), second is the related DXCC entity name (%hs)
valMsg = wxString::Format(_("You have an overlapping Certificate for %s (DXCC=%hs) having QSO dates: "), val.c_str(), dxcc.name());
// TRANSLATORS: here "to" separates two dates in a date range
valMsg += wxString::FromUTF8(cert_before_buf) + _(" to ") + wxString::FromUTF8(cert_after_buf);
}
}
while (tkz.HasMoreTokens()) {
wxString pend = tkz.GetNextToken();
if (pend == val) {
wxString fmt = _("You have already requested a Callsign Certificate for %s "
"and can not request another until that request has been "
"processed by LoTW Staff.");
fmt += wxT("\n\n");
fmt += _("Please wait until you receive an e-mail bearing your "
"requested Callsign Certificate.");
fmt += wxT("\n\n");
fmt += _("If you are sure that the earlier request is now invalid "
"you should delete the pending Callsign Certificate for %s.");
valMsg = wxString::Format(fmt, val.c_str(), val.c_str());
}
}
notok:
tc_status->SetLabel(valMsg);
tc_status->Wrap(Parent()->maxWidth);
return 0;
}
bool
CRQ_IntroPage::TransferDataFromWindow() {
tqslTrace("CRQ_IntroPage::TransferDataFromWindow", NULL);
bool ok;
validate();
if (valMsg.Len() == 0) {
ok = true;
} else {
wxMessageBox(valMsg, _("Error"), wxOK | wxICON_ERROR, this);
ok = false;
}
if (ok && Parent()->dxcc == 0) {
if (Parent()->ncerts == 0) {
wxString msg = _("You cannot select DXCC Entity NONE as you must sign any request for entity NONE and you have no valid Callsign Certificates that you can use to sign this request.");
wxMessageBox(msg, _("TQSL Error"), wxOK | wxICON_ERROR, this);
return false;
}
wxString msg = _("You have selected DXCC Entity NONE");
msg += wxT("\n\n");
msg += _("QSO records signed using the Certificate will not "
"be valid for DXCC award credit (but will be valid "
"for other applicable awards). If the Certificate is "
"to be used for signing QSOs from maritime/marine "
"mobile, shipboard, or air mobile operations, that is "
"the correct selection. Otherwise, you probably "
"should use the \"Back\" button to return to the DXCC "
"page after clicking \"OK\"");
wxMessageBox(msg, _("TQSL Warning"), wxOK | wxICON_WARNING, this);
}
if (ok && !tqsl_isDateNull(&Parent()->qsonotafter) && tqsl_isDateValid(&Parent()->qsonotafter)) {
wxString msg = _("You have chosen a QSO end date for this Callsign Certificate. "
"The 'QSO end date' should ONLY be set if that date is the date when that callsign's license "
"expired or the license was replaced by a new callsign.");
msg += wxT("\n\n");
msg += _("If you set an end date, you will not be able to sign "
"QSOs past that date, even if the Callsign Certificate "
"itself is still valid.");
msg += wxT("\n\n");
msg += _("If you still hold this callsign (or if you plan to renew the license for the "
"callsign), you should not set a 'QSO end date'.");
msg += wxT("\n");
msg += _("Do you really want to keep this 'QSO end date'?");
if (wxMessageBox(msg, _("Warning"), wxYES_NO|wxICON_EXCLAMATION, this) == wxNO) {
tc_qsoendy->SetSelection(0);
tc_qsoendm->SetSelection(0);
tc_qsoendd->SetSelection(0);
return false;
}
}
Parent()->callsign = tc_call->GetValue();
Parent()->callsign.MakeUpper();
tc_call->SetValue(Parent()->callsign);
return ok;
}
static bool
cleanString(wxString &str) {
str.Trim();
str.Trim(FALSE);
int idx;
while ((idx = str.Find(wxT(" "))) > 0) {
str.Remove(idx, 1);
}
return str.IsEmpty();
}
const char *
CRQ_NamePage::validate() {
tqslTrace("CRQ_NamePage::validate", NULL);
if (!initialized)
return 0;
valMsg = wxT("");
Parent()->name = tc_name->GetValue();
Parent()->addr1 = tc_addr1->GetValue();
Parent()->city = tc_city->GetValue();
if (cleanString(Parent()->name))
valMsg = _("You must enter your name");
if (valMsg.Len() == 0 && cleanString(Parent()->addr1))
valMsg = _("You must enter your address");
if (valMsg.Len() == 0 && cleanString(Parent()->city))
valMsg = _("You must enter your city");
tc_status->SetLabel(valMsg);
return 0;
}
bool
CRQ_NamePage::TransferDataFromWindow() {
tqslTrace("CRQ_NamePage::TransferDataFromWindow", NULL);
Parent()->name = tc_name->GetValue();
Parent()->addr1 = tc_addr1->GetValue();
Parent()->addr2 = tc_addr2->GetValue();
Parent()->city = tc_city->GetValue();
Parent()->state = tc_state->GetValue();
Parent()->zip = tc_zip->GetValue();
Parent()->country = tc_country->GetValue();
bool ok;
validate();
if (valMsg.Len() == 0) {
ok = true;
} else {
wxMessageBox(valMsg, _("Error"), wxOK | wxICON_ERROR, this);
ok = false;
}
cleanString(Parent()->name);
cleanString(Parent()->addr1);
cleanString(Parent()->addr2);
cleanString(Parent()->city);
cleanString(Parent()->state);
cleanString(Parent()->zip);
cleanString(Parent()->country);
tc_name->SetValue(Parent()->name);
tc_addr1->SetValue(Parent()->addr1);
tc_addr2->SetValue(Parent()->addr2);
tc_city->SetValue(Parent()->city);
tc_state->SetValue(Parent()->state);
tc_zip->SetValue(Parent()->zip);
tc_country->SetValue(Parent()->country);
wxConfig *config = reinterpret_cast<wxConfig *>(wxConfig::Get());
config->Write(wxT("Name"), Parent()->name);
config->Write(wxT("Addr1"), Parent()->addr1);
config->Write(wxT("Addr2"), Parent()->addr2);
config->Write(wxT("City"), Parent()->city);
config->Write(wxT("State"), Parent()->state);
config->Write(wxT("ZIP"), Parent()->zip);
config->Write(wxT("Country"), Parent()->country);
return ok;
}
const char *
CRQ_EmailPage::validate() {
tqslTrace("CRQ_EmailPage::validate()", NULL);
if (!initialized)
return 0;
valMsg = wxT("");
Parent()->email = tc_email->GetValue();
cleanString(Parent()->email);
int i = Parent()->email.First('@');
int j = Parent()->email.Last('.');
if (i < 1 || j < i+2 || j == static_cast<int>(Parent()->email.length())-1)
valMsg = _("You must enter a valid email address");
tc_status->SetLabel(valMsg);
return 0;
}
bool
CRQ_EmailPage::TransferDataFromWindow() {
tqslTrace("CRQ_EmailPage::TransferDataFromWindow", NULL);
bool ok;
validate();
if (valMsg.Len() == 0) {
ok = true;
} else {
wxMessageBox(valMsg, _("Error"), wxOK | wxICON_ERROR, this);
ok = false;
}
Parent()->email = tc_email->GetValue();
cleanString(Parent()->email);
wxConfig *config = reinterpret_cast<wxConfig *>(wxConfig::Get());
config->Write(wxT("Email"), Parent()->email);
return ok;
}
const char *
CRQ_PasswordPage::validate() {
tqslTrace("CRQ_PasswordPage::validate", NULL);
if (!initialized)
return 0;
valMsg = wxT("");
wxString pw1 = tc_pw1->GetValue();
wxString pw2 = tc_pw2->GetValue();
if (pw1 != pw2)
valMsg = _("The two copies of the password do not match.");
tc_status->SetLabel(valMsg);
return 0;
}
bool
CRQ_PasswordPage::TransferDataFromWindow() {
tqslTrace("CRQ_PasswordPage::TransferDataFromWindow", NULL);
bool ok;
validate();
if (valMsg.Len() == 0) {
ok = true;
} else {
wxMessageBox(valMsg, _("Error"), wxOK | wxICON_ERROR, this);
ok = false;
}
Parent()->password = tc_pw1->GetValue();
return ok;
}
void
CRQ_SignPage::OnPageChanging(wxWizardEvent& ev) {
tqslTrace("CRQ_SignPage::OnPageChanging", "Direction=", ev.GetDirection());
validate();
if (valMsg.Len() > 0 && ev.GetDirection()) {
ev.Veto();
wxMessageBox(valMsg, _("TQSL Error"), wxOK | wxICON_ERROR, this);
}
}
const char *
CRQ_SignPage::validate() {
tqslTrace("CRQ_SignPage::validate", NULL);
bool error = false;
if (!initialized)
return 0;
valMsg = wxT("");
wxString nextprompt = _("Click 'Finish' to complete this Callsign Certificate request.");
cert_tree->Enable(Parent()->signIt);
if (Parent()->signIt) {
if (!cert_tree->GetSelection().IsOk() || cert_tree->GetItemData(cert_tree->GetSelection()) == NULL) {
error = true;
valMsg = Parent()->signPrompt;
} else {
char callsign[512];
tQSL_Cert cert = cert_tree->GetItemData(cert_tree->GetSelection())->getCert();
if (0 == tqsl_getCertificateCallSign(cert, callsign, sizeof callsign)) {
wxString fmt = wxT("\n\n");
fmt += _("You are saying that the requested Certificate for %s "
"belongs to the same person as %hs and are using "
"the selected Certificate to prove %hs's identity.");
nextprompt+=wxString::Format(fmt, Parent()->callsign.c_str(), callsign, callsign);
}
}
}
tc_status->SetLabel(error ? valMsg : nextprompt);
tc_status->Wrap(Parent()->maxWidth);
return 0;
}
bool
CRQ_SignPage::TransferDataFromWindow() {
tqslTrace("CRQ_SignPage::TransferDataFromWindow", NULL);
validate();
Parent()->cert = 0;
CertTreeItemData *data = reinterpret_cast<CertTreeItemData *>(cert_tree->GetItemData(cert_tree->GetSelection()));
if (data)
Parent()->cert = data->getCert();
return true;
}
|