[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Patch to associate a PGP key with an identity instead of globally.
From:       Steven Brown <swbrown () ucsd ! edu>
Date:       2001-03-01 8:48:41
[Download RAW message or body]

I reported it as a wishlist item but then decided it'd be easy enough to do 
right now so here's a patch. :>

Kmail has facilities for handling separate identities, but applies the same
PGP key for signing/encryption to each.  This patch changes things so the
PGP key to use is specified in the identity, not globally configured.  I
left KpgpBase's loading + saving of the old 'user' setting in the code as
I'm not sure if it affects any apps other than kmail (since it saves to
kpgprc).  It should probably be removed.

["kmail-pgp-identity.patch" (text/plain)]

Kmail has facilities for handling separate identities, but applies the same
PGP key for signing/encryption to each.  This patch changes things so the
PGP key to use is specified in the identity, not globally configured.  I
left KpgpBase's loading + saving of the old 'user' setting in the code as
I'm not sure if it affects any apps other than kmail (since it saves to
kpgprc).  It should probably be removed.

- Steven Brown <swbrown@ucsd.edu>


diff -cr kmail/configuredialog.cpp newkmail/configuredialog.cpp
*** kmail/configuredialog.cpp	Thu Mar  1 00:32:22 2001
--- newkmail/configuredialog.cpp	Thu Mar  1 00:07:16 2001
***************
*** 567,581 ****
    mIdentity.organizationEdit = new QLineEdit( page );
    glay->addMultiCellWidget( mIdentity.organizationEdit, 3, 3, 1, 2 );
  
!   label = new QLabel( i18n("Email Address:"), page );
    glay->addWidget( label, 4, 0 );
    mIdentity.emailEdit = new QLineEdit( page );
!   glay->addMultiCellWidget( mIdentity.emailEdit, 4, 4, 1, 2 );
  
    label = new QLabel( i18n("Reply-To Address:"), page );
!   glay->addWidget( label, 5, 0 );
    mIdentity.replytoEdit = new QLineEdit( page );
