X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fanalytics.cc;h=836051fe59616756482acf6003ba4539226e90a9;hb=2b0e9dd97a5773f52eba5704903b82e90f4c6f63;hp=34f67116e3a7355ea42dc6ee5cf1c0ad6ae1491b;hpb=447ee98f36b5ae2cd40b98e4316dc4428b374d90;p=dcpomatic.git diff --git a/src/lib/analytics.cc b/src/lib/analytics.cc index 34f67116e..836051fe5 100644 --- a/src/lib/analytics.cc +++ b/src/lib/analytics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,30 +18,38 @@ */ + #include "analytics.h" -#include "exceptions.h" #include "compose.hpp" +#include "exceptions.h" +#include #include +#include #include +LIBDCP_DISABLE_WARNINGS #include -#include +LIBDCP_ENABLE_WARNINGS #include +#include #include "i18n.h" + using std::string; using dcp::raw_convert; using boost::algorithm::trim; + Analytics* Analytics::_instance; int const Analytics::_current_version = 1; + Analytics::Analytics () - : _successful_dcp_encodes (0) { } + void Analytics::successful_dcp_encode () { @@ -78,35 +86,38 @@ Analytics::successful_dcp_encode () } } + void Analytics::write () const { xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("Analytics"); + auto root = doc.create_root_node ("Analytics"); root->add_child("Version")->add_child_text(raw_convert(_current_version)); root->add_child("SuccessfulDCPEncodes")->add_child_text(raw_convert(_successful_dcp_encodes)); try { - doc.write_to_file_formatted(path("analytics.xml").string()); + doc.write_to_file_formatted(write_path("analytics.xml").string()); } catch (xmlpp::exception& e) { string s = e.what (); trim (s); - throw FileError (s, path("analytics.xml")); + throw FileError (s, write_path("analytics.xml")); } } + void Analytics::read () try { cxml::Document f ("Analytics"); - f.read_file (path("analytics.xml")); + f.read_file(dcp::filesystem::fix_long_path(read_path("analytics.xml"))); _successful_dcp_encodes = f.number_child("SuccessfulDCPEncodes"); } catch (...) { /* Never mind */ } + Analytics* Analytics::instance () {