Move ports around to allow master/server to coexist (#962).
[dcpomatic.git] / src / tools / dcpomatic.cc
index d091512a04a94eed1073d43bf5a99b6570abaaa2..e9a1f652cea81ef535369e8cb82604b855316a06 100644 (file)
@@ -61,6 +61,7 @@
 #include "lib/cinema_kdms.h"
 #include "lib/dcpomatic_socket.h"
 #include "lib/hints.h"
+#include "lib/dcp_content.h"
 #include <dcp/exceptions.h>
 #include <dcp/raw_convert.h>
 #include <wx/generic/aboutdlgg.h>
@@ -495,6 +496,16 @@ private:
                        }
                }
 
+
+               /* Remove any existing DCP if the user agrees */
+               boost::filesystem::path const dcp_dir = _film->dir (_film->dcp_name(), false);
+               if (boost::filesystem::exists (dcp_dir)) {
+                       if (!confirm_dialog (this, wxString::Format (_("Do you want to overwrite the existing DCP %s?"), std_to_wx(dcp_dir.string()).data()))) {
+                               return;
+                       }
+                       boost::filesystem::remove_all (dcp_dir);
+               }
+
                try {
                        /* It seems to make sense to auto-save metadata here, since the make DCP may last
                           a long time, and crashes/power failures are moderately likely.
@@ -548,7 +559,7 @@ private:
                        try {
                                boost::asio::io_service io_service;
                                boost::asio::ip::tcp::resolver resolver (io_service);
-                               boost::asio::ip::tcp::resolver::query query ("127.0.0.1", raw_convert<string> (Config::instance()->server_port_base() + 2));
+                               boost::asio::ip::tcp::resolver::query query ("127.0.0.1", raw_convert<string> (BATCH_JOB_PORT));
                                boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve (query);
                                Socket socket (5);
                                socket.connect (*endpoint_iterator);
@@ -1029,7 +1040,8 @@ private:
 
 static const wxCmdLineEntryDesc command_line_description[] = {
        { wxCMD_LINE_SWITCH, "n", "new", "create new film", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
-       { wxCMD_LINE_OPTION, "c", "content", "add content file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
+       { wxCMD_LINE_OPTION, "c", "content", "add content file / directory", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
+       { wxCMD_LINE_OPTION, "d", "dcp", "add content DCP", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
        { wxCMD_LINE_PARAM, 0, 0, "film to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
        { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
 };
@@ -1127,6 +1139,9 @@ private:
                                        _frame->film()->examine_and_add_content (i);
                                }
                        }
+                       if (!_dcp_to_add.empty ()) {
+                               _frame->film()->examine_and_add_content (shared_ptr<DCPContent> (new DCPContent (_frame->film(), _dcp_to_add)));
+                       }
                }
 
                signal_manager = new wxSignalManager (this);
@@ -1169,6 +1184,11 @@ private:
                        _content_to_add = wx_to_std (content);
                }
 
+               wxString dcp;
+               if (parser.Found (wxT ("dcp"), &dcp)) {
+                       _dcp_to_add = wx_to_std (dcp);
+               }
+
                return true;
        }
 
@@ -1235,6 +1255,7 @@ private:
        string _film_to_load;
        string _film_to_create;
        string _content_to_add;
+       string _dcp_to_add;
 };
 
 IMPLEMENT_APP (App)