1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <boost/shared_ptr.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <string>
#include <Swiften/JID/JID.h>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Elements/Payload.h>
namespace Swift {
class VCard : public Payload {
public:
typedef boost::shared_ptr<VCard> ref;
struct EMailAddress {
EMailAddress() : isHome(false), isWork(false), isInternet(false), isPreferred(false), isX400(false) {
}
bool isHome;
bool isWork;
bool isInternet;
bool isPreferred;
bool isX400;
std::string address;
};
struct Telephone {
Telephone() : isHome(false), isWork(false), isVoice(false), isFax(false), isPager(false), isMSG(false), isCell(false),
isVideo(false), isBBS(false), isModem(false), isISDN(false), isPCS(false), isPreferred(false) {
}
bool isHome;
bool isWork;
bool isVoice;
bool isFax;
bool isPager;
bool isMSG;
bool isCell;
bool isVideo;
bool isBBS;
bool isModem;
bool isISDN;
bool isPCS;
bool isPreferred;
std::string number;
};
enum DeliveryType {
DomesticDelivery,
InternationalDelivery,
None
};
struct Address {
Address() : isHome(false), isWork(false), isPostal(false), isParcel(false), deliveryType(None), isPreferred(false) {
}
bool isHome;
bool isWork;
bool isPostal;
bool isParcel;
DeliveryType deliveryType;
bool isPreferred;
std::string poBox;
std::string addressExtension;
std::string street;
std::string locality;
std::string region;
std::string postalCode;
std::string country;
};
struct AddressLabel {
AddressLabel() : isHome(false), isWork(false), isPostal(false), isParcel(false), deliveryType(None), isPreferred(false) {
}
bool isHome;
bool isWork;
bool isPostal;
bool isParcel;
DeliveryType deliveryType;
bool isPreferred;
std::vector<std::string> lines;
};
struct Organization {
std::string name;
std::vector<std::string> units;
};
VCard() {}
void setVersion(const std::string& version) { version_ = version; }
const std::string& getVersion() const { return version_; }
void setFullName(const std::string& fullName) { fullName_ = fullName; }
const std::string& getFullName() const { return fullName_; }
void setFamilyName(const std::string& familyName) { familyName_ = familyName; }
const std::string& getFamilyName() const { return familyName_; }
void setGivenName(const std::string& givenName) { givenName_ = givenName; }
const std::string& getGivenName() const { return givenName_; }
void setMiddleName(const std::string& middleName) { middleName_ = middleName; }
const std::string& getMiddleName() const { return middleName_; }
void setPrefix(const std::string& prefix) { prefix_ = prefix; }
const std::string& getPrefix() const { return prefix_; }
void setSuffix(const std::string& suffix) { suffix_ = suffix; }
const std::string& getSuffix() const { return suffix_; }
//void setEMailAddress(const std::string& email) { email_ = email; }
//const std::string& getEMailAddress() const { return email_; }
void setNickname(const std::string& nick) { nick_ = nick; }
const std::string& getNickname() const { return nick_; }
void setPhoto(const ByteArray& photo) { photo_ = photo; }
const ByteArray& getPhoto() const { return photo_; }
void setPhotoType(const std::string& photoType) { photoType_ = photoType; }
const std::string& getPhotoType() const { return photoType_; }
const std::string& getUnknownContent() const { return unknownContent_; }
void addUnknownContent(const std::string& c) {
unknownContent_ += c;
}
const std::vector<EMailAddress>& getEMailAddresses() const {
return emailAddresses_;
}
void addEMailAddress(const EMailAddress& email) {
emailAddresses_.push_back(email);
}
void clearEMailAddresses() {
emailAddresses_.clear();
}
EMailAddress getPreferredEMailAddress() const;
void setBirthday(const boost::posix_time::ptime& birthday) {
birthday_ = birthday;
}
const boost::posix_time::ptime& getBirthday() const {
return birthday_;
}
const std::vector<Telephone>& getTelephones() const {
return telephones_;
}
void addTelephone(const Telephone& phone) {
telephones_.push_back(phone);
}
void clearTelephones() {
telephones_.clear();
}
const std::vector<Address>& getAddresses() const {
return addresses_;
}
void addAddress(const Address& address) {
addresses_.push_back(address);
}
void clearAddresses() {
addresses_.clear();
}
const std::vector<AddressLabel>& getAddressLabels() const {
return addressLabels_;
}
void addAddressLabel(const AddressLabel& addressLabel) {
addressLabels_.push_back(addressLabel);
}
void clearAddressLabels() {
addressLabels_.clear();
}
const std::vector<JID>& getJIDs() const {
return jids_;
}
void addJID(const JID& jid) {
jids_.push_back(jid);
}
void clearJIDs() {
jids_.clear();
}
const std::string& getDescription() const {
return description_;
}
void setDescription(const std::string& description) {
this->description_ = description;
}
const std::vector<Organization>& getOrganizations() const {
return organizations_;
}
void addOrganization(const Organization& organization) {
organizations_.push_back(organization);
}
void clearOrganizations() {
organizations_.clear();
}
const std::vector<std::string>& getTitles() const {
return titles_;
}
void addTitle(const std::string& title) {
titles_.push_back(title);
}
void clearTitles() {
titles_.clear();
}
const std::vector<std::string>& getRoles() const {
return roles_;
}
void addRole(const std::string& role) {
roles_.push_back(role);
}
void clearRoles() {
roles_.clear();
}
const std::vector<std::string>& getURLs() const {
return urls_;
}
void addURL(const std::string& url) {
urls_.push_back(url);
}
void clearURLs() {
urls_.clear();
}
bool isEmpty() const {
bool empty = version_.empty() && fullName_.empty() && familyName_.empty() && givenName_.empty() && middleName_.empty() && prefix_.empty() && suffix_.empty();
empty &= photo_.empty() && photoType_.empty() && nick_.empty();
empty &= birthday_.is_not_a_date_time();
empty &= unknownContent_.empty();
empty &= emailAddresses_.empty() && telephones_.empty() && addresses_.empty() && addressLabels_.empty() && jids_.empty();
empty &= description_.empty() && organizations_.empty() && titles_.empty() && roles_.empty() && urls_.empty();
return empty;
}
private:
std::string version_;
std::string fullName_;
std::string familyName_;
std::string givenName_;
std::string middleName_;
std::string prefix_;
std::string suffix_;
//std::string email_;
ByteArray photo_;
std::string photoType_;
std::string nick_;
boost::posix_time::ptime birthday_;
std::string unknownContent_;
std::vector<EMailAddress> emailAddresses_;
std::vector<Telephone> telephones_;
std::vector<Address> addresses_;
std::vector<AddressLabel> addressLabels_;
std::vector<JID> jids_;
std::string description_;
std::vector<Organization> organizations_;
std::vector<std::string> titles_;
std::vector<std::string> roles_;
std::vector<std::string> urls_;
};
}
|