gloox 1.0
|
00001 /* 00002 Copyright (c) 2006-2009 by Jakob Schroeter <js@camaya.net> 00003 This file is part of the gloox library. http://camaya.net/gloox 00004 00005 This software is distributed under a license. The full license 00006 agreement can be found in the file LICENSE in this distribution. 00007 This software may not be copied, modified, sold or distributed 00008 other than expressed in the named license agreement. 00009 00010 This software is distributed without any warranty. 00011 */ 00012 00013 00014 #ifndef VCARD_H__ 00015 #define VCARD_H__ 00016 00017 #include "gloox.h" 00018 #include "stanzaextension.h" 00019 00020 namespace gloox 00021 { 00022 00023 class Tag; 00024 00034 class GLOOX_API VCard : public StanzaExtension 00035 { 00036 public: 00045 enum AddressType 00046 { 00047 AddrTypeHome = 1, 00048 AddrTypeWork = 2, 00049 AddrTypePref = 4, 00050 AddrTypeX400 = 8, 00051 AddrTypeInet = 16, 00052 AddrTypeParcel = 32, 00053 AddrTypePostal = 64, 00054 AddrTypeDom = 128, 00055 AddrTypeIntl = 256, 00056 AddrTypeVoice = 512, 00057 AddrTypeFax = 1024, 00058 AddrTypePager = 2048, 00059 AddrTypeMsg = 4096, 00060 AddrTypeCell = 8192, 00061 AddrTypeVideo = 16384, 00062 AddrTypeBbs = 32768, 00063 AddrTypeModem = 65536, 00064 AddrTypeIsdn = 131072, 00065 AddrTypePcs = 262144 00066 }; 00067 00071 struct Name 00072 { 00073 std::string family; 00074 std::string given; 00075 std::string middle; 00076 std::string prefix; 00077 std::string suffix; 00078 }; 00079 00083 enum VCardClassification 00084 { 00085 ClassNone = 0, 00086 ClassPublic = 1, 00087 ClassPrivate = 2, 00088 ClassConfidential = 4 00089 }; 00090 00094 struct Email 00095 { 00096 std::string userid; 00097 bool home; 00098 bool work; 00099 bool internet; 00100 bool pref; 00101 bool x400; 00102 }; 00103 00107 typedef std::list<Email> EmailList; 00108 00112 struct Telephone 00113 { 00114 std::string number; 00115 bool home; 00116 bool work; 00117 bool voice; 00118 bool fax; 00119 bool pager; 00120 bool msg; 00121 bool cell; 00122 bool video; 00123 bool bbs; 00124 bool modem; 00125 bool isdn; 00126 bool pcs; 00127 bool pref; 00128 }; 00129 00133 typedef std::list<Telephone> TelephoneList; 00134 00138 struct Address 00139 { 00140 std::string pobox; 00141 std::string extadd; 00142 std::string street; 00143 std::string locality; 00144 std::string region; 00145 std::string pcode; 00146 std::string ctry; 00147 bool home; 00148 bool work; 00149 bool postal; 00150 bool parcel; 00151 bool pref; 00152 bool dom; 00153 bool intl; 00154 }; 00155 00159 struct Label 00160 { 00161 StringList lines; 00162 bool home; 00163 bool work; 00164 bool postal; 00165 bool parcel; 00166 bool pref; 00167 bool dom; 00168 bool intl; 00169 }; 00170 00174 struct Geo 00175 { 00176 std::string latitude; 00177 std::string longitude; 00178 }; 00179 00183 struct Org 00184 { 00185 std::string name; 00186 StringList units; 00188 }; 00189 00193 struct Photo 00194 { 00195 std::string extval; 00197 std::string binval; 00198 std::string type; 00199 }; 00200 00204 typedef std::list<Address> AddressList; 00205 00209 typedef std::list<Label> LabelList; 00210 00214 VCard(); 00215 00220 VCard( const Tag* vcard ); 00221 00225 virtual ~VCard() {} 00226 00231 void setFormattedname( const std::string& name ) { m_formattedname = name; } 00232 00237 const std::string& formattedname() const { return m_formattedname; } 00238 00247 void setName( const std::string& family, const std::string& given, 00248 const std::string& middle = EmptyString, 00249 const std::string& prefix = EmptyString, 00250 const std::string& suffix = EmptyString ); 00251 00256 const Name& name() const { return m_name; } 00257 00262 void setNickname( const std::string& nickname ) { m_nickname = nickname; } 00263 00268 const std::string& nickname() const { return m_nickname; } 00269 00274 void setUrl( const std::string& url ) { m_url = url; } 00275 00280 const std::string& url() const { return m_url; } 00281 00286 void setBday( const std::string& bday ) { m_bday = bday; } 00287 00292 const std::string& bday() const { return m_bday; } 00293 00298 void setJabberid( const std::string& jabberid ) { m_jabberid = jabberid; } 00299 00304 const std::string& jabberid() const { return m_jabberid; } 00305 00310 void setTitle( const std::string& title ) { m_title = title; } 00311 00316 const std::string& title() const { return m_title; } 00317 00322 void setRole( const std::string& role ) { m_role = role; } 00323 00328 const std::string& role() const { return m_role; } 00329 00334 void setNote( const std::string& note ) { m_note = note; } 00335 00340 const std::string& note() const { return m_note; } 00341 00346 void setDesc( const std::string& desc ) { m_desc = desc; } 00347 00352 const std::string& desc() const { return m_desc; } 00353 00358 void setMailer( const std::string& mailer ) { m_mailer = mailer; } 00359 00364 const std::string& mailer() const { return m_mailer; } 00365 00370 void setRev( const std::string& rev ) { m_rev = rev; } 00371 00376 const std::string& rev() const { return m_rev; } 00377 00382 void setUid( const std::string& uid ) { m_uid = uid; } 00383 00388 const std::string& uid() const { return m_uid; } 00389 00395 void setTz( const std::string& tz ) { m_tz = tz; } 00396 00401 const std::string& tz() const { return m_tz; } 00402 00407 void setProdid( const std::string& prodid ) { m_prodid = prodid; } 00408 00413 const std::string& prodid() const { return m_prodid; } 00414 00419 void setSortstring( const std::string& sortstring ) { m_sortstring = sortstring; } 00420 00425 const std::string& sortstring() const { return m_sortstring; } 00426 00431 void setPhoto( const std::string& extval ); 00432 00439 void setPhoto( const std::string& type = EmptyString, const std::string& binval = EmptyString ); 00440 00445 const Photo& photo() const { return m_photo; } 00446 00451 void setLogo( const std::string& extval ); 00452 00459 void setLogo( const std::string& type = EmptyString, const std::string& binval = EmptyString ); 00460 00465 const Photo& logo() const { return m_logo; } 00466 00472 void addEmail( const std::string& userid, int type ); 00473 00478 EmailList& emailAddresses() { return m_emailList; } 00479 00491 void addAddress( const std::string& pobox, const std::string& extadd, 00492 const std::string& street, const std::string& locality, 00493 const std::string& region, const std::string& pcode, 00494 const std::string& ctry, int type ); 00495 00501 void addLabel( const StringList& lines, int type ); 00502 00507 AddressList& addresses() { return m_addressList; } 00508 00513 LabelList& labels() { return m_labelList; } 00514 00520 void addTelephone( const std::string& number, int type ); 00521 00526 TelephoneList& telephone() { return m_telephoneList; } 00527 00534 void setGeo( const std::string& lat, const std::string& lon ); 00535 00540 const Geo& geo() const { return m_geo; } 00541 00547 void setOrganization( const std::string& orgname, const StringList& orgunits ); 00548 00553 const Org& org() const { return m_org; } 00554 00559 void setClass( VCardClassification vclass ) { m_class = vclass; } 00560 00565 VCardClassification classification() const { return m_class; } 00566 00567 // reimplemented from StanzaExtension 00568 virtual const std::string& filterString() const; 00569 00570 // reimplemented from StanzaExtension 00571 virtual StanzaExtension* newInstance( const Tag* tag ) const 00572 { 00573 return new VCard( tag ); 00574 } 00575 00576 // reimplemented from StanzaExtension 00577 virtual Tag* tag() const; 00578 00579 // reimplemented from StanzaExtension 00580 virtual StanzaExtension* clone() const 00581 { 00582 return new VCard( *this ); 00583 } 00584 00585 private: 00586 00587 static void insertField( Tag* vcard, const char* field, const std::string& var ); 00588 static void insertField( Tag* vcard, const char* field, bool var ); 00589 static void checkField ( const Tag* vcard, const char* field, std::string& var ); 00590 00591 EmailList m_emailList; 00592 TelephoneList m_telephoneList; 00593 AddressList m_addressList; 00594 LabelList m_labelList; 00595 00596 Name m_name; 00597 Geo m_geo; 00598 Org m_org; 00599 Photo m_photo; 00600 Photo m_logo; 00601 00602 VCardClassification m_class; 00603 00604 std::string m_formattedname; 00605 std::string m_nickname; 00606 std::string m_url; 00607 std::string m_bday; 00608 std::string m_jabberid; 00609 std::string m_title; 00610 std::string m_role; 00611 std::string m_note; 00612 std::string m_desc; 00613 std::string m_mailer; 00614 std::string m_tz; 00615 std::string m_prodid; 00616 std::string m_rev; 00617 std::string m_sortstring; 00618 std::string m_uid; 00619 00620 bool m_N; 00621 bool m_PHOTO; 00622 bool m_LOGO; 00623 }; 00624 00625 } 00626 00627 #endif // VCARD_H__