identity.cpp
00001 // -*- mode: C++; c-file-style: "gnu" -*- 00002 // tdemidentity.cpp 00003 // License: GPL 00004 00005 #ifdef HAVE_CONFIG_H 00006 #include <config.h> 00007 #endif 00008 00009 #include "identity.h" 00010 00011 #include <libtdepim/tdefileio.h> 00012 #include <libtdepim/collectingprocess.h> 00013 00014 #include <kdebug.h> 00015 #include <tdelocale.h> 00016 #include <tdemessagebox.h> 00017 #include <tdeconfig.h> 00018 #include <kurl.h> 00019 00020 #include <tqfileinfo.h> 00021 00022 #include <sys/types.h> 00023 #include <stdlib.h> 00024 #include <stdio.h> 00025 #include <errno.h> 00026 #include <assert.h> 00027 00028 using namespace KPIM; 00029 00030 00031 Signature::Signature() 00032 : mType( Disabled ) 00033 { 00034 00035 } 00036 00037 Signature::Signature( const TQString & text ) 00038 : mText( text ), 00039 mType( Inlined ) 00040 { 00041 00042 } 00043 00044 Signature::Signature( const TQString & url, bool isExecutable ) 00045 : mUrl( url ), 00046 mType( isExecutable ? FromCommand : FromFile ) 00047 { 00048 } 00049 00050 bool Signature::operator==( const Signature & other ) const { 00051 if ( mType != other.mType ) return false; 00052 switch ( mType ) { 00053 case Inlined: return mText == other.mText; 00054 case FromFile: 00055 case FromCommand: return mUrl == other.mUrl; 00056 default: 00057 case Disabled: return true; 00058 } 00059 } 00060 00061 TQString Signature::rawText( bool * ok ) const 00062 { 00063 switch ( mType ) { 00064 case Disabled: 00065 if ( ok ) *ok = true; 00066 return TQString(); 00067 case Inlined: 00068 if ( ok ) *ok = true; 00069 return mText; 00070 case FromFile: 00071 return textFromFile( ok ); 00072 case FromCommand: 00073 return textFromCommand( ok ); 00074 }; 00075 kdFatal( 5006 ) << "Signature::type() returned unknown value!" << endl; 00076 return TQString(); // make compiler happy 00077 } 00078 00079 TQString Signature::textFromCommand( bool * ok ) const 00080 { 00081 assert( mType == FromCommand ); 00082 00083 // handle pathological cases: 00084 if ( mUrl.isEmpty() ) { 00085 if ( ok ) *ok = true; 00086 return TQString(); 00087 } 00088 00089 // create a shell process: 00090 CollectingProcess proc; 00091 proc.setUseShell(true); 00092 proc << mUrl; 00093 00094 // run the process: 00095 int rc = 0; 00096 if ( !proc.start( TDEProcess::Block, TDEProcess::Stdout ) ) 00097 rc = -1; 00098 else 00099 rc = ( proc.normalExit() ) ? proc.exitStatus() : -1 ; 00100 00101 // handle errors, if any: 00102 if ( rc != 0 ) { 00103 if ( ok ) *ok = false; 00104 TQString wmsg = i18n("<qt>Failed to execute signature script<br><b>%1</b>:<br>%2</qt>") 00105 .arg( mUrl ).arg( strerror(rc) ); 00106 KMessageBox::error(0, wmsg); 00107 return TQString(); 00108 } 00109 00110 // no errors: 00111 if ( ok ) *ok = true; 00112 00113 // get output: 00114 TQByteArray output = proc.collectedStdout(); 00115 00116 // ### hmm, should we allow other encodings, too? 00117 return TQString::fromLocal8Bit( output.data(), output.size() ); 00118 } 00119 00120 TQString Signature::textFromFile( bool * ok ) const 00121 { 00122 assert( mType == FromFile ); 00123 00124 // ### FIXME: Use TDEIO::NetAccess to download non-local files! 00125 if ( !KURL(mUrl).isLocalFile() && !(TQFileInfo(mUrl).isRelative() 00126 && TQFileInfo(mUrl).exists()) ) { 00127 kdDebug( 5006 ) << "Signature::textFromFile: non-local URLs are unsupported" << endl; 00128 if ( ok ) *ok = false; 00129 return TQString(); 00130 } 00131 if ( ok ) *ok = true; 00132 // ### hmm, should we allow other encodings, too? 00133 return TQString::fromLocal8Bit( kFileToString( mUrl, false ) ); 00134 } 00135 00136 TQString Signature::withSeparator( bool * ok ) const 00137 { 00138 bool internalOK = false; 00139 TQString signature = rawText( &internalOK ); 00140 if ( !internalOK ) { 00141 if ( ok ) *ok = false; 00142 return TQString(); 00143 } 00144 if ( ok ) *ok = true; 00145 if ( signature.isEmpty() ) return signature; // don't add a separator in this case 00146 if ( signature.startsWith( TQString::fromLatin1("-- \n") ) ) 00147 // already have signature separator at start of sig: 00148 return TQString::fromLatin1("\n") += signature; 00149 else if ( signature.find( TQString::fromLatin1("\n-- \n") ) != -1 ) 00150 // already have signature separator inside sig; don't prepend '\n' 00151 // to improve abusing signatures as templates: 00152 return signature; 00153 else 00154 // need to prepend one: 00155 return TQString::fromLatin1("\n-- \n") + signature; 00156 } 00157 00158 00159 void Signature::setUrl( const TQString & url, bool isExecutable ) 00160 { 00161 mUrl = url; 00162 mType = isExecutable ? FromCommand : FromFile ; 00163 } 00164 00165 // config keys and values: 00166 static const char sigTypeKey[] = "Signature Type"; 00167 static const char sigTypeInlineValue[] = "inline"; 00168 static const char sigTypeFileValue[] = "file"; 00169 static const char sigTypeCommandValue[] = "command"; 00170 static const char sigTypeDisabledValue[] = "disabled"; 00171 static const char sigTextKey[] = "Inline Signature"; 00172 static const char sigFileKey[] = "Signature File"; 00173 static const char sigCommandKey[] = "Signature Command"; 00174 00175 void Signature::readConfig( const TDEConfigBase * config ) 00176 { 00177 TQString sigType = config->readEntry( sigTypeKey ); 00178 if ( sigType == sigTypeInlineValue ) { 00179 mType = Inlined; 00180 } else if ( sigType == sigTypeFileValue ) { 00181 mType = FromFile; 00182 mUrl = config->readPathEntry( sigFileKey ); 00183 } else if ( sigType == sigTypeCommandValue ) { 00184 mType = FromCommand; 00185 mUrl = config->readPathEntry( sigCommandKey ); 00186 } else { 00187 mType = Disabled; 00188 } 00189 mText = config->readEntry( sigTextKey ); 00190 } 00191 00192 void Signature::writeConfig( TDEConfigBase * config ) const 00193 { 00194 switch ( mType ) { 00195 case Inlined: 00196 config->writeEntry( sigTypeKey, sigTypeInlineValue ); 00197 break; 00198 case FromFile: 00199 config->writeEntry( sigTypeKey, sigTypeFileValue ); 00200 config->writePathEntry( sigFileKey, mUrl ); 00201 break; 00202 case FromCommand: 00203 config->writeEntry( sigTypeKey, sigTypeCommandValue ); 00204 config->writePathEntry( sigCommandKey, mUrl ); 00205 break; 00206 case Disabled: 00207 config->writeEntry( sigTypeKey, sigTypeDisabledValue ); 00208 default: ; 00209 } 00210 config->writeEntry( sigTextKey, mText ); 00211 } 00212 00213 TQDataStream & KPIM::operator<<( TQDataStream & stream, const KPIM::Signature & sig ) { 00214 return stream << static_cast<TQ_UINT8>(sig.mType) 00215 << sig.mUrl 00216 << sig.mText; 00217 } 00218 00219 TQDataStream & KPIM::operator>>( TQDataStream & stream, KPIM::Signature & sig ) { 00220 TQ_UINT8 s; 00221 stream >> s 00222 >> sig.mUrl 00223 >> sig.mText; 00224 sig.mType = static_cast<Signature::Type>(s); 00225 return stream; 00226 } 00227 00228 // ### should use a kstaticdeleter? 00229 static Identity* identityNull = 0; 00230 const Identity& Identity::null() 00231 { 00232 if ( !identityNull ) 00233 identityNull = new Identity; 00234 return *identityNull; 00235 } 00236 00237 bool Identity::isNull() const { 00238 return mIdentity.isEmpty() && mFullName.isEmpty() && mEmailAddr.isEmpty() && 00239 mEmailAliases.empty() && 00240 mOrganization.isEmpty() && mReplyToAddr.isEmpty() && mBcc.isEmpty() && 00241 mVCardFile.isEmpty() && 00242 mFcc.isEmpty() && mDrafts.isEmpty() && mTemplates.isEmpty() && 00243 mPGPEncryptionKey.isEmpty() && mPGPSigningKey.isEmpty() && 00244 mSMIMEEncryptionKey.isEmpty() && mSMIMESigningKey.isEmpty() && 00245 mTransport.isEmpty() && mDictionary.isEmpty() && 00246 mPreferredCryptoMessageFormat == Kleo::AutoFormat && 00247 mSignature.type() == Signature::Disabled && 00248 mXFace.isEmpty(); 00249 } 00250 00251 bool Identity::operator==( const Identity & other ) const { 00252 bool same = mUoid == other.mUoid && 00253 mIdentity == other.mIdentity && mFullName == other.mFullName && 00254 mEmailAddr == other.mEmailAddr && mOrganization == other.mOrganization && 00255 mEmailAliases == other.mEmailAliases && 00256 mReplyToAddr == other.mReplyToAddr && mBcc == other.mBcc && 00257 mVCardFile == other.mVCardFile && 00258 mFcc == other.mFcc && 00259 mPGPEncryptionKey == other.mPGPEncryptionKey && 00260 mPGPSigningKey == other.mPGPSigningKey && 00261 mSMIMEEncryptionKey == other.mSMIMEEncryptionKey && 00262 mSMIMESigningKey == other.mSMIMESigningKey && 00263 mPreferredCryptoMessageFormat == other.mPreferredCryptoMessageFormat && 00264 mDrafts == other.mDrafts && mTemplates == other.mTemplates && 00265 mTransport == other.mTransport && 00266 mDictionary == other.mDictionary && mSignature == other.mSignature && 00267 mXFace == other.mXFace && mXFaceEnabled == other.mXFaceEnabled; 00268 00269 #if 0 00270 if ( same ) 00271 return true; 00272 if ( mUoid != other.mUoid ) kdDebug() << "mUoid differs : " << mUoid << " != " << other.mUoid << endl; 00273 if ( mIdentity != other.mIdentity ) kdDebug() << "mIdentity differs : " << mIdentity << " != " << other.mIdentity << endl; 00274 if ( mFullName != other.mFullName ) kdDebug() << "mFullName differs : " << mFullName << " != " << other.mFullName << endl; 00275 if ( mEmailAddr != other.mEmailAddr ) kdDebug() << "mEmailAddr differs : " << mEmailAddr << " != " << other.mEmailAddr << endl; 00276 if ( mEmailAliases != other.mEmailAliases ) kdDebug() << "mEmailAliases differs : " << mEmailAliases.join(";") << " != " << other.mEmailAliases.join(";") << endl; 00277 if ( mOrganization != other.mOrganization ) kdDebug() << "mOrganization differs : " << mOrganization << " != " << other.mOrganization << endl; 00278 if ( mReplyToAddr != other.mReplyToAddr ) kdDebug() << "mReplyToAddr differs : " << mReplyToAddr << " != " << other.mReplyToAddr << endl; 00279 if ( mBcc != other.mBcc ) kdDebug() << "mBcc differs : " << mBcc << " != " << other.mBcc << endl; 00280 if ( mVCardFile != other.mVCardFile ) kdDebug() << "mVCardFile differs : " << mVCardFile << " != " << other.mVCardFile << endl; 00281 if ( mFcc != other.mFcc ) kdDebug() << "mFcc differs : " << mFcc << " != " << other.mFcc << endl; 00282 if ( mPGPEncryptionKey != other.mPGPEncryptionKey ) kdDebug() << "mPGPEncryptionKey differs : " << mPGPEncryptionKey << " != " << other.mPGPEncryptionKey << endl; 00283 if ( mPGPSigningKey != other.mPGPSigningKey ) kdDebug() << "mPGPSigningKey differs : " << mPGPSigningKey << " != " << other.mPGPSigningKey << endl; 00284 if ( mSMIMEEncryptionKey != other.mSMIMEEncryptionKey ) kdDebug() << "mSMIMEEncryptionKey differs : '" << mSMIMEEncryptionKey << "' != '" << other.mSMIMEEncryptionKey << "'" << endl; 00285 if ( mSMIMESigningKey != other.mSMIMESigningKey ) kdDebug() << "mSMIMESigningKey differs : " << mSMIMESigningKey << " != " << other.mSMIMESigningKey << endl; 00286 if ( mPreferredCryptoMessageFormat != other.mPreferredCryptoMessageFormat ) kdDebug() << "mPreferredCryptoMessageFormat differs : " << mPreferredCryptoMessageFormat << " != " << other.mPreferredCryptoMessageFormat << endl; 00287 if ( mDrafts != other.mDrafts ) kdDebug() << "mDrafts differs : " << mDrafts << " != " << other.mDrafts << endl; 00288 if ( mTemplates != other.mTemplates ) kdDebug() << "mTemplates differs : " << mTemplates << " != " << other.mTemplates << endl; 00289 if ( mTransport != other.mTransport ) kdDebug() << "mTransport differs : " << mTransport << " != " << other.mTransport << endl; 00290 if ( mDictionary != other.mDictionary ) kdDebug() << "mDictionary differs : " << mDictionary << " != " << other.mDictionary << endl; 00291 if ( ! ( mSignature == other.mSignature ) ) kdDebug() << "mSignature differs" << endl; 00292 #endif 00293 return same; 00294 } 00295 00296 Identity::Identity( const TQString & id, const TQString & fullName, 00297 const TQString & emailAddr, const TQString & organization, 00298 const TQString & replyToAddr ) 00299 : mUoid( 0 ), mIdentity( id ), mFullName( fullName ), 00300 mEmailAddr( emailAddr ), mOrganization( organization ), 00301 mReplyToAddr( replyToAddr ), 00302 // Using "" instead of null to make operator==() not fail 00303 // (readConfig returns "") 00304 mBcc( "" ), mVCardFile( "" ), mPGPEncryptionKey( "" ), mPGPSigningKey( "" ), 00305 mSMIMEEncryptionKey( "" ), mSMIMESigningKey( "" ), mFcc( "" ), 00306 mDrafts( "" ), mTemplates( "" ), mTransport( "" ), 00307 mDictionary( "" ), 00308 mXFace( "" ), mXFaceEnabled( false ), 00309 mIsDefault( false ), 00310 mPreferredCryptoMessageFormat( Kleo::AutoFormat ) 00311 { 00312 } 00313 00314 Identity::~Identity() 00315 { 00316 } 00317 00318 00319 void Identity::readConfig( const TDEConfigBase * config ) 00320 { 00321 mUoid = config->readUnsignedNumEntry("uoid",0); 00322 00323 mIdentity = config->readEntry("Identity"); 00324 mFullName = config->readEntry("Name"); 00325 mEmailAddr = config->readEntry("Email Address"); 00326 mEmailAliases = config->readListEntry("Email Aliases"); 00327 mVCardFile = config->readPathEntry("VCardFile"); 00328 mOrganization = config->readEntry("Organization"); 00329 mPGPSigningKey = config->readEntry("PGP Signing Key").latin1(); 00330 mPGPEncryptionKey = config->readEntry("PGP Encryption Key").latin1(); 00331 mSMIMESigningKey = config->readEntry("SMIME Signing Key").latin1(); 00332 mSMIMEEncryptionKey = config->readEntry("SMIME Encryption Key").latin1(); 00333 mPreferredCryptoMessageFormat = Kleo::stringToCryptoMessageFormat( config->readEntry("Preferred Crypto Message Format", "none" ) ); 00334 mReplyToAddr = config->readEntry( "Reply-To Address" ); 00335 mBcc = config->readEntry( "Bcc" ); 00336 mFcc = config->readEntry( "Fcc", "sent-mail" ); 00337 if( mFcc.isEmpty() ) 00338 mFcc = "sent-mail"; 00339 mDrafts = config->readEntry( "Drafts", "drafts" ); 00340 if( mDrafts.isEmpty() ) 00341 mDrafts = "drafts"; 00342 mTemplates = config->readEntry( "Templates", "templates" ); 00343 if( mTemplates.isEmpty() ) 00344 mTemplates = "templates"; 00345 mTransport = config->readEntry( "Transport" ); 00346 mDictionary = config->readEntry( "Dictionary" ); 00347 mXFace = config->readEntry( "X-Face" ); 00348 mXFaceEnabled = config->readBoolEntry( "X-FaceEnabled", false ); 00349 00350 mSignature.readConfig( config ); 00351 kdDebug(5006) << "Identity::readConfig(): UOID = " << mUoid 00352 << " for identity named \"" << mIdentity << "\"" << endl; 00353 } 00354 00355 00356 void Identity::writeConfig( TDEConfigBase * config ) const 00357 { 00358 config->writeEntry("uoid", mUoid); 00359 00360 config->writeEntry("Identity", mIdentity); 00361 config->writeEntry("Name", mFullName); 00362 config->writeEntry("Organization", mOrganization); 00363 config->writeEntry("PGP Signing Key", mPGPSigningKey.data()); 00364 config->writeEntry("PGP Encryption Key", mPGPEncryptionKey.data()); 00365 config->writeEntry("SMIME Signing Key", mSMIMESigningKey.data()); 00366 config->writeEntry("SMIME Encryption Key", mSMIMEEncryptionKey.data()); 00367 config->writeEntry("Preferred Crypto Message Format", Kleo::cryptoMessageFormatToString( mPreferredCryptoMessageFormat ) ); 00368 config->writeEntry("Email Address", mEmailAddr); 00369 config->writeEntry("Email Aliases", mEmailAliases); 00370 config->writeEntry("Reply-To Address", mReplyToAddr); 00371 config->writeEntry("Bcc", mBcc); 00372 config->writePathEntry("VCardFile", mVCardFile); 00373 config->writeEntry("Transport", mTransport); 00374 config->writeEntry("Fcc", mFcc); 00375 config->writeEntry("Drafts", mDrafts); 00376 config->writeEntry("Templates", mTemplates); 00377 config->writeEntry( "Dictionary", mDictionary ); 00378 config->writeEntry( "X-Face", mXFace ); 00379 config->writeEntry( "X-FaceEnabled", mXFaceEnabled ); 00380 00381 mSignature.writeConfig( config ); 00382 } 00383 00384 TQDataStream & KPIM::operator<<( TQDataStream & stream, const KPIM::Identity & i ) { 00385 return stream << static_cast<TQ_UINT32>(i.uoid()) 00386 << i.identityName() 00387 << i.fullName() 00388 << i.organization() 00389 << i.pgpSigningKey() 00390 << i.pgpEncryptionKey() 00391 << i.smimeSigningKey() 00392 << i.smimeEncryptionKey() 00393 << i.primaryEmailAddress() 00394 << i.emailAliases() 00395 << i.replyToAddr() 00396 << i.bcc() 00397 << i.vCardFile() 00398 << i.transport() 00399 << i.fcc() 00400 << i.drafts() 00401 << i.templates() 00402 << i.mSignature 00403 << i.dictionary() 00404 << i.xface() 00405 << TQString( Kleo::cryptoMessageFormatToString( i.mPreferredCryptoMessageFormat ) ); 00406 } 00407 00408 TQDataStream & KPIM::operator>>( TQDataStream & stream, KPIM::Identity & i ) { 00409 TQ_UINT32 uoid; 00410 TQString format; 00411 stream >> uoid 00412 >> i.mIdentity 00413 >> i.mFullName 00414 >> i.mOrganization 00415 >> i.mPGPSigningKey 00416 >> i.mPGPEncryptionKey 00417 >> i.mSMIMESigningKey 00418 >> i.mSMIMEEncryptionKey 00419 >> i.mEmailAddr 00420 >> i.mEmailAliases 00421 >> i.mReplyToAddr 00422 >> i.mBcc 00423 >> i.mVCardFile 00424 >> i.mTransport 00425 >> i.mFcc 00426 >> i.mDrafts 00427 >> i.mTemplates 00428 >> i.mSignature 00429 >> i.mDictionary 00430 >> i.mXFace 00431 >> format; 00432 i.mUoid = uoid; 00433 i.mPreferredCryptoMessageFormat = Kleo::stringToCryptoMessageFormat( format.latin1() ); 00434 00435 return stream; 00436 } 00437 00438 //----------------------------------------------------------------------------- 00439 bool Identity::mailingAllowed() const 00440 { 00441 return !mEmailAddr.isEmpty(); 00442 } 00443 00444 00445 void Identity::setIsDefault( bool flag ) { 00446 mIsDefault = flag; 00447 } 00448 00449 void Identity::setIdentityName( const TQString & name ) { 00450 mIdentity = name; 00451 } 00452 00453 void Identity::setFullName(const TQString &str) 00454 { 00455 mFullName = str; 00456 } 00457 00458 00459 //----------------------------------------------------------------------------- 00460 void Identity::setOrganization(const TQString &str) 00461 { 00462 mOrganization = str; 00463 } 00464 00465 void Identity::setPGPSigningKey(const TQCString &str) 00466 { 00467 mPGPSigningKey = str; 00468 if ( mPGPSigningKey.isNull() ) 00469 mPGPSigningKey = ""; 00470 } 00471 00472 void Identity::setPGPEncryptionKey(const TQCString &str) 00473 { 00474 mPGPEncryptionKey = str; 00475 if ( mPGPEncryptionKey.isNull() ) 00476 mPGPEncryptionKey = ""; 00477 } 00478 00479 void Identity::setSMIMESigningKey(const TQCString &str) 00480 { 00481 mSMIMESigningKey = str; 00482 if ( mSMIMESigningKey.isNull() ) 00483 mSMIMESigningKey = ""; 00484 } 00485 00486 void Identity::setSMIMEEncryptionKey(const TQCString &str) 00487 { 00488 mSMIMEEncryptionKey = str; 00489 if ( mSMIMEEncryptionKey.isNull() ) 00490 mSMIMEEncryptionKey = ""; 00491 } 00492 00493 //----------------------------------------------------------------------------- 00494 void Identity::setPrimaryEmailAddress( const TQString & str ) 00495 { 00496 mEmailAddr = str; 00497 } 00498 00499 void Identity::setEmailAliases( const TQStringList & list ) 00500 { 00501 mEmailAliases = list; 00502 } 00503 00504 bool Identity::matchesEmailAddress( const TQString & addr ) const 00505 { 00506 const TQString lower = addr.lower(); 00507 if ( lower == mEmailAddr.lower() ) 00508 return true; 00509 for ( TQStringList::const_iterator it = mEmailAliases.begin(), end = mEmailAliases.end() ; it != end ; ++it ) 00510 if ( (*it).lower() == lower ) 00511 return true; 00512 return false; 00513 } 00514 00515 //----------------------------------------------------------------------------- 00516 void Identity::setVCardFile(const TQString &str) 00517 { 00518 mVCardFile = str; 00519 } 00520 00521 00522 //----------------------------------------------------------------------------- 00523 TQString Identity::fullEmailAddr(void) const 00524 { 00525 if (mFullName.isEmpty()) return mEmailAddr; 00526 00527 const TQString specials("()<>@,.;:[]"); 00528 00529 TQString result; 00530 00531 // add DQUOTE's if necessary: 00532 bool needsQuotes=false; 00533 for (unsigned int i=0; i < mFullName.length(); i++) { 00534 if ( specials.contains( mFullName[i] ) ) 00535 needsQuotes = true; 00536 else if ( mFullName[i] == '\\' || mFullName[i] == '"' ) { 00537 needsQuotes = true; 00538 result += '\\'; 00539 } 00540 result += mFullName[i]; 00541 } 00542 00543 if (needsQuotes) { 00544 result.insert(0,'"'); 00545 result += '"'; 00546 } 00547 00548 result += " <" + mEmailAddr + '>'; 00549 00550 return result; 00551 } 00552 00553 //----------------------------------------------------------------------------- 00554 void Identity::setReplyToAddr(const TQString& str) 00555 { 00556 mReplyToAddr = str; 00557 } 00558 00559 00560 //----------------------------------------------------------------------------- 00561 void Identity::setSignatureFile(const TQString &str) 00562 { 00563 mSignature.setUrl( str, signatureIsCommand() ); 00564 } 00565 00566 00567 //----------------------------------------------------------------------------- 00568 void Identity::setSignatureInlineText(const TQString &str ) 00569 { 00570 mSignature.setText( str ); 00571 } 00572 00573 00574 //----------------------------------------------------------------------------- 00575 void Identity::setTransport( const TQString &str ) 00576 { 00577 mTransport = str; 00578 if ( mTransport.isNull() ) 00579 mTransport = ""; 00580 } 00581 00582 //----------------------------------------------------------------------------- 00583 void Identity::setFcc( const TQString &str ) 00584 { 00585 mFcc = str; 00586 if ( mFcc.isNull() ) 00587 mFcc = ""; 00588 } 00589 00590 //----------------------------------------------------------------------------- 00591 void Identity::setDrafts( const TQString &str ) 00592 { 00593 mDrafts = str; 00594 if ( mDrafts.isNull() ) 00595 mDrafts = ""; 00596 } 00597 00598 //----------------------------------------------------------------------------- 00599 void Identity::setTemplates( const TQString &str ) 00600 { 00601 mTemplates = str; 00602 if ( mTemplates.isNull() ) 00603 mTemplates = ""; 00604 } 00605 00606 //----------------------------------------------------------------------------- 00607 void Identity::setDictionary( const TQString &str ) 00608 { 00609 mDictionary = str; 00610 if ( mDictionary.isNull() ) 00611 mDictionary = ""; 00612 } 00613 00614 00615 //----------------------------------------------------------------------------- 00616 void Identity::setXFace( const TQString &str ) 00617 { 00618 mXFace = str; 00619 mXFace.remove( " " ); 00620 mXFace.remove( "\n" ); 00621 mXFace.remove( "\r" ); 00622 } 00623 00624 00625 //----------------------------------------------------------------------------- 00626 void Identity::setXFaceEnabled( const bool on ) 00627 { 00628 mXFaceEnabled = on; 00629 } 00630 00631 00632 //----------------------------------------------------------------------------- 00633 TQString Identity::signatureText( bool * ok ) const 00634 { 00635 bool internalOK = false; 00636 TQString signatureText = mSignature.withSeparator( &internalOK ); 00637 if ( internalOK ) { 00638 if ( ok ) *ok=true; 00639 return signatureText; 00640 } 00641 00642 // OK, here comes the funny part. The call to 00643 // Signature::withSeparator() failed, so we should probably fix the 00644 // cause: 00645 if ( ok ) *ok = false; 00646 return TQString(); 00647 00648 #if 0 // ### FIXME: error handling 00649 if (mSignatureFile.endsWith("|")) 00650 { 00651 } 00652 else 00653 { 00654 } 00655 #endif 00656 00657 return TQString(); 00658 }