Remove configuration of servers.
authorCarl Hetherington <cth@carlh.net>
Wed, 6 Nov 2013 18:00:53 +0000 (18:00 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 6 Nov 2013 18:00:53 +0000 (18:00 +0000)
15 files changed:
src/lib/config.cc
src/lib/config.h
src/lib/encoder.cc
src/lib/server.cc
src/lib/server.h
src/lib/server_finder.cc
src/lib/server_finder.h
src/tools/dcpomatic_cli.cc
src/wx/config_dialog.cc
src/wx/config_dialog.h
src/wx/server_dialog.cc [deleted file]
src/wx/server_dialog.h [deleted file]
src/wx/servers_list_dialog.h
src/wx/wscript
test/test.cc

index 02feecce89173ea0e03d73e3376bca9ca7858b30..1a7c64405d88e5ae25a3346373b3884e4a5eb0fc 100644 (file)
@@ -102,11 +102,6 @@ Config::read ()
        }
        _server_port_base = b.get ();
        
-       list<shared_ptr<cxml::Node> > servers = f.node_children ("Server");
-       for (list<shared_ptr<cxml::Node> >::iterator i = servers.begin(); i != servers.end(); ++i) {
-               _servers.push_back (ServerDescription (*i));
-       }
-
        _tms_ip = f.string_child ("TMSIP");
        _tms_path = f.string_child ("TMSPath");
        _tms_user = f.string_child ("TMSUser");
@@ -197,11 +192,6 @@ Config::read_old_metadata ()
                        _default_directory = v;
                } else if (k == N_("server_port")) {
                        _server_port_base = atoi (v.c_str ());
-               } else if (k == N_("server")) {
-                       optional<ServerDescription> server = ServerDescription::create_from_metadata (v);
-                       if (server) {
-                               _servers.push_back (server.get ());
-                       }
                } else if (k == N_("tms_ip")) {
                        _tms_ip = v;
                } else if (k == N_("tms_path")) {
@@ -293,11 +283,6 @@ Config::write () const
        root->add_child("NumLocalEncodingThreads")->add_child_text (lexical_cast<string> (_num_local_encoding_threads));
        root->add_child("DefaultDirectory")->add_child_text (_default_directory.string ());
        root->add_child("ServerPortBase")->add_child_text (lexical_cast<string> (_server_port_base));
-       
-       for (vector<ServerDescription>::const_iterator i = _servers.begin(); i != _servers.end(); ++i) {
-               i->as_xml (root->add_child ("Server"));
-       }
-
        root->add_child("TMSIP")->add_child_text (_tms_ip);
        root->add_child("TMSPath")->add_child_text (_tms_path);
        root->add_child("TMSUser")->add_child_text (_tms_user);
@@ -334,9 +319,7 @@ Config::write () const
        root->add_child("KDMFrom")->add_child_text (_kdm_from);
        root->add_child("KDMEmail")->add_child_text (_kdm_email);
 
-       std::cout << "dcpomatic: writing configuration to " << file(false).string() << "\n";
        doc.write_to_file_formatted (file(false).string ());
-       std::cout << "dcpomatic: wrote configuration to " << file(false).string() << "\n";
 }
 
 boost::filesystem::path
index 07b3d68910edce82281a7295132cd85e60f32364..0dcfd3f58b9593e420661652928e7885de3cd765 100644 (file)
@@ -31,9 +31,7 @@
 #include <libdcp/metadata.h>
 #include "dci_metadata.h"
 #include "colour_conversion.h"
-#include "server.h"
 
-class ServerDescription;
 class Scaler;
 class Filter;
 class SoundProcessor;
@@ -64,11 +62,6 @@ public:
                return _server_port_base;
        }
 
-       /** @return J2K encoding servers to use */
-       std::vector<ServerDescription> servers () const {
-               return _servers;
-       }
-
        /** @return The IP address of a TMS that we can copy DCPs to */
        std::string tms_ip () const {
                return _tms_ip;
@@ -160,11 +153,6 @@ public:
                _server_port_base = p;
        }
 
-       /** @param s New list of servers */
-       void set_servers (std::vector<ServerDescription> s) {
-               _servers = s;
-       }
-
        void set_reference_scaler (Scaler const * s) {
                _reference_scaler = s;
        }
