vcard.h

00001 /*
00002   Copyright (c) 2006-2008 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 Label
00159       {
00160         StringList lines;           
00161         bool home;                  
00162         bool work;                  
00163         bool postal;                
00164         bool parcel;                
00165         bool pref;                  
00166         bool dom;                   
00167         bool intl;                  
00168       };
00169 
00173       struct Geo
00174       {
00175         std::string latitude;       
00176         std::string longitude;      
00177       };
00178 
00182       struct Org
00183       {
00184         std::string name;           
00185         StringList units;           
00187       };
00188 
00192       struct Photo
00193       {
00194         std::string extval;         
00196         std::string binval;         
00197         std::string type;           
00198       };
00199 
00203       typedef std::list<Address> AddressList;
00204 
00208       typedef std::list<Label> LabelList;
00209 
00213       VCard();
00214 
00219       VCard( Tag* vcard );
00220 
00224       virtual ~VCard() {}
00225 
00230       Tag* tag() const;
00231 
00236       void setFormattedname( const std::string& name ) { m_formattedname = name; }
00237 
00242       const std::string& formattedname() const { return m_formattedname; }
00243 
00252       void setName( const std::string& family, const std::string& given, const std::string& middle = "",
00253                     const std::string& prefix = "", const std::string& suffix = "" );
00254 
00259       const Name& name() const { return m_name; }
00260 
00265       void setNickname( const std::string& nickname ) { m_nickname = nickname; }
00266 
00271       const std::string& nickname() const { return m_nickname; }
00272 
00277       void setUrl( const std::string& url ) { m_url = url; }
00278 
00283       const std::string& url() const { return m_url; }
00284 
00289       void setBday( const std::string& bday ) { m_bday = bday; }
00290 
00295       const std::string& bday() const { return m_bday; }
00296 
00301       void setJabberid( const std::string& jabberid ) { m_jabberid = jabberid; }
00302 
00307       const std::string& jabberid() const { return m_jabberid; }
00308 
00313       void setTitle( const std::string& title ) { m_title = title; }
00314 
00319       const std::string& title() const { return m_title; }
00320 
00325       void setRole( const std::string& role ) { m_role = role; }
00326 
00331       const std::string& role() const { return m_role; }
00332 
00337       void setNote( const std::string& note ) { m_note = note; }
00338 
00343       const std::string& note() const { return m_note; }
00344 
00349       void setDesc( const std::string& desc ) { m_desc = desc; }
00350 
00355       const std::string& desc() const { return m_desc; }
00356 
00361       void setMailer( const std::string& mailer ) { m_mailer = mailer; }
00362 
00367       const std::string& mailer() const { return m_mailer; }
00368 
00373       void setRev( const std::string& rev ) { m_rev = rev; }
00374 
00379       const std::string& rev() const { return m_rev; }
00380 
00385       void setUid( const std::string& uid ) { m_uid = uid; }
00386 
00391       const std::string& uid() const { return m_uid; }
00392 
00398       void setTz( const std::string& tz ) { m_tz = tz; }
00399 
00404       const std::string& tz() const { return m_tz; }
00405 
00410       void setProdid( const std::string& prodid ) { m_prodid = prodid; }
00411 
00416       const std::string& prodid() const { return m_prodid; }
00417 
00422       void setSortstring( const std::string& sortstring ) { m_sortstring = sortstring; }
00423 
00428       const std::string& sortstring() const { return m_sortstring; }
00429 
00434       void setPhoto( const std::string& extval );
00435 
00441       void setPhoto( const std::string& type, const std::string& binval );
00442 
00447       const Photo& photo() const { return m_photo; }
00448 
00453       void setLogo( const std::string& extval );
00454 
00460       void setLogo( const std::string& type, const std::string& binval );
00461 
00466       const Photo& logo() const { return m_logo; }
00467 
00473       void addEmail( const std::string& userid, int type );
00474 
00479       EmailList& emailAddresses() { return m_emailList; }
00480 
00492       void addAddress( const std::string& pobox, const std::string& extadd,
00493                        const std::string& street, const std::string& locality,
00494                        const std::string& region, const std::string& pcode,
00495                        const std::string& ctry, int type );
00496 
00502       void addLabel( const StringList& lines, int type );
00503 
00508       AddressList& addresses() { return m_addressList; }
00509 
00514       LabelList& labels() { return m_labelList; }
00515 
00521       void addTelephone( const std::string& number, int type );
00522 
00527       TelephoneList& telephone() { return m_telephoneList; }
00528 
00535       void setGeo( const std::string& lat, const std::string& lon );
00536 
00541       const Geo& geo() const { return m_geo; }
00542 
00548       void setOrganization( const std::string& orgname, const StringList& orgunits );
00549 
00554       const Org& org() const { return m_org; }
00555 
00560       void setClass( VCardClassification vclass ) { m_class = vclass; }
00561 
00566       VCardClassification classification() const { return m_class; }
00567 
00568 
00569     private:
00570       void checkField( Tag *vcard, const std::string& field, std::string& var );
00571       void insertField( Tag *vcard, const std::string& field, const std::string& var ) const;
00572       void insertField( Tag *vcard, const std::string& field, bool var ) const;
00573 
00574 
00575       EmailList m_emailList;
00576       TelephoneList m_telephoneList;
00577       AddressList m_addressList;
00578       LabelList m_labelList;
00579 
00580       Name m_name;
00581       Geo m_geo;
00582       Org m_org;
00583       Photo m_photo;
00584       Photo m_logo;
00585 
00586       VCardClassification m_class;
00587 
00588       std::string m_formattedname;
00589       std::string m_nickname;
00590       std::string m_url;
00591       std::string m_bday;
00592       std::string m_jabberid;
00593       std::string m_title;
00594       std::string m_role;
00595       std::string m_note;
00596       std::string m_desc;
00597       std::string m_mailer;
00598       std::string m_tz;
00599       std::string m_prodid;
00600       std::string m_rev;
00601       std::string m_sortstring;
00602       std::string m_uid;
00603 
00604       bool m_N;
00605       bool m_PHOTO;
00606       bool m_LOGO;
00607   };
00608 
00609 }
00610 
00611 #endif // VCARD_H__

Generated on Mon Dec 7 13:28:19 2009 for gloox by  doxygen 1.6.1