1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
/* -*- mode: C++; c-file-style: "gnu" -*-
* User identity information
*
* Author: Stefan Taferner <taferner@kde.org>
* This code is under GPL
*/
#ifndef kpim_identity_h
#define kpim_identity_h
#include <kleo/enum.h>
#include <tdepimmacros.h>
#include <tqstring.h>
#include <tqcstring.h>
#include <tqstringlist.h>
class TDEProcess;
namespace KPIM {
class Identity;
class Signature;
}
class KConfigBase;
class IdentityList;
class TQDataStream;
namespace KPIM {
/**
* @short abstraction of a signature (aka "footer").
* @author Marc Mutz <mutz@kde.org>
*/
class KDE_EXPORT Signature {
friend class Identity;
friend TQDataStream & KPIM::operator<<( TQDataStream & stream, const Signature & sig );
friend TQDataStream & KPIM::operator>>( TQDataStream & stream, Signature & sig );
public:
/** Type of signature (ie. way to obtain the signature text) */
enum Type { Disabled = 0, Inlined = 1, FromFile = 2, FromCommand = 3 };
/** Used for comparison */
bool operator==( const Signature & other ) const;
/** Constructor for disabled signature */
Signature();
/** Constructor for inline text */
Signature( const TQString & text );
/** Constructor for text from a file or from output of a command */
Signature( const TQString & url, bool isExecutable );
/** @return the raw signature text as entered resp. read from file. */
TQString rawText( bool * ok=0 ) const;
/** @return the signature text with a "-- " separator added, if
necessary. */
TQString withSeparator( bool * ok=0 ) const;
/** Set the signature text and mark this signature as being of
"inline text" type. */
void setText( const TQString & text ) { mText = text; }
TQString text() const { return mText; }
/** Set the signature URL and mark this signature as being of
"from file" resp. "from output of command" type. */
void setUrl( const TQString & url, bool isExecutable=false );
TQString url() const { return mUrl; }
/// @return the type of signature (ie. way to obtain the signature text)
Type type() const { return mType; }
void setType( Type type ) { mType = type; }
protected:
void writeConfig( KConfigBase * config ) const;
void readConfig( const KConfigBase * config );
private:
TQString textFromFile( bool * ok ) const;
TQString textFromCommand( bool * ok ) const;
private:
TQString mUrl;
TQString mText;
Type mType;
};
/** User identity information */
class KDE_EXPORT Identity
{
// only the identity manager should be able to construct and
// destruct us, but then we get into problems with using
// TQValueList<Identity> and especially qHeapSort().
friend class IdentityManager;
friend TQDataStream & operator<<( TQDataStream & stream, const KPIM::Identity & ident );
friend TQDataStream & operator>>( TQDataStream & stream, KPIM::Identity & ident );
public:
typedef TQValueList<Identity> List;
/** used for comparison */
bool operator==( const Identity & other ) const;
bool operator!=( const Identity & other ) const {
return !operator==( other );
}
/** used for sorting */
bool operator<( const Identity & other ) const {
if ( isDefault() ) return true;
if ( other.isDefault() ) return false;
return identityName() < other.identityName();
}
bool operator>( const Identity & other ) const {
if ( isDefault() ) return false;
if ( other.isDefault() ) return true;
return identityName() > other.identityName();
}
bool operator<=( const Identity & other ) const {
return !operator>( other );
}
bool operator>=( const Identity & other ) const {
return !operator<( other );
}
/** Constructor */
explicit Identity( const TQString & id=TQString(),
const TQString & realName=TQString(),
const TQString & emailAddr=TQString(),
const TQString & organization=TQString(),
const TQString & replyToAddress=TQString() );
/** Destructor */
~Identity();
protected:
/** Read configuration from config. Group must be preset (or use
KConfigGroup). Called from IdentityManager. */
void readConfig( const KConfigBase * );
/** Write configuration to config. Group must be preset (or use
KConfigGroup). Called from IdentityManager. */
void writeConfig( KConfigBase * ) const;
public:
/** Tests if there are enough values set to allow mailing */
bool mailingAllowed() const;
/** Identity/nickname for this collection */
TQString identityName() const { return mIdentity; }
void setIdentityName( const TQString & name );
/** @return whether this identity is the default identity */
bool isDefault() const { return mIsDefault; }
/// Unique Object Identifier for this identity
uint uoid() const { return mUoid; }
protected:
/** Set whether this identity is the default identity. Since this
affects all other identites, too (most notably, the old default
identity), only the IdentityManager can change this.
You should use
<pre>
kmkernel->identityManager()->setAsDefault( name_of_default )
</pre>
instead.
**/
void setIsDefault( bool flag );
void setUoid( uint aUoid ) { mUoid = aUoid; }
public:
/** Full name of the user */
TQString fullName() const { return mFullName; }
void setFullName(const TQString&);
/** The user's organization (optional) */
TQString organization() const { return mOrganization; }
void setOrganization(const TQString&);
KDE_DEPRECATED TQCString pgpIdentity() const { return pgpEncryptionKey(); }
KDE_DEPRECATED void setPgpIdentity( const TQCString & key ) {
setPGPEncryptionKey( key );
setPGPSigningKey( key );
}
/** The user's OpenPGP encryption key */
TQCString pgpEncryptionKey() const { return mPGPEncryptionKey; }
void setPGPEncryptionKey( const TQCString & key );
/** The user's OpenPGP signing key */
TQCString pgpSigningKey() const { return mPGPSigningKey; }
void setPGPSigningKey( const TQCString & key );
/** The user's S/MIME encryption key */
TQCString smimeEncryptionKey() const { return mSMIMEEncryptionKey; }
void setSMIMEEncryptionKey( const TQCString & key );
/** The user's S/MIME signing key */
TQCString smimeSigningKey() const { return mSMIMESigningKey; }
void setSMIMESigningKey( const TQCString & key );
Kleo::CryptoMessageFormat preferredCryptoMessageFormat() const { return mPreferredCryptoMessageFormat; }
void setPreferredCryptoMessageFormat( Kleo::CryptoMessageFormat format ) { mPreferredCryptoMessageFormat = format; }
/** email address (without the user name - only name\@host) */
KDE_DEPRECATED TQString emailAddr() const { return primaryEmailAddress(); }
KDE_DEPRECATED void setEmailAddr( const TQString & email ) { setPrimaryEmailAddress( email ); }
/** primary email address (without the user name - only name\@host).
The primary email address is used for all outgoing mail. */
TQString primaryEmailAddress() const { return mEmailAddr; }
void setPrimaryEmailAddress( const TQString & email );
/** email address aliases */
const TQStringList & emailAliases() const { return mEmailAliases; }
void setEmailAliases( const TQStringList & );
bool matchesEmailAddress( const TQString & addr ) const;
/** vCard to attach to outgoing emails */
TQString vCardFile() const { return mVCardFile; }
void setVCardFile(const TQString&);
/** email address in the format "username <name@host>" suitable
for the "From:" field of email messages. */
TQString fullEmailAddr() const;
/** email address for the ReplyTo: field */
TQString replyToAddr() const { return mReplyToAddr; }
void setReplyToAddr(const TQString&);
/** email addresses for the BCC: field */
TQString bcc() const { return mBcc; }
void setBcc(const TQString& aBcc) { mBcc = aBcc; }
void setSignature( const Signature & sig ) { mSignature = sig; }
Signature & signature() /* _not_ const! */ { return mSignature; }
const Signature & signature() const { return mSignature; }
protected:
/** @return true if the signature is read from the output of a command */
bool signatureIsCommand() const { return mSignature.type() == Signature::FromCommand; }
/** @return true if the signature is read from a text file */
bool signatureIsPlainFile() const { return mSignature.type() == Signature::FromFile; }
/** @return true if the signature was specified directly */
bool signatureIsInline() const { return mSignature.type() == Signature::Inlined; }
/** name of the signature file (with path) */
TQString signatureFile() const { return mSignature.url(); }
void setSignatureFile(const TQString&);
/** inline signature */
TQString signatureInlineText() const { return mSignature.text();}
void setSignatureInlineText(const TQString&);
/** Inline or signature from a file */
bool useSignatureFile() const { return signatureIsPlainFile() || signatureIsCommand(); }
public:
/** Returns the signature. This method also takes care of special
signature files that are shell scripts and handles them
correct. So use this method to rectreive the contents of the
signature file. If @p prompt is false, no errors will be displayed
(useful for retries). */
TQString signatureText( bool * ok=0) const;
/** The transport that is set for this identity. Used to link a
transport with an identity. */
TQString transport() const { return mTransport; }
void setTransport(const TQString&);
/** The folder where sent messages from this identity will be
stored by default. */
TQString fcc() const { return mFcc; }
void setFcc(const TQString&);
/** The folder where draft messages from this identity will be
stored by default. */
TQString drafts() const { return mDrafts; }
void setDrafts(const TQString&);
/** The folder where template messages from this identity will be
stored by default. */
TQString templates() const { return mTemplates; }
void setTemplates( const TQString& );
/** dictionary which should be used for spell checking */
TQString dictionary() const { return mDictionary; }
void setDictionary( const TQString& );
/** a X-Face header for this identity */
TQString xface() const { return mXFace; }
void setXFace( const TQString& );
bool isXFaceEnabled() const { return mXFaceEnabled; }
void setXFaceEnabled( const bool );
static const Identity& null();
bool isNull() const;
protected:
// if you add new members, make sure they have an operator= (or the
// compiler can synthesize one) and amend Identity::operator==,
// isNull(), readConfig() and writeConfig() as well as operator<<
// and operator>> accordingly:
uint mUoid;
TQString mIdentity, mFullName, mEmailAddr, mOrganization;
TQStringList mEmailAliases;
TQString mReplyToAddr;
TQString mBcc;
TQString mVCardFile;
TQCString mPGPEncryptionKey, mPGPSigningKey, mSMIMEEncryptionKey, mSMIMESigningKey;
TQString mFcc, mDrafts, mTemplates, mTransport;
TQString mDictionary;
TQString mXFace;
bool mXFaceEnabled;
Signature mSignature;
bool mIsDefault;
Kleo::CryptoMessageFormat mPreferredCryptoMessageFormat;
};
KDE_EXPORT TQDataStream & operator<<( TQDataStream & stream, const KPIM::Signature & sig );
KDE_EXPORT TQDataStream & operator>>( TQDataStream & stream, KPIM::Signature & sig );
KDE_EXPORT TQDataStream & operator<<( TQDataStream & stream, const KPIM::Identity & ident );
KDE_EXPORT TQDataStream & operator>>( TQDataStream & stream, KPIM::Identity & ident );
} // namespace KPIM
#endif /*kpim_identity_h*/
|