From: Carl Hetherington Date: Thu, 6 Aug 2020 21:24:11 +0000 (+0200) Subject: hackz. X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=82612ae590e5d76a8ce66812838f27214802d78b hackz. --- diff --git a/src/lib/copy_to_drive_job.cc b/src/lib/copy_to_drive_job.cc index e222807f4..315d2529d 100644 --- a/src/lib/copy_to_drive_job.cc +++ b/src/lib/copy_to_drive_job.cc @@ -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 diff --git a/src/lib/disk_writer_messages.h b/src/lib/disk_writer_messages.h index d31a9cb0a..406afc61d 100644 --- a/src/lib/disk_writer_messages.h +++ b/src/lib/disk_writer_messages.h @@ -23,6 +23,16 @@ * 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: diff --git a/src/lib/nanomsg.h b/src/lib/nanomsg.h index 9bd87098b..f9951f165 100644 --- a/src/lib/nanomsg.h +++ b/src/lib/nanomsg.h @@ -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. diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index c4a04aea8..73fb35304 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -222,11 +222,36 @@ private: setup_sensitivity (); } + void copy () { DCPOMATIC_ASSERT (_drive->GetSelection() != wxNOT_FOUND); DCPOMATIC_ASSERT (static_cast(_dcp_path)); + bool have_writer = true; + if (!_nanomsg.send(DISK_WRITER_PING "\n", 2000)) { + have_writer = false; + } else { + optional 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()); diff --git a/src/tools/dcpomatic_disk_writer.cc b/src/tools/dcpomatic_disk_writer.cc index fa0a7bb7e..b95d12a8e 100644 --- a/src/tools/dcpomatic_disk_writer.cc +++ b/src/tools/dcpomatic_disk_writer.cc @@ -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 xml_head = nanomsg->receive (LONG_TIMEOUT);