#include "download_certificate_dialog.h"
#include "wx_util.h"
#include "lib/compose.hpp"
-#include "lib/util.h"
-#include "lib/signal_manager.h"
#include "lib/internet.h"
+#include "lib/signal_manager.h"
+#include "lib/util.h"
#include <dcp/raw_convert.h>
#include <curl/curl.h>
#include <zip.h>
-#include <iostream>
+#include <boost/algorithm/string.hpp>
-using std::string;
-using std::cout;
+using std::function;
using std::list;
-using boost::function;
+using std::string;
+using namespace boost::algorithm;
using boost::optional;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
static void
try_dcp2000 (list<string>& urls, list<string>& files, string prefix, string serial)
{
+ urls.push_back(String::compose("%1%2xxx/Dolby-DCP2000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial));
+ files.push_back(String::compose("Dolby-DCP2000-%1.cert.sha256.pem", serial));
+
+ urls.push_back(String::compose("%1%2xxx/Dolby-DCP2000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial));
+ files.push_back(String::compose("Dolby-DCP2000-%1.cert.sha256.pem", serial));
+
+ urls.push_back(String::compose("%1%2xxx/Dolby-DCP2000-%3.certs.zip", prefix, serial.substr(0, 3), serial));
+ files.push_back(String::compose("Dolby-DCP2000-%1.cert.sha256.pem", serial));
+
urls.push_back (String::compose("%1%2xxx/dcp2000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial));
files.push_back (String::compose("dcp2000-%1.cert.sha256.pem", serial));
void
DolbyDoremiCertificatePanel::do_download ()
{
- string const serial = wx_to_std (_serial->GetValue());
+ string serial = wx_to_std(_serial->GetValue());
+ trim(serial);
/* Try dcp2000, imb and ims prefixes (see mantis #375) */
}
}
+ list<string> errors;
+
if (starts_with_digit) {
try_dcp2000 (urls, files, prefix, serial);
try_imb (urls, files, prefix, serial);
try_cat745 (urls, files, prefix, serial);
} else if (starting_char == 'F') {
try_cp850 (urls, files, prefix, serial);
+ } else {
+ errors.push_back(wx_to_std(_("Unrecognised serial number format (does not start with a number, H or F)")));
}
- list<string> errors;
bool ok = false;
auto i = urls.begin ();
auto j = files.begin ();
while (!ok && i != urls.end ()) {
- auto error = get_from_zip_url (*i++, *j++, true, true, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1));
+ auto error = get_from_zip_url (*i++, *j++, true, true, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1, _2));
if (error) {
errors.push_back (error.get ());
} else {