diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llfloaterabout.cpp | 36 | ||||
-rw-r--r-- | indra/newview/lllicenseinfo.cpp | 84 | ||||
-rw-r--r-- | indra/newview/lllicenseinfo.h | 67 |
5 files changed, 173 insertions, 22 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 5a06106de3..67ada9cc2e 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -385,6 +385,7 @@ set(viewer_SOURCE_FILES lllandmarkactions.cpp lllandmarklist.cpp lllegacyatmospherics.cpp + lllicenseinfo.cpp lllistbrowser.cpp lllistcontextmenu.cpp lllistview.cpp @@ -1025,6 +1026,7 @@ set(viewer_HEADER_FILES llkeyconflict.h lllandmarkactions.h lllandmarklist.h + lllicenseinfo.h lllightconstants.h lllistbrowser.h lllistcontextmenu.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c9d852686e..4cc5ae7630 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -30,6 +30,7 @@ // Viewer includes #include "llversioninfo.h" +#include "lllicenseinfo.h" #include "llfeaturemanager.h" #include "lluictrlfactory.h" #include "lltexteditor.h" @@ -3207,9 +3208,10 @@ LLSD LLAppViewer::getViewerInfo() const info["AUDIO_DRIVER_VERSION"] = gAudiop ? LLSD(gAudiop->getDriverName(want_fullname)) : "Undefined"; if(LLVoiceClient::getInstance()->voiceEnabled()) { - LLVoiceVersionInfo version = LLVoiceClient::getInstance()->getVersion(); + auto& licenseInfo(LLLicenseInfo::instance()); + LLVoiceVersionInfo version = LLVoiceClient::getInstance()->getVersion(); std::ostringstream version_string; - version_string << version.serverType << " " << version.serverVersion << std::endl; + version_string << version.serverType << " " << version.serverVersion << " SLVoice " << licenseInfo.getVersion("slvoice") << std::endl; info["VOICE_VERSION"] = version_string.str(); } else diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp index 1fbd198019..60c7a737b2 100644 --- a/indra/newview/llfloaterabout.cpp +++ b/indra/newview/llfloaterabout.cpp @@ -44,6 +44,7 @@ #include "llviewerstats.h" #include "llviewerregion.h" #include "llversioninfo.h" +#include "lllicenseinfo.h" #include "llweb.h" // Linden library includes @@ -178,26 +179,21 @@ BOOL LLFloaterAbout::postBuild() contrib_names_widget->setEnabled(FALSE); contrib_names_widget->startOfDoc(); - // Get the Versions and Copyrights, created at build time - std::string licenses_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"packages-info.txt"); - llifstream licenses_file; - licenses_file.open(licenses_path.c_str()); /* Flawfinder: ignore */ - if (licenses_file.is_open()) - { - std::string license_line; - licenses_widget->clear(); - while ( std::getline(licenses_file, license_line) ) - { - licenses_widget->appendText(license_line+"\n", FALSE, - LLStyle::Params() .color(about_color)); - } - licenses_file.close(); - } - else - { - // this case will use the (out of date) hard coded value from the XUI - LL_INFOS("AboutInit") << "Could not read licenses file at " << licenses_path << LL_ENDL; - } + auto& license_info(LLLicenseInfo::instance()); + if (!license_info.empty()) + { + // Although the iteration is fine if empty(), we only want to clear if not empty(). + // That then uses the (out of date) hard coded value from the XUI. + licenses_widget->clear(); + for (const auto& library : license_info) + { + const std::string& name = library.first; + const LLLicenseInfo::LibraryData& data = library.second; + std::string license_line = name + ": " + data.version + "\n" + data.copyrights + "\n\n"; + licenses_widget->appendText(license_line, FALSE, + LLStyle::Params() .color(about_color)); + } + } licenses_widget->setEnabled(FALSE); licenses_widget->startOfDoc(); diff --git a/indra/newview/lllicenseinfo.cpp b/indra/newview/lllicenseinfo.cpp new file mode 100644 index 0000000000..e68b661763 --- /dev/null +++ b/indra/newview/lllicenseinfo.cpp @@ -0,0 +1,84 @@ +/** + * @file lllicenseinfo.cpp + * @brief Routines to access library version and license information + * @author Aech Linden + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "lllicenseinfo.h" +#include <boost/algorithm/string.hpp> +#include "lldir.h" + +LLLicenseInfo::LLLicenseInfo() +{ + LL_DEBUGS("LicenseInfo") << "instantiating license info" << LL_ENDL; +} + +void LLLicenseInfo::initSingleton() +{ + // Get the the map with name => {version, cpyrights}, from file created at build time + std::string licenses_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "packages-info.txt"); + llifstream licenses_file; + licenses_file.open(licenses_path.c_str()); /* Flawfinder: ignore */ + if (!licenses_file.is_open()) { + LL_INFOS("LicenseInfo") << "Could not read licenses file at " << licenses_path << LL_ENDL; + return; + } + + LL_DEBUGS("LicenseInfo") << "Reading licenses file at " << licenses_path << LL_ENDL; + std::string license_line; + std::string name{}, version{}, copyright{}; + while ( std::getline(licenses_file, license_line) ) + { + if (license_line.empty()) // blank line starts a new library/version/copyright + { + if (!name.empty()) { // Add what we have accumulated. + mLibraries.insert({name, {version, copyright}}); + } + else + { + LL_WARNS("LicenseInfo") << "new line with no current data" << LL_ENDL; + } + name.clear(); + version.clear(); + copyright.clear(); + } + else + { + if (name.empty()) { // No name yet. Parse this line into name and version. + auto name_termination_index = license_line.find(':'); + if (name_termination_index == std::string::npos) // First line has no colon. + { + name_termination_index = license_line.find_last_of(' '); + } + name = license_line.substr(0, name_termination_index); + version = license_line.substr(name_termination_index + 1); + boost::algorithm::trim(version); + } else { + copyright += license_line; + } + } + } + licenses_file.close(); +} diff --git a/indra/newview/lllicenseinfo.h b/indra/newview/lllicenseinfo.h new file mode 100644 index 0000000000..ff889285b8 --- /dev/null +++ b/indra/newview/lllicenseinfo.h @@ -0,0 +1,67 @@ +/** + * @file llicenseinfo.h + * @brief Routines to access library versions and license information + * @author Aech Linden + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLLICENSEINFO_H +#define LL_LLLICENSEINFO_H + +#include "stdtypes.h" +#include "llsingleton.h" +#include <string> + +/// +/// This API provides license information for the viewer. +/// The singleton is initialized once (from package-info.txt), after which +/// it acts like a map of name => {version, copyrights} for each library. +/// +class LLLicenseInfo: public LLSingleton<LLLicenseInfo> +{ + LLSINGLETON(LLLicenseInfo); + +public: + struct LibraryData + { + std::string version; + std::string copyrights; + }; + typedef std::map<std::string, LibraryData> LibraryMap; + + /// return the version as a string of the requested library, like "2.0.0.200030" + const std::string& getVersion(const std::string& library_name) const { return mLibraries.at(library_name).version; } + + /// return an indication of whether any library data was found (e.g., false if packages-info.txt is missing) + bool empty() const noexcept { return mLibraries.empty(); }; + + LibraryMap::const_iterator begin() const noexcept { return mLibraries.begin(); }; + LibraryMap::const_iterator end() const noexcept { return mLibraries.end(); }; + +protected: + virtual void initSingleton();; +private: + LibraryMap mLibraries{}; +}; + +#endif |