using boost::optional;
using dcp::raw_convert;
-DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog)
- : DownloadCertificatePanel (parent, dialog)
+DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog)
+ : DownloadCertificatePanel (parent, message, dialog)
{
- add_label_to_sizer (_table, this, _("Serial number"), true);
- _serial = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (300, -1));
- _table->Add (_serial, 1, wxEXPAND);
- _serial->Bind (wxEVT_TEXT, boost::bind (&DownloadCertificateDialog::setup_sensitivity, _dialog));
-
- layout ();
}
static void
}
void
-DolbyDoremiCertificatePanel::do_download (wxStaticText* message)
+DolbyDoremiCertificatePanel::do_download (string serial)
{
/* Try dcp2000, imb and ims prefixes (see mantis #375) */
string const prefix = "ftp://anonymous@ftp.cinema.dolby.com/Certificates/";
list<string> urls;
list<string> files;
- string const serial = wx_to_std (_serial->GetValue());
bool starts_with_digit = false;
optional<char> starting_char;
}
if (ok) {
- message->SetLabel (_("Certificate downloaded"));
+ _message->SetLabel (_("Certificate downloaded"));
_dialog->setup_sensitivity ();
} else {
- message->SetLabel (wxT (""));
+ _message->SetLabel (wxT (""));
string s;
BOOST_FOREACH (string e, errors) {
}
}
-bool
-DolbyDoremiCertificatePanel::ready_to_download () const
-{
- return !_serial->IsEmpty ();
-}
-
wxString
DolbyDoremiCertificatePanel::name () const
{
class DolbyDoremiCertificatePanel : public DownloadCertificatePanel
{
public:
- DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog);
+ DolbyDoremiCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog);
- bool ready_to_download () const;
- void do_download (wxStaticText* message);
+ void do_download (std::string serial);
wxString name () const;
-
-private:
- void finish_download (std::string serial, wxStaticText* message);
-
- wxTextCtrl* _serial;
};
_notebook = new wxNotebook (this, wxID_ANY);
sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
- _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, this));
-
- BOOST_FOREACH (DownloadCertificatePanel* i, _pages) {
- _notebook->AddPage (i, i->name(), true);
- }
-
_download = new wxButton (this, wxID_ANY, _("Download"));
sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
font.SetPointSize (font.GetPointSize() - 1);
_message->SetFont (font);
+ _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, _message, this));
+
+ BOOST_FOREACH (DownloadCertificatePanel* i, _pages) {
+ _notebook->AddPage (i, i->name(), true);
+ }
+
wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
if (buttons) {
sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
void
DownloadCertificateDialog::download ()
{
- _pages[_notebook->GetSelection()]->download (_message);
+ _pages[_notebook->GetSelection()]->download ();
}
dcp::Certificate
#include "wx_util.h"
#include "download_certificate_panel.h"
+#include "download_certificate_dialog.h"
#include "lib/signal_manager.h"
#include <dcp/util.h>
#include <dcp/exceptions.h>
using boost::function;
using boost::optional;
-DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog)
+DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog)
: wxPanel (parent, wxID_ANY)
, _dialog (dialog)
+ , _message (message)
{
_overall_sizer = new wxBoxSizer (wxVERTICAL);
SetSizer (_overall_sizer);
_table->AddGrowableCol (1, 1);
_overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-}
-void
-DownloadCertificatePanel::layout ()
-{
+ add_label_to_sizer (_table, this, _("Serial number"), true);
+ _serial = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (300, -1));
+ _table->Add (_serial, 1, wxEXPAND);
+
+ _serial->Bind (wxEVT_TEXT, boost::bind (&DownloadCertificateDialog::setup_sensitivity, _dialog));
+
_overall_sizer->Layout ();
_overall_sizer->SetSizeHints (this);
}
}
void
-DownloadCertificatePanel::download (wxStaticText* message)
+DownloadCertificatePanel::download ()
{
- message->SetLabel (_("Downloading certificate"));
+ _message->SetLabel (_("Downloading certificate"));
/* Hack: without this the SetLabel() above has no visible effect */
wxMilliSleep (200);
- signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this, message));
+ signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this, wx_to_std(_serial->GetValue())));
+}
+
+bool
+DownloadCertificatePanel::ready_to_download () const
+{
+ return !_serial->IsEmpty ();
}
class DownloadCertificatePanel : public wxPanel
{
public:
- DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog);
+ DownloadCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog);
- virtual bool ready_to_download () const = 0;
- virtual void do_download (wxStaticText* message) = 0;
+ virtual void do_download (std::string serial) = 0;
virtual wxString name () const = 0;
- void download (wxStaticText* message);
+ bool ready_to_download () const;
+ void download ();
void load (boost::filesystem::path);
boost::optional<dcp::Certificate> certificate () const;
protected:
- void layout ();
-
DownloadCertificateDialog* _dialog;
wxFlexGridSizer* _table;
+ wxStaticText* _message;
private:
wxSizer* _overall_sizer;
boost::optional<dcp::Certificate> _certificate;
+ wxTextCtrl* _serial;
};
#endif