llfloaterparcel.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**
  2. * @file llfloaterparcel.cpp
  3. * @brief LLFloaterParcel class implementation
  4. * Parcel information as shown in a floating window from secondlife:// command
  5. * handler.
  6. *
  7. * $LicenseInfo:firstyear=2007&license=viewergpl$
  8. *
  9. * Copyright (c) 2007-2009, Linden Research, Inc.
  10. *
  11. * Second Life Viewer Source Code
  12. * The source code in this file ("Source Code") is provided by Linden Lab
  13. * to you under the terms of the GNU General Public License, version 2.0
  14. * ("GPL"), unless you have obtained a separate licensing agreement
  15. * ("Other License"), formally executed by you and Linden Lab. Terms of
  16. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  17. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  18. *
  19. * There are special exceptions to the terms and conditions of the GPL as
  20. * it is applied to this Source Code. View the full text of the exception
  21. * in the file doc/FLOSS-exception.txt in this software distribution, or
  22. * online at
  23. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  24. *
  25. * By copying, modifying or distributing this software, you acknowledge
  26. * that you have read and understood your obligations described above,
  27. * and agree to abide by those obligations.
  28. *
  29. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  30. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  31. * COMPLETENESS OR PERFORMANCE.
  32. * $/LicenseInfo$
  33. */
  34. #include "llviewerprecompiledheaders.h"
  35. #include "llfloaterparcel.h"
  36. #include "lluictrlfactory.h"
  37. #include "llcommandhandler.h"
  38. #include "llpanelplace.h"
  39. LLFloaterParcelInfo::instances_map_t LLFloaterParcelInfo::sInstances;
  40. class LLParcelHandler final : public LLCommandHandler
  41. {
  42. public:
  43. LLParcelHandler()
  44. : LLCommandHandler("parcel", UNTRUSTED_THROTTLE)
  45. {
  46. }
  47. bool handle(const LLSD& params, const LLSD&, LLMediaCtrl*) override
  48. {
  49. if (params.size() < 2)
  50. {
  51. return false;
  52. }
  53. LLUUID parcel_id;
  54. if (!parcel_id.set(params[0], false))
  55. {
  56. return false;
  57. }
  58. if (params[1].asString() == "about")
  59. {
  60. LLFloaterParcelInfo::show(parcel_id);
  61. return true;
  62. }
  63. return false;
  64. }
  65. };
  66. LLParcelHandler gParcelHandler;
  67. void* LLFloaterParcelInfo::createPanelPlace(void* data)
  68. {
  69. LLFloaterParcelInfo* self = (LLFloaterParcelInfo*)data;
  70. self->mPanelParcelp = new LLPanelPlace(); // allow edit self
  71. LLUICtrlFactory::getInstance()->buildPanel(self->mPanelParcelp,
  72. "panel_place.xml");
  73. return self->mPanelParcelp;
  74. }
  75. LLFloaterParcelInfo::LLFloaterParcelInfo(const std::string& name,
  76. const LLUUID& parcel_id)
  77. : LLFloater(name),
  78. mParcelID(parcel_id)
  79. {
  80. mFactoryMap["place_details_panel"] = LLCallbackMap(LLFloaterParcelInfo::createPanelPlace,
  81. this);
  82. LLUICtrlFactory::getInstance()->buildFloater(this,
  83. "floater_preview_url.xml",
  84. &getFactoryMap());
  85. sInstances[parcel_id] = this;
  86. }
  87. //virtual
  88. LLFloaterParcelInfo::~LLFloaterParcelInfo()
  89. {
  90. // Child views automatically deleted
  91. sInstances.erase(mParcelID);
  92. }
  93. void LLFloaterParcelInfo::displayParcelInfo(const LLUUID& parcel_id)
  94. {
  95. mPanelParcelp->setParcelID(parcel_id);
  96. }
  97. //static
  98. LLFloaterParcelInfo* LLFloaterParcelInfo::show(const LLUUID& parcel_id)
  99. {
  100. if (parcel_id.isNull())
  101. {
  102. return NULL;
  103. }
  104. LLFloaterParcelInfo* floater;
  105. instances_map_t::iterator it = sInstances.find(parcel_id);
  106. if (it != sInstances.end())
  107. {
  108. // ...bring that window to front
  109. floater = it->second;
  110. floater->open();
  111. floater->setFrontmost(true);
  112. }
  113. else
  114. {
  115. floater = new LLFloaterParcelInfo("parcelinfo", parcel_id);
  116. floater->center();
  117. floater->open();
  118. floater->displayParcelInfo(parcel_id);
  119. floater->setFrontmost(true);
  120. }
  121. return floater;
  122. }