author | ulf69 <ulf69> | 2004-07-09 08:07:47 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-09 08:07:47 (UTC) |
commit | d56bb523048598245ac4ffcb16689687e082f831 (patch) (unidiff) | |
tree | 6db6859ad1246fec51f7b93b77a16b5afe21f733 | |
parent | 259a7a50e4f8138cedfc2004fbde3b37cedcc49f (diff) | |
download | kdepimpi-d56bb523048598245ac4ffcb16689687e082f831.zip kdepimpi-d56bb523048598245ac4ffcb16689687e082f831.tar.gz kdepimpi-d56bb523048598245ac4ffcb16689687e082f831.tar.bz2 |
export of kde 2.1 vcards is not supported by the converter
-rw-r--r-- | kaddressbook/xxport/vcard_xxport.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp index b53f873..adf47cd 100644 --- a/kaddressbook/xxport/vcard_xxport.cpp +++ b/kaddressbook/xxport/vcard_xxport.cpp | |||
@@ -32,97 +32,98 @@ $Id$ | |||
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | 33 | ||
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kabc/vcardparser/vcardtool.h> | 35 | #include <kabc/vcardparser/vcardtool.h> |
36 | #include <kfiledialog.h> | 36 | #include <kfiledialog.h> |
37 | #ifndef KAB_EMBEDDED | 37 | #ifndef KAB_EMBEDDED |
38 | #include <kio/netaccess.h> | 38 | #include <kio/netaccess.h> |
39 | #endif //KAB_EMBEDDED | 39 | #endif //KAB_EMBEDDED |
40 | 40 | ||
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | #include <ktempfile.h> | 43 | #include <ktempfile.h> |
44 | #include <kurl.h> | 44 | #include <kurl.h> |
45 | 45 | ||
46 | #include "xxportmanager.h" | 46 | #include "xxportmanager.h" |
47 | 47 | ||
48 | #include "vcard_xxport.h" | 48 | #include "vcard_xxport.h" |
49 | 49 | ||
50 | #ifndef KAB_EMBEDDED | 50 | #ifndef KAB_EMBEDDED |
51 | 51 | ||
52 | class VCardXXPortFactory : public XXPortFactory | 52 | class VCardXXPortFactory : public XXPortFactory |
53 | { | 53 | { |
54 | public: | 54 | public: |
55 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 55 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
56 | { | 56 | { |
57 | return new VCardXXPort( ab, parent, name ); | 57 | return new VCardXXPort( ab, parent, name ); |
58 | } | 58 | } |
59 | }; | 59 | }; |
60 | #endif //KAB_EMBEDDED | 60 | #endif //KAB_EMBEDDED |
61 | 61 | ||
62 | 62 | ||
63 | extern "C" | 63 | extern "C" |
64 | { | 64 | { |
65 | #ifndef KAB_EMBEDDED | 65 | #ifndef KAB_EMBEDDED |
66 | void *init_libkaddrbk_vcard_xxport() | 66 | void *init_libkaddrbk_vcard_xxport() |
67 | #else //KAB_EMBEDDED | 67 | #else //KAB_EMBEDDED |
68 | void *init_kaddrbk_vcard_xxport() | 68 | void *init_kaddrbk_vcard_xxport() |
69 | #endif //KAB_EMBEDDED | 69 | #endif //KAB_EMBEDDED |
70 | { | 70 | { |
71 | return ( new VCardXXPortFactory() ); | 71 | return ( new VCardXXPortFactory() ); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 76 | VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
77 | : XXPortObject( ab, parent, name ) | 77 | : XXPortObject( ab, parent, name ) |
78 | { | 78 | { |
79 | createImportAction( i18n( "Import vCard..." ) ); | 79 | createImportAction( i18n( "Import vCard..." ) ); |
80 | createExportAction( i18n( "Export vCard 2.1..." ), "v21" ); | 80 | //US KABC::VCardConverter does not support the export of 2.1 addressbooks. |
81 | //US createExportAction( i18n( "Export vCard 2.1..." ), "v21" ); | ||
81 | createExportAction( i18n( "Export vCard 3.0..." ), "v30" ); | 82 | createExportAction( i18n( "Export vCard 3.0..." ), "v30" ); |
82 | } | 83 | } |
83 | 84 | ||
84 | bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) | 85 | bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) |
85 | { | 86 | { |
86 | QString name; | 87 | QString name; |
87 | 88 | ||
88 | if ( list.count() == 1 ) | 89 | if ( list.count() == 1 ) |
89 | name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; | 90 | name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; |
90 | else | 91 | else |
91 | name = "addressbook.vcf"; | 92 | name = "addressbook.vcf"; |
92 | 93 | ||
93 | #ifndef KAB_EMBEDDED | 94 | #ifndef KAB_EMBEDDED |
94 | QString fileName = KFileDialog::getSaveFileName( name ); | 95 | QString fileName = KFileDialog::getSaveFileName( name ); |
95 | #else //KAB_EMBEDDED | 96 | #else //KAB_EMBEDDED |
96 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); | 97 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); |
97 | #endif //KAB_EMBEDDED | 98 | #endif //KAB_EMBEDDED |
98 | 99 | ||
99 | if ( fileName.isEmpty() ) | 100 | if ( fileName.isEmpty() ) |
100 | return true; | 101 | return true; |
101 | 102 | ||
102 | QFile outFile( fileName ); | 103 | QFile outFile( fileName ); |
103 | if ( !outFile.open( IO_WriteOnly ) ) { | 104 | if ( !outFile.open( IO_WriteOnly ) ) { |
104 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 105 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
105 | KMessageBox::error( parentWidget(), text.arg( fileName ) ); | 106 | KMessageBox::error( parentWidget(), text.arg( fileName ) ); |
106 | return false; | 107 | return false; |
107 | } | 108 | } |
108 | 109 | ||
109 | QTextStream t( &outFile ); | 110 | QTextStream t( &outFile ); |
110 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 111 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
111 | 112 | ||
112 | KABC::Addressee::List::ConstIterator it; | 113 | KABC::Addressee::List::ConstIterator it; |
113 | for ( it = list.begin(); it != list.end(); ++it ) { | 114 | for ( it = list.begin(); it != list.end(); ++it ) { |
114 | KABC::VCardConverter converter; | 115 | KABC::VCardConverter converter; |
115 | QString vcard; | 116 | QString vcard; |
116 | 117 | ||
117 | KABC::VCardConverter::Version version; | 118 | KABC::VCardConverter::Version version; |
118 | if ( data == "v21" ) | 119 | if ( data == "v21" ) |
119 | version = KABC::VCardConverter::v2_1; | 120 | version = KABC::VCardConverter::v2_1; |
120 | else | 121 | else |
121 | version = KABC::VCardConverter::v3_0; | 122 | version = KABC::VCardConverter::v3_0; |
122 | 123 | ||
123 | converter.addresseeToVCard( *it, vcard, version ); | 124 | converter.addresseeToVCard( *it, vcard, version ); |
124 | t << vcard << "\r\n\r\n"; | 125 | t << vcard << "\r\n\r\n"; |
125 | } | 126 | } |
126 | 127 | ||
127 | outFile.close(); | 128 | outFile.close(); |
128 | 129 | ||