kmail Library API Documentation

certificatehandlingdialogimpl.cpp

00001 #ifdef HAVE_CONFIG_H 00002 #include <config.h> 00003 #endif 00004 00005 #include "certificatehandlingdialogimpl.h" 00006 #include "certificatewizardimpl.h" 00007 00008 #include <qlistview.h> 00009 #include <qpopupmenu.h> 00010 #include <qpushbutton.h> 00011 #include <qlabel.h> 00012 00013 #include <klocale.h> 00014 #include <kdebug.h> 00015 /* 00016 * Constructs a CertificateHandlingDialogImpl which is a child of 'parent', with the 00017 * name 'name' and widget flags set to 'f' 00018 */ 00019 CertificateHandlingDialogImpl::CertificateHandlingDialogImpl( QWidget* parent, const char* name, WFlags fl ) 00020 : CertificateHandlingDialog( parent, name, fl ) 00021 { 00022 } 00023 00024 /* 00025 * Destroys the object and frees any allocated resources 00026 */ 00027 CertificateHandlingDialogImpl::~CertificateHandlingDialogImpl() 00028 { 00029 // no need to delete child widgets, Qt does it all for us 00030 } 00031 00032 /* 00033 * protected slot 00034 */ 00035 void CertificateHandlingDialogImpl::slotDeleteCertificate() 00036 { 00037 // PENDING(khz) Add code to delete certificate. 00038 00039 QListViewItem* item = certificatesLV->selectedItem(); 00040 Q_ASSERT( item ); 00041 delete item; 00042 } 00043 00044 /* 00045 * protected slot 00046 */ 00047 void CertificateHandlingDialogImpl::slotCertificateSelectionChanged( QListViewItem* item ) 00048 { 00049 if( item ) { 00050 requestPopup->setItemEnabled(1, true); 00051 requestPopup->setItemEnabled(2, true); 00052 deletePB->setEnabled( true ); 00053 if( item->text( 2 ) == i18n( "Sign/Encrypt" ) ) { 00054 useForSigningPB->setEnabled( true ); 00055 useForEncryptingPB->setEnabled( true ); 00056 } else if( item->text( 2 ) == i18n( "Sign" ) ) { 00057 useForSigningPB->setEnabled( true ); 00058 useForEncryptingPB->setEnabled( false ); 00059 } else if( item->text( 2 ) == i18n( "Encrypt" ) ) { 00060 useForSigningPB->setEnabled( false ); 00061 useForEncryptingPB->setEnabled( true ); 00062 } else { 00063 // should not happen, such a certificate would be pretty useless 00064 useForSigningPB->setEnabled( false ); 00065 useForEncryptingPB->setEnabled( false ); 00066 } 00067 } else { 00068 useForSigningPB->setEnabled( false ); 00069 useForEncryptingPB->setEnabled( false ); 00070 requestPopup->setItemEnabled(1, false); 00071 requestPopup->setItemEnabled(2, true); 00072 deletePB->setEnabled( false ); 00073 } 00074 } 00075 00076 /* 00077 * protected slot 00078 */ 00079 void CertificateHandlingDialogImpl::slotRequestChangedCertificate() 00080 { 00081 // PENDING(khz) Send change request to CA 00082 kdWarning() << "CertificateHandlingDialogImpl::slotRequestChangedCertificate() not yet implemented!" << endl; 00083 } 00084 00085 /* 00086 * protected slot 00087 */ 00088 void CertificateHandlingDialogImpl::slotRequestExtendedCertificate() 00089 { 00090 // PENDING(khz) Send extension request CA 00091 kdWarning() << "CertificateHandlingDialogImpl::slotRequestExtendedCertificate() not yet implemented!" << endl; 00092 } 00093 00094 /* 00095 * protected slot 00096 */ 00097 void CertificateHandlingDialogImpl::slotRequestNewCertificate() 00098 { 00099 CertificateWizardImpl wizard; 00100 if( wizard.exec() == QDialog::Accepted ) { 00101 // PENDING(khz) Handle the created certificates. 00102 00103 // Insert a dummy certificate. 00104 // PENDING(khz) Remove this code. 00105 new QListViewItem( certificatesLV, "BlahCertificate", "0x58643BFE", i18n( "Sign/Encrypt" ) ); 00106 } 00107 } 00108 00109 /* 00110 * protected slot 00111 */ 00112 void CertificateHandlingDialogImpl::slotUseForEncrypting() 00113 { 00114 QListViewItem* item = certificatesLV->selectedItem(); 00115 Q_ASSERT( item ); 00116 if( item ) { 00117 // show the used certificate in label 00118 encryptCertLA->setText( item->text( 0 ) ); 00119 00120 // iterate over the listview and reset all usage markings 00121 QListViewItemIterator it( certificatesLV ); 00122 QListViewItem* current; 00123 while( ( current = it.current() ) ) { 00124 if( current->text( 3 ) == i18n( "Sign/Encrypt" ) ) 00125 current->setText( 3, i18n( "Sign" ) ); 00126 else if( current->text( 3 ) == i18n( "Encrypt" ) ) 00127 current->setText( 3, "" ); 00128 ++it; 00129 } 00130 00131 // mark the current one as used 00132 if( item->text( 3 ) == i18n( "Sign" ) ) 00133 item->setText( 3, i18n( "Sign/Encrypt" ) ); 00134 else if( item->text( 3 ).isEmpty() ) 00135 item->setText( 3, i18n( "Encrypt" ) ); 00136 } 00137 } 00138 00139 /* 00140 * protected slot 00141 */ 00142 void CertificateHandlingDialogImpl::slotUseForSigning() 00143 { 00144 QListViewItem* item = certificatesLV->selectedItem(); 00145 Q_ASSERT( item ); 00146 if( item ) { 00147 // show the used certificate in label 00148 signCertLA->setText( item->text( 0 ) ); 00149 00150 // iterate over the listview and reset all usage markings 00151 QListViewItemIterator it( certificatesLV ); 00152 QListViewItem* current; 00153 while( ( current = it.current() ) ) { 00154 ++it; 00155 if( current->text( 3 ) == i18n( "Sign/Encrypt" ) ) 00156 current->setText( 3, i18n( "Encrypt" ) ); 00157 else if( current->text( 3 ) == i18n( "Sign" ) ) 00158 current->setText( 3, "" ); 00159 } 00160 00161 // mark the current one as used 00162 if( item->text( 3 ) == i18n( "Encrypt" ) ) 00163 item->setText( 3, i18n( "Sign/Encrypt" ) ); 00164 else if( item->text( 3 ).isEmpty() ) 00165 item->setText( 3, i18n( "Sign" ) ); 00166 } 00167 } 00168 00169 00170 #include "certificatehandlingdialogimpl.moc"
KDE Logo
This file is part of the documentation for kmail Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:56 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003