llgridmanager.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /**
  2. * @file llgridmanager.h
  3. * @brief Grids management.
  4. *
  5. * $LicenseInfo:firstyear=2006&license=viewergpl$
  6. *
  7. * Copyright (c) 2006-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLVIEWERNETWORK_H
  33. #define LL_LLVIEWERNETWORK_H
  34. #include <time.h> // For time_t
  35. #include "llstring.h"
  36. class LLHost;
  37. #define EGridInfo S32
  38. /**
  39. * @brief A singleton class to manage the grids available to the viewer.
  40. *
  41. * This class maintains several properties for each known grid, and provides
  42. * interfaces for obtaining each of these properties given a specified
  43. * grid. Grids are specified by an identifier (the "grid host", normally
  44. * (part of) the actual domain name for the grid), which must be unique among
  45. * all known grids:
  46. **/
  47. class LLGridManager final : public LLSingleton<LLGridManager>
  48. {
  49. friend class LLSingleton<LLGridManager>;
  50. protected:
  51. LOG_CLASS(LLGridManager);
  52. public:
  53. LLGridManager();
  54. void setGridChoice(EGridInfo grid);
  55. void setGridChoice(const std::string& grid_name);
  56. LL_INLINE void setGridURI(const std::string& uri) { mGridURI = uri; }
  57. // Get the enumeration of the grid choice. Should only return values > 0
  58. // and <= GRID_INFO_OTHER
  59. LL_INLINE EGridInfo getGridChoice() const { return mGridChoice; }
  60. // Returns the readable name for the grid choice. If the grid is 'other',
  61. // returns something the string used to specifiy the grid.
  62. std::string getGridLabel();
  63. std::string getKnownGridLabel(EGridInfo grid_index) const;
  64. const std::string getStaticGridURI(const EGridInfo grid) const;
  65. const std::string getStaticGridHelperURI(const EGridInfo grid) const;
  66. const std::string& getGridURI() const { return mGridURI; }
  67. #if 0 // Not used any more since SL is now on varying IP, AWS servers...
  68. const std::string getGridIP() const;
  69. #endif
  70. const std::vector<std::string>& getCommandLineURIs();
  71. const std::string getHelperURI() const;
  72. void setHelperURI(const std::string& uri);
  73. const std::string getLoginPageURI() const;
  74. void setLoginPageURI(const std::string& uri);
  75. LL_INLINE const std::string& getWebsiteURL() const { return mWebsiteURL; }
  76. LL_INLINE const std::string& getSupportURL() const { return mSupportURL; }
  77. LL_INLINE const std::string& getAccountURL() const { return mAccountURL; }
  78. LL_INLINE const std::string& getPasswordURL() const { return mPasswordURL; }
  79. // Returns the shorter grid host matching "grid". When "grid" is omitted or
  80. // empty, returns the current grid's host.
  81. std::string getGridHost(std::string grid = LLStringUtil::null);
  82. // Returns an Id for the grid, based on its domain name (stripping leading
  83. // "prefix." and trailing ".suffix" parts). When "grid" is omitted or
  84. // empty, returns the current grid's Id.
  85. std::string getGridId(const std::string& grid = LLStringUtil::null);
  86. std::string getSLURLBase(const std::string& grid = LLStringUtil::null);
  87. std::string getAppSLURLBase(const std::string& grid = LLStringUtil::null);
  88. LL_INLINE void setNameEdited(bool value) { mNameEdited = value; }
  89. LL_INLINE bool nameEdited() const { return mNameEdited; }
  90. void setIsInSecondlife();
  91. void setMenuColor() const;
  92. void loadGridsList();
  93. const EGridInfo gridIndexInList(LLSD& grids, std::string name,
  94. std::string label = "");
  95. void loadGridsLLSD(LLSD& grids, const std::string& filename,
  96. bool can_edit = false);
  97. LL_INLINE const LLSD& getGridsList() const { return mGridList; }
  98. static std::string getDomain(const std::string& url);
  99. // Returns a time stamp in the time zone of the grid: PDT or PST for SL,
  100. // and since we do not know what else to use, UTC for OpenSim grids. The
  101. // time zone is automatically appended to the returned string (i.e. it
  102. // does not need to be part of the 'fmt' format string) when 'append_tz' is
  103. // true. HB
  104. static std::string getTimeStamp(time_t time_utc, const std::string& fmt,
  105. bool append_tz = true);
  106. private:
  107. void parseCommandLineURIs();
  108. private:
  109. LLSD mGridList;
  110. EGridInfo mGridChoice;
  111. std::string mGridName;
  112. std::string mGridHost;
  113. std::string mGridURI;
  114. std::string mHelperURI;
  115. std::string mLoginPageURI;
  116. std::string mWebsiteURL;
  117. std::string mSupportURL;
  118. std::string mAccountURL;
  119. std::string mPasswordURL;
  120. std::vector<std::string> mCommandLineURIs;
  121. // Set if the user edits/sets the First or Last name field:
  122. bool mNameEdited;
  123. bool mVerbose;
  124. };
  125. constexpr EGridInfo DEFAULT_GRID_CHOICE = 1;
  126. constexpr EGridInfo GRID_INFO_NONE = 0;
  127. extern EGridInfo GRID_INFO_OTHER;
  128. extern bool gIsInSecondLife;
  129. extern bool gIsInSecondLifeProductionGrid;
  130. extern bool gIsInSecondLifeBetaGrid;
  131. extern bool gIsInProductionGrid;
  132. // Is the Pacific time zone (aka server time zone) currently in daylight
  133. // savings time ?
  134. extern bool gPacificDaylightTime;
  135. // SecondLife URLs
  136. // Account registration web page
  137. extern const std::string CREATE_ACCOUNT_URL;
  138. extern const std::string AUCTION_URL;
  139. extern const std::string EVENTS_URL;
  140. // Support URL
  141. extern const std::string SUPPORT_URL;
  142. // Forgotten Password URL
  143. extern const std::string FORGOTTEN_PASSWORD_URL;
  144. // Currency page
  145. extern const std::string BUY_CURRENCY_URL;
  146. // LSL script wiki
  147. extern const std::string LSL_DOC_URL;
  148. // Release Notes Redirect URL for Server and Viewer
  149. extern const std::string RELEASE_NOTES_BASE_URL;
  150. // Agni login URI
  151. extern const std::string AGNI_LOGIN_URI;
  152. // Aditi login URI
  153. extern const std::string ADITI_LOGIN_URI;
  154. // Agni helper URI
  155. extern const std::string AGNI_HELPER_URI;
  156. // Aditi helper URI
  157. extern const std::string ADITI_HELPER_URI;
  158. // SL login page URL (legacy)
  159. extern const std::string SL_LOGIN_PAGE_URL;
  160. // Agni Mesh upload validation URL
  161. extern const std::string AGNI_VALIDATE_MESH_UPLOAD_PAGE_URL;
  162. // Aditi Mesh upload validation URL
  163. extern const std::string ADITI_VALIDATE_MESH_UPLOAD_PAGE_URL;
  164. // SL grid status BLOG URL
  165. extern const std::string SL_GRID_STATUS_URL;
  166. #endif