24 #include <tqcstring.h> 26 #include <tqstringlist.h> 27 #include <tqvaluelist.h> 36 KPGP_VALIDITY_UNKNOWN = 0,
37 KPGP_VALIDITY_UNDEFINED = 1,
38 KPGP_VALIDITY_NEVER = 2,
39 KPGP_VALIDITY_MARGINAL = 3,
40 KPGP_VALIDITY_FULL = 4,
41 KPGP_VALIDITY_ULTIMATE = 5
49 UnknownEncryptPref = 0,
51 AlwaysEncryptIfPossible = 2,
52 AlwaysAskForEncryption = 3,
53 AskWheneverPossible = 4
57 typedef TQCString KeyID;
59 class KeyIDList :
public TQValueList<KeyID>
63 KeyIDList(
const KeyIDList& l ) : TQValueList<KeyID>(l) { }
64 KeyIDList(
const TQValueList<KeyID>& l ) : TQValueList<KeyID>(l) { }
65 KeyIDList(
const KeyID& i ) { append(i); }
67 TQStringList toStringList()
const;
69 static KeyIDList fromStringList(
const TQStringList& );
78 UserID(
const TQString& str,
79 const Validity validity = KPGP_VALIDITY_UNKNOWN,
80 const bool revoked =
false,
81 const bool invalid =
false);
85 TQString text()
const;
94 Validity validity()
const;
97 void setText(
const TQString& str);
100 void setRevoked(
const bool revoked);
103 void setInvalid(
const bool invalid);
107 void setValidity(
const Validity validity);
116 typedef TQPtrList<UserID> UserIDList;
117 typedef TQPtrListIterator<UserID> UserIDListIterator;
156 mValidity = validity;
166 Subkey(
const KeyID& keyID,
const bool secret =
false);
173 bool revoked()
const;
176 bool expired()
const;
179 bool disabled()
const;
182 bool invalid()
const;
185 bool canEncrypt()
const;
188 bool canSign()
const;
191 bool canCertify()
const;
194 unsigned int keyAlgorithm()
const;
197 unsigned int keyLength()
const;
201 KeyID longKeyID()
const;
207 TQCString fingerprint()
const;
210 time_t creationDate()
const;
213 time_t expirationDate()
const;
216 void setSecret(
const bool secret);
219 void setRevoked(
const bool revoked);
222 void setExpired(
const bool expired);
225 void setDisabled(
const bool disabled);
228 void setInvalid(
const bool invalid);
232 void setCanEncrypt(
const bool canEncrypt);
236 void setCanSign(
const bool canSign);
240 void setCanCertify(
const bool canCertify);
243 void setKeyAlgorithm(
const unsigned int keyAlgo);
246 void setKeyLength(
const unsigned int keyLen);
249 void setKeyID(
const KeyID& keyID);
252 void setFingerprint(
const TQCString& fingerprint);
256 void setCreationDate(
const time_t creationDate);
260 void setExpirationDate(
const time_t expirationDate);
269 bool mCanEncrypt : 1;
271 bool mCanCertify : 1;
273 unsigned int mKeyAlgo;
274 unsigned int mKeyLen;
276 TQCString mFingerprint;
338 return mKeyID.right(8);
373 mDisabled = disabled;
383 mCanEncrypt = canEncrypt;
393 mCanCertify = canCertify;
413 mFingerprint = fingerprint;
418 mTimestamp = creationDate;
423 mExpiration = expirationDate;
426 typedef TQPtrList<Subkey> SubkeyList;
427 typedef TQPtrListIterator<Subkey> SubkeyListIterator;
437 Key(
const KeyID& keyid = KeyID(),
438 const TQString& uid = TQString(),
439 const bool secret =
false);
449 bool revoked()
const;
452 bool expired()
const;
455 bool disabled()
const;
458 bool invalid()
const;
461 bool canEncrypt()
const;
464 bool canSign()
const;
467 bool canCertify()
const;
470 void setSecret(
const bool secret);
473 void setRevoked(
const bool revoked);
476 void setExpired(
const bool expired);
479 void setDisabled(
const bool disabled);
482 void setInvalid(
const bool invalid);
486 void setCanEncrypt(
const bool canEncrypt);
490 void setCanSign(
const bool canSign);
494 void setCanCertify(
const bool canCertify);
498 EncryptPref encryptionPreference();
501 void setEncryptionPreference(
const EncryptPref encrPref );
506 TQString primaryUserID()
const;
510 KeyID primaryKeyID()
const;
514 TQCString primaryFingerprint()
const;
521 time_t creationDate()
const;
526 Validity keyTrust()
const;
530 Validity keyTrust(
const TQString& uid )
const;
536 void cloneKeyTrust(
const Key* key );
541 bool isValid()
const;
546 bool isValidEncryptionKey()
const;
550 bool isValidSigningKey()
const;
553 const UserIDList userIDs()
const;
556 const SubkeyList subkeys()
const;
560 void addUserID(
const TQString& uid,
561 const Validity validity = KPGP_VALIDITY_UNKNOWN,
562 const bool revoked =
false,
563 const bool invalid =
false);
566 void addUserID(
const UserID *userID);
571 bool matchesUserID(
const TQString& str,
bool cs =
true);
575 void addSubkey(
const KeyID& keyID,
const bool secret =
false);
578 void addSubkey(
const Subkey *subkey);
581 Subkey *getSubkey(
const KeyID& keyID);
584 void setFingerprint(
const KeyID& keyID,
const TQCString& fpr);
593 bool mCanEncrypt : 1;
595 bool mCanCertify : 1;
597 EncryptPref mEncryptPref;
660 mDisabled = disabled;
670 mCanEncrypt = canEncrypt;
680 mCanCertify = canCertify;
690 mEncryptPref = encrPref;
695 UserID *uid = mUserIDs.getFirst();
705 Subkey *key = mSubkeys.getFirst();
715 Subkey *key = mSubkeys.getFirst();
735 return (mUserIDs.isEmpty() || mSubkeys.isEmpty());
740 if( !mSubkeys.isEmpty() )
741 return mSubkeys.getFirst()->creationDate();
749 mUserIDs.append(userID);
755 mSubkeys.append(subkey);
760 typedef TQPtrList<Key> KeyListBase;
761 typedef TQPtrListIterator<Key> KeyListIterator;
763 class KeyList :
public KeyListBase
770 int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 )
773 return TQString::compare((static_cast<Key*>(s1))->primaryUserID().lower(),
774 (static_cast<Key*>(s2))->primaryUserID().lower());
void setRevoked(const bool revoked)
Sets the flag if the subkey has been revoked to revoked.
void setCanCertify(const bool canCertify)
Sets the flag if the key can be used to certify keys to canCertify.
bool canEncrypt() const
Returns true if the subkey can be used to encrypt data.
void setDisabled(const bool disabled)
Sets the flag if the subkey has been disabled to disabled.
const UserIDList userIDs() const
Returns the list of userIDs.
void setExpired(const bool expired)
Sets the flag if the subkey has expired to expired.
bool canCertify() const
Returns true if the subkey can be used to certify keys.
TQCString fingerprint() const
Returns the fingerprint of the subkey.
void setCanEncrypt(const bool canEncrypt)
Sets the flag if the key can be used to encrypt data to canEncrypt.
void setEncryptionPreference(const EncryptPref encrPref)
Sets the encryption preference for this key to encrPref.
TQCString primaryFingerprint() const
Returns the fingerprint of the primary key or a null string if there are no subkeys.
void setKeyLength(const unsigned int keyLen)
Sets the key length of the subkey to keyLen bits.
const SubkeyList subkeys() const
Returns the list of subkeys.
bool canSign() const
Returns true if the subkey can be used to sign data.
bool canEncrypt() const
Returns true if the key can be used to encrypt data.
void setInvalid(const bool invalid)
Sets the flag if the subkey is invalid to invalid.
void setText(const TQString &str)
Sets the text of the user id to str.
time_t creationDate() const
Returns the creation date of the primary subkey.
void setCanSign(const bool canSign)
Sets the flag if the subkey can be used to sign data to canSign.
void setKeyID(const KeyID &keyID)
Sets the key ID of the subkey to keyID.
void setSecret(const bool secret)
Sets the flag if the key is a secret key to secret.
bool invalid() const
Returns true if the key is invalid.
bool canSign() const
Returns true if the key can be used to sign data.
bool disabled() const
Returns true if the key has been disabled.
void setDisabled(const bool disabled)
Sets the flag if the key has been disabled to disabled.
void setFingerprint(const TQCString &fingerprint)
Sets the fingerprint of the subkey to fingerprint.
void setInvalid(const bool invalid)
Sets the flag if the user id is invalid to invalid.
bool revoked() const
Returns true if the key has been revoked.
bool secret() const
Returns true if the key is a secret key.
TQString primaryUserID() const
Returns the primary user ID or a null string if there are no user IDs.
EncryptPref encryptionPreference()
Returns the encryption preference for this key.
bool revoked() const
Returns true if the subkey has been revoked.
TQString text() const
Returns the text of the user id.
void setInvalid(const bool invalid)
Sets the flag if the key is invalid to invalid.
KeyID longKeyID() const
Returns the long 64 bit key ID of the subkey if it's available.
KeyID keyID() const
Returns the (short) 32 bit key ID of the subkey.
bool expired() const
Returns true if the subkey has expired.
This class is used to store information about a subkey of a PGP key.
void setRevoked(const bool revoked)
Sets the flag if the user id has been revoked to revoked.
bool invalid() const
Returns true if the subkey is invalid.
bool expired() const
Returns true if the key has expired.
time_t expirationDate() const
Returns the expiration date of the subkey.
bool invalid() const
Returns true if the user id is invalid.
time_t creationDate() const
Returns the creation date of the subkey.
void setSecret(const bool secret)
Sets the flag if the subkey is a secret subkey to secret.
void setValidity(const Validity validity)
Sets the validity of resp.
void setExpirationDate(const time_t expirationDate)
Sets the expiration date of the subkey to expirationDate seconds since Epoch.
This class is used to store information about a user id of a PGP key.
bool canCertify() const
Returns true if the key can be used to certify keys.
unsigned int keyAlgorithm() const
Returns the key algorithm of the subkey.
unsigned int keyLength() const
Returns the length of the subkey in bits.
bool disabled() const
Returns true if the subkey has been disabled.
void addUserID(const TQString &uid, const Validity validity=KPGP_VALIDITY_UNKNOWN, const bool revoked=false, const bool invalid=false)
Adds a user ID with the given values to the key if uid isn't an empty string.
Validity validity() const
Returns the validity of resp.
void setCanCertify(const bool canCertify)
Sets the flag if the subkey can be used to certify keys to canCertify.
void setKeyAlgorithm(const unsigned int keyAlgo)
Sets the key algorithm of the subkey to keyAlgo.
bool secret() const
Returns true if the subkey is a secret subkey.
void addSubkey(const KeyID &keyID, const bool secret=false)
Adds a subkey with the given values to the key if keyID isn't an empty string.
void setExpired(const bool expired)
Sets the flag if the key has expired to expired.
void setRevoked(const bool revoked)
Sets the flag if the key has been revoked to revoked.
This class is used to store information about a PGP key.
void setCanEncrypt(const bool canEncrypt)
Sets the flag if the subkey can be used to encrypt data to canEncrypt.
void setCanSign(const bool canSign)
Sets the flag if the key can be used to sign data to canSign.
void setCreationDate(const time_t creationDate)
Sets the creation date of the subkey to creationDate seconds since Epoch.
bool revoked() const
Returns true if the user id has been revoked.
bool isNull() const
Returns true if there are no user IDs or no subkeys.
KeyID primaryKeyID() const
Returns the key ID of the primary key or a null string if there are no subkeys.