vcard.h
/*
Copyright (c) 2006-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef VCARD_H__
#define VCARD_H__
#include "gloox.h"
#include "stanzaextension.h"
namespace gloox
{
class Tag;
class GLOOX_API VCard : public StanzaExtension
{
public:
enum AddressType
{
AddrTypeHome = 1,
AddrTypeWork = 2,
AddrTypePref = 4,
AddrTypeX400 = 8,
AddrTypeInet = 16,
AddrTypeParcel = 32,
AddrTypePostal = 64,
AddrTypeDom = 128,
AddrTypeIntl = 256,
AddrTypeVoice = 512,
AddrTypeFax = 1024,
AddrTypePager = 2048,
AddrTypeMsg = 4096,
AddrTypeCell = 8192,
AddrTypeVideo = 16384,
AddrTypeBbs = 32768,
AddrTypeModem = 65536,
AddrTypeIsdn = 131072,
AddrTypePcs = 262144
};
struct Name
{
std::string family;
std::string given;
std::string middle;
std::string prefix;
std::string suffix;
};
enum VCardClassification
{
ClassNone = 0,
ClassPublic = 1,
ClassPrivate = 2,
ClassConfidential = 4
};
struct Email
{
std::string userid;
bool home;
bool work;
bool internet;
bool pref;
bool x400;
};
typedef std::list<Email> EmailList;
struct Telephone
{
std::string number;
bool home;
bool work;
bool voice;
bool fax;
bool pager;
bool msg;
bool cell;
bool video;
bool bbs;
bool modem;
bool isdn;
bool pcs;
bool pref;
};
typedef std::list<Telephone> TelephoneList;
struct Address
{
std::string pobox;
std::string extadd;
std::string street;
std::string locality;
std::string region;
std::string pcode;
std::string ctry;
bool home;
bool work;
bool postal;
bool parcel;
bool pref;
bool dom;
bool intl;
};
struct Label
{
StringList lines;
bool home;
bool work;
bool postal;
bool parcel;
bool pref;
bool dom;
bool intl;
};
struct Geo
{
std::string latitude;
std::string longitude;
};
struct Org
{
std::string name;
StringList units;
};
struct Photo
{
std::string extval;
std::string binval;
std::string type;
};
typedef std::list<Address> AddressList;
typedef std::list<Label> LabelList;
VCard();
VCard( const Tag* vcard );
virtual ~VCard() {}
void setFormattedname( const std::string& name ) { m_formattedname = name; }
const std::string& formattedname() const { return m_formattedname; }
void setName( const std::string& family, const std::string& given,
const std::string& middle = EmptyString,
const std::string& prefix = EmptyString,
const std::string& suffix = EmptyString );
const Name& name() const { return m_name; }
void setNickname( const std::string& nickname ) { m_nickname = nickname; }
const std::string& nickname() const { return m_nickname; }
void setUrl( const std::string& url ) { m_url = url; }
const std::string& url() const { return m_url; }
void setBday( const std::string& bday ) { m_bday = bday; }
const std::string& bday() const { return m_bday; }
void setJabberid( const std::string& jabberid ) { m_jabberid = jabberid; }
const std::string& jabberid() const { return m_jabberid; }
void setTitle( const std::string& title ) { m_title = title; }
const std::string& title() const { return m_title; }
void setRole( const std::string& role ) { m_role = role; }
const std::string& role() const { return m_role; }
void setNote( const std::string& note ) { m_note = note; }
const std::string& note() const { return m_note; }
void setDesc( const std::string& desc ) { m_desc = desc; }
const std::string& desc() const { return m_desc; }
void setMailer( const std::string& mailer ) { m_mailer = mailer; }
const std::string& mailer() const { return m_mailer; }
void setRev( const std::string& rev ) { m_rev = rev; }
const std::string& rev() const { return m_rev; }
void setUid( const std::string& uid ) { m_uid = uid; }
const std::string& uid() const { return m_uid; }
void setTz( const std::string& tz ) { m_tz = tz; }
const std::string& tz() const { return m_tz; }
void setProdid( const std::string& prodid ) { m_prodid = prodid; }
const std::string& prodid() const { return m_prodid; }
void setSortstring( const std::string& sortstring ) { m_sortstring = sortstring; }
const std::string& sortstring() const { return m_sortstring; }
void setPhotoUri( const std::string& extval );
void setPhoto( const std::string& type = EmptyString, const std::string& binval = EmptyString );
const Photo& photo() const { return m_photo; }
void setLogo( const std::string& extval );
void setLogo( const std::string& type = EmptyString, const std::string& binval = EmptyString );
const Photo& logo() const { return m_logo; }
void addEmail( const std::string& userid, int type );
const EmailList& emailAddresses() const { return m_emailList; }
void 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 );
void addLabel( const StringList& lines, int type );
const AddressList& addresses() const { return m_addressList; }
const LabelList& labels() const { return m_labelList; }
void addTelephone( const std::string& number, int type );
const TelephoneList& telephone() const { return m_telephoneList; }
void setGeo( const std::string& lat, const std::string& lon );
const Geo& geo() const { return m_geo; }
void setOrganization( const std::string& orgname, const StringList& orgunits );
const Org& org() const { return m_org; }
void setClass( VCardClassification vclass ) { m_class = vclass; }
const VCardClassification& classification() const { return m_class; }
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new VCard( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const
{
return new VCard( *this );
}
private:
static void insertField( Tag* vcard, const char* field, const std::string& var );
static void insertField( Tag* vcard, const char* field, bool var );
static void checkField ( const Tag* vcard, const char* field, std::string& var );
EmailList m_emailList;
TelephoneList m_telephoneList;
AddressList m_addressList;
LabelList m_labelList;
Name m_name;
Geo m_geo;
Org m_org;
Photo m_photo;
Photo m_logo;
VCardClassification m_class;
std::string m_formattedname;
std::string m_nickname;
std::string m_url;
std::string m_bday;
std::string m_jabberid;
std::string m_title;
std::string m_role;
std::string m_note;
std::string m_desc;
std::string m_mailer;
std::string m_tz;
std::string m_prodid;
std::string m_rev;
std::string m_sortstring;
std::string m_uid;
bool m_N;
bool m_PHOTO;
bool m_LOGO;
};
}
#endif // VCARD_H__
gloox::StanzaExtension::StanzaExtension
StanzaExtension(int type)
Definition stanzaextension.h:211
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox::VCard::prodid
const std::string & prodid() const
Definition vcard.h:413
gloox::VCard::telephone
const TelephoneList & telephone() const
Definition vcard.h:526
gloox::VCard::formattedname
const std::string & formattedname() const
Definition vcard.h:237
gloox::VCard::~VCard
virtual ~VCard()
Definition vcard.h:225
gloox::VCard::desc
const std::string & desc() const
Definition vcard.h:352
gloox::VCard::labels
const LabelList & labels() const
Definition vcard.h:513
gloox::VCard::clone
virtual StanzaExtension * clone() const
Definition vcard.h:580
gloox::VCard::sortstring
const std::string & sortstring() const
Definition vcard.h:425
gloox::VCard::setProdid
void setProdid(const std::string &prodid)
Definition vcard.h:407
gloox::VCard::VCardClassification
VCardClassification
Definition vcard.h:84
gloox::VCard::ClassNone
@ ClassNone
Definition vcard.h:85
gloox::VCard::ClassPrivate
@ ClassPrivate
Definition vcard.h:87
gloox::VCard::ClassPublic
@ ClassPublic
Definition vcard.h:86
gloox::VCard::ClassConfidential
@ ClassConfidential
Definition vcard.h:88
gloox::VCard::title
const std::string & title() const
Definition vcard.h:316
gloox::VCard::setRole
void setRole(const std::string &role)
Definition vcard.h:322
gloox::VCard::jabberid
const std::string & jabberid() const
Definition vcard.h:304
gloox::VCard::logo
const Photo & logo() const
Definition vcard.h:465
gloox::VCard::VCard
VCard()
Definition vcard.cpp:43
gloox::VCard::setNote
void setNote(const std::string &note)
Definition vcard.h:334
gloox::VCard::org
const Org & org() const
Definition vcard.h:553
gloox::VCard::note
const std::string & note() const
Definition vcard.h:340
gloox::VCard::name
const Name & name() const
Definition vcard.h:256
gloox::VCard::mailer
const std::string & mailer() const
Definition vcard.h:364
gloox::VCard::LabelList
std::list< Label > LabelList
Definition vcard.h:209
gloox::VCard::setDesc
void setDesc(const std::string &desc)
Definition vcard.h:346
gloox::VCard::uid
const std::string & uid() const
Definition vcard.h:388
gloox::VCard::nickname
const std::string & nickname() const
Definition vcard.h:268
gloox::VCard::TelephoneList
std::list< Telephone > TelephoneList
Definition vcard.h:133
gloox::VCard::setTz
void setTz(const std::string &tz)
Definition vcard.h:395
gloox::VCard::setBday
void setBday(const std::string &bday)
Definition vcard.h:286
gloox::VCard::setUrl
void setUrl(const std::string &url)
Definition vcard.h:274
gloox::VCard::newInstance
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition vcard.h:571
gloox::VCard::AddressList
std::list< Address > AddressList
Definition vcard.h:204
gloox::VCard::tz
const std::string & tz() const
Definition vcard.h:401
gloox::VCard::setSortstring
void setSortstring(const std::string &sortstring)
Definition vcard.h:419
gloox::VCard::setRev
void setRev(const std::string &rev)
Definition vcard.h:370
gloox::VCard::addresses
const AddressList & addresses() const
Definition vcard.h:507
gloox::VCard::geo
const Geo & geo() const
Definition vcard.h:540
gloox::VCard::setJabberid
void setJabberid(const std::string &jabberid)
Definition vcard.h:298
gloox::VCard::classification
const VCardClassification & classification() const
Definition vcard.h:565
gloox::VCard::bday
const std::string & bday() const
Definition vcard.h:292
gloox::VCard::setFormattedname
void setFormattedname(const std::string &name)
Definition vcard.h:231
gloox::VCard::AddressType
AddressType
Definition vcard.h:46
gloox::VCard::AddrTypeMsg
@ AddrTypeMsg
Definition vcard.h:59
gloox::VCard::AddrTypeX400
@ AddrTypeX400
Definition vcard.h:50
gloox::VCard::AddrTypePref
@ AddrTypePref
Definition vcard.h:49
gloox::VCard::AddrTypeModem
@ AddrTypeModem
Definition vcard.h:63
gloox::VCard::AddrTypeWork
@ AddrTypeWork
Definition vcard.h:48
gloox::VCard::AddrTypeDom
@ AddrTypeDom
Definition vcard.h:54
gloox::VCard::AddrTypeInet
@ AddrTypeInet
Definition vcard.h:51
gloox::VCard::AddrTypeParcel
@ AddrTypeParcel
Definition vcard.h:52
gloox::VCard::AddrTypeVideo
@ AddrTypeVideo
Definition vcard.h:61
gloox::VCard::AddrTypeIsdn
@ AddrTypeIsdn
Definition vcard.h:64
gloox::VCard::AddrTypeHome
@ AddrTypeHome
Definition vcard.h:47
gloox::VCard::AddrTypeBbs
@ AddrTypeBbs
Definition vcard.h:62
gloox::VCard::AddrTypeIntl
@ AddrTypeIntl
Definition vcard.h:55
gloox::VCard::AddrTypeFax
@ AddrTypeFax
Definition vcard.h:57
gloox::VCard::AddrTypePcs
@ AddrTypePcs
Definition vcard.h:65
gloox::VCard::AddrTypeVoice
@ AddrTypeVoice
Definition vcard.h:56
gloox::VCard::AddrTypePager
@ AddrTypePager
Definition vcard.h:58
gloox::VCard::AddrTypePostal
@ AddrTypePostal
Definition vcard.h:53
gloox::VCard::AddrTypeCell
@ AddrTypeCell
Definition vcard.h:60
gloox::VCard::setTitle
void setTitle(const std::string &title)
Definition vcard.h:310
gloox::VCard::photo
const Photo & photo() const
Definition vcard.h:445
gloox::VCard::setMailer
void setMailer(const std::string &mailer)
Definition vcard.h:358
gloox::VCard::EmailList
std::list< Email > EmailList
Definition vcard.h:107
gloox::VCard::url
const std::string & url() const
Definition vcard.h:280
gloox::VCard::rev
const std::string & rev() const
Definition vcard.h:376
gloox::VCard::setUid
void setUid(const std::string &uid)
Definition vcard.h:382
gloox::VCard::setNickname
void setNickname(const std::string &nickname)
Definition vcard.h:262
gloox::VCard::role
const std::string & role() const
Definition vcard.h:328
gloox::VCard::tag
virtual Tag * tag() const
Definition vcard.cpp:405
gloox::VCard::emailAddresses
const EmailList & emailAddresses() const
Definition vcard.h:478
gloox::VCard::setClass
void setClass(VCardClassification vclass)
Definition vcard.h:559
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StringList
std::list< std::string > StringList
Definition gloox.h:1251
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124
gloox::VCard::Address
Definition vcard.h:139
gloox::VCard::Address::intl
bool intl
Definition vcard.h:153
gloox::VCard::Address::ctry
std::string ctry
Definition vcard.h:146
gloox::VCard::Address::postal
bool postal
Definition vcard.h:149
gloox::VCard::Address::pref
bool pref
Definition vcard.h:151
gloox::VCard::Address::region
std::string region
Definition vcard.h:144
gloox::VCard::Address::dom
bool dom
Definition vcard.h:152
gloox::VCard::Address::locality
std::string locality
Definition vcard.h:143
gloox::VCard::Address::work
bool work
Definition vcard.h:148
gloox::VCard::Address::parcel
bool parcel
Definition vcard.h:150
gloox::VCard::Address::extadd
std::string extadd
Definition vcard.h:141
gloox::VCard::Address::street
std::string street
Definition vcard.h:142
gloox::VCard::Address::pobox
std::string pobox
Definition vcard.h:140
gloox::VCard::Address::home
bool home
Definition vcard.h:147
gloox::VCard::Address::pcode
std::string pcode
Definition vcard.h:145
gloox::VCard::Email
Definition vcard.h:95
gloox::VCard::Email::pref
bool pref
Definition vcard.h:100
gloox::VCard::Email::x400
bool x400
Definition vcard.h:101
gloox::VCard::Email::internet
bool internet
Definition vcard.h:99
gloox::VCard::Email::userid
std::string userid
Definition vcard.h:96
gloox::VCard::Email::work
bool work
Definition vcard.h:98
gloox::VCard::Email::home
bool home
Definition vcard.h:97
gloox::VCard::Geo
Definition vcard.h:175
gloox::VCard::Geo::latitude
std::string latitude
Definition vcard.h:176
gloox::VCard::Geo::longitude
std::string longitude
Definition vcard.h:177
gloox::VCard::Label
Definition vcard.h:160
gloox::VCard::Label::intl
bool intl
Definition vcard.h:168
gloox::VCard::Label::postal
bool postal
Definition vcard.h:164
gloox::VCard::Label::pref
bool pref
Definition vcard.h:166
gloox::VCard::Label::dom
bool dom
Definition vcard.h:167
gloox::VCard::Label::lines
StringList lines
Definition vcard.h:161
gloox::VCard::Label::work
bool work
Definition vcard.h:163
gloox::VCard::Label::parcel
bool parcel
Definition vcard.h:165
gloox::VCard::Label::home
bool home
Definition vcard.h:162
gloox::VCard::Name
Definition vcard.h:72
gloox::VCard::Name::middle
std::string middle
Definition vcard.h:75
gloox::VCard::Name::given
std::string given
Definition vcard.h:74
gloox::VCard::Name::prefix
std::string prefix
Definition vcard.h:76
gloox::VCard::Name::suffix
std::string suffix
Definition vcard.h:77
gloox::VCard::Name::family
std::string family
Definition vcard.h:73
gloox::VCard::Org
Definition vcard.h:184
gloox::VCard::Org::name
std::string name
Definition vcard.h:185
gloox::VCard::Org::units
StringList units
Definition vcard.h:186
gloox::VCard::Photo
Definition vcard.h:194
gloox::VCard::Photo::binval
std::string binval
Definition vcard.h:197
gloox::VCard::Photo::extval
std::string extval
Definition vcard.h:195
gloox::VCard::Photo::type
std::string type
Definition vcard.h:198
gloox::VCard::Telephone
Definition vcard.h:113
gloox::VCard::Telephone::cell
bool cell
Definition vcard.h:121
gloox::VCard::Telephone::pref
bool pref
Definition vcard.h:127
gloox::VCard::Telephone::number
std::string number
Definition vcard.h:114
gloox::VCard::Telephone::voice
bool voice
Definition vcard.h:117
gloox::VCard::Telephone::bbs
bool bbs
Definition vcard.h:123
gloox::VCard::Telephone::pager
bool pager
Definition vcard.h:119
gloox::VCard::Telephone::work
bool work
Definition vcard.h:116
gloox::VCard::Telephone::fax
bool fax
Definition vcard.h:118
gloox::VCard::Telephone::isdn
bool isdn
Definition vcard.h:125
gloox::VCard::Telephone::msg
bool msg
Definition vcard.h:120
gloox::VCard::Telephone::modem
bool modem
Definition vcard.h:124
gloox::VCard::Telephone::pcs
bool pcs
Definition vcard.h:126
gloox::VCard::Telephone::home
bool home
Definition vcard.h:115
gloox::VCard::Telephone::video
bool video
Definition vcard.h:122