Display the filename / URL that a screen certificate was obtained from (#1894).
[dcpomatic.git] / src / lib / kdm_cli.cc
index 3815b3d65ea475651aef31e67b921048b3ce125a..0ec648e0489d1a9eb88db033fbfbe14e9d35731d 100644 (file)
@@ -354,8 +354,11 @@ from_dkdm (
                                continue;
                        }
 
-                       dcp::LocalTime begin(valid_from, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute());
-                       dcp::LocalTime end(valid_to, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute());
+                       int const offset_hour = i->cinema ? i->cinema->utc_offset_hour() : 0;
+                       int const offset_minute = i->cinema ? i->cinema->utc_offset_minute() : 0;
+
+                       dcp::LocalTime begin(valid_from, offset_hour, offset_minute);
+                       dcp::LocalTime end(valid_to, offset_hour, offset_minute);
 
                        auto const kdm = kdm_from_dkdm(
                                                        dkdm,
@@ -369,14 +372,14 @@ from_dkdm (
                                                        );
 
                        dcp::NameFormat::Map name_values;
-                       name_values['c'] = i->cinema->name;
+                       name_values['c'] = i->cinema ? i->cinema->name : "";
                        name_values['s'] = i->name;
                        name_values['f'] = dkdm.annotation_text().get_value_or("");
                        name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
                        name_values['e'] = end.date() + " " + end.time_of_day(true, false);
                        name_values['i'] = kdm.cpl_id();
 
-                       kdms.push_back (make_shared<KDMWithMetadata>(name_values, i->cinema.get(), i->cinema->emails, kdm));
+                       kdms.push_back (make_shared<KDMWithMetadata>(name_values, i->cinema.get(), i->cinema ? i->cinema->emails : list<string>(), kdm));
                }
                write_files (kdms, zip, output, container_name_format, filename_format, verbose, out);
                if (email) {
@@ -414,7 +417,7 @@ optional<string>
 kdm_cli (int argc, char* argv[], std::function<void (string)> out)
 try
 {
-       boost::filesystem::path output = ".";
+       boost::filesystem::path output = boost::filesystem::current_path();
        auto container_name_format = Config::instance()->kdm_container_name_format();
        auto filename_format = Config::instance()->kdm_filename_format();
        optional<string> cinema_name;
@@ -537,7 +540,7 @@ try
                {
                        /* Make a new screen and add it to the current cinema */
                        dcp::CertificateChain chain (dcp::file_to_string(optarg));
-                       auto screen = make_shared<Screen>(screen_description, "", chain.leaf(), vector<TrustedDevice>());
+                       auto screen = std::make_shared<Screen>(screen_description, "", chain.leaf(), boost::none, vector<TrustedDevice>());
                        if (cinema) {
                                cinema->add_screen (screen);
                        }
@@ -596,9 +599,6 @@ try
                valid_to = valid_from.get() + duration_from_string (*duration_string);
        }
 
-       dcpomatic_setup_path_encoding ();
-       dcpomatic_setup ();
-
        if (verbose) {
                out (String::compose("Making KDMs valid from %1 to %2", boost::posix_time::to_simple_string(valid_from.get()), boost::posix_time::to_simple_string(valid_to.get())));
        }