author | zautrix <zautrix> | 2005-10-28 03:24:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-28 03:24:50 (UTC) |
commit | f83a59cf4f9d0cff4111b6f5c88e88e6dc96e79e (patch) (unidiff) | |
tree | 969e6cf85499e3b1dcaa4dc24c972b65c906cfa9 /kabc/vcard21parser.cpp | |
parent | cbda16d4966c7483d20d1b6b5a64c8af367ea732 (diff) | |
download | kdepimpi-f83a59cf4f9d0cff4111b6f5c88e88e6dc96e79e.zip kdepimpi-f83a59cf4f9d0cff4111b6f5c88e88e6dc96e79e.tar.gz kdepimpi-f83a59cf4f9d0cff4111b6f5c88e88e6dc96e79e.tar.bz2 |
many new bugs...
-rw-r--r-- | kabc/vcard21parser.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/kabc/vcard21parser.cpp b/kabc/vcard21parser.cpp index 277de22..60d02b8 100644 --- a/kabc/vcard21parser.cpp +++ b/kabc/vcard21parser.cpp | |||
@@ -141,66 +141,65 @@ bool VCardLineX::isValid() const | |||
141 | return true; | 141 | return true; |
142 | break; | 142 | break; |
143 | 143 | ||
144 | case 'r': | 144 | case 'r': |
145 | if ( name == VCARD_ROLE ) | 145 | if ( name == VCARD_ROLE ) |
146 | return true; | 146 | return true; |
147 | if ( name == VCARD_REV ) | 147 | if ( name == VCARD_REV ) |
148 | return true; | 148 | return true; |
149 | break; | 149 | break; |
150 | 150 | ||
151 | case 's': | 151 | case 's': |
152 | if ( name == VCARD_SOURCE ) | 152 | if ( name == VCARD_SOURCE ) |
153 | return true; | 153 | return true; |
154 | if ( name == VCARD_SOUND ) | 154 | if ( name == VCARD_SOUND ) |
155 | return true; | 155 | return true; |
156 | break; | 156 | break; |
157 | 157 | ||
158 | case 't': | 158 | case 't': |
159 | if ( name == VCARD_TEL && qualified && | 159 | if ( name == VCARD_TEL && qualified && |
160 | (qualifiers.contains(VCARD_TEL_HOME) || | 160 | (qualifiers.contains(VCARD_TEL_HOME) || |
161 | qualifiers.contains(VCARD_TEL_WORK) || | 161 | qualifiers.contains(VCARD_TEL_WORK) || |
162 | qualifiers.contains(VCARD_TEL_PREF) || | 162 | qualifiers.contains(VCARD_TEL_PREF) || |
163 | qualifiers.contains(VCARD_TEL_VOICE) || | 163 | qualifiers.contains(VCARD_TEL_VOICE) || |
164 | qualifiers.contains(VCARD_TEL_FAX) || | 164 | qualifiers.contains(VCARD_TEL_FAX) || |
165 | qualifiers.contains(VCARD_TEL_MSG) || | 165 | qualifiers.contains(VCARD_TEL_MSG) || |
166 | qualifiers.contains(VCARD_TEL_CELL) || | 166 | qualifiers.contains(VCARD_TEL_CELL) || |
167 | qualifiers.contains(VCARD_TEL_PAGER) || | 167 | qualifiers.contains(VCARD_TEL_PAGER) || |
168 | qualifiers.contains(VCARD_TEL_BBS) || | 168 | qualifiers.contains(VCARD_TEL_BBS) || |
169 | qualifiers.contains(VCARD_TEL_MODEM) || | 169 | qualifiers.contains(VCARD_TEL_MODEM) || |
170 | qualifiers.contains(VCARD_TEL_CAR) || | 170 | qualifiers.contains(VCARD_TEL_CAR) || |
171 | qualifiers.contains(VCARD_TEL_ISDN) || | 171 | qualifiers.contains(VCARD_TEL_ISDN) || |
172 | qualifiers.contains(VCARD_TEL_VIDEO) || | 172 | qualifiers.contains(VCARD_TEL_VIDEO) || |
173 | qualifiers.contains(VCARD_TEL_PCS) || | 173 | qualifiers.contains(VCARD_TEL_PCS) |
174 | qualifiers.contains(VCARD_TEL_SIP) | ||
175 | ) ) | 174 | ) ) |
176 | return true; | 175 | return true; |
177 | if ( name == VCARD_TZ ) | 176 | if ( name == VCARD_TZ ) |
178 | return true; | 177 | return true; |
179 | if ( name == VCARD_TITLE ) | 178 | if ( name == VCARD_TITLE ) |
180 | return true; | 179 | return true; |
181 | break; | 180 | break; |
182 | 181 | ||
183 | case 'u': | 182 | case 'u': |
184 | if ( name == VCARD_URL ) | 183 | if ( name == VCARD_URL ) |
185 | return true; | 184 | return true; |
186 | if ( name == VCARD_UID ) | 185 | if ( name == VCARD_UID ) |
187 | return true; | 186 | return true; |
188 | break; | 187 | break; |
189 | 188 | ||
190 | case 'v': | 189 | case 'v': |
191 | if ( name == VCARD_VERSION ) | 190 | if ( name == VCARD_VERSION ) |
192 | return true; | 191 | return true; |
193 | break; | 192 | break; |
194 | default: | 193 | default: |
195 | break; | 194 | break; |
196 | } | 195 | } |
197 | 196 | ||
198 | return false; | 197 | return false; |
199 | } | 198 | } |
200 | 199 | ||
201 | 200 | ||
202 | VCard21Parser::VCard21Parser() | 201 | VCard21Parser::VCard21Parser() |
203 | { | 202 | { |
204 | } | 203 | } |
205 | 204 | ||
206 | VCard21Parser::~VCard21Parser() | 205 | VCard21Parser::~VCard21Parser() |
@@ -250,94 +249,93 @@ KABC::Addressee VCard21Parser::readFromString( const QString &data) | |||
250 | tmpStr = mVCard->getValue(VCARD_ORG); | 249 | tmpStr = mVCard->getValue(VCARD_ORG); |
251 | addressee.setOrganization(tmpStr); | 250 | addressee.setOrganization(tmpStr); |
252 | //set the addressee's title | 251 | //set the addressee's title |
253 | tmpStr = mVCard->getValue(VCARD_TITLE); | 252 | tmpStr = mVCard->getValue(VCARD_TITLE); |
254 | addressee.setTitle(tmpStr); | 253 | addressee.setTitle(tmpStr); |
255 | //set the addressee's email - we can only deal with two. The preferenced one and one other. | 254 | //set the addressee's email - we can only deal with two. The preferenced one and one other. |
256 | tmpStr = mVCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET); | 255 | tmpStr = mVCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET); |
257 | addressee.insertEmail(tmpStr, false); | 256 | addressee.insertEmail(tmpStr, false); |
258 | tmpStr = mVCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF); | 257 | tmpStr = mVCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF); |
259 | addressee.insertEmail(tmpStr, true); | 258 | addressee.insertEmail(tmpStr, true); |
260 | //set the addressee's url | 259 | //set the addressee's url |
261 | tmpStr = mVCard->getValue(VCARD_URL); | 260 | tmpStr = mVCard->getValue(VCARD_URL); |
262 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_WORK); | 261 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_WORK); |
263 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_HOME); | 262 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_HOME); |
264 | if (!tmpStr.isEmpty()) { | 263 | if (!tmpStr.isEmpty()) { |
265 | addressee.setUrl(KURL(tmpStr)); | 264 | addressee.setUrl(KURL(tmpStr)); |
266 | } | 265 | } |
267 | 266 | ||
268 | //set the addressee's birthday | 267 | //set the addressee's birthday |
269 | tmpStr = mVCard->getValue(VCARD_BDAY); | 268 | tmpStr = mVCard->getValue(VCARD_BDAY); |
270 | addressee.setBirthday(VCardStringToDate(tmpStr)); | 269 | addressee.setBirthday(VCardStringToDate(tmpStr)); |
271 | 270 | ||
272 | //set the addressee's phone numbers | 271 | //set the addressee's phone numbers |
273 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { | 272 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { |
274 | if ( (*i).name == VCARD_TEL ) { | 273 | if ( (*i).name == VCARD_TEL ) { |
275 | int type = 0; | 274 | int type = 0; |
276 | if ( (*i).qualified ) { | 275 | if ( (*i).qualified ) { |
277 | if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) ) | 276 | if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) ) |
278 | type |= PhoneNumber::Home; | 277 | type |= PhoneNumber::Home; |
279 | if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) ) | 278 | if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) ) |
280 | type |= PhoneNumber::Work; | 279 | type |= PhoneNumber::Work; |
281 | if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) ) | 280 | if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) ) |
282 | type |= PhoneNumber::Pref; | 281 | type |= PhoneNumber::Pref; |
283 | // if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) ) | 282 | if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) ) |
284 | // type |= PhoneNumber::Voice; | 283 | type |= PhoneNumber::Voice; |
285 | if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) ) | 284 | if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) ) |
286 | type |= PhoneNumber::Fax; | 285 | type |= PhoneNumber::Fax; |
287 | if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) ) | 286 | if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) ) |
288 | type |= PhoneNumber::Msg; | 287 | type |= PhoneNumber::Msg; |
289 | if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) ) | 288 | if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) ) |
290 | type |= PhoneNumber::Cell; | 289 | type |= PhoneNumber::Cell; |
291 | if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) ) | 290 | if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) ) |
292 | type |= PhoneNumber::Pager; | 291 | type |= PhoneNumber::Pager; |
293 | if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) ) | 292 | if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) ) |
294 | type |= PhoneNumber::Bbs; | 293 | type |= PhoneNumber::Bbs; |
295 | if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) ) | 294 | if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) ) |
296 | type |= PhoneNumber::Modem; | 295 | type |= PhoneNumber::Modem; |
297 | if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) ) | 296 | if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) ) |
298 | type |= PhoneNumber::Car; | 297 | type |= PhoneNumber::Car; |
299 | if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) ) | 298 | if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) ) |
300 | type |= PhoneNumber::Isdn; | 299 | type |= PhoneNumber::Isdn; |
301 | if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) ) | 300 | if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) ) |
302 | type |= PhoneNumber::Video; | 301 | type |= PhoneNumber::Video; |
303 | if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) ) | 302 | if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) ) |
304 | type |= PhoneNumber::Pcs; | 303 | type |= PhoneNumber::Pcs; |
305 | if ( (*i).qualifiers.contains( VCARD_TEL_SIP ) ) | 304 | |
306 | type |= PhoneNumber::Sip; | ||
307 | } | 305 | } |
308 | addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) ); | 306 | addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) ); |
309 | } | 307 | } |
310 | } | 308 | } |
311 | 309 | addressee.makePhoneNumbersOLcompatible(); | |
312 | //set the addressee's addresses | 310 | //set the addressee's addresses |
313 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { | 311 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { |
314 | if ( (*i).name == VCARD_ADR ) { | 312 | if ( (*i).name == VCARD_ADR ) { |
315 | int type = 0; | 313 | int type = 0; |
316 | if ( (*i).qualified ) { | 314 | if ( (*i).qualified ) { |
317 | if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) ) | 315 | if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) ) |
318 | type |= Address::Dom; | 316 | type |= Address::Dom; |
319 | if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) ) | 317 | if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) ) |
320 | type |= Address::Intl; | 318 | type |= Address::Intl; |
321 | if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) ) | 319 | if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) ) |
322 | type |= Address::Postal; | 320 | type |= Address::Postal; |
323 | if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) ) | 321 | if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) ) |
324 | type |= Address::Parcel; | 322 | type |= Address::Parcel; |
325 | if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) ) | 323 | if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) ) |
326 | type |= Address::Home; | 324 | type |= Address::Home; |
327 | if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) ) | 325 | if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) ) |
328 | type |= Address::Work; | 326 | type |= Address::Work; |
329 | if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) | 327 | if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) |
330 | type |= Address::Pref; | 328 | type |= Address::Pref; |
331 | } | 329 | } |
332 | addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); | 330 | addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); |
333 | } | 331 | } |
334 | } | 332 | } |
335 | 333 | ||
336 | //set the addressee's delivery label | 334 | //set the addressee's delivery label |
337 | tmpStr = mVCard->getValue(VCARD_LABEL); | 335 | tmpStr = mVCard->getValue(VCARD_LABEL); |
338 | if (!tmpStr.isEmpty()) { | 336 | if (!tmpStr.isEmpty()) { |
339 | qDebug("VCard21Parser::readFromString please verify if replace is correct"); | 337 | qDebug("VCard21Parser::readFromString please verify if replace is correct"); |
340 | //US tmpStr.replace("\r\n","\n"); | 338 | //US tmpStr.replace("\r\n","\n"); |
341 | tmpStr.replace( QRegExp("\r\n"), "\n" ); | 339 | tmpStr.replace( QRegExp("\r\n"), "\n" ); |
342 | Address tmpAddress; | 340 | Address tmpAddress; |
343 | tmpAddress.setLabel(tmpStr); | 341 | tmpAddress.setLabel(tmpStr); |