//--------------------------------------------------------------------- #include #pragma hdrstop #include //--------------------------------------------------------------------- #include #include #include #include #include #include "WinInterface.h" #include "About.h" #include "TextsCore.h" #include "TextsWin.h" #ifndef NO_COMPONENTS // must be included before WebBrowserEx.hpp to avoid ambiguity of tagLOGFONTW #include #include #endif #include #include #include #ifndef NO_FILEZILLA #include #endif //--------------------------------------------------------------------- #pragma link "SHDocVw_OCX" #ifndef NO_RESOURCES #pragma resource "*.dfm" #endif //--------------------------------------------------------------------------- static void __fastcall DoAboutDialog(TConfiguration * Configuration, bool AllowLicense, TRegistration * Registration, bool LoadThirdParty) { TAboutDialog * AboutDialog = NULL; try { AboutDialog = new TAboutDialog(Application, Configuration, AllowLicense, Registration, LoadThirdParty); AboutDialog->ShowModal(); } __finally { delete AboutDialog; } } //--------------------------------------------------------------------------- void __fastcall DoAboutDialog(TConfiguration * Configuration, bool AllowLicense, TRegistration * Registration) { try { DoAboutDialog(Configuration, AllowLicense, Registration, true); } catch (EOleException & E) { // This happens particularly on Wine that's does not support some // functionality of embedded IE we need. DoAboutDialog(Configuration, AllowLicense, Registration, false); } } //--------------------------------------------------------------------------- __fastcall TAboutDialog::TAboutDialog(TComponent * AOwner, TConfiguration * Configuration, bool AllowLicense, TRegistration * Registration, bool ALoadThirdParty) : TForm(AOwner) { FConfiguration = Configuration; UseSystemSettings(this); LinkLabel(HomepageLabel, LoadStr(HOMEPAGE_URL)); LinkLabel(ForumUrlLabel, LoadStr(FORUM_URL)); ApplicationLabel->ParentFont = true; ApplicationLabel->Font->Style = ApplicationLabel->Font->Style << fsBold; ApplicationLabel->Caption = AppName; WinSCPCopyrightLabel->Caption = LoadStr(WINSCP_COPYRIGHT); UnicodeString Translator = LoadStr(TRANSLATOR_INFO); if (Registration == NULL) { RegistrationLabel->Visible = false; RegistrationBox->Visible = false; ClientHeight = ClientHeight - (ThirdPartyPanel->Top - RegistrationBox->Top); } else { RegistrationSubjectLabel->Caption = Registration->Subject; if (Registration->Registered) { UnicodeString Text; Text = FORMAT(LoadStrPart(ABOUT_REGISTRATION_LICENSES, 1), (Registration->Licenses >= 0 ? IntToStr(Registration->Licenses) : UnicodeString(LoadStrPart(ABOUT_REGISTRATION_LICENSES, 2)))); if (!Registration->NeverExpires) { Text = FMTLOAD(ABOUT_REGISTRATION_EXPIRES, (Text, FormatDateTime(L"ddddd", Registration->Expiration))); } RegistrationLicensesLabel->Caption = Text; Text = FMTLOAD(ABOUT_REGISTRATION_PRODUCTID, (Registration->ProductId)); if (Registration->EduLicense) { Text = FMTLOAD(ABOUT_REGISTRATION_EDULICENSE, (Text)); } RegistrationProductIdLabel->Caption = Text; RegistrationProductIdLabel->Font->Style = RegistrationProductIdLabel->Font->Style << fsBold; } else { RegistrationLicensesLabel->Visible = false; FOnRegistrationLink = Registration->OnRegistrationLink; RegistrationProductIdLabel->Caption = LoadStr(ABOUT_REGISTRATION_LINK); LinkLabel(RegistrationProductIdLabel, L""); } } if (Translator.IsEmpty()) { TranslatorLabel->Visible = false; TranslatorUrlLabel->Visible = false; ClientHeight = ClientHeight - (TranslatorLabel->Top - ProductSpecificMessageLabel->Top); } else { TranslatorLabel->Caption = LoadStr(TRANSLATOR_INFO); UnicodeString TranslatorUrl = LoadStr(TRANSLATOR_URL); if (!TranslatorUrl.IsEmpty()) { LinkLabel(TranslatorUrlLabel, TranslatorUrl); } else { TranslatorUrlLabel->Visible = false; } } LicenseButton->Visible = AllowLicense; LoadData(); if (ALoadThirdParty) { LoadThirdParty(); } else { CreateLabelPanel(ThirdPartyPanel, LoadStr(MESSAGE_DISPLAY_ERROR)); } } //--------------------------------------------------------------------------- void __fastcall TAboutDialog::LoadData() { UnicodeString Version = FConfiguration->VersionStr; if (!FConfiguration->ProductName.IsEmpty() && (FConfiguration->Version != FConfiguration->ProductVersion)) { Version = FMTLOAD(ABOUT_BASED_ON_PRODUCT, (Version, FConfiguration->ProductName, FConfiguration->ProductVersion)); } VersionLabel->Caption = Version; } //--------------------------------------------------------------------------- void __fastcall TAboutDialog::LoadThirdParty() { TWebBrowserEx * ThirdPartyWebBrowser = CreateBrowserViewer(ThirdPartyPanel, L""); reinterpret_cast(ThirdPartyWebBrowser)->Color = clBtnFace; ThirdPartyWebBrowser->Navigate(L"about:blank"); while (ThirdPartyWebBrowser->ReadyState < ::READYSTATE_INTERACTIVE) { Application->ProcessMessages(); } std::unique_ptr DefaultFont(new TFont()); UnicodeString ThirdParty; ThirdParty += L"\n" L"\n" L"\n" L"\n" L"\n" L"\n" L"\n"; UnicodeString Br = "
\n"; AddPara(ThirdParty, LoadStr(ABOUT_THIRDPARTY_HEADER)); AddPara(ThirdParty, FMTLOAD(PUTTY_BASED_ON, (LoadStr(PUTTY_VERSION))) + Br + LoadStr(PUTTY_COPYRIGHT) + Br + CreateLink(LoadStr(PUTTY_LICENSE_URL), LoadStr(ABOUT_THIRDPARTY_LICENSE)) + Br + CreateLink(LoadStr(PUTTY_URL))); #ifndef NO_FILEZILLA UnicodeString OpenSSLVersionText = GetOpenSSLVersionText(); CutToChar(OpenSSLVersionText, L' ', true); // "OpenSSL" UnicodeString OpenSSLVersion = CutToChar(OpenSSLVersionText, L' ', true); CutToChar(OpenSSLVersionText, L' ', true); // day CutToChar(OpenSSLVersionText, L' ', true); // month UnicodeString OpenSSLYear = CutToChar(OpenSSLVersionText, L' ', true); AddPara(ThirdParty, FMTLOAD(OPENSSL_BASED_ON, (OpenSSLVersion)) + Br + FMTLOAD(OPENSSL_COPYRIGHT2, (OpenSSLYear)) + Br + CreateLink(LoadStr(OPENSSL_URL))); AddPara(ThirdParty, LoadStr(FILEZILLA_BASED_ON2) + Br + LoadStr(FILEZILLA_COPYRIGHT2) + Br + CreateLink(LoadStr(FILEZILLA_URL))); #endif AddPara(ThirdParty, FMTLOAD(NEON_BASED_ON, (NeonVersion())) + Br + LoadStr(NEON_COPYRIGHT) + Br + CreateLink(LoadStr(NEON_URL))); #define EXPAT_LICENSE_URL L"license:expat" AddPara(ThirdParty, FMTLOAD(EXPAT_BASED_ON, (ExpatVersion())) + Br + CreateLink(EXPAT_LICENSE_URL, LoadStr(ABOUT_THIRDPARTY_LICENSE)) + Br + CreateLink(LoadStr(EXPAT_URL))); AddBrowserLinkHandler(ThirdPartyWebBrowser, EXPAT_LICENSE_URL, ExpatLicenceHandler); #ifndef NO_COMPONENTS AddPara(ThirdParty, FMTLOAD(ABOUT_TOOLBAR2000, (Toolbar2000Version)) + Br + LoadStr(ABOUT_TOOLBAR2000_COPYRIGHT) + Br + CreateLink(LoadStr(ABOUT_TOOLBAR2000_URL))); AddPara(ThirdParty, FMTLOAD(ABOUT_TBX, (TBXVersionString)) + Br + LoadStr(ABOUT_TBX_COPYRIGHT) + Br + CreateLink(LoadStr(ABOUT_TBX_URL))); AddPara(ThirdParty, LoadStr(ABOUT_FILEMANAGER) + Br + LoadStr(ABOUT_FILEMANAGER_COPYRIGHT)); #endif UnicodeString JclVersion = FormatVersion(JclVersionMajor, JclVersionMinor, JclVersionRelease); AddPara(ThirdParty, FMTLOAD(ABOUT_JCL, (JclVersion)) + Br + CreateLink(LoadStr(ABOUT_JCL_URL))); AddPara(ThirdParty, LoadStr(ABOUT_PNG) + Br + LoadStr(ABOUT_PNG_COPYRIGHT) + Br + CreateLink(LoadStr(ABOUT_PNG_URL))); ThirdParty += L"\n" L"\n"; std::unique_ptr ThirdPartyStream(new TMemoryStream()); UTF8String ThirdPartyUTF8 = UTF8String(ThirdParty); ThirdPartyStream->Write(ThirdPartyUTF8.c_str(), ThirdPartyUTF8.Length()); ThirdPartyStream->Seek(0, 0); // For stream-loaded document, when set only after loading from OnDocumentComplete, // browser stops working SetBrowserDesignModeOff(ThirdPartyWebBrowser); TStreamAdapter * ThirdPartyStreamAdapter = new TStreamAdapter(ThirdPartyStream.get(), soReference); IPersistStreamInit * PersistStreamInit = NULL; if (ALWAYS_TRUE(ThirdPartyWebBrowser->Document != NULL) && SUCCEEDED(ThirdPartyWebBrowser->Document->QueryInterface(IID_IPersistStreamInit, (void **)&PersistStreamInit)) && ALWAYS_TRUE(PersistStreamInit != NULL)) { PersistStreamInit->Load(static_cast<_di_IStream>(*ThirdPartyStreamAdapter)); } } //--------------------------------------------------------------------------- void __fastcall TAboutDialog::AddPara(UnicodeString & Text, const UnicodeString & S) { Text += L"

