void CFileExistsDlg::DisplayFile(bool left, wxString name, wxLongLong const& size, CDateTime const& time, wxString const& iconFile) { name = GetPathEllipsis(name, FindWindow(left ? XRCID("ID_FILE1_NAME") : XRCID("ID_FILE2_NAME"))); name.Replace(_T("&"), _T("&&")); wxString sizeStr = _("Size unknown"); if (size != -1) { bool const thousands_separator = COptions::Get()->GetOptionVal(OPTION_SIZE_USETHOUSANDSEP) != 0; sizeStr = CSizeFormat::Format(size, true, CSizeFormat::bytes, thousands_separator, 0); } wxString timeStr = _("Date/time unknown"); if (time.IsValid()) timeStr = CTimeFormat::Format(time); xrc_call(*this, left ? "ID_FILE1_NAME" : "ID_FILE2_NAME", &wxStaticText::SetLabel, name); xrc_call(*this, left ? "ID_FILE1_SIZE" : "ID_FILE2_SIZE", &wxStaticText::SetLabel, sizeStr); xrc_call(*this, left ? "ID_FILE1_TIME" : "ID_FILE2_TIME", &wxStaticText::SetLabel, timeStr); LoadIcon(left ? XRCID("ID_FILE1_ICON") : XRCID("ID_FILE2_ICON"), iconFile); }
void CFileExistsDlg::OnOK(wxCommandEvent& event) { if (xrc_call(*this, "ID_ACTION1", &wxRadioButton::GetValue)) m_action = CFileExistsNotification::overwrite; else if (xrc_call(*this, "ID_ACTION2", &wxRadioButton::GetValue)) m_action = CFileExistsNotification::overwriteNewer; else if (xrc_call(*this, "ID_ACTION3", &wxRadioButton::GetValue)) m_action = CFileExistsNotification::resume; else if (xrc_call(*this, "ID_ACTION4", &wxRadioButton::GetValue)) m_action = CFileExistsNotification::rename; else if (xrc_call(*this, "ID_ACTION5", &wxRadioButton::GetValue)) m_action = CFileExistsNotification::skip; else if (xrc_call(*this, "ID_ACTION6", &wxRadioButton::GetValue)) m_action = CFileExistsNotification::overwriteSizeOrNewer; else if (xrc_call(*this, "ID_ACTION7", &wxRadioButton::GetValue)) m_action = CFileExistsNotification::overwriteSize; else m_action = CFileExistsNotification::overwrite; m_always = xrc_call(*this, "ID_ALWAYS", &wxCheckBox::GetValue); m_directionOnly = xrc_call(*this, "ID_UPDOWNONLY", &wxCheckBox::GetValue); m_queueOnly = xrc_call(*this, "ID_QUEUEONLY", &wxCheckBox::GetValue); EndModal(wxID_OK); }
bool CFileExistsDlg::CreateControls() { if (!Load(GetParent(), _T("ID_FILEEXISTSDLG"))) { return false; } wxString localFile = m_pNotification->localFile; wxString remoteFile = m_pNotification->remotePath.FormatFilename(m_pNotification->remoteFile); DisplayFile(m_pNotification->download, localFile, m_pNotification->localSize, m_pNotification->localTime, m_pNotification->localFile); DisplayFile(!m_pNotification->download, remoteFile, m_pNotification->remoteSize, m_pNotification->remoteTime, m_pNotification->remoteFile); xrc_call(*this, "ID_UPDOWNONLY", &wxCheckBox::SetLabel, m_pNotification->download ? _("A&pply only to downloads") : _("A&pply only to uploads")); return true; }
bool CAboutDialog::Create(wxWindow* parent) { if (!Load(parent, _T("ID_ABOUT"))) { return false; } wxBitmap bmp = CThemeProvider::Get()->CreateBitmap("ART_FILEZILLA", wxString(), CThemeProvider::GetIconSize(iconSizeLarge)); xrc_call(*this, "ID_FILEZILLA_LOGO", &wxStaticBitmap::SetBitmap, bmp); xrc_call(*this, "ID_URL", &wxHyperlinkCtrl::SetLabel, _T("https://filezilla-project.org/")); xrc_call(*this, "ID_COPYRIGHT", &wxStaticText::SetLabel, _T("Copyright (C) 2004-2016 Tim Kosse")); wxString version = CBuildInfo::GetVersion(); if (CBuildInfo::GetBuildType() == _T("nightly")) version += _T("-nightly"); if (!SetChildLabel(XRCID("ID_VERSION"), version)) return false; wxString const host = CBuildInfo::GetHostname(); if (host.empty()) { xrc_call(*this, "ID_HOST", &wxStaticText::Hide); xrc_call(*this, "ID_HOST_DESC", &wxStaticText::Hide); } else { xrc_call(*this, "ID_HOST", &wxStaticText::SetLabel, host); } wxString const build = CBuildInfo::GetBuildSystem(); if (build.empty()) { xrc_call(*this, "ID_BUILD", &wxStaticText::Hide); xrc_call(*this, "ID_BUILD_DESC", &wxStaticText::Hide); } else { xrc_call(*this, "ID_BUILD", &wxStaticText::SetLabel, build); } if (!SetChildLabel(XRCID("ID_BUILDDATE"), CBuildInfo::GetBuildDateString())) return false; if (!SetChildLabel(XRCID("ID_COMPILEDWITH"), CBuildInfo::GetCompiler(), 200)) return false; wxString compilerFlags = CBuildInfo::GetCompilerFlags(); if (compilerFlags.empty()) { xrc_call(*this, "ID_CFLAGS", &wxStaticText::Hide); xrc_call(*this, "ID_CFLAGS_DESC", &wxStaticText::Hide); } else { WrapText(this, compilerFlags, 250); xrc_call(*this, "ID_CFLAGS", &wxStaticText::SetLabel, compilerFlags); } xrc_call(*this, "ID_VER_WX", &wxStaticText::SetLabel, GetDependencyVersion(lib_dependency::wxwidgets)); xrc_call(*this, "ID_VER_GNUTLS", &wxStaticText::SetLabel, GetDependencyVersion(lib_dependency::gnutls)); xrc_call(*this, "ID_VER_SQLITE", &wxStaticText::SetLabel, GetDependencyVersion(lib_dependency::sqlite)); wxString const os = wxGetOsDescription(); if (os.empty()) { xrc_call(*this, "ID_SYSTEM_NAME", &wxStaticText::Hide); xrc_call(*this, "ID_SYSTEM_NAME_DESC", &wxStaticText::Hide); } else { xrc_call(*this, "ID_SYSTEM_NAME", &wxStaticText::SetLabel, os); } int major, minor; if (GetRealOsVersion(major, minor)) { wxString osVersion = wxString::Format(_T("%d.%d"), major, minor); int fakeMajor, fakeMinor; if (wxGetOsVersion(&fakeMajor, &fakeMinor) != wxOS_UNKNOWN && (fakeMajor != major || fakeMinor != minor)) { osVersion += _T(" "); osVersion += wxString::Format(_("(app-compat is set to %d.%d)"), fakeMajor, fakeMinor); } xrc_call(*this, "ID_SYSTEM_VER", &wxStaticText::SetLabel, osVersion); } else { xrc_call(*this, "ID_SYSTEM_VER", &wxStaticText::Hide); xrc_call(*this, "ID_SYSTEM_VER_DESC", &wxStaticText::Hide); } #ifdef __WXMSW__ if (::wxIsPlatform64Bit()) xrc_call(*this, "ID_SYSTEM_PLATFORM", &wxStaticText::SetLabel, _("64-bit system")); else xrc_call(*this, "ID_SYSTEM_PLATFORM", &wxStaticText::SetLabel, _("32-bit system")); #else xrc_call(*this, "ID_SYSTEM_PLATFORM", &wxStaticText::Hide); xrc_call(*this, "ID_SYSTEM_PLATFORM_DESC", &wxStaticText::Hide); #endif wxString cpuCaps = CBuildInfo::GetCPUCaps(' '); if (!cpuCaps.empty()) { WrapText(this, cpuCaps, 250); xrc_call(*this, "ID_SYSTEM_CPU", &wxStaticText::SetLabel, cpuCaps); } else { xrc_call(*this, "ID_SYSTEM_CPU_DESC", &wxStaticText::Hide); xrc_call(*this, "ID_SYSTEM_CPU", &wxStaticText::Hide); } xrc_call(*this, "ID_SYSTEM_SETTINGS_DIR", &wxStaticText::SetLabel, COptions::Get()->GetOption(OPTION_DEFAULT_SETTINGSDIR)); GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); return true; }
bool CVerifyCertDialog::DisplayCert(wxDialogEx* pDlg, const CCertificate& cert) { bool warning = false; if (cert.GetActivationTime().empty()) { if (cert.GetActivationTime() > fz::datetime::now()) { pDlg->SetChildLabel(XRCID("ID_ACTIVATION_TIME"), wxString::Format(_("%s - Not yet valid!"), CTimeFormat::Format(cert.GetActivationTime()))); xrc_call(*pDlg, "ID_ACTIVATION_TIME", &wxWindow::SetForegroundColour, wxColour(255, 0, 0)); warning = true; } else pDlg->SetChildLabel(XRCID("ID_ACTIVATION_TIME"), CTimeFormat::Format(cert.GetActivationTime())); } else { warning = true; pDlg->SetChildLabel(XRCID("ID_ACTIVATION_TIME"), _("Invalid date")); } if (cert.GetExpirationTime().empty()) { if (cert.GetExpirationTime() < fz::datetime::now()) { pDlg->SetChildLabel(XRCID("ID_EXPIRATION_TIME"), wxString::Format(_("%s - Certificate expired!"), CTimeFormat::Format(cert.GetExpirationTime()))); xrc_call(*pDlg, "ID_EXPIRATION_TIME", &wxWindow::SetForegroundColour, wxColour(255, 0, 0)); warning = true; } else pDlg->SetChildLabel(XRCID("ID_EXPIRATION_TIME"), CTimeFormat::Format(cert.GetExpirationTime())); } else { warning = true; pDlg->SetChildLabel(XRCID("ID_EXPIRATION_TIME"), _("Invalid date")); } if (!cert.GetSerial().empty()) pDlg->SetChildLabel(XRCID("ID_SERIAL"), cert.GetSerial()); else pDlg->SetChildLabel(XRCID("ID_SERIAL"), _("None")); pDlg->SetChildLabel(XRCID("ID_PKALGO"), wxString::Format(_("%s with %d bits"), cert.GetPkAlgoName(), cert.GetPkAlgoBits())); pDlg->SetChildLabel(XRCID("ID_SIGNALGO"), cert.GetSignatureAlgorithm()); wxString const& sha256 = cert.GetFingerPrintSHA256(); pDlg->SetChildLabel(XRCID("ID_FINGERPRINT_SHA256"), sha256.Left(sha256.size() / 2 + 1) + _T("\n") + sha256.Mid(sha256.size() / 2 + 1)); pDlg->SetChildLabel(XRCID("ID_FINGERPRINT_SHA1"), cert.GetFingerPrintSHA1()); ParseDN(XRCCTRL(*pDlg, "ID_ISSUER_BOX", wxStaticBox), cert.GetIssuer(), m_pIssuerSizer); auto subjectPanel = XRCCTRL(*pDlg, "ID_SUBJECT_PANEL", wxScrolledWindow); subjectPanel->Freeze(); ParseDN(subjectPanel, cert.GetSubject(), m_pSubjectSizer); auto const& altNames = cert.GetAltSubjectNames(); if (!altNames.empty()) { wxString str; for (auto const& altName : altNames) { str += altName + _T("\n"); } str.RemoveLast(); m_pSubjectSizer->Add(new wxStaticText(subjectPanel, wxID_ANY, wxPLURAL("Alternative name:", "Alternative names:", altNames.size()))); m_pSubjectSizer->Add(new wxStaticText(subjectPanel, wxID_ANY, str)); } m_pSubjectSizer->Fit(subjectPanel); wxSize min = m_pSubjectSizer->CalcMin(); int const maxHeight = (line_height_ + m_pDlg->ConvertDialogToPixels(wxPoint(0, 1)).y) * 15; if (min.y >= maxHeight) { min.y = maxHeight; min.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); } // Add extra safety margin to prevent squishing on OS X. min.x += 2; subjectPanel->SetMinSize(min); subjectPanel->Thaw(); return warning; }
void CVerifyCertDialog::ShowVerificationDialog(CCertificateNotification& notification, bool displayOnly /*=false*/) { LoadTrustedCerts(); m_pDlg = new wxDialogEx; if (!m_pDlg->Load(0, _T("ID_VERIFYCERT"))) { wxBell(); delete m_pDlg; m_pDlg = 0; return; } if (displayOnly) { xrc_call(*m_pDlg, "ID_DESC", &wxWindow::Hide); xrc_call(*m_pDlg, "ID_ALWAYS_DESC", &wxWindow::Hide); xrc_call(*m_pDlg, "ID_ALWAYS", &wxWindow::Hide); xrc_call(*m_pDlg, "wxID_CANCEL", &wxWindow::Hide); m_pDlg->SetTitle(_T("Certificate details")); } else { m_pDlg->WrapText(m_pDlg, XRCID("ID_DESC"), 400); if (COptions::Get()->GetOptionVal(OPTION_DEFAULT_KIOSKMODE) == 2) XRCCTRL(*m_pDlg, "ID_ALWAYS", wxCheckBox)->Hide(); } m_certificates = notification.GetCertificates(); if (m_certificates.size() == 1) { XRCCTRL(*m_pDlg, "ID_CHAIN_DESC", wxStaticText)->Hide(); XRCCTRL(*m_pDlg, "ID_CHAIN", wxChoice)->Hide(); } else { wxChoice* pChoice = XRCCTRL(*m_pDlg, "ID_CHAIN", wxChoice); for (unsigned int i = 0; i < m_certificates.size(); ++i) { pChoice->Append(wxString::Format(_T("%d"), i)); } pChoice->SetSelection(0); pChoice->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(CVerifyCertDialog::OnCertificateChoice), 0, this); } m_pDlg->SetChildLabel(XRCID("ID_HOST"), wxString::Format(_T("%s:%d"), notification.GetHost(), notification.GetPort())); line_height_ = XRCCTRL(*m_pDlg, "ID_SUBJECT_DUMMY", wxStaticText)->GetSize().y; m_pSubjectSizer = XRCCTRL(*m_pDlg, "ID_SUBJECT_DUMMY", wxStaticText)->GetContainingSizer(); m_pSubjectSizer->Clear(true); m_pIssuerSizer = XRCCTRL(*m_pDlg, "ID_ISSUER_DUMMY", wxStaticText)->GetContainingSizer(); m_pIssuerSizer->Clear(true); wxSize minSize(0, 0); for (unsigned int i = 0; i < m_certificates.size(); ++i) { DisplayCert(m_pDlg, m_certificates[i]); m_pDlg->Layout(); m_pDlg->GetSizer()->Fit(m_pDlg); minSize.IncTo(m_pDlg->GetSizer()->GetMinSize()); } m_pDlg->GetSizer()->SetMinSize(minSize); bool warning = DisplayCert(m_pDlg, m_certificates[0]); DisplayAlgorithm(XRCID("ID_PROTOCOL"), notification.GetProtocol(), (notification.GetAlgorithmWarnings() & CCertificateNotification::tlsver) != 0); DisplayAlgorithm(XRCID("ID_KEYEXCHANGE"), notification.GetKeyExchange(), (notification.GetAlgorithmWarnings() & CCertificateNotification::kex) != 0); DisplayAlgorithm(XRCID("ID_CIPHER"), notification.GetSessionCipher(), (notification.GetAlgorithmWarnings() & CCertificateNotification::cipher) != 0); DisplayAlgorithm(XRCID("ID_MAC"), notification.GetSessionMac(), (notification.GetAlgorithmWarnings() & CCertificateNotification::mac) != 0); if (notification.GetAlgorithmWarnings() != 0) { warning = true; } if (warning) { XRCCTRL(*m_pDlg, "ID_IMAGE", wxStaticBitmap)->SetBitmap(wxArtProvider::GetBitmap(wxART_WARNING)); XRCCTRL(*m_pDlg, "ID_ALWAYS", wxCheckBox)->Enable(false); } m_pDlg->GetSizer()->Fit(m_pDlg); m_pDlg->GetSizer()->SetSizeHints(m_pDlg); int res = m_pDlg->ShowModal(); if (!displayOnly) { if (res == wxID_OK) { wxASSERT(!IsTrusted(notification)); notification.m_trusted = true; if (!notification.GetAlgorithmWarnings()) { if (!warning && XRCCTRL(*m_pDlg, "ID_ALWAYS", wxCheckBox)->GetValue()) SetPermanentlyTrusted(notification); else { t_certData cert; cert.host = notification.GetHost(); cert.port = notification.GetPort(); const unsigned char* data = m_certificates[0].GetRawData(cert.len); cert.data = new unsigned char[cert.len]; memcpy(cert.data, data, cert.len); m_sessionTrustedCerts.push_back(cert); } } } else notification.m_trusted = false; } delete m_pDlg; m_pDlg = 0; }
bool CWelcomeDialog::Run(wxWindow* parent, bool force /*=false*/, bool delay /*=false*/) { const wxString ownVersion = CBuildInfo::GetVersion(); wxString greetingVersion = COptions::Get()->GetOption(OPTION_GREETINGVERSION); wxString const resources = COptions::Get()->GetOption(OPTION_GREETINGRESOURCES); COptions::Get()->SetOption(OPTION_GREETINGRESOURCES, _T("")); if (!force) { if (COptions::Get()->GetOptionVal(OPTION_DEFAULT_KIOSKMODE) == 2) { if (delay) delete this; return true; } if (!greetingVersion.empty() && CBuildInfo::ConvertToVersionNumber(ownVersion.c_str()) <= CBuildInfo::ConvertToVersionNumber(greetingVersion.c_str())) { // Been there done that if (delay) delete this; return true; } COptions::Get()->SetOption(OPTION_GREETINGVERSION, ownVersion.ToStdWstring()); if (greetingVersion.empty() && !COptions::Get()->GetOptionVal(OPTION_DEFAULT_KIOSKMODE)) COptions::Get()->SetOption(OPTION_PROMPTPASSWORDSAVE, 1); } if (!Load(parent, _T("ID_WELCOME"))) { if (delay) { delete this; } return false; } InitFooter(force ? wxString() : resources); xrc_call(*this, "ID_FZVERSION", &wxStaticText::SetLabel, _T("FileZilla ") + CBuildInfo::GetVersion()); wxString const url = _T("https://welcome.filezilla-project.org/welcome?type=client&category=%s&version=") + ownVersion; if (!greetingVersion.empty()) { xrc_call(*this, "ID_LINK_NEWS", &wxHyperlinkCtrl::SetURL, wxString::Format(url, _T("news")) + _T("&oldversion=") + greetingVersion); xrc_call(*this, "ID_LINK_NEWS", &wxHyperlinkCtrl::SetLabel, wxString::Format(_("New features and improvements in %s"), CBuildInfo::GetVersion())); } else { xrc_call(*this, "ID_LINK_NEWS", &wxHyperlinkCtrl::Hide); xrc_call(*this, "ID_HEADING_NEWS", &wxStaticText::Hide); } xrc_call(*this, "ID_DOCUMENTATION_BASIC", &wxHyperlinkCtrl::SetURL, wxString::Format(url, _T("documentation_basic"))); xrc_call(*this, "ID_DOCUMENTATION_NETWORK", &wxHyperlinkCtrl::SetURL, wxString::Format(url, _T("documentation_network"))); xrc_call(*this, "ID_DOCUMENTATION_MORE", &wxHyperlinkCtrl::SetURL, wxString::Format(url, _T("documentation_more"))); xrc_call(*this, "ID_SUPPORT_FORUM", &wxHyperlinkCtrl::SetURL, wxString::Format(url, _T("support_forum"))); xrc_call(*this, "ID_SUPPORT_MORE", &wxHyperlinkCtrl::SetURL, wxString::Format(url, _T("support_more"))); #ifdef FZ_WINDOWS // Add phone support link in official Windows builds builds... if (CBuildInfo::GetBuildType() == _T("official")) { auto lang = wxGetLocale() ? wxGetLocale()->GetName() : wxString(); // but only in English... if (lang.StartsWith(_T("en"))) { auto const now = fz::datetime::now(); // while the build is fresh... if ((now - CBuildInfo::GetBuildDate()).get_days() < 60) { // and only for US and Canada, so limit by timezone auto ref = fz::datetime(now.format("%Y%m%d%H%M%S", fz::datetime::utc), fz::datetime::utc); auto offset = fz::datetime(ref.format("%Y%m%d%H%M%S", fz::datetime::utc), fz::datetime::local); auto diff = (ref - offset).get_hours(); if (diff >= -9 && diff <= -3) { auto sizer = xrc_call(*this, "ID_SUPPORT_MORE", &wxWindow::GetContainingSizer); if (sizer) { auto link = new wxHyperlinkCtrl(sizer->GetContainingWindow(), wxID_ANY, _T("Phone support"), _T("https://filezilla-project.org/phone_support.php")); sizer->Insert(0, link); } } } } } #endif Layout(); GetSizer()->Fit(this); if (delay) { m_delayedShowTimer.SetOwner(this); m_delayedShowTimer.Start(10, true); } else ShowModal(); return true; }