2 commits - c++/lib c++/tests schemas/kolabformat-xcard.xsd schemas/xCard.xsd
Christian Mollekopf
mollekopf at kolabsys.com
Mon Mar 19 21:35:25 CET 2012
c++/lib/kolabcontainers.h | 2 -
c++/lib/shared_conversions.h | 5 +++
c++/lib/xcalconversions.h | 63 ++++++++++++++++++++++--------------------
c++/lib/xcardconversions.h | 34 +++++++++++-----------
c++/tests/bindingstest.cpp | 10 +++---
schemas/kolabformat-xcard.xsd | 3 --
schemas/xCard.xsd | 6 ++++
7 files changed, 69 insertions(+), 54 deletions(-)
New commits:
commit ce31a625d5c013361c5fd48004acd5aee4b9be1e
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Mon Mar 19 21:35:04 2012 +0100
Use the key property instead of having the keys inside x-crypto.
diff --git a/c++/lib/xcardconversions.h b/c++/lib/xcardconversions.h
index 52b1b5e..00291e7 100644
--- a/c++/lib/xcardconversions.h
+++ b/c++/lib/xcardconversions.h
@@ -636,13 +636,16 @@ void writeCard<Kolab::Contact>(vcard_4_0::vcard &vcard, const Kolab::Contact &co
allowed.text(seq);
crypto.allowed(allowed);
}
+ vcard_4_0::vcard::key_sequence keys;
if (!c.pgpKey().empty()) {
- crypto.pgpkey(vcard_4_0::CryptoType::pgpkey_type(uriInlineEncoding(c.pgpKey(), MIME_PGP_KEYS)));
+ keys.push_back(vcard_4_0::keyPropType(uriInlineEncoding(c.pgpKey(), MIME_PGP_KEYS)));
}
if (!c.smimeKey().empty()) {
- crypto.smimekey(vcard_4_0::CryptoType::smimekey_type(uriInlineEncoding(c.smimeKey(), MIME_PKCS7_MIME)));
+ keys.push_back(vcard_4_0::keyPropType(uriInlineEncoding(c.smimeKey(), MIME_PKCS7_MIME)));
+ }
+ if (!keys.empty()) {
+ vcard.key(keys);
}
-
crypto.encryptpref(fromCryptoPref(c.encryptPref()));
crypto.signpref(fromCryptoPref(c.signPref()));
@@ -947,21 +950,18 @@ boost::shared_ptr<Kolab::Contact> readCard <Kolab::Contact> (const vcard_4_0::Vc
}
c.setAllowed(allowed);
}
- if (crypto.pgpkey()) {
- std::string mimetype;
- const std::string &key = uriInlineDecoding(crypto.pgpkey()->uri(), mimetype);
- if (mimetype != MIME_PGP_KEYS) {
- WARNING("wrong mimetype on key");
- }
- c.setPGPKey(key);
- }
- if (crypto.smimekey()) {
- std::string mimetype;
- const std::string &key = uriInlineDecoding(crypto.smimekey()->uri(), mimetype);
- if (mimetype != MIME_PKCS7_MIME) {
- WARNING("wrong mimetype on key");
+ if (!vcard.key().empty()) {
+ BOOST_FOREACH(const vcard_4_0::keyPropType &k, vcard.key()) {
+ std::string mimetype;
+ const std::string &key = uriInlineDecoding(k.uri(), mimetype);
+ if (mimetype == MIME_PGP_KEYS) {
+ c.setPGPKey(key);
+ } else if (mimetype == MIME_PKCS7_MIME) {
+ c.setSMIMEKey(key);
+ } else {
+ WARNING("wrong mimetype on key");
+ }
}
- c.setSMIMEKey(key);
}
if (crypto.encryptpref()) {
c.setEncryptPref(toCryptoPref(crypto.encryptpref()->text()));
diff --git a/schemas/kolabformat-xcard.xsd b/schemas/kolabformat-xcard.xsd
index 0983401..6a422b8 100644
--- a/schemas/kolabformat-xcard.xsd
+++ b/schemas/kolabformat-xcard.xsd
@@ -60,8 +60,6 @@
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="pgpkey" type="UriPropertyType" minOccurs="0"/>
- <xs:element name="smimekey" type="UriPropertyType" minOccurs="0"/>
<xs:element name="signpref" minOccurs="0">
<xs:complexType>
<xs:sequence>
@@ -113,6 +111,7 @@
<xs:element name="impp" type="imppPropType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="email" type="emailPropType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="geo" type="geoPropType" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="key" type="keyPropType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="x-crypto" type="CryptoType" minOccurs="0"/>
<xs:element name="member" type="memberPropType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="x-custom" type="CustomType" minOccurs="0" maxOccurs="unbounded"/>
diff --git a/schemas/xCard.xsd b/schemas/xCard.xsd
index 560cc7c..3efafe5 100644
--- a/schemas/xCard.xsd
+++ b/schemas/xCard.xsd
@@ -395,6 +395,12 @@
</xs:complexContent>
</xs:complexType>
+ <xs:complexType name="keyPropType">
+ <xs:complexContent mixed="false">
+ <xs:extension base="xcard:UriPropertyType"/>
+ </xs:complexContent>
+ </xs:complexType>
+
<xs:complexType name="geoPropType">
<xs:complexContent mixed="false">
<xs:extension base="xcard:UriPropertyType"/>
commit 4eef326e9d130350b94f348c27d69efab52e6f4b
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Mon Mar 19 21:15:14 2012 +0100
Make use of the dir attribute.
diff --git a/c++/lib/kolabcontainers.h b/c++/lib/kolabcontainers.h
index cd577b7..47dc5fc 100644
--- a/c++/lib/kolabcontainers.h
+++ b/c++/lib/kolabcontainers.h
@@ -224,7 +224,7 @@ public:
void operator=(const Alarm &);
bool operator==(const Alarm &other) const;
- ///EMail Alarm
+ ///EMail Alarm, @param attendees accepts only email + name and no uid
Alarm(const std::string &summary, const std::string &description, const std::vector<ContactReference> attendees);
std::string summary() const;
std::string description() const;
diff --git a/c++/lib/shared_conversions.h b/c++/lib/shared_conversions.h
index 948e836..fd64ae5 100644
--- a/c++/lib/shared_conversions.h
+++ b/c++/lib/shared_conversions.h
@@ -22,6 +22,7 @@
#include "kolabcontainers.h"
#include <boost/shared_ptr.hpp>
#include "utils.h"
+#include <bindings/iCalendar-params.hxx>
namespace Kolab {
namespace Shared {
@@ -100,6 +101,7 @@ std::string fromContactReference(const Kolab::ContactReference &c, bool embeddNa
case ContactReference::UidReference:
return toURN(c.uid());
case ContactReference::EmailReference:
+ case ContactReference::EmailAndUidReference:
if (embeddName) {
return toMailto(c.email(), c.name());
}
@@ -111,6 +113,9 @@ std::string fromContactReference(const Kolab::ContactReference &c, bool embeddNa
return std::string();
}
+
+
+
} //Namespace
} //Namespace
diff --git a/c++/lib/xcalconversions.h b/c++/lib/xcalconversions.h
index 1e19491..526af01 100644
--- a/c++/lib/xcalconversions.h
+++ b/c++/lib/xcalconversions.h
@@ -349,25 +349,41 @@ Kolab::Duration toDuration(const icalendar_2_0::DurationValueType &d)
return Duration(days, hours, minutes, seconds, negative);
}
-
+template <typename T>
+T fromContactReference(const Kolab::ContactReference &c) {
+ T organizer(toMailto(c.email()));
+
+ typename T::parameters_type p;
+ if (!c.name().empty()) {
+ icalendar_2_0::CnParamType name(c.name());
+ p.baseParameter().push_back(name);
+ }
+ if (!c.uid().empty()) {
+ icalendar_2_0::DirParamType dir(toURN(c.uid()));
+ p.baseParameter().push_back(dir);
+ }
+ organizer.parameters(p);
+ return organizer;
+}
Kolab::ContactReference toContactReference(const icalendar_2_0::CalAddressPropertyType &cal)
{
- Kolab::ContactReference ref = Shared::toContactReference(cal.cal_address());
-
+ const std::string &email = fromMailto(cal.cal_address());;
+ std::string name;
+ std::string uid;
if (cal.parameters()) {
for (icalendar_2_0::ArrayOfParameters::baseParameter_const_iterator it((*cal.parameters()).baseParameter().begin()); it != (*cal.parameters()).baseParameter().end(); it++) {
if (const icalendar_2_0::CnParamType * tz = dynamic_cast<const icalendar_2_0::CnParamType*> (&*it)) {
- if (!ref.name().empty()) {
- WARNING("name from mailto uri not empty, overwriting with cn attirbute");
- assert(0);
- }
- ref.setName(tz->text());
- break;
+ name = tz->text();
+ continue;
+ }
+ if (const icalendar_2_0::DirParamType * tz = dynamic_cast<const icalendar_2_0::DirParamType*> (&*it)) {
+ uid = tz->uri();
+ continue;
}
}
}
- return ref;
+ return Kolab::ContactReference(email, name, uid);
}
@@ -872,8 +888,7 @@ void setIncidenceProperties(I &inc, const T &prop)
}
}
}
- Kolab::ContactReference ref = toContactReference(aProp.cal_address());
- ref.setName(name);
+ Kolab::ContactReference ref = toContactReference(aProp);
a.setContact(ref);
attendees.push_back(a);
}
@@ -1100,13 +1115,9 @@ void getIncidenceProperties(T &prop, const I &inc)
BOOST_FOREACH(const Kolab::Attendee &a, inc.attendees()) {
const Kolab::ContactReference &c = a.contact();
- typename properties::attendee_type attendee(fromContactReference(c));
+ typename properties::attendee_type attendee = fromContactReference<typename properties::attendee_type>(c);
- typename properties::attendee_type::parameters_type p;
- if (!c.name().empty()) {
- icalendar_2_0::CnParamType name(c.name());
- p.baseParameter().push_back(name);
- }
+ typename properties::attendee_type::parameters_type &p = *attendee.parameters();
std::string stat = mapPartStat(a.partStat());
if (!stat.empty()) {
@@ -1122,7 +1133,6 @@ void getIncidenceProperties(T &prop, const I &inc)
p.baseParameter().push_back(icalendar_2_0::RsvpParamType(true));
}
- attendee.parameters(p);
prop.attendee().push_back(attendee);
}
@@ -1186,14 +1196,7 @@ void getTodoEventProperties(T &prop, const I &inc)
}
if (inc.organizer().isValid()) {
- typename properties::organizer_type organizer(fromContactReference(inc.organizer(), false));
-
- typename properties::organizer_type::parameters_type p;
- icalendar_2_0::CnParamType name(inc.organizer().name());
- p.baseParameter().push_back(name);
-
- organizer.parameters(p);
- prop.organizer(organizer);
+ prop.organizer(fromContactReference<typename properties::organizer_type>(inc.organizer()));
}
}
@@ -1235,7 +1238,7 @@ void setAlarms(typename KolabType::components_type& components, const IncidenceT
p->summary(PropType::summary_type(alarm.summary()));
p->description(PropType::description_type(alarm.description()));
BOOST_FOREACH(const Kolab::ContactReference &attendee, alarm.attendees()) {
- p->attendee().push_back(icalendar_2_0::ContactType(fromContactReference(attendee)));
+ p->attendee().push_back(icalendar_2_0::ContactType(toMailto(attendee.email(), attendee.name())));
}
break;
case Kolab::Alarm::AudioAlarm:
@@ -1279,7 +1282,9 @@ void getAlarms(IncidenceType &incidence, const typename KolabType::components_ty
WARNING("No receipents for email alarm");
}
for (typename PropType::attendee_const_iterator at(prop.attendee().begin()); at != prop.attendee().end(); at++) {
- attendees.push_back(toContactReference((*at).cal_address()));
+ std::string name;
+ const std::string &email = fromMailto((*at).cal_address(), name);
+ attendees.push_back(Kolab::ContactReference(Kolab::ContactReference::EmailReference, email, name));
}
if (!prop.description() || !prop.summary()) {
ERROR("description or summary is missing");
diff --git a/c++/tests/bindingstest.cpp b/c++/tests/bindingstest.cpp
index a33f359..1c26297 100644
--- a/c++/tests/bindingstest.cpp
+++ b/c++/tests/bindingstest.cpp
@@ -86,9 +86,9 @@ void setIncidence(T &ev)
ev.setPriority(3);
ev.setStatus(Kolab::StatusConfirmed);
ev.setLocation("location");
- ev.setOrganizer(Kolab::ContactReference(Kolab::ContactReference::EmailReference, "mail", "name")); //TODO UID
+ ev.setOrganizer(Kolab::ContactReference("mail", "name", "uid"));
- Kolab::Attendee attendee(Kolab::ContactReference(Kolab::ContactReference::EmailReference, "mail", "name")); //TODO UID
+ Kolab::Attendee attendee(Kolab::ContactReference("mail", "name", "uid"));
attendee.setPartStat(Kolab::PartDelegated);
attendee.setRole(Kolab::Chair);
attendee.setRSVP(true);
@@ -136,7 +136,7 @@ void setIncidence(T &ev)
// alarms.push_back(dispAlarm);
std::vector<Kolab::ContactReference> att;
att.push_back(Kolab::ContactReference(Kolab::ContactReference::EmailReference, "mail", "name"));
- att.push_back(Kolab::ContactReference(Kolab::ContactReference::EmailReference, "mail", "name")); //TODO UID
+ att.push_back(Kolab::ContactReference(Kolab::ContactReference::EmailReference, "mail", "name"));
Kolab::Alarm emailAlarm("ident", "value", att);
emailAlarm.setStart(Kolab::cDateTime(2003,2,3,2,3,4, true));
alarms.push_back(emailAlarm);
@@ -262,7 +262,7 @@ void BindingsTest::journalCompletness()
ev.setClassification(Kolab::ClassConfidential);
ev.addCategory("Category");
ev.setStart(Kolab::cDateTime("Europe/Zurich", 2006,1,6,12,0,0));
- Kolab::Attendee attendee(Kolab::ContactReference(Kolab::ContactReference::EmailReference, "mail", "name")); //TODO uid
+ Kolab::Attendee attendee(Kolab::ContactReference("mail", "name", "uid"));
attendee.setPartStat(Kolab::PartDelegated);
attendee.setRole(Kolab::Chair);
attendee.setRSVP(true);
@@ -438,7 +438,7 @@ void BindingsTest::contactCompletness()
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());
More information about the commits
mailing list