diff --git a/kleo/CMakeLists.txt b/kleo/CMakeLists.txt index a78fc649d..d53535b62 100644 --- a/kleo/CMakeLists.txt +++ b/kleo/CMakeLists.txt @@ -1,143 +1,143 @@ include_directories( ${CMAKE_BINARY_DIR}/kleo/backends/chiasmus/ ${GPGME_INCLUDES} ) add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS) add_subdirectory( pics ) add_subdirectory( backends ) add_subdirectory( tests ) ########### next target ############### set(libkleo_backend_qgpgme_SRCS ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/gnupgprocessbase.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmeprogresstokenmapper.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmebackend.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmejob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmekeylistjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmekeygenerationjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmeimportjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmeexportjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmesecretkeyexportjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmedownloadjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmedeletejob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmeencryptjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmedecryptjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmesignjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmeverifydetachedjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmeverifyopaquejob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmesignencryptjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmedecryptverifyjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmecryptoconfig.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/qgpgme/qgpgmerefreshkeysjob.cpp ) set(libkleo_backend_chiasmus_SRCS ${CMAKE_SOURCE_DIR}/kleo/backends/chiasmus/config_data.c ${CMAKE_SOURCE_DIR}/kleo/backends/chiasmus/obtainkeysjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/chiasmus/symcryptrunprocessbase.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/chiasmus/chiasmusjob.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/chiasmus/chiasmuslibrary.cpp ${CMAKE_SOURCE_DIR}/kleo/backends/chiasmus/chiasmusbackend.cpp ) set(libkleo_core_SRCS ${CMAKE_SOURCE_DIR}/kleo/kleo/cryptobackend.cpp ${CMAKE_SOURCE_DIR}/kleo/kleo/cryptobackendfactory.cpp ${CMAKE_SOURCE_DIR}/kleo/kleo/enum.cpp ${CMAKE_SOURCE_DIR}/kleo/kleo/dn.cpp ${CMAKE_SOURCE_DIR}/kleo/kleo/job.cpp ${CMAKE_SOURCE_DIR}/kleo/kleo/multideletejob.cpp ${CMAKE_SOURCE_DIR}/kleo/kleo/hierarchicalkeylistjob.cpp ${CMAKE_SOURCE_DIR}/kleo/kleo/kconfigbasedkeyfilter.cpp ${CMAKE_SOURCE_DIR}/kleo/kleo/keyfiltermanager.cpp ) set(libkleo_ui_SRCS ${CMAKE_SOURCE_DIR}/kleo/ui/kdhorizontalline.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/progressbar.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/progressdialog.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/keylistview.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/keyselectiondialog.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/keyrequester.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/keyapprovaldialog.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/backendconfigwidget.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/dnattributeorderconfigwidget.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/cryptoconfigmodule.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/cryptoconfigdialog.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/directoryserviceswidget.cpp ${CMAKE_SOURCE_DIR}/kleo/ui/adddirectoryservicedialogimpl.cpp ) kde4_add_ui_files(libkleo_ui_SRCS ${CMAKE_SOURCE_DIR}/kleo/ui/adddirectoryservicedialog.ui ${CMAKE_SOURCE_DIR}/kleo/ui/directoryserviceswidgetbase.ui ) set(kleo_LIB_SRCS ${libkleo_core_SRCS} ${libkleo_ui_SRCS} ${libkleo_backend_chiasmus_SRCS} cryptplug.cpp cryptplugwrapper.cpp cryptplugwrapperlist.cpp cryptplugfactory.cpp ) if(NOT WIN32) set(kleo_LIB_SRCS ${kleo_LIB_SRCS} ${libkleo_backend_qgpgme_SRCS}) endif(NOT WIN32) kde4_add_library(kleo-gpl SHARED ${kleo_LIB_SRCS}) -target_link_libraries(kleo-gpl ${KDE4_KDE3SUPPORT_LIBS} gpgme qgpgme ${GPGME_LIBRARIES} ${QT_QT3SUPPORT_LIBRARY}) +target_link_libraries(kleo-gpl ${KDE4_KDE3SUPPORT_LIBS} qgpgme ${GPGME_LIBRARIES} ${QT_QT3SUPPORT_LIBRARY}) set_target_properties(kleo-gpl PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) install(TARGETS kleo-gpl DESTINATION ${LIB_INSTALL_DIR}) install( FILES cryptplug.h cryptplugfactory.h cryptplugwrapper.h cryptplugwrapperlist.h kleo_export.h kleo/enum.h kleo/oidmap.h kleo/cryptobackend.h kleo/cryptobackendfactory.h kleo/cryptoconfig.h kleo/dn.h kleo/job.h kleo/keylistjob.h kleo/keygenerationjob.h kleo/importjob.h kleo/exportjob.h kleo/downloadjob.h kleo/deletejob.h kleo/encryptjob.h kleo/decryptjob.h kleo/signjob.h kleo/specialjob.h kleo/verifydetachedjob.h kleo/verifyopaquejob.h kleo/decryptverifyjob.h kleo/signencryptjob.h kleo/refreshkeysjob.h kleo/multideletejob.h kleo/hierarchicalkeylistjob.h kleo/keyfilter.h kleo/keyfiltermanager.h DESTINATION ${INCLUDE_INSTALL_DIR}/kleo) install ( FILES ui/kdhorizontalline.h ui/progressbar.h ui/progressdialog.h ui/keylistview.h ui/keyselectiondialog.h ui/keyrequester.h ui/keyapprovaldialog.h ui/backendconfigwidget.h ui/dnattributeorderconfigwidget.h ui/cryptoconfigmodule.h ui/cryptoconfigdialog.h ui/directoryserviceswidget.h DESTINATION ${INCLUDE_INSTALL_DIR}/kleo/ui) diff --git a/kleo/backends/chiasmus/symcryptrunprocessbase.cpp b/kleo/backends/chiasmus/symcryptrunprocessbase.cpp index d0b89b592..a33acb079 100644 --- a/kleo/backends/chiasmus/symcryptrunprocessbase.cpp +++ b/kleo/backends/chiasmus/symcryptrunprocessbase.cpp @@ -1,109 +1,105 @@ /* symcryptrunbackend.cpp This file is part of libkleopatra, the KDE keymanagement library Copyright (c) 2005 Klar�vdalens Datakonsult AB Libkleopatra 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. Libkleopatra 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 "symcryptrunprocessbase.h" #include #include #include #include #include #include #include Kleo::SymCryptRunProcessBase::SymCryptRunProcessBase( const QString & class_, const QString & program, const QString & keyFile, const QString & options, Operation mode, QObject * parent ) : KProcess( parent ), mOperation( mode ), mOptions( options ) { *this << "symcryptrun" << "--class" << class_ << "--program" << program << "--keyfile" << keyFile << ( mode == Encrypt ? "--encrypt" : "--decrypt" ); } Kleo::SymCryptRunProcessBase::~SymCryptRunProcessBase() {} bool Kleo::SymCryptRunProcessBase::launch( const QByteArray & input, bool block ) { connect( this, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadyReadStandardOutput()) ); connect( this, SIGNAL(readyReadStandardError()), this, SLOT(slotReadyReadStandardError()) ); if ( block ) { KTemporaryFile tempfile; if ( tempfile.open() ) tempfile.write( input ); else return false; tempfile.flush(); *this << "--input" << tempfile.fileName(); addOptions(); - KProcess::start(); - if(!waitForStarted()) - return false; - while(waitForFinished(10)) - ; + KProcess::execute(); } else { addOptions(); KProcess::start(); const bool ok = waitForStarted(); if ( !ok ) return ok; mInput = input; write( mInput ); closeWriteChannel(); } return true; } void Kleo::SymCryptRunProcessBase::addOptions() { if ( !mOptions.isEmpty() ) { const QStringList args = KShell::splitArgs( mOptions ); *this << "--" << args; } } void Kleo::SymCryptRunProcessBase::slotReadyReadStandardOutput() { mOutput += readAllStandardOutput(); } void Kleo::SymCryptRunProcessBase::slotReadyReadStandardError() { mStderr += readAllStandardError(); } #include "symcryptrunprocessbase.moc" diff --git a/kleo/ui/dnattributeorderconfigwidget.cpp b/kleo/ui/dnattributeorderconfigwidget.cpp index 6f81160a1..0223d6051 100644 --- a/kleo/ui/dnattributeorderconfigwidget.cpp +++ b/kleo/ui/dnattributeorderconfigwidget.cpp @@ -1,310 +1,311 @@ /* -*- c++ -*- dnattributeorderconfigwidget.cpp This file is part of libkleopatra, the KDE keymanagement library Copyright (c) 2004 Klar�vdalens Datakonsult AB Libkleopatra 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. Libkleopatra 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 "dnattributeorderconfigwidget.h" #include "kleo/dn.h" #include #include #include #include #include #include #include #include #include #include //Added by qt3to4: #include #include -struct Kleo::DNAttributeOrderConfigWidget::Private { +class Kleo::DNAttributeOrderConfigWidget::Private { +public: enum { UUp=0, Up=1, Left=2, Right=3, Down=4, DDown=5 }; Q3ListView * availableLV; Q3ListView * currentLV; QToolButton * navTB[6]; Q3ListViewItem * placeHolderItem; Kleo::DNAttributeMapper * mapper; }; static void prepare( Q3ListView * lv ) { lv->setAllColumnsShowFocus( true ); lv->setResizeMode( Q3ListView::LastColumn ); lv->header()->setClickEnabled( false ); lv->addColumn( QString() ); lv->addColumn( i18n("Description") ); } Kleo::DNAttributeOrderConfigWidget::DNAttributeOrderConfigWidget( DNAttributeMapper * mapper, QWidget * parent, const char * name, Qt::WFlags f ) : QWidget( parent, f ), d( new Private() ) { setObjectName(name); assert( mapper ); d->mapper = mapper; QGridLayout * glay = new QGridLayout( this ); glay->setMargin( 0 ); glay->setSpacing( KDialog::spacingHint() ); glay->setColumnStretch( 0, 1 ); glay->setColumnStretch( 2, 1 ); int row = -1; ++row; glay->addWidget( new QLabel( i18n("Available attributes:"), this ), row, 0 ); glay->addWidget( new QLabel( i18n("Current attribute order:"), this ), row, 2 ); ++row; glay->setRowStretch( row, 1 ); d->availableLV = new Q3ListView( this ); prepare( d->availableLV ); d->availableLV->setSorting( 0 ); glay->addWidget( d->availableLV, row, 0 ); d->currentLV = new Q3ListView( this ); prepare( d->currentLV ); d->currentLV->setSorting( -1 ); glay->addWidget( d->currentLV, row, 2 ); connect( d->availableLV, SIGNAL(clicked(Q3ListViewItem*)), SLOT(slotAvailableSelectionChanged(Q3ListViewItem*)) ); connect( d->currentLV, SIGNAL(clicked(Q3ListViewItem*)), SLOT(slotCurrentOrderSelectionChanged(Q3ListViewItem*)) ); d->placeHolderItem = new Q3ListViewItem( d->availableLV, "_X_", i18n("All others") ); // the up/down/left/right arrow cross: QGridLayout * xlay = new QGridLayout(); xlay->setSpacing( 0 ); xlay->setObjectName( "xlay" ); xlay->setAlignment( Qt::AlignCenter ); static const struct { const char * icon; int row, col; const char * tooltip; const char * slot; } navButtons[] = { { "arrow-up-double", 0, 1, I18N_NOOP( "Move to top" ), SLOT(slotDoubleUpButtonClicked()) }, { "arrow-up", 1, 1, I18N_NOOP( "Move one up" ), SLOT(slotUpButtonClicked()) }, { "arrow-left", 2, 0, I18N_NOOP( "Remove from current attribute order" ), SLOT(slotLeftButtonClicked()) }, { "arrow-right", 2, 2, I18N_NOOP( "Add to current attribute order" ), SLOT(slotRightButtonClicked()) }, { "arrow-down", 3, 1, I18N_NOOP( "Move one down" ), SLOT(slotDownButtonClicked()) }, { "arrow-down-double", 4, 1, I18N_NOOP( "Move to bottom" ), SLOT(slotDoubleDownButtonClicked()) } }; for ( unsigned int i = 0 ; i < sizeof navButtons / sizeof *navButtons ; ++i ) { QToolButton * tb = d->navTB[i] = new QToolButton( this ); tb->setIcon( KIcon( navButtons[i].icon ) ); tb->setEnabled( false ); tb->setToolTip( i18n( navButtons[i].tooltip ) ); xlay->addWidget( tb, navButtons[i].row, navButtons[i].col ); connect( tb, SIGNAL(clicked()), navButtons[i].slot ); } glay->addLayout( xlay, row, 1 ); } Kleo::DNAttributeOrderConfigWidget::~DNAttributeOrderConfigWidget() { delete d; } void Kleo::DNAttributeOrderConfigWidget::load() { // save the _X_ item: takePlaceHolderItem(); // clear the rest: d->availableLV->clear(); d->currentLV->clear(); const QStringList order = d->mapper->attributeOrder(); // fill the RHS listview: Q3ListViewItem * last = 0; for ( QStringList::const_iterator it = order.begin() ; it != order.end() ; ++it ) { const QString attr = (*it).toUpper(); if ( attr == "_X_" ) { takePlaceHolderItem(); d->currentLV->insertItem( d->placeHolderItem ); d->placeHolderItem->moveItem( last ); last = d->placeHolderItem; } else last = new Q3ListViewItem( d->currentLV, last, attr, d->mapper->name2label( attr ) ); } // fill the LHS listview with what's left: const QStringList all = Kleo::DNAttributeMapper::instance()->names(); for ( QStringList::const_iterator it = all.begin() ; it != all.end() ; ++it ) if ( !order.contains( *it ) ) (void)new Q3ListViewItem( d->availableLV, *it, d->mapper->name2label( *it ) ); if ( !d->placeHolderItem->listView() ) d->availableLV->insertItem( d->placeHolderItem ); } void Kleo::DNAttributeOrderConfigWidget::takePlaceHolderItem() { if ( Q3ListView * lv = d->placeHolderItem->listView() ) lv->takeItem( d->placeHolderItem ); } void Kleo::DNAttributeOrderConfigWidget::save() const { QStringList order; for ( Q3ListViewItemIterator it( d->currentLV ) ; it.current() ; ++it ) order.push_back( it.current()->text( 0 ) ); d->mapper->setAttributeOrder( order ); } void Kleo::DNAttributeOrderConfigWidget::defaults() { kDebug() << "Sorry, not implemented: Kleo::DNAttributeOrderConfigWidget::defaults()" << endl; } void Kleo::DNAttributeOrderConfigWidget::slotAvailableSelectionChanged( Q3ListViewItem * item ) { d->navTB[Private::Right]->setEnabled( item ); } void Kleo::DNAttributeOrderConfigWidget::slotCurrentOrderSelectionChanged( Q3ListViewItem * item ) { enableDisableButtons( item ); } void Kleo::DNAttributeOrderConfigWidget::enableDisableButtons( Q3ListViewItem * item ) { d->navTB[Private::UUp ]->setEnabled( item && item->itemAbove() ); d->navTB[Private::Up ]->setEnabled( item && item->itemAbove() ); d->navTB[Private::Left ]->setEnabled( item ); d->navTB[Private::Down ]->setEnabled( item && item->itemBelow() ); d->navTB[Private::DDown]->setEnabled( item && item->itemBelow() ); } void Kleo::DNAttributeOrderConfigWidget::slotUpButtonClicked() { Q3ListViewItem * item = d->currentLV->selectedItem(); if ( !item ) return; Q3ListViewItem * above = item->itemAbove(); if ( !above ) return; above->moveItem( item ); // moves "above" to after "item", ie. "item" one up enableDisableButtons( item ); emit changed(); } void Kleo::DNAttributeOrderConfigWidget::slotDoubleUpButtonClicked() { Q3ListViewItem * item = d->currentLV->selectedItem(); if ( !item ) return; if ( item == d->currentLV->firstChild() ) return; d->currentLV->takeItem( item ); d->currentLV->insertItem( item ); d->currentLV->setSelected( item, true ); enableDisableButtons( item ); emit changed(); } void Kleo::DNAttributeOrderConfigWidget::slotDownButtonClicked() { Q3ListViewItem * item = d->currentLV->selectedItem(); if ( !item ) return; Q3ListViewItem * below = item->itemBelow(); if ( !below ) return; item->moveItem( below ); // moves "item" to after "below", ie. "item" one down enableDisableButtons( item ); emit changed(); } void Kleo::DNAttributeOrderConfigWidget::slotDoubleDownButtonClicked() { Q3ListViewItem * item = d->currentLV->selectedItem(); if ( !item ) return; Q3ListViewItem * last = d->currentLV->lastItem(); assert( last ); if ( item == last ) return; item->moveItem( last ); // moves "item" to after "last", ie. to the bottom enableDisableButtons( item ); emit changed(); } void Kleo::DNAttributeOrderConfigWidget::slotLeftButtonClicked() { Q3ListViewItem * right = d->currentLV->selectedItem(); if ( !right ) return; Q3ListViewItem * next = right->itemBelow(); if ( !next ) next = right->itemAbove(); d->currentLV->takeItem( right ); d->availableLV->insertItem( right ); if ( next ) d->currentLV->setSelected( next, true ); enableDisableButtons( next ); emit changed(); } void Kleo::DNAttributeOrderConfigWidget::slotRightButtonClicked() { Q3ListViewItem * left = d->availableLV->selectedItem(); if ( !left ) return; Q3ListViewItem * next = left->itemBelow(); if ( !next ) next = left->itemAbove(); d->availableLV->takeItem( left ); d->currentLV->insertItem( left ); if ( Q3ListViewItem * right = d->currentLV->selectedItem() ) { if ( Q3ListViewItem * above = right->itemAbove() ) left->moveItem( above ); // move new item immediately before old selected d->currentLV->setSelected( right, false ); } d->currentLV->setSelected( left, true ); enableDisableButtons( left ); d->navTB[Private::Right]->setEnabled( next ); if ( next ) d->availableLV->setSelected( next, true ); emit changed(); } void Kleo::DNAttributeOrderConfigWidget::virtual_hook( int, void* ) {} #include "dnattributeorderconfigwidget.moc" diff --git a/kleo/ui/keyapprovaldialog.cpp b/kleo/ui/keyapprovaldialog.cpp index 0de4c1e6b..2c3ca5b68 100644 --- a/kleo/ui/keyapprovaldialog.cpp +++ b/kleo/ui/keyapprovaldialog.cpp @@ -1,215 +1,216 @@ /* -*- c++ -*- keyapprovaldialog.h This file is part of libkleopatra, the KDE keymanagement library Copyright (c) 2004 Klarälvdalens Datakonsult AB Based on kpgpui.h Copyright (C) 2001,2002 the KPGP authors See file libkdenetwork/AUTHORS.kpgp for details Libkleopatra 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. Libkleopatra 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 "keyapprovaldialog.h" #include "keyrequester.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static Kleo::EncryptionPreference cb2pref( int i ) { switch ( i ) { default: case 0: return Kleo::UnknownPreference; case 1: return Kleo::NeverEncrypt; case 2: return Kleo::AlwaysEncrypt; case 3: return Kleo::AlwaysEncryptIfPossible; case 4: return Kleo::AlwaysAskForEncryption; case 5: return Kleo::AskWheneverPossible; } } static int pref2cb( Kleo::EncryptionPreference p ) { switch ( p ) { default: return 0; case Kleo::NeverEncrypt: return 1; case Kleo::AlwaysEncrypt: return 2; case Kleo::AlwaysEncryptIfPossible: return 3; case Kleo::AlwaysAskForEncryption: return 4; case Kleo::AskWheneverPossible: return 5; } } static QStringList preferencesStrings() { return QStringList() << i18n("none") << i18n("Never Encrypt with This Key") << i18n("Always Encrypt with This Key") << i18n("Encrypt Whenever Encryption is Possible") << i18n("Always Ask") << i18n("Ask Whenever Encryption is Possible"); } -struct Kleo::KeyApprovalDialog::Private { +class Kleo::KeyApprovalDialog::Private { +public: Private() : selfRequester( 0 ), prefsChanged( false ) {} Kleo::KeyRequester * selfRequester; QStringList addresses; std::vector requesters; std::vector preferences; bool prefsChanged; }; Kleo::KeyApprovalDialog::KeyApprovalDialog( const std::vector & recipients, const std::vector & sender, QWidget * parent ) : KDialog( parent ), d( new Private() ) { setCaption( i18n("Encryption Key Approval") ); setButtons( Ok|Cancel ); setDefaultButton( Ok ); assert( !recipients.empty() ); QFrame *page = new QFrame( this ); setMainWidget( page ); QVBoxLayout * vlay = new QVBoxLayout( page ); vlay->setMargin( 0 ); vlay->setSpacing( spacingHint() ); vlay->addWidget( new QLabel( i18n("The following keys will be used for encryption:"), page ) ); QScrollArea * sv = new QScrollArea( page ); //Laurent not sure sv->setWidgetResizable(true); //sv->setResizePolicy( Q3ScrollView::AutoOneFit ); vlay->addWidget( sv ); QWidget * view = new QWidget( sv->viewport() ); QGridLayout * glay = new QGridLayout( view ); glay->setMargin( marginHint() ); glay->setSpacing( spacingHint() ); glay->setColumnStretch( 1, 1 ); sv->setWidget( view ); int row = -1; if ( !sender.empty() ) { ++row; glay->addWidget( new QLabel( i18n("Your keys:"), view ), row, 0 ); d->selfRequester = new EncryptionKeyRequester( true, EncryptionKeyRequester::AllProtocols, view ); d->selfRequester->setKeys( sender ); glay->addWidget( d->selfRequester, row, 1 ); ++row; glay->addWidget( new KSeparator( Qt::Horizontal, view ), row, 0, 1, 2 ); } const QStringList prefs = preferencesStrings(); for ( std::vector::const_iterator it = recipients.begin() ; it != recipients.end() ; ++it ) { ++row; glay->addWidget( new QLabel( i18n("Recipient:"), view ), row, 0 ); glay->addWidget( new QLabel( it->address, view ), row, 1 ); d->addresses.push_back( it->address ); ++row; glay->addWidget( new QLabel( i18n("Encryption keys:"), view ), row, 0 ); KeyRequester * req = new EncryptionKeyRequester( true, EncryptionKeyRequester::AllProtocols, view ); req->setKeys( it->keys ); glay->addWidget( req, row, 1 ); d->requesters.push_back( req ); ++row; glay->addWidget( new QLabel( i18n("Encryption preference:"), view ), row, 0 ); QComboBox * cb = new QComboBox( view ); cb->setEditable( false ); cb->addItems( prefs ); glay->addWidget( cb, row, 1 ); cb->setCurrentIndex( pref2cb( it->pref ) ); connect( cb, SIGNAL(activated(int)), SLOT(slotPrefsChanged()) ); d->preferences.push_back( cb ); } QSize size = sizeHint(); // don't make the dialog too large const QRect desk = KGlobalSettings::desktopGeometry( this ); setInitialSize( QSize( qMin( size.width(), 3 * desk.width() / 4 ), qMin( size.height(), 7 * desk.height() / 8 ) ) ); } Kleo::KeyApprovalDialog::~KeyApprovalDialog() { delete d; } std::vector Kleo::KeyApprovalDialog::senderKeys() const { return d->selfRequester ? d->selfRequester->keys() : std::vector() ; } std::vector Kleo::KeyApprovalDialog::items() const { assert( d->requesters.size() == d->addresses.size() ); assert( d->requesters.size() == d->preferences.size() ); std::vector result; result.reserve( d->requesters.size() ); QStringList::const_iterator ait = d->addresses.begin(); std::vector::const_iterator rit = d->requesters.begin(); std::vector::const_iterator cit = d->preferences.begin(); while ( ait != d->addresses.end() ) result.push_back( Item( *ait++, (*rit++)->keys(), cb2pref( (*cit++)->currentIndex() ) ) ); return result; } bool Kleo::KeyApprovalDialog::preferencesChanged() const { return d->prefsChanged; } void Kleo::KeyApprovalDialog::slotPrefsChanged() { d->prefsChanged = true; } #include "keyapprovaldialog.moc"