+ DCPOMATIC_ASSERT (!_dcp_paths.empty());
+
+ auto ping = [this](int attempt) {
+ if (_nanomsg.send(DISK_WRITER_PING "\n", 1000)) {
+ auto reply = _nanomsg.receive (1000);
+ if (reply && *reply == DISK_WRITER_PONG) {
+ return true;
+ } else if (reply) {
+ LOG_DISK("Unexpected response %1 to ping received (attempt %2)", *reply, attempt);
+ } else {
+ LOG_DISK("No reply received from ping (attempt %1)", attempt);
+ }
+ } else {
+ LOG_DISK("Could not send ping to writer (attempt %1)", attempt);
+ }
+ dcpomatic_sleep_seconds (1);
+ return false;
+ };
+
+ bool have_writer = false;
+ for (int i = 0; i < 8; ++i) {
+ if (ping(i + 1)) {
+ have_writer = true;
+ break;
+ }
+ }
+
+ if (!have_writer) {
+#if defined(DCPOMATIC_WINDOWS)
+ auto 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 ();
+ return;
+#elif defined(DCPOMATIC_OSX)
+ auto m = new MessageDialog (
+ this,
+ _("DCP-o-matic Disk Writer"),
+ _("Did you install the DCP-o-matic Disk Writer.pkg from the .dmg? Please check and try again.")
+ );
+ m->ShowModal ();
+ m->Destroy ();
+ return;
+#else
+ LOG_DISK_NC ("Failed to ping writer");
+ throw CommunicationFailedError ();
+#endif
+ }
+
+ auto const& drive = _drives[_drive->GetSelection()];
+ if (drive.mounted()) {
+ auto d = new TryUnmountDialog(this, drive.description());
+ int const r = d->ShowModal ();
+ d->Destroy ();
+ if (r != wxID_OK) {
+ return;
+ }
+
+ LOG_DISK("Sending unmount request to disk writer for %1", drive.as_xml());
+ if (!_nanomsg.send(DISK_WRITER_UNMOUNT "\n", 2000)) {
+ LOG_DISK_NC("Failed to send unmount request.");
+ throw CommunicationFailedError ();
+ }
+ if (!_nanomsg.send(drive.as_xml(), 2000)) {
+ LOG_DISK_NC("Failed to send drive for unmount request.");
+ throw CommunicationFailedError ();
+ }
+ /* The reply may have to wait for the user to authenticate, so let's wait a while */
+ auto reply = _nanomsg.receive (30000);
+ if (!reply || *reply != DISK_WRITER_OK) {
+ auto * m = new MessageDialog (
+ this,
+ _("DCP-o-matic Disk Writer"),
+ wxString::Format(_("The drive %s could not be unmounted.\nClose any application that is using it, then try again."), std_to_wx(drive.description()))
+ );
+ m->ShowModal ();
+ m->Destroy ();
+ return;
+ }
+ }
+
+
+ auto * d = new DriveWipeWarningDialog (this, _drive->GetString(_drive->GetSelection()));