diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ae5a403d9..d2b6780d1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,330 +1,328 @@ add_subdirectory(icons) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) if (NOT DISABLE_KWATCHGNUPG) add_subdirectory(kwatchgnupg) endif() add_subdirectory(libkleopatraclient) add_subdirectory(conf) add_subdirectory(kconf_update) if(WIN32) set(_kleopatra_extra_uiserver_SRCS uiserver/uiserver_win.cpp) set(_kleopatra_extra_SRCS utils/gnupg-registry.c selftest/registrycheck.cpp) else() set(_kleopatra_extra_uiserver_SRCS uiserver/uiserver_unix.cpp) set(_kleopatra_extra_SRCS) endif() set(_kleopatra_uiserver_SRCS uiserver/sessiondata.cpp uiserver/uiserver.cpp ${_kleopatra_extra_uiserver_SRCS} uiserver/assuanserverconnection.cpp uiserver/echocommand.cpp uiserver/decryptverifycommandemailbase.cpp uiserver/decryptverifycommandfilesbase.cpp uiserver/signcommand.cpp uiserver/signencryptfilescommand.cpp uiserver/prepencryptcommand.cpp uiserver/prepsigncommand.cpp uiserver/encryptcommand.cpp uiserver/selectcertificatecommand.cpp uiserver/importfilescommand.cpp uiserver/createchecksumscommand.cpp uiserver/verifychecksumscommand.cpp selftest/uiservercheck.cpp ) if(ASSUAN2_FOUND) include_directories(${ASSUAN2_INCLUDES}) set(_kleopatra_uiserver_extra_libs ${ASSUAN2_LIBRARIES}) else() include_directories(${ASSUAN_INCLUDES}) if(WIN32) set(_kleopatra_uiserver_extra_libs ${ASSUAN_VANILLA_LIBRARIES}) else() set(_kleopatra_uiserver_extra_libs ${ASSUAN_PTHREAD_LIBRARIES}) endif() endif() if(HAVE_GPG_ERR_SOURCE_KLEO) add_definitions(-DGPG_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_KLEO) else() add_definitions(-DGPG_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_USER_1) endif() ki18n_wrap_ui(_kleopatra_uiserver_SRCS crypto/gui/signingcertificateselectionwidget.ui) set(_kleopatra_SRCS utils/gnupg-helper.cpp utils/gui-helper.cpp utils/filedialog.cpp utils/kdpipeiodevice.cpp utils/headerview.cpp utils/scrollarea.cpp utils/dragqueen.cpp utils/multivalidator.cpp utils/systemtrayicon.cpp utils/hex.cpp utils/path-helper.cpp utils/input.cpp utils/output.cpp utils/validation.cpp utils/wsastarter.cpp utils/iodevicelogger.cpp utils/log.cpp utils/action_data.cpp utils/types.cpp utils/archivedefinition.cpp utils/auditlog.cpp utils/clipboardmenu.cpp utils/kuniqueservice.cpp selftest/selftest.cpp selftest/enginecheck.cpp selftest/gpgconfcheck.cpp selftest/gpgagentcheck.cpp selftest/libkleopatrarccheck.cpp ${_kleopatra_extra_SRCS} view/keylistcontroller.cpp view/keytreeview.cpp view/searchbar.cpp view/smartcardwidget.cpp view/padwidget.cpp view/pgpcardwidget.cpp view/netkeywidget.cpp view/nullpinwidget.cpp view/tabwidget.cpp view/keycacheoverlay.cpp view/waitwidget.cpp view/welcomewidget.cpp dialogs/certificateselectiondialog.cpp dialogs/expirydialog.cpp dialogs/lookupcertificatesdialog.cpp dialogs/ownertrustdialog.cpp dialogs/selftestdialog.cpp dialogs/certifycertificatedialog.cpp - dialogs/exportsecretkeydialog.cpp dialogs/adduseriddialog.cpp dialogs/exportcertificatesdialog.cpp dialogs/deletecertificatesdialog.cpp dialogs/setinitialpindialog.cpp dialogs/certificatedetailswidget.cpp dialogs/trustchainwidget.cpp dialogs/weboftrustwidget.cpp dialogs/weboftrustdialog.cpp dialogs/exportdialog.cpp dialogs/subkeyswidget.cpp dialogs/gencardkeydialog.cpp dialogs/updatenotification.cpp crypto/controller.cpp crypto/certificateresolver.cpp crypto/sender.cpp crypto/recipient.cpp crypto/task.cpp crypto/taskcollection.cpp crypto/decryptverifytask.cpp crypto/decryptverifyemailcontroller.cpp crypto/decryptverifyfilescontroller.cpp crypto/autodecryptverifyfilescontroller.cpp crypto/encryptemailtask.cpp crypto/encryptemailcontroller.cpp crypto/newsignencryptemailcontroller.cpp crypto/signencrypttask.cpp crypto/signencryptfilescontroller.cpp crypto/signemailtask.cpp crypto/signemailcontroller.cpp crypto/createchecksumscontroller.cpp crypto/verifychecksumscontroller.cpp crypto/gui/wizard.cpp crypto/gui/wizardpage.cpp crypto/gui/certificateselectionline.cpp crypto/gui/certificatelineedit.cpp crypto/gui/signingcertificateselectionwidget.cpp crypto/gui/signingcertificateselectiondialog.cpp crypto/gui/resultitemwidget.cpp crypto/gui/resultlistwidget.cpp crypto/gui/resultpage.cpp crypto/gui/newresultpage.cpp crypto/gui/signencryptfileswizard.cpp crypto/gui/signencryptemailconflictdialog.cpp crypto/gui/decryptverifyoperationwidget.cpp crypto/gui/decryptverifyfileswizard.cpp crypto/gui/decryptverifyfilesdialog.cpp crypto/gui/objectspage.cpp crypto/gui/resolverecipientspage.cpp crypto/gui/signerresolvepage.cpp crypto/gui/encryptemailwizard.cpp crypto/gui/signemailwizard.cpp crypto/gui/signencryptwidget.cpp crypto/gui/signencryptwizard.cpp crypto/gui/unknownrecipientwidget.cpp crypto/gui/verifychecksumsdialog.cpp commands/command.cpp commands/gnupgprocesscommand.cpp commands/detailscommand.cpp commands/exportcertificatecommand.cpp commands/importcertificatescommand.cpp commands/importcertificatefromfilecommand.cpp commands/importcertificatefromclipboardcommand.cpp commands/importcertificatefromdatacommand.cpp commands/lookupcertificatescommand.cpp commands/reloadkeyscommand.cpp commands/refreshx509certscommand.cpp commands/refreshopenpgpcertscommand.cpp commands/deletecertificatescommand.cpp commands/decryptverifyfilescommand.cpp commands/signencryptfilescommand.cpp commands/signencryptfoldercommand.cpp commands/encryptclipboardcommand.cpp commands/signclipboardcommand.cpp commands/decryptverifyclipboardcommand.cpp commands/clearcrlcachecommand.cpp commands/dumpcrlcachecommand.cpp commands/dumpcertificatecommand.cpp commands/importcrlcommand.cpp commands/changeexpirycommand.cpp commands/changeownertrustcommand.cpp commands/changeroottrustcommand.cpp commands/changepassphrasecommand.cpp commands/certifycertificatecommand.cpp commands/selftestcommand.cpp commands/exportsecretkeycommand.cpp commands/exportopenpgpcertstoservercommand.cpp commands/adduseridcommand.cpp commands/newcertificatecommand.cpp commands/setinitialpincommand.cpp commands/learncardkeyscommand.cpp commands/checksumcreatefilescommand.cpp commands/checksumverifyfilescommand.cpp commands/exportpaperkeycommand.cpp commands/importpaperkeycommand.cpp commands/genrevokecommand.cpp commands/keytocardcommand.cpp ${_kleopatra_uiserver_files} conf/configuredialog.cpp newcertificatewizard/listwidget.cpp newcertificatewizard/newcertificatewizard.cpp smartcard/readerstatus.cpp smartcard/card.cpp smartcard/openpgpcard.cpp smartcard/netkeycard.cpp aboutdata.cpp systrayicon.cpp kleopatraapplication.cpp mainwindow.cpp main.cpp ) if(WIN32) configure_file (versioninfo.rc.in versioninfo.rc) set(_kleopatra_SRCS ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc ${_kleopatra_SRCS}) endif() if(HAVE_KCMUTILS) set (_kleopatra_extra_libs KF5::KCMUtils) else() set (_kleopatra_SRCS conf/kleopageconfigdialog.cpp ${_kleopatra_SRCS}) endif() ecm_qt_declare_logging_category(_kleopatra_SRCS HEADER kleopatra_debug.h IDENTIFIER KLEOPATRA_LOG CATEGORY_NAME org.kde.pim.kleopatra) if(KLEO_MODEL_TEST) add_definitions(-DKLEO_MODEL_TEST) set(_kleopatra_SRCS ${_kleopatra_SRCS} models/modeltest.cpp) endif() ki18n_wrap_ui(_kleopatra_SRCS dialogs/certificationoptionswidget.ui dialogs/expirydialog.ui dialogs/lookupcertificatesdialog.ui dialogs/ownertrustdialog.ui dialogs/selectchecklevelwidget.ui dialogs/selftestdialog.ui - dialogs/exportsecretkeydialog.ui dialogs/adduseriddialog.ui dialogs/setinitialpindialog.ui dialogs/certificatedetailswidget.ui dialogs/trustchainwidget.ui dialogs/subkeyswidget.ui newcertificatewizard/listwidget.ui newcertificatewizard/chooseprotocolpage.ui newcertificatewizard/enterdetailspage.ui newcertificatewizard/overviewpage.ui newcertificatewizard/keycreationpage.ui newcertificatewizard/resultpage.ui newcertificatewizard/advancedsettingsdialog.ui ) kconfig_add_kcfg_files(_kleopatra_SRCS kcfg/tooltippreferences.kcfgc kcfg/emailoperationspreferences.kcfgc kcfg/fileoperationspreferences.kcfgc kcfg/smimevalidationpreferences.kcfgc ) file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/icons/*-apps-kleopatra.png") ecm_add_app_icon(_kleopatra_SRCS ICONS ${ICONS_SRCS}) qt5_add_resources(_kleopatra_SRCS kleopatra.qrc) add_executable(kleopatra_bin ${_kleopatra_SRCS} ${_kleopatra_uiserver_SRCS}) set_target_properties(kleopatra_bin PROPERTIES OUTPUT_NAME kleopatra) target_link_libraries(kleopatra_bin Gpgmepp QGpgme ${_kleopatra_extra_libs} KF5::Libkleo KF5::Mime KF5::I18n KF5::XmlGui KF5::IconThemes KF5::WindowSystem KF5::CoreAddons KF5::ItemModels KF5::Crash Qt5::Network Qt5::PrintSupport # Printing secret keys ${_kleopatra_uiserver_extra_libs} ${_kleopatra_dbusaddons_libs} kleopatraclientcore ) install(TARGETS kleopatra_bin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install( PROGRAMS data/org.kde.kleopatra.desktop data/kleopatra_import.desktop DESTINATION ${KDE_INSTALL_APPDIR} ) install(FILES data/org.kde.kleopatra.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) install( FILES data/kleopatra_signencryptfiles.desktop data/kleopatra_signencryptfolders.desktop data/kleopatra_decryptverifyfiles.desktop data/kleopatra_decryptverifyfolders.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) diff --git a/src/commands/exportsecretkeycommand.cpp b/src/commands/exportsecretkeycommand.cpp index cb96aa6f0..702e0de50 100644 --- a/src/commands/exportsecretkeycommand.cpp +++ b/src/commands/exportsecretkeycommand.cpp @@ -1,165 +1,171 @@ /* -*- mode: c++; c-basic-offset:4 -*- commands/exportsecretkeycommand.cpp This file is part of Kleopatra, the KDE keymanager Copyright (c) 2008 Klarälvdalens Datakonsult AB Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include #include "exportsecretkeycommand.h" -#include "command_p.h" +#include "fileoperationspreferences.h" -#include +#include "command_p.h" #include +#include + +#include #include #include using namespace Kleo; using namespace Kleo::Commands; -using namespace Kleo::Dialogs; using namespace GpgME; ExportSecretKeyCommand::ExportSecretKeyCommand(KeyListController *c) : GnuPGProcessCommand(c) { } ExportSecretKeyCommand::ExportSecretKeyCommand(QAbstractItemView *v, KeyListController *c) : GnuPGProcessCommand(v, c) { } ExportSecretKeyCommand::ExportSecretKeyCommand(const Key &key) : GnuPGProcessCommand(key) { } ExportSecretKeyCommand::~ExportSecretKeyCommand() {} void ExportSecretKeyCommand::setFileName(const QString &fileName) { m_filename = fileName; } -void ExportSecretKeyCommand::setPassphraseCharset(const QByteArray &charset) -{ - m_charset = charset; -} - -void ExportSecretKeyCommand::setUseArmor(bool armor) -{ - m_armor = armor; -} - bool ExportSecretKeyCommand::preStartHook(QWidget *parent) const { if (!m_filename.isEmpty()) { return true; } - ExportSecretKeyDialog dlg(parent); - dlg.setKey(d->key()); - if (!dlg.exec()) { - return false; - } + const auto key = d->key(); + + const auto protocol = key.protocol(); + + QString proposedFileName; + const bool usePGPFileExt = FileOperationsPreferences().usePGPFileExt(); + proposedFileName + = QString::fromLatin1(key.primaryFingerprint()) + + QLatin1Char('.') + + QString::fromLatin1(outputFileExtension(protocol == OpenPGP + ? Class::OpenPGP | Class::Ascii | Class::Certificate + : Class::CMS | Class::Binary | Class::ExportedPSM, usePGPFileExt)) + ; + + m_filename = FileDialog::getSaveFileNameEx(parent ? parent : d->parentWidgetOrView(), + i18n("Export Secret Key"), + QStringLiteral("imp"), + proposedFileName, + protocol == GpgME::OpenPGP + ? i18n("Secret Key Files") + QLatin1String(" (*.asc *.gpg *.pgp)") + : i18n("Secret Key Files") + QLatin1String(" (*.p12)")); - m_filename = dlg.fileName(); - m_armor = dlg.useArmor(); - m_charset = dlg.charset(); + m_armor = m_filename.endsWith (QLatin1String (".asc")); - return true; + return !m_filename.isEmpty (); } QStringList ExportSecretKeyCommand::arguments() const { const Key key = d->key(); QStringList result; if (key.protocol() == OpenPGP) { result << gpgPath() << QStringLiteral("--batch"); } else { result << gpgSmPath(); } result << QStringLiteral("--output") << m_filename; if (m_armor) { result << QStringLiteral("--armor"); } - if (key.protocol() == CMS && !m_charset.isEmpty()) { - result << QStringLiteral("--p12-charset") << QLatin1String(m_charset); + if (key.protocol() == CMS) { + result << QStringLiteral("--p12-charset") << QLatin1String("utf-8"); } if (key.protocol() == OpenPGP) { result << QStringLiteral("--export-secret-key"); } else { result << QStringLiteral("--export-secret-key-p12"); } result << QLatin1String(key.primaryFingerprint()); return result; } QString ExportSecretKeyCommand::errorCaption() const { return i18nc("@title:window", "Secret Key Export Error"); } QString ExportSecretKeyCommand::successCaption() const { return i18nc("@title:window", "Secret Key Export Finished"); } QString ExportSecretKeyCommand::crashExitMessage(const QStringList &args) const { return xi18nc("@info", "The GPG or GpgSM process that tried to export the secret key " "ended prematurely because of an unexpected error." "Please check the output of %1 for details.", args.join(QLatin1Char(' '))); } QString ExportSecretKeyCommand::errorExitMessage(const QStringList &args) const { return xi18nc("@info", "An error occurred while trying to export the secret key. " "The output from %1 was: %2", args[0], errorString()); } QString ExportSecretKeyCommand::successMessage(const QStringList &) const { return i18nc("@info", "Secret key successfully exported."); } diff --git a/src/commands/exportsecretkeycommand.h b/src/commands/exportsecretkeycommand.h index 4316909b2..26e73de7a 100644 --- a/src/commands/exportsecretkeycommand.h +++ b/src/commands/exportsecretkeycommand.h @@ -1,99 +1,86 @@ /* -*- mode: c++; c-basic-offset:4 -*- commands/exportsecretkeycommand.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2008 Klarälvdalens Datakonsult AB Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #ifndef __KLEOPATRA_COMMMANDS_EXPORTSECRETKEYCOMMAND_H__ #define __KLEOPATRA_COMMMANDS_EXPORTSECRETKEYCOMMAND_H__ #include #include #include namespace Kleo { namespace Commands { class ExportSecretKeyCommand : public GnuPGProcessCommand { Q_OBJECT public: explicit ExportSecretKeyCommand(QAbstractItemView *view, KeyListController *parent); explicit ExportSecretKeyCommand(KeyListController *parent); explicit ExportSecretKeyCommand(const GpgME::Key &key); ~ExportSecretKeyCommand() override; void setFileName(const QString &fileName); QString fileName() const { return m_filename; } - void setPassphraseCharset(const QByteArray &charset); - QByteArray passphraseCharset() const - { - return m_charset; - } - - void setUseArmor(bool armor); - bool useArmor() const - { - return m_armor; - } - /* reimp */ static Restrictions restrictions() { return OnlyOneKey | NeedSecretKey; } private: bool preStartHook(QWidget *) const override; QStringList arguments() const override; QString errorCaption() const override; QString successCaption() const override; QString crashExitMessage(const QStringList &) const override; QString errorExitMessage(const QStringList &) const override; QString successMessage(const QStringList &) const override; private: mutable QString m_filename; - mutable QByteArray m_charset; mutable bool m_armor; }; } } #endif // __KLEOPATRA_COMMMANDS_EXPORTSECRETKEYCOMMAND_H__ diff --git a/src/dialogs/exportsecretkeydialog.cpp b/src/dialogs/exportsecretkeydialog.cpp deleted file mode 100644 index 9bb8f5d3f..000000000 --- a/src/dialogs/exportsecretkeydialog.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* -*- mode: c++; c-basic-offset:4 -*- - dialogs/exportsecretkeydialog.cpp - - This file is part of Kleopatra, the KDE keymanager - Copyright (c) 2008 Klarälvdalens Datakonsult AB - - Kleopatra is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - Kleopatra is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#include - -#include "exportsecretkeydialog.h" - -#include "ui_exportsecretkeydialog.h" - -#include - -#include - -#include -#include - - -using namespace Kleo; -using namespace Kleo::Dialogs; -using namespace GpgME; - -// This comes from gnupg's sources, agent/minip12.c -// In fact, any charset supported by iconv would work, but we don't link to iconv directly... -static const char *charsets[] = { - "utf8", - "iso-8859-1", - "iso-8859-15", - "iso-8859-2", - "iso-8859-3", - "iso-8859-4", - "iso-8859-5", - "iso-8859-6", - "iso-8859-7", - "iso-8859-8", - "iso-8859-9", - "koi8-r", - "ibm437", - "ibm850", - "euc-jp", - "big5", -}; -static const unsigned int numCharsets = sizeof charsets / sizeof * charsets; - -class ExportSecretKeyDialog::Private -{ - friend class ::Kleo::Dialogs::ExportSecretKeyDialog; - ExportSecretKeyDialog *const q; -public: - explicit Private(ExportSecretKeyDialog *qq) - : q(qq), - ui(q) - { - - } - -private: - void updateWidgets() - { - const bool x509 = key.protocol() == CMS; - ui.charsetCB->setVisible(x509); - ui.charsetLB->setVisible(x509); - } - - void updateFileName() - { - const bool x509 = key.protocol() == CMS; - const bool armor = q->useArmor(); - - static const char *extensions[] = { - ".gpg", ".asc", ".p12", ".pem" - }; - const unsigned int idx = 2 * x509 + armor; - const char *const extension = extensions[idx]; - - const QString nf = i18n("Secret Key Files") + QStringLiteral("(*%1 *%2 *%3 *%4 *.pgp)") - .arg(QLatin1String(extensions[idx]), QLatin1String(extensions[(idx + 1) % 4]), QLatin1String(extensions[(idx + 2) % 4]), QLatin1String(extensions[(idx + 3) % 4])); - ui.outputFileFR->setNameFilter(nf); - - QString fn = q->fileName(); - if (fn.isEmpty()) { - return; - } - - bool found = false; - for (unsigned int i = 0; i < sizeof extensions / sizeof * extensions; ++i) - if (fn.endsWith(QLatin1String(extensions[i]), Qt::CaseInsensitive)) { - fn.chop(4); - found = true; - break; - } - if (found) { - q->setFileName(fn + QLatin1String(extension)); - } - } - - void updateLabel() - { - ui.descriptionLB->setText(i18nc("@info", - "Please select export options for %1:", - Formatting::formatForComboBox(key))); - } -private: - Key key; - - struct UI : public Ui_ExportSecretKeyDialog { - explicit UI(Dialogs::ExportSecretKeyDialog *qq) - : Ui_ExportSecretKeyDialog() - { - setupUi(qq); - - outputFileFR->setExistingOnly(false); - outputFileFR->setFilter(QDir::Files); - outputFileFR->setNameFilter(i18n("Secret Key Files (*.pem *.p12 *.gpg *.asc *.pgp)")); - - for (unsigned int i = 0; i < numCharsets; ++i) { - charsetCB->addItem(QString::fromLatin1(charsets[i])); - } - charsetCB->setCurrentIndex(0); - - } - } ui; -}; - -ExportSecretKeyDialog::ExportSecretKeyDialog(QWidget *p) - : QDialog(p), d(new Private(this)) -{ - -} - -ExportSecretKeyDialog::~ExportSecretKeyDialog() {} - -void ExportSecretKeyDialog::setKey(const Key &key) -{ - if (qstricmp(key.primaryFingerprint(), d->key.primaryFingerprint()) == 0) { - return; - } - d->key = key; - d->updateWidgets(); - d->updateLabel(); - d->updateFileName(); -} - -Key ExportSecretKeyDialog::key() const -{ - return d->key; -} - -void ExportSecretKeyDialog::setFileName(const QString &fileName) -{ - d->ui.outputFileFR->setFileName(fileName); -} - -QString ExportSecretKeyDialog::fileName() const -{ - return d->ui.outputFileFR->fileName(); -} - -void ExportSecretKeyDialog::setCharset(const QByteArray &charset) -{ - for (unsigned int i = 0; i < sizeof charsets / sizeof * charsets; ++i) - if (charset == charsets[i]) { - d->ui.charsetCB->setCurrentIndex(static_cast(i)); - return; - } -} - -QByteArray ExportSecretKeyDialog::charset() const -{ - if (d->ui.charsetCB->isVisible()) { - return d->ui.charsetCB->currentText().toLatin1(); - } else { - return QByteArray(); - } -} - -void ExportSecretKeyDialog::setUseArmor(bool on) -{ - d->ui.armorCB->setChecked(on); -} - -bool ExportSecretKeyDialog::useArmor() const -{ - return d->ui.armorCB->isChecked(); -} - -void ExportSecretKeyDialog::accept() -{ - d->updateFileName(); - const QString fn = fileName(); - if (fn.isEmpty()) { - KMessageBox::information(this, i18nc("@info", - "You have to enter an output filename."), - i18nc("@title", "Incomplete data")); - d->ui.outputFileFR->setFocus(); - return; - } - - const QByteArray cs = charset(); - if (d->key.protocol() == CMS && cs.isEmpty()) { - KMessageBox::information(this, i18nc("@info", - "You have to choose a passphrase character set."), - i18nc("@title", "Incomplete data")); - d->ui.charsetCB->setFocus(); - return; - } - - QDialog::accept(); -} - -#include "moc_exportsecretkeydialog.cpp" diff --git a/src/dialogs/exportsecretkeydialog.h b/src/dialogs/exportsecretkeydialog.h deleted file mode 100644 index a0c0bb660..000000000 --- a/src/dialogs/exportsecretkeydialog.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- mode: c++; c-basic-offset:4 -*- - dialogs/exportsecretkeydialog.h - - This file is part of Kleopatra, the KDE keymanager - Copyright (c) 2008 Klarälvdalens Datakonsult AB - - Kleopatra is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - Kleopatra is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the Qt library by Trolltech AS, Norway (or with modified versions - of Qt that use the same license as Qt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - Qt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. -*/ - -#ifndef __KLEOPATRA_DIALOGS_EXPORTSECRETKEYDIALOG_H__ -#define __KLEOPATRA_DIALOGS_EXPORTSECRETKEYDIALOG_H__ - -#include - -#include - -namespace GpgME -{ -class Key; -} - -namespace Kleo -{ -namespace Dialogs -{ - -class ExportSecretKeyDialog : public QDialog -{ - Q_OBJECT -public: - explicit ExportSecretKeyDialog(QWidget *parent = nullptr); - ~ExportSecretKeyDialog() override; - - void setKey(const GpgME::Key &key); - GpgME::Key key() const; - - void setFileName(const QString &fileName); - QString fileName() const; - - void setCharset(const QByteArray &charset); - QByteArray charset() const; - - void setUseArmor(bool armor); - bool useArmor() const; - -protected Q_SLOTS: - void accept() override; - -private: - class Private; - kdtools::pimpl_ptr d; - Q_PRIVATE_SLOT(d, void updateFileName()) -}; - -} -} - -#endif /* __KLEOPATRA_DIALOGS_EXPORTSECRETKEYDIALOG_H__ */ - diff --git a/src/dialogs/exportsecretkeydialog.ui b/src/dialogs/exportsecretkeydialog.ui deleted file mode 100644 index 57c199e31..000000000 --- a/src/dialogs/exportsecretkeydialog.ui +++ /dev/null @@ -1,169 +0,0 @@ - - ExportSecretKeyDialog - - - - 0 - 0 - 372 - 194 - - - - Export Secret Certificate - - - - - - true - - - - - - - Output file: - - - outputFileFR - - - - - - - Passphrase charset: - - - charsetCB - - - - - - - - 0 - 0 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - ASCII armor - - - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - - - - - - - Kleo::FileNameRequester - QWidget -
libkleo/filenamerequester.h
- 1 - - fileNameChanged(QString) - -
-
- - - - buttonBox - accepted() - ExportSecretKeyDialog - accept() - - - 227 - 165 - - - 157 - 193 - - - - - buttonBox - rejected() - ExportSecretKeyDialog - reject() - - - 295 - 171 - - - 286 - 193 - - - - - armorCB - toggled(bool) - ExportSecretKeyDialog - updateFileName() - - - 77 - 83 - - - 69 - 131 - - - - - outputFileFR - fileNameChanged(QString) - ExportSecretKeyDialog - updateFileName() - - - 267 - 53 - - - 159 - 131 - - - - - - updateFileName() - -