summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-08-13 16:52:31 (UTC)
committer ulf69 <ulf69>2004-08-13 16:52:31 (UTC)
commit0e46d151bca931ff5c69a637d91cfcc381094e0b (patch) (side-by-side diff)
tree8a821a892aaa3035a17b843ab5dbead0353398e5
parent2de1d7732f0f44895b353bb61520f725ede484ea (diff)
downloadkdepimpi-0e46d151bca931ff5c69a637d91cfcc381094e0b.zip
kdepimpi-0e46d151bca931ff5c69a637d91cfcc381094e0b.tar.gz
kdepimpi-0e46d151bca931ff5c69a637d91cfcc381094e0b.tar.bz2
fixed a bug. I passed the QString parameters as latin1 representation, which was not correct.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 1093abf..35638b1 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -256,425 +256,426 @@ 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::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);
qDebug("Using 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());
+ 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
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::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;
}
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;
}
//first check if one of the mailers need the emails right in the message.
message = translateMessage(message, name, emailadress);
qDebug("Using 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());
+ 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
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)
{
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, "");
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());
+ 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
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, "");
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());
+ 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
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;
message = dai->_message;
parameters = dai->_parameters;
}
//first check if one of the mailers need the emails right in the message.
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());
+ 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
passParameters(&e, parameters, pagernumber, "");
#else
KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
#endif
return true;
}
/**************************************************************************
*
**************************************************************************/
//calls the faxapplication with the number
bool ExternalAppHandler::callByFax( const QString& faxnumber )
{
#ifndef DESKTOP_VERSION
QString channel;
QString message;
QString parameters;
int client = KPimGlobalPrefs::instance()->mFaxClient;
if (client == KPimGlobalPrefs::OTHER_FAC)
{
channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
}
else
{
DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
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, "");
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());
+ 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
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& param2 ) const
{
message = message.replace( QRegExp("%1"), param1 );
return message.replace( QRegExp("%2"), param2 );
}
/**************************************************************************
*
**************************************************************************/
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();
+ // qDebug("pass parameter << %s", key.latin1());
+ (*e) << key;
}
}
if (useValMap == true)
(*e) << valmap;
#endif
}