📄 vcard.cpp
字号:
item.work = type & AddrTypeWork ? true : false; item.home = type & AddrTypeHome ? true : false; item.pref = type & AddrTypePref ? true : false; m_emailList.push_back( item ); } void VCard::addAddress( const std::string& pobox, const std::string& extadd, const std::string& street, const std::string& locality, const std::string& region, const std::string& pcode, const std::string& ctry, int type ) { if( pobox.empty() && extadd.empty() && street.empty() && locality.empty() && region.empty() && pcode.empty() && ctry.empty() ) return; Address item; item.pobox = pobox; item.extadd = extadd; item.street = street; item.locality = locality; item.region = region; item.pcode = pcode; item.ctry = ctry; item.home = type & AddrTypeHome ? true : false; item.work = type & AddrTypeWork ? true : false; item.parcel = type & AddrTypeParcel ? true : false; item.postal = type & AddrTypePostal ? true : false; item.dom = type & AddrTypeDom ? true : false; item.intl = !item.dom && type & AddrTypeIntl ? true : false; item.pref = type & AddrTypePref ? true : false; m_addressList.push_back( item ); } void VCard::addLabel( const StringList& lines, int type ) { if( !lines.size() ) return; Label item; item.lines = lines; item.work = type & AddrTypeWork ? true : false; item.home = type & AddrTypeHome ? true : false; item.postal = type & AddrTypePostal ? true : false; item.parcel = type & AddrTypeParcel ? true : false; item.pref = type & AddrTypePref ? true : false; item.dom = type & AddrTypeDom ? true : false; item.intl = !item.dom && type & AddrTypeIntl; m_labelList.push_back( item ); } void VCard::addTelephone( const std::string& number, int type ) { if( number.empty() ) return; Telephone item; item.number = number; item.work = type & AddrTypeWork ? true : false; item.home = type & AddrTypeHome ? true : false; item.voice = type & AddrTypeVoice ? true : false; item.fax = type & AddrTypeFax ? true : false; item.pager = type & AddrTypePager ? true : false; item.msg = type & AddrTypeMsg ? true : false; item.cell = type & AddrTypeCell ? true : false; item.video = type & AddrTypeVideo ? true : false; item.bbs = type & AddrTypeBbs ? true : false; item.modem = type & AddrTypeModem ? true : false; item.isdn = type & AddrTypeIsdn ? true : false; item.pcs = type & AddrTypePcs ? true : false; item.pref = type & AddrTypePref ? true : false; m_telephoneList.push_back( item ); } void VCard::setGeo( const std::string& lat, const std::string& lon ) { if( !lat.empty() && !lon.empty() ) { m_geo.latitude = lat; m_geo.longitude = lon; } } void VCard::setOrganization( const std::string& orgname, const StringList& orgunits ) { if( !orgname.empty() ) { m_org.name = orgname; m_org.units = orgunits; } } Tag* VCard::tag() const { Tag *v = new Tag( "vCard" ); v->addAttribute( "xmlns", XMLNS_VCARD_TEMP ); v->addAttribute( "version", "3.0" ); insertField( v, "FN", m_formattedname ); insertField( v, "NICKNAME", m_nickname ); insertField( v, "URL", m_url ); insertField( v, "BDAY", m_bday ); insertField( v, "JABBERID", m_jabberid ); insertField( v, "TITLE", m_title ); insertField( v, "ROLE", m_role ); insertField( v, "NOTE", m_note ); insertField( v, "DESC", m_desc ); insertField( v, "MAILER", m_mailer ); insertField( v, "TZ", m_tz ); insertField( v, "REV", m_rev ); insertField( v, "SORT_STRING", m_sortstring ); insertField( v, "UID", m_uid ); if( m_N ) { Tag *n = new Tag( v, "N" ); insertField( n, "FAMILY", m_name.family ); insertField( n, "GIVEN", m_name.given ); insertField( n, "MIDDLE", m_name.middle ); insertField( n, "PREFIX", m_name.prefix ); insertField( n, "SUFFIX", m_name.suffix ); } if( m_PHOTO ) { Tag *p = new Tag( v, "PHOTO" ); if( !m_photo.extval.empty() ) { new Tag( p, "EXTVAL", m_photo.extval ); } else if( !m_photo.type.empty() && !m_photo.binval.empty() ) { new Tag( p, "TYPE", m_photo.type ); new Tag( p, "BINVAL", Base64::encode64( m_photo.binval ) ); } } if( m_LOGO ) { Tag *l = new Tag( v, "LOGO" ); if( !m_logo.extval.empty() ) { new Tag( l, "EXTVAL", m_logo.extval ); } else if( !m_logo.type.empty() && !m_logo.binval.empty() ) { new Tag( l, "TYPE", m_logo.type ); new Tag( l, "BINVAL", Base64::encode64( m_logo.binval ) ); } } EmailList::const_iterator ite = m_emailList.begin(); for( ; ite != m_emailList.end(); ++ite ) { Tag *e = new Tag( v, "EMAIL" ); insertField( e, "INTERNET", (*ite).internet ); insertField( e, "WORK", (*ite).work ); insertField( e, "HOME", (*ite).home ); insertField( e, "X400", (*ite).x400 ); insertField( e, "PREF", (*ite).pref ); insertField( e, "USERID", (*ite).userid ); } AddressList::const_iterator ita = m_addressList.begin(); for( ; ita != m_addressList.end(); ++ita ) { Tag *a = new Tag( v, "ADR" ); insertField( a, "POSTAL", (*ita).postal ); insertField( a, "PARCEL", (*ita).parcel ); insertField( a, "HOME", (*ita).home ); insertField( a, "WORK", (*ita).work ); insertField( a, "PREF", (*ita).pref ); insertField( a, "DOM", (*ita).dom ); if( !(*ita).dom ) insertField( a, "INTL", (*ita).intl ); insertField( a, "POBOX", (*ita).pobox ); insertField( a, "EXTADD", (*ita).extadd ); insertField( a, "STREET", (*ita).street ); insertField( a, "LOCALITY", (*ita).locality ); insertField( a, "REGION", (*ita).region ); insertField( a, "PCODE", (*ita).pcode ); insertField( a, "CTRY", (*ita).ctry ); } TelephoneList::const_iterator itt = m_telephoneList.begin(); for( ; itt != m_telephoneList.end(); ++itt ) { Tag *t = new Tag( v, "TEL" ); insertField( t, "NUMBER", (*itt).number ); insertField( t, "HOME", (*itt).home ); insertField( t, "WORK", (*itt).work ); insertField( t, "VOICE", (*itt).voice ); insertField( t, "FAX", (*itt).fax ); insertField( t, "PAGER", (*itt).pager ); insertField( t, "MSG", (*itt).msg ); insertField( t, "CELL", (*itt).cell ); insertField( t, "VIDEO", (*itt).video ); insertField( t, "BBS", (*itt).bbs ); insertField( t, "MODEM", (*itt).modem ); insertField( t, "ISDN", (*itt).isdn ); insertField( t, "PCS", (*itt).pcs ); insertField( t, "PREF", (*itt).pref ); } if( !m_geo.latitude.empty() && !m_geo.longitude.empty() ) { Tag *g = new Tag( v, "GEO" ); new Tag( g, "LAT", m_geo.latitude ); new Tag( g, "LON", m_geo.longitude ); } if( !m_org.name.empty() ) { Tag *o = new Tag( v, "ORG" ); new Tag( o, "ORGNAME", m_org.name ); StringList::const_iterator ito = m_org.units.begin(); for( ; ito != m_org.units.end(); ++ito ) new Tag( o, "ORGUNITS", (*ito) ); } if( m_class != ClassNone ) { Tag *c = new Tag( v, "CLASS" ); switch( m_class ) { case ClassPublic: new Tag( c, "PUBLIC" ); break; case ClassPrivate: new Tag( c, "PRIVATE" ); break; case ClassConfidential: new Tag( c, "CONFIDENTIAL" ); break; default: break; } } return v; } void VCard::insertField( Tag *vcard, const std::string& field, const std::string& var ) const { if( !var.empty() ) new Tag( vcard, field, var ); } void VCard::insertField( Tag *vcard, const std::string& field, bool var ) const { if( var ) new Tag( vcard, field ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -