vcard.h

00001 /*
00002   Copyright (c) 2006 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 
00019 namespace gloox
00020 {
00021 
00022   class Tag;
00023 
00033   class GLOOX_API VCard
00034   {
00035     public:
00044       enum AddressType
00045       {
00046         AddrTypeHome   =      1,    
00047         AddrTypeWork   =      2,    
00048         AddrTypePref   =      4,    
00049         AddrTypeX400   =      8,    
00050         AddrTypeInet   =     16,    
00051         AddrTypeParcel =     32,    
00052         AddrTypePostal =     64,    
00053         AddrTypeDom    =    128,    
00054         AddrTypeIntl   =    256,    
00055         AddrTypeVoice  =    512,    
00056         AddrTypeFax    =   1024,    
00057         AddrTypePager  =   2048,    
00058         AddrTypeMsg    =   4096,    
00059         AddrTypeCell   =   8192,    
00060         AddrTypeVideo  =  16384,    
00061         AddrTypeBbs    =  32768,    
00062         AddrTypeModem  =  65536,    
00063         AddrTypeIsdn   = 131072,    
00064         AddrTypePcs    = 262144     
00065       };
00066 
00070       struct Name
00071       {
00072         std::string family;
00073         std::string given;
00074         std::string middle;
00075         std::string prefix;
00076         std::string suffix;
00077       };
00078 
00082       enum VCardClassification
00083       {
00084         ClassNone         = 0,      
00085         ClassPublic       = 1,      
00086         ClassPrivate      = 2,      
00087         ClassConfidential = 4       
00088       };
00089 
00093       struct Email
00094       {
00095         std::string userid;
00096         bool home;
00097         bool work;
00098         bool internet;
00099         bool pref;
00100         bool x400;
00101       };
00102 
00106       typedef std::list<Email> EmailList;
00107 
00111       struct Telephone
00112       {
00113         std::string number;
00114         bool home;
00115         bool work;
00116         bool voice;
00117         bool fax;
00118         bool pager;
00119         bool msg;
00120         bool cell;
00121         bool video;
00122         bool bbs;
00123         bool modem;
00124         bool isdn;
00125         bool pcs;
00126         bool pref;
00127       };
00128 
00132       typedef std::list<Telephone> TelephoneList;
00133 
00137       struct Address
00138       {
00139         std::string pobox;
00140         std::string extadd;
00141         std::string street;
00142         std::string locality;
00143         std::string region;
00144         std::string pcode;
00145         std::string ctry;
00146         bool home;
00147         bool work;
00148         bool postal;
00149         bool parcel;
00150         bool pref;
00151         bool dom;
00152         bool intl;
00153       };
00154 
00158       struct Geo
00159       {
00160         std::string latitude;
00161         std::string longitude;
00162       };
00163 
00167       struct Org
00168       {
00169         std::string name;
00170         StringList units;
00171       };
00172 
00176       struct Photo
00177       {
00178         std::string extval;
00179         std::string binval;
00180         std::string type;
00181       };
00182 
00186       typedef std::list<Address> AddressList;
00187 
00191       VCard();
00192 
00197       VCard( Tag* vcard );
00198 
00202       virtual ~VCard();
00203 
00208       Tag* tag() const;
00209 
00214       void setFormattedname( const std::string& name ) { m_formattedname = name; };
00215 
00220       const std::string& formattedname() const { return m_formattedname; };
00221 
00230       void setName( const std::string& family, const std::string& given, const std::string& middle = "",
00231                     const std::string& prefix = "", const std::string& suffix = "" );
00232 
00237       const Name& name() const { return m_name; };
00238 
00243       void setNickname( const std::string& nickname ) { m_nickname = nickname; };
00244 
00249       const std::string& nickname() const { return m_nickname; };
00250 
00255       void setUrl( const std::string& url ) { m_url = url; };
00256 
00261       const std::string& url() const { return m_url; };
00262 
00267       void setBday( const std::string& bday ) { m_bday = bday; };
00268 
00273       const std::string& bday() const { return m_bday; };
00274 
00279       void setJabberid( const std::string& jabberid ) { m_jabberid = jabberid; };
00280 
00285       const std::string& jabberid() const { return m_jabberid; };
00286 
00291       void setTitle( const std::string& title ) { m_title = title; };
00292 
00297       const std::string& title() const { return m_title; };
00298 
00303       void setRole( const std::string& role ) { m_role = role; };
00304 
00309       const std::string& role() const { return m_role; };
00310 
00315       void setNote( const std::string& note ) { m_note = note; };
00316 
00321       const std::string& note() const { return m_note; };
00322 
00327       void setDesc( const std::string& desc ) { m_desc = desc; };
00328 
00333       const std::string& desc() const { return m_desc; };
00334 
00339       void setMailer( const std::string& mailer ) { m_mailer = mailer; };
00340 
00345       const std::string& mailer() const { return m_mailer; };
00346 
00351       void setRev( const std::string& rev ) { m_rev = rev; };
00352 
00357       const std::string& rev() const { return m_rev; };
00358 
00363       void setUid( const std::string& uid ) { m_uid = uid; };
00364 
00369       const std::string& uid() const { return m_uid; };
00370 
00376       void setTz( const std::string& tz ) { m_tz = tz; };
00377 
00382       const std::string& tz() const { return m_tz; };
00383 
00388       void setProdid( const std::string& prodid ) { m_prodid = prodid; };
00389 
00394       const std::string& prodid() const { return m_prodid; };
00395 
00400       void setSortstring( const std::string& sortstring ) { m_sortstring = sortstring; };
00401 
00406       const std::string& sortstring() const { return m_sortstring; };
00407 
00412       void setPhoto( const std::string& extval );
00413 
00419       void setPhoto( const std::string& type, const std::string& binval );
00420 
00425       const Photo& photo() const { return m_photo; };
00426 
00431       void setLogo( const std::string& extval );
00432 
00438       void setLogo( const std::string& type, const std::string& binval );
00439 
00444       const Photo& logo() const { return m_logo; };
00445 
00451       void addEmail( const std::string& userid, int type );
00452 
00457       const EmailList& emailAddresses() const { return m_emailList; };
00458 
00470       void addAddress( const std::string& pobox, const std::string& extadd,
00471                        const std::string& street, const std::string& locality,
00472                        const std::string& region, const std::string& pcode,
00473                        const std::string& ctry, int type );
00474 
00479       const AddressList& addresses() const { return m_addressList; };
00480 
00486       void addTelephone( const std::string& number, int type );
00487 
00492       const TelephoneList& telephone() const { return m_telephoneList; };
00493 
00500       void setGeo( const std::string& lat, const std::string& lon );
00501 
00506       const Geo& geo() const { return m_geo; };
00507 
00513       void setOrganization( const std::string& orgname, const StringList& orgunits );
00514 
00519       const Org& org() const { return m_org; };
00520 
00525       void setClass( VCardClassification vclass ) { m_class = vclass; };
00526 
00531       VCardClassification classification() const { return m_class; };
00532 
00533 
00534     private:
00535       void checkField( Tag *vcard, const std::string& field, std::string& var );
00536       void insertField( Tag *vcard, const std::string& field, const std::string& var ) const;
00537       void insertField( Tag *vcard, const std::string& field, bool var ) const;
00538 
00539 
00540       EmailList m_emailList;
00541       TelephoneList m_telephoneList;
00542       AddressList m_addressList;
00543 
00544       Name m_name;
00545       Geo m_geo;
00546       Org m_org;
00547       Photo m_photo;
00548       Photo m_logo;
00549 
00550       VCardClassification m_class;
00551 
00552       std::string m_formattedname;
00553       std::string m_nickname;
00554       std::string m_url;
00555       std::string m_bday;
00556       std::string m_jabberid;
00557       std::string m_title;
00558       std::string m_role;
00559       std::string m_note;
00560       std::string m_desc;
00561       std::string m_mailer;
00562       std::string m_tz;
00563       std::string m_prodid;
00564       std::string m_rev;
00565       std::string m_sortstring;
00566       std::string m_uid;
00567 
00568       bool m_N;
00569       bool m_PHOTO;
00570       bool m_LOGO;
00571   };
00572 
00573 }
00574 
00575 #endif // VCARD_H__

Generated on Tue May 1 14:20:20 2007 for gloox by  doxygen 1.5.1