r_contact.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __BARRY_RECORD_CONTACT_H__
00023 #define __BARRY_RECORD_CONTACT_H__
00024
00025 #include "dll.h"
00026 #include "record.h"
00027 #include <iosfwd>
00028 #include <string>
00029 #include <vector>
00030 #include <map>
00031 #include <stdint.h>
00032
00033 namespace Barry {
00034
00035
00036 class IConverter;
00037
00038
00039
00040
00041
00042
00043 struct BXEXPORT ContactGroupLink
00044 {
00045 uint32_t Link;
00046 uint16_t Unknown;
00047
00048 ContactGroupLink() : Link(0), Unknown(0) {}
00049 ContactGroupLink(uint32_t link, uint16_t unknown)
00050 : Link(link), Unknown(unknown)
00051 {}
00052 };
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 class BXEXPORT Contact
00063 {
00064 public:
00065 typedef Barry::CategoryList CategoryList;
00066 typedef ContactGroupLink GroupLink;
00067 typedef std::vector<GroupLink> GroupLinksType;
00068 typedef Barry::UnknownsType UnknownsType;
00069 typedef std::string EmailType;
00070 typedef std::vector<EmailType> EmailList;
00071
00072
00073
00074
00075
00076
00077 uint8_t RecType;
00078 uint32_t RecordId;
00079 EmailList EmailAddresses;
00080
00081
00082
00083
00084
00085
00086
00087
00088 std::string Phone;
00089
00090 std::string
00091 Fax,
00092 HomeFax,
00093 WorkPhone,
00094 HomePhone,
00095 MobilePhone,
00096 MobilePhone2,
00097 Pager,
00098 PIN,
00099 Radio,
00100 WorkPhone2,
00101 HomePhone2,
00102 OtherPhone,
00103 FirstName,
00104 LastName,
00105 Company,
00106 DefaultCommunicationsMethod,
00107 JobTitle,
00108 PublicKey,
00109 URL,
00110 Prefix,
00111 Notes,
00112 UserDefined1,
00113 UserDefined2,
00114 UserDefined3,
00115 UserDefined4,
00116 Image,
00117 Nickname;
00118
00119 Date Birthday;
00120 Date Anniversary;
00121
00122 PostalAddress WorkAddress;
00123 PostalAddress HomeAddress;
00124
00125
00126
00127
00128
00129 CategoryList Categories;
00130
00131 GroupLinksType GroupLinks;
00132 UnknownsType Unknowns;
00133
00134 private:
00135 bool m_FirstNameSeen;
00136
00137 public:
00138 const unsigned char* ParseField(const unsigned char *begin,
00139 const unsigned char *end, const IConverter *ic = 0);
00140
00141 public:
00142 Contact();
00143 ~Contact();
00144
00145 uint32_t GetID() const { return RecordId; }
00146 std::string GetFullName() const;
00147 const std::string& GetEmail(unsigned int index = 0) const;
00148
00149
00150 uint8_t GetRecType() const { return RecType; }
00151 uint32_t GetUniqueId() const { return RecordId; }
00152 void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00153 void ParseHeader(const Data &data, size_t &offset);
00154 void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
00155 void BuildHeader(Data &data, size_t &offset) const;
00156 void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
00157
00158
00159 void Clear();
00160 void Dump(std::ostream &os) const;
00161 std::string GetDescription() const;
00162
00163
00164
00165 bool operator<(const Contact &other) const;
00166
00167
00168 static const char * GetDBName() { return "Address Book"; }
00169 static uint8_t GetDefaultRecType() { return 0; }
00170
00171
00172 static void SplitName(const std::string &full, std::string &first, std::string &last);
00173 };
00174
00175 BXEXPORT inline std::ostream& operator<< (std::ostream &os, const Contact &contact) {
00176 contact.Dump(os);
00177 return os;
00178 }
00179
00180
00181
00182 }
00183
00184 #endif
00185