summaryrefslogtreecommitdiff
path: root/src/xcardconversions.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/xcardconversions.h')
-rw-r--r--src/xcardconversions.h61
1 files changed, 39 insertions, 22 deletions
diff --git a/src/xcardconversions.h b/src/xcardconversions.h
index 501eb1a..8125ff6 100644
--- a/src/xcardconversions.h
+++ b/src/xcardconversions.h
@@ -679,20 +679,32 @@ void writeCard<Kolab::Contact>(vcard_4_0::vcard &vcard, const Kolab::Contact &co
allowed.text(seq);
crypto.allowed(allowed);
}
+
+ crypto.encryptpref(fromCryptoPref(c.encryptPref()));
+ crypto.signpref(fromCryptoPref(c.signPref()));
+
+ vcard.x_crypto(crypto);
+ }
+
+ if (!contact.keys().empty()) {
vcard_4_0::vcard::key_sequence keys;
- if (!c.pgpKey().empty()) {
- keys.push_back(vcard_4_0::keyPropType(uriInlineEncoding(c.pgpKey(), MIME_PGP_KEYS)));
- }
- if (!c.smimeKey().empty()) {
- keys.push_back(vcard_4_0::keyPropType(uriInlineEncoding(c.smimeKey(), MIME_PKCS7_MIME)));
+ BOOST_FOREACH (const Kolab::Key &k, contact.keys()) {
+ switch (k.type()) {
+ case Kolab::Key::PGP:
+ keys.push_back(vcard_4_0::keyPropType(uriInlineEncoding(k.key(), MIME_PGP_KEYS)));
+ break;
+ case Kolab::Key::PKCS7_MIME:
+ keys.push_back(vcard_4_0::keyPropType(uriInlineEncoding(k.key(), MIME_PKCS7_MIME)));
+ break;
+ default:
+ LOG("Unhandled/Invalid keytype");
+ break;
+ }
}
+
if (!keys.empty()) {
vcard.key(keys);
}
- crypto.encryptpref(fromCryptoPref(c.encryptPref()));
- crypto.signpref(fromCryptoPref(c.signPref()));
-
- vcard.x_crypto(crypto);
}
@@ -999,19 +1011,7 @@ boost::shared_ptr<Kolab::Contact> readCard <Kolab::Contact> (const vcard_4_0::Vc
}
c.setAllowed(allowed);
}
- 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");
- }
- }
- }
+
if (crypto.encryptpref()) {
c.setEncryptPref(toCryptoPref(crypto.encryptpref()->text()));
}
@@ -1020,6 +1020,23 @@ boost::shared_ptr<Kolab::Contact> readCard <Kolab::Contact> (const vcard_4_0::Vc
}
contact->setCrypto(c);
}
+
+ if (!vcard.key().empty()) {
+ std::string mimetype;
+ std::vector<Kolab::Key> keys;
+ BOOST_FOREACH(const vcard_4_0::keyPropType &k, vcard.key()) {
+ const std::string &key = uriInlineDecoding(k.uri(), mimetype);
+ if (mimetype == MIME_PGP_KEYS) {
+ keys.push_back(Kolab::Key(key, Kolab::Key::PGP));
+ } else if (mimetype == MIME_PKCS7_MIME) {
+ keys.push_back(Kolab::Key(key, Kolab::Key::PKCS7_MIME));
+ } else {
+ WARNING("wrong mimetype on key");
+ }
+ }
+ contact->setKeys(keys);
+ }
+
return contact;
}