summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2012-04-09 11:59:17 (GMT)
committerChristian Mollekopf <chrigi_1@fastmail.fm>2012-04-09 11:59:17 (GMT)
commit748958554827c49d81470bd5e7acbf10579e5179 (patch)
tree3ff04d56f5ac8a828d19d3730e33072236e3c87f
parent57ae48b85f2ee73836b4c6566094590c953c5eaa (diff)
downloadlibkolabxml-748958554827c49d81470bd5e7acbf10579e5179.tar.gz
Use a container for urls too, as they can have types attached.
-rw-r--r--schemas/xCard.xsd2
-rw-r--r--src/kolabcontact.cpp6
-rw-r--r--src/kolabcontact.h21
-rw-r--r--src/xcardconversions.h24
-rw-r--r--tests/bindingstest.cpp2
5 files changed, 47 insertions, 8 deletions
diff --git a/schemas/xCard.xsd b/schemas/xCard.xsd
index 3efafe5..c02ab52 100644
--- a/schemas/xCard.xsd
+++ b/schemas/xCard.xsd
@@ -81,6 +81,8 @@
<xs:enumeration value="child"/>
<xs:enumeration value="x-assistant"/>
<xs:enumeration value="x-manager"/>
+ <!-- Url -->
+ <xs:enumeration value="x-blog"/>
</xs:restriction>
</xs:simpleType>
diff --git a/src/kolabcontact.cpp b/src/kolabcontact.cpp
index 4f68b72..528b13d 100644
--- a/src/kolabcontact.cpp
+++ b/src/kolabcontact.cpp
@@ -135,7 +135,7 @@ struct Contact::Private
std::string freeBusyUrl;
std::vector< std::string > titles;
std::vector<Affiliation> affiliations;
- std::vector<std::string> urls;
+ std::vector<Url> urls;
std::vector<Address> addresses;
int addressPreferredIndex;
std::vector<std::string> nickNames;
@@ -281,12 +281,12 @@ std::vector< Affiliation > Contact::affiliations() const
return d->affiliations;
}
-void Contact::setUrls(const std::vector< std::string > &urls)
+void Contact::setUrls(const std::vector<Url> &urls)
{
d->urls = urls;
}
-std::vector< std::string > Contact::urls() const
+std::vector< Url > Contact::urls() const
{
return d->urls;
}
diff --git a/src/kolabcontact.h b/src/kolabcontact.h
index 30d3814..6f8eba9 100644
--- a/src/kolabcontact.h
+++ b/src/kolabcontact.h
@@ -238,6 +238,23 @@ struct Geo {
double longitude;
};
+struct Url {
+ enum UrlTypes {
+ None = 0,
+ Blog
+ };
+ Url(): mType(None) {};
+ Url(const std::string &u, int t = None): mUrl(u), mType(t) {};
+
+ bool operator==(const Url &other) const{ return (mType == other.mType && mUrl == other.mUrl);};
+
+ int type() const { return mType; };
+ std::string url() const { return mUrl; };
+private:
+ std::string mUrl;
+ int mType;
+};
+
struct Key {
enum KeyType {
Invalid,
@@ -325,8 +342,8 @@ public:
void setAffiliations(const std::vector<Affiliation> &);
std::vector<Affiliation> affiliations() const;
- void setUrls(const std::vector<std::string> &);
- std::vector<std::string> urls() const;
+ void setUrls(const std::vector<Url> &);
+ std::vector<Url> urls() const;
void setAddresses(const std::vector<Address> &, int preferred = -1);
std::vector<Address> addresses() const;
diff --git a/src/xcardconversions.h b/src/xcardconversions.h
index 8125ff6..1960c71 100644
--- a/src/xcardconversions.h
+++ b/src/xcardconversions.h
@@ -507,7 +507,19 @@ void writeCard<Kolab::Contact>(vcard_4_0::vcard &vcard, const Kolab::Contact &co
}
if (!contact.urls().empty()) {
- vcard.url(fromList<vcard::url_type>(contact.urls()));
+ vcard_4_0::vcard::url_sequence urls;
+ BOOST_FOREACH(const Kolab::Url &url, contact.urls()) {
+ vcard::url_type u(url.url());
+ if (url.type() == Kolab::Url::Blog) {
+ vcard::adr_type::parameters_type b;
+ vcard_4_0::typeParamType p;
+ p.text().push_back(vcard_4_0::TypeValueType::x_blog);
+ b.baseParameter().push_back(p);
+ u.parameters(b);
+ }
+ urls.push_back(u);
+ }
+ vcard.url(urls);
}
if (!contact.addresses().empty()) {
@@ -832,7 +844,15 @@ boost::shared_ptr<Kolab::Contact> readCard <Kolab::Contact> (const vcard_4_0::Vc
contact->setAffiliations(list);
}
if (!vcard.url().empty()) {
- contact->setUrls(toUriList<vcard::url_type >(vcard.url()));
+ std::vector<Kolab::Url> urls;
+ BOOST_FOREACH(const vcard_4_0::vcard::url_type &url, vcard.url()) {
+ if (url.parameters()) { //We have only one fixed parameter (x-blog)
+ urls.push_back(Kolab::Url(url.uri(), Kolab::Url::Blog));
+ } else {
+ urls.push_back(Kolab::Url(url.uri()));
+ }
+ }
+ contact->setUrls(urls);
}
if (!vcard.adr().empty()) {
std::vector<Kolab::Address> list;
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index ea0d6e4..ba71757 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -348,7 +348,7 @@ void BindingsTest::contactCompletness()
c.setNameComponents(nc);
c.setNote("note");
c.setFreeBusyUrl("freebusy");
- c.setUrls(stringlist);
+ c.setUrls(std::vector<Kolab::Url>() << Kolab::Url("url1") << Kolab::Url("url1", Kolab::Url::Blog));
c.setNickNames(stringlist);
std::vector <Kolab::Related> relateds;