" + S + L"

\n"; } //--------------------------------------------------------------------------- UnicodeString __fastcall TAboutDialog::CreateLink(const UnicodeString & URL, const UnicodeString & Title) { return FORMAT(L"%s", (URL, Title.IsEmpty() ? URL : Title)); } //--------------------------------------------------------------------------- void __fastcall TAboutDialog::LicenseButtonClick(TObject * /*Sender*/) { DoProductLicense(); } //--------------------------------------------------------------------------- void __fastcall TAboutDialog::HelpButtonClick(TObject * /*Sender*/) { FormHelp(this); } //--------------------------------------------------------------------------- void __fastcall TAboutDialog::RegistrationProductIdLabelClick( TObject * /*Sender*/) { if (FOnRegistrationLink != NULL) { FOnRegistrationLink(this); } } //--------------------------------------------------------------------------- void __fastcall TAboutDialog::OKButtonMouseDown(TObject * /*Sender*/, TMouseButton Button, TShiftState Shift, int /*X*/, int /*Y*/) { if ((Button == mbRight) && Shift.Contains(ssAlt)) { try { ACCESS_VIOLATION_TEST; } catch (Exception & E) { throw ExtException(&E, MainInstructions(L"Internal error test.")); } } } //--------------------------------------------------------------------------- void __fastcall TAboutDialog::ExpatLicenceHandler(TObject * /*Sender*/) { DoLicenseDialog(lcExpat); } //---------------------------------------------------------------------------