Diffstat (limited to 'kaddressbook/xxport/vcard_xxport.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/xxport/vcard_xxport.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp index acf6419..c56be8b 100644 --- a/kaddressbook/xxport/vcard_xxport.cpp +++ b/kaddressbook/xxport/vcard_xxport.cpp | |||
@@ -27,12 +27,13 @@ Copyright (c) 2004 Ulf Schenk | |||
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qfileinfo.h> | ||
33 | 34 | ||
34 | #include <kabc/vcardconverter.h> | 35 | #include <kabc/vcardconverter.h> |
35 | #include <kabc/vcardparser/vcardtool.h> | 36 | #include <kabc/vcardparser/vcardtool.h> |
36 | #include <kfiledialog.h> | 37 | #include <kfiledialog.h> |
37 | #ifndef KAB_EMBEDDED | 38 | #ifndef KAB_EMBEDDED |
38 | #include <kio/netaccess.h> | 39 | #include <kio/netaccess.h> |
@@ -143,16 +144,14 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const | |||
143 | if ( XXPortManager::importURL.isEmpty() ) | 144 | if ( XXPortManager::importURL.isEmpty() ) |
144 | { | 145 | { |
145 | url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); | 146 | url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); |
146 | } | 147 | } |
147 | else | 148 | else |
148 | url = XXPortManager::importURL; | 149 | url = XXPortManager::importURL; |
149 | |||
150 | if ( url.isEmpty() ) | 150 | if ( url.isEmpty() ) |
151 | return addrList; | 151 | return addrList; |
152 | |||
153 | QString caption( i18n( "vCard Import Failed" ) ); | 152 | QString caption( i18n( "vCard Import Failed" ) ); |
154 | if ( KIO::NetAccess::download( url, fileName ) ) { | 153 | if ( KIO::NetAccess::download( url, fileName ) ) { |
155 | QFile file( fileName ); | 154 | QFile file( fileName ); |
156 | 155 | ||
157 | file.open( IO_ReadOnly ); | 156 | file.open( IO_ReadOnly ); |
158 | QByteArray rawData = file.readAll(); | 157 | QByteArray rawData = file.readAll(); |
@@ -178,34 +177,34 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const | |||
178 | if ( !XXPortManager::importData.isEmpty() ) | 177 | if ( !XXPortManager::importData.isEmpty() ) |
179 | addrList = parseVCard( XXPortManager::importData ); | 178 | addrList = parseVCard( XXPortManager::importData ); |
180 | else { | 179 | else { |
181 | if ( XXPortManager::importURL.isEmpty() ) | 180 | if ( XXPortManager::importURL.isEmpty() ) |
182 | { | 181 | { |
183 | fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); | 182 | fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); |
183 | |||
184 | if ( fileName.isEmpty() ) | 184 | if ( fileName.isEmpty() ) |
185 | return addrList; | 185 | return addrList; |
186 | 186 | QFileInfo fi ( fileName ); | |
187 | if ( !fi.isFile() ) | ||
188 | return addrList; | ||
187 | } | 189 | } |
188 | else | 190 | else |
189 | { | 191 | { |
190 | //US url = XXPortManager::importURL; | 192 | //US url = XXPortManager::importURL; |
191 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); | 193 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); |
192 | if ( url.isEmpty() ) | 194 | if ( url.isEmpty() ) |
193 | return addrList; | 195 | return addrList; |
194 | 196 | ||
195 | } | 197 | } |
196 | |||
197 | |||
198 | QFile file( fileName ); | 198 | QFile file( fileName ); |
199 | 199 | if ( file.open( IO_ReadOnly ) ) { | |
200 | file.open( IO_ReadOnly ); | ||
201 | QByteArray rawData = file.readAll(); | 200 | QByteArray rawData = file.readAll(); |
202 | file.close(); | 201 | file.close(); |
203 | |||
204 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 202 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
205 | addrList = parseVCard( data ); | 203 | addrList = parseVCard( data ); |
204 | } | ||
206 | 205 | ||
207 | } | 206 | } |
208 | #endif //KAB_EMBEDDED | 207 | #endif //KAB_EMBEDDED |
209 | 208 | ||
210 | return addrList; | 209 | return addrList; |
211 | } | 210 | } |