diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
commit | cc29364f06178f8f6b457384f2ec37a042bd9d43 (patch) | |
tree | 7c77a3184c698bbf9d98cef09fb1ba8124daceba /kmail/callback.cpp | |
parent | 4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff) | |
download | tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip |
* 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
Diffstat (limited to 'kmail/callback.cpp')
-rw-r--r-- | kmail/callback.cpp | 82 |
1 files changed, 71 insertions, 11 deletions
diff --git a/kmail/callback.cpp b/kmail/callback.cpp index 0e25758c1..be787ff8e 100644 --- a/kmail/callback.cpp +++ b/kmail/callback.cpp @@ -41,6 +41,7 @@ #include "composer.h" #include "kmreaderwin.h" #include "secondarywindow.h" +#include "transportmanager.h" #include <mimelib/enum.h> @@ -56,6 +57,32 @@ Callback::Callback( KMMessage* msg, KMReaderWin* readerWin ) { } +TQString Callback::askForTransport( bool nullIdentity ) const +{ + const TQStringList transports = KMail::TransportManager::transportNames(); + if ( transports.size() == 1 ) + return transports.first(); + + const TQString defaultTransport = GlobalSettings::self()->defaultTransport(); + const int defaultIndex = QMAX( 0, transports.findIndex( defaultTransport ) ); + + TQString text; + if ( nullIdentity ) + text = i18n( "<qt>The receiver of this invitation doesn't match any of your identities.<br>" + "Please select the transport which should be used to send your reply.</qt>" ); + else + text = i18n( "<qt>The identity matching the receiver of this invitation doesn't have an " + "associated transport configured.<br>" + "Please select the transport which should be used to send your reply.</qt>"); + bool ok; + const TQString transport = KInputDialog::getItem( i18n( "Select Transport" ), text, + transports, defaultIndex, FALSE, &ok, kmkernel->mainWin() ); + if ( !ok ) + return TQString(); + + return transport; +} + bool Callback::mailICal( const TQString& to, const TQString &iCal, const TQString& subject, const TQString &status, bool delMessage ) const @@ -67,13 +94,13 @@ bool Callback::mailICal( const TQString& to, const TQString &iCal, msg->setSubject( subject ); if ( GlobalSettings::self()->exchangeCompatibleInvitations() ) { if ( status == TQString("cancel") ) - msg->setSubject( TQString("Declined: %1").arg(subject).replace("Answer: ","") ); + msg->setSubject( i18n( "Declined: %1" ).arg(subject).replace("Answer: ","") ); else if ( status == TQString("tentative") ) - msg->setSubject(TQString("Tentative: %1").arg(subject).replace("Answer: ","") ); + msg->setSubject( i18n( "Tentative: %1" ).arg(subject).replace("Answer: ","") ); else if ( status == TQString("accepted") ) - msg->setSubject( TQString("Accepted: %1").arg(subject).replace("Answer: ","") ); + msg->setSubject( i18n( "Accepted: %1" ).arg(subject).replace("Answer: ","") ); else if ( status == TQString("delegated") ) - msg->setSubject( TQString("Delegated: %1").arg(subject).replace("Answer: ","") ); + msg->setSubject( i18n( "Delegated: %1" ).arg(subject).replace("Answer: ","") ); } msg->setTo( to ); msg->setFrom( receiver() ); @@ -89,23 +116,40 @@ bool Callback::mailICal( const TQString& to, const TQString &iCal, * has been sent successfully. Set a link header which accomplishes that. */ msg->link( mMsg, KMMsgStatusDeleted ); + // Try and match the receiver with an identity. + // Setting the identity here is important, as that is used to select the correct + // transport later + const KPIM::Identity& identity = kmkernel->identityManager()->identityForAddress( receiver() ); + const bool nullIdentity = ( identity == KPIM::Identity::null() ); + if ( !nullIdentity ) { + msg->setHeaderField("X-KMail-Identity", TQString::number( identity.uoid() )); + } + + const bool identityHasTransport = !identity.transport().isEmpty(); + if ( !nullIdentity && identityHasTransport ) + msg->setHeaderField( "X-KMail-Transport", identity.transport() ); + else if ( !nullIdentity && identity.isDefault() ) + msg->setHeaderField( "X-KMail-Transport", GlobalSettings::self()->defaultTransport() ); + else { + const TQString transport = askForTransport( nullIdentity ); + if ( transport.isEmpty() ) + return false; // user canceled transport selection dialog + msg->setHeaderField( "X-KMail-Transport", transport ); + } + // Outlook will only understand the reply if the From: header is the // same as the To: header of the invitation message. KConfigGroup options( KMKernel::config(), "Groupware" ); if( !options.readBoolEntry( "LegacyMangleFromToHeaders", true ) ) { - // Try and match the receiver with an identity - const KPIM::Identity& identity = - kmkernel->identityManager()->identityForAddress( receiver() ); if( identity != KPIM::Identity::null() ) { - // Identity found. Use this msg->setFrom( identity.fullEmailAddr() ); - msg->setHeaderField("X-KMail-Identity", TQString::number( identity.uoid() )); } // Remove BCC from identity on ical invitations (https://intevation.de/roundup/kolab/issue474) msg->setBcc( "" ); } KMail::Composer * cWin = KMail::makeComposer(); + cWin->ignoreStickyFields(); cWin->setMsg( msg, false /* mayAutoSign */ ); // cWin->setCharset( "", true ); cWin->disableWordWrap(); @@ -126,6 +170,8 @@ bool Callback::mailICal( const TQString& to, const TQString &iCal, cWin->addAttach( msgPart ); } + cWin->disableRecipientNumberCheck(); + cWin->disableForgottenAttachmentsCheck(); if ( options.readBoolEntry( "AutomaticSending", true ) ) { cWin->setAutoDeleteWindow( true ); cWin->slotSendNow(); @@ -170,7 +216,7 @@ TQString Callback::receiver() const selectMessage = i18n("<qt>None of your identities match the " "receiver of this message,<br>please " "choose which of the following addresses " - "is yours, if any:"); + "is yours, if any, or select one of your identities to use in the reply:"); addrs += kmkernel->identityManager()->allEmails(); } else { selectMessage = i18n("<qt>Several of your identities match the " @@ -179,10 +225,14 @@ TQString Callback::receiver() const "is yours:"); } + // select default identity by default + const TQString defaultAddr = kmkernel->identityManager()->defaultIdentity().primaryEmailAddress(); + const int defaultIndex = QMAX( 0, addrs.findIndex( defaultAddr ) ); + mReceiver = KInputDialog::getItem( i18n( "Select Address" ), selectMessage, - addrs+ccaddrs, 0, FALSE, &ok, kmkernel->mainWin() ); + addrs+ccaddrs, defaultIndex, FALSE, &ok, kmkernel->mainWin() ); if( !ok ) mReceiver = TQString::null; } @@ -213,6 +263,16 @@ bool Callback::deleteInvitationAfterReply() const return GlobalSettings::self()->deleteInvitationEmailsAfterSendingReply(); } +bool Callback::exchangeCompatibleInvitations() const +{ + return GlobalSettings::self()->exchangeCompatibleInvitations(); +} + +bool Callback::outlookCompatibleInvitationReplyComments() const +{ + return GlobalSettings::self()->outlookCompatibleInvitationReplyComments(); +} + TQString Callback::sender() const { return mMsg->from(); |