!   glay->addMultiCellWidget( mIdentity.replytoEdit, 5, 5, 1, 2 );
  
    QButtonGroup *buttonGroup = new QButtonGroup( page );
    connect( buttonGroup, SIGNAL(clicked(int)),
--- 567,586 ----
    mIdentity.organizationEdit = new QLineEdit( page );
    glay->addMultiCellWidget( mIdentity.organizationEdit, 3, 3, 1, 2 );
  
!   label = new QLabel( i18n("PGP User Identity:"),page );
    glay->addWidget( label, 4, 0 );
+   mIdentity.pgpIdentityEdit = new QLineEdit( page );
+   glay->addMultiCellWidget( mIdentity.pgpIdentityEdit, 4, 4, 1, 2 );
+ 
+   label = new QLabel( i18n("Email Address:"), page );
+   glay->addWidget( label, 5, 0 );
    mIdentity.emailEdit = new QLineEdit( page );
!   glay->addMultiCellWidget( mIdentity.emailEdit, 5, 5, 1, 2 );
  
    label = new QLabel( i18n("Reply-To Address:"), page );
!   glay->addWidget( label, 6, 0 );
    mIdentity.replytoEdit = new QLineEdit( page );
!   glay->addMultiCellWidget( mIdentity.replytoEdit, 6, 6, 1, 2 );
  
    QButtonGroup *buttonGroup = new QButtonGroup( page );
    connect( buttonGroup, SIGNAL(clicked(int)),
***************
*** 2112,2117 ****
--- 2117,2123 ----
    {
      entry->setFullName( mIdentity.nameEdit->text() );
      entry->setOrganization( mIdentity.organizationEdit->text() );
+     entry->setPgpIdentity( mIdentity.pgpIdentityEdit->text() );
      entry->setEmailAddress( mIdentity.emailEdit->text() );
      entry->setReplyToAddress( mIdentity.replytoEdit->text() );
      entry->setSignatureFileName( mIdentity.signatureFileEdit->text() );
***************
*** 2146,2151 ****
--- 2152,2158 ----
    {
      mIdentity.nameEdit->setText("");
      mIdentity.organizationEdit->setText("");
+     mIdentity.pgpIdentityEdit->setText("");
      mIdentity.emailEdit->setText("");
      mIdentity.replytoEdit->setText("");
      mIdentity.signatureFileEdit->setText("");
***************
*** 2157,2162 ****
--- 2164,2170 ----
    {
      mIdentity.nameEdit->setText( entry->fullName() );
      mIdentity.organizationEdit->setText( entry->organization() );
+     mIdentity.pgpIdentityEdit->setText( entry->pgpIdentity() );
      mIdentity.emailEdit->setText( entry->emailAddress() );
      mIdentity.replytoEdit->setText( entry->replyToAddress() );
      mIdentity.signatureFileEdit->setText( entry->signatureFileName() );
***************
*** 3115,3120 ****
--- 3123,3133 ----
    return( mOrganization );
  }
  
+ QString IdentityEntry::pgpIdentity() const
+ {
+   return( mPgpIdentity );
+ }
+ 
  QString IdentityEntry::emailAddress() const
  {
    return( mEmailAddress );
***************
*** 3171,3176 ****
--- 3184,3194 ----
    mOrganization = organization;
  }
  
+ void IdentityEntry::setPgpIdentity( const QString &pgpIdentity )
+ {
+   mPgpIdentity = pgpIdentity;
+ }
+ 
  void IdentityEntry::setEmailAddress( const QString &emailAddress )
  {
    mEmailAddress = emailAddress;
***************
*** 3282,3287 ****
--- 3300,3306 ----
      entry.setIdentity( ident.identity() );
      entry.setFullName( ident.fullName() );
      entry.setOrganization( ident.organization() );
+     entry.setPgpIdentity( ident.pgpIdentity() );
      entry.setEmailAddress( ident.emailAddr() );
      entry.setReplyToAddress( ident.replyToAddr() );
      entry.setSignatureFileName( ident.signatureFile(), true );
***************
*** 3300,3305 ****
--- 3319,3325 ----
      KMIdentity ident( e->identity() );
      ident.setFullName( e->fullName() );
      ident.setOrganization( e->organization() );
+     ident.setPgpIdentity( e->pgpIdentity() );
      ident.setEmailAddr( e->emailAddress() );
      ident.setReplyToAddr( e->replyToAddress() );
      ident.setUseSignatureFile( e->useSignatureFile() );
diff -cr kmail/configuredialog.h newkmail/configuredialog.h
*** kmail/configuredialog.h	Thu Mar  1 00:32:22 2001
--- newkmail/configuredialog.h	Thu Mar  1 00:07:16 2001
***************
*** 110,115 ****
--- 110,116 ----
      QString identity() const;
      QString fullName() const;
      QString organization() const;
+     QString pgpIdentity() const;
      QString emailAddress() const;
      QString replyToAddress() const;
      QString signatureFileName( bool exportIdentity = false ) const;
***************
*** 120,125 ****
--- 121,127 ----
      void setIdentity( const QString &identity );
      void setFullName( const QString &fullName );
      void setOrganization( const QString &organization );
+     void setPgpIdentity( const QString &pgpIdentity );
      void setEmailAddress( const QString &emailAddress );
      void setReplyToAddress( const QString &replytoAddress );
      void setSignatureFileName( const QString &signatureFileName,
***************
*** 132,137 ****
--- 134,140 ----
      QString mIdentity;
      QString mFullName;
      QString mOrganization;
+     QString mPgpIdentity;
      QString mEmailAddress;
      QString mReplytoAddress;
      QString mSignatureFileName;
***************
*** 244,249 ****
--- 247,253 ----
        QPushButton    *renameIdentityButton;
        QLineEdit      *nameEdit;
        QLineEdit      *organizationEdit;
+       QLineEdit      *pgpIdentityEdit;
        QLineEdit      *emailEdit;
        QLineEdit      *replytoEdit;
        QLineEdit      *signatureFileEdit;
diff -cr kmail/kmcomposewin.cpp newkmail/kmcomposewin.cpp
*** kmail/kmcomposewin.cpp	Thu Mar  1 00:32:22 2001
--- newkmail/kmcomposewin.cpp	Thu Mar  1 00:07:16 2001
***************
*** 2239,2244 ****
--- 2239,2245 ----
      mMsg->removeHeaderField("Organization");
    else
      mMsg->setHeaderField("Organization", ident.organization());
+   Kpgp::getKpgp()->setUser(ident.pgpIdentity());
  
    QString edtText = mEditor->text();
    int pos = edtText.findRev( "\n-- \n" + mOldSigText);
diff -cr kmail/kmidentity.cpp newkmail/kmidentity.cpp
*** kmail/kmidentity.cpp	Thu Mar  1 00:32:22 2001
--- newkmail/kmidentity.cpp	Thu Mar  1 00:07:16 2001
***************
*** 100,105 ****
--- 100,106 ----
  
    mVCardFile = config->readEntry("VCardFile");
    mOrganization = config->readEntry("Organization");
+   mPgpIdentity = config->readEntry("PGP Identity");
    mReplyToAddr = config->readEntry("Reply-To Address");
    mSignatureFile = config->readEntry("Signature File");
    mUseSignatureFile = config->readBoolEntry("UseSignatureFile", false);
***************
*** 120,125 ****
--- 121,127 ----
    config->writeEntry("Identity", mIdentity);
    config->writeEntry("Name", mFullName);
    config->writeEntry("Organization", mOrganization);
+   config->writeEntry("PGP Identity", mPgpIdentity);
    config->writeEntry("Email Address", mEmailAddr);
    config->writeEntry("Reply-To Address", mReplyToAddr);
    config->writeEntry("Signature File", mSignatureFile);
***************
*** 149,154 ****
--- 151,163 ----
  void KMIdentity::setOrganization(const QString str)
  {
    mOrganization = str.copy();
+ }
+ 
+ 
+ //-----------------------------------------------------------------------------
+ void KMIdentity::setPgpIdentity(const QString str)
+ {
+   mPgpIdentity = str.copy();
  }
  
  
diff -cr kmail/kmidentity.h newkmail/kmidentity.h
*** kmail/kmidentity.h	Thu Mar  1 00:32:22 2001
--- newkmail/kmidentity.h	Thu Mar  1 00:07:16 2001
***************
*** 43,48 ****
--- 43,52 ----
    /** The user's organization (optional) */
    const QString organization(void) const { return mOrganization; }
    virtual void setOrganization(const QString);
+  
+   /** The user's PGP identity */
+   const QString pgpIdentity(void) const { return mPgpIdentity; }
+   virtual void setPgpIdentity(const QString);
  
    /** email address (without the user name - only name@host) */
    const QString emailAddr(void) const { return mEmailAddr; }
***************
*** 80,86 ****
    virtual const QString signature(void) const;
  
  protected:
!   QString mIdentity, mFullName, mOrganization, mEmailAddr;
    QString mReplyToAddr, mSignatureFile;
    QString mSignatureInlineText;
    QString mVCardFile;
--- 84,90 ----
    virtual const QString signature(void) const;
  
  protected:
!   QString mIdentity, mFullName, mOrganization, mPgpIdentity, mEmailAddr;
    QString mReplyToAddr, mSignatureFile;
    QString mSignatureInlineText;
    QString mVCardFile;
diff -cr kmail/kpgp.cpp newkmail/kpgp.cpp
*** kmail/kpgp.cpp	Thu Mar  1 00:32:22 2001
--- newkmail/kpgp.cpp	Thu Mar  1 00:07:16 2001
***************
*** 1029,1045 ****
  	"are not encrypted by KMail."), group );
    glay->addWidget ( label, 1, 0 );
  
-   group = new QGroupBox( i18n("Identity"), this );
-   topLayout->addWidget( group );
-   glay = new QGridLayout( group, 2, 2,  KDialog::spacingHint() );
-   glay->addRowSpacing( 0, fontMetrics().lineSpacing() );
- 
-   label = new QLabel( i18n("PGP User Identity:"), group );
-   pgpUserEdit = new QLineEdit( group );
-   pgpUserEdit->setText( pgp->user() );
-   glay->addWidget( label, 1, 0 );
-   glay->addWidget( pgpUserEdit, 1, 1 );
- 
    group = new QGroupBox( i18n("Options"), this );
    topLayout->addWidget( group );
    QVBoxLayout *vlay = new QVBoxLayout( group, KDialog::spacingHint() );
--- 1029,1034 ----
***************
*** 1090,1096 ****
  KpgpConfig::setValues()
  {
    // set default values
-   pgpUserEdit->setText( pgp->user() );
    storePass->setChecked( pgp->storePassPhrase() );
    encToSelf->setChecked( pgp->encryptToSelf() );
    showCipherText->setChecked( pgp->showCipherText() );
--- 1079,1084 ----
***************
*** 1118,1124 ****
  void
  KpgpConfig::applySettings()
  {
-   pgp->setUser(pgpUserEdit->text());
    pgp->setStorePassPhrase(storePass->isChecked());
    pgp->setEncryptToSelf(encToSelf->isChecked());
    pgp->setShowCipherText(showCipherText->isChecked());
--- 1106,1111 ----
diff -cr kmail/kpgp.h newkmail/kpgp.h
*** kmail/kpgp.h	Thu Mar  1 00:32:22 2001
--- newkmail/kpgp.h	Thu Mar  1 00:07:16 2001
***************
*** 258,264 ****
  
    protected:
      Kpgp *pgp;
-     QLineEdit *pgpUserEdit;
      QCheckBox *storePass;
      QCheckBox *encToSelf;
      QCheckBox *showCipherText;
--- 258,263 ----

_______________________________________________
Kmail Developers mailing list
Kmail@master.kde.org
http://master.kde.org/mailman/listinfo/kmail


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic