summaryrefslogtreecommitdiff
path: root/indra/newview/llviewernetwork.h
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2012-06-12 21:58:52 -0400
committerOz Linden <oz@lindenlab.com>2012-06-12 21:58:52 -0400
commitd500379cea865e4a6958eee82b5615ace61036c4 (patch)
treee1646aa036beae68d5d15371d7ea2731ad49602c /indra/newview/llviewernetwork.h
parentce563795e1f5d7493b975393bea9ec5cab90fd6a (diff)
PATH-735: Limit and clean up grid selection
Diffstat (limited to 'indra/newview/llviewernetwork.h')
-rw-r--r--indra/newview/llviewernetwork.h206
1 files changed, 138 insertions, 68 deletions
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<LLGridManager>
{
-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<std::string, std::string> 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<std::string, std::string> 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<std::string>& 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<std::string>& 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,