• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

kgpg

kgpgkey.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  ***************************************************************************/
00009 
00010 #ifndef KGPGKEY_H
00011 #define KGPGKEY_H
00012 
00013 #include <QSharedDataPointer>
00014 #include <QSharedData>
00015 #include <QStringList>
00016 #include <QPointer>
00017 #include <QObject>
00018 #include <QList>
00019 #include <QDate>
00020 
00021 namespace KgpgCore
00022 {
00023 
00024 //BEGIN Enums
00025 
00026 enum KgpgKeyAlgoFlag
00027 {
00028     ALGO_UNKNOWN = 0,
00029     ALGO_RSA = 1,
00030     ALGO_DSA = 2,
00031     ALGO_ELGAMAL = 4,
00032     ALGO_DSA_ELGAMAL = ALGO_DSA | ALGO_ELGAMAL
00033 };
00034 Q_DECLARE_FLAGS(KgpgKeyAlgo, KgpgKeyAlgoFlag)
00035 Q_DECLARE_OPERATORS_FOR_FLAGS(KgpgKeyAlgo)
00036 
00044 enum KgpgKeyTrustFlag
00045 {
00046     TRUST_MINIMUM = 0,      
00047     TRUST_INVALID = 1,      
00048     TRUST_DISABLED = 2,     
00049     TRUST_REVOKED = 3,      
00050     TRUST_EXPIRED = 4,      
00051     TRUST_UNDEFINED = 5,    
00052     TRUST_UNKNOWN = 6,      
00053     TRUST_NONE = 7,     
00054     TRUST_MARGINAL = 8,     
00055     TRUST_FULL = 9,     
00056     TRUST_ULTIMATE = 10,    
00057     TRUST_NOKEY = 11        
00058 };
00059 Q_DECLARE_FLAGS(KgpgKeyTrust, KgpgKeyTrustFlag)
00060 Q_DECLARE_OPERATORS_FOR_FLAGS(KgpgKeyTrust)
00061 
00069 enum KgpgKeyOwnerTrustFlag
00070 {
00071     OWTRUST_UNKNOWN = 0,    
00072     OWTRUST_UNDEFINED = 1,  
00073     OWTRUST_NONE = 2,       
00074     OWTRUST_MARGINAL = 3,   
00075     OWTRUST_FULL = 4,       
00076     OWTRUST_ULTIMATE = 5    
00077 };
00078 Q_DECLARE_FLAGS(KgpgKeyOwnerTrust, KgpgKeyOwnerTrustFlag)
00079 Q_DECLARE_OPERATORS_FOR_FLAGS(KgpgKeyOwnerTrust)
00080 
00081 enum KgpgSubKeyTypeFlag
00082 {
00083     SKT_ENCRYPTION = 0,
00084     SKT_SIGNATURE = 1
00085 };
00086 Q_DECLARE_FLAGS(KgpgSubKeyType, KgpgSubKeyTypeFlag)
00087 Q_DECLARE_OPERATORS_FOR_FLAGS(KgpgSubKeyType)
00088 
00098 enum KgpgItemTypeFlag
00099 {
00100     ITYPE_GROUP = 1,                
00101     ITYPE_SECRET = 2,               
00102     ITYPE_PUBLIC = 4,               
00103     ITYPE_PAIR = ITYPE_SECRET | ITYPE_PUBLIC,   
00104     ITYPE_GSECRET = ITYPE_GROUP | ITYPE_SECRET, 
00105     ITYPE_GPUBLIC = ITYPE_GROUP | ITYPE_PUBLIC, 
00106     ITYPE_GPAIR = ITYPE_GROUP | ITYPE_PAIR, 
00107     ITYPE_SUB = 8,              
00108     ITYPE_UID = 16,             
00109     ITYPE_UAT = 32,             
00110     ITYPE_REVSIGN = 64,             
00111     ITYPE_SIGN = 128                
00112 };
00113 Q_DECLARE_FLAGS(KgpgItemType, KgpgItemTypeFlag)
00114 Q_DECLARE_OPERATORS_FOR_FLAGS(KgpgItemType)
00115 
00116 //END Enums
00117 
00118 
00119 //BEGIN KeySign
00120 
00121 class KgpgKeySignPrivate : public QSharedData
00122 {
00123 public:
00124     bool    gpgsignrevocation;
00125     QString gpgsignid;
00126     QString gpgsignname;
00127     QString gpgsignemail;
00128     QString gpgsigncomment;
00129     QDate   gpgsignexpiration;
00130     QDate   gpgsigncreation;
00131     bool    gpgsignlocal;
00132 
00133     bool operator==(const KgpgKeySignPrivate &other) const;
00134     inline bool operator!=(const KgpgKeySignPrivate &other) const
00135     { return !operator==(other); }
00136 };
00137 
00138 class KgpgKeySign : public QObject
00139 {
00140     Q_OBJECT
00141 
00142 public:
00143     KgpgKeySign();
00144     KgpgKeySign(const KgpgKeySign &other);
00145 
00146     void setId(const QString &id);
00147     void setName(const QString &name);
00148     void setEmail(const QString &email);
00149     void setComment(const QString &comment);
00150     void setExpiration(const QDate &date);
00151     void setCreation(const QDate &date);
00152     void setLocal(const bool &local);
00153     void setRevocation(const bool &revoc);
00154 
00155     QString id() const;
00156     QString fullId() const;
00157     QString name() const;
00158     QString email() const;
00159     QString comment() const;
00160     bool unlimited() const;
00161     QDate expirationDate() const;
00162     QDate creationDate() const;
00163     bool local() const;
00164     bool revocation() const;
00165 
00166     QString expiration() const;
00167     QString creation() const;
00168 
00169     bool operator==(const KgpgKeySign &other) const;
00170     inline bool operator!=(const KgpgKeySign &other) const
00171     { return !operator==(other); }
00172     KgpgKeySign& operator=(const KgpgKeySign &other);
00173 
00174 private:
00175     QSharedDataPointer<KgpgKeySignPrivate> d;
00176 };
00177 
00178 class KgpgKeySignList : public QList<KgpgKeySign>, QObject
00179 {
00180 public:
00181     inline KgpgKeySignList() { }
00182     inline explicit KgpgKeySignList(const KgpgKeySign &sign) { append(sign); }
00183     inline KgpgKeySignList(const KgpgKeySignList &other) : QList<KgpgKeySign>(other), QObject() { }
00184     inline KgpgKeySignList(const QList<KgpgKeySign> &other) : QList<KgpgKeySign>(other), QObject() { }
00185 
00186     inline KgpgKeySignList operator+(const KgpgKeySignList &other) const
00187     {
00188         KgpgKeySignList n = *this;
00189         n += other;
00190         return n;
00191     }
00192 
00193     inline KgpgKeySignList &operator<<(KgpgKeySign sign)
00194     {
00195         append(sign);
00196         return *this;
00197     }
00198 
00199     inline KgpgKeySignList &operator<<(const KgpgKeySignList &l)
00200     {
00201         *this += l;
00202         return *this;
00203     }
00204 };
00205 
00206 //END KeySign
00207 
00208 
00209 //BEGIN KeyUat
00210 
00211 class KgpgKeyUatPrivate : public QSharedData
00212 {
00213 public:
00214     QString gpguatid;
00215     QDate   gpguatcreation;
00216     KgpgKeySignList gpgsignlist;
00217 
00218     bool operator==(const KgpgKeyUatPrivate &other) const;
00219     inline bool operator!=(const KgpgKeyUatPrivate &other) const
00220     { return !operator==(other); }
00221 };
00222 
00223 class KgpgKeyUat : public QObject
00224 {
00225     Q_OBJECT
00226 
00227 public:
00228     KgpgKeyUat();
00229     KgpgKeyUat(const KgpgKeyUat &other);
00230 
00231     void setId(const QString &id);
00232     void setCreation(const QDate &date);
00233     QString id() const;
00234     QDate creationDate() const;
00235     QString creation() const;
00236 
00237     void addSign(const KgpgKeySign &sign);
00238     KgpgKeySignList signList() const;
00239 
00240     bool operator==(const KgpgKeyUat &other) const;
00241     inline bool operator!=(const KgpgKeyUat &other) const
00242     { return !operator==(other); }
00243     KgpgKeyUat& operator=(const KgpgKeyUat &other);
00244 
00245 private:
00246     QSharedDataPointer<KgpgKeyUatPrivate> d;
00247 };
00248 
00249 class KgpgKeyUatList : public QList<KgpgKeyUat>, public QObject
00250 {
00251 public:
00252     inline KgpgKeyUatList() { }
00253     inline explicit KgpgKeyUatList(const KgpgKeyUat &uat) { append(uat); }
00254     inline KgpgKeyUatList(const KgpgKeyUatList &other) : QList<KgpgKeyUat>(other), QObject() { }
00255     inline KgpgKeyUatList(const QList<KgpgKeyUat> &other) : QList<KgpgKeyUat>(other), QObject() { }
00256 
00257     inline KgpgKeyUatList operator+(const KgpgKeyUatList &other) const
00258     {
00259         KgpgKeyUatList n = *this;
00260         n += other;
00261         return n;
00262     }
00263 
00264     inline KgpgKeyUatList &operator<<(KgpgKeyUat uat)
00265     {
00266         append(uat);
00267         return *this;
00268     }
00269 
00270     inline KgpgKeyUatList &operator<<(const KgpgKeyUatList &l)
00271     {
00272         *this += l;
00273         return *this;
00274     }
00275 };
00276 typedef QPointer<KgpgKeyUatList> KgpgKeyUatListPtr;
00277 
00278 //END KeyUat
00279 
00280 
00281 //BEGIN KeyUid
00282 
00283 class KgpgKeyUidPrivate : public QSharedData
00284 {
00285 public:
00286     bool     gpguidvalid;
00287     unsigned int gpguidindex;
00288     KgpgKeyTrust gpguidtrust;
00289     QString  gpguidname;
00290     QString  gpguidemail;
00291     QString  gpguidcomment;
00292     KgpgKeySignList gpgsignlist;
00293 
00294     bool operator==(const KgpgKeyUidPrivate &other) const;
00295     inline bool operator!=(const KgpgKeyUidPrivate &other) const
00296     { return !operator==(other); }
00297 };
00298 
00299 class KgpgKeyUid : public QObject
00300 {
00301     Q_OBJECT
00302 
00303 public:
00304     KgpgKeyUid();
00305     KgpgKeyUid(const KgpgKeyUid &other);
00306 
00307     void setName(const QString &name);
00308     void setEmail(const QString &email);
00309     void setComment(const QString &comment);
00310     void setValid(const bool &valid);
00311     void setTrust(const KgpgKeyTrust &trust);
00312     void setIndex(const unsigned int &index);
00313 
00314     QString name() const;
00315     QString email() const;
00316     QString comment() const;
00317     bool valid() const;
00318     KgpgKeyTrust trust() const;
00319     unsigned int index() const;
00320 
00321     void addSign(const KgpgKeySign &sign);
00322     KgpgKeySignList signList() const;
00323 
00324     bool operator==(const KgpgKeyUid &other) const;
00325     inline bool operator!=(const KgpgKeyUid &other) const
00326     { return !operator==(other); }
00327     KgpgKeyUid& operator=(const KgpgKeyUid &other);
00328 
00329 private:
00330     QSharedDataPointer<KgpgKeyUidPrivate> d;
00331 };
00332 
00333 class KgpgKeyUidList : public QList<KgpgKeyUid>, public QObject
00334 {
00335 public:
00336     inline KgpgKeyUidList() { }
00337     inline explicit KgpgKeyUidList(const KgpgKeyUid &uid) { append(uid); }
00338     inline KgpgKeyUidList(const KgpgKeyUidList &other) : QList<KgpgKeyUid>(other), QObject() { }
00339     inline KgpgKeyUidList(const QList<KgpgKeyUid> &other) : QList<KgpgKeyUid>(other), QObject() { }
00340 
00341     inline KgpgKeyUidList operator+(const KgpgKeyUidList &other) const
00342     {
00343         KgpgKeyUidList n = *this;
00344         n += other;
00345         return n;
00346     }
00347 
00348     inline KgpgKeyUidList &operator<<(KgpgKeyUid uid)
00349     {
00350         append(uid);
00351         return *this;
00352     }
00353 
00354     inline KgpgKeyUidList &operator<<(const KgpgKeyUidList &l)
00355     {
00356         *this += l;
00357         return *this;
00358     }
00359 };
00360 typedef QPointer<KgpgKeyUidList> KgpgKeyUidListPtr;
00361 
00362 //END KeyUid
00363 
00364 
00365 //BEGIN KeySub
00366 
00367 class KgpgKeySubPrivate : public QSharedData
00368 {
00369 public:
00370     bool            gpgsubvalid;
00371     QString         gpgsubid;
00372     uint            gpgsubsize;
00373     QDate           gpgsubexpiration;
00374     QDate           gpgsubcreation;
00375     KgpgKeyTrust    gpgsubtrust;
00376     KgpgKeyAlgo     gpgsubalgo;
00377     KgpgKeySignList gpgsignlist;
00378     KgpgSubKeyType  gpgsubtype;
00379 
00380     bool operator==(const KgpgKeySubPrivate &other) const;
00381     inline bool operator!=(const KgpgKeySubPrivate &other) const
00382     { return !operator==(other); }
00383 };
00384 
00385 class KgpgKeySub : public QObject
00386 {
00387     Q_OBJECT
00388 
00389 public:
00390     KgpgKeySub();
00391     KgpgKeySub(const KgpgKeySub &other);
00392 
00393     void setId(const QString &id);
00394     void setSize(const uint &size);
00395     void setExpiration(const QDate &date);
00396     void setCreation(const QDate &date);
00397     void setTrust(const KgpgKeyTrust &trust);
00398     void setAlgorithm(const KgpgKeyAlgo &algo);
00399     void setValid(const bool &valid); // FIXME : is it possible to have a subkey that is not valid (disabled)? Please give an example. Thx. If not, this method should be removed.
00400     void setType(const KgpgSubKeyType &type); // a sub key can be a signature key or a encryption key
00401 
00402     QString id() const;
00403     uint size() const;
00404     bool unlimited() const;
00405     QDate expirationDate() const;
00406     QDate creationDate() const;
00407     KgpgKeyTrust trust() const;
00408     KgpgKeyAlgo algorithm() const;
00409     bool valid() const;
00410     KgpgSubKeyType type() const;
00411 
00412     QString creation() const;
00413     QString expiration() const;
00414 
00415     void addSign(const KgpgKeySign &sign);
00416     KgpgKeySignList signList() const;
00417 
00418     bool operator==(const KgpgKeySub &other) const;
00419     inline bool operator!=(const KgpgKeySub &other) const
00420     { return !operator==(other); }
00421     KgpgKeySub& operator=(const KgpgKeySub &other);
00422 
00423 private:
00424     QSharedDataPointer<KgpgKeySubPrivate> d;
00425 };
00426 
00427 class KgpgKeySubList : public QList<KgpgKeySub>, public QObject
00428 {
00429 public:
00430     inline KgpgKeySubList() { }
00431     inline explicit KgpgKeySubList(const KgpgKeySub &sub) { append(sub); }
00432     inline KgpgKeySubList(const KgpgKeySubList &other) : QList<KgpgKeySub>(other), QObject() { }
00433     inline KgpgKeySubList(const QList<KgpgKeySub> &other) : QList<KgpgKeySub>(other), QObject() { }
00434 
00435     inline KgpgKeySubList operator+(const KgpgKeySubList &other) const
00436     {
00437         KgpgKeySubList n = *this;
00438         n += other;
00439         return n;
00440     }
00441 
00442     inline KgpgKeySubList &operator<<(KgpgKeySub sub)
00443     {
00444         append(sub);
00445         return *this;
00446     }
00447 
00448     inline KgpgKeySubList &operator<<(const KgpgKeySubList &l)
00449     {
00450         *this += l;
00451         return *this;
00452     }
00453 };
00454 typedef QPointer<KgpgKeySubList> KgpgKeySubListPtr;
00455 
00456 //END KeySub
00457 
00458 
00459 //BEGIN Key
00460 
00461 class KgpgKeyPrivate : public QSharedData
00462 {
00463 public:
00464     KgpgKeyPrivate();
00465 
00466     bool          gpgkeysecret;
00467     bool          gpgkeyvalid;
00468     QString       gpgkeymail;
00469     QString       gpgkeyname;
00470     QString       gpgkeycomment;
00471     QString       gpgkeyfingerprint;
00472     uint          gpgkeysize;
00473     KgpgKeyOwnerTrust gpgkeyownertrust;
00474     KgpgKeyTrust  gpgkeytrust;
00475     QDate         gpgkeycreation;
00476     QDate         gpgkeyexpiration;
00477     KgpgKeyAlgo   gpgkeyalgo;
00478 
00479     KgpgKeySignList   gpgsignlist;
00480     KgpgKeyUatListPtr gpguatlist;
00481     KgpgKeyUidListPtr gpguidlist;
00482     KgpgKeySubListPtr gpgsublist;
00483 
00484     bool operator==(const KgpgKeyPrivate &other) const;
00485     inline bool operator!=(const KgpgKeyPrivate &other) const
00486     { return !operator==(other); }
00487 };
00488 
00489 class KgpgKey : public QObject
00490 {
00491     Q_OBJECT
00492 
00493 public:
00494     static QString expiration(const QDate &date);
00495 
00496     KgpgKey();
00497     KgpgKey(const KgpgKey &other);
00498 
00499     void setSecret(const bool &secret);
00500     void setValid(const bool &valid);
00501     void setName(const QString &name);
00502     void setEmail(const QString &email);
00503     void setComment(const QString &comment);
00504     void setFingerprint(const QString &fingerprint);
00505     void setSize(const uint &size);
00506     void setOwnerTrust(const KgpgKeyOwnerTrust &owtrust);
00507     void setTrust(const KgpgKeyTrust &trust);
00508     void setCreation(const QDate &date);
00509     void setExpiration(const QDate &date);
00510     void setAlgorithm(const KgpgKeyAlgo &algo);
00511 
00512     bool secret() const;
00513     bool valid() const;
00514     QString id() const;
00515     QString fullId() const;
00516     QString name() const;
00517     QString email() const;
00518     QString comment() const;
00519     QString fingerprint() const;
00520     QString fingerprintBeautified() const;
00521     uint size() const;
00522     uint encryptionSize() const;
00523     KgpgKeyOwnerTrust ownerTrust() const;
00524     KgpgKeyTrust trust() const;
00525     QDate creationDate() const;
00526     QDate expirationDate() const;
00527     bool unlimited() const;
00528     KgpgKeyAlgo algorithm() const;
00529     KgpgKeyAlgo encryptionAlgorithm() const;
00530 
00531     QString creation() const;
00532     QString expiration() const;
00533     QStringList photoList() const;
00534 
00535     void addSign(const KgpgKeySign &sign);
00536     KgpgKeySignList signList() const;
00537 
00538     KgpgKeyUatListPtr uatList() const;
00539     KgpgKeyUidListPtr uidList() const;
00540     KgpgKeySubListPtr subList() const;
00541 
00542     bool operator==(const KgpgKey &other) const;
00543     inline bool operator!=(const KgpgKey &other) const
00544     { return !operator==(other); }
00545     KgpgKey& operator=(const KgpgKey &other);
00546 
00547 private:
00548     QSharedDataPointer<KgpgKeyPrivate> d;
00549 };
00550 
00551 class KgpgKeyList : public QList<KgpgKey>, public QObject
00552 {
00553 public:
00554     inline KgpgKeyList() { }
00555     inline explicit KgpgKeyList(const KgpgKey &key) { append(key); }
00556     inline KgpgKeyList(const KgpgKeyList &other) : QList<KgpgKey>(other), QObject() { }
00557     inline KgpgKeyList(const QList<KgpgKey> &other) : QList<KgpgKey>(other), QObject() { }
00558 
00559     inline KgpgKeyList& operator=(const KgpgKeyList &other)
00560     {
00561         QList<KgpgKey>::operator=(static_cast<const QList<KgpgKey> >(other));
00562         return *this;
00563     }
00564 
00565     inline KgpgKeyList operator+(const KgpgKeyList &other) const
00566     {
00567         KgpgKeyList n = *this;
00568         n += other;
00569         return n;
00570     }
00571 
00572     inline KgpgKeyList &operator<<(KgpgKey key)
00573     {
00574         append(key);
00575         return *this;
00576     }
00577 
00578     inline KgpgKeyList &operator<<(const KgpgKeyList &l)
00579     {
00580         *this += l;
00581         return *this;
00582     }
00583 
00584     operator QStringList() const
00585     {
00586         QStringList res;
00587         foreach(KgpgKey key, *this)
00588             res << key.fullId();
00589         return res;
00590     }
00591 };
00592 
00593 //END Key
00594 
00595 } // namespace
00596 
00597 #endif // KGPGKEY_H

kgpg

Skip menu "kgpg"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • okteta
  • printer-applet
  • superkaramba
  • sweeper
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal