Tell user we need a KDM when we have none, and content is encrypted.
[dcpomatic.git] / src / lib / copy_to_drive_job.cc
index 7760c072fdd4b46cefcf23dcab796a6b328aa279..eafa126b6148538ab56018d074e6274b5fca51a8 100644 (file)
@@ -37,7 +37,7 @@
 using std::string;
 using std::cout;
 using std::min;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::optional;
 using dcp::raw_convert;
 
@@ -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
@@ -70,7 +70,13 @@ CopyToDriveJob::run ()
                throw CommunicationFailedError ();
        }
 
-       bool formatting = false;
+       enum State {
+               SETUP,
+               FORMAT,
+               COPY,
+               VERIFY
+       } state = SETUP;
+
        while (true) {
                optional<string> s = _nanomsg.receive (10000);
                if (!s) {
@@ -84,13 +90,22 @@ CopyToDriveJob::run ()
                        optional<string> const n = _nanomsg.receive (500);
                        throw CopyError (m.get_value_or("Unknown"), raw_convert<int>(n.get_value_or("0")));
                } else if (*s == DISK_WRITER_FORMATTING) {
-                       sub ("Formatting drive");
+                       sub (_("Formatting drive"));
                        set_progress_unknown ();
-                       formatting = true;
-               } else if (*s == DISK_WRITER_PROGRESS) {
-                       if (formatting) {
-                               sub ("Copying DCP");
-                               formatting = false;
+                       state = FORMAT;
+               } else if (*s == DISK_WRITER_COPY_PROGRESS) {
+                       if (state == FORMAT) {
+                               sub (_("Copying DCP"));
+                               state = COPY;
+                       }
+                       optional<string> progress = _nanomsg.receive (500);
+                       if (progress) {
+                               set_progress (raw_convert<float>(*progress));
+                       }
+               } else if (*s == DISK_WRITER_VERIFY_PROGRESS) {
+                       if (state == COPY) {
+                               sub (_("Verifying copied files"));
+                               state = VERIFY;
                        }
                        optional<string> progress = _nanomsg.receive (500);
                        if (progress) {