summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
Side-by-side diff
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp111
1 files changed, 97 insertions, 14 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 2ce6926..edefda4 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -36,12 +36,13 @@ $Id$
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#include <qtopia/qcopenvelope_qws.h>
#else
#include <qapplication.h>
+#include <qprocess.h>
#endif
#include <kstaticdeleter.h>
#include <kmessagebox.h>
@@ -431,12 +432,31 @@ void ExternalAppHandler::loadConfig()
QString undefined = "";
addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
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" )) ||
( QFile::exists( qtpath + "/bin/ompi" )))
addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
if (( QFile::exists( qtopiapath + "/bin/qtmail" )) ||
@@ -445,13 +465,13 @@ void ExternalAppHandler::loadConfig()
if ( QFile::exists( opiepath + "/bin/opiemail" ))
addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
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
//phoneclients
addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
@@ -525,26 +545,23 @@ DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
return 0;
}
bool ExternalAppHandler::isEmailAppAvailable()
{
-#ifndef DESKTOP_VERSION
+
if (mEmailAppAvailable == UNDEFINED)
{
int client = KPimGlobalPrefs::instance()->mEmailClient;
if (client == KPimGlobalPrefs::NONE_EMC)
mEmailAppAvailable = UNAVAILABLE;
else
mEmailAppAvailable = AVAILABLE;
}
return (mEmailAppAvailable == AVAILABLE);
-#else //DESKTOP_VERSION
- return false;
-#endif //DESKTOP_VERSION
}
bool ExternalAppHandler::isSMSAppAvailable()
{
#ifndef DESKTOP_VERSION
if (mSMSAppAvailable == UNDEFINED)
@@ -685,13 +702,67 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS
passParameters(&e, parameters2, emails, urls);
#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
return true;
}
/**************************************************************************
@@ -699,13 +770,13 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS
**************************************************************************/
//calls the emailapplication and creates a mail with parameter emails as recipients
bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
{
-#ifndef DESKTOP_VERSION
+
QString channel;
QString message;
QString parameters;
int client = KPimGlobalPrefs::instance()->mEmailClient;
@@ -725,33 +796,45 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e
}
channel = dai->_channel;
message = dai->_message;
parameters = dai->_parameters;
}
-
+#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());
qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
#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
- KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
+#else // DESKTOP_VERSION
+
+ //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;
}
/**************************************************************************
*
**************************************************************************/