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 /korganizer/komailclient.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 'korganizer/komailclient.cpp')
-rw-r--r-- | korganizer/komailclient.cpp | 111 |
1 files changed, 87 insertions, 24 deletions
diff --git a/korganizer/komailclient.cpp b/korganizer/komailclient.cpp index 946331fde..1b3215c09 100644 --- a/korganizer/komailclient.cpp +++ b/korganizer/komailclient.cpp @@ -34,12 +34,18 @@ #include <dcopclient.h> #include <kprocess.h> +#include <libemailfunctions/email.h> + +#include <libkpimidentities/identity.h> +#include <libkpimidentities/identitymanager.h> + #include <libkcal/event.h> #include <libkcal/todo.h> #include <libkcal/incidenceformatter.h> #include "version.h" #include "koprefs.h" +#include "kocore.h" #include "komailclient.h" @@ -54,23 +60,59 @@ KOMailClient::~KOMailClient() bool KOMailClient::mailAttendees(IncidenceBase *incidence,const TQString &attachment) { Attendee::List attendees = incidence->attendees(); - if (attendees.count() == 0) return false; + if ( attendees.count() == 0 ) { + return false; + } const TQString from = incidence->organizer().fullName(); const TQString organizerEmail = incidence->organizer().email(); + TQStringList toList; - for(uint i=0; i<attendees.count();++i) { - const TQString email = (*attendees.at(i))->email(); - // In case we (as one of our identities) are the organizer we are sending this - // mail. We could also have added ourselves as an attendee, in which case we - // don't want to send ourselves a notification mail. - if( organizerEmail != email ) - toList << email; + TQStringList ccList; + for ( uint i=0; i<attendees.count(); ++i ) { + Attendee *a = (*attendees.at(i)); + + const TQString email = a->email(); + if ( email.isEmpty() ) { + continue; + } + + // In case we (as one of our identities) are the organizer we are sending + // this mail. We could also have added ourselves as an attendee, in which + // case we don't want to send ourselves a notification mail. + if ( organizerEmail == email ) { + continue; + } + + // Build a nice address for this attendee including the CN. + TQString tname, temail; + const TQString username = KPIM::quoteNameIfNecessary( a->name() ); + KPIM::getNameAndMail( username, tname, temail ); // ignore return value + // which is always false + tname += " <" + email + '>'; + + + // Optional Participants and Non-Participants are copied on the email + if ( a->role() == Attendee::OptParticipant || + a->role() == Attendee::NonParticipant ) { + ccList << tname; + } else { + toList << tname; + } } - if( toList.count() == 0 ) + + if( toList.count() == 0 && ccList.count() == 0 ) { // Not really to be called a groupware meeting, eh return false; - TQString to = toList.join( ", " ); + } + TQString to; + if ( toList.count() > 0 ) { + to = toList.join( ", " ); + } + TQString cc; + if ( ccList.count() > 0 ) { + cc = ccList.join( ", " ); + } TQString subject; if(incidence->type()!="FreeBusy") { @@ -84,7 +126,7 @@ bool KOMailClient::mailAttendees(IncidenceBase *incidence,const TQString &attach bool bcc = KOPrefs::instance()->mBcc; - return send(from,to,subject,body,bcc,attachment); + return send(from,to,cc,subject,body,bcc,attachment); } bool KOMailClient::mailOrganizer(IncidenceBase *incidence,const TQString &attachment, const TQString &sub) @@ -106,7 +148,7 @@ bool KOMailClient::mailOrganizer(IncidenceBase *incidence,const TQString &attach bool bcc = KOPrefs::instance()->mBcc; - return send(from,to,subject,body,bcc,attachment); + return send(from,to,TQString::null,subject,body,bcc,attachment); } bool KOMailClient::mailTo(IncidenceBase *incidence,const TQString &recipients, @@ -123,16 +165,25 @@ bool KOMailClient::mailTo(IncidenceBase *incidence,const TQString &recipients, TQString body = IncidenceFormatter::mailBodyString(incidence); bool bcc = KOPrefs::instance()->mBcc; kdDebug () << "KOMailClient::mailTo " << recipients << endl; - return send(from,recipients,subject,body,bcc,attachment); + return send(from,recipients,TQString::null,subject,body,bcc,attachment); } -bool KOMailClient::send(const TQString &from,const TQString &to, +bool KOMailClient::send(const TQString &from,const TQString &_to,const TQString &cc, const TQString &subject,const TQString &body,bool bcc, const TQString &attachment) { - kdDebug(5850) << "KOMailClient::sendMail():\nFrom: " << from << "\nTo: " << to - << "\nSubject: " << subject << "\nBody: \n" << body - << "\nAttachment:\n" << attachment << endl; + // We must have a recipients list for most MUAs. Thus, if the 'to' list + // is empty simply use the 'from' address as the recipient. + TQString to = _to; + if ( to.isEmpty() ) { + to = from; + } + + kdDebug(5850) << "KOMailClient::sendMail():\nFrom: " << from + << "\nTo: " << to + << "\nCC: " << cc + << "\nSubject: " << subject << "\nBody: \n" << body + << "\nAttachment:\n" << attachment << endl; if (KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail) { bool needHeaders = true; @@ -152,6 +203,11 @@ bool KOMailClient::send(const TQString &from,const TQString &to, command.append(KProcess::quote(from)); } + if ( !cc.isEmpty() ) { + command.append(" -c "); + command.append(KProcess::quote(cc)); + } + command.append(" "); command.append(KProcess::quote(to)); @@ -170,6 +226,9 @@ bool KOMailClient::send(const TQString &from,const TQString &to, { textComplete += TQString::fromLatin1("From: ") + from + '\n'; textComplete += TQString::fromLatin1("To: ") + to + '\n'; + if ( !cc.isEmpty() ) { + textComplete += TQString::fromLatin1("Cc: " ) + cc + '\n'; + } if (bcc) textComplete += TQString::fromLatin1("Bcc: ") + from + '\n'; textComplete += TQString::fromLatin1("Subject: ") + subject + '\n'; textComplete += TQString::fromLatin1("X-Mailer: KOrganizer") + korgVersion + '\n'; @@ -184,14 +243,14 @@ bool KOMailClient::send(const TQString &from,const TQString &to, pclose(fd); } else { if (!kapp->dcopClient()->isApplicationRegistered("kmail")) { - if (KApplication::startServiceByDesktopName("kmail")) { + if (KApplication::startServiceByDesktopName("kmail")) { KMessageBox::error(0,i18n("No running instance of KMail found.")); return false; - } + } } if (attachment.isEmpty()) { - if (!kMailOpenComposer(to,"",bcc ? from : "",subject,body,0,KURL())) return false; + if (!kMailOpenComposer(to,cc,bcc ? from : "",subject,body,0,KURL())) return false; } else { TQString meth; int idx = attachment.find("METHOD"); @@ -203,9 +262,12 @@ bool KOMailClient::send(const TQString &from,const TQString &to, } else { meth = "publish"; } - if (!kMailOpenComposer(to,"",bcc ? from : "",subject,body,0,"cal.ics","7bit", + if (!kMailOpenComposer(to,cc,bcc ? from : "",subject,body,0,"cal.ics","7bit", attachment.utf8(),"text","calendar","method",meth, - "attachment","utf-8")) return false; + "attachment","utf-8", + KOCore::self()->identityManager()->identityForAddress( from ).uoid())) { + return false; + } } } return true; @@ -252,7 +314,7 @@ int KOMailClient::kMailOpenComposer( const TQString& arg0, const TQString& arg1, const TQCString& arg7, const TQCString& arg8, const TQCString& arg9, const TQCString& arg10, const TQCString& arg11, const TQString& arg12, - const TQCString& arg13, const TQCString& arg14 ) + const TQCString& arg13, const TQCString& arg14, uint identity ) { //kdDebug(5850) << "KOMailClient::kMailOpenComposer( " // << arg0 << " , " << arg1 << arg2 << " , " << arg3 @@ -281,11 +343,12 @@ int KOMailClient::kMailOpenComposer( const TQString& arg0, const TQString& arg1, arg << arg12; arg << arg13; arg << arg14; + arg << identity; #if KDE_IS_VERSION( 3, 2, 90 ) kapp->updateRemoteUserTimestamp("kmail"); #endif if ( kapp->dcopClient()->call("kmail","KMailIface", - "openComposer(TQString,TQString,TQString,TQString,TQString,int,TQString,TQCString,TQCString,TQCString,TQCString,TQCString,TQString,TQCString,TQCString)", data, replyType, replyData ) ) { + "openComposer(TQString,TQString,TQString,TQString,TQString,int,TQString,TQCString,TQCString,TQCString,TQCString,TQCString,TQString,TQCString,TQCString,uint)", data, replyType, replyData ) ) { if ( replyType == "int" ) { TQDataStream _reply_stream( replyData, IO_ReadOnly ); _reply_stream >> result; |