int utc_offset_hour_,
int utc_offset_minute_
)
- : KDMRecipient (name_, notes_, recipient_)
+ : KDMRecipient (name_, notes_, recipient_, boost::none)
, emails (emails_)
, utc_offset_hour (utc_offset_hour_)
, utc_offset_minute (utc_offset_minute_)
optional<string>
-get_from_url (string url, bool pasv, bool skip_pasv_ip, function<optional<string> (boost::filesystem::path)> load)
+get_from_url (string url, bool pasv, bool skip_pasv_ip, function<optional<string> (boost::filesystem::path, string)> load)
{
ScopedTemporary temp;
auto e = get_from_url (url, pasv, skip_pasv_ip, temp);
if (e) {
return e;
}
- return load (temp.file());
+ return load (temp.file(), url);
}
* @param load Function passed a (temporary) filesystem path of the unpacked file.
*/
optional<string>
-get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, function<optional<string> (boost::filesystem::path)> load)
+get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, function<optional<string> (boost::filesystem::path, string)> load)
{
/* Download the ZIP file to temp_zip */
ScopedTemporary temp_zip;
zip_close (zip);
temp_cert.close ();
- return load (temp_cert.file());
+ return load (temp_cert.file(), url);
}
boost::optional<std::string> get_from_url (std::string url, bool pasv, bool skip_pasv_ip, ScopedTemporary& temp);
-boost::optional<std::string> get_from_url (std::string url, bool pasv, bool skip_pasv_ip, std::function<boost::optional<std::string> (boost::filesystem::path)> load);
-boost::optional<std::string> get_from_zip_url (std::string url, std::string file, bool pasv, bool skip_pasv_ip, std::function<boost::optional<std::string> (boost::filesystem::path)> load);
+
+boost::optional<std::string> get_from_url (
+ std::string url,
+ bool pasv,
+ bool skip_pasv_ip,
+ std::function<boost::optional<std::string> (boost::filesystem::path, std::string)> load
+ );
+
+boost::optional<std::string> get_from_zip_url (
+ std::string url,
+ std::string file,
+ bool pasv,
+ bool skip_pasv_ip,
+ std::function<boost::optional<std::string> (boost::filesystem::path, std::string)> load
+ );
+
std::list<std::string> ls_url (std::string url);
{
/* Make a new screen and add it to the current cinema */
dcp::CertificateChain chain (dcp::file_to_string(optarg));
- auto screen = make_shared<Screen>(screen_description, "", chain.leaf(), vector<TrustedDevice>());
+ auto screen = std::make_shared<Screen>(screen_description, "", chain.leaf(), boost::none, vector<TrustedDevice>());
if (cinema) {
cinema->add_screen (screen);
}
} else if (node->optional_string_child("Recipient")) {
recipient = dcp::Certificate (node->string_child("Recipient"));
}
+
+ recipient_file = node->optional_string_child("RecipientFile");
}
if (recipient) {
parent->add_child("Recipient")->add_child_text(recipient->certificate(true));
}
+ if (recipient_file) {
+ parent->add_child("RecipientFile")->add_child_text(*recipient_file);
+ }
parent->add_child("Notes")->add_child_text(notes);
}
class KDMRecipient
{
public:
- KDMRecipient (std::string const& name_, std::string const& notes_, boost::optional<dcp::Certificate> recipient_)
+ KDMRecipient (std::string const& name_, std::string const& notes_, boost::optional<dcp::Certificate> recipient_, boost::optional<std::string> recipient_file_)
: name (name_)
, notes (notes_)
, recipient (recipient_)
+ , recipient_file (recipient_file_)
{}
explicit KDMRecipient (cxml::ConstNodePtr);
std::string name;
std::string notes;
boost::optional<dcp::Certificate> recipient;
+ /** The pathname or URL that the recipient certificate was obtained from; purely
+ * to inform the user.
+ */
+ boost::optional<std::string> recipient_file;
};
class Screen : public KDMRecipient
{
public:
- Screen (std::string const & name_, std::string const & notes_, boost::optional<dcp::Certificate> recipient_, std::vector<TrustedDevice> trusted_devices_)
- : KDMRecipient (name_, notes_, recipient_)
+ Screen (
+ std::string const & name_,
+ std::string const & notes_,
+ boost::optional<dcp::Certificate> recipient_,
+ boost::optional<std::string> recipient_file_,
+ std::vector<TrustedDevice> trusted_devices_
+ )
+ : KDMRecipient (name_, notes_, recipient_, recipient_file_)
, trusted_devices (trusted_devices_)
{}
serial
);
- optional<string> error = get_from_url (url, true, false, boost::bind (&DownloadCertificatePanel::load_certificate, this, _1));
+ auto error = get_from_url (url, true, false, boost::bind (&DownloadCertificatePanel::load_certificate, this, _1, _2));
if (error) {
_dialog->message()->SetLabel(wxT(""));
error_dialog (this, std_to_wx(*error));
optional<string> all_errors;
bool ok = true;
- optional<string> error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate_from_chain, this, _1));
+ auto error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate_from_chain, this, _1, _2));
if (error) {
all_errors = *error;
auto const url = String::compose ("%1IMB-S2/IMB-S2_%2_sha256.pem", prefix, serial);
- error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate_from_chain, this, _1));
+ error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate_from_chain, this, _1, _2));
if (error) {
*all_errors += "\n" + *error;
ok = false;
auto i = urls.begin ();
auto j = files.begin ();
while (!ok && i != urls.end ()) {
- auto error = get_from_zip_url (*i++, *j++, true, true, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1));
+ auto error = get_from_zip_url (*i++, *j++, true, true, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1, _2));
if (error) {
errors.push_back (error.get ());
} else {
#include "wx_util.h"
+using std::string;
using boost::optional;
return *c;
}
+
+string
+DownloadCertificateDialog::url () const
+{
+ auto u = _pages[_notebook->GetSelection()]->url();
+ DCPOMATIC_ASSERT (u);
+ return *u;
+}
+
+
void
DownloadCertificateDialog::setup_sensitivity ()
{
~DownloadCertificateDialog ();
dcp::Certificate certificate () const;
+ std::string url () const;
void setup_sensitivity ();
optional<string>
-DownloadCertificatePanel::load_certificate (boost::filesystem::path file)
+DownloadCertificatePanel::load_certificate (boost::filesystem::path file, string url)
{
try {
_certificate = dcp::Certificate (dcp::file_to_string(file));
+ _url = url;
} catch (dcp::MiscError& e) {
return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what());
}
optional<string>
-DownloadCertificatePanel::load_certificate_from_chain (boost::filesystem::path file)
+DownloadCertificatePanel::load_certificate_from_chain (boost::filesystem::path file, string url)
{
try {
_certificate = dcp::CertificateChain (dcp::file_to_string(file)).leaf();
+ _url = url;
} catch (dcp::MiscError& e) {
return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what());
}
}
+
+optional<string>
+DownloadCertificatePanel::url () const
+{
+ return _url;
+
+}
+
void
DownloadCertificatePanel::download ()
{
virtual bool ready_to_download () const;
void download ();
- boost::optional<std::string> load_certificate (boost::filesystem::path);
- boost::optional<std::string> load_certificate_from_chain (boost::filesystem::path);
+ boost::optional<std::string> load_certificate (boost::filesystem::path, std::string url);
+ boost::optional<std::string> load_certificate_from_chain (boost::filesystem::path, std::string url);
boost::optional<dcp::Certificate> certificate () const;
+ boost::optional<std::string> url () const;
protected:
DownloadCertificateDialog* _dialog;
private:
boost::optional<dcp::Certificate> _certificate;
+ boost::optional<std::string> _url;
};
serial
);
- optional<string> error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1));
+ auto error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1, _2));
if (error) {
_dialog->message()->SetLabel(wxT(""));
return;
}
- auto error = get_from_url (String::compose("%1SMPTE-%2/%3", base, _type, *name), true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1));
+ auto error = get_from_url (String::compose("%1SMPTE-%2/%3", base, _type, *name), true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1, _2));
if (error) {
_dialog->message()->SetLabel(wxT(""));
ScreenDialog::ScreenDialog (
- wxWindow* parent, wxString title, string name, string notes, optional<dcp::Certificate> recipient, vector<TrustedDevice> trusted_devices
+ wxWindow* parent,
+ wxString title,
+ string name,
+ string notes,
+ optional<dcp::Certificate> recipient,
+ optional<string> recipient_file,
+ vector<TrustedDevice> trusted_devices
)
: wxDialog (parent, wxID_ANY, title)
, _recipient (recipient)
_recipient_thumbprint = new StaticText (this, wxT (""), wxDefaultPosition, size);
_recipient_thumbprint->SetFont (font);
set_recipient (recipient);
+
_get_recipient_from_file = new Button (this, _("Get from file..."));
_download_recipient = new Button (this, _("Download..."));
- s->Add (_recipient_thumbprint, 1, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
+ s->Add (_recipient_thumbprint, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT, DCPOMATIC_SIZER_X_GAP);
s->Add (_get_recipient_from_file, 0, wxLEFT | wxRIGHT | wxEXPAND, DCPOMATIC_SIZER_X_GAP);
s->Add (_download_recipient, 0, wxLEFT | wxRIGHT | wxEXPAND, DCPOMATIC_SIZER_X_GAP);
_sizer->Add (s, wxGBPosition (r, 1));
++r;
- add_label_to_sizer (_sizer, this, _("Other trusted devices"), true, wxGBPosition (r, 0));
+ add_label_to_sizer (_sizer, this, _("Filename"), true, wxGBPosition(r, 0));
+ _recipient_file = new wxStaticText (this, wxID_ANY, wxT(""));
+ checked_set (_recipient_file, recipient_file.get_value_or(""));
+ _sizer->Add (_recipient_file, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP);
+ ++r;
+
+ {
+ int flags = wxALIGN_CENTER_VERTICAL | wxTOP;
+#ifdef __WXOSX__
+ flags |= wxALIGN_RIGHT;
+ auto m = new StaticText (this, _("Other trusted devices") + wxT(":"));
+#else
+ auto m = new StaticText (this, _("Other trusted devices"));
+#endif
+ _sizer->Add (m, wxGBPosition(r, 0), wxDefaultSpan, flags, DCPOMATIC_SIZER_Y_GAP);
+ }
++r;
vector<EditableListColumn> columns;
}
+optional<string>
+ScreenDialog::recipient_file () const
+{
+ auto const f = wx_to_std(_recipient_file->GetLabel());
+ if (f.empty()) {
+ return {};
+ }
+ return f;
+}
+
+
void
ScreenDialog::load_recipient (boost::filesystem::path file)
{
return;
}
set_recipient (c.leaf ());
+ checked_set (_recipient_file, file.string());
} catch (dcp::MiscError& e) {
error_dialog (this, _("Could not read certificate file."), std_to_wx(e.what()));
}
auto d = new DownloadCertificateDialog (this);
if (d->ShowModal() == wxID_OK) {
set_recipient (d->certificate());
+ checked_set (_recipient_file, d->url());
}
d->Destroy ();
setup_sensitivity ();
wxString,
std::string name = "",
std::string notes = "",
- boost::optional<dcp::Certificate> c = boost::optional<dcp::Certificate>(),
- std::vector<TrustedDevice> d = std::vector<TrustedDevice>()
+ boost::optional<dcp::Certificate> c = {},
+ boost::optional<std::string> f = {},
+ std::vector<TrustedDevice> d = {}
);
std::string name () const;
std::string notes () const;
boost::optional<dcp::Certificate> recipient () const;
+ boost::optional<std::string> recipient_file () const;
std::vector<TrustedDevice> trusted_devices () {
return _trusted_devices;
}
wxTextCtrl* _name;
wxTextCtrl* _notes;
wxStaticText* _recipient_thumbprint;
+ wxStaticText* _recipient_file;
wxButton* _get_recipient_from_file;
wxButton* _download_recipient;
EditableList<TrustedDevice, TrustedDeviceDialog>* _trusted_device_list;
}
}
- auto s = std::make_shared<Screen>(d->name(), d->notes(), d->recipient(), d->trusted_devices());
+ auto s = std::make_shared<Screen>(d->name(), d->notes(), d->recipient(), d->recipient_file(), d->trusted_devices());
c->add_screen (s);
auto id = add_screen (c, s);
if (id) {
auto s = *_selected_screens.begin();
- auto d = new ScreenDialog (GetParent(), _("Edit screen"), s.second->name, s.second->notes, s.second->recipient, s.second->trusted_devices);
+ auto d = new ScreenDialog (GetParent(), _("Edit screen"), s.second->name, s.second->notes, s.second->recipient, s.second->recipient_file, s.second->trusted_devices);
if (d->ShowModal() != wxID_OK) {
d->Destroy ();
return;
s.second->name = d->name ();
s.second->notes = d->notes ();
s.second->recipient = d->recipient ();
+ s.second->recipient_file = d->recipient_file ();
s.second->trusted_devices = d->trusted_devices ();
_targets->SetItemText (s.first, std_to_wx (d->name()));
Config::instance()->changed (Config::CINEMAS);
/* Cinema A: UTC +4:30 */
auto cinema_a = make_shared<Cinema>("Cinema A", list<string>(), "", 4, 30);
- cinema_a_screen_1 = make_shared<dcpomatic::Screen>("Screen 1", "", crypt_cert, vector<TrustedDevice>());
+ cinema_a_screen_1 = std::make_shared<dcpomatic::Screen>("Screen 1", "", crypt_cert, boost::none, vector<TrustedDevice>());
cinema_a->add_screen (cinema_a_screen_1);
- cinema_a_screen_2 = make_shared<dcpomatic::Screen>("Screen 2", "", crypt_cert, vector<TrustedDevice>());
+ cinema_a_screen_2 = std::make_shared<dcpomatic::Screen>("Screen 2", "", crypt_cert, boost::none, vector<TrustedDevice>());
cinema_a->add_screen (cinema_a_screen_2);
c->add_cinema (cinema_a);
/* Cinema B: UTC -1:00 */
auto cinema_b = make_shared<Cinema>("Cinema B", list<string>(), "", -1, 0);
- cinema_b_screen_x = make_shared<dcpomatic::Screen>("Screen X", "", crypt_cert, vector<TrustedDevice>());
+ cinema_b_screen_x = std::make_shared<dcpomatic::Screen>("Screen X", "", crypt_cert, boost::none, vector<TrustedDevice>());
cinema_b->add_screen (cinema_b_screen_x);
- cinema_b_screen_y = make_shared<dcpomatic::Screen>("Screen Y", "", crypt_cert, vector<TrustedDevice>());
+ cinema_b_screen_y = std::make_shared<dcpomatic::Screen>("Screen Y", "", crypt_cert, boost::none, vector<TrustedDevice>());
cinema_b->add_screen (cinema_b_screen_y);
- cinema_b_screen_z = make_shared<dcpomatic::Screen>("Screen Z", "", crypt_cert, vector<TrustedDevice>());
+ cinema_b_screen_z = std::make_shared<dcpomatic::Screen>("Screen Z", "", crypt_cert, boost::none, vector<TrustedDevice>());
cinema_b->add_screen (cinema_b_screen_z);
c->add_cinema (cinema_a);