c++/lib c++/tests
Christian Mollekopf
mollekopf at kolabsys.com
Thu Feb 23 12:03:49 CET 2012
c++/lib/xcardconversions.h | 15 ++++++++++++++-
c++/tests/bindingstest.cpp | 17 +++++++++++++----
2 files changed, 27 insertions(+), 5 deletions(-)
New commits:
commit 55179fa8290b0c8e55635476ad0b06693a8b32af
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Thu Feb 23 12:02:54 2012 +0100
Custom Properties in vcards
diff --git a/c++/lib/xcardconversions.h b/c++/lib/xcardconversions.h
index 3d11bc3..5ef70bb 100644
--- a/c++/lib/xcardconversions.h
+++ b/c++/lib/xcardconversions.h
@@ -482,9 +482,14 @@ std::string serializeCard(const T &card, const std::string prod = std::string())
vcard_4_0::vcard vcard(uid, kolab_version, prodid, rev, kind, fn);
- //TODO custom properties
writeCard<T>(vcard, card);
+ if (!card.customProperties().empty()) {
+ BOOST_FOREACH(const Kolab::CustomProperty &a, card.customProperties()) {
+ vcard.x_custom().push_back(vcard_4_0::CustomType(a.identifier, a.value));
+ }
+ }
+
VcardsType vcards(vcard);
xml_schema::namespace_infomap map;
@@ -777,6 +782,14 @@ boost::shared_ptr<T> deserializeCard(const std::string& s, bool isUrl)
// global_xCardVersion = vcalendar.properties().version().text();
setKolabVersion( vcards->vcard().x_kolab_version().text() );
+ if (!vcards->vcard().x_custom().empty()) {
+ std::vector<Kolab::CustomProperty> customProperties;
+ BOOST_FOREACH(const vcard_4_0::CustomType &p, vcards->vcard().x_custom()) {
+ customProperties.push_back(CustomProperty(p.identifier(), p.value()));
+ }
+ card->setCustomProperties(customProperties);
+ }
+
return card;
} catch (const xml_schema::exception& e) {
std::cerr << e << std::endl;
diff --git a/c++/tests/bindingstest.cpp b/c++/tests/bindingstest.cpp
index f7a55e4..69422f3 100644
--- a/c++/tests/bindingstest.cpp
+++ b/c++/tests/bindingstest.cpp
@@ -382,9 +382,14 @@ void BindingsTest::contactCompletness()
// c.setGPSpos(stringlist,1);
+ std::vector<Kolab::CustomProperty> properties;
+ properties.push_back(Kolab::CustomProperty("ident", "value"));
+ properties.push_back(Kolab::CustomProperty("ident", "value"));
+ c.setCustomProperties(properties);
+
const std::string result = Kolab::writeContact(c);
QVERIFY(Kolab::error() == Kolab::NoError);
- //std::cout << result << endl;
+// std::cout << result << endl;
Kolab::Contact e = Kolab::readContact(result, false);
QVERIFY(Kolab::error() == Kolab::NoError);
QCOMPARE(e.uid(), c.uid());
@@ -413,7 +418,7 @@ void BindingsTest::contactCompletness()
QCOMPARE(e.emailAddressPreferredIndex(), c.emailAddressPreferredIndex());
// QCOMPARE(e.gpsPos(), c.gpsPos());
// QCOMPARE(e.crypto(), c.crypto());
-// QCOMPARE(e.customProperties(), c.customProperties());
+ QCOMPARE(e.customProperties(), c.customProperties());
}
void BindingsTest::distlistCompletness()
@@ -426,16 +431,20 @@ void BindingsTest::distlistCompletness()
c.setName("name");
c.setUid("uid");
c.setMembers(stringlist);
+ std::vector<Kolab::CustomProperty> properties;
+ properties.push_back(Kolab::CustomProperty("ident", "value"));
+ properties.push_back(Kolab::CustomProperty("ident", "value"));
+ c.setCustomProperties(properties);
const std::string result = Kolab::writeDistlist(c);
QVERIFY(Kolab::error() == Kolab::NoError);
- std::cout << result << endl;
+// std::cout << result << endl;
Kolab::DistList e = Kolab::readDistlist(result, false);
QVERIFY(Kolab::error() == Kolab::NoError);
QCOMPARE(e.uid(), c.uid());
QCOMPARE(e.name(), c.name());
QCOMPARE(e.members(), c.members());
-// QCOMPARE(e.customProperties(), c.customProperties());
+ QCOMPARE(e.customProperties(), c.customProperties());
}
More information about the commits
mailing list