kmail Library API Documentation

kmidentity.h

00001 /* -*- mode: C++; c-file-style: "gnu" -*-
00002  * User identity information
00003  *
00004  * Author: Stefan Taferner <taferner@kde.org>
00005  * This code is under GPL
00006  */
00007 #ifndef kmidentity_h
00008 #define kmidentity_h
00009 
00010 #include <qstring.h>
00011 #include <qcstring.h>
00012 #include <qstringlist.h>
00013 
00014 class KMIdentity;
00015 class KConfigBase;
00016 class IdentityList;
00017 class QDataStream;
00018 namespace KMail {
00019   class SignatureConfigurator;
00020 }
00021 
00026 class Signature {
00027   friend class KMIdentity;
00028   friend class KMail::SignatureConfigurator;
00029 
00030   friend QDataStream & operator<<( QDataStream & stream, const Signature & sig );
00031   friend QDataStream & operator>>( QDataStream & stream, Signature & sig );
00032 
00033 public:
00035   enum Type { Disabled = 0, Inlined = 1, FromFile = 2, FromCommand = 3 };
00036 
00038   bool operator==( const Signature & other ) const;
00039 
00041   Signature();
00043   Signature( const QString & text );
00045   Signature( const QString & url, bool isExecutable );
00046 
00048   QString rawText( bool * ok=0 ) const;
00049 
00052   QString withSeparator( bool * ok=0 ) const;
00053 
00056   void setText( const QString & text ) { mText = text; mType = Inlined; }
00059   void setUrl( const QString & url, bool isExecutable=false );
00060 
00061 protected:
00062   void writeConfig( KConfigBase * config ) const;
00063   void readConfig( const KConfigBase * config );
00064 
00065   Type type() const { return mType; }
00066 
00067   QString url() const { return mUrl; }
00068   QString text() const { return mText; }
00069 
00070 protected:
00071   QString mUrl;
00072   QString mText;
00073   Type    mType;
00074 
00075 private:
00076   QString textFromFile( bool * ok ) const;
00077   QString textFromCommand( bool * ok ) const;
00078 };
00079 
00081 class KMIdentity
00082 {
00083   // only the identity manager should be able to construct and
00084   // destruct us, but then we get into problems with using
00085   // QValueList<KMIdentity> and especially qHeapSort().
00086   friend class IdentityManager;
00087 
00088   friend QDataStream & operator<<( QDataStream & stream, const KMIdentity & ident );
00089   friend QDataStream & operator>>( QDataStream & stream, KMIdentity & ident );
00090 
00091 public:
00092   typedef QValueList<KMIdentity> List;
00093 
00095   bool operator==( const KMIdentity & other ) const;
00096 
00097   bool operator!=( const KMIdentity & other ) const {
00098     return !operator==( other );
00099   }
00100 
00102   bool operator<( const KMIdentity & other ) const {
00103     if ( isDefault() ) return true;
00104     if ( other.isDefault() ) return false;
00105     return identityName() < other.identityName();
00106   }
00107   bool operator>( const KMIdentity & other ) const {
00108     if ( isDefault() ) return false;
00109     if ( other.isDefault() ) return true;
00110     return identityName() > other.identityName();
00111   }
00112   bool operator<=( const KMIdentity & other ) const {
00113     return !operator>( other );
00114   }
00115   bool operator>=( const KMIdentity & other ) const {
00116     return !operator<( other );
00117   }
00118 
00120   explicit KMIdentity( const QString & id=QString::null,
00121                const QString & realName=QString::null,
00122                const QString & emailAddr=QString::null,
00123                const QString & organization=QString::null,
00124                const QString & replyToAddress=QString::null );
00125 
00127   ~KMIdentity();
00128 
00129 protected:
00132   void readConfig( const KConfigBase * );
00133 
00136   void writeConfig( KConfigBase * ) const;
00137 
00138 public:
00140   bool mailingAllowed() const;
00141 
00143   QString identityName() const { return mIdentity; }
00144   void setIdentityName( const QString & name );
00145 
00147   bool isDefault() const { return mIsDefault; }
00148 
00149   uint uoid() const { return mUoid; }
00150 
00151 protected:
00161   void setIsDefault( bool flag );
00162 
00163   void setUoid( uint aUoid ) { mUoid = aUoid; }
00164 
00165 public:
00167   QString fullName() const { return mFullName; }
00168   void setFullName(const QString&);
00169 
00171   QString organization() const { return mOrganization; }
00172   void setOrganization(const QString&);
00173 
00175   QCString pgpIdentity() const { return mPgpIdentity; }
00176   void setPgpIdentity(const QCString&);
00177 
00179   QString emailAddr() const { return mEmailAddr; }
00180   void setEmailAddr(const QString&);
00181 
00183   QString vCardFile() const { return mVCardFile; }
00184   void setVCardFile(const QString&);
00185 
00188   QString fullEmailAddr() const;
00189 
00191   QString replyToAddr() const { return mReplyToAddr; }
00192   void setReplyToAddr(const QString&);
00193 
00195   QString bcc() const { return mBcc; }
00196   void setBcc(const QString& aBcc) { mBcc = aBcc; }
00197 
00198   void setSignature( const Signature & sig ) { mSignature = sig; }
00199   Signature & signature() /* _not_ const! */ { return mSignature; }
00200 
00201 protected:
00203   bool signatureIsCommand() const { return mSignature.type() == Signature::FromCommand; }
00205   bool signatureIsPlainFile() const { return mSignature.type() == Signature::FromFile; }
00207   bool signatureIsInline() const { return mSignature.type() == Signature::Inlined; }
00208 
00210   QString signatureFile() const { return mSignature.url(); }
00211   void setSignatureFile(const QString&);
00212 
00214   QString signatureInlineText() const { return mSignature.text();}
00215   void setSignatureInlineText(const QString&);
00216 
00218   bool useSignatureFile() const { return signatureIsPlainFile() || signatureIsCommand(); }
00219 
00220 public:
00226   QString signatureText( bool * ok=0) const;
00227 
00230   QString transport() const { return mTransport; }
00231   void setTransport(const QString&);
00232 
00235   QString fcc() const { return mFcc; }
00236   void setFcc(const QString&);
00237 
00240   QString drafts() const { return mDrafts; }
00241   void setDrafts(const QString&);
00242 
00244   QString dictionary() const { return mDictionary; }
00245   void setDictionary( const QString& );
00246 
00247   static KMIdentity null;
00248   bool isNull() const;
00249 protected:
00250   // if you add new members, make sure they have an operator= (or the
00251   // compiler can synthesize one) and amend KMIdentity::operator==,
00252   // isNull(), readConfig() and writeConfig() as well as operator<<
00253   // and operator>> accordingly:
00254   uint mUoid;
00255   QString mIdentity, mFullName, mEmailAddr, mOrganization;
00256   QString mReplyToAddr;
00257   QString mBcc;
00258   QString mVCardFile;
00259   QCString mPgpIdentity;
00260   QString mFcc, mDrafts, mTransport;
00261   QString mDictionary;
00262   Signature mSignature;
00263   bool      mIsDefault;
00264 };
00265 
00266 QDataStream & operator<<( QDataStream & stream, const Signature & sig );
00267 QDataStream & operator>>( QDataStream & stream, Signature & sig );
00268 
00269 QDataStream & operator<<( QDataStream & stream, const KMIdentity & ident );
00270 QDataStream & operator>>( QDataStream & stream, KMIdentity & ident );
00271 
00272 
00273 #endif /*kmidentity_h*/
KDE Logo
This file is part of the documentation for kmail Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:37:29 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003