From b608bea0b51b0f24fbf1fada87d3ad7abbb9a07b Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Mon, 19 Apr 2010 18:54:05 -0400 Subject: [PATCH] lib: added LDIF mapping support for Contact::Image fields Note that jpegPhoto looks like the only LDIF field for photo images... it is unknown which format will come from the BlackBerry in the Image field, so we can't guarantee that "Image" will be in JPG format. Therefore the LDIF mapping of "jpegPhoto" to "Image" is not done automatically. The LDIF mapping can be done manually from the btool command line with "-m jpegPhoto,Image,Image" and hope that your LDAP software and your BlackBerry uses JPG. Reading photos from LDIF should be fine, since the BlackBerry seems to handle most formats, when going in the LDIF -> BlackBerry direction. --- src/ldif.cc | 20 ++++++++++++++++++++ src/ldif.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/ldif.cc b/src/ldif.cc index 105a1a4c..3dc43cf9 100644 --- a/src/ldif.cc +++ b/src/ldif.cc @@ -78,6 +78,8 @@ const ContactLdif::NameToFunc ContactLdif::FieldMap[] = { &ContactLdif::PublicKey, &ContactLdif::SetPublicKey }, { "Notes", "Notes", &ContactLdif::Notes, &ContactLdif::SetNotes }, + { "Image", "Contact photo", + &ContactLdif::Image, &ContactLdif::SetImage }, { "WorkPostalAddress", "Mailing Work address (includes address lines, city, province, country, and postal code)", &ContactLdif::WorkPostalAddress, &ContactLdif::SetWorkPostalAddress }, { "HomePostalAddress", "Mailing home address (includes address lines, city, province, country, and postal code)", @@ -141,6 +143,14 @@ ContactLdif::ContactLdif(const std::string &baseDN) Map("postalAddress", &ContactLdif::WorkPostalAddress, &ContactLdif::SetWorkPostalAddress); Map("homePostalAddress", &ContactLdif::HomePostalAddress, &ContactLdif::SetHomePostalAddress); Map("note", &ContactLdif::Notes, &ContactLdif::SetNotes); + // FIXME - jpegPhoto looks like the only LDIF field for photo + // images... it is unknown which format will come from the + // BlackBerry in the Image field, so we can't guarantee + // that Image will be in JPG. This mapping can be done manually + // from the btool command line with "-m jpegPhoto,Image,Image" + // Reading photos from LDIF should be fine, since the BlackBerry + // seems to handle most formats. +// Map("jpegPhoto", &ContactLdif::Image, &ContactLdif::SetImage); // add heuristics hooks Hook("cn", &m_cn); @@ -392,6 +402,11 @@ std::string ContactLdif::Notes(const Barry::Contact &con) const return con.Notes; } +std::string ContactLdif::Image(const Barry::Contact &con) const +{ + return con.Image; +} + std::string ContactLdif::WorkPostalAddress(const Barry::Contact &con) const { return con.WorkAddress.GetLabel(); @@ -548,6 +563,11 @@ void ContactLdif::SetNotes(Barry::Contact &con, const std::string &val) const con.Notes = val; } +void ContactLdif::SetImage(Barry::Contact &con, const std::string &val) const +{ + con.Image = val; +} + void ContactLdif::SetWorkPostalAddress(Barry::Contact &con, const std::string &val) const { // FIXME; diff --git a/src/ldif.h b/src/ldif.h index 38198dc5..cc602eeb 100644 --- a/src/ldif.h +++ b/src/ldif.h @@ -175,6 +175,7 @@ public: virtual std::string JobTitle(const Barry::Contact &con) const; virtual std::string PublicKey(const Barry::Contact &con) const; virtual std::string Notes(const Barry::Contact &con) const; + virtual std::string Image(const Barry::Contact &con) const; // calculated values... virtual std::string WorkPostalAddress(const Barry::Contact &con) const; virtual std::string HomePostalAddress(const Barry::Contact &con) const; @@ -214,6 +215,7 @@ public: virtual void SetJobTitle(Barry::Contact &con, const std::string &val) const; virtual void SetPublicKey(Barry::Contact &con, const std::string &val) const; virtual void SetNotes(Barry::Contact &con, const std::string &val) const; + virtual void SetImage(Barry::Contact &con, const std::string &val) const; virtual void SetWorkPostalAddress(Barry::Contact &con, const std::string &val) const; virtual void SetHomePostalAddress(Barry::Contact &con, const std::string &val) const; virtual void SetFullName(Barry::Contact &con, const std::string &val) const; -- 2.11.4.GIT