From cc29364f06178f8f6b457384f2ec37a042bd9d43 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 1 Sep 2010 00:37:02 +0000 Subject: * Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch * Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed * Added journal read support to the CalDAV resource * Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- libkpimidentities/identity.cpp | 26 ++++++++++++++++++++++++-- libkpimidentities/identity.h | 16 ++++++++++++++-- libkpimidentities/identitymanager.cpp | 22 ++++++++++------------ 3 files changed, 48 insertions(+), 16 deletions(-) (limited to 'libkpimidentities') diff --git a/libkpimidentities/identity.cpp b/libkpimidentities/identity.cpp index 19cd6593..fb2f1ac1 100644 --- a/libkpimidentities/identity.cpp +++ b/libkpimidentities/identity.cpp @@ -236,6 +236,7 @@ const Identity& Identity::null() bool Identity::isNull() const { return mIdentity.isEmpty() && mFullName.isEmpty() && mEmailAddr.isEmpty() && + mEmailAliases.empty() && mOrganization.isEmpty() && mReplyToAddr.isEmpty() && mBcc.isEmpty() && mVCardFile.isEmpty() && mFcc.isEmpty() && mDrafts.isEmpty() && mTemplates.isEmpty() && @@ -251,6 +252,7 @@ bool Identity::operator==( const Identity & other ) const { bool same = mUoid == other.mUoid && mIdentity == other.mIdentity && mFullName == other.mFullName && mEmailAddr == other.mEmailAddr && mOrganization == other.mOrganization && + mEmailAliases == other.mEmailAliases && mReplyToAddr == other.mReplyToAddr && mBcc == other.mBcc && mVCardFile == other.mVCardFile && mFcc == other.mFcc && @@ -271,6 +273,7 @@ bool Identity::operator==( const Identity & other ) const { if ( mIdentity != other.mIdentity ) kdDebug() << "mIdentity differs : " << mIdentity << " != " << other.mIdentity << endl; if ( mFullName != other.mFullName ) kdDebug() << "mFullName differs : " << mFullName << " != " << other.mFullName << endl; if ( mEmailAddr != other.mEmailAddr ) kdDebug() << "mEmailAddr differs : " << mEmailAddr << " != " << other.mEmailAddr << endl; + if ( mEmailAliases != other.mEmailAliases ) kdDebug() << "mEmailAliases differs : " << mEmailAliases.join(";") << " != " << other.mEmailAliases.join(";") << endl; if ( mOrganization != other.mOrganization ) kdDebug() << "mOrganization differs : " << mOrganization << " != " << other.mOrganization << endl; if ( mReplyToAddr != other.mReplyToAddr ) kdDebug() << "mReplyToAddr differs : " << mReplyToAddr << " != " << other.mReplyToAddr << endl; if ( mBcc != other.mBcc ) kdDebug() << "mBcc differs : " << mBcc << " != " << other.mBcc << endl; @@ -320,6 +323,7 @@ void Identity::readConfig( const KConfigBase * config ) mIdentity = config->readEntry("Identity"); mFullName = config->readEntry("Name"); mEmailAddr = config->readEntry("Email Address"); + mEmailAliases = config->readListEntry("Email Aliases"); mVCardFile = config->readPathEntry("VCardFile"); mOrganization = config->readEntry("Organization"); mPGPSigningKey = config->readEntry("PGP Signing Key").latin1(); @@ -362,6 +366,7 @@ void Identity::writeConfig( KConfigBase * config ) const config->writeEntry("SMIME Encryption Key", mSMIMEEncryptionKey.data()); config->writeEntry("Preferred Crypto Message Format", Kleo::cryptoMessageFormatToString( mPreferredCryptoMessageFormat ) ); config->writeEntry("Email Address", mEmailAddr); + config->writeEntry("Email Aliases", mEmailAliases); config->writeEntry("Reply-To Address", mReplyToAddr); config->writeEntry("Bcc", mBcc); config->writePathEntry("VCardFile", mVCardFile); @@ -385,7 +390,8 @@ TQDataStream & KPIM::operator<<( TQDataStream & stream, const KPIM::Identity & i << i.pgpEncryptionKey() << i.smimeSigningKey() << i.smimeEncryptionKey() - << i.emailAddr() + << i.primaryEmailAddress() + << i.emailAliases() << i.replyToAddr() << i.bcc() << i.vCardFile() @@ -411,6 +417,7 @@ TQDataStream & KPIM::operator>>( TQDataStream & stream, KPIM::Identity & i ) { >> i.mSMIMESigningKey >> i.mSMIMEEncryptionKey >> i.mEmailAddr + >> i.mEmailAliases >> i.mReplyToAddr >> i.mBcc >> i.mVCardFile @@ -484,11 +491,26 @@ void Identity::setSMIMEEncryptionKey(const TQCString &str) } //----------------------------------------------------------------------------- -void Identity::setEmailAddr(const TQString &str) +void Identity::setPrimaryEmailAddress( const TQString & str ) { mEmailAddr = str; } +void Identity::setEmailAliases( const TQStringList & list ) +{ + mEmailAliases = list; +} + +bool Identity::matchesEmailAddress( const TQString & addr ) const +{ + const TQString lower = addr.lower(); + if ( lower == mEmailAddr.lower() ) + return true; + for ( TQStringList::const_iterator it = mEmailAliases.begin(), end = mEmailAliases.end() ; it != end ; ++it ) + if ( (*it).lower() == lower ) + return true; + return false; +} //----------------------------------------------------------------------------- void Identity::setVCardFile(const TQString &str) diff --git a/libkpimidentities/identity.h b/libkpimidentities/identity.h index 236a2dc6..9baba4fa 100644 --- a/libkpimidentities/identity.h +++ b/libkpimidentities/identity.h @@ -206,8 +206,19 @@ public: void setPreferredCryptoMessageFormat( Kleo::CryptoMessageFormat format ) { mPreferredCryptoMessageFormat = format; } /** email address (without the user name - only name\@host) */ - TQString emailAddr() const { return mEmailAddr; } - void setEmailAddr(const TQString&); + 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; } @@ -295,6 +306,7 @@ protected: // and operator>> accordingly: uint mUoid; TQString mIdentity, mFullName, mEmailAddr, mOrganization; + TQStringList mEmailAliases; TQString mReplyToAddr; TQString mBcc; TQString mVCardFile; diff --git a/libkpimidentities/identitymanager.cpp b/libkpimidentities/identitymanager.cpp index 4c6ed02a..e7380ca6 100644 --- a/libkpimidentities/identitymanager.cpp +++ b/libkpimidentities/identitymanager.cpp @@ -211,7 +211,7 @@ void IdentityManager::writeConfig() const { // Also write the default identity to emailsettings KEMailSettings es; es.setSetting( KEMailSettings::RealName, (*it).fullName() ); - es.setSetting( KEMailSettings::EmailAddress, (*it).emailAddr() ); + es.setSetting( KEMailSettings::EmailAddress, (*it).primaryEmailAddress() ); es.setSetting( KEMailSettings::Organization, (*it).organization() ); es.setSetting( KEMailSettings::ReplyToAddress, (*it).replyToAddr() ); } @@ -304,16 +304,14 @@ const Identity & IdentityManager::identityForUoidOrDefault( uint uoid ) const const Identity & IdentityManager::identityForAddress( const TQString & addresses ) const { - TQStringList addressList = KPIM::splitEmailAddrList( addresses ); - for ( ConstIterator it = begin() ; it != end() ; ++it ) { - for( TQStringList::ConstIterator addrIt = addressList.begin(); - addrIt != addressList.end(); ++addrIt ) { - // I use TQString::utf8() instead of TQString::latin1() because I want - // a TQCString and not a char*. It doesn't matter because emailAddr() - // returns a 7-bit string. - if( (*it).emailAddr().lower() == - KPIM::getEmailAddress( *addrIt ).lower() ) { - return (*it); + const TQStringList addressList = KPIM::splitEmailAddrList( addresses ); + for( TQStringList::ConstIterator addrIt = addressList.begin(); + addrIt != addressList.end(); ++addrIt ) { + const TQString addr = KPIM::getEmailAddress( *addrIt ).lower(); + for ( ConstIterator it = begin() ; it != end() ; ++it ) { + const Identity & id = *it; + if ( id.matchesEmailAddress( addr ) ) { + return id; } } } @@ -499,7 +497,7 @@ TQStringList KPIM::IdentityManager::allEmails() const { TQStringList lst; for ( ConstIterator it = begin() ; it != end() ; ++it ) { - lst << (*it).emailAddr(); + lst << (*it).primaryEmailAddress(); } return lst; } -- cgit v1.2.3