@@ -274,9 +262,6 @@ private:
         *  this port and the one above it will be used.
         */
        int _server_port_base;
-
-       /** J2K encoding servers to use */
-       std::vector<ServerDescription> _servers;
        /** Scaler to use for the "A" part of A/B comparisons */
        Scaler const * _reference_scaler;
        /** Filters to use for the "A" part of A/B comparisons */
index ccaeab18c6ad0f6b9226ecb519421610b5b6c908..eb331551fffb6d6c10dee1e3b96280a72e8f89e4 100644 (file)
@@ -90,12 +90,6 @@ Encoder::process_begin ()
                _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<ServerDescription> ())));
        }
 
-       vector<ServerDescription> servers = Config::instance()->servers ();
-
-       for (vector<ServerDescription>::iterator i = servers.begin(); i != servers.end(); ++i) {
-               add_worker_threads (*i);
-       }
-
        _writer.reset (new Writer (_film, _job));
        ServerFinder::instance()->connect (boost::bind (&Encoder::server_found, this, _1));
 }
index 2930e3c4b6381f83597776a8d4708ba760930d83..1f3f61e425a0392b791453245e0fcd6b2cd7b671 100644 (file)
@@ -59,36 +59,6 @@ using boost::optional;
 using boost::lexical_cast;
 using libdcp::Size;
 
-ServerDescription::ServerDescription (shared_ptr<const cxml::Node> node)
-{
-       _host_name = node->string_child ("HostName");
-       _threads = node->number_child<int> ("Threads");
-}
-
-void
-ServerDescription::as_xml (xmlpp::Node* root) const
-{
-       root->add_child("HostName")->add_child_text (_host_name);
-       root->add_child("Threads")->add_child_text (boost::lexical_cast<string> (_threads));
-}
-
-/** Create a server description from a string of metadata returned from as_metadata().
- *  @param v Metadata.
- *  @return ServerDescription, or 0.
- */
-optional<ServerDescription>
-ServerDescription::create_from_metadata (string v)
-{
-       vector<string> b;
-       split (b, v, is_any_of (" "));
-
-       if (b.size() != 2) {
-               return optional<ServerDescription> ();
-       }
-
-       return ServerDescription (b[0], atoi (b[1].c_str ()));
-}
-
 Server::Server (shared_ptr<Log> log, bool verbose)
        : _log (log)
        , _verbose (verbose)
index 9be47bd944fadbb94c8a3b1f63a01a4f91642610..a9b4b1c1c8982ed9d57c615c9cee6fcfd9df0324 100644 (file)
@@ -59,8 +59,6 @@ public:
                , _threads (t)
        {}
 
-       ServerDescription (boost::shared_ptr<const cxml::Node>);
-
        /* Default copy constructor is fine */
        
        /** @return server's host name or IP address in string form */
@@ -81,10 +79,6 @@ public:
                _threads = t;
        }
 
-       void as_xml (xmlpp::Node *) const;
-       
-       static boost::optional<ServerDescription> create_from_metadata (std::string);
-
 private:
        /** server's host name */
        std::string _host_name;
index 56f52b7fc292d9510d0b77a0264ca68ef8fede41..941caf4d97b3f50e94c8f849b4a0187937b93d3e 100644 (file)
@@ -34,7 +34,8 @@ using boost::scoped_array;
 ServerFinder* ServerFinder::_instance = 0;
 
 ServerFinder::ServerFinder ()
