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

List:       kde-pim
Subject:    [Kde-pim] [PATCH] split sign/encryption keys,
From:       Marc Mutz <marc () klaralvdalens-datakonsult ! se>
Date:       2004-05-30 12:17:30
Message-ID: 200405301417.32779.marc () klaralvdalens-datakonsult ! se
[Download RAW message or body]

Hi folks!

This comes from aegypten_branch, where the user can select separate sign and 
encryption keys (OpenPGP) and certificates (S/MIME) per identity.

Unfortunately, due to the move of KMIdentity to libkdepim, libkdepim now 
depends on libkleopatra in certmanager/, which depends on libkdenetwork (not 
only libgpgme++/qgpgme).

But that's ok for now. Possible solutions (after the merge, please ;) involve 
moving libkleo out of certmanager, making a libkpim_identity.la, adding 
custom entries to KPIM::Identity and re-adding KMIdentity as a local 
extension of that, which translates between the Kleo-enum and the resp. 
string representation, or any combination thereof.

Apart from adding the obvious four methods, it also deprecated the old 
(set)pgpIdentity(), as well as moving the opertor<</>>'s back to the global 
namespace, as is normal for overloaded operators (they don't get in the way 
of each other, since they are overloads of each other).

I expect this to go in today, so if you have any questions or comments, post 
them quickly or save your review resources for the big patch to be posted to 
kmail-devel@kde.org shortly :)

Marc

-- 
Marc Mutz -- marc@klaralvdalens-datakonsult.se, mutz@kde.org
Klarälvdalens Datakonsult AB, Platform-independent software solutions

["ae2-libkdepim-identity-split-enc-sign-keys.diff" (text/x-diff)]

? diff.diff
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdepim/libkdepim/Makefile.am,v
retrieving revision 1.43
diff -u -3 -p -r1.43 Makefile.am
--- Makefile.am	20 May 2004 14:26:56 -0000	1.43
+++ Makefile.am	30 May 2004 11:53:17 -0000
@@ -1,6 +1,6 @@
 SUBDIRS = cfgc interfaces tests
 
-INCLUDES = -I$(top_srcdir)/libkdepim $(all_includes)
+INCLUDES = -I$(top_srcdir)/libkdepim -I$(top_srcdir)/certmanager/lib $(all_includes)
 
 lib_LTLIBRARIES   = libkdepim.la
 libkdepim_la_SOURCES = \
@@ -34,7 +34,7 @@ MailTransportServiceIface_DIR = $(srcdir
 AddressBookServiceIface_DIR = $(srcdir)/interfaces
 
 libkdepim_la_LDFLAGS = $(all_libraries) -no-undefined -version-info 1:0:0
-libkdepim_la_LIBADD  = $(LIB_KIO) $(LIB_KABC) $(LIB_KDEUI) 
+libkdepim_la_LIBADD  = ../certmanager/lib/libkleopatra.la $(LIB_KIO) $(LIB_KABC) \
$(LIB_KDEUI)   #               $top_builddir)/libkdepim/resources/libkpimresources.la
 
 identitymanager_DCOPIDLNG = true
Index: identity.cpp
===================================================================
RCS file: /home/kde/kdepim/libkdepim/identity.cpp,v
retrieving revision 1.76
diff -u -3 -p -r1.76 identity.cpp
--- identity.cpp	15 May 2004 16:36:46 -0000	1.76
+++ identity.cpp	30 May 2004 11:53:17 -0000
@@ -210,13 +210,13 @@ void Signature::writeConfig( KConfigBase
   }
 }
 
