author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /kabc/key.h | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | kabc/key.h | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/kabc/key.h b/kabc/key.h new file mode 100644 index 0000000..6ea5b47 --- a/dev/null +++ b/kabc/key.h | |||
@@ -0,0 +1,155 @@ | |||
1 | /* | ||
2 | This file is part of libkabc. | ||
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | Enhanced Version of the file for platform independent KDE tools. | ||
23 | Copyright (c) 2004 Ulf Schenk | ||
24 | |||
25 | $Id$ | ||
26 | */ | ||
27 | |||
28 | #ifndef KABC_KEY_H | ||
29 | #define KABC_KEY_H | ||
30 | |||
31 | #include <qvaluelist.h> | ||
32 | |||
33 | namespace KABC { | ||
34 | |||
35 | /** | ||
36 | * @short A class to store an encryption key. | ||
37 | */ | ||
38 | class Key | ||
39 | { | ||
40 | friend QDataStream &operator<<( QDataStream &, const Key & ); | ||
41 | friend QDataStream &operator>>( QDataStream &, Key & ); | ||
42 | |||
43 | public: | ||
44 | typedef QValueList<Key> List; | ||
45 | typedef QValueList<int> TypeList; | ||
46 | |||
47 | /** | ||
48 | * Key types | ||
49 | * | ||
50 | * @li X509 - X509 key | ||
51 | * @li PGP - Pretty Good Privacy key | ||
52 | * @li Custom - Custom or IANA conform key | ||
53 | */ | ||
54 | enum Types { | ||
55 | X509, | ||
56 | PGP, | ||
57 | Custom | ||
58 | }; | ||
59 | |||
60 | /** | ||
61 | * Constructor. | ||
62 | * | ||
63 | * @param text The text data. | ||
64 | * @param type The key type, @see Types. | ||
65 | */ | ||
66 | Key( const QString &text = QString::null, int type = PGP ); | ||
67 | |||
68 | /** | ||
69 | * Destructor. | ||
70 | */ | ||
71 | ~Key(); | ||
72 | |||
73 | bool operator==( const Key & ) const; | ||
74 | bool operator!=( const Key & ) const; | ||
75 | |||
76 | /** | ||
77 | * Sets the unique identifier. | ||
78 | */ | ||
79 | void setId( const QString &id ); | ||
80 | |||
81 | /** | ||
82 | * Returns the unique identifier. | ||
83 | */ | ||
84 | QString id() const; | ||
85 | |||
86 | /** | ||
87 | * Sets binary data. | ||
88 | */ | ||
89 | void setBinaryData( const QByteArray &binary ); | ||
90 | |||
91 | /** | ||
92 | * Returns the binary data. | ||
93 | */ | ||
94 | QByteArray binaryData() const; | ||
95 | |||
96 | /** | ||
97 | * Sets text data. | ||
98 | */ | ||
99 | void setTextData( const QString &text ); | ||
100 | |||
101 | /** | ||
102 | * Returns the text data. | ||
103 | */ | ||
104 | QString textData() const; | ||
105 | |||
106 | /** | ||
107 | * Returns whether the key contains binary or text data. | ||
108 | */ | ||
109 | bool isBinary() const; | ||
110 | |||
111 | /** | ||
112 | * Sets the type, @see Type. | ||
113 | */ | ||
114 | void setType( int type ); | ||
115 | |||
116 | /** | ||
117 | * Sets custom type string. | ||
118 | */ | ||
119 | void setCustomTypeString( const QString &custom ); | ||
120 | |||
121 | /** | ||
122 | * Returns the type, @see Type. | ||
123 | */ | ||
124 | int type() const; | ||
125 | |||
126 | /** | ||
127 | * Returns the custom type string. | ||
128 | */ | ||
129 | QString customTypeString() const; | ||
130 | |||
131 | /** | ||
132 | * Returns a list of all available key types. | ||
133 | */ | ||
134 | static TypeList typeList(); | ||
135 | |||
136 | /** | ||
137 | * Returns a translated label for a given key type. | ||
138 | */ | ||
139 | static QString typeLabel( int type ); | ||
140 | |||
141 | private: | ||
142 | QByteArray mBinaryData; | ||
143 | QString mId; | ||
144 | QString mTextData; | ||
145 | QString mCustomTypeString; | ||
146 | |||
147 | int mIsBinary; | ||
148 | int mType; | ||
149 | }; | ||
150 | |||
151 | QDataStream &operator<<( QDataStream &, const Key & ); | ||
152 | QDataStream &operator>>( QDataStream &, Key & ); | ||
153 | |||
154 | } | ||
155 | #endif | ||