Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkdepim/externalapphandler.cpp | 111 |
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 | |||
@@ -40,4 +40,5 @@ $Id$ | |||
40 | #else | 40 | #else |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #include <qprocess.h> | ||
42 | #endif | 43 | #endif |
43 | 44 | ||
@@ -435,4 +436,23 @@ void ExternalAppHandler::loadConfig() | |||
435 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 436 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
436 | 437 | ||
438 | #ifdef DESKTOP_VERSION | ||
439 | QString appPath; | ||
440 | #ifdef _WIN32_ | ||
441 | appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe"; | ||
442 | #else | ||
443 | appPath = "/usr/bin/thunderbird"; | ||
444 | #endif | ||
445 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1"); | ||
446 | |||
447 | #ifdef _WIN32_ | ||
448 | appPath = "C:\\Programme\\Mozilla\\mozilla.exe"; | ||
449 | #else | ||
450 | appPath = "/usr/bin/mozilla"; | ||
451 | #endif | ||
452 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1"); | ||
453 | |||
454 | |||
455 | |||
456 | #else | ||
437 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 457 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
438 | ( QFile::exists( opiepath + "/bin/ompi" )) || | 458 | ( QFile::exists( opiepath + "/bin/ompi" )) || |
@@ -449,5 +469,5 @@ void ExternalAppHandler::loadConfig() | |||
449 | if ( QFile::exists( opiepath + "/bin/mailit" )) | 469 | if ( QFile::exists( opiepath + "/bin/mailit" )) |
450 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 470 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
451 | 471 | #endif | |
452 | 472 | ||
453 | 473 | ||
@@ -529,5 +549,5 @@ DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | |||
529 | bool ExternalAppHandler::isEmailAppAvailable() | 549 | bool ExternalAppHandler::isEmailAppAvailable() |
530 | { | 550 | { |
531 | #ifndef DESKTOP_VERSION | 551 | |
532 | if (mEmailAppAvailable == UNDEFINED) | 552 | if (mEmailAppAvailable == UNDEFINED) |
533 | { | 553 | { |
@@ -540,7 +560,4 @@ bool ExternalAppHandler::isEmailAppAvailable() | |||
540 | return (mEmailAppAvailable == AVAILABLE); | 560 | return (mEmailAppAvailable == AVAILABLE); |
541 | 561 | ||
542 | #else //DESKTOP_VERSION | ||
543 | return false; | ||
544 | #endif //DESKTOP_VERSION | ||
545 | } | 562 | } |
546 | 563 | ||
@@ -689,5 +706,59 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS | |||
689 | 706 | ||
690 | #else | 707 | #else |
691 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 708 | //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); |
709 | |||
710 | QString channel; | ||
711 | QString message2; | ||
712 | QString parameters2; | ||
713 | QString message; | ||
714 | QString parameters; | ||
715 | |||
716 | |||
717 | int client = KPimGlobalPrefs::instance()->mEmailClient; | ||
718 | if (client == KPimGlobalPrefs::OTHER_EMC) | ||
719 | { | ||
720 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | ||
721 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | ||
722 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | ||
723 | } | ||
724 | else | ||
725 | { | ||
726 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | ||
727 | if (!dai) | ||
728 | { | ||
729 | qDebug("could not find configured email application."); | ||
730 | return false; | ||
731 | } | ||
732 | channel = dai->_channel; | ||
733 | message2 = dai->_message2; | ||
734 | parameters2 = dai->_parameters2; | ||
735 | message = dai->_message; | ||
736 | parameters = dai->_parameters; | ||
737 | } | ||
738 | |||
739 | //first check if one of the mailers need the emails right in the message. | ||
740 | message2 = translateMessage(message2, emails, urls); | ||
741 | #ifdef DEBUG_EXT_APP_HANDLER | ||
742 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | ||
743 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | ||
744 | #endif | ||
745 | qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); | ||
746 | //KMessageBox::sorry( 0, message2 ); | ||
747 | QProcess * proc = new QProcess( this ); | ||
748 | QStringList list = QStringList::split( " ", message ); | ||
749 | int i = 0; | ||
750 | proc->addArgument( channel ); | ||
751 | while ( i < list.count ( ) ) { | ||
752 | //qDebug("add%sdd ",list[i].stripWhiteSpace().latin1() ); | ||
753 | proc->addArgument( list[i].stripWhiteSpace() ); | ||
754 | ++i; | ||
755 | } | ||
756 | parameters2 = translateMessage(parameters2, urls, "" ); | ||
757 | QString arg = "to='%1'"; | ||
758 | arg = arg.arg( emails ) + ","+parameters2;; | ||
759 | |||
760 | //qDebug("2add%sdd ",arg.latin1() ); | ||
761 | proc->addArgument( arg); | ||
762 | proc->launch(""); | ||
692 | #endif | 763 | #endif |
693 | 764 | ||
@@ -703,5 +774,5 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS | |||
703 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 774 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
704 | { | 775 | { |
705 | #ifndef DESKTOP_VERSION | 776 | |
706 | QString channel; | 777 | QString channel; |
707 | QString message; | 778 | QString message; |
@@ -729,9 +800,10 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e | |||
729 | } | 800 | } |
730 | 801 | ||
731 | 802 | #ifdef DESKTOP_VERSION | |
803 | //message = channel + " " +message + " \""+ parameters + "\""; | ||
804 | #endif | ||
732 | //first check if one of the mailers need the emails right in the message. | 805 | //first check if one of the mailers need the emails right in the message. |
733 | message = translateMessage(message, name, emailadress); | 806 | message = translateMessage(message, name, emailadress); |
734 | 807 | ||
735 | |||
736 | #ifdef DEBUG_EXT_APP_HANDLER | 808 | #ifdef DEBUG_EXT_APP_HANDLER |
737 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 809 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
@@ -739,15 +811,26 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e | |||
739 | #endif | 811 | #endif |
740 | 812 | ||
813 | #ifndef DESKTOP_VERSION | ||
741 | QCopEnvelope e(channel.latin1(), message.latin1()); | 814 | QCopEnvelope e(channel.latin1(), message.latin1()); |
742 | //US we need no names in the To field. The emailadresses are enough | 815 | //US we need no names in the To field. The emailadresses are enough |
743 | 816 | ||
744 | passParameters(&e, parameters, name, emailadress); | 817 | passParameters(&e, parameters, name, emailadress); |
745 | 818 | #else // DESKTOP_VERSION | |
746 | 819 | ||
747 | #else | 820 | //KMessageBox::sorry( 0, message ); |
748 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 821 | QProcess * proc = new QProcess( this ); |
822 | QStringList list = QStringList::split( " ", message ); | ||
823 | int i = 0; | ||
824 | proc->addArgument( channel ); | ||
825 | while ( i < list.count ( ) ) { | ||
826 | //qDebug("add%sdd ",list[i].latin1() ); | ||
827 | proc->addArgument( list[i] ); | ||
828 | ++i; | ||
829 | } | ||
830 | parameters = translateMessage(parameters, name, emailadress); | ||
831 | proc->addArgument( parameters ); | ||
832 | proc->launch(""); | ||
749 | #endif | 833 | #endif |
750 | 834 | ||
751 | |||
752 | return true; | 835 | return true; |
753 | } | 836 | } |