identity.h
00001 /* 00002 Copyright (c) 2002-2004 Marc Mutz <mutz@kde.org> 00003 Copyright (c) 2007 Tom Albers <tomalbers@kde.nl> 00004 Author: Stefan Taferner <taferner@kde.org> 00005 00006 This library is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU Library General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or (at your 00009 option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, but WITHOUT 00012 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00014 License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to the 00018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00019 02110-1301, USA. 00020 */ 00021 00022 #ifndef KPIMIDENTITES_IDENTITY_H 00023 #define KPIMIDENTITES_IDENTITY_H 00024 00025 #include "kpimidentities_export.h" 00026 #include "signature.h" 00027 00028 #include <kdemacros.h> 00029 00030 #include <QtCore/QString> 00031 #include <QtCore/QStringList> 00032 #include <QtCore/QList> 00033 #include <QtCore/QHash> 00034 #include <QtCore/QVariant> 00035 00036 namespace KPIMIdentities 00037 { 00038 class Identity; 00039 class Signature; 00040 } 00041 class KConfigGroup; 00042 class QDataStream; 00043 class QMimeData; 00044 00045 namespace KPIMIdentities 00046 { 00047 00048 static const char s_uoid[] = "uoid"; 00049 static const char s_identity[] = "Identity"; 00050 static const char s_name[] = "Name"; 00051 static const char s_organization[] = "Organization"; 00052 static const char s_pgps[] = "PGP Signing Key"; 00053 static const char s_pgpe[] = "PGP Encryption Key"; 00054 static const char s_smimes[] = "SMIME Signing Key"; 00055 static const char s_smimee[] = "SMIME Encryption Key"; 00056 static const char s_prefcrypt[] = "Preferred Crypto Message Format"; 00057 static const char s_email[] = "Email Address"; // TODO: KDE5: Rename to s_primaryEmail 00058 static const char s_replyto[] = "Reply-To Address"; 00059 static const char s_bcc[] = "Bcc"; 00060 static const char s_vcard[] = "VCardFile"; 00061 static const char s_transport[] = "Transport"; 00062 static const char s_fcc[] = "Fcc"; 00063 static const char s_drafts[] = "Drafts"; 00064 static const char s_templates[] = "Templates"; 00065 static const char s_dict[] = "Dictionary"; 00066 static const char s_xface[] = "X-Face"; 00067 static const char s_xfaceenabled[] = "X-FaceEnabled"; 00068 static const char s_signature[] = "Signature"; 00069 static const char s_emailAliases[] = "Email Aliases"; 00070 00071 KPIMIDENTITIES_EXPORT QDataStream &operator<< 00072 ( QDataStream &stream, const KPIMIdentities::Identity &ident ); 00073 KPIMIDENTITIES_EXPORT QDataStream &operator>> 00074 ( QDataStream &stream, KPIMIdentities::Identity &ident ); 00075 00077 class KPIMIDENTITIES_EXPORT Identity 00078 { 00079 // only the identity manager should be able to construct and 00080 // destruct us, but then we get into problems with using 00081 // QValueList<Identity> and especially qHeapSort(). 00082 friend class IdentityManager; 00083 00084 friend KPIMIDENTITIES_EXPORT QDataStream &operator<< 00085 ( QDataStream &stream, const KPIMIdentities::Identity &ident ); 00086 friend KPIMIDENTITIES_EXPORT QDataStream &operator>> 00087 ( QDataStream &stream, KPIMIdentities::Identity &ident ); 00088 00089 public: 00090 typedef QList<Identity> List; 00091 00093 explicit Identity( const QString &id=QString(), 00094 const QString &realName=QString(), 00095 const QString &emailAddr=QString(), 00096 const QString &organization=QString(), 00097 const QString &replyToAddress=QString() ); 00098 00100 ~Identity(); 00101 00103 bool operator== ( const Identity &other ) const; 00104 00106 bool operator!= ( const Identity &other ) const; 00107 00109 bool operator< ( const Identity &other ) const; 00110 00112 bool operator> ( const Identity &other ) const; 00113 00115 bool operator<= ( const Identity &other ) const; 00116 00118 bool operator>= ( const Identity &other ) const; 00119 00121 bool mailingAllowed() const; 00122 00124 QString identityName() const; 00125 00127 void setIdentityName( const QString &name ); 00128 00130 bool isDefault() const; 00131 00133 uint uoid() const; 00134 00136 QString fullName() const; 00137 void setFullName( const QString& ); 00138 00140 QString organization() const; 00141 void setOrganization( const QString& ); 00142 00144 QByteArray pgpEncryptionKey() const; 00145 void setPGPEncryptionKey( const QByteArray &key ); 00146 00148 QByteArray pgpSigningKey() const; 00149 void setPGPSigningKey( const QByteArray &key ); 00150 00152 QByteArray smimeEncryptionKey() const; 00153 void setSMIMEEncryptionKey( const QByteArray &key ); 00154 00156 QByteArray smimeSigningKey() const; 00157 void setSMIMESigningKey( const QByteArray &key ); 00158 00159 QString preferredCryptoMessageFormat() const; 00160 void setPreferredCryptoMessageFormat( const QString& ); 00161 00168 KDE_DEPRECATED QString emailAddr() const; 00169 KDE_DEPRECATED void setEmailAddr( const QString& ); 00170 00177 QString primaryEmailAddress() const; 00178 void setPrimaryEmailAddress( const QString & email ); 00179 00185 const QStringList emailAliases() const; 00186 void setEmailAliases( const QStringList & aliases ); 00187 00194 bool matchesEmailAddress( const QString & addr ) const; 00195 00197 QString vCardFile() const; 00198 void setVCardFile( const QString& ); 00199 00202 QString fullEmailAddr() const; 00203 00205 QString replyToAddr() const; 00206 void setReplyToAddr( const QString& ); 00207 00209 QString bcc() const; 00210 void setBcc( const QString& ); 00211 00212 void setSignature( const Signature &sig ); 00213 Signature &signature(); /* _not_ const! */ 00214 00221 QString signatureText( bool *ok = 0 ) const; 00222 00227 bool signatureIsInlinedHtml() const; 00228 00231 QString transport() const; 00232 void setTransport( const QString& ); 00233 00236 QString fcc() const; 00237 void setFcc( const QString& ); 00238 00243 QString drafts() const; 00244 void setDrafts( const QString& ); 00245 00250 QString templates() const; 00251 void setTemplates( const QString& ); 00252 00259 QString dictionary() const; 00260 void setDictionary( const QString& ); 00261 00263 QString xface() const; 00264 void setXFace( const QString& ); 00265 bool isXFaceEnabled() const; 00266 void setXFaceEnabled( const bool ); 00267 00269 QVariant property( const QString &key ) const; 00272 void setProperty( const QString &key, const QVariant &value ); 00273 00274 static const Identity &null(); 00277 bool isNull() const; 00278 00279 static QString mimeDataType(); 00280 static bool canDecode( const QMimeData* ); 00281 void populateMimeData( QMimeData* ); 00282 static Identity fromMimeData( const QMimeData* ); 00283 00286 void readConfig( const KConfigGroup & ); 00287 00290 void writeConfig( KConfigGroup & ) const; 00291 00300 void setIsDefault( bool flag ); 00301 00303 void setUoid( uint aUoid ); 00304 00305 protected: 00307 bool signatureIsCommand() const; 00308 00310 bool signatureIsPlainFile() const; 00311 00313 bool signatureIsInline() const; 00314 00316 QString signatureFile() const; 00317 void setSignatureFile( const QString& ); 00318 00320 QString signatureInlineText() const; 00321 void setSignatureInlineText( const QString& ); 00322 00324 bool useSignatureFile() const; 00325 00326 Signature mSignature; 00327 bool mIsDefault; 00328 QHash<QString,QVariant> mPropertiesMap; 00329 }; 00330 00331 } 00332 00333 #endif /*kpim_identity_h*/