00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifdef HAVE_CONFIG_H
00033 #include <config.h>
00034 #endif
00035
00036 #include "identitydialog.h"
00037
00038
00039 #include "signatureconfigurator.h"
00040 #include "xfaceconfigurator.h"
00041 #include "folderrequester.h"
00042 using KMail::FolderRequester;
00043 #include "kmfoldermgr.h"
00044 #include "transportmanager.h"
00045 #include "dictionarycombobox.h"
00046 #include "kleo_util.h"
00047 #include "kmmainwidget.h"
00048 #include "kmfolder.h"
00049
00050
00051
00052 #include <libkpimidentities/identity.h>
00053 #include <libkdepim/addresseelineedit.h>
00054
00055 #include <ui/keyrequester.h>
00056 #include <kleo/cryptobackendfactory.h>
00057
00058 #include <libemailfunctions/email.h>
00059
00060
00061 #include <klocale.h>
00062 #include <kmessagebox.h>
00063 #include <kconfig.h>
00064 #include <kfileitem.h>
00065 #include <kurl.h>
00066 #include <kdebug.h>
00067
00068
00069 #include <qtabwidget.h>
00070 #include <qlabel.h>
00071 #include <qwhatsthis.h>
00072 #include <qlayout.h>
00073 #include <qpushbutton.h>
00074 #include <qcheckbox.h>
00075 #include <qcombobox.h>
00076
00077
00078 #include <gpgmepp/key.h>
00079 #include <iterator>
00080 #include <algorithm>
00081
00082 using namespace KPIM;
00083
00084 namespace KMail {
00085
00086 IdentityDialog::IdentityDialog( QWidget * parent, const char * name )
00087 : KDialogBase( Plain, i18n("Edit Identity"), Ok|Cancel|Help, Ok,
00088 parent, name )
00089 {
00090
00091 QWidget * tab;
00092 QLabel * label;
00093 int row;
00094 QGridLayout * glay;
00095 QString msg;
00096
00097
00098
00099
00100 row = -1;
00101 QVBoxLayout * vlay = new QVBoxLayout( plainPage(), 0, spacingHint() );
00102 QTabWidget *tabWidget = new QTabWidget( plainPage(), "config-identity-tab" );
00103 vlay->addWidget( tabWidget );
00104
00105 tab = new QWidget( tabWidget );
00106 tabWidget->addTab( tab, i18n("&General") );
00107 glay = new QGridLayout( tab, 4, 2, marginHint(), spacingHint() );
00108 glay->setRowStretch( 3, 1 );
00109 glay->setColStretch( 1, 1 );
00110
00111
00112 ++row;
00113 mNameEdit = new KLineEdit( tab );
00114 glay->addWidget( mNameEdit, row, 1 );
00115 label = new QLabel( mNameEdit, i18n("&Your name:"), tab );
00116 glay->addWidget( label, row, 0 );
00117 msg = i18n("<qt><h3>Your name</h3>"
00118 "<p>This field should contain your name as you would like "
00119 "it to appear in the email header that is sent out;</p>"
00120 "<p>if you leave this blank your real name will not "
00121 "appear, only the email address.</p></qt>");
00122 QWhatsThis::add( label, msg );
00123 QWhatsThis::add( mNameEdit, msg );
00124
00125
00126 ++row;
00127 mOrganizationEdit = new KLineEdit( tab );
00128 glay->addWidget( mOrganizationEdit, row, 1 );
00129 label = new QLabel( mOrganizationEdit, i18n("Organi&zation:"), tab );
00130 glay->addWidget( label, row, 0 );
00131 msg = i18n("<qt><h3>Organization</h3>"
00132 "<p>This field should have the name of your organization "
00133 "if you'd like it to be shown in the email header that "
00134 "is sent out.</p>"
00135 "<p>It is safe (and normal) to leave this blank.</p></qt>");
00136 QWhatsThis::add( label, msg );
00137 QWhatsThis::add( mOrganizationEdit, msg );
00138
00139
00140
00141 ++row;
00142 mEmailEdit = new KLineEdit( tab );
00143 glay->addWidget( mEmailEdit, row, 1 );
00144 label = new QLabel( mEmailEdit, i18n("&Email address:"), tab );
00145 glay->addWidget( label, row, 0 );
00146 msg = i18n("<qt><h3>Email address</h3>"
00147 "<p>This field should have your full email address.</p>"
00148 "<p>If you leave this blank, or get it wrong, people "
00149 "will have trouble replying to you.</p></qt>");
00150 QWhatsThis::add( label, msg );
00151 QWhatsThis::add( mEmailEdit, msg );
00152
00153
00154
00155
00156 row = -1;
00157 mCryptographyTab = tab = new QWidget( tabWidget );
00158 tabWidget->addTab( tab, i18n("Cryptograph&y") );
00159 glay = new QGridLayout( tab, 6, 2, marginHint(), spacingHint() );
00160 glay->setColStretch( 1, 1 );
00161
00162
00163 ++row;
00164 mPGPSigningKeyRequester = new Kleo::SigningKeyRequester( false, Kleo::SigningKeyRequester::OpenPGP, tab );
00165 mPGPSigningKeyRequester->dialogButton()->setText( i18n("Chang&e...") );
00166 mPGPSigningKeyRequester->setDialogCaption( i18n("Your OpenPGP Signature Key") );
00167 msg = i18n("Select the OpenPGP key which should be used to "
00168 "digitally sign your messages.");
00169 mPGPSigningKeyRequester->setDialogMessage( msg );
00170
00171 msg = i18n("<qt><p>The OpenPGP key you choose here will be used "
00172 "to digitally sign messages. You can also use GnuPG keys.</p>"
00173 "<p>You can leave this blank, but KMail will not be able "
00174 "to digitally sign emails using OpenPGP; "
00175 "normal mail functions will not be affected.</p>"
00176 "<p>You can find out more about keys at <a>http://www.gnupg.org</a></p></qt>");
00177
00178 label = new QLabel( mPGPSigningKeyRequester, i18n("OpenPGP signing key:"), tab );
00179 QWhatsThis::add( mPGPSigningKeyRequester, msg );
00180 QWhatsThis::add( label, msg );
00181
00182 glay->addWidget( label, row, 0 );
00183 glay->addWidget( mPGPSigningKeyRequester, row, 1 );
00184
00185
00186
00187 ++row;
00188 mPGPEncryptionKeyRequester = new Kleo::EncryptionKeyRequester( false, Kleo::EncryptionKeyRequester::OpenPGP, tab );
00189 mPGPEncryptionKeyRequester->dialogButton()->setText( i18n("Chang&e...") );
00190 mPGPEncryptionKeyRequester->setDialogCaption( i18n("Your OpenPGP Encryption Key") );
00191 msg = i18n("Select the OpenPGP key which should be used when encrypting "
00192 "to yourself and for the \"Attach My Public Key\" "
00193 "feature in the composer.");
00194 mPGPEncryptionKeyRequester->setDialogMessage( msg );
00195
00196 msg = i18n("<qt><p>The OpenPGP key you choose here will be used "
00197 "to encrypt messages to yourself and for the \"Attach My Public Key\" "
00198 "feature in the composer. You can also use GnuPG keys.</p>"
00199 "<p>You can leave this blank, but KMail will not be able "
00200 "to encrypt copies of outgoing messages to you using OpenPGP; "
00201 "normal mail functions will not be affected.</p>"
00202 "<p>You can find out more about keys at <a>http://www.gnupg.org</a></qt>");
00203 label = new QLabel( mPGPEncryptionKeyRequester, i18n("OpenPGP encryption key:"), tab );
00204 QWhatsThis::add( mPGPEncryptionKeyRequester, msg );
00205 QWhatsThis::add( label, msg );
00206
00207 glay->addWidget( label, row, 0 );
00208 glay->addWidget( mPGPEncryptionKeyRequester, row, 1 );
00209
00210
00211
00212 ++row;
00213 mSMIMESigningKeyRequester = new Kleo::SigningKeyRequester( false, Kleo::SigningKeyRequester::SMIME, tab );
00214 mSMIMESigningKeyRequester->dialogButton()->setText( i18n("Chang&e...") );
00215 mSMIMESigningKeyRequester->setDialogCaption( i18n("Your S/MIME Signature Certificate") );
00216 msg = i18n("Select the S/MIME certificate which should be used to "
00217 "digitally sign your messages.");
00218 mSMIMESigningKeyRequester->setDialogMessage( msg );
00219
00220 msg = i18n("<qt><p>The S/MIME (X.509) certificate you choose here will be used "
00221 "to digitally sign messages.</p>"
00222 "<p>You can leave this blank, but KMail will not be able "
00223 "to digitally sign emails using S/MIME; "
00224 "normal mail functions will not be affected.</p></qt>");
00225 label = new QLabel( mSMIMESigningKeyRequester, i18n("S/MIME signing certificate:"), tab );
00226 QWhatsThis::add( mSMIMESigningKeyRequester, msg );
00227 QWhatsThis::add( label, msg );
00228 glay->addWidget( label, row, 0 );
00229 glay->addWidget( mSMIMESigningKeyRequester, row, 1 );
00230
00231 const Kleo::CryptoBackend::Protocol * smimeProtocol
00232 = Kleo::CryptoBackendFactory::instance()->smime();
00233
00234 label->setEnabled( smimeProtocol );
00235 mSMIMESigningKeyRequester->setEnabled( smimeProtocol );
00236
00237
00238 ++row;
00239 mSMIMEEncryptionKeyRequester = new Kleo::EncryptionKeyRequester( false, Kleo::EncryptionKeyRequester::SMIME, tab );
00240 mSMIMEEncryptionKeyRequester->dialogButton()->setText( i18n("Chang&e...") );
00241 mSMIMEEncryptionKeyRequester->setDialogCaption( i18n("Your S/MIME Encryption Certificate") );
00242 msg = i18n("Select the S/MIME certificate which should be used when encrypting "
00243 "to yourself and for the \"Attach My Certificate\" "
00244 "feature in the composer.");
00245 mSMIMEEncryptionKeyRequester->setDialogMessage( msg );
00246
00247 msg = i18n("<qt><p>The S/MIME certificate you choose here will be used "
00248 "to encrypt messages to yourself and for the \"Attach My Certificate\" "
00249 "feature in the composer.</p>"
00250 "<p>You can leave this blank, but KMail will not be able "
00251 "to encrypt copies of outgoing messages to you using S/MIME; "
00252 "normal mail functions will not be affected.</p></qt>");
00253 label = new QLabel( mSMIMEEncryptionKeyRequester, i18n("S/MIME encryption certificate:"), tab );
00254 QWhatsThis::add( mSMIMEEncryptionKeyRequester, msg );
00255 QWhatsThis::add( label, msg );
00256
00257 glay->addWidget( label, row, 0 );
00258 glay->addWidget( mSMIMEEncryptionKeyRequester, row, 1 );
00259
00260 label->setEnabled( smimeProtocol );
00261 mSMIMEEncryptionKeyRequester->setEnabled( smimeProtocol );
00262
00263
00264 ++row;
00265 mPreferredCryptoMessageFormat = new QComboBox( false, tab );
00266 QStringList l;
00267 l << Kleo::cryptoMessageFormatToLabel( Kleo::AutoFormat )
00268 << Kleo::cryptoMessageFormatToLabel( Kleo::InlineOpenPGPFormat )
00269 << Kleo::cryptoMessageFormatToLabel( Kleo::OpenPGPMIMEFormat )
00270 << Kleo::cryptoMessageFormatToLabel( Kleo::SMIMEFormat )
00271 << Kleo::cryptoMessageFormatToLabel( Kleo::SMIMEOpaqueFormat );
00272 mPreferredCryptoMessageFormat->insertStringList( l );
00273 label = new QLabel( mPreferredCryptoMessageFormat,
00274 i18n("Preferred crypto message format:"), tab );
00275
00276 glay->addWidget( label, row, 0 );
00277 glay->addWidget( mPreferredCryptoMessageFormat, row, 1 );
00278
00279 ++row;
00280 glay->setRowStretch( row, 1 );
00281
00282
00283
00284
00285 row = -1;
00286 tab = new QWidget( tabWidget );
00287 tabWidget->addTab( tab, i18n("&Advanced") );
00288 glay = new QGridLayout( tab, 7, 2, marginHint(), spacingHint() );
00289
00290 glay->setRowStretch( 7-1, 1 );
00291 glay->setColStretch( 1, 1 );
00292
00293
00294 ++row;
00295 mReplyToEdit = new KPIM::AddresseeLineEdit( tab, true, "mReplyToEdit" );
00296 glay->addWidget( mReplyToEdit, row, 1 );
00297 label = new QLabel ( mReplyToEdit, i18n("&Reply-To address:"), tab);
00298 glay->addWidget( label , row, 0 );
00299 msg = i18n("<qt><h3>Reply-To addresses</h3>"
00300 "<p>This sets the <tt>Reply-to:</tt> header to contain a "
00301 "different email address to the normal <tt>From:</tt> "
00302 "address.</p>"
00303 "<p>This can be useful when you have a group of people "
00304 "working together in similar roles. For example, you "
00305 "might want any emails sent to have your email in the "
00306 "<tt>From:</tt> field, but any responses to go to "
00307 "a group address.</p>"
00308 "<p>If in doubt, leave this field blank.</p></qt>");
00309 QWhatsThis::add( label, msg );
00310 QWhatsThis::add( mReplyToEdit, msg );
00311
00312
00313 ++row;
00314 mBccEdit = new KPIM::AddresseeLineEdit( tab, true, "mBccEdit" );
00315 glay->addWidget( mBccEdit, row, 1 );
00316 label = new QLabel( mBccEdit, i18n("&BCC addresses:"), tab );
00317 glay->addWidget( label, row, 0 );
00318 msg = i18n("<qt><h3>BCC (Blind Carbon Copy) addresses</h3>"
00319 "<p>The addresses that you enter here will be added to each "
00320 "outgoing mail that is sent with this identity. They will not "
00321 "be visible to other recipients.</p>"
00322 "<p>This is commonly used to send a copy of each sent message to "
00323 "another account of yours.</p>"
00324 "<p>To specify more than one address, use commas to separate "
00325 "the list of BCC recipients.</p>"
00326 "<p>If in doubt, leave this field blank.</p></qt>");
00327 QWhatsThis::add( label, msg );
00328 QWhatsThis::add( mBccEdit, msg );
00329
00330
00331 ++row;
00332 mDictionaryCombo = new DictionaryComboBox( tab );
00333 glay->addWidget( mDictionaryCombo, row, 1 );
00334 glay->addWidget( new QLabel( mDictionaryCombo, i18n("D&ictionary:"), tab ),
00335 row, 0 );
00336
00337
00338 ++row;
00339 mFccCombo = new FolderRequester( tab,
00340 kmkernel->getKMMainWidget()->folderTree() );
00341 mFccCombo->setShowOutbox( false );
00342 glay->addWidget( mFccCombo, row, 1 );
00343 glay->addWidget( new QLabel( mFccCombo, i18n("Sent-mail &folder:"), tab ),
00344 row, 0 );
00345
00346
00347 ++row;
00348 mDraftsCombo = new FolderRequester( tab,
00349 kmkernel->getKMMainWidget()->folderTree() );
00350 mDraftsCombo->setShowOutbox( false );
00351 glay->addWidget( mDraftsCombo, row, 1 );
00352 glay->addWidget( new QLabel( mDraftsCombo, i18n("&Drafts folder:"), tab ),
00353 row, 0 );
00354
00355
00356 ++row;
00357 mTransportCheck = new QCheckBox( i18n("Special &transport:"), tab );
00358 glay->addWidget( mTransportCheck, row, 0 );
00359 mTransportCombo = new QComboBox( true, tab );
00360 mTransportCombo->setEnabled( false );
00361 mTransportCombo->insertStringList( KMail::TransportManager::transportNames() );
00362 glay->addWidget( mTransportCombo, row, 1 );
00363 connect( mTransportCheck, SIGNAL(toggled(bool)),
00364 mTransportCombo, SLOT(setEnabled(bool)) );
00365
00366
00367
00368
00369
00370
00371 mSignatureConfigurator = new SignatureConfigurator( tabWidget );
00372 mSignatureConfigurator->layout()->setMargin( KDialog::marginHint() );
00373 tabWidget->addTab( mSignatureConfigurator, i18n("&Signature") );
00374
00375 mXFaceConfigurator = new XFaceConfigurator( tabWidget );
00376 mXFaceConfigurator->layout()->setMargin( KDialog::marginHint() );
00377 tabWidget->addTab( mXFaceConfigurator, i18n("&Picture") );
00378
00379 KConfigGroup geometry( KMKernel::config(), "Geometry" );
00380 if ( geometry.hasKey( "Identity Dialog size" ) )
00381 resize( geometry.readSizeEntry( "Identity Dialog size" ) );
00382 mNameEdit->setFocus();
00383
00384 connect( tabWidget, SIGNAL(currentChanged(QWidget*)),
00385 SLOT(slotAboutToShow(QWidget*)) );
00386 }
00387
00388 IdentityDialog::~IdentityDialog() {
00389 KConfigGroup geometry( KMKernel::config(), "Geometry" );
00390 geometry.writeEntry( "Identity Dialog size", size() );
00391 }
00392
00393 void IdentityDialog::slotAboutToShow( QWidget * w ) {
00394 if ( w == mCryptographyTab ) {
00395
00396
00397 const QString email = mEmailEdit->text().stripWhiteSpace();
00398 mPGPEncryptionKeyRequester->setInitialQuery( email );
00399 mPGPSigningKeyRequester->setInitialQuery( email );
00400 mSMIMEEncryptionKeyRequester->setInitialQuery( email );
00401 mSMIMESigningKeyRequester->setInitialQuery( email );
00402 }
00403 }
00404
00405 namespace {
00406 struct DoesntMatchEMailAddress {
00407 explicit DoesntMatchEMailAddress( const QString & s )
00408 : email( s.stripWhiteSpace().lower() ) {}
00409 bool operator()( const GpgME::Key & key ) const;
00410 private:
00411 bool checkForEmail( const char * email ) const;
00412 static QString extractEmail( const char * email );
00413 const QString email;
00414 };
00415
00416 bool DoesntMatchEMailAddress::operator()( const GpgME::Key & key ) const {
00417 const std::vector<GpgME::UserID> uids = key.userIDs();
00418 for ( std::vector<GpgME::UserID>::const_iterator it = uids.begin() ; it != uids.end() ; ++it )
00419 if ( checkForEmail( it->email() ? it->email() : it->id() ) )
00420 return false;
00421 return true;
00422 }
00423
00424 bool DoesntMatchEMailAddress::checkForEmail( const char * e ) const {
00425 const QString em = extractEmail( e );
00426 return !em.isEmpty() && email == em;
00427 }
00428
00429 QString DoesntMatchEMailAddress::extractEmail( const char * e ) {
00430 if ( !e || !*e )
00431 return QString::null;
00432 const QString em = QString::fromUtf8( e );
00433 if ( e[0] == '<' )
00434 return em.mid( 1, em.length() - 2 );
00435 else
00436 return em;
00437 }
00438 }
00439
00440 bool IdentityDialog::validateAddresses( const QString & addresses )
00441 {
00442 QString brokenAddress;
00443 KPIM::EmailParseResult errorCode = KMMessage::isValidEmailAddressList( KMMessage::expandAliases( addresses ), brokenAddress );
00444 if ( !( errorCode == KPIM::AddressOk || errorCode == KPIM::AddressEmpty ) ) {
00445 QString errorMsg( "<qt><p><b>" + brokenAddress +
00446 "</b></p><p>" + KPIM::emailParseResultToString( errorCode ) +
00447 "</p></qt>" );
00448 KMessageBox::sorry( this, errorMsg, i18n("Invalid Email Address") );
00449 return false;
00450 }
00451 return true;
00452 }
00453
00454 void IdentityDialog::slotOk() {
00455 const QString email = mEmailEdit->text().stripWhiteSpace();
00456
00457
00458 if ( !isValidSimpleEmailAddress( email )) {
00459 QString errorMsg( simpleEmailAddressErrorMsg());
00460 KMessageBox::sorry( this, errorMsg, i18n("Invalid Email Address") );
00461 return;
00462 }
00463
00464 if ( !validateAddresses( mReplyToEdit->text().stripWhiteSpace() ) ) {
00465 return;
00466 }
00467
00468 if ( !validateAddresses( mBccEdit->text().stripWhiteSpace() ) ) {
00469 return;
00470 }
00471
00472 const std::vector<GpgME::Key> & pgpSigningKeys = mPGPSigningKeyRequester->keys();
00473 const std::vector<GpgME::Key> & pgpEncryptionKeys = mPGPEncryptionKeyRequester->keys();
00474 const std::vector<GpgME::Key> & smimeSigningKeys = mSMIMESigningKeyRequester->keys();
00475 const std::vector<GpgME::Key> & smimeEncryptionKeys = mSMIMEEncryptionKeyRequester->keys();
00476 QString msg;
00477 bool err = false;
00478 if ( std::find_if( pgpSigningKeys.begin(), pgpSigningKeys.end(),
00479 DoesntMatchEMailAddress( email ) ) != pgpSigningKeys.end() ) {
00480 msg = i18n("One of the configured OpenPGP signing keys does not contain "
00481 "any user ID with the configured email address for this "
00482 "identity (%1).\n"
00483 "This might result in warning messages on the receiving side "
00484 "when trying to verify signatures made with this configuration.");
00485 err = true;
00486 }
00487 else if ( std::find_if( pgpEncryptionKeys.begin(), pgpEncryptionKeys.end(),
00488 DoesntMatchEMailAddress( email ) ) != pgpEncryptionKeys.end() ) {
00489 msg = i18n("One of the configured OpenPGP encryption keys does not contain "
00490 "any user ID with the configured email address for this "
00491 "identity (%1).");
00492 err = true;
00493 }
00494 else if ( std::find_if( smimeSigningKeys.begin(), smimeSigningKeys.end(),
00495 DoesntMatchEMailAddress( email ) ) != smimeSigningKeys.end() ) {
00496 msg = i18n("One of the configured S/MIME signing certificates does not contain "
00497 "the configured email address for this "
00498 "identity (%1).\n"
00499 "This might result in warning messages on the receiving side "
00500 "when trying to verify signatures made with this configuration.");
00501 err = true;
00502 }
00503 else if ( std::find_if( smimeEncryptionKeys.begin(), smimeEncryptionKeys.end(),
00504 DoesntMatchEMailAddress( email ) ) != smimeEncryptionKeys.end() ) {
00505 msg = i18n("One of the configured S/MIME encryption certificates does not contain "
00506 "the configured email address for this "
00507 "identity (%1).");
00508 err = true;
00509 }
00510
00511 if ( err )
00512 if ( KMessageBox::warningContinueCancel( this, msg.arg( email ),
00513 i18n("Email Address Not Found in Key/Certificates"),
00514 KStdGuiItem::cont(), "warn_email_not_in_certificate" )
00515 != KMessageBox::Continue)
00516 return;
00517
00518
00519 if ( mSignatureConfigurator->isSignatureEnabled() &&
00520 mSignatureConfigurator->signatureType()==Signature::FromFile ) {
00521 KURL url( mSignatureConfigurator->fileURL() );
00522 KFileItem signatureFile( KFileItem::Unknown, KFileItem::Unknown, url );
00523 if ( !signatureFile.isFile() || !signatureFile.isReadable() || !signatureFile.isLocalFile() ) {
00524 KMessageBox::error( this, i18n( "The signature file is not valid" ) );
00525 return;
00526 }
00527 }
00528
00529 return KDialogBase::slotOk();
00530 }
00531
00532 bool IdentityDialog::checkFolderExists( const QString & folderID,
00533 const QString & msg ) {
00534 KMFolder * folder = kmkernel->findFolderById( folderID );
00535 if ( !folder ) {
00536 KMessageBox::sorry( this, msg );
00537 return false;
00538 }
00539 return true;
00540 }
00541
00542 void IdentityDialog::setIdentity( KPIM::Identity & ident ) {
00543
00544 setCaption( i18n("Edit Identity \"%1\"").arg( ident.identityName() ) );
00545
00546
00547 mNameEdit->setText( ident.fullName() );
00548 mOrganizationEdit->setText( ident.organization() );
00549 mEmailEdit->setText( ident.emailAddr() );
00550
00551
00552 mPGPSigningKeyRequester->setFingerprint( ident.pgpSigningKey() );
00553 mPGPEncryptionKeyRequester->setFingerprint( ident.pgpEncryptionKey() );
00554 mSMIMESigningKeyRequester->setFingerprint( ident.smimeSigningKey() );
00555 mSMIMEEncryptionKeyRequester->setFingerprint( ident.smimeEncryptionKey() );
00556 mPreferredCryptoMessageFormat->setCurrentItem( format2cb( ident.preferredCryptoMessageFormat() ) );
00557
00558
00559 mReplyToEdit->setText( ident.replyToAddr() );
00560 mBccEdit->setText( ident.bcc() );
00561 mTransportCheck->setChecked( !ident.transport().isEmpty() );
00562 mTransportCombo->setEditText( ident.transport() );
00563 mTransportCombo->setEnabled( !ident.transport().isEmpty() );
00564 mDictionaryCombo->setCurrentByDictionary( ident.dictionary() );
00565
00566 if ( ident.fcc().isEmpty() ||
00567 !checkFolderExists( ident.fcc(),
00568 i18n("The custom sent-mail folder for identity "
00569 "\"%1\" does not exist (anymore); "
00570 "therefore, the default sent-mail folder "
00571 "will be used.")
00572 .arg( ident.identityName() ) ) )
00573 mFccCombo->setFolder( kmkernel->sentFolder() );
00574 else
00575 mFccCombo->setFolder( ident.fcc() );
00576
00577 if ( ident.drafts().isEmpty() ||
00578 !checkFolderExists( ident.drafts(),
00579 i18n("The custom drafts folder for identity "
00580 "\"%1\" does not exist (anymore); "
00581 "therefore, the default drafts folder "
00582 "will be used.")
00583 .arg( ident.identityName() ) ) )
00584 mDraftsCombo->setFolder( kmkernel->draftsFolder() );
00585 else
00586 mDraftsCombo->setFolder( ident.drafts() );
00587
00588
00589 mSignatureConfigurator->setSignature( ident.signature() );
00590 mXFaceConfigurator->setXFace( ident.xface() );
00591 mXFaceConfigurator->setXFaceEnabled( ident.isXFaceEnabled() );
00592 }
00593
00594 void IdentityDialog::updateIdentity( KPIM::Identity & ident ) {
00595
00596 ident.setFullName( mNameEdit->text() );
00597 ident.setOrganization( mOrganizationEdit->text() );
00598 QString email = mEmailEdit->text();
00599 ident.setEmailAddr( email );
00600
00601 ident.setPGPSigningKey( mPGPSigningKeyRequester->fingerprint().latin1() );
00602 ident.setPGPEncryptionKey( mPGPEncryptionKeyRequester->fingerprint().latin1() );
00603 ident.setSMIMESigningKey( mSMIMESigningKeyRequester->fingerprint().latin1() );
00604 ident.setSMIMEEncryptionKey( mSMIMEEncryptionKeyRequester->fingerprint().latin1() );
00605 ident.setPreferredCryptoMessageFormat( cb2format( mPreferredCryptoMessageFormat->currentItem() ) );
00606
00607 ident.setReplyToAddr( mReplyToEdit->text() );
00608 ident.setBcc( mBccEdit->text() );
00609 ident.setTransport( ( mTransportCheck->isChecked() ) ?
00610 mTransportCombo->currentText() : QString::null );
00611 ident.setDictionary( mDictionaryCombo->currentDictionary() );
00612 ident.setFcc( mFccCombo->folder() ?
00613 mFccCombo->folder()->idString() : QString::null );
00614 ident.setDrafts( mDraftsCombo->folder() ?
00615 mDraftsCombo->folder()->idString() : QString::null );
00616
00617 ident.setSignature( mSignatureConfigurator->signature() );
00618 ident.setXFace( mXFaceConfigurator->xface() );
00619 ident.setXFaceEnabled( mXFaceConfigurator->isXFaceEnabled() );
00620 }
00621
00622 void IdentityDialog::slotUpdateTransportCombo( const QStringList & sl ) {
00623
00624 QString content = mTransportCombo->currentText();
00625
00626 mTransportCombo->clear();
00627 mTransportCombo->insertStringList( sl );
00628
00629 mTransportCombo->setEditText( content );
00630 }
00631
00632 }
00633
00634 #include "identitydialog.moc"