diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-06-28 00:40:03 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-10-11 21:45:04 +0200 |
| commit | 58735d74bec27a45081b478b1ee9057a2a7e7cde (patch) | |
| tree | e56a377b06ee6ca5411fa8f26a8e87036189a3d4 | |
| parent | 88c6fa1a5ae60831bf0fb3a6ac8bbd1d3f00fae0 (diff) | |
Download Dolby certs more intelligently.
Rather than doing a load of connections to look for different filenames
in a specific FTP directory, list that directory and then look for the
filenames.
| -rw-r--r-- | src/wx/dolby_doremi_certificate_panel.cc | 108 |
1 files changed, 24 insertions, 84 deletions
diff --git a/src/wx/dolby_doremi_certificate_panel.cc b/src/wx/dolby_doremi_certificate_panel.cc index 4d8845402..7f1139753 100644 --- a/src/wx/dolby_doremi_certificate_panel.cc +++ b/src/wx/dolby_doremi_certificate_panel.cc @@ -64,77 +64,30 @@ DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (DownloadCertificateDia static void -try_dcp2000(vector<Location>& locations, string prefix, string serial) +try_common(vector<Location>& locations, string prefix, string serial) { - locations.push_back({ - String::compose("%1%2xxx/Dolby-DCP2000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial), - String::compose("Dolby-DCP2000-%1.cert.sha256.pem", serial) - }); - - locations.push_back({ - String::compose("%1%2xxx/Dolby-DCP2000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial), - String::compose("Dolby-DCP2000-%1.cert.sha256.pem", serial) - }); - - locations.push_back({ - String::compose("%1%2xxx/Dolby-DCP2000-%3.certs.zip", prefix, serial.substr(0, 3), serial), - String::compose("Dolby-DCP2000-%1.cert.sha256.pem", serial) - }); - - locations.push_back({ - String::compose("%1%2xxx/dcp2000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial), - String::compose("dcp2000-%1.cert.sha256.pem", serial) - }); - - locations.push_back({ - String::compose("%1%2xxx/dcp2000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial), - String::compose("dcp2000-%1.cert.sha256.pem", serial) - }); - - locations.push_back({ - String::compose("%1%2xxx/dcp2000-%3.certs.zip", prefix, serial.substr(0, 3), serial), - String::compose("dcp2000-%1.cert.sha256.pem", serial) - }); -} - - -static void -try_imb(vector<Location>& locations, string prefix, string serial) -{ - locations.push_back({ - String::compose("%1%2xxx/Dolby-IMB-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial), - String::compose("Dolby-IMB-%1.cert.sha256.pem", serial) - }); - - locations.push_back({ - String::compose("%1%2xxx/imb-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial), - String::compose("imb-%1.cert.sha256.pem", serial) - }); -} - - -static void -try_ims(vector<Location>& locations, string prefix, string serial) -{ - locations.push_back({ - String::compose("%1%2xxx/Dolby-IMS1000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial), - String::compose("Dolby-IMS1000-%1.cert.sha256.pem", serial) - }); - - locations.push_back({ - String::compose("%1%2xxx/Dolby-IMS2000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial), - String::compose("Dolby-IMS2000-%1.cert.sha256.pem", 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) - }); - - locations.push_back({ - String::compose("%1%2xxx/ims-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial), - String::compose("ims-%1.cert.sha256.pem", serial) - }); + auto files = ls_url(String::compose("%1%2xxx/", prefix, serial.substr(0, 3))); + + auto check = [&locations, prefix, files, serial](string format, string file) { + auto const zip = String::compose(format, serial); + if (find(files.begin(), files.end(), zip) != files.end()) { + locations.push_back({ + String::compose("%1%2xxx/%3", prefix, serial.substr(0, 3), zip), + String::compose(file, serial) + }); + } + }; + + check("Dolby-DCP2000-%1.dcicerts.zip", "Dolby-DCP2000-%1.cert.sha256.pem"); + check("Dolby-DCP2000-%1.certs.zip", "Dolby-DCP2000-%1.cert.sha256.pem"); + check("dcp2000-%1.dcicerts.zip", "dcp2000-%1.cert.sha256.pem"); + check("dcp2000-%1.certs.zip", "dcp2000-%1.cert.sha256.pem"); + check("Dolby-IMB-%1.dcicerts.zip", "Dolby-IMB-%1.cert.sha256.pem"); + check("imb-%1.dcicerts.zip", "imb-%1.cert.sha256.pem"); + check("Dolby-IMS1000-%1.dcicerts.zip", "Dolby-IMS1000-%1.cert.sha256.pem"); + check("Dolby-IMS2000-%1.dcicerts.zip", "Dolby-IMS2000-%1.cert.sha256.pem"); + check("cert_Dolby-IMS3000-%1-SMPTE.zip", "cert_Dolby-IMS3000-%1-SMPTE.pem"); + check("ims-%1.dcicerts.zip", "ims-%1.cert.sha256.pem"); } @@ -217,16 +170,6 @@ try_cp850(vector<Location>& locations, string prefix, string serial) } -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 () { @@ -252,12 +195,9 @@ DolbyDoremiCertificatePanel::do_download () vector<string> errors; if (starts_with_digit) { - try_dcp2000(locations, prefix, serial); - try_imb(locations, prefix, serial); - try_ims(locations, prefix, serial); + try_common(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') { |
