gloox  1.0.22
vcard.h
1 /*
2  Copyright (c) 2006-2017 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef VCARD_H__
15 #define VCARD_H__
16 
17 #include "gloox.h"
18 #include "stanzaextension.h"
19 
20 namespace gloox
21 {
22 
23  class Tag;
24 
34  class GLOOX_API VCard : public StanzaExtension
35  {
36  public:
46  {
47  AddrTypeHome = 1,
48  AddrTypeWork = 2,
49  AddrTypePref = 4,
50  AddrTypeX400 = 8,
51  AddrTypeInet = 16,
52  AddrTypeParcel = 32,
53  AddrTypePostal = 64,
54  AddrTypeDom = 128,
55  AddrTypeIntl = 256,
56  AddrTypeVoice = 512,
57  AddrTypeFax = 1024,
58  AddrTypePager = 2048,
59  AddrTypeMsg = 4096,
60  AddrTypeCell = 8192,
61  AddrTypeVideo = 16384,
62  AddrTypeBbs = 32768,
63  AddrTypeModem = 65536,
64  AddrTypeIsdn = 131072,
65  AddrTypePcs = 262144
66  };
67 
71  struct Name
72  {
73  std::string family;
74  std::string given;
75  std::string middle;
76  std::string prefix;
77  std::string suffix;
78  };
79 
84  {
85  ClassNone = 0,
86  ClassPublic = 1,
87  ClassPrivate = 2,
88  ClassConfidential = 4
89  };
90 
94  struct Email
95  {
96  std::string userid;
97  bool home;
98  bool work;
99  bool internet;
100  bool pref;
101  bool x400;
102  };
103 
107  typedef std::list<Email> EmailList;
108 
112  struct Telephone
113  {
114  std::string number;
115  bool home;
116  bool work;
117  bool voice;
118  bool fax;
119  bool pager;
120  bool msg;
121  bool cell;
122  bool video;
123  bool bbs;
124  bool modem;
125  bool isdn;
126  bool pcs;
127  bool pref;
128  };
129 
133  typedef std::list<Telephone> TelephoneList;
134 
138  struct Address
139  {
140  std::string pobox;
141  std::string extadd;
142  std::string street;
143  std::string locality;
144  std::string region;
145  std::string pcode;
146  std::string ctry;
147  bool home;
148  bool work;
149  bool postal;
150  bool parcel;
151  bool pref;
152  bool dom;
153  bool intl;
154  };
155 
159  struct Label
160  {
162  bool home;
163  bool work;
164  bool postal;
165  bool parcel;
166  bool pref;
167  bool dom;
168  bool intl;
169  };
170 
174  struct Geo
175  {
176  std::string latitude;
177  std::string longitude;
178  };
179 
183  struct Org
184  {
185  std::string name;
188  };
189 
193  struct Photo
194  {
195  std::string extval;
197  std::string binval;
198  std::string type;
199  };
200 
204  typedef std::list<Address> AddressList;
205 
209  typedef std::list<Label> LabelList;
210 
214  VCard();
215 
220  VCard( const Tag* vcard );
221 
225  virtual ~VCard() {}
226 
231  void setFormattedname( const std::string& name ) { m_formattedname = name; }
232 
237  const std::string& formattedname() const { return m_formattedname; }
238 
247  void setName( const std::string& family, const std::string& given,
248  const std::string& middle = EmptyString,
249  const std::string& prefix = EmptyString,
250  const std::string& suffix = EmptyString );
251 
256  const Name& name() const { return m_name; }
257 
262  void setNickname( const std::string& nickname ) { m_nickname = nickname; }
263 
268  const std::string& nickname() const { return m_nickname; }
269 
274  void setUrl( const std::string& url ) { m_url = url; }
275 
280  const std::string& url() const { return m_url; }
281 
286  void setBday( const std::string& bday ) { m_bday = bday; }
287 
292  const std::string& bday() const { return m_bday; }
293 
298  void setJabberid( const std::string& jabberid ) { m_jabberid = jabberid; }
299 
304  const std::string& jabberid() const { return m_jabberid; }
305 
310  void setTitle( const std::string& title ) { m_title = title; }
311 
316  const std::string& title() const { return m_title; }
317 
322  void setRole( const std::string& role ) { m_role = role; }
323 
328  const std::string& role() const { return m_role; }
329 
334  void setNote( const std::string& note ) { m_note = note; }
335 
340  const std::string& note() const { return m_note; }
341 
346  void setDesc( const std::string& desc ) { m_desc = desc; }
347 
352  const std::string& desc() const { return m_desc; }
353 
358  void setMailer( const std::string& mailer ) { m_mailer = mailer; }
359 
364  const std::string& mailer() const { return m_mailer; }
365 
370  void setRev( const std::string& rev ) { m_rev = rev; }
371 
376  const std::string& rev() const { return m_rev; }
377 
382  void setUid( const std::string& uid ) { m_uid = uid; }
383 
388  const std::string& uid() const { return m_uid; }
389 
395  void setTz( const std::string& tz ) { m_tz = tz; }
396 
401  const std::string& tz() const { return m_tz; }
402 
407  void setProdid( const std::string& prodid ) { m_prodid = prodid; }
408 
413  const std::string& prodid() const { return m_prodid; }
414 
419  void setSortstring( const std::string& sortstring ) { m_sortstring = sortstring; }
420 
425  const std::string& sortstring() const { return m_sortstring; }
426 
431  void setPhotoUri( const std::string& extval );
432 
439  void setPhoto( const std::string& type = EmptyString, const std::string& binval = EmptyString );
440 
445  const Photo& photo() const { return m_photo; }
446 
451  void setLogo( const std::string& extval );
452 
459  void setLogo( const std::string& type = EmptyString, const std::string& binval = EmptyString );
460 
465  const Photo& logo() const { return m_logo; }
466 
472  void addEmail( const std::string& userid, int type );
473 
478  const EmailList& emailAddresses() const { return m_emailList; }
479 
491  void addAddress( const std::string& pobox, const std::string& extadd,
492  const std::string& street, const std::string& locality,
493  const std::string& region, const std::string& pcode,
494  const std::string& ctry, int type );
495 
501  void addLabel( const StringList& lines, int type );
502 
507  const AddressList& addresses() const { return m_addressList; }
508 
513  const LabelList& labels() const { return m_labelList; }
514 
520  void addTelephone( const std::string& number, int type );
521 
526  const TelephoneList& telephone() const { return m_telephoneList; }
527 
534  void setGeo( const std::string& lat, const std::string& lon );
535 
540  const Geo& geo() const { return m_geo; }
541 
547  void setOrganization( const std::string& orgname, const StringList& orgunits );
548 
553  const Org& org() const { return m_org; }
554 
559  void setClass( VCardClassification vclass ) { m_class = vclass; }
560 
565  const VCardClassification& classification() const { return m_class; }
566 
567  // reimplemented from StanzaExtension
568  virtual const std::string& filterString() const;
569 
570  // reimplemented from StanzaExtension
571  virtual StanzaExtension* newInstance( const Tag* tag ) const
572  {
573  return new VCard( tag );
574  }
575 
576  // reimplemented from StanzaExtension
577  virtual Tag* tag() const;
578 
579  // reimplemented from StanzaExtension
580  virtual StanzaExtension* clone() const
581  {
582  return new VCard( *this );
583  }
584 
585  private:
586 
587  static void insertField( Tag* vcard, const char* field, const std::string& var );
588  static void insertField( Tag* vcard, const char* field, bool var );
589  static void checkField ( const Tag* vcard, const char* field, std::string& var );
590 
591  EmailList m_emailList;
592  TelephoneList m_telephoneList;
593  AddressList m_addressList;
594  LabelList m_labelList;
595 
596  Name m_name;
597  Geo m_geo;
598  Org m_org;
599  Photo m_photo;
600  Photo m_logo;
601 
602  VCardClassification m_class;
603 
604  std::string m_formattedname;
605  std::string m_nickname;
606  std::string m_url;
607  std::string m_bday;
608  std::string m_jabberid;
609  std::string m_title;
610  std::string m_role;
611  std::string m_note;
612  std::string m_desc;
613  std::string m_mailer;
614  std::string m_tz;
615  std::string m_prodid;
616  std::string m_rev;
617  std::string m_sortstring;
618  std::string m_uid;
619 
620  bool m_N;
621  bool m_PHOTO;
622  bool m_LOGO;
623  };
624 
625 }
626 
627 #endif // VCARD_H__
gloox::VCard::Photo::extval
std::string extval
Definition: vcard.h:195
gloox::VCard::setDesc
void setDesc(const std::string &desc)
Definition: vcard.h:346
gloox::VCard::Address::locality
std::string locality
Definition: vcard.h:143
gloox::VCard::Name::suffix
std::string suffix
Definition: vcard.h:77
gloox::VCard::Address::ctry
std::string ctry
Definition: vcard.h:146
gloox::VCard::Label::parcel
bool parcel
Definition: vcard.h:165
gloox::VCard::org
const Org & org() const
Definition: vcard.h:553
gloox::VCard::setRole
void setRole(const std::string &role)
Definition: vcard.h:322
gloox::VCard::uid
const std::string & uid() const
Definition: vcard.h:388
gloox::VCard::Address::pcode
std::string pcode
Definition: vcard.h:145
gloox::VCard::Label::home
bool home
Definition: vcard.h:162
gloox::VCard::telephone
const TelephoneList & telephone() const
Definition: vcard.h:526
gloox::VCard::mailer
const std::string & mailer() const
Definition: vcard.h:364
gloox::StanzaExtension
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
Definition: stanzaextension.h:203
gloox::VCard::Label
Definition: vcard.h:159
gloox::VCard::Email::internet
bool internet
Definition: vcard.h:99
gloox::VCard::Address::region
std::string region
Definition: vcard.h:144
gloox::VCard::Photo::type
std::string type
Definition: vcard.h:198
gloox::VCard::Telephone::isdn
bool isdn
Definition: vcard.h:125
gloox::VCard::Label::pref
bool pref
Definition: vcard.h:166
gloox::VCard::setMailer
void setMailer(const std::string &mailer)
Definition: vcard.h:358
gloox::VCard::name
const Name & name() const
Definition: vcard.h:256
gloox::VCard::Address::home
bool home
Definition: vcard.h:147
gloox::VCard::Name::prefix
std::string prefix
Definition: vcard.h:76
gloox::VCard::Telephone::number
std::string number
Definition: vcard.h:114
gloox::VCard::geo
const Geo & geo() const
Definition: vcard.h:540
gloox::VCard::EmailList
std::list< Email > EmailList
Definition: vcard.h:107
gloox::VCard::Label::work
bool work
Definition: vcard.h:163
gloox::VCard::Name::middle
std::string middle
Definition: vcard.h:75
gloox::VCard::TelephoneList
std::list< Telephone > TelephoneList
Definition: vcard.h:133
gloox::VCard::AddressType
AddressType
Definition: vcard.h:45
gloox::VCard::Email
Definition: vcard.h:94
gloox::VCard::Telephone::home
bool home
Definition: vcard.h:115
gloox::VCard::Label::dom
bool dom
Definition: vcard.h:167
gloox::VCard::Email::work
bool work
Definition: vcard.h:98
gloox::VCard::prodid
const std::string & prodid() const
Definition: vcard.h:413
gloox::VCard::setProdid
void setProdid(const std::string &prodid)
Definition: vcard.h:407
gloox::VCard::LabelList
std::list< Label > LabelList
Definition: vcard.h:209
gloox::VCard::Org::name
std::string name
Definition: vcard.h:185
gloox::VCard::classification
const VCardClassification & classification() const
Definition: vcard.h:565
gloox::VCard::Address
Definition: vcard.h:138
gloox::VCard::Photo::binval
std::string binval
Definition: vcard.h:197
gloox::VCard::photo
const Photo & photo() const
Definition: vcard.h:445
gloox::VCard::AddressList
std::list< Address > AddressList
Definition: vcard.h:204
gloox::VCard::Telephone::work
bool work
Definition: vcard.h:116
gloox::VCard::setTz
void setTz(const std::string &tz)
Definition: vcard.h:395
gloox::StringList
std::list< std::string > StringList
Definition: gloox.h:1251
gloox::VCard::Email::pref
bool pref
Definition: vcard.h:100
gloox::EmptyString
const std::string EmptyString
Definition: gloox.cpp:124
gloox::VCard::Name::family
std::string family
Definition: vcard.h:73
gloox::VCard::Name::given
std::string given
Definition: vcard.h:74
gloox::VCard::addresses
const AddressList & addresses() const
Definition: vcard.h:507
gloox::VCard::Email::userid
std::string userid
Definition: vcard.h:96
gloox::VCard::nickname
const std::string & nickname() const
Definition: vcard.h:268
gloox::VCard::Telephone::pref
bool pref
Definition: vcard.h:127
gloox::VCard
A VCard abstraction.
Definition: vcard.h:34
gloox::VCard::title
const std::string & title() const
Definition: vcard.h:316
gloox::VCard::logo
const Photo & logo() const
Definition: vcard.h:465
gloox::VCard::Address::intl
bool intl
Definition: vcard.h:153
gloox::VCard::labels
const LabelList & labels() const
Definition: vcard.h:513
gloox::VCard::rev
const std::string & rev() const
Definition: vcard.h:376
gloox::VCard::setRev
void setRev(const std::string &rev)
Definition: vcard.h:370
gloox::VCard::Address::parcel
bool parcel
Definition: vcard.h:150
gloox::VCard::Address::dom
bool dom
Definition: vcard.h:152
gloox::VCard::Label::postal
bool postal
Definition: vcard.h:164
gloox::VCard::note
const std::string & note() const
Definition: vcard.h:340
gloox::VCard::Address::work
bool work
Definition: vcard.h:148
gloox::VCard::setTitle
void setTitle(const std::string &title)
Definition: vcard.h:310
gloox::VCard::Telephone::cell
bool cell
Definition: vcard.h:121
gloox::VCard::Telephone::pager
bool pager
Definition: vcard.h:119
gloox
The namespace for the gloox library.
Definition: adhoc.cpp:27
gloox::VCard::bday
const std::string & bday() const
Definition: vcard.h:292
gloox::VCard::Telephone
Definition: vcard.h:112
gloox::Tag
This is an abstraction of an XML element.
Definition: tag.h:46
gloox::VCard::setFormattedname
void setFormattedname(const std::string &name)
Definition: vcard.h:231
gloox::VCard::Org
Definition: vcard.h:183
gloox::VCard::Telephone::voice
bool voice
Definition: vcard.h:117
gloox::VCard::Telephone::modem
bool modem
Definition: vcard.h:124
gloox::VCard::setBday
void setBday(const std::string &bday)
Definition: vcard.h:286
gloox::VCard::setUid
void setUid(const std::string &uid)
Definition: vcard.h:382
gloox::VCard::Label::intl
bool intl
Definition: vcard.h:168
gloox::VCard::Email::x400
bool x400
Definition: vcard.h:101
gloox::VCard::Org::units
StringList units
Definition: vcard.h:186
gloox::VCard::clone
virtual StanzaExtension * clone() const
Definition: vcard.h:580
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::Telephone::fax
bool fax
Definition: vcard.h:118
gloox::VCard::Geo::latitude
std::string latitude
Definition: vcard.h:176
gloox::VCard::desc
const std::string & desc() const
Definition: vcard.h:352
gloox::VCard::sortstring
const std::string & sortstring() const
Definition: vcard.h:425
gloox::VCard::Address::street
std::string street
Definition: vcard.h:142
gloox::VCard::Address::pobox
std::string pobox
Definition: vcard.h:140
gloox::VCard::url
const std::string & url() const
Definition: vcard.h:280
gloox::VCard::Telephone::msg
bool msg
Definition: vcard.h:120
gloox::VCard::Email::home
bool home
Definition: vcard.h:97
gloox::VCard::setClass
void setClass(VCardClassification vclass)
Definition: vcard.h:559
gloox::VCard::Geo::longitude
std::string longitude
Definition: vcard.h:177
gloox::VCard::Telephone::pcs
bool pcs
Definition: vcard.h:126
gloox::VCard::Telephone::video
bool video
Definition: vcard.h:122
gloox::VCard::setUrl
void setUrl(const std::string &url)
Definition: vcard.h:274
gloox::VCard::Name
Definition: vcard.h:71
gloox::VCard::tz
const std::string & tz() const
Definition: vcard.h:401
gloox::VCard::~VCard
virtual ~VCard()
Definition: vcard.h:225
gloox::VCard::Address::postal
bool postal
Definition: vcard.h:149
gloox::VCard::setNote
void setNote(const std::string &note)
Definition: vcard.h:334
gloox::VCard::Address::pref
bool pref
Definition: vcard.h:151
gloox::VCard::Telephone::bbs
bool bbs
Definition: vcard.h:123
gloox::VCard::Photo
Definition: vcard.h:193
gloox::VCard::Address::extadd
std::string extadd
Definition: vcard.h:141
gloox::VCard::formattedname
const std::string & formattedname() const
Definition: vcard.h:237
gloox::VCard::newInstance
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition: vcard.h:571
gloox::VCard::setJabberid
void setJabberid(const std::string &jabberid)
Definition: vcard.h:298
gloox::VCard::VCardClassification
VCardClassification
Definition: vcard.h:83
gloox::VCard::Label::lines
StringList lines
Definition: vcard.h:161
gloox::VCard::Geo
Definition: vcard.h:174
gloox::VCard::jabberid
const std::string & jabberid() const
Definition: vcard.h:304
gloox::VCard::setSortstring
void setSortstring(const std::string &sortstring)
Definition: vcard.h:419
gloox::VCard::emailAddresses
const EmailList & emailAddresses() const
Definition: vcard.h:478