-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 | |||
@@ -337,954 +337,973 @@ bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& d | |||
337 | 337 | ||
338 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; | 338 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; |
339 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); | 339 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); |
340 | 340 | ||
341 | 341 | ||
342 | return true; | 342 | return true; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | return false; | 346 | return false; |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | 350 | ||
351 | /********************************************************************************* | 351 | /********************************************************************************* |
352 | * | 352 | * |
353 | ********************************************************************************/ | 353 | ********************************************************************************/ |
354 | 354 | ||
355 | 355 | ||
356 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 356 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
357 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 357 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
358 | 358 | ||
359 | ExternalAppHandler::ExternalAppHandler() | 359 | ExternalAppHandler::ExternalAppHandler() |
360 | { | 360 | { |
361 | mDefaultItems.setAutoDelete(true); | 361 | mDefaultItems.setAutoDelete(true); |
362 | 362 | ||
363 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); | 363 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); |
364 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); | 364 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); |
365 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 365 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
366 | 366 | ||
367 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); | 367 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); |
368 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); | 368 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); |
369 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 369 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
370 | 370 | ||
371 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); | 371 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); |
372 | 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&))); | 372 | 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&))); |
373 | 373 | ||
374 | 374 | ||
375 | 375 | ||
376 | mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); | 376 | mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); |
377 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); | 377 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); |
378 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 378 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
379 | 379 | ||
380 | 380 | ||
381 | } | 381 | } |
382 | 382 | ||
383 | ExternalAppHandler::~ExternalAppHandler() | 383 | ExternalAppHandler::~ExternalAppHandler() |
384 | { | 384 | { |
385 | delete mNameEmailUidListFromKAPITransfer; | 385 | delete mNameEmailUidListFromKAPITransfer; |
386 | //delete mFindByEmailFromKAPITransfer; | 386 | //delete mFindByEmailFromKAPITransfer; |
387 | delete mDisplayDetails; | 387 | delete mDisplayDetails; |
388 | delete mBirthdayListFromKAPITransfer; | 388 | delete mBirthdayListFromKAPITransfer; |
389 | } | 389 | } |
390 | 390 | ||
391 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, | 391 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, |
392 | const QStringList& nameList, | 392 | const QStringList& nameList, |
393 | const QStringList& emailList, | 393 | const QStringList& emailList, |
394 | const QStringList& uidList, | 394 | const QStringList& uidList, |
395 | const QStringList&, | 395 | const QStringList&, |
396 | const QStringList&, | 396 | const QStringList&, |
397 | const QStringList& ) | 397 | const QStringList& ) |
398 | { | 398 | { |
399 | // this method is a conevnient way to reduce the number of parameters I have to pass | 399 | // this method is a conevnient way to reduce the number of parameters I have to pass |
400 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); | 400 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); |
401 | } | 401 | } |
402 | 402 | ||
403 | 403 | ||
404 | void ExternalAppHandler::loadConfig() | 404 | void ExternalAppHandler::loadConfig() |
405 | { | 405 | { |
406 | 406 | ||
407 | mDefaultItems.clear(); | 407 | mDefaultItems.clear(); |
408 | mEmailAppAvailable = UNDEFINED; | 408 | mEmailAppAvailable = UNDEFINED; |
409 | mPhoneAppAvailable = UNDEFINED; | 409 | mPhoneAppAvailable = UNDEFINED; |
410 | mFaxAppAvailable = UNDEFINED; | 410 | mFaxAppAvailable = UNDEFINED; |
411 | mSMSAppAvailable = UNDEFINED; | 411 | mSMSAppAvailable = UNDEFINED; |
412 | mPagerAppAvailable = UNDEFINED; | 412 | mPagerAppAvailable = UNDEFINED; |
413 | mSIPAppAvailable = UNDEFINED; | 413 | mSIPAppAvailable = UNDEFINED; |
414 | 414 | ||
415 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | 415 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); |
416 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | 416 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); |
417 | QString qtpath = QString::fromLatin1( getenv("QTDIR") ); | 417 | QString qtpath = QString::fromLatin1( getenv("QTDIR") ); |
418 | 418 | ||
419 | //if qtopiapath is not set, fallback to qt | 419 | //if qtopiapath is not set, fallback to qt |
420 | if (qtopiapath.isEmpty()) | 420 | if (qtopiapath.isEmpty()) |
421 | qtopiapath = qtpath; | 421 | qtopiapath = qtpath; |
422 | 422 | ||
423 | //if opiepath is not set, fallback to qtopia | 423 | //if opiepath is not set, fallback to qtopia |
424 | if (opiepath.isEmpty()) | 424 | if (opiepath.isEmpty()) |
425 | opiepath = qtopiapath; | 425 | opiepath = qtopiapath; |
426 | 426 | ||
427 | 427 | ||
428 | 428 | ||
429 | //mailclients | 429 | //mailclients |
430 | QString mailmsg1 = "writeMail(QString,QString)"; | 430 | QString mailmsg1 = "writeMail(QString,QString)"; |
431 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 431 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
432 | 432 | ||
433 | QString undefined = ""; | 433 | QString undefined = ""; |
434 | 434 | ||
435 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 435 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); |
436 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 436 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
437 | 437 | ||
438 | #ifdef DESKTOP_VERSION | 438 | #ifdef DESKTOP_VERSION |
439 | QString appPath; | 439 | QString appPath; |
440 | #ifdef _WIN32_ | 440 | #ifdef _WIN32_ |
441 | appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe"; | 441 | appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe"; |
442 | #else | 442 | #else |
443 | appPath = "/usr/bin/thunderbird"; | 443 | appPath = "/usr/bin/thunderbird"; |
444 | #endif | 444 | #endif |
445 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1"); | 445 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1"); |
446 | 446 | ||
447 | #ifdef _WIN32_ | 447 | #ifdef _WIN32_ |
448 | appPath = "C:\\Programme\\Mozilla\\mozilla.exe"; | 448 | appPath = "C:\\Programme\\Mozilla\\mozilla.exe"; |
449 | #else | 449 | #else |
450 | appPath = "/usr/bin/mozilla"; | 450 | appPath = "/usr/bin/mozilla"; |
451 | #endif | 451 | #endif |
452 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1"); | 452 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1"); |
453 | 453 | ||
454 | 454 | ||
455 | 455 | ||
456 | #else | 456 | #else |
457 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 457 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
458 | ( QFile::exists( opiepath + "/bin/ompi" )) || | 458 | ( QFile::exists( opiepath + "/bin/ompi" )) || |
459 | ( QFile::exists( qtpath + "/bin/ompi" ))) | 459 | ( QFile::exists( qtpath + "/bin/ompi" ))) |
460 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 460 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
461 | 461 | ||
462 | if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || | 462 | if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || |
463 | ( QFile::exists( qtpath + "/bin/qtmail" ))) | 463 | ( QFile::exists( qtpath + "/bin/qtmail" ))) |
464 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 464 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
465 | 465 | ||
466 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | 466 | if ( QFile::exists( opiepath + "/bin/opiemail" )) |
467 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 467 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
468 | 468 | ||
469 | if ( QFile::exists( opiepath + "/bin/mailit" )) | 469 | if ( QFile::exists( opiepath + "/bin/mailit" )) |
470 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 470 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
471 | #endif | 471 | #endif |
472 | 472 | ||
473 | 473 | ||
474 | //phoneclients | 474 | //phoneclients |
475 | 475 | ||
476 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | 476 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); |
477 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); | 477 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); |
478 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 478 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
479 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 479 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
480 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 480 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
481 | 481 | ||
482 | //faxclients | 482 | //faxclients |
483 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 483 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); |
484 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | 484 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
485 | 485 | ||
486 | //smsclients | 486 | //smsclients |
487 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 487 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); |
488 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | 488 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
489 | 489 | ||
490 | //pagerclients | 490 | //pagerclients |
491 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 491 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); |
492 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | 492 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
493 | 493 | ||
494 | //sipclients | 494 | //sipclients |
495 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); | 495 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); |
496 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); | 496 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); |
497 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 497 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
498 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 498 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
499 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 499 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
500 | 500 | ||
501 | } | 501 | } |
502 | 502 | ||
503 | ExternalAppHandler *ExternalAppHandler::instance() | 503 | ExternalAppHandler *ExternalAppHandler::instance() |
504 | { | 504 | { |
505 | if ( !sInstance ) { | 505 | if ( !sInstance ) { |
506 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 506 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
507 | sInstance->loadConfig(); | 507 | sInstance->loadConfig(); |
508 | } | 508 | } |
509 | 509 | ||
510 | return sInstance; | 510 | return sInstance; |
511 | } | 511 | } |
512 | 512 | ||
513 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) | 513 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) |
514 | { | 514 | { |
515 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 515 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
516 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); | 516 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); |
517 | mDefaultItems.append(dai); | 517 | mDefaultItems.append(dai); |
518 | } | 518 | } |
519 | 519 | ||
520 | 520 | ||
521 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 521 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
522 | { | 522 | { |
523 | QList<DefaultAppItem> list; | 523 | QList<DefaultAppItem> list; |
524 | 524 | ||
525 | DefaultAppItem* dai; | 525 | DefaultAppItem* dai; |
526 | 526 | ||
527 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 527 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
528 | { | 528 | { |
529 | if (dai->_type == type) | 529 | if (dai->_type == type) |
530 | list.append(dai); | 530 | list.append(dai); |
531 | } | 531 | } |
532 | 532 | ||
533 | return list; | 533 | return list; |
534 | } | 534 | } |
535 | 535 | ||
536 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 536 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
537 | { | 537 | { |
538 | DefaultAppItem* dai; | 538 | DefaultAppItem* dai; |
539 | 539 | ||
540 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 540 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
541 | { | 541 | { |
542 | if (dai->_type == type && dai->_id == clientid) | 542 | if (dai->_type == type && dai->_id == clientid) |
543 | return dai; | 543 | return dai; |
544 | } | 544 | } |
545 | 545 | ||
546 | return 0; | 546 | return 0; |
547 | } | 547 | } |
548 | 548 | ||
549 | bool ExternalAppHandler::isEmailAppAvailable() | 549 | bool ExternalAppHandler::isEmailAppAvailable() |
550 | { | 550 | { |
551 | 551 | ||
552 | if (mEmailAppAvailable == UNDEFINED) | 552 | if (mEmailAppAvailable == UNDEFINED) |
553 | { | 553 | { |
554 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 554 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
555 | if (client == KPimGlobalPrefs::NONE_EMC) | 555 | if (client == KPimGlobalPrefs::NONE_EMC) |
556 | mEmailAppAvailable = UNAVAILABLE; | 556 | mEmailAppAvailable = UNAVAILABLE; |
557 | else | 557 | else |
558 | mEmailAppAvailable = AVAILABLE; | 558 | mEmailAppAvailable = AVAILABLE; |
559 | } | 559 | } |
560 | return (mEmailAppAvailable == AVAILABLE); | 560 | return (mEmailAppAvailable == AVAILABLE); |
561 | 561 | ||
562 | } | 562 | } |
563 | 563 | ||
564 | bool ExternalAppHandler::isSMSAppAvailable() | 564 | bool ExternalAppHandler::isSMSAppAvailable() |
565 | { | 565 | { |
566 | #ifndef DESKTOP_VERSION | 566 | #ifndef DESKTOP_VERSION |
567 | if (mSMSAppAvailable == UNDEFINED) | 567 | if (mSMSAppAvailable == UNDEFINED) |
568 | { | 568 | { |
569 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 569 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
570 | if (client == KPimGlobalPrefs::NONE_SMC) | 570 | if (client == KPimGlobalPrefs::NONE_SMC) |
571 | mSMSAppAvailable = UNAVAILABLE; | 571 | mSMSAppAvailable = UNAVAILABLE; |
572 | else | 572 | else |
573 | mSMSAppAvailable = AVAILABLE; | 573 | mSMSAppAvailable = AVAILABLE; |
574 | } | 574 | } |
575 | 575 | ||
576 | return (mSMSAppAvailable == AVAILABLE); | 576 | return (mSMSAppAvailable == AVAILABLE); |
577 | #else //DESKTOP_VERSION | 577 | #else //DESKTOP_VERSION |
578 | return false; | 578 | return false; |
579 | #endif //DESKTOP_VERSION | 579 | #endif //DESKTOP_VERSION |
580 | } | 580 | } |
581 | 581 | ||
582 | bool ExternalAppHandler::isPhoneAppAvailable() | 582 | bool ExternalAppHandler::isPhoneAppAvailable() |
583 | { | 583 | { |
584 | #ifndef DESKTOP_VERSION | 584 | #ifndef DESKTOP_VERSION |
585 | if (mPhoneAppAvailable == UNDEFINED) | 585 | if (mPhoneAppAvailable == UNDEFINED) |
586 | { | 586 | { |
587 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 587 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
588 | if (client == KPimGlobalPrefs::NONE_PHC) | 588 | if (client == KPimGlobalPrefs::NONE_PHC) |
589 | mPhoneAppAvailable = UNAVAILABLE; | 589 | mPhoneAppAvailable = UNAVAILABLE; |
590 | else | 590 | else |
591 | mPhoneAppAvailable = AVAILABLE; | 591 | mPhoneAppAvailable = AVAILABLE; |
592 | } | 592 | } |
593 | 593 | ||
594 | return (mPhoneAppAvailable == AVAILABLE); | 594 | return (mPhoneAppAvailable == AVAILABLE); |
595 | #else //DESKTOP_VERSION | 595 | #else //DESKTOP_VERSION |
596 | return false; | 596 | return false; |
597 | #endif //DESKTOP_VERSION | 597 | #endif //DESKTOP_VERSION |
598 | } | 598 | } |
599 | 599 | ||
600 | bool ExternalAppHandler::isFaxAppAvailable() | 600 | bool ExternalAppHandler::isFaxAppAvailable() |
601 | { | 601 | { |
602 | #ifndef DESKTOP_VERSION | 602 | #ifndef DESKTOP_VERSION |
603 | if (mFaxAppAvailable == UNDEFINED) | 603 | if (mFaxAppAvailable == UNDEFINED) |
604 | { | 604 | { |
605 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 605 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
606 | if (client == KPimGlobalPrefs::NONE_FAC) | 606 | if (client == KPimGlobalPrefs::NONE_FAC) |
607 | mFaxAppAvailable = UNAVAILABLE; | 607 | mFaxAppAvailable = UNAVAILABLE; |
608 | else | 608 | else |
609 | mFaxAppAvailable = AVAILABLE; | 609 | mFaxAppAvailable = AVAILABLE; |
610 | } | 610 | } |
611 | 611 | ||
612 | return (mFaxAppAvailable == AVAILABLE); | 612 | return (mFaxAppAvailable == AVAILABLE); |
613 | #else //DESKTOP_VERSION | 613 | #else //DESKTOP_VERSION |
614 | return false; | 614 | return false; |
615 | #endif //DESKTOP_VERSION | 615 | #endif //DESKTOP_VERSION |
616 | } | 616 | } |
617 | 617 | ||
618 | bool ExternalAppHandler::isPagerAppAvailable() | 618 | bool ExternalAppHandler::isPagerAppAvailable() |
619 | { | 619 | { |
620 | #ifndef DESKTOP_VERSION | 620 | #ifndef DESKTOP_VERSION |
621 | if (mPagerAppAvailable == UNDEFINED) | 621 | if (mPagerAppAvailable == UNDEFINED) |
622 | { | 622 | { |
623 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 623 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
624 | if (client == KPimGlobalPrefs::NONE_PAC) | 624 | if (client == KPimGlobalPrefs::NONE_PAC) |
625 | mPagerAppAvailable = UNAVAILABLE; | 625 | mPagerAppAvailable = UNAVAILABLE; |
626 | else | 626 | else |
627 | mPagerAppAvailable = AVAILABLE; | 627 | mPagerAppAvailable = AVAILABLE; |
628 | } | 628 | } |
629 | 629 | ||
630 | return (mPagerAppAvailable == AVAILABLE); | 630 | return (mPagerAppAvailable == AVAILABLE); |
631 | #else //DESKTOP_VERSION | 631 | #else //DESKTOP_VERSION |
632 | return false; | 632 | return false; |
633 | #endif //DESKTOP_VERSION | 633 | #endif //DESKTOP_VERSION |
634 | } | 634 | } |
635 | 635 | ||
636 | 636 | ||
637 | bool ExternalAppHandler::isSIPAppAvailable() | 637 | bool ExternalAppHandler::isSIPAppAvailable() |
638 | { | 638 | { |
639 | #ifndef DESKTOP_VERSION | 639 | #ifndef DESKTOP_VERSION |
640 | if (mSIPAppAvailable == UNDEFINED) | 640 | if (mSIPAppAvailable == UNDEFINED) |
641 | { | 641 | { |
642 | int client = KPimGlobalPrefs::instance()->mSipClient; | 642 | int client = KPimGlobalPrefs::instance()->mSipClient; |
643 | if (client == KPimGlobalPrefs::NONE_SIC) | 643 | if (client == KPimGlobalPrefs::NONE_SIC) |
644 | mSIPAppAvailable = UNAVAILABLE; | 644 | mSIPAppAvailable = UNAVAILABLE; |
645 | else | 645 | else |
646 | mSIPAppAvailable = AVAILABLE; | 646 | mSIPAppAvailable = AVAILABLE; |
647 | } | 647 | } |
648 | 648 | ||
649 | return (mSIPAppAvailable == AVAILABLE); | 649 | return (mSIPAppAvailable == AVAILABLE); |
650 | #else //DESKTOP_VERSION | 650 | #else //DESKTOP_VERSION |
651 | return false; | 651 | return false; |
652 | #endif //DESKTOP_VERSION | 652 | #endif //DESKTOP_VERSION |
653 | } | 653 | } |
654 | 654 | ||
655 | /************************************************************************** | 655 | /************************************************************************** |
656 | * | 656 | * |
657 | **************************************************************************/ | 657 | **************************************************************************/ |
658 | 658 | ||
659 | 659 | ||
660 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 660 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
661 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) | 661 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) |
662 | { | 662 | { |
663 | 663 | ||
664 | #ifndef DESKTOP_VERSION | 664 | #ifndef DESKTOP_VERSION |
665 | QString channel; | 665 | QString channel; |
666 | QString message2; | 666 | QString message2; |
667 | QString parameters2; | 667 | QString parameters2; |
668 | 668 | ||
669 | 669 | ||
670 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 670 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
671 | if (client == KPimGlobalPrefs::OTHER_EMC) | 671 | if (client == KPimGlobalPrefs::OTHER_EMC) |
672 | { | 672 | { |
673 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 673 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
674 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 674 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
675 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 675 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
676 | } | 676 | } |
677 | else | 677 | else |
678 | { | 678 | { |
679 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 679 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
680 | if (!dai) | 680 | if (!dai) |
681 | { | 681 | { |
682 | qDebug("could not find configured email application."); | 682 | qDebug("could not find configured email application."); |
683 | return false; | 683 | return false; |
684 | } | 684 | } |
685 | channel = dai->_channel; | 685 | channel = dai->_channel; |
686 | message2 = dai->_message2; | 686 | message2 = dai->_message2; |
687 | parameters2 = dai->_parameters2; | 687 | parameters2 = dai->_parameters2; |
688 | } | 688 | } |
689 | 689 | ||
690 | //first check if one of the mailers need the emails right in the message. | 690 | //first check if one of the mailers need the emails right in the message. |
691 | message2 = translateMessage(message2, emails, urls); | 691 | message2 = translateMessage(message2, emails, urls); |
692 | 692 | ||
693 | 693 | ||
694 | #ifdef DEBUG_EXT_APP_HANDLER | 694 | #ifdef DEBUG_EXT_APP_HANDLER |
695 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 695 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
696 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 696 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
697 | #endif | 697 | #endif |
698 | 698 | ||
699 | 699 | ||
700 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 700 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
701 | //US we need no names in the To field. The emailadresses are enough | 701 | //US we need no names in the To field. The emailadresses are enough |
702 | 702 | ||
703 | passParameters(&e, parameters2, emails, urls); | 703 | passParameters(&e, parameters2, emails, urls); |
704 | 704 | ||
705 | 705 | ||
706 | 706 | ||
707 | #else | 707 | #else |
708 | //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); | 708 | //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); |
709 | 709 | ||
710 | QString channel; | 710 | QString channel; |
711 | QString message2; | 711 | QString message2; |
712 | QString parameters2; | 712 | QString parameters2; |
713 | QString message; | 713 | QString message; |
714 | QString parameters; | 714 | QString parameters; |
715 | 715 | ||
716 | 716 | ||
717 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 717 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
718 | if (client == KPimGlobalPrefs::OTHER_EMC) | 718 | if (client == KPimGlobalPrefs::OTHER_EMC) |
719 | { | 719 | { |
720 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 720 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
721 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 721 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
722 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 722 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; |
723 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | ||
724 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; | ||
723 | } | 725 | } |
724 | else | 726 | else |
725 | { | 727 | { |
726 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 728 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
727 | if (!dai) | 729 | if (!dai) |
728 | { | 730 | { |
729 | qDebug("could not find configured email application."); | 731 | qDebug("could not find configured email application."); |
730 | return false; | 732 | return false; |
731 | } | 733 | } |
732 | channel = dai->_channel; | 734 | channel = dai->_channel; |
733 | message2 = dai->_message2; | 735 | message2 = dai->_message2; |
734 | parameters2 = dai->_parameters2; | 736 | parameters2 = dai->_parameters2; |
735 | message = dai->_message; | 737 | message = dai->_message; |
736 | parameters = dai->_parameters; | 738 | parameters = dai->_parameters; |
737 | } | 739 | } |
738 | 740 | ||
739 | //first check if one of the mailers need the emails right in the message. | 741 | //first check if one of the mailers need the emails right in the message. |
740 | message2 = translateMessage(message2, emails, urls); | 742 | message2 = translateMessage(message2, emails, urls); |
741 | #ifdef DEBUG_EXT_APP_HANDLER | 743 | #ifdef DEBUG_EXT_APP_HANDLER |
742 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 744 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
743 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 745 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
744 | #endif | 746 | #endif |
745 | qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); | 747 | qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); |
746 | //KMessageBox::sorry( 0, message2 ); | 748 | //KMessageBox::sorry( 0, message2 ); |
747 | QProcess * proc = new QProcess( this ); | 749 | QProcess * proc = new QProcess( this ); |
748 | QStringList list = QStringList::split( " ", message ); | ||
749 | int i = 0; | 750 | int i = 0; |
750 | proc->addArgument( channel ); | 751 | proc->addArgument( channel ); |
751 | while ( i < list.count ( ) ) { | 752 | |
752 | //qDebug("add%sdd ",list[i].stripWhiteSpace().latin1() ); | 753 | if ( message.find (" " ) > 0 ) { |
753 | proc->addArgument( list[i].stripWhiteSpace() ); | 754 | QStringList list = QStringList::split( " ", message ); |
755 | int i = 0; | ||
756 | while ( i < list.count ( ) ) { | ||
757 | //qDebug("add%sdd ",list[i].latin1() ); | ||
758 | proc->addArgument( list[i] ); | ||
759 | //KMessageBox::sorry( 0,list[i]); | ||
754 | ++i; | 760 | ++i; |
761 | } | ||
762 | } else { | ||
763 | proc->addArgument(message ); | ||
764 | //KMessageBox::sorry( 0, message ); | ||
765 | |||
755 | } | 766 | } |
767 | |||
756 | parameters2 = translateMessage(parameters2, urls, "" ); | 768 | parameters2 = translateMessage(parameters2, urls, "" ); |
757 | QString arg = "to='%1'"; | 769 | QString arg = "to='%1'"; |
758 | arg = arg.arg( emails ) + ","+parameters2;; | 770 | arg = arg.arg( emails ) + ","+parameters2;; |
759 | 771 | ||
772 | //KMessageBox::sorry( 0,arg ); | ||
760 | //qDebug("2add%sdd ",arg.latin1() ); | 773 | //qDebug("2add%sdd ",arg.latin1() ); |
761 | proc->addArgument( arg); | 774 | proc->addArgument( arg); |
762 | proc->launch(""); | 775 | proc->launch(""); |
763 | #endif | 776 | #endif |
764 | 777 | ||
765 | return true; | 778 | return true; |
766 | } | 779 | } |
767 | 780 | ||
768 | /************************************************************************** | 781 | /************************************************************************** |
769 | * | 782 | * |
770 | **************************************************************************/ | 783 | **************************************************************************/ |
771 | 784 | ||
772 | 785 | ||
773 | //calls the emailapplication and creates a mail with parameter emails as recipients | 786 | //calls the emailapplication and creates a mail with parameter emails as recipients |
774 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 787 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
775 | { | 788 | { |
776 | 789 | ||
777 | QString channel; | 790 | QString channel; |
778 | QString message; | 791 | QString message; |
779 | QString parameters; | 792 | QString parameters; |
780 | 793 | ||
781 | 794 | ||
782 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 795 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
783 | if (client == KPimGlobalPrefs::OTHER_EMC) | 796 | if (client == KPimGlobalPrefs::OTHER_EMC) |
784 | { | 797 | { |
785 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 798 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
786 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 799 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
787 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 800 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
788 | } | 801 | } |
789 | else | 802 | else |
790 | { | 803 | { |
791 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 804 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
792 | if (!dai) | 805 | if (!dai) |
793 | { | 806 | { |
794 | qDebug("could not find configured email application."); | 807 | qDebug("could not find configured email application."); |
795 | return false; | 808 | return false; |
796 | } | 809 | } |
797 | channel = dai->_channel; | 810 | channel = dai->_channel; |
798 | message = dai->_message; | 811 | message = dai->_message; |
799 | parameters = dai->_parameters; | 812 | parameters = dai->_parameters; |
800 | } | 813 | } |
801 | 814 | ||
802 | #ifdef DESKTOP_VERSION | 815 | #ifdef DESKTOP_VERSION |
803 | //message = channel + " " +message + " \""+ parameters + "\""; | 816 | //message = channel + " " +message + " \""+ parameters + "\""; |
804 | #endif | 817 | #endif |
805 | //first check if one of the mailers need the emails right in the message. | 818 | //first check if one of the mailers need the emails right in the message. |
806 | message = translateMessage(message, name, emailadress); | 819 | message = translateMessage(message, name, emailadress); |
807 | 820 | ||
808 | #ifdef DEBUG_EXT_APP_HANDLER | 821 | #ifdef DEBUG_EXT_APP_HANDLER |
809 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 822 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
810 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 823 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
811 | #endif | 824 | #endif |
812 | 825 | ||
813 | #ifndef DESKTOP_VERSION | 826 | #ifndef DESKTOP_VERSION |
814 | QCopEnvelope e(channel.latin1(), message.latin1()); | 827 | QCopEnvelope e(channel.latin1(), message.latin1()); |
815 | //US we need no names in the To field. The emailadresses are enough | 828 | //US we need no names in the To field. The emailadresses are enough |
816 | 829 | ||
817 | passParameters(&e, parameters, name, emailadress); | 830 | passParameters(&e, parameters, name, emailadress); |
818 | #else // DESKTOP_VERSION | 831 | #else // DESKTOP_VERSION |
819 | 832 | ||
820 | //KMessageBox::sorry( 0, message ); | 833 | //KMessageBox::sorry( 0,channel ); |
821 | QProcess * proc = new QProcess( this ); | 834 | QProcess * proc = new QProcess( this ); |
822 | QStringList list = QStringList::split( " ", message ); | ||
823 | int i = 0; | ||
824 | proc->addArgument( channel ); | 835 | proc->addArgument( channel ); |
825 | while ( i < list.count ( ) ) { | 836 | if ( message.find (" " ) > 0 ) { |
837 | QStringList list = QStringList::split( " ", message ); | ||
838 | int i = 0; | ||
839 | while ( i < list.count ( ) ) { | ||
826 | //qDebug("add%sdd ",list[i].latin1() ); | 840 | //qDebug("add%sdd ",list[i].latin1() ); |
827 | proc->addArgument( list[i] ); | 841 | proc->addArgument( list[i] ); |
842 | //KMessageBox::sorry( 0,list[i]); | ||
828 | ++i; | 843 | ++i; |
844 | } | ||
845 | } else { | ||
846 | proc->addArgument(message ); | ||
847 | |||
829 | } | 848 | } |
830 | parameters = translateMessage(parameters, name, emailadress); | 849 | parameters = translateMessage(parameters, name, emailadress); |
831 | proc->addArgument( parameters ); | 850 | proc->addArgument( parameters ); |
832 | proc->launch(""); | 851 | proc->launch(""); |
833 | #endif | 852 | #endif |
834 | 853 | ||
835 | return true; | 854 | return true; |
836 | } | 855 | } |
837 | 856 | ||
838 | /************************************************************************** | 857 | /************************************************************************** |
839 | * | 858 | * |
840 | **************************************************************************/ | 859 | **************************************************************************/ |
841 | 860 | ||
842 | //calls the emailapplication and creates a mail with parameter as recipients | 861 | //calls the emailapplication and creates a mail with parameter as recipients |
843 | // parameters format is | 862 | // parameters format is |
844 | // NAME <EMAIL>:SUBJECT | 863 | // NAME <EMAIL>:SUBJECT |
845 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 864 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
846 | { | 865 | { |
847 | QString line = adressline; | 866 | QString line = adressline; |
848 | 867 | ||
849 | int first = line.find( "<"); | 868 | int first = line.find( "<"); |
850 | int last = line.find( ">"); | 869 | int last = line.find( ">"); |
851 | QString name = line.left(first); | 870 | QString name = line.left(first); |
852 | QString emailadress = line.mid(first+1, last-first-1); | 871 | QString emailadress = line.mid(first+1, last-first-1); |
853 | 872 | ||
854 | //Subject can not be handled right now. | 873 | //Subject can not be handled right now. |
855 | return mailToOneContact( name, emailadress ); | 874 | return mailToOneContact( name, emailadress ); |
856 | 875 | ||
857 | } | 876 | } |
858 | 877 | ||
859 | 878 | ||
860 | /************************************************************************** | 879 | /************************************************************************** |
861 | * | 880 | * |
862 | **************************************************************************/ | 881 | **************************************************************************/ |
863 | 882 | ||
864 | //calls the phoneapplication with the number | 883 | //calls the phoneapplication with the number |
865 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 884 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
866 | { | 885 | { |
867 | #ifndef DESKTOP_VERSION | 886 | #ifndef DESKTOP_VERSION |
868 | QString channel; | 887 | QString channel; |
869 | QString message; | 888 | QString message; |
870 | QString parameters; | 889 | QString parameters; |
871 | 890 | ||
872 | 891 | ||
873 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 892 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
874 | if (client == KPimGlobalPrefs::OTHER_PHC) | 893 | if (client == KPimGlobalPrefs::OTHER_PHC) |
875 | { | 894 | { |
876 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 895 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
877 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 896 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
878 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 897 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
879 | } | 898 | } |
880 | else | 899 | else |
881 | { | 900 | { |
882 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 901 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
883 | if (!dai) | 902 | if (!dai) |
884 | { | 903 | { |
885 | qDebug("could not find configured phone application."); | 904 | qDebug("could not find configured phone application."); |
886 | return false; | 905 | return false; |
887 | } | 906 | } |
888 | channel = dai->_channel; | 907 | channel = dai->_channel; |
889 | message = dai->_message; | 908 | message = dai->_message; |
890 | parameters = dai->_parameters; | 909 | parameters = dai->_parameters; |
891 | } | 910 | } |
892 | 911 | ||
893 | 912 | ||
894 | //first check if one of the mailers need the emails right in the message. | 913 | //first check if one of the mailers need the emails right in the message. |
895 | message = translateMessage(message, phonenumber, ""); | 914 | message = translateMessage(message, phonenumber, ""); |
896 | 915 | ||
897 | 916 | ||
898 | #ifdef DEBUG_EXT_APP_HANDLER | 917 | #ifdef DEBUG_EXT_APP_HANDLER |
899 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 918 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
900 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 919 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
901 | #endif | 920 | #endif |
902 | 921 | ||
903 | QCopEnvelope e(channel.latin1(), message.latin1()); | 922 | QCopEnvelope e(channel.latin1(), message.latin1()); |
904 | //US we need no names in the To field. The emailadresses are enough | 923 | //US we need no names in the To field. The emailadresses are enough |
905 | 924 | ||
906 | passParameters(&e, parameters, phonenumber, ""); | 925 | passParameters(&e, parameters, phonenumber, ""); |
907 | 926 | ||
908 | 927 | ||
909 | #else | 928 | #else |
910 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 929 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
911 | #endif | 930 | #endif |
912 | 931 | ||
913 | 932 | ||
914 | return true; | 933 | return true; |
915 | } | 934 | } |
916 | 935 | ||
917 | /************************************************************************** | 936 | /************************************************************************** |
918 | * | 937 | * |
919 | **************************************************************************/ | 938 | **************************************************************************/ |
920 | 939 | ||
921 | //calls the smsapplication with the number | 940 | //calls the smsapplication with the number |
922 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 941 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
923 | { | 942 | { |
924 | #ifndef DESKTOP_VERSION | 943 | #ifndef DESKTOP_VERSION |
925 | QString channel; | 944 | QString channel; |
926 | QString message; | 945 | QString message; |
927 | QString parameters; | 946 | QString parameters; |
928 | 947 | ||
929 | 948 | ||
930 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 949 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
931 | if (client == KPimGlobalPrefs::OTHER_SMC) | 950 | if (client == KPimGlobalPrefs::OTHER_SMC) |
932 | { | 951 | { |
933 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 952 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
934 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 953 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
935 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 954 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
936 | } | 955 | } |
937 | else | 956 | else |
938 | { | 957 | { |
939 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 958 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
940 | if (!dai) | 959 | if (!dai) |
941 | { | 960 | { |
942 | qDebug("could not find configured sms application."); | 961 | qDebug("could not find configured sms application."); |
943 | return false; | 962 | return false; |
944 | } | 963 | } |
945 | channel = dai->_channel; | 964 | channel = dai->_channel; |
946 | message = dai->_message; | 965 | message = dai->_message; |
947 | parameters = dai->_parameters; | 966 | parameters = dai->_parameters; |
948 | } | 967 | } |
949 | 968 | ||
950 | 969 | ||
951 | //first check if one of the mailers need the emails right in the message. | 970 | //first check if one of the mailers need the emails right in the message. |
952 | message = translateMessage(message, phonenumber, ""); | 971 | message = translateMessage(message, phonenumber, ""); |
953 | 972 | ||
954 | 973 | ||
955 | #ifdef DEBUG_EXT_APP_HANDLER | 974 | #ifdef DEBUG_EXT_APP_HANDLER |
956 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 975 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
957 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 976 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
958 | #endif | 977 | #endif |
959 | 978 | ||
960 | QCopEnvelope e(channel.latin1(), message.latin1()); | 979 | QCopEnvelope e(channel.latin1(), message.latin1()); |
961 | //US we need no names in the To field. The emailadresses are enough | 980 | //US we need no names in the To field. The emailadresses are enough |
962 | 981 | ||
963 | passParameters(&e, parameters, phonenumber, ""); | 982 | passParameters(&e, parameters, phonenumber, ""); |
964 | 983 | ||
965 | 984 | ||
966 | #else | 985 | #else |
967 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); | 986 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); |
968 | #endif | 987 | #endif |
969 | 988 | ||
970 | 989 | ||
971 | return true; | 990 | return true; |
972 | } | 991 | } |
973 | 992 | ||
974 | /************************************************************************** | 993 | /************************************************************************** |
975 | * | 994 | * |
976 | **************************************************************************/ | 995 | **************************************************************************/ |
977 | 996 | ||
978 | //calls the pagerapplication with the number | 997 | //calls the pagerapplication with the number |
979 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 998 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) |
980 | { | 999 | { |
981 | #ifndef DESKTOP_VERSION | 1000 | #ifndef DESKTOP_VERSION |
982 | QString channel; | 1001 | QString channel; |
983 | QString message; | 1002 | QString message; |
984 | QString parameters; | 1003 | QString parameters; |
985 | 1004 | ||
986 | 1005 | ||
987 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 1006 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
988 | if (client == KPimGlobalPrefs::OTHER_PAC) | 1007 | if (client == KPimGlobalPrefs::OTHER_PAC) |
989 | { | 1008 | { |
990 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; | 1009 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; |
991 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; | 1010 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; |
992 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; | 1011 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; |
993 | } | 1012 | } |
994 | else | 1013 | else |
995 | { | 1014 | { |
996 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); | 1015 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); |
997 | if (!dai) | 1016 | if (!dai) |
998 | { | 1017 | { |
999 | qDebug("could not find configured pager application."); | 1018 | qDebug("could not find configured pager application."); |
1000 | return false; | 1019 | return false; |
1001 | } | 1020 | } |
1002 | channel = dai->_channel; | 1021 | channel = dai->_channel; |
1003 | message = dai->_message; | 1022 | message = dai->_message; |
1004 | parameters = dai->_parameters; | 1023 | parameters = dai->_parameters; |
1005 | } | 1024 | } |
1006 | 1025 | ||
1007 | 1026 | ||
1008 | //first check if one of the mailers need the emails right in the message. | 1027 | //first check if one of the mailers need the emails right in the message. |
1009 | message = translateMessage(message, pagernumber, ""); | 1028 | message = translateMessage(message, pagernumber, ""); |
1010 | 1029 | ||
1011 | 1030 | ||
1012 | #ifdef DEBUG_EXT_APP_HANDLER | 1031 | #ifdef DEBUG_EXT_APP_HANDLER |
1013 | qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 1032 | qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
1014 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); | 1033 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); |
1015 | #endif | 1034 | #endif |
1016 | 1035 | ||
1017 | QCopEnvelope e(channel.latin1(), message.latin1()); | 1036 | QCopEnvelope e(channel.latin1(), message.latin1()); |
1018 | //US we need no names in the To field. The emailadresses are enough | 1037 | //US we need no names in the To field. The emailadresses are enough |
1019 | 1038 | ||
1020 | passParameters(&e, parameters, pagernumber, ""); | 1039 | passParameters(&e, parameters, pagernumber, ""); |
1021 | 1040 | ||
1022 | 1041 | ||
1023 | #else | 1042 | #else |
1024 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); | 1043 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); |
1025 | #endif | 1044 | #endif |
1026 | 1045 | ||
1027 | 1046 | ||
1028 | return true; | 1047 | return true; |
1029 | } | 1048 | } |
1030 | 1049 | ||
1031 | /************************************************************************** | 1050 | /************************************************************************** |
1032 | * | 1051 | * |
1033 | **************************************************************************/ | 1052 | **************************************************************************/ |
1034 | 1053 | ||
1035 | //calls the faxapplication with the number | 1054 | //calls the faxapplication with the number |
1036 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 1055 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) |
1037 | { | 1056 | { |
1038 | #ifndef DESKTOP_VERSION | 1057 | #ifndef DESKTOP_VERSION |
1039 | QString channel; | 1058 | QString channel; |
1040 | QString message; | 1059 | QString message; |
1041 | QString parameters; | 1060 | QString parameters; |
1042 | 1061 | ||
1043 | 1062 | ||
1044 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 1063 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
1045 | if (client == KPimGlobalPrefs::OTHER_FAC) | 1064 | if (client == KPimGlobalPrefs::OTHER_FAC) |
1046 | { | 1065 | { |
1047 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | 1066 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; |
1048 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | 1067 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; |
1049 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | 1068 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; |
1050 | } | 1069 | } |
1051 | else | 1070 | else |
1052 | { | 1071 | { |
1053 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | 1072 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); |
1054 | if (!dai) | 1073 | if (!dai) |
1055 | { | 1074 | { |
1056 | qDebug("could not find configured fax application."); | 1075 | qDebug("could not find configured fax application."); |
1057 | return false; | 1076 | return false; |
1058 | } | 1077 | } |
1059 | channel = dai->_channel; | 1078 | channel = dai->_channel; |
1060 | message = dai->_message; | 1079 | message = dai->_message; |
1061 | parameters = dai->_parameters; | 1080 | parameters = dai->_parameters; |
1062 | } | 1081 | } |
1063 | 1082 | ||
1064 | 1083 | ||
1065 | //first check if one of the mailers need the emails right in the message. | 1084 | //first check if one of the mailers need the emails right in the message. |
1066 | message = translateMessage(message, faxnumber, ""); | 1085 | message = translateMessage(message, faxnumber, ""); |
1067 | 1086 | ||
1068 | 1087 | ||
1069 | #ifdef DEBUG_EXT_APP_HANDLER | 1088 | #ifdef DEBUG_EXT_APP_HANDLER |
1070 | qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 1089 | qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
1071 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | 1090 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); |
1072 | #endif | 1091 | #endif |
1073 | 1092 | ||
1074 | QCopEnvelope e(channel.latin1(), message.latin1()); | 1093 | QCopEnvelope e(channel.latin1(), message.latin1()); |
1075 | //US we need no names in the To field. The emailadresses are enough | 1094 | //US we need no names in the To field. The emailadresses are enough |
1076 | 1095 | ||
1077 | passParameters(&e, parameters, faxnumber, ""); | 1096 | passParameters(&e, parameters, faxnumber, ""); |
1078 | 1097 | ||
1079 | 1098 | ||
1080 | #else | 1099 | #else |
1081 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); | 1100 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); |
1082 | #endif | 1101 | #endif |
1083 | 1102 | ||
1084 | 1103 | ||
1085 | return true; | 1104 | return true; |
1086 | } | 1105 | } |
1087 | 1106 | ||
1088 | /************************************************************************** | 1107 | /************************************************************************** |
1089 | * | 1108 | * |
1090 | **************************************************************************/ | 1109 | **************************************************************************/ |
1091 | 1110 | ||
1092 | //calls the sipapplication with the number | 1111 | //calls the sipapplication with the number |
1093 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) | 1112 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) |
1094 | { | 1113 | { |
1095 | #ifndef DESKTOP_VERSION | 1114 | #ifndef DESKTOP_VERSION |
1096 | QString channel; | 1115 | QString channel; |
1097 | QString message; | 1116 | QString message; |
1098 | QString parameters; | 1117 | QString parameters; |
1099 | 1118 | ||
1100 | 1119 | ||
1101 | int client = KPimGlobalPrefs::instance()->mSipClient; | 1120 | int client = KPimGlobalPrefs::instance()->mSipClient; |
1102 | if (client == KPimGlobalPrefs::OTHER_SIC) | 1121 | if (client == KPimGlobalPrefs::OTHER_SIC) |
1103 | { | 1122 | { |
1104 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; | 1123 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; |
1105 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; | 1124 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; |
1106 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; | 1125 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; |
1107 | } | 1126 | } |
1108 | else | 1127 | else |
1109 | { | 1128 | { |
1110 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); | 1129 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); |
1111 | if (!dai) | 1130 | if (!dai) |
1112 | { | 1131 | { |
1113 | qDebug("could not find configured sip application."); | 1132 | qDebug("could not find configured sip application."); |
1114 | return false; | 1133 | return false; |
1115 | } | 1134 | } |
1116 | channel = dai->_channel; | 1135 | channel = dai->_channel; |
1117 | message = dai->_message; | 1136 | message = dai->_message; |
1118 | parameters = dai->_parameters; | 1137 | parameters = dai->_parameters; |
1119 | } | 1138 | } |
1120 | 1139 | ||
1121 | 1140 | ||
1122 | //first check if one of the sip apps need the emails right in the message. | 1141 | //first check if one of the sip apps need the emails right in the message. |
1123 | message = translateMessage(message, sipnumber, ""); | 1142 | message = translateMessage(message, sipnumber, ""); |
1124 | 1143 | ||
1125 | 1144 | ||
1126 | #ifdef DEBUG_EXT_APP_HANDLER | 1145 | #ifdef DEBUG_EXT_APP_HANDLER |
1127 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 1146 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
1128 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); | 1147 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); |
1129 | #endif | 1148 | #endif |
1130 | 1149 | ||
1131 | QCopEnvelope e(channel.latin1(), message.latin1()); | 1150 | QCopEnvelope e(channel.latin1(), message.latin1()); |
1132 | //US we need no names in the To field. The emailadresses are enough | 1151 | //US we need no names in the To field. The emailadresses are enough |
1133 | 1152 | ||
1134 | passParameters(&e, parameters, sipnumber, ""); | 1153 | passParameters(&e, parameters, sipnumber, ""); |
1135 | 1154 | ||
1136 | 1155 | ||
1137 | #else | 1156 | #else |
1138 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); | 1157 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); |
1139 | #endif | 1158 | #endif |
1140 | 1159 | ||
1141 | 1160 | ||
1142 | return true; | 1161 | return true; |
1143 | } | 1162 | } |
1144 | 1163 | ||
1145 | 1164 | ||
1146 | /************************************************************************** | 1165 | /************************************************************************** |
1147 | * | 1166 | * |
1148 | **************************************************************************/ | 1167 | **************************************************************************/ |
1149 | 1168 | ||
1150 | 1169 | ||
1151 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 1170 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const |
1152 | { | 1171 | { |
1153 | message = message.replace( QRegExp("%1"), param1 ); | 1172 | message = message.replace( QRegExp("%1"), param1 ); |
1154 | return message.replace( QRegExp("%2"), param2 ); | 1173 | return message.replace( QRegExp("%2"), param2 ); |
1155 | } | 1174 | } |
1156 | 1175 | ||
1157 | /************************************************************************** | 1176 | /************************************************************************** |
1158 | * | 1177 | * |
1159 | **************************************************************************/ | 1178 | **************************************************************************/ |
1160 | 1179 | ||
1161 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 1180 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const |
1162 | { | 1181 | { |
1163 | #ifndef DESKTOP_VERSION | 1182 | #ifndef DESKTOP_VERSION |
1164 | QMap<QString, QString> valmap; | 1183 | QMap<QString, QString> valmap; |
1165 | bool useValMap = false; | 1184 | bool useValMap = false; |
1166 | 1185 | ||
1167 | // first extract all parts of the parameters. | 1186 | // first extract all parts of the parameters. |
1168 | QStringList paramlist = QStringList::split(";", parameters); | 1187 | QStringList paramlist = QStringList::split(";", parameters); |
1169 | 1188 | ||
1170 | //Now check how many parts we have. | 1189 | //Now check how many parts we have. |
1171 | //=0 :no params to pass | 1190 | //=0 :no params to pass |
1172 | //>0 :parameters to pass | 1191 | //>0 :parameters to pass |
1173 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 1192 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
1174 | { | 1193 | { |
1175 | QString param = (*it); | 1194 | QString param = (*it); |
1176 | QStringList keyvallist = QStringList::split("=", param); | 1195 | QStringList keyvallist = QStringList::split("=", param); |
1177 | 1196 | ||
1178 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 1197 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
1179 | QStringList::Iterator it2 = keyvallist.begin(); | 1198 | QStringList::Iterator it2 = keyvallist.begin(); |
1180 | QString key = (*it2); | 1199 | QString key = (*it2); |
1181 | key = key.replace( QRegExp("%1"), param1 ); | 1200 | key = key.replace( QRegExp("%1"), param1 ); |
1182 | key = key.replace( QRegExp("%2"), param2 ); | 1201 | key = key.replace( QRegExp("%2"), param2 ); |
1183 | ++it2; | 1202 | ++it2; |
1184 | 1203 | ||
1185 | if(it2 != keyvallist.end()) | 1204 | if(it2 != keyvallist.end()) |
1186 | { | 1205 | { |
1187 | QString value = (*it2); | 1206 | QString value = (*it2); |
1188 | value = value.replace( QRegExp("%1"), param1 ); | 1207 | value = value.replace( QRegExp("%1"), param1 ); |
1189 | value = value.replace( QRegExp("%2"), param2 ); | 1208 | value = value.replace( QRegExp("%2"), param2 ); |
1190 | 1209 | ||
1191 | valmap.insert(key, value); | 1210 | valmap.insert(key, value); |
1192 | useValMap = true; | 1211 | useValMap = true; |
1193 | } | 1212 | } |
1194 | else | 1213 | else |
1195 | { | 1214 | { |
1196 | // qDebug("pass parameter << %s", key.latin1()); | 1215 | // qDebug("pass parameter << %s", key.latin1()); |
1197 | (*e) << key; | 1216 | (*e) << key; |
1198 | } | 1217 | } |
1199 | } | 1218 | } |
1200 | 1219 | ||
1201 | if (useValMap == true) | 1220 | if (useValMap == true) |
1202 | (*e) << valmap; | 1221 | (*e) << valmap; |
1203 | 1222 | ||
1204 | #endif | 1223 | #endif |
1205 | 1224 | ||
1206 | } | 1225 | } |
1207 | 1226 | ||
1208 | 1227 | ||
1209 | 1228 | ||
1210 | /************************************************************************** | 1229 | /************************************************************************** |
1211 | * | 1230 | * |
1212 | **************************************************************************/ | 1231 | **************************************************************************/ |
1213 | 1232 | ||
1214 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) | 1233 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) |
1215 | { | 1234 | { |
1216 | qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this); | 1235 | qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this); |
1217 | if ( cmsg == "nextView()" ) { | 1236 | if ( cmsg == "nextView()" ) { |
1218 | qDebug("nextView()"); | 1237 | qDebug("nextView()"); |
1219 | QTimer::singleShot( 0, this, SIGNAL ( nextView() )); | 1238 | QTimer::singleShot( 0, this, SIGNAL ( nextView() )); |
1220 | return; | 1239 | return; |
1221 | } | 1240 | } |
1222 | if ( cmsg == "callContactdialog()" ) { | 1241 | if ( cmsg == "callContactdialog()" ) { |
1223 | qDebug("callContactdialog()"); | 1242 | qDebug("callContactdialog()"); |
1224 | QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() )); | 1243 | QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() )); |
1225 | return; | 1244 | return; |
1226 | } | 1245 | } |
1227 | if ( cmsg == "doRingSync" ) { | 1246 | if ( cmsg == "doRingSync" ) { |
1228 | qDebug("doRingSync"); | 1247 | qDebug("doRingSync"); |
1229 | QTimer::singleShot( 0, this, SIGNAL ( doRingSync() )); | 1248 | QTimer::singleShot( 0, this, SIGNAL ( doRingSync() )); |
1230 | return; | 1249 | return; |
1231 | } | 1250 | } |
1232 | 1251 | ||
1233 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1252 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1234 | if (!res) | 1253 | if (!res) |
1235 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); | 1254 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); |
1236 | 1255 | ||
1237 | if (!res) | 1256 | if (!res) |
1238 | res = mDisplayDetails->appMessage( cmsg, data ); | 1257 | res = mDisplayDetails->appMessage( cmsg, data ); |
1239 | 1258 | ||
1240 | // if (!res) | 1259 | // if (!res) |
1241 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1260 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1242 | } | 1261 | } |
1243 | 1262 | ||
1244 | 1263 | ||
1245 | 1264 | ||
1246 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1265 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
1247 | { | 1266 | { |
1248 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1267 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
1249 | // maybe we are sending to KA/Pi fom a different worldd... | 1268 | // maybe we are sending to KA/Pi fom a different worldd... |
1250 | // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application | 1269 | // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application |
1251 | // for that reason we send the current QApplication::desktop()->width() to KA/Pi | 1270 | // for that reason we send the current QApplication::desktop()->width() to KA/Pi |
1252 | //qDebug("UID %s ", sessionuid.latin1()); | 1271 | //qDebug("UID %s ", sessionuid.latin1()); |
1253 | //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() )); | 1272 | //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() )); |
1254 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); | 1273 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); |
1255 | } | 1274 | } |
1256 | 1275 | ||
1257 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1276 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1258 | { | 1277 | { |
1259 | QStringList list4, list5, list6; | 1278 | QStringList list4, list5, list6; |
1260 | 1279 | ||
1261 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1280 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
1262 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1281 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1263 | } | 1282 | } |
1264 | 1283 | ||
1265 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) | 1284 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) |
1266 | { | 1285 | { |
1267 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1286 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1268 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); | 1287 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); |
1269 | } | 1288 | } |
1270 | 1289 | ||
1271 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1290 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1272 | { | 1291 | { |
1273 | QStringList list4, list5, list6; | 1292 | QStringList list4, list5, list6; |
1274 | 1293 | ||
1275 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1294 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1276 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1295 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1277 | } | 1296 | } |
1278 | 1297 | ||
1279 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) | 1298 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) |
1280 | { | 1299 | { |
1281 | mDisplayDetails->setSourceChannel(""); | 1300 | mDisplayDetails->setSourceChannel(""); |
1282 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); | 1301 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); |
1283 | } | 1302 | } |
1284 | 1303 | ||
1285 | bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1304 | bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
1286 | { | 1305 | { |
1287 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); | 1306 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); |
1288 | return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); | 1307 | return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); |
1289 | } | 1308 | } |
1290 | 1309 | ||