hackz.
authorCarl Hetherington <cth@carlh.net>
Thu, 6 Aug 2020 21:24:11 +0000 (23:24 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 6 Aug 2020 21:24:11 +0000 (23:24 +0200)
src/lib/copy_to_drive_job.cc
src/lib/disk_writer_messages.h
src/lib/nanomsg.h
src/tools/dcpomatic_disk.cc
src/tools/dcpomatic_disk_writer.cc

index e222807f4a68651aa503f987908ae5cab5e4a21a..315d2529d1ec72f4a031a87b5f2bfb809a5962ca 100644 (file)
@@ -53,7 +53,7 @@ CopyToDriveJob::CopyToDriveJob (boost::filesystem::path dcp, Drive drive, Nanoms
 string
 CopyToDriveJob::name () const
 {
-       return String::compose (_("Copying %1 to %2"), _dcp.filename().string(), _drive.description());
+       return String::compose (_("Copying %1\nto %2"), _dcp.filename().string(), _drive.description());
 }
 
 string
index d31a9cb0ad50c8b63455280b4150d77360bbbed1..406afc61da866b36001582e5b374514ce19478f5 100644 (file)
  * by \n.
  */
 
+/* PING */
+
+// Front-end sends:
+
+#define DISK_WRITER_PING "P"
+
+// Back-end responds
+
+#define DISK_WRITER_PONG "O"
+
 /* REQUEST TO WRITE DCP */
 
 // Front-end sends:
index 9bd87098b4814465fd4773a876fb0ef5566464c0..f9951f165907448344f986f385a1c63e82eebd85 100644 (file)
@@ -33,7 +33,7 @@ public:
         *  @return true if the send happened, false if there was a timeout.
         */
        bool send (std::string s, int timeout);
-       
+
        /** Try to receive a message, waiting for some timeout before giving up.
         *  @param timeout Timeout in milliseconds, or -1 for infinite timeout.
         *  @return Empty if the timeout was reached, otherwise the received string.
index c4a04aea8eee6cfe983851c2905698c9a0d772d9..73fb353046491b86bfdae32b4262054008bf8d02 100644 (file)
@@ -222,11 +222,36 @@ private:
                setup_sensitivity ();
        }
 
+
        void copy ()
        {
                DCPOMATIC_ASSERT (_drive->GetSelection() != wxNOT_FOUND);
                DCPOMATIC_ASSERT (static_cast<bool>(_dcp_path));
 
+               bool have_writer = true;
+               if (!_nanomsg.send(DISK_WRITER_PING "\n", 2000)) {
+                       have_writer = false;
+               } else {
+                       optional<string> reply = _nanomsg.receive (2000);
+                       if (!reply || *reply != DISK_WRITER_PONG) {
+                               have_writer = false;
+                       }
+               }
+
+               if (!have_writer) {
+#ifdef DCPOMATIC_WINDOWS
+                       MessageDialog* m = new MessageDialog (
+                               this,
+                               _("DCP-o-matic Disk Writer"),
+                               _("Do you see a 'User Account Control' dialogue asking about dcpomatic2_disk_writer.exe?  If so, click 'Yes', then try again.")
+                               );
+                       m->ShowModal ();
+                       m->Destroy ();
+#else
+                       throw CommunicationFailedError ();
+#endif
+               }
+
                Drive const& drive = _drives[_drive->GetSelection()];
                if (drive.mounted()) {
                        TryUnmountDialog* d = new TryUnmountDialog(this, drive.description());
index fa0a7bb7e6094dd398faa72cf5f1aaf5d19e1f69..b95d12a8e6522b5c5bd34567243cc80964a1d823 100644 (file)
@@ -463,6 +463,8 @@ try
 
        if (*s == DISK_WRITER_QUIT) {
                exit (EXIT_SUCCESS);
+       } else if (*s == DISK_WRITER_PING) {
+               nanomsg->send(DISK_WRITER_PONG "\n", LONG_TIMEOUT);
        } else if (*s == DISK_WRITER_UNMOUNT) {
                /* XXX: should do Linux polkit stuff here */
                optional<string> xml_head = nanomsg->receive (LONG_TIMEOUT);