-rw-r--r-- | libkdepim/externalapphandler.cpp | 109 |
1 files changed, 96 insertions, 13 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 2ce6926..edefda4 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp @@ -40,4 +40,5 @@ $Id$ #else #include <qapplication.h> +#include <qprocess.h> #endif @@ -435,4 +436,23 @@ void ExternalAppHandler::loadConfig() addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); +#ifdef DESKTOP_VERSION + QString appPath; +#ifdef _WIN32_ + appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe"; +#else + appPath = "/usr/bin/thunderbird"; +#endif + addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1"); + +#ifdef _WIN32_ + appPath = "C:\\Programme\\Mozilla\\mozilla.exe"; +#else + appPath = "/usr/bin/mozilla"; +#endif + addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1"); + + + +#else if (( QFile::exists( qtopiapath + "/bin/ompi" )) || ( QFile::exists( opiepath + "/bin/ompi" )) || @@ -449,5 +469,5 @@ void ExternalAppHandler::loadConfig() if ( QFile::exists( opiepath + "/bin/mailit" )) addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); - +#endif @@ -529,5 +549,5 @@ DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) bool ExternalAppHandler::isEmailAppAvailable() { -#ifndef DESKTOP_VERSION + if (mEmailAppAvailable == UNDEFINED) { @@ -540,7 +560,4 @@ bool ExternalAppHandler::isEmailAppAvailable() return (mEmailAppAvailable == AVAILABLE); -#else //DESKTOP_VERSION - return false; -#endif //DESKTOP_VERSION } @@ -689,5 +706,59 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS #else - KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); + //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); + + QString channel; + QString message2; + QString parameters2; + QString message; + QString parameters; + + + int client = KPimGlobalPrefs::instance()->mEmailClient; + if (client == KPimGlobalPrefs::OTHER_EMC) + { + channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; + message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; + parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; + } + else + { + DefaultAppItem* dai = getDefaultItem(EMAIL, client); + if (!dai) + { + qDebug("could not find configured email application."); + return false; + } + channel = dai->_channel; + message2 = dai->_message2; + parameters2 = dai->_parameters2; + message = dai->_message; + parameters = dai->_parameters; + } + + //first check if one of the mailers need the emails right in the message. + message2 = translateMessage(message2, emails, urls); +#ifdef DEBUG_EXT_APP_HANDLER + qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); + qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); +#endif + qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); + //KMessageBox::sorry( 0, message2 ); + QProcess * proc = new QProcess( this ); + QStringList list = QStringList::split( " ", message ); + int i = 0; + proc->addArgument( channel ); + while ( i < list.count ( ) ) { + //qDebug("add%sdd ",list[i].stripWhiteSpace().latin1() ); + proc->addArgument( list[i].stripWhiteSpace() ); + ++i; + } + parameters2 = translateMessage(parameters2, urls, "" ); + QString arg = "to='%1'"; + arg = arg.arg( emails ) + ","+parameters2;; + + //qDebug("2add%sdd ",arg.latin1() ); + proc->addArgument( arg); + proc->launch(""); #endif @@ -703,5 +774,5 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) { -#ifndef DESKTOP_VERSION + QString channel; QString message; @@ -729,9 +800,10 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e } - +#ifdef DESKTOP_VERSION + //message = channel + " " +message + " \""+ parameters + "\""; +#endif //first check if one of the mailers need the emails right in the message. message = translateMessage(message, name, emailadress); - #ifdef DEBUG_EXT_APP_HANDLER qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); @@ -739,15 +811,26 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e #endif +#ifndef DESKTOP_VERSION QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough passParameters(&e, parameters, name, emailadress); +#else // DESKTOP_VERSION - -#else - KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); + //KMessageBox::sorry( 0, message ); + QProcess * proc = new QProcess( this ); + QStringList list = QStringList::split( " ", message ); + int i = 0; + proc->addArgument( channel ); + while ( i < list.count ( ) ) { + //qDebug("add%sdd ",list[i].latin1() ); + proc->addArgument( list[i] ); + ++i; + } + parameters = translateMessage(parameters, name, emailadress); + proc->addArgument( parameters ); + proc->launch(""); #endif - return true; } |