libkpimidentities

identity.cpp
1 // -*- mode: C++; c-file-style: "gnu" -*-
2 // tdemidentity.cpp
3 // License: GPL
4 
5 #ifdef HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8 
9 #include "identity.h"
10 
11 #include <libtdepim/tdefileio.h>
12 #include <libtdepim/collectingprocess.h>
13 
14 #include <kdebug.h>
15 #include <tdelocale.h>
16 #include <tdemessagebox.h>
17 #include <tdeconfig.h>
18 #include <kurl.h>
19 
20 #include <tqfileinfo.h>
21 
22 #include <sys/types.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <errno.h>
26 #include <assert.h>
27 
28 using namespace KPIM;
29 
30 
32  : mType( Disabled )
33 {
34 
35 }
36 
37 Signature::Signature( const TQString & text )
38  : mText( text ),
39  mType( Inlined )
40 {
41 
42 }
43 
44 Signature::Signature( const TQString & url, bool isExecutable )
45  : mUrl( url ),
46  mType( isExecutable ? FromCommand : FromFile )
47 {
48 }
49 
50 bool Signature::operator==( const Signature & other ) const {
51  if ( mType != other.mType ) return false;
52  switch ( mType ) {
53  case Inlined: return mText == other.mText;
54  case FromFile:
55  case FromCommand: return mUrl == other.mUrl;
56  default:
57  case Disabled: return true;
58  }
59 }
60 
61 TQString Signature::rawText( bool * ok ) const
62 {
63  switch ( mType ) {
64  case Disabled:
65  if ( ok ) *ok = true;
66  return TQString();
67  case Inlined:
68  if ( ok ) *ok = true;
69  return mText;
70  case FromFile:
71  return textFromFile( ok );
72  case FromCommand:
73  return textFromCommand( ok );
74  };
75  kdFatal( 5006 ) << "Signature::type() returned unknown value!" << endl;
76  return TQString(); // make compiler happy
77 }
78 
79 TQString Signature::textFromCommand( bool * ok ) const
80 {
81  assert( mType == FromCommand );
82 
83  // handle pathological cases:
84  if ( mUrl.isEmpty() ) {
85  if ( ok ) *ok = true;
86  return TQString();
87  }
88 
89  // create a shell process:
90  CollectingProcess proc;
91  proc.setUseShell(true);
92  proc << mUrl;
93 
94  // run the process:
95  int rc = 0;
96  if ( !proc.start( TDEProcess::Block, TDEProcess::Stdout ) )
97  rc = -1;
98  else
99  rc = ( proc.normalExit() ) ? proc.exitStatus() : -1 ;
100 
101  // handle errors, if any:
102  if ( rc != 0 ) {
103  if ( ok ) *ok = false;
104  TQString wmsg = i18n("<qt>Failed to execute signature script<br><b>%1</b>:<br>%2</qt>")
105  .arg( mUrl ).arg( strerror(rc) );
106  KMessageBox::error(0, wmsg);
107  return TQString();
108  }
109 
110  // no errors:
111  if ( ok ) *ok = true;
112 
113  // get output:
114  TQByteArray output = proc.collectedStdout();
115 
116  // ### hmm, should we allow other encodings, too?
117  return TQString::fromLocal8Bit( output.data(), output.size() );
118 }
119 
120 TQString Signature::textFromFile( bool * ok ) const
121 {
122  assert( mType == FromFile );
123 
124  // ### FIXME: Use TDEIO::NetAccess to download non-local files!
125  if ( !KURL(mUrl).isLocalFile() && !(TQFileInfo(mUrl).isRelative()
126  && TQFileInfo(mUrl).exists()) ) {
127  kdDebug( 5006 ) << "Signature::textFromFile: non-local URLs are unsupported" << endl;
128  if ( ok ) *ok = false;
129  return TQString();
130  }
131  if ( ok ) *ok = true;
132  // ### hmm, should we allow other encodings, too?
133  return TQString::fromLocal8Bit( kFileToString( mUrl, false ) );
134 }
135 
136 TQString Signature::withSeparator( bool * ok ) const
137 {
138  bool internalOK = false;
139  TQString signature = rawText( &internalOK );
140  if ( !internalOK ) {
141  if ( ok ) *ok = false;
142  return TQString();
143  }
144  if ( ok ) *ok = true;
145  if ( signature.isEmpty() ) return signature; // don't add a separator in this case
146  if ( signature.startsWith( TQString::fromLatin1("-- \n") ) )
147  // already have signature separator at start of sig:
148  return TQString::fromLatin1("\n") += signature;
149  else if ( signature.find( TQString::fromLatin1("\n-- \n") ) != -1 )
150  // already have signature separator inside sig; don't prepend '\n'
151  // to improve abusing signatures as templates:
152  return signature;
153  else
154  // need to prepend one:
155  return TQString::fromLatin1("\n-- \n") + signature;
156 }
157 
158 
159 void Signature::setUrl( const TQString & url, bool isExecutable )
160 {
161  mUrl = url;
162  mType = isExecutable ? FromCommand : FromFile ;
163 }
164 
165 // config keys and values:
166 static const char sigTypeKey[] = "Signature Type";
167 static const char sigTypeInlineValue[] = "inline";
168 static const char sigTypeFileValue[] = "file";
169 static const char sigTypeCommandValue[] = "command";
170 static const char sigTypeDisabledValue[] = "disabled";
171 static const char sigTextKey[] = "Inline Signature";
172 static const char sigFileKey[] = "Signature File";
173 static const char sigCommandKey[] = "Signature Command";
174 
175 void Signature::readConfig( const TDEConfigBase * config )
176 {
177  TQString sigType = config->readEntry( sigTypeKey );
178  if ( sigType == sigTypeInlineValue ) {
179  mType = Inlined;
180  } else if ( sigType == sigTypeFileValue ) {
181  mType = FromFile;
182  mUrl = config->readPathEntry( sigFileKey );
183  } else if ( sigType == sigTypeCommandValue ) {
184  mType = FromCommand;
185  mUrl = config->readPathEntry( sigCommandKey );
186  } else {
187  mType = Disabled;
188  }
189  mText = config->readEntry( sigTextKey );
190 }
191 
192 void Signature::writeConfig( TDEConfigBase * config ) const
193 {
194  switch ( mType ) {
195  case Inlined:
196  config->writeEntry( sigTypeKey, sigTypeInlineValue );
197  break;
198  case FromFile:
199  config->writeEntry( sigTypeKey, sigTypeFileValue );
200  config->writePathEntry( sigFileKey, mUrl );
201  break;
202  case FromCommand:
203  config->writeEntry( sigTypeKey, sigTypeCommandValue );
204  config->writePathEntry( sigCommandKey, mUrl );
205  break;
206  case Disabled:
207  config->writeEntry( sigTypeKey, sigTypeDisabledValue );
208  default: ;
209  }
210  config->writeEntry( sigTextKey, mText );
211 }
212 
213 TQDataStream & KPIM::operator<<( TQDataStream & stream, const KPIM::Signature & sig ) {
214  return stream << static_cast<TQ_UINT8>(sig.mType)
215  << sig.mUrl
216  << sig.mText;
217 }
218 
219 TQDataStream & KPIM::operator>>( TQDataStream & stream, KPIM::Signature & sig ) {
220  TQ_UINT8 s;
221  stream >> s
222  >> sig.mUrl
223  >> sig.mText;
224  sig.mType = static_cast<Signature::Type>(s);
225  return stream;
226 }
227 
228 // ### should use a kstaticdeleter?
229 static Identity* identityNull = 0;
230 const Identity& Identity::null()
231 {
232  if ( !identityNull )
233  identityNull = new Identity;
234  return *identityNull;
235 }
236 
237 bool Identity::isNull() const {
238  return mIdentity.isEmpty() && mFullName.isEmpty() && mEmailAddr.isEmpty() &&
239  mEmailAliases.empty() &&
240  mOrganization.isEmpty() && mReplyToAddr.isEmpty() && mBcc.isEmpty() &&
241  mVCardFile.isEmpty() &&
242  mFcc.isEmpty() && mDrafts.isEmpty() && mTemplates.isEmpty() &&
243  mPGPEncryptionKey.isEmpty() && mPGPSigningKey.isEmpty() &&
244  mSMIMEEncryptionKey.isEmpty() && mSMIMESigningKey.isEmpty() &&
245  mTransport.isEmpty() && mDictionary.isEmpty() &&
246  mPreferredCryptoMessageFormat == Kleo::AutoFormat &&
247  mSignature.type() == Signature::Disabled &&
248  mXFace.isEmpty();
249 }
250 
251 bool Identity::operator==( const Identity & other ) const {
252  bool same = mUoid == other.mUoid &&
253  mIdentity == other.mIdentity && mFullName == other.mFullName &&
254  mEmailAddr == other.mEmailAddr && mOrganization == other.mOrganization &&
255  mEmailAliases == other.mEmailAliases &&
256  mReplyToAddr == other.mReplyToAddr && mBcc == other.mBcc &&
257  mVCardFile == other.mVCardFile &&
258  mFcc == other.mFcc &&
259  mPGPEncryptionKey == other.mPGPEncryptionKey &&
260  mPGPSigningKey == other.mPGPSigningKey &&
261  mSMIMEEncryptionKey == other.mSMIMEEncryptionKey &&
262  mSMIMESigningKey == other.mSMIMESigningKey &&
263  mPreferredCryptoMessageFormat == other.mPreferredCryptoMessageFormat &&
264  mDrafts == other.mDrafts && mTemplates == other.mTemplates &&
265  mTransport == other.mTransport &&
266  mDictionary == other.mDictionary && mSignature == other.mSignature &&
267  mXFace == other.mXFace && mXFaceEnabled == other.mXFaceEnabled;
268 
269 #if 0
270  if ( same )
271  return true;
272  if ( mUoid != other.mUoid ) kdDebug() << "mUoid differs : " << mUoid << " != " << other.mUoid << endl;
273  if ( mIdentity != other.mIdentity ) kdDebug() << "mIdentity differs : " << mIdentity << " != " << other.mIdentity << endl;
274  if ( mFullName != other.mFullName ) kdDebug() << "mFullName differs : " << mFullName << " != " << other.mFullName << endl;
275  if ( mEmailAddr != other.mEmailAddr ) kdDebug() << "mEmailAddr differs : " << mEmailAddr << " != " << other.mEmailAddr << endl;
276  if ( mEmailAliases != other.mEmailAliases ) kdDebug() << "mEmailAliases differs : " << mEmailAliases.join(";") << " != " << other.mEmailAliases.join(";") << endl;
277  if ( mOrganization != other.mOrganization ) kdDebug() << "mOrganization differs : " << mOrganization << " != " << other.mOrganization << endl;
278  if ( mReplyToAddr != other.mReplyToAddr ) kdDebug() << "mReplyToAddr differs : " << mReplyToAddr << " != " << other.mReplyToAddr << endl;
279  if ( mBcc != other.mBcc ) kdDebug() << "mBcc differs : " << mBcc << " != " << other.mBcc << endl;
280  if ( mVCardFile != other.mVCardFile ) kdDebug() << "mVCardFile differs : " << mVCardFile << " != " << other.mVCardFile << endl;
281  if ( mFcc != other.mFcc ) kdDebug() << "mFcc differs : " << mFcc << " != " << other.mFcc << endl;
282  if ( mPGPEncryptionKey != other.mPGPEncryptionKey ) kdDebug() << "mPGPEncryptionKey differs : " << mPGPEncryptionKey << " != " << other.mPGPEncryptionKey << endl;
283  if ( mPGPSigningKey != other.mPGPSigningKey ) kdDebug() << "mPGPSigningKey differs : " << mPGPSigningKey << " != " << other.mPGPSigningKey << endl;
284  if ( mSMIMEEncryptionKey != other.mSMIMEEncryptionKey ) kdDebug() << "mSMIMEEncryptionKey differs : '" << mSMIMEEncryptionKey << "' != '" << other.mSMIMEEncryptionKey << "'" << endl;
285  if ( mSMIMESigningKey != other.mSMIMESigningKey ) kdDebug() << "mSMIMESigningKey differs : " << mSMIMESigningKey << " != " << other.mSMIMESigningKey << endl;
286  if ( mPreferredCryptoMessageFormat != other.mPreferredCryptoMessageFormat ) kdDebug() << "mPreferredCryptoMessageFormat differs : " << mPreferredCryptoMessageFormat << " != " << other.mPreferredCryptoMessageFormat << endl;
287  if ( mDrafts != other.mDrafts ) kdDebug() << "mDrafts differs : " << mDrafts << " != " << other.mDrafts << endl;
288  if ( mTemplates != other.mTemplates ) kdDebug() << "mTemplates differs : " << mTemplates << " != " << other.mTemplates << endl;
289  if ( mTransport != other.mTransport ) kdDebug() << "mTransport differs : " << mTransport << " != " << other.mTransport << endl;
290  if ( mDictionary != other.mDictionary ) kdDebug() << "mDictionary differs : " << mDictionary << " != " << other.mDictionary << endl;
291  if ( ! ( mSignature == other.mSignature ) ) kdDebug() << "mSignature differs" << endl;
292 #endif
293  return same;
294 }
295 
296 Identity::Identity( const TQString & id, const TQString & fullName,
297  const TQString & emailAddr, const TQString & organization,
298  const TQString & replyToAddr )
299  : mUoid( 0 ), mIdentity( id ), mFullName( fullName ),
300  mEmailAddr( emailAddr ), mOrganization( organization ),
301  mReplyToAddr( replyToAddr ),
302  // Using "" instead of null to make operator==() not fail
303  // (readConfig returns "")
304  mBcc( "" ), mVCardFile( "" ), mPGPEncryptionKey( "" ), mPGPSigningKey( "" ),
305  mSMIMEEncryptionKey( "" ), mSMIMESigningKey( "" ), mFcc( "" ),
306  mDrafts( "" ), mTemplates( "" ), mTransport( "" ),
307  mDictionary( "" ),
308  mXFace( "" ), mXFaceEnabled( false ),
309  mIsDefault( false ),
310  mPreferredCryptoMessageFormat( Kleo::AutoFormat )
311 {
312 }
313 
315 {
316 }
317 
318 
319 void Identity::readConfig( const TDEConfigBase * config )
320 {
321  mUoid = config->readUnsignedNumEntry("uoid",0);
322 
323  mIdentity = config->readEntry("Identity");
324  mFullName = config->readEntry("Name");
325  mEmailAddr = config->readEntry("Email Address");
326  mEmailAliases = config->readListEntry("Email Aliases");
327  mVCardFile = config->readPathEntry("VCardFile");
328  mOrganization = config->readEntry("Organization");
329  mPGPSigningKey = config->readEntry("PGP Signing Key").latin1();
330  mPGPEncryptionKey = config->readEntry("PGP Encryption Key").latin1();
331  mSMIMESigningKey = config->readEntry("SMIME Signing Key").latin1();
332  mSMIMEEncryptionKey = config->readEntry("SMIME Encryption Key").latin1();
333  mPreferredCryptoMessageFormat = Kleo::stringToCryptoMessageFormat( config->readEntry("Preferred Crypto Message Format", "none" ) );
334  mReplyToAddr = config->readEntry( "Reply-To Address" );
335  mBcc = config->readEntry( "Bcc" );
336  mFcc = config->readEntry( "Fcc", "sent-mail" );
337  if( mFcc.isEmpty() )
338  mFcc = "sent-mail";
339  mDrafts = config->readEntry( "Drafts", "drafts" );
340  if( mDrafts.isEmpty() )
341  mDrafts = "drafts";
342  mTemplates = config->readEntry( "Templates", "templates" );
343  if( mTemplates.isEmpty() )
344  mTemplates = "templates";
345  mTransport = config->readEntry( "Transport" );
346  mDictionary = config->readEntry( "Dictionary" );
347  mXFace = config->readEntry( "X-Face" );
348  mXFaceEnabled = config->readBoolEntry( "X-FaceEnabled", false );
349 
350  mSignature.readConfig( config );
351  kdDebug(5006) << "Identity::readConfig(): UOID = " << mUoid
352  << " for identity named \"" << mIdentity << "\"" << endl;
353 }
354 
355 
356 void Identity::writeConfig( TDEConfigBase * config ) const
357 {
358  config->writeEntry("uoid", mUoid);
359 
360  config->writeEntry("Identity", mIdentity);
361  config->writeEntry("Name", mFullName);
362  config->writeEntry("Organization", mOrganization);
363  config->writeEntry("PGP Signing Key", mPGPSigningKey.data());
364  config->writeEntry("PGP Encryption Key", mPGPEncryptionKey.data());
365  config->writeEntry("SMIME Signing Key", mSMIMESigningKey.data());
366  config->writeEntry("SMIME Encryption Key", mSMIMEEncryptionKey.data());
367  config->writeEntry("Preferred Crypto Message Format", Kleo::cryptoMessageFormatToString( mPreferredCryptoMessageFormat ) );
368  config->writeEntry("Email Address", mEmailAddr);
369  config->writeEntry("Email Aliases", mEmailAliases);
370  config->writeEntry("Reply-To Address", mReplyToAddr);
371  config->writeEntry("Bcc", mBcc);
372  config->writePathEntry("VCardFile", mVCardFile);
373  config->writeEntry("Transport", mTransport);
374  config->writeEntry("Fcc", mFcc);
375  config->writeEntry("Drafts", mDrafts);
376  config->writeEntry("Templates", mTemplates);
377  config->writeEntry( "Dictionary", mDictionary );
378  config->writeEntry( "X-Face", mXFace );
379  config->writeEntry( "X-FaceEnabled", mXFaceEnabled );
380 
381  mSignature.writeConfig( config );
382 }
383 
384 TQDataStream & KPIM::operator<<( TQDataStream & stream, const KPIM::Identity & i ) {
385  return stream << static_cast<TQ_UINT32>(i.uoid())
386  << i.identityName()
387  << i.fullName()
388  << i.organization()
389  << i.pgpSigningKey()
390  << i.pgpEncryptionKey()
391  << i.smimeSigningKey()
392  << i.smimeEncryptionKey()
393  << i.primaryEmailAddress()
394  << i.emailAliases()
395  << i.replyToAddr()
396  << i.bcc()
397  << i.vCardFile()
398  << i.transport()
399  << i.fcc()
400  << i.drafts()
401  << i.templates()
402  << i.mSignature
403  << i.dictionary()
404  << i.xface()
405  << TQString( Kleo::cryptoMessageFormatToString( i.mPreferredCryptoMessageFormat ) );
406 }
407 
408 TQDataStream & KPIM::operator>>( TQDataStream & stream, KPIM::Identity & i ) {
409  TQ_UINT32 uoid;
410  TQString format;
411  stream >> uoid
412  >> i.mIdentity
413  >> i.mFullName
414  >> i.mOrganization
415  >> i.mPGPSigningKey
416  >> i.mPGPEncryptionKey
417  >> i.mSMIMESigningKey
418  >> i.mSMIMEEncryptionKey
419  >> i.mEmailAddr
420  >> i.mEmailAliases
421  >> i.mReplyToAddr
422  >> i.mBcc
423  >> i.mVCardFile
424  >> i.mTransport
425  >> i.mFcc
426  >> i.mDrafts
427  >> i.mTemplates
428  >> i.mSignature
429  >> i.mDictionary
430  >> i.mXFace
431  >> format;
432  i.mUoid = uoid;
433  i.mPreferredCryptoMessageFormat = Kleo::stringToCryptoMessageFormat( format.latin1() );
434 
435  return stream;
436 }
437 
438 //-----------------------------------------------------------------------------
440 {
441  return !mEmailAddr.isEmpty();
442 }
443 
444 
445 void Identity::setIsDefault( bool flag ) {
446  mIsDefault = flag;
447 }
448 
449 void Identity::setIdentityName( const TQString & name ) {
450  mIdentity = name;
451 }
452 
453 void Identity::setFullName(const TQString &str)
454 {
455  mFullName = str;
456 }
457 
458 
459 //-----------------------------------------------------------------------------
460 void Identity::setOrganization(const TQString &str)
461 {
462  mOrganization = str;
463 }
464 
465 void Identity::setPGPSigningKey(const TQCString &str)
466 {
467  mPGPSigningKey = str;
468  if ( mPGPSigningKey.isNull() )
469  mPGPSigningKey = "";
470 }
471 
472 void Identity::setPGPEncryptionKey(const TQCString &str)
473 {
474  mPGPEncryptionKey = str;
475  if ( mPGPEncryptionKey.isNull() )
476  mPGPEncryptionKey = "";
477 }
478 
479 void Identity::setSMIMESigningKey(const TQCString &str)
480 {
481  mSMIMESigningKey = str;
482  if ( mSMIMESigningKey.isNull() )
483  mSMIMESigningKey = "";
484 }
485 
486 void Identity::setSMIMEEncryptionKey(const TQCString &str)
487 {
488  mSMIMEEncryptionKey = str;
489  if ( mSMIMEEncryptionKey.isNull() )
490  mSMIMEEncryptionKey = "";
491 }
492 
493 //-----------------------------------------------------------------------------
494 void Identity::setPrimaryEmailAddress( const TQString & str )
495 {
496  mEmailAddr = str;
497 }
498 
499 void Identity::setEmailAliases( const TQStringList & list )
500 {
501  mEmailAliases = list;
502 }
503 
504 bool Identity::matchesEmailAddress( const TQString & addr ) const
505 {
506  const TQString lower = addr.lower();
507  if ( lower == mEmailAddr.lower() )
508  return true;
509  for ( TQStringList::const_iterator it = mEmailAliases.begin(), end = mEmailAliases.end() ; it != end ; ++it )
510  if ( (*it).lower() == lower )
511  return true;
512  return false;
513 }
514 
515 //-----------------------------------------------------------------------------
516 void Identity::setVCardFile(const TQString &str)
517 {
518  mVCardFile = str;
519 }
520 
521 
522 //-----------------------------------------------------------------------------
523 TQString Identity::fullEmailAddr(void) const
524 {
525  if (mFullName.isEmpty()) return mEmailAddr;
526 
527  const TQString specials("()<>@,.;:[]");
528 
529  TQString result;
530 
531  // add DQUOTE's if necessary:
532  bool needsQuotes=false;
533  for (unsigned int i=0; i < mFullName.length(); i++) {
534  if ( specials.contains( mFullName[i] ) )
535  needsQuotes = true;
536  else if ( mFullName[i] == '\\' || mFullName[i] == '"' ) {
537  needsQuotes = true;
538  result += '\\';
539  }
540  result += mFullName[i];
541  }
542 
543  if (needsQuotes) {
544  result.insert(0,'"');
545  result += '"';
546  }
547 
548  result += " <" + mEmailAddr + '>';
549 
550  return result;
551 }
552 
553 //-----------------------------------------------------------------------------
554 void Identity::setReplyToAddr(const TQString& str)
555 {
556  mReplyToAddr = str;
557 }
558 
559 
560 //-----------------------------------------------------------------------------
561 void Identity::setSignatureFile(const TQString &str)
562 {
563  mSignature.setUrl( str, signatureIsCommand() );
564 }
565 
566 
567 //-----------------------------------------------------------------------------
568 void Identity::setSignatureInlineText(const TQString &str )
569 {
570  mSignature.setText( str );
571 }
572 
573 
574 //-----------------------------------------------------------------------------
575 void Identity::setTransport( const TQString &str )
576 {
577  mTransport = str;
578  if ( mTransport.isNull() )
579  mTransport = "";
580 }
581 
582 //-----------------------------------------------------------------------------
583 void Identity::setFcc( const TQString &str )
584 {
585  mFcc = str;
586  if ( mFcc.isNull() )
587  mFcc = "";
588 }
589 
590 //-----------------------------------------------------------------------------
591 void Identity::setDrafts( const TQString &str )
592 {
593  mDrafts = str;
594  if ( mDrafts.isNull() )
595  mDrafts = "";
596 }
597 
598 //-----------------------------------------------------------------------------
599 void Identity::setTemplates( const TQString &str )
600 {
601  mTemplates = str;
602  if ( mTemplates.isNull() )
603  mTemplates = "";
604 }
605 
606 //-----------------------------------------------------------------------------
607 void Identity::setDictionary( const TQString &str )
608 {
609  mDictionary = str;
610  if ( mDictionary.isNull() )
611  mDictionary = "";
612 }
613 
614 
615 //-----------------------------------------------------------------------------
616 void Identity::setXFace( const TQString &str )
617 {
618  mXFace = str;
619  mXFace.remove( " " );
620  mXFace.remove( "\n" );
621  mXFace.remove( "\r" );
622 }
623 
624 
625 //-----------------------------------------------------------------------------
626 void Identity::setXFaceEnabled( const bool on )
627 {
628  mXFaceEnabled = on;
629 }
630 
631 
632 //-----------------------------------------------------------------------------
633 TQString Identity::signatureText( bool * ok ) const
634 {
635  bool internalOK = false;
636  TQString signatureText = mSignature.withSeparator( &internalOK );
637  if ( internalOK ) {
638  if ( ok ) *ok=true;
639  return signatureText;
640  }
641 
642  // OK, here comes the funny part. The call to
643  // Signature::withSeparator() failed, so we should probably fix the
644  // cause:
645  if ( ok ) *ok = false;
646  return TQString();
647 
648 #if 0 // ### FIXME: error handling
649  if (mSignatureFile.endsWith("|"))
650  {
651  }
652  else
653  {
654  }
655 #endif
656 
657  return TQString();
658 }
TQCString smimeEncryptionKey() const
The user&#39;s S/MIME encryption key.
Definition: identity.h:204
TQString templates() const
The folder where template messages from this identity will be stored by default.
Definition: identity.h:293
TQString xface() const
a X-Face header for this identity
Definition: identity.h:301
bool signatureIsCommand() const
Definition: identity.h:251
TQString identityName() const
Identity/nickname for this collection.
Definition: identity.h:157
TQString fullEmailAddr() const
email address in the format "username <name@host>" suitable for the "From:" field of email messages...
Definition: identity.cpp:523
TQString withSeparator(bool *ok=0) const
Definition: identity.cpp:136
TQString dictionary() const
dictionary which should be used for spell checking
Definition: identity.h:297
Type
Type of signature (ie.
Definition: identity.h:47
TQString vCardFile() const
vCard to attach to outgoing emails
Definition: identity.h:230
void setIsDefault(bool flag)
Set whether this identity is the default identity.
Definition: identity.cpp:445
TQString organization() const
The user&#39;s organization (optional)
Definition: identity.h:186
bool operator==(const Identity &other) const
used for comparison
Definition: identity.cpp:251
TQString drafts() const
The folder where draft messages from this identity will be stored by default.
Definition: identity.h:288
TQString bcc() const
email addresses for the BCC: field
Definition: identity.h:242
uint uoid() const
Unique Object Identifier for this identity.
Definition: identity.h:164
bool operator==(const Signature &other) const
Used for comparison.
Definition: identity.cpp:50
bool mailingAllowed() const
Tests if there are enough values set to allow mailing.
Definition: identity.cpp:439
Signature()
Constructor for disabled signature.
Definition: identity.cpp:31
User identity information.
Definition: identity.h:95
void setText(const TQString &text)
Set the signature text and mark this signature as being of "inline text" type.
Definition: identity.h:68
TQCString pgpEncryptionKey() const
The user&#39;s OpenPGP encryption key.
Definition: identity.h:196
TQString rawText(bool *ok=0) const
Definition: identity.cpp:61
TQCString pgpSigningKey() const
The user&#39;s OpenPGP signing key.
Definition: identity.h:200
TQString signatureText(bool *ok=0) const
Returns the signature.
Definition: identity.cpp:633
const TQStringList & emailAliases() const
email address aliases
Definition: identity.h:224
Identity(const TQString &id=TQString(), const TQString &realName=TQString(), const TQString &emailAddr=TQString(), const TQString &organization=TQString(), const TQString &replyToAddress=TQString())
Constructor.
Definition: identity.cpp:296
void setUrl(const TQString &url, bool isExecutable=false)
Set the signature URL and mark this signature as being of "from file" resp.
Definition: identity.cpp:159
TQString replyToAddr() const
email address for the ReplyTo: field
Definition: identity.h:238
TQCString smimeSigningKey() const
The user&#39;s S/MIME signing key.
Definition: identity.h:208
~Identity()
Destructor.
Definition: identity.cpp:314
Definition: identity.h:19
TQString fcc() const
The folder where sent messages from this identity will be stored by default.
Definition: identity.h:283
TQString fullName() const
Full name of the user.
Definition: identity.h:182
void writeConfig(TDEConfigBase *) const
Write configuration to config.
Definition: identity.cpp:356
TQString transport() const
The transport that is set for this identity.
Definition: identity.h:278
abstraction of a signature (aka "footer").
Definition: identity.h:39
void readConfig(const TDEConfigBase *)
Read configuration from config.
Definition: identity.cpp:319
TQString primaryEmailAddress() const
primary email address (without the user name - only name@host).
Definition: identity.h:220