From e3660b2fdf88f70a0c0f573523e7ef1c372e2c37 Mon Sep 17 00:00:00 2001
From: Jacek Antonelli
Date: Thu, 19 May 2011 00:19:12 -0500
Subject: Ported viewerinfo.cpp from Kokua.
It defines the ViewerInfo module/namespace, which contains a variety
of functions for querying the viewer name and version. It is designed
to be a replacement for viewerversion.cpp and viewerversion.xml.
viewerversion.cpp has been removed, but viewerversion.xml remains
(albeit with a bogus version number) until the packaging system no
longer uses it.
---
linden/indra/llcommon/llversionviewer.h | 22 ++-
linden/indra/newview/CMakeLists.txt | 4 +-
.../indra/newview/app_settings/viewerversion.xml | 9 +-
linden/indra/newview/llappviewer.cpp | 55 ++++----
linden/indra/newview/llfloaterabout.cpp | 18 +--
linden/indra/newview/llfloaterreporter.cpp | 25 ++--
linden/indra/newview/llpanellogin.cpp | 40 +-----
linden/indra/newview/llstartup.cpp | 8 +-
linden/indra/newview/llviewermedia.cpp | 4 +-
linden/indra/newview/viewerinfo.cpp | 148 +++++++++++++++++++++
linden/indra/newview/viewerinfo.h | 93 +++++++++++++
linden/indra/newview/viewerversion.cpp | 89 -------------
linden/indra/newview/viewerversion.h | 79 -----------
13 files changed, 308 insertions(+), 286 deletions(-)
create mode 100644 linden/indra/newview/viewerinfo.cpp
create mode 100644 linden/indra/newview/viewerinfo.h
delete mode 100644 linden/indra/newview/viewerversion.cpp
delete mode 100644 linden/indra/newview/viewerversion.h
diff --git a/linden/indra/llcommon/llversionviewer.h b/linden/indra/llcommon/llversionviewer.h
index ab74a3f..4162234 100644
--- a/linden/indra/llcommon/llversionviewer.h
+++ b/linden/indra/llcommon/llversionviewer.h
@@ -33,8 +33,6 @@
#ifndef LL_LLVERSIONVIEWER_H
#define LL_LLVERSIONVIEWER_H
-// Version info should be accessed using newview\viewerversion.h -- MC
-
const S32 LL_VERSION_MAJOR = 1;
const S32 LL_VERSION_MINOR = 23;
const S32 LL_VERSION_PATCH = 5;
@@ -42,17 +40,13 @@ const S32 LL_VERSION_BUILD = 136262;
const char * const LL_VIEWER_NAME = "Second Life";
-// These aren't used anymore.
-// The channel is ViewerChannelName in settings.xml
-// The Imprudence version is set in app_settings\viewerversion.xml -- MC
-
-/*const char * const LL_CHANNEL = "Imprudence";
-
-const char * const IMP_VIEWER_NAME = "Imprudence";
-
-const S32 IMP_VERSION_MAJOR = 1;
-const S32 IMP_VERSION_MINOR = 3;
-const S32 IMP_VERSION_PATCH = 0;
-const char * const IMP_VERSION_TEST = "beta 4";*/
+// These aren't used anymore. See newview/viewerinfo.cpp instead.
+//
+// const char * const LL_CHANNEL = "Imprudence";
+// const char * const IMP_VIEWER_NAME = "Imprudence";
+// const S32 IMP_VERSION_MAJOR = 0;
+// const S32 IMP_VERSION_MINOR = 0;
+// const S32 IMP_VERSION_PATCH = 0;
+// const char * const IMP_VERSION_TEST = "";
#endif
diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt
index df6d8b5..7ffb32b 100644
--- a/linden/indra/newview/CMakeLists.txt
+++ b/linden/indra/newview/CMakeLists.txt
@@ -500,8 +500,8 @@ set(viewer_SOURCE_FILES
rlvextensions.cpp
rlvfloaterbehaviour.cpp
slfloatermediafilter.cpp
+ viewerinfo.cpp
viewertime.cpp
- viewerversion.cpp
windlightsettingsupdate.cpp
wlfloatermanager.cpp
wlfloaterwindlightsend.cpp
@@ -973,8 +973,8 @@ set(viewer_HEADER_FILES
slfloatermediafilter.h
VertexCache.h
VorbisFramework.h
+ viewerinfo.h
viewertime.h
- viewerversion.h
wlfloatermanager.h
wlfloaterwindlightsend.h
wlretrievesettings.h
diff --git a/linden/indra/newview/app_settings/viewerversion.xml b/linden/indra/newview/app_settings/viewerversion.xml
index 33d810e..cadb946 100644
--- a/linden/indra/newview/app_settings/viewerversion.xml
+++ b/linden/indra/newview/app_settings/viewerversion.xml
@@ -1,5 +1,6 @@
-
+
-
+
-
+
diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp
index aa3de97..aeb52a2 100644
--- a/linden/indra/newview/llappviewer.cpp
+++ b/linden/indra/newview/llappviewer.cpp
@@ -154,7 +154,7 @@
#include "llflexibleobject.h"
#include "llvosurfacepatch.h"
#include "llslider.h"
-#include "viewerversion.h"
+#include "viewerinfo.h"
// includes for idle() idleShutdown()
#include "floaterao.h"
@@ -597,7 +597,7 @@ bool LLAppViewer::init()
// Need to do this initialization before we do anything else, since anything
// that touches files should really go through the lldir API
- gDirUtilp->initAppDirs(ViewerVersion::getImpViewerName());
+ gDirUtilp->initAppDirs(ViewerInfo::viewerName());
// set skin search path to default, will be overridden later
// this allows simple skinned file lookups to work
gDirUtilp->setSkinFolder("default");
@@ -619,15 +619,8 @@ bool LLAppViewer::init()
writeSystemInfo();
- // Build a string representing the current version number.
- gCurrentVersion = llformat(
- "%s %d.%d.%d.%d",
- gSavedSettings.getString("VersionChannelName").c_str(),
- ViewerVersion::getImpMajorVersion(),
- ViewerVersion::getImpMinorVersion(),
- ViewerVersion::getImpPatchVersion(),
- 0 // our 'build number'
- );
+ // String representing the current version name/number.
+ gCurrentVersion = ViewerInfo::terseInfo();
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -1796,9 +1789,6 @@ std::string LLAppViewer::getSettingsFilename(const std::string& location_key,
bool LLAppViewer::initConfiguration()
{
- // init Imprudence version - MC
- ViewerVersion::initViewerVersion();
-
//Set up internal pointers
gSettings[sGlobalSettingsName] = &gSavedSettings;
gSettings[sPerAccountSettingsName] = &gSavedPerAccountSettings;
@@ -1846,7 +1836,7 @@ bool LLAppViewer::initConfiguration()
// gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, getSettingsFilename("Default", "Global")));
gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "settings_imprudence.xml"));
- gSavedSettings.setString("VersionChannelName", ViewerVersion::getImpViewerName());
+ gSavedSettings.setString("VersionChannelName", ViewerInfo::nameWithVariant());
//*FIX:Mani - Set default to disabling watchdog mainloop
// timeout for mac and linux. There is no call stack info
@@ -2092,7 +2082,7 @@ bool LLAppViewer::initConfiguration()
mYieldTime = gSavedSettings.getS32("YieldTime");
// XUI:translate
- gSecondLife = ViewerVersion::getImpViewerName();
+ gSecondLife = ViewerInfo::viewerName();
// Read skin/branding settings if specified.
//if (! gDirUtilp->getSkinDir().empty() )
@@ -2464,11 +2454,12 @@ void LLAppViewer::writeSystemInfo()
{
gDebugInfo["SLLog"] = LLError::logFileName();
- gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("VersionChannelName");
- gDebugInfo["ClientInfo"]["MajorVersion"] = ViewerVersion::getImpMajorVersion();
- gDebugInfo["ClientInfo"]["MinorVersion"] = ViewerVersion::getImpMinorVersion();
- gDebugInfo["ClientInfo"]["PatchVersion"] = ViewerVersion::getImpPatchVersion();
- gDebugInfo["ClientInfo"]["BuildVersion"] = 0;
+ gDebugInfo["ClientInfo"]["Name"] = ViewerInfo::viewerName();
+ gDebugInfo["ClientInfo"]["MajorVersion"] = ViewerInfo::versionMajor();
+ gDebugInfo["ClientInfo"]["MinorVersion"] = ViewerInfo::versionMinor();
+ gDebugInfo["ClientInfo"]["PatchVersion"] = ViewerInfo::versionPatch();
+ gDebugInfo["ClientInfo"]["ReleaseVersion"] = ViewerInfo::versionRelease();
+ gDebugInfo["ClientInfo"]["ExtraVersion"] = ViewerInfo::versionExtra();
gDebugInfo["CAFilename"] = gDirUtilp->getCAFile();
@@ -2553,11 +2544,12 @@ void LLAppViewer::handleViewerCrash()
//We already do this in writeSystemInfo(), but we do it again here to make /sure/ we have a version
//to check against no matter what
- gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("VersionChannelName");
- gDebugInfo["ClientInfo"]["MajorVersion"] = ViewerVersion::getImpMajorVersion();
- gDebugInfo["ClientInfo"]["MinorVersion"] = ViewerVersion::getImpMinorVersion();
- gDebugInfo["ClientInfo"]["PatchVersion"] = ViewerVersion::getImpPatchVersion();
- gDebugInfo["ClientInfo"]["BuildVersion"] = 0;
+ gDebugInfo["ClientInfo"]["Name"] = ViewerInfo::viewerName();
+ gDebugInfo["ClientInfo"]["MajorVersion"] = ViewerInfo::versionMajor();
+ gDebugInfo["ClientInfo"]["MinorVersion"] = ViewerInfo::versionMinor();
+ gDebugInfo["ClientInfo"]["PatchVersion"] = ViewerInfo::versionPatch();
+ gDebugInfo["ClientInfo"]["ReleaseVersion"] = ViewerInfo::versionRelease();
+ gDebugInfo["ClientInfo"]["ExtraVersion"] = ViewerInfo::versionExtra();
LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
if ( parcel && parcel->getMusicURL()[0])
@@ -4333,11 +4325,12 @@ void LLAppViewer::handleLoginComplete()
initMainloopTimeout("Mainloop Init");
// Store some data to DebugInfo in case of a freeze.
- gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("VersionChannelName");
- gDebugInfo["ClientInfo"]["MajorVersion"] = ViewerVersion::getImpMajorVersion();
- gDebugInfo["ClientInfo"]["MinorVersion"] = ViewerVersion::getImpMinorVersion();
- gDebugInfo["ClientInfo"]["PatchVersion"] = ViewerVersion::getImpPatchVersion();
- gDebugInfo["ClientInfo"]["BuildVersion"] = 0;
+ gDebugInfo["ClientInfo"]["Name"] = ViewerInfo::viewerName();
+ gDebugInfo["ClientInfo"]["MajorVersion"] = ViewerInfo::versionMajor();
+ gDebugInfo["ClientInfo"]["MinorVersion"] = ViewerInfo::versionMinor();
+ gDebugInfo["ClientInfo"]["PatchVersion"] = ViewerInfo::versionPatch();
+ gDebugInfo["ClientInfo"]["ReleaseVersion"] = ViewerInfo::versionRelease();
+ gDebugInfo["ClientInfo"]["ExtraVersion"] = ViewerInfo::versionExtra();
gDebugInfo["SettingsFilename"] = gSavedSettings.getString("ClientSettingsFile");
gDebugInfo["CAFilename"] = gDirUtilp->getCAFile();
diff --git a/linden/indra/newview/llfloaterabout.cpp b/linden/indra/newview/llfloaterabout.cpp
index a5d2c98..8878de5 100644
--- a/linden/indra/newview/llfloaterabout.cpp
+++ b/linden/indra/newview/llfloaterabout.cpp
@@ -59,7 +59,7 @@
#include "llglheaders.h"
#include "llviewerwindow.h"
#include "llwindow.h"
-#include "viewerversion.h"
+#include "viewerinfo.h"
// [RLVa:KB]
#include "rlvhandler.h"
@@ -120,11 +120,7 @@ LLFloaterAbout::LLFloaterAbout()
viewer_link_style->setColor(gSavedSettings.getColor4("HTMLLinkColor"));
// Version string
- std::string version = llformat(
- "%s %d.%d.%d %s (%s %s)\n",
- ViewerVersion::getImpViewerName().c_str(),
- ViewerVersion::getImpMajorVersion(), ViewerVersion::getImpMinorVersion(), ViewerVersion::getImpPatchVersion(), ViewerVersion::getImpTestVersion().c_str(),
- __DATE__, __TIME__);
+ std::string version = llformat("%s (%s %s)\n", ViewerInfo::prettyInfo().c_str(), __DATE__, __TIME__);
support_widget->appendColoredText(version, FALSE, FALSE, gColors.getColor("TextFgReadOnlyColor"));
support_widget->appendStyledText(LLTrans::getString("ReleaseNotes"), false, false, viewer_link_style);
@@ -318,13 +314,13 @@ void LLFloaterAbout::onClickCopy(void* user_data)
static std::string get_viewer_release_notes_url()
{
std::ostringstream version;
- version << ViewerVersion::getImpMajorVersion() << "."
- << ViewerVersion::getImpMinorVersion() << "."
- << ViewerVersion::getImpPatchVersion();
+ version << ViewerInfo::versionMajor() << "."
+ << ViewerInfo::versionMinor() << "."
+ << ViewerInfo::versionPatch();
// Append the test version if it's not empty
- if( !(ViewerVersion::getImpTestVersion().empty()) )
- version << "-" << ViewerVersion::getImpTestVersion();
+ if( !(ViewerInfo::versionExtra().empty()) )
+ version << "-" << ViewerInfo::versionExtra();
std::ostringstream url;
url << RELEASE_NOTES_BASE_URL << version.str();
diff --git a/linden/indra/newview/llfloaterreporter.cpp b/linden/indra/newview/llfloaterreporter.cpp
index 15f278d..16123ae 100644
--- a/linden/indra/newview/llfloaterreporter.cpp
+++ b/linden/indra/newview/llfloaterreporter.cpp
@@ -80,7 +80,7 @@
#include "llselectmgr.h"
#include "lluictrlfactory.h"
#include "llviewernetwork.h"
-#include "viewerversion.h"
+#include "viewerinfo.h"
#include "llassetuploadresponders.h"
@@ -742,13 +742,11 @@ LLSD LLFloaterReporter::gatherReport()
if ( mReportType == BUG_REPORT)
{
- summary << short_platform << " V" << ViewerVersion::getLLMajorVersion() << "."
- << ViewerVersion::getLLMinorVersion() << "."
- << ViewerVersion::getLLPatchVersion() << "."
- << ViewerVersion::getLLBuildVersion()
- << " (" << regionp->getName() << ")"
- << "[" << category_name << "] "
- << "\"" << childGetValue("summary_edit").asString() << "\"";
+ summary << short_platform << " "
+ << ViewerInfo::terseInfo()
+ << " (" << regionp->getName() << ")"
+ << "[" << category_name << "] "
+ << "\"" << childGetValue("summary_edit").asString() << "\"";
}
else
{
@@ -763,10 +761,7 @@ LLSD LLFloaterReporter::gatherReport()
std::ostringstream details;
if (mReportType != BUG_REPORT)
{
- details << "V" << ViewerVersion::getLLMajorVersion() << "." // client version moved to body of email for abuse reports
- << ViewerVersion::getLLMinorVersion() << "."
- << ViewerVersion::getLLPatchVersion() << "."
- << ViewerVersion::getLLBuildVersion() << std::endl << std::endl;
+ details << ViewerInfo::terseInfo() << std::endl << std::endl;
}
std::string object_name = childGetText("object_name");
std::string owner_name = childGetText("owner_name");
@@ -786,10 +781,8 @@ LLSD LLFloaterReporter::gatherReport()
std::string version_string;
version_string = llformat(
- "%d.%d.%d %s %s %s %s",
- ViewerVersion::getLLMajorVersion(),
- ViewerVersion::getLLMinorVersion(),
- ViewerVersion::getLLPatchVersion(),
+ "%s %s %s %s %s",
+ ViewerInfo::terseInfo().c_str(),
platform,
gSysCPU.getFamily().c_str(),
gGLManager.mGLRenderer.c_str(),
diff --git a/linden/indra/newview/llpanellogin.cpp b/linden/indra/newview/llpanellogin.cpp
index e83a466..824c5b0 100644
--- a/linden/indra/newview/llpanellogin.cpp
+++ b/linden/indra/newview/llpanellogin.cpp
@@ -73,7 +73,7 @@
#include "lluictrlfactory.h"
#include "llhttpclient.h"
#include "llweb.h"
-#include "viewerversion.h"
+#include "viewerinfo.h"
#include "llmediactrl.h"
#include "llfloatermediabrowser.h"
@@ -264,25 +264,10 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
// childSetAction("quit_btn", onClickQuit, this);
- std::string imp_channel = gSavedSettings.getString("VersionChannelName");
- std::string imp_version = llformat("%d.%d.%d %s",
- ViewerVersion::getImpMajorVersion(),
- ViewerVersion::getImpMinorVersion(),
- ViewerVersion::getImpPatchVersion(),
- ViewerVersion::getImpTestVersion().c_str() );
-
- std::string ll_channel = ViewerVersion::getLLViewerName();
- std::string ll_version = llformat("%d.%d.%d (%d)",
- ViewerVersion::getLLMajorVersion(),
- ViewerVersion::getLLMinorVersion(),
- ViewerVersion::getLLPatchVersion(),
- ViewerVersion::getLLBuildVersion() );
+ std::string imp_version = ViewerInfo::prettyInfo();
LLTextBox* channel_text = getChild("channel_text");
- channel_text->setTextArg("[CHANNEL]", imp_channel);
channel_text->setTextArg("[VERSION]", imp_version);
- channel_text->setTextArg("[ALT_CHANNEL]", ll_channel);
- channel_text->setTextArg("[ALT_VERSION]", ll_version);
channel_text->setClickedCallback(onClickVersion);
channel_text->setCallbackUserData(this);
@@ -916,12 +901,8 @@ void LLPanelLogin::loadLoginPage()
}
// Channel and Version
- std::string version = llformat("%d.%d.%d %s",
- ViewerVersion::getImpMajorVersion(), ViewerVersion::getImpMinorVersion(),
- ViewerVersion::getImpPatchVersion(), ViewerVersion::getImpTestVersion().c_str() );
-
- char* curl_channel = curl_escape(gSavedSettings.getString("VersionChannelName").c_str(), 0);
- char* curl_version = curl_escape(version.c_str(), 0);
+ char* curl_channel = curl_escape(ViewerInfo::nameWithVariant().c_str(), 0);
+ char* curl_version = curl_escape(ViewerInfo::versionNumbers4().c_str(), 0);
oStr << "&channel=" << curl_channel;
oStr << "&version=" << curl_version;
@@ -1373,19 +1354,10 @@ bool LLPanelLogin::loadNewsBar()
full_url << "?";
}
- std::string channel = gSavedSettings.getString("VersionChannelName");
+ std::string channel = ViewerInfo::nameWithVariant();
+ std::string version = ViewerInfo::versionNumbers4();
std::string skin = gSavedSettings.getString("SkinCurrent");
- std::string version =
- llformat("%d.%d.%d",
- ViewerVersion::getImpMajorVersion(),
- ViewerVersion::getImpMinorVersion(),
- ViewerVersion::getImpPatchVersion());
- if (!ViewerVersion::getImpTestVersion().empty())
- {
- version += " " + ViewerVersion::getImpTestVersion();
- }
-
char* curl_channel = curl_escape(channel.c_str(), 0);
char* curl_version = curl_escape(version.c_str(), 0);
char* curl_skin = curl_escape(skin.c_str(), 0);
diff --git a/linden/indra/newview/llstartup.cpp b/linden/indra/newview/llstartup.cpp
index e29dc5a..b05e36d 100644
--- a/linden/indra/newview/llstartup.cpp
+++ b/linden/indra/newview/llstartup.cpp
@@ -190,7 +190,7 @@
#include "llwaterparammanager.h"
#include "llagentlanguage.h"
#include "llsocks5.h"
-#include "viewerversion.h"
+#include "viewerinfo.h"
#include "lgghunspell_wrapper.h"
#include "jcfloater_animation_list.h"
@@ -533,9 +533,9 @@ bool idle_startup()
if(!start_messaging_system(
message_template_path,
port,
- ViewerVersion::getLLMajorVersion(),
- ViewerVersion::getLLMinorVersion(),
- ViewerVersion::getLLPatchVersion(),
+ ViewerInfo::versionMajor(),
+ ViewerInfo::versionMinor(),
+ ViewerInfo::versionPatch(),
FALSE,
std::string(),
responder,
diff --git a/linden/indra/newview/llviewermedia.cpp b/linden/indra/newview/llviewermedia.cpp
index c228468..89d7b1f 100644
--- a/linden/indra/newview/llviewermedia.cpp
+++ b/linden/indra/newview/llviewermedia.cpp
@@ -40,7 +40,7 @@
#include "llviewerimage.h"
#include "llviewerwindow.h"
#include "llviewerimagelist.h"
-//#include "viewerversion.h"
+//#include "viewerinfo.h"
#include "llpluginclassmedia.h"
@@ -261,7 +261,7 @@ std::string LLViewerMedia::getCurrentUserAgent()
std::ostringstream codec;
codec << "SecondLife/";
codec << "C64 Basic V2";
- //codec << ViewerVersion::getImpMajorVersion() << "." << ViewerVersion::getImpMinorVersion() << "." << ViewerVersion::getImpPatchVersion() << " " << ViewerVersion::getImpTestVersion();
+ //codec << " " << ViewerInfo::versionNumbers3();
//codec << " (" << channel << "; " << skin_name << " skin)";
// llinfos << codec.str() << llendl;
diff --git a/linden/indra/newview/viewerinfo.cpp b/linden/indra/newview/viewerinfo.cpp
new file mode 100644
index 0000000..3da924c
--- /dev/null
+++ b/linden/indra/newview/viewerinfo.cpp
@@ -0,0 +1,148 @@
+/**
+ * @file viewerinfo.cpp
+ * @brief Functions for querying the viewer name, version, and other info.
+ * @author Jacek Antonelli
+ *
+ * Copyright (c) 2010-2011, Jacek Antonelli
+ *
+ * This program 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 program 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 program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "viewerinfo.h"
+
+namespace ViewerInfo
+{
+
+ // These are intentionally defined here instead of in the header,
+ // because they should NOT be read directly. Use the functions.
+ const std::string NAME = "Imprudence";
+ const std::string VARNT = "";
+ const S32 MAJOR = 1;
+ const S32 MINOR = 4;
+ const S32 PATCH = 1;
+ const S32 RLEAS = 1; // increment for each beta/RC/release
+ const std::string EXTRA = "beta 1";
+
+ // Mac OS X bundle identifier. Should match the one in Info.plist.
+ const std::string BUNDLE_ID = "org.imprudenceviewer.viewer";
+
+
+ const std::string& viewerName()
+ {
+ return NAME;
+ }
+
+ const std::string& viewerVariant()
+ {
+ return VARNT;
+ }
+
+ const std::string& nameWithVariant()
+ {
+ static std::string s;
+ if (!s.empty())
+ {
+ return s;
+ }
+
+ if (VARNT.empty())
+ {
+ s = NAME;
+ }
+ else
+ {
+ s = NAME + " " + VARNT;
+ }
+
+ return s;
+ }
+
+ S32 versionMajor()
+ {
+ return MAJOR;
+ }
+
+ S32 versionMinor()
+ {
+ return MINOR;
+ }
+
+ S32 versionPatch()
+ {
+ return PATCH;
+ }
+
+ S32 versionRelease()
+ {
+ return RLEAS;
+ }
+
+ const std::string& versionExtra()
+ {
+ return EXTRA;
+ }
+
+ const std::string& versionNumbers3()
+ {
+ static std::string s = llformat("%d.%d.%d", MAJOR, MINOR, PATCH);
+ return s;
+ }
+
+ const std::string& versionNumbers4()
+ {
+ static std::string s = llformat("%d.%d.%d.%d",
+ MAJOR, MINOR, PATCH, RLEAS);
+ return s;
+ }
+
+ const std::string& prettyVersion()
+ {
+ static std::string s;
+ if (s.length() > 0)
+ {
+ return s;
+ }
+
+ s = versionNumbers3();
+
+ if (EXTRA.length() > 0)
+ {
+ s += " " + EXTRA;
+ }
+
+ return s;
+ }
+
+ const std::string& prettyInfo()
+ {
+ static std::string s = nameWithVariant() + " " + prettyVersion();
+ return s;
+ }
+
+ const std::string& terseInfo()
+ {
+ static std::string s = nameWithVariant() + " " + versionNumbers4();
+ return s;
+ }
+
+ const std::string& bundleID()
+ {
+ return BUNDLE_ID;
+ }
+
+}
diff --git a/linden/indra/newview/viewerinfo.h b/linden/indra/newview/viewerinfo.h
new file mode 100644
index 0000000..fe2e829
--- /dev/null
+++ b/linden/indra/newview/viewerinfo.h
@@ -0,0 +1,93 @@
+/**
+ * @file viewerinfo.h
+ * @brief Functions for querying the viewer name, version, and other info.
+ * @author Jacek Antonelli
+ *
+ * Copyright (c) 2010-2011, Jacek Antonelli
+ *
+ * This program 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 program 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 program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef VERSIONINFO_H
+#define VERSIONINFO_H
+
+#include "linden_common.h"
+
+namespace ViewerInfo
+{
+ /// Returns the name of the viewer.
+ const std::string& viewerName();
+
+ /// Returns the viewer variant (e.g. "Experimental").
+ /// May be empty, if no variant string was set.
+ const std::string& viewerVariant();
+
+ /// Returns a string with the viewer name and variant
+ /// (if it has one).
+ const std::string& nameWithVariant();
+
+ /// Returns the major (first) version number.
+ /// This number increases for each major release, and the
+ /// minor, patch, and release numbers are reset to zero.
+ S32 versionMajor();
+
+ /// Returns the minor (second) version number.
+ /// This number increases for each minor release, and the
+ /// patch and release numbers are reset to zero.
+ S32 versionMinor();
+
+ /// Returns the patch (third) version number.
+ /// This number increases for each patch (bugfix) release,
+ /// and the release number is reset to zero.
+ S32 versionPatch();
+
+ /// Returns the release (fourth) version number.
+ /// This number increases for each beta, release candidate,
+ /// and final release.
+ S32 versionRelease();
+
+ /// Returns the extra version string (e.g. "beta 1", "RC1").
+ /// May be empty, if no extra string was set.
+ const std::string& versionExtra();
+
+ /// Returns a three-segment dot-separated version string
+ /// ("major.minor.patch"). Intended for human reading.
+ const std::string& versionNumbers3();
+
+ /// Returns a four-segment dot-separated version string
+ /// ("major.minor.patch.release"). Intended for computer use, e.g.
+ /// login channel or version number comparison.
+ const std::string& versionNumbers4();
+
+ /// Returns the three-segment version number with extra version
+ /// string (if not empty). Intended for human reading.
+ const std::string& prettyVersion();
+
+ /// Returns the viewer name, variant (if not empty), and pretty
+ /// version. Intended for human reading.
+ const std::string& prettyInfo();
+
+ /// Returns the the viewer name, variant (if not empty), and
+ /// 4-segment version. Intended for computer use, e.g. login channel
+ /// or version number comparison.
+ const std::string& terseInfo();
+
+ /// Returns a string with the viewer's Mac OS X bundle identifier.
+ const std::string& bundleID();
+
+}
+
+#endif // VERSIONINFO_H
diff --git a/linden/indra/newview/viewerversion.cpp b/linden/indra/newview/viewerversion.cpp
deleted file mode 100644
index 95c8f76..0000000
--- a/linden/indra/newview/viewerversion.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
-* @file viewerversion.cpp
-* @brief set the viewer version in xml
-*
-* $LicenseInfo:firstyear=2009&license=viewergpl$
-*
-* Copyright (c) 2010, McCabe Maxsted
-*
-* Imprudence Viewer Source Code
-* The source code in this file ("Source Code") is provided to you
-* under the terms of the GNU General Public License, version 2.0
-* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
-* this distribution, or online at
-* http://secondlifegrid.net/programs/open_source/licensing/gplv2
-*
-* There are special exceptions to the terms and conditions of the GPL as
-* it is applied to this Source Code. View the full text of the exception
-* in the file doc/FLOSS-exception.txt in this software distribution, or
-* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
-*
-* By copying, modifying or distributing this software, you acknowledge
-* that you have read and understood your obligations described above,
-* and agree to abide by those obligations.
-*
-* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
-* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
-* COMPLETENESS OR PERFORMANCE.
-* $/LicenseInfo$
-*/
-
-#include "llviewerprecompiledheaders.h"
-
-#include "lldir.h"
-#include "llxmltree.h"
-#include "viewerversion.h"
-
-
-S32 ViewerVersion::sVersionMajor = 0;
-S32 ViewerVersion::sVersionMinor = 0;
-S32 ViewerVersion::sVersionPatch = 0;
-std::string ViewerVersion::sVersionTest = "";
-
-const std::string ViewerVersion::sViewerName = "Imprudence";
-
-ViewerVersion::ViewerVersion()
-{
-}
-
-bool ViewerVersion::initViewerVersion()
-{
- std::string file_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "viewerversion.xml");
-
- if (!gDirUtilp->fileExists(file_path))
- {
- llwarns << "Unable to find viewerversion.xml in app_settings folder" << llendl;
- return false;
- }
- else
- {
- LLXMLNodePtr root;
-
- if (!LLXMLNode::parseFile(file_path, root, NULL))
- {
- llwarns << "Unable to parse version file: " << file_path << llendl;
- return false;
- }
-
- if (root.isNull()) // shouldn't ever happen
- {
- llwarns << "Error while trying to read viewerversion.xml" << llendl;
- return false;
- }
-
- LLXMLNodePtr child_nodep = root->getFirstChild();
- while (child_nodep.notNull())
- {
- child_nodep->getAttributeS32("version_major", sVersionMajor);
- child_nodep->getAttributeS32("version_minor", sVersionMinor);
- child_nodep->getAttributeS32("version_patch", sVersionPatch);
- child_nodep->getAttributeString("version_test", sVersionTest);
-
- child_nodep = child_nodep->getNextSibling();
- }
-
- llinfos << "Version set to: " << sVersionMajor << "." << sVersionMinor << "." << sVersionPatch << " " << sVersionTest << llendl;
-
- return true;
- }
-}
diff --git a/linden/indra/newview/viewerversion.h b/linden/indra/newview/viewerversion.h
deleted file mode 100644
index d67cee5..0000000
--- a/linden/indra/newview/viewerversion.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
-* @file viewerversion.h
-* @brief set the viewer version in xml
-*
-* $LicenseInfo:firstyear=2009&license=viewergpl$
-*
-* Copyright (c) 2010, McCabe Maxsted
-*
-* Imprudence Viewer Source Code
-* The source code in this file ("Source Code") is provided to you
-* under the terms of the GNU General Public License, version 2.0
-* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
-* this distribution, or online at
-* http://secondlifegrid.net/programs/open_source/licensing/gplv2
-*
-* There are special exceptions to the terms and conditions of the GPL as
-* it is applied to this Source Code. View the full text of the exception
-* in the file doc/FLOSS-exception.txt in this software distribution, or
-* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
-*
-* By copying, modifying or distributing this software, you acknowledge
-* that you have read and understood your obligations described above,
-* and agree to abide by those obligations.
-*
-* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
-* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
-* COMPLETENESS OR PERFORMANCE.
-* $/LicenseInfo$
-*/
-
-#ifndef VIEWERVERSION_H
-#define VIEWERVERSION_H
-
-#include "llversionviewer.h" // for LL versioning only
-
-class ViewerVersion
-{
-public:
- ViewerVersion();
- /*virtual*/ ~ViewerVersion();
-
- static bool initViewerVersion();
-
- // Returns the major version of Imprudence
- static S32 getImpMajorVersion() { return sVersionMajor; }
- // Returns the minor version of Imprudence
- static S32 getImpMinorVersion() { return sVersionMinor; }
- // Returns the patch version of Imprudence
- static S32 getImpPatchVersion() { return sVersionPatch; }
- // Returns the test version of Imprudence
- static std::string getImpTestVersion() { return sVersionTest; }
- // Returns the name of the viewer. Currently always "Imprudence"
- static std::string getImpViewerName() { return sViewerName; }
-
- // Returns the major version of Second Life
- static S32 getLLMajorVersion() { return LL_VERSION_MAJOR; }
- // Returns the minor version of Second Life
- static S32 getLLMinorVersion() { return LL_VERSION_MINOR; }
- // Returns the patch version of Second Life
- static S32 getLLPatchVersion() { return LL_VERSION_PATCH; }
- // Returns the build version of Second Life
- static S32 getLLBuildVersion() { return LL_VERSION_BUILD; }
- // Returns the name of the LL viewer ("Second Life")
- static std::string getLLViewerName() { return LL_VIEWER_NAME; }
-
- // Note that the viewer channel is set in settings.xml
- // as VersionChannelName. LL_VIEWER_CHANNEL is not
- // used in Imprudence
-
-private:
- static S32 sVersionMajor;
- static S32 sVersionMinor;
- static S32 sVersionPatch;
- static std::string sVersionTest;
-
- static const std::string sViewerName;
-};
-
-#endif // VIEWERVERSION_H
--
cgit v1.1