author | ulf69 <ulf69> | 2004-08-10 22:40:58 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-10 22:40:58 (UTC) |
commit | c1ef5e08dbc5d0b891de75ef8e90e73cc4f3d26f (patch) (side-by-side diff) | |
tree | d225831e4aa2af66480dbb7df3a9e56590c8ddbb /libkdepim | |
parent | 29abd716e5187a4717a5459b9c25c6c299df8d56 (diff) | |
download | kdepimpi-c1ef5e08dbc5d0b891de75ef8e90e73cc4f3d26f.zip kdepimpi-c1ef5e08dbc5d0b891de75ef8e90e73cc4f3d26f.tar.gz kdepimpi-c1ef5e08dbc5d0b891de75ef8e90e73cc4f3d26f.tar.bz2 |
changes on how we call external email application
-rw-r--r-- | libkdepim/externalapphandler.cpp | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 5a56d68..1093abf 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp @@ -84,31 +84,31 @@ 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); if (( QFile::exists( qtopiapath + "/bin/ompi" )) || ( QFile::exists( opiepath + "/bin/ompi" ))) - addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", "newMail(QString)", "%1", mailmsg2, "ATTACHMENT=%1"); + 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" )) - addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, ";%1", mailmsg2, "ATTACHMENT=%1"); + 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", mailmsg2, "ATTACHMENT=%1"); + addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); //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 @@ -258,25 +258,25 @@ bool ExternalAppHandler::isPagerAppAvailable() return (mPagerAppAvailable == 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::mailAttachments( const QString& urls ) +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; @@ -287,50 +287,53 @@ bool ExternalAppHandler::mailAttachments( const QString& urls ) { 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); + qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); - qDebug("passing attachmenturls:(%s) as parameter in the form %s to QCopEnvelope", urls.latin1(), parameters2.latin1()); + qDebug("passing emailadresses:(%s), attachmenturls:(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); QCopEnvelope e(channel.latin1(), message2.latin1()); //US we need no names in the To field. The emailadresses are enough - passParameter(&e, parameters2, urls); + passParameters(&e, parameters2, emails, urls); #else KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); #endif return true; } /************************************************************************** * **************************************************************************/ //calls the emailapplication and creates a mail with parameter emails as recipients -bool ExternalAppHandler::mailToContacts( const QString& emails ) +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; @@ -342,48 +345,69 @@ bool ExternalAppHandler::mailToContacts( const QString& emails ) if (!dai) { qDebug("could not find configured email 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, emails); + message = translateMessage(message, name, emailadress); qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); - qDebug("passing emailadresses:(%s) as parameter in the form %s to QCopEnvelope", emails.latin1(), parameters.latin1()); + qDebug("passing name:(%s), emailadresses:(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough - passParameter(&e, parameters, emails); + passParameters(&e, parameters, name, emailadress); #else KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); #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. + 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) { @@ -397,34 +421,34 @@ bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 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); + message = translateMessage(message, phonenumber, ""); qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough - passParameter(&e, parameters, phonenumber); + passParameters(&e, parameters, phonenumber, ""); #else KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); #endif return true; } /************************************************************************** * @@ -452,34 +476,34 @@ bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 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); + message = translateMessage(message, phonenumber, ""); qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough - passParameter(&e, parameters, phonenumber); + passParameters(&e, parameters, phonenumber, ""); #else KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); #endif return true; } /************************************************************************** * @@ -507,34 +531,34 @@ bool ExternalAppHandler::callByPager( const QString& pagernumber ) if (!dai) { qDebug("could not find configured pager 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, pagernumber); + message = translateMessage(message, pagernumber, ""); qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); qDebug("passing pagernumber:(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough - passParameter(&e, parameters, pagernumber); + passParameters(&e, parameters, pagernumber, ""); #else KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); #endif return true; } /************************************************************************** * @@ -562,86 +586,88 @@ bool ExternalAppHandler::callByFax( const QString& faxnumber ) if (!dai) { qDebug("could not find configured fax 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, faxnumber); + message = translateMessage(message, faxnumber, ""); qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); qDebug("passing faxnumber:(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough - passParameter(&e, parameters, faxnumber); + passParameters(&e, parameters, faxnumber, ""); #else KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); #endif return true; } /************************************************************************** * **************************************************************************/ - -QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1) const +QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const { - return message.replace( QRegExp("%1"), param1 ); + message = message.replace( QRegExp("%1"), param1 ); + return message.replace( QRegExp("%2"), param2 ); } /************************************************************************** * **************************************************************************/ -void ExternalAppHandler::passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const +void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const { #ifndef DESKTOP_VERSION QMap<QString, QString> valmap; bool useValMap = false; // first extract all parts of the parameters. QStringList paramlist = QStringList::split(";", parameters); //Now check how many parts we have. //=0 :no params to pass //>0 :parameters to pass for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) { QString param = (*it); QStringList keyvallist = QStringList::split("=", param); //if we have keyvalue pairs, we assume that we pass a map to the envelope QStringList::Iterator it2 = keyvallist.begin(); QString key = (*it2); key = key.replace( QRegExp("%1"), param1 ); + key = key.replace( QRegExp("%2"), param2 ); ++it2; if(it2 != keyvallist.end()) { QString value = (*it2); value = value.replace( QRegExp("%1"), param1 ); + value = value.replace( QRegExp("%2"), param2 ); valmap.insert(key, value); useValMap = true; } else { (*e) << key.latin1(); } } if (useValMap == true) (*e) << valmap; |