diff options
Diffstat (limited to 'src/lib/kdm_recipient.cc')
| -rw-r--r-- | src/lib/kdm_recipient.cc | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/lib/kdm_recipient.cc b/src/lib/kdm_recipient.cc index c33eb1b9f..7e7e14324 100644 --- a/src/lib/kdm_recipient.cc +++ b/src/lib/kdm_recipient.cc @@ -22,14 +22,17 @@ #include "kdm_recipient.h" +using boost::optional; + + KDMRecipient::KDMRecipient (cxml::ConstNodePtr node) : name (node->string_child("Name")) , notes (node->optional_string_child("Notes").get_value_or("")) { if (node->optional_string_child("Certificate")) { - recipient = dcp::Certificate (node->string_child("Certificate")); + _recipient = dcp::Certificate(node->string_child("Certificate")); } else if (node->optional_string_child("Recipient")) { - recipient = dcp::Certificate (node->string_child("Recipient")); + _recipient = dcp::Certificate(node->string_child("Recipient")); } recipient_file = node->optional_string_child("RecipientFile"); @@ -40,8 +43,8 @@ void KDMRecipient::as_xml (xmlpp::Element* parent) const { cxml::add_text_child(parent, "Name", name); - if (recipient) { - cxml::add_text_child(parent, "Recipient", recipient->certificate(true)); + if (auto const r = recipient()) { + cxml::add_text_child(parent, "Recipient", r->certificate(true)); } if (recipient_file) { cxml::add_text_child(parent, "RecipientFile", *recipient_file); @@ -50,3 +53,26 @@ KDMRecipient::as_xml (xmlpp::Element* parent) const cxml::add_text_child(parent, "Notes", notes); } + +boost::optional<dcp::Certificate> +KDMRecipient::recipient() const +{ + if (_recipient) { + return _recipient; + } + + if (_recipient_string) { + return dcp::Certificate(*_recipient_string); + } + + return {}; +} + + +void +KDMRecipient::set_recipient(optional<dcp::Certificate> certificate) +{ + _recipient = certificate; + _recipient_string = {}; +} + |
