author | ulf69 <ulf69> | 2004-08-10 22:46:12 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-10 22:46:12 (UTC) |
commit | 02d51ae409a353d3a79e976c26ccc1f652e55de8 (patch) (unidiff) | |
tree | 54d7a9f1eecd2ef9c3332f2bc22ff6ac6d9af335 /kaddressbook | |
parent | dc81e96e29f619c6eb32c3ed18ff45b789c8504e (diff) | |
download | kdepimpi-02d51ae409a353d3a79e976c26ccc1f652e55de8.zip kdepimpi-02d51ae409a353d3a79e976c26ccc1f652e55de8.tar.gz kdepimpi-02d51ae409a353d3a79e976c26ccc1f652e55de8.tar.bz2 |
final changes on how to send emails to selected contacts
-rw-r--r-- | kaddressbook/kabcore.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d6f0cee..6610288 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -420,161 +420,155 @@ void KABCore::setContactSelected( const QString &uid ) | |||
420 | 420 | ||
421 | if ( !addr.isEmpty() ) { | 421 | if ( !addr.isEmpty() ) { |
422 | emit contactSelected( addr.formattedName() ); | 422 | emit contactSelected( addr.formattedName() ); |
423 | KABC::Picture pic = addr.photo(); | 423 | KABC::Picture pic = addr.photo(); |
424 | if ( pic.isIntern() ) { | 424 | if ( pic.isIntern() ) { |
425 | //US emit contactSelected( pic.data() ); | 425 | //US emit contactSelected( pic.data() ); |
426 | //US instead use: | 426 | //US instead use: |
427 | QPixmap px; | 427 | QPixmap px; |
428 | if (pic.data().isNull() != true) | 428 | if (pic.data().isNull() != true) |
429 | { | 429 | { |
430 | px.convertFromImage(pic.data()); | 430 | px.convertFromImage(pic.data()); |
431 | } | 431 | } |
432 | 432 | ||
433 | emit contactSelected( px ); | 433 | emit contactSelected( px ); |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | 437 | ||
438 | mExtensionManager->setSelectionChanged(); | 438 | mExtensionManager->setSelectionChanged(); |
439 | 439 | ||
440 | // update the actions | 440 | // update the actions |
441 | bool selected = !uid.isEmpty(); | 441 | bool selected = !uid.isEmpty(); |
442 | 442 | ||
443 | if ( mReadWrite ) { | 443 | if ( mReadWrite ) { |
444 | mActionCut->setEnabled( selected ); | 444 | mActionCut->setEnabled( selected ); |
445 | mActionPaste->setEnabled( selected ); | 445 | mActionPaste->setEnabled( selected ); |
446 | } | 446 | } |
447 | 447 | ||
448 | mActionCopy->setEnabled( selected ); | 448 | mActionCopy->setEnabled( selected ); |
449 | mActionDelete->setEnabled( selected ); | 449 | mActionDelete->setEnabled( selected ); |
450 | mActionEditAddressee->setEnabled( selected ); | 450 | mActionEditAddressee->setEnabled( selected ); |
451 | mActionMail->setEnabled( selected ); | 451 | mActionMail->setEnabled( selected ); |
452 | mActionMailVCard->setEnabled( selected ); | 452 | mActionMailVCard->setEnabled( selected ); |
453 | //if (mActionBeam) | 453 | //if (mActionBeam) |
454 | //mActionBeam->setEnabled( selected ); | 454 | //mActionBeam->setEnabled( selected ); |
455 | 455 | ||
456 | if (mActionBeamVCard) | 456 | if (mActionBeamVCard) |
457 | mActionBeamVCard->setEnabled( selected ); | 457 | mActionBeamVCard->setEnabled( selected ); |
458 | 458 | ||
459 | mActionWhoAmI->setEnabled( selected ); | 459 | mActionWhoAmI->setEnabled( selected ); |
460 | mActionCategories->setEnabled( selected ); | 460 | mActionCategories->setEnabled( selected ); |
461 | } | 461 | } |
462 | 462 | ||
463 | void KABCore::sendMail() | 463 | void KABCore::sendMail() |
464 | { | 464 | { |
465 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 465 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
466 | } | 466 | } |
467 | 467 | ||
468 | void KABCore::sendMail( const QString& email ) | 468 | void KABCore::sendMail( const QString& emaillist ) |
469 | { | 469 | { |
470 | bool result = ExternalAppHandler::instance()->mailToContacts(email); | 470 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
471 | if (emaillist.contains(",") > 0) | ||
472 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | ||
473 | else | ||
474 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | ||
471 | } | 475 | } |
472 | 476 | ||
473 | 477 | ||
474 | 478 | ||
475 | void KABCore::mailVCard() | 479 | void KABCore::mailVCard() |
476 | { | 480 | { |
477 | QStringList uids = mViewManager->selectedUids(); | 481 | QStringList uids = mViewManager->selectedUids(); |
478 | if ( !uids.isEmpty() ) | 482 | if ( !uids.isEmpty() ) |
479 | mailVCard( uids ); | 483 | mailVCard( uids ); |
480 | } | 484 | } |
481 | 485 | ||
482 | void KABCore::mailVCard( const QStringList& uids ) | 486 | void KABCore::mailVCard( const QStringList& uids ) |
483 | { | 487 | { |
484 | QStringList urls; | 488 | QStringList urls; |
485 | 489 | ||
486 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 490 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
487 | 491 | ||
488 | /*US | 492 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
489 | // Create a temp dir, so that we can put the files in it with proper names | ||
490 | KTempFile tempDir; | ||
491 | if ( tempDir.status() != 0 ) { | ||
492 | kdWarning() << strerror( tempDir.status() ) << endl; | ||
493 | return; | ||
494 | } | ||
495 | |||
496 | QString dirName = tempDir.name(); | ||
497 | tempDir.unlink(); | ||
498 | */ | ||
499 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | ||
500 | 493 | ||
501 | 494 | ||
502 | 495 | ||
503 | QDir().mkdir( dirName, true ); | 496 | QDir().mkdir( dirName, true ); |
504 | 497 | ||
505 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 498 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
506 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 499 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
507 | 500 | ||
508 | if ( a.isEmpty() ) | 501 | if ( a.isEmpty() ) |
509 | continue; | 502 | continue; |
510 | 503 | ||
511 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 504 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
512 | 505 | ||
513 | QString fileName = dirName + "/" + name; | 506 | QString fileName = dirName + "/" + name; |
514 | 507 | ||
515 | QFile outFile(fileName); | 508 | QFile outFile(fileName); |
509 | |||
516 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 510 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
517 | KABC::VCardConverter converter; | 511 | KABC::VCardConverter converter; |
518 | QString vcard; | 512 | QString vcard; |
519 | 513 | ||
520 | converter.addresseeToVCard( a, vcard ); | 514 | converter.addresseeToVCard( a, vcard ); |
521 | 515 | ||
522 | QTextStream t( &outFile ); // use a text stream | 516 | QTextStream t( &outFile ); // use a text stream |
523 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 517 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
524 | t << vcard; | 518 | t << vcard; |
525 | 519 | ||
526 | outFile.close(); | 520 | outFile.close(); |
527 | 521 | ||
528 | urls.append( fileName ); | 522 | urls.append( fileName ); |
529 | } | 523 | } |
530 | } | 524 | } |
531 | 525 | ||
532 | bool result = ExternalAppHandler::instance()->mailAttachments(urls.join(", ")); | 526 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
533 | 527 | ||
534 | 528 | ||
535 | /*US | 529 | /*US |
536 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 530 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
537 | QString::null, // subject | 531 | QString::null, // subject |
538 | QString::null, // body | 532 | QString::null, // body |
539 | QString::null, | 533 | QString::null, |
540 | urls ); // attachments | 534 | urls ); // attachments |
541 | */ | 535 | */ |
542 | 536 | ||
543 | } | 537 | } |
544 | 538 | ||
545 | /** | 539 | /** |
546 | Beams the "WhoAmI contact. | 540 | Beams the "WhoAmI contact. |
547 | */ | 541 | */ |
548 | void KABCore::beamMySelf() | 542 | void KABCore::beamMySelf() |
549 | { | 543 | { |
550 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 544 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
551 | if (!a.isEmpty()) | 545 | if (!a.isEmpty()) |
552 | { | 546 | { |
553 | QStringList uids; | 547 | QStringList uids; |
554 | uids << a.uid(); | 548 | uids << a.uid(); |
555 | 549 | ||
556 | beamVCard(uids); | 550 | beamVCard(uids); |
557 | } else { | 551 | } else { |
558 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 552 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
559 | 553 | ||
560 | 554 | ||
561 | } | 555 | } |
562 | } | 556 | } |
563 | 557 | ||
564 | void KABCore::beamVCard() | 558 | void KABCore::beamVCard() |
565 | { | 559 | { |
566 | QStringList uids = mViewManager->selectedUids(); | 560 | QStringList uids = mViewManager->selectedUids(); |
567 | if ( !uids.isEmpty() ) | 561 | if ( !uids.isEmpty() ) |
568 | beamVCard( uids ); | 562 | beamVCard( uids ); |
569 | } | 563 | } |
570 | 564 | ||
571 | 565 | ||
572 | void KABCore::beamVCard(const QStringList& uids) | 566 | void KABCore::beamVCard(const QStringList& uids) |
573 | { | 567 | { |
574 | /*US | 568 | /*US |
575 | QString beamFilename; | 569 | QString beamFilename; |
576 | Opie::OPimContact c; | 570 | Opie::OPimContact c; |
577 | if ( actionPersonal->isOn() ) { | 571 | if ( actionPersonal->isOn() ) { |
578 | beamFilename = addressbookPersonalVCardName(); | 572 | beamFilename = addressbookPersonalVCardName(); |
579 | if ( !QFile::exists( beamFilename ) ) | 573 | if ( !QFile::exists( beamFilename ) ) |
580 | return; // can't beam a non-existent file | 574 | return; // can't beam a non-existent file |