TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

658 lines
20 KiB

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