-QDataStream & KPIM::operator<<( QDataStream & stream, const Signature & sig ) {
+QDataStream & operator<<( QDataStream & stream, const KPIM::Signature & sig ) {
   return stream << static_cast<Q_UINT8>(sig.mType)
 		<< sig.mUrl
 		<< sig.mText;
 }
 
-QDataStream & KPIM::operator>>( QDataStream & stream, Signature & sig ) {
+QDataStream & operator>>( QDataStream & stream, KPIM::Signature & sig ) {
     Q_UINT8 s;
     stream >> s
            >> sig.mUrl
@@ -232,8 +232,11 @@ bool Identity::isNull() const {
   return mIdentity.isNull() && mFullName.isNull() && mEmailAddr.isNull() &&
     mOrganization.isNull() && mReplyToAddr.isNull() && mBcc.isNull() &&
     mVCardFile.isNull() &&
-    mPgpIdentity.isNull() && mFcc.isNull() && mDrafts.isNull() &&
+    mFcc.isNull() && mDrafts.isNull() &&
+    mPGPEncryptionKey.isNull() && mPGPSigningKey.isNull() &&
+    mSMIMEEncryptionKey.isNull() && mSMIMESigningKey.isNull() &&
     mTransport.isNull() && mDictionary.isNull() &&
+    mPreferredCryptoMessageFormat == Kleo::AutoFormat &&
     mSignature.type() == Signature::Disabled;
 }
 
@@ -243,7 +246,12 @@ bool Identity::operator==( const Identit
       mEmailAddr == other.mEmailAddr && mOrganization == other.mOrganization &&
       mReplyToAddr == other.mReplyToAddr && mBcc == other.mBcc &&
       mVCardFile == other.mVCardFile &&
-      mPgpIdentity == other.mPgpIdentity && mFcc == other.mFcc &&
+      mFcc == other.mFcc &&
+      mPGPEncryptionKey == other.mPGPEncryptionKey &&
+      mPGPSigningKey == other.mPGPSigningKey &&
+      mSMIMEEncryptionKey == other.mSMIMEEncryptionKey &&
+      mSMIMESigningKey == other.mSMIMESigningKey &&
+      mPreferredCryptoMessageFormat == other.mPreferredCryptoMessageFormat &&
       mDrafts == other.mDrafts && mTransport == other.mTransport &&
       mDictionary == other.mDictionary && mSignature == other.mSignature;
 }
@@ -253,7 +261,8 @@ Identity::Identity( const QString & id, 
 			const QString & replyToAddr )
   : mUoid( 0 ), mIdentity( id ), mFullName( fullName ),
     mEmailAddr( emailAddr ), mOrganization( organization ),
-    mReplyToAddr( replyToAddr ), mIsDefault( false )
+    mReplyToAddr( replyToAddr ), mIsDefault( false ),
+    mPreferredCryptoMessageFormat( Kleo::AutoFormat )
 {
 
 }
@@ -272,7 +281,11 @@ void Identity::readConfig( const KConfig
   mEmailAddr = config->readEntry("Email Address");
   mVCardFile = config->readPathEntry("VCardFile");
   mOrganization = config->readEntry("Organization");
-  mPgpIdentity = config->readEntry("Default PGP Key").local8Bit();
+  mPGPSigningKey = config->readEntry("PGP Signing Key").latin1();
+  mPGPEncryptionKey = config->readEntry("PGP Encryption Key").latin1();
+  mSMIMESigningKey = config->readEntry("SMIME Signing Key").latin1();
+  mSMIMEEncryptionKey = config->readEntry("SMIME Encryption Key").latin1();
+  mPreferredCryptoMessageFormat = Kleo::stringToCryptoMessageFormat( \
config->readEntry("Preferred Crypto Message Format", "none" ) );  mReplyToAddr = \
config->readEntry("Reply-To Address");  mBcc = config->readEntry("Bcc");
   mFcc = config->readEntry("Fcc", "sent-mail");
@@ -297,7 +310,11 @@ void Identity::writeConfig( KConfigBase 
   config->writeEntry("Identity", mIdentity);
   config->writeEntry("Name", mFullName);
   config->writeEntry("Organization", mOrganization);
-  config->writeEntry("Default PGP Key", mPgpIdentity.data());
+  config->writeEntry("PGP Signing Key", mPGPSigningKey.data());
+  config->writeEntry("PGP Encryption Key", mPGPEncryptionKey.data());
+  config->writeEntry("SMIME Signing Key", mSMIMESigningKey.data());
+  config->writeEntry("SMIME Encryption Key", mSMIMEEncryptionKey.data());
+  config->writeEntry("Preferred Crypto Message Format", \
Kleo::cryptoMessageFormatToString( mPreferredCryptoMessageFormat ) );  \
config->writeEntry("Email Address", mEmailAddr);  config->writeEntry("Reply-To \
Address", mReplyToAddr);  config->writeEntry("Bcc", mBcc);
@@ -310,12 +327,15 @@ void Identity::writeConfig( KConfigBase 
   mSignature.writeConfig( config );
 }
 
-QDataStream & KPIM::operator<<( QDataStream & stream, const Identity & i ) {
+QDataStream & operator<<( QDataStream & stream, const KPIM::Identity & i ) {
   return stream << static_cast<Q_UINT32>(i.uoid())
 		<< i.identityName()
 		<< i.fullName()
 		<< i.organization()
-		<< i.pgpIdentity()
+		<< i.pgpSigningKey()
+		<< i.pgpEncryptionKey()
+		<< i.smimeSigningKey()
+		<< i.smimeEncryptionKey()
 		<< i.emailAddr()
 		<< i.replyToAddr()
 		<< i.bcc()
@@ -324,18 +344,21 @@ QDataStream & KPIM::operator<<( QDataStr
 		<< i.fcc()
 		<< i.drafts()
 		<< i.mSignature
-                << i.dictionary();
+                << i.dictionary()
+		<< QString( Kleo::cryptoMessageFormatToString( i.mPreferredCryptoMessageFormat ) \
);  }
 
-QDataStream & KPIM::operator>>( QDataStream & stream, Identity & i ) {
+QDataStream & operator>>( QDataStream & stream, KPIM::Identity & i ) {
   Q_UINT32 uoid;
-  stream >> uoid;
-  i.mUoid = uoid;
-  return stream
+  QString format;
+  stream        >> uoid
 		>> i.mIdentity
 		>> i.mFullName
 		>> i.mOrganization
-		>> i.mPgpIdentity
+		>> i.mPGPSigningKey
+		>> i.mPGPEncryptionKey
+		>> i.mSMIMESigningKey
+		>> i.mSMIMEEncryptionKey
 		>> i.mEmailAddr
 		>> i.mReplyToAddr
 		>> i.mBcc
@@ -344,7 +367,12 @@ QDataStream & KPIM::operator>>( QDataStr
 		>> i.mFcc
 		>> i.mDrafts
 		>> i.mSignature
-                >> i.mDictionary;
+                >> i.mDictionary
+		>> format;
+  i.mUoid = uoid;
+  i.mPreferredCryptoMessageFormat = Kleo::stringToCryptoMessageFormat( \
format.latin1() ); +
+  return stream;
 }
 
 //-----------------------------------------------------------------------------
@@ -374,13 +402,25 @@ void Identity::setOrganization(const QSt
   mOrganization = str;
 }
 
+void Identity::setPGPSigningKey(const QCString &str)
+{
+  mPGPSigningKey = str;
+}
 
-//-----------------------------------------------------------------------------
-void Identity::setPgpIdentity(const QCString &str)
+void Identity::setPGPEncryptionKey(const QCString &str)
 {
-  mPgpIdentity = str;
+  mPGPEncryptionKey = str;
 }
 
+void Identity::setSMIMESigningKey(const QCString &str)
+{
+  mSMIMESigningKey = str;
+}
+
+void Identity::setSMIMEEncryptionKey(const QCString &str)
+{
+  mSMIMEEncryptionKey = str;
+}
 
 //-----------------------------------------------------------------------------
 void Identity::setEmailAddr(const QString &str)
Index: identity.h
===================================================================
RCS file: /home/kde/kdepim/libkdepim/identity.h,v
retrieving revision 1.28
diff -u -3 -p -r1.28 identity.h
--- identity.h	14 May 2004 11:42:36 -0000	1.28
+++ identity.h	30 May 2004 11:53:17 -0000
@@ -7,6 +7,10 @@
 #ifndef kpim_identity_h
 #define kpim_identity_h
 
+#include <kleo/enum.h>
+
+#include <kdemacros.h>
+
 #include <qstring.h>
 #include <qcstring.h>
 #include <qstringlist.h>
@@ -14,11 +18,18 @@
 class KProcess;
 namespace KPIM {
   class Identity;
+  class Signature;
 }
 class KConfigBase;
 class IdentityList;
 class QDataStream;
 
+QDataStream & operator<<( QDataStream & stream, const KPIM::Signature & sig );
+QDataStream & operator>>( QDataStream & stream, KPIM::Signature & sig );
+
+QDataStream & operator<<( QDataStream & stream, const KPIM::Identity & ident );
+QDataStream & operator>>( QDataStream & stream, KPIM::Identity & ident );
+
 namespace KPIM {
 
 /**
@@ -28,8 +39,8 @@ namespace KPIM {
 class Signature {
   friend class Identity;
 
-  friend QDataStream & operator<<( QDataStream & stream, const Signature & sig );
-  friend QDataStream & operator>>( QDataStream & stream, Signature & sig );
+  friend QDataStream & ::operator<<( QDataStream & stream, const Signature & sig );
+  friend QDataStream & ::operator>>( QDataStream & stream, Signature & sig );
 
 public:
   /** Type of signature (ie. way to obtain the signature text) */
@@ -87,8 +98,8 @@ class Identity
   // QValueList<Identity> and especially qHeapSort().
   friend class IdentityManager;
 
-  friend QDataStream & operator<<( QDataStream & stream, const Identity & ident );
-  friend QDataStream & operator>>( QDataStream & stream, Identity & ident );
+  friend QDataStream & ::operator<<( QDataStream & stream, const Identity & ident );
+  friend QDataStream & ::operator>>( QDataStream & stream, Identity & ident );
 
 public:
   typedef QValueList<Identity> List;
@@ -174,9 +185,30 @@ public:
   QString organization() const { return mOrganization; }
   void setOrganization(const QString&);
 
-  /** The user's PGP identity */
-  QCString pgpIdentity() const { return mPgpIdentity; }
-  void setPgpIdentity(const QCString&);
+  KDE_DEPRECATED QCString pgpIdentity() const { return pgpEncryptionKey(); }
+  KDE_DEPRECATED void setPgpIdentity( const QCString & key ) {
+    setPGPEncryptionKey( key );
+    setPGPSigningKey( key );
+  }
+
+  /** The user's OpenPGP encryption key */
+  QCString pgpEncryptionKey() const { return mPGPEncryptionKey; }
+  void setPGPEncryptionKey( const QCString & key );
+
+  /** The user's OpenPGP signing key */
+  QCString pgpSigningKey() const { return mPGPSigningKey; }
+  void setPGPSigningKey( const QCString & key );
+
+  /** The user's S/MIME encryption key */
+  QCString smimeEncryptionKey() const { return mSMIMEEncryptionKey; }
+  void setSMIMEEncryptionKey( const QCString & key );
+
+  /** The user's S/MIME signing key */
+  QCString smimeSigningKey() const { return mSMIMESigningKey; }
+  void setSMIMESigningKey( const QCString & key );
+
+  Kleo::CryptoMessageFormat preferredCryptoMessageFormat() const { return \
mPreferredCryptoMessageFormat; } +  void setPreferredCryptoMessageFormat( \
Kleo::CryptoMessageFormat format ) { mPreferredCryptoMessageFormat = format; }  
   /** email address (without the user name - only name@host) */
   QString emailAddr() const { return mEmailAddr; }
@@ -259,19 +291,14 @@ protected:
   QString mReplyToAddr;
   QString mBcc;
   QString mVCardFile;
-  QCString mPgpIdentity;
+  QCString mPGPEncryptionKey, mPGPSigningKey, mSMIMEEncryptionKey, mSMIMESigningKey;
   QString mFcc, mDrafts, mTransport;
   QString mDictionary;
   Signature mSignature;
   bool      mIsDefault;
+  Kleo::CryptoMessageFormat mPreferredCryptoMessageFormat;
 };
 
-QDataStream & operator<<( QDataStream & stream, const Signature & sig );
-QDataStream & operator>>( QDataStream & stream, Signature & sig );
-
-QDataStream & operator<<( QDataStream & stream, const Identity & ident );
-QDataStream & operator>>( QDataStream & stream, Identity & ident );
-
-}
+} // namespace KPIM
 
 #endif /*kpim_identity_h*/



_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

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

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