summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2005-10-29 16:39:40 (UTC)
committer zautrix <zautrix>2005-10-29 16:39:40 (UTC)
commit898dbabef6d747447999add46201315d04f85f63 (patch) (side-by-side diff)
treefb247cbbd99ca6918400547e16484a58a8ba1523 /libkdepim
parent1360f8e3b5da58b561f868643d2d5f04b874cee7 (diff)
downloadkdepimpi-898dbabef6d747447999add46201315d04f85f63.zip
kdepimpi-898dbabef6d747447999add46201315d04f85f63.tar.gz
kdepimpi-898dbabef6d747447999add46201315d04f85f63.tar.bz2
commit
Diffstat (limited to 'libkdepim') (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
@@ -30,24 +30,25 @@ $Id$
#include <stdlib.h>
#include <qfile.h>
#include <qtimer.h>
#include <qmap.h>
#include <qregexp.h>
#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>
#include "externalapphandler.h"
#include "kpimglobalprefs.h"
//uncomment line to get debug output
//#define DEBUG_EXT_APP_HANDLER
@@ -425,39 +426,58 @@ void ExternalAppHandler::loadConfig()
//mailclients
QString mailmsg1 = "writeMail(QString,QString)";
QString mailmsg2 = "writeMail(QMap(QString,QString))";
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" )) ||
( QFile::exists( qtpath + "/bin/qtmail" )))
addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
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);
if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
( QFile::exists( opiepath + "/bin/kppi" )))
addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
//faxclients
addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
@@ -519,38 +539,35 @@ DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
{
if (dai->_type == type && dai->_id == clientid)
return dai;
}
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)
{
int client = KPimGlobalPrefs::instance()->mSMSClient;
if (client == KPimGlobalPrefs::NONE_SMC)
mSMSAppAvailable = UNAVAILABLE;
else
mSMSAppAvailable = AVAILABLE;
@@ -679,39 +696,93 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS
qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
#endif
QCopEnvelope e(channel.latin1(), message2.latin1());
//US we need no names in the To field. The emailadresses are enough
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;
}
/**************************************************************************
*
**************************************************************************/
//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;
if (client == KPimGlobalPrefs::OTHER_EMC)
{
channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
}
@@ -719,45 +790,57 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e
{
DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
if (!dai)
{
qDebug("could not find configured email application.");
return false;
}
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;
}
/**************************************************************************
*
**************************************************************************/
//calls the emailapplication and creates a mail with parameter as recipients
// parameters format is
// NAME <EMAIL>:SUBJECT
bool ExternalAppHandler::mailToOneContact( const QString& adressline )
{