-       : _broadcast_thread (0)
+       : _disabled (false)
+       , _broadcast_thread (0)
        , _listen_thread (0)
 {
        _broadcast_thread = new boost::thread (boost::bind (&ServerFinder::broadcast_thread, this));
@@ -103,6 +104,10 @@ ServerFinder::listen_thread ()
 void
 ServerFinder::connect (boost::function<void (ServerDescription)> fn)
 {
+       if (_disabled) {
+               return;
+       }
+       
        boost::mutex::scoped_lock lm (_mutex);
 
        /* Emit the current list of servers */
index 04a7786cf4442a255268660a93a9673626f4dcc8..f964d4e1abf5df854c69bc908380929b05c1daed 100644 (file)
@@ -27,6 +27,10 @@ public:
 
        static ServerFinder* instance ();
 
+       void disable () {
+               _disabled = true;
+       }
+
 private:
        ServerFinder ();
 
@@ -34,6 +38,8 @@ private:
        void listen_thread ();
 
        boost::signals2::signal<void (ServerDescription)> ServerFound;
+
+       bool _disabled;
        
        /** Thread to periodically issue broadcasts to find encoding servers */
        boost::thread* _broadcast_thread;
index 51248fde7f613c543db955ca60ca30eb75dbb4fa..1f3d47fe84d1cb1b129de4fe084d2bc365b5b047 100644 (file)
@@ -32,6 +32,7 @@
 #include "lib/config.h"
 #include "lib/log.h"
 #include "lib/ui_signaller.h"
+#include "lib/server_finder.h"
 
 using std::string;
 using std::cerr;
@@ -118,7 +119,7 @@ main (int argc, char* argv[])
        ui_signaller = new UISignaller ();
 
        if (no_remote) {
-               Config::instance()->set_servers (vector<ServerDescription> ());
+               ServerFinder::instance()->disable ();
        }
 
        cout << "DCP-o-matic " << dcpomatic_version << " git " << dcpomatic_git_commit;
index 5479c22cee8857955cc321208264a05ca764e194..0428f302fc8617d5cfad341c40e874c319c41757 100644 (file)
@@ -28,7 +28,6 @@
 #include <wx/notebook.h>
 #include <libdcp/colour_matrix.h>
 #include "lib/config.h"
-#include "lib/server.h"
 #include "lib/ratio.h"
 #include "lib/scaler.h"
 #include "lib/filter.h"
@@ -37,7 +36,6 @@
 #include "config_dialog.h"
 #include "wx_util.h"
 #include "filter_dialog.h"
-#include "server_dialog.h"
 #include "dir_picker_ctrl.h"
 #include "dci_metadata_dialog.h"
 #include "preset_colour_conversion_dialog.h"
@@ -58,8 +56,6 @@ ConfigDialog::ConfigDialog (wxWindow* parent)
 
        make_misc_panel ();
        _notebook->AddPage (_misc_panel, _("Miscellaneous"), true);
-       make_servers_panel ();
-       _notebook->AddPage (_servers_panel, _("Encoding servers"), false);
        make_colour_conversions_panel ();
        _notebook->AddPage (_colour_conversions_panel, _("Colour conversions"), false);
        make_metadata_panel ();
@@ -294,34 +290,6 @@ ConfigDialog::make_metadata_panel ()
        _creator->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ConfigDialog::creator_changed, this));
 }
 
