23 #include <klocalizedstring.h>
26 #include <QtCore/QDataStream>
27 #include <QtCore/QSharedData>
35 : mId( KRandom::randomString( 8 ) )
39 Private(
const Private &other )
43 mBinaryData = other.mBinaryData;
44 mTextData = other.mTextData;
45 mCustomTypeString = other.mCustomTypeString;
46 mIsBinary = other.mIsBinary;
78 if ( d->mId != other.d->mId ) {
82 if ( d->mType != other.d->mType ) {
86 if ( d->mIsBinary != other.d->mIsBinary ) {
91 if ( d->mBinaryData != other.d->mBinaryData ) {
95 if ( d->mTextData != other.d->mTextData ) {
100 if ( d->mCustomTypeString != other.d->mCustomTypeString ) {
109 return !( *
this == other );
114 if (
this != &other ) {
133 d->mBinaryData = binary;
139 return d->mBinaryData;
145 d->mIsBinary =
false;
165 d->mCustomTypeString = custom;
175 return d->mCustomTypeString;
185 if ( d->mType ==
Custom ) {
190 if ( d->mIsBinary ) {
216 return i18nc(
"X.509 public key",
"X509" );
219 return i18nc(
"Pretty Good Privacy key",
"PGP" );
222 return i18nc(
"A custom key",
"Custom" );
225 return i18nc(
"another type of encryption key",
"Unknown type" );
232 return s << key.d->mId << key.d->mType << key.d->mIsBinary << key.d->mBinaryData
233 << key.d->mTextData << key.d->mCustomTypeString;
239 s >> key.d->mId >> type >> key.d->mIsBinary >> key.d->mBinaryData >> key.d->mTextData
240 >> key.d->mCustomTypeString;
void setId(const QString &identifier)
Sets the unique identifier.
Key(const QString &text=QString(), Type type=PGP)
Creates a new key.
QString textData() const
Returns the text data.
void setBinaryData(const QByteArray &data)
Sets binary data.
void setTextData(const QString &data)
Sets text data.
static TypeList typeList()
Returns a list of all available key types.
QByteArray binaryData() const
Returns the binary data.
A class to store an encryption key.
bool isBinary() const
Returns whether the key contains binary or text data.
Custom or IANA conform key.
QDataStream & operator<<(QDataStream &stream, const Address &address)
Serializes the address object into the stream.
static QString typeLabel(Type type)
Returns a translated label for a given key type.
QString toString() const
Returns a string representation of the key.
void setCustomTypeString(const QString &type)
Sets custom type string.
QDataStream & operator>>(QDataStream &stream, Address &address)
Initializes the address object from the stream.
void setType(Type type)
Sets the type.
QString id() const
Returns the unique identifier.
Key & operator=(const Key &other)
Assignment operator.
QString customTypeString() const
Returns the custom type string.
QString fromLatin1(const char *str, int size)
Type type() const
Returns the type, see Type.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
bool operator!=(const Key &) const
Not-equal operator.
bool operator==(const Key &) const
Equality operator.