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