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
@@ -310,145 +310,149 @@ bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& d
310 310
311 311
312 return true; 312 return true;
313 } 313 }
314 } 314 }
315 315
316 return false; 316 return false;
317} 317}
318 318
319 319
320 320
321/********************************************************************************* 321/*********************************************************************************
322 * 322 *
323 ********************************************************************************/ 323 ********************************************************************************/
324 324
325 325
326ExternalAppHandler *ExternalAppHandler::sInstance = 0; 326ExternalAppHandler *ExternalAppHandler::sInstance = 0;
327static KStaticDeleter<ExternalAppHandler> staticDeleter; 327static KStaticDeleter<ExternalAppHandler> staticDeleter;
328 328
329ExternalAppHandler::ExternalAppHandler() 329ExternalAppHandler::ExternalAppHandler()
330{ 330{
331 mDefaultItems.setAutoDelete(true); 331 mDefaultItems.setAutoDelete(true);
332 332
333 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 333 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
334 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 334 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
335 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 335 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
336 336
337//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 337//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
338//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 338//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
339//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 339//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
340 340
341 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 341 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
342 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 342 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
343} 343}
344 344
345ExternalAppHandler::~ExternalAppHandler() 345ExternalAppHandler::~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 = "";
371 371
372 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 372 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
373 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 373 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
374 374
375 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 375 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
376 ( QFile::exists( opiepath + "/bin/ompi" ))) 376 ( QFile::exists( opiepath + "/bin/ompi" )))
377 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 377 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
378 378
379 if ( QFile::exists( qtopiapath + "/bin/qtmail" )) 379 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
380 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 380 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
381 381
382 if ( QFile::exists( opiepath + "/bin/opiemail" )) 382 if ( QFile::exists( opiepath + "/bin/opiemail" ))
383 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 383 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
384 384
385 385
386 386
387 //phoneclients 387 //phoneclients
388 388
389 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 389 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
390 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 390 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
391 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 391 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
392 ( QFile::exists( opiepath + "/bin/kppi" ))) 392 ( QFile::exists( opiepath + "/bin/kppi" )))
393 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 393 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
394 394
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
419void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 423void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
420{ 424{
421 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 425 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
422 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 426 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
423 mDefaultItems.append(dai); 427 mDefaultItems.append(dai);
424} 428}
425 429
426 430
427QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 431QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
428{ 432{
429 QList<DefaultAppItem> list; 433 QList<DefaultAppItem> list;
430 434
431 DefaultAppItem* dai; 435 DefaultAppItem* dai;
432 436
433 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 437 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
434 { 438 {
435 if (dai->_type == type) 439 if (dai->_type == type)
436 list.append(dai); 440 list.append(dai);
437 } 441 }
438 442
439 return list; 443 return list;
440} 444}
441 445
442DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 446DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
443{ 447{
444 DefaultAppItem* dai; 448 DefaultAppItem* dai;
445 449
446 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 450 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
447 { 451 {
448 if (dai->_type == type && dai->_id == clientid) 452 if (dai->_type == type && dai->_id == clientid)
449 return dai; 453 return dai;
450 } 454 }
451 455
452 return 0; 456 return 0;
453} 457}
454 458
@@ -497,96 +501,115 @@ bool ExternalAppHandler::isPhoneAppAvailable()
497 if (client == KPimGlobalPrefs::NONE_PHC) 501 if (client == KPimGlobalPrefs::NONE_PHC)
498 mPhoneAppAvailable = UNAVAILABLE; 502 mPhoneAppAvailable = UNAVAILABLE;
499 else 503 else
500 mPhoneAppAvailable = AVAILABLE; 504 mPhoneAppAvailable = AVAILABLE;
501 } 505 }
502 506
503 return (mPhoneAppAvailable == AVAILABLE); 507 return (mPhoneAppAvailable == AVAILABLE);
504#else //DESKTOP_VERSION 508#else //DESKTOP_VERSION
505 return false; 509 return false;
506#endif //DESKTOP_VERSION 510#endif //DESKTOP_VERSION
507} 511}
508 512
509bool ExternalAppHandler::isFaxAppAvailable() 513bool ExternalAppHandler::isFaxAppAvailable()
510{ 514{
511#ifndef DESKTOP_VERSION 515#ifndef DESKTOP_VERSION
512 if (mFaxAppAvailable == UNDEFINED) 516 if (mFaxAppAvailable == UNDEFINED)
513 { 517 {
514 int client = KPimGlobalPrefs::instance()->mFaxClient; 518 int client = KPimGlobalPrefs::instance()->mFaxClient;
515 if (client == KPimGlobalPrefs::NONE_FAC) 519 if (client == KPimGlobalPrefs::NONE_FAC)
516 mFaxAppAvailable = UNAVAILABLE; 520 mFaxAppAvailable = UNAVAILABLE;
517 else 521 else
518 mFaxAppAvailable = AVAILABLE; 522 mFaxAppAvailable = AVAILABLE;
519 } 523 }
520 524
521 return (mFaxAppAvailable == AVAILABLE); 525 return (mFaxAppAvailable == AVAILABLE);
522#else //DESKTOP_VERSION 526#else //DESKTOP_VERSION
523 return false; 527 return false;
524#endif //DESKTOP_VERSION 528#endif //DESKTOP_VERSION
525} 529}
526 530
527bool ExternalAppHandler::isPagerAppAvailable() 531bool ExternalAppHandler::isPagerAppAvailable()
528{ 532{
529#ifndef DESKTOP_VERSION 533#ifndef DESKTOP_VERSION
530 if (mPagerAppAvailable == UNDEFINED) 534 if (mPagerAppAvailable == UNDEFINED)
531 { 535 {
532 int client = KPimGlobalPrefs::instance()->mPagerClient; 536 int client = KPimGlobalPrefs::instance()->mPagerClient;
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;
557 QString parameters2; 580 QString parameters2;
558 581
559 582
560 int client = KPimGlobalPrefs::instance()->mEmailClient; 583 int client = KPimGlobalPrefs::instance()->mEmailClient;
561 if (client == KPimGlobalPrefs::OTHER_EMC) 584 if (client == KPimGlobalPrefs::OTHER_EMC)
562 { 585 {
563 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 586 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
564 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 587 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
565 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 588 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
566 } 589 }
567 else 590 else
568 { 591 {
569 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 592 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
570 if (!dai) 593 if (!dai)
571 { 594 {
572 qDebug("could not find configured email application."); 595 qDebug("could not find configured email application.");
573 return false; 596 return false;
574 } 597 }
575 channel = dai->_channel; 598 channel = dai->_channel;
576 message2 = dai->_message2; 599 message2 = dai->_message2;
577 parameters2 = dai->_parameters2; 600 parameters2 = dai->_parameters2;
578 } 601 }
579 602
580 //first check if one of the mailers need the emails right in the message. 603 //first check if one of the mailers need the emails right in the message.
581 message2 = translateMessage(message2, emails, urls); 604 message2 = translateMessage(message2, emails, urls);
582 605
583 606
584 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 607 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
585 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 608 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
586 609
587 610
588 QCopEnvelope e(channel.latin1(), message2.latin1()); 611 QCopEnvelope e(channel.latin1(), message2.latin1());
589 //US we need no names in the To field. The emailadresses are enough 612 //US we need no names in the To field. The emailadresses are enough
590 613
591 passParameters(&e, parameters2, emails, urls); 614 passParameters(&e, parameters2, emails, urls);
592 615
@@ -856,96 +879,152 @@ bool ExternalAppHandler::callByFax( const QString& faxnumber )
856 879
857 880
858 int client = KPimGlobalPrefs::instance()->mFaxClient; 881 int client = KPimGlobalPrefs::instance()->mFaxClient;
859 if (client == KPimGlobalPrefs::OTHER_FAC) 882 if (client == KPimGlobalPrefs::OTHER_FAC)
860 { 883 {
861 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 884 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
862 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 885 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
863 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 886 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
864 } 887 }
865 else 888 else
866 { 889 {
867 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 890 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
868 if (!dai) 891 if (!dai)
869 { 892 {
870 qDebug("could not find configured fax application."); 893 qDebug("could not find configured fax application.");
871 return false; 894 return false;
872 } 895 }
873 channel = dai->_channel; 896 channel = dai->_channel;
874 message = dai->_message; 897 message = dai->_message;
875 parameters = dai->_parameters; 898 parameters = dai->_parameters;
876 } 899 }
877 900
878 901
879 //first check if one of the mailers need the emails right in the message. 902 //first check if one of the mailers need the emails right in the message.
880 message = translateMessage(message, faxnumber, ""); 903 message = translateMessage(message, faxnumber, "");
881 904
882 905
883 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 906 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
884 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 907 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
885 908
886 QCopEnvelope e(channel.latin1(), message.latin1()); 909 QCopEnvelope e(channel.latin1(), message.latin1());
887 //US we need no names in the To field. The emailadresses are enough 910 //US we need no names in the To field. The emailadresses are enough
888 911
889 passParameters(&e, parameters, faxnumber, ""); 912 passParameters(&e, parameters, faxnumber, "");
890 913
891 914
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
916{ 995{
917#ifndef DESKTOP_VERSION 996#ifndef DESKTOP_VERSION
918 QMap<QString, QString> valmap; 997 QMap<QString, QString> valmap;
919 bool useValMap = false; 998 bool useValMap = false;
920 999
921 // first extract all parts of the parameters. 1000 // first extract all parts of the parameters.
922 QStringList paramlist = QStringList::split(";", parameters); 1001 QStringList paramlist = QStringList::split(";", parameters);
923 1002
924 //Now check how many parts we have. 1003 //Now check how many parts we have.
925 //=0 :no params to pass 1004 //=0 :no params to pass
926 //>0 :parameters to pass 1005 //>0 :parameters to pass
927 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 1006 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
928 { 1007 {
929 QString param = (*it); 1008 QString param = (*it);
930 QStringList keyvallist = QStringList::split("=", param); 1009 QStringList keyvallist = QStringList::split("=", param);
931 1010
932 //if we have keyvalue pairs, we assume that we pass a map to the envelope 1011 //if we have keyvalue pairs, we assume that we pass a map to the envelope
933 QStringList::Iterator it2 = keyvallist.begin(); 1012 QStringList::Iterator it2 = keyvallist.begin();
934 QString key = (*it2); 1013 QString key = (*it2);
935 key = key.replace( QRegExp("%1"), param1 ); 1014 key = key.replace( QRegExp("%1"), param1 );
936 key = key.replace( QRegExp("%2"), param2 ); 1015 key = key.replace( QRegExp("%2"), param2 );
937 ++it2; 1016 ++it2;
938 1017
939 if(it2 != keyvallist.end()) 1018 if(it2 != keyvallist.end())
940 { 1019 {
941 QString value = (*it2); 1020 QString value = (*it2);
942 value = value.replace( QRegExp("%1"), param1 ); 1021 value = value.replace( QRegExp("%1"), param1 );
943 value = value.replace( QRegExp("%2"), param2 ); 1022 value = value.replace( QRegExp("%2"), param2 );
944 1023
945 valmap.insert(key, value); 1024 valmap.insert(key, value);
946 useValMap = true; 1025 useValMap = true;
947 } 1026 }
948 else 1027 else
949 { 1028 {
950 // qDebug("pass parameter << %s", key.latin1()); 1029 // qDebug("pass parameter << %s", key.latin1());
951 (*e) << key; 1030 (*e) << key;