summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp232
1 files changed, 228 insertions, 4 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index b6ea461..caf3c6e 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -210,6 +210,215 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
210{ 210{
211 OPimContact c; 211 OPimContact c;
212 212
213<<<<<<< ocontactaccessbackend_vcard.cpp
214 VObjectIterator it;
215 initPropIterator( &it, obj );
216 while( moreIteration( &it ) ) {
217 VObject *o = nextVObject( &it );
218 QCString name = vObjectName( o );
219 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
220 qDebug( "(1)Read: %s", QString( value ).latin1() );
221 if ( name == VCNameProp ) {
222 VObjectIterator nit;
223 initPropIterator( &nit, o );
224 while( moreIteration( &nit ) ) {
225 VObject *o = nextVObject( &nit );
226 QCString name = vObjectTypeInfo( o );
227 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
228 qDebug( "(2)Read: %s", value.latin1() );
229 if ( name == VCNamePrefixesProp )
230 c.setTitle( value );
231 else if ( name == VCNameSuffixesProp )
232 c.setSuffix( value );
233 else if ( name == VCFamilyNameProp )
234 c.setLastName( value );
235 else if ( name == VCGivenNameProp )
236 c.setFirstName( value );
237 else if ( name == VCAdditionalNamesProp )
238 c.setMiddleName( value );
239 }
240 }
241 else if ( name == VCAdrProp ) {
242 bool work = TRUE; // default address is work address
243 QString street;
244 QString city;
245 QString region;
246 QString postal;
247 QString country;
248
249 VObjectIterator nit;
250 initPropIterator( &nit, o );
251 while( moreIteration( &nit ) ) {
252 VObject *o = nextVObject( &nit );
253 QCString name = vObjectName( o );
254 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
255 if ( name == VCHomeProp )
256 work = FALSE;
257 else if ( name == VCWorkProp )
258 work = TRUE;
259 else if ( name == VCStreetAddressProp )
260 street = value;
261 else if ( name == VCCityProp )
262 city = value;
263 else if ( name == VCRegionProp )
264 region = value;
265 else if ( name == VCPostalCodeProp )
266 postal = value;
267 else if ( name == VCCountryNameProp )
268 country = value;
269 }
270 if ( work ) {
271 c.setBusinessStreet( street );
272 c.setBusinessCity( city );
273 c.setBusinessCountry( country );
274 c.setBusinessZip( postal );
275 c.setBusinessState( region );
276 } else {
277 c.setHomeStreet( street );
278 c.setHomeCity( city );
279 c.setHomeCountry( country );
280 c.setHomeZip( postal );
281 c.setHomeState( region );
282 }
283 }
284 else if ( name == VCTelephoneProp ) {
285 enum {
286 HOME = 0x01,
287 WORK = 0x02,
288 VOICE = 0x04,
289 CELL = 0x08,
290 FAX = 0x10,
291 PAGER = 0x20,
292 UNKNOWN = 0x80
293 };
294 int type = 0;
295
296 VObjectIterator nit;
297 initPropIterator( &nit, o );
298 while( moreIteration( &nit ) ) {
299 VObject *o = nextVObject( &nit );
300 QCString name = vObjectTypeInfo( o );
301 if ( name == VCHomeProp )
302 type |= HOME;
303 else if ( name == VCWorkProp )
304 type |= WORK;
305 else if ( name == VCVoiceProp )
306 type |= VOICE;
307 else if ( name == VCCellularProp )
308 type |= CELL;
309 else if ( name == VCFaxProp )
310 type |= FAX;
311 else if ( name == VCPagerProp )
312 type |= PAGER;
313 else if ( name == VCPreferredProp )
314 ;
315 else
316 type |= UNKNOWN;
317 }
318 if ( (type & UNKNOWN) != UNKNOWN ) {
319 if ( ( type & (HOME|WORK) ) == 0 ) // default
320 type |= HOME;
321 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
322 type |= VOICE;
323
324 qWarning("value %s %d", value.data(), type );
325 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
326 c.setHomePhone( value );
327 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
328 c.setHomeFax( value );
329 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
330 c.setHomeMobile( value );
331 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
332 c.setBusinessPhone( value );
333 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
334 c.setBusinessFax( value );
335 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
336 c.setBusinessMobile( value );
337 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
338 c.setBusinessPager( value );
339 }
340 }
341 else if ( name == VCEmailAddressProp ) {
342 QString email = QString::fromUtf8( vObjectStringZValue( o ) );
343 bool valid = TRUE;
344 VObjectIterator nit;
345 initPropIterator( &nit, o );
346 while( moreIteration( &nit ) ) {
347 VObject *o = nextVObject( &nit );
348 QCString name = vObjectTypeInfo( o );
349 if ( name != VCInternetProp && name != VCHomeProp &&
350 name != VCWorkProp &&
351 name != VCPreferredProp )
352 // ### preffered should map to default email
353 valid = FALSE;
354 }
355 if ( valid ) {
356 c.insertEmail( email );
357 }
358 }
359 else if ( name == VCURLProp ) {
360 VObjectIterator nit;
361 initPropIterator( &nit, o );
362 while( moreIteration( &nit ) ) {
363 VObject *o = nextVObject( &nit );
364 QCString name = vObjectTypeInfo( o );
365 if ( name == VCHomeProp )
366 c.setHomeWebpage( value );
367 else if ( name == VCWorkProp )
368 c.setBusinessWebpage( value );
369 }
370 }
371 else if ( name == VCOrgProp ) {
372 VObjectIterator nit;
373 initPropIterator( &nit, o );
374 while( moreIteration( &nit ) ) {
375 VObject *o = nextVObject( &nit );
376 QCString name = vObjectName( o );
377 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
378 if ( name == VCOrgNameProp )
379 c.setCompany( value );
380 else if ( name == VCOrgUnitProp )
381 c.setDepartment( value );
382 else if ( name == VCOrgUnit2Prop )
383 c.setOffice( value );
384 }
385 }
386 else if ( name == VCTitleProp ) {
387 c.setJobTitle( value );
388 }
389 else if ( name == "X-Qtopia-Profession" ) {
390 c.setProfession( value );
391 }
392 else if ( name == "X-Qtopia-Manager" ) {
393 c.setManager( value );
394 }
395 else if ( name == "X-Qtopia-Assistant" ) {
396 c.setAssistant( value );
397 }
398 else if ( name == "X-Qtopia-Spouse" ) {
399 c.setSpouse( value );
400 }
401 else if ( name == "X-Qtopia-Gender" ) {
402 c.setGender( value );
403 }
404 else if ( name == "X-Qtopia-Anniversary" ) {
405 c.setAnniversary( convVCardDateToDate( value ) );
406 }
407 else if ( name == "X-Qtopia-Nickname" ) {
408 c.setNickname( value );
409 }
410 else if ( name == "X-Qtopia-Children" ) {
411 c.setChildren( value );
412 }
413 else if ( name == VCBirthDateProp ) {
414 // Reading Birthdate regarding RFC 2425 (5.8.4)
415 c.setBirthday( convVCardDateToDate( value ) );
416
417 }
418 else if ( name == VCCommentProp ) {
419 c.setNotes( value );
420 }
421=======
213 VObjectIterator it; 422 VObjectIterator it;
214 initPropIterator( &it, obj ); 423 initPropIterator( &it, obj );
215 while( moreIteration( &it ) ) { 424 while( moreIteration( &it ) ) {
@@ -415,7 +624,21 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
415 else if ( name == VCCommentProp ) { 624 else if ( name == VCCommentProp ) {
416 c.setNotes( value ); 625 c.setNotes( value );
417 } 626 }
627>>>>>>> 1.15
418#if 0 628#if 0
629<<<<<<< ocontactaccessbackend_vcard.cpp
630 else {
631 printf("Name: %s, value=%s\n", name.data(), QString::fromUtf8( vObjectStringZValue( o ) ) );
632 VObjectIterator nit;
633 initPropIterator( &nit, o );
634 while( moreIteration( &nit ) ) {
635 VObject *o = nextVObject( &nit );
636 QCString name = vObjectName( o );
637 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
638 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
639 }
640 }
641=======
419 else { 642 else {
420 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 643 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
421 VObjectIterator nit; 644 VObjectIterator nit;
@@ -427,6 +650,7 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
427 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 650 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
428 } 651 }
429 } 652 }
653>>>>>>> 1.15
430#endif 654#endif
431 } 655 }
432 c.setFileAs(); 656 c.setFileAs();
@@ -581,10 +805,10 @@ QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datest
581 805
582VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) 806VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value )
583{ 807{
584 VObject *ret = 0; 808 VObject *ret = 0;
585 if ( o && !value.isEmpty() ) 809 if ( o && !value.isEmpty() )
586 ret = addPropValue( o, prop, value.latin1() ); 810 ret = addPropValue( o, prop, value.utf8() );
587 return ret; 811 return ret;
588} 812}
589 813
590VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) 814VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop)