From b0c11dce0d5a37122d7a1126a330ff7f16f8c9bb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 30 Apr 2020 00:28:33 +0200 Subject: [PATCH] Move TrustedDevice to its own source files. --- src/lib/screen.cc | 31 ---------------------- src/lib/screen.h | 19 +------------ src/lib/trusted_device.cc | 56 +++++++++++++++++++++++++++++++++++++++ src/lib/trusted_device.h | 46 ++++++++++++++++++++++++++++++++ src/lib/wscript | 1 + 5 files changed, 104 insertions(+), 49 deletions(-) create mode 100644 src/lib/trusted_device.cc create mode 100644 src/lib/trusted_device.h diff --git a/src/lib/screen.cc b/src/lib/screen.cc index fe62a5e6c..2453e1eaf 100644 --- a/src/lib/screen.cc +++ b/src/lib/screen.cc @@ -71,34 +71,3 @@ Screen::trusted_device_thumbprints () const return t; } -TrustedDevice::TrustedDevice (string thumbprint) - : _thumbprint (thumbprint) -{ - -} - -TrustedDevice::TrustedDevice (dcp::Certificate certificate) - : _certificate (certificate) -{ - -} - -string -TrustedDevice::as_string () const -{ - if (_certificate) { - return _certificate->certificate(true); - } - - return *_thumbprint; -} - -string -TrustedDevice::thumbprint () const -{ - if (_certificate) { - return _certificate->thumbprint (); - } - - return *_thumbprint; -} diff --git a/src/lib/screen.h b/src/lib/screen.h index 40990b684..abc229ec6 100644 --- a/src/lib/screen.h +++ b/src/lib/screen.h @@ -21,6 +21,7 @@ #ifndef DCPOMATIC_SCREEN_H #define DCPOMATIC_SCREEN_H +#include "trusted_device.h" #include #include #include @@ -28,24 +29,6 @@ class Cinema; -class TrustedDevice -{ -public: - explicit TrustedDevice (std::string); - explicit TrustedDevice (dcp::Certificate); - - boost::optional certificate () const { - return _certificate; - } - - std::string thumbprint () const; - std::string as_string () const; - -private: - boost::optional _certificate; - boost::optional _thumbprint; -}; - namespace dcpomatic { /** @class Screen diff --git a/src/lib/trusted_device.cc b/src/lib/trusted_device.cc new file mode 100644 index 000000000..5849b8fd2 --- /dev/null +++ b/src/lib/trusted_device.cc @@ -0,0 +1,56 @@ +/* + Copyright (C) 2013-2016 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + +#include "trusted_device.h" + +using std::string; + +TrustedDevice::TrustedDevice (string thumbprint) + : _thumbprint (thumbprint) +{ + +} + +TrustedDevice::TrustedDevice (dcp::Certificate certificate) + : _certificate (certificate) +{ + +} + +string +TrustedDevice::as_string () const +{ + if (_certificate) { + return _certificate->certificate(true); + } + + return *_thumbprint; +} + +string +TrustedDevice::thumbprint () const +{ + if (_certificate) { + return _certificate->thumbprint (); + } + + return *_thumbprint; +} + diff --git a/src/lib/trusted_device.h b/src/lib/trusted_device.h new file mode 100644 index 000000000..7c6af3ea8 --- /dev/null +++ b/src/lib/trusted_device.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2013-2019 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + +#ifndef DCPOMATIC_TRUSTED_DEVICE_H +#define DCPOMATIC_TRUSTED_DEVICE_H + +#include +#include +#include + +class TrustedDevice +{ +public: + explicit TrustedDevice (std::string); + explicit TrustedDevice (dcp::Certificate); + + boost::optional certificate () const { + return _certificate; + } + + std::string thumbprint () const; + std::string as_string () const; + +private: + boost::optional _certificate; + boost::optional _thumbprint; +}; + +#endif diff --git a/src/lib/wscript b/src/lib/wscript index ea52079d0..f8f251cf1 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -163,6 +163,7 @@ sources = """ text_ring_buffers.cc timer.cc transcode_job.cc + trusted_device.cc types.cc signal_manager.cc stdout_log.cc -- 2.30.2