summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2013-05-20 13:56:45 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2013-05-20 13:56:45 (GMT)
commit84f194233beccdd43a349e4f378012e319ecdca2 (patch)
tree8f724f1acaa7d9a00687377b223d2dd074cccec7
parente7423d80e03085d8dccda629baeb17cbb99a42d4 (diff)
downloadlibkolab-84f194233beccdd43a349e4f378012e319ecdca2.tar.gz
Adapt to binary incompatible changes for setting email addresses on
contacts. Requires libkolabxml 1.0. Types are not preserved yet.
-rw-r--r--CMakeLists.txt2
-rw-r--r--conversion/kabcconversion.cpp23
2 files changed, 17 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f66bcc..ca0edfb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,7 +47,7 @@ set(CMAKECONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/Libkolab )
include(MacroLogFeature)
# Do the building
-find_package(Libkolabxml 0.9 REQUIRED)
+find_package(Libkolabxml 1.0 REQUIRED)
macro_log_feature(Libkolabxml_FOUND "Libkolabxml" "Kolab XML Format 3 serializing library" "http://git.kolab.org/libkolabxml/" TRUE "0.8.3" "Required for reading/writing Kolab XML Objects")
find_package(Qt4 4.6.0 REQUIRED)
diff --git a/conversion/kabcconversion.cpp b/conversion/kabcconversion.cpp
index b69aa72..ce33913 100644
--- a/conversion/kabcconversion.cpp
+++ b/conversion/kabcconversion.cpp
@@ -432,11 +432,16 @@ KABC::Addressee toKABC(const Kolab::Contact &contact)
QString preferredEmail;
if (!contact.emailAddresses().empty()) {
- addressee.setEmails(toStringList(contact.emailAddresses()));
+ QStringList emails;
+ foreach( const Kolab::Email &email, contact.emailAddresses()) {
+ emails << fromStdString(email.address());
+ //FIXME preserve type
+ }
+ addressee.setEmails(emails);
if ((contact.emailAddressPreferredIndex() >= 0) && (contact.emailAddressPreferredIndex() < static_cast<int>(contact.emailAddresses().size()))) {
- preferredEmail = fromStdString(contact.emailAddresses().at(contact.emailAddressPreferredIndex()));
+ preferredEmail = fromStdString(contact.emailAddresses().at(contact.emailAddressPreferredIndex()).address());
} else {
- preferredEmail = fromStdString(contact.emailAddresses().at(0));
+ preferredEmail = fromStdString(contact.emailAddresses().at(0).address());
}
addressee.insertEmail(preferredEmail, true);
}
@@ -705,13 +710,17 @@ Kolab::Contact fromKABC(const KABC::Addressee &addressee)
}
int prefEmail = -1;
+ int count = 0;
+ std::vector<Kolab::Email> emails;
foreach(const QString &e, addressee.emails()) {
- prefEmail++;
- if (e == addressee.preferredEmail()) {
- break;
+ if ((prefEmail == -1) && (e == addressee.preferredEmail())) {
+ prefEmail = count;
}
+ count++;
+ //FIXME preserve types
+ emails.push_back(Kolab::Email(toStdString(e)));
}
- c.setEmailAddresses(fromStringList(addressee.emails()), prefEmail);
+ c.setEmailAddresses(emails, prefEmail);
if (addressee.geo().isValid()) {
c.setGPSpos(std::vector<Kolab::Geo>() << Kolab::Geo(addressee.geo().latitude(), addressee.geo().longitude()));
}