+ locations.push_back({
+ String::compose("%1%2/cert_Dolby256-DSP100-%3.zip", prefix, dsp100, serial_int),
+ String::compose("cert_Dolby256-DSP100-%1.pem.crt", serial_int)
+ });
+}
+
+
+static void
+try_cat745(vector<Location>& locations, string prefix, string serial)
+{
+ int const serial_int = raw_convert<int>(serial.substr (1));
+
+ string cat745;
+ if (serial_int <= 999) {
+ cat745 = "CAT745_1_thru_999";
+ } else if (serial_int >= 6000) {
+ cat745 = "CAT745_6000_and_higher";
+ } else {
+ int const lower = serial_int - (serial_int % 1000);
+ cat745 = String::compose("CAT745_%1_thru_%2", lower, lower + 999);
+ }
+
+ locations.push_back({
+ String::compose("%1%2/cert_Dolby-CAT745-%3.zip", prefix, cat745, serial_int),
+ String::compose("cert_Dolby-CAT745-%1.pem.crt", serial_int)
+ });
+}
+
+
+static void
+try_cp850(vector<Location>& locations, string prefix, string serial)
+{
+ int const serial_int = raw_convert<int> (serial.substr (1));
+
+ int const lower = serial_int - (serial_int % 1000);
+ locations.push_back({
+ String::compose ("%1CP850_CAT1600_F%2-F%3/cert_RMB_SPB_MDE_FMA.Dolby-CP850-F%4.zip", prefix, lower, lower + 999, serial_int),
+ String::compose ("cert_RMB_SPB_MDE_FMA.Dolby-CP850-F%1.pem.crt", serial_int)
+ });
+}
+
+
+static void
+try_ims3000(vector<Location>& locations, string prefix, string serial)
+{
+ locations.push_back({
+ String::compose ("%1%2xxx/cert_Dolby-IMS3000-%3-SMPTE.zip", prefix, serial.substr(0, 3), serial),
+ String::compose("cert_Dolby-IMS3000-%1-SMPTE.pem", serial)
+ });
+}
+
+
+void
+DolbyDoremiCertificatePanel::do_download ()
+{
+ string serial = wx_to_std(_serial->GetValue());
+ trim(serial);
+
+ /* Try dcp2000, imb and ims prefixes (see mantis #375) */
+
+ string const prefix = "ftp://ftp.cinema.dolby.com/Certificates/";
+ vector<Location> locations;
+
+ bool starts_with_digit = false;
+ optional<char> starting_char;
+
+ if (!serial.empty()) {
+ if (isdigit (serial[0])) {
+ starts_with_digit = true;
+ } else {
+ starting_char = serial[0];
+ }
+ }
+
+ vector<string> errors;
+
+ if (starts_with_digit) {
+ try_dcp2000(locations, prefix, serial);
+ try_imb(locations, prefix, serial);
+ try_ims(locations, prefix, serial);
+ try_cat862(locations, prefix, serial);
+ try_dsp100(locations, prefix, serial);
+ try_ims3000(locations, prefix, serial);
+ } else if (starting_char == 'H') {
+ try_cat745(locations, prefix, serial);
+ } else if (starting_char == 'F') {
+ try_cp850(locations, prefix, serial);
+ } else {
+ errors.push_back(wx_to_std(_("Unrecognised serial number format (does not start with a number, H or F)")));
+ }