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 --- kmail/callback.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 11 deletions(-) (limited to 'kmail/callback.cpp') 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 @@ -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( "The receiver of this invitation doesn't match any of your identities.
" + "Please select the transport which should be used to send your reply.
" ); + else + text = i18n( "The identity matching the receiver of this invitation doesn't have an " + "associated transport configured.
" + "Please select the transport which should be used to send your reply.
"); + 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("None of your identities match the " "receiver of this message,
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("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(); -- cgit v1.2.1