KContacts

key.h
1/*
2 This file is part of the KContacts framework.
3 SPDX-FileCopyrightText: 2002 Tobias Koenig <tokoe@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KCONTACTS_KEY_H
9#define KCONTACTS_KEY_H
10
11#include "kcontacts_export.h"
12
13#include <QDataStream>
14#include <QSharedDataPointer>
15
16namespace KContacts
17{
18/**
19 * @short A class to store an encryption key.
20 */
21class KCONTACTS_EXPORT Key
22{
23 friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Key &);
24 friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Key &);
25
26public:
27 /**
28 List of keys.
29 */
31
32 /**
33 Key types
34 */
35 enum Type {
36 X509, /**< X509 key */
37 PGP, /**< Pretty Good Privacy key */
38 Custom, /**< Custom or IANA conform key */
39 };
40
41 /**
42 List of key types.
43 */
45
46 /**
47 Creates a new key.
48
49 @param text The text data.
50 @param type The key type, see Types.
51 */
52 explicit Key(const QString &text = QString(), Type type = PGP);
53
54 /**
55 Copy constructor.
56 */
57 Key(const Key &other);
58
59 /**
60 Destroys the key.
61 */
62 ~Key();
63
64 /**
65 Equality operator.
66 */
67 Q_REQUIRED_RESULT bool operator==(const Key &other) const;
68
69 /**
70 Not-equal operator.
71 */
72 Q_REQUIRED_RESULT bool operator!=(const Key &other) const;
73
74 /**
75 Assignment operator.
76
77 @param other The Key instance to assign to @c this
78 */
79 Key &operator=(const Key &other);
80
81 /**
82 Sets the unique @p identifier.
83 */
84 void setId(const QString &identifier);
85
86 /**
87 Returns the unique identifier.
88 */
89 Q_REQUIRED_RESULT QString id() const;
90
91 /**
92 Sets binary @p data.
93 */
94 void setBinaryData(const QByteArray &data);
95
96 /**
97 Returns the binary data.
98 */
99 Q_REQUIRED_RESULT QByteArray binaryData() const;
100
101 /**
102 Sets text @p data.
103 */
104 void setTextData(const QString &data);
105
106 /**
107 Returns the text data.
108 */
109 Q_REQUIRED_RESULT QString textData() const;
110
111 /**
112 Returns whether the key contains binary or text data.
113 */
114 Q_REQUIRED_RESULT bool isBinary() const;
115
116 /**
117 Sets the @p type.
118
119 @param type The type of the key
120
121 @see Type
122 */
123 void setType(Type type);
124
125 /**
126 Sets custom @p type string.
127 */
128 void setCustomTypeString(const QString &type);
129
130 /**
131 Returns the type, see Type.
132 */
133 Q_REQUIRED_RESULT Type type() const;
134
135 /**
136 Returns the custom type string.
137 */
138 Q_REQUIRED_RESULT QString customTypeString() const;
139
140 /**
141 Returns a string representation of the key.
142 */
143 Q_REQUIRED_RESULT QString toString() const;
144
145 /**
146 Returns a list of all available key types.
147 */
148 Q_REQUIRED_RESULT static TypeList typeList();
149
150 /**
151 Returns a translated label for a given key @p type.
152 */
153 Q_REQUIRED_RESULT static QString typeLabel(Type type);
154
155private:
156 class Private;
158};
159
160/**
161 Serializes the @p key object into the @p stream.
162*/
163KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Key &key);
164
165/**
166 Initializes the @p key object from the @p stream.
167*/
168KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Key &key);
169}
170Q_DECLARE_TYPEINFO(KContacts::Key, Q_RELOCATABLE_TYPE);
171#endif
A class to store an encryption key.
Definition key.h:22
QList< Key > List
List of keys.
Definition key.h:30
friend KCONTACTS_EXPORT QDataStream & operator>>(QDataStream &, Key &)
Initializes the key object from the stream.
Type
Key types.
Definition key.h:35
@ Custom
Custom or IANA conform key.
Definition key.h:38
@ X509
X509 key.
Definition key.h:36
@ PGP
Pretty Good Privacy key.
Definition key.h:37
friend KCONTACTS_EXPORT QDataStream & operator<<(QDataStream &, const Key &)
Serializes the key object into the stream.
QList< Type > TypeList
List of key types.
Definition key.h:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:08 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.