Include trimming.
[dcpomatic.git] / src / tools / dcpomatic_dist.cc
index 433dcd2097a3fc682777d245f352f8513c3bb19d..1720aaa79690da5084343a3999e3b2a13d2acc22 100644 (file)
 #include "lib/job_manager.h"
 #include <wx/wx.h>
 #include <boost/process.hpp>
-#ifdef __WXOSX__
+#ifdef DCPOMATIC_WINDOWS
+#include <boost/process/windows.hpp>
+#endif
+#ifdef DCPOMATIC_OSX
 #include <ApplicationServices/ApplicationServices.h>
 #endif
 
@@ -40,6 +43,7 @@ using std::string;
 using std::exception;
 using std::cout;
 using std::cerr;
+using std::runtime_error;
 using boost::shared_ptr;
 
 class DOMFrame : public wxFrame
@@ -47,6 +51,7 @@ class DOMFrame : public wxFrame
 public:
        explicit DOMFrame (wxString const & title)
                : wxFrame (0, -1, title)
+               , _nanomsg (true)
                , _sizer (new wxBoxSizer(wxVERTICAL))
        {
                /* Use a panel as the only child of the Frame so that we avoid
@@ -96,7 +101,7 @@ public:
                _sizer->Add (grid, 1, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER);
                overall_panel->SetSizer (_sizer);
                Fit ();
-               SetSize (512, GetSize().GetHeight() + 32);
+               SetSize (768, GetSize().GetHeight() + 32);
 
                /* XXX: this is a hack, but I expect we'll need logs and I'm not sure if there's
                 * a better place to put them.
@@ -109,7 +114,14 @@ public:
 
                Bind (wxEVT_SIZE, boost::bind (&DOMFrame::sized, this, _1));
 
-               _writer = new boost::process::child ("dcpomatic2_dist_writer", boost::process::std_in < _to_writer, boost::process::std_out > _from_writer);
+               JobManager::instance()->ActiveJobsChanged.connect(boost::bind(&DOMFrame::setup_sensitivity, this));
+
+#ifdef DCPOMATIC_WINDOWS
+               /* We must use ::shell here, it seems, to avoid error code 740 (related to privilege escalation) */
+               _writer = new boost::process::child (dist_writer_path(), boost::process::shell, boost::process::windows::hide);
+#else
+               _writer = new boost::process::child (dist_writer_path());
+#endif
        }
 
 private:
@@ -148,7 +160,8 @@ private:
                        return;
                }
 
-               JobManager::instance()->add(shared_ptr<Job>(new CopyToDriveJob(*_dcp_path, _drives[_drive->GetSelection()], _to_writer, _from_writer)));
+               JobManager::instance()->add(shared_ptr<Job>(new CopyToDriveJob(*_dcp_path, _drives[_drive->GetSelection()], _nanomsg)));
+               setup_sensitivity ();
        }
 
        void drive_refresh ()
@@ -181,7 +194,7 @@ private:
 
        void setup_sensitivity ()
        {
-               _copy->Enable (static_cast<bool>(_dcp_path) && _drive->GetSelection() != wxNOT_FOUND);
+               _copy->Enable (static_cast<bool>(_dcp_path) && _drive->GetSelection() != wxNOT_FOUND && !JobManager::instance()->work_to_do());
        }
 
        wxStaticText* _dcp_name;
@@ -193,8 +206,7 @@ private:
        boost::optional<boost::filesystem::path> _dcp_path;
        std::vector<Drive> _drives;
        boost::process::child* _writer;
-       boost::process::opstream _to_writer;
-       boost::process::ipstream _from_writer;
+       Nanomsg _nanomsg;
        wxSizer* _sizer;
 };