summaryrefslogtreecommitdiff
path: root/indra/newview/llviewernetwork.cpp
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2008-06-06 22:43:38 +0000
committerSteven Bennetts <steve@lindenlab.com>2008-06-06 22:43:38 +0000
commitad332810078a0bbb8fa08fcbfdf3d756de6914f6 (patch)
tree1608b2db5d620d323673607ea7ddadfba9d58bda /indra/newview/llviewernetwork.cpp
parenta7d9a543e587ffe84b355db7a2e8193bfe6c68b6 (diff)
QAR-650 - Viewer RC 9 merge -> release (post cmake)
merge release@88802 Branch_1-20-Viewer-2-merge-1@89178 -> release
Diffstat (limited to 'indra/newview/llviewernetwork.cpp')
-rw-r--r--indra/newview/llviewernetwork.cpp201
1 files changed, 197 insertions, 4 deletions
diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp
index b0ebc64b7a..fed98d5daa 100644
--- a/indra/newview/llviewernetwork.cpp
+++ b/indra/newview/llviewernetwork.cpp
@@ -33,8 +33,17 @@
#include "llviewerprecompiledheaders.h"
#include "llviewernetwork.h"
+#include "llviewercontrol.h"
-LLGridData gGridInfo[GRID_INFO_COUNT] =
+struct LLGridData
+{
+ const char* mLabel;
+ const char* mName;
+ const char* mLoginURI;
+ const char* mHelperURI;
+};
+
+static LLGridData gGridInfo[GRID_INFO_COUNT] =
{
{ "None", "", "", ""},
{ "Aditi",
@@ -111,8 +120,192 @@ LLGridData gGridInfo[GRID_INFO_COUNT] =
"" }
};
-// Use this to figure out which domain name and login URI to use.
+#if LL_RELEASE_FOR_DOWNLOAD
+ // Default userserver for production builds is agni
+ const EGridInfo DEFAULT_GRID_CHOICE = GRID_INFO_AGNI;
+#else
+ // Default userserver for development builds is none
+ const EGridInfo DEFAULT_GRID_CHOICE = GRID_INFO_NONE;
+#endif
-EGridInfo gGridChoice = GRID_INFO_NONE;
-LLString gGridName; /* Flawfinder: ignore */
unsigned char gMACAddress[MAC_ADDRESS_BYTES]; /* Flawfinder: ignore */
+
+LLViewerLogin::LLViewerLogin() :
+ mGridChoice(DEFAULT_GRID_CHOICE)
+{
+}
+
+void LLViewerLogin::setGridChoice(EGridInfo grid)
+{
+ if(grid < 0 || grid >= GRID_INFO_COUNT)
+ {
+ llerrs << "Invalid grid index specified." << llendl;
+ }
+
+ if(mGridChoice != grid)
+ {
+ mGridChoice = grid;
+ if(GRID_INFO_LOCAL == mGridChoice)
+ {
+ mGridName = LOOPBACK_ADDRESS_STRING;
+ }
+ else if(GRID_INFO_OTHER == mGridChoice)
+ {
+ // *FIX:Mani - could this possibly be valid?
+ mGridName = "other";
+ }
+ else
+ {
+ mGridName = gGridInfo[mGridChoice].mLabel;
+ }
+
+ gSavedSettings.setS32("ServerChoice", mGridChoice);
+ gSavedSettings.setString("CustomServer", "");
+ }
+}
+
+void LLViewerLogin::setGridChoice(const std::string& grid_name)
+{
+ // Set the grid choice based on a string.
+ // The string can be:
+ // - a grid label from the gGridInfo table
+ // - an ip address
+ if(!grid_name.empty())
+ {
+ // find the grid choice from the user setting.
+ int grid_index = GRID_INFO_NONE;
+ for(;grid_index < GRID_INFO_OTHER; ++grid_index)
+ {
+ if(0 == LLString::compareInsensitive(gGridInfo[grid_index].mLabel, grid_name.c_str()))
+ {
+ // Founding a matching label in the list...
+ setGridChoice((EGridInfo)grid_index);
+ break;
+ }
+ }
+
+ if(GRID_INFO_OTHER == grid_index)
+ {
+ // *FIX:MEP Can and should we validate that this is an IP address?
+ mGridChoice = GRID_INFO_OTHER;
+ mGridName = grid_name;
+ gSavedSettings.setS32("ServerChoice", mGridChoice);
+ gSavedSettings.setString("CustomServer", mGridName);
+ }
+ }
+}
+
+void LLViewerLogin::resetURIs()
+{
+ // Clear URIs when picking a new server
+ gSavedSettings.setValue("CmdLineLoginURI", LLSD::emptyArray());
+ gSavedSettings.setString("CmdLineHelperURI", "");
+}
+
+EGridInfo LLViewerLogin::getGridChoice() const
+{
+ return mGridChoice;
+}
+
+std::string LLViewerLogin::getGridLabel() const
+{
+ if(mGridChoice == GRID_INFO_NONE)
+ {
+ return "None";
+ }
+ else if(mGridChoice < GRID_INFO_OTHER)
+ {
+ return gGridInfo[mGridChoice].mLabel;
+ }
+
+ return mGridName;
+}
+
+std::string LLViewerLogin::getKnownGridLabel(EGridInfo grid_index) const
+{
+ if(grid_index > GRID_INFO_NONE && grid_index < GRID_INFO_OTHER)
+ {
+ return gGridInfo[grid_index].mLabel;
+ }
+ return gGridInfo[GRID_INFO_NONE].mLabel;
+}
+
+void LLViewerLogin::getLoginURIs(std::vector<std::string>& uris) const
+{
+ // return the login uri set on the command line.
+ LLControlVariable* c = gSavedSettings.getControl("CmdLineLoginURI");
+ if(c)
+ {
+ LLSD v = c->getValue();
+ if(v.isArray())
+ {
+ for(LLSD::array_const_iterator itr = v.beginArray();
+ itr != v.endArray(); ++itr)
+ {
+ std::string uri = itr->asString();
+ if(!uri.empty())
+ {
+ uris.push_back(uri);
+ }
+ }
+ }
+ else
+ {
+ std::string uri = v.asString();
+ if(!uri.empty())
+ {
+ uris.push_back(uri);
+ }
+ }
+ }
+
+ // If there was no command line uri...
+ if(uris.empty())
+ {
+ // If its a known grid choice, get the uri from the table,
+ // else try the grid name.
+ if(mGridChoice > GRID_INFO_NONE && mGridChoice < GRID_INFO_OTHER)
+ {
+ uris.push_back(gGridInfo[mGridChoice].mLoginURI);
+ }
+ else
+ {
+ uris.push_back(mGridName);
+ }
+ }
+}
+
+std::string LLViewerLogin::getHelperURI() const
+{
+ std::string helper_uri = gSavedSettings.getString("CmdLineHelperURI");
+ if (helper_uri.empty())
+ {
+ // grab URI from selected grid
+ if(mGridChoice > GRID_INFO_NONE && mGridChoice < GRID_INFO_OTHER)
+ {
+ helper_uri = gGridInfo[mGridChoice].mHelperURI;
+ }
+
+ if (helper_uri.empty())
+ {
+ // what do we do with unnamed/miscellaneous grids?
+ // for now, operations that rely on the helper URI (currency/land purchasing) will fail
+ }
+ }
+ return helper_uri;
+}
+
+bool LLViewerLogin::isInProductionGrid()
+{
+ // *NOTE:Mani This used to compare GRID_INFO_AGNI to gGridChoice,
+ // but it seems that loginURI trumps that.
+ std::vector<std::string> uris;
+ getLoginURIs(uris);
+ LLString::toLower(uris[0]);
+ if((uris[0].find("agni") != std::string::npos))
+ {
+ return true;
+ }
+
+ return false;
+}