-static std::string
-server_column (ServerDescription s, int c)
-{
-       switch (c) {
-       case 0:
-               return s.host_name ();
-       case 1:
-               return lexical_cast<string> (s.threads ());
-       }
-
-       return "";
-}
-
-void
-ConfigDialog::make_servers_panel ()
-{
-       vector<string> columns;
-       columns.push_back (wx_to_std (_("IP address")));
-       columns.push_back (wx_to_std (_("Threads")));
-       _servers_panel = new EditableList<ServerDescription, ServerDialog> (
-               _notebook,
-               columns,
-               boost::bind (&Config::servers, Config::instance()),
-               boost::bind (&Config::set_servers, Config::instance(), _1),
-               boost::bind (&server_column, _1, _2)
-               );
-}
-
 void
 ConfigDialog::language_changed ()
 {
index b1a59e8b9d4161d0a646ed0d62d552bde8aebbdb..2492f4899bdb7d90251bd50cf8d8eb6fd52ce7af 100644 (file)
 
 class DirPickerCtrl;
 class wxNotebook;
-class ServerDescription;
 class PresetColourConversion;
 class PresetColourConversionDialog;
-class ServerDialog;
 
 /** @class ConfigDialog
  *  @brief A dialogue to edit DCP-o-matic configuration.
@@ -68,7 +66,6 @@ private:
        void make_misc_panel ();
        void make_tms_panel ();
        void make_metadata_panel ();
-       void make_servers_panel ();
        void make_colour_conversions_panel ();
        void make_kdm_email_panel ();
 
@@ -76,7 +73,6 @@ private:
        wxPanel* _misc_panel;
        wxPanel* _tms_panel;
        EditableList<PresetColourConversion, PresetColourConversionDialog>* _colour_conversions_panel;
-       EditableList<ServerDescription, ServerDialog>* _servers_panel;
        wxPanel* _metadata_panel;
        wxCheckBox* _set_language;
        wxChoice* _language;
diff --git a/src/wx/server_dialog.cc b/src/wx/server_dialog.cc
deleted file mode 100644 (file)
index c1dbc4b..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
-    This program 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.
-
-    This program 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 this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "lib/server.h"
-#include "server_dialog.h"
-#include "wx_util.h"
-
-using boost::shared_ptr;
-
-ServerDialog::ServerDialog (wxWindow* parent)
-       : wxDialog (parent, wxID_ANY, _("Server"))
-{
-       wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
-       table->AddGrowableCol (1, 1);
-
-        wxClientDC dc (parent);
-       /* XXX: bit of a mystery why we need such a long string here */
-        wxSize size = dc.GetTextExtent (wxT ("255.255.255.255.255.255.255.255"));
-        size.SetHeight (-1);
-
-        wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
-        wxArrayString list;
-
-       add_label_to_sizer (table, this, _("Host name or IP address"), true);
-       _host = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, size);
-       table->Add (_host, 1, wxEXPAND | wxALL);
-
-       add_label_to_sizer (table, this, _("Threads to use"), true);
-       _threads = new wxSpinCtrl (this, wxID_ANY);
-       table->Add (_threads, 1, wxEXPAND);
-
-       _threads->SetRange (0, 256);
-
-       wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
-       overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-
-       wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
-       if (buttons) {
-               overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
-       }
-
-       SetSizer (overall_sizer);
-       overall_sizer->Layout ();
-       overall_sizer->SetSizeHints (this);
-}
-
-void
-ServerDialog::set (ServerDescription server)
-{
-       _host->SetValue (std_to_wx (server.host_name ()));
-       _threads->SetValue (server.threads ());
-}
-
-ServerDescription
-ServerDialog::get () const
-{
-       ServerDescription server;
-       server.set_host_name (wx_to_std (_host->GetValue ()));
-       server.set_threads (_threads->GetValue ());
-       return server;
-}
-
diff --git a/src/wx/server_dialog.h b/src/wx/server_dialog.h
deleted file mode 100644 (file)
index a6f48fe..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
-    This program 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.
-
-    This program 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 this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include <wx/wx.h>
-#include <wx/spinctrl.h>
-
-class ServerDescription;
-
-class ServerDialog : public wxDialog
-{
-public:
-       ServerDialog (wxWindow *);
-
-       void set (ServerDescription);
-       ServerDescription get () const;
-
-private:
-       wxTextCtrl* _host;
-       wxSpinCtrl* _threads;
-};
index 63f1cd6a9b87c2330af12d04d26385a45b16c7e8..27a3c55cb0d302ccf6b12b169bb74c657f1998ae 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <wx/wx.h>
 #include <wx/listctrl.h>
+#include "lib/server.h"
 
 class ServersListDialog : public wxDialog
 {
index c86188c6aded9c93ffe2c1ac68ce44a5227401a0..85bb697ab915a3e67a9894477a6ade5a98235421 100644 (file)
@@ -30,7 +30,6 @@ sources = """
           properties_dialog.cc
           repeat_dialog.cc
           screen_dialog.cc
-          server_dialog.cc
           servers_list_dialog.cc
           subtitle_panel.cc
           timecode.cc
index 473626fac8a313a80d6235b19a54bbdc9bdab876..6adb56e8f66d26da498921a880201ffbc1ca1595 100644 (file)
@@ -28,6 +28,7 @@
 #include "lib/job_manager.h"
 #include "lib/job.h"
 #include "lib/cross.h"
+#include "lib/server_finder.h"
 #define BOOST_TEST_DYN_LINK
 #define BOOST_TEST_MODULE dcpomatic_test
 #include <boost/test/unit_test.hpp>
@@ -57,12 +58,13 @@ struct TestConfig
                dcpomatic_setup();
 
                Config::instance()->set_num_local_encoding_threads (1);
-               Config::instance()->set_servers (vector<ServerDescription> ());
                Config::instance()->set_server_port_base (61920);
                Config::instance()->set_default_dci_metadata (DCIMetadata ());
                Config::instance()->set_default_container (static_cast<Ratio*> (0));
                Config::instance()->set_default_dcp_content_type (static_cast<DCPContentType*> (0));
 
+               ServerFinder::instance()->disable ();
+
                ui_signaller = new TestUISignaller ();
        }
 };