author | eilers <eilers> | 2002-10-28 13:41:31 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-28 13:41:31 (UTC) |
commit | d033fbaff92f1e8e89a96c69dadda068cf3177cd (patch) (unidiff) | |
tree | d23b6ee600ef7ac095a2ae191ac63436386351f6 | |
parent | 54b9d51694242a1f2e0c1898b05c56114827ca10 (diff) | |
download | opie-d033fbaff92f1e8e89a96c69dadda068cf3177cd.zip opie-d033fbaff92f1e8e89a96c69dadda068cf3177cd.tar.gz opie-d033fbaff92f1e8e89a96c69dadda068cf3177cd.tar.bz2 |
Vcard now exports date in correct format (Regarding RFC 2425).
Vcard now imports birthday..
-rw-r--r-- | libopie/pim/ocontact.cpp | 30 | ||||
-rw-r--r-- | libopie/pim/ocontact.h | 5 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 30 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.h | 5 |
4 files changed, 62 insertions, 8 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index 21fc088..734f5a2 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -613,997 +613,1023 @@ void OContact::insert( int key, const QString &v ) | |||
613 | /*! | 613 | /*! |
614 | \internal | 614 | \internal |
615 | */ | 615 | */ |
616 | void OContact::replace( int key, const QString & v ) | 616 | void OContact::replace( int key, const QString & v ) |
617 | { | 617 | { |
618 | QString value = v.stripWhiteSpace(); | 618 | QString value = v.stripWhiteSpace(); |
619 | if ( value.isEmpty() ) | 619 | if ( value.isEmpty() ) |
620 | mMap.remove( key ); | 620 | mMap.remove( key ); |
621 | else | 621 | else |
622 | mMap.replace( key, value ); | 622 | mMap.replace( key, value ); |
623 | } | 623 | } |
624 | 624 | ||
625 | /*! | 625 | /*! |
626 | \internal | 626 | \internal |
627 | */ | 627 | */ |
628 | QString OContact::find( int key ) const | 628 | QString OContact::find( int key ) const |
629 | { | 629 | { |
630 | return mMap[key]; | 630 | return mMap[key]; |
631 | } | 631 | } |
632 | 632 | ||
633 | /*! | 633 | /*! |
634 | \internal | 634 | \internal |
635 | */ | 635 | */ |
636 | QString OContact::displayAddress( const QString &street, | 636 | QString OContact::displayAddress( const QString &street, |
637 | const QString &city, | 637 | const QString &city, |
638 | const QString &state, | 638 | const QString &state, |
639 | const QString &zip, | 639 | const QString &zip, |
640 | const QString &country ) const | 640 | const QString &country ) const |
641 | { | 641 | { |
642 | QString s = street; | 642 | QString s = street; |
643 | if ( !street.isEmpty() ) | 643 | if ( !street.isEmpty() ) |
644 | s+= "\n"; | 644 | s+= "\n"; |
645 | s += city; | 645 | s += city; |
646 | if ( !city.isEmpty() && !state.isEmpty() ) | 646 | if ( !city.isEmpty() && !state.isEmpty() ) |
647 | s += ", "; | 647 | s += ", "; |
648 | s += state; | 648 | s += state; |
649 | if ( !state.isEmpty() && !zip.isEmpty() ) | 649 | if ( !state.isEmpty() && !zip.isEmpty() ) |
650 | s += " "; | 650 | s += " "; |
651 | s += zip; | 651 | s += zip; |
652 | if ( !country.isEmpty() && !s.isEmpty() ) | 652 | if ( !country.isEmpty() && !s.isEmpty() ) |
653 | s += "\n"; | 653 | s += "\n"; |
654 | s += country; | 654 | s += country; |
655 | return s; | 655 | return s; |
656 | } | 656 | } |
657 | 657 | ||
658 | /*! | 658 | /*! |
659 | \internal | 659 | \internal |
660 | */ | 660 | */ |
661 | QString OContact::displayBusinessAddress() const | 661 | QString OContact::displayBusinessAddress() const |
662 | { | 662 | { |
663 | return displayAddress( businessStreet(), businessCity(), | 663 | return displayAddress( businessStreet(), businessCity(), |
664 | businessState(), businessZip(), | 664 | businessState(), businessZip(), |
665 | businessCountry() ); | 665 | businessCountry() ); |
666 | } | 666 | } |
667 | 667 | ||
668 | /*! | 668 | /*! |
669 | \internal | 669 | \internal |
670 | */ | 670 | */ |
671 | QString OContact::displayHomeAddress() const | 671 | QString OContact::displayHomeAddress() const |
672 | { | 672 | { |
673 | return displayAddress( homeStreet(), homeCity(), | 673 | return displayAddress( homeStreet(), homeCity(), |
674 | homeState(), homeZip(), | 674 | homeState(), homeZip(), |
675 | homeCountry() ); | 675 | homeCountry() ); |
676 | } | 676 | } |
677 | 677 | ||
678 | /*! | 678 | /*! |
679 | Returns the full name of the contact | 679 | Returns the full name of the contact |
680 | */ | 680 | */ |
681 | QString OContact::fullName() const | 681 | QString OContact::fullName() const |
682 | { | 682 | { |
683 | QString title = find( Qtopia::Title ); | 683 | QString title = find( Qtopia::Title ); |
684 | QString firstName = find( Qtopia::FirstName ); | 684 | QString firstName = find( Qtopia::FirstName ); |
685 | QString middleName = find( Qtopia::MiddleName ); | 685 | QString middleName = find( Qtopia::MiddleName ); |
686 | QString lastName = find( Qtopia::LastName ); | 686 | QString lastName = find( Qtopia::LastName ); |
687 | QString suffix = find( Qtopia::Suffix ); | 687 | QString suffix = find( Qtopia::Suffix ); |
688 | 688 | ||
689 | QString name = title; | 689 | QString name = title; |
690 | if ( !firstName.isEmpty() ) { | 690 | if ( !firstName.isEmpty() ) { |
691 | if ( !name.isEmpty() ) | 691 | if ( !name.isEmpty() ) |
692 | name += " "; | 692 | name += " "; |
693 | name += firstName; | 693 | name += firstName; |
694 | } | 694 | } |
695 | if ( !middleName.isEmpty() ) { | 695 | if ( !middleName.isEmpty() ) { |
696 | if ( !name.isEmpty() ) | 696 | if ( !name.isEmpty() ) |
697 | name += " "; | 697 | name += " "; |
698 | name += middleName; | 698 | name += middleName; |
699 | } | 699 | } |
700 | if ( !lastName.isEmpty() ) { | 700 | if ( !lastName.isEmpty() ) { |
701 | if ( !name.isEmpty() ) | 701 | if ( !name.isEmpty() ) |
702 | name += " "; | 702 | name += " "; |
703 | name += lastName; | 703 | name += lastName; |
704 | } | 704 | } |
705 | if ( !suffix.isEmpty() ) { | 705 | if ( !suffix.isEmpty() ) { |
706 | if ( !name.isEmpty() ) | 706 | if ( !name.isEmpty() ) |
707 | name += " "; | 707 | name += " "; |
708 | name += suffix; | 708 | name += suffix; |
709 | } | 709 | } |
710 | return name.simplifyWhiteSpace(); | 710 | return name.simplifyWhiteSpace(); |
711 | } | 711 | } |
712 | 712 | ||
713 | /*! | 713 | /*! |
714 | Returns a list of the names of the children of the contact. | 714 | Returns a list of the names of the children of the contact. |
715 | */ | 715 | */ |
716 | QStringList OContact::childrenList() const | 716 | QStringList OContact::childrenList() const |
717 | { | 717 | { |
718 | return QStringList::split( " ", find( Qtopia::Children ) ); | 718 | return QStringList::split( " ", find( Qtopia::Children ) ); |
719 | } | 719 | } |
720 | 720 | ||
721 | /*! \fn void OContact::insertEmail( const QString &email ) | 721 | /*! \fn void OContact::insertEmail( const QString &email ) |
722 | 722 | ||
723 | Insert \a email into the email list. Ensures \a email can only be added | 723 | Insert \a email into the email list. Ensures \a email can only be added |
724 | once. If there is no default email address set, it sets it to the \a email. | 724 | once. If there is no default email address set, it sets it to the \a email. |
725 | */ | 725 | */ |
726 | 726 | ||
727 | /*! \fn void OContact::removeEmail( const QString &email ) | 727 | /*! \fn void OContact::removeEmail( const QString &email ) |
728 | 728 | ||
729 | Removes the \a email from the email list. If the default email was \a email, | 729 | Removes the \a email from the email list. If the default email was \a email, |
730 | then the default email address is assigned to the first email in the | 730 | then the default email address is assigned to the first email in the |
731 | email list | 731 | email list |
732 | */ | 732 | */ |
733 | 733 | ||
734 | /*! \fn void OContact::clearEmails() | 734 | /*! \fn void OContact::clearEmails() |
735 | 735 | ||
736 | Clears the email list. | 736 | Clears the email list. |
737 | */ | 737 | */ |
738 | 738 | ||
739 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) | 739 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) |
740 | 740 | ||
741 | Appends the \a emailList to the exiting email list | 741 | Appends the \a emailList to the exiting email list |
742 | */ | 742 | */ |
743 | 743 | ||
744 | /*! | 744 | /*! |
745 | Returns a list of email addresses belonging to the contact, including | 745 | Returns a list of email addresses belonging to the contact, including |
746 | the default email address. | 746 | the default email address. |
747 | */ | 747 | */ |
748 | QStringList OContact::emailList() const | 748 | QStringList OContact::emailList() const |
749 | { | 749 | { |
750 | QString emailStr = emails(); | 750 | QString emailStr = emails(); |
751 | 751 | ||
752 | QStringList r; | 752 | QStringList r; |
753 | if ( !emailStr.isEmpty() ) { | 753 | if ( !emailStr.isEmpty() ) { |
754 | qDebug(" emailstr "); | 754 | qDebug(" emailstr "); |
755 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 755 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
756 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 756 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
757 | r += (*it).simplifyWhiteSpace(); | 757 | r += (*it).simplifyWhiteSpace(); |
758 | } | 758 | } |
759 | 759 | ||
760 | return r; | 760 | return r; |
761 | } | 761 | } |
762 | 762 | ||
763 | /*! | 763 | /*! |
764 | \overload | 764 | \overload |
765 | 765 | ||
766 | Generates the string for the contact to be filed as from the first, | 766 | Generates the string for the contact to be filed as from the first, |
767 | middle and last name of the contact. | 767 | middle and last name of the contact. |
768 | */ | 768 | */ |
769 | void OContact::setFileAs() | 769 | void OContact::setFileAs() |
770 | { | 770 | { |
771 | QString lastName, firstName, middleName, fileas; | 771 | QString lastName, firstName, middleName, fileas; |
772 | 772 | ||
773 | lastName = find( Qtopia::LastName ); | 773 | lastName = find( Qtopia::LastName ); |
774 | firstName = find( Qtopia::FirstName ); | 774 | firstName = find( Qtopia::FirstName ); |
775 | middleName = find( Qtopia::MiddleName ); | 775 | middleName = find( Qtopia::MiddleName ); |
776 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 776 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
777 | && !middleName.isEmpty() ) | 777 | && !middleName.isEmpty() ) |
778 | fileas = lastName + ", " + firstName + " " + middleName; | 778 | fileas = lastName + ", " + firstName + " " + middleName; |
779 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 779 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
780 | fileas = lastName + ", " + firstName; | 780 | fileas = lastName + ", " + firstName; |
781 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 781 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
782 | !middleName.isEmpty() ) | 782 | !middleName.isEmpty() ) |
783 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 783 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
784 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 784 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
785 | + lastName; | 785 | + lastName; |
786 | 786 | ||
787 | replace( Qtopia::FileAs, fileas ); | 787 | replace( Qtopia::FileAs, fileas ); |
788 | } | 788 | } |
789 | 789 | ||
790 | /*! | 790 | /*! |
791 | \internal | 791 | \internal |
792 | Appends the contact information to \a buf. | 792 | Appends the contact information to \a buf. |
793 | */ | 793 | */ |
794 | void OContact::save( QString &buf ) const | 794 | void OContact::save( QString &buf ) const |
795 | { | 795 | { |
796 | static const QStringList SLFIELDS = fields(); | 796 | static const QStringList SLFIELDS = fields(); |
797 | // I'm expecting "<Contact " in front of this... | 797 | // I'm expecting "<Contact " in front of this... |
798 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 798 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
799 | it != mMap.end(); ++it ) { | 799 | it != mMap.end(); ++it ) { |
800 | const QString &value = it.data(); | 800 | const QString &value = it.data(); |
801 | int key = it.key(); | 801 | int key = it.key(); |
802 | if ( !value.isEmpty() ) { | 802 | if ( !value.isEmpty() ) { |
803 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 803 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
804 | continue; | 804 | continue; |
805 | 805 | ||
806 | key -= Qtopia::AddressCategory+1; | 806 | key -= Qtopia::AddressCategory+1; |
807 | buf += SLFIELDS[key]; | 807 | buf += SLFIELDS[key]; |
808 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 808 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
809 | } | 809 | } |
810 | } | 810 | } |
811 | buf += customToXml(); | 811 | buf += customToXml(); |
812 | if ( categories().count() > 0 ) | 812 | if ( categories().count() > 0 ) |
813 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 813 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
814 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 814 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
815 | // You need to close this yourself | 815 | // You need to close this yourself |
816 | } | 816 | } |
817 | 817 | ||
818 | /*! | 818 | /*! |
819 | \internal | 819 | \internal |
820 | Returns the list of fields belonging to a contact | 820 | Returns the list of fields belonging to a contact |
821 | */ | 821 | */ |
822 | QStringList OContact::fields() | 822 | QStringList OContact::fields() |
823 | { | 823 | { |
824 | QStringList list; | 824 | QStringList list; |
825 | 825 | ||
826 | list.append( "Title" ); // Not Used! | 826 | list.append( "Title" ); // Not Used! |
827 | list.append( "FirstName" ); | 827 | list.append( "FirstName" ); |
828 | list.append( "MiddleName" ); | 828 | list.append( "MiddleName" ); |
829 | list.append( "LastName" ); | 829 | list.append( "LastName" ); |
830 | list.append( "Suffix" ); | 830 | list.append( "Suffix" ); |
831 | list.append( "FileAs" ); | 831 | list.append( "FileAs" ); |
832 | 832 | ||
833 | list.append( "JobTitle" ); | 833 | list.append( "JobTitle" ); |
834 | list.append( "Department" ); | 834 | list.append( "Department" ); |
835 | list.append( "Company" ); | 835 | list.append( "Company" ); |
836 | list.append( "BusinessPhone" ); | 836 | list.append( "BusinessPhone" ); |
837 | list.append( "BusinessFax" ); | 837 | list.append( "BusinessFax" ); |
838 | list.append( "BusinessMobile" ); | 838 | list.append( "BusinessMobile" ); |
839 | 839 | ||
840 | list.append( "DefaultEmail" ); | 840 | list.append( "DefaultEmail" ); |
841 | list.append( "Emails" ); | 841 | list.append( "Emails" ); |
842 | 842 | ||
843 | list.append( "HomePhone" ); | 843 | list.append( "HomePhone" ); |
844 | list.append( "HomeFax" ); | 844 | list.append( "HomeFax" ); |
845 | list.append( "HomeMobile" ); | 845 | list.append( "HomeMobile" ); |
846 | 846 | ||
847 | list.append( "BusinessStreet" ); | 847 | list.append( "BusinessStreet" ); |
848 | list.append( "BusinessCity" ); | 848 | list.append( "BusinessCity" ); |
849 | list.append( "BusinessState" ); | 849 | list.append( "BusinessState" ); |
850 | list.append( "BusinessZip" ); | 850 | list.append( "BusinessZip" ); |
851 | list.append( "BusinessCountry" ); | 851 | list.append( "BusinessCountry" ); |
852 | list.append( "BusinessPager" ); | 852 | list.append( "BusinessPager" ); |
853 | list.append( "BusinessWebPage" ); | 853 | list.append( "BusinessWebPage" ); |
854 | 854 | ||
855 | list.append( "Office" ); | 855 | list.append( "Office" ); |
856 | list.append( "Profession" ); | 856 | list.append( "Profession" ); |
857 | list.append( "Assistant" ); | 857 | list.append( "Assistant" ); |
858 | list.append( "Manager" ); | 858 | list.append( "Manager" ); |
859 | 859 | ||
860 | list.append( "HomeStreet" ); | 860 | list.append( "HomeStreet" ); |
861 | list.append( "HomeCity" ); | 861 | list.append( "HomeCity" ); |
862 | list.append( "HomeState" ); | 862 | list.append( "HomeState" ); |
863 | list.append( "HomeZip" ); | 863 | list.append( "HomeZip" ); |
864 | list.append( "HomeCountry" ); | 864 | list.append( "HomeCountry" ); |
865 | list.append( "HomeWebPage" ); | 865 | list.append( "HomeWebPage" ); |
866 | 866 | ||
867 | list.append( "Spouse" ); | 867 | list.append( "Spouse" ); |
868 | list.append( "Gender" ); | 868 | list.append( "Gender" ); |
869 | list.append( "Birthday" ); | 869 | list.append( "Birthday" ); |
870 | list.append( "Anniversary" ); | 870 | list.append( "Anniversary" ); |
871 | list.append( "Nickname" ); | 871 | list.append( "Nickname" ); |
872 | list.append( "Children" ); | 872 | list.append( "Children" ); |
873 | 873 | ||
874 | list.append( "Notes" ); | 874 | list.append( "Notes" ); |
875 | list.append( "Groups" ); | 875 | list.append( "Groups" ); |
876 | 876 | ||
877 | return list; | 877 | return list; |
878 | } | 878 | } |
879 | 879 | ||
880 | /*! | 880 | /*! |
881 | \internal | 881 | \internal |
882 | Returns a translated list of field names for a contact. | 882 | Returns a translated list of field names for a contact. |
883 | */ | 883 | */ |
884 | QStringList OContact::trfields() | 884 | QStringList OContact::trfields() |
885 | { | 885 | { |
886 | QStringList list; | 886 | QStringList list; |
887 | 887 | ||
888 | list.append( QObject::tr( "Name Title") ); | 888 | list.append( QObject::tr( "Name Title") ); |
889 | list.append( QObject::tr( "First Name" ) ); | 889 | list.append( QObject::tr( "First Name" ) ); |
890 | list.append( QObject::tr( "Middle Name" ) ); | 890 | list.append( QObject::tr( "Middle Name" ) ); |
891 | list.append( QObject::tr( "Last Name" ) ); | 891 | list.append( QObject::tr( "Last Name" ) ); |
892 | list.append( QObject::tr( "Suffix" ) ); | 892 | list.append( QObject::tr( "Suffix" ) ); |
893 | list.append( QObject::tr( "File As" ) ); | 893 | list.append( QObject::tr( "File As" ) ); |
894 | 894 | ||
895 | list.append( QObject::tr( "Job Title" ) ); | 895 | list.append( QObject::tr( "Job Title" ) ); |
896 | list.append( QObject::tr( "Department" ) ); | 896 | list.append( QObject::tr( "Department" ) ); |
897 | list.append( QObject::tr( "Company" ) ); | 897 | list.append( QObject::tr( "Company" ) ); |
898 | list.append( QObject::tr( "Business Phone" ) ); | 898 | list.append( QObject::tr( "Business Phone" ) ); |
899 | list.append( QObject::tr( "Business Fax" ) ); | 899 | list.append( QObject::tr( "Business Fax" ) ); |
900 | list.append( QObject::tr( "Business Mobile" ) ); | 900 | list.append( QObject::tr( "Business Mobile" ) ); |
901 | 901 | ||
902 | list.append( QObject::tr( "Default Email" ) ); | 902 | list.append( QObject::tr( "Default Email" ) ); |
903 | list.append( QObject::tr( "Emails" ) ); | 903 | list.append( QObject::tr( "Emails" ) ); |
904 | 904 | ||
905 | list.append( QObject::tr( "Home Phone" ) ); | 905 | list.append( QObject::tr( "Home Phone" ) ); |
906 | list.append( QObject::tr( "Home Fax" ) ); | 906 | list.append( QObject::tr( "Home Fax" ) ); |
907 | list.append( QObject::tr( "Home Mobile" ) ); | 907 | list.append( QObject::tr( "Home Mobile" ) ); |
908 | 908 | ||
909 | list.append( QObject::tr( "Business Street" ) ); | 909 | list.append( QObject::tr( "Business Street" ) ); |
910 | list.append( QObject::tr( "Business City" ) ); | 910 | list.append( QObject::tr( "Business City" ) ); |
911 | list.append( QObject::tr( "Business State" ) ); | 911 | list.append( QObject::tr( "Business State" ) ); |
912 | list.append( QObject::tr( "Business Zip" ) ); | 912 | list.append( QObject::tr( "Business Zip" ) ); |
913 | list.append( QObject::tr( "Business Country" ) ); | 913 | list.append( QObject::tr( "Business Country" ) ); |
914 | list.append( QObject::tr( "Business Pager" ) ); | 914 | list.append( QObject::tr( "Business Pager" ) ); |
915 | list.append( QObject::tr( "Business WebPage" ) ); | 915 | list.append( QObject::tr( "Business WebPage" ) ); |
916 | 916 | ||
917 | list.append( QObject::tr( "Office" ) ); | 917 | list.append( QObject::tr( "Office" ) ); |
918 | list.append( QObject::tr( "Profession" ) ); | 918 | list.append( QObject::tr( "Profession" ) ); |
919 | list.append( QObject::tr( "Assistant" ) ); | 919 | list.append( QObject::tr( "Assistant" ) ); |
920 | list.append( QObject::tr( "Manager" ) ); | 920 | list.append( QObject::tr( "Manager" ) ); |
921 | 921 | ||
922 | list.append( QObject::tr( "Home Street" ) ); | 922 | list.append( QObject::tr( "Home Street" ) ); |
923 | list.append( QObject::tr( "Home City" ) ); | 923 | list.append( QObject::tr( "Home City" ) ); |
924 | list.append( QObject::tr( "Home State" ) ); | 924 | list.append( QObject::tr( "Home State" ) ); |
925 | list.append( QObject::tr( "Home Zip" ) ); | 925 | list.append( QObject::tr( "Home Zip" ) ); |
926 | list.append( QObject::tr( "Home Country" ) ); | 926 | list.append( QObject::tr( "Home Country" ) ); |
927 | list.append( QObject::tr( "Home Web Page" ) ); | 927 | list.append( QObject::tr( "Home Web Page" ) ); |
928 | 928 | ||
929 | list.append( QObject::tr( "Spouse" ) ); | 929 | list.append( QObject::tr( "Spouse" ) ); |
930 | list.append( QObject::tr( "Gender" ) ); | 930 | list.append( QObject::tr( "Gender" ) ); |
931 | list.append( QObject::tr( "Birthday" ) ); | 931 | list.append( QObject::tr( "Birthday" ) ); |
932 | list.append( QObject::tr( "Anniversary" ) ); | 932 | list.append( QObject::tr( "Anniversary" ) ); |
933 | list.append( QObject::tr( "Nickname" ) ); | 933 | list.append( QObject::tr( "Nickname" ) ); |
934 | list.append( QObject::tr( "Children" ) ); | 934 | list.append( QObject::tr( "Children" ) ); |
935 | 935 | ||
936 | list.append( QObject::tr( "Notes" ) ); | 936 | list.append( QObject::tr( "Notes" ) ); |
937 | list.append( QObject::tr( "Groups" ) ); | 937 | list.append( QObject::tr( "Groups" ) ); |
938 | 938 | ||
939 | return list; | 939 | return list; |
940 | } | 940 | } |
941 | 941 | ||
942 | /*! | 942 | /*! |
943 | \internal | 943 | \internal |
944 | Returns an untranslated list of field names for a contact. | 944 | Returns an untranslated list of field names for a contact. |
945 | */ | 945 | */ |
946 | QStringList OContact::untrfields() | 946 | QStringList OContact::untrfields() |
947 | { | 947 | { |
948 | QStringList list; | 948 | QStringList list; |
949 | 949 | ||
950 | list.append( "Name Title" ); | 950 | list.append( "Name Title" ); |
951 | list.append( "First Name" ); | 951 | list.append( "First Name" ); |
952 | list.append( "Middle Name" ); | 952 | list.append( "Middle Name" ); |
953 | list.append( "Last Name" ); | 953 | list.append( "Last Name" ); |
954 | list.append( "Suffix" ); | 954 | list.append( "Suffix" ); |
955 | list.append( "File As" ); | 955 | list.append( "File As" ); |
956 | 956 | ||
957 | list.append( "Job Title" ); | 957 | list.append( "Job Title" ); |
958 | list.append( "Department" ); | 958 | list.append( "Department" ); |
959 | list.append( "Company" ); | 959 | list.append( "Company" ); |
960 | list.append( "Business Phone" ); | 960 | list.append( "Business Phone" ); |
961 | list.append( "Business Fax" ); | 961 | list.append( "Business Fax" ); |
962 | list.append( "Business Mobile" ); | 962 | list.append( "Business Mobile" ); |
963 | 963 | ||
964 | list.append( "Default Email" ); | 964 | list.append( "Default Email" ); |
965 | list.append( "Emails" ); | 965 | list.append( "Emails" ); |
966 | 966 | ||
967 | list.append( "Home Phone" ); | 967 | list.append( "Home Phone" ); |
968 | list.append( "Home Fax" ); | 968 | list.append( "Home Fax" ); |
969 | list.append( "Home Mobile" ); | 969 | list.append( "Home Mobile" ); |
970 | 970 | ||
971 | list.append( "Business Street" ); | 971 | list.append( "Business Street" ); |
972 | list.append( "Business City" ); | 972 | list.append( "Business City" ); |
973 | list.append( "Business State" ); | 973 | list.append( "Business State" ); |
974 | list.append( "Business Zip" ); | 974 | list.append( "Business Zip" ); |
975 | list.append( "Business Country" ); | 975 | list.append( "Business Country" ); |
976 | list.append( "Business Pager" ); | 976 | list.append( "Business Pager" ); |
977 | list.append( "Business WebPage" ); | 977 | list.append( "Business WebPage" ); |
978 | 978 | ||
979 | list.append( "Office" ); | 979 | list.append( "Office" ); |
980 | list.append( "Profession" ); | 980 | list.append( "Profession" ); |
981 | list.append( "Assistant" ); | 981 | list.append( "Assistant" ); |
982 | list.append( "Manager" ); | 982 | list.append( "Manager" ); |
983 | 983 | ||
984 | list.append( "Home Street" ); | 984 | list.append( "Home Street" ); |
985 | list.append( "Home City" ); | 985 | list.append( "Home City" ); |
986 | list.append( "Home State" ); | 986 | list.append( "Home State" ); |
987 | list.append( "Home Zip" ); | 987 | list.append( "Home Zip" ); |
988 | list.append( "Home Country" ); | 988 | list.append( "Home Country" ); |
989 | list.append( "Home Web Page" ); | 989 | list.append( "Home Web Page" ); |
990 | 990 | ||
991 | list.append( "Spouse" ); | 991 | list.append( "Spouse" ); |
992 | list.append( "Gender" ); | 992 | list.append( "Gender" ); |
993 | list.append( "Birthday" ); | 993 | list.append( "Birthday" ); |
994 | list.append( "Anniversary" ); | 994 | list.append( "Anniversary" ); |
995 | list.append( "Nickname" ); | 995 | list.append( "Nickname" ); |
996 | list.append( "Children" ); | 996 | list.append( "Children" ); |
997 | 997 | ||
998 | list.append( "Notes" ); | 998 | list.append( "Notes" ); |
999 | list.append( "Groups" ); | 999 | list.append( "Groups" ); |
1000 | 1000 | ||
1001 | return list; | 1001 | return list; |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | /*! | 1004 | /*! |
1005 | Sets the list of email address for contact to those contained in \a str. | 1005 | Sets the list of email address for contact to those contained in \a str. |
1006 | Email address should be separated by ';'s. | 1006 | Email address should be separated by ';'s. |
1007 | */ | 1007 | */ |
1008 | void OContact::setEmails( const QString &str ) | 1008 | void OContact::setEmails( const QString &str ) |
1009 | { | 1009 | { |
1010 | replace( Qtopia::Emails, str ); | 1010 | replace( Qtopia::Emails, str ); |
1011 | if ( str.isEmpty() ) | 1011 | if ( str.isEmpty() ) |
1012 | setDefaultEmail( QString::null ); | 1012 | setDefaultEmail( QString::null ); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | /*! | 1015 | /*! |
1016 | Sets the list of children for the contact to those contained in \a str. | 1016 | Sets the list of children for the contact to those contained in \a str. |
1017 | */ | 1017 | */ |
1018 | void OContact::setChildren( const QString &str ) | 1018 | void OContact::setChildren( const QString &str ) |
1019 | { | 1019 | { |
1020 | replace( Qtopia::Children, str ); | 1020 | replace( Qtopia::Children, str ); |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | // vcard conversion code | 1023 | // vcard conversion code |
1024 | /*! | 1024 | /*! |
1025 | \internal | 1025 | \internal |
1026 | */ | 1026 | */ |
1027 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 1027 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
1028 | { | 1028 | { |
1029 | VObject *ret = 0; | 1029 | VObject *ret = 0; |
1030 | if ( o && !value.isEmpty() ) | 1030 | if ( o && !value.isEmpty() ) |
1031 | ret = addPropValue( o, prop, value.latin1() ); | 1031 | ret = addPropValue( o, prop, value.latin1() ); |
1032 | return ret; | 1032 | return ret; |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | /*! | 1035 | /*! |
1036 | \internal | 1036 | \internal |
1037 | */ | 1037 | */ |
1038 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 1038 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
1039 | { | 1039 | { |
1040 | VObject *ret = 0; | 1040 | VObject *ret = 0; |
1041 | if ( o ) | 1041 | if ( o ) |
1042 | ret = addProp( o, prop ); | 1042 | ret = addProp( o, prop ); |
1043 | return ret; | 1043 | return ret; |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | /*! | 1046 | /*! |
1047 | \internal | 1047 | \internal |
1048 | */ | 1048 | */ |
1049 | static VObject *createVObject( const OContact &c ) | 1049 | static VObject *createVObject( const OContact &c ) |
1050 | { | 1050 | { |
1051 | VObject *vcard = newVObject( VCCardProp ); | 1051 | VObject *vcard = newVObject( VCCardProp ); |
1052 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 1052 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
1053 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 1053 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
1054 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 1054 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
1055 | 1055 | ||
1056 | // full name | 1056 | // full name |
1057 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 1057 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
1058 | 1058 | ||
1059 | // name properties | 1059 | // name properties |
1060 | VObject *name = safeAddProp( vcard, VCNameProp ); | 1060 | VObject *name = safeAddProp( vcard, VCNameProp ); |
1061 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 1061 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
1062 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 1062 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
1063 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 1063 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
1064 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 1064 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
1065 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 1065 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
1066 | 1066 | ||
1067 | // home properties | 1067 | // home properties |
1068 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 1068 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
1069 | safeAddProp( home_adr, VCHomeProp ); | 1069 | safeAddProp( home_adr, VCHomeProp ); |
1070 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 1070 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
1071 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 1071 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
1072 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 1072 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
1073 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 1073 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
1074 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 1074 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
1075 | 1075 | ||
1076 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 1076 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
1077 | safeAddProp( home_phone, VCHomeProp ); | 1077 | safeAddProp( home_phone, VCHomeProp ); |
1078 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 1078 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
1079 | safeAddProp( home_phone, VCHomeProp ); | 1079 | safeAddProp( home_phone, VCHomeProp ); |
1080 | safeAddProp( home_phone, VCCellularProp ); | 1080 | safeAddProp( home_phone, VCCellularProp ); |
1081 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); | 1081 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); |
1082 | safeAddProp( home_phone, VCHomeProp ); | 1082 | safeAddProp( home_phone, VCHomeProp ); |
1083 | safeAddProp( home_phone, VCFaxProp ); | 1083 | safeAddProp( home_phone, VCFaxProp ); |
1084 | 1084 | ||
1085 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); | 1085 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); |
1086 | safeAddProp( url, VCHomeProp ); | 1086 | safeAddProp( url, VCHomeProp ); |
1087 | 1087 | ||
1088 | // work properties | 1088 | // work properties |
1089 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); | 1089 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); |
1090 | safeAddProp( work_adr, VCWorkProp ); | 1090 | safeAddProp( work_adr, VCWorkProp ); |
1091 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); | 1091 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); |
1092 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); | 1092 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); |
1093 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); | 1093 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); |
1094 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); | 1094 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); |
1095 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); | 1095 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); |
1096 | 1096 | ||
1097 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); | 1097 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); |
1098 | safeAddProp( work_phone, VCWorkProp ); | 1098 | safeAddProp( work_phone, VCWorkProp ); |
1099 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); | 1099 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); |
1100 | safeAddProp( work_phone, VCWorkProp ); | 1100 | safeAddProp( work_phone, VCWorkProp ); |
1101 | safeAddProp( work_phone, VCCellularProp ); | 1101 | safeAddProp( work_phone, VCCellularProp ); |
1102 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 1102 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
1103 | safeAddProp( work_phone, VCWorkProp ); | 1103 | safeAddProp( work_phone, VCWorkProp ); |
1104 | safeAddProp( work_phone, VCFaxProp ); | 1104 | safeAddProp( work_phone, VCFaxProp ); |
1105 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 1105 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
1106 | safeAddProp( work_phone, VCWorkProp ); | 1106 | safeAddProp( work_phone, VCWorkProp ); |
1107 | safeAddProp( work_phone, VCPagerProp ); | 1107 | safeAddProp( work_phone, VCPagerProp ); |
1108 | 1108 | ||
1109 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 1109 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
1110 | safeAddProp( url, VCWorkProp ); | 1110 | safeAddProp( url, VCWorkProp ); |
1111 | 1111 | ||
1112 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 1112 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
1113 | safeAddProp( title, VCWorkProp ); | 1113 | safeAddProp( title, VCWorkProp ); |
1114 | 1114 | ||
1115 | 1115 | ||
1116 | QStringList emails = c.emailList(); | 1116 | QStringList emails = c.emailList(); |
1117 | emails.prepend( c.defaultEmail() ); | 1117 | emails.prepend( c.defaultEmail() ); |
1118 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 1118 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
1119 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 1119 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
1120 | safeAddProp( email, VCInternetProp ); | 1120 | safeAddProp( email, VCInternetProp ); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 1123 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
1124 | 1124 | ||
1125 | safeAddPropValue( vcard, VCBirthDateProp, TimeConversion::toString( c.birthday() ) ); | 1125 | // Exporting Birthday regarding RFC 2425 (5.8.4) |
1126 | if ( !c.birthday().isNull() ){ | ||
1127 | QString birthd_rfc2425 = c.birthday().year() + QString( "-" ) + c.birthday().month() + QString( "-" ) + c.birthday().day(); | ||
1128 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); | ||
1129 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); | ||
1130 | } | ||
1126 | 1131 | ||
1127 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 1132 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
1128 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 1133 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
1129 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 1134 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
1130 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 1135 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
1131 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 1136 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
1132 | } | 1137 | } |
1133 | 1138 | ||
1134 | // some values we have to export as custom fields | 1139 | // some values we have to export as custom fields |
1135 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 1140 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
1136 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 1141 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
1137 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 1142 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
1138 | 1143 | ||
1139 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 1144 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
1140 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 1145 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
1141 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); | 1146 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); |
1142 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 1147 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
1143 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 1148 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
1144 | 1149 | ||
1145 | return vcard; | 1150 | return vcard; |
1146 | } | 1151 | } |
1147 | 1152 | ||
1148 | 1153 | ||
1149 | /*! | 1154 | /*! |
1150 | \internal | 1155 | \internal |
1151 | */ | 1156 | */ |
1157 | static QDate convVCardDateToDate( const QString& datestr ) | ||
1158 | { | ||
1159 | int monthPos = datestr.find('-'); | ||
1160 | int dayPos = datestr.find('-', monthPos+1 ); | ||
1161 | if ( monthPos == -1 || dayPos == -1 ) { | ||
1162 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | ||
1163 | return QDate(); | ||
1164 | } | ||
1165 | int y = datestr.left( monthPos ).toInt(); | ||
1166 | int m = datestr.mid( monthPos+1, dayPos - monthPos - 1 ).toInt(); | ||
1167 | int d = datestr.mid( dayPos+1 ).toInt(); | ||
1168 | QDate date ( y,m,d ); | ||
1169 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); | ||
1170 | return date; | ||
1171 | } | ||
1172 | |||
1152 | static OContact parseVObject( VObject *obj ) | 1173 | static OContact parseVObject( VObject *obj ) |
1153 | { | 1174 | { |
1154 | OContact c; | 1175 | OContact c; |
1155 | 1176 | ||
1156 | VObjectIterator it; | 1177 | VObjectIterator it; |
1157 | initPropIterator( &it, obj ); | 1178 | initPropIterator( &it, obj ); |
1158 | while( moreIteration( &it ) ) { | 1179 | while( moreIteration( &it ) ) { |
1159 | VObject *o = nextVObject( &it ); | 1180 | VObject *o = nextVObject( &it ); |
1160 | QCString name = vObjectName( o ); | 1181 | QCString name = vObjectName( o ); |
1161 | QCString value = vObjectStringZValue( o ); | 1182 | QCString value = vObjectStringZValue( o ); |
1162 | if ( name == VCNameProp ) { | 1183 | if ( name == VCNameProp ) { |
1163 | VObjectIterator nit; | 1184 | VObjectIterator nit; |
1164 | initPropIterator( &nit, o ); | 1185 | initPropIterator( &nit, o ); |
1165 | while( moreIteration( &nit ) ) { | 1186 | while( moreIteration( &nit ) ) { |
1166 | VObject *o = nextVObject( &nit ); | 1187 | VObject *o = nextVObject( &nit ); |
1167 | QCString name = vObjectTypeInfo( o ); | 1188 | QCString name = vObjectTypeInfo( o ); |
1168 | QString value = vObjectStringZValue( o ); | 1189 | QString value = vObjectStringZValue( o ); |
1169 | if ( name == VCNamePrefixesProp ) | 1190 | if ( name == VCNamePrefixesProp ) |
1170 | c.setTitle( value ); | 1191 | c.setTitle( value ); |
1171 | else if ( name == VCNameSuffixesProp ) | 1192 | else if ( name == VCNameSuffixesProp ) |
1172 | c.setSuffix( value ); | 1193 | c.setSuffix( value ); |
1173 | else if ( name == VCFamilyNameProp ) | 1194 | else if ( name == VCFamilyNameProp ) |
1174 | c.setLastName( value ); | 1195 | c.setLastName( value ); |
1175 | else if ( name == VCGivenNameProp ) | 1196 | else if ( name == VCGivenNameProp ) |
1176 | c.setFirstName( value ); | 1197 | c.setFirstName( value ); |
1177 | else if ( name == VCAdditionalNamesProp ) | 1198 | else if ( name == VCAdditionalNamesProp ) |
1178 | c.setMiddleName( value ); | 1199 | c.setMiddleName( value ); |
1179 | } | 1200 | } |
1180 | } | 1201 | } |
1181 | else if ( name == VCAdrProp ) { | 1202 | else if ( name == VCAdrProp ) { |
1182 | bool work = TRUE; // default address is work address | 1203 | bool work = TRUE; // default address is work address |
1183 | QString street; | 1204 | QString street; |
1184 | QString city; | 1205 | QString city; |
1185 | QString region; | 1206 | QString region; |
1186 | QString postal; | 1207 | QString postal; |
1187 | QString country; | 1208 | QString country; |
1188 | 1209 | ||
1189 | VObjectIterator nit; | 1210 | VObjectIterator nit; |
1190 | initPropIterator( &nit, o ); | 1211 | initPropIterator( &nit, o ); |
1191 | while( moreIteration( &nit ) ) { | 1212 | while( moreIteration( &nit ) ) { |
1192 | VObject *o = nextVObject( &nit ); | 1213 | VObject *o = nextVObject( &nit ); |
1193 | QCString name = vObjectName( o ); | 1214 | QCString name = vObjectName( o ); |
1194 | QString value = vObjectStringZValue( o ); | 1215 | QString value = vObjectStringZValue( o ); |
1195 | if ( name == VCHomeProp ) | 1216 | if ( name == VCHomeProp ) |
1196 | work = FALSE; | 1217 | work = FALSE; |
1197 | else if ( name == VCWorkProp ) | 1218 | else if ( name == VCWorkProp ) |
1198 | work = TRUE; | 1219 | work = TRUE; |
1199 | else if ( name == VCStreetAddressProp ) | 1220 | else if ( name == VCStreetAddressProp ) |
1200 | street = value; | 1221 | street = value; |
1201 | else if ( name == VCCityProp ) | 1222 | else if ( name == VCCityProp ) |
1202 | city = value; | 1223 | city = value; |
1203 | else if ( name == VCRegionProp ) | 1224 | else if ( name == VCRegionProp ) |
1204 | region = value; | 1225 | region = value; |
1205 | else if ( name == VCPostalCodeProp ) | 1226 | else if ( name == VCPostalCodeProp ) |
1206 | postal = value; | 1227 | postal = value; |
1207 | else if ( name == VCCountryNameProp ) | 1228 | else if ( name == VCCountryNameProp ) |
1208 | country = value; | 1229 | country = value; |
1209 | } | 1230 | } |
1210 | if ( work ) { | 1231 | if ( work ) { |
1211 | c.setBusinessStreet( street ); | 1232 | c.setBusinessStreet( street ); |
1212 | c.setBusinessCity( city ); | 1233 | c.setBusinessCity( city ); |
1213 | c.setBusinessCountry( country ); | 1234 | c.setBusinessCountry( country ); |
1214 | c.setBusinessZip( postal ); | 1235 | c.setBusinessZip( postal ); |
1215 | c.setBusinessState( region ); | 1236 | c.setBusinessState( region ); |
1216 | } else { | 1237 | } else { |
1217 | c.setHomeStreet( street ); | 1238 | c.setHomeStreet( street ); |
1218 | c.setHomeCity( city ); | 1239 | c.setHomeCity( city ); |
1219 | c.setHomeCountry( country ); | 1240 | c.setHomeCountry( country ); |
1220 | c.setHomeZip( postal ); | 1241 | c.setHomeZip( postal ); |
1221 | c.setHomeState( region ); | 1242 | c.setHomeState( region ); |
1222 | } | 1243 | } |
1223 | } | 1244 | } |
1224 | else if ( name == VCTelephoneProp ) { | 1245 | else if ( name == VCTelephoneProp ) { |
1225 | enum { | 1246 | enum { |
1226 | HOME = 0x01, | 1247 | HOME = 0x01, |
1227 | WORK = 0x02, | 1248 | WORK = 0x02, |
1228 | VOICE = 0x04, | 1249 | VOICE = 0x04, |
1229 | CELL = 0x08, | 1250 | CELL = 0x08, |
1230 | FAX = 0x10, | 1251 | FAX = 0x10, |
1231 | PAGER = 0x20, | 1252 | PAGER = 0x20, |
1232 | UNKNOWN = 0x80 | 1253 | UNKNOWN = 0x80 |
1233 | }; | 1254 | }; |
1234 | int type = 0; | 1255 | int type = 0; |
1235 | 1256 | ||
1236 | VObjectIterator nit; | 1257 | VObjectIterator nit; |
1237 | initPropIterator( &nit, o ); | 1258 | initPropIterator( &nit, o ); |
1238 | while( moreIteration( &nit ) ) { | 1259 | while( moreIteration( &nit ) ) { |
1239 | VObject *o = nextVObject( &nit ); | 1260 | VObject *o = nextVObject( &nit ); |
1240 | QCString name = vObjectTypeInfo( o ); | 1261 | QCString name = vObjectTypeInfo( o ); |
1241 | if ( name == VCHomeProp ) | 1262 | if ( name == VCHomeProp ) |
1242 | type |= HOME; | 1263 | type |= HOME; |
1243 | else if ( name == VCWorkProp ) | 1264 | else if ( name == VCWorkProp ) |
1244 | type |= WORK; | 1265 | type |= WORK; |
1245 | else if ( name == VCVoiceProp ) | 1266 | else if ( name == VCVoiceProp ) |
1246 | type |= VOICE; | 1267 | type |= VOICE; |
1247 | else if ( name == VCCellularProp ) | 1268 | else if ( name == VCCellularProp ) |
1248 | type |= CELL; | 1269 | type |= CELL; |
1249 | else if ( name == VCFaxProp ) | 1270 | else if ( name == VCFaxProp ) |
1250 | type |= FAX; | 1271 | type |= FAX; |
1251 | else if ( name == VCPagerProp ) | 1272 | else if ( name == VCPagerProp ) |
1252 | type |= PAGER; | 1273 | type |= PAGER; |
1253 | else if ( name == VCPreferredProp ) | 1274 | else if ( name == VCPreferredProp ) |
1254 | ; | 1275 | ; |
1255 | else | 1276 | else |
1256 | type |= UNKNOWN; | 1277 | type |= UNKNOWN; |
1257 | } | 1278 | } |
1258 | if ( (type & UNKNOWN) != UNKNOWN ) { | 1279 | if ( (type & UNKNOWN) != UNKNOWN ) { |
1259 | if ( ( type & (HOME|WORK) ) == 0 ) // default | 1280 | if ( ( type & (HOME|WORK) ) == 0 ) // default |
1260 | type |= HOME; | 1281 | type |= HOME; |
1261 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default | 1282 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default |
1262 | type |= VOICE; | 1283 | type |= VOICE; |
1263 | 1284 | ||
1264 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) | 1285 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) |
1265 | c.setHomePhone( value ); | 1286 | c.setHomePhone( value ); |
1266 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) | 1287 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) |
1267 | c.setHomeFax( value ); | 1288 | c.setHomeFax( value ); |
1268 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) | 1289 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) |
1269 | c.setHomeMobile( value ); | 1290 | c.setHomeMobile( value ); |
1270 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) | 1291 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) |
1271 | c.setBusinessPhone( value ); | 1292 | c.setBusinessPhone( value ); |
1272 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) | 1293 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) |
1273 | c.setBusinessFax( value ); | 1294 | c.setBusinessFax( value ); |
1274 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) | 1295 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) |
1275 | c.setBusinessMobile( value ); | 1296 | c.setBusinessMobile( value ); |
1276 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) | 1297 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) |
1277 | c.setBusinessPager( value ); | 1298 | c.setBusinessPager( value ); |
1278 | } | 1299 | } |
1279 | } | 1300 | } |
1280 | else if ( name == VCEmailAddressProp ) { | 1301 | else if ( name == VCEmailAddressProp ) { |
1281 | QString email = vObjectStringZValue( o ); | 1302 | QString email = vObjectStringZValue( o ); |
1282 | bool valid = TRUE; | 1303 | bool valid = TRUE; |
1283 | VObjectIterator nit; | 1304 | VObjectIterator nit; |
1284 | initPropIterator( &nit, o ); | 1305 | initPropIterator( &nit, o ); |
1285 | while( moreIteration( &nit ) ) { | 1306 | while( moreIteration( &nit ) ) { |
1286 | VObject *o = nextVObject( &nit ); | 1307 | VObject *o = nextVObject( &nit ); |
1287 | QCString name = vObjectTypeInfo( o ); | 1308 | QCString name = vObjectTypeInfo( o ); |
1288 | if ( name != VCInternetProp && name != VCHomeProp && | 1309 | if ( name != VCInternetProp && name != VCHomeProp && |
1289 | name != VCWorkProp && | 1310 | name != VCWorkProp && |
1290 | name != VCPreferredProp ) | 1311 | name != VCPreferredProp ) |
1291 | // ### preffered should map to default email | 1312 | // ### preffered should map to default email |
1292 | valid = FALSE; | 1313 | valid = FALSE; |
1293 | } | 1314 | } |
1294 | if ( valid ) { | 1315 | if ( valid ) { |
1295 | c.insertEmail( email ); | 1316 | c.insertEmail( email ); |
1296 | } | 1317 | } |
1297 | } | 1318 | } |
1298 | else if ( name == VCURLProp ) { | 1319 | else if ( name == VCURLProp ) { |
1299 | VObjectIterator nit; | 1320 | VObjectIterator nit; |
1300 | initPropIterator( &nit, o ); | 1321 | initPropIterator( &nit, o ); |
1301 | while( moreIteration( &nit ) ) { | 1322 | while( moreIteration( &nit ) ) { |
1302 | VObject *o = nextVObject( &nit ); | 1323 | VObject *o = nextVObject( &nit ); |
1303 | QCString name = vObjectTypeInfo( o ); | 1324 | QCString name = vObjectTypeInfo( o ); |
1304 | if ( name == VCHomeProp ) | 1325 | if ( name == VCHomeProp ) |
1305 | c.setHomeWebpage( value ); | 1326 | c.setHomeWebpage( value ); |
1306 | else if ( name == VCWorkProp ) | 1327 | else if ( name == VCWorkProp ) |
1307 | c.setBusinessWebpage( value ); | 1328 | c.setBusinessWebpage( value ); |
1308 | } | 1329 | } |
1309 | } | 1330 | } |
1310 | else if ( name == VCOrgProp ) { | 1331 | else if ( name == VCOrgProp ) { |
1311 | VObjectIterator nit; | 1332 | VObjectIterator nit; |
1312 | initPropIterator( &nit, o ); | 1333 | initPropIterator( &nit, o ); |
1313 | while( moreIteration( &nit ) ) { | 1334 | while( moreIteration( &nit ) ) { |
1314 | VObject *o = nextVObject( &nit ); | 1335 | VObject *o = nextVObject( &nit ); |
1315 | QCString name = vObjectName( o ); | 1336 | QCString name = vObjectName( o ); |
1316 | QString value = vObjectStringZValue( o ); | 1337 | QString value = vObjectStringZValue( o ); |
1317 | if ( name == VCOrgNameProp ) | 1338 | if ( name == VCOrgNameProp ) |
1318 | c.setCompany( value ); | 1339 | c.setCompany( value ); |
1319 | else if ( name == VCOrgUnitProp ) | 1340 | else if ( name == VCOrgUnitProp ) |
1320 | c.setDepartment( value ); | 1341 | c.setDepartment( value ); |
1321 | else if ( name == VCOrgUnit2Prop ) | 1342 | else if ( name == VCOrgUnit2Prop ) |
1322 | c.setOffice( value ); | 1343 | c.setOffice( value ); |
1323 | } | 1344 | } |
1324 | } | 1345 | } |
1325 | else if ( name == VCTitleProp ) { | 1346 | else if ( name == VCTitleProp ) { |
1326 | c.setJobTitle( value ); | 1347 | c.setJobTitle( value ); |
1327 | } | 1348 | } |
1328 | else if ( name == "X-Qtopia-Profession" ) { | 1349 | else if ( name == "X-Qtopia-Profession" ) { |
1329 | c.setProfession( value ); | 1350 | c.setProfession( value ); |
1330 | } | 1351 | } |
1331 | else if ( name == "X-Qtopia-Manager" ) { | 1352 | else if ( name == "X-Qtopia-Manager" ) { |
1332 | c.setManager( value ); | 1353 | c.setManager( value ); |
1333 | } | 1354 | } |
1334 | else if ( name == "X-Qtopia-Assistant" ) { | 1355 | else if ( name == "X-Qtopia-Assistant" ) { |
1335 | c.setAssistant( value ); | 1356 | c.setAssistant( value ); |
1336 | } | 1357 | } |
1337 | else if ( name == "X-Qtopia-Spouse" ) { | 1358 | else if ( name == "X-Qtopia-Spouse" ) { |
1338 | c.setSpouse( value ); | 1359 | c.setSpouse( value ); |
1339 | } | 1360 | } |
1340 | else if ( name == "X-Qtopia-Gender" ) { | 1361 | else if ( name == "X-Qtopia-Gender" ) { |
1341 | c.setGender( value ); | 1362 | c.setGender( value ); |
1342 | } | 1363 | } |
1343 | else if ( name == "X-Qtopia-Anniversary" ) { | 1364 | else if ( name == "X-Qtopia-Anniversary" ) { |
1344 | c.setAnniversary( TimeConversion::fromString( value ) ); | 1365 | c.setAnniversary( TimeConversion::fromString( value ) ); |
1345 | } | 1366 | } |
1346 | else if ( name == "X-Qtopia-Nickname" ) { | 1367 | else if ( name == "X-Qtopia-Nickname" ) { |
1347 | c.setNickname( value ); | 1368 | c.setNickname( value ); |
1348 | } | 1369 | } |
1349 | else if ( name == "X-Qtopia-Children" ) { | 1370 | else if ( name == "X-Qtopia-Children" ) { |
1350 | c.setChildren( value ); | 1371 | c.setChildren( value ); |
1372 | } | ||
1373 | else if ( name == VCBirthDateProp ) { | ||
1374 | // Reading Birthdate regarding RFC 2425 (5.8.4) | ||
1375 | c.setBirthday( convVCardDateToDate( value ) ); | ||
1376 | |||
1351 | } | 1377 | } |
1352 | 1378 | ||
1353 | |||
1354 | #if 0 | 1379 | #if 0 |
1355 | else { | 1380 | else { |
1356 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 1381 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
1357 | VObjectIterator nit; | 1382 | VObjectIterator nit; |
1358 | initPropIterator( &nit, o ); | 1383 | initPropIterator( &nit, o ); |
1359 | while( moreIteration( &nit ) ) { | 1384 | while( moreIteration( &nit ) ) { |
1360 | VObject *o = nextVObject( &nit ); | 1385 | VObject *o = nextVObject( &nit ); |
1361 | QCString name = vObjectName( o ); | 1386 | QCString name = vObjectName( o ); |
1362 | QString value = vObjectStringZValue( o ); | 1387 | QString value = vObjectStringZValue( o ); |
1363 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 1388 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
1364 | } | 1389 | } |
1365 | } | 1390 | } |
1366 | #endif | 1391 | #endif |
1367 | } | 1392 | } |
1368 | c.setFileAs(); | 1393 | c.setFileAs(); |
1369 | return c; | 1394 | return c; |
1370 | } | 1395 | } |
1371 | 1396 | ||
1372 | /*! | 1397 | /*! |
1373 | Writes the list of \a contacts as a set of VCards to the file \a filename. | 1398 | Writes the list of \a contacts as a set of VCards to the file \a filename. |
1374 | */ | 1399 | */ |
1375 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) | 1400 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) |
1376 | { | 1401 | { |
1377 | QFileDirect f( filename.utf8().data() ); | 1402 | QFileDirect f( filename.utf8().data() ); |
1378 | if ( !f.open( IO_WriteOnly ) ) { | 1403 | if ( !f.open( IO_WriteOnly ) ) { |
1379 | qWarning("Unable to open vcard write"); | 1404 | qWarning("Unable to open vcard write"); |
1380 | return; | 1405 | return; |
1381 | } | 1406 | } |
1382 | 1407 | ||
1383 | QValueList<OContact>::ConstIterator it; | 1408 | QValueList<OContact>::ConstIterator it; |
1384 | for( it = contacts.begin(); it != contacts.end(); ++it ) { | 1409 | for( it = contacts.begin(); it != contacts.end(); ++it ) { |
1385 | VObject *obj = createVObject( *it ); | 1410 | VObject *obj = createVObject( *it ); |
1386 | writeVObject(f.directHandle() , obj ); | 1411 | writeVObject(f.directHandle() , obj ); |
1387 | cleanVObject( obj ); | 1412 | cleanVObject( obj ); |
1388 | } | 1413 | } |
1389 | cleanStrTbl(); | 1414 | cleanStrTbl(); |
1390 | } | 1415 | } |
1391 | 1416 | ||
1392 | /*! | 1417 | /*! |
1393 | writes \a contact as a VCard to the file \a filename. | 1418 | writes \a contact as a VCard to the file \a filename. |
1394 | */ | 1419 | */ |
1395 | void OContact::writeVCard( const QString &filename, const OContact &contact) | 1420 | void OContact::writeVCard( const QString &filename, const OContact &contact) |
1396 | { | 1421 | { |
1397 | QFileDirect f( filename.utf8().data() ); | 1422 | QFileDirect f( filename.utf8().data() ); |
1398 | if ( !f.open( IO_WriteOnly ) ) { | 1423 | if ( !f.open( IO_WriteOnly ) ) { |
1399 | qWarning("Unable to open vcard write"); | 1424 | qWarning("Unable to open vcard write"); |
1400 | return; | 1425 | return; |
1401 | } | 1426 | } |
1402 | 1427 | ||
1403 | VObject *obj = createVObject( contact ); | 1428 | VObject *obj = createVObject( contact ); |
1404 | writeVObject( f.directHandle() , obj ); | 1429 | writeVObject( f.directHandle() , obj ); |
1405 | cleanVObject( obj ); | 1430 | cleanVObject( obj ); |
1406 | 1431 | ||
1407 | cleanStrTbl(); | 1432 | cleanStrTbl(); |
1408 | } | 1433 | } |
1409 | 1434 | ||
1410 | /*! | 1435 | /*! |
1411 | Returns the set of contacts read as VCards from the file \a filename. | 1436 | Returns the set of contacts read as VCards from the file \a filename. |
1412 | */ | 1437 | */ |
1413 | QValueList<OContact> OContact::readVCard( const QString &filename ) | 1438 | QValueList<OContact> OContact::readVCard( const QString &filename ) |
1414 | { | 1439 | { |
1415 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 1440 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
1416 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 1441 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
1417 | 1442 | ||
1418 | qDebug("vobject = %p", obj ); | 1443 | qDebug("vobject = %p", obj ); |
1419 | 1444 | ||
1420 | QValueList<OContact> contacts; | 1445 | QValueList<OContact> contacts; |
1421 | 1446 | ||
1422 | while ( obj ) { | 1447 | while ( obj ) { |
1423 | contacts.append( parseVObject( obj ) ); | 1448 | contacts.append( parseVObject( obj ) ); |
1424 | 1449 | ||
1425 | VObject *t = obj; | 1450 | VObject *t = obj; |
1426 | obj = nextVObjectInList(obj); | 1451 | obj = nextVObjectInList(obj); |
1427 | cleanVObject( t ); | 1452 | cleanVObject( t ); |
1428 | } | 1453 | } |
1429 | 1454 | ||
1430 | return contacts; | 1455 | return contacts; |
1431 | } | 1456 | } |
1432 | 1457 | ||
1433 | /*! | 1458 | /*! |
1434 | Returns TRUE if the contact matches the regular expression \a regexp. | 1459 | Returns TRUE if the contact matches the regular expression \a regexp. |
1435 | Otherwise returns FALSE. | 1460 | Otherwise returns FALSE. |
1436 | */ | 1461 | */ |
1437 | bool OContact::match( const QString ®exp ) const | 1462 | bool OContact::match( const QString ®exp ) const |
1438 | { | 1463 | { |
1439 | return match(QRegExp(regexp)); | 1464 | return match(QRegExp(regexp)); |
1440 | } | 1465 | } |
1441 | 1466 | ||
1442 | /*! | 1467 | /*! |
1443 | \overload | 1468 | \overload |
1444 | Returns TRUE if the contact matches the regular expression \a regexp. | 1469 | Returns TRUE if the contact matches the regular expression \a regexp. |
1445 | Otherwise returns FALSE. | 1470 | Otherwise returns FALSE. |
1446 | */ | 1471 | */ |
1447 | bool OContact::match( const QRegExp &r ) const | 1472 | bool OContact::match( const QRegExp &r ) const |
1448 | { | 1473 | { |
1449 | bool match; | 1474 | bool match; |
1450 | match = false; | 1475 | match = false; |
1451 | QMap<int, QString>::ConstIterator it; | 1476 | QMap<int, QString>::ConstIterator it; |
1452 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 1477 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
1453 | if ( (*it).find( r ) > -1 ) { | 1478 | if ( (*it).find( r ) > -1 ) { |
1454 | match = true; | 1479 | match = true; |
1455 | break; | 1480 | break; |
1456 | } | 1481 | } |
1457 | } | 1482 | } |
1458 | return match; | 1483 | return match; |
1459 | } | 1484 | } |
1460 | 1485 | ||
1461 | 1486 | ||
1462 | QString OContact::toShortText() const | 1487 | QString OContact::toShortText() const |
1463 | { | 1488 | { |
1464 | return ( fullName() ); | 1489 | return ( fullName() ); |
1465 | } | 1490 | } |
1466 | QString OContact::type() const | 1491 | QString OContact::type() const |
1467 | { | 1492 | { |
1468 | return QString::fromLatin1( "OContact" ); | 1493 | return QString::fromLatin1( "OContact" ); |
1469 | } | 1494 | } |
1470 | 1495 | ||
1471 | // Definition is missing ! (se) | 1496 | // Definition is missing ! (se) |
1472 | QMap<QString,QString> OContact::toExtraMap() const | 1497 | QMap<QString,QString> OContact::toExtraMap() const |
1473 | { | 1498 | { |
1474 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 1499 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
1475 | QMap <QString,QString> useless; | 1500 | QMap <QString,QString> useless; |
1476 | return useless; | 1501 | return useless; |
1477 | } | 1502 | } |
1478 | 1503 | ||
1479 | class QString OContact::recordField( int pos ) const | 1504 | class QString OContact::recordField( int pos ) const |
1480 | { | 1505 | { |
1481 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 1506 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
1482 | return SLFIELDS[pos]; | 1507 | return SLFIELDS[pos]; |
1483 | } | 1508 | } |
1484 | 1509 | ||
1485 | // In future releases, we should store birthday and anniversary | 1510 | // In future releases, we should store birthday and anniversary |
1486 | // internally as QDate instead of QString ! | 1511 | // internally as QDate instead of QString ! |
1487 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1512 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1488 | 1513 | ||
1489 | /*! \fn void OContact::setBirthday( const QDate& date ) | 1514 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1490 | Sets the birthday for the contact to \a date. | 1515 | Sets the birthday for the contact to \a date. |
1491 | */ | 1516 | */ |
1492 | void OContact::setBirthday( const QDate &v ) | 1517 | void OContact::setBirthday( const QDate &v ) |
1493 | { | 1518 | { |
1494 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1519 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1495 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); | 1520 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); |
1496 | 1521 | ||
1497 | } | 1522 | } |
1498 | 1523 | ||
1499 | 1524 | ||
1500 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1525 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1501 | Sets the anniversary of the contact to \a date. | 1526 | Sets the anniversary of the contact to \a date. |
1502 | */ | 1527 | */ |
1503 | void OContact::setAnniversary( const QDate &v ) | 1528 | void OContact::setAnniversary( const QDate &v ) |
1504 | { | 1529 | { |
1505 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1530 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1506 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); | 1531 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); |
1507 | } | 1532 | } |
1508 | 1533 | ||
1509 | /*! \fn QDate OContact::birthday() const | 1534 | /*! \fn QDate OContact::birthday() const |
1510 | Returns the birthday of the contact. | 1535 | Returns the birthday of the contact. |
1511 | */ | 1536 | */ |
1512 | QDate OContact::birthday() const | 1537 | QDate OContact::birthday() const |
1513 | { | 1538 | { |
1514 | QDate empty; | 1539 | QDate empty; |
1515 | QString str = find( Qtopia::Birthday ); | 1540 | QString str = find( Qtopia::Birthday ); |
1516 | qWarning ("Birthday %s", str.latin1() ); | 1541 | qWarning ("Birthday %s", str.latin1() ); |
1517 | if ( !str.isEmpty() ) | 1542 | if ( !str.isEmpty() ) |
1518 | return TimeConversion::fromString ( str ); | 1543 | return TimeConversion::fromString ( str ); |
1519 | else | 1544 | else |
1520 | return empty; | 1545 | return empty; |
1521 | } | 1546 | } |
1522 | 1547 | ||
1523 | 1548 | ||
1524 | /*! \fn QDate OContact::anniversary() const | 1549 | /*! \fn QDate OContact::anniversary() const |
1525 | Returns the anniversary of the contact. | 1550 | Returns the anniversary of the contact. |
1526 | */ | 1551 | */ |
1527 | QDate OContact::anniversary() const | 1552 | QDate OContact::anniversary() const |
1528 | { | 1553 | { |
1529 | QDate empty; | 1554 | QDate empty; |
1530 | QString str = find( Qtopia::Anniversary ); | 1555 | QString str = find( Qtopia::Anniversary ); |
1531 | qWarning ("Anniversary %s", str.latin1() ); | 1556 | qWarning ("Anniversary %s", str.latin1() ); |
1532 | if ( !str.isEmpty() ) | 1557 | if ( !str.isEmpty() ) |
1533 | return TimeConversion::fromString ( str ); | 1558 | return TimeConversion::fromString ( str ); |
1534 | else | 1559 | else |
1535 | return empty; | 1560 | return empty; |
1536 | } | 1561 | } |
1537 | 1562 | ||
1538 | 1563 | ||
1539 | void OContact::insertEmail( const QString &v ) | 1564 | void OContact::insertEmail( const QString &v ) |
1540 | { | 1565 | { |
1541 | //qDebug("insertEmail %s", v.latin1()); | 1566 | //qDebug("insertEmail %s", v.latin1()); |
1542 | QString e = v.simplifyWhiteSpace(); | 1567 | QString e = v.simplifyWhiteSpace(); |
1543 | QString def = defaultEmail(); | 1568 | QString def = defaultEmail(); |
1544 | 1569 | ||
1545 | // if no default, set it as the default email and don't insert | 1570 | // if no default, set it as the default email and don't insert |
1546 | if ( def.isEmpty() ) { | 1571 | if ( def.isEmpty() ) { |
1547 | setDefaultEmail( e ); // will insert into the list for us | 1572 | setDefaultEmail( e ); // will insert into the list for us |
1548 | return; | 1573 | return; |
1549 | } | 1574 | } |
1550 | 1575 | ||
1551 | // otherwise, insert assuming doesn't already exist | 1576 | // otherwise, insert assuming doesn't already exist |
1552 | QString emailsStr = find( Qtopia::Emails ); | 1577 | QString emailsStr = find( Qtopia::Emails ); |
1553 | if ( emailsStr.contains( e )) | 1578 | if ( emailsStr.contains( e )) |
1554 | return; | 1579 | return; |
1555 | if ( !emailsStr.isEmpty() ) | 1580 | if ( !emailsStr.isEmpty() ) |
1556 | emailsStr += emailSeparator(); | 1581 | emailsStr += emailSeparator(); |
1557 | emailsStr += e; | 1582 | emailsStr += e; |
1558 | replace( Qtopia::Emails, emailsStr ); | 1583 | replace( Qtopia::Emails, emailsStr ); |
1559 | } | 1584 | } |
1560 | 1585 | ||
1561 | void OContact::removeEmail( const QString &v ) | 1586 | void OContact::removeEmail( const QString &v ) |
1562 | { | 1587 | { |
1563 | QString e = v.simplifyWhiteSpace(); | 1588 | QString e = v.simplifyWhiteSpace(); |
1564 | QString def = defaultEmail(); | 1589 | QString def = defaultEmail(); |
1565 | QString emailsStr = find( Qtopia::Emails ); | 1590 | QString emailsStr = find( Qtopia::Emails ); |
1566 | QStringList emails = emailList(); | 1591 | QStringList emails = emailList(); |
1567 | 1592 | ||
1568 | // otherwise, must first contain it | 1593 | // otherwise, must first contain it |
1569 | if ( !emailsStr.contains( e ) ) | 1594 | if ( !emailsStr.contains( e ) ) |
1570 | return; | 1595 | return; |
1571 | 1596 | ||
1572 | // remove it | 1597 | // remove it |
1573 | //qDebug(" removing email from list %s", e.latin1()); | 1598 | //qDebug(" removing email from list %s", e.latin1()); |
1574 | emails.remove( e ); | 1599 | emails.remove( e ); |
1575 | // reset the string | 1600 | // reset the string |
1576 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | 1601 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator |
1577 | replace( Qtopia::Emails, emailsStr ); | 1602 | replace( Qtopia::Emails, emailsStr ); |
1578 | 1603 | ||
1579 | // if default, then replace the default email with the first one | 1604 | // if default, then replace the default email with the first one |
1580 | if ( def == e ) { | 1605 | if ( def == e ) { |
1581 | //qDebug("removeEmail is default; setting new default"); | 1606 | //qDebug("removeEmail is default; setting new default"); |
1582 | if ( !emails.count() ) | 1607 | if ( !emails.count() ) |
1583 | clearEmails(); | 1608 | clearEmails(); |
1584 | else // setDefaultEmail will remove e from the list | 1609 | else // setDefaultEmail will remove e from the list |
1585 | setDefaultEmail( emails.first() ); | 1610 | setDefaultEmail( emails.first() ); |
1586 | } | 1611 | } |
1587 | } | 1612 | } |
1588 | void OContact::clearEmails() | 1613 | void OContact::clearEmails() |
1589 | { | 1614 | { |
1590 | mMap.remove( Qtopia::DefaultEmail ); | 1615 | mMap.remove( Qtopia::DefaultEmail ); |
1591 | mMap.remove( Qtopia::Emails ); | 1616 | mMap.remove( Qtopia::Emails ); |
1592 | } | 1617 | } |
1593 | void OContact::setDefaultEmail( const QString &v ) | 1618 | void OContact::setDefaultEmail( const QString &v ) |
1594 | { | 1619 | { |
1595 | QString e = v.simplifyWhiteSpace(); | 1620 | QString e = v.simplifyWhiteSpace(); |
1596 | 1621 | ||
1597 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | 1622 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); |
1598 | replace( Qtopia::DefaultEmail, e ); | 1623 | replace( Qtopia::DefaultEmail, e ); |
1599 | 1624 | ||
1600 | if ( !e.isEmpty() ) | 1625 | if ( !e.isEmpty() ) |
1601 | insertEmail( e ); | 1626 | insertEmail( e ); |
1602 | 1627 | ||
1603 | } | 1628 | } |
1604 | 1629 | ||
1605 | void OContact::insertEmails( const QStringList &v ) | 1630 | void OContact::insertEmails( const QStringList &v ) |
1606 | { | 1631 | { |
1607 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1632 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
1608 | insertEmail( *it ); | 1633 | insertEmail( *it ); |
1609 | } | 1634 | } |
1635 | |||
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index 9e83150..382ab94 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h | |||
@@ -1,245 +1,246 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Qtopia Environment. | 5 | ** This file is part of the Qtopia Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef __OCONTACT_H__ | 22 | #ifndef __OCONTACT_H__ |
23 | #define __OCONTACT_H__ | 23 | #define __OCONTACT_H__ |
24 | 24 | ||
25 | #include <opie/opimrecord.h> | 25 | #include <opie/opimrecord.h> |
26 | #include <qpe/recordfields.h> | 26 | #include <qpe/recordfields.h> |
27 | 27 | ||
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | 30 | ||
31 | #if defined(QPC_TEMPLATEDLL) | 31 | #if defined(QPC_TEMPLATEDLL) |
32 | // MOC_SKIP_BEGIN | 32 | // MOC_SKIP_BEGIN |
33 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; | 33 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
34 | // MOC_SKIP_END | 34 | // MOC_SKIP_END |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) | 37 | class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) |
38 | class QPC_EXPORT OContact : public OPimRecord | 38 | class QPC_EXPORT OContact : public OPimRecord |
39 | { | 39 | { |
40 | friend class DataSet; | 40 | friend class DataSet; |
41 | public: | 41 | public: |
42 | OContact(); | 42 | OContact(); |
43 | OContact( const QMap<int, QString> &fromMap ); | 43 | OContact( const QMap<int, QString> &fromMap ); |
44 | virtual ~OContact(); | 44 | virtual ~OContact(); |
45 | 45 | ||
46 | static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); | 46 | static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); |
47 | static void writeVCard( const QString &filename, const OContact &c ); | 47 | static void writeVCard( const QString &filename, const OContact &c ); |
48 | static QValueList<OContact> readVCard( const QString &filename ); | 48 | static QValueList<OContact> readVCard( const QString &filename ); |
49 | 49 | ||
50 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | 50 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; |
51 | 51 | ||
52 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 52 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
53 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 53 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
54 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 54 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
55 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 55 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
56 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 56 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
57 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 57 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
58 | void setFileAs(); | 58 | void setFileAs(); |
59 | 59 | ||
60 | // default email address | 60 | // default email address |
61 | void setDefaultEmail( const QString &v ); | 61 | void setDefaultEmail( const QString &v ); |
62 | // inserts email to list and ensure's doesn't already exist | 62 | // inserts email to list and ensure's doesn't already exist |
63 | void insertEmail( const QString &v ); | 63 | void insertEmail( const QString &v ); |
64 | void removeEmail( const QString &v ); | 64 | void removeEmail( const QString &v ); |
65 | void clearEmails(); | 65 | void clearEmails(); |
66 | void insertEmails( const QStringList &v ); | 66 | void insertEmails( const QStringList &v ); |
67 | 67 | ||
68 | // home | 68 | // home |
69 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 69 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
70 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 70 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
71 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 71 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
72 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 72 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
73 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 73 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
74 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 74 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
75 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 75 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
76 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 76 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
77 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 77 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
78 | 78 | ||
79 | // business | 79 | // business |
80 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 80 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
81 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 81 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
82 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 82 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
83 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 83 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
84 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 84 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
85 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 85 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
86 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 86 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
87 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 87 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
88 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 88 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
89 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 89 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
90 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 90 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
91 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 91 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
92 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 92 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
93 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 93 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
94 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 94 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
95 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 95 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
96 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 96 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
97 | 97 | ||
98 | // personal | 98 | // personal |
99 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 99 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
100 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 100 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
101 | void setBirthday( const QDate &v ); | 101 | void setBirthday( const QDate &v ); |
102 | void setAnniversary( const QDate &v ); | 102 | void setAnniversary( const QDate &v ); |
103 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 103 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
104 | void setChildren( const QString &v ); | 104 | void setChildren( const QString &v ); |
105 | 105 | ||
106 | // other | 106 | // other |
107 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 107 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
108 | 108 | ||
109 | bool match( const QString ®exp ) const; | 109 | bool match( const QString ®exp ) const; |
110 | 110 | ||
111 | // DON'T ATTEMPT TO USE THIS | 111 | // DON'T ATTEMPT TO USE THIS |
112 | #ifdef QTOPIA_INTERNAL_CONTACT_MRE | 112 | #ifdef QTOPIA_INTERNAL_CONTACT_MRE |
113 | bool match( const QRegExp ®exp ) const; | 113 | bool match( const QRegExp ®exp ) const; |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | // // custom | 116 | // // custom |
117 | // void setCustomField( const QString &key, const QString &v ) | 117 | // void setCustomField( const QString &key, const QString &v ) |
118 | // { replace(Custom- + key, v ); } | 118 | // { replace(Custom- + key, v ); } |
119 | 119 | ||
120 | // name | 120 | // name |
121 | QString fullName() const; | 121 | QString fullName() const; |
122 | QString title() const { return find( Qtopia::Title ); } | 122 | QString title() const { return find( Qtopia::Title ); } |
123 | QString firstName() const { return find( Qtopia::FirstName ); } | 123 | QString firstName() const { return find( Qtopia::FirstName ); } |
124 | QString middleName() const { return find( Qtopia::MiddleName ); } | 124 | QString middleName() const { return find( Qtopia::MiddleName ); } |
125 | QString lastName() const { return find( Qtopia::LastName ); } | 125 | QString lastName() const { return find( Qtopia::LastName ); } |
126 | QString suffix() const { return find( Qtopia::Suffix ); } | 126 | QString suffix() const { return find( Qtopia::Suffix ); } |
127 | QString fileAs() const { return find( Qtopia::FileAs ); } | 127 | QString fileAs() const { return find( Qtopia::FileAs ); } |
128 | 128 | ||
129 | 129 | ||
130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
131 | QStringList emailList() const; | 131 | QStringList emailList() const; |
132 | 132 | ||
133 | // home | 133 | // home |
134 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 134 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
135 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 135 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
136 | QString homeState() const { return find( Qtopia::HomeState ); } | 136 | QString homeState() const { return find( Qtopia::HomeState ); } |
137 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 137 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
138 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 138 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
139 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 139 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
140 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 140 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
141 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 141 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
142 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 142 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
143 | /** Multi line string containing all non-empty address info in the form | 143 | /** Multi line string containing all non-empty address info in the form |
144 | * Street | 144 | * Street |
145 | * City, State Zip | 145 | * City, State Zip |
146 | * Country | 146 | * Country |
147 | */ | 147 | */ |
148 | QString displayHomeAddress() const; | 148 | QString displayHomeAddress() const; |
149 | 149 | ||
150 | // business | 150 | // business |
151 | QString company() const { return find( Qtopia::Company ); } | 151 | QString company() const { return find( Qtopia::Company ); } |
152 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 152 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
153 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 153 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
154 | QString businessState() const { return find( Qtopia::BusinessState ); } | 154 | QString businessState() const { return find( Qtopia::BusinessState ); } |
155 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 155 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
156 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 156 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
157 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 157 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
158 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 158 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
159 | QString department() const { return find( Qtopia::Department ); } | 159 | QString department() const { return find( Qtopia::Department ); } |
160 | QString office() const { return find( Qtopia::Office ); } | 160 | QString office() const { return find( Qtopia::Office ); } |
161 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 161 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
162 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 162 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
163 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 163 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
164 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 164 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
165 | QString profession() const { return find( Qtopia::Profession ); } | 165 | QString profession() const { return find( Qtopia::Profession ); } |
166 | QString assistant() const { return find( Qtopia::Assistant ); } | 166 | QString assistant() const { return find( Qtopia::Assistant ); } |
167 | QString manager() const { return find( Qtopia::Manager ); } | 167 | QString manager() const { return find( Qtopia::Manager ); } |
168 | /** Multi line string containing all non-empty address info in the form | 168 | /** Multi line string containing all non-empty address info in the form |
169 | * Street | 169 | * Street |
170 | * City, State Zip | 170 | * City, State Zip |
171 | * Country | 171 | * Country |
172 | */ | 172 | */ |
173 | QString displayBusinessAddress() const; | 173 | QString displayBusinessAddress() const; |
174 | 174 | ||
175 | //personal | 175 | //personal |
176 | QString spouse() const { return find( Qtopia::Spouse ); } | 176 | QString spouse() const { return find( Qtopia::Spouse ); } |
177 | QString gender() const { return find( Qtopia::Gender ); } | 177 | QString gender() const { return find( Qtopia::Gender ); } |
178 | QDate birthday() const; | 178 | QDate birthday() const; |
179 | QDate anniversary() const; | 179 | QDate anniversary() const; |
180 | QString nickname() const { return find( Qtopia::Nickname ); } | 180 | QString nickname() const { return find( Qtopia::Nickname ); } |
181 | QString children() const { return find( Qtopia::Children ); } | 181 | QString children() const { return find( Qtopia::Children ); } |
182 | QStringList childrenList() const; | 182 | QStringList childrenList() const; |
183 | 183 | ||
184 | // other | 184 | // other |
185 | QString notes() const { return find( Qtopia::Notes ); } | 185 | QString notes() const { return find( Qtopia::Notes ); } |
186 | QString groups() const { return find( Qtopia::Groups ); } | 186 | QString groups() const { return find( Qtopia::Groups ); } |
187 | QStringList groupList() const; | 187 | QStringList groupList() const; |
188 | 188 | ||
189 | // // custom | 189 | // // custom |
190 | // const QString &customField( const QString &key ) | 190 | // const QString &customField( const QString &key ) |
191 | // { return find( Custom- + key ); } | 191 | // { return find( Custom- + key ); } |
192 | 192 | ||
193 | static QStringList fields(); | 193 | static QStringList fields(); |
194 | static QStringList trfields(); | 194 | static QStringList trfields(); |
195 | static QStringList untrfields(); | 195 | static QStringList untrfields(); |
196 | 196 | ||
197 | QString toRichText() const; | 197 | QString toRichText() const; |
198 | QMap<int, QString> toMap() const; | 198 | QMap<int, QString> toMap() const; |
199 | QString field( int key ) const { return find( key ); } | 199 | QString field( int key ) const { return find( key ); } |
200 | 200 | ||
201 | 201 | ||
202 | // journaling... | 202 | // journaling... |
203 | void saveJournal( journal_action action, const QString &key = QString::null ); | 203 | void saveJournal( journal_action action, const QString &key = QString::null ); |
204 | void save( QString &buf ) const; | 204 | void save( QString &buf ) const; |
205 | 205 | ||
206 | void setUid( int i ) | 206 | void setUid( int i ) |
207 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } | 207 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } |
208 | 208 | ||
209 | QString toShortText()const; | 209 | QString toShortText()const; |
210 | QString OContact::type()const; | 210 | QString OContact::type()const; |
211 | QMap<QString,QString> OContact::toExtraMap() const; | 211 | QMap<QString,QString> OContact::toExtraMap() const; |
212 | class QString OContact::recordField(int) const; | 212 | class QString OContact::recordField(int) const; |
213 | 213 | ||
214 | // Why private ? (eilers,se) | 214 | // Why private ? (eilers,se) |
215 | QString emailSeparator() const { return " "; } | 215 | QString emailSeparator() const { return " "; } |
216 | // the emails should be seperated by a comma | 216 | // the emails should be seperated by a comma |
217 | void setEmails( const QString &v ); | 217 | void setEmails( const QString &v ); |
218 | QString emails() const { return find( Qtopia::Emails ); } | 218 | QString emails() const { return find( Qtopia::Emails ); } |
219 | 219 | ||
220 | 220 | ||
221 | private: | 221 | private: |
222 | friend class AbEditor; | 222 | friend class AbEditor; |
223 | friend class AbTable; | 223 | friend class AbTable; |
224 | friend class AddressBookAccessPrivate; | 224 | friend class AddressBookAccessPrivate; |
225 | friend class XMLIO; | 225 | friend class XMLIO; |
226 | 226 | ||
227 | |||
228 | void insert( int key, const QString &value ); | 227 | void insert( int key, const QString &value ); |
229 | void replace( int key, const QString &value ); | 228 | void replace( int key, const QString &value ); |
230 | QString find( int key ) const; | 229 | QString find( int key ) const; |
231 | 230 | ||
232 | QString displayAddress( const QString &street, | 231 | QString displayAddress( const QString &street, |
233 | const QString &city, | 232 | const QString &city, |
234 | const QString &state, | 233 | const QString &state, |
235 | const QString &zip, | 234 | const QString &zip, |
236 | const QString &country ) const; | 235 | const QString &country ) const; |
237 | 236 | ||
238 | Qtopia::UidGen &uidGen() { return sUidGen; } | 237 | Qtopia::UidGen &uidGen() { return sUidGen; } |
238 | |||
239 | |||
239 | static Qtopia::UidGen sUidGen; | 240 | static Qtopia::UidGen sUidGen; |
240 | QMap<int, QString> mMap; | 241 | QMap<int, QString> mMap; |
241 | ContactPrivate *d; | 242 | ContactPrivate *d; |
242 | }; | 243 | }; |
243 | 244 | ||
244 | 245 | ||
245 | #endif | 246 | #endif |
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index 21fc088..734f5a2 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -613,997 +613,1023 @@ void OContact::insert( int key, const QString &v ) | |||
613 | /*! | 613 | /*! |
614 | \internal | 614 | \internal |
615 | */ | 615 | */ |
616 | void OContact::replace( int key, const QString & v ) | 616 | void OContact::replace( int key, const QString & v ) |
617 | { | 617 | { |
618 | QString value = v.stripWhiteSpace(); | 618 | QString value = v.stripWhiteSpace(); |
619 | if ( value.isEmpty() ) | 619 | if ( value.isEmpty() ) |
620 | mMap.remove( key ); | 620 | mMap.remove( key ); |
621 | else | 621 | else |
622 | mMap.replace( key, value ); | 622 | mMap.replace( key, value ); |
623 | } | 623 | } |
624 | 624 | ||
625 | /*! | 625 | /*! |
626 | \internal | 626 | \internal |
627 | */ | 627 | */ |
628 | QString OContact::find( int key ) const | 628 | QString OContact::find( int key ) const |
629 | { | 629 | { |
630 | return mMap[key]; | 630 | return mMap[key]; |
631 | } | 631 | } |
632 | 632 | ||
633 | /*! | 633 | /*! |
634 | \internal | 634 | \internal |
635 | */ | 635 | */ |
636 | QString OContact::displayAddress( const QString &street, | 636 | QString OContact::displayAddress( const QString &street, |
637 | const QString &city, | 637 | const QString &city, |
638 | const QString &state, | 638 | const QString &state, |
639 | const QString &zip, | 639 | const QString &zip, |
640 | const QString &country ) const | 640 | const QString &country ) const |
641 | { | 641 | { |
642 | QString s = street; | 642 | QString s = street; |
643 | if ( !street.isEmpty() ) | 643 | if ( !street.isEmpty() ) |
644 | s+= "\n"; | 644 | s+= "\n"; |
645 | s += city; | 645 | s += city; |
646 | if ( !city.isEmpty() && !state.isEmpty() ) | 646 | if ( !city.isEmpty() && !state.isEmpty() ) |
647 | s += ", "; | 647 | s += ", "; |
648 | s += state; | 648 | s += state; |
649 | if ( !state.isEmpty() && !zip.isEmpty() ) | 649 | if ( !state.isEmpty() && !zip.isEmpty() ) |
650 | s += " "; | 650 | s += " "; |
651 | s += zip; | 651 | s += zip; |
652 | if ( !country.isEmpty() && !s.isEmpty() ) | 652 | if ( !country.isEmpty() && !s.isEmpty() ) |
653 | s += "\n"; | 653 | s += "\n"; |
654 | s += country; | 654 | s += country; |
655 | return s; | 655 | return s; |
656 | } | 656 | } |
657 | 657 | ||
658 | /*! | 658 | /*! |
659 | \internal | 659 | \internal |
660 | */ | 660 | */ |
661 | QString OContact::displayBusinessAddress() const | 661 | QString OContact::displayBusinessAddress() const |
662 | { | 662 | { |
663 | return displayAddress( businessStreet(), businessCity(), | 663 | return displayAddress( businessStreet(), businessCity(), |
664 | businessState(), businessZip(), | 664 | businessState(), businessZip(), |
665 | businessCountry() ); | 665 | businessCountry() ); |
666 | } | 666 | } |
667 | 667 | ||
668 | /*! | 668 | /*! |
669 | \internal | 669 | \internal |
670 | */ | 670 | */ |
671 | QString OContact::displayHomeAddress() const | 671 | QString OContact::displayHomeAddress() const |
672 | { | 672 | { |
673 | return displayAddress( homeStreet(), homeCity(), | 673 | return displayAddress( homeStreet(), homeCity(), |
674 | homeState(), homeZip(), | 674 | homeState(), homeZip(), |
675 | homeCountry() ); | 675 | homeCountry() ); |
676 | } | 676 | } |
677 | 677 | ||
678 | /*! | 678 | /*! |
679 | Returns the full name of the contact | 679 | Returns the full name of the contact |
680 | */ | 680 | */ |
681 | QString OContact::fullName() const | 681 | QString OContact::fullName() const |
682 | { | 682 | { |
683 | QString title = find( Qtopia::Title ); | 683 | QString title = find( Qtopia::Title ); |
684 | QString firstName = find( Qtopia::FirstName ); | 684 | QString firstName = find( Qtopia::FirstName ); |
685 | QString middleName = find( Qtopia::MiddleName ); | 685 | QString middleName = find( Qtopia::MiddleName ); |
686 | QString lastName = find( Qtopia::LastName ); | 686 | QString lastName = find( Qtopia::LastName ); |
687 | QString suffix = find( Qtopia::Suffix ); | 687 | QString suffix = find( Qtopia::Suffix ); |
688 | 688 | ||
689 | QString name = title; | 689 | QString name = title; |
690 | if ( !firstName.isEmpty() ) { | 690 | if ( !firstName.isEmpty() ) { |
691 | if ( !name.isEmpty() ) | 691 | if ( !name.isEmpty() ) |
692 | name += " "; | 692 | name += " "; |
693 | name += firstName; | 693 | name += firstName; |
694 | } | 694 | } |
695 | if ( !middleName.isEmpty() ) { | 695 | if ( !middleName.isEmpty() ) { |
696 | if ( !name.isEmpty() ) | 696 | if ( !name.isEmpty() ) |
697 | name += " "; | 697 | name += " "; |
698 | name += middleName; | 698 | name += middleName; |
699 | } | 699 | } |
700 | if ( !lastName.isEmpty() ) { | 700 | if ( !lastName.isEmpty() ) { |
701 | if ( !name.isEmpty() ) | 701 | if ( !name.isEmpty() ) |
702 | name += " "; | 702 | name += " "; |
703 | name += lastName; | 703 | name += lastName; |
704 | } | 704 | } |
705 | if ( !suffix.isEmpty() ) { | 705 | if ( !suffix.isEmpty() ) { |
706 | if ( !name.isEmpty() ) | 706 | if ( !name.isEmpty() ) |
707 | name += " "; | 707 | name += " "; |
708 | name += suffix; | 708 | name += suffix; |
709 | } | 709 | } |
710 | return name.simplifyWhiteSpace(); | 710 | return name.simplifyWhiteSpace(); |
711 | } | 711 | } |
712 | 712 | ||
713 | /*! | 713 | /*! |
714 | Returns a list of the names of the children of the contact. | 714 | Returns a list of the names of the children of the contact. |
715 | */ | 715 | */ |
716 | QStringList OContact::childrenList() const | 716 | QStringList OContact::childrenList() const |
717 | { | 717 | { |
718 | return QStringList::split( " ", find( Qtopia::Children ) ); | 718 | return QStringList::split( " ", find( Qtopia::Children ) ); |
719 | } | 719 | } |
720 | 720 | ||
721 | /*! \fn void OContact::insertEmail( const QString &email ) | 721 | /*! \fn void OContact::insertEmail( const QString &email ) |
722 | 722 | ||
723 | Insert \a email into the email list. Ensures \a email can only be added | 723 | Insert \a email into the email list. Ensures \a email can only be added |
724 | once. If there is no default email address set, it sets it to the \a email. | 724 | once. If there is no default email address set, it sets it to the \a email. |
725 | */ | 725 | */ |
726 | 726 | ||
727 | /*! \fn void OContact::removeEmail( const QString &email ) | 727 | /*! \fn void OContact::removeEmail( const QString &email ) |
728 | 728 | ||
729 | Removes the \a email from the email list. If the default email was \a email, | 729 | Removes the \a email from the email list. If the default email was \a email, |
730 | then the default email address is assigned to the first email in the | 730 | then the default email address is assigned to the first email in the |
731 | email list | 731 | email list |
732 | */ | 732 | */ |
733 | 733 | ||
734 | /*! \fn void OContact::clearEmails() | 734 | /*! \fn void OContact::clearEmails() |
735 | 735 | ||
736 | Clears the email list. | 736 | Clears the email list. |
737 | */ | 737 | */ |
738 | 738 | ||
739 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) | 739 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) |
740 | 740 | ||
741 | Appends the \a emailList to the exiting email list | 741 | Appends the \a emailList to the exiting email list |
742 | */ | 742 | */ |
743 | 743 | ||
744 | /*! | 744 | /*! |
745 | Returns a list of email addresses belonging to the contact, including | 745 | Returns a list of email addresses belonging to the contact, including |
746 | the default email address. | 746 | the default email address. |
747 | */ | 747 | */ |
748 | QStringList OContact::emailList() const | 748 | QStringList OContact::emailList() const |
749 | { | 749 | { |
750 | QString emailStr = emails(); | 750 | QString emailStr = emails(); |
751 | 751 | ||
752 | QStringList r; | 752 | QStringList r; |
753 | if ( !emailStr.isEmpty() ) { | 753 | if ( !emailStr.isEmpty() ) { |
754 | qDebug(" emailstr "); | 754 | qDebug(" emailstr "); |
755 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 755 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
756 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 756 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
757 | r += (*it).simplifyWhiteSpace(); | 757 | r += (*it).simplifyWhiteSpace(); |
758 | } | 758 | } |
759 | 759 | ||
760 | return r; | 760 | return r; |
761 | } | 761 | } |
762 | 762 | ||
763 | /*! | 763 | /*! |
764 | \overload | 764 | \overload |
765 | 765 | ||
766 | Generates the string for the contact to be filed as from the first, | 766 | Generates the string for the contact to be filed as from the first, |
767 | middle and last name of the contact. | 767 | middle and last name of the contact. |
768 | */ | 768 | */ |
769 | void OContact::setFileAs() | 769 | void OContact::setFileAs() |
770 | { | 770 | { |
771 | QString lastName, firstName, middleName, fileas; | 771 | QString lastName, firstName, middleName, fileas; |
772 | 772 | ||
773 | lastName = find( Qtopia::LastName ); | 773 | lastName = find( Qtopia::LastName ); |
774 | firstName = find( Qtopia::FirstName ); | 774 | firstName = find( Qtopia::FirstName ); |
775 | middleName = find( Qtopia::MiddleName ); | 775 | middleName = find( Qtopia::MiddleName ); |
776 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 776 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
777 | && !middleName.isEmpty() ) | 777 | && !middleName.isEmpty() ) |
778 | fileas = lastName + ", " + firstName + " " + middleName; | 778 | fileas = lastName + ", " + firstName + " " + middleName; |
779 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 779 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
780 | fileas = lastName + ", " + firstName; | 780 | fileas = lastName + ", " + firstName; |
781 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 781 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
782 | !middleName.isEmpty() ) | 782 | !middleName.isEmpty() ) |
783 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 783 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
784 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 784 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
785 | + lastName; | 785 | + lastName; |
786 | 786 | ||
787 | replace( Qtopia::FileAs, fileas ); | 787 | replace( Qtopia::FileAs, fileas ); |
788 | } | 788 | } |
789 | 789 | ||
790 | /*! | 790 | /*! |
791 | \internal | 791 | \internal |
792 | Appends the contact information to \a buf. | 792 | Appends the contact information to \a buf. |
793 | */ | 793 | */ |
794 | void OContact::save( QString &buf ) const | 794 | void OContact::save( QString &buf ) const |
795 | { | 795 | { |
796 | static const QStringList SLFIELDS = fields(); | 796 | static const QStringList SLFIELDS = fields(); |
797 | // I'm expecting "<Contact " in front of this... | 797 | // I'm expecting "<Contact " in front of this... |
798 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 798 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
799 | it != mMap.end(); ++it ) { | 799 | it != mMap.end(); ++it ) { |
800 | const QString &value = it.data(); | 800 | const QString &value = it.data(); |
801 | int key = it.key(); | 801 | int key = it.key(); |
802 | if ( !value.isEmpty() ) { | 802 | if ( !value.isEmpty() ) { |
803 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 803 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
804 | continue; | 804 | continue; |
805 | 805 | ||
806 | key -= Qtopia::AddressCategory+1; | 806 | key -= Qtopia::AddressCategory+1; |
807 | buf += SLFIELDS[key]; | 807 | buf += SLFIELDS[key]; |
808 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 808 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
809 | } | 809 | } |
810 | } | 810 | } |
811 | buf += customToXml(); | 811 | buf += customToXml(); |
812 | if ( categories().count() > 0 ) | 812 | if ( categories().count() > 0 ) |
813 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 813 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
814 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 814 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
815 | // You need to close this yourself | 815 | // You need to close this yourself |
816 | } | 816 | } |
817 | 817 | ||
818 | /*! | 818 | /*! |
819 | \internal | 819 | \internal |
820 | Returns the list of fields belonging to a contact | 820 | Returns the list of fields belonging to a contact |
821 | */ | 821 | */ |
822 | QStringList OContact::fields() | 822 | QStringList OContact::fields() |
823 | { | 823 | { |
824 | QStringList list; | 824 | QStringList list; |
825 | 825 | ||
826 | list.append( "Title" ); // Not Used! | 826 | list.append( "Title" ); // Not Used! |
827 | list.append( "FirstName" ); | 827 | list.append( "FirstName" ); |
828 | list.append( "MiddleName" ); | 828 | list.append( "MiddleName" ); |
829 | list.append( "LastName" ); | 829 | list.append( "LastName" ); |
830 | list.append( "Suffix" ); | 830 | list.append( "Suffix" ); |
831 | list.append( "FileAs" ); | 831 | list.append( "FileAs" ); |
832 | 832 | ||
833 | list.append( "JobTitle" ); | 833 | list.append( "JobTitle" ); |
834 | list.append( "Department" ); | 834 | list.append( "Department" ); |
835 | list.append( "Company" ); | 835 | list.append( "Company" ); |
836 | list.append( "BusinessPhone" ); | 836 | list.append( "BusinessPhone" ); |
837 | list.append( "BusinessFax" ); | 837 | list.append( "BusinessFax" ); |
838 | list.append( "BusinessMobile" ); | 838 | list.append( "BusinessMobile" ); |
839 | 839 | ||
840 | list.append( "DefaultEmail" ); | 840 | list.append( "DefaultEmail" ); |
841 | list.append( "Emails" ); | 841 | list.append( "Emails" ); |
842 | 842 | ||
843 | list.append( "HomePhone" ); | 843 | list.append( "HomePhone" ); |
844 | list.append( "HomeFax" ); | 844 | list.append( "HomeFax" ); |
845 | list.append( "HomeMobile" ); | 845 | list.append( "HomeMobile" ); |
846 | 846 | ||
847 | list.append( "BusinessStreet" ); | 847 | list.append( "BusinessStreet" ); |
848 | list.append( "BusinessCity" ); | 848 | list.append( "BusinessCity" ); |
849 | list.append( "BusinessState" ); | 849 | list.append( "BusinessState" ); |
850 | list.append( "BusinessZip" ); | 850 | list.append( "BusinessZip" ); |
851 | list.append( "BusinessCountry" ); | 851 | list.append( "BusinessCountry" ); |
852 | list.append( "BusinessPager" ); | 852 | list.append( "BusinessPager" ); |
853 | list.append( "BusinessWebPage" ); | 853 | list.append( "BusinessWebPage" ); |
854 | 854 | ||
855 | list.append( "Office" ); | 855 | list.append( "Office" ); |
856 | list.append( "Profession" ); | 856 | list.append( "Profession" ); |
857 | list.append( "Assistant" ); | 857 | list.append( "Assistant" ); |
858 | list.append( "Manager" ); | 858 | list.append( "Manager" ); |
859 | 859 | ||
860 | list.append( "HomeStreet" ); | 860 | list.append( "HomeStreet" ); |
861 | list.append( "HomeCity" ); | 861 | list.append( "HomeCity" ); |
862 | list.append( "HomeState" ); | 862 | list.append( "HomeState" ); |
863 | list.append( "HomeZip" ); | 863 | list.append( "HomeZip" ); |
864 | list.append( "HomeCountry" ); | 864 | list.append( "HomeCountry" ); |
865 | list.append( "HomeWebPage" ); | 865 | list.append( "HomeWebPage" ); |
866 | 866 | ||
867 | list.append( "Spouse" ); | 867 | list.append( "Spouse" ); |
868 | list.append( "Gender" ); | 868 | list.append( "Gender" ); |
869 | list.append( "Birthday" ); | 869 | list.append( "Birthday" ); |
870 | list.append( "Anniversary" ); | 870 | list.append( "Anniversary" ); |
871 | list.append( "Nickname" ); | 871 | list.append( "Nickname" ); |
872 | list.append( "Children" ); | 872 | list.append( "Children" ); |
873 | 873 | ||
874 | list.append( "Notes" ); | 874 | list.append( "Notes" ); |
875 | list.append( "Groups" ); | 875 | list.append( "Groups" ); |
876 | 876 | ||
877 | return list; | 877 | return list; |
878 | } | 878 | } |
879 | 879 | ||
880 | /*! | 880 | /*! |
881 | \internal | 881 | \internal |
882 | Returns a translated list of field names for a contact. | 882 | Returns a translated list of field names for a contact. |
883 | */ | 883 | */ |
884 | QStringList OContact::trfields() | 884 | QStringList OContact::trfields() |
885 | { | 885 | { |
886 | QStringList list; | 886 | QStringList list; |
887 | 887 | ||
888 | list.append( QObject::tr( "Name Title") ); | 888 | list.append( QObject::tr( "Name Title") ); |
889 | list.append( QObject::tr( "First Name" ) ); | 889 | list.append( QObject::tr( "First Name" ) ); |
890 | list.append( QObject::tr( "Middle Name" ) ); | 890 | list.append( QObject::tr( "Middle Name" ) ); |
891 | list.append( QObject::tr( "Last Name" ) ); | 891 | list.append( QObject::tr( "Last Name" ) ); |
892 | list.append( QObject::tr( "Suffix" ) ); | 892 | list.append( QObject::tr( "Suffix" ) ); |
893 | list.append( QObject::tr( "File As" ) ); | 893 | list.append( QObject::tr( "File As" ) ); |
894 | 894 | ||
895 | list.append( QObject::tr( "Job Title" ) ); | 895 | list.append( QObject::tr( "Job Title" ) ); |
896 | list.append( QObject::tr( "Department" ) ); | 896 | list.append( QObject::tr( "Department" ) ); |
897 | list.append( QObject::tr( "Company" ) ); | 897 | list.append( QObject::tr( "Company" ) ); |
898 | list.append( QObject::tr( "Business Phone" ) ); | 898 | list.append( QObject::tr( "Business Phone" ) ); |
899 | list.append( QObject::tr( "Business Fax" ) ); | 899 | list.append( QObject::tr( "Business Fax" ) ); |
900 | list.append( QObject::tr( "Business Mobile" ) ); | 900 | list.append( QObject::tr( "Business Mobile" ) ); |
901 | 901 | ||
902 | list.append( QObject::tr( "Default Email" ) ); | 902 | list.append( QObject::tr( "Default Email" ) ); |
903 | list.append( QObject::tr( "Emails" ) ); | 903 | list.append( QObject::tr( "Emails" ) ); |
904 | 904 | ||
905 | list.append( QObject::tr( "Home Phone" ) ); | 905 | list.append( QObject::tr( "Home Phone" ) ); |
906 | list.append( QObject::tr( "Home Fax" ) ); | 906 | list.append( QObject::tr( "Home Fax" ) ); |
907 | list.append( QObject::tr( "Home Mobile" ) ); | 907 | list.append( QObject::tr( "Home Mobile" ) ); |
908 | 908 | ||
909 | list.append( QObject::tr( "Business Street" ) ); | 909 | list.append( QObject::tr( "Business Street" ) ); |
910 | list.append( QObject::tr( "Business City" ) ); | 910 | list.append( QObject::tr( "Business City" ) ); |
911 | list.append( QObject::tr( "Business State" ) ); | 911 | list.append( QObject::tr( "Business State" ) ); |
912 | list.append( QObject::tr( "Business Zip" ) ); | 912 | list.append( QObject::tr( "Business Zip" ) ); |
913 | list.append( QObject::tr( "Business Country" ) ); | 913 | list.append( QObject::tr( "Business Country" ) ); |
914 | list.append( QObject::tr( "Business Pager" ) ); | 914 | list.append( QObject::tr( "Business Pager" ) ); |
915 | list.append( QObject::tr( "Business WebPage" ) ); | 915 | list.append( QObject::tr( "Business WebPage" ) ); |
916 | 916 | ||
917 | list.append( QObject::tr( "Office" ) ); | 917 | list.append( QObject::tr( "Office" ) ); |
918 | list.append( QObject::tr( "Profession" ) ); | 918 | list.append( QObject::tr( "Profession" ) ); |
919 | list.append( QObject::tr( "Assistant" ) ); | 919 | list.append( QObject::tr( "Assistant" ) ); |
920 | list.append( QObject::tr( "Manager" ) ); | 920 | list.append( QObject::tr( "Manager" ) ); |
921 | 921 | ||
922 | list.append( QObject::tr( "Home Street" ) ); | 922 | list.append( QObject::tr( "Home Street" ) ); |
923 | list.append( QObject::tr( "Home City" ) ); | 923 | list.append( QObject::tr( "Home City" ) ); |
924 | list.append( QObject::tr( "Home State" ) ); | 924 | list.append( QObject::tr( "Home State" ) ); |
925 | list.append( QObject::tr( "Home Zip" ) ); | 925 | list.append( QObject::tr( "Home Zip" ) ); |
926 | list.append( QObject::tr( "Home Country" ) ); | 926 | list.append( QObject::tr( "Home Country" ) ); |
927 | list.append( QObject::tr( "Home Web Page" ) ); | 927 | list.append( QObject::tr( "Home Web Page" ) ); |
928 | 928 | ||
929 | list.append( QObject::tr( "Spouse" ) ); | 929 | list.append( QObject::tr( "Spouse" ) ); |
930 | list.append( QObject::tr( "Gender" ) ); | 930 | list.append( QObject::tr( "Gender" ) ); |
931 | list.append( QObject::tr( "Birthday" ) ); | 931 | list.append( QObject::tr( "Birthday" ) ); |
932 | list.append( QObject::tr( "Anniversary" ) ); | 932 | list.append( QObject::tr( "Anniversary" ) ); |
933 | list.append( QObject::tr( "Nickname" ) ); | 933 | list.append( QObject::tr( "Nickname" ) ); |
934 | list.append( QObject::tr( "Children" ) ); | 934 | list.append( QObject::tr( "Children" ) ); |
935 | 935 | ||
936 | list.append( QObject::tr( "Notes" ) ); | 936 | list.append( QObject::tr( "Notes" ) ); |
937 | list.append( QObject::tr( "Groups" ) ); | 937 | list.append( QObject::tr( "Groups" ) ); |
938 | 938 | ||
939 | return list; | 939 | return list; |
940 | } | 940 | } |
941 | 941 | ||
942 | /*! | 942 | /*! |
943 | \internal | 943 | \internal |
944 | Returns an untranslated list of field names for a contact. | 944 | Returns an untranslated list of field names for a contact. |
945 | */ | 945 | */ |
946 | QStringList OContact::untrfields() | 946 | QStringList OContact::untrfields() |
947 | { | 947 | { |
948 | QStringList list; | 948 | QStringList list; |
949 | 949 | ||
950 | list.append( "Name Title" ); | 950 | list.append( "Name Title" ); |
951 | list.append( "First Name" ); | 951 | list.append( "First Name" ); |
952 | list.append( "Middle Name" ); | 952 | list.append( "Middle Name" ); |
953 | list.append( "Last Name" ); | 953 | list.append( "Last Name" ); |
954 | list.append( "Suffix" ); | 954 | list.append( "Suffix" ); |
955 | list.append( "File As" ); | 955 | list.append( "File As" ); |
956 | 956 | ||
957 | list.append( "Job Title" ); | 957 | list.append( "Job Title" ); |
958 | list.append( "Department" ); | 958 | list.append( "Department" ); |
959 | list.append( "Company" ); | 959 | list.append( "Company" ); |
960 | list.append( "Business Phone" ); | 960 | list.append( "Business Phone" ); |
961 | list.append( "Business Fax" ); | 961 | list.append( "Business Fax" ); |
962 | list.append( "Business Mobile" ); | 962 | list.append( "Business Mobile" ); |
963 | 963 | ||
964 | list.append( "Default Email" ); | 964 | list.append( "Default Email" ); |
965 | list.append( "Emails" ); | 965 | list.append( "Emails" ); |
966 | 966 | ||
967 | list.append( "Home Phone" ); | 967 | list.append( "Home Phone" ); |
968 | list.append( "Home Fax" ); | 968 | list.append( "Home Fax" ); |
969 | list.append( "Home Mobile" ); | 969 | list.append( "Home Mobile" ); |
970 | 970 | ||
971 | list.append( "Business Street" ); | 971 | list.append( "Business Street" ); |
972 | list.append( "Business City" ); | 972 | list.append( "Business City" ); |
973 | list.append( "Business State" ); | 973 | list.append( "Business State" ); |
974 | list.append( "Business Zip" ); | 974 | list.append( "Business Zip" ); |
975 | list.append( "Business Country" ); | 975 | list.append( "Business Country" ); |
976 | list.append( "Business Pager" ); | 976 | list.append( "Business Pager" ); |
977 | list.append( "Business WebPage" ); | 977 | list.append( "Business WebPage" ); |
978 | 978 | ||
979 | list.append( "Office" ); | 979 | list.append( "Office" ); |
980 | list.append( "Profession" ); | 980 | list.append( "Profession" ); |
981 | list.append( "Assistant" ); | 981 | list.append( "Assistant" ); |
982 | list.append( "Manager" ); | 982 | list.append( "Manager" ); |
983 | 983 | ||
984 | list.append( "Home Street" ); | 984 | list.append( "Home Street" ); |
985 | list.append( "Home City" ); | 985 | list.append( "Home City" ); |
986 | list.append( "Home State" ); | 986 | list.append( "Home State" ); |
987 | list.append( "Home Zip" ); | 987 | list.append( "Home Zip" ); |
988 | list.append( "Home Country" ); | 988 | list.append( "Home Country" ); |
989 | list.append( "Home Web Page" ); | 989 | list.append( "Home Web Page" ); |
990 | 990 | ||
991 | list.append( "Spouse" ); | 991 | list.append( "Spouse" ); |
992 | list.append( "Gender" ); | 992 | list.append( "Gender" ); |
993 | list.append( "Birthday" ); | 993 | list.append( "Birthday" ); |
994 | list.append( "Anniversary" ); | 994 | list.append( "Anniversary" ); |
995 | list.append( "Nickname" ); | 995 | list.append( "Nickname" ); |
996 | list.append( "Children" ); | 996 | list.append( "Children" ); |
997 | 997 | ||
998 | list.append( "Notes" ); | 998 | list.append( "Notes" ); |
999 | list.append( "Groups" ); | 999 | list.append( "Groups" ); |
1000 | 1000 | ||
1001 | return list; | 1001 | return list; |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | /*! | 1004 | /*! |
1005 | Sets the list of email address for contact to those contained in \a str. | 1005 | Sets the list of email address for contact to those contained in \a str. |
1006 | Email address should be separated by ';'s. | 1006 | Email address should be separated by ';'s. |
1007 | */ | 1007 | */ |
1008 | void OContact::setEmails( const QString &str ) | 1008 | void OContact::setEmails( const QString &str ) |
1009 | { | 1009 | { |
1010 | replace( Qtopia::Emails, str ); | 1010 | replace( Qtopia::Emails, str ); |
1011 | if ( str.isEmpty() ) | 1011 | if ( str.isEmpty() ) |
1012 | setDefaultEmail( QString::null ); | 1012 | setDefaultEmail( QString::null ); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | /*! | 1015 | /*! |
1016 | Sets the list of children for the contact to those contained in \a str. | 1016 | Sets the list of children for the contact to those contained in \a str. |
1017 | */ | 1017 | */ |
1018 | void OContact::setChildren( const QString &str ) | 1018 | void OContact::setChildren( const QString &str ) |
1019 | { | 1019 | { |
1020 | replace( Qtopia::Children, str ); | 1020 | replace( Qtopia::Children, str ); |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | // vcard conversion code | 1023 | // vcard conversion code |
1024 | /*! | 1024 | /*! |
1025 | \internal | 1025 | \internal |
1026 | */ | 1026 | */ |
1027 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 1027 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
1028 | { | 1028 | { |
1029 | VObject *ret = 0; | 1029 | VObject *ret = 0; |
1030 | if ( o && !value.isEmpty() ) | 1030 | if ( o && !value.isEmpty() ) |
1031 | ret = addPropValue( o, prop, value.latin1() ); | 1031 | ret = addPropValue( o, prop, value.latin1() ); |
1032 | return ret; | 1032 | return ret; |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | /*! | 1035 | /*! |
1036 | \internal | 1036 | \internal |
1037 | */ | 1037 | */ |
1038 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 1038 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
1039 | { | 1039 | { |
1040 | VObject *ret = 0; | 1040 | VObject *ret = 0; |
1041 | if ( o ) | 1041 | if ( o ) |
1042 | ret = addProp( o, prop ); | 1042 | ret = addProp( o, prop ); |
1043 | return ret; | 1043 | return ret; |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | /*! | 1046 | /*! |
1047 | \internal | 1047 | \internal |
1048 | */ | 1048 | */ |
1049 | static VObject *createVObject( const OContact &c ) | 1049 | static VObject *createVObject( const OContact &c ) |
1050 | { | 1050 | { |
1051 | VObject *vcard = newVObject( VCCardProp ); | 1051 | VObject *vcard = newVObject( VCCardProp ); |
1052 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 1052 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
1053 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 1053 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
1054 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 1054 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
1055 | 1055 | ||
1056 | // full name | 1056 | // full name |
1057 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 1057 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
1058 | 1058 | ||
1059 | // name properties | 1059 | // name properties |
1060 | VObject *name = safeAddProp( vcard, VCNameProp ); | 1060 | VObject *name = safeAddProp( vcard, VCNameProp ); |
1061 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 1061 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
1062 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 1062 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
1063 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 1063 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
1064 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 1064 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
1065 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 1065 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
1066 | 1066 | ||
1067 | // home properties | 1067 | // home properties |
1068 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 1068 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
1069 | safeAddProp( home_adr, VCHomeProp ); | 1069 | safeAddProp( home_adr, VCHomeProp ); |
1070 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 1070 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
1071 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 1071 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
1072 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 1072 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
1073 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 1073 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
1074 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 1074 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
1075 | 1075 | ||
1076 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 1076 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
1077 | safeAddProp( home_phone, VCHomeProp ); | 1077 | safeAddProp( home_phone, VCHomeProp ); |
1078 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 1078 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
1079 | safeAddProp( home_phone, VCHomeProp ); | 1079 | safeAddProp( home_phone, VCHomeProp ); |
1080 | safeAddProp( home_phone, VCCellularProp ); | 1080 | safeAddProp( home_phone, VCCellularProp ); |
1081 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); | 1081 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); |
1082 | safeAddProp( home_phone, VCHomeProp ); | 1082 | safeAddProp( home_phone, VCHomeProp ); |
1083 | safeAddProp( home_phone, VCFaxProp ); | 1083 | safeAddProp( home_phone, VCFaxProp ); |
1084 | 1084 | ||
1085 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); | 1085 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); |
1086 | safeAddProp( url, VCHomeProp ); | 1086 | safeAddProp( url, VCHomeProp ); |
1087 | 1087 | ||
1088 | // work properties | 1088 | // work properties |
1089 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); | 1089 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); |
1090 | safeAddProp( work_adr, VCWorkProp ); | 1090 | safeAddProp( work_adr, VCWorkProp ); |
1091 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); | 1091 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); |
1092 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); | 1092 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); |
1093 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); | 1093 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); |
1094 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); | 1094 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); |
1095 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); | 1095 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); |
1096 | 1096 | ||
1097 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); | 1097 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); |
1098 | safeAddProp( work_phone, VCWorkProp ); | 1098 | safeAddProp( work_phone, VCWorkProp ); |
1099 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); | 1099 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); |
1100 | safeAddProp( work_phone, VCWorkProp ); | 1100 | safeAddProp( work_phone, VCWorkProp ); |
1101 | safeAddProp( work_phone, VCCellularProp ); | 1101 | safeAddProp( work_phone, VCCellularProp ); |
1102 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 1102 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
1103 | safeAddProp( work_phone, VCWorkProp ); | 1103 | safeAddProp( work_phone, VCWorkProp ); |
1104 | safeAddProp( work_phone, VCFaxProp ); | 1104 | safeAddProp( work_phone, VCFaxProp ); |
1105 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 1105 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
1106 | safeAddProp( work_phone, VCWorkProp ); | 1106 | safeAddProp( work_phone, VCWorkProp ); |
1107 | safeAddProp( work_phone, VCPagerProp ); | 1107 | safeAddProp( work_phone, VCPagerProp ); |
1108 | 1108 | ||
1109 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 1109 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
1110 | safeAddProp( url, VCWorkProp ); | 1110 | safeAddProp( url, VCWorkProp ); |
1111 | 1111 | ||
1112 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 1112 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
1113 | safeAddProp( title, VCWorkProp ); | 1113 | safeAddProp( title, VCWorkProp ); |
1114 | 1114 | ||
1115 | 1115 | ||
1116 | QStringList emails = c.emailList(); | 1116 | QStringList emails = c.emailList(); |
1117 | emails.prepend( c.defaultEmail() ); | 1117 | emails.prepend( c.defaultEmail() ); |
1118 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 1118 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
1119 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 1119 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
1120 | safeAddProp( email, VCInternetProp ); | 1120 | safeAddProp( email, VCInternetProp ); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 1123 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
1124 | 1124 | ||
1125 | safeAddPropValue( vcard, VCBirthDateProp, TimeConversion::toString( c.birthday() ) ); | 1125 | // Exporting Birthday regarding RFC 2425 (5.8.4) |
1126 | if ( !c.birthday().isNull() ){ | ||
1127 | QString birthd_rfc2425 = c.birthday().year() + QString( "-" ) + c.birthday().month() + QString( "-" ) + c.birthday().day(); | ||
1128 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); | ||
1129 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); | ||
1130 | } | ||
1126 | 1131 | ||
1127 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 1132 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
1128 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 1133 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
1129 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 1134 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
1130 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 1135 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
1131 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 1136 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
1132 | } | 1137 | } |
1133 | 1138 | ||
1134 | // some values we have to export as custom fields | 1139 | // some values we have to export as custom fields |
1135 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 1140 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
1136 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 1141 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
1137 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 1142 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
1138 | 1143 | ||
1139 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 1144 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
1140 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 1145 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
1141 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); | 1146 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); |
1142 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 1147 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
1143 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 1148 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
1144 | 1149 | ||
1145 | return vcard; | 1150 | return vcard; |
1146 | } | 1151 | } |
1147 | 1152 | ||
1148 | 1153 | ||
1149 | /*! | 1154 | /*! |
1150 | \internal | 1155 | \internal |
1151 | */ | 1156 | */ |
1157 | static QDate convVCardDateToDate( const QString& datestr ) | ||
1158 | { | ||
1159 | int monthPos = datestr.find('-'); | ||
1160 | int dayPos = datestr.find('-', monthPos+1 ); | ||
1161 | if ( monthPos == -1 || dayPos == -1 ) { | ||
1162 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | ||
1163 | return QDate(); | ||
1164 | } | ||
1165 | int y = datestr.left( monthPos ).toInt(); | ||
1166 | int m = datestr.mid( monthPos+1, dayPos - monthPos - 1 ).toInt(); | ||
1167 | int d = datestr.mid( dayPos+1 ).toInt(); | ||
1168 | QDate date ( y,m,d ); | ||
1169 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); | ||
1170 | return date; | ||
1171 | } | ||
1172 | |||
1152 | static OContact parseVObject( VObject *obj ) | 1173 | static OContact parseVObject( VObject *obj ) |
1153 | { | 1174 | { |
1154 | OContact c; | 1175 | OContact c; |
1155 | 1176 | ||
1156 | VObjectIterator it; | 1177 | VObjectIterator it; |
1157 | initPropIterator( &it, obj ); | 1178 | initPropIterator( &it, obj ); |
1158 | while( moreIteration( &it ) ) { | 1179 | while( moreIteration( &it ) ) { |
1159 | VObject *o = nextVObject( &it ); | 1180 | VObject *o = nextVObject( &it ); |
1160 | QCString name = vObjectName( o ); | 1181 | QCString name = vObjectName( o ); |
1161 | QCString value = vObjectStringZValue( o ); | 1182 | QCString value = vObjectStringZValue( o ); |
1162 | if ( name == VCNameProp ) { | 1183 | if ( name == VCNameProp ) { |
1163 | VObjectIterator nit; | 1184 | VObjectIterator nit; |
1164 | initPropIterator( &nit, o ); | 1185 | initPropIterator( &nit, o ); |
1165 | while( moreIteration( &nit ) ) { | 1186 | while( moreIteration( &nit ) ) { |
1166 | VObject *o = nextVObject( &nit ); | 1187 | VObject *o = nextVObject( &nit ); |
1167 | QCString name = vObjectTypeInfo( o ); | 1188 | QCString name = vObjectTypeInfo( o ); |
1168 | QString value = vObjectStringZValue( o ); | 1189 | QString value = vObjectStringZValue( o ); |
1169 | if ( name == VCNamePrefixesProp ) | 1190 | if ( name == VCNamePrefixesProp ) |
1170 | c.setTitle( value ); | 1191 | c.setTitle( value ); |
1171 | else if ( name == VCNameSuffixesProp ) | 1192 | else if ( name == VCNameSuffixesProp ) |
1172 | c.setSuffix( value ); | 1193 | c.setSuffix( value ); |
1173 | else if ( name == VCFamilyNameProp ) | 1194 | else if ( name == VCFamilyNameProp ) |
1174 | c.setLastName( value ); | 1195 | c.setLastName( value ); |
1175 | else if ( name == VCGivenNameProp ) | 1196 | else if ( name == VCGivenNameProp ) |
1176 | c.setFirstName( value ); | 1197 | c.setFirstName( value ); |
1177 | else if ( name == VCAdditionalNamesProp ) | 1198 | else if ( name == VCAdditionalNamesProp ) |
1178 | c.setMiddleName( value ); | 1199 | c.setMiddleName( value ); |
1179 | } | 1200 | } |
1180 | } | 1201 | } |
1181 | else if ( name == VCAdrProp ) { | 1202 | else if ( name == VCAdrProp ) { |
1182 | bool work = TRUE; // default address is work address | 1203 | bool work = TRUE; // default address is work address |
1183 | QString street; | 1204 | QString street; |
1184 | QString city; | 1205 | QString city; |
1185 | QString region; | 1206 | QString region; |
1186 | QString postal; | 1207 | QString postal; |
1187 | QString country; | 1208 | QString country; |
1188 | 1209 | ||
1189 | VObjectIterator nit; | 1210 | VObjectIterator nit; |
1190 | initPropIterator( &nit, o ); | 1211 | initPropIterator( &nit, o ); |
1191 | while( moreIteration( &nit ) ) { | 1212 | while( moreIteration( &nit ) ) { |
1192 | VObject *o = nextVObject( &nit ); | 1213 | VObject *o = nextVObject( &nit ); |
1193 | QCString name = vObjectName( o ); | 1214 | QCString name = vObjectName( o ); |
1194 | QString value = vObjectStringZValue( o ); | 1215 | QString value = vObjectStringZValue( o ); |
1195 | if ( name == VCHomeProp ) | 1216 | if ( name == VCHomeProp ) |
1196 | work = FALSE; | 1217 | work = FALSE; |
1197 | else if ( name == VCWorkProp ) | 1218 | else if ( name == VCWorkProp ) |
1198 | work = TRUE; | 1219 | work = TRUE; |
1199 | else if ( name == VCStreetAddressProp ) | 1220 | else if ( name == VCStreetAddressProp ) |
1200 | street = value; | 1221 | street = value; |
1201 | else if ( name == VCCityProp ) | 1222 | else if ( name == VCCityProp ) |
1202 | city = value; | 1223 | city = value; |
1203 | else if ( name == VCRegionProp ) | 1224 | else if ( name == VCRegionProp ) |
1204 | region = value; | 1225 | region = value; |
1205 | else if ( name == VCPostalCodeProp ) | 1226 | else if ( name == VCPostalCodeProp ) |
1206 | postal = value; | 1227 | postal = value; |
1207 | else if ( name == VCCountryNameProp ) | 1228 | else if ( name == VCCountryNameProp ) |
1208 | country = value; | 1229 | country = value; |
1209 | } | 1230 | } |
1210 | if ( work ) { | 1231 | if ( work ) { |
1211 | c.setBusinessStreet( street ); | 1232 | c.setBusinessStreet( street ); |
1212 | c.setBusinessCity( city ); | 1233 | c.setBusinessCity( city ); |
1213 | c.setBusinessCountry( country ); | 1234 | c.setBusinessCountry( country ); |
1214 | c.setBusinessZip( postal ); | 1235 | c.setBusinessZip( postal ); |
1215 | c.setBusinessState( region ); | 1236 | c.setBusinessState( region ); |
1216 | } else { | 1237 | } else { |
1217 | c.setHomeStreet( street ); | 1238 | c.setHomeStreet( street ); |
1218 | c.setHomeCity( city ); | 1239 | c.setHomeCity( city ); |
1219 | c.setHomeCountry( country ); | 1240 | c.setHomeCountry( country ); |
1220 | c.setHomeZip( postal ); | 1241 | c.setHomeZip( postal ); |
1221 | c.setHomeState( region ); | 1242 | c.setHomeState( region ); |
1222 | } | 1243 | } |
1223 | } | 1244 | } |
1224 | else if ( name == VCTelephoneProp ) { | 1245 | else if ( name == VCTelephoneProp ) { |
1225 | enum { | 1246 | enum { |
1226 | HOME = 0x01, | 1247 | HOME = 0x01, |
1227 | WORK = 0x02, | 1248 | WORK = 0x02, |
1228 | VOICE = 0x04, | 1249 | VOICE = 0x04, |
1229 | CELL = 0x08, | 1250 | CELL = 0x08, |
1230 | FAX = 0x10, | 1251 | FAX = 0x10, |
1231 | PAGER = 0x20, | 1252 | PAGER = 0x20, |
1232 | UNKNOWN = 0x80 | 1253 | UNKNOWN = 0x80 |
1233 | }; | 1254 | }; |
1234 | int type = 0; | 1255 | int type = 0; |
1235 | 1256 | ||
1236 | VObjectIterator nit; | 1257 | VObjectIterator nit; |
1237 | initPropIterator( &nit, o ); | 1258 | initPropIterator( &nit, o ); |
1238 | while( moreIteration( &nit ) ) { | 1259 | while( moreIteration( &nit ) ) { |
1239 | VObject *o = nextVObject( &nit ); | 1260 | VObject *o = nextVObject( &nit ); |
1240 | QCString name = vObjectTypeInfo( o ); | 1261 | QCString name = vObjectTypeInfo( o ); |
1241 | if ( name == VCHomeProp ) | 1262 | if ( name == VCHomeProp ) |
1242 | type |= HOME; | 1263 | type |= HOME; |
1243 | else if ( name == VCWorkProp ) | 1264 | else if ( name == VCWorkProp ) |
1244 | type |= WORK; | 1265 | type |= WORK; |
1245 | else if ( name == VCVoiceProp ) | 1266 | else if ( name == VCVoiceProp ) |
1246 | type |= VOICE; | 1267 | type |= VOICE; |
1247 | else if ( name == VCCellularProp ) | 1268 | else if ( name == VCCellularProp ) |
1248 | type |= CELL; | 1269 | type |= CELL; |
1249 | else if ( name == VCFaxProp ) | 1270 | else if ( name == VCFaxProp ) |
1250 | type |= FAX; | 1271 | type |= FAX; |
1251 | else if ( name == VCPagerProp ) | 1272 | else if ( name == VCPagerProp ) |
1252 | type |= PAGER; | 1273 | type |= PAGER; |
1253 | else if ( name == VCPreferredProp ) | 1274 | else if ( name == VCPreferredProp ) |
1254 | ; | 1275 | ; |
1255 | else | 1276 | else |
1256 | type |= UNKNOWN; | 1277 | type |= UNKNOWN; |
1257 | } | 1278 | } |
1258 | if ( (type & UNKNOWN) != UNKNOWN ) { | 1279 | if ( (type & UNKNOWN) != UNKNOWN ) { |
1259 | if ( ( type & (HOME|WORK) ) == 0 ) // default | 1280 | if ( ( type & (HOME|WORK) ) == 0 ) // default |
1260 | type |= HOME; | 1281 | type |= HOME; |
1261 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default | 1282 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default |
1262 | type |= VOICE; | 1283 | type |= VOICE; |
1263 | 1284 | ||
1264 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) | 1285 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) |
1265 | c.setHomePhone( value ); | 1286 | c.setHomePhone( value ); |
1266 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) | 1287 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) |
1267 | c.setHomeFax( value ); | 1288 | c.setHomeFax( value ); |
1268 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) | 1289 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) |
1269 | c.setHomeMobile( value ); | 1290 | c.setHomeMobile( value ); |
1270 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) | 1291 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) |
1271 | c.setBusinessPhone( value ); | 1292 | c.setBusinessPhone( value ); |
1272 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) | 1293 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) |
1273 | c.setBusinessFax( value ); | 1294 | c.setBusinessFax( value ); |
1274 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) | 1295 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) |
1275 | c.setBusinessMobile( value ); | 1296 | c.setBusinessMobile( value ); |
1276 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) | 1297 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) |
1277 | c.setBusinessPager( value ); | 1298 | c.setBusinessPager( value ); |
1278 | } | 1299 | } |
1279 | } | 1300 | } |
1280 | else if ( name == VCEmailAddressProp ) { | 1301 | else if ( name == VCEmailAddressProp ) { |
1281 | QString email = vObjectStringZValue( o ); | 1302 | QString email = vObjectStringZValue( o ); |
1282 | bool valid = TRUE; | 1303 | bool valid = TRUE; |
1283 | VObjectIterator nit; | 1304 | VObjectIterator nit; |
1284 | initPropIterator( &nit, o ); | 1305 | initPropIterator( &nit, o ); |
1285 | while( moreIteration( &nit ) ) { | 1306 | while( moreIteration( &nit ) ) { |
1286 | VObject *o = nextVObject( &nit ); | 1307 | VObject *o = nextVObject( &nit ); |
1287 | QCString name = vObjectTypeInfo( o ); | 1308 | QCString name = vObjectTypeInfo( o ); |
1288 | if ( name != VCInternetProp && name != VCHomeProp && | 1309 | if ( name != VCInternetProp && name != VCHomeProp && |
1289 | name != VCWorkProp && | 1310 | name != VCWorkProp && |
1290 | name != VCPreferredProp ) | 1311 | name != VCPreferredProp ) |
1291 | // ### preffered should map to default email | 1312 | // ### preffered should map to default email |
1292 | valid = FALSE; | 1313 | valid = FALSE; |
1293 | } | 1314 | } |
1294 | if ( valid ) { | 1315 | if ( valid ) { |
1295 | c.insertEmail( email ); | 1316 | c.insertEmail( email ); |
1296 | } | 1317 | } |
1297 | } | 1318 | } |
1298 | else if ( name == VCURLProp ) { | 1319 | else if ( name == VCURLProp ) { |
1299 | VObjectIterator nit; | 1320 | VObjectIterator nit; |
1300 | initPropIterator( &nit, o ); | 1321 | initPropIterator( &nit, o ); |
1301 | while( moreIteration( &nit ) ) { | 1322 | while( moreIteration( &nit ) ) { |
1302 | VObject *o = nextVObject( &nit ); | 1323 | VObject *o = nextVObject( &nit ); |
1303 | QCString name = vObjectTypeInfo( o ); | 1324 | QCString name = vObjectTypeInfo( o ); |
1304 | if ( name == VCHomeProp ) | 1325 | if ( name == VCHomeProp ) |
1305 | c.setHomeWebpage( value ); | 1326 | c.setHomeWebpage( value ); |
1306 | else if ( name == VCWorkProp ) | 1327 | else if ( name == VCWorkProp ) |
1307 | c.setBusinessWebpage( value ); | 1328 | c.setBusinessWebpage( value ); |
1308 | } | 1329 | } |
1309 | } | 1330 | } |
1310 | else if ( name == VCOrgProp ) { | 1331 | else if ( name == VCOrgProp ) { |
1311 | VObjectIterator nit; | 1332 | VObjectIterator nit; |
1312 | initPropIterator( &nit, o ); | 1333 | initPropIterator( &nit, o ); |
1313 | while( moreIteration( &nit ) ) { | 1334 | while( moreIteration( &nit ) ) { |
1314 | VObject *o = nextVObject( &nit ); | 1335 | VObject *o = nextVObject( &nit ); |
1315 | QCString name = vObjectName( o ); | 1336 | QCString name = vObjectName( o ); |
1316 | QString value = vObjectStringZValue( o ); | 1337 | QString value = vObjectStringZValue( o ); |
1317 | if ( name == VCOrgNameProp ) | 1338 | if ( name == VCOrgNameProp ) |
1318 | c.setCompany( value ); | 1339 | c.setCompany( value ); |
1319 | else if ( name == VCOrgUnitProp ) | 1340 | else if ( name == VCOrgUnitProp ) |
1320 | c.setDepartment( value ); | 1341 | c.setDepartment( value ); |
1321 | else if ( name == VCOrgUnit2Prop ) | 1342 | else if ( name == VCOrgUnit2Prop ) |
1322 | c.setOffice( value ); | 1343 | c.setOffice( value ); |
1323 | } | 1344 | } |
1324 | } | 1345 | } |
1325 | else if ( name == VCTitleProp ) { | 1346 | else if ( name == VCTitleProp ) { |
1326 | c.setJobTitle( value ); | 1347 | c.setJobTitle( value ); |
1327 | } | 1348 | } |
1328 | else if ( name == "X-Qtopia-Profession" ) { | 1349 | else if ( name == "X-Qtopia-Profession" ) { |
1329 | c.setProfession( value ); | 1350 | c.setProfession( value ); |
1330 | } | 1351 | } |
1331 | else if ( name == "X-Qtopia-Manager" ) { | 1352 | else if ( name == "X-Qtopia-Manager" ) { |
1332 | c.setManager( value ); | 1353 | c.setManager( value ); |
1333 | } | 1354 | } |
1334 | else if ( name == "X-Qtopia-Assistant" ) { | 1355 | else if ( name == "X-Qtopia-Assistant" ) { |
1335 | c.setAssistant( value ); | 1356 | c.setAssistant( value ); |
1336 | } | 1357 | } |
1337 | else if ( name == "X-Qtopia-Spouse" ) { | 1358 | else if ( name == "X-Qtopia-Spouse" ) { |
1338 | c.setSpouse( value ); | 1359 | c.setSpouse( value ); |
1339 | } | 1360 | } |
1340 | else if ( name == "X-Qtopia-Gender" ) { | 1361 | else if ( name == "X-Qtopia-Gender" ) { |
1341 | c.setGender( value ); | 1362 | c.setGender( value ); |
1342 | } | 1363 | } |
1343 | else if ( name == "X-Qtopia-Anniversary" ) { | 1364 | else if ( name == "X-Qtopia-Anniversary" ) { |
1344 | c.setAnniversary( TimeConversion::fromString( value ) ); | 1365 | c.setAnniversary( TimeConversion::fromString( value ) ); |
1345 | } | 1366 | } |
1346 | else if ( name == "X-Qtopia-Nickname" ) { | 1367 | else if ( name == "X-Qtopia-Nickname" ) { |
1347 | c.setNickname( value ); | 1368 | c.setNickname( value ); |
1348 | } | 1369 | } |
1349 | else if ( name == "X-Qtopia-Children" ) { | 1370 | else if ( name == "X-Qtopia-Children" ) { |
1350 | c.setChildren( value ); | 1371 | c.setChildren( value ); |
1372 | } | ||
1373 | else if ( name == VCBirthDateProp ) { | ||
1374 | // Reading Birthdate regarding RFC 2425 (5.8.4) | ||
1375 | c.setBirthday( convVCardDateToDate( value ) ); | ||
1376 | |||
1351 | } | 1377 | } |
1352 | 1378 | ||
1353 | |||
1354 | #if 0 | 1379 | #if 0 |
1355 | else { | 1380 | else { |
1356 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 1381 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
1357 | VObjectIterator nit; | 1382 | VObjectIterator nit; |
1358 | initPropIterator( &nit, o ); | 1383 | initPropIterator( &nit, o ); |
1359 | while( moreIteration( &nit ) ) { | 1384 | while( moreIteration( &nit ) ) { |
1360 | VObject *o = nextVObject( &nit ); | 1385 | VObject *o = nextVObject( &nit ); |
1361 | QCString name = vObjectName( o ); | 1386 | QCString name = vObjectName( o ); |
1362 | QString value = vObjectStringZValue( o ); | 1387 | QString value = vObjectStringZValue( o ); |
1363 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 1388 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
1364 | } | 1389 | } |
1365 | } | 1390 | } |
1366 | #endif | 1391 | #endif |
1367 | } | 1392 | } |
1368 | c.setFileAs(); | 1393 | c.setFileAs(); |
1369 | return c; | 1394 | return c; |
1370 | } | 1395 | } |
1371 | 1396 | ||
1372 | /*! | 1397 | /*! |
1373 | Writes the list of \a contacts as a set of VCards to the file \a filename. | 1398 | Writes the list of \a contacts as a set of VCards to the file \a filename. |
1374 | */ | 1399 | */ |
1375 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) | 1400 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) |
1376 | { | 1401 | { |
1377 | QFileDirect f( filename.utf8().data() ); | 1402 | QFileDirect f( filename.utf8().data() ); |
1378 | if ( !f.open( IO_WriteOnly ) ) { | 1403 | if ( !f.open( IO_WriteOnly ) ) { |
1379 | qWarning("Unable to open vcard write"); | 1404 | qWarning("Unable to open vcard write"); |
1380 | return; | 1405 | return; |
1381 | } | 1406 | } |
1382 | 1407 | ||
1383 | QValueList<OContact>::ConstIterator it; | 1408 | QValueList<OContact>::ConstIterator it; |
1384 | for( it = contacts.begin(); it != contacts.end(); ++it ) { | 1409 | for( it = contacts.begin(); it != contacts.end(); ++it ) { |
1385 | VObject *obj = createVObject( *it ); | 1410 | VObject *obj = createVObject( *it ); |
1386 | writeVObject(f.directHandle() , obj ); | 1411 | writeVObject(f.directHandle() , obj ); |
1387 | cleanVObject( obj ); | 1412 | cleanVObject( obj ); |
1388 | } | 1413 | } |
1389 | cleanStrTbl(); | 1414 | cleanStrTbl(); |
1390 | } | 1415 | } |
1391 | 1416 | ||
1392 | /*! | 1417 | /*! |
1393 | writes \a contact as a VCard to the file \a filename. | 1418 | writes \a contact as a VCard to the file \a filename. |
1394 | */ | 1419 | */ |
1395 | void OContact::writeVCard( const QString &filename, const OContact &contact) | 1420 | void OContact::writeVCard( const QString &filename, const OContact &contact) |
1396 | { | 1421 | { |
1397 | QFileDirect f( filename.utf8().data() ); | 1422 | QFileDirect f( filename.utf8().data() ); |
1398 | if ( !f.open( IO_WriteOnly ) ) { | 1423 | if ( !f.open( IO_WriteOnly ) ) { |
1399 | qWarning("Unable to open vcard write"); | 1424 | qWarning("Unable to open vcard write"); |
1400 | return; | 1425 | return; |
1401 | } | 1426 | } |
1402 | 1427 | ||
1403 | VObject *obj = createVObject( contact ); | 1428 | VObject *obj = createVObject( contact ); |
1404 | writeVObject( f.directHandle() , obj ); | 1429 | writeVObject( f.directHandle() , obj ); |
1405 | cleanVObject( obj ); | 1430 | cleanVObject( obj ); |
1406 | 1431 | ||
1407 | cleanStrTbl(); | 1432 | cleanStrTbl(); |
1408 | } | 1433 | } |
1409 | 1434 | ||
1410 | /*! | 1435 | /*! |
1411 | Returns the set of contacts read as VCards from the file \a filename. | 1436 | Returns the set of contacts read as VCards from the file \a filename. |
1412 | */ | 1437 | */ |
1413 | QValueList<OContact> OContact::readVCard( const QString &filename ) | 1438 | QValueList<OContact> OContact::readVCard( const QString &filename ) |
1414 | { | 1439 | { |
1415 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 1440 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
1416 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 1441 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
1417 | 1442 | ||
1418 | qDebug("vobject = %p", obj ); | 1443 | qDebug("vobject = %p", obj ); |
1419 | 1444 | ||
1420 | QValueList<OContact> contacts; | 1445 | QValueList<OContact> contacts; |
1421 | 1446 | ||
1422 | while ( obj ) { | 1447 | while ( obj ) { |
1423 | contacts.append( parseVObject( obj ) ); | 1448 | contacts.append( parseVObject( obj ) ); |
1424 | 1449 | ||
1425 | VObject *t = obj; | 1450 | VObject *t = obj; |
1426 | obj = nextVObjectInList(obj); | 1451 | obj = nextVObjectInList(obj); |
1427 | cleanVObject( t ); | 1452 | cleanVObject( t ); |
1428 | } | 1453 | } |
1429 | 1454 | ||
1430 | return contacts; | 1455 | return contacts; |
1431 | } | 1456 | } |
1432 | 1457 | ||
1433 | /*! | 1458 | /*! |
1434 | Returns TRUE if the contact matches the regular expression \a regexp. | 1459 | Returns TRUE if the contact matches the regular expression \a regexp. |
1435 | Otherwise returns FALSE. | 1460 | Otherwise returns FALSE. |
1436 | */ | 1461 | */ |
1437 | bool OContact::match( const QString ®exp ) const | 1462 | bool OContact::match( const QString ®exp ) const |
1438 | { | 1463 | { |
1439 | return match(QRegExp(regexp)); | 1464 | return match(QRegExp(regexp)); |
1440 | } | 1465 | } |
1441 | 1466 | ||
1442 | /*! | 1467 | /*! |
1443 | \overload | 1468 | \overload |
1444 | Returns TRUE if the contact matches the regular expression \a regexp. | 1469 | Returns TRUE if the contact matches the regular expression \a regexp. |
1445 | Otherwise returns FALSE. | 1470 | Otherwise returns FALSE. |
1446 | */ | 1471 | */ |
1447 | bool OContact::match( const QRegExp &r ) const | 1472 | bool OContact::match( const QRegExp &r ) const |
1448 | { | 1473 | { |
1449 | bool match; | 1474 | bool match; |
1450 | match = false; | 1475 | match = false; |
1451 | QMap<int, QString>::ConstIterator it; | 1476 | QMap<int, QString>::ConstIterator it; |
1452 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 1477 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
1453 | if ( (*it).find( r ) > -1 ) { | 1478 | if ( (*it).find( r ) > -1 ) { |
1454 | match = true; | 1479 | match = true; |
1455 | break; | 1480 | break; |
1456 | } | 1481 | } |
1457 | } | 1482 | } |
1458 | return match; | 1483 | return match; |
1459 | } | 1484 | } |
1460 | 1485 | ||
1461 | 1486 | ||
1462 | QString OContact::toShortText() const | 1487 | QString OContact::toShortText() const |
1463 | { | 1488 | { |
1464 | return ( fullName() ); | 1489 | return ( fullName() ); |
1465 | } | 1490 | } |
1466 | QString OContact::type() const | 1491 | QString OContact::type() const |
1467 | { | 1492 | { |
1468 | return QString::fromLatin1( "OContact" ); | 1493 | return QString::fromLatin1( "OContact" ); |
1469 | } | 1494 | } |
1470 | 1495 | ||
1471 | // Definition is missing ! (se) | 1496 | // Definition is missing ! (se) |
1472 | QMap<QString,QString> OContact::toExtraMap() const | 1497 | QMap<QString,QString> OContact::toExtraMap() const |
1473 | { | 1498 | { |
1474 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 1499 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
1475 | QMap <QString,QString> useless; | 1500 | QMap <QString,QString> useless; |
1476 | return useless; | 1501 | return useless; |
1477 | } | 1502 | } |
1478 | 1503 | ||
1479 | class QString OContact::recordField( int pos ) const | 1504 | class QString OContact::recordField( int pos ) const |
1480 | { | 1505 | { |
1481 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 1506 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
1482 | return SLFIELDS[pos]; | 1507 | return SLFIELDS[pos]; |
1483 | } | 1508 | } |
1484 | 1509 | ||
1485 | // In future releases, we should store birthday and anniversary | 1510 | // In future releases, we should store birthday and anniversary |
1486 | // internally as QDate instead of QString ! | 1511 | // internally as QDate instead of QString ! |
1487 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1512 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1488 | 1513 | ||
1489 | /*! \fn void OContact::setBirthday( const QDate& date ) | 1514 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1490 | Sets the birthday for the contact to \a date. | 1515 | Sets the birthday for the contact to \a date. |
1491 | */ | 1516 | */ |
1492 | void OContact::setBirthday( const QDate &v ) | 1517 | void OContact::setBirthday( const QDate &v ) |
1493 | { | 1518 | { |
1494 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1519 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1495 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); | 1520 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); |
1496 | 1521 | ||
1497 | } | 1522 | } |
1498 | 1523 | ||
1499 | 1524 | ||
1500 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1525 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1501 | Sets the anniversary of the contact to \a date. | 1526 | Sets the anniversary of the contact to \a date. |
1502 | */ | 1527 | */ |
1503 | void OContact::setAnniversary( const QDate &v ) | 1528 | void OContact::setAnniversary( const QDate &v ) |
1504 | { | 1529 | { |
1505 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1530 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1506 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); | 1531 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); |
1507 | } | 1532 | } |
1508 | 1533 | ||
1509 | /*! \fn QDate OContact::birthday() const | 1534 | /*! \fn QDate OContact::birthday() const |
1510 | Returns the birthday of the contact. | 1535 | Returns the birthday of the contact. |
1511 | */ | 1536 | */ |
1512 | QDate OContact::birthday() const | 1537 | QDate OContact::birthday() const |
1513 | { | 1538 | { |
1514 | QDate empty; | 1539 | QDate empty; |
1515 | QString str = find( Qtopia::Birthday ); | 1540 | QString str = find( Qtopia::Birthday ); |
1516 | qWarning ("Birthday %s", str.latin1() ); | 1541 | qWarning ("Birthday %s", str.latin1() ); |
1517 | if ( !str.isEmpty() ) | 1542 | if ( !str.isEmpty() ) |
1518 | return TimeConversion::fromString ( str ); | 1543 | return TimeConversion::fromString ( str ); |
1519 | else | 1544 | else |
1520 | return empty; | 1545 | return empty; |
1521 | } | 1546 | } |
1522 | 1547 | ||
1523 | 1548 | ||
1524 | /*! \fn QDate OContact::anniversary() const | 1549 | /*! \fn QDate OContact::anniversary() const |
1525 | Returns the anniversary of the contact. | 1550 | Returns the anniversary of the contact. |
1526 | */ | 1551 | */ |
1527 | QDate OContact::anniversary() const | 1552 | QDate OContact::anniversary() const |
1528 | { | 1553 | { |
1529 | QDate empty; | 1554 | QDate empty; |
1530 | QString str = find( Qtopia::Anniversary ); | 1555 | QString str = find( Qtopia::Anniversary ); |
1531 | qWarning ("Anniversary %s", str.latin1() ); | 1556 | qWarning ("Anniversary %s", str.latin1() ); |
1532 | if ( !str.isEmpty() ) | 1557 | if ( !str.isEmpty() ) |
1533 | return TimeConversion::fromString ( str ); | 1558 | return TimeConversion::fromString ( str ); |
1534 | else | 1559 | else |
1535 | return empty; | 1560 | return empty; |
1536 | } | 1561 | } |
1537 | 1562 | ||
1538 | 1563 | ||
1539 | void OContact::insertEmail( const QString &v ) | 1564 | void OContact::insertEmail( const QString &v ) |
1540 | { | 1565 | { |
1541 | //qDebug("insertEmail %s", v.latin1()); | 1566 | //qDebug("insertEmail %s", v.latin1()); |
1542 | QString e = v.simplifyWhiteSpace(); | 1567 | QString e = v.simplifyWhiteSpace(); |
1543 | QString def = defaultEmail(); | 1568 | QString def = defaultEmail(); |
1544 | 1569 | ||
1545 | // if no default, set it as the default email and don't insert | 1570 | // if no default, set it as the default email and don't insert |
1546 | if ( def.isEmpty() ) { | 1571 | if ( def.isEmpty() ) { |
1547 | setDefaultEmail( e ); // will insert into the list for us | 1572 | setDefaultEmail( e ); // will insert into the list for us |
1548 | return; | 1573 | return; |
1549 | } | 1574 | } |
1550 | 1575 | ||
1551 | // otherwise, insert assuming doesn't already exist | 1576 | // otherwise, insert assuming doesn't already exist |
1552 | QString emailsStr = find( Qtopia::Emails ); | 1577 | QString emailsStr = find( Qtopia::Emails ); |
1553 | if ( emailsStr.contains( e )) | 1578 | if ( emailsStr.contains( e )) |
1554 | return; | 1579 | return; |
1555 | if ( !emailsStr.isEmpty() ) | 1580 | if ( !emailsStr.isEmpty() ) |
1556 | emailsStr += emailSeparator(); | 1581 | emailsStr += emailSeparator(); |
1557 | emailsStr += e; | 1582 | emailsStr += e; |
1558 | replace( Qtopia::Emails, emailsStr ); | 1583 | replace( Qtopia::Emails, emailsStr ); |
1559 | } | 1584 | } |
1560 | 1585 | ||
1561 | void OContact::removeEmail( const QString &v ) | 1586 | void OContact::removeEmail( const QString &v ) |
1562 | { | 1587 | { |
1563 | QString e = v.simplifyWhiteSpace(); | 1588 | QString e = v.simplifyWhiteSpace(); |
1564 | QString def = defaultEmail(); | 1589 | QString def = defaultEmail(); |
1565 | QString emailsStr = find( Qtopia::Emails ); | 1590 | QString emailsStr = find( Qtopia::Emails ); |
1566 | QStringList emails = emailList(); | 1591 | QStringList emails = emailList(); |
1567 | 1592 | ||
1568 | // otherwise, must first contain it | 1593 | // otherwise, must first contain it |
1569 | if ( !emailsStr.contains( e ) ) | 1594 | if ( !emailsStr.contains( e ) ) |
1570 | return; | 1595 | return; |
1571 | 1596 | ||
1572 | // remove it | 1597 | // remove it |
1573 | //qDebug(" removing email from list %s", e.latin1()); | 1598 | //qDebug(" removing email from list %s", e.latin1()); |
1574 | emails.remove( e ); | 1599 | emails.remove( e ); |
1575 | // reset the string | 1600 | // reset the string |
1576 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | 1601 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator |
1577 | replace( Qtopia::Emails, emailsStr ); | 1602 | replace( Qtopia::Emails, emailsStr ); |
1578 | 1603 | ||
1579 | // if default, then replace the default email with the first one | 1604 | // if default, then replace the default email with the first one |
1580 | if ( def == e ) { | 1605 | if ( def == e ) { |
1581 | //qDebug("removeEmail is default; setting new default"); | 1606 | //qDebug("removeEmail is default; setting new default"); |
1582 | if ( !emails.count() ) | 1607 | if ( !emails.count() ) |
1583 | clearEmails(); | 1608 | clearEmails(); |
1584 | else // setDefaultEmail will remove e from the list | 1609 | else // setDefaultEmail will remove e from the list |
1585 | setDefaultEmail( emails.first() ); | 1610 | setDefaultEmail( emails.first() ); |
1586 | } | 1611 | } |
1587 | } | 1612 | } |
1588 | void OContact::clearEmails() | 1613 | void OContact::clearEmails() |
1589 | { | 1614 | { |
1590 | mMap.remove( Qtopia::DefaultEmail ); | 1615 | mMap.remove( Qtopia::DefaultEmail ); |
1591 | mMap.remove( Qtopia::Emails ); | 1616 | mMap.remove( Qtopia::Emails ); |
1592 | } | 1617 | } |
1593 | void OContact::setDefaultEmail( const QString &v ) | 1618 | void OContact::setDefaultEmail( const QString &v ) |
1594 | { | 1619 | { |
1595 | QString e = v.simplifyWhiteSpace(); | 1620 | QString e = v.simplifyWhiteSpace(); |
1596 | 1621 | ||
1597 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | 1622 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); |
1598 | replace( Qtopia::DefaultEmail, e ); | 1623 | replace( Qtopia::DefaultEmail, e ); |
1599 | 1624 | ||
1600 | if ( !e.isEmpty() ) | 1625 | if ( !e.isEmpty() ) |
1601 | insertEmail( e ); | 1626 | insertEmail( e ); |
1602 | 1627 | ||
1603 | } | 1628 | } |
1604 | 1629 | ||
1605 | void OContact::insertEmails( const QStringList &v ) | 1630 | void OContact::insertEmails( const QStringList &v ) |
1606 | { | 1631 | { |
1607 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1632 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
1608 | insertEmail( *it ); | 1633 | insertEmail( *it ); |
1609 | } | 1634 | } |
1635 | |||
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index 9e83150..382ab94 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h | |||
@@ -1,245 +1,246 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Qtopia Environment. | 5 | ** This file is part of the Qtopia Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef __OCONTACT_H__ | 22 | #ifndef __OCONTACT_H__ |
23 | #define __OCONTACT_H__ | 23 | #define __OCONTACT_H__ |
24 | 24 | ||
25 | #include <opie/opimrecord.h> | 25 | #include <opie/opimrecord.h> |
26 | #include <qpe/recordfields.h> | 26 | #include <qpe/recordfields.h> |
27 | 27 | ||
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | 30 | ||
31 | #if defined(QPC_TEMPLATEDLL) | 31 | #if defined(QPC_TEMPLATEDLL) |
32 | // MOC_SKIP_BEGIN | 32 | // MOC_SKIP_BEGIN |
33 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; | 33 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
34 | // MOC_SKIP_END | 34 | // MOC_SKIP_END |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) | 37 | class ContactPrivate; // Wozu ist das gut und wo ist das decrariert ? (se) |
38 | class QPC_EXPORT OContact : public OPimRecord | 38 | class QPC_EXPORT OContact : public OPimRecord |
39 | { | 39 | { |
40 | friend class DataSet; | 40 | friend class DataSet; |
41 | public: | 41 | public: |
42 | OContact(); | 42 | OContact(); |
43 | OContact( const QMap<int, QString> &fromMap ); | 43 | OContact( const QMap<int, QString> &fromMap ); |
44 | virtual ~OContact(); | 44 | virtual ~OContact(); |
45 | 45 | ||
46 | static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); | 46 | static void writeVCard( const QString &filename, const QValueList<OContact> &contacts); |
47 | static void writeVCard( const QString &filename, const OContact &c ); | 47 | static void writeVCard( const QString &filename, const OContact &c ); |
48 | static QValueList<OContact> readVCard( const QString &filename ); | 48 | static QValueList<OContact> readVCard( const QString &filename ); |
49 | 49 | ||
50 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | 50 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; |
51 | 51 | ||
52 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 52 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
53 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 53 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
54 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 54 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
55 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 55 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
56 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 56 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
57 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 57 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
58 | void setFileAs(); | 58 | void setFileAs(); |
59 | 59 | ||
60 | // default email address | 60 | // default email address |
61 | void setDefaultEmail( const QString &v ); | 61 | void setDefaultEmail( const QString &v ); |
62 | // inserts email to list and ensure's doesn't already exist | 62 | // inserts email to list and ensure's doesn't already exist |
63 | void insertEmail( const QString &v ); | 63 | void insertEmail( const QString &v ); |
64 | void removeEmail( const QString &v ); | 64 | void removeEmail( const QString &v ); |
65 | void clearEmails(); | 65 | void clearEmails(); |
66 | void insertEmails( const QStringList &v ); | 66 | void insertEmails( const QStringList &v ); |
67 | 67 | ||
68 | // home | 68 | // home |
69 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 69 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
70 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 70 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
71 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 71 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
72 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 72 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
73 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 73 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
74 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 74 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
75 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 75 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
76 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 76 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
77 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 77 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
78 | 78 | ||
79 | // business | 79 | // business |
80 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 80 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
81 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 81 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
82 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 82 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
83 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 83 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
84 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 84 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
85 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 85 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
86 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 86 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
87 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 87 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
88 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 88 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
89 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 89 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
90 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 90 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
91 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 91 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
92 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 92 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
93 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 93 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
94 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 94 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
95 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 95 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
96 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 96 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
97 | 97 | ||
98 | // personal | 98 | // personal |
99 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 99 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
100 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 100 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
101 | void setBirthday( const QDate &v ); | 101 | void setBirthday( const QDate &v ); |
102 | void setAnniversary( const QDate &v ); | 102 | void setAnniversary( const QDate &v ); |
103 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 103 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
104 | void setChildren( const QString &v ); | 104 | void setChildren( const QString &v ); |
105 | 105 | ||
106 | // other | 106 | // other |
107 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 107 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
108 | 108 | ||
109 | bool match( const QString ®exp ) const; | 109 | bool match( const QString ®exp ) const; |
110 | 110 | ||
111 | // DON'T ATTEMPT TO USE THIS | 111 | // DON'T ATTEMPT TO USE THIS |
112 | #ifdef QTOPIA_INTERNAL_CONTACT_MRE | 112 | #ifdef QTOPIA_INTERNAL_CONTACT_MRE |
113 | bool match( const QRegExp ®exp ) const; | 113 | bool match( const QRegExp ®exp ) const; |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | // // custom | 116 | // // custom |
117 | // void setCustomField( const QString &key, const QString &v ) | 117 | // void setCustomField( const QString &key, const QString &v ) |
118 | // { replace(Custom- + key, v ); } | 118 | // { replace(Custom- + key, v ); } |
119 | 119 | ||
120 | // name | 120 | // name |
121 | QString fullName() const; | 121 | QString fullName() const; |
122 | QString title() const { return find( Qtopia::Title ); } | 122 | QString title() const { return find( Qtopia::Title ); } |
123 | QString firstName() const { return find( Qtopia::FirstName ); } | 123 | QString firstName() const { return find( Qtopia::FirstName ); } |
124 | QString middleName() const { return find( Qtopia::MiddleName ); } | 124 | QString middleName() const { return find( Qtopia::MiddleName ); } |
125 | QString lastName() const { return find( Qtopia::LastName ); } | 125 | QString lastName() const { return find( Qtopia::LastName ); } |
126 | QString suffix() const { return find( Qtopia::Suffix ); } | 126 | QString suffix() const { return find( Qtopia::Suffix ); } |
127 | QString fileAs() const { return find( Qtopia::FileAs ); } | 127 | QString fileAs() const { return find( Qtopia::FileAs ); } |
128 | 128 | ||
129 | 129 | ||
130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
131 | QStringList emailList() const; | 131 | QStringList emailList() const; |
132 | 132 | ||
133 | // home | 133 | // home |
134 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 134 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
135 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 135 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
136 | QString homeState() const { return find( Qtopia::HomeState ); } | 136 | QString homeState() const { return find( Qtopia::HomeState ); } |
137 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 137 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
138 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 138 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
139 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 139 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
140 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 140 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
141 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 141 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
142 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 142 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
143 | /** Multi line string containing all non-empty address info in the form | 143 | /** Multi line string containing all non-empty address info in the form |
144 | * Street | 144 | * Street |
145 | * City, State Zip | 145 | * City, State Zip |
146 | * Country | 146 | * Country |
147 | */ | 147 | */ |
148 | QString displayHomeAddress() const; | 148 | QString displayHomeAddress() const; |
149 | 149 | ||
150 | // business | 150 | // business |
151 | QString company() const { return find( Qtopia::Company ); } | 151 | QString company() const { return find( Qtopia::Company ); } |
152 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 152 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
153 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 153 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
154 | QString businessState() const { return find( Qtopia::BusinessState ); } | 154 | QString businessState() const { return find( Qtopia::BusinessState ); } |
155 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 155 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
156 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 156 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
157 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 157 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
158 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 158 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
159 | QString department() const { return find( Qtopia::Department ); } | 159 | QString department() const { return find( Qtopia::Department ); } |
160 | QString office() const { return find( Qtopia::Office ); } | 160 | QString office() const { return find( Qtopia::Office ); } |
161 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 161 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
162 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 162 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
163 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 163 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
164 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 164 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
165 | QString profession() const { return find( Qtopia::Profession ); } | 165 | QString profession() const { return find( Qtopia::Profession ); } |
166 | QString assistant() const { return find( Qtopia::Assistant ); } | 166 | QString assistant() const { return find( Qtopia::Assistant ); } |
167 | QString manager() const { return find( Qtopia::Manager ); } | 167 | QString manager() const { return find( Qtopia::Manager ); } |
168 | /** Multi line string containing all non-empty address info in the form | 168 | /** Multi line string containing all non-empty address info in the form |
169 | * Street | 169 | * Street |
170 | * City, State Zip | 170 | * City, State Zip |
171 | * Country | 171 | * Country |
172 | */ | 172 | */ |
173 | QString displayBusinessAddress() const; | 173 | QString displayBusinessAddress() const; |
174 | 174 | ||
175 | //personal | 175 | //personal |
176 | QString spouse() const { return find( Qtopia::Spouse ); } | 176 | QString spouse() const { return find( Qtopia::Spouse ); } |
177 | QString gender() const { return find( Qtopia::Gender ); } | 177 | QString gender() const { return find( Qtopia::Gender ); } |
178 | QDate birthday() const; | 178 | QDate birthday() const; |
179 | QDate anniversary() const; | 179 | QDate anniversary() const; |
180 | QString nickname() const { return find( Qtopia::Nickname ); } | 180 | QString nickname() const { return find( Qtopia::Nickname ); } |
181 | QString children() const { return find( Qtopia::Children ); } | 181 | QString children() const { return find( Qtopia::Children ); } |
182 | QStringList childrenList() const; | 182 | QStringList childrenList() const; |
183 | 183 | ||
184 | // other | 184 | // other |
185 | QString notes() const { return find( Qtopia::Notes ); } | 185 | QString notes() const { return find( Qtopia::Notes ); } |
186 | QString groups() const { return find( Qtopia::Groups ); } | 186 | QString groups() const { return find( Qtopia::Groups ); } |
187 | QStringList groupList() const; | 187 | QStringList groupList() const; |
188 | 188 | ||
189 | // // custom | 189 | // // custom |
190 | // const QString &customField( const QString &key ) | 190 | // const QString &customField( const QString &key ) |
191 | // { return find( Custom- + key ); } | 191 | // { return find( Custom- + key ); } |
192 | 192 | ||
193 | static QStringList fields(); | 193 | static QStringList fields(); |
194 | static QStringList trfields(); | 194 | static QStringList trfields(); |
195 | static QStringList untrfields(); | 195 | static QStringList untrfields(); |
196 | 196 | ||
197 | QString toRichText() const; | 197 | QString toRichText() const; |
198 | QMap<int, QString> toMap() const; | 198 | QMap<int, QString> toMap() const; |
199 | QString field( int key ) const { return find( key ); } | 199 | QString field( int key ) const { return find( key ); } |
200 | 200 | ||
201 | 201 | ||
202 | // journaling... | 202 | // journaling... |
203 | void saveJournal( journal_action action, const QString &key = QString::null ); | 203 | void saveJournal( journal_action action, const QString &key = QString::null ); |
204 | void save( QString &buf ) const; | 204 | void save( QString &buf ) const; |
205 | 205 | ||
206 | void setUid( int i ) | 206 | void setUid( int i ) |
207 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } | 207 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } |
208 | 208 | ||
209 | QString toShortText()const; | 209 | QString toShortText()const; |
210 | QString OContact::type()const; | 210 | QString OContact::type()const; |
211 | QMap<QString,QString> OContact::toExtraMap() const; | 211 | QMap<QString,QString> OContact::toExtraMap() const; |
212 | class QString OContact::recordField(int) const; | 212 | class QString OContact::recordField(int) const; |
213 | 213 | ||
214 | // Why private ? (eilers,se) | 214 | // Why private ? (eilers,se) |
215 | QString emailSeparator() const { return " "; } | 215 | QString emailSeparator() const { return " "; } |
216 | // the emails should be seperated by a comma | 216 | // the emails should be seperated by a comma |
217 | void setEmails( const QString &v ); | 217 | void setEmails( const QString &v ); |
218 | QString emails() const { return find( Qtopia::Emails ); } | 218 | QString emails() const { return find( Qtopia::Emails ); } |
219 | 219 | ||
220 | 220 | ||
221 | private: | 221 | private: |
222 | friend class AbEditor; | 222 | friend class AbEditor; |
223 | friend class AbTable; | 223 | friend class AbTable; |
224 | friend class AddressBookAccessPrivate; | 224 | friend class AddressBookAccessPrivate; |
225 | friend class XMLIO; | 225 | friend class XMLIO; |
226 | 226 | ||
227 | |||
228 | void insert( int key, const QString &value ); | 227 | void insert( int key, const QString &value ); |
229 | void replace( int key, const QString &value ); | 228 | void replace( int key, const QString &value ); |
230 | QString find( int key ) const; | 229 | QString find( int key ) const; |
231 | 230 | ||
232 | QString displayAddress( const QString &street, | 231 | QString displayAddress( const QString &street, |
233 | const QString &city, | 232 | const QString &city, |
234 | const QString &state, | 233 | const QString &state, |
235 | const QString &zip, | 234 | const QString &zip, |
236 | const QString &country ) const; | 235 | const QString &country ) const; |
237 | 236 | ||
238 | Qtopia::UidGen &uidGen() { return sUidGen; } | 237 | Qtopia::UidGen &uidGen() { return sUidGen; } |
238 | |||
239 | |||
239 | static Qtopia::UidGen sUidGen; | 240 | static Qtopia::UidGen sUidGen; |
240 | QMap<int, QString> mMap; | 241 | QMap<int, QString> mMap; |
241 | ContactPrivate *d; | 242 | ContactPrivate *d; |
242 | }; | 243 | }; |
243 | 244 | ||
244 | 245 | ||
245 | #endif | 246 | #endif |