llslurl.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /**
  2. * @file llslurl.h
  3. * @brief Handles "SLURL fragments" like Ahern/123/45 for
  4. * startup processing, login screen, prefs, etc.
  5. *
  6. * $LicenseInfo:firstyear=2010&license=viewergpl$
  7. *
  8. * Copyright (c) 2010, Linden Research, Inc.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #ifndef LLSLURL_H
  34. #define LLSLURL_H
  35. #include "llerror.h"
  36. #include "llstring.h"
  37. class LLAvatarName;
  38. class LLUUID;
  39. class LLVector3;
  40. class LLVector3d;
  41. class LLSLURL
  42. {
  43. protected:
  44. LOG_CLASS(LLSLURL);
  45. public:
  46. // If you modify this enumeration, update typeName as well
  47. enum eType {
  48. INVALID,
  49. LOCATION,
  50. HOME_LOCATION,
  51. LAST_LOCATION,
  52. APP,
  53. HELP,
  54. NUM_SLURL_TYPES // must be last
  55. };
  56. LL_INLINE LLSLURL()
  57. : mType(INVALID)
  58. {
  59. }
  60. LLSLURL(const std::string& slurl);
  61. LLSLURL(const std::string& grid, const std::string& region);
  62. LLSLURL(const std::string& region, const LLVector3& position);
  63. LLSLURL(const std::string& grid, const std::string& region,
  64. const LLVector3& position);
  65. LLSLURL(const std::string& grid, const std::string& region,
  66. const LLVector3d& global_position);
  67. LLSLURL(const std::string& region, const LLVector3d& global_position);
  68. LLSLURL(const std::string& command, const LLUUID& id,
  69. const std::string& verb);
  70. LL_INLINE eType getType() const { return mType; }
  71. std::string getSLURLString() const;
  72. std::string getLocationString() const;
  73. LL_INLINE std::string getGrid() const { return mGrid; }
  74. LL_INLINE std::string getRegion() const { return mRegion; }
  75. LL_INLINE LLVector3 getPosition() const { return mPosition; }
  76. LL_INLINE std::string getAppCmd() const { return mAppCmd; }
  77. LL_INLINE std::string getAppQuery() const { return mAppQuery; }
  78. LL_INLINE LLSD getAppQueryMap() const { return mAppQueryMap; }
  79. LL_INLINE LLSD getAppPath() const { return mAppPath; }
  80. LL_INLINE bool isValid() const { return mType != INVALID; }
  81. LL_INLINE bool isSpatial() const { return mType != INVALID && mType <= LAST_LOCATION; }
  82. bool operator==(const LLSLURL& rhs);
  83. LL_INLINE bool operator!=(const LLSLURL& rhs)
  84. {
  85. return !(*this == rhs);
  86. }
  87. std::string asString() const;
  88. static uuid_list_t findSLURLs(const std::string& txt);
  89. static void resolveSLURLs();
  90. private:
  91. // Get a human-readable version of the type for logging
  92. static std::string getTypeString(eType type);
  93. static void avatarNameCallback(const LLUUID& id,
  94. const LLAvatarName& avatar_name);
  95. static void cacheNameCallback(const LLUUID& id, const std::string& name,
  96. bool is_group);
  97. static void experienceNameCallback(const LLSD& experience_details);
  98. public:
  99. static const char* SLURL_SECONDLIFE_SCHEME;
  100. static const char* SLURL_HOP_SCHEME;
  101. static const char* SLURL_X_GRID_LOCATION_INFO_SCHEME;
  102. static const char* SLURL_X_GRID_INFO_SCHEME;
  103. static const char* SLURL_HTTPS_SCHEME;
  104. static const char* SLURL_HTTP_SCHEME;
  105. static const char* SLURL_SECONDLIFE_PATH;
  106. static const char* SLURL_COM;
  107. static const char* WWW_SLURL_COM;
  108. static const char* MAPS_SECONDLIFE_COM;
  109. static const char* SIM_LOCATION_HOME;
  110. static const char* SIM_LOCATION_LAST;
  111. static const char* SLURL_APP_PATH;
  112. static const char* SLURL_REGION_PATH;
  113. private:
  114. eType mType;
  115. // Used for Apps and Help
  116. std::string mAppCmd;
  117. LLSD mAppPath;
  118. LLSD mAppQueryMap;
  119. std::string mAppQuery;
  120. std::string mGrid; // Reference to grid manager grid
  121. std::string mRegion;
  122. LLVector3 mPosition;
  123. static uuid_list_t sAvatarUUIDs;
  124. static uuid_list_t sGroupUUIDs;
  125. static uuid_list_t sExperienceUUIDs;
  126. static uuid_list_t sObjectsUUIDs;
  127. typedef std::map<std::string, LLUUID> slurls_map_t;
  128. static slurls_map_t sPendingSLURLs;
  129. static const std::string typeName[NUM_SLURL_TYPES];
  130. };
  131. #endif // LLSLURL_H