Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F23020442
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
47 KB
Subscribers
None
View Options
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7de6010b2..e51f4143d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,315 +1,316 @@
project(kleopatra)
include(MacroOptionalAddSubdirectory)
set( kleopatra_version 2.0.8 )
set( kleopatra_release FALSE )
if (NOT kleopatra_release)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn")
if ( NOT KdeSubversion_FOUND )
find_package( KdeSubversion )
endif ( NOT KdeSubversion_FOUND )
if ( KdeSubversion_FOUND )
KdeSubversion_WC_INFO( ${PROJECT_SOURCE_DIR} Kleopatra )
string( SUBSTRING "${Kleopatra_WC_LAST_CHANGED_DATE}" 0 10 Kleopatra_WC_LAST_CHANGED_DATE )
set( kleopatra_version "${kleopatra_version}-svn${Kleopatra_WC_REVISION} (${Kleopatra_WC_LAST_CHANGED_DATE})" )
endif ( KdeSubversion_FOUND )
endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn")
endif (NOT kleopatra_release)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-kleopatra.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kleopatra.h )
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/libkleo
${CMAKE_SOURCE_DIR}/libkdepim
${Boost_INCLUDE_DIR}
${QGPGME_INCLUDES}
${GPGME_INCLUDES} )
if (USABLE_ASSUAN_FOUND)
include_directories(${ASSUAN_INCLUDES})
endif(USABLE_ASSUAN_FOUND)
add_definitions ( -DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS -D_ASSUAN_ONLY_GPG_ERRORS )
remove_definitions ( -DQT_NO_STL )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")
add_subdirectory( pics )
add_subdirectory( conf )
if ( USABLE_ASSUAN_FOUND AND BUILD_libkleopatraclient )
# can't use macro_optional_add_subdirectory here, since it's split
# off into ConfigureChecks.cmake..
add_subdirectory( libkleopatraclient )
endif ( USABLE_ASSUAN_FOUND AND BUILD_libkleopatraclient )
add_subdirectory( kgpgconf )
add_subdirectory( kwatchgnupg )
add_subdirectory( tests )
if ( WIN32 )
set( _kleopatra_extra_uiserver_SRCS
uiserver/uiserver_win.cpp
)
set( _kleopatra_extra_SRCS
utils/gnupg-registry.c
selftest/registrycheck.cpp
)
else ( WIN32 )
set( _kleopatra_extra_uiserver_SRCS
uiserver/uiserver_unix.cpp
)
set( _kleopatra_extra_SRCS
)
endif ( WIN32 )
if ( USABLE_ASSUAN_FOUND )
add_definitions ( -DKLEOPATRACLIENT_NAMESPACE=KleopatraClientCopy -DKLEOPATRACLIENTCORE_EXPORT= )
set(_kleopatra_uiserver_SRCS
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/encryptcommand.cpp
uiserver/selectcertificatecommand.cpp
uiserver/importfilescommand.cpp
libkleopatraclient/core/command.cpp
selftest/uiservercheck.cpp
)
if ( WIN32 )
set( _kleopatra_uiserver_extra_libs ${ASSUAN_VANILLA_LIBRARIES} )
else ( WIN32 )
set( _kleopatra_uiserver_extra_libs ${ASSUAN_PTHREAD_LIBRARIES} )
endif( WIN32 )
if ( HAVE_GPG_ERR_SOURCE_KLEO )
add_definitions( -DGPG_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_KLEO )
else( HAVE_GPG_ERR_SOURCE_KLEO )
add_definitions( -DGPG_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_USER_1 )
endif( HAVE_GPG_ERR_SOURCE_KLEO )
else ( USABLE_ASSUAN_FOUND )
set(_kleopatra_uiserver_SRCS)
endif ( USABLE_ASSUAN_FOUND )
kde4_add_ui_files( _kleopatra_uiserver_SRCS
crypto/gui/signingcertificateselectionwidget.ui)
set( _kleopatra_SRCS
utils/gnupg-helper.cpp
utils/filesystemwatcher.cpp
utils/kdpipeiodevice.cpp
utils/kdlogtextwidget.cpp
utils/headerview.cpp
utils/scrollarea.cpp
utils/dragqueen.cpp
utils/multivalidator.cpp
utils/progressmanager.cpp
utils/filedialog.cpp
utils/hex.cpp
utils/input.cpp
utils/output.cpp
utils/exception.cpp
utils/formatting.cpp
utils/validation.cpp
utils/wsastarter.cpp
utils/classify.cpp
utils/iodevicelogger.cpp
utils/log.cpp
utils/action_data.cpp
utils/types.cpp
selftest/selftest.cpp
selftest/enginecheck.cpp
selftest/gpgconfcheck.cpp
${_kleopatra_extra_SRCS}
models/keycache.cpp
models/keylistmodel.cpp
models/keylistsortfilterproxymodel.cpp
models/subkeylistmodel.cpp
models/useridlistmodel.cpp
view/keylistcontroller.cpp
view/keytreeview.cpp
view/searchbar.cpp
view/tabwidget.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/certificatedetailsdialog.cpp
dialogs/exportcertificatesdialog.cpp
+ dialogs/deletecertificatesdialog.cpp
crypto/certificateresolver.cpp
crypto/task.cpp
crypto/taskcollection.cpp
crypto/decryptverifytask.cpp
crypto/decryptverifyemailcontroller.cpp
crypto/decryptverifyfilescontroller.cpp
crypto/encryptemailtask.cpp
crypto/encryptemailcontroller.cpp
crypto/signencryptfilestask.cpp
crypto/signemailtask.cpp
crypto/signemailcontroller.cpp
crypto/gui/wizard.cpp
crypto/gui/wizardpage.cpp
crypto/gui/signingcertificateselectiondialog.cpp
crypto/gui/resultitemwidget.cpp
crypto/gui/resultlistwidget.cpp
crypto/gui/resultpage.cpp
crypto/gui/decryptverifyoperationwidget.cpp
crypto/gui/decryptverifyfileswizard.cpp
crypto/gui/objectspage.cpp
crypto/gui/resolverecipientspage.cpp
crypto/gui/signerresolvepage.cpp
crypto/gui/encryptemailwizard.cpp
crypto/gui/signemailwizard.cpp
crypto/gui/signencryptfileswizard.cpp
crypto/gui/signencryptwizard.cpp
crypto/controller.cpp
crypto/signencryptfilescontroller.cpp
commands/command.cpp
commands/gnupgprocesscommand.cpp
commands/detailscommand.cpp
commands/exportcertificatecommand.cpp
commands/importcertificatescommand.cpp
commands/importcertificatefromfilecommand.cpp
commands/lookupcertificatescommand.cpp
commands/reloadkeyscommand.cpp
commands/refreshx509certscommand.cpp
commands/refreshopenpgpcertscommand.cpp
commands/deletecertificatescommand.cpp
commands/decryptverifyfilescommand.cpp
commands/signencryptfilescommand.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/changepassphrasecommand.cpp
commands/certifycertificatecommand.cpp
commands/selftestcommand.cpp
commands/exportsecretkeycommand.cpp
commands/exportopenpgpcertstoservercommand.cpp
commands/adduseridcommand.cpp
commands/newcertificatecommand.cpp
${_kleopatra_uiserver_files}
conf/configuredialog.cpp
newcertificatewizard/listwidget.cpp
newcertificatewizard/newcertificatewizard.cpp
aboutdata.cpp
systemtrayicon.cpp
kleopatraapplication.cpp
main.cpp )
if ( KLEO_MODEL_TEST )
add_definitions( -DKLEO_MODEL_TEST )
set( _kleopatra_SRCS ${_kleopatra_SRCS} models/modeltest.cpp )
endif ( KLEO_MODEL_TEST )
kde4_add_ui_files( _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/certificatedetailsdialog.ui
newcertificatewizard/listwidget.ui
newcertificatewizard/chooseprotocolpage.ui
newcertificatewizard/enterdetailspage.ui
newcertificatewizard/overviewpage.ui
newcertificatewizard/keycreationpage.ui
newcertificatewizard/resultpage.ui
newcertificatewizard/advancedsettingsdialog.ui
)
kde4_add_kcfg_files( _kleopatra_SRCS
kcfg/tooltippreferences.kcfgc
kcfg/emailoperationspreferences.kcfgc
kcfg/smimevalidationpreferences.kcfgc
)
if (ONLY_KLEO)
add_definitions( -DONLY_KLEO -DKDEPIM_EXPORT= )
set( _kleopatra_libkdepim_SRCS
../libkdepim/progressmanager.cpp
../libkdepim/progressdialog.cpp
../libkdepim/overlaywidget.cpp
../libkdepim/ssllabel.cpp
../libkdepim/statusbarprogresswidget.cpp
)
set( _kleopatra_libkdepim_LIBS )
else(ONLY_KLEO)
set( _kleopatra_libkdepim_SRCS )
set( _kleopatra_libkdepim_LIBS kdepim )
endif(ONLY_KLEO)
set( _kleopatra_mainwindow_SRCS
mainwindow.cpp
)
add_definitions ( -DKDE_DEFAULT_DEBUG_AREA=5151 )
kde4_add_app_icon(_kleopatra_mainwindow_SRCS "ox*-app-kleopatra.png")
kde4_add_executable(kleopatra_bin ${_kleopatra_SRCS} ${_kleopatra_mainwindow_SRCS} ${_kleopatra_uiserver_SRCS} ${_kleopatra_libkdepim_SRCS} )
set_target_properties(kleopatra_bin PROPERTIES OUTPUT_NAME kleopatra)
set( _kleopatra_extra_libs ${QT_QT3SUPPORT_LIBRARY} )
if ( NOT KDE4_KCMUTILS_LIBS )
set( KDE4_KCMUTILS_LIBS ${KDE4_KUTILS_LIBS} )
endif ( NOT KDE4_KCMUTILS_LIBS )
target_link_libraries(kleopatra_bin ${_kleopatra_extra_libs} kleo ${_kleopatra_libkdepim_LIBS} ${QGPGME_LIBRARIES} ${KDE4_KMIME_LIBRARY} ${KDE4_KCMUTILS_LIBS} ${_kleopatra_uiserver_extra_libs} )
if ( USABLE_ASSUAN_FOUND )
target_link_libraries(kleopatra_bin ${QT_QTNETWORK_LIBRARY})
ENDIF ( USABLE_ASSUAN_FOUND )
install(TARGETS kleopatra_bin DESTINATION ${BIN_INSTALL_DIR} )
########### install files ###############
install( FILES kleopatra_import.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
install( FILES kleopatra_signencryptfiles.desktop
kleopatra_signencryptfolders.desktop
kleopatra_decryptverifyfiles.desktop
kleopatra_decryptverifyfolders.desktop
DESTINATION ${SERVICES_INSTALL_DIR})
install( FILES kleopatra.rc DESTINATION ${DATA_INSTALL_DIR}/kleopatra)
kde4_install_icons( ${ICON_INSTALL_DIR} )
diff --git a/commands/deletecertificatescommand.cpp b/commands/deletecertificatescommand.cpp
index 801308726..1a7f73da8 100644
--- a/commands/deletecertificatescommand.cpp
+++ b/commands/deletecertificatescommand.cpp
@@ -1,478 +1,385 @@
/* -*- mode: c++; c-basic-offset:4 -*-
deleteCertificatescommand.cpp
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2007 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 <config-kleopatra.h>
#include "deletecertificatescommand.h"
#include "command_p.h"
+#include <dialogs/deletecertificatesdialog.h>
+
#include <models/keycache.h>
#include <models/predicates.h>
#include <utils/stl_util.h>
#include <kleo/cryptobackend.h>
#include <kleo/cryptobackendfactory.h>
#include <kleo/multideletejob.h>
#include <kleo/deletejob.h>
#include <gpgme++/key.h>
#include <KLocale>
#include <KMessageBox>
#include <QPointer>
#include <QAbstractItemView>
#include <boost/bind.hpp>
#include <algorithm>
#include <vector>
#include <cassert>
using namespace boost;
using namespace GpgME;
using namespace Kleo;
+using namespace Kleo::Dialogs;
class DeleteCertificatesCommand::Private : public Command::Private {
friend class ::Kleo::DeleteCertificatesCommand;
DeleteCertificatesCommand * q_func() const { return static_cast<DeleteCertificatesCommand*>(q); }
public:
explicit Private( DeleteCertificatesCommand * qq, KeyListController * c );
~Private();
void startDeleteJob( GpgME::Protocol protocol );
void cancelJobs();
void pgpDeleteResult( const GpgME::Error & );
void cmsDeleteResult( const GpgME::Error & );
void showErrorsAndFinish();
bool canDelete( GpgME::Protocol proto ) const {
if ( const CryptoBackend::Protocol * const cbp = CryptoBackendFactory::instance()->protocol( proto ) )
if ( DeleteJob * const job = cbp->deleteJob() ) {
job->slotCancel();
return true;
}
return false;
}
+ void ensureDialogCreated() {
+ if ( dialog )
+ return;
+ dialog = new DeleteCertificatesDialog( parentWidgetOrView() );
+ dialog->setAttribute( Qt::WA_DeleteOnClose );
+ dialog->setWindowTitle( i18nc("@title:window", "Delete Certificates") );
+ connect( dialog, SIGNAL(accepted()), q, SLOT(slotDialogAccepted()) );
+ connect( dialog, SIGNAL(rejected()), q, SLOT(slotDialogRejected()) );
+ }
+ void ensureDialogShown() {
+ if ( dialog )
+ dialog->show();
+ }
+
+ void slotDialogAccepted();
+ void slotDialogRejected() {
+ canceled();
+ }
+
private:
+ QPointer<DeleteCertificatesDialog> dialog;
QPointer<MultiDeleteJob> cmsJob, pgpJob;
GpgME::Error cmsError, pgpError;
std::vector<Key> cmsKeys, pgpKeys;
};
DeleteCertificatesCommand::Private * DeleteCertificatesCommand::d_func() { return static_cast<Private*>(d.get()); }
const DeleteCertificatesCommand::Private * DeleteCertificatesCommand::d_func() const { return static_cast<const Private*>(d.get()); }
#define d d_func()
#define q q_func()
DeleteCertificatesCommand::Private::Private( DeleteCertificatesCommand * qq, KeyListController * c )
: Command::Private( qq, c )
{
}
DeleteCertificatesCommand::Private::~Private() {}
DeleteCertificatesCommand::DeleteCertificatesCommand( KeyListController * p )
: Command( new Private( this, p ) )
{
}
DeleteCertificatesCommand::DeleteCertificatesCommand( QAbstractItemView * v, KeyListController * p )
: Command( v, new Private( this, p ) )
{
}
DeleteCertificatesCommand::~DeleteCertificatesCommand() {}
namespace {
enum Action { Nothing = 0, Failure = 1, ClearCMS = 2, ClearPGP = 4 };
// const unsigned int errorCase =
// openpgp.empty() << 3U | d->canDelete( OpenPGP ) << 2U |
// cms.empty() << 1U | d->canDelete( CMS ) << 0U ;
static const struct {
const char * text;
Action actions;
} deletionErrorCases[16] = {
// if havePGP
// if cantPGP
// if haveCMS
{ I18N_NOOP( "Neither the OpenPGP nor the CMS "
"backends support certificate deletion.\n"
"Check your installation." ),
Failure }, // cantCMS
{ I18N_NOOP( "The OpenPGP backend does not support "
"certificate deletion.\n"
"Check your installation.\n"
"Only the selected CMS certificates "
"will be deleted." ),
ClearPGP }, // canCMS
// if !haveCMS
{ I18N_NOOP( "The OpenPGP backend does not support "
"certificate deletion.\n"
"Check your installation." ),
Failure },
{ I18N_NOOP( "The OpenPGP backend does not support "
"certificate deletion.\n"
"Check your installation." ),
Failure },
// if canPGP
// if haveCMS
{ I18N_NOOP( "The CMS backend does not support "
"certificate deletion.\n"
"Check your installation.\n"
"Only the selected OpenPGP certificates "
"will be deleted." ),
ClearCMS }, // cantCMS
{ 0,
Nothing }, // canCMS
// if !haveCMS
{ 0,
Nothing }, // cantCMS
{ 0,
Nothing }, // canCMS
// if !havePGP
// if cantPGP
// if haveCMS
{ I18N_NOOP( "The CMS backend does not support "
"certificate deletion.\n"
"Check your installation." ),
Failure }, // cantCMS
{ 0,
Nothing }, // canCMS
// if !haveCMS
{ 0,
Nothing }, // cantCMS
{ 0,
Nothing }, // canCMS
// if canPGP
// if haveCMS
{ I18N_NOOP( "The CMS backend does not support "
"certificate deletion.\n"
"Check your installation." ),
Failure }, // cantCMS
{ 0,
Nothing }, // canCMS
// if !haveCMS
{ 0,
Nothing }, // cantCMS
{ 0,
Nothing }, // canCMS
};
} // anon namespace
void DeleteCertificatesCommand::doStart() {
- std::vector<Key> keys = d->keys();
- if ( keys.empty() ) {
+ std::vector<Key> selected = d->keys();
+ if ( selected.empty() ) {
d->finished();
return;
}
- // 1. Remove secret keys:
+ kdtools::sort( selected, _detail::ByFingerprint<std::less>() );
- std::vector<Key>::iterator keysEnd
- = std::remove_if( keys.begin(), keys.end(), bind( &Key::hasSecret, _1 ) );
+ // Calculate the closure of the selected keys (those that need to
+ // be deleted with them, though not selected themselves):
- if ( keysEnd == keys.begin() ) {
- KMessageBox::information( d->parentWidgetOrView(),
- i18np("The certificate to be deleted is your own. "
- "It contains private key material, "
- "which is needed to decrypt past communication "
- "encrypted to the certificate, and can therefore "
- "not be deleted.",
+ std::vector<Key> toBeDeleted = KeyCache::instance()->findSubjects( selected );
+ kdtools::sort( toBeDeleted, _detail::ByFingerprint<std::less>() );
- "All of the certificates to be deleted "
- "are your own. "
- "They contain private key material, "
- "which is needed to decrypt past communication "
- "encrypted to the certificate, and can therefore "
- "not be deleted.",
+ std::vector<Key> unselected;
+ unselected.reserve( toBeDeleted.size() );
+ std::set_difference( toBeDeleted.begin(), toBeDeleted.end(),
+ selected.begin(), selected.end(),
+ std::back_inserter( unselected ),
+ _detail::ByFingerprint<std::less>() );
- keys.size() ),
- i18n("Secret Key Deletion") );
- d->finished();
- return;
- }
+ d->ensureDialogCreated();
- const bool hadSecretKeys = keysEnd != keys.end();
-
- // 2. Remove issuers of secret keys:
-
- const std::vector<Key> issuersOfSecretKeys = KeyCache::instance()->findIssuers( KeyCache::instance()->keys() );
-
- std::sort( keys.begin(), keysEnd, _detail::ByFingerprint<std::less>() );
-
- const std::vector<Key>::iterator it
- = std::set_difference( keys.begin(), keysEnd,
- issuersOfSecretKeys.begin(), issuersOfSecretKeys.end(),
- keys.begin(),
- _detail::ByFingerprint<std::less>() );
-
- if ( it == keys.begin() ) {
- KMessageBox::information( d->parentWidgetOrView(),
- hadSecretKeys ?
- i18n("All of the certificates to be deleted "
- "are either your own, or are issuers of one of your own certificates. "
- "Your own certificates contain private key material, "
- "which is needed to decrypt past communication "
- "encrypted to the certificate. They can therefore not be deleted, "
- "and neither can their issuers.")
- :
- i18np("The certificate to be deleted "
- "is an issuer of one of your own certificates. "
- "Your own certificates contain private key material, "
- "which is needed to decrypt past communication "
- "encrypted to the certificate. They can therefore not be deleted, "
- "and neither can their issuers.",
-
- "All of the certificates to be deleted "
- "are issuers of one of your own certificates. "
- "Your own certificates contain private key material, "
- "which is needed to decrypt past communication "
- "encrypted to the certificate. They can therefore not be deleted, "
- "and neither can their issuers.",
-
- keys.size() ),
- i18n("Secret Key Deletion") );
- d->finished();
- return;
- }
+ d->dialog->setSelectedKeys( selected );
+ d->dialog->setUnselectedKeys( unselected );
- const bool hadSecretKeyIssuers = it != keysEnd;
- keysEnd = it;
-
- if ( hadSecretKeys || hadSecretKeyIssuers )
- if ( KMessageBox::Continue !=
- KMessageBox::warningContinueCancel( d->parentWidgetOrView(),
- hadSecretKeys ?
- hadSecretKeyIssuers ?
- i18n("Some of the certificates to be deleted "
- "are your own, or are issuers of one of your own certificates. "
- "Your own certificates contain private key material, "
- "which is needed to decrypt past communication "
- "encrypted to the certificate. They can therefore not be deleted, "
- "and neither can their issuers.\n"
- "If you choose to continue, your own, "
- "as well as any issuer certificates, will be "
- "skipped from deletion.")
- :
- i18n("Some of the certificates to be deleted "
- "are your own. "
- "They contain private key material, "
- "which is needed to decrypt past communication "
- "encrypted to the certificate. They can therefore not be deleted.\n"
- "If you choose to continue, they will be "
- "skipped from deletion.")
- :
- i18n("Some of the certificates to be deleted "
- "are issuers of one of your own certificates. "
- "Your own certificates contain private key material, "
- "which is needed to decrypt past communication "
- "encrypted to the certificate. They can therefore not be deleted, "
- "and neither can their issuers.\n"
- "If you choose to continue, they will be "
- "skipped from deletion."),
- i18n("Secret Key Deletion" ) ) )
- {
- emit canceled();
- d->finished();
- return;
- }
+ d->ensureDialogShown();
+
+}
- std::sort( keys.begin(), keysEnd, _detail::ByFingerprint<std::less>() );
+void DeleteCertificatesCommand::Private::slotDialogAccepted() {
+ std::vector<Key> keys = dialog->keys();
+ assert( !keys.empty() );
std::vector<Key>::iterator
pgpBegin = keys.begin(),
- pgpEnd = std::stable_partition( pgpBegin, keysEnd,
+ pgpEnd = std::stable_partition( pgpBegin, keys.end(),
bind( &GpgME::Key::protocol, _1 ) != CMS ),
cmsBegin = pgpEnd,
- cmsEnd = std::set_difference( cmsBegin, keysEnd,
- issuersOfSecretKeys.begin(), issuersOfSecretKeys.end(),
- cmsBegin,
- _detail::ByFingerprint<std::less>() );
-
- const std::vector<Key> subjects = KeyCache::instance()->findSubjects( cmsBegin, cmsEnd );
-
- assert( !kdtools::any( subjects.begin(), subjects.end(), bind( &Key::hasSecret, _1 ) ) );
-
- std::vector<Key> cms;
- cms.reserve( cmsEnd - cmsBegin + subjects.size() );
- std::set_union( cmsBegin, cmsEnd,
- subjects.begin(), subjects.end(),
- std::back_inserter( cms ),
- _detail::ByFingerprint<std::less>() );
-
- std::vector<Key> openpgp( pgpBegin, pgpEnd );
-
- if ( cms.size() > static_cast<std::size_t>( cmsEnd - cmsBegin ) &&
- KMessageBox::warningContinueCancel( d->parentWidgetOrView(),
- i18n("Some or all of the selected "
- "certificates are issuers (CA certificates) "
- "for other, non-selected certificates.\n"
- "Deleting a CA certificate will also delete "
- "all certificates issued by it."),
- i18n("Deleting CA Certificates") )
- != KMessageBox::Continue ) {
- emit canceled();
- d->finished();
- return;
- }
+ cmsEnd = keys.end() ;
- assert( !kdtools::any( openpgp.begin(), openpgp.end(), bind( &Key::hasSecret, _1 ) ) );
- assert( !kdtools::any( cms.begin(), cms.end(), bind( &Key::hasSecret, _1 ) ) );
+ std::vector<Key> openpgp( pgpBegin, pgpEnd );
+ std::vector<Key> cms( cmsBegin, cmsEnd );
const unsigned int errorCase =
- openpgp.empty() << 3U | d->canDelete( OpenPGP ) << 2U |
- cms.empty() << 1U | d->canDelete( CMS ) << 0U ;
+ openpgp.empty() << 3U | canDelete( OpenPGP ) << 2U |
+ cms.empty() << 1U | canDelete( CMS ) << 0U ;
if ( const unsigned int actions = deletionErrorCases[errorCase].actions ) {
- KMessageBox::information( d->parentWidgetOrView(),
+ KMessageBox::information( parentWidgetOrView(),
i18n( deletionErrorCases[errorCase].text ),
(actions & Failure)
? i18n( "Certificate Deletion Failed" )
: i18n( "Certificate Deletion Problem" ) );
if ( actions & ClearCMS )
cms.clear();
if ( actions & ClearPGP )
openpgp.clear();
if ( actions & Failure ) {
- emit canceled();
- d->finished();
+ canceled();
return;
}
}
assert( !openpgp.empty() || !cms.empty() );
- d->pgpKeys.swap( openpgp );
- d->cmsKeys.swap( cms );
+ pgpKeys.swap( openpgp );
+ cmsKeys.swap( cms );
- if ( !d->pgpKeys.empty() )
- d->startDeleteJob( GpgME::OpenPGP );
- if ( !d->cmsKeys.empty() )
- d->startDeleteJob( GpgME::CMS );
+ if ( !pgpKeys.empty() )
+ startDeleteJob( GpgME::OpenPGP );
+ if ( !cmsKeys.empty() )
+ startDeleteJob( GpgME::CMS );
- if ( ( d->pgpKeys.empty() || d->pgpError.code() ) &&
- ( d->cmsKeys.empty() || d->cmsError.code() ) )
- d->showErrorsAndFinish();
+ if ( ( pgpKeys.empty() || pgpError.code() ) &&
+ ( cmsKeys.empty() || cmsError.code() ) )
+ showErrorsAndFinish();
}
void DeleteCertificatesCommand::Private::startDeleteJob( GpgME::Protocol protocol ) {
assert( protocol != GpgME::UnknownProtocol );
const std::vector<Key> & keys = protocol == CMS ? cmsKeys : pgpKeys ;
const CryptoBackend::Protocol * const backend = CryptoBackendFactory::instance()->protocol( protocol );
assert( backend );
std::auto_ptr<MultiDeleteJob> job( new MultiDeleteJob( backend ) );
connect( job.get(), SIGNAL(result(GpgME::Error,GpgME::Key)),
q, protocol == CMS ? SLOT(cmsDeleteResult(GpgME::Error)) : SLOT(pgpDeleteResult(GpgME::Error)) );
connect( job.get(), SIGNAL(progress(QString,int,int)),
q, SIGNAL(progress(QString,int,int)) );
- if ( const Error err = job->start( keys ) )
+ if ( const Error err = job->start( keys, true /*allowSecretKeyDeletion*/ ) )
( protocol == CMS ? cmsError : pgpError ) = err;
else
( protocol == CMS ? cmsJob : pgpJob ) = job.release();
}
void DeleteCertificatesCommand::Private::showErrorsAndFinish() {
assert( !pgpJob ); assert( !cmsJob );
if ( pgpError || cmsError ) {
QString pgpErrorString;
if ( pgpError )
pgpErrorString = i18n( "OpenPGP backend: %1", QString::fromLocal8Bit( pgpError.asString() ) );
QString cmsErrorString;
if ( cmsError )
cmsErrorString = i18n( "CMS backend: %1", QString::fromLocal8Bit( cmsError.asString() ) );
const QString msg = i18n("<qt><p>An error occurred while trying to delete "
"the certificate:</p>"
"<p><b>%1</b></p></qt>",
pgpError ? cmsError ? pgpErrorString + "</br>" + cmsErrorString : pgpErrorString : cmsErrorString );
KMessageBox::error( parentWidgetOrView(), msg, i18n("Certificate Deletion Failed") );
} else {
std::vector<Key> keys = pgpKeys;
keys.insert( keys.end(), cmsKeys.begin(), cmsKeys.end() );
KeyCache::mutableInstance()->remove( keys );
}
finished();
}
void DeleteCertificatesCommand::doCancel() {
d->cancelJobs();
}
void DeleteCertificatesCommand::Private::pgpDeleteResult( const Error & err ) {
pgpError = err;
pgpJob = 0;
if ( !cmsJob )
showErrorsAndFinish();
}
void DeleteCertificatesCommand::Private::cmsDeleteResult( const Error & err ) {
cmsError = err;
cmsJob = 0;
if ( !pgpJob )
showErrorsAndFinish();
}
void DeleteCertificatesCommand::Private::cancelJobs()
{
if ( cmsJob )
cmsJob->slotCancel();
if ( pgpJob )
pgpJob->slotCancel();
}
#undef d
#undef q
#include "moc_deletecertificatescommand.cpp"
diff --git a/commands/deletecertificatescommand.h b/commands/deletecertificatescommand.h
index 0b66f9d69..a0df8542a 100644
--- a/commands/deletecertificatescommand.h
+++ b/commands/deletecertificatescommand.h
@@ -1,62 +1,64 @@
/* -*- mode: c++; c-basic-offset:4 -*-
deletecertificatescommand.h
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2007 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_COMMANDS_DELETECERTIFICATESCOMMAND_H__
#define __KLEOPATRA_COMMANDS_DELETECERTIFICATESCOMMAND_H__
#include "command.h"
namespace Kleo {
class DeleteCertificatesCommand : public Command {
Q_OBJECT
public:
explicit DeleteCertificatesCommand( QAbstractItemView * view, KeyListController * parent );
explicit DeleteCertificatesCommand( KeyListController * parent );
~DeleteCertificatesCommand();
/* reimp */ static Restrictions restrictions() { return NeedSelection; }
private:
/* reimp */ void doStart();
/* reimp */ void doCancel();
private:
class Private;
inline Private * d_func();
inline const Private * d_func() const;
+ Q_PRIVATE_SLOT( d_func(), void slotDialogAccepted() )
+ Q_PRIVATE_SLOT( d_func(), void slotDialogRejected() )
Q_PRIVATE_SLOT( d_func(), void pgpDeleteResult( GpgME::Error ) )
Q_PRIVATE_SLOT( d_func(), void cmsDeleteResult( GpgME::Error ) )
};
}
#endif // __KLEOPATRA_COMMANDS_DELETECERTIFICATESCOMMAND_H__
diff --git a/dialogs/deletecertificatesdialog.cpp b/dialogs/deletecertificatesdialog.cpp
new file mode 100644
index 000000000..d97f4cce6
--- /dev/null
+++ b/dialogs/deletecertificatesdialog.cpp
@@ -0,0 +1,227 @@
+/* -*- mode: c++; c-basic-offset:4 -*-
+ dialogs/deletecertificatesdialog.cpp
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2009 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 <config-kleopatra.h>
+
+#include "deletecertificatesdialog.h"
+
+#include <view/keytreeview.h>
+#include <models/keylistmodel.h>
+
+#include <utils/stl_util.h>
+
+#include <KLocale>
+#include <KMessageBox>
+#include <KStandardGuiItem>
+#include <KDebug>
+
+#include <QLabel>
+#include <QDialogButtonBox>
+#include <QVBoxLayout>
+#include <QWhatsThis>
+#include <QCursor>
+#include <QPushButton>
+#include <QTreeView>
+
+#include <gpgme++/key.h>
+
+#include <boost/mem_fn.hpp>
+
+#include <cassert>
+
+using namespace Kleo;
+using namespace Kleo::Dialogs;
+using namespace GpgME;
+using namespace boost;
+
+class DeleteCertificatesDialog::Private {
+ friend class ::Kleo::Dialogs::DeleteCertificatesDialog;
+ DeleteCertificatesDialog * const q;
+public:
+ explicit Private( DeleteCertificatesDialog * qq )
+ : q( qq ),
+ ui( q )
+ {
+
+ }
+
+ void slotWhatsThisRequested() {
+ kDebug();
+ if ( QWidget * const widget = qobject_cast<QWidget*>( q->sender() ) )
+ if ( !widget->whatsThis().isEmpty() )
+ QWhatsThis::showText( QCursor::pos(), widget->whatsThis() );
+ }
+
+private:
+ struct UI {
+ QLabel selectedLB;
+ KeyTreeView selectedKTV;
+ QLabel unselectedLB;
+ KeyTreeView unselectedKTV;
+ QDialogButtonBox buttonBox;
+ QVBoxLayout vlay;
+
+ explicit UI( DeleteCertificatesDialog * qq )
+ : selectedLB( i18n( "These are the certificates you have selected for deletion:" ), qq ),
+ selectedKTV( qq ),
+ unselectedLB( i18n("These certificates will be deleted even though you did <emphasis>not</emphasis><nl> "
+ "explicitly select them (<a href=\"whatsthis://\">Why?</a>):"), qq ),
+ unselectedKTV( qq ),
+ buttonBox( QDialogButtonBox::Ok|QDialogButtonBox::Cancel ),
+ vlay( qq )
+ {
+ KDAB_SET_OBJECT_NAME( selectedLB );
+ KDAB_SET_OBJECT_NAME( selectedKTV );
+ KDAB_SET_OBJECT_NAME( unselectedLB );
+ KDAB_SET_OBJECT_NAME( unselectedKTV );
+ KDAB_SET_OBJECT_NAME( buttonBox );
+ KDAB_SET_OBJECT_NAME( vlay );
+
+ vlay.addWidget( &selectedLB );
+ vlay.addWidget( &selectedKTV, 1 );
+ vlay.addWidget( &unselectedLB );
+ vlay.addWidget( &unselectedKTV, 1 );
+ vlay.addWidget( &buttonBox );
+
+ const QString unselectedWhatsThis
+ = i18nc( "@info:whatsthis",
+ "<title>Why do you want to delete more certificates than I selected?</title>"
+ "<para>When you delete CA certificates (both root CAs and intermediate CAs), "
+ "the certificates issued by them will also be deleted.</para>"
+ "<para>This can be nicely seen in <application>Kleopatra</application>'s "
+ "hierarchical view mode: In this mode, if you delete a certificate that has "
+ "children, those children will also be deleted. Think of CA certificates as "
+ "folders containing other certificates: When you delete the folder, you "
+ "delete its contents, too.</para>" );
+
+ unselectedLB.setWhatsThis( unselectedWhatsThis );
+ unselectedKTV.setWhatsThis( unselectedWhatsThis );
+
+ buttonBox.button( QDialogButtonBox::Ok )->setText( i18nc("@action:button","Delete") );
+
+ connect( &unselectedLB, SIGNAL(linkActivated(QString)), qq, SLOT(slotWhatsThisRequested()) );
+
+ selectedKTV.setHierarchicalView( false );
+ selectedKTV.view()->setSelectionMode( QAbstractItemView::NoSelection );
+ unselectedKTV.setHierarchicalView( false );
+ unselectedKTV.view()->setSelectionMode( QAbstractItemView::NoSelection );
+
+ selectedKTV.setFlatModel( AbstractKeyListModel::createFlatKeyListModel( &selectedKTV ) );
+ unselectedKTV.setFlatModel( AbstractKeyListModel::createFlatKeyListModel( &unselectedKTV ) );
+
+ connect( &buttonBox, SIGNAL(accepted()), qq, SLOT(accept()) );
+ connect( &buttonBox, SIGNAL(rejected()), qq, SLOT(reject()) );
+ }
+ } ui;
+};
+
+DeleteCertificatesDialog::DeleteCertificatesDialog( QWidget * p, Qt::WindowFlags f )
+ : QDialog( p, f ), d( new Private( this ) )
+{
+
+}
+
+DeleteCertificatesDialog::~DeleteCertificatesDialog() {}
+
+
+void DeleteCertificatesDialog::setSelectedKeys( const std::vector<Key> & keys ) {
+ d->ui.selectedKTV.setKeys( keys );
+}
+
+void DeleteCertificatesDialog::setUnselectedKeys( const std::vector<Key> & keys ) {
+ d->ui.unselectedLB .setVisible( !keys.empty() );
+ d->ui.unselectedKTV.setVisible( !keys.empty() );
+ d->ui.unselectedKTV.setKeys( keys );
+}
+
+std::vector<Key> DeleteCertificatesDialog::keys() const {
+ const std::vector<Key> sel = d->ui.selectedKTV.keys();
+ const std::vector<Key> uns = d->ui.unselectedKTV.keys();
+ std::vector<Key> result;
+ result.reserve( sel.size() + uns.size() );
+ result.insert( result.end(), sel.begin(), sel.end() );
+ result.insert( result.end(), uns.begin(), uns.end() );
+ return result;
+}
+
+void DeleteCertificatesDialog::accept() {
+
+ const std::vector<Key> sel = d->ui.selectedKTV.keys();
+ const std::vector<Key> uns = d->ui.unselectedKTV.keys();
+
+ const uint secret = kdtools::count_if( sel, mem_fn( &Key::hasSecret ) )
+ + kdtools::count_if( uns, mem_fn( &Key::hasSecret ) );
+ const uint total = sel.size() + uns.size();
+
+ int ret = KMessageBox::Continue;
+ if ( secret )
+ ret = KMessageBox::warningContinueCancel( this,
+ secret == total
+ ? i18np("The certificate to be deleted is your own. "
+ "It contains private key material, "
+ "which is needed to decrypt past communication "
+ "encrypted to the certificate, and should therefore "
+ "not be deleted.",
+
+ "All of the certificates to be deleted "
+ "are your own. "
+ "They contain private key material, "
+ "which is needed to decrypt past communication "
+ "encrypted to the certificate, and should therefore "
+ "not be deleted.",
+
+ secret )
+ : i18np("One of the certificates to be deleted "
+ "is your own. "
+ "It contains private key material, "
+ "which is needed to decrypt past communication "
+ "encrypted to the certificate, and should therefore "
+ "not be deleted.",
+
+ "Some of the certificates to be deleted "
+ "are your own. "
+ "They contain private key material, "
+ "which is needed to decrypt past communication "
+ "encrypted to the certificate, and should therefore "
+ "not be deleted.",
+
+ secret ),
+ i18n("Secret Key Deletion"),
+ KStandardGuiItem::guiItem( KStandardGuiItem::Delete ) );
+
+ if ( ret == KMessageBox::Continue )
+ QDialog::accept();
+ else
+ QDialog::reject();
+}
+
+#include "moc_deletecertificatesdialog.cpp"
diff --git a/commands/deletecertificatescommand.h b/dialogs/deletecertificatesdialog.h
similarity index 62%
copy from commands/deletecertificatescommand.h
copy to dialogs/deletecertificatesdialog.h
index 0b66f9d69..3e8f79a2c 100644
--- a/commands/deletecertificatescommand.h
+++ b/dialogs/deletecertificatesdialog.h
@@ -1,62 +1,71 @@
/* -*- mode: c++; c-basic-offset:4 -*-
- deletecertificatescommand.h
+ dialogs/deletecertificatesdialog.h
This file is part of Kleopatra, the KDE keymanager
- Copyright (c) 2007 Klarälvdalens Datakonsult AB
+ Copyright (c) 2009 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_COMMANDS_DELETECERTIFICATESCOMMAND_H__
-#define __KLEOPATRA_COMMANDS_DELETECERTIFICATESCOMMAND_H__
+#ifndef __KLEOPATRA_DIALOGS_DELETECERTIFICATESDIALOG_H__
+#define __KLEOPATRA_DIALOGS_DELETECERTIFICATESDIALOG_H__
-#include "command.h"
+#include <QDialog>
+
+#include <utils/pimpl_ptr.h>
+
+#include <vector>
+
+namespace GpgME {
+ class Key;
+}
namespace Kleo {
- class DeleteCertificatesCommand : public Command {
+namespace Dialogs {
+
+ class DeleteCertificatesDialog : public QDialog {
Q_OBJECT
public:
- explicit DeleteCertificatesCommand( QAbstractItemView * view, KeyListController * parent );
- explicit DeleteCertificatesCommand( KeyListController * parent );
- ~DeleteCertificatesCommand();
+ explicit DeleteCertificatesDialog( QWidget * parent=0, Qt::WindowFlags f=0 );
+ ~DeleteCertificatesDialog();
- /* reimp */ static Restrictions restrictions() { return NeedSelection; }
+ void setSelectedKeys( const std::vector<GpgME::Key> & keys );
+ void setUnselectedKeys( const std::vector<GpgME::Key> & keys );
- private:
- /* reimp */ void doStart();
- /* reimp */ void doCancel();
+ std::vector<GpgME::Key> keys() const;
+
+ /* reimp */ void accept();
private:
class Private;
- inline Private * d_func();
- inline const Private * d_func() const;
- Q_PRIVATE_SLOT( d_func(), void pgpDeleteResult( GpgME::Error ) )
- Q_PRIVATE_SLOT( d_func(), void cmsDeleteResult( GpgME::Error ) )
+ kdtools::pimpl_ptr<Private> d;
+ Q_PRIVATE_SLOT( d, void slotWhatsThisRequested() );
};
-}
-#endif // __KLEOPATRA_COMMANDS_DELETECERTIFICATESCOMMAND_H__
+}
+}
+#endif /* __KLEOPATRA_DIALOGS_DELETECERTIFICATESDIALOG_H__ */
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, May 12, 6:14 PM (13 h, 3 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5a/9b/0414e99c297e6ca6a4ba0e5ab7c0
Attached To
rKLEOPATRA Kleopatra
Event Timeline
Log In to Comment