author | zautrix <zautrix> | 2004-08-06 08:39:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-06 08:39:55 (UTC) |
commit | 15edf84bf2bdd1cb00cbdc37d0402b9587c40f21 (patch) (unidiff) | |
tree | f4da393d531292ff6702aed0936f2405bdf20555 /kaddressbook | |
parent | 3bf62eb85312197352b7c836239d6d239e9a70cf (diff) | |
download | kdepimpi-15edf84bf2bdd1cb00cbdc37d0402b9587c40f21.zip kdepimpi-15edf84bf2bdd1cb00cbdc37d0402b9587c40f21.tar.gz kdepimpi-15edf84bf2bdd1cb00cbdc37d0402b9587c40f21.tar.bz2 |
Fixed some beaming problems
-rw-r--r-- | kaddressbook/kabcore.cpp | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d891b07..25891a0 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -441,29 +441,29 @@ void KABCore::setContactSelected( const QString &uid ) | |||
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 (mActionBeam) | 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& email ) |
469 | { | 469 | { |
@@ -576,24 +576,28 @@ void KABCore::mailVCard( const QStringList& uids ) | |||
576 | /** | 576 | /** |
577 | Beams the "WhoAmI contact. | 577 | Beams the "WhoAmI contact. |
578 | */ | 578 | */ |
579 | void KABCore::beamMySelf() | 579 | void KABCore::beamMySelf() |
580 | { | 580 | { |
581 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 581 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
582 | if (!a.isEmpty()) | 582 | if (!a.isEmpty()) |
583 | { | 583 | { |
584 | QStringList uids; | 584 | QStringList uids; |
585 | uids << a.uid(); | 585 | uids << a.uid(); |
586 | 586 | ||
587 | beamVCard(uids); | 587 | beamVCard(uids); |
588 | } else { | ||
589 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | ||
590 | |||
591 | |||
588 | } | 592 | } |
589 | } | 593 | } |
590 | 594 | ||
591 | void KABCore::beamVCard() | 595 | void KABCore::beamVCard() |
592 | { | 596 | { |
593 | QStringList uids = mViewManager->selectedUids(); | 597 | QStringList uids = mViewManager->selectedUids(); |
594 | if ( !uids.isEmpty() ) | 598 | if ( !uids.isEmpty() ) |
595 | beamVCard( uids ); | 599 | beamVCard( uids ); |
596 | } | 600 | } |
597 | 601 | ||
598 | 602 | ||
599 | void KABCore::beamVCard(const QStringList& uids) | 603 | void KABCore::beamVCard(const QStringList& uids) |
@@ -620,71 +624,84 @@ void KABCore::beamVCard(const QStringList& uids) | |||
620 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 624 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
621 | beamfile ); | 625 | beamfile ); |
622 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 626 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
623 | access->add( c ); | 627 | access->add( c ); |
624 | access->save(); | 628 | access->save(); |
625 | delete access; | 629 | delete access; |
626 | 630 | ||
627 | beamFilename = beamfile; | 631 | beamFilename = beamfile; |
628 | } | 632 | } |
629 | 633 | ||
630 | owarn << "Beaming: " << beamFilename << oendl; | 634 | owarn << "Beaming: " << beamFilename << oendl; |
631 | */ | 635 | */ |
636 | |||
637 | #if 0 | ||
632 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 638 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
633 | 639 | ||
634 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 640 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
635 | 641 | ||
636 | QString name = "contact.vcf"; | 642 | QString name = "contact.vcf"; |
637 | 643 | ||
638 | QString fileName = dirName + "/" + name; | 644 | QString fileName = dirName + "/" + name; |
645 | #endif | ||
646 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | ||
647 | // | ||
648 | QString fileName = "/tmp/kdepimbeamfile"; | ||
639 | 649 | ||
640 | 650 | ||
641 | QDir().mkdir( dirName, true ); | 651 | //QDir().mkdir( dirName, true ); |
642 | 652 | ||
643 | QFile outFile(fileName); | 653 | QFile outFile(fileName); |
644 | KABC::VCardConverter converter; | 654 | KABC::VCardConverter converter; |
645 | QString description; | 655 | QString description; |
646 | 656 | ||
647 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 657 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
648 | 658 | ||
649 | QTextStream t( &outFile ); // use a text stream | 659 | QTextStream t( &outFile ); // use a text stream |
650 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 660 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
651 | 661 | ||
652 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 662 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
653 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 663 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
654 | 664 | ||
655 | if ( a.isEmpty() ) | 665 | if ( a.isEmpty() ) |
656 | continue; | 666 | continue; |
657 | 667 | ||
658 | if (description.isEmpty()) | 668 | if (description.isEmpty()) |
659 | description = a.formattedName(); | 669 | description = a.formattedName(); |
660 | 670 | ||
661 | QString vcard; | 671 | QString vcard; |
662 | converter.addresseeToVCard( a, vcard ); | 672 | converter.addresseeToVCard( a, vcard ); |
663 | t << vcard; | 673 | t << vcard; |
664 | 674 | ||
665 | } | 675 | } |
676 | } else { | ||
677 | qDebug("Error open temp beam file "); | ||
678 | return; | ||
666 | } | 679 | } |
667 | 680 | ||
668 | outFile.close(); | 681 | outFile.close(); |
669 | 682 | ||
683 | #ifndef DESKTOP_VERSION | ||
670 | Ir *ir = new Ir( this ); | 684 | Ir *ir = new Ir( this ); |
671 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 685 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
672 | ir->send( fileName, description, "text/x-vCard" ); | 686 | ir->send( fileName, description, "text/x-vCard" ); |
687 | #endif | ||
673 | 688 | ||
674 | } | 689 | } |
675 | 690 | ||
676 | void KABCore::beamDone( Ir *ir ) | 691 | void KABCore::beamDone( Ir *ir ) |
677 | { | 692 | { |
693 | #ifndef DESKTOP_VERSION | ||
678 | delete ir; | 694 | delete ir; |
695 | #endif | ||
679 | } | 696 | } |
680 | 697 | ||
681 | 698 | ||
682 | void KABCore::browse( const QString& url ) | 699 | void KABCore::browse( const QString& url ) |
683 | { | 700 | { |
684 | #ifndef KAB_EMBEDDED | 701 | #ifndef KAB_EMBEDDED |
685 | kapp->invokeBrowser( url ); | 702 | kapp->invokeBrowser( url ); |
686 | #else //KAB_EMBEDDED | 703 | #else //KAB_EMBEDDED |
687 | qDebug("KABCore::browse must be fixed"); | 704 | qDebug("KABCore::browse must be fixed"); |
688 | #endif //KAB_EMBEDDED | 705 | #endif //KAB_EMBEDDED |
689 | } | 706 | } |
690 | 707 | ||
@@ -1481,30 +1498,37 @@ void KABCore::initActions() | |||
1481 | 1498 | ||
1482 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1499 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1483 | SLOT( save() ), actionCollection(), "file_sync" ); | 1500 | SLOT( save() ), actionCollection(), "file_sync" ); |
1484 | 1501 | ||
1485 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1502 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1486 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1503 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1487 | 1504 | ||
1488 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1505 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1489 | this, SLOT( mailVCard() ), | 1506 | this, SLOT( mailVCard() ), |
1490 | actionCollection(), "file_mail_vcard"); | 1507 | actionCollection(), "file_mail_vcard"); |
1491 | 1508 | ||
1492 | mActionBeamVCard = 0; | 1509 | mActionBeamVCard = 0; |
1510 | mActionBeam = 0; | ||
1511 | |||
1512 | #ifndef DESKTOP_VERSION | ||
1493 | if ( Ir::supported() ) { | 1513 | if ( Ir::supported() ) { |
1494 | mActionBeamVCard = new KAction( i18n( "Beam v&Card" ), "beam", 0, this, | 1514 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1495 | SLOT( beamVCard() ), actionCollection(), | 1515 | SLOT( beamVCard() ), actionCollection(), |
1496 | "kaddressbook_beam_vcard" ); | 1516 | "kaddressbook_beam_vcard" ); |
1517 | |||
1518 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | ||
1519 | SLOT( beamMySelf() ), actionCollection(), | ||
1520 | "kaddressbook_beam_myself" ); | ||
1497 | } | 1521 | } |
1498 | 1522 | #endif | |
1499 | 1523 | ||
1500 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1524 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1501 | this, SLOT( editContact2() ), | 1525 | this, SLOT( editContact2() ), |
1502 | actionCollection(), "file_properties" ); | 1526 | actionCollection(), "file_properties" ); |
1503 | 1527 | ||
1504 | #ifdef KAB_EMBEDDED | 1528 | #ifdef KAB_EMBEDDED |
1505 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1529 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1506 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1530 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1507 | mMainWindow, SLOT( exit() ), | 1531 | mMainWindow, SLOT( exit() ), |
1508 | actionCollection(), "quit" ); | 1532 | actionCollection(), "quit" ); |
1509 | #endif //KAB_EMBEDDED | 1533 | #endif //KAB_EMBEDDED |
1510 | 1534 | ||
@@ -1588,30 +1612,25 @@ void KABCore::initActions() | |||
1588 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1612 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1589 | "ldap_lookup" ); | 1613 | "ldap_lookup" ); |
1590 | } | 1614 | } |
1591 | #else //KAB_EMBEDDED | 1615 | #else //KAB_EMBEDDED |
1592 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1616 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1593 | #endif //KAB_EMBEDDED | 1617 | #endif //KAB_EMBEDDED |
1594 | 1618 | ||
1595 | 1619 | ||
1596 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1620 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1597 | SLOT( setWhoAmI() ), actionCollection(), | 1621 | SLOT( setWhoAmI() ), actionCollection(), |
1598 | "set_personal" ); | 1622 | "set_personal" ); |
1599 | 1623 | ||
1600 | mActionBeam = 0; | 1624 | |
1601 | if ( Ir::supported() ) { | ||
1602 | mActionBeam = new KAction( i18n( "&Beam Who Am I" ), "beam", 0, this, | ||
1603 | SLOT( beamMySelf() ), actionCollection(), | ||
1604 | "kaddressbook_beam_myself" ); | ||
1605 | } | ||
1606 | 1625 | ||
1607 | 1626 | ||
1608 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1627 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1609 | SLOT( setCategories() ), actionCollection(), | 1628 | SLOT( setCategories() ), actionCollection(), |
1610 | "edit_set_categories" ); | 1629 | "edit_set_categories" ); |
1611 | 1630 | ||
1612 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1631 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1613 | SLOT( removeVoice() ), actionCollection(), | 1632 | SLOT( removeVoice() ), actionCollection(), |
1614 | "remove_voice" ); | 1633 | "remove_voice" ); |
1615 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, | 1634 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, |
1616 | SLOT( importFromOL() ), actionCollection(), | 1635 | SLOT( importFromOL() ), actionCollection(), |
1617 | "import_OL" ); | 1636 | "import_OL" ); |
@@ -1684,25 +1703,28 @@ void KABCore::addActionsManually() | |||
1684 | fileMenu->insertSeparator(); | 1703 | fileMenu->insertSeparator(); |
1685 | 1704 | ||
1686 | mActionNewContact->plug( fileMenu ); | 1705 | mActionNewContact->plug( fileMenu ); |
1687 | mActionNewContact->plug( tb ); | 1706 | mActionNewContact->plug( tb ); |
1688 | 1707 | ||
1689 | mActionEditAddressee->plug( fileMenu ); | 1708 | mActionEditAddressee->plug( fileMenu ); |
1690 | fileMenu->insertSeparator(); | 1709 | fileMenu->insertSeparator(); |
1691 | mActionSave->plug( fileMenu ); | 1710 | mActionSave->plug( fileMenu ); |
1692 | fileMenu->insertItem( "&Import", ImportMenu ); | 1711 | fileMenu->insertItem( "&Import", ImportMenu ); |
1693 | fileMenu->insertItem( "&Emport", ExportMenu ); | 1712 | fileMenu->insertItem( "&Emport", ExportMenu ); |
1694 | fileMenu->insertSeparator(); | 1713 | fileMenu->insertSeparator(); |
1695 | mActionMailVCard->plug( fileMenu ); | 1714 | mActionMailVCard->plug( fileMenu ); |
1715 | #ifndef DESKTOP_VERSION | ||
1696 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1716 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1717 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | ||
1718 | #endif | ||
1697 | fileMenu->insertSeparator(); | 1719 | fileMenu->insertSeparator(); |
1698 | mActionQuit->plug( fileMenu ); | 1720 | mActionQuit->plug( fileMenu ); |
1699 | #ifdef _WIN32_ | 1721 | #ifdef _WIN32_ |
1700 | mActionImportOL->plug( ImportMenu ); | 1722 | mActionImportOL->plug( ImportMenu ); |
1701 | #endif | 1723 | #endif |
1702 | // edit menu | 1724 | // edit menu |
1703 | mActionUndo->plug( editMenu ); | 1725 | mActionUndo->plug( editMenu ); |
1704 | mActionRedo->plug( editMenu ); | 1726 | mActionRedo->plug( editMenu ); |
1705 | editMenu->insertSeparator(); | 1727 | editMenu->insertSeparator(); |
1706 | mActionCut->plug( editMenu ); | 1728 | mActionCut->plug( editMenu ); |
1707 | mActionCopy->plug( editMenu ); | 1729 | mActionCopy->plug( editMenu ); |
1708 | mActionPaste->plug( editMenu ); | 1730 | mActionPaste->plug( editMenu ); |
@@ -1725,25 +1747,24 @@ void KABCore::addActionsManually() | |||
1725 | 1747 | ||
1726 | } else { | 1748 | } else { |
1727 | mActionKeyBindings->plug( settingsMenu ); | 1749 | mActionKeyBindings->plug( settingsMenu ); |
1728 | } | 1750 | } |
1729 | 1751 | ||
1730 | settingsMenu->insertSeparator(); | 1752 | settingsMenu->insertSeparator(); |
1731 | 1753 | ||
1732 | mActionJumpBar->plug( settingsMenu ); | 1754 | mActionJumpBar->plug( settingsMenu ); |
1733 | mActionDetails->plug( settingsMenu ); | 1755 | mActionDetails->plug( settingsMenu ); |
1734 | settingsMenu->insertSeparator(); | 1756 | settingsMenu->insertSeparator(); |
1735 | 1757 | ||
1736 | mActionWhoAmI->plug( settingsMenu ); | 1758 | mActionWhoAmI->plug( settingsMenu ); |
1737 | if ( Ir::supported() ) mActionBeam->plug( settingsMenu ); | ||
1738 | mActionCategories->plug( settingsMenu ); | 1759 | mActionCategories->plug( settingsMenu ); |
1739 | 1760 | ||
1740 | mActionAboutKAddressbook->plug( helpMenu ); | 1761 | mActionAboutKAddressbook->plug( helpMenu ); |
1741 | 1762 | ||
1742 | 1763 | ||
1743 | if (QApplication::desktop()->width() > 320 ) { | 1764 | if (QApplication::desktop()->width() > 320 ) { |
1744 | 1765 | ||
1745 | mActionEditAddressee->plug( tb ); | 1766 | mActionEditAddressee->plug( tb ); |
1746 | mActionSave->plug( tb ); | 1767 | mActionSave->plug( tb ); |
1747 | mViewManager->getFilterAction()->plug ( tb); | 1768 | mViewManager->getFilterAction()->plug ( tb); |
1748 | if (QApplication::desktop()->width() > 480 ) { | 1769 | if (QApplication::desktop()->width() > 480 ) { |
1749 | mActionUndo->plug( tb ); | 1770 | mActionUndo->plug( tb ); |