summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
Unidiff
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp81
1 files changed, 80 insertions, 1 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 5ba32b6..fa56ee9 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -346,25 +346,25 @@ ExternalAppHandler::~ExternalAppHandler()
346{ 346{
347} 347}
348 348
349void ExternalAppHandler::loadConfig() 349void ExternalAppHandler::loadConfig()
350{ 350{
351 351
352 mDefaultItems.clear(); 352 mDefaultItems.clear();
353 mEmailAppAvailable = UNDEFINED; 353 mEmailAppAvailable = UNDEFINED;
354 mPhoneAppAvailable = UNDEFINED; 354 mPhoneAppAvailable = UNDEFINED;
355 mFaxAppAvailable = UNDEFINED; 355 mFaxAppAvailable = UNDEFINED;
356 mSMSAppAvailable = UNDEFINED; 356 mSMSAppAvailable = UNDEFINED;
357 mPagerAppAvailable = UNDEFINED; 357 mPagerAppAvailable = UNDEFINED;
358 358 mSIPAppAvailable = UNDEFINED;
359 359
360 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 360 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
361 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 361 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
362 362
363 if (opiepath.isEmpty()) 363 if (opiepath.isEmpty())
364 opiepath = qtopiapath; 364 opiepath = qtopiapath;
365 365
366 //mailclients 366 //mailclients
367 QString mailmsg1 = "writeMail(QString,QString)"; 367 QString mailmsg1 = "writeMail(QString,QString)";
368 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 368 QString mailmsg2 = "writeMail(QMap(QString,QString))";
369 369
370 QString undefined = ""; 370 QString undefined = "";
@@ -395,24 +395,28 @@ void ExternalAppHandler::loadConfig()
395 //faxclients 395 //faxclients
396 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 396 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
397 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 397 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
398 398
399 //smsclients 399 //smsclients
400 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 400 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
401 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 401 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
402 402
403 //pagerclients 403 //pagerclients
404 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 404 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
405 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 405 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
406 406
407 //sipclients
408 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No sip client installed", undefined, undefined, undefined, undefined, undefined);
409 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other sip client", undefined, undefined, undefined, undefined, undefined);
410
407} 411}
408 412
409ExternalAppHandler *ExternalAppHandler::instance() 413ExternalAppHandler *ExternalAppHandler::instance()
410{ 414{
411 if ( !sInstance ) { 415 if ( !sInstance ) {
412 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 416 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
413 sInstance->loadConfig(); 417 sInstance->loadConfig();
414 } 418 }
415 419
416 return sInstance; 420 return sInstance;
417} 421}
418 422
@@ -533,24 +537,43 @@ bool ExternalAppHandler::isPagerAppAvailable()
533 if (client == KPimGlobalPrefs::NONE_PAC) 537 if (client == KPimGlobalPrefs::NONE_PAC)
534 mPagerAppAvailable = UNAVAILABLE; 538 mPagerAppAvailable = UNAVAILABLE;
535 else 539 else
536 mPagerAppAvailable = AVAILABLE; 540 mPagerAppAvailable = AVAILABLE;
537 } 541 }
538 542
539 return (mPagerAppAvailable == AVAILABLE); 543 return (mPagerAppAvailable == AVAILABLE);
540#else //DESKTOP_VERSION 544#else //DESKTOP_VERSION
541 return false; 545 return false;
542#endif //DESKTOP_VERSION 546#endif //DESKTOP_VERSION
543} 547}
544 548
549
550bool ExternalAppHandler::isSIPAppAvailable()
551{
552#ifndef DESKTOP_VERSION
553 if (mSIPAppAvailable == UNDEFINED)
554 {
555 int client = KPimGlobalPrefs::instance()->mSipClient;
556 if (client == KPimGlobalPrefs::NONE_SIC)
557 mSIPAppAvailable = UNAVAILABLE;
558 else
559 mSIPAppAvailable = AVAILABLE;
560 }
561
562 return (mSIPAppAvailable == AVAILABLE);
563#else //DESKTOP_VERSION
564 return false;
565#endif //DESKTOP_VERSION
566}
567
545/************************************************************************** 568/**************************************************************************
546 * 569 *
547 **************************************************************************/ 570 **************************************************************************/
548 571
549 572
550//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 573//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
551bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 574bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
552{ 575{
553 576
554#ifndef DESKTOP_VERSION 577#ifndef DESKTOP_VERSION
555 QString channel; 578 QString channel;
556 QString message2; 579 QString message2;
@@ -892,24 +915,80 @@ bool ExternalAppHandler::callByFax( const QString& faxnumber )
892#else 915#else
893 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 916 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
894#endif 917#endif
895 918
896 919
897 return true; 920 return true;
898} 921}
899 922
900/************************************************************************** 923/**************************************************************************
901 * 924 *
902 **************************************************************************/ 925 **************************************************************************/
903 926
927//calls the sipapplication with the number
928bool ExternalAppHandler::callBySIP( const QString& sipnumber )
929{
930#ifndef DESKTOP_VERSION
931 QString channel;
932 QString message;
933 QString parameters;
934
935
936 int client = KPimGlobalPrefs::instance()->mSipClient;
937 if (client == KPimGlobalPrefs::OTHER_SIC)
938 {
939 channel = KPimGlobalPrefs::instance()->mSipOtherChannel;
940 message = KPimGlobalPrefs::instance()->mSipOtherMessage;
941 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters;
942 }
943 else
944 {
945 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client);
946 if (!dai)
947 {
948 qDebug("could not find configured sip application.");
949 return false;
950 }
951 channel = dai->_channel;
952 message = dai->_message;
953 parameters = dai->_parameters;
954 }
955
956
957 //first check if one of the sip apps need the emails right in the message.
958 message = translateMessage(message, sipnumber, "");
959
960
961 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
962 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1());
963
964 QCopEnvelope e(channel.latin1(), message.latin1());
965 //US we need no names in the To field. The emailadresses are enough
966
967 passParameters(&e, parameters, sipnumber, "");
968
969
970#else
971 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
972#endif
973
974
975 return true;
976}
977
978
979/**************************************************************************
980 *
981 **************************************************************************/
982
904 983
905QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 984QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
906{ 985{
907 message = message.replace( QRegExp("%1"), param1 ); 986 message = message.replace( QRegExp("%1"), param1 );
908 return message.replace( QRegExp("%2"), param2 ); 987 return message.replace( QRegExp("%2"), param2 );
909} 988}
910 989
911/************************************************************************** 990/**************************************************************************
912 * 991 *
913 **************************************************************************/ 992 **************************************************************************/
914 993
915void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 994void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const