dcpomatic::Screen
-CinemaList::screen_from_result(SQLiteStatement& statement, ScreenID screen_id) const
+CinemaList::screen_from_result(SQLiteStatement& statement, ScreenID screen_id, bool with_trusted_devices) const
{
auto certificate_string = statement.column_text(4);
optional<string> certificate = certificate_string.empty() ? optional<string>() : certificate_string;
auto recipient_file_string = statement.column_text(5);
optional<string> recipient_file = recipient_file_string.empty() ? optional<string>() : recipient_file_string;
- SQLiteStatement trusted_devices_statement(_db, _trusted_devices.select("WHERE screen=?"));
- trusted_devices_statement.bind_int64(1, screen_id.get());
vector<TrustedDevice> trusted_devices;
- trusted_devices_statement.execute([&trusted_devices](SQLiteStatement& statement) {
- DCPOMATIC_ASSERT(statement.data_count() == 1);
- auto description = statement.column_text(1);
- if (boost::algorithm::starts_with(description, "-----BEGIN CERTIFICATE")) {
- trusted_devices.push_back(TrustedDevice(dcp::Certificate(description)));
- } else {
- trusted_devices.push_back(TrustedDevice(description));
- }
- });
+ if (with_trusted_devices) {
+ SQLiteStatement trusted_devices_statement(_db, _trusted_devices.select("WHERE screen=?"));
+ trusted_devices_statement.bind_int64(1, screen_id.get());
+ trusted_devices_statement.execute([&trusted_devices](SQLiteStatement& statement) {
+ DCPOMATIC_ASSERT(statement.data_count() == 3);
+ auto description = statement.column_text(2);
+ if (boost::algorithm::starts_with(description, "-----BEGIN CERTIFICATE")) {
+ trusted_devices.push_back(TrustedDevice(dcp::Certificate(description)));
+ } else {
+ trusted_devices.push_back(TrustedDevice(description));
+ }
+ });
+ }
return dcpomatic::Screen(statement.column_text(2), statement.column_text(3), certificate, recipient_file, trusted_devices);
}
statement.execute([this, &output, screen_id](SQLiteStatement& statement) {
DCPOMATIC_ASSERT(statement.data_count() == 6);
- output = screen_from_result(statement, screen_id);
+ output = screen_from_result(statement, screen_id, true);
});
return output;
statement.execute([this, &output](SQLiteStatement& statement) {
DCPOMATIC_ASSERT(statement.data_count() == 6);
ScreenID const screen_id = statement.column_int64(0);
- output.push_back({screen_id, screen_from_result(statement, screen_id)});
+ output.push_back({screen_id, screen_from_result(statement, screen_id, true)});
});
return output;
void
-CinemaList::screens(function<void (CinemaID, ScreenID, dcpomatic::Screen const& screen)> callback) const
+CinemaList::screens(function<void (CinemaID, ScreenID, dcpomatic::Screen const& screen)> callback, bool with_trusted_devices) const
{
SQLiteStatement statement(_db, _screens.select(""));
- statement.execute([this, &callback](SQLiteStatement& statement) {
+ statement.execute([this, &callback, with_trusted_devices](SQLiteStatement& statement) {
auto const screen_id = statement.column_int64(0);
- callback(statement.column_int64(1), screen_id, screen_from_result(statement, screen_id));
+ callback(statement.column_int64(1), screen_id, screen_from_result(statement, screen_id, with_trusted_devices));
});
}
std::vector<std::pair<ScreenID, dcpomatic::Screen>> screens(CinemaID cinema_id) const;
std::vector<std::pair<ScreenID, dcpomatic::Screen>> screens_by_cinema_and_name(CinemaID id, std::string const& name) const;
- void screens(std::function<void (CinemaID, ScreenID, dcpomatic::Screen const&)> callback) const;
+ /** Call a callback with every screen.
+ * @param with_trusted_devices true to read screen's trusted devices into the Screen, false to not bother.
+ */
+ void screens(std::function<void (CinemaID, ScreenID, dcpomatic::Screen const&)> callback, bool with_trusted_devices) const;
boost::optional<dcp::UTCOffset> unique_utc_offset(std::set<CinemaID> const& cinemas);
private:
- dcpomatic::Screen screen_from_result(SQLiteStatement& statement, ScreenID screen_id) const;
+ /** @param with_trusted_devices true to read screen's trusted devices into the Screen, false to not bother */
+ dcpomatic::Screen screen_from_result(SQLiteStatement& statement, ScreenID screen_id, bool with_trusted_devices) const;
std::vector<std::pair<ScreenID, dcpomatic::Screen>> screens_from_result(SQLiteStatement& statement) const;
void setup_tables();
void setup(boost::filesystem::path db_file);