Move credentials settings into certificate download dialogue (#1480).
authorCarl Hetherington <cth@carlh.net>
Sun, 5 Jan 2020 14:25:58 +0000 (15:25 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 6 Jan 2020 09:29:24 +0000 (10:29 +0100)
17 files changed:
doc/manual/dcpomatic.xml
graphics/osx/preferences/accounts.png [deleted file]
graphics/src/accounts.svg [deleted file]
graphics/update
platform/osx/make_dmg.sh
src/wx/barco_alchemy_certificate_panel.cc
src/wx/barco_alchemy_certificate_panel.h
src/wx/christie_certificate_panel.cc
src/wx/christie_certificate_panel.h
src/wx/credentials_download_certificate_panel.cc [new file with mode: 0644]
src/wx/credentials_download_certificate_panel.h [new file with mode: 0644]
src/wx/download_certificate_dialog.h
src/wx/download_certificate_panel.h
src/wx/full_config_dialog.cc
src/wx/gdc_certificate_panel.cc
src/wx/gdc_certificate_panel.h
src/wx/wscript

index 18fe753b59b49cb54cf6b3fe76bdc53050023cbf..3e4e1eadd01615c5c3b0c0b29dbaa387c2987c0e 100644 (file)
@@ -3018,33 +3018,6 @@ The <guilabel>Reset to default text</guilabel> will replace the current KDM emai
 
 </section>
 
-
-<!-- ============================================================== -->
-<section>
-<title>Accounts</title>
-
-<para>
-The Accounts tab is shown in <xref linkend="fig-prefs-accounts"/>.
-</para>
-
-<figure id="fig-prefs-accounts">
-  <title>Accounts preferences</title>
-  <mediaobject>
-    <imageobject>
-      <imagedata fileref="screenshots/prefs-accounts&scs;"/>
-    </imageobject>
-  </mediaobject>
-</figure>
-
-<para>
-DCP-o-matic can download projector certificates from the Barco,
-Christie and GDC websites if you have the appropriate credentials.
-Enter your usernames and passwords.
-</para>
-
-</section>
-
-
 <!-- ============================================================== -->
 <section>
 <title>Notifications</title>
diff --git a/graphics/osx/preferences/accounts.png b/graphics/osx/preferences/accounts.png
deleted file mode 100644 (file)
index f9909b7..0000000
Binary files a/graphics/osx/preferences/accounts.png and /dev/null differ
diff --git a/graphics/src/accounts.svg b/graphics/src/accounts.svg
deleted file mode 100644 (file)
index 9200518..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://creativecommons.org/ns#"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   id="svg5816"
-   viewBox="0 0 48 48"
-   sodipodi:version="0.32"
-   inkscape:output_extension="org.inkscape.output.svg.inkscape"
-   inkscape:version="0.92.3 (2405546, 2018-03-11)"
-   sodipodi:docname="accounts.svg"
-   version="1.1">
-  <defs
-     id="defs3">
-    <linearGradient
-       id="linearGradient2152">
-      <stop
-         id="stop2154"
-         style="stop-color:#9aa29a"
-         offset="0" />
-      <stop
-         id="stop2156"
-         style="stop-color:#b5beb5"
-         offset="1" />
-    </linearGradient>
-    <linearGradient
-       id="linearGradient3601"
-       y2="613.94"
-       gradientUnits="userSpaceOnUse"
-       x2="385.04001"
-       gradientTransform="matrix(0.04860254,-0.04951283,0.04860254,0.04951283,-9.7664634,27.282)"
-       y1="63.870998"
-       x1="386.39001">
-      <stop
-         id="stop3797"
-         stop-color="#ffe800"
-         offset="0" />
-      <stop
-         id="stop3799"
-         stop-color="#dfb300"
-         offset="1" />
-    </linearGradient>
-  </defs>
-  <sodipodi:namedview
-     id="base"
-     bordercolor="#666666"
-     inkscape:window-x="0"
-     inkscape:window-y="27"
-     pagecolor="#ffffff"
-     inkscape:grid-bbox="true"
-     inkscape:zoom="5.6568542"
-     inkscape:pageshadow="2"
-     showgrid="false"
-     borderopacity="1.0"
-     inkscape:current-layer="layer1"
-     inkscape:cx="-28.201318"
-     inkscape:cy="3.7247721"
-     inkscape:window-width="1366"
-     inkscape:pageopacity="0.0"
-     inkscape:window-height="704"
-     inkscape:document-units="px"
-     inkscape:snap-global="false"
-     inkscape:window-maximized="1" />
-  <g
-     id="layer1"
-     inkscape:label="Layer 1"
-     inkscape:groupmode="layer">
-    <g
-       id="g1455"
-       transform="translate(0.88388348)">
-      <g
-         id="g1449">
-        <path
-           style="fill:#b3b3b3;stroke:#808080;stroke-width:0.98399496px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-           d="m 29.978487,33.024462 h 16.06181 v -3.097551 c 0,-16.716246 -16.06181,-15.645777 -16.06181,-0.0014 z"
-           id="path280-9-0"
-           inkscape:connector-curvature="0"
-           sodipodi:nodetypes="ccccc" />
-      </g>
-      <g
-         id="g1446">
-        <ellipse
-           style="opacity:1;vector-effect:none;fill:#b3b3b3;fill-opacity:1;stroke:#808080;stroke-width:0.73654598px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
-           id="path282-3-6"
-           cx="38.009392"
-           cy="11.693348"
-           rx="4.6944504"
-           ry="5.4944878" />
-      </g>
-    </g>
-    <g
-       id="g1459">
-      <path
-         sodipodi:nodetypes="ccccc"
-         inkscape:connector-curvature="0"
-         id="path280-9"
-         d="M 1.1590826,33.024462 H 17.220893 v -3.097551 c 0,-16.716246 -16.0618104,-15.645777 -16.0618104,-0.0014 z"
-         style="fill:#b3b3b3;stroke:#808080;stroke-width:0.98399496px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
-      <ellipse
-         ry="5.4944878"
-         rx="4.6944504"
-         cy="11.693348"
-         cx="9.1899881"
-         id="path282-3"
-         style="opacity:1;vector-effect:none;fill:#b3b3b3;fill-opacity:1;stroke:#808080;stroke-width:0.73654598px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
-    </g>
-    <g
-       id="g1443"
-       transform="translate(-1.0044895)">
-      <path
-         sodipodi:nodetypes="ccccc"
-         inkscape:connector-curvature="0"
-         id="path280"
-         d="m 13.185526,45.935377 h 23.637927 v -5.599269 c 0,-30.217034 -23.637927,-28.282004 -23.637927,-0.0024 z"
-         style="fill:#1a1a1a;stroke:#000000;stroke-width:1.60493279px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
-      <ellipse
-         ry="8.1366978"
-         rx="6.9519358"
-         cy="9.6214514"
-         cx="25.00449"
-         id="path282"
-         style="opacity:1;vector-effect:none;fill:#1a1a1a;fill-opacity:1;stroke:#000000;stroke-width:1.09073901px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
-    </g>
-  </g>
-  <metadata
-     id="metadata53">
-    <rdf:RDF>
-      <cc:Work>
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <cc:license
-           rdf:resource="http://creativecommons.org/licenses/publicdomain/" />
-        <dc:publisher>
-          <cc:Agent
-             rdf:about="http://openclipart.org/">
-            <dc:title>Openclipart</dc:title>
-          </cc:Agent>
-        </dc:publisher>
-        <dc:title></dc:title>
-        <dc:date>2010-03-29T08:04:16</dc:date>
-        <dc:description>&quot;E-mail&quot; icon from &lt;a href=&quot;http://tango.freedesktop.org/Tango_Desktop_Project&quot;&gt; Tango Project &lt;/a&gt; 
-\n&lt;br&gt;&lt;br&gt;
-\nSince version 0.8.90 Tango Project icons are Public Domain: &lt;a href=&quot;http://tango.freedesktop.org/Frequently_Asked_Questions#Terms_of_Use.3F&quot;&gt; Tango Project FAQ &lt;/a&gt;</dc:description>
-        <dc:source>https://openclipart.org/detail/35215/tango-internet-mail-by-warszawianka</dc:source>
-        <dc:creator>
-          <cc:Agent>
-            <dc:title>warszawianka</dc:title>
-          </cc:Agent>
-        </dc:creator>
-        <dc:subject>
-          <rdf:Bag>
-            <rdf:li>email</rdf:li>
-            <rdf:li>envelope</rdf:li>
-            <rdf:li>externalsource</rdf:li>
-            <rdf:li>icon</rdf:li>
-            <rdf:li>letter</rdf:li>
-            <rdf:li>tango</rdf:li>
-          </rdf:Bag>
-        </dc:subject>
-      </cc:Work>
-      <cc:License
-         rdf:about="http://creativecommons.org/licenses/publicdomain/">
-        <cc:permits
-           rdf:resource="http://creativecommons.org/ns#Reproduction" />
-        <cc:permits
-           rdf:resource="http://creativecommons.org/ns#Distribution" />
-        <cc:permits
-           rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
-      </cc:License>
-    </rdf:RDF>
-  </metadata>
-</svg>
index f0d91bf8976b2c07446e94e1b3f359bb2eab9e6b..2e5bccd17d63aee71b49f59b156cc7c6cccf3f0e 100755 (executable)
@@ -63,7 +63,7 @@ else
     # OS X preferences icons
     # servers.png does not have an SVG version
     mkdir -p osx/preferences
-    for i in colour_conversions defaults email kdm_email cover_sheet keys tms notifications accounts locations sound; do
+    for i in colour_conversions defaults email kdm_email cover_sheet keys tms notifications locations sound; do
        $INKSCAPE osx/preferences/$i.png src/$i.svg -w 32 -h 32
     done
 
index fa92400509648e85c396ff6a7e9031e87eafc7b4..7a9542fd74099de6104a67e2f254c0153426d698 100644 (file)
@@ -195,7 +195,6 @@ function copy_resources {
     cp $prefix/src/dcpomatic/graphics/osx/preferences/keys.png "$dest"
     cp $prefix/src/dcpomatic/graphics/osx/preferences/cover_sheet.png "$dest"
     cp $prefix/src/dcpomatic/graphics/osx/preferences/notifications.png "$dest"
-    cp $prefix/src/dcpomatic/graphics/osx/preferences/accounts.png "$dest"
     cp $prefix/src/dcpomatic/graphics/osx/preferences/locations.png "$dest"
     cp $prefix/src/dcpomatic/fonts/LiberationSans-Regular.ttf "$dest"
     cp $prefix/src/dcpomatic/fonts/LiberationSans-Italic.ttf "$dest"
index 84048c65cf98d97b767577668d14e489e9dad93c..47dd85e0705a03b9ce87d2cb482cb508a705a62c 100644 (file)
@@ -29,7 +29,15 @@ using std::string;
 using boost::optional;
 
 BarcoAlchemyCertificatePanel::BarcoAlchemyCertificatePanel (DownloadCertificateDialog* dialog)
-       : DownloadCertificatePanel (dialog)
+       : CredentialsDownloadCertificatePanel (
+                       dialog,
+                       boost::bind(&Config::barco_username, Config::instance()),
+                       boost::bind(&Config::set_barco_username, Config::instance(), _1),
+                       boost::bind(&Config::unset_barco_username, Config::instance()),
+                       boost::bind(&Config::barco_password, Config::instance()),
+                       boost::bind(&Config::set_barco_password, Config::instance(), _1),
+                       boost::bind(&Config::unset_barco_password, Config::instance())
+                       )
 {
 
 }
@@ -37,19 +45,12 @@ BarcoAlchemyCertificatePanel::BarcoAlchemyCertificatePanel (DownloadCertificateD
 bool
 BarcoAlchemyCertificatePanel::ready_to_download () const
 {
-       return _serial->GetValue().Length() == 10;
+       return CredentialsDownloadCertificatePanel::ready_to_download() && _serial->GetValue().Length() == 10;
 }
 
 void
 BarcoAlchemyCertificatePanel::do_download ()
 {
-       Config* config = Config::instance ();
-       if (!config->barco_username() || !config->barco_password()) {
-               _dialog->message()->SetLabel(wxT(""));
-               error_dialog (this, _("No Barco username/password configured.  Add your account details to the Accounts page in Preferences."));
-               return;
-       }
-
        string const serial = wx_to_std (_serial->GetValue());
        string const url = String::compose (
                "ftp://%1:%2@certificates.barco.com/%3xxx/%4/Barco-ICMP.%5_cert.pem",
index 83a74fa214c5b063cee77688f1525fa7ad66aab8..fce7d3f5d6543aa3387c48d50b519918a2026a92 100644 (file)
@@ -18,9 +18,9 @@
 
 */
 
-#include "download_certificate_panel.h"
+#include "credentials_download_certificate_panel.h"
 
-class BarcoAlchemyCertificatePanel : public DownloadCertificatePanel
+class BarcoAlchemyCertificatePanel : public CredentialsDownloadCertificatePanel
 {
 public:
        BarcoAlchemyCertificatePanel (DownloadCertificateDialog* dialog);
index 9e95aa994531a728a989d153b560bb25e2cd6652..7db3fef2500303e226d1202e44cc30ad7f340369 100644 (file)
 
 using std::string;
 using boost::optional;
+using boost::bind;
 
 ChristieCertificatePanel::ChristieCertificatePanel (DownloadCertificateDialog* dialog)
-       : DownloadCertificatePanel (dialog)
+       : CredentialsDownloadCertificatePanel (
+                       dialog,
+                       bind(&Config::christie_username, Config::instance()),
+                       bind(&Config::set_christie_username, Config::instance(), _1),
+                       bind(&Config::unset_christie_username, Config::instance()),
+                       bind(&Config::christie_password, Config::instance()),
+                       bind(&Config::set_christie_password, Config::instance(), _1),
+                       bind(&Config::unset_christie_password, Config::instance())
+                       )
+
 {
 
 }
@@ -37,13 +47,6 @@ ChristieCertificatePanel::ChristieCertificatePanel (DownloadCertificateDialog* d
 void
 ChristieCertificatePanel::do_download ()
 {
-       Config* config = Config::instance ();
-       if (!config->christie_username() || !config->christie_password()) {
-               _dialog->message()->SetLabel(wxT(""));
-               error_dialog (this, _("No Christie username/password configured.  Add your account details to the Accounts page in Preferences."));
-               return;
-       }
-
        string const prefix = String::compose(
                "ftp://%1:%2@certificates.christiedigital.com/Certificates/",
                Config::instance()->christie_username().get(),
index 0c9a64d4600e0739c0306919c29f343963123218..41278cb7c6c3d83e5c3590647d1b771cbb15eba9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -18,9 +18,9 @@
 
 */
 
-#include "download_certificate_panel.h"
+#include "credentials_download_certificate_panel.h"
 
-class ChristieCertificatePanel : public DownloadCertificatePanel
+class ChristieCertificatePanel : public CredentialsDownloadCertificatePanel
 {
 public:
        ChristieCertificatePanel (DownloadCertificateDialog* dialog);
diff --git a/src/wx/credentials_download_certificate_panel.cc b/src/wx/credentials_download_certificate_panel.cc
new file mode 100644 (file)
index 0000000..fb49082
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+    Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "download_certificate_dialog.h"
+#include "credentials_download_certificate_panel.h"
+#include "password_entry.h"
+#include "wx_util.h"
+
+using std::string;
+using boost::function;
+using boost::optional;
+
+CredentialsDownloadCertificatePanel::CredentialsDownloadCertificatePanel (
+               DownloadCertificateDialog* dialog,
+               function<optional<string> ()> get_username,
+               function<void (string)> set_username,
+               function<void ()> unset_username,
+               function<optional<string> ()> get_password,
+               function<void (string)> set_password,
+               function<void ()> unset_password
+               )
+       : DownloadCertificatePanel (dialog)
+       , _get_username (get_username)
+       , _set_username (set_username)
+       , _unset_username (unset_username)
+       , _get_password (get_password)
+       , _set_password (set_password)
+       , _unset_password (unset_password)
+{
+       add_label_to_sizer (_table, this, _("User name"), true);
+       _username = new wxTextCtrl (this, wxID_ANY, std_to_wx(_get_username().get_value_or("")), wxDefaultPosition, wxSize(300, -1));
+       _table->Add (_username, 1, wxEXPAND);
+
+       add_label_to_sizer (_table, this, _("Password"), true);
+       _password = new PasswordEntry (this);
+       _password->set (_get_password().get_value_or(""));
+       _table->Add (_password->get_panel(), 1, wxEXPAND);
+
+       _username->Bind (wxEVT_TEXT, boost::bind(&CredentialsDownloadCertificatePanel::username_changed, this));
+       _password->Changed.connect (boost::bind(&CredentialsDownloadCertificatePanel::password_changed, this));
+
+       _overall_sizer->Layout ();
+       _overall_sizer->SetSizeHints (this);
+}
+
+bool
+CredentialsDownloadCertificatePanel::ready_to_download () const
+{
+       return DownloadCertificatePanel::ready_to_download() && static_cast<bool>(_get_username()) && _get_username().get() != "" && static_cast<bool>(_get_password()) && _get_password().get() != "";
+}
+
+void
+CredentialsDownloadCertificatePanel::username_changed ()
+{
+       wxString const s = _username->GetValue();
+       if (!s.IsEmpty()) {
+               _set_username (wx_to_std(s));
+       } else {
+               _unset_username ();
+       }
+       _dialog->setup_sensitivity ();
+}
+
+void
+CredentialsDownloadCertificatePanel::password_changed ()
+{
+       string const s = _password->get();
+       if (!s.empty()) {
+               _set_password (s);
+       } else {
+               _unset_password ();
+       }
+       _dialog->setup_sensitivity ();
+}
+
diff --git a/src/wx/credentials_download_certificate_panel.h b/src/wx/credentials_download_certificate_panel.h
new file mode 100644 (file)
index 0000000..6847246
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+    Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef CREDENTIALS_DOWNLOAD_CERTIFICATE_PANEL_H
+#define CREDENTIALS_DOWNLOAD_CERTIFICATE_PANEL_H
+
+#include "download_certificate_panel.h"
+#include <boost/function.hpp>
+
+class PasswordEntry;
+
+class CredentialsDownloadCertificatePanel : public DownloadCertificatePanel
+{
+public:
+       CredentialsDownloadCertificatePanel (
+                       DownloadCertificateDialog* dialog,
+                       boost::function<boost::optional<std::string> ()> get_username,
+                       boost::function<void (std::string)> set_username,
+                       boost::function<void ()> unset_username,
+                       boost::function<boost::optional<std::string> ()> get_password,
+                       boost::function<void (std::string)> set_password,
+                       boost::function<void ()> unset_password
+                       );
+
+       virtual bool ready_to_download () const;
+
+private:
+       void username_changed ();
+       void password_changed ();
+
+       boost::function<boost::optional<std::string> (void)> _get_username;
+       boost::function<void (std::string)> _set_username;
+       boost::function<void ()> _unset_username;
+       boost::function<boost::optional<std::string> (void)> _get_password;
+       boost::function<void (std::string)> _set_password;
+       boost::function<void ()> _unset_password;
+
+       wxTextCtrl* _username;
+       PasswordEntry* _password;
+};
+
+#endif
index 180c132789312ca5c04c92c42f063184d8a009d0..a2fbf808f768b39c77e5f56a1e9e7ea0cff57ac9 100644 (file)
@@ -18,6 +18,7 @@
 
 */
 
+#include <dcp/certificate.h>
 #include <wx/wx.h>
 #include <wx/notebook.h>
 
index 55594c74c66b6f1df48a43d927608594f54e6c93..d1f0bf4defbbaac96ec55a772d1ddf757f0920cc 100644 (file)
@@ -44,9 +44,9 @@ protected:
        DownloadCertificateDialog* _dialog;
        wxFlexGridSizer* _table;
        wxTextCtrl* _serial;
+       wxSizer* _overall_sizer;
 
 private:
-       wxSizer* _overall_sizer;
        boost::optional<dcp::Certificate> _certificate;
 };
 
index f586672a8e6d60fc6fa76ce8ec2dc095aa415d8e..ce199e58aae87b3975e3210c65caba1d66cc097a 100644 (file)
@@ -981,145 +981,6 @@ private:
        wxButton* _reset_email;
 };
 
-class AccountsPage : public StandardPage
-{
-public:
-       AccountsPage (wxSize panel_size, int border)
-               : StandardPage (panel_size, border)
-       {}
-
-       wxString GetName () const
-       {
-               return _("Accounts");
-       }
-
-#ifdef DCPOMATIC_OSX
-       wxBitmap GetLargeIcon () const
-       {
-               return wxBitmap ("accounts", wxBITMAP_TYPE_PNG_RESOURCE);
-       }
-#endif
-
-       void setup ()
-       {
-               wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
-               table->AddGrowableCol (1, 1);
-               _panel->GetSizer()->Add (table, 1, wxEXPAND | wxALL, _border);
-
-               add_label_to_sizer (table, _panel, _("certificates.barco.com user name"), true);
-               _barco_username = new wxTextCtrl (_panel, wxID_ANY);
-               table->Add (_barco_username, 1, wxEXPAND | wxALL);
-
-               add_label_to_sizer (table, _panel, _("certificates.barco.com password"), true);
-               _barco_password = new PasswordEntry (_panel);
-               table->Add (_barco_password->get_panel(), 1, wxEXPAND | wxALL);
-
-               add_label_to_sizer (table, _panel, _("certificates.christiedigital.com user name"), true);
-               _christie_username = new wxTextCtrl (_panel, wxID_ANY);
-               table->Add (_christie_username, 1, wxEXPAND | wxALL);
-
-               add_label_to_sizer (table, _panel, _("certificates.christiedigital.com password"), true);
-               _christie_password = new PasswordEntry (_panel);
-               table->Add (_christie_password->get_panel(), 1, wxEXPAND | wxALL);
-
-               add_label_to_sizer (table, _panel, _("GDC user name"), true);
-               _gdc_username = new wxTextCtrl (_panel, wxID_ANY);
-               table->Add (_gdc_username, 1, wxEXPAND | wxALL);
-
-               add_label_to_sizer (table, _panel, _("GDC password"), true);
-               _gdc_password = new PasswordEntry (_panel);
-               table->Add (_gdc_password->get_panel(), 1, wxEXPAND | wxALL);
-
-               _barco_username->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::barco_username_changed, this));
-               _barco_password->Changed.connect (boost::bind(&AccountsPage::barco_password_changed, this));
-               _christie_username->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::christie_username_changed, this));
-               _christie_password->Changed.connect (boost::bind(&AccountsPage::christie_password_changed, this));
-               _gdc_username->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::gdc_username_changed, this));
-               _gdc_password->Changed.connect (boost::bind(&AccountsPage::gdc_password_changed, this));
-       }
-
-       void config_changed ()
-       {
-               Config* config = Config::instance ();
-
-               checked_set (_barco_username, config->barco_username().get_value_or(""));
-               checked_set (_barco_password, config->barco_password().get_value_or(""));
-               checked_set (_christie_username, config->christie_username().get_value_or(""));
-               checked_set (_christie_password, config->christie_password().get_value_or(""));
-               checked_set (_gdc_username, config->gdc_username().get_value_or(""));
-               checked_set (_gdc_password, config->gdc_password().get_value_or(""));
-       }
-
-       void barco_username_changed ()
-       {
-               wxString const s = _barco_username->GetValue();
-               if (!s.IsEmpty()) {
-                       Config::instance()->set_barco_username (wx_to_std(s));
-               } else {
-                       Config::instance()->unset_barco_username ();
-               }
-       }
-
-       void barco_password_changed ()
-       {
-               string const s = _barco_password->get();
-               if (!s.empty()) {
-                       Config::instance()->set_barco_password(s);
-               } else {
-                       Config::instance()->unset_barco_password();
-               }
-       }
-
-       void christie_username_changed ()
-       {
-               wxString const s = _christie_username->GetValue();
-               if (!s.IsEmpty()) {
-                       Config::instance()->set_christie_username (wx_to_std(s));
-               } else {
-                       Config::instance()->unset_christie_username ();
-               }
-       }
-
-       void christie_password_changed ()
-       {
-               string const s = _christie_password->get();
-               if (!s.empty()) {
-                       Config::instance()->set_christie_password(s);
-               } else {
-                       Config::instance()->unset_christie_password();
-               }
-       }
-
-       void gdc_username_changed ()
-       {
-               wxString const s = _gdc_username->GetValue();
-               if (!s.IsEmpty()) {
-                       Config::instance()->set_gdc_username (wx_to_std(s));
-               } else {
-                       Config::instance()->unset_gdc_username ();
-               }
-       }
-
-       void gdc_password_changed ()
-       {
-               string const s = _gdc_password->get();
-               if (!s.empty()) {
-                       Config::instance()->set_gdc_password(s);
-               } else {
-                       Config::instance()->unset_gdc_password();
-               }
-       }
-
-private:
-       wxTextCtrl* _barco_username;
-       PasswordEntry* _barco_password;
-       wxTextCtrl* _christie_username;
-       PasswordEntry* _christie_password;
-       wxTextCtrl* _gdc_username;
-       PasswordEntry* _gdc_password;
-};
-
-
 class NotificationsPage : public StandardPage
 {
 public:
@@ -1683,7 +1544,6 @@ create_full_config_dialog ()
        e->AddPage (new TMSPage (ps, border));
        e->AddPage (new EmailPage (ps, border));
        e->AddPage (new KDMEmailPage (ps, border));
-       e->AddPage (new AccountsPage (ps, border));
        e->AddPage (new NotificationsPage (ps, border));
        e->AddPage (new CoverSheetPage (ps, border));
        e->AddPage (new AdvancedPage (ps, border));
index b0bb31674458fc7711a7c6bf634660f1ba73dcb9..a4301087dea1980f1dcda2f8c7990214a7206fe9 100644 (file)
 
 using std::string;
 using boost::optional;
+using boost::bind;
 
 GDCCertificatePanel::GDCCertificatePanel (DownloadCertificateDialog* dialog)
-       : DownloadCertificatePanel (dialog)
+       : CredentialsDownloadCertificatePanel (
+                       dialog,
+                       bind(&Config::gdc_username, Config::instance()),
+                       bind(&Config::set_gdc_username, Config::instance(), _1),
+                       bind(&Config::unset_gdc_username, Config::instance()),
+                       bind(&Config::gdc_password, Config::instance()),
+                       bind(&Config::set_gdc_password, Config::instance(), _1),
+                       bind(&Config::unset_gdc_password, Config::instance())
+                       )
 {
 
 }
@@ -37,13 +46,6 @@ GDCCertificatePanel::GDCCertificatePanel (DownloadCertificateDialog* dialog)
 void
 GDCCertificatePanel::do_download ()
 {
-       Config* config = Config::instance ();
-       if (!config->gdc_username() || !config->gdc_password()) {
-               _dialog->message()->SetLabel(wxT(""));
-               error_dialog (this, _("No GDC username/password configured.  Add your account details to the Accounts page in Preferences."));
-               return;
-       }
-
        string const url = String::compose(
                "ftp://%1:%2@ftp.gdc-tech.com/SHA256/A%3.crt.pem",
                Config::instance()->gdc_username().get(),
index 18a78e586b54986e7b1662bddc96595c9488f0c7..b69c7a51fdab3fd7ca74284540428d352e8830db 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -18,9 +18,9 @@
 
 */
 
-#include "download_certificate_panel.h"
+#include "credentials_download_certificate_panel.h"
 
-class GDCCertificatePanel : public DownloadCertificatePanel
+class GDCCertificatePanel : public CredentialsDownloadCertificatePanel
 {
 public:
        GDCCertificatePanel (DownloadCertificateDialog* dialog);
index b04054a7758711e63c08073e40d892efcc23077c..f4fc4927e31562f8105a3ada3ac65e076e11755d 100644 (file)
@@ -48,6 +48,7 @@ sources = """
           content_view.cc
           controls.cc
           closed_captions_dialog.cc
+          credentials_download_certificate_panel.cc
           dcp_panel.cc
           dcpomatic_button.cc
           email_dialog.cc