Branch 'libkolabxml-0.8' - 3 commits - schemas/ical schemas/xCard.xsd src/containers src/kolabformat.i src/xcalconversions.h src/xcardconversions.h tests/bindingstest.cpp
Christian Mollekopf
mollekopf at kolabsys.com
Mon Apr 15 16:22:31 CEST 2013
schemas/ical/kolabformat-xcal.xsd | 2 +
schemas/xCard.xsd | 2 -
src/containers/incidence_p.h | 1
src/containers/kolabcontact.cpp | 24 +++++++++++++++++--
src/containers/kolabcontact.h | 32 +++++++++++++++++++++++++
src/containers/kolabevent.cpp | 10 ++++++++
src/containers/kolabevent.h | 3 ++
src/containers/kolabtodo.cpp | 10 ++++++++
src/containers/kolabtodo.h | 3 ++
src/kolabformat.i | 1
src/xcalconversions.h | 8 ++++++
src/xcardconversions.h | 47 +++++++++++++++++++++++++++++++++-----
tests/bindingstest.cpp | 8 ++++++
13 files changed, 142 insertions(+), 9 deletions(-)
New commits:
commit 663a4d7f5913722816f72d12f01f6a4b3c543bb8
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Wed Apr 10 11:50:21 2013 +0200
url property for todos and events.
(cherry picked from commit 41189cfb47c7e8866b4cb1c83c79f298c47c2b85)
diff --git a/schemas/ical/kolabformat-xcal.xsd b/schemas/ical/kolabformat-xcal.xsd
index 6960df9..e3de445 100644
--- a/schemas/ical/kolabformat-xcal.xsd
+++ b/schemas/ical/kolabformat-xcal.xsd
@@ -111,6 +111,7 @@
<xs:element name="status" type="StatusPropType" minOccurs="0"/>
<xs:element name="location" type="LocationPropType" minOccurs="0"/>
<xs:element name="organizer" type="OrganizerPropType" minOccurs="0"/>
+ <xs:element name="url" type="UrlPropType" minOccurs="0"/>
<xs:element name="attendee" type="AttendeePropType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="attach" type="AttachPropType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="x-custom" type="CustomType" minOccurs="0" maxOccurs="unbounded"/>
@@ -152,6 +153,7 @@
<xs:element name="percent-complete" type="PercentCompletePropType" minOccurs="0"/>
<xs:element name="location" type="LocationPropType" minOccurs="0"/>
<xs:element name="organizer" type="OrganizerPropType" minOccurs="0"/>
+ <xs:element name="url" type="UrlPropType" minOccurs="0"/>
<xs:element name="attendee" type="AttendeePropType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="attach" type="AttachPropType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="x-custom" type="CustomType" minOccurs="0" maxOccurs="unbounded"/>
diff --git a/src/containers/incidence_p.h b/src/containers/incidence_p.h
index 8602feb..854f849 100644
--- a/src/containers/incidence_p.h
+++ b/src/containers/incidence_p.h
@@ -58,6 +58,7 @@ namespace Kolab {
std::vector<CustomProperty> customProperties;
std::vector<Alarm> alarms;
+ std::string url;
};
}
diff --git a/src/containers/kolabevent.cpp b/src/containers/kolabevent.cpp
index 0fd4d2b..a1a97c5 100644
--- a/src/containers/kolabevent.cpp
+++ b/src/containers/kolabevent.cpp
@@ -290,6 +290,16 @@ std::vector< Attachment > Event::attachments() const
return d->attachments;
}
+void Event::setUrl(const std::string &url)
+{
+ d->url = url;
+}
+
+std::string Event::url() const
+{
+ return d->url;
+}
+
void Event::setCustomProperties(const std::vector< CustomProperty > &prop)
{
d->customProperties = prop;
diff --git a/src/containers/kolabevent.h b/src/containers/kolabevent.h
index 8973d1a..a1df32e 100644
--- a/src/containers/kolabevent.h
+++ b/src/containers/kolabevent.h
@@ -103,6 +103,9 @@ public:
void setAttachments(const std::vector<Attachment> &);
std::vector<Attachment> attachments() const;
+ void setUrl(const std::string &);
+ std::string url() const;
+
void setCustomProperties(const std::vector<CustomProperty> &);
std::vector<CustomProperty> customProperties() const;
diff --git a/src/containers/kolabtodo.cpp b/src/containers/kolabtodo.cpp
index 2286d25..c80f2fe 100644
--- a/src/containers/kolabtodo.cpp
+++ b/src/containers/kolabtodo.cpp
@@ -305,6 +305,16 @@ std::vector< Attachment > Todo::attachments() const
return d->attachments;
}
+void Todo::setUrl(const std::string &url)
+{
+ d->url = url;
+}
+
+std::string Todo::url() const
+{
+ return d->url;
+}
+
void Todo::setCustomProperties(const std::vector< CustomProperty > &prop)
{
d->customProperties = prop;
diff --git a/src/containers/kolabtodo.h b/src/containers/kolabtodo.h
index 1ab8024..bad8cbf 100644
--- a/src/containers/kolabtodo.h
+++ b/src/containers/kolabtodo.h
@@ -105,6 +105,9 @@ public:
void setAttachments(const std::vector<Attachment> &);
std::vector<Attachment> attachments() const;
+ void setUrl(const std::string &);
+ std::string url() const;
+
void setCustomProperties(const std::vector<CustomProperty> &);
std::vector<CustomProperty> customProperties() const;
diff --git a/src/xcalconversions.h b/src/xcalconversions.h
index d11536c..82c7699 100644
--- a/src/xcalconversions.h
+++ b/src/xcalconversions.h
@@ -1006,6 +1006,10 @@ void setTodoEventProperties(I &inc, const T &prop)
inc.setOrganizer(toContactReference(*prop.organizer()));
}
+ if (prop.url()) {
+ inc.setUrl((*prop.url()).uri());
+ }
+
}
@@ -1283,6 +1287,10 @@ void getTodoEventProperties(T &prop, const I &inc)
if (inc.organizer().isValid()) {
prop.organizer(fromContactReference<typename properties::organizer_type>(inc.organizer()));
}
+
+ if (!inc.url().empty()) {
+ prop.url(typename properties::url_type(inc.url()));
+ }
}
//=== Alarms ===
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index f493886..c639ab0 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -187,6 +187,7 @@ void setIncidence(T &ev)
ev.setStatus(Kolab::StatusConfirmed);
ev.setLocation("location");
ev.setOrganizer(Kolab::ContactReference("mail", "name", "uid"));
+ ev.setUrl("http://example.com");
Kolab::Attendee attendee(Kolab::ContactReference("mail", "name", "uid"));
attendee.setPartStat(Kolab::PartDelegated);
@@ -298,6 +299,7 @@ void checkIncidence(const T &ev, const T &re)
QCOMPARE(ev.status(), re.status());
QCOMPARE(ev.location(), re.location());
QCOMPARE(ev.organizer(), re.organizer());
+ QCOMPARE(ev.url(), re.url());
QCOMPARE(ev.attendees(), re.attendees());
QCOMPARE(ev.attachments(), re.attachments());
QCOMPARE(ev.customProperties(), re.customProperties());
commit 691835bb25f7ef33d75ba654c394a3498a4b0dc9
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Mon Apr 15 12:47:23 2013 +0200
Restore binary compatiblity for 2c8ebffc69bad7d4e566c562120b1c0ecb375105.
diff --git a/src/containers/kolabcontact.cpp b/src/containers/kolabcontact.cpp
index 1c5bb0d..01acace 100644
--- a/src/containers/kolabcontact.cpp
+++ b/src/containers/kolabcontact.cpp
@@ -17,6 +17,8 @@
#include "kolabcontact.h"
+#include <boost/foreach.hpp>
+
namespace Kolab {
struct DistList::Private
@@ -416,13 +418,31 @@ int Contact::imAddressPreferredIndex() const
return d->imAddressPreferredIndex;
}
-void Contact::setEmailAddresses(const std::vector< Email >& email, int preferredIndex)
+void Contact::setEmailAddresses(const std::vector< std::string >& email, int preferredIndex)
+{
+ d->emailAddresses.clear();
+ BOOST_FOREACH(const std::string adr, email) {
+ d->emailAddresses.push_back(Email(adr, Email::None));
+ }
+ d->emailAddressPreferredIndex = preferredIndex;
+}
+
+std::vector< std::string > Contact::emailAddresses() const
+{
+ std::vector<std::string> emails;
+ BOOST_FOREACH(const Email email, d->emailAddresses) {
+ emails.push_back(email.address());
+ }
+ return emails;
+}
+
+void Contact::setEmailAddressesWithType(const std::vector< Email >& email, int preferredIndex)
{
d->emailAddresses = email;
d->emailAddressPreferredIndex = preferredIndex;
}
-std::vector< Email > Contact::emailAddresses() const
+std::vector< Email > Contact::emailAddressesWithType() const
{
return d->emailAddresses;
}
diff --git a/src/containers/kolabcontact.h b/src/containers/kolabcontact.h
index c790b1e..7430919 100644
--- a/src/containers/kolabcontact.h
+++ b/src/containers/kolabcontact.h
@@ -404,9 +404,20 @@ public:
void setIMaddresses(const std::vector<std::string> &, int preferredIndex = -1);
std::vector<std::string> imAddresses() const;
int imAddressPreferredIndex() const;
-
- void setEmailAddresses(const std::vector<Email> &, int preferredIndex = -1);
- std::vector<Email> emailAddresses() const;
+
+ /**
+ * Defaults to emailType other
+ * @deprecated use setEmailAddressesWithType(std::vector<Email>, int) instead
+ */
+ void setEmailAddresses(const std::vector<std::string> &, int preferredIndex = -1);
+
+ /**
+ * @deprecated use std::vector<Email>emailAddressesWithType() instead
+ */
+ std::vector<std::string> emailAddresses() const;
+
+ void setEmailAddressesWithType(const std::vector<Email> &, int preferredIndex = -1);
+ std::vector<Email> emailAddressesWithType() const;
int emailAddressPreferredIndex() const;
void setGPSpos(const std::vector<Geo> &);
diff --git a/src/xcardconversions.h b/src/xcardconversions.h
index 6461556..f52e304 100644
--- a/src/xcardconversions.h
+++ b/src/xcardconversions.h
@@ -671,7 +671,7 @@ void writeCard<Kolab::Contact>(vcard_4_0::vcard &vcard, const Kolab::Contact &co
if (!contact.emailAddresses().empty()) {
vcard::email_sequence seq;
int index = 0;
- const std::vector<Email> &l = contact.emailAddresses();
+ const std::vector<Email> &l = contact.emailAddressesWithType();
BOOST_FOREACH(const Kolab::Email &e, l) {
vcard::email_type email(e.address());
vcard_4_0::typeParamType emailTypeParam;
@@ -1056,7 +1056,7 @@ boost::shared_ptr<Kolab::Contact> readCard <Kolab::Contact> (const vcard_4_0::Vc
list.push_back(email);
}
- contact->setEmailAddresses(list, preferredIndex);
+ contact->setEmailAddressesWithType(list, preferredIndex);
}
if (!vcard.geo().empty()) {
std::vector<Geo> list;
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index d6f2f84..f493886 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -568,7 +568,8 @@ void BindingsTest::contactCompletness()
emails.push_back(Kolab::Email("email1 at example.org", Kolab::Email::None));
emails.push_back(Kolab::Email("email2 at example.org", Kolab::Email::Work));
emails.push_back(Kolab::Email("email3 at example.org", Kolab::Email::Work|Kolab::Email::Home));
- c.setEmailAddresses(emails,1);
+ c.setEmailAddressesWithType(emails,1);
+ c.setEmailAddresses(stringlist,1);
c.setTitles(stringlist);
std::vector<Kolab::Affiliation> list;
@@ -672,6 +673,7 @@ void BindingsTest::contactCompletness()
QCOMPARE(e.telephonesPreferredIndex(), c.telephonesPreferredIndex());
QCOMPARE(e.imAddresses(), c.imAddresses());
QCOMPARE(e.imAddressPreferredIndex(), c.imAddressPreferredIndex());
+ QCOMPARE(e.emailAddressesWithType(), c.emailAddressesWithType());
QCOMPARE(e.emailAddresses(), c.emailAddresses());
QCOMPARE(e.emailAddressPreferredIndex(), c.emailAddressPreferredIndex());
QCOMPARE(e.gpsPos(), c.gpsPos());
commit 2c8ebffc69bad7d4e566c562120b1c0ecb375105
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Apr 12 10:17:04 2013 +0200
Support for types on email addresses.
Patch by Thomas
(cherry picked from commit bc397320d395054960197b85861636c5b6a7551c)
diff --git a/schemas/xCard.xsd b/schemas/xCard.xsd
index c02ab52..e2d8034 100644
--- a/schemas/xCard.xsd
+++ b/schemas/xCard.xsd
@@ -64,7 +64,7 @@
<!-- We mix types from different properties here for simplicity -->
<xs:simpleType name="TypeValueType">
<xs:restriction base="xs:token">
- <!--Address-->
+ <!--Address/Email-->
<xs:enumeration value="work"/>
<xs:enumeration value="home"/>
<!--Telephone-->
diff --git a/src/containers/kolabcontact.cpp b/src/containers/kolabcontact.cpp
index 528b13d..1c5bb0d 100644
--- a/src/containers/kolabcontact.cpp
+++ b/src/containers/kolabcontact.cpp
@@ -150,7 +150,7 @@ struct Contact::Private
int telephonesPreferredIndex;
std::vector<std::string> imAddresses;
int imAddressPreferredIndex;
- std::vector<std::string> emailAddresses;
+ std::vector<Email> emailAddresses;
int emailAddressPreferredIndex;
std::vector<Geo> gpsPos;
std::vector<Key> keys;
@@ -416,13 +416,13 @@ int Contact::imAddressPreferredIndex() const
return d->imAddressPreferredIndex;
}
-void Contact::setEmailAddresses(const std::vector< std::string >& email, int preferredIndex)
+void Contact::setEmailAddresses(const std::vector< Email >& email, int preferredIndex)
{
d->emailAddresses = email;
d->emailAddressPreferredIndex = preferredIndex;
}
-std::vector< std::string > Contact::emailAddresses() const
+std::vector< Email > Contact::emailAddresses() const
{
return d->emailAddresses;
}
diff --git a/src/containers/kolabcontact.h b/src/containers/kolabcontact.h
index 86306ba..c790b1e 100644
--- a/src/containers/kolabcontact.h
+++ b/src/containers/kolabcontact.h
@@ -196,6 +196,25 @@ private:
int mType;
};
+struct Email {
+ enum Type {
+ None = 0,
+ Work = 0x01,
+ Home = 0x02
+ };
+ Email(): mType(None){};
+ Email(const std::string &a, int t = None): mAddress(a), mType(t) {};
+ bool operator==(const Email &other) const { return mAddress == other.mAddress &&
+ mType == other.mType; };
+ void setTypes(int t) { mType = t; };
+ int types() const { return mType; };
+ void setAddress(const std::string &n) { mAddress = n; };
+ std::string address() const { return mAddress; };
+private:
+ std::string mAddress;
+ int mType;
+};
+
struct Crypto {
enum CryptoTypes {
PGPinline = 0x01,
@@ -386,8 +405,8 @@ public:
std::vector<std::string> imAddresses() const;
int imAddressPreferredIndex() const;
- void setEmailAddresses(const std::vector<std::string> &, int preferredIndex = -1);
- std::vector<std::string> emailAddresses() const;
+ void setEmailAddresses(const std::vector<Email> &, int preferredIndex = -1);
+ std::vector<Email> emailAddresses() const;
int emailAddressPreferredIndex() const;
void setGPSpos(const std::vector<Geo> &);
diff --git a/src/kolabformat.i b/src/kolabformat.i
index 8db5e75..07395c5 100644
--- a/src/kolabformat.i
+++ b/src/kolabformat.i
@@ -35,6 +35,7 @@ namespace std {
%template(vectorevent) vector<Kolab::Event>;
%template(vectorrelated) vector<Kolab::Related>;
%template(vectortelephone) vector<Kolab::Telephone>;
+ %template(vectoremail) vector<Kolab::Email>;
%template(vectordatetime) vector<Kolab::cDateTime>;
%template(vectorurl) vector<Kolab::Url>;
%template(vectorkey) vector<Kolab::Key>;
diff --git a/src/xcardconversions.h b/src/xcardconversions.h
index 8e913d3..6461556 100644
--- a/src/xcardconversions.h
+++ b/src/xcardconversions.h
@@ -669,7 +669,31 @@ void writeCard<Kolab::Contact>(vcard_4_0::vcard &vcard, const Kolab::Contact &co
}
if (!contact.emailAddresses().empty()) {
- vcard.email(fromList<vcard::email_type>(contact.emailAddresses(), contact.emailAddressPreferredIndex()));
+ vcard::email_sequence seq;
+ int index = 0;
+ const std::vector<Email> &l = contact.emailAddresses();
+ BOOST_FOREACH(const Kolab::Email &e, l) {
+ vcard::email_type email(e.address());
+ vcard_4_0::typeParamType emailTypeParam;
+ if (e.types() & Kolab::Email::Home) {
+ emailTypeParam.text().push_back(TypeValueType::home);
+ }
+ if (e.types() & Kolab::Email::Work) {
+ emailTypeParam.text().push_back(TypeValueType::work);
+ }
+ vcard::tel_type::parameters_type params;
+ if(contact.emailAddressPreferredIndex() == index) {
+ params.baseParameter().push_back(vcard_4_0::prefParamType(vcard_4_0::prefParamType::integer_default_value()));
+ }
+ index++;
+
+ if (!emailTypeParam.text().empty()) {
+ params.baseParameter().push_back(emailTypeParam);
+ email.parameters(params);
+ }
+ seq.push_back(email);
+ }
+ vcard.email(seq);
}
if (!contact.gpsPos().empty()) {
@@ -1005,18 +1029,31 @@ boost::shared_ptr<Kolab::Contact> readCard <Kolab::Contact> (const vcard_4_0::Vc
if (!vcard.email().empty()) {
int preferredIndex = -1;
- std::vector<std::string> list;
+ std::vector<Kolab::Email> list;
int i = 0;
BOOST_FOREACH(const vcard_4_0::TextPropertyType &s, vcard.email()) {
+ Kolab::Email email;
if (s.parameters()) {
BOOST_FOREACH(const vcard_4_0::ArrayOfParameters::baseParameter_type ¶m, (*s.parameters()).baseParameter()) {
if (dynamic_cast<const vcard_4_0::prefParamType*> (¶m)) {
preferredIndex = i;
- }
+ } else if (const vcard_4_0::typeParamType *rel = dynamic_cast<const vcard_4_0::typeParamType*> (¶m)) {
+ int types = 0;
+ BOOST_FOREACH(const std::string &s, rel->text()) {
+ if (s == TypeValueType(TypeValueType::work)) {
+ types |= Kolab::Email::Work;
+ }
+ if (s == TypeValueType(TypeValueType::home)) {
+ types |= Kolab::Email::Home;
+ }
+ }
+ email.setTypes(types);
+ }
}
}
i++;
- list.push_back(s.text());
+ email.setAddress(s.text());
+ list.push_back(email);
}
contact->setEmailAddresses(list, preferredIndex);
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index d979217..d6f2f84 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -564,7 +564,11 @@ void BindingsTest::contactCompletness()
c.setGender(Kolab::Contact::Male);
c.setLanguages(stringlist);
c.setIMaddresses(stringlist,1);
- c.setEmailAddresses(stringlist,1);
+ std::vector <Kolab::Email> emails;
+ emails.push_back(Kolab::Email("email1 at example.org", Kolab::Email::None));
+ emails.push_back(Kolab::Email("email2 at example.org", Kolab::Email::Work));
+ emails.push_back(Kolab::Email("email3 at example.org", Kolab::Email::Work|Kolab::Email::Home));
+ c.setEmailAddresses(emails,1);
c.setTitles(stringlist);
std::vector<Kolab::Affiliation> list;
More information about the commits
mailing list