-rw-r--r-- | libkdepim/externalapphandler.cpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index edefda4..59be506 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -697,87 +697,100 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS | |||
697 | #endif | 697 | #endif |
698 | 698 | ||
699 | 699 | ||
700 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 700 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
701 | //US we need no names in the To field. The emailadresses are enough | 701 | //US we need no names in the To field. The emailadresses are enough |
702 | 702 | ||
703 | passParameters(&e, parameters2, emails, urls); | 703 | passParameters(&e, parameters2, emails, urls); |
704 | 704 | ||
705 | 705 | ||
706 | 706 | ||
707 | #else | 707 | #else |
708 | //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); | 708 | //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); |
709 | 709 | ||
710 | QString channel; | 710 | QString channel; |
711 | QString message2; | 711 | QString message2; |
712 | QString parameters2; | 712 | QString parameters2; |
713 | QString message; | 713 | QString message; |
714 | QString parameters; | 714 | QString parameters; |
715 | 715 | ||
716 | 716 | ||
717 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 717 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
718 | if (client == KPimGlobalPrefs::OTHER_EMC) | 718 | if (client == KPimGlobalPrefs::OTHER_EMC) |
719 | { | 719 | { |
720 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 720 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
721 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 721 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
722 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 722 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; |
723 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | ||
724 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; | ||
723 | } | 725 | } |
724 | else | 726 | else |
725 | { | 727 | { |
726 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 728 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
727 | if (!dai) | 729 | if (!dai) |
728 | { | 730 | { |
729 | qDebug("could not find configured email application."); | 731 | qDebug("could not find configured email application."); |
730 | return false; | 732 | return false; |
731 | } | 733 | } |
732 | channel = dai->_channel; | 734 | channel = dai->_channel; |
733 | message2 = dai->_message2; | 735 | message2 = dai->_message2; |
734 | parameters2 = dai->_parameters2; | 736 | parameters2 = dai->_parameters2; |
735 | message = dai->_message; | 737 | message = dai->_message; |
736 | parameters = dai->_parameters; | 738 | parameters = dai->_parameters; |
737 | } | 739 | } |
738 | 740 | ||
739 | //first check if one of the mailers need the emails right in the message. | 741 | //first check if one of the mailers need the emails right in the message. |
740 | message2 = translateMessage(message2, emails, urls); | 742 | message2 = translateMessage(message2, emails, urls); |
741 | #ifdef DEBUG_EXT_APP_HANDLER | 743 | #ifdef DEBUG_EXT_APP_HANDLER |
742 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 744 | 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()); | 745 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
744 | #endif | 746 | #endif |
745 | qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); | 747 | qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); |
746 | //KMessageBox::sorry( 0, message2 ); | 748 | //KMessageBox::sorry( 0, message2 ); |
747 | QProcess * proc = new QProcess( this ); | 749 | QProcess * proc = new QProcess( this ); |
748 | QStringList list = QStringList::split( " ", message ); | ||
749 | int i = 0; | 750 | int i = 0; |
750 | proc->addArgument( channel ); | 751 | proc->addArgument( channel ); |
751 | while ( i < list.count ( ) ) { | 752 | |
752 | //qDebug("add%sdd ",list[i].stripWhiteSpace().latin1() ); | 753 | if ( message.find (" " ) > 0 ) { |
753 | proc->addArgument( list[i].stripWhiteSpace() ); | 754 | QStringList list = QStringList::split( " ", message ); |
755 | int i = 0; | ||
756 | while ( i < list.count ( ) ) { | ||
757 | //qDebug("add%sdd ",list[i].latin1() ); | ||
758 | proc->addArgument( list[i] ); | ||
759 | //KMessageBox::sorry( 0,list[i]); | ||
754 | ++i; | 760 | ++i; |
761 | } | ||
762 | } else { | ||
763 | proc->addArgument(message ); | ||
764 | //KMessageBox::sorry( 0, message ); | ||
765 | |||
755 | } | 766 | } |
767 | |||
756 | parameters2 = translateMessage(parameters2, urls, "" ); | 768 | parameters2 = translateMessage(parameters2, urls, "" ); |
757 | QString arg = "to='%1'"; | 769 | QString arg = "to='%1'"; |
758 | arg = arg.arg( emails ) + ","+parameters2;; | 770 | arg = arg.arg( emails ) + ","+parameters2;; |
759 | 771 | ||
772 | //KMessageBox::sorry( 0,arg ); | ||
760 | //qDebug("2add%sdd ",arg.latin1() ); | 773 | //qDebug("2add%sdd ",arg.latin1() ); |
761 | proc->addArgument( arg); | 774 | proc->addArgument( arg); |
762 | proc->launch(""); | 775 | proc->launch(""); |
763 | #endif | 776 | #endif |
764 | 777 | ||
765 | return true; | 778 | return true; |
766 | } | 779 | } |
767 | 780 | ||
768 | /************************************************************************** | 781 | /************************************************************************** |
769 | * | 782 | * |
770 | **************************************************************************/ | 783 | **************************************************************************/ |
771 | 784 | ||
772 | 785 | ||
773 | //calls the emailapplication and creates a mail with parameter emails as recipients | 786 | //calls the emailapplication and creates a mail with parameter emails as recipients |
774 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 787 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
775 | { | 788 | { |
776 | 789 | ||
777 | QString channel; | 790 | QString channel; |
778 | QString message; | 791 | QString message; |
779 | QString parameters; | 792 | QString parameters; |
780 | 793 | ||
781 | 794 | ||
782 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 795 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
783 | if (client == KPimGlobalPrefs::OTHER_EMC) | 796 | if (client == KPimGlobalPrefs::OTHER_EMC) |
@@ -796,57 +809,63 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e | |||
796 | } | 809 | } |
797 | channel = dai->_channel; | 810 | channel = dai->_channel; |
798 | message = dai->_message; | 811 | message = dai->_message; |
799 | parameters = dai->_parameters; | 812 | parameters = dai->_parameters; |
800 | } | 813 | } |
801 | 814 | ||
802 | #ifdef DESKTOP_VERSION | 815 | #ifdef DESKTOP_VERSION |
803 | //message = channel + " " +message + " \""+ parameters + "\""; | 816 | //message = channel + " " +message + " \""+ parameters + "\""; |
804 | #endif | 817 | #endif |
805 | //first check if one of the mailers need the emails right in the message. | 818 | //first check if one of the mailers need the emails right in the message. |
806 | message = translateMessage(message, name, emailadress); | 819 | message = translateMessage(message, name, emailadress); |
807 | 820 | ||
808 | #ifdef DEBUG_EXT_APP_HANDLER | 821 | #ifdef DEBUG_EXT_APP_HANDLER |
809 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 822 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
810 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 823 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
811 | #endif | 824 | #endif |
812 | 825 | ||
813 | #ifndef DESKTOP_VERSION | 826 | #ifndef DESKTOP_VERSION |
814 | QCopEnvelope e(channel.latin1(), message.latin1()); | 827 | QCopEnvelope e(channel.latin1(), message.latin1()); |
815 | //US we need no names in the To field. The emailadresses are enough | 828 | //US we need no names in the To field. The emailadresses are enough |
816 | 829 | ||
817 | passParameters(&e, parameters, name, emailadress); | 830 | passParameters(&e, parameters, name, emailadress); |
818 | #else // DESKTOP_VERSION | 831 | #else // DESKTOP_VERSION |
819 | 832 | ||
820 | //KMessageBox::sorry( 0, message ); | 833 | //KMessageBox::sorry( 0,channel ); |
821 | QProcess * proc = new QProcess( this ); | 834 | QProcess * proc = new QProcess( this ); |
822 | QStringList list = QStringList::split( " ", message ); | ||
823 | int i = 0; | ||
824 | proc->addArgument( channel ); | 835 | proc->addArgument( channel ); |
825 | while ( i < list.count ( ) ) { | 836 | if ( message.find (" " ) > 0 ) { |
837 | QStringList list = QStringList::split( " ", message ); | ||
838 | int i = 0; | ||
839 | while ( i < list.count ( ) ) { | ||
826 | //qDebug("add%sdd ",list[i].latin1() ); | 840 | //qDebug("add%sdd ",list[i].latin1() ); |
827 | proc->addArgument( list[i] ); | 841 | proc->addArgument( list[i] ); |
842 | //KMessageBox::sorry( 0,list[i]); | ||
828 | ++i; | 843 | ++i; |
844 | } | ||
845 | } else { | ||
846 | proc->addArgument(message ); | ||
847 | |||
829 | } | 848 | } |
830 | parameters = translateMessage(parameters, name, emailadress); | 849 | parameters = translateMessage(parameters, name, emailadress); |
831 | proc->addArgument( parameters ); | 850 | proc->addArgument( parameters ); |
832 | proc->launch(""); | 851 | proc->launch(""); |
833 | #endif | 852 | #endif |
834 | 853 | ||
835 | return true; | 854 | return true; |
836 | } | 855 | } |
837 | 856 | ||
838 | /************************************************************************** | 857 | /************************************************************************** |
839 | * | 858 | * |
840 | **************************************************************************/ | 859 | **************************************************************************/ |
841 | 860 | ||
842 | //calls the emailapplication and creates a mail with parameter as recipients | 861 | //calls the emailapplication and creates a mail with parameter as recipients |
843 | // parameters format is | 862 | // parameters format is |
844 | // NAME <EMAIL>:SUBJECT | 863 | // NAME <EMAIL>:SUBJECT |
845 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 864 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
846 | { | 865 | { |
847 | QString line = adressline; | 866 | QString line = adressline; |
848 | 867 | ||
849 | int first = line.find( "<"); | 868 | int first = line.find( "<"); |
850 | int last = line.find( ">"); | 869 | int last = line.find( ">"); |
851 | QString name = line.left(first); | 870 | QString name = line.left(first); |
852 | QString emailadress = line.mid(first+1, last-first-1); | 871 | QString emailadress = line.mid(first+1, last-first-1); |
@@ -882,49 +901,49 @@ bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | |||
882 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 901 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
883 | if (!dai) | 902 | if (!dai) |
884 | { | 903 | { |
885 | qDebug("could not find configured phone application."); | 904 | qDebug("could not find configured phone application."); |
886 | return false; | 905 | return false; |
887 | } | 906 | } |
888 | channel = dai->_channel; | 907 | channel = dai->_channel; |
889 | message = dai->_message; | 908 | message = dai->_message; |
890 | parameters = dai->_parameters; | 909 | parameters = dai->_parameters; |
891 | } | 910 | } |
892 | 911 | ||
893 | 912 | ||
894 | //first check if one of the mailers need the emails right in the message. | 913 | //first check if one of the mailers need the emails right in the message. |
895 | message = translateMessage(message, phonenumber, ""); | 914 | message = translateMessage(message, phonenumber, ""); |
896 | 915 | ||
897 | 916 | ||
898 | #ifdef DEBUG_EXT_APP_HANDLER | 917 | #ifdef DEBUG_EXT_APP_HANDLER |
899 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 918 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
900 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 919 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
901 | #endif | 920 | #endif |
902 | 921 | ||
903 | QCopEnvelope e(channel.latin1(), message.latin1()); | 922 | QCopEnvelope e(channel.latin1(), message.latin1()); |
904 | //US we need no names in the To field. The emailadresses are enough | 923 | //US we need no names in the To field. The emailadresses are enough |
905 | 924 | ||
906 | passParameters(&e, parameters, phonenumber, ""); | 925 | passParameters(&e, parameters, phonenumber, ""); |
907 | 926 | ||
908 | 927 | ||
909 | #else | 928 | #else |
910 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 929 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
911 | #endif | 930 | #endif |
912 | 931 | ||
913 | 932 | ||
914 | return true; | 933 | return true; |
915 | } | 934 | } |
916 | 935 | ||
917 | /************************************************************************** | 936 | /************************************************************************** |
918 | * | 937 | * |
919 | **************************************************************************/ | 938 | **************************************************************************/ |
920 | 939 | ||
921 | //calls the smsapplication with the number | 940 | //calls the smsapplication with the number |
922 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 941 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
923 | { | 942 | { |
924 | #ifndef DESKTOP_VERSION | 943 | #ifndef DESKTOP_VERSION |
925 | QString channel; | 944 | QString channel; |
926 | QString message; | 945 | QString message; |
927 | QString parameters; | 946 | QString parameters; |
928 | 947 | ||
929 | 948 | ||
930 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 949 | int client = KPimGlobalPrefs::instance()->mSMSClient; |