PageRenderTime 27ms CodeModel.GetById 12ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llviewernetwork.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 153 lines | 75 code | 28 blank | 50 comment | 1 complexity | 1d78ebf76c6555a32092def4fe8d61a5 MD5 | raw file
  1/** 
  2 * @file llviewernetwork.h
  3 * @author James Cook
  4 * @brief Networking constants and globals for viewer.
  5 *
  6 * $LicenseInfo:firstyear=2006&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28#ifndef LL_LLVIEWERNETWORK_H
 29#define LL_LLVIEWERNETWORK_H
 30                                                                                                       
 31extern const char* DEFAULT_LOGIN_PAGE;
 32      
 33#define GRID_VALUE "name"
 34#define GRID_LABEL_VALUE "label"
 35#define GRID_ID_VALUE "grid_login_id"
 36#define GRID_LOGIN_URI_VALUE "login_uri"
 37#define GRID_HELPER_URI_VALUE "helper_uri"
 38#define GRID_LOGIN_PAGE_VALUE "login_page"
 39#define GRID_IS_SYSTEM_GRID_VALUE "system_grid"
 40#define GRID_IS_FAVORITE_VALUE "favorite"
 41#define MAINGRID "util.agni.lindenlab.com"
 42#define GRID_LOGIN_IDENTIFIER_TYPES "login_identifier_types"
 43// defines slurl formats associated with various grids.
 44// we need to continue to support existing forms, as slurls
 45// are shared between viewers that may not understand newer
 46// forms.
 47#define GRID_SLURL_BASE "slurl_base"
 48#define GRID_APP_SLURL_BASE "app_slurl_base"
 49
 50class LLInvalidGridName
 51{
 52public:
 53	LLInvalidGridName(std::string grid) : mGrid(grid)
 54	{
 55	}
 56protected:
 57	std::string mGrid;
 58};
 59
 60
 61/**
 62 * @brief A class to manage the grids available to the viewer
 63 * including persistance.  This class also maintains the currently
 64 * selected grid.
 65 * 
 66 **/
 67class LLGridManager : public LLSingleton<LLGridManager>
 68{
 69public:
 70	
 71	// when the grid manager is instantiated, the default grids are automatically
 72	// loaded, and the grids favorites list is loaded from the xml file.
 73	LLGridManager(const std::string& grid_file);
 74	LLGridManager();
 75	~LLGridManager();
 76	
 77	void initialize(const std::string& grid_file);
 78	// grid list management
 79	
 80	// add a grid to the list of grids
 81	void addGrid(LLSD& grid_info);	
 82
 83	// retrieve a map of grid-name <-> label
 84	// by default only return the user visible grids
 85	std::map<std::string, std::string> getKnownGrids(bool favorites_only=FALSE);
 86	
 87	void getGridInfo(const std::string& grid, LLSD &grid_info);
 88	
 89	// current grid management
 90
 91	// select a given grid as the current grid.  If the grid
 92	// is not a known grid, then it's assumed to be a dns name for the
 93	// grid, and the various URIs will be automatically generated.
 94	void setGridChoice(const std::string& grid);
 95	
 96	
 97	std::string getGridLabel() { return mGridList[mGrid][GRID_LABEL_VALUE]; } 	
 98	std::string getGrid() const { return mGrid; }
 99	void getLoginURIs(std::vector<std::string>& uris);
100	std::string getHelperURI();
101	std::string getLoginPage();
102	std::string getGridLoginID() { return mGridList[mGrid][GRID_ID_VALUE]; }	
103	std::string getLoginPage(const std::string& grid) { return mGridList[grid][GRID_LOGIN_PAGE_VALUE]; }
104	void        getLoginIdentifierTypes(LLSD& idTypes) { idTypes = mGridList[mGrid][GRID_LOGIN_IDENTIFIER_TYPES]; }
105	
106	// build a slurl for the given region within the selected grid
107	std::string getSLURLBase(const std::string& grid);
108	std::string getSLURLBase() { return getSLURLBase(mGrid); }
109	
110	std::string getAppSLURLBase(const std::string& grid);
111	std::string getAppSLURLBase() { return getAppSLURLBase(mGrid); }	
112	
113	void getGridInfo(LLSD &grid_info) { getGridInfo(mGrid, grid_info); }
114	
115	std::string getGridByLabel( const std::string &grid_label, bool case_sensitive = false);
116	
117	bool isSystemGrid(const std::string& grid) 
118	{ 
119		return mGridList.has(grid) &&
120		      mGridList[grid].has(GRID_IS_SYSTEM_GRID_VALUE) && 
121	           mGridList[grid][GRID_IS_SYSTEM_GRID_VALUE].asBoolean(); 
122	}
123	bool isSystemGrid() { return isSystemGrid(mGrid); }
124	// Mark this grid as a favorite that should be persisited on 'save'
125	// this is currently used to persist a grid after a successful login
126	void setFavorite() { mGridList[mGrid][GRID_IS_FAVORITE_VALUE] = TRUE; }
127	
128	bool isInProductionGrid();
129	void saveFavorites();
130	void clearFavorites();
131
132protected:
133
134	void updateIsInProductionGrid();
135
136	// helper function for adding the predefined grids
137	void addSystemGrid(const std::string& label, 
138					   const std::string& name, 
139					   const std::string& login, 
140					   const std::string& helper,
141					   const std::string& login_page,
142					   const std::string& login_id = "");	
143	
144	
145	std::string mGrid;
146	std::string mGridFile;
147	LLSD mGridList;
148	bool mIsInProductionGrid;
149};
150
151const S32 MAC_ADDRESS_BYTES = 6;
152
153#endif