PageRenderTime 18ms CodeModel.GetById 11ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LL_LLVIEWERNETWORK_H
  28. #define LL_LLVIEWERNETWORK_H
  29. extern const char* DEFAULT_LOGIN_PAGE;
  30. #define GRID_VALUE "name"
  31. #define GRID_LABEL_VALUE "label"
  32. #define GRID_ID_VALUE "grid_login_id"
  33. #define GRID_LOGIN_URI_VALUE "login_uri"
  34. #define GRID_HELPER_URI_VALUE "helper_uri"
  35. #define GRID_LOGIN_PAGE_VALUE "login_page"
  36. #define GRID_IS_SYSTEM_GRID_VALUE "system_grid"
  37. #define GRID_IS_FAVORITE_VALUE "favorite"
  38. #define MAINGRID "util.agni.lindenlab.com"
  39. #define GRID_LOGIN_IDENTIFIER_TYPES "login_identifier_types"
  40. // defines slurl formats associated with various grids.
  41. // we need to continue to support existing forms, as slurls
  42. // are shared between viewers that may not understand newer
  43. // forms.
  44. #define GRID_SLURL_BASE "slurl_base"
  45. #define GRID_APP_SLURL_BASE "app_slurl_base"
  46. class LLInvalidGridName
  47. {
  48. public:
  49. LLInvalidGridName(std::string grid) : mGrid(grid)
  50. {
  51. }
  52. protected:
  53. std::string mGrid;
  54. };
  55. /**
  56. * @brief A class to manage the grids available to the viewer
  57. * including persistance. This class also maintains the currently
  58. * selected grid.
  59. *
  60. **/
  61. class LLGridManager : public LLSingleton<LLGridManager>
  62. {
  63. public:
  64. // when the grid manager is instantiated, the default grids are automatically
  65. // loaded, and the grids favorites list is loaded from the xml file.
  66. LLGridManager(const std::string& grid_file);
  67. LLGridManager();
  68. ~LLGridManager();
  69. void initialize(const std::string& grid_file);
  70. // grid list management
  71. // add a grid to the list of grids
  72. void addGrid(LLSD& grid_info);
  73. // retrieve a map of grid-name <-> label
  74. // by default only return the user visible grids
  75. std::map<std::string, std::string> getKnownGrids(bool favorites_only=FALSE);
  76. void getGridInfo(const std::string& grid, LLSD &grid_info);
  77. // current grid management
  78. // select a given grid as the current grid. If the grid
  79. // is not a known grid, then it's assumed to be a dns name for the
  80. // grid, and the various URIs will be automatically generated.
  81. void setGridChoice(const std::string& grid);
  82. std::string getGridLabel() { return mGridList[mGrid][GRID_LABEL_VALUE]; }
  83. std::string getGrid() const { return mGrid; }
  84. void getLoginURIs(std::vector<std::string>& uris);
  85. std::string getHelperURI();
  86. std::string getLoginPage();
  87. std::string getGridLoginID() { return mGridList[mGrid][GRID_ID_VALUE]; }
  88. std::string getLoginPage(const std::string& grid) { return mGridList[grid][GRID_LOGIN_PAGE_VALUE]; }
  89. void getLoginIdentifierTypes(LLSD& idTypes) { idTypes = mGridList[mGrid][GRID_LOGIN_IDENTIFIER_TYPES]; }
  90. // build a slurl for the given region within the selected grid
  91. std::string getSLURLBase(const std::string& grid);
  92. std::string getSLURLBase() { return getSLURLBase(mGrid); }
  93. std::string getAppSLURLBase(const std::string& grid);
  94. std::string getAppSLURLBase() { return getAppSLURLBase(mGrid); }
  95. void getGridInfo(LLSD &grid_info) { getGridInfo(mGrid, grid_info); }
  96. std::string getGridByLabel( const std::string &grid_label, bool case_sensitive = false);
  97. bool isSystemGrid(const std::string& grid)
  98. {
  99. return mGridList.has(grid) &&
  100. mGridList[grid].has(GRID_IS_SYSTEM_GRID_VALUE) &&
  101. mGridList[grid][GRID_IS_SYSTEM_GRID_VALUE].asBoolean();
  102. }
  103. bool isSystemGrid() { return isSystemGrid(mGrid); }
  104. // Mark this grid as a favorite that should be persisited on 'save'
  105. // this is currently used to persist a grid after a successful login
  106. void setFavorite() { mGridList[mGrid][GRID_IS_FAVORITE_VALUE] = TRUE; }
  107. bool isInProductionGrid();
  108. void saveFavorites();
  109. void clearFavorites();
  110. protected:
  111. void updateIsInProductionGrid();
  112. // helper function for adding the predefined grids
  113. void addSystemGrid(const std::string& label,
  114. const std::string& name,
  115. const std::string& login,
  116. const std::string& helper,
  117. const std::string& login_page,
  118. const std::string& login_id = "");
  119. std::string mGrid;
  120. std::string mGridFile;
  121. LLSD mGridList;
  122. bool mIsInProductionGrid;
  123. };
  124. const S32 MAC_ADDRESS_BYTES = 6;
  125. #endif