File indexing completed on 2024-05-12 05:20:00
0001 /* 0002 aboutdata.cpp 0003 0004 This file is part of Kleopatra, the KDE keymanager 0005 SPDX-FileCopyrightText: 2001, 2002, 2004 Klarälvdalens Datakonsult AB 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #include <config-kleopatra.h> 0011 #include <version-kleopatra.h> 0012 0013 #include "aboutdata.h" 0014 0015 #include "kleopatraapplication.h" 0016 0017 #include <Libkleo/GnuPG> 0018 0019 #include <QCoreApplication> 0020 #include <QSettings> 0021 #include <QThread> 0022 0023 #include <KLazyLocalizedString> 0024 #include <KLocalizedString> 0025 0026 #include "kleopatra_debug.h" 0027 0028 /* Path to GnuPGs signing keys relative to the GnuPG installation */ 0029 #ifndef GNUPG_DISTSIGKEY_RELPATH 0030 #define GNUPG_DISTSIGKEY_RELPATH "/../share/gnupg/distsigkey.gpg" 0031 #endif 0032 /* Path to a VERSION file relative to QCoreApplication::applicationDirPath */ 0033 #ifndef VERSION_RELPATH 0034 #define VERSION_RELPATH "/../VERSION" 0035 #endif 0036 0037 static const char kleopatra_version[] = KLEOPATRA_VERSION_STRING; 0038 0039 struct about_data { 0040 const KLazyLocalizedString name; 0041 const KLazyLocalizedString desc; 0042 const char *email; 0043 const char *web; 0044 }; 0045 0046 static const about_data authors[] = { 0047 {kli18n("Andre Heinecke"), kli18n("Current Maintainer"), "aheinecke@gnupg.org", nullptr}, 0048 {kli18n("Marc Mutz"), kli18n("Former Maintainer"), "mutz@kde.org", nullptr}, 0049 {kli18n("Steffen Hansen"), kli18n("Former Maintainer"), "hansen@kde.org", nullptr}, 0050 {kli18n("Matthias Kalle Dalheimer"), kli18n("Original Author"), "kalle@kde.org", nullptr}, 0051 }; 0052 0053 static const about_data credits[] = { 0054 {kli18n("David Faure"), kli18n("Backend configuration framework, KIO integration"), "faure@kde.org", nullptr}, 0055 {kli18n("Michel Boyer de la Giroday"), 0056 kli18n("Key-state dependent colors and fonts in the certificates list"), 0057 "michel@klaralvdalens-datakonsult.se", 0058 nullptr}, 0059 {kli18n("Thomas Moenicke"), kli18n("Artwork"), "tm@php-qt.org", nullptr}, 0060 {kli18n("Frank Osterfeld"), kli18n("Resident gpgme/win wrangler, UI Server commands and dialogs"), "osterfeld@kde.org", nullptr}, 0061 {kli18n("Karl-Heinz Zimmer"), kli18n("DN display ordering support, infrastructure"), "khz@kde.org", nullptr}, 0062 {kli18n("Laurent Montel"), kli18n("Qt5 port, general code maintenance"), "montel@kde.org", nullptr}, 0063 }; 0064 0065 static void updateAboutDataFromSettings(KAboutData *about, const QSettings *settings) 0066 { 0067 if (!about || !settings) { 0068 return; 0069 } 0070 about->setDisplayName(settings->value(QStringLiteral("displayName"), about->displayName()).toString()); 0071 about->setProductName(settings->value(QStringLiteral("productName"), about->productName()).toByteArray()); 0072 about->setComponentName(settings->value(QStringLiteral("componentName"), about->componentName()).toString()); 0073 about->setShortDescription(settings->value(QStringLiteral("shortDescription"), about->shortDescription()).toString()); 0074 about->setHomepage(settings->value(QStringLiteral("homepage"), about->homepage()).toString()); 0075 about->setBugAddress(settings->value(QStringLiteral("bugAddress"), about->bugAddress()).toByteArray()); 0076 about->setVersion(settings->value(QStringLiteral("version"), about->version()).toByteArray()); 0077 about->setOtherText(settings->value(QStringLiteral("otherText"), about->otherText()).toString()); 0078 about->setCopyrightStatement(settings->value(QStringLiteral("copyrightStatement"), about->copyrightStatement()).toString()); 0079 about->setDesktopFileName(settings->value(QStringLiteral("desktopFileName"), about->desktopFileName()).toString()); 0080 } 0081 0082 // Extend the about data with the used GnuPG Version since this can 0083 // make a big difference with regards to the available features. 0084 static void loadBackendVersions() 0085 { 0086 auto thread = QThread::create([]() { 0087 STARTUP_TIMING << "Checking backend versions"; 0088 const auto backendVersions = Kleo::backendVersionInfo(); 0089 STARTUP_TIMING << "backend versions checked"; 0090 if (!backendVersions.empty()) { 0091 QMetaObject::invokeMethod(qApp, [backendVersions]() { 0092 auto about = KAboutData::applicationData(); 0093 about.setOtherText(i18nc("Preceeds a list of applications/libraries used by Kleopatra", "Uses:") // 0094 + QLatin1StringView{"<ul><li>"} // 0095 + backendVersions.join(QLatin1StringView{"</li><li>"}) // 0096 + QLatin1StringView{"</li></ul>"} // 0097 + about.otherText()); 0098 KAboutData::setApplicationData(about); 0099 }); 0100 } 0101 }); 0102 thread->start(); 0103 } 0104 0105 // This code is mostly for Gpg4win and GnuPG VS-Desktop so that they 0106 // can put in their own about data information. 0107 static void loadCustomAboutData(KAboutData *about) 0108 { 0109 const QStringList searchPaths = {Kleo::gnupgInstallPath()}; 0110 const QString versionFile = QCoreApplication::applicationDirPath() + QStringLiteral(VERSION_RELPATH); 0111 const QString distSigKeys = Kleo::gnupgInstallPath() + QStringLiteral(GNUPG_DISTSIGKEY_RELPATH); 0112 STARTUP_TIMING << "Starting version info check"; 0113 bool valid = Kleo::gpgvVerify(versionFile, QString(), distSigKeys, searchPaths); 0114 STARTUP_TIMING << "Version info checked"; 0115 if (valid) { 0116 qCDebug(KLEOPATRA_LOG) << "Found valid VERSION file. Updating about data."; 0117 auto settings = std::make_shared<QSettings>(versionFile, QSettings::IniFormat); 0118 settings->beginGroup(QStringLiteral("Kleopatra")); 0119 updateAboutDataFromSettings(about, settings.get()); 0120 KleopatraApplication::instance()->setDistributionSettings(settings); 0121 } 0122 loadBackendVersions(); 0123 } 0124 0125 AboutData::AboutData() 0126 : KAboutData(QStringLiteral("kleopatra"), 0127 i18n("Kleopatra"), 0128 QLatin1StringView(kleopatra_version), 0129 i18n("Certificate Manager and Unified Crypto GUI"), 0130 KAboutLicense::GPL, 0131 i18n("(c) 2002 Steffen\u00A0Hansen, Matthias\u00A0Kalle\u00A0Dalheimer, Klar\u00E4lvdalens\u00A0Datakonsult\u00A0AB\n" 0132 "(c) 2004, 2007, 2008, 2009 Marc\u00A0Mutz, Klar\u00E4lvdalens\u00A0Datakonsult\u00A0AB") // 0133 + QLatin1Char('\n') // 0134 + i18n("(c) 2016-2018 Intevation GmbH") // 0135 + QLatin1Char('\n') // 0136 + i18n("(c) 2010-%1 The Kleopatra developers, g10 Code GmbH", QStringLiteral("2024"))) 0137 { 0138 using ::authors; 0139 using ::credits; 0140 for (unsigned int i = 0; i < sizeof authors / sizeof *authors; ++i) { 0141 addAuthor(KLocalizedString(authors[i].name).toString(), 0142 KLocalizedString(authors[i].desc).toString(), 0143 QLatin1StringView(authors[i].email), 0144 QLatin1StringView(authors[i].web)); 0145 } 0146 for (unsigned int i = 0; i < sizeof credits / sizeof *credits; ++i) { 0147 addCredit(KLocalizedString(credits[i].name).toString(), 0148 KLocalizedString(credits[i].desc).toString(), 0149 QLatin1StringView(credits[i].email), 0150 QLatin1StringView(credits[i].web)); 0151 } 0152 0153 loadCustomAboutData(this); 0154 }