Simple and optional messagebox notification when jobs finish.
[dcpomatic.git] / src / lib / config.h
index abfdba3dd56cd2347022a7aaf4d47e12acfcbecb..1e16fc840a607814bd8fcef1891151cb2918a569 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -40,6 +40,7 @@ class DCPContentType;
 class Ratio;
 class Cinema;
 class Film;
+class DKDMGroup;
 
 /** @class Config
  *  @brief A singleton class holding configuration.
@@ -47,9 +48,14 @@ class Film;
 class Config : public boost::noncopyable
 {
 public:
-       /** @return number of threads to use for J2K encoding on the local machine */
-       int num_local_encoding_threads () const {
-               return _num_local_encoding_threads;
+       /** @return number of threads which a master DoM should use for J2K encoding on the local machine */
+       int master_encoding_threads () const {
+               return _master_encoding_threads;
+       }
+
+       /** @return number of threads which a server should use for J2K encoding on the local machine */
+       int server_encoding_threads () const {
+               return _server_encoding_threads;
        }
 
        boost::optional<boost::filesystem::path> default_directory () const {
@@ -67,6 +73,7 @@ public:
                USE_ANY_SERVERS,
                SERVERS,
                CINEMAS,
+               SOUND,
                SOUND_OUTPUT,
                OTHER
        };
@@ -157,6 +164,10 @@ public:
                return _default_container;
        }
 
+       Ratio const * default_scale_to () const {
+               return _default_scale_to;
+       }
+
        DCPContentType const * default_dcp_content_type () const {
                return _default_dcp_content_type;
        }
@@ -185,6 +196,10 @@ public:
                return _default_interop;
        }
 
+       bool default_upload_after_make_dcp () {
+               return _default_upload_after_make_dcp;
+       }
+
        void set_default_kdm_directory (boost::filesystem::path d) {
                if (_default_kdm_directory && _default_kdm_directory.get() == d) {
                        return;
@@ -271,7 +286,11 @@ public:
                return _history;
        }
 
-       std::vector<dcp::EncryptedKDM> dkdms () const {
+       std::vector<boost::filesystem::path> player_history () const {
+               return _player_history;
+       }
+
+       boost::shared_ptr<DKDMGroup> dkdms () const {
                return _dkdms;
        }
 
@@ -307,13 +326,73 @@ public:
                return _jump_to_selected;
        }
 
+       enum Nag {
+               NAG_DKDM_CONFIG,
+               NAG_ENCRYPTED_METADATA,
+               NAG_REMAKE_DECRYPTION_CHAIN,
+               NAG_BAD_SIGNER_CHAIN,
+               NAG_COUNT
+       };
+
+       bool nagged (Nag nag) const {
+               return _nagged[nag];
+       }
+
+       bool sound () const {
+               return _sound;
+       }
+
+       std::string cover_sheet () const {
+               return _cover_sheet;
+       }
+
        boost::optional<std::string> sound_output () const {
                return _sound_output;
        }
 
-       /** @param n New number of local encoding threads */
-       void set_num_local_encoding_threads (int n) {
-               maybe_set (_num_local_encoding_threads, n);
+       boost::optional<boost::filesystem::path> last_player_load_directory () const {
+               return _last_player_load_directory;
+       }
+
+       enum KDMWriteType {
+               KDM_WRITE_FLAT,
+               KDM_WRITE_FOLDER,
+               KDM_WRITE_ZIP
+       };
+
+       boost::optional<KDMWriteType> last_kdm_write_type () const {
+               return _last_kdm_write_type;
+       }
+
+       enum DKDMWriteType {
+               DKDM_WRITE_INTERNAL,
+               DKDM_WRITE_FILE
+       };
+
+       boost::optional<DKDMWriteType> last_dkdm_write_type () const {
+               return _last_dkdm_write_type;
+       }
+
+       int frames_in_memory_multiplier () const {
+               return _frames_in_memory_multiplier;
+       }
+
+       boost::optional<int> decode_reduction () const {
+               return _decode_reduction;
+       }
+
+       bool default_notify () const {
+               return _default_notify;
+       }
+
+       /* SET (mostly) */
+
+       void set_master_encoding_threads (int n) {
+               maybe_set (_master_encoding_threads, n);
+       }
+
+       void set_server_encoding_threads (int n) {
+               maybe_set (_server_encoding_threads, n);
        }
 
        void set_default_directory (boost::filesystem::path d) {
@@ -404,6 +483,10 @@ public:
                maybe_set (_default_container, c);
        }
 
+       void set_default_scale_to (Ratio const * c) {
+               maybe_set (_default_scale_to, c);
+       }
+
        void set_default_dcp_content_type (DCPContentType const * t) {
                maybe_set (_default_dcp_content_type, t);
        }
@@ -432,6 +515,10 @@ public:
                maybe_set (_default_interop, i);
        }
 
+       void set_default_upload_after_make_dcp (bool u) {
+               maybe_set (_default_upload_after_make_dcp, u);
+       }
+
        void set_mail_server (std::string s) {
                maybe_set (_mail_server, s);
        }
@@ -511,7 +598,7 @@ public:
        }
 #endif
 
-       void set_dkdms (std::vector<dcp::EncryptedKDM> dkdms) {
+       void set_dkdms (boost::shared_ptr<DKDMGroup> dkdms) {
                _dkdms = dkdms;
                changed ();
        }
@@ -526,13 +613,27 @@ public:
                maybe_set (_confirm_kdm_email, s);
        }
 
-       void set_sound_output (std::string o)
-       {
+       void set_sound (bool s) {
+               maybe_set (_sound, s, SOUND);
+       }
+
+       void set_sound_output (std::string o) {
                maybe_set (_sound_output, o, SOUND_OUTPUT);
        }
 
-       void unset_sound_output ()
-       {
+       void set_last_player_load_directory (boost::filesystem::path d) {
+               maybe_set (_last_player_load_directory, d);
+       }
+
+       void set_last_kdm_write_type (KDMWriteType t) {
+               maybe_set (_last_kdm_write_type, t);
+       }
+
+       void set_last_dkdm_write_type (DKDMWriteType t) {
+               maybe_set (_last_dkdm_write_type, t);
+       }
+
+       void unset_sound_output () {
                if (!_sound_output) {
                        return;
                }
@@ -557,27 +658,63 @@ public:
                maybe_set (_dcp_asset_filename_format, n);
        }
 
+       void set_frames_in_memory_multiplier (int m) {
+               maybe_set (_frames_in_memory_multiplier, m);
+       }
+
+       void set_decode_reduction (boost::optional<int> r) {
+               maybe_set (_decode_reduction, r);
+       }
+
+       void set_default_notify (bool n) {
+               maybe_set (_default_notify, n);
+       }
+
        void clear_history () {
                _history.clear ();
                changed ();
        }
 
+       void clear_player_history () {
+               _player_history.clear ();
+               changed ();
+       }
+
        void add_to_history (boost::filesystem::path p);
+       void add_to_player_history (boost::filesystem::path p);
 
        void set_jump_to_selected (bool j) {
                maybe_set (_jump_to_selected, j);
        }
 
+       void set_nagged (Nag nag, bool nagged) {
+               maybe_set (_nagged[nag], nagged);
+       }
+
+       void set_cover_sheet (std::string s) {
+               maybe_set (_cover_sheet, s);
+       }
+
+       void reset_cover_sheet ();
+
        void changed (Property p = OTHER);
        boost::signals2::signal<void (Property)> Changed;
        /** Emitted if read() failed on an existing Config file.  There is nothing
            a listener can do about it: this is just for information.
        */
        static boost::signals2::signal<void ()> FailedToLoad;
+       /** Emitted if read() issued a warning which the user might want to know about */
+       static boost::signals2::signal<void (std::string)> Warning;
+       /** Emitted if there is a bad certificate in the signer chain.  Handler can call
+        *  true to ask Config to re-create the chain.
+        */
+       static boost::signals2::signal<bool (void)> BadSignerChain;
 
        void write () const;
        void write_config () const;
        void write_cinemas () const;
+       void link (boost::filesystem::path new_file) const;
+       void copy_and_link (boost::filesystem::path new_file) const;
 
        void save_template (boost::shared_ptr<const Film> film, std::string name) const;
        bool existing_template (std::string name) const;
@@ -590,6 +727,10 @@ public:
        static void drop ();
        static void restore_defaults ();
        static bool have_existing (std::string);
+       static boost::filesystem::path config_file ();
+
+       /** If set, this overrides the standard path (in home, Library, AppData or wherever) for config.xml and cinemas.xml */
+       static boost::optional<boost::filesystem::path> override_path;
 
 private:
        Config ();
@@ -597,9 +738,12 @@ private:
        void read ();
        void set_defaults ();
        void set_kdm_email_to_default ();
+       void set_cover_sheet_to_default ();
        void read_cinemas (cxml::Document const & f);
        boost::shared_ptr<dcp::CertificateChain> create_certificate_chain ();
        boost::filesystem::path directory_or (boost::optional<boost::filesystem::path> dir, boost::filesystem::path a) const;
+       void add_to_history_internal (std::vector<boost::filesystem::path>& h, boost::filesystem::path p);
+       void backup ();
 
        template <class T>
        void maybe_set (T& member, T new_value, Property prop = OTHER) {
@@ -619,8 +763,10 @@ private:
                changed (prop);
        }
 
-       /** number of threads to use for J2K encoding on the local machine */
-       int _num_local_encoding_threads;
+       /** number of threads which a master DoM should use for J2K encoding on the local machine */
+       int _master_encoding_threads;
+       /** number of threads which a server should use for J2K encoding on the local machine */
+       int _server_encoding_threads;
        /** default directory to put new films in */
        boost::optional<boost::filesystem::path> _default_directory;
        /** base port number to use for J2K encoding servers;
@@ -652,6 +798,7 @@ private:
        /** Default length of still image content (seconds) */
        int _default_still_length;
        Ratio const * _default_container;
+       Ratio const * _default_scale_to;
        DCPContentType const * _default_dcp_content_type;
        int _default_dcp_audio_channels;
        std::string _dcp_issuer;
@@ -663,6 +810,7 @@ private:
            the home directory will be offered.
        */
        boost::optional<boost::filesystem::path> _default_kdm_directory;
+       bool _default_upload_after_make_dcp;
        std::list<boost::shared_ptr<Cinema> > _cinemas;
        std::string _mail_server;
        int _mail_port;
@@ -690,7 +838,8 @@ private:
        bool _win32_console;
 #endif
        std::vector<boost::filesystem::path> _history;
-       std::vector<dcp::EncryptedKDM> _dkdms;
+       std::vector<boost::filesystem::path> _player_history;
+       boost::shared_ptr<DKDMGroup> _dkdms;
        boost::filesystem::path _cinemas_file;
        bool _show_hints_before_make_dcp;
        bool _confirm_kdm_email;
@@ -698,12 +847,20 @@ private:
        dcp::NameFormat _kdm_container_name_format;
        dcp::NameFormat _dcp_metadata_filename_format;
        dcp::NameFormat _dcp_asset_filename_format;
-<<<<<<< 8de6a5d1d054bab25ab0d86bc48442d9d6adb849
        bool _jump_to_selected;
-=======
-       /** name of a specific sound output stream to use for preview */
+       bool _nagged[NAG_COUNT];
+       bool _sound;
+       /** name of a specific sound output stream to use, or empty to use the default */
        boost::optional<std::string> _sound_output;
->>>>>>> First bits of audio support.
+       std::string _cover_sheet;
+       boost::optional<boost::filesystem::path> _last_player_load_directory;
+       boost::optional<KDMWriteType> _last_kdm_write_type;
+       boost::optional<DKDMWriteType> _last_dkdm_write_type;
+       int _frames_in_memory_multiplier;
+       boost::optional<int> _decode_reduction;
+       bool _default_notify;
+
+       static int const _current_version;
 
        /** Singleton instance, or 0 */
        static Config* _instance;