-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 @@ -625,378 +625,397 @@ bool ExternalAppHandler::isPagerAppAvailable() mPagerAppAvailable = UNAVAILABLE; else mPagerAppAvailable = AVAILABLE; } return (mPagerAppAvailable == AVAILABLE); #else //DESKTOP_VERSION return false; #endif //DESKTOP_VERSION } bool ExternalAppHandler::isSIPAppAvailable() { #ifndef DESKTOP_VERSION if (mSIPAppAvailable == UNDEFINED) { int client = KPimGlobalPrefs::instance()->mSipClient; if (client == KPimGlobalPrefs::NONE_SIC) mSIPAppAvailable = UNAVAILABLE; else mSIPAppAvailable = AVAILABLE; } return (mSIPAppAvailable == AVAILABLE); #else //DESKTOP_VERSION return false; #endif //DESKTOP_VERSION } /************************************************************************** * **************************************************************************/ //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) { #ifndef DESKTOP_VERSION QString channel; QString message2; QString parameters2; 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; } //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 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 //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; + message = KPimGlobalPrefs::instance()->mEmailOtherMessage; + message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; + parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; + parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; } 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() ); + + if ( message.find (" " ) > 0 ) { + QStringList list = QStringList::split( " ", message ); + int i = 0; + while ( i < list.count ( ) ) { + //qDebug("add%sdd ",list[i].latin1() ); + proc->addArgument( list[i] ); + //KMessageBox::sorry( 0,list[i]); ++i; + } + } else { + proc->addArgument(message ); + //KMessageBox::sorry( 0, message ); + } + parameters2 = translateMessage(parameters2, urls, "" ); QString arg = "to='%1'"; arg = arg.arg( emails ) + ","+parameters2;; + //KMessageBox::sorry( 0,arg ); //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 ) { 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; } else { 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 // DESKTOP_VERSION - //KMessageBox::sorry( 0, message ); + //KMessageBox::sorry( 0,channel ); QProcess * proc = new QProcess( this ); - QStringList list = QStringList::split( " ", message ); - int i = 0; proc->addArgument( channel ); - while ( i < list.count ( ) ) { + if ( message.find (" " ) > 0 ) { + QStringList list = QStringList::split( " ", message ); + int i = 0; + while ( i < list.count ( ) ) { //qDebug("add%sdd ",list[i].latin1() ); proc->addArgument( list[i] ); + //KMessageBox::sorry( 0,list[i]); ++i; + } + } else { + proc->addArgument(message ); + } 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 ) { QString line = adressline; int first = line.find( "<"); int last = line.find( ">"); QString name = line.left(first); QString emailadress = line.mid(first+1, last-first-1); //Subject can not be handled right now. return mailToOneContact( name, emailadress ); } /************************************************************************** * **************************************************************************/ //calls the phoneapplication with the number bool ExternalAppHandler::callByPhone( const QString& phonenumber ) { #ifndef DESKTOP_VERSION QString channel; QString message; QString parameters; int client = KPimGlobalPrefs::instance()->mPhoneClient; if (client == KPimGlobalPrefs::OTHER_PHC) { channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; } else { DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); if (!dai) { qDebug("could not find configured phone application."); return false; } channel = dai->_channel; message = dai->_message; parameters = dai->_parameters; } //first check if one of the mailers need the emails right in the message. message = translateMessage(message, phonenumber, ""); #ifdef DEBUG_EXT_APP_HANDLER qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); #endif QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough - passParameters(&e, parameters, phonenumber, ""); + passParameters(&e, parameters, phonenumber, ""); #else KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); #endif return true; } /************************************************************************** * **************************************************************************/ //calls the smsapplication with the number bool ExternalAppHandler::callBySMS( const QString& phonenumber ) { #ifndef DESKTOP_VERSION QString channel; QString message; QString parameters; int client = KPimGlobalPrefs::instance()->mSMSClient; if (client == KPimGlobalPrefs::OTHER_SMC) { channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; message = KPimGlobalPrefs::instance()->mSMSOtherMessage; parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; } else { DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); if (!dai) { qDebug("could not find configured sms application."); return false; } channel = dai->_channel; message = dai->_message; parameters = dai->_parameters; } //first check if one of the mailers need the emails right in the message. message = translateMessage(message, phonenumber, ""); #ifdef DEBUG_EXT_APP_HANDLER qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); #endif QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough passParameters(&e, parameters, phonenumber, ""); #else KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); #endif return true; } /************************************************************************** * **************************************************************************/ //calls the pagerapplication with the number bool ExternalAppHandler::callByPager( const QString& pagernumber ) { #ifndef DESKTOP_VERSION QString channel; QString message; QString parameters; int client = KPimGlobalPrefs::instance()->mPagerClient; if (client == KPimGlobalPrefs::OTHER_PAC) { channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; message = KPimGlobalPrefs::instance()->mPagerOtherMessage; parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; } else { DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); if (!dai) { qDebug("could not find configured pager application."); return false; } channel = dai->_channel; |