From d500379cea865e4a6958eee82b5615ace61036c4 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 12 Jun 2012 21:58:52 -0400 Subject: PATH-735: Limit and clean up grid selection --- indra/newview/app_settings/cmd_line.xml | 34 +- indra/newview/llappviewer.cpp | 6 +- indra/newview/llappviewerlinux.cpp | 2 +- indra/newview/llfloatermodelpreview.cpp | 2 +- indra/newview/llmarketplacefunctions.cpp | 8 +- indra/newview/llpanellogin.cpp | 29 +- indra/newview/llslurl.cpp | 2 +- indra/newview/llstartup.cpp | 3 +- indra/newview/llurldispatcher.cpp | 8 +- indra/newview/llviewernetwork.cpp | 645 +++++++++---------- indra/newview/llviewernetwork.h | 206 ++++-- indra/newview/llweb.cpp | 4 +- .../newview/skins/default/xui/en/notifications.xml | 9 +- indra/newview/skins/default/xui/en/panel_login.xml | 426 ++++++------- indra/newview/tests/lllogininstance_test.cpp | 4 +- indra/newview/tests/llviewernetwork_test.cpp | 697 ++++++++------------- 16 files changed, 967 insertions(+), 1118 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/cmd_line.xml b/indra/newview/app_settings/cmd_line.xml index 15434f2b8f..c02f89dee5 100644 --- a/indra/newview/app_settings/cmd_line.xml +++ b/indra/newview/app_settings/cmd_line.xml @@ -45,35 +45,13 @@ grid desc - Specify the name of the grid, local, or an IP address to connect to. + Specify the name of the grid to connect to. count 1 map-to CmdLineGridChoice - loginuri - - desc - login server and CGI script to use - count - 1 - compose - true - map-to - CmdLineLoginURI - - - helperuri - - desc - helper web CGI prefix to use - count - 1 - map-to - CmdLineHelperURI - - debugviews map-to @@ -377,16 +355,6 @@ - loginpage - - desc - Login authentication page to use. - count - 1 - map-to - LoginPage - - qa desc diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 1174d108d2..8e9e3d8ad8 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3023,8 +3023,8 @@ void LLAppViewer::writeSystemInfo() gDebugInfo["OSInfo"] = getOSInfo().getOSStringSimple(); // The user is not logged on yet, but record the current grid choice login url - // which may have been the intended grid. This can b - gDebugInfo["GridName"] = LLGridManager::getInstance()->getGridLabel(); + // which may have been the intended grid. + gDebugInfo["GridName"] = LLGridManager::getInstance()->getGridId(); // *FIX:Mani - move this down in llappviewerwin32 #ifdef LL_WINDOWS @@ -5054,7 +5054,7 @@ void LLAppViewer::launchUpdater() #endif // *TODO change userserver to be grid on both viewer and sim, since // userserver no longer exists. - query_map["userserver"] = LLGridManager::getInstance()->getGridLabel(); + query_map["userserver"] = LLGridManager::getInstance()->getGridId(); query_map["channel"] = LLVersionInfo::getChannel(); // *TODO constantize this guy // *NOTE: This URL is also used in win_setup/lldownloader.cpp diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp index 48d02dfeaa..e8d8efdc0a 100644 --- a/indra/newview/llappviewerlinux.cpp +++ b/indra/newview/llappviewerlinux.cpp @@ -365,7 +365,7 @@ void LLAppViewerLinux::handleCrashReporting(bool reportFreeze) const char * cmdargv[] = {cmd.c_str(), "-user", - (char*)LLGridManager::getInstance()->getGridLabel().c_str(), + (char*)LLGridManager::getInstance()->getGridId().c_str(), "-name", LLAppViewer::instance()->getSecondLifeTitle().c_str(), NULL}; diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 7448f2bb2a..e8cf7d1ba4 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -498,7 +498,7 @@ BOOL LLFloaterModelPreview::postBuild() text->setMouseDownCallback(boost::bind(&LLModelPreview::setPreviewLOD, mModelPreview, i)); } } - std::string current_grid = LLGridManager::getInstance()->getGridLabel(); + std::string current_grid = LLGridManager::getInstance()->getGridId(); std::transform(current_grid.begin(),current_grid.end(),current_grid.begin(),::tolower); std::string validate_url; if (current_grid == "agni") diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 93dd82957f..1e1243c78a 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -47,16 +47,16 @@ static std::string getMarketplaceDomain() if (!LLGridManager::getInstance()->isInProductionGrid()) { - const std::string& grid_label = LLGridManager::getInstance()->getGridLabel(); - const std::string& grid_label_lower = utf8str_tolower(grid_label); + const std::string& grid_id = LLGridManager::getInstance()->getGridId(); + const std::string& grid_id_lower = utf8str_tolower(grid_id); - if (grid_label_lower == "damballah") + if (grid_id_lower == "damballah") { domain = "secondlife-staging.com"; } else { - domain = llformat("%s.lindenlab.com", grid_label_lower.c_str()); + domain = llformat("%s.lindenlab.com", grid_id_lower.c_str()); } } diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 76aadcd913..6c50a9c374 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -761,7 +761,7 @@ void LLPanelLogin::loadLoginPage() curl_free(curl_version); // Grid - char* curl_grid = curl_escape(LLGridManager::getInstance()->getGridLabel().c_str(), 0); + char* curl_grid = curl_escape(LLGridManager::getInstance()->getGridId().c_str(), 0); oStr << "&grid=" << curl_grid; curl_free(curl_grid); @@ -828,7 +828,7 @@ void LLPanelLogin::onClickConnect(void *) catch (LLInvalidGridName ex) { LLSD args; - args["GRID"] = combo_val.asString(); + args["GRID"] = ex.name(); LLNotificationsUtil::add("InvalidGrid", args); return; } @@ -939,7 +939,11 @@ void LLPanelLogin::updateServer() } catch (LLInvalidGridName ex) { - // do nothing + LL_WARNS("AppInit")<<"server '"<getChild("server_combo"); server_choice_combo->removeall(); - std::map known_grids = LLGridManager::getInstance()->getKnownGrids(!gSavedSettings.getBOOL("ShowBetaGrids")); + std::string current_grid = LLGridManager::getInstance()->getGrid(); + std::map known_grids = LLGridManager::getInstance()->getKnownGrids(); for (std::map::iterator grid_choice = known_grids.begin(); grid_choice != known_grids.end(); grid_choice++) { - if (!grid_choice->first.empty()) + if (!grid_choice->first.empty() && current_grid != grid_choice->first) { + LL_DEBUGS("AppInit")<<"adding "<first<add(grid_choice->second, grid_choice->first); } } @@ -968,9 +974,11 @@ void LLPanelLogin::updateServerCombo() server_choice_combo->addSeparator(ADD_TOP); + LL_DEBUGS("AppInit")<<"adding current "<add(LLGridManager::getInstance()->getGridLabel(), - LLGridManager::getInstance()->getGrid(), ADD_TOP); - + current_grid, + ADD_TOP); + server_choice_combo->selectFirstItem(); } @@ -980,7 +988,7 @@ void LLPanelLogin::onSelectServer(LLUICtrl*, void*) // *NOTE: The paramters for this method are ignored. // LLPanelLogin::onServerComboLostFocus(LLFocusableElement* fe, void*) // calls this method. - LL_INFOS("AppInit") << "onSelectServer" << LL_ENDL; + // The user twiddled with the grid choice ui. // apply the selection to the grid setting. LLPointer credential; @@ -991,6 +999,7 @@ void LLPanelLogin::onSelectServer(LLUICtrl*, void*) { combo_val = combo->getValue(); } + LL_INFOS("AppInit") << "onSelectServer "<getChild("start_location_combo"); combo->setCurrentByIndex(1); @@ -1019,9 +1028,7 @@ void LLPanelLogin::onServerComboLostFocus(LLFocusableElement* fe) void LLPanelLogin::updateLoginPanelLinks() { - LLSD grid_data; - LLGridManager::getInstance()->getGridInfo(grid_data); - bool system_grid = grid_data.has(GRID_IS_SYSTEM_GRID_VALUE); + bool system_grid = LLGridManager::getInstance()->isSystemGrid(); // need to call through sInstance, as it's called from onSelectServer, which // is static. diff --git a/indra/newview/llslurl.cpp b/indra/newview/llslurl.cpp index a853726dea..657a261945 100644 --- a/indra/newview/llslurl.cpp +++ b/indra/newview/llslurl.cpp @@ -138,7 +138,7 @@ LLSLURL::LLSLURL(const std::string& slurl) // so parse the grid name to derive the grid ID if (!slurl_uri.hostName().empty()) { - mGrid = LLGridManager::getInstance()->getGridByLabel(slurl_uri.hostName()); + mGrid = LLGridManager::getInstance()->getGrid(slurl_uri.hostName()); } else if(path_array[0].asString() == LLSLURL::SLURL_SECONDLIFE_PATH) { diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 0ac8c1fe39..f7d1e2a331 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -994,7 +994,7 @@ bool idle_startup() if(STATE_LOGIN_AUTH_INIT == LLStartUp::getStartupState()) { - gDebugInfo["GridName"] = LLGridManager::getInstance()->getGridLabel(); + gDebugInfo["GridName"] = LLGridManager::getInstance()->getGridId(); // Update progress status and the display loop. auth_desc = LLTrans::getString("LoginInProgress"); @@ -1158,7 +1158,6 @@ bool idle_startup() LLVoiceClient::getInstance()->userAuthorized(gUserCredential->userID(), gAgentID); // create the default proximal channel LLVoiceChannel::initClass(); - LLGridManager::getInstance()->setFavorite(); LLStartUp::setStartupState( STATE_WORLD_INIT); } else diff --git a/indra/newview/llurldispatcher.cpp b/indra/newview/llurldispatcher.cpp index 4240a38326..f514254f8f 100644 --- a/indra/newview/llurldispatcher.cpp +++ b/indra/newview/llurldispatcher.cpp @@ -211,12 +211,12 @@ void LLURLDispatcherImpl::regionHandleCallback(U64 region_handle, const LLSLURL& LLSD args; args["SLURL"] = slurl.getLocationString(); args["CURRENT_GRID"] = LLGridManager::getInstance()->getGridLabel(); - LLSD grid_info; - LLGridManager::getInstance()->getGridInfo(slurl.getGrid(), grid_info); + std::string grid_label = + LLGridManager::getInstance()->getGridLabel(slurl.getGrid()); - if(grid_info.has(GRID_LABEL_VALUE)) + if(!grid_label.empty()) { - args["GRID"] = grid_info[GRID_LABEL_VALUE].asString(); + args["GRID"] = grid_label; } else { diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp index ef5c65eb87..b8994d2182 100644 --- a/indra/newview/llviewernetwork.cpp +++ b/indra/newview/llviewernetwork.cpp @@ -1,4 +1,4 @@ -/** +/** * @file llviewernetwork.cpp * @author James Cook, Richard Nelson * @brief Networking constants and globals for viewer. @@ -6,21 +6,21 @@ * $LicenseInfo:firstyear=2006&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, 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$ */ @@ -34,13 +34,39 @@ #include "lltrans.h" #include "llweb.h" - -const char* DEFAULT_LOGIN_PAGE = "http://viewer-login.agni.lindenlab.com/"; -const char* SYSTEM_GRID_SLURL_BASE = "secondlife://%s/secondlife/"; -const char* MAIN_GRID_SLURL_BASE = "http://maps.secondlife.com/secondlife/"; -const char* SYSTEM_GRID_APP_SLURL_BASE = "secondlife:///app"; +/// key used to store the grid, and the name attribute in the grid data +const std::string GRID_VALUE = "name"; +/// the value displayed in the grid selector menu, and other human-oriented text +const std::string GRID_LABEL_VALUE = "label"; +/// the value used on the --grid command line argument +const std::string GRID_ID_VALUE = "grid_login_id"; +/// the url for the login cgi script +const std::string GRID_LOGIN_URI_VALUE = "login_uri"; +/// +const std::string GRID_HELPER_URI_VALUE = "helper_uri"; +/// the splash page url +const std::string GRID_LOGIN_PAGE_VALUE = "login_page"; +/// internal data on system grids +const std::string GRID_IS_SYSTEM_GRID_VALUE = "system_grid"; +/// whether this is single or double names +const std::string GRID_LOGIN_IDENTIFIER_TYPES = "login_identifier_types"; + +// defines slurl formats associated with various grids. +// we need to continue to support existing forms, as slurls +// are shared between viewers that may not understand newer +// forms. +const std::string GRID_SLURL_BASE = "slurl_base"; +const std::string GRID_APP_SLURL_BASE = "app_slurl_base"; + +const std::string DEFAULT_LOGIN_PAGE = "http://viewer-login.agni.lindenlab.com/"; + +const std::string MAIN_GRID_LOGIN_URI = "https://login.agni.lindenlab.com/cgi-bin/login.cgi"; + +const std::string MAIN_GRID_SLURL_BASE = "http://maps.secondlife.com/secondlife/"; +const std::string SYSTEM_GRID_APP_SLURL_BASE = "secondlife:///app"; +const char* SYSTEM_GRID_SLURL_BASE = "secondlife://%s/secondlife/"; const char* DEFAULT_SLURL_BASE = "https://%s/region/"; const char* DEFAULT_APP_SLURL_BASE = "x-grid-location-info://%s/app"; @@ -54,14 +80,17 @@ LLGridManager::LLGridManager() // an attacker. Don't want someone snagging a password. std::string grid_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grids.xml"); + LL_DEBUGS("GridManager")<first; LLSD grid = grid_itr->second; - // TODO: Make sure gridfile specified label is not - // a system grid label - LL_DEBUGS("GridManager") << "reading: " << key_name << LL_ENDL; - if (mGridList.has(key_name) && - mGridList[key_name].has(GRID_IS_SYSTEM_GRID_VALUE)) + + std::string existingGrid = getGrid(grid); + if (mGridList.has(key_name) || !existingGrid.empty()) { - LL_DEBUGS("GridManager") << "Cannot override grid " << key_name << " as it's a system grid" << LL_ENDL; - // If the system grid does exist in the grids file, and it's marked as a favorite, set it as a favorite. - if(grid_itr->second.has(GRID_IS_FAVORITE_VALUE) && grid_itr->second[GRID_IS_FAVORITE_VALUE].asBoolean() ) - { - mGridList[key_name][GRID_IS_FAVORITE_VALUE] = TRUE; - } + LL_WARNS("GridManager") << "Cannot override existing grid '" << key_name << "'; ignoring definition from '"<asString()<<"\n"; + } + LL_CONT << LL_ENDL; + mGridList[grid] = grid_data; + } + else + { + LL_WARNS("GridManager")<<"duplicate grid id'"< grid label mappings for UI purposes -std::map LLGridManager::getKnownGrids(bool favorite_only) +std::map LLGridManager::getKnownGrids() { std::map result; for(LLSD::map_iterator grid_iter = mGridList.beginMap(); grid_iter != mGridList.endMap(); - grid_iter++) + grid_iter++) { - if(!favorite_only || grid_iter->second.has(GRID_IS_FAVORITE_VALUE)) - { - result[grid_iter->first] = grid_iter->second[GRID_LABEL_VALUE].asString(); - } + result[grid_iter->first] = grid_iter->second[GRID_LABEL_VALUE].asString(); } return result; } - void LLGridManager::setGridChoice(const std::string& grid) { // Set the grid choice based on a string. - // The string can be: - // - a grid label from the gGridInfo table - // - a hostname - // - an ip address + // The string must be a grid label from the gGridInfo table // loop through. We could do just a hash lookup but we also want to match - // on label + // on the id std::string grid_name = grid; if(!mGridList.has(grid_name)) { // case insensitive - grid_name = getGridByLabel(grid); + grid_name = getGrid(grid); } - + if(grid_name.empty()) { // the grid was not in the list of grids. LLSD grid_data = LLSD::emptyMap(); grid_data[GRID_VALUE] = grid; - addGrid(grid_data); + addGrid(grid_data); } mGrid = grid; gSavedSettings.setString("CurrentGrid", grid); @@ -510,61 +408,139 @@ void LLGridManager::setGridChoice(const std::string& grid) updateIsInProductionGrid(); } -std::string LLGridManager::getGridByLabel( const std::string &grid_label, bool case_sensitive) +std::string LLGridManager::getGrid( const std::string &grid ) { - for(LLSD::map_iterator grid_iter = mGridList.beginMap(); - grid_iter != mGridList.endMap(); - grid_iter++) + std::string grid_name; + + if (mGridList.has(grid)) { - if (grid_iter->second.has(GRID_LABEL_VALUE)) + // the grid was the long name, so we're good, return it + grid_name = grid; + } + else + { + // search the grid list for a grid with a matching id + for(LLSD::map_iterator grid_iter = mGridList.beginMap(); + grid_name.empty() && grid_iter != mGridList.endMap(); + grid_iter++) { - if (0 == (case_sensitive?LLStringUtil::compareStrings(grid_label, grid_iter->second[GRID_LABEL_VALUE].asString()): - LLStringUtil::compareInsensitive(grid_label, grid_iter->second[GRID_LABEL_VALUE].asString()))) + if (grid_iter->second.has(GRID_ID_VALUE)) { - return grid_iter->first; + if (0 == (LLStringUtil::compareInsensitive(grid, + grid_iter->second[GRID_ID_VALUE].asString()))) + { + // found a matching label, return this name + grid_name = grid_iter->first; + } } } } - return std::string(); + return grid_name; } -void LLGridManager::getLoginURIs(std::vector& uris) +std::string LLGridManager::getGridLabel(const std::string& grid) +{ + std::string grid_label; + std::string grid_name = getGrid(grid); + if (!grid.empty()) + { + grid_label = mGridList[grid_name][GRID_LABEL_VALUE].asString(); + } + else + { + LL_WARNS("GridManager")<<"invalid grid '"<& uris) { uris.clear(); - LLSD cmd_line_login_uri = gSavedSettings.getLLSD("CmdLineLoginURI"); - if (cmd_line_login_uri.isString()) - { - uris.push_back(cmd_line_login_uri); - return; + std::string grid_name = getGrid(grid); + if (!grid_name.empty()) + { + for (LLSD::array_iterator llsd_uri = mGridList[grid_name][GRID_LOGIN_URI_VALUE].beginArray(); + llsd_uri != mGridList[grid_name][GRID_LOGIN_URI_VALUE].endArray(); + llsd_uri++) + { + uris.push_back(llsd_uri->asString()); + } } - for (LLSD::array_iterator llsd_uri = mGridList[mGrid][GRID_LOGIN_URI_VALUE].beginArray(); - llsd_uri != mGridList[mGrid][GRID_LOGIN_URI_VALUE].endArray(); - llsd_uri++) + else { - uris.push_back(llsd_uri->asString()); + LL_WARNS("GridManager")<<"invalid grid '"<& uris) +{ + getLoginURIs(mGrid, uris); +} + +std::string LLGridManager::getHelperURI(const std::string& grid) +{ + std::string helper_uri; + std::string grid_name = getGrid(grid); + if (!grid_name.empty()) + { + helper_uri = mGridList[grid_name][GRID_HELPER_URI_VALUE].asString(); + } + else + { + LL_WARNS("GridManager")<<"invalid grid '"<::iterator uri_it = uris.begin(); + ! mIsInProductionGrid && uri_it != uris.end(); + uri_it++ + ) + { + if( MAIN_GRID_LOGIN_URI == *uri_it ) + { + mIsInProductionGrid = true; + } + } } } @@ -593,25 +575,16 @@ bool LLGridManager::isInProductionGrid() return mIsInProductionGrid; } -void LLGridManager::saveFavorites() +bool LLGridManager::isSystemGrid(const std::string& grid) { - // filter out just those marked as favorites - LLSD output_grid_list = LLSD::emptyMap(); - for(LLSD::map_iterator grid_iter = mGridList.beginMap(); - grid_iter != mGridList.endMap(); - grid_iter++) - { - if(grid_iter->second.has(GRID_IS_FAVORITE_VALUE)) - { - output_grid_list[grid_iter->first] = grid_iter->second; - } - } - llofstream llsd_xml; - llsd_xml.open( mGridFile.c_str(), std::ios::out | std::ios::binary); - LLSDSerialize::toPrettyXML(output_grid_list, llsd_xml); - llsd_xml.close(); -} + std::string grid_name = getGrid(grid); + return ( !grid_name.empty() + && mGridList.has(grid) + && mGridList[grid].has(GRID_IS_SYSTEM_GRID_VALUE) + && mGridList[grid][GRID_IS_SYSTEM_GRID_VALUE].asBoolean() + ); +} // build a slurl for the given region within the selected grid std::string LLGridManager::getSLURLBase(const std::string& grid) diff --git a/indra/newview/llviewernetwork.h b/indra/newview/llviewernetwork.h index 15e25b4952..802badd494 100644 --- a/indra/newview/llviewernetwork.h +++ b/indra/newview/llviewernetwork.h @@ -27,113 +27,183 @@ #ifndef LL_LLVIEWERNETWORK_H #define LL_LLVIEWERNETWORK_H - -extern const char* DEFAULT_LOGIN_PAGE; - -#define GRID_VALUE "name" -#define GRID_LABEL_VALUE "label" -#define GRID_ID_VALUE "grid_login_id" -#define GRID_LOGIN_URI_VALUE "login_uri" -#define GRID_HELPER_URI_VALUE "helper_uri" -#define GRID_LOGIN_PAGE_VALUE "login_page" -#define GRID_IS_SYSTEM_GRID_VALUE "system_grid" -#define GRID_IS_FAVORITE_VALUE "favorite" + +// @TODO this really should be private, but is used in llslurl #define MAINGRID "util.agni.lindenlab.com" -#define GRID_LOGIN_IDENTIFIER_TYPES "login_identifier_types" -// defines slurl formats associated with various grids. -// we need to continue to support existing forms, as slurls -// are shared between viewers that may not understand newer -// forms. -#define GRID_SLURL_BASE "slurl_base" -#define GRID_APP_SLURL_BASE "app_slurl_base" +/// Exception thrown when a grid is not valid class LLInvalidGridName { public: LLInvalidGridName(std::string grid) : mGrid(grid) { } + std::string name() { return mGrid; } protected: std::string mGrid; }; - /** - * @brief A class to manage the grids available to the viewer - * including persistance. This class also maintains the currently - * selected grid. - * + * @brief A singleton class to manage the grids available to the viewer. + * + * This class maintains several properties for each known grid, and provides + * interfaces for obtaining each of these properties given a specified + * grid. Grids are specified by either of two identifiers, each of which + * must be unique among all known grids: + * - grid name : DNS name for the grid + * - grid id : a short form (conventionally a single word) + * + * This class maintains the currently selected grid, and provides short + * form accessors for each of the properties of the selected grid. **/ class LLGridManager : public LLSingleton { -public: - - // when the grid manager is instantiated, the default grids are automatically - // loaded, and the grids favorites list is loaded from the xml file. + public: + /* ================================================================ + * @name Initialization and Configuration + * @{ + */ + /// Instantiate the grid manager, load default grids, selects the default grid LLGridManager(const std::string& grid_file); LLGridManager(); ~LLGridManager(); + /// add grids from an external grids file void initialize(const std::string& grid_file); - // grid list management - // add a grid to the list of grids - void addGrid(LLSD& grid_info); - - // retrieve a map of grid-name <-> label - // by default only return the user visible grids - std::map getKnownGrids(bool favorites_only=FALSE); - - void getGridInfo(const std::string& grid, LLSD &grid_info); + //@} - // current grid management + /* ================================================================ + * @name Grid Identifiers + * @{ + * The id is a short form (typically one word) grid name, + * It should be used in URL path elements or parameters + * + * Each grid also has a "label", intented to be a user friendly + * descriptive form (it is used in the login panel grid menu, for example). + */ + /// Return the name of a grid, given either its name or its id + std::string getGrid( const std::string &grid ); - // select a given grid as the current grid. If the grid - // is not a known grid, then it's assumed to be a dns name for the - // grid, and the various URIs will be automatically generated. - void setGridChoice(const std::string& grid); + /// Get the id (short form selector) for a given grid + std::string getGridId(const std::string& grid); + + /// Get the id (short form selector) for the selected grid + std::string getGridId() { return getGridId(mGrid); } + + /// Get the user-friendly long form descriptor for a given grid + std::string getGridLabel(const std::string& grid); + /// Get the user-friendly long form descriptor for the selected grid + std::string getGridLabel() { return getGridLabel(mGrid); } + + /// Retrieve a map of grid-name -> label + std::map getKnownGrids(); + + //@} + + /* ================================================================ + * @name Login related properties + * @{ + */ + + /** + * Get the login uris for the specified grid. + * The login uri for a grid is the target of the authentication request. + * A grid may have multple login uris, so they are returned as a vector. + */ + void getLoginURIs(const std::string& grid, std::vector& uris); - std::string getGridLabel() { return mGridList[mGrid][GRID_LABEL_VALUE]; } - std::string getGrid() const { return mGrid; } + /// Get the login uris for the selected grid void getLoginURIs(std::vector& uris); - std::string getHelperURI(); - std::string getLoginPage(); - std::string getGridLoginID() { return mGridList[mGrid][GRID_ID_VALUE]; } - std::string getLoginPage(const std::string& grid) { return mGridList[grid][GRID_LOGIN_PAGE_VALUE]; } - void getLoginIdentifierTypes(LLSD& idTypes) { idTypes = mGridList[mGrid][GRID_LOGIN_IDENTIFIER_TYPES]; } - // build a slurl for the given region within the selected grid + /// Get the URI for webdev help functions for the specified grid + std::string getHelperURI(const std::string& grid); + + /// Get the URI for webdev help functions for the selected grid + std::string getHelperURI() { return getHelperURI(mGrid); } + + /// Get the url of the splash page to be displayed prior to login + std::string getLoginPage(const std::string& grid_name); + + /// Get the URI for the login splash page for the selected grid + std::string getLoginPage(); + + /// Get the id to be used as a short name in url path components or parameters + std::string getGridLoginID(); + + /// Get an array of the login types supported by the grid + void getLoginIdentifierTypes(LLSD& idTypes); + /**< the types are "agent" and "avatar"; + * one means single-name (someone Resident) accounts and other first/last name accounts + * I am not sure which is which + */ + + //@} + + /* ================================================================ + * @name URL Construction Properties + * @{ + */ + + /// Return the slurl prefix (everything up to but not including the region) for a given grid std::string getSLURLBase(const std::string& grid); + + /// Return the slurl prefix (everything up to but not including the region) for the selected grid std::string getSLURLBase() { return getSLURLBase(mGrid); } + /// Return the application URL prefix for the given grid std::string getAppSLURLBase(const std::string& grid); + + /// Return the application URL prefix for the selected grid std::string getAppSLURLBase() { return getAppSLURLBase(mGrid); } - - void getGridInfo(LLSD &grid_info) { getGridInfo(mGrid, grid_info); } - - std::string getGridByLabel( const std::string &grid_label, bool case_sensitive = false); - - bool isSystemGrid(const std::string& grid) - { - return mGridList.has(grid) && - mGridList[grid].has(GRID_IS_SYSTEM_GRID_VALUE) && - mGridList[grid][GRID_IS_SYSTEM_GRID_VALUE].asBoolean(); - } + + //@} + + /* ================================================================ + * @name Selecting the current grid + * @{ + * At initialization, the current grid is set by the first of: + * -# The value supplied by the --grid command line option (setting CmdLineGridChoice); + * Note that a default for this may be set at build time. + * -# The grid used most recently (setting CurrentGrid) + * -# The main grid (Agni) + */ + + /// Select a given grid as the current grid. + void setGridChoice(const std::string& grid); + + /// Returns the name of the currently selected grid + std::string getGrid() const { return mGrid; } + + //@} + + /// Is the given grid one of the hard-coded default grids (Agni or Aditi) + bool isSystemGrid(const std::string& grid); + + /// Is the selected grid one of the hard-coded default grids (Agni or Aditi) bool isSystemGrid() { return isSystemGrid(mGrid); } - // Mark this grid as a favorite that should be persisited on 'save' - // this is currently used to persist a grid after a successful login - void setFavorite() { mGridList[mGrid][GRID_IS_FAVORITE_VALUE] = TRUE; } - + + /// Is the selected grid a production grid? bool isInProductionGrid(); - void saveFavorites(); - void clearFavorites(); + /** + * yes, that's not a very helpful description. + * I don't really know why that is different from isSystemGrid() + * In practice, the implementation is that it + * @returns true if the login uri for the grid is the uri for MAINGRID + */ -protected: + private: + + /// Add a grid to the list of grids + void addGrid(LLSD& grid_info); + /// find the LLSD definition for a given grid + void getGridInfo(const std::string& grid, LLSD &grid_info); + void updateIsInProductionGrid(); - // helper function for adding the predefined grids + // helper function for adding the hard coded grids void addSystemGrid(const std::string& label, const std::string& name, const std::string& login, diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp index d2d48dc68f..83337b386d 100644 --- a/indra/newview/llweb.cpp +++ b/indra/newview/llweb.cpp @@ -185,8 +185,8 @@ std::string LLWeb::expandURLSubstitutions(const std::string &url, substitution["VERSION_PATCH"] = LLVersionInfo::getPatch(); substitution["VERSION_BUILD"] = LLVersionInfo::getBuild(); substitution["CHANNEL"] = LLVersionInfo::getChannel(); - substitution["GRID"] = LLGridManager::getInstance()->getGridLabel(); - substitution["GRID_LOWERCASE"] = utf8str_tolower(LLGridManager::getInstance()->getGridLabel()); + substitution["GRID"] = LLGridManager::getInstance()->getGridId(); + substitution["GRID_LOWERCASE"] = utf8str_tolower(LLGridManager::getInstance()->getGridId()); substitution["OS"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple(); substitution["SESSION_ID"] = gAgent.getSessionID(); substitution["FIRST_LOGIN"] = gAgent.isFirstLogin(); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index afc5b916e7..590707fceb 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -898,7 +898,14 @@ You need an account to enter [SECOND_LIFE]. Would you like to create one now? You need to enter either the Username or both the First and Last name of your avatar into the Username field, then login again. - + + fail +'[GRID]' is not a valid grid identifier. + + - - http://join.secondlife.com/ - - - http://secondlife.eniac15.lindenlab.com/reg-in-client/ - - - http://secondlife.com/account/request.php - - - - - - -Username: - - - - - - - Password: - - - -