37 #include "messagecomposer/settings/messagecomposersettings.h"
39 #include <kpimidentities/identitymanager.h>
42 #ifndef KDEPIM_MOBILE_UI
45 #include "pimcommon/widgets/simplestringlisteditor.h"
46 #include "folderrequester.h"
47 #ifndef KCM_KPIMIDENTITIES_STANDALONE
52 #include "kernel/mailkernel.h"
55 #include "kleo_util.h"
56 #include "utils/stringutil.h"
57 #ifndef KDEPIM_MOBILE_UI
58 #include "templatesconfiguration.h"
60 #include "templatesconfiguration_kfg.h"
62 #include <kpimidentities/identity.h>
63 #include <kpimidentities/signatureconfigurator.h>
65 #include "pimcommon/autocorrection/autocorrectionlanguage.h"
69 #include "libkleo/ui/keyrequester.h"
70 #include "kleo/cryptobackendfactory.h"
72 #include <kpimutils/email.h>
73 #include <kpimutils/emailvalidator.h>
74 #include <mailtransport/transport.h>
75 #include <mailtransport/transportmanager.h>
76 #include <mailtransport/transportcombobox.h>
77 using MailTransport::TransportManager;
81 #include <kmessagebox.h>
82 #include <kfileitem.h>
85 #include <kpushbutton.h>
86 #include <kcombobox.h>
87 #include <ktabwidget.h>
88 #include <KStandardDirs>
90 #include <sonnet/dictionarycombobox.h>
95 #include <QVBoxLayout>
96 #include <QGridLayout>
99 #include <QToolButton>
102 #include <gpgme++/key.h>
106 #include <akonadi/entitydisplayattribute.h>
107 #include <akonadi/collectionmodifyjob.h>
110 using namespace KPIM;
111 using namespace MailTransport;
112 using namespace MailCommon;
116 IdentityDialog::IdentityDialog(
QWidget * parent )
119 setCaption( i18n(
"Edit Identity") );
120 #ifndef KDEPIM_MOBILE_UI
121 setButtons( Ok|Cancel|Help );
123 setButtons( Ok|Cancel );
125 setDefaultButton( Ok );
139 setMainWidget( page );
143 mTabWidget =
new KTabWidget( page );
144 mTabWidget->setObjectName(
QLatin1String(
"config-identity-tab") );
147 tab =
new QWidget( mTabWidget );
148 mTabWidget->addTab( tab, i18nc(
"@title:tab General identity settings.",
"General") );
159 label =
new QLabel( i18n(
"&Your name:"), tab );
162 msg = i18n(
"<qt><h3>Your name</h3>"
163 "<p>This field should contain your name as you would like "
164 "it to appear in the email header that is sent out;</p>"
165 "<p>if you leave this blank your real name will not "
166 "appear, only the email address.</p></qt>");
168 mNameEdit->setWhatsThis( msg );
172 mOrganizationEdit =
new KLineEdit( tab );
173 glay->
addWidget( mOrganizationEdit, row, 1 );
174 label =
new QLabel( i18n(
"Organi&zation:"), tab );
175 label->
setBuddy( mOrganizationEdit );
177 msg = i18n(
"<qt><h3>Organization</h3>"
178 "<p>This field should have the name of your organization "
179 "if you would like it to be shown in the email header that "
181 "<p>It is safe (and normal) to leave this blank.</p></qt>");
183 mOrganizationEdit->setWhatsThis( msg );
190 label =
new QLabel( i18n(
"&Email address:"), tab );
193 msg = i18n(
"<qt><h3>Email address</h3>"
194 "<p>This field should have your full email address.</p>"
195 "<p>This address is the primary one, used for all outgoing mail. "
196 "If you have more than one address, either create a new identity, "
197 "or add additional alias addresses in the field below.</p>"
198 "<p>If you leave this blank, or get it wrong, people "
199 "will have trouble replying to you.</p></qt>");
201 mEmailEdit->setWhatsThis( msg );
203 KPIMUtils::EmailValidator* emailValidator =
new KPIMUtils::EmailValidator(
this );
204 mEmailEdit->setValidator( emailValidator );
208 mAliasEdit =
new PimCommon::SimpleStringListEditor( tab );
210 label =
new QLabel( i18n(
"Email a&liases:"), tab );
212 glay->
addWidget( label, row, 0, Qt::AlignTop );
213 msg = i18n(
"<qt><h3>Email aliases</h3>"
214 "<p>This field contains alias addresses that should also "
215 "be considered as belonging to this identity (as opposed "
216 "to representing a different identity).</p>"
219 "<tr><th>Primary address:</th><td>first.last@example.org</td></tr>"
220 "<tr><th>Aliases:</th><td>first@example.org<br>last@example.org</td></tr>"
222 "<p>Type one alias address per line.</p></qt>");
224 mAliasEdit->setWhatsThis( msg );
230 mCryptographyTab = tab =
new QWidget( mTabWidget );
231 mTabWidget->addTab( tab, i18n(
"Cryptography") );
239 mPGPSigningKeyRequester =
new Kleo::SigningKeyRequester(
false, Kleo::SigningKeyRequester::OpenPGP, tab );
240 mPGPSigningKeyRequester->dialogButton()->setText( i18n(
"Chang&e...") );
241 mPGPSigningKeyRequester->setDialogCaption( i18n(
"Your OpenPGP Signature Key") );
242 msg = i18n(
"Select the OpenPGP key which should be used to "
243 "digitally sign your messages.");
244 mPGPSigningKeyRequester->setDialogMessage( msg );
246 msg = i18n(
"<qt><p>The OpenPGP key you choose here will be used "
247 "to digitally sign messages. You can also use GnuPG keys.</p>"
248 "<p>You can leave this blank, but KMail will not be able "
249 "to digitally sign emails using OpenPGP; "
250 "normal mail functions will not be affected.</p>"
251 "<p>You can find out more about keys at <a>http://www.gnupg.org</a></p></qt>");
253 label =
new QLabel( i18n(
"OpenPGP signing key:"), tab );
254 label->
setBuddy( mPGPSigningKeyRequester );
255 mPGPSigningKeyRequester->setWhatsThis( msg );
259 glay->
addWidget( mPGPSigningKeyRequester, row, 1 );
264 mPGPEncryptionKeyRequester =
new Kleo::EncryptionKeyRequester(
false, Kleo::EncryptionKeyRequester::OpenPGP, tab );
265 mPGPEncryptionKeyRequester->dialogButton()->setText( i18n(
"Chang&e...") );
266 mPGPEncryptionKeyRequester->setDialogCaption( i18n(
"Your OpenPGP Encryption Key") );
267 msg = i18n(
"Select the OpenPGP key which should be used when encrypting "
268 "to yourself and for the \"Attach My Public Key\" "
269 "feature in the composer.");
270 mPGPEncryptionKeyRequester->setDialogMessage( msg );
272 msg = i18n(
"<qt><p>The OpenPGP key you choose here will be used "
273 "to encrypt messages to yourself and for the \"Attach My Public Key\" "
274 "feature in the composer. You can also use GnuPG keys.</p>"
275 "<p>You can leave this blank, but KMail will not be able "
276 "to encrypt copies of outgoing messages to you using OpenPGP; "
277 "normal mail functions will not be affected.</p>"
278 "<p>You can find out more about keys at <a>http://www.gnupg.org</a></p></qt>");
279 label =
new QLabel( i18n(
"OpenPGP encryption key:"), tab );
280 label->
setBuddy( mPGPEncryptionKeyRequester );
281 mPGPEncryptionKeyRequester->setWhatsThis( msg );
285 glay->
addWidget( mPGPEncryptionKeyRequester, row, 1 );
290 mSMIMESigningKeyRequester =
new Kleo::SigningKeyRequester(
false, Kleo::SigningKeyRequester::SMIME, tab );
291 mSMIMESigningKeyRequester->dialogButton()->setText( i18n(
"Chang&e...") );
292 mSMIMESigningKeyRequester->setDialogCaption( i18n(
"Your S/MIME Signature Certificate") );
293 msg = i18n(
"Select the S/MIME certificate which should be used to "
294 "digitally sign your messages.");
295 mSMIMESigningKeyRequester->setDialogMessage( msg );
297 msg = i18n(
"<qt><p>The S/MIME (X.509) certificate you choose here will be used "
298 "to digitally sign messages.</p>"
299 "<p>You can leave this blank, but KMail will not be able "
300 "to digitally sign emails using S/MIME; "
301 "normal mail functions will not be affected.</p></qt>");
302 label =
new QLabel( i18n(
"S/MIME signing certificate:"), tab );
303 label->
setBuddy( mSMIMESigningKeyRequester );
304 mSMIMESigningKeyRequester->setWhatsThis( msg );
307 glay->
addWidget( mSMIMESigningKeyRequester, row, 1 );
309 const Kleo::CryptoBackend::Protocol * smimeProtocol
310 = Kleo::CryptoBackendFactory::instance()->smime();
313 mSMIMESigningKeyRequester->setEnabled( smimeProtocol );
317 mSMIMEEncryptionKeyRequester =
new Kleo::EncryptionKeyRequester(
false, Kleo::EncryptionKeyRequester::SMIME, tab );
318 mSMIMEEncryptionKeyRequester->dialogButton()->setText( i18n(
"Chang&e...") );
319 mSMIMEEncryptionKeyRequester->setDialogCaption( i18n(
"Your S/MIME Encryption Certificate") );
320 msg = i18n(
"Select the S/MIME certificate which should be used when encrypting "
321 "to yourself and for the \"Attach My Certificate\" "
322 "feature in the composer.");
323 mSMIMEEncryptionKeyRequester->setDialogMessage( msg );
325 msg = i18n(
"<qt><p>The S/MIME certificate you choose here will be used "
326 "to encrypt messages to yourself and for the \"Attach My Certificate\" "
327 "feature in the composer.</p>"
328 "<p>You can leave this blank, but KMail will not be able "
329 "to encrypt copies of outgoing messages to you using S/MIME; "
330 "normal mail functions will not be affected.</p></qt>");
331 label =
new QLabel( i18n(
"S/MIME encryption certificate:"), tab );
332 label->
setBuddy( mSMIMEEncryptionKeyRequester );
333 mSMIMEEncryptionKeyRequester->setWhatsThis( msg );
337 glay->
addWidget( mSMIMEEncryptionKeyRequester, row, 1 );
340 mSMIMEEncryptionKeyRequester->setEnabled( smimeProtocol );
344 mPreferredCryptoMessageFormat =
new KComboBox( tab );
345 mPreferredCryptoMessageFormat->setEditable(
false );
347 l << Kleo::cryptoMessageFormatToLabel( Kleo::AutoFormat )
348 << Kleo::cryptoMessageFormatToLabel( Kleo::InlineOpenPGPFormat )
349 << Kleo::cryptoMessageFormatToLabel( Kleo::OpenPGPMIMEFormat )
350 << Kleo::cryptoMessageFormatToLabel( Kleo::SMIMEFormat )
351 << Kleo::cryptoMessageFormatToLabel( Kleo::SMIMEOpaqueFormat );
352 mPreferredCryptoMessageFormat->addItems( l );
353 label =
new QLabel( i18nc(
"preferred format of encrypted messages",
"Preferred format:"), tab );
354 label->
setBuddy( mPreferredCryptoMessageFormat );
357 glay->
addWidget( mPreferredCryptoMessageFormat, row, 1 );
361 mAutoSign =
new QCheckBox(i18n(
"Automatically sign messages"));
371 tab =
new QWidget( mTabWidget );
372 mTabWidget->addTab( tab, i18nc(
"@title:tab Advanced identity settings.",
"Advanced") );
382 mReplyToEdit->setClearButtonShown(
true);
383 mReplyToEdit->setObjectName(
QLatin1String(
"mReplyToEdit") );
385 label =
new QLabel ( i18n(
"&Reply-To address:"), tab );
388 msg = i18n(
"<qt><h3>Reply-To addresses</h3>"
389 "<p>This sets the <tt>Reply-to:</tt> header to contain a "
390 "different email address to the normal <tt>From:</tt> "
392 "<p>This can be useful when you have a group of people "
393 "working together in similar roles. For example, you "
394 "might want any emails sent to have your email in the "
395 "<tt>From:</tt> field, but any responses to go to "
396 "a group address.</p>"
397 "<p>If in doubt, leave this field blank.</p></qt>");
399 mReplyToEdit->setWhatsThis( msg );
406 mCcEdit->setClearButtonShown(
true);
409 label =
new QLabel( i18n(
"&CC addresses:"), tab );
412 msg = i18n(
"<qt><h3>CC (Carbon Copy) addresses</h3>"
413 "<p>The addresses that you enter here will be added to each "
414 "outgoing mail that is sent with this identity.</p>"
415 "<p>This is commonly used to send a copy of each sent message to "
416 "another account of yours.</p>"
417 "<p>To specify more than one address, use commas to separate "
418 "the list of CC recipients.</p>"
419 "<p>If in doubt, leave this field blank.</p></qt>");
421 mCcEdit->setWhatsThis( msg );
427 mBccEdit->setClearButtonShown(
true);
430 label =
new QLabel( i18n(
"&BCC addresses:"), tab );
433 msg = i18n(
"<qt><h3>BCC (Blind Carbon Copy) addresses</h3>"
434 "<p>The addresses that you enter here will be added to each "
435 "outgoing mail that is sent with this identity. They will not "
436 "be visible to other recipients.</p>"
437 "<p>This is commonly used to send a copy of each sent message to "
438 "another account of yours.</p>"
439 "<p>To specify more than one address, use commas to separate "
440 "the list of BCC recipients.</p>"
441 "<p>If in doubt, leave this field blank.</p></qt>");
443 mBccEdit->setWhatsThis( msg );
447 mDictionaryCombo =
new Sonnet::DictionaryComboBox( tab );
448 glay->
addWidget( mDictionaryCombo, row, 1 );
449 label =
new QLabel( i18n(
"D&ictionary:"), tab );
450 label->
setBuddy( mDictionaryCombo );
455 mFccCombo =
new FolderRequester( tab );
456 mFccCombo->setShowOutbox(
false );
458 mSentMailFolderCheck =
new QCheckBox( i18n(
"Sent-mail &folder:"), tab );
459 glay->
addWidget( mSentMailFolderCheck, row, 0 );
460 connect(mSentMailFolderCheck,SIGNAL(toggled(
bool)),mFccCombo,SLOT(setEnabled(
bool)));
464 mDraftsCombo =
new FolderRequester( tab );
465 mDraftsCombo->setShowOutbox(
false );
467 label =
new QLabel( i18n(
"&Drafts folder:"), tab );
473 mTemplatesCombo =
new FolderRequester( tab );
474 mTemplatesCombo->setShowOutbox(
false );
475 glay->
addWidget( mTemplatesCombo, row, 1 );
476 label =
new QLabel( i18n(
"&Templates folder:"), tab );
482 mTransportCheck =
new QCheckBox( i18n(
"Outgoing Account:"), tab );
483 glay->
addWidget( mTransportCheck, row, 0 );
484 mTransportCombo =
new TransportComboBox( tab );
485 mTransportCombo->setEnabled(
false );
486 glay->
addWidget( mTransportCombo, row, 1 );
487 connect( mTransportCheck, SIGNAL(toggled(
bool)),
488 mTransportCombo, SLOT(setEnabled(
bool)) );
491 mAttachMyVCard =
new QCheckBox(i18n(
"Attach my vCard to message"), tab);
492 glay->
addWidget( mAttachMyVCard, row, 0 );
493 mEditVCard =
new KPushButton(i18n(
"Create..."),tab);
494 connect(mEditVCard,SIGNAL(clicked()),SLOT(slotEditVcard()));
499 mAutoCorrectionLanguage =
new PimCommon::AutoCorrectionLanguage(tab);
500 glay->
addWidget( mAutoCorrectionLanguage, row, 1 );
501 label =
new QLabel( i18n(
"Autocorrection language:"), tab );
502 label->
setBuddy( mAutoCorrectionLanguage );
508 mDefaultDomainEdit =
new KLineEdit( tab );
509 mDefaultDomainEdit->setClearButtonShown(
true);
513 restoreDefaultDomainName->
setToolTip(i18n(
"Restore default domain name"));
514 hbox->
addWidget(restoreDefaultDomainName);
515 connect(restoreDefaultDomainName, SIGNAL(clicked()),
this, SLOT(slotRefreshDefaultDomainName()));
517 label =
new QLabel( i18n(
"Defaul&t domain:"), tab );
518 label->
setBuddy( mDefaultDomainEdit );
522 msg = i18n(
"<qt><p>The default domain is used to complete email "
523 "addresses that only consist of the user's name."
526 mDefaultDomainEdit->setWhatsThis( msg );
537 tab =
new QWidget( mTabWidget );
545 mCustom =
new QCheckBox( i18n(
"&Use custom message templates for this identity"), tab );
546 tlay->
addWidget( mCustom, Qt::AlignLeft );
548 #ifndef KDEPIM_MOBILE_UI
549 mWidget =
new TemplateParser::TemplatesConfiguration( tab,
QLatin1String(
"identity-templates") );
550 mWidget->setEnabled(
false );
555 tlay->
addWidget( mWidget->helpLabel(), Qt::AlignRight );
562 mCopyGlobal =
new KPushButton( i18n(
"&Copy Global Templates"), tab );
563 mCopyGlobal->setEnabled(
false );
566 #ifndef KDEPIM_MOBILE_UI
567 connect( mCustom, SIGNAL(toggled(
bool)),
568 mWidget, SLOT(setEnabled(
bool)) );
570 connect( mCustom, SIGNAL(toggled(
bool)),
571 mCopyGlobal, SLOT(setEnabled(
bool)) );
572 connect( mCopyGlobal, SIGNAL(clicked()),
574 #ifdef KDEPIM_MOBILE_UI
577 mTabWidget->addTab( tab, i18n(
"Templates") );
583 mSignatureConfigurator =
new KPIMIdentities::SignatureConfigurator( mTabWidget );
584 mSignatureConfigurator->layout()->setMargin( KDialog::marginHint() );
585 mTabWidget->addTab( mSignatureConfigurator, i18n(
"Signature") );
591 #ifndef KDEPIM_MOBILE_UI
594 mTabWidget->addTab( mXFaceConfigurator, i18n(
"Picture") );
597 #ifndef KCM_KPIMIDENTITIES_STANDALONE
600 mNameEdit->setFocus();
602 connect( mTabWidget, SIGNAL(currentChanged(
int)),
608 #ifndef KCM_KPIMIDENTITIES_STANDALONE
614 QWidget *w = mTabWidget->widget( index );
615 if ( w == mCryptographyTab ) {
619 mPGPEncryptionKeyRequester->setInitialQuery( email );
620 mPGPSigningKeyRequester->setInitialQuery( email );
621 mSMIMEEncryptionKeyRequester->setInitialQuery( email );
622 mSMIMESigningKeyRequester->setInitialQuery( email );
627 #ifndef KDEPIM_MOBILE_UI
628 mWidget->loadFromGlobal();
633 struct DoesntMatchEMailAddress {
634 explicit DoesntMatchEMailAddress(
const QString & s )
635 :
email( s.trimmed().toLower() ) {}
636 bool operator()(
const GpgME::Key & key )
const;
638 bool checkForEmail(
const char *
email )
const;
643 bool DoesntMatchEMailAddress::operator()(
const GpgME::Key & key )
const {
644 const std::vector<GpgME::UserID> uids = key.userIDs();
645 std::vector<GpgME::UserID>::const_iterator end = uids.
end();
646 for ( std::vector<GpgME::UserID>::const_iterator it = uids.begin() ; it != end ; ++it )
647 if ( checkForEmail( it->email() ? it->email() : it->id() ) )
652 bool DoesntMatchEMailAddress::checkForEmail(
const char * e )
const {
653 const QString em = extractEmail( e );
657 QString DoesntMatchEMailAddress::extractEmail(
const char * e ) {
668 void IdentityDialog::slotRefreshDefaultDomainName()
675 if ( button != KDialog::Ok ) {
676 KDialog::slotButtonClicked( button );
680 const QStringList aliases = mAliasEdit->stringList();
681 foreach (
const QString &alias, aliases ) {
682 if ( !KPIMUtils::isValidSimpleAddress( alias ) ) {
683 const QString errorMsg( KPIMUtils::simpleEmailAddressErrorMsg() );
684 KMessageBox::sorry(
this, errorMsg, i18n(
"Invalid Email Alias \"%1\"", alias ) );
691 if ( !KPIMUtils::isValidSimpleAddress( email ) ) {
692 const QString errorMsg( KPIMUtils::simpleEmailAddressErrorMsg() );
693 KMessageBox::sorry(
this, errorMsg, i18n(
"Invalid Email Address") );
698 const QString recipients = mReplyToEdit->text().trimmed() +
QLatin1String(
", " ) + mBccEdit->text().trimmed() +
QLatin1String(
", " ) + mCcEdit->text().trimmed();
702 job->setProperty(
"email", email );
703 connect( job, SIGNAL(result(
KJob*)), SLOT(slotDelayedButtonClicked(
KJob*)) );
707 void IdentityDialog::slotDelayedButtonClicked(
KJob *job )
712 if ( !validationJob->
isValid() )
715 const QString email = validationJob->property(
"email" ).toString();
717 const std::vector<GpgME::Key> &pgpSigningKeys =
718 mPGPSigningKeyRequester->keys();
719 const std::vector<GpgME::Key> &pgpEncryptionKeys =
720 mPGPEncryptionKeyRequester->keys();
721 const std::vector<GpgME::Key> &smimeSigningKeys =
722 mSMIMESigningKeyRequester->keys();
723 const std::vector<GpgME::Key> &smimeEncryptionKeys =
724 mSMIMEEncryptionKeyRequester->keys();
728 if ( std::find_if( pgpSigningKeys.begin(), pgpSigningKeys.end(),
729 DoesntMatchEMailAddress( email ) ) != pgpSigningKeys.end() ) {
730 msg = i18n(
"One of the configured OpenPGP signing keys does not contain "
731 "any user ID with the configured email address for this "
733 "This might result in warning messages on the receiving side "
734 "when trying to verify signatures made with this configuration.", email);
736 }
else if ( std::find_if( pgpEncryptionKeys.begin(), pgpEncryptionKeys.end(),
737 DoesntMatchEMailAddress( email ) ) != pgpEncryptionKeys.end() ) {
738 msg = i18n(
"One of the configured OpenPGP encryption keys does not contain "
739 "any user ID with the configured email address for this "
740 "identity (%1).", email);
742 }
else if ( std::find_if( smimeSigningKeys.begin(), smimeSigningKeys.end(),
743 DoesntMatchEMailAddress( email ) ) != smimeSigningKeys.end() ) {
744 msg = i18n(
"One of the configured S/MIME signing certificates does not contain "
745 "the configured email address for this "
747 "This might result in warning messages on the receiving side "
748 "when trying to verify signatures made with this configuration.", email);
750 }
else if ( std::find_if( smimeEncryptionKeys.begin(), smimeEncryptionKeys.end(),
751 DoesntMatchEMailAddress( email ) ) != smimeEncryptionKeys.end() ) {
752 msg = i18n(
"One of the configured S/MIME encryption certificates does not contain "
753 "the configured email address for this "
754 "identity (%1).", email);
759 if ( KMessageBox::warningContinueCancel(
this, msg,
760 i18n(
"Email Address Not Found in Key/Certificates"),
761 KStandardGuiItem::cont(),
762 KStandardGuiItem::cancel(),
764 != KMessageBox::Continue) {
770 if ( mSignatureConfigurator->isSignatureEnabled() &&
771 mSignatureConfigurator->signatureType()==Signature::FromFile ) {
772 KUrl url( mSignatureConfigurator->fileURL() );
773 KFileItem signatureFile( KFileItem::Unknown, KFileItem::Unknown, url );
774 if ( !signatureFile.isFile() || !signatureFile.isReadable() || !signatureFile.isLocalFile() ) {
775 KMessageBox::error(
this, i18n(
"The signature file is not valid" ) );
783 bool IdentityDialog::checkFolderExists(
const QString & folderID,
786 const Akonadi::Collection folder = CommonKernel->collectionFromId( folderID.
toLongLong() );
787 if ( !folder.isValid() ) {
788 KMessageBox::sorry(
this, msg );
797 setCaption( i18n(
"Edit Identity \"%1\"", ident.identityName() ) );
800 mNameEdit->setText( ident.fullName() );
801 mOrganizationEdit->setText( ident.organization() );
802 mEmailEdit->setText( ident.primaryEmailAddress() );
803 mAliasEdit->setStringList( ident.emailAliases() );
806 mPGPSigningKeyRequester->setFingerprint(
QLatin1String(ident.pgpSigningKey()) );
807 mPGPEncryptionKeyRequester->setFingerprint(
QLatin1String(ident.pgpEncryptionKey()) );
808 mSMIMESigningKeyRequester->setFingerprint(
QLatin1String(ident.smimeSigningKey()) );
809 mSMIMEEncryptionKeyRequester->setFingerprint(
QLatin1String(ident.smimeEncryptionKey()) );
811 mPreferredCryptoMessageFormat->setCurrentIndex( format2cb(
812 Kleo::stringToCryptoMessageFormat( ident.preferredCryptoMessageFormat() ) ) );
816 mReplyToEdit->setText( ident.replyToAddr() );
817 mBccEdit->setText( ident.bcc() );
818 mCcEdit->setText( ident.cc() );
819 const int transportId = ident.transport().isEmpty() ? -1 : ident.transport().toInt();
820 const Transport *transport = TransportManager::self()->transportById( transportId,
true );
821 mTransportCheck->
setChecked( transportId != -1 );
822 mTransportCombo->setEnabled( transportId != -1 );
824 mTransportCombo->setCurrentTransport( transport->id() );
825 mDictionaryCombo->setCurrentByDictionaryName( ident.dictionary() );
827 mSentMailFolderCheck->
setChecked(!ident.disabledFcc());
828 mFccCombo->setEnabled(mSentMailFolderCheck->
isChecked());
829 if ( ident.fcc().isEmpty() ||
830 !checkFolderExists( ident.fcc(),
831 i18n(
"The custom sent-mail folder for identity "
832 "\"%1\" does not exist (anymore); "
833 "therefore, the default sent-mail folder "
835 ident.identityName() ) ) ) {
836 mFccCombo->setCollection( CommonKernel->sentCollectionFolder() );
839 mFccCombo->setCollection( Akonadi::Collection( ident.fcc().toLongLong() ) );
841 if ( ident.drafts().isEmpty() ||
842 !checkFolderExists( ident.drafts(),
843 i18n(
"The custom drafts folder for identity "
844 "\"%1\" does not exist (anymore); "
845 "therefore, the default drafts folder "
847 ident.identityName() ) ) ) {
848 mDraftsCombo->setCollection( CommonKernel->draftsCollectionFolder() );
851 mDraftsCombo->setCollection( Akonadi::Collection( ident.drafts().toLongLong() ) );
853 if ( ident.templates().isEmpty() ||
854 !checkFolderExists( ident.templates(),
855 i18n(
"The custom templates folder for identity "
856 "\"%1\" does not exist (anymore); "
857 "therefore, the default templates folder "
858 "will be used.", ident.identityName()) ) ) {
859 mTemplatesCombo->setCollection( CommonKernel->templatesCollectionFolder() );
863 mTemplatesCombo->setCollection( Akonadi::Collection( ident.templates().toLongLong() ) );
865 mVcardFilename = ident.vCardFile();
867 mAutoCorrectionLanguage->setLanguage(ident.autocorrectionLanguage());
870 mVcardFilename = KStandardDirs::locateLocal(
"appdata",ident.identityName() +
QLatin1String(
".vcf"));
872 mAttachMyVCard->
setChecked(ident.attachVcard());
873 QString defaultDomainName = ident.defaultDomainName();
874 if (defaultDomainName.
isEmpty()) {
877 mDefaultDomainEdit->setText(defaultDomainName);
880 #ifndef KDEPIM_MOBILE_UI
881 uint identity = ident.uoid();
882 QString iid = TemplateParser::TemplatesConfiguration::configIdString( identity );
883 TemplateParser::Templates t( iid );
885 mWidget->loadFromIdentity( identity );
889 mSignatureConfigurator->setImageLocation( ident );
890 mSignatureConfigurator->setSignature( ident.signature() );
891 #ifndef KDEPIM_MOBILE_UI
892 mXFaceConfigurator->
setXFace( ident.xface() );
899 ident.setFullName( mNameEdit->text() );
900 ident.setOrganization( mOrganizationEdit->text() );
901 QString email = mEmailEdit->text();
902 ident.setPrimaryEmailAddress( email );
903 ident.setEmailAliases( mAliasEdit->stringList() );
905 ident.setPGPSigningKey( mPGPSigningKeyRequester->fingerprint().toLatin1() );
906 ident.setPGPEncryptionKey( mPGPEncryptionKeyRequester->fingerprint().toLatin1() );
907 ident.setSMIMESigningKey( mSMIMESigningKeyRequester->fingerprint().toLatin1() );
908 ident.setSMIMEEncryptionKey( mSMIMEEncryptionKeyRequester->fingerprint().toLatin1() );
909 ident.setPreferredCryptoMessageFormat(
910 QLatin1String(Kleo::cryptoMessageFormatToString(cb2format( mPreferredCryptoMessageFormat->currentIndex() ) )) );
911 ident.setPgpAutoSign(mAutoSign->
isChecked());
913 ident.setReplyToAddr( mReplyToEdit->text() );
914 ident.setBcc( mBccEdit->text() );
915 ident.setCc( mCcEdit->text() );
918 ident.setDictionary( mDictionaryCombo->currentDictionaryName() );
919 ident.setDisabledFcc( !mSentMailFolderCheck->
isChecked() );
920 Akonadi::Collection collection = mFccCombo->collection();
921 if ( collection.isValid() ) {
923 Akonadi::EntityDisplayAttribute *attribute = collection.attribute<Akonadi::EntityDisplayAttribute>( Akonadi::Entity::AddIfMissing );
924 attribute->setIconName(
QLatin1String(
"mail-folder-sent" ) );
925 new Akonadi::CollectionModifyJob( collection );
930 collection = mDraftsCombo->collection();
931 if ( collection.isValid() ) {
933 Akonadi::EntityDisplayAttribute *attribute = collection.attribute<Akonadi::EntityDisplayAttribute>( Akonadi::Entity::AddIfMissing );
934 attribute->setIconName(
QLatin1String(
"document-properties" ) );
935 new Akonadi::CollectionModifyJob( collection );
940 collection = mTemplatesCombo->collection();
941 if ( collection.isValid() ) {
943 Akonadi::EntityDisplayAttribute *attribute = collection.attribute<Akonadi::EntityDisplayAttribute>( Akonadi::Entity::AddIfMissing );
945 new Akonadi::CollectionModifyJob( collection );
948 ident.setTemplates(
QString() );
949 ident.setVCardFile(mVcardFilename);
950 ident.setAutocorrectionLanguage(mAutoCorrectionLanguage->language());
952 ident.setAttachVcard(mAttachMyVCard->
isChecked());
954 ident.setDefaultDomainName(mDefaultDomainEdit->text());
957 #ifndef KDEPIM_MOBILE_UI
958 uint identity = ident.uoid();
959 QString iid = TemplateParser::TemplatesConfiguration::configIdString( identity );
960 TemplateParser::Templates t( iid );
961 kDebug() <<
"use custom templates for identity" << identity <<
":" << mCustom->
isChecked();
962 t.setUseCustomTemplates(mCustom->
isChecked());
964 mWidget->saveToIdentity( identity );
968 ident.setSignature( mSignatureConfigurator->signature() );
969 #ifndef KDEPIM_MOBILE_UI
970 ident.setXFace( mXFaceConfigurator->
xface() );
975 void IdentityDialog::slotEditVcard()
977 if(
QFile(mVcardFilename).exists()) {
978 editVcard(mVcardFilename);
980 if ( !MailCommon::Kernel::self()->kernelIsRegistered() ) {
983 KPIMIdentities::IdentityManager *manager = KernelIf->identityManager();
990 editVcard(mVcardFilename);
994 KPIMIdentities::Identity ident = manager->modifyIdentityForName( dlg->duplicateVcardFromIdentity() );
995 const QString filename = ident.vCardFile();
999 editVcard(mVcardFilename);
1003 const QString filename = dlg->existingVCard().path();
1005 mVcardFilename = filename;
1007 editVcard(mVcardFilename);
1016 void IdentityDialog::editVcard(
const QString &filename)
1019 connect(dlg, SIGNAL(vcardRemoved()), SLOT(slotVCardRemoved()));
1021 mVcardFilename = dlg->saveVcard();
1023 updateVcardButton();
1027 void IdentityDialog::slotVCardRemoved()
1029 mVcardFilename.
clear();
1032 void IdentityDialog::updateVcardButton()
1035 mEditVCard->setText(i18n(
"Create..."));
1037 mEditVCard->setText(i18n(
"Edit..."));
void updateIdentity(KPIMIdentities::Identity &ident)
void slotAboutToShow(int)
void setDefaultDomain(const QString &domainName)
void setXFaceEnabled(bool enable)
void setXFace(const QString &text)
bool copy(const QString &newName)
void setSpacing(int spacing)
void setBuddy(QWidget *buddy)
QString number(int n, int base)
QString fromUtf8(const char *str, int size)
void setRowStretch(int row, int stretch)
bool isXFaceEnabled() const
void slotButtonClicked(int button)
void setMargin(int margin)
void addLayout(QLayout *layout, int row, int column, QFlags< Qt::AlignmentFlag > alignment)
static GlobalSettings * self()
QString mid(int position, int n) const
void addStretch(int stretch)
void setColumnStretch(int column, int stretch)
qlonglong toLongLong(bool *ok, int base) const
void setSpacing(int spacing)
void addLayout(QLayout *layout, int stretch)
void setIdentity(KPIMIdentities::Identity &ident)