-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index e053e94..975911e 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -527,307 +527,313 @@ void AddressbookWindow::slotViewEdit() | |||
527 | if (actionPersonal->isOn()) { | 527 | if (actionPersonal->isOn()) { |
528 | editPersonal(); | 528 | editPersonal(); |
529 | } else { | 529 | } else { |
530 | editEntry( EditEntry ); | 530 | editEntry( EditEntry ); |
531 | } | 531 | } |
532 | } else { | 532 | } else { |
533 | QMessageBox::warning( this, tr("Contacts"), | 533 | QMessageBox::warning( this, tr("Contacts"), |
534 | tr("Can not edit data, currently syncing") ); | 534 | tr("Can not edit data, currently syncing") ); |
535 | } | 535 | } |
536 | } | 536 | } |
537 | 537 | ||
538 | 538 | ||
539 | 539 | ||
540 | void AddressbookWindow::writeMail() | 540 | void AddressbookWindow::writeMail() |
541 | { | 541 | { |
542 | OContact c = m_abView -> currentEntry(); | 542 | OContact c = m_abView -> currentEntry(); |
543 | QString name = c.fileAs(); | 543 | QString name = c.fileAs(); |
544 | QString email = c.defaultEmail(); | 544 | QString email = c.defaultEmail(); |
545 | 545 | ||
546 | // I prefer the OPIE-Environment variable before the | 546 | // I prefer the OPIE-Environment variable before the |
547 | // QPE-one.. | 547 | // QPE-one.. |
548 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 548 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
549 | if ( basepath.isEmpty() ) | 549 | if ( basepath.isEmpty() ) |
550 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 550 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
551 | 551 | ||
552 | // Try to access the preferred. If not possible, try to | 552 | // Try to access the preferred. If not possible, try to |
553 | // switch to the other one.. | 553 | // switch to the other one.. |
554 | if ( m_config.useQtMail() ){ | 554 | if ( m_config.useQtMail() ){ |
555 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); | 555 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); |
556 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 556 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
557 | qWarning ("QCop"); | 557 | qWarning ("QCop"); |
558 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 558 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
559 | e << name << email; | 559 | e << name << email; |
560 | return; | 560 | return; |
561 | } else | 561 | } else |
562 | m_config.setUseOpieMail( true ); | 562 | m_config.setUseOpieMail( true ); |
563 | } | 563 | } |
564 | if ( m_config.useOpieMail() ){ | 564 | if ( m_config.useOpieMail() ){ |
565 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); | 565 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); |
566 | if ( QFile::exists( basepath + "/bin/mail" ) ){ | 566 | if ( QFile::exists( basepath + "/bin/mail" ) ){ |
567 | qWarning ("QCop"); | 567 | qWarning ("QCop"); |
568 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); | 568 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); |
569 | e << name << email; | 569 | e << name << email; |
570 | return; | 570 | return; |
571 | } else | 571 | } else |
572 | m_config.setUseQtMail( true ); | 572 | m_config.setUseQtMail( true ); |
573 | } | 573 | } |
574 | 574 | ||
575 | } | 575 | } |
576 | 576 | ||
577 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 577 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
578 | 578 | ||
579 | void AddressbookWindow::slotBeam() | 579 | void AddressbookWindow::slotBeam() |
580 | { | 580 | { |
581 | QString beamFilename; | 581 | QString beamFilename; |
582 | OContact c; | 582 | OContact c; |
583 | if ( actionPersonal->isOn() ) { | 583 | if ( actionPersonal->isOn() ) { |
584 | beamFilename = addressbookPersonalVCardName(); | 584 | beamFilename = addressbookPersonalVCardName(); |
585 | if ( !QFile::exists( beamFilename ) ) | 585 | if ( !QFile::exists( beamFilename ) ) |
586 | return; // can't beam a non-existent file | 586 | return; // can't beam a non-existent file |
587 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 587 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
588 | beamFilename ); | 588 | beamFilename ); |
589 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 589 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
590 | OContactAccess::List allList = access->allRecords(); | 590 | OContactAccess::List allList = access->allRecords(); |
591 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 591 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
592 | c = *it; | 592 | c = *it; |
593 | 593 | ||
594 | delete access; | 594 | delete access; |
595 | } else { | 595 | } else { |
596 | unlink( beamfile ); // delete if exists | 596 | unlink( beamfile ); // delete if exists |
597 | mkdir("/tmp/obex/", 0755); | 597 | mkdir("/tmp/obex/", 0755); |
598 | c = m_abView -> currentEntry(); | 598 | c = m_abView -> currentEntry(); |
599 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 599 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
600 | beamfile ); | 600 | beamfile ); |
601 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 601 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
602 | access->add( c ); | 602 | access->add( c ); |
603 | access->save(); | 603 | access->save(); |
604 | delete access; | 604 | delete access; |
605 | 605 | ||
606 | beamFilename = beamfile; | 606 | beamFilename = beamfile; |
607 | } | 607 | } |
608 | 608 | ||
609 | qWarning("Beaming: %s", beamFilename.latin1() ); | 609 | qWarning("Beaming: %s", beamFilename.latin1() ); |
610 | 610 | ||
611 | Ir *ir = new Ir( this ); | 611 | Ir *ir = new Ir( this ); |
612 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 612 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
613 | QString description = c.fullName(); | 613 | QString description = c.fullName(); |
614 | ir->send( beamFilename, description, "text/x-vCard" ); | 614 | ir->send( beamFilename, description, "text/x-vCard" ); |
615 | } | 615 | } |
616 | 616 | ||
617 | void AddressbookWindow::beamDone( Ir *ir ) | 617 | void AddressbookWindow::beamDone( Ir *ir ) |
618 | { | 618 | { |
619 | 619 | ||
620 | delete ir; | 620 | delete ir; |
621 | unlink( beamfile ); | 621 | unlink( beamfile ); |
622 | } | 622 | } |
623 | 623 | ||
624 | 624 | ||
625 | static void parseName( const QString& name, QString *first, QString *middle, | 625 | static void parseName( const QString& name, QString *first, QString *middle, |
626 | QString * last ) | 626 | QString * last ) |
627 | { | 627 | { |
628 | 628 | ||
629 | int comma = name.find ( "," ); | 629 | int comma = name.find ( "," ); |
630 | QString rest; | 630 | QString rest; |
631 | if ( comma > 0 ) { | 631 | if ( comma > 0 ) { |
632 | *last = name.left( comma ); | 632 | *last = name.left( comma ); |
633 | comma++; | 633 | comma++; |
634 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 634 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
635 | comma++; | 635 | comma++; |
636 | rest = name.mid( comma ); | 636 | rest = name.mid( comma ); |
637 | } else { | 637 | } else { |
638 | int space = name.findRev( ' ' ); | 638 | int space = name.findRev( ' ' ); |
639 | *last = name.mid( space+1 ); | 639 | *last = name.mid( space+1 ); |
640 | rest = name.left( space ); | 640 | rest = name.left( space ); |
641 | } | 641 | } |
642 | int space = rest.find( ' ' ); | 642 | int space = rest.find( ' ' ); |
643 | if ( space <= 0 ) { | 643 | if ( space <= 0 ) { |
644 | *first = rest; | 644 | *first = rest; |
645 | } else { | 645 | } else { |
646 | *first = rest.left( space ); | 646 | *first = rest.left( space ); |
647 | *middle = rest.mid( space+1 ); | 647 | *middle = rest.mid( space+1 ); |
648 | } | 648 | } |
649 | 649 | ||
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
654 | { | 654 | { |
655 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); | ||
656 | |||
655 | if (msg == "editPersonal()") { | 657 | if (msg == "editPersonal()") { |
656 | editPersonal(); | 658 | editPersonal(); |
657 | } else if (msg == "editPersonalAndClose()") { | 659 | } else if (msg == "editPersonalAndClose()") { |
658 | editPersonal(); | 660 | editPersonal(); |
659 | close(); | 661 | close(); |
660 | } else if ( msg == "addContact(QString,QString)" ) { | 662 | } else if ( msg == "addContact(QString,QString)" ) { |
661 | QDataStream stream(data,IO_ReadOnly); | 663 | QDataStream stream(data,IO_ReadOnly); |
662 | QString name, email; | 664 | QString name, email; |
663 | stream >> name >> email; | 665 | stream >> name >> email; |
664 | 666 | ||
665 | OContact cnt; | 667 | OContact cnt; |
666 | QString fn, mn, ln; | 668 | QString fn, mn, ln; |
667 | parseName( name, &fn, &mn, &ln ); | 669 | parseName( name, &fn, &mn, &ln ); |
668 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 670 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
669 | cnt.setFirstName( fn ); | 671 | cnt.setFirstName( fn ); |
670 | cnt.setMiddleName( mn ); | 672 | cnt.setMiddleName( mn ); |
671 | cnt.setLastName( ln ); | 673 | cnt.setLastName( ln ); |
672 | cnt.insertEmails( email ); | 674 | cnt.insertEmails( email ); |
673 | cnt.setDefaultEmail( email ); | 675 | cnt.setDefaultEmail( email ); |
674 | cnt.setFileAs(); | 676 | cnt.setFileAs(); |
675 | 677 | ||
676 | m_abView -> addEntry( cnt ); | 678 | m_abView -> addEntry( cnt ); |
677 | 679 | ||
678 | // :SXm_abView()->init( cnt ); | 680 | // :SXm_abView()->init( cnt ); |
679 | editEntry( EditEntry ); | 681 | editEntry( EditEntry ); |
680 | } else if ( msg == "beamBusinessCard()" ) { | 682 | } else if ( msg == "beamBusinessCard()" ) { |
681 | QString beamFilename = addressbookPersonalVCardName(); | 683 | QString beamFilename = addressbookPersonalVCardName(); |
682 | if ( !QFile::exists( beamFilename ) ) | 684 | if ( !QFile::exists( beamFilename ) ) |
683 | return; // can't beam a non-existent file | 685 | return; // can't beam a non-existent file |
684 | 686 | ||
685 | Ir *ir = new Ir( this ); | 687 | Ir *ir = new Ir( this ); |
686 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 688 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
687 | QString description = "mycard.vcf"; | 689 | QString description = "mycard.vcf"; |
688 | ir->send( beamFilename, description, "text/x-vCard" ); | 690 | ir->send( beamFilename, description, "text/x-vCard" ); |
689 | } else if ( msg == "showUid(int)" ) { | 691 | } else if ( msg == "show(int)" ) { |
690 | QDataStream stream(data,IO_ReadOnly); | 692 | QDataStream stream(data,IO_ReadOnly); |
691 | int uid; | 693 | int uid; |
692 | stream >> uid; | 694 | stream >> uid; |
693 | 695 | ||
696 | qWarning( "Showing uid: %d" , uid ); | ||
697 | |||
694 | // Deactivate Personal View.. | 698 | // Deactivate Personal View.. |
695 | if ( actionPersonal->isOn() ){ | 699 | if ( actionPersonal->isOn() ){ |
696 | actionPersonal->setOn( false ); | 700 | actionPersonal->setOn( false ); |
697 | slotPersonalView(); | 701 | slotPersonalView(); |
698 | } | 702 | } |
699 | 703 | ||
700 | // Reset category and show as card.. | 704 | // Reset category and show as card.. |
701 | m_abView -> setShowByCategory( QString::null ); | 705 | m_abView -> setShowByCategory( QString::null ); |
702 | m_abView -> setCurrentUid( uid ); | 706 | m_abView -> setCurrentUid( uid ); |
703 | slotViewSwitched ( AbView::CardView ); | 707 | slotViewSwitched ( AbView::CardView ); |
708 | |||
709 | qApp->exec(); | ||
704 | 710 | ||
705 | } else if ( msg == "editUid(int)" ) { | 711 | } else if ( msg == "edit(int)" ) { |
706 | QDataStream stream(data,IO_ReadOnly); | 712 | QDataStream stream(data,IO_ReadOnly); |
707 | int uid; | 713 | int uid; |
708 | stream >> uid; | 714 | stream >> uid; |
709 | 715 | ||
710 | // Deactivate Personal View.. | 716 | // Deactivate Personal View.. |
711 | if ( actionPersonal->isOn() ){ | 717 | if ( actionPersonal->isOn() ){ |
712 | actionPersonal->setOn( false ); | 718 | actionPersonal->setOn( false ); |
713 | slotPersonalView(); | 719 | slotPersonalView(); |
714 | } | 720 | } |
715 | 721 | ||
716 | // Reset category and edit.. | 722 | // Reset category and edit.. |
717 | m_abView -> setShowByCategory( QString::null ); | 723 | m_abView -> setShowByCategory( QString::null ); |
718 | m_abView -> setCurrentUid( uid ); | 724 | m_abView -> setCurrentUid( uid ); |
719 | slotViewEdit(); | 725 | slotViewEdit(); |
720 | } | 726 | } |
721 | 727 | ||
722 | } | 728 | } |
723 | 729 | ||
724 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 730 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
725 | { | 731 | { |
726 | OContact entry; | 732 | OContact entry; |
727 | if ( !abEditor ) { | 733 | if ( !abEditor ) { |
728 | abEditor = new ContactEditor( entry, this, "editor" ); | 734 | abEditor = new ContactEditor( entry, this, "editor" ); |
729 | } | 735 | } |
730 | if ( entryMode == EditEntry ) | 736 | if ( entryMode == EditEntry ) |
731 | abEditor->setEntry( m_abView -> currentEntry() ); | 737 | abEditor->setEntry( m_abView -> currentEntry() ); |
732 | else if ( entryMode == NewEntry ) | 738 | else if ( entryMode == NewEntry ) |
733 | abEditor->setEntry( entry ); | 739 | abEditor->setEntry( entry ); |
734 | // other things may change the caption. | 740 | // other things may change the caption. |
735 | abEditor->setCaption( tr("Edit Address") ); | 741 | abEditor->setCaption( tr("Edit Address") ); |
736 | 742 | ||
737 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 743 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
738 | abEditor->showMaximized(); | 744 | abEditor->showMaximized(); |
739 | #endif | 745 | #endif |
740 | // fix the foxus... | 746 | // fix the foxus... |
741 | abEditor->setNameFocus(); | 747 | abEditor->setNameFocus(); |
742 | if ( abEditor->exec() ) { | 748 | if ( abEditor->exec() ) { |
743 | setFocus(); | 749 | setFocus(); |
744 | if ( entryMode == NewEntry ) { | 750 | if ( entryMode == NewEntry ) { |
745 | OContact insertEntry = abEditor->entry(); | 751 | OContact insertEntry = abEditor->entry(); |
746 | insertEntry.assignUid(); | 752 | insertEntry.assignUid(); |
747 | m_abView -> addEntry( insertEntry ); | 753 | m_abView -> addEntry( insertEntry ); |
748 | } else { | 754 | } else { |
749 | OContact replEntry = abEditor->entry(); | 755 | OContact replEntry = abEditor->entry(); |
750 | 756 | ||
751 | if ( !replEntry.isValidUid() ) | 757 | if ( !replEntry.isValidUid() ) |
752 | replEntry.assignUid(); | 758 | replEntry.assignUid(); |
753 | 759 | ||
754 | m_abView -> replaceEntry( replEntry ); | 760 | m_abView -> replaceEntry( replEntry ); |
755 | } | 761 | } |
756 | } | 762 | } |
757 | // populateCategories(); | 763 | // populateCategories(); |
758 | 764 | ||
759 | } | 765 | } |
760 | 766 | ||
761 | void AddressbookWindow::editPersonal() | 767 | void AddressbookWindow::editPersonal() |
762 | { | 768 | { |
763 | OContact entry; | 769 | OContact entry; |
764 | 770 | ||
765 | // Switch to personal view if not selected | 771 | // Switch to personal view if not selected |
766 | // but take care of the menu, too | 772 | // but take care of the menu, too |
767 | if ( ! actionPersonal->isOn() ){ | 773 | if ( ! actionPersonal->isOn() ){ |
768 | qWarning("*** ++++"); | 774 | qWarning("*** ++++"); |
769 | actionPersonal->setOn( true ); | 775 | actionPersonal->setOn( true ); |
770 | slotPersonalView(); | 776 | slotPersonalView(); |
771 | } | 777 | } |
772 | 778 | ||
773 | if ( !abEditor ) { | 779 | if ( !abEditor ) { |
774 | abEditor = new ContactEditor( entry, this, "editor" ); | 780 | abEditor = new ContactEditor( entry, this, "editor" ); |
775 | } | 781 | } |
776 | 782 | ||
777 | abEditor->setCaption(tr("Edit My Personal Details")); | 783 | abEditor->setCaption(tr("Edit My Personal Details")); |
778 | abEditor->setPersonalView( true ); | 784 | abEditor->setPersonalView( true ); |
779 | editEntry( EditEntry ); | 785 | editEntry( EditEntry ); |
780 | abEditor->setPersonalView( false ); | 786 | abEditor->setPersonalView( false ); |
781 | 787 | ||
782 | } | 788 | } |
783 | 789 | ||
784 | 790 | ||
785 | void AddressbookWindow::slotPersonalView() | 791 | void AddressbookWindow::slotPersonalView() |
786 | { | 792 | { |
787 | qWarning("slotPersonalView()"); | 793 | qWarning("slotPersonalView()"); |
788 | if (!actionPersonal->isOn()) { | 794 | if (!actionPersonal->isOn()) { |
789 | // we just turned it off | 795 | // we just turned it off |
790 | qWarning("slotPersonalView()-> OFF"); | 796 | qWarning("slotPersonalView()-> OFF"); |
791 | setCaption( tr("Contacts") ); | 797 | setCaption( tr("Contacts") ); |
792 | actionNew->setEnabled(TRUE); | 798 | actionNew->setEnabled(TRUE); |
793 | actionTrash->setEnabled(TRUE); | 799 | actionTrash->setEnabled(TRUE); |
794 | actionFind->setEnabled(TRUE); | 800 | actionFind->setEnabled(TRUE); |
795 | actionMail->setEnabled(TRUE); | 801 | actionMail->setEnabled(TRUE); |
796 | // slotUpdateToolbar(); | 802 | // slotUpdateToolbar(); |
797 | 803 | ||
798 | m_abView->showPersonal( false ); | 804 | m_abView->showPersonal( false ); |
799 | 805 | ||
800 | return; | 806 | return; |
801 | } | 807 | } |
802 | 808 | ||
803 | qWarning("slotPersonalView()-> ON"); | 809 | qWarning("slotPersonalView()-> ON"); |
804 | // XXX need to disable some QActions. | 810 | // XXX need to disable some QActions. |
805 | actionNew->setEnabled(FALSE); | 811 | actionNew->setEnabled(FALSE); |
806 | actionTrash->setEnabled(FALSE); | 812 | actionTrash->setEnabled(FALSE); |
807 | actionFind->setEnabled(FALSE); | 813 | actionFind->setEnabled(FALSE); |
808 | actionMail->setEnabled(FALSE); | 814 | actionMail->setEnabled(FALSE); |
809 | 815 | ||
810 | setCaption( tr("Contacts - My Personal Details") ); | 816 | setCaption( tr("Contacts - My Personal Details") ); |
811 | 817 | ||
812 | m_abView->showPersonal( true ); | 818 | m_abView->showPersonal( true ); |
813 | 819 | ||
814 | } | 820 | } |
815 | 821 | ||
816 | 822 | ||
817 | void AddressbookWindow::listIsEmpty( bool empty ) | 823 | void AddressbookWindow::listIsEmpty( bool empty ) |
818 | { | 824 | { |
819 | if ( !empty ) { | 825 | if ( !empty ) { |
820 | deleteButton->setEnabled( TRUE ); | 826 | deleteButton->setEnabled( TRUE ); |
821 | } | 827 | } |
822 | } | 828 | } |
823 | 829 | ||
824 | void AddressbookWindow::reload() | 830 | void AddressbookWindow::reload() |
825 | { | 831 | { |
826 | syncing = FALSE; | 832 | syncing = FALSE; |
827 | m_abView->clear(); | 833 | m_abView->clear(); |
828 | m_abView->reload(); | 834 | m_abView->reload(); |
829 | } | 835 | } |
830 | 836 | ||
831 | void AddressbookWindow::flush() | 837 | void AddressbookWindow::flush() |
832 | { | 838 | { |
833 | syncing = TRUE; | 839 | syncing = TRUE; |