summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Elements')
-rw-r--r--Swiften/Elements/VCard.cpp26
-rw-r--r--Swiften/Elements/VCard.h52
2 files changed, 75 insertions, 3 deletions
diff --git a/Swiften/Elements/VCard.cpp b/Swiften/Elements/VCard.cpp
new file mode 100644
index 0000000..8262e07
--- /dev/null
+++ b/Swiften/Elements/VCard.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Elements/VCard.h"
+
+#include "Swiften/Base/foreach.h"
+
+namespace Swift {
+
+VCard::EMailAddress VCard::getPreferredEMailAddress() const {
+ foreach(const EMailAddress& address, emailAddresses_) {
+ if (address.isPreferred) {
+ return address;
+ }
+ }
+ if (emailAddresses_.size() > 0) {
+ return emailAddresses_[0];
+ }
+ return EMailAddress();
+}
+
+
+}
diff --git a/Swiften/Elements/VCard.h b/Swiften/Elements/VCard.h
index 60f94b1..15173f1 100644
--- a/Swiften/Elements/VCard.h
+++ b/Swiften/Elements/VCard.h
@@ -14,8 +14,23 @@
namespace Swift {
class VCard : public Payload, public Shared<VCard> {
public:
+ struct EMailAddress {
+ EMailAddress() : isHome(false), isWork(false), isInternet(false), isPreferred(false), isX400(false) {
+ }
+
+ bool isHome;
+ bool isWork;
+ bool isInternet;
+ bool isPreferred;
+ bool isX400;
+ String address;
+ };
+
VCard() {}
+ void setVersion(const String& version) { version_ = version; }
+ const String& getVersion() const { return version_; }
+
void setFullName(const String& fullName) { fullName_ = fullName; }
const String& getFullName() const { return fullName_; }
@@ -25,8 +40,18 @@ namespace Swift {
void setGivenName(const String& givenName) { givenName_ = givenName; }
const String& getGivenName() const { return givenName_; }
- void setEMail(const String& email) { email_ = email; }
- const String& getEMail() const { return email_; }
+ void setMiddleName(const String& middleName) { middleName_ = middleName; }
+ const String& getMiddleName() const { return middleName_; }
+
+ void setPrefix(const String& prefix) { prefix_ = prefix; }
+ const String& getPrefix() const { return prefix_; }
+
+ void setSuffix(const String& suffix) { suffix_ = suffix; }
+ const String& getSuffix() const { return suffix_; }
+
+
+ //void setEMailAddress(const String& email) { email_ = email; }
+ //const String& getEMailAddress() const { return email_; }
void setNickname(const String& nick) { nick_ = nick; }
const String& getNickname() const { return nick_; }
@@ -37,13 +62,34 @@ namespace Swift {
void setPhotoType(const String& photoType) { photoType_ = photoType; }
const String& getPhotoType() { return photoType_; }
+ const String& getUnknownContent() const { return unknownContent_; }
+ void addUnknownContent(const String& c) {
+ unknownContent_ += c;
+ }
+
+ const std::vector<EMailAddress> getEMailAddresses() const {
+ return emailAddresses_;
+ }
+
+ void addEMailAddress(const EMailAddress& email) {
+ emailAddresses_.push_back(email);
+ }
+
+ EMailAddress getPreferredEMailAddress() const;
+
private:
+ String version_;
String fullName_;
String familyName_;
String givenName_;
- String email_;
+ String middleName_;
+ String prefix_;
+ String suffix_;
+ //String email_;
ByteArray photo_;
String photoType_;
String nick_;
+ String unknownContent_;
+ std::vector<EMailAddress> emailAddresses_;
};
}