author | zautrix <zautrix> | 2005-09-28 00:19:15 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-09-28 00:19:15 (UTC) |
commit | e6112c5497b334d6dc38108b37963c5e803413d3 (patch) (unidiff) | |
tree | b9afccc4169ffcb3b360d79e659a4b1119f2aef4 /kaddressbook/xxport | |
parent | fa126dfea03b4ebed9a4eed4f2104f93abb72e22 (diff) | |
download | kdepimpi-e6112c5497b334d6dc38108b37963c5e803413d3.zip kdepimpi-e6112c5497b334d6dc38108b37963c5e803413d3.tar.gz kdepimpi-e6112c5497b334d6dc38108b37963c5e803413d3.tar.bz2 |
import latin1 kapi
-rw-r--r-- | kaddressbook/xxport/vcard_xxport.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp index 91df96d..9a8fa68 100644 --- a/kaddressbook/xxport/vcard_xxport.cpp +++ b/kaddressbook/xxport/vcard_xxport.cpp | |||
@@ -166,97 +166,103 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const | |||
166 | } else { | 166 | } else { |
167 | QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); | 167 | QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); |
168 | KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); | 168 | KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); |
169 | } | 169 | } |
170 | 170 | ||
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | #else //KAB_EMBEDDED | 174 | #else //KAB_EMBEDDED |
175 | 175 | ||
176 | 176 | ||
177 | if ( !XXPortManager::importData.isEmpty() ) | 177 | if ( !XXPortManager::importData.isEmpty() ) |
178 | addrList = parseVCard( XXPortManager::importData ); | 178 | addrList = parseVCard( XXPortManager::importData ); |
179 | else { | 179 | else { |
180 | if ( XXPortManager::importURL.isEmpty() ) | 180 | if ( XXPortManager::importURL.isEmpty() ) |
181 | { | 181 | { |
182 | fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); | 182 | fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); |
183 | 183 | ||
184 | if ( fileName.isEmpty() ) | 184 | if ( fileName.isEmpty() ) |
185 | return addrList; | 185 | return addrList; |
186 | QFileInfo fi ( fileName ); | 186 | QFileInfo fi ( fileName ); |
187 | if ( !fi.isFile() ) | 187 | if ( !fi.isFile() ) |
188 | return addrList; | 188 | return addrList; |
189 | } | 189 | } |
190 | else | 190 | else |
191 | { | 191 | { |
192 | //US url = XXPortManager::importURL; | 192 | //US url = XXPortManager::importURL; |
193 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); | 193 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); |
194 | if ( url.isEmpty() ) | 194 | if ( url.isEmpty() ) |
195 | return addrList; | 195 | return addrList; |
196 | 196 | ||
197 | } | 197 | } |
198 | QFile file( fileName ); | 198 | QFile file( fileName ); |
199 | if ( file.open( IO_ReadOnly ) ) { | 199 | if ( file.open( IO_ReadOnly ) ) { |
200 | QCString rawData ( file.readAll().data(),file.size()+1); | 200 | QCString rawData ( file.readAll().data(),file.size()+1); |
201 | file.close(); | 201 | file.close(); |
202 | int start = 0; | 202 | int start = 0; |
203 | #ifndef DESKTOP_VERSION | 203 | #ifndef DESKTOP_VERSION |
204 | while ( start < rawData.size()-2 ) { | 204 | while ( start < rawData.size()-2 ) { |
205 | if ( rawData.at( start ) == '\r' ) | 205 | if ( rawData.at( start ) == '\r' ) |
206 | if ( rawData.at( start+1 ) == '\n' ) | 206 | if ( rawData.at( start+1 ) == '\n' ) |
207 | if ( rawData.at( start+2 ) == ' ' ) { | 207 | if ( rawData.at( start+2 ) == ' ' ) { |
208 | rawData.remove(start,3); | 208 | rawData.remove(start,3); |
209 | --start; | 209 | --start; |
210 | } | 210 | } |
211 | ++start; | 211 | ++start; |
212 | } | 212 | } |
213 | #endif | 213 | #endif |
214 | addrList = parseVCard( QString::fromUtf8( rawData.data() ) ); | 214 | int ret = KMessageBox::warningYesNoCancel( 0, i18n("Select import format!\nDefault and standard is Utf8.\nLatin1 may be the right\nfor some West Europian languages."), i18n("Import Format"), i18n("Utf8"), i18n("Latin1") ); |
215 | if ( ret == KMessageBox::Cancel ) | ||
216 | return addrList; | ||
217 | if ( ret == KMessageBox::Yes ) | ||
218 | addrList = parseVCard( QString::fromUtf8( rawData.data() ) ); | ||
219 | else | ||
220 | addrList = parseVCard( QString::fromLatin1( rawData.data() ) ); | ||
215 | } | 221 | } |
216 | 222 | ||
217 | } | 223 | } |
218 | #endif //KAB_EMBEDDED | 224 | #endif //KAB_EMBEDDED |
219 | 225 | ||
220 | return addrList; | 226 | return addrList; |
221 | } | 227 | } |
222 | 228 | ||
223 | KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const | 229 | KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const |
224 | { | 230 | { |
225 | 231 | ||
226 | KABC::VCardTool tool; | 232 | KABC::VCardTool tool; |
227 | KABC::AddresseeList addrList; | 233 | KABC::AddresseeList addrList; |
228 | addrList = tool.parseVCards( data ); | 234 | addrList = tool.parseVCards( data ); |
229 | // LR : I switched to the code, which is in current cvs HEAD | 235 | // LR : I switched to the code, which is in current cvs HEAD |
230 | /* | 236 | /* |
231 | uint numVCards = data.contains( "BEGIN:VCARD", false ); | 237 | uint numVCards = data.contains( "BEGIN:VCARD", false ); |
232 | QStringList dataList = QStringList::split( "\r\n\r\n", data ); | 238 | QStringList dataList = QStringList::split( "\r\n\r\n", data ); |
233 | 239 | ||
234 | for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) { | 240 | for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) { |
235 | KABC::Addressee addr; | 241 | KABC::Addressee addr; |
236 | bool ok = false; | 242 | bool ok = false; |
237 | 243 | ||
238 | if ( dataList[ i ].contains( "VERSION:3.0" ) ) | 244 | if ( dataList[ i ].contains( "VERSION:3.0" ) ) |
239 | ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v3_0 ); | 245 | ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v3_0 ); |
240 | else if ( dataList[ i ].contains( "VERSION:2.1" ) ) | 246 | else if ( dataList[ i ].contains( "VERSION:2.1" ) ) |
241 | ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v2_1 ); | 247 | ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v2_1 ); |
242 | else { | 248 | else { |
243 | KMessageBox::sorry( parentWidget(), i18n( "Not supported vCard version." ) ); | 249 | KMessageBox::sorry( parentWidget(), i18n( "Not supported vCard version." ) ); |
244 | continue; | 250 | continue; |
245 | } | 251 | } |
246 | 252 | ||
247 | if ( !addr.isEmpty() && ok ) | 253 | if ( !addr.isEmpty() && ok ) |
248 | addrList.append( addr ); | 254 | addrList.append( addr ); |
249 | else { | 255 | else { |
250 | QString text = i18n( "The selected file does not include a valid vCard. " | 256 | QString text = i18n( "The selected file does not include a valid vCard. " |
251 | "Please check the file and try again." ); | 257 | "Please check the file and try again." ); |
252 | KMessageBox::sorry( parentWidget(), text ); | 258 | KMessageBox::sorry( parentWidget(), text ); |
253 | } | 259 | } |
254 | } | 260 | } |
255 | */ | 261 | */ |
256 | if ( addrList.isEmpty() ) { | 262 | if ( addrList.isEmpty() ) { |
257 | QString text = i18n( "The selected file does not\ninclude a valid vCard.\nPlease check the file and try again.\n" ); | 263 | QString text = i18n( "The selected file does not\ninclude a valid vCard.\nPlease check the file and try again.\n" ); |
258 | KMessageBox::sorry( parentWidget(), text ); | 264 | KMessageBox::sorry( parentWidget(), text ); |
259 | } | 265 | } |
260 | return addrList; | 266 | return addrList; |
261 | } | 267 | } |
262 | 268 | ||