21 void VCard::insertField( Tag* vcard,
const char* field,
const std::string& var )
23 if( field && !var.empty() )
24 new Tag( vcard, field, var );
27 void VCard::insertField( Tag* vcard,
const char* field,
bool var )
30 new Tag( vcard, field );
33 void VCard::checkField(
const Tag* vcard,
const char* field, std::string& var )
37 Tag* child = vcard->findChild( field );
45 m_N( false ), m_PHOTO( false ), m_LOGO( false )
52 m_N( false ), m_PHOTO( false ), m_LOGO( false )
59 checkField( vcard,
"FN", m_formattedname );
60 checkField( vcard,
"NICKNAME", m_nickname );
61 checkField( vcard,
"URL", m_url );
62 checkField( vcard,
"BDAY", m_bday );
63 checkField( vcard,
"JABBERID", m_jabberid );
64 checkField( vcard,
"TITLE", m_title );
65 checkField( vcard,
"ROLE", m_role );
66 checkField( vcard,
"NOTE", m_note );
67 checkField( vcard,
"DESC", m_desc );
68 checkField( vcard,
"MAILER", m_mailer );
69 checkField( vcard,
"TZ", m_tz );
70 checkField( vcard,
"PRODID", m_prodid );
71 checkField( vcard,
"REV", m_rev );
72 checkField( vcard,
"SORT-STRING", m_sortstring );
73 checkField( vcard,
"UID", m_uid );
75 TagList::const_iterator it = vcard->
children().begin();
76 for( ; it != vcard->
children().end(); ++it )
79 if( tag.
name() ==
"N" )
85 if( ( child = tag.
findChild(
"GIVEN" ) ) )
87 if( ( child = tag.
findChild(
"MIDDLE" ) ) )
89 if( ( child = tag.
findChild(
"PREFIX" ) ) )
91 if( ( child = tag.
findChild(
"SUFFIX" ) ) )
94 else if( tag.
name() ==
"PHOTO" )
104 std::string::size_type pos = 0;
105 while( ( pos = binval.find(
'\n' ) ) != std::string::npos )
106 binval.erase( pos, 1 );
112 else if( tag.
name() ==
"LOGO" )
122 std::string::size_type pos = 0;
123 while( ( pos = binval.find(
'\n' ) ) != std::string::npos )
124 binval.erase( pos, 1 );
130 else if( tag.
name() ==
"EMAIL" && tag.
hasChild(
"USERID" ) )
139 m_emailList.push_back( item );
141 else if( tag.
name() ==
"ADR" )
144 checkField( &tag,
"POBOX", item.
pobox );
145 checkField( &tag,
"EXTADD", item.
extadd );
146 checkField( &tag,
"STREET", item.
street );
147 checkField( &tag,
"LOCALITY", item.
locality );
148 checkField( &tag,
"REGION", item.
region );
149 checkField( &tag,
"PCODE", item.
pcode );
150 checkField( &tag,
"CTRY", item.
ctry );
158 m_addressList.push_back( item );
160 else if( tag.
name() ==
"LABEL" )
163 TagList::const_iterator it2 = tag.
children().begin();
164 for( ; it2 != tag.
children().end(); ++it2 )
166 if( (*it2)->name() ==
"LINE" )
167 item.
lines.push_back( (*it)->cdata() );
168 item.
postal = (*it2)->name() ==
"POSTAL";
169 item.
parcel = (*it2)->name() ==
"PARCEL";
170 item.
work = (*it2)->name() ==
"WORK";
171 item.
home = (*it2)->name() ==
"HOME";
172 item.
pref = (*it2)->name() ==
"PREF";
173 item.
dom = (*it2)->name() ==
"DOM";
174 item.
intl = !item.
dom && (*it2)->name() ==
"INTL";
176 m_labelList.push_back( item );
178 else if( tag.
name() ==
"TEL" && tag.
hasChild(
"NUMBER" ) )
195 m_telephoneList.push_back( item );
197 else if( tag.
name() ==
"ORG" )
199 TagList::const_iterator ito = tag.
children().begin();
200 for( ; ito != tag.
children().end(); ++ito )
202 if( (*ito)->name() ==
"ORGNAME" )
203 m_org.
name = (*ito)->cdata();
204 else if( (*ito)->name() ==
"ORGUNIT" )
205 m_org.
units.push_back( (*ito)->cdata() );
208 else if( tag.
name() ==
"GEO" )
210 checkField( &tag,
"LON", m_geo.
longitude );
211 checkField( &tag,
"LAT", m_geo.
latitude );
213 else if( tag.
name() ==
"CLASS" )
219 else if( tag.
hasChild(
"CONFIDENTIAL" ) )
228 const std::string& middle,
const std::string& prefix,
229 const std::string& suffix )
232 m_name.
given = given;
241 if( !extval.empty() )
250 if( !type.empty() && !binval.empty() )
267 if( !extval.empty() )
276 if( !type.empty() && !binval.empty() )
304 m_emailList.push_back( item );
308 const std::string& street,
const std::string& locality,
309 const std::string& region,
const std::string& pcode,
310 const std::string& ctry,
int type )
312 if( pobox.empty() && extadd.empty() && street.empty() &&
313 locality.empty() && region.empty() && pcode.empty() && ctry.empty() )
332 m_addressList.push_back( item );
350 m_labelList.push_back( item );
374 m_telephoneList.push_back( item );
379 if( !lat.empty() && !lon.empty() )
388 if( !orgname.empty() )
390 m_org.
name = orgname;
391 m_org.
units = orgunits;
397 static const std::string filter =
"/iq/vCard[@xmlns='" +
XMLNS_VCARD_TEMP +
"']";
403 Tag* v =
new Tag(
"vCard" );
411 insertField( v,
"FN", m_formattedname );
412 insertField( v,
"NICKNAME", m_nickname );
413 insertField( v,
"URL", m_url );
414 insertField( v,
"BDAY", m_bday );
415 insertField( v,
"JABBERID", m_jabberid );
416 insertField( v,
"TITLE", m_title );
417 insertField( v,
"ROLE", m_role );
418 insertField( v,
"NOTE", m_note );
419 insertField( v,
"DESC", m_desc );
420 insertField( v,
"MAILER", m_mailer );
421 insertField( v,
"TZ", m_tz );
422 insertField( v,
"REV", m_rev );
423 insertField( v,
"SORT_STRING", m_sortstring );
424 insertField( v,
"UID", m_uid );
428 Tag* n =
new Tag( v,
"N" );
429 insertField( n,
"FAMILY", m_name.
family );
430 insertField( n,
"GIVEN", m_name.
given );
431 insertField( n,
"MIDDLE", m_name.
middle );
432 insertField( n,
"PREFIX", m_name.
prefix );
433 insertField( n,
"SUFFIX", m_name.
suffix );
438 Tag* p =
new Tag( v,
"PHOTO" );
439 if( !m_photo.
extval.empty() )
443 else if( !m_photo.
type.empty() && !m_photo.
binval.empty() )
445 new Tag( p,
"TYPE", m_photo.
type );
452 Tag* l =
new Tag( v,
"LOGO" );
453 if( !m_logo.
extval.empty() )
457 else if( !m_logo.
type.empty() && !m_logo.
binval.empty() )
459 new Tag( l,
"TYPE", m_logo.
type );
464 EmailList::const_iterator ite = m_emailList.begin();
465 for( ; ite != m_emailList.end(); ++ite )
467 Tag* e =
new Tag( v,
"EMAIL" );
468 insertField( e,
"INTERNET", (*ite).internet );
469 insertField( e,
"WORK", (*ite).work );
470 insertField( e,
"HOME", (*ite).home );
471 insertField( e,
"X400", (*ite).x400 );
472 insertField( e,
"PREF", (*ite).pref );
473 insertField( e,
"USERID", (*ite).userid );
476 AddressList::const_iterator ita = m_addressList.begin();
477 for( ; ita != m_addressList.end(); ++ita )
479 Tag* a =
new Tag( v,
"ADR" );
480 insertField( a,
"POSTAL", (*ita).postal );
481 insertField( a,
"PARCEL", (*ita).parcel );
482 insertField( a,
"HOME", (*ita).home );
483 insertField( a,
"WORK", (*ita).work );
484 insertField( a,
"PREF", (*ita).pref );
485 insertField( a,
"DOM", (*ita).dom );
487 insertField( a,
"INTL", (*ita).intl );
489 insertField( a,
"POBOX", (*ita).pobox );
490 insertField( a,
"EXTADD", (*ita).extadd );
491 insertField( a,
"STREET", (*ita).street );
492 insertField( a,
"LOCALITY", (*ita).locality );
493 insertField( a,
"REGION", (*ita).region );
494 insertField( a,
"PCODE", (*ita).pcode );
495 insertField( a,
"CTRY", (*ita).ctry );
498 TelephoneList::const_iterator itt = m_telephoneList.begin();
499 for( ; itt != m_telephoneList.end(); ++itt )
501 Tag* t =
new Tag( v,
"TEL" );
502 insertField( t,
"NUMBER", (*itt).number );
503 insertField( t,
"HOME", (*itt).home );
504 insertField( t,
"WORK", (*itt).work );
505 insertField( t,
"VOICE", (*itt).voice );
506 insertField( t,
"FAX", (*itt).fax );
507 insertField( t,
"PAGER", (*itt).pager );
508 insertField( t,
"MSG", (*itt).msg );
509 insertField( t,
"CELL", (*itt).cell );
510 insertField( t,
"VIDEO", (*itt).video );
511 insertField( t,
"BBS", (*itt).bbs );
512 insertField( t,
"MODEM", (*itt).modem );
513 insertField( t,
"ISDN", (*itt).isdn );
514 insertField( t,
"PCS", (*itt).pcs );
515 insertField( t,
"PREF", (*itt).pref );
520 Tag* g =
new Tag( v,
"GEO" );
525 if( !m_org.
name.empty() )
527 Tag* o =
new Tag( v,
"ORG" );
528 new Tag( o,
"ORGNAME", m_org.
name );
529 StringList::const_iterator ito = m_org.
units.begin();
530 for( ; ito != m_org.
units.end(); ++ito )
531 new Tag( o,
"ORGUNIT", (*ito) );
536 Tag* c =
new Tag( v,
"CLASS" );
540 new Tag( c,
"PUBLIC" );
543 new Tag( c,
"PRIVATE" );
546 new Tag( c,
"CONFIDENTIAL" );