diff --git a/.hgpatchinfo/.RLVa.dep b/.hgpatchinfo/.RLVa.dep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.hgpatchinfo/RLVa.dep b/.hgpatchinfo/RLVa.dep new file mode 100644 index 0000000000000000000000000000000000000000..718819c0f1ab7e01a863f4197b07d3027c7d15d9 --- /dev/null +++ b/.hgpatchinfo/RLVa.dep @@ -0,0 +1 @@ +c38e721ae826e65ed1714a464ef34b4bdd1a5d80 \ No newline at end of file diff --git a/.hgtags b/.hgtags index d4f368b851e37dc870e80f40862202bc3cf5d287..84981704300394a01461a1be029d74fd22e81783 100755 --- a/.hgtags +++ b/.hgtags @@ -994,3 +994,16 @@ bf6d453046011a11de2643fac610cc5258650f82 SL-3.6.5 b62e417982d9d4f3ec49d0de3b3c2e37c6d394c1 SL-3.6.6 d40c66e410741de7e90b1ed6dac28dd8a2d7e1f6 SL-3.6.8 70eda3721d36df3e00730629c42a1304e5bc65b8 SL-3.6.9 +425f96b1e81e01644bf5e951961e7d1023bffb89 RLVa-1.2.0 +fc0cbb86f5bd6e7737159e35aea2c4cf9f619b62 RLVa-1.2.1 +43cb7dc1804de1a25c0b2b3f0715584af1f8b470 RLVa-1.2.2 +89532c8dfd5b6c29f1cb032665b44a74a52452e1 RLVa-1.3.0 +7bc5039ccf0b36eafbf6ce33a52b5e26332aa04c RLVa-1.3.1 +a563f7e215c7883c1cfd20908085687a0ed96284 RLVa-1.4.0 +40644beae9c4a617504163d5c9f195dc7bfff1b4 RLVa-1.4.1 +8787094c309a44ca32b7472acc9217a3c37f00c3 RLVa-1.4.2 +11c6c85ddd223bcbd6b3afc53f9a0f5fd349ba65 RLVa-1.4.3 +53b44208d44a601fe24e78c1a1909dc82356cded RLVa-1.4.4 +6522747820037cc11e5b7d0491a0a9808a958709 RLVa-1.4.5 +0c8f23b2c4cf96d1a08bd527b3ccb6339a9fdb60 RLVa-1.4.6 +674db463770b78f836fc9c87a1b2235e212a576c RLVa-1.4.7 diff --git a/indra/integration_tests/llui_libtest/llui_libtest.cpp b/indra/integration_tests/llui_libtest/llui_libtest.cpp index 38aa1bbeb2a7a4e6f9f2ff497eae96b25c8b4b3c..00c118be51e43af401dcf50e47412f83c27c4500 100755 --- a/indra/integration_tests/llui_libtest/llui_libtest.cpp +++ b/indra/integration_tests/llui_libtest/llui_libtest.cpp @@ -52,6 +52,17 @@ LLControlGroup gSavedSettings("Global"); // saved at end of session LLControlGroup gSavedPerAccountSettings("PerAccount"); // saved at end of session LLControlGroup gWarningSettings("Warnings"); // persists ignored dialogs/warnings +// [RLVa:KB] - Checked: 2010-11-12 (RLVa-1.2.2a) | Added: RLVa-1.2.2a +#include "llavatarname.h" + +// Stub for rlvGetAnonym +const std::string& rlvGetAnonym(const LLAvatarName& avName) +{ + static std::string strAnonym = "A resident"; + return strAnonym; +} +// [/RLVa:KB] + // We can't create LLImageGL objects because we have no window or rendering // context. Provide enough of an LLUIImage to test the LLUI library without // an underlying image. diff --git a/indra/llappearance/llwearabledata.cpp b/indra/llappearance/llwearabledata.cpp index 68fdcca78214dc7030de849e35e9280838cbd1c2..ae67f36194d4a0720937d2f1502f5cc48a5cb990 100644 --- a/indra/llappearance/llwearabledata.cpp +++ b/indra/llappearance/llwearabledata.cpp @@ -102,16 +102,36 @@ U32 LLWearableData::pushWearable(const LLWearableType::EType type, llwarns << "Null wearable sent for type " << type << llendl; return MAX_CLOTHING_PER_TYPE; } - if (type < LLWearableType::WT_COUNT || mWearableDatas[type].size() < MAX_CLOTHING_PER_TYPE) +// [RLVa:KB] - Checked: 2010-06-08 (RLVa-1.2.0) + if ( (type < LLWearableType::WT_COUNT) && (mWearableDatas[type].size() < MAX_CLOTHING_PER_TYPE) ) { - mWearableDatas[type].push_back(wearable); + // Don't add the same wearable twice + U32 idxWearable = getWearableIndex(wearable); + llassert(MAX_CLOTHING_PER_TYPE == idxWearable); // pushWearable() on an already added wearable is a bug *somewhere* + if (MAX_CLOTHING_PER_TYPE == idxWearable) + { + mWearableDatas[type].push_back(wearable); + idxWearable = mWearableDatas[type].size() - 1; + } + if (trigger_updated) { const BOOL removed = FALSE; wearableUpdated(wearable, removed); } - return mWearableDatas[type].size()-1; + return idxWearable; } +// [/RLVa:KB] +// if (type < LLWearableType::WT_COUNT || mWearableDatas[type].size() < MAX_CLOTHING_PER_TYPE) +// { +// mWearableDatas[type].push_back(wearable); +// if (trigger_updated) +// { +// const BOOL removed = FALSE; +// wearableUpdated(wearable, removed); +// } +// return mWearableDatas[type].size()-1; +// } return MAX_CLOTHING_PER_TYPE; } @@ -160,16 +180,16 @@ void LLWearableData::popWearable(const LLWearableType::EType type, U32 index) } } -void LLWearableData::clearWearableType(const LLWearableType::EType type) -{ - wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type); - if (wearable_iter == mWearableDatas.end()) - { - return; - } - wearableentry_vec_t& wearable_vec = wearable_iter->second; - wearable_vec.clear(); -} +//void LLWearableData::clearWearableType(const LLWearableType::EType type) +//{ +// wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type); +// if (wearable_iter == mWearableDatas.end()) +// { +// return; +// } +// wearableentry_vec_t& wearable_vec = wearable_iter->second; +// wearable_vec.clear(); +//} bool LLWearableData::swapWearables(const LLWearableType::EType type, U32 index_a, U32 index_b) { diff --git a/indra/llappearance/llwearabledata.h b/indra/llappearance/llwearabledata.h index 03bd179f258812a1fdac747fd5404f41f7d2cd2a..cee9592caa498f58b386cdab5a9bc0cf89f80980 100644 --- a/indra/llappearance/llwearabledata.h +++ b/indra/llappearance/llwearabledata.h @@ -77,7 +77,7 @@ class LLWearableData virtual void wearableUpdated(LLWearable *wearable, BOOL removed); void popWearable(LLWearable *wearable); void popWearable(const LLWearableType::EType type, U32 index); - void clearWearableType(const LLWearableType::EType type); +// void clearWearableType(const LLWearableType::EType type); bool swapWearables(const LLWearableType::EType type, U32 index_a, U32 index_b); private: diff --git a/indra/llappearance/llwearabletype.cpp b/indra/llappearance/llwearabletype.cpp index 65afb0addec66dcad0294b77bcef6d41bce2a042..7ee49d21e823f96bfbb8b9d50903adedb1c3d033 100644 --- a/indra/llappearance/llwearabletype.cpp +++ b/indra/llappearance/llwearabletype.cpp @@ -72,6 +72,12 @@ class LLWearableDictionary : public LLSingleton<LLWearableDictionary>, { public: LLWearableDictionary(); + +// [RLVa:KB] - Checked: 2010-03-03 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +protected: + // The default implementation asserts on 'notFound()' and returns -1 which isn't a valid EWearableType + virtual LLWearableType::EType notFound() const { return LLWearableType::WT_INVALID; } +// [/RLVa:KB] }; LLWearableDictionary::LLWearableDictionary() diff --git a/indra/llcommon/llchat.h b/indra/llcommon/llchat.h index f5b242fdfcddabbbba473dff6b405ad63103d35c..746103b9115590a9cc9400931457848ee79f57f1 100755 --- a/indra/llcommon/llchat.h +++ b/indra/llcommon/llchat.h @@ -81,6 +81,10 @@ class LLChat mChatType(CHAT_TYPE_NORMAL), mAudible(CHAT_AUDIBLE_FULLY), mMuted(FALSE), +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.0.0a + mRlvLocFiltered(FALSE), + mRlvNamesFiltered(FALSE), +// [/RLVa:KB] mTime(0.0), mTimeStr(), mPosAgent(), @@ -98,6 +102,10 @@ class LLChat EChatType mChatType; EChatAudible mAudible; BOOL mMuted; // pass muted chat to maintain list of chatters +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.0.0a + BOOL mRlvLocFiltered; + BOOL mRlvNamesFiltered; +// [/RLVa:KB] F64 mTime; // viewer only, seconds from viewer start std::string mTimeStr; LLVector3 mPosAgent; diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 9a68093427d241b8c8000edfdc18920598333b18..c6db95a67dba43aea3185f97f50b27f0dc4dc98a 100755 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -43,6 +43,11 @@ namespace LLAvatarNameCache { use_display_name_signal_t mUseDisplayNamesSignal; +// [RLVa:KB] - Checked: 2010-12-08 (RLVa-1.4.0a) | Added: RLVa-1.2.2c + // RLVa override for display names + bool sForceDisplayNames = false; +// [/RLVa:KB] + // Cache starts in a paused state until we can determine if the // current region supports display names. bool sRunning = false; @@ -670,10 +675,30 @@ LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& ag return connection; } +// [RLVa:KB] - Checked: 2010-12-08 (RLVa-1.4.0a) | Added: RLVa-1.2.2c +bool LLAvatarNameCache::getForceDisplayNames() +{ + return sForceDisplayNames; +} + +void LLAvatarNameCache::setForceDisplayNames(bool force) +{ + sForceDisplayNames = force; + if ( (!LLAvatarName::useDisplayNames()) && (force) ) + { + LLAvatarName::setUseDisplayNames(true); + } +} +// [/RLVa:KB] void LLAvatarNameCache::setUseDisplayNames(bool use) { +// [RLVa:KB] - Checked: 2010-12-08 (RLVa-1.4.0a) | Added: RLVa-1.2.2c + // We need to force the use of the "display names" cache when @shownames=n restricted (and disallow toggling it) + use |= getForceDisplayNames(); +// [/RLVa:KB] if (use != LLAvatarName::useDisplayNames()) + { LLAvatarName::setUseDisplayNames(use); mUseDisplayNamesSignal(); diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 2a8eb46187b1af5fbd308fbb551f6fe73f73a85f..3bd11ed878fcb18d4dcfa2c87e862c6d711ce4fc 100755 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -81,6 +81,12 @@ namespace LLAvatarNameCache void setUseDisplayNames(bool use); void insert(const LLUUID& agent_id, const LLAvatarName& av_name); + +// [RLVa:KB] - Checked: 2010-12-08 (RLVa-1.4.0a) | Added: RLVa-1.2.2c + bool getForceDisplayNames(); + void setForceDisplayNames(bool force); +// [/RLVa:KB] + void erase(const LLUUID& agent_id); /// Provide some fallback for agents that return errors. diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp old mode 100755 new mode 100644 diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index b1b75776a7b43bc56a4dca5d419103b6faced0cb..e7cd81f96810f12a9acabdd8e2b83f35813460f7 100755 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -45,6 +45,10 @@ std::set<std::string> LLFloaterReg::sAlwaysShowableList; static LLFloaterRegListener sFloaterRegListener; +// [RLVa:KB] - Checked: 2010-02-28 (RLVa-1.4.0a) | Modified: RLVa-1.2.0a +LLFloaterReg::validate_signal_t LLFloaterReg::mValidateSignal; +// [/RLVa:KB] + //******************************************************* //static @@ -240,12 +244,23 @@ LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::str // Visibility Management +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 +//static +bool LLFloaterReg::canShowInstance(const std::string& name, const LLSD& key) +{ + return mValidateSignal(name, key); +} +// [/RLVa:KB] + //static LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, BOOL focus) { - if( sBlockShowFloaters - // see EXT-7090 - && sAlwaysShowableList.find(name) == sAlwaysShowableList.end()) +// if( sBlockShowFloaters +// // see EXT-7090 +// && sAlwaysShowableList.find(name) == sAlwaysShowableList.end()) +// [RLVa:KB] - Checked: 2010-02-28 (RLVa-1.4.0a) | Modified: RLVa-1.2.0a + if ( (sBlockShowFloaters && sAlwaysShowableList.find(name) == sAlwaysShowableList.end()) || (!mValidateSignal(name, key)) ) +// [/RLVa:KB] return 0;// LLFloater* instance = getInstance(name, key); if (instance) diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index a1e1f8a98835ffa6bd8fd257a8a5799268b5e6ce..78a8b7676c4d9a8f94376e6ce05c0b0a9ab8e3ab 100755 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -31,6 +31,10 @@ #include "llsd.h" #include <boost/function.hpp> +// [RLVa:KB] - Checked: 2011-05-25 (RLVa-1.4.0a) +#include <boost/signals2.hpp> +#include "llboost.h" +// [/RLVa:KB] //******************************************************* // @@ -71,6 +75,15 @@ class LLFloaterReg */ static std::set<std::string> sAlwaysShowableList; +// [RLVa:KB] - Checked: 2010-02-28 (RLVa-1.4.0a) | Modified: RLVa-1.2.0a + // Used to determine whether a floater can be shown +public: + typedef boost::signals2::signal<bool(const std::string&, const LLSD&), boost_boolean_combiner> validate_signal_t; + static boost::signals2::connection setValidateCallback(const validate_signal_t::slot_type& cb) { return mValidateSignal.connect(cb); } +private: + static validate_signal_t mValidateSignal; +// [/RLVa:KB] + public: // Registration @@ -99,6 +112,10 @@ class LLFloaterReg static const_instance_list_t& getFloaterList(const std::string& name); // Visibility Management +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 + // return false if floater can not be shown (=doesn't pass the validation filter) + static bool canShowInstance(const std::string& name, const LLSD& key = LLSD()); +// [/RLVa:KB] // return NULL if instance not found or can't create instance (no builder) static LLFloater* showInstance(const std::string& name, const LLSD& key = LLSD(), BOOL focus = FALSE); // Close a floater (may destroy or set invisible) diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 5c288c3f03e618a1597c630dd005475c522262ad..e7987edfb53f64588394c65ab43acfef26437e06 100755 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -904,6 +904,13 @@ std::string LLNotification::getLabel() const return (mTemplatep ? label : ""); } +// [SL:KB] - Patch: UI-Notifications | Checked: 2011-04-11 (Catznip-2.5.0a) | Added: Catznip-2.5.0a +bool LLNotification::hasLabel() const +{ + return !mTemplatep->mLabel.empty(); +} +// [/SL:KB] + std::string LLNotification::getURL() const { if (!mTemplatep) diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 6ac4a988060a653b668cbcd0ef7c4a121b211698..4459808e989e3865d81fa8cc067db707aeded265 100755 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -527,6 +527,10 @@ friend class LLNotifications; return mTimestamp; } +// [SL:KB] - Patch: UI-Notifications | Checked: 2011-04-11 (Catznip-2.5.0a) | Added: Catznip-2.5.0a + bool hasLabel() const; +// [/SL:KB] + bool getOfferFromAgent() const { return mOfferFromAgent; diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 928e82cb8c21c798e2cdb1744270ababa2b7012c..3b90dfb0768f0f1aaa30d13d13eb57e20e30a7e2 100755 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -1218,6 +1218,9 @@ void LLToolBarButton::setEnabled(BOOL enabled) mImageOverlayColor = mImageOverlayDisabledColor; mImageOverlaySelectedColor = mImageOverlayDisabledColor; } +// [RLVa:KB] - Checked: 2011-12-17 (RLVa-1.4.5a) | Added: RLVa-1.4.5a + LLButton::setEnabled(enabled); +// [/RLVa:KB] } const std::string LLToolBarButton::getToolTip() const diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 0ddb14973831628f9fc1922909aaafc6e7dd11a6..3614402c12eda48b744e632e3a18170ea50bd26f 100755 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -201,6 +201,9 @@ void LLUI::initClass(const settings_map_t& settings, // Used by menus along with Floater.Toggle to display visibility as a check-mark LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD())); LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD())); +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.CanShow", boost::bind(&LLFloaterReg::canShowInstance, _2, LLSD())); +// [/RLVa:KB] // Parse the master list of commands LLCommandManager::load(); diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index b1cc502c4bbf881222d58aed55080d55c0b1ff5f..492fa7d1cde7b53fe0a4e18a49e4864618c197cd 100755 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -630,6 +630,27 @@ std::string LLUrlEntryAgentUserName::getName(const LLAvatarName& avatar_name) return avatar_name.getAccountName(); } +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + +// Defined in rlvcommon.cpp - redirects to RlvStrings::getAnonym() since we can't really get to that class from here +extern const std::string& rlvGetAnonym(const LLAvatarName& avName); + +// +// LLUrlEntryAgentRLVAnonymizedName Describes an RLV anonymized agent name Url, e.g., +// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/rlvanonym +// x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/rlvanonym +// +LLUrlEntryAgentRLVAnonymizedName::LLUrlEntryAgentRLVAnonymizedName() +{ + mPattern = boost::regex(APP_HEADER_REGEX "/agent/[\\da-f-]+/rlvanonym", boost::regex::perl|boost::regex::icase); +} + +std::string LLUrlEntryAgentRLVAnonymizedName::getName(const LLAvatarName& avatar_name) +{ + return rlvGetAnonym(avatar_name); +} +// [/RLVa:KB] + // // LLUrlEntryGroup Describes a Second Life group Url, e.g., // secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index 8c6c32178af66856990ff00967c639d6560afeb4..f7d97594d9b3a6b3dab1257ec61a7102078979fa 100755 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -257,6 +257,21 @@ class LLUrlEntryAgentUserName : public LLUrlEntryAgentName /*virtual*/ std::string getName(const LLAvatarName& avatar_name); }; +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Added: RLVa-1.2.2a +/// +/// LLUrlEntryAgentRLVAnonymizedName Describes an RLV anonymized agent name Url, e.g., +/// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/rlvanonym +/// that diplays an anonym (based on the display name) for an avatar +/// such as "An individual" +class LLUrlEntryAgentRLVAnonymizedName : public LLUrlEntryAgentName +{ +public: + LLUrlEntryAgentRLVAnonymizedName(); +private: + /*virtual*/ std::string getName(const LLAvatarName& avatar_name); +}; +// [/RLVa:KB] + /// /// LLUrlEntryGroup Describes a Second Life group Url, e.g., /// secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index 523ee5d78c6534c1682d4aee4f166b52c92b4bab..877a1e6e6b21e67e822a6fb0cac9fc10b21bdfed 100755 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -37,7 +37,10 @@ void LLUrlRegistryNullCallback(const std::string &url, const std::string &label, LLUrlRegistry::LLUrlRegistry() { - mUrlEntry.reserve(20); +// mUrlEntry.reserve(20); +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + mUrlEntry.reserve(21); +// [/RLVa:KB] // Urls are matched in the order that they were registered registerUrl(new LLUrlEntryNoLink()); @@ -48,6 +51,9 @@ LLUrlRegistry::LLUrlRegistry() registerUrl(new LLUrlEntryAgentCompleteName()); registerUrl(new LLUrlEntryAgentDisplayName()); registerUrl(new LLUrlEntryAgentUserName()); +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + registerUrl(new LLUrlEntryAgentRLVAnonymizedName()); +// [/RLVa:KB] // LLUrlEntryAgent*Name must appear before LLUrlEntryAgent since // LLUrlEntryAgent is a less specific (catchall for agent urls) registerUrl(new LLUrlEntryAgent()); diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp index 5d3f9ac327be6352eeb877da19519ddc0dac443c..7151139c77a3e11e307696300a87e4af9b6278b8 100755 --- a/indra/llui/tests/llurlentry_stub.cpp +++ b/indra/llui/tests/llurlentry_stub.cpp @@ -34,6 +34,15 @@ #include <string> +// [RLVa:KB] - Checked: 2010-11-12 (RLVa-1.2.2a) | Added: RLVa-1.2.2a +// Stub for rlvGetAnonym +const std::string& rlvGetAnonym(const LLAvatarName& avName) +{ + static std::string strAnonym = "A resident"; + return strAnonym; +} +// [/RLVa:KB] + // Stub for LLAvatarNameCache bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) { diff --git a/indra/lscript/lscript_compile/bison.bat b/indra/lscript/lscript_compile/bison.bat index d40997225e01d8d744871d55002881587b966dbe..fe8e500f0b78d6b3898481c55541f298308402d1 100644 --- a/indra/lscript/lscript_compile/bison.bat +++ b/indra/lscript/lscript_compile/bison.bat @@ -1,12 +1,12 @@ -@REM Run bison under Windows. This script is needed so that bison can -@REM find m4, even if neither program is present in PATH. - -@set bison=%1 -shift -set M4PATH=%1 -shift -set M4= - -set PATH=%M4PATH%;%PATH% -@REM %* does not work with shift... -%bison% %1 %2 %3 %4 %5 %6 %7 %8 %9 +@REM Run bison under Windows. This script is needed so that bison can +@REM find m4, even if neither program is present in PATH. + +@set bison=%1 +shift +set M4PATH=%1 +shift +set M4= + +set PATH=%M4PATH%;%PATH% +@REM %* does not work with shift... +%bison% %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/indra/lscript/lscript_compile/windows/unistd.h b/indra/lscript/lscript_compile/windows/unistd.h index 0b7e2581e3de354d9f0792ca4dbbb7f80cefb74c..49e9152d633e85aa9dff1307194715c7db1b8968 100755 --- a/indra/lscript/lscript_compile/windows/unistd.h +++ b/indra/lscript/lscript_compile/windows/unistd.h @@ -1,24 +1,24 @@ -/** - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/* After all that, this file is empty. */ +/** + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/* After all that, this file is empty. */ diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 6a2392100b56661e5c9edb6bee687845ddc021b7..17e0a19a8909f9eb59f0fa3d66de51a74cb496c1 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -676,6 +676,15 @@ set(viewer_SOURCE_FILES llxmlrpctransaction.cpp noise.cpp pipeline.cpp + rlvactions.cpp + rlvhandler.cpp + rlvhelper.cpp + rlvcommon.cpp + rlvlocks.cpp + rlvinventory.cpp + rlvextensions.cpp + rlvfloaters.cpp + rlvui.cpp ) set(VIEWER_BINARY_NAME "secondlife-bin" CACHE STRING @@ -1256,6 +1265,16 @@ set(viewer_HEADER_FILES macmain.h noise.h pipeline.h + rlvactions.h + rlvdefines.h + rlvhandler.h + rlvhelper.h + rlvcommon.h + rlvlocks.h + rlvinventory.h + rlvextensions.h + rlvfloaters.h + rlvui.h VertexCache.h VorbisFramework.h ) diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index 60c942094aad44fcc98f66c0a29ae3da1975dfd2..e421bf486a27249a7d8ecef61a439eb387be9a58 100755 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -7,6 +7,8 @@ tooltip_ref="Command_AboutLand_Tooltip" execute_function="Floater.ToggleOrBringToFront" execute_parameters="about_land" + is_enabled_function="Floater.CanShow" + is_enabled_parameters="about_land" is_running_function="Floater.IsOpen" is_running_parameters="about_land" /> @@ -98,6 +100,8 @@ tooltip_ref="Command_Inventory_Tooltip" execute_function="Floater.ToggleOrBringToFront" execute_parameters="inventory" + is_enabled_function="RLV.EnableIfNot" + is_enabled_parameters="showinv" is_running_function="Floater.IsOpen" is_running_parameters="inventory" /> @@ -108,6 +112,8 @@ tooltip_ref="Command_Map_Tooltip" execute_function="Floater.ToggleOrBringToFront" execute_parameters="world_map" + is_enabled_function="RLV.EnableIfNot" + is_enabled_parameters="showworldmap" is_running_function="Floater.IsOpen" is_running_parameters="world_map" /> @@ -125,6 +131,8 @@ tooltip_ref="Command_MiniMap_Tooltip" execute_function="Floater.ToggleOrBringToFront" execute_parameters="mini_map" + is_enabled_function="RLV.EnableIfNot" + is_enabled_parameters="showminimap" is_running_function="Floater.IsOpen" is_running_parameters="mini_map" /> diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml old mode 100755 new mode 100644 diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml old mode 100755 new mode 100644 index 41aac583d7661a270e4de4287efac459473dc1cd..f4acbcc77a3523703c62c46eb4664c9285b945d4 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -2,6 +2,237 @@ <llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="llsd.xsd"> <map> + <key>RestrainedLove</key> + <map> + <key>Comment</key> + <string>Toggles the RestrainedLove features (BDSM lockable toys support). Needs a restart of the viewer.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>RestrainedLoveDebug</key> + <map> + <key>Comment</key> + <string>Toggles the RestrainedLove debug mode (displays the commands when in debug mode).</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>RestrainedLoveCanOOC</key> + <map> + <key>Comment</key> + <string>Allows sending OOC chat when send chat restricted, or seeing OOC chat when receive chat restricted</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>RestrainedLoveForbidGiveToRLV</key> + <map> + <key>Comment</key> + <string>When TRUE, forbids to give sub-folders to the #RLV RestrainedLove folder.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>RestrainedLoveNoSetEnv</key> + <map> + <key>Comment</key> + <string>When TRUE, forbids to set the environment (time of day and Windlight settings) via RestrainedLove. Needs a restart of the viewer.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>RestrainedLoveReplaceWhenFolderBeginsWith</key> + <map> + <key>Comment</key> + <string>If a folder name begins with this string, its attach behavior will always be "replace", never "stack". Default is blank (disabled).</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>String</string> + <key>Value</key> + <string></string> + </map> + <key>RestrainedLoveShowEllipsis</key> + <map> + <key>Comment</key> + <string>When TRUE, show "..." when someone speaks, while the avatar is prevented from hearing. When FALSE, don't show anything.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>RestrainedLoveStackWhenFolderBeginsWith</key> + <map> + <key>Comment</key> + <string>If a folder name begins with this string, its attach behavior will always be "stack", never "replace". Default is "+".</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>String</string> + <key>Value</key> + <string>+</string> + </map> + <key>RLVaDebugDeprecateExplicitPoint</key> + <map> + <key>Comment</key> + <string>Ignore attachment point names on inventory items and categories (incomplete)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <boolean>0</boolean> + </map> + <key>RLVaDebugHideUnsetDuplicate</key> + <map> + <key>Comment</key> + <string>Suppresses reporting "unset" or "duplicate" command restrictions when RestrainedLoveDebug is TRUE</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>RLVaEnableCompositeFolders</key> + <map> + <key>Comment</key> + <string>Enables composite folders for shared inventory</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>RLVaEnableLegacyNaming</key> + <map> + <key>Comment</key> + <string>Enables legacy naming convention for folders</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>RLVaEnableSharedWear</key> + <map> + <key>Comment</key> + <string>Attachments in the shared #RLV folder can be force-attached without needing to specify an attachment point</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>RLVaHideLockedLayers</key> + <map> + <key>Comment</key> + <string>Hides "remove outfit" restricted worn clothing layers from @getoufit</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>RLVaHideLockedAttachments</key> + <map> + <key>Comment</key> + <string>Hides non-detachable worn attachments from @getattach</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>RLVaSharedInvAutoRename</key> + <map> + <key>Comment</key> + <string>Automatically renames shared inventory items when worn</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>RLVaShowAssertionFailures</key> + <map> + <key>Comment</key> + <string>Notify the user when an assertion fails</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>RLVaShowNameTags</key> + <map> + <key>Comment</key> + <string>Display of names above avatars is subject to the general "Show Names" setting when @shownames=n restricted</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>RLVaTopLevelMenu</key> + <map> + <key>Comment</key> + <string>Show the RLVa specific menu as a top level menu</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>RLVaWearReplaceUnlocked</key> + <map> + <key>Comment</key> + <string>Don't block wear replace when at least one attachment on the target attachment point is non-detachable</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>WarnFirstRLVGiveToRLV</key> + <map> + <key>Comment</key> + <string>Enables FirstRLVGiveToRLV warning dialog</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>IMShowTime</key> <map> <key>Comment</key> @@ -4171,6 +4402,17 @@ <key>Value</key> <integer>255</integer> </map> + <key>ForceInitialCOFDelay</key> + <map> + <key>Comment</key> + <string>Number of seconds to delay initial processing of COF contents</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <integer>0.0</integer> + </map> <key>ForceShowGrid</key> <map> <key>Comment</key> @@ -4193,6 +4435,17 @@ <key>Value</key> <integer>0</integer> </map> + <key>ForceMissingType</key> + <map> + <key>Comment</key> + <string>Force this wearable type to be missing from COF</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>255</integer> + </map> <key>FreezeTime</key> <map> <key>Comment</key> @@ -6569,6 +6822,17 @@ <key>Value</key> <integer>305</integer> </map> + <key>NotificationCanEmbedInIM</key> + <map> + <key>Comment</key> + <string>Controls notification panel embedding in IMs (0 = default, 1 = focused, 2 = never)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>S32</string> + <key>Value</key> + <integer>0</integer> + </map> <key>NotificationConferenceIMOptions</key> <map> <key>Comment</key> @@ -10661,7 +10925,7 @@ <key>Type</key> <string>Boolean</string> <key>Value</key> - <integer>1</integer> + <boolean>1</boolean> </map> <key>NearbyListShowIcons</key> <map> diff --git a/indra/newview/app_settings/settings_per_account.xml b/indra/newview/app_settings/settings_per_account.xml index 636caf5ef321cd69a50cb381609e6745ab26889f..0ec3589685382c04d9c66b47c9af5e3f62df2760 100755 --- a/indra/newview/app_settings/settings_per_account.xml +++ b/indra/newview/app_settings/settings_per_account.xml @@ -1,5 +1,16 @@ <llsd> <map> + <key>RLVaLoginLastLocation</key> + <map> + <key>Comment</key> + <string>Determines whether the next login will be forced to the last logoff location (set by the viewer)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <boolean>1</boolean> + </map> <key>DoNotDisturbResponseChanged</key> <map> <key>Comment</key> diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 49f77e6c347ac70e0ead94e10fc27481ed225cd0..6d47774eeb4dc4cf03d7b45828f3eb18e571f825 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -94,6 +94,11 @@ #include "lscript_byteformat.h" #include "stringize.h" #include "boost/foreach.hpp" +// [RLVa:KB] - Checked: 2011-11-04 (RLVa-1.4.4a) +#include "rlvhandler.h" +#include "rlvhelper.h" +#include "rlvui.h" +// [/RLVa:KB] using namespace LLAvatarAppearanceDefines; @@ -344,7 +349,10 @@ LLAgent::LLAgent() : mDoubleTapRunMode(DOUBLETAP_NONE), mbAlwaysRun(false), - mbRunning(false), +// mbRunning(false), +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + mbTempRun(false), +// [/RLVa:KB] mbTeleportKeepsLookAt(false), mAgentAccess(new LLAgentAccess(gSavedSettings)), @@ -698,6 +706,9 @@ void LLAgent::movePitch(F32 mag) // Does this parcel allow you to fly? BOOL LLAgent::canFly() { +// [RLVa:KB] - Checked: 2010-03-02 (RLVa-1.2.0d) | Modified: RLVa-1.0.0c + if (gRlvHandler.hasBehaviour(RLV_BHVR_FLY)) return FALSE; +// [/RLVa:KB] if (isGodlike()) return TRUE; LLViewerRegion* regionp = getRegion(); @@ -746,6 +757,13 @@ void LLAgent::setFlying(BOOL fly) if (fly) { +// [RLVa:KB] - Checked: 2010-03-02 (RLVa-1.2.0d) | Modified: RLVa-1.0.0c + if (gRlvHandler.hasBehaviour(RLV_BHVR_FLY)) + { + return; + } +// [/RLVa:KB] + BOOL was_flying = getFlying(); if (!canFly() && !was_flying) { @@ -808,7 +826,14 @@ bool LLAgent::enableFlying() void LLAgent::standUp() { - setControlFlags(AGENT_CONTROL_STAND_UP); +// setControlFlags(AGENT_CONTROL_STAND_UP); +// [RLVa:KB] - Checked: 2010-03-07 (RLVa-1.2.0c) | Added: RLVa-1.2.0a + // RELEASE-RLVa: [SL-2.0.0] Check this function's callers since usually they require explicit blocking + if ( (!rlv_handler_t::isEnabled()) || (gRlvHandler.canStand()) ) + { + setControlFlags(AGENT_CONTROL_STAND_UP); + } +// [/RLVa:KB] } @@ -920,7 +945,10 @@ void LLAgent::setRegion(LLViewerRegion *regionp) LLSelectMgr::getInstance()->updateSelectionCenter(); - LLFloaterMove::sUpdateFlyingStatus(); +// LLFloaterMove::sUpdateFlyingStatus(); +// [RLVa:KB] - Checked: 2011-05-27 (RLVa-1.4.0a) | Added: RLVa-1.4.0a + LLFloaterMove::sUpdateMovementStatus(); +// [/RLVa:KB] if (teleport) { @@ -1140,7 +1168,14 @@ LLVector3d LLAgent::getPosGlobalFromAgent(const LLVector3 &pos_agent) const void LLAgent::sitDown() { - setControlFlags(AGENT_CONTROL_SIT_ON_GROUND); +// setControlFlags(AGENT_CONTROL_SIT_ON_GROUND); +// [RLVa:KB] - Checked: 2010-08-28 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + // RELEASE-RLVa: [SL-2.0.0] Check this function's callers since usually they require explicit blocking + if ( (!rlv_handler_t::isEnabled()) || ((gRlvHandler.canStand()) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SIT))) ) + { + setControlFlags(AGENT_CONTROL_SIT_ON_GROUND); + } +// [/RLVa:KB] } @@ -2423,7 +2458,15 @@ void LLAgent::onAnimStop(const LLUUID& id) } else if (id == ANIM_AGENT_AWAY) { +// clearAFK(); +// [RLVa:KB] - Checked: 2010-05-03 (RLVa-1.2.0g) | Added: RLVa-1.1.0g +#ifdef RLV_EXTENSION_CMD_ALLOWIDLE + if (!gRlvHandler.hasBehaviour(RLV_BHVR_ALLOWIDLE)) + clearAFK(); +#else clearAFK(); +#endif // RLV_EXTENSION_CMD_ALLOWIDLE +// [/RLVa:KB] } else if (id == ANIM_AGENT_STANDUP) { @@ -3109,7 +3152,36 @@ void LLAgent::sendRevokePermissions(const LLUUID & target, U32 permissions) } } -void LLAgent::sendWalkRun(bool running) +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i +void LLAgent::setAlwaysRun() +{ + mbAlwaysRun = (!rlv_handler_t::isEnabled()) || (!gRlvHandler.hasBehaviour(RLV_BHVR_ALWAYSRUN)); + sendWalkRun(); +} + +void LLAgent::setTempRun() +{ + mbTempRun = (!rlv_handler_t::isEnabled()) || (!gRlvHandler.hasBehaviour(RLV_BHVR_TEMPRUN)); + sendWalkRun(); +} + +void LLAgent::clearAlwaysRun() +{ + mbAlwaysRun = false; + sendWalkRun(); +} + +void LLAgent::clearTempRun() +{ + mbTempRun = false; + sendWalkRun(); +} +// [/RLVa:KB] + +//void LLAgent::sendWalkRun(bool running) +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i +void LLAgent::sendWalkRun() +// [/RLVa:KB] { LLMessageSystem* msgsys = gMessageSystem; if (msgsys) @@ -3118,7 +3190,10 @@ void LLAgent::sendWalkRun(bool running) msgsys->nextBlockFast(_PREHASH_AgentData); msgsys->addUUIDFast(_PREHASH_AgentID, getID()); msgsys->addUUIDFast(_PREHASH_SessionID, getSessionID()); - msgsys->addBOOLFast(_PREHASH_AlwaysRun, BOOL(running) ); +// msgsys->addBOOLFast(_PREHASH_AlwaysRun, BOOL(running) ); +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + msgsys->addBOOLFast(_PREHASH_AlwaysRun, BOOL(getRunning()) ); +// [/RLVa:KB] sendReliableMessage(); } } @@ -4003,6 +4078,18 @@ void LLAgent::teleportRequest( // Landmark ID = LLUUID::null means teleport home void LLAgent::teleportViaLandmark(const LLUUID& landmark_asset_id) { +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) | Modified: RLVa-1.2.1a + // NOTE: we'll allow teleporting home unless both @tplm=n *and* @tploc=n restricted + if ( (rlv_handler_t::isEnabled()) && + ( ( (landmark_asset_id.notNull()) ? gRlvHandler.hasBehaviour(RLV_BHVR_TPLM) + : gRlvHandler.hasBehaviour(RLV_BHVR_TPLM) && gRlvHandler.hasBehaviour(RLV_BHVR_TPLOC) ) || + ((gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) && (isAgentAvatarValid()) && (gAgentAvatarp->isSitting())) )) + { + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_TELEPORT); + return; + } +// [/RLVa:KB] + mTeleportRequest = LLTeleportRequestPtr(new LLTeleportRequestViaLandmark(landmark_asset_id)); startTeleportRequest(); } @@ -4082,6 +4169,25 @@ void LLAgent::teleportCancel() void LLAgent::teleportViaLocation(const LLVector3d& pos_global) { +// [RLVa:KB] - Checked: 2010-03-02 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a + if ( (rlv_handler_t::isEnabled()) && (!RlvUtil::isForceTp()) ) + { + // If we're getting teleported due to @tpto we should disregard any @tploc=n or @unsit=n restrictions from the same object + if ( (gRlvHandler.hasBehaviourExcept(RLV_BHVR_TPLOC, gRlvHandler.getCurrentObject())) || + ( (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) && + (gRlvHandler.hasBehaviourExcept(RLV_BHVR_UNSIT, gRlvHandler.getCurrentObject()))) ) + { + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_TELEPORT); + return; + } + + if ( (gRlvHandler.getCurrentCommand()) && (RLV_BHVR_TPTO == gRlvHandler.getCurrentCommand()->getBehaviourType()) ) + { + gRlvHandler.setCanCancelTp(false); + } + } +// [/RLVa:KB] + mTeleportRequest = LLTeleportRequestPtr(new LLTeleportRequestViaLocation(pos_global)); startTeleportRequest(); } @@ -4136,6 +4242,16 @@ void LLAgent::doTeleportViaLocation(const LLVector3d& pos_global) // Teleport to global position, but keep facing in the same direction void LLAgent::teleportViaLocationLookAt(const LLVector3d& pos_global) { +// [RLVa:KB] - Checked: 2010-10-07 (RLVa-1.2.1f) | Added: RLVa-1.2.1f + // RELEASE-RLVa: [SL-2.2.0] Make sure this isn't used for anything except double-click teleporting + if ( (rlv_handler_t::isEnabled()) && (!RlvUtil::isForceTp()) && + ((gRlvHandler.hasBehaviour(RLV_BHVR_SITTP)) || (!gRlvHandler.canStand())) ) + { + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_TELEPORT); + return; + } +// [/RLVa:KB] + mTeleportRequest = LLTeleportRequestPtr(new LLTeleportRequestViaLocationLookAt(pos_global)); startTeleportRequest(); } diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 7fac17d098b4c1b9e078e4d9090924b462f2c916..f7b44b5dc9c16908fc50326c4ff8f0e99ee824a8 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -355,19 +355,31 @@ class LLAgent : public LLOldEvents::LLObservable DOUBLETAP_SLIDERIGHT }; - void setAlwaysRun() { mbAlwaysRun = true; } - void clearAlwaysRun() { mbAlwaysRun = false; } - void setRunning() { mbRunning = true; } - void clearRunning() { mbRunning = false; } - void sendWalkRun(bool running); +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + void setAlwaysRun(); + void setTempRun(); + void clearAlwaysRun(); + void clearTempRun(); + void sendWalkRun(); + bool getTempRun() { return mbTempRun; } + bool getRunning() const { return (mbAlwaysRun) || (mbTempRun); } +// [/RLVa:KB] +// void setAlwaysRun() { mbAlwaysRun = true; } +// void clearAlwaysRun() { mbAlwaysRun = false; } +// void setRunning() { mbRunning = true; } +// void clearRunning() { mbRunning = false; } +// void sendWalkRun(bool running); bool getAlwaysRun() const { return mbAlwaysRun; } - bool getRunning() const { return mbRunning; } +// bool getRunning() const { return mbRunning; } public: LLFrameTimer mDoubleTapRunTimer; EDoubleTapRunMode mDoubleTapRunMode; private: bool mbAlwaysRun; // Should the avatar run by default rather than walk? - bool mbRunning; // Is the avatar trying to run right now? +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + bool mbTempRun; +// [/RLVa:KB] +// bool mbRunning; // Is the avatar trying to run right now? bool mbTeleportKeepsLookAt; // Try to keep look-at after teleport is complete //-------------------------------------------------------------------- diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 488a134aa24d008fc6cca74fdd3f708f75be5b89..571a70585e0b2fd83b26cfce2228251f5c950ed3 100755 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -49,6 +49,9 @@ #include "llvoavatarself.h" #include "llwindow.h" #include "llworld.h" +// [RLVa:KB] - Checked: 2010-05-10 (RLVa-1.2.0g) +#include "rlvhandler.h" +// [/RLVa:KB] using namespace LLAvatarAppearanceDefines; @@ -2248,6 +2251,13 @@ void LLAgentCamera::changeCameraToCustomizeAvatar() return; } +// [RLVa:KB] - Checked: 2010-03-07 (RLVa-1.2.0c) | Modified: RLVa-1.0.0g + if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canStand()) ) + { + return; + } +// [/RLVa:KB] + gAgent.standUp(); // force stand up gViewerWindow->getWindow()->resetBusyCount(); diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp index a4c0b056ac192f5384cb81e41fad73520279fb1d..e49b9cc20ef232f2672ed3087ec8bdfda9ce058f 100755 --- a/indra/newview/llagentlistener.cpp +++ b/indra/newview/llagentlistener.cpp @@ -43,6 +43,10 @@ #include "lltoolgrab.h" #include "llhudeffectlookat.h" #include "llagentcamera.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "llvoavatarself.h" +// [/RLVa:KB] LLAgentListener::LLAgentListener(LLAgent &agent) : LLEventAPI("LLAgent", @@ -179,8 +183,28 @@ void LLAgentListener::requestSit(LLSD const & event_data) const object = findObjectClosestTo(target_position); } +// [RLVa:KB] - Checked: 2010-03-06 (RLVa-1.2.0c) | Modified: RLVa-1.1.0j + // TODO-RLVa: [RLVa-1.2.1] Figure out how to call this? + if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canSit(object)) ) + { + return; + } +// [/RLVa:KB] + if (object && object->getPCode() == LL_PCODE_VOLUME) { +// [RLVa:KB] - Checked: 2010-08-29 (RLVa-1.2.1c) | Added: RLVa-1.2.1c + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_STANDTP)) && (isAgentAvatarValid()) ) + { + if (gAgentAvatarp->isSitting()) + { + gAgent.standUp(); + return; + } + gRlvHandler.setSitSource(gAgent.getPositionGlobal()); + } +// [/RLVa:KB] + gMessageSystem->newMessageFast(_PREHASH_AgentRequestSit); gMessageSystem->nextBlockFast(_PREHASH_AgentData); gMessageSystem->addUUIDFast(_PREHASH_AgentID, mAgent.getID()); @@ -200,6 +224,14 @@ void LLAgentListener::requestSit(LLSD const & event_data) const void LLAgentListener::requestStand(LLSD const & event_data) const { +// [RLVa:KB] - Checked: 2010-03-07 (RLVa-1.2.0c) | Added: RLVa-1.2.0a + // TODO-RLVa: [RLVa-1.2.1] Figure out how to call this? + if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canStand()) ) + { + return; + } +// [/RLVa:KB] + mAgent.setControlFlags(AGENT_CONTROL_STAND_UP); } diff --git a/indra/newview/llagentui.cpp b/indra/newview/llagentui.cpp index 3410a37890505052f86db52601015e878f6f469c..8258e77caa2387699a1eb8d16ec3f72fa5830a19 100755 --- a/indra/newview/llagentui.cpp +++ b/indra/newview/llagentui.cpp @@ -38,6 +38,9 @@ #include "llviewerparcelmgr.h" #include "llvoavatarself.h" #include "llslurl.h" +// [RLVa:KB] - Checked: 2010-04-04 (RLVa-1.2.0d) +#include "rlvhandler.h" +// [/RLVa:KB] //static void LLAgentUI::buildFullname(std::string& name) @@ -99,6 +102,18 @@ BOOL LLAgentUI::buildLocationString(std::string& str, ELocationFormat fmt,const // create a default name and description for the landmark std::string parcel_name = LLViewerParcelMgr::getInstance()->getAgentParcelName(); std::string region_name = region->getName(); +// [RLVa:KB] - Checked: 2010-04-04 (RLVa-1.2.0d) | Modified: RLVa-1.2.0d + // RELEASE-RLVa: [SL-2.0.0] Check ELocationFormat to make sure our switch still makes sense + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { + parcel_name = RlvStrings::getString(RLV_STRING_HIDDEN_PARCEL); + region_name = RlvStrings::getString(RLV_STRING_HIDDEN_REGION); + if (LOCATION_FORMAT_NO_MATURITY == fmt) + fmt = LOCATION_FORMAT_LANDMARK; + else if (LOCATION_FORMAT_FULL == fmt) + fmt = LOCATION_FORMAT_NO_COORDS; + } +// [/RLVa:KB] std::string sim_access_string = region->getSimAccessString(); std::string buffer; if( parcel_name.empty() ) diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp old mode 100755 new mode 100644 index 9c749d49d590db490d00c12f5d683feeb712f931..ed7e3e8ac4ba541303a0df7ac68c427311c3639a --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -49,6 +49,10 @@ #include "llvoavatarself.h" #include "llviewerwearable.h" #include "llwearablelist.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] #include <boost/scoped_ptr.hpp> @@ -771,6 +775,34 @@ const LLUUID LLAgentWearables::getWearableItemID(LLWearableType::EType type, U32 return LLUUID(); } +// [RLVa:KB] - Checked: 2011-03-31 (RLVa-1.3.0) +void LLAgentWearables::getWearableItemIDs(uuid_vec_t& idItems) const +{ + for (wearableentry_map_t::const_iterator itWearableType = mWearableDatas.begin(); + itWearableType != mWearableDatas.end(); ++itWearableType) + { + getWearableItemIDs(itWearableType->first, idItems); + } +} + +void LLAgentWearables::getWearableItemIDs(LLWearableType::EType eType, uuid_vec_t& idItems) const +{ + wearableentry_map_t::const_iterator itWearableType = mWearableDatas.find(eType); + if (mWearableDatas.end() != itWearableType) + { + for (wearableentry_vec_t::const_iterator itWearable = itWearableType->second.begin(); + itWearable != itWearableType->second.end(); ++itWearable) + { + const LLViewerWearable* pWearable = dynamic_cast<LLViewerWearable*>(*itWearable); + if (pWearable) + { + idItems.push_back(pWearable->getItemID()); + } + } + } +} +// [/RLVa:KB] + const LLUUID LLAgentWearables::getWearableAssetID(LLWearableType::EType type, U32 index) const { const LLViewerWearable *wearable = getViewerWearable(type,index); @@ -1214,7 +1246,11 @@ void LLAgentWearables::removeWearableFinal(const LLWearableType::EType type, boo old_wearable->removeFromAvatar(TRUE); } } - clearWearableType(type); +// clearWearableType(type); +// [RLVa:KB] - Checked: 2010-05-14 (RLVa-1.2.0) + // The line above shouldn't be needed + RLV_VERIFY(0 == getWearableCount(type)); +// [/RLVa:KB] } else { @@ -1325,46 +1361,46 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it } -// User has picked "wear on avatar" from a menu. -void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLViewerWearable* new_wearable, bool do_append) -{ - //LLAgentDumper dumper("setWearableItem"); - if (isWearingItem(new_item->getUUID())) - { - llwarns << "wearable " << new_item->getUUID() << " is already worn" << llendl; - return; - } - - const LLWearableType::EType type = new_wearable->getType(); - - if (!do_append) - { - // Remove old wearable, if any - // MULTI_WEARABLE: hardwired to 0 - LLViewerWearable* old_wearable = getViewerWearable(type,0); - if (old_wearable) - { - const LLUUID& old_item_id = old_wearable->getItemID(); - if ((old_wearable->getAssetID() == new_wearable->getAssetID()) && - (old_item_id == new_item->getUUID())) - { - lldebugs << "No change to wearable asset and item: " << LLWearableType::getTypeName(type) << llendl; - return; - } - - if (old_wearable->isDirty()) - { - // Bring up modal dialog: Save changes? Yes, No, Cancel - LLSD payload; - payload["item_id"] = new_item->getUUID(); - LLNotificationsUtil::add("WearableSave", LLSD(), payload, boost::bind(onSetWearableDialog, _1, _2, new_wearable)); - return; - } - } - } - - setWearableFinal(new_item, new_wearable, do_append); -} +//// User has picked "wear on avatar" from a menu. +//void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLViewerWearable* new_wearable, bool do_append) +//{ +// //LLAgentDumper dumper("setWearableItem"); +// if (isWearingItem(new_item->getUUID())) +// { +// llwarns << "wearable " << new_item->getUUID() << " is already worn" << llendl; +// return; +// } +// +// const LLWearableType::EType type = new_wearable->getType(); +// +// if (!do_append) +// { +// // Remove old wearable, if any +// // MULTI_WEARABLE: hardwired to 0 +// LLViewerWearable* old_wearable = getViewerWearable(type,0); +// if (old_wearable) +// { +// const LLUUID& old_item_id = old_wearable->getItemID(); +// if ((old_wearable->getAssetID() == new_wearable->getAssetID()) && +// (old_item_id == new_item->getUUID())) +// { +// lldebugs << "No change to wearable asset and item: " << LLWearableType::getTypeName(type) << llendl; +// return; +// } +// +// if (old_wearable->isDirty()) +// { +// // Bring up modal dialog: Save changes? Yes, No, Cancel +// LLSD payload; +// payload["item_id"] = new_item->getUUID(); +// LLNotificationsUtil::add("WearableSave", LLSD(), payload, boost::bind(onSetWearableDialog, _1, _2, new_wearable)); +// return; +// } +// } +// } +// +// setWearableFinal(new_item, new_wearable, do_append); +//} // static bool LLAgentWearables::onSetWearableDialog(const LLSD& notification, const LLSD& response, LLViewerWearable* wearable) @@ -1515,24 +1551,24 @@ void LLAgentWearables::invalidateBakedTextureHash(LLMD5& hash) const // User has picked "remove from avatar" from a menu. // static -void LLAgentWearables::userRemoveWearable(const LLWearableType::EType &type, const U32 &index) -{ - if (!(type==LLWearableType::WT_SHAPE || type==LLWearableType::WT_SKIN || type==LLWearableType::WT_HAIR || type==LLWearableType::WT_EYES)) //&& - //!((!gAgent.isTeen()) && (type==LLWearableType::WT_UNDERPANTS || type==LLWearableType::WT_UNDERSHIRT))) - { - gAgentWearables.removeWearable(type,false,index); - } -} +//void LLAgentWearables::userRemoveWearable(const LLWearableType::EType &type, const U32 &index) +//{ +// if (!(type==LLWearableType::WT_SHAPE || type==LLWearableType::WT_SKIN || type==LLWearableType::WT_HAIR || type==LLWearableType::WT_EYES)) //&& +// //!((!gAgent.isTeen()) && (type==LLWearableType::WT_UNDERPANTS || type==LLWearableType::WT_UNDERSHIRT))) +// { +// gAgentWearables.removeWearable(type,false,index); +// } +//} //static -void LLAgentWearables::userRemoveWearablesOfType(const LLWearableType::EType &type) -{ - if (!(type==LLWearableType::WT_SHAPE || type==LLWearableType::WT_SKIN || type==LLWearableType::WT_HAIR || type==LLWearableType::WT_EYES)) //&& - //!((!gAgent.isTeen()) && (type==LLWearableType::WT_UNDERPANTS || type==LLWearableType::WT_UNDERSHIRT))) - { - gAgentWearables.removeWearable(type,true,0); - } -} +//void LLAgentWearables::userRemoveWearablesOfType(const LLWearableType::EType &type) +//{ +// if (!(type==LLWearableType::WT_SHAPE || type==LLWearableType::WT_SKIN || type==LLWearableType::WT_HAIR || type==LLWearableType::WT_EYES)) //&& +// //!((!gAgent.isTeen()) && (type==LLWearableType::WT_UNDERPANTS || type==LLWearableType::WT_UNDERSHIRT))) +// { +// gAgentWearables.removeWearable(type,true,0); +// } +//} // Combines userRemoveMulipleAttachments() and userAttachMultipleAttachments() logic to // get attachments into desired state with minimal number of adds/removes. @@ -1620,6 +1656,34 @@ void LLAgentWearables::userRemoveMultipleAttachments(llvo_vec_t& objects_to_remo { if (!isAgentAvatarValid()) return; +// [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.0) + // RELEASE-RLVa: [SL-3.4] Check our callers and verify that erasing elements from the passed vector won't break random things + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_REMOVE)) ) + { + llvo_vec_t::iterator itObj = objects_to_remove.begin(); + while (objects_to_remove.end() != itObj) + { + const LLViewerObject* pAttachObj = *itObj; + if (gRlvAttachmentLocks.isLockedAttachment(pAttachObj)) + { + itObj = objects_to_remove.erase(itObj); + + // Fall-back code: re-add the attachment if it got removed from COF somehow (compensates for possible bugs elsewhere) + bool fInCOF = LLAppearanceMgr::isLinkInCOF(pAttachObj->getAttachmentItemID()); + RLV_ASSERT(fInCOF); + if (!fInCOF) + { + LLAppearanceMgr::instance().registerAttachment(pAttachObj->getAttachmentItemID()); + } + } + else + { + ++itObj; + } + } + } +// [/RLVa:KB] + if (objects_to_remove.empty()) return; @@ -1641,6 +1705,25 @@ void LLAgentWearables::userRemoveMultipleAttachments(llvo_vec_t& objects_to_remo void LLAgentWearables::userAttachMultipleAttachments(LLInventoryModel::item_array_t& obj_item_array) { +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1) + static bool sInitialAttachmentsRequested = false; + + // RELEASE-RLVa: [SL-3.4] Check our callers and verify that erasing elements from the passed vector won't break random things + if ( (rlv_handler_t::isEnabled()) && (sInitialAttachmentsRequested) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY)) ) + { + // Fall-back code: everything should really already have been pruned before we get this far + for (S32 idxItem = obj_item_array.count() - 1; idxItem >= 0; idxItem--) + { + const LLInventoryItem* pItem = obj_item_array.get(idxItem).get(); + if (!gRlvAttachmentLocks.canAttach(pItem)) + { + obj_item_array.remove(idxItem); + RLV_ASSERT(false); + } + } + } +// [/RLVa:KB] + // Build a compound message to send all the objects that need to be rezzed. S32 obj_count = obj_item_array.count(); @@ -1678,6 +1761,12 @@ void LLAgentWearables::userAttachMultipleAttachments(LLInventoryModel::item_arra msg->addUUIDFast(_PREHASH_ItemID, item->getLinkedUUID()); msg->addUUIDFast(_PREHASH_OwnerID, item->getPermissions().getOwner()); msg->addU8Fast(_PREHASH_AttachmentPt, 0 | ATTACHMENT_ADD); // Wear at the previous or default attachment point +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1) + if ( (rlv_handler_t::isEnabled()) && (sInitialAttachmentsRequested) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY)) ) + { + RlvAttachmentLockWatchdog::instance().onWearAttachment(item, RLV_WEAR_ADD); + } +// [/RLVa:KB] pack_permissions_slam(msg, item->getFlags(), item->getPermissions()); msg->addStringFast(_PREHASH_Name, item->getName()); msg->addStringFast(_PREHASH_Description, item->getDescription()); @@ -1688,6 +1777,10 @@ void LLAgentWearables::userAttachMultipleAttachments(LLInventoryModel::item_arra msg->sendReliable( gAgent.getRegion()->getHost() ); } } + +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1) + sInitialAttachmentsRequested = true; +// [/RLVa:KB] } void LLAgentWearables::checkWearablesLoaded() const diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h index 2b2a16799508d2ee21c63a867f1c08a9ced45b70..a54f362dcfce0d22655ef17d9a0352cd629e685d 100755 --- a/indra/newview/llagentwearables.h +++ b/indra/newview/llagentwearables.h @@ -93,6 +93,10 @@ class LLAgentWearables : public LLInitClass<LLAgentWearables>, public LLWearable // Accessors //-------------------------------------------------------------------- public: +// [RLVa:KB] - Checked: 2011-03-31 (RLVa-1.3.0) + void getWearableItemIDs(uuid_vec_t& idItems) const; + void getWearableItemIDs(LLWearableType::EType eType, uuid_vec_t& idItems) const; +// [/RLVa:KB] const LLUUID getWearableItemID(LLWearableType::EType type, U32 index /*= 0*/) const; const LLUUID getWearableAssetID(LLWearableType::EType type, U32 index /*= 0*/) const; const LLViewerWearable* getWearableFromItemID(const LLUUID& item_id) const; @@ -109,7 +113,7 @@ class LLAgentWearables : public LLInitClass<LLAgentWearables>, public LLWearable private: /*virtual*/void wearableUpdated(LLWearable *wearable, BOOL removed); public: - void setWearableItem(LLInventoryItem* new_item, LLViewerWearable* wearable, bool do_append = false); +// void setWearableItem(LLInventoryItem* new_item, LLViewerWearable* wearable, bool do_append = false); void setWearableOutfit(const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLViewerWearable* >& wearables, BOOL remove); void setWearableName(const LLUUID& item_id, const std::string& new_name); // *TODO: Move this into llappearance/LLWearableData ? @@ -149,8 +153,11 @@ class LLAgentWearables : public LLInitClass<LLAgentWearables>, public LLWearable // Removing wearables //-------------------------------------------------------------------- public: - void removeWearable(const LLWearableType::EType type, bool do_remove_all /*= false*/, U32 index /*= 0*/); +// void removeWearable(const LLWearableType::EType type, bool do_remove_all /*= false*/, U32 index /*= 0*/); private: +// [RLVa:KB] - Checked: 2010-05-11 (RLVa-1.2.0) + void removeWearable(const LLWearableType::EType type, bool do_remove_all /*= false*/, U32 index /*= 0*/); +// [/RLVa:KB] void removeWearableFinal(const LLWearableType::EType type, bool do_remove_all /*= false*/, U32 index /*= 0*/); protected: static bool onRemoveWearableDialog(const LLSD& notification, const LLSD& response); @@ -196,8 +203,8 @@ class LLAgentWearables : public LLInitClass<LLAgentWearables>, public LLWearable // Static UI hooks //-------------------------------------------------------------------- public: - static void userRemoveWearable(const LLWearableType::EType &type, const U32 &index); - static void userRemoveWearablesOfType(const LLWearableType::EType &type); +// static void userRemoveWearable(const LLWearableType::EType &type, const U32 &index); +// static void userRemoveWearablesOfType(const LLWearableType::EType &type); typedef std::vector<LLViewerObject*> llvo_vec_t; diff --git a/indra/newview/llagentwearablesfetch.cpp b/indra/newview/llagentwearablesfetch.cpp index 8b6b6db525058d2547a04262d55deffaf41e27f1..52b63a43bec5f690af114ef36cba61827c30f450 100755 --- a/indra/newview/llagentwearablesfetch.cpp +++ b/indra/newview/llagentwearablesfetch.cpp @@ -33,7 +33,9 @@ #include "llinventoryfunctions.h" #include "llstartup.h" #include "llvoavatarself.h" - +// [RLVa:KB] - Checked: 2010-12-15 (RLVa-1.2.2c) +#include "rlvhelper.h" +// [/RLVa:KB] void order_my_outfits_cb() { @@ -96,7 +98,14 @@ void LLInitialWearablesFetch::done() // gInventory.notifyObservers. The results will be handled in the next // idle tick instead. gInventory.removeObserver(this); - doOnIdleOneTime(boost::bind(&LLInitialWearablesFetch::processContents,this)); +// doOnIdleOneTime(boost::bind(&LLInitialWearablesFetch::processContents,this)); +// [RLVa:KB] - Checked: 2010-12-15 (RLVa-1.2.2c) | Added: RLVa-1.2.2c + F32 nDelay = gSavedSettings.getF32("ForceInitialCOFDelay"); + if (0.0f == nDelay) + doOnIdleOneTime(boost::bind(&LLInitialWearablesFetch::processContents,this)); + else + rlvCallbackTimerOnce(nDelay, boost::bind(&LLInitialWearablesFetch::processContents,this)); +// [/RLVa:KB] if (isAgentAvatarValid()) { gAgentAvatarp->stopPhase("initial_wearables_fetch"); diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp old mode 100755 new mode 100644 index f10a44e8ebbca29ab478494b4bce4990270de93c..25d1c21efdbd5cbb30bb82ea6e6296ffa6e085ba --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -52,6 +52,11 @@ #include "llwearablelist.h" #include "llsdutil.h" #include "llsdserialize.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvhelper.h" +#include "rlvlocks.h" +// [/RLVa:KB] #if LL_MSVC // disable boost::lexical_cast warning @@ -1210,6 +1215,23 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items) items = new_items; } +// [SL:KB] - Patch: Appearance-WearableDuplicateAssets | Checked: 2011-07-24 (Catznip-2.6.0e) | Added: Catznip-2.6.0e +static void removeDuplicateWearableItemsByAssetID(LLInventoryModel::item_array_t& items) +{ + std::set<LLUUID> idsAsset; + for (S32 idxItem = items.count() - 1; idxItem >= 0; idxItem--) + { + const LLViewerInventoryItem* pItem = items.get(idxItem); + if (!pItem->isWearableType()) + continue; + if (idsAsset.end() == idsAsset.find(pItem->getAssetUUID())) + idsAsset.insert(pItem->getAssetUUID()); + else + items.remove(idxItem); + } +} +// [/SL:KB] + const LLUUID LLAppearanceMgr::getCOF() const { return gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); @@ -1344,6 +1366,14 @@ bool LLAppearanceMgr::wearItemOnAvatar(const LLUUID& item_id_to_wear, bool do_up return false; } +// [RLVa:KB] - Checked: 2013-02-12 (RLVa-1.4.8) + replace |= (LLAssetType::AT_BODYPART == item_to_wear->getType()); // Body parts should always replace + if ( (rlv_handler_t::isEnabled()) && (!rlvPredCanWearItem(item_to_wear, (replace) ? RLV_WEAR_REPLACE : RLV_WEAR_ADD)) ) + { + return false; + } +// [/RLVa:KB] + switch (item_to_wear->getType()) { case LLAssetType::AT_CLOTHING: @@ -1729,6 +1759,78 @@ void LLAppearanceMgr::purgeCategory(const LLUUID& category, bool keep_outfit_lin } } +// [SL:KB] - Checked: 2010-04-24 (RLVa-1.2.0f) | Added: RLVa-1.2.0f +void LLAppearanceMgr::purgeItems(const LLInventoryModel::item_array_t& items) +{ + for (LLInventoryModel::item_array_t::const_iterator itItem = items.begin(); itItem != items.end(); ++itItem) + { + const LLViewerInventoryItem* pItem = *itItem; + if (pItem->getIsLinkType()) + { + gInventory.purgeObject(pItem->getUUID()); + } + } +} + +void LLAppearanceMgr::purgeItemsOfType(LLAssetType::EType asset_type) +{ + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + gInventory.collectDescendents(getCOF(), cats, items, LLInventoryModel::EXCLUDE_TRASH); + for (LLInventoryModel::item_array_t::const_iterator itItem = items.begin(); itItem != items.end(); ++itItem) + { + const LLInventoryItem* pItem = *itItem; + if ( (pItem->getIsLinkType()) && (asset_type == pItem->getType()) ) + { + gInventory.purgeObject(pItem->getUUID()); + } + } +} + +void LLAppearanceMgr::syncCOF(const LLInventoryModel::item_array_t& items, + LLInventoryModel::item_array_t& items_to_add, LLInventoryModel::item_array_t& items_to_remove) +{ + const LLUUID idCOF = getCOF(); + LLInventoryModel::item_array_t cur_cof_items, new_cof_items = items; + + // Grab the current COF contents + LLInventoryModel::cat_array_t cats; + gInventory.collectDescendents(getCOF(), cats, cur_cof_items, LLInventoryModel::EXCLUDE_TRASH); + + // Purge everything in cur_cof_items that isn't part of new_cof_items + for (S32 idxCurItem = 0, cntCurItem = cur_cof_items.count(); idxCurItem < cntCurItem; idxCurItem++) + { + LLViewerInventoryItem* pItem = cur_cof_items.get(idxCurItem); + if (std::find_if(new_cof_items.begin(), new_cof_items.end(), RlvPredIsEqualOrLinkedItem(pItem)) == new_cof_items.end()) + { + // Item doesn't exist in new_cof_items => purge (if it's a link) + if ( (pItem->getIsLinkType()) && + (LLAssetType::AT_LINK_FOLDER != pItem->getActualType()) && + (items_to_remove.end() == std::find(items_to_remove.begin(), items_to_remove.end(), pItem)) ) + { + items_to_remove.push_back(pItem); + } + } + else + { + // Item exists in new_cof_items => remove *all* occurances in new_cof_items (removes duplicate COF links to this item as well) + new_cof_items.erase( + std::remove_if(new_cof_items.begin(), new_cof_items.end(), RlvPredIsEqualOrLinkedItem(pItem)), new_cof_items.end()); + } + } + + // Whatever remains in new_cof_items will need to have a link created + for (S32 idxNewItem = 0, cntNewItem = new_cof_items.count(); idxNewItem < cntNewItem; idxNewItem++) + { + LLViewerInventoryItem* pItem = new_cof_items.get(idxNewItem); + if (items_to_add.end() == std::find(items_to_add.begin(), items_to_add.end(), pItem)) + { + items_to_add.push_back(pItem); + } + } +} +// [/SL:KB] + // Keep the last N wearables of each type. For viewer 2.0, N is 1 for // both body parts and clothing items. void LLAppearanceMgr::filterWearableItems( @@ -1780,10 +1882,31 @@ void LLAppearanceMgr::linkAll(const LLUUID& cat_uuid, } } +//void LLAppearanceMgr::updateCOF(const LLUUID& category, bool append) +// [RLVa:KB] - Checked: 2010-03-05 (RLVa-1.2.0b) | Added: RLVa-1.2.0b void LLAppearanceMgr::updateCOF(const LLUUID& category, bool append) { - LLViewerInventoryCategory *pcat = gInventory.getCategory(category); - LL_INFOS("Avatar") << self_av_string() << "starting, cat '" << (pcat ? pcat->getName() : "[UNKNOWN]") << "'" << LL_ENDL; + LLInventoryModel::item_array_t body_items_new, wear_items_new, obj_items_new, gest_items_new; + getDescendentsOfAssetType(category, body_items_new, LLAssetType::AT_BODYPART, false); + getDescendentsOfAssetType(category, wear_items_new, LLAssetType::AT_CLOTHING, false); + getDescendentsOfAssetType(category, obj_items_new, LLAssetType::AT_OBJECT, false); + getDescendentsOfAssetType(category, gest_items_new, LLAssetType::AT_GESTURE, false); + updateCOF(body_items_new, wear_items_new, obj_items_new, gest_items_new, append, category); +} + +void LLAppearanceMgr::updateCOF(LLInventoryModel::item_array_t& body_items_new, + LLInventoryModel::item_array_t& wear_items_new, + LLInventoryModel::item_array_t& obj_items_new, + LLInventoryModel::item_array_t& gest_items_new, + bool append /*=false*/, const LLUUID& idOutfit /*=LLUUID::null*/) +// [/RLVa:KB] +{ +// LLViewerInventoryCategory *pcat = gInventory.getCategory(category); +// LL_INFOS("Avatar") << self_av_string() << "starting, cat '" << (pcat ? pcat->getName() : "[UNKNOWN]") << "'" << LL_ENDL; +// [RLVa:KB] - Checked: 2010-03-26 (RLVa-1.2.0b) | Added: RLVa-1.2.0b + // RELEASE-RLVa: [SL-2.0.0] If pcat ever gets used for anything further down the beta we'll know about it + llinfos << "starting" << llendl; +// [/RLVa:KB] const LLUUID cof = getCOF(); @@ -1804,39 +1927,87 @@ void LLAppearanceMgr::updateCOF(const LLUUID& category, bool append) // Collect and filter descendents to determine new COF contents. - // - Body parts: always include COF contents as a fallback in case any - // required parts are missing. + // + // - Body parts: always include COF contents as a fallback in case any required parts are missing. + // // Preserve body parts from COF if appending. LLInventoryModel::item_array_t body_items; getDescendentsOfAssetType(cof, body_items, LLAssetType::AT_BODYPART, false); - getDescendentsOfAssetType(category, body_items, LLAssetType::AT_BODYPART, false); - if (append) - reverse(body_items.begin(), body_items.end()); +// getDescendentsOfAssetType(category, body_items, LLAssetType::AT_BODYPART, false); +// [RLVa:KB] - Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0b + // Filter out any new body parts that can't be worn before adding them + if ( (rlv_handler_t::isEnabled()) && (gRlvWearableLocks.hasLockedWearableType(RLV_LOCK_ANY)) ) + body_items_new.erase(std::remove_if(body_items_new.begin(), body_items_new.end(), RlvPredCanNotWearItem(RLV_WEAR_REPLACE)), body_items_new.end()); + body_items.insert(body_items.end(), body_items_new.begin(), body_items_new.end()); +// [/RLVa:KB] + // NOTE-RLVa: we don't actually want to favour COF body parts over the folder's body parts (if only because it breaks force wear) +// if (append) +// reverse(body_items.begin(), body_items.end()); // Reduce body items to max of one per type. removeDuplicateItems(body_items); filterWearableItems(body_items, 1); + // // - Wearables: include COF contents only if appending. + // LLInventoryModel::item_array_t wear_items; if (append) getDescendentsOfAssetType(cof, wear_items, LLAssetType::AT_CLOTHING, false); - getDescendentsOfAssetType(category, wear_items, LLAssetType::AT_CLOTHING, false); +// [RLVa:KB] - Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0b + else if ( (rlv_handler_t::isEnabled()) && (gRlvWearableLocks.hasLockedWearableType(RLV_LOCK_ANY)) ) + { + // Make sure that all currently locked clothing layers remain in COF when replacing + getDescendentsOfAssetType(cof, wear_items, LLAssetType::AT_CLOTHING, false); + wear_items.erase(std::remove_if(wear_items.begin(), wear_items.end(), rlvPredCanRemoveItem), wear_items.end()); + } +// [/RLVa:KB] +// getDescendentsOfAssetType(category, wear_items, LLAssetType::AT_CLOTHING, false); +// [RLVa:KB] - Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0b + // Filter out any new wearables that can't be worn before adding them + if ( (rlv_handler_t::isEnabled()) && (gRlvWearableLocks.hasLockedWearableType(RLV_LOCK_ANY)) ) + wear_items_new.erase(std::remove_if(wear_items_new.begin(), wear_items_new.end(), RlvPredCanNotWearItem(RLV_WEAR)), wear_items_new.end()); + wear_items.insert(wear_items.end(), wear_items_new.begin(), wear_items_new.end()); +// [/RLVa:KB] // Reduce wearables to max of one per type. removeDuplicateItems(wear_items); +// [SL:KB] - Patch: Appearance-WearableDuplicateAssets | Checked: 2011-07-24 (Catznip-2.6.0e) | Added: Catznip-2.6.0e + removeDuplicateWearableItemsByAssetID(wear_items); +// [/SL:KB] filterWearableItems(wear_items, LLAgentWearables::MAX_CLOTHING_PER_TYPE); + // // - Attachments: include COF contents only if appending. + // LLInventoryModel::item_array_t obj_items; if (append) getDescendentsOfAssetType(cof, obj_items, LLAssetType::AT_OBJECT, false); - getDescendentsOfAssetType(category, obj_items, LLAssetType::AT_OBJECT, false); +// [RLVa:KB] - Checked: 2010-03-05 (RLVa-1.2.0z) | Modified: RLVa-1.2.0b + else if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY)) ) + { + // Make sure that all currently locked attachments remain in COF when replacing + getDescendentsOfAssetType(cof, obj_items, LLAssetType::AT_OBJECT, false); + obj_items.erase(std::remove_if(obj_items.begin(), obj_items.end(), rlvPredCanRemoveItem), obj_items.end()); + } +// [/RLVa:KB] +// getDescendentsOfAssetType(category, obj_items, LLAssetType::AT_OBJECT, false); +// [RLVa:KB] - Checked: 2010-03-05 (RLVa-1.2.0z) | Modified: RLVa-1.2.0b + // Filter out any new attachments that can't be worn before adding them + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY)) ) + obj_items_new.erase(std::remove_if(obj_items_new.begin(), obj_items_new.end(), RlvPredCanNotWearItem(RLV_WEAR)), obj_items_new.end()); + obj_items.insert(obj_items.end(), obj_items_new.begin(), obj_items_new.end()); +// [/RLVa:KB] removeDuplicateItems(obj_items); + // // - Gestures: include COF contents only if appending. + // LLInventoryModel::item_array_t gest_items; if (append) getDescendentsOfAssetType(cof, gest_items, LLAssetType::AT_GESTURE, false); - getDescendentsOfAssetType(category, gest_items, LLAssetType::AT_GESTURE, false); +// getDescendentsOfAssetType(category, gest_items, LLAssetType::AT_GESTURE, false); +// [RLVa:KB] - Checked: 2010-03-05 (RLVa-1.2.0z) | Added: RLVa-1.2.0b + gest_items.insert(gest_items.end(), gest_items_new.begin(), gest_items_new.end()); +// [/RLVa:KB] removeDuplicateItems(gest_items); // Create links to new COF contents. @@ -1846,23 +2017,50 @@ void LLAppearanceMgr::updateCOF(const LLUUID& category, bool append) all_items += obj_items; all_items += gest_items; +// [SL:KB] + // Synchronize COF + // -> it's possible that we don't link to any new items in which case 'link_waiter' fires when it goes out of scope below + LLInventoryModel::item_array_t items_add, items_remove; + syncCOF(all_items, items_add, items_remove); +// [/SL:KB] + // Will link all the above items. LLPointer<LLInventoryCallback> link_waiter = new LLUpdateAppearanceOnDestroy; - linkAll(cof,all_items,link_waiter); +// [SL:KB] - Checked: 2013-03-05 (RLVa-1.4.8) + linkAll(cof, items_add, link_waiter); +// [/SL:KB] +// linkAll(cof,all_items,link_waiter); // Add link to outfit if category is an outfit. - if (!append) +// [SL:KB] - Checked: 2010-04-24 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + if ( (!append) && (idOutfit.notNull()) ) { - createBaseOutfitLink(category, link_waiter); + createBaseOutfitLink(idOutfit, link_waiter); } - +// [/SL:KB] +// if (!append) +// { +// createBaseOutfitLink(category, link_waiter); +// } +// // Remove current COF contents. Have to do this after creating // the link_waiter so links can be followed for any items that get // carried over (e.g. keeping old shape if the new outfit does not // contain one) +// [SL:KB] + purgeItems(items_remove); + bool keep_outfit_links = append; - purgeCategory(cof, keep_outfit_links, &all_items); + if (!keep_outfit_links) + { + purgeItemsOfType(LLAssetType::AT_LINK_FOLDER); + } + gInventory.notifyObservers(); +// [/SL:KB] +// bool keep_outfit_links = append; +// purgeCategory(cof, keep_outfit_links, &all_items); +// gInventory.notifyObservers(); LL_DEBUGS("Avatar") << self_av_string() << "waiting for LLUpdateAppearanceOnDestroy" << LL_ENDL; } @@ -1900,6 +2098,14 @@ void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder, boo lldebugs << "updateAgentWearables()" << llendl; LLInventoryItem::item_array_t items; LLDynamicArray< LLViewerWearable* > wearables; +// [RLVa:KB] - Checked: 2011-03-31 (RLVa-1.3.0f) | Added: RLVa-1.3.0f + uuid_vec_t idsCurrent; LLInventoryModel::item_array_t itemsNew; + if (rlv_handler_t::isEnabled()) + { + // Collect the item UUIDs of all currently worn wearables + gAgentWearables.getWearableItemIDs(idsCurrent); + } +// [/RLVa:KB] // For each wearable type, find the wearables of that type. for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ ) @@ -1914,13 +2120,60 @@ void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder, boo LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(data.mItemID); if( item && (item->getAssetUUID() == wearable->getAssetID()) ) { +// [RLVa:KB] - Checked: 2010-03-19 (RLVa-1.2.0g) | Modified: RLVa-1.2.0g + // TODO-RLVa: [RLVa-1.2.1] This is fall-back code so if we don't ever trigger this code it can just be removed + // -> one way to trigger the assertion: + // 1) "Replace Outfit" on a folder with clothing and an attachment that goes @addoutfit=n + // 2) updateCOF will add/link the items into COF => no @addoutfit=n present yet => allowed + // 3) llOwnerSay("@addoutfit=n") executes + // 4) code below runs => @addoutfit=n conflicts with adding new wearables + // => if it's left as-is then the wearables won't get worn (but remain in COF which causes issues of its own) + // => if it's changed to debug-only then we make tge assumption that anything that makes it into COF is always OK +#ifdef RLV_DEBUG + // NOTE: make sure we don't accidentally block setting the initial wearables + if ( (rlv_handler_t::isEnabled()) && (RLV_WEAR_LOCKED == gRlvWearableLocks.canWear(wearable->getType())) && + (!gAgentWearables.getWearableFromItemID(item->getUUID())) && (gAgentWearables.areWearablesLoaded()) ) + { + RLV_VERIFY(RLV_WEAR_LOCKED == gRlvWearableLocks.canWear(wearable->getType())); + continue; + } +#endif // RLV_DEBUG +// [/RLVa:KB] items.put(item); wearables.put(wearable); +// [RLVa:KB] - Checked: 2011-03-31 (RLVa-1.3.0f) | Added: RLVa-1.3.0f + if ( (rlv_handler_t::isEnabled()) && (gAgentWearables.areInitalWearablesLoaded()) ) + { + // Remove the wearable from current item UUIDs if currently worn and requested, otherwise mark it as a new item + uuid_vec_t::iterator itItemID = std::find(idsCurrent.begin(), idsCurrent.end(), item->getUUID()); + if (idsCurrent.end() != itItemID) + idsCurrent.erase(itItemID); + else + itemsNew.push_back(item); + } +// [/RLVa:KB] } } } } +// [RLVa:KB] - Checked: 2011-03-31 (RLVa-1.3.0f) | Added: RLVa-1.3.0f + if ( (rlv_handler_t::isEnabled()) && (gAgentWearables.areInitalWearablesLoaded()) ) + { + // We need to report removals before additions or scripts will get confused + for (uuid_vec_t::const_iterator itItemID = idsCurrent.begin(); itItemID != idsCurrent.end(); ++itItemID) + { + const LLWearable* pWearable = gAgentWearables.getWearableFromItemID(*itItemID); + if (pWearable) + RlvBehaviourNotifyHandler::onTakeOff(pWearable->getType(), true); + } + for (S32 idxItem = 0, cntItem = itemsNew.count(); idxItem < cntItem; idxItem++) + { + RlvBehaviourNotifyHandler::onWear(itemsNew.get(idxItem)->getWearableType(), true); + } + } +// [/RLVa:KB] + if(wearables.count() > 0) { gAgentWearables.setWearableOutfit(items, wearables, !append); @@ -2082,6 +2335,10 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering) removeDuplicateItems(gest_items); filterWearableItems(wear_items, LLAgentWearables::MAX_CLOTHING_PER_TYPE); // [/SL:KB] +// [SL:KB] - Patch: Appearance-WearableDuplicateAssets | Checked: 2011-07-24 (Catznip-2.6.0e) | Added: Catznip-2.6.0e + // Wearing two wearables that share the same asset causes some issues + removeDuplicateWearableItemsByAssetID(wear_items); +// [/SL:KB] dumpItemArray(wear_items,"asset_dump: wear_item"); dumpItemArray(obj_items,"asset_dump: obj_item"); @@ -2145,6 +2402,9 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering) // fetch failures (should be replaced by new defaults in // lost&found). U32 skip_type = gSavedSettings.getU32("ForceAssetFail"); +// [RLVa:KB] - Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c + U32 missing_type = gSavedSettings.getU32("ForceMissingType"); +// [/RLVa:KB] if (item && item->getIsLinkType() && linked_item) { @@ -2155,10 +2415,25 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering) linked_item->isWearableType() ? linked_item->getWearableType() : LLWearableType::WT_INVALID ); - if (skip_type != LLWearableType::WT_INVALID && skip_type == found.mWearableType) +// [RLVa:KB] - Checked: 2010-12-15 (RLVa-1.2.2c) | Modified: RLVa-1.2.2c +#ifdef LL_RELEASE_FOR_DOWNLOAD + // Don't allow forcing an invalid wearable if the initial wearables aren't set yet, or if any wearable type is currently locked + if ( (!rlv_handler_t::isEnabled()) || + ((gAgentWearables.areInitalWearablesLoaded()) && (!gRlvWearableLocks.hasLockedWearableType(RLV_LOCK_REMOVE))) ) +#endif // LL_RELEASE_FOR_DOWNLOAD { - found.mAssetID.generate(); // Replace with new UUID, guaranteed not to exist in DB + if (missing_type != LLWearableType::WT_INVALID && missing_type == found.mWearableType) + { + continue; + } +// [/RLVa:KB] + if (skip_type != LLWearableType::WT_INVALID && skip_type == found.mWearableType) + { + found.mAssetID.generate(); // Replace with new UUID, guaranteed not to exist in DB + } +// [RLVa:KB] - Checked: 2010-12-15 (RLVa-1.2.2c) | Modified: RLVa-1.2.2c } +// [/RLVa:KB] //pushing back, not front, to preserve order of wearables for LLAgentWearables holder->getFoundList().push_back(found); } @@ -2535,6 +2810,13 @@ void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update // MULTI-WEARABLES: make sure we don't go over MAX_CLOTHING_PER_TYPE gInventory.purgeObject(inv_item->getUUID()); } +// [SL:KB] - Patch: Appearance-WearableDuplicateAssets | Checked: 2011-07-24 (Catznip-2.6.0e) | Added: Catznip-2.6.0e + else if ( (vitem->getWearableType() == wearable_type) && (vitem->getAssetUUID() == inv_item->getAssetUUID()) ) + { + // Only allow one wearable per unique asset + linked_already = true; + } +// [/SL:KB] } } @@ -2664,6 +2946,16 @@ void LLAppearanceMgr::removeCOFItemLinks(const LLUUID& item_id) const LLInventoryItem* item = item_array.get(i).get(); if (item->getIsLinkType() && item->getLinkedUUID() == item_id) { +// [RLVa:KB] - Checked: 2013-02-12 (RLVa-1.4.8) +#if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG + // NOTE-RLVa: debug-only, can be removed down the line + if (rlv_handler_t::isEnabled()) + { + RLV_ASSERT(rlvPredCanRemoveItem(item)); + } +#endif // LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG +// [/RLVa:KB] + gInventory.purgeObject(item->getUUID()); } } @@ -2682,6 +2974,16 @@ void LLAppearanceMgr::removeCOFLinksOfType(LLWearableType::EType type) const LLViewerInventoryItem* item = *it; if (item->getIsLinkType()) // we must operate on links only { +// [RLVa:KB] - Checked: 2013-02-12 (RLVa-1.4.8) +#if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG + // NOTE-RLVa: debug-only, can be removed down the line + if (rlv_handler_t::isEnabled()) + { + RLV_ASSERT(rlvPredCanRemoveItem(item)); + } +#endif // LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG +// [/RLVa:KB] + gInventory.purgeObject(item->getUUID()); } } @@ -3494,18 +3796,47 @@ void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove) { llwarns << "called with empty list, nothing to do" << llendl; } + +// [RLVa:KB] - Checked: 2013-02-12 (RLVa-1.4.8) + bool fUpdateAppearance = false; for (uuid_vec_t::const_iterator it = ids_to_remove.begin(); it != ids_to_remove.end(); ++it) { - const LLUUID& id_to_remove = *it; - const LLUUID& linked_item_id = gInventory.getLinkedItemID(id_to_remove); + const LLUUID& linked_item_id = gInventory.getLinkedItemID(*it); + + if ( (rlv_handler_t::isEnabled()) && (!rlvPredCanRemoveItem(gInventory.getItem(linked_item_id))) ) + { + continue; + } + + fUpdateAppearance = true; removeCOFItemLinks(linked_item_id); } - updateAppearanceFromCOF(); + + if (fUpdateAppearance) + { + updateAppearanceFromCOF(); } +// [/RLVa:KB] +// for (uuid_vec_t::const_iterator it = ids_to_remove.begin(); it != ids_to_remove.end(); ++it) +// { +// const LLUUID& id_to_remove = *it; +// const LLUUID& linked_item_id = gInventory.getLinkedItemID(id_to_remove); +// removeCOFItemLinks(linked_item_id); +// } +// updateAppearanceFromCOF(); +} void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove) { LLUUID linked_item_id = gInventory.getLinkedItemID(id_to_remove); + +// [RLVa:KB] - Checked: 2013-02-12 (RLVa-1.4.8) + if ( (rlv_handler_t::isEnabled()) && (!rlvPredCanRemoveItem(gInventory.getItem(linked_item_id))) ) + { + return; + } +// [/RLVA:KB] + removeCOFItemLinks(linked_item_id); updateAppearanceFromCOF(); } diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h old mode 100755 new mode 100644 index 0251153d9e44f701e33273b21188a29101d76de0..4ce657845e3fba88f097223034865c31f364aed8 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -52,6 +52,11 @@ class LLAppearanceMgr: public LLSingleton<LLAppearanceMgr> void updateAppearanceFromCOF(bool update_base_outfit_ordering = false); bool needToSaveCOF(); void updateCOF(const LLUUID& category, bool append = false); +// [RLVa:KB] - Checked: 2010-03-05 (RLVa-1.2.0a) | Added: RLVa-1.2.0a + void updateCOF(LLInventoryModel::item_array_t& body_items_new, LLInventoryModel::item_array_t& wear_items_new, + LLInventoryModel::item_array_t& obj_items_new, LLInventoryModel::item_array_t& gest_items_new, + bool append = false, const LLUUID& idOutfit = LLUUID::null); +// [/RLVa:KB] void wearInventoryCategory(LLInventoryCategory* category, bool copy, bool append); void wearInventoryCategoryOnAvatar(LLInventoryCategory* category, bool append); void wearCategoryFinal(LLUUID& cat_id, bool copy_items, bool append); @@ -227,6 +232,13 @@ class LLAppearanceMgr: public LLSingleton<LLAppearanceMgr> void setOutfitLocked(bool locked); +// [SL:KB] - Checked: 2010-04-24 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + void purgeItems(const LLInventoryModel::item_array_t& items); + void purgeItemsOfType(LLAssetType::EType asset_type); + void syncCOF(const LLInventoryModel::item_array_t& items, + LLInventoryModel::item_array_t& items_to_add, LLInventoryModel::item_array_t& items_to_remove); +// [/SL:KB] + bool mAttachmentInvLinkEnabled; bool mOutfitIsDirty; bool mIsInUpdateAppearanceFromCOF; // to detect recursive calls. diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 75e611fdef54e96de096c1edc8e2031e15fc168e..2b5785a2df58ab766e905354540dae9e605ab04d 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -91,6 +91,13 @@ #include "llprogressview.h" #include "llvocache.h" #include "llvopartgroup.h" +// [SL:KB] - Patch: Appearance-Misc | Checked: 2013-02-12 (Catznip-3.4) +#include "llappearancemgr.h" +// [/SL:KB] +// [RLVa:KB] - Checked: 2010-05-03 (RLVa-1.2.0g) +#include "rlvhandler.h" +// [/RLVa:KB] + #include "llweb.h" #include "llsecondlifeurls.h" #include "llupdaterservice.h" @@ -473,7 +480,15 @@ void idle_afk_check() { // check idle timers F32 current_idle = gAwayTriggerTimer.getElapsedTimeF32(); - F32 afk_timeout = gSavedSettings.getS32("AFKTimeout"); +// F32 afk_timeout = gSavedSettings.getS32("AFKTimeout"); +// [RLVa:KB] - Checked: 2010-05-03 (RLVa-1.2.0g) | Modified: RLVa-1.2.0g +#ifdef RLV_EXTENSION_CMD_ALLOWIDLE + // Enforce an idle time of 30 minutes if @allowidle=n restricted + F32 afk_timeout = (!gRlvHandler.hasBehaviour(RLV_BHVR_ALLOWIDLE)) ? gSavedSettings.getS32("AFKTimeout") : 60 * 30; +#else + F32 afk_timeout = gSavedSettings.getS32("AFKTimeout"); +#endif // RLV_EXTENSION_CMD_ALLOWIDLE +// [/RLVa:KB] if (afk_timeout && (current_idle > afk_timeout) && ! gAgent.getAFK()) { LL_INFOS("IdleAway") << "Idle more than " << afk_timeout << " seconds: automatically changing to Away status" << LL_ENDL; @@ -5232,6 +5247,11 @@ void LLAppViewer::disconnectViewer() // close inventory interface, close all windows LLFloaterInventory::cleanup(); +// [SL:KB] - Patch: Appearance-Misc | Checked: 2013-02-12 (Catznip-3.4) + // Destroying all objects below will trigger attachment detaching code and attempt to remove the COF links for them + LLAppearanceMgr::instance().setAttachmentInvLinkEnable(false); +// [/SL:KB] + gAgentWearables.cleanup(); gAgentCamera.cleanup(); // Also writes cached agent settings to gSavedSettings diff --git a/indra/newview/llattachmentsmgr.cpp b/indra/newview/llattachmentsmgr.cpp index ea0b8f00a4342f63e68b7f104e6beee32625e188..b5644fc7abe0482edd06f7b35d0ad881286d194b 100755 --- a/indra/newview/llattachmentsmgr.cpp +++ b/indra/newview/llattachmentsmgr.cpp @@ -33,7 +33,10 @@ #include "llviewerinventory.h" #include "llviewerregion.h" #include "message.h" - +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] LLAttachmentsMgr::LLAttachmentsMgr() { @@ -45,12 +48,35 @@ LLAttachmentsMgr::~LLAttachmentsMgr() void LLAttachmentsMgr::addAttachment(const LLUUID& item_id, const U8 attachment_pt, - const BOOL add) +// const BOOL add) +// [RLVa:KB] - Checked: 2010-09-13 (RLVa-1.2.1c) | Added: RLVa-1.2.1c + const BOOL add, const BOOL fRlvForce /*=FALSE*/) +// [/RLVa:KB] { AttachmentsInfo attachment; attachment.mItemID = item_id; attachment.mAttachmentPt = attachment_pt; attachment.mAdd = add; + +// [RLVa:KB] - Checked: 2010-09-23 (RLVa-1.2.1d) | Modified: RLVa-1.2.1d + if ( (rlv_handler_t::isEnabled()) && (!fRlvForce) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY)) ) + { + const LLInventoryItem* pItem = gInventory.getItem(item_id); + if (!pItem) + return; + + LLViewerJointAttachment* pAttachPt = NULL; + ERlvWearMask eWearMask = gRlvAttachmentLocks.canAttach(pItem, &pAttachPt); + if ( ((add) && ((RLV_WEAR_ADD & eWearMask) == 0)) || ((!add) && ((RLV_WEAR_REPLACE & eWearMask) == 0)) ) + return; + + if ( (0 == attachment_pt) && (NULL != pAttachPt) ) + attachment.mAttachmentPt = RlvAttachPtLookup::getAttachPointIndex(pAttachPt); + RlvAttachmentLockWatchdog::instance().onWearAttachment(pItem, (add) ? RLV_WEAR_ADD : RLV_WEAR_REPLACE); + attachment.mAdd = true; + } +// [/RLVa:KB] + mPendingAttachments.push_back(attachment); } diff --git a/indra/newview/llattachmentsmgr.h b/indra/newview/llattachmentsmgr.h index 1d8ab74dfd9b6caa739f60b9bcb7d2ece67947d8..997db59d229ce8c4ff75465e959b1ea9683672e7 100755 --- a/indra/newview/llattachmentsmgr.h +++ b/indra/newview/llattachmentsmgr.h @@ -54,7 +54,10 @@ class LLAttachmentsMgr: public LLSingleton<LLAttachmentsMgr> void addAttachment(const LLUUID& item_id, const U8 attachment_pt, - const BOOL add); +// const BOOL add); +// [RLVa:KB] - Checked: 2010-09-13 (RLVa-1.2.1c) | Added: RLVa-1.2.1c + const BOOL add, const BOOL fRlvForce = FALSE); +// [/RLVa:KB] static void onIdle(void *); protected: void onIdle(); diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 70cc48f12b8fddef99008917a2e341295eee5e3f..affcd71be5e5b0b16c7e79855c6cbc4f66705717 100755 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -75,6 +75,10 @@ #include "llsidepanelinventory.h" #include "llavatarname.h" #include "llagentui.h" +// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0) +#include "rlvactions.h" +#include "rlvcommon.h" +// [/RLVa:KB] // static void LLAvatarActions::requestFriendshipDialog(const LLUUID& id, const std::string& name) @@ -198,6 +202,15 @@ void LLAvatarActions::startIM(const LLUUID& id) if (id.isNull() || gAgent.getID() == id) return; +// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) + if ( (!RlvActions::canStartIM(id)) && (!RlvActions::hasOpenP2PSession(id)) ) + { + make_ui_sound("UISndInvalidOp"); + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("agent", id, "completename").getSLURLString())); + return; + } +// [/RLVa:KB] + LLAvatarNameCache::get(id, boost::bind(&on_avatar_name_cache_start_im, _1, _2)); } @@ -233,6 +246,16 @@ void LLAvatarActions::startCall(const LLUUID& id) { return; } + +// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) + if ( (!RlvActions::canStartIM(id)) && (!RlvActions::hasOpenP2PSession(id)) ) + { + make_ui_sound("UISndInvalidOp"); + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("agent", id, "completename").getSLURLString())); + return; + } +// [/RLVa:KB] + LLAvatarNameCache::get(id, boost::bind(&on_avatar_name_cache_start_call, _1, _2)); } @@ -248,7 +271,17 @@ void LLAvatarActions::startAdhocCall(const uuid_vec_t& ids, const LLUUID& floate LLDynamicArray<LLUUID> id_array; for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it) { - id_array.push_back(*it); +// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0) + const LLUUID& idAgent = *it; + if (!RlvActions::canStartIM(idAgent)) + { + make_ui_sound("UISndInvalidOp"); + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTCONF); + return; + } + id_array.push_back(idAgent); +// [/RLVa:KB] +// id_array.push_back(*it); } // create the new ad hoc voice session @@ -293,7 +326,17 @@ void LLAvatarActions::startConference(const uuid_vec_t& ids, const LLUUID& float LLDynamicArray<LLUUID> id_array; for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it) { - id_array.push_back(*it); +// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0) + const LLUUID& idAgent = *it; + if (!RlvActions::canStartIM(idAgent)) + { + make_ui_sound("UISndInvalidOp"); + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTCONF); + return; + } + id_array.push_back(idAgent); +// [/RLVa:KB] +// id_array.push_back(*it); } const std::string title = LLTrans::getString("conference-title"); LLUUID session_id = gIMMgr->addSession(title, IM_SESSION_CONFERENCE_START, ids[0], id_array, false, floater_id); diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp old mode 100755 new mode 100644 index f34ad2376994316c71cc874fd33af9e695a542a8..eaf738481c4163511b53960095b16b7370590025 --- a/indra/newview/llavatariconctrl.cpp +++ b/indra/newview/llavatariconctrl.cpp @@ -333,3 +333,13 @@ void LLAvatarIconCtrl::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarN } } } + +// [SL:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Added: RLVa-1.2.2a +BOOL LLAvatarIconCtrl::handleToolTip(S32 x, S32 y, MASK mask) +{ + // Don't show our tooltip if we were asked not to + if (!mDrawTooltip) + return FALSE; + return LLIconCtrl::handleToolTip(x, y, mask); +} +// [/SL:KB] diff --git a/indra/newview/llavatariconctrl.h b/indra/newview/llavatariconctrl.h index 4929efb7d0300de292415b692026a8fa360e9056..aca925dd107d4d90a0d242d08b407a4e5df3e634 100755 --- a/indra/newview/llavatariconctrl.h +++ b/indra/newview/llavatariconctrl.h @@ -83,6 +83,10 @@ class LLAvatarIconCtrl public: virtual ~LLAvatarIconCtrl(); +// [SL:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + /*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask); +// [/SL:KB] + virtual void setValue(const LLSD& value); // LLAvatarPropertiesProcessor observer trigger diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp index 9f02f301a187390dad5879bda3fe83e64e750fca..b14a7ff24e19955cc7df6198408bff1293a2931d 100755 --- a/indra/newview/llavatarlist.cpp +++ b/indra/newview/llavatarlist.cpp @@ -47,6 +47,9 @@ #include "llvoiceclient.h" #include "llviewercontrol.h" // for gSavedSettings #include "lltooldraganddrop.h" +// [RLVa:KB] - Checked: 2010-06-04 (RLVa-1.2.2a) +#include "rlvhandler.h" +// [/RLVa:KB] static LLDefaultChildRegistry::Register<LLAvatarList> r("avatar_list"); @@ -140,6 +143,9 @@ LLAvatarList::LLAvatarList(const Params& p) , mShowProfileBtn(p.show_profile_btn) , mShowSpeakingIndicator(p.show_speaking_indicator) , mShowPermissions(p.show_permissions_granted) +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d +, mRlvCheckShowNames(false) +// [/RLVa:KB] { setCommitOnSelectionChange(true); @@ -434,6 +440,9 @@ S32 LLAvatarList::notifyParent(const LLSD& info) void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos) { LLAvatarListItem* item = new LLAvatarListItem(); +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d + item->setRlvCheckShowNames(mRlvCheckShowNames); +// [/RLVa:KB] // This sets the name as a side effect item->setAvatarId(id, mSessionID, mIgnoreOnlineStatus); item->setOnline(mIgnoreOnlineStatus ? true : is_online); @@ -454,7 +463,10 @@ void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is BOOL LLAvatarList::handleRightMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = LLUICtrl::handleRightMouseDown(x, y, mask); - if ( mContextMenu && !isAvalineItemSelected()) +// if ( mContextMenu && !isAvalineItemSelected()) +// [RLVa:KB] - Checked: 2010-06-04 (RLVa-1.2.2a) | Modified: RLVa-1.2.0d + if ( (mContextMenu && !isAvalineItemSelected()) && ((!mRlvCheckShowNames) || (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))) ) +// [/RLVa:KB] { uuid_vec_t selected_uuids; getSelectedUUIDs(selected_uuids); @@ -576,7 +588,11 @@ void LLAvatarList::updateLastInteractionTimes() void LLAvatarList::onItemDoubleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask) { - mItemDoubleClickSignal(ctrl, x, y, mask); +// mItemDoubleClickSignal(ctrl, x, y, mask); +// [RLVa:KB] - Checked: 2010-06-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d + if ( (!mRlvCheckShowNames) || (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ) + mItemDoubleClickSignal(ctrl, x, y, mask); +// [/RLVa:KB] } bool LLAvatarItemComparator::compare(const LLPanel* item1, const LLPanel* item2) const diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h index 3542577ae3c3f7cfb89272fdf1968624c0bd576f..a1479895a35d339c1b51f9a233df0f7b1562e3b3 100755 --- a/indra/newview/llavatarlist.h +++ b/indra/newview/llavatarlist.h @@ -91,6 +91,12 @@ class LLAvatarList : public LLFlatListViewEx // Return true if filter has at least one match. bool filterHasMatches(); +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d + void setRlvCheckShowNames(bool fRlvCheckShowNames) { mRlvCheckShowNames = fRlvCheckShowNames; } + // We need this to be public since we call it from RlvUIEnabler::onToggleShowNames() + void updateAvatarNames(); +// [/RLVa:KB] + boost::signals2::connection setRefreshCompleteCallback(const commit_signal_t::slot_type& cb); boost::signals2::connection setItemDoubleClickCallback(const mouse_signal_t::slot_type& cb); @@ -111,7 +117,7 @@ class LLAvatarList : public LLFlatListViewEx void updateLastInteractionTimes(); void rebuildNames(); void onItemDoubleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask); - void updateAvatarNames(); +// void updateAvatarNames(); private: @@ -126,6 +132,9 @@ class LLAvatarList : public LLFlatListViewEx bool mShowProfileBtn; bool mShowSpeakingIndicator; bool mShowPermissions; +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d + bool mRlvCheckShowNames; +// [/RLVa:KB] LLTimer* mLITUpdateTimer; // last interaction time update timer std::string mIconParamName; diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp index 3e6c817dd6229f718c05af53b689c9d8e045fc36..5c0700fccdddd5fe8fab1d72766d7cce1ad229d9 100755 --- a/indra/newview/llavatarlistitem.cpp +++ b/indra/newview/llavatarlistitem.cpp @@ -41,6 +41,9 @@ #include "llavatariconctrl.h" #include "lloutputmonitorctrl.h" #include "lltooldraganddrop.h" +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) +#include "rlvhandler.h" +// [/RLVa:KB] bool LLAvatarListItem::sStaticInitialized = false; S32 LLAvatarListItem::sLeftPadding = 0; @@ -76,6 +79,9 @@ LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/) mOnlineStatus(E_UNKNOWN), mShowInfoBtn(true), mShowProfileBtn(true), +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d + mRlvCheckShowNames(false), +// [/RLVa:KB] mShowPermissions(false), mHovered(false), mAvatarNameCacheConnection() @@ -177,8 +183,12 @@ S32 LLAvatarListItem::notifyParent(const LLSD& info) void LLAvatarListItem::onMouseEnter(S32 x, S32 y, MASK mask) { getChildView("hovered_icon")->setVisible( true); - mInfoBtn->setVisible(mShowInfoBtn); - mProfileBtn->setVisible(mShowProfileBtn); +// mInfoBtn->setVisible(mShowInfoBtn); +// mProfileBtn->setVisible(mShowProfileBtn); +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d + mInfoBtn->setVisible( (mShowInfoBtn) && ((!mRlvCheckShowNames) || (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))) ); + mProfileBtn->setVisible( (mShowProfileBtn) && ((!mRlvCheckShowNames) || (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))) ); +// [/RLVa:KB] mHovered = true; LLPanel::onMouseEnter(x, y, mask); @@ -355,12 +365,18 @@ void LLAvatarListItem::onProfileBtnClick() BOOL LLAvatarListItem::handleDoubleClick(S32 x, S32 y, MASK mask) { - if(mInfoBtn->getRect().pointInRect(x, y)) +// if(mInfoBtn->getRect().pointInRect(x, y)) +// [SL:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + if ( (mInfoBtn->getVisible()) && (mInfoBtn->getEnabled()) && (mInfoBtn->getRect().pointInRect(x, y)) ) +// [/SL:KB] { onInfoBtnClick(); return TRUE; } - if(mProfileBtn->getRect().pointInRect(x, y)) +// if(mProfileBtn->getRect().pointInRect(x, y)) +// [SL:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + if ( (mProfileBtn->getVisible()) && (mProfileBtn->getEnabled()) && (mProfileBtn->getRect().pointInRect(x, y)) ) +// [/SL:KB] { onProfileBtnClick(); return TRUE; @@ -406,8 +422,15 @@ void LLAvatarListItem::onAvatarNameCache(const LLAvatarName& av_name) { mAvatarNameCacheConnection.disconnect(); - setAvatarName(av_name.getDisplayName()); - setAvatarToolTip(av_name.getUserName()); +// setAvatarName(av_name.getDisplayName()); +// setAvatarToolTip(av_name.getUserName()); +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + bool fRlvFilter = (mRlvCheckShowNames) && (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)); + setAvatarName( (!fRlvFilter) ? av_name.getDisplayName() : RlvStrings::getAnonym(av_name) ); + setAvatarToolTip( (!fRlvFilter) ? av_name.getUserName() : RlvStrings::getAnonym(av_name) ); + // TODO-RLVa: bit of a hack putting this here. Maybe find a better way? + mAvatarIcon->setDrawTooltip(!fRlvFilter); +// [/RLVa:KB] //requesting the list to resort notifyParent(LLSD().with("sort", LLSD())); diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h index 7ef35a746ec9719018680cd8485663d0cd980b42..e1533d38d07e07b7255be44496fa412c53089c16 100755 --- a/indra/newview/llavatarlistitem.h +++ b/indra/newview/llavatarlistitem.h @@ -106,6 +106,9 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver void setShowPermissions(bool show) { mShowPermissions = show; }; void showLastInteractionTime(bool show); void setAvatarIconVisible(bool visible); +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d + void setRlvCheckShowNames(bool fRlvCheckShowNames) { mRlvCheckShowNames = fRlvCheckShowNames; } +// [/RLVa:KB] const LLUUID& getAvatarId() const; std::string getAvatarName() const; @@ -211,6 +214,9 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver //Speaker indicator and avatar name coords are translated accordingly bool mShowInfoBtn; bool mShowProfileBtn; +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d + bool mRlvCheckShowNames; +// [/RLVa:KB] /// indicates whether to show icons representing permissions granted bool mShowPermissions; diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp index b3bc0ba966dca4760715f539dd433572a80afafd..fd360e6931b8cd850042f3bff91707100bde7527 100755 --- a/indra/newview/llchatbar.cpp +++ b/indra/newview/llchatbar.cpp @@ -60,6 +60,9 @@ #include "llui.h" #include "llviewermenu.h" #include "lluictrlfactory.h" +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) +#include "rlvhandler.h" +// [/RLVa:KB] // // Globals @@ -79,7 +82,10 @@ class LLChatBarGestureObserver : public LLGestureManagerObserver }; -extern void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); +//extern void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-0.2.2) +extern void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel); +// [/RLVa:KB] // // Functions @@ -472,7 +478,11 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) S32 length = raw_text.length(); - if( (length > 0) && (raw_text[0] != '/') ) // forward slash is used for escape (eg. emote) sequences +// if( (length > 0) && (raw_text[0] != '/') ) // forward slash is used for escape (eg. emote) sequences +// [RLVa:KB] - Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.0.0d + // RELEASE-RLVa: [SL-2.0.0] This entire class appears to be dead/non-functional? + if ( (length > 0) && (raw_text[0] != '/') && (!gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT)) ) +// [/RLVa:KB] { gAgent.startTyping(); } @@ -584,6 +594,22 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL utf8_text = utf8str_truncate(utf8_text, MAX_STRING - 1); } +// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0b + // RELEASE-RLVa: [SL-2.0.0] This entire class appears to be dead/non-functional? + if ( (0 == channel) && (rlv_handler_t::isEnabled()) ) + { + // Adjust the (public) chat "volume" on chat and gestures (also takes care of playing the proper animation) + if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATNORMAL)) ) + type = CHAT_TYPE_WHISPER; + else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATSHOUT)) ) + type = CHAT_TYPE_NORMAL; + else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) ) + type = CHAT_TYPE_NORMAL; + + animate &= !gRlvHandler.hasBehaviour( (!RlvUtil::isEmote(utf8_text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE ); + } +// [/RLVa:KB] + // Don't animate for chats people can't hear (chat to scripts) if (animate && (channel == 0)) { diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 43a733f918725afe2d2f9634f43d517adbc40ed3..d14a443fd944c5f40544868587547222e61bf23f 100755 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -60,6 +60,9 @@ #include "llstring.h" #include "llurlaction.h" #include "llviewercontrol.h" +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) +#include "rlvcommon.h" +// [/RLVa:KB] static LLDefaultChildRegistry::Register<LLChatHistory> r("chat_history"); @@ -91,6 +94,10 @@ class LLObjectIMHandler : public LLCommandHandler LLSD payload; payload["object_id"] = object_id; payload["owner_id"] = query_map["owner"]; +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + if (query_map.has("rlv_shownames")) + payload["rlv_shownames"] = query_map["rlv_shownames"]; +// [/RLVa:KB] payload["name"] = query_map["name"]; payload["slurl"] = LLWeb::escapeURL(query_map["slurl"]); payload["group_owned"] = query_map["groupowned"]; @@ -105,6 +112,10 @@ class LLChatHistoryHeader: public LLPanel public: LLChatHistoryHeader() : LLPanel(), +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.2a) | Added: RLVa-1.2.0f + mShowContextMenu(true), + mShowInfoCtrl(true), +// [/RLVa:KB] mPopupMenuHandleAvatar(), mPopupMenuHandleObject(), mAvatarID(), @@ -246,7 +257,11 @@ class LLChatHistoryHeader: public LLPanel void showInspector() { - if (mAvatarID.isNull() && CHAT_SOURCE_SYSTEM != mSourceType) return; +// if (mAvatarID.isNull() && CHAT_SOURCE_SYSTEM != mSourceType) return; +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.2a) | Added: RLVa-1.2.0f + // Don't double-click show the inspector if we're not showing the info control + if ( (!mShowInfoCtrl) || (mAvatarID.isNull() && CHAT_SOURCE_SYSTEM != mSourceType) ) return; +// [/RLVa:KB] if (mSourceType == CHAT_SOURCE_OBJECT) { @@ -306,8 +321,24 @@ class LLChatHistoryHeader: public LLPanel // Start with blank so sample data from XUI XML doesn't // flash on the screen - user_name->setValue( LLSD() ); - fetchAvatarName(); +// user_name->setValue( LLSD() ); +// fetchAvatarName(); +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + if (!chat.mRlvNamesFiltered) + { + user_name->setValue( LLSD() ); + fetchAvatarName(); + } + else + { + // If the agent's chat was subject to @shownames=n we should display their anonimized name + mFrom = chat.mFromName; + user_name->setValue(mFrom); + user_name->setToolTip(mFrom); + setToolTip(mFrom); + updateMinUserNameWidth(); + } +// [/RLVa:KB] } else if (chat.mChatStyle == CHAT_STYLE_HISTORY || mSourceType == CHAT_SOURCE_AGENT) @@ -359,6 +390,15 @@ class LLChatHistoryHeader: public LLPanel if(mSourceType != CHAT_SOURCE_AGENT || mAvatarID.isNull()) icon->setDrawTooltip(false); +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.2a) | Added: RLVa-1.2.0f + // Don't show the context menu, info control or avatar icon tooltip if this chat was subject to @shownames=n + if ( (chat.mRlvNamesFiltered) && ((CHAT_SOURCE_AGENT == mSourceType) || (CHAT_SOURCE_OBJECT == mSourceType)) ) + { + mShowInfoCtrl = mShowContextMenu = false; + icon->setDrawTooltip(false); + } +// [/RLVa:KB] + switch (mSourceType) { case CHAT_SOURCE_AGENT: @@ -435,6 +475,10 @@ class LLChatHistoryHeader: public LLPanel void showContextMenu(S32 x,S32 y) { +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.2a) | Added: RLVa-1.2.0f + if (!mShowContextMenu) + return; +// [/RLVa:KB] if(mSourceType == CHAT_SOURCE_SYSTEM) showSystemContextMenu(x,y); if(mAvatarID.notNull() && mSourceType == CHAT_SOURCE_AGENT) @@ -486,6 +530,9 @@ class LLChatHistoryHeader: public LLPanel void showInfoCtrl() { if (mAvatarID.isNull() || mFrom.empty() || CHAT_SOURCE_SYSTEM == mSourceType) return; +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.2a) | Added: RLVa-1.2.0f + if ( (!mShowInfoCtrl) || (mAvatarID.isNull() || mFrom.empty() || CHAT_SOURCE_SYSTEM == mSourceType) ) return; +// [/RLVa:KB] if (!sInfoCtrl) { @@ -595,6 +642,10 @@ class LLChatHistoryHeader: public LLPanel EChatSourceType mSourceType; std::string mFrom; LLUUID mSessionID; +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.2a) | Added: RLVa-1.2.0f + bool mShowContextMenu; + bool mShowInfoCtrl; +// [/RLVa:KB] S32 mMinUserNameWidth; const LLFontGL* mUserNameFont; @@ -878,8 +929,18 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL // Don't hotlink any messages from the system (e.g. "Second Life:"), so just add those in plain text. if ( chat.mSourceType == CHAT_SOURCE_OBJECT && chat.mFromID.notNull()) { - // for object IMs, create a secondlife:///app/objectim SLapp - std::string url = LLViewerChat::getSenderSLURL(chat, args); +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + // NOTE-RLVa: we don't need to do any @shownames or @showloc filtering here because we'll already have an existing URL + std::string url = chat.mURL; + RLV_ASSERT( (url.empty()) || (std::string::npos != url.find("objectim")) ); + if ( (url.empty()) || (std::string::npos == url.find("objectim")) ) + { +// [/RLVa:KB] + // for object IMs, create a secondlife:///app/objectim SLapp + /*std::string*/ url = LLViewerChat::getSenderSLURL(chat, args); +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + } +// [/RLVa:KB] // set the link for the object name to be the objectim SLapp // (don't let object names with hyperlinks override our objectim Url) @@ -893,7 +954,10 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL mEditor->appendText(chat.mFromName + delimiter, prependNewLineState, link_params); prependNewLineState = false; } - else if ( chat.mFromName != SYSTEM_FROM && chat.mFromID.notNull() && !message_from_log) +// else if (chat.mFromName != SYSTEM_FROM && chat.mFromID.notNull() && !message_from_log) +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + else if (chat.mFromName != SYSTEM_FROM && chat.mFromID.notNull() && !message_from_log && !chat.mRlvNamesFiltered) +// [/RLVa:KB] { LLStyle::Params link_params(body_message_params); link_params.overwriteFrom(LLStyleMap::instance().lookupAgent(chat.mFromID)); diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index fd4f17b69439ab3321af1c0626c7e5d60d570340..a0a59cefbf8d9dc20c1f0d68ddc5f61dacf2e07b 100755 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -42,6 +42,10 @@ #include "llslurl.h" +// [RLVa:KB] - Checked: 2010-04-21 (RLVa-1.2.0f) +#include "rlvhandler.h" +// [/RLVa:KB] + static const S32 msg_left_offset = 10; static const S32 msg_right_offset = 10; static const S32 msg_height_pad = 5; @@ -184,7 +188,11 @@ void LLFloaterIMNearbyChatToastPanel::init(LLSD& notification) std::string fromName = notification["from"].asString(); // agent or object name mFromID = notification["from_id"].asUUID(); // agent id or object id mFromName = fromName; - + +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + mShowIconTooltip = notification.has("show_icon_tooltip") ? notification["show_icon_tooltip"].asBoolean() : true; +// [/RLVa:KB] + int sType = notification["source"].asInteger(); mSourceType = (EChatSourceType)sType; @@ -229,8 +237,15 @@ void LLFloaterIMNearbyChatToastPanel::init(LLSD& notification) style_params_name.font.name(font_name); style_params_name.font.size(font_style_size); - style_params_name.link_href = notification["sender_slurl"].asString(); - style_params_name.is_link = true; +// style_params_name.link_href = notification["sender_slurl"].asString(); +// style_params_name.is_link = true; +// [RLVa:KB] - Checked: 2011-12-13 (RLVa-1.4.6) | Added: RLVa-1.4.6 + if (notification.has("sender_slurl")) + { + style_params_name.link_href = notification["sender_slurl"].asString(); + style_params_name.is_link = true; + } +// [/RLVa:KB] msg_text->appendText(str_sender, FALSE, style_params_name); @@ -368,7 +383,10 @@ void LLFloaterIMNearbyChatToastPanel::draw() LLAvatarIconCtrl* icon = getChild<LLAvatarIconCtrl>("avatar_icon", false); if(icon) { - icon->setDrawTooltip(mSourceType == CHAT_SOURCE_AGENT); +// icon->setDrawTooltip(mSourceType == CHAT_SOURCE_AGENT); +// [RLVa:KB] - Checked: 2010-04-200 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + icon->setDrawTooltip( (mShowIconTooltip) && (mSourceType == CHAT_SOURCE_AGENT) ); +// [/RLVa:KB] if(mSourceType == CHAT_SOURCE_OBJECT) icon->setValue(LLSD("OBJECT_Icon")); else if(mSourceType == CHAT_SOURCE_SYSTEM) diff --git a/indra/newview/llchatitemscontainerctrl.h b/indra/newview/llchatitemscontainerctrl.h index 54b6499d52ff721768d9769625608094c1157b7e..f2390980248637dfc2d37bd65645bff65f0e8a89 100755 --- a/indra/newview/llchatitemscontainerctrl.h +++ b/indra/newview/llchatitemscontainerctrl.h @@ -46,6 +46,9 @@ class LLFloaterIMNearbyChatToastPanel : public LLPanel LLFloaterIMNearbyChatToastPanel() : mIsDirty(false), +// [RLVa:KB] - Checked: 2010-04-200 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + mShowIconTooltip(true), +// [/RLVa:KB] mSourceType(CHAT_SOURCE_OBJECT) {}; public: @@ -89,6 +92,9 @@ class LLFloaterIMNearbyChatToastPanel : public LLPanel bool mIsDirty; +// [RLVa:KB] - Checked: 2010-04-200 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + bool mShowIconTooltip; +// [/RLVa:KB] }; diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index 131aea9da3890ce3ce24df217ab59b9dd5135dcd..0ac5695a7fa4ee4e66d6709963d339b573ba6b54 100755 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -35,6 +35,9 @@ #include "llscriptfloater.h" #include "llsingleton.h" #include "llsyswellwindow.h" +// [SL:KB] - Patch: UI-Notifications | Checked: 2013-05-09 (Catznip-3.5) +#include "llchannelmanager.h" +// [/SL:KB] static LLDefaultChildRegistry::Register<LLChicletPanel> t1("chiclet_panel"); static LLDefaultChildRegistry::Register<LLNotificationChiclet> t2("chiclet_notification"); @@ -234,6 +237,15 @@ bool LLNotificationChiclet::ChicletNotificationChannel::filterNotification( LLNo { displayNotification = true; } +// [SL:KB] - Patch: UI-Notifications | Checked: 2013-05-09 (Catznip-3.5) + else if ("offer" == notification->getType()) + { + // Assume that any offer notification with "getCanBeStored() == true" is the result of RLVa routing it to the notifcation syswell + /*const*/ LLNotificationsUI::LLScreenChannel* pChannel = LLNotificationsUI::LLChannelManager::instance().getNotificationScreenChannel(); + /*const*/ LLNotificationsUI::LLToast* pToast = (pChannel) ? pChannel->getToastByNotificationID(notification->getID()) : NULL; + displayNotification = (pToast) && (pToast->getCanBeStored()); + } +// [/SL:KB] else { displayNotification = false; diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp index 8af2f4ea3366818c9cbcada2a4cdcb7236a1f209..b8b4f9b09d4a26fd79f49fdf1a4fa20c4436b3f2 100755 --- a/indra/newview/lldaycyclemanager.cpp +++ b/indra/newview/lldaycyclemanager.cpp @@ -30,6 +30,10 @@ #include "lldiriterator.h" +// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +#include <boost/algorithm/string.hpp> +// [/RLVa:KB] + void LLDayCycleManager::getPresetNames(preset_name_list_t& names) const { names.clear(); @@ -60,6 +64,18 @@ void LLDayCycleManager::getPresetNames(preset_name_list_t& user, preset_name_lis } } +// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +const std::string& LLDayCycleManager::findPreset(const std::string& strPresetName) +{ + for (dc_map_t::const_iterator itCycle = mDayCycleMap.begin(); itCycle != mDayCycleMap.end(); ++itCycle) + { + if (boost::iequals(itCycle->first, strPresetName)) + return itCycle->first; + } + return LLStringUtil::null; +} +// [/RLVa:KB] + void LLDayCycleManager::getUserPresetNames(preset_name_list_t& user) const { preset_name_list_t sys; // unused diff --git a/indra/newview/lldaycyclemanager.h b/indra/newview/lldaycyclemanager.h index 3d2144960da160d3429ec6b039f7db70f554911a..81b31dc71c536c2644752286e8b5ff16bf816f08 100755 --- a/indra/newview/lldaycyclemanager.h +++ b/indra/newview/lldaycyclemanager.h @@ -51,6 +51,9 @@ class LLDayCycleManager : public LLSingleton<LLDayCycleManager> void getPresetNames(preset_name_list_t& names) const; void getPresetNames(preset_name_list_t& user, preset_name_list_t& sys) const; void getUserPresetNames(preset_name_list_t& user) const; +// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a + const std::string& findPreset(const std::string& strPresetName); +// [/RLVa:KB] bool getPreset(const std::string name, LLWLDayCycle& day_cycle) const; bool getPreset(const std::string name, LLSD& day_cycle) const; diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index 86fe6754dc8d652217d50bc6226552d440d06d22..5df9ac428b8241d1b8bc23e89a564fbc275e418f 100755 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -35,6 +35,10 @@ #include "llwaterparammanager.h" #include "llwlhandlers.h" #include "llwlparammanager.h" +// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +#include <boost/algorithm/string.hpp> +#include "rlvhandler.h" +// [/RLVa:KB] std::string LLEnvPrefs::getWaterPresetName() const { @@ -484,7 +488,10 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) LLWLParamManager::instance().refreshRegionPresets(); // If using server settings, update managers. - if (getUseRegionSettings()) +// if (getUseRegionSettings()) +// [RLVa:KB] - Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a + if ( (getUseRegionSettings()) && (LLWLParamManager::getInstance()->mAnimator.getIsRunning()) ) +// [/RLVa:KB] { updateManagersFromPrefs(mInterpNextChangeMessage); } @@ -594,6 +601,13 @@ void LLEnvManagerNew::updateWaterFromPrefs(bool interpolate) void LLEnvManagerNew::updateManagersFromPrefs(bool interpolate) { +// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a + if (gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)) + { + return; + } +// [/RLVa:KB] + // Apply water settings. updateWaterFromPrefs(interpolate); diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp index fea8e34729e131acea20aa70213df227e135592a..f95cfa7acbf03658093d31dd92ef17c5440af224 100755 --- a/indra/newview/llfloaterabout.cpp +++ b/indra/newview/llfloaterabout.cpp @@ -45,6 +45,9 @@ #include "llviewerregion.h" #include "llversioninfo.h" #include "llweb.h" +// [RLVa:KB] - Checked: 2010-04-18 (RLVa-1.4.0a) +#include "rlvhandler.h" +// [/RLVa:KB] // Linden library includes #include "llaudioengine.h" @@ -280,6 +283,9 @@ LLSD LLFloaterAbout::getInfo() } #endif +// [RLVa:KB] - Checked: 2010-04-18 (RLVa-1.4.0a) | Added: RLVa-1.2.0e + info["RLV_VERSION"] = (rlv_handler_t::isEnabled()) ? RlvStrings::getVersionAbout() : "(disabled)"; +// [/RLVa:KB] info["OPENGL_VERSION"] = (const char*)(glGetString(GL_VERSION)); info["LIBCURL_VERSION"] = LLCurl::getVersionString(); info["J2C_VERSION"] = LLImageJ2C::getEngineInfo(); diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index c0afb72cffb05ed6702c0c70ba374a445088be56..0fd02538f2da380ee52e2d14732b4a00f34b026b 100755 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -37,6 +37,10 @@ #include "llviewercontrol.h" #include "llviewerregion.h" // getCapability() #include "llworld.h" +// [RLVa:KB] - Checked: 2010-06-04 (RLVa-1.2.2a) +#include "rlvactions.h" +#include "rlvhandler.h" +// [/RLVa:KB] // Linden libraries #include "llavatarnamecache.h" // IDEVO @@ -279,6 +283,22 @@ void LLFloaterAvatarPicker::onRangeAdjust() void LLFloaterAvatarPicker::onList() { getChildView("ok_btn")->setEnabled(isSelectBtnEnabled()); + +// [RLVa:KB] - Checked: 2010-06-05 (RLVa-1.2.2a) | Modified: RLVa-1.2.0d + if (rlv_handler_t::isEnabled()) + { + LLTabContainer* pTabs = getChild<LLTabContainer>("ResidentChooserTabs"); + LLPanel* pNearMePanel = getChild<LLPanel>("NearMePanel"); + RLV_ASSERT( (pTabs) && (pNearMePanel) ); + if ( (pTabs) && (pNearMePanel) ) + { + bool fRlvEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES); + pTabs->enableTabButton(pTabs->getIndexForPanel(pNearMePanel), fRlvEnable); + if ( (!fRlvEnable) && (pTabs->getCurrentPanel() == pNearMePanel) ) + pTabs->selectTabByName("SearchPanel"); + } + } +// [/RLVa:KB] } void LLFloaterAvatarPicker::populateNearMe() @@ -592,7 +612,10 @@ BOOL LLFloaterAvatarPicker::handleDragAndDrop(S32 x, S32 y, MASK mask, std::string avatar_name = selection->getColumn(0)->getValue().asString(); if (dest_agent_id.notNull() && dest_agent_id != gAgentID) { - if (drop) +// if (drop) +// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0) + if ( (drop) && (RlvActions::canStartIM(dest_agent_id)) ) +// [/RLVa:KB] { // Start up IM before give the item session_id = gIMMgr->addSession(avatar_name, IM_NOTHING_SPECIAL, dest_agent_id); diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp index 3d77ea4f0bb3ab7fc1861214f39b125173e0ae68..c707ebdc071ae6a91b27219ed7bdb80a47349789 100755 --- a/indra/newview/llfloaterimnearbychat.cpp +++ b/indra/newview/llfloaterimnearbychat.cpp @@ -67,6 +67,9 @@ #include "llviewerchat.h" #include "lltranslate.h" #include "llautoreplace.h" +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) +#include "rlvhandler.h" +// [/RLVa:KB] S32 LLFloaterIMNearbyChat::sLastSpecialChatChannel = 0; @@ -75,7 +78,10 @@ const S32 COLLAPSED_HEIGHT = 60; const S32 EXPANDED_MIN_HEIGHT = 150; // legacy callback glue -void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); +//void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-0.2.2) +void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel); +// [/RLVa:KB] struct LLChatTypeTrigger { std::string name; @@ -835,8 +841,57 @@ LLWString LLFloaterIMNearbyChat::stripChannelNumber(const LLWString &mesg, S32* } } -void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) +//void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-0.2.2a +void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel) +// [/RLVa:KB] { +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0a + // Only process chat messages (ie not CHAT_TYPE_START, CHAT_TYPE_STOP, etc) + if ( (rlv_handler_t::isEnabled()) && ( (CHAT_TYPE_WHISPER == type) || (CHAT_TYPE_NORMAL == type) || (CHAT_TYPE_SHOUT == type) ) ) + { + if (0 == channel) + { + // (We already did this before, but LLChatHandler::handle() calls this directly) + if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATNORMAL)) ) + type = CHAT_TYPE_WHISPER; + else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATSHOUT)) ) + type = CHAT_TYPE_NORMAL; + else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) ) + type = CHAT_TYPE_NORMAL; + + // Redirect chat if needed + if ( ( (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT) || (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE)) ) && + (gRlvHandler.redirectChatOrEmote(utf8_out_text)) ) ) + { + return; + } + + // Filter public chat if sendchat restricted + if (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) + gRlvHandler.filterChat(utf8_out_text, true); + } + else + { + // Don't allow chat on a non-public channel if sendchannel restricted (unless the channel is an exception) + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHANNEL)) && (!gRlvHandler.isException(RLV_BHVR_SENDCHANNEL, channel)) ) + return; + + // Don't allow chat on debug channel if @sendchat, @redirchat or @rediremote restricted (shows as public chat on viewers) + if (CHAT_CHANNEL_DEBUG == channel) + { + bool fIsEmote = RlvUtil::isEmote(utf8_out_text); + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) || + ((!fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT))) || + ((fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE))) ) + { + return; + } + } + } + } +// [/RLVa:KB] + LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ChatFromViewer); msg->nextBlockFast(_PREHASH_AgentData); diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp index a8f815c389343de80ebd1aa120c4efb1c10e0de7..f3cd89ae706f53a456b99149f274ac0cb97cce8f 100755 --- a/indra/newview/llfloaterimnearbychathandler.cpp +++ b/indra/newview/llfloaterimnearbychathandler.cpp @@ -45,7 +45,12 @@ #include "llrootview.h" #include "lllayoutstack.h" +// [RLVa:KB] - Checked: 2010-04-21 (RLVa-1.2.0f) +#include "rlvhandler.h" +// [/RLVa:KB] + //add LLFloaterIMNearbyChatHandler to LLNotificationsUI namespace + using namespace LLNotificationsUI; static LLFloaterIMNearbyChatToastPanel* createToastPanel() @@ -485,6 +490,24 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg, if(chat_msg.mText.empty()) return;//don't process empty messages +// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f + if (rlv_handler_t::isEnabled()) + { + // NOTE-RLVa: we can only filter the *message* here since most everything else will already be part of "args" as well + LLChat& tmp_chat = const_cast<LLChat&>(chat_msg); + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) && (!tmp_chat.mRlvLocFiltered) && (CHAT_SOURCE_AGENT != tmp_chat.mSourceType) ) + { + RlvUtil::filterLocation(tmp_chat.mText); + tmp_chat.mRlvLocFiltered = TRUE; + } + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (!tmp_chat.mRlvNamesFiltered) && (CHAT_SOURCE_AGENT != tmp_chat.mSourceType) ) + { + RlvUtil::filterNames(tmp_chat.mText); + tmp_chat.mRlvNamesFiltered = TRUE; + } + } +// [/RLVa:KB] + LLFloaterReg::getInstance("im_container"); LLFloaterIMNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLFloaterIMNearbyChat>("nearby_chat"); @@ -498,7 +521,11 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg, chat["chat_type"] = (S32)chat_msg.mChatType; chat["chat_style"] = (S32)chat_msg.mChatStyle; // Pass sender info so that it can be rendered properly (STORM-1021). - chat["sender_slurl"] = LLViewerChat::getSenderSLURL(chat_msg, args); +// chat["sender_slurl"] = LLViewerChat::getSenderSLURL(chat_msg, args); +// [RLVa:KB] - Checked: 2011-12-13 (RLVa-1.4.6) | Added: RLVa-1.4.6 + if ((CHAT_SOURCE_AGENT != chat_msg.mSourceType) || (!chat_msg.mRlvNamesFiltered)) + chat["sender_slurl"] = LLViewerChat::getSenderSLURL(chat_msg, args); +// [/RLVa:KB] if (chat_msg.mChatType == CHAT_TYPE_DIRECT && chat_msg.mText.length() > 0 && @@ -547,8 +574,11 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg, LLFirstUse::otherAvatarChatFirst(); // Add sender to the recent people list. - LLRecentPeople::instance().add(chat_msg.mFromID); - +// [RLVa:KB] - Checked: 2012-03-15 (RLVa-1.4.6) | Added: RLVa-1.4.6 + if (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + LLRecentPeople::instance().add(chat_msg.mFromID); +// [/RLVa:KB] +// LLRecentPeople::instance().add(chat_msg.mFromID); } // Send event on to LLEventStream @@ -621,6 +651,10 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg, LLUUID id; id.generate(); chat["id"] = id; +// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + if (rlv_handler_t::isEnabled()) + chat["show_icon_tooltip"] = !chat_msg.mRlvNamesFiltered; +// [/RLVa:KB] std::string r_color_name = "White"; F32 r_color_alpha = 1.0f; LLViewerChat::getChatColor( chat_msg, r_color_name, r_color_alpha); diff --git a/indra/newview/llfloaterimsession.cpp b/indra/newview/llfloaterimsession.cpp index 5cb9df5625895f96c22dcfb1c9e58aa1195af85c..9f6957a051b19c2ebf16d43dc207f9b8e29873cd 100755 --- a/indra/newview/llfloaterimsession.cpp +++ b/indra/newview/llfloaterimsession.cpp @@ -60,6 +60,10 @@ #include "llviewerchat.h" #include "llnotificationmanager.h" #include "llautoreplace.h" +// [RLVa:KB] - Checked: 2013-05-10 (RLVa-1.4.9) +#include "rlvactions.h" +#include "rlvcommon.h" +// [/RLVa:KB] floater_showed_signal_t LLFloaterIMSession::sIMFloaterShowedSignal; @@ -242,7 +246,60 @@ void LLFloaterIMSession::sendMsgFromInputEditor() void LLFloaterIMSession::sendMsg(const std::string& msg) { - const std::string utf8_text = utf8str_truncate(msg, MAX_MSG_BUF_SIZE - 1); +// const std::string utf8_text = utf8str_truncate(msg, MAX_MSG_BUF_SIZE - 1); +// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0) + std::string utf8_text = utf8str_truncate(msg, MAX_MSG_BUF_SIZE - 1); + + if ( (RlvActions::hasBehaviour(RLV_BHVR_SENDIM)) || (RlvActions::hasBehaviour(RLV_BHVR_SENDIMTO)) ) + { + const LLIMModel::LLIMSession* pIMSession = LLIMModel::instance().findIMSession(mSessionID); + RLV_ASSERT(pIMSession); + + bool fRlvFilter = !pIMSession; + if (pIMSession) + { + switch (pIMSession->mSessionType) + { + case LLIMModel::LLIMSession::P2P_SESSION: // One-on-one IM + fRlvFilter = !RlvActions::canSendIM(mOtherParticipantUUID); + break; + case LLIMModel::LLIMSession::GROUP_SESSION: // Group chat + fRlvFilter = !RlvActions::canSendIM(mSessionID); + break; + case LLIMModel::LLIMSession::ADHOC_SESSION: // Conference chat: allow if all participants can be sent an IM + { + if (!pIMSession->mSpeakers) + { + fRlvFilter = true; + break; + } + + LLSpeakerMgr::speaker_list_t speakers; + pIMSession->mSpeakers->getSpeakerList(&speakers, TRUE); + for (LLSpeakerMgr::speaker_list_t::const_iterator itSpeaker = speakers.begin(); + itSpeaker != speakers.end(); ++itSpeaker) + { + const LLSpeaker* pSpeaker = *itSpeaker; + if ( (gAgent.getID() != pSpeaker->mID) && (!RlvActions::canSendIM(pSpeaker->mID)) ) + { + fRlvFilter = true; + break; + } + } + } + break; + default: + fRlvFilter = true; + break; + } + } + + if (fRlvFilter) + { + utf8_text = RlvStrings::getString(RLV_STRING_BLOCKED_SENDIM); + } + } +// [/RLVa:KB] if (mSessionInitialized) { diff --git a/indra/newview/llfloaterinspect.cpp b/indra/newview/llfloaterinspect.cpp index 5a1dfc99ab53b95714ac909af9de28c39e555d50..57534f421abea9ce6079850606879b262a33cacd 100755 --- a/indra/newview/llfloaterinspect.cpp +++ b/indra/newview/llfloaterinspect.cpp @@ -41,6 +41,10 @@ #include "llviewercontrol.h" #include "llviewerobject.h" #include "lluictrlfactory.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "llagent.h" +// [/RLVa:KB] //LLFloaterInspect* LLFloaterInspect::sInstance = NULL; @@ -122,7 +126,16 @@ void LLFloaterInspect::onClickCreatorProfile() LLSelectNode* node = mObjectSelection->getFirstNode(&func); if(node) { - LLAvatarActions::showProfile(node->mPermissions->getCreator()); +// LLAvatarActions::showProfile(node->mPermissions->getCreator()); +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.2a) | Modified: RLVa-1.0.0e + const LLUUID& idCreator = node->mPermissions->getCreator(); + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && + ((node->mPermissions->getOwner() == idCreator) || (RlvUtil::isNearbyAgent(idCreator))) ) + { + return; + } + LLAvatarActions::showProfile(idCreator); +// [/RLVa:KB] } } } @@ -148,6 +161,10 @@ void LLFloaterInspect::onClickOwnerProfile() if(node) { const LLUUID& owner_id = node->mPermissions->getOwner(); +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.2a) | Modified: RLVa-1.0.0e + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + return; +// [/RLVa:KB] LLAvatarActions::showProfile(owner_id); } } @@ -157,8 +174,13 @@ void LLFloaterInspect::onSelectObject() { if(LLFloaterInspect::getSelectedUUID() != LLUUID::null) { - getChildView("button owner")->setEnabled(true); +// getChildView("button owner")->setEnabled(true); +// getChildView("button creator")->setEnabled(true); +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.2a) | Modified: RLVa-1.0.0e + getChildView("button owner")->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)); + // TODO-RLVa: [RLVa-1.2.2] Is it worth checking the selected node just to selectively disable this button? getChildView("button creator")->setEnabled(true); +// [/RLVa:KB] } } @@ -224,7 +246,12 @@ void LLFloaterInspect::refresh() // actual name and set a placeholder. if (LLAvatarNameCache::get(idOwner, &av_name)) { - owner_name = av_name.getCompleteName(); +// owner_name = av_name.getCompleteName(); +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + bool fRlvFilterOwner = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (idOwner != gAgent.getID()) && + (!obj->mPermissions->isGroupOwned()); + owner_name = (!fRlvFilterOwner) ? av_name.getCompleteName() : RlvStrings::getAnonym(av_name); +// [/RLVa:KB] } else { @@ -238,7 +265,14 @@ void LLFloaterInspect::refresh() if (LLAvatarNameCache::get(idCreator, &av_name)) { - creator_name = av_name.getCompleteName(); +// creator_name = av_name.getCompleteName(); +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + const LLUUID& idCreator = obj->mPermissions->getCreator(); + LLAvatarNameCache::get(idCreator, &av_name); + bool fRlvFilterCreator = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (idCreator != gAgent.getID()) && + ( (obj->mPermissions->getOwner() == idCreator) || (RlvUtil::isNearbyAgent(idCreator)) ); + creator_name = (!fRlvFilterCreator) ? av_name.getCompleteName() : RlvStrings::getAnonym(av_name); +// [/RLVa:KB] } else { @@ -249,7 +283,7 @@ void LLFloaterInspect::refresh() } mCreatorNameCacheConnection = LLAvatarNameCache::get(idCreator, boost::bind(&LLFloaterInspect::onGetCreatorNameCallback, this)); } - + row["id"] = obj->getObject()->getID(); row["columns"][0]["column"] = "object_name"; row["columns"][0]["type"] = "text"; diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 87ae36716d4ef073f35f53db68a8b3bb5224d337..0dc19c0bb45e4c69a4e55218bf48cd11899e121f 100755 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -106,6 +106,10 @@ #include "llpluginclassmedia.h" #include "llteleporthistorystorage.h" #include "llproxy.h" +// [RLVa:KB] - Checked: 2010-03-18 (RLVa-1.2.0a) +#include "rlvactions.h" +#include "rlvhandler.h" +// [/RLVa:KB] #include "lllogininstance.h" // to check if logged in yet #include "llsdserialize.h" @@ -1087,6 +1091,13 @@ void LLFloaterPreference::refreshEnabledState() LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections"); LLRadioGroup* radio_reflection_detail = getChild<LLRadioGroup>("ReflectionDetailRadio"); +// [RLVa:KB] - Checked: 2013-05-11 (RLVa-1.4.9) + if (rlv_handler_t::isEnabled()) + { + getChild<LLUICtrl>("do_not_disturb_response")->setEnabled(!RlvActions::hasBehaviour(RLV_BHVR_SENDIM)); + } +// [/RLVa:KB] + // Reflections BOOL reflections = gSavedSettings.getBOOL("VertexShaderEnable") && gGLManager.mHasCubeMap @@ -1131,8 +1142,14 @@ void LLFloaterPreference::refreshEnabledState() // radio set for terrain detail mode LLRadioGroup* mRadioTerrainDetail = getChild<LLRadioGroup>("TerrainDetailRadio"); // can be linked with control var - ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable")); - +// ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable")); +// [RLVa:KB] - Checked: 2010-03-18 (RLVa-1.2.0a) | Modified: RLVa-0.2.0a + // "Basic Shaders" can't be disabled - but can be enabled - under @setenv=n + bool fCtrlShaderEnable = LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"); + ctrl_shader_enable->setEnabled( + fCtrlShaderEnable && ((!gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)) || (!gSavedSettings.getBOOL("VertexShaderEnable"))) ); +// [/RLVa:KB] + BOOL shaders = ctrl_shader_enable->get(); if (shaders) { @@ -1149,7 +1166,13 @@ void LLFloaterPreference::refreshEnabledState() // *HACK just checks to see if we can use shaders... // maybe some cards that use shaders, but don't support windlight - ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders); +// ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders); +// [RLVa:KB] - Checked: 2010-03-18 (RLVa-1.2.0a) | Modified: RLVa-0.2.0a + // "Atmospheric Shaders" can't be disabled - but can be enabled - under @setenv=n + bool fCtrlWindLightEnable = fCtrlShaderEnable && shaders; + ctrl_wind_light->setEnabled( + fCtrlWindLightEnable && ((!gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)) || (!gSavedSettings.getBOOL("WindLightUseAtmosShaders"))) ); +// [/RLVa:KB] //Deferred/SSAO/Shadows LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders"); diff --git a/indra/newview/llfloaterproperties.cpp b/indra/newview/llfloaterproperties.cpp index 3f00ba39c72550a2b2c138ae68cecbabc0f68dc9..4eaa3256574eb6ec6837f61abd26f02ffa35fafb 100755 --- a/indra/newview/llfloaterproperties.cpp +++ b/indra/newview/llfloaterproperties.cpp @@ -58,6 +58,9 @@ #include "lluictrlfactory.h" +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) +#include "rlvhandler.h" +// [/RLVa:KB] //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLPropertiesObserver @@ -278,6 +281,16 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item) getChildView("BtnCreator")->setEnabled(TRUE); getChildView("LabelCreatorTitle")->setEnabled(TRUE); getChildView("LabelCreatorName")->setEnabled(TRUE); +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Modified: RLVa-1.0.0e + // If the object creator matches the object owner we need to anonymize the creator field as well + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && + ( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == item->getCreatorUUID()) ) || + (RlvUtil::isNearbyAgent(item->getCreatorUUID())) ) ) + { + childSetEnabled("BtnCreator", FALSE); + name = RlvStrings::getAnonym(name); + } +// [/RLVa:KB] getChild<LLUICtrl>("LabelCreatorName")->setValue(name); } else @@ -301,8 +314,15 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item) else { gCacheName->getFullName(perm.getOwner(), name); +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Modified: RLVa-1.0.0e + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + name = RlvStrings::getAnonym(name); +// [/RLVa:KB] } - getChildView("BtnOwner")->setEnabled(TRUE); +// getChildView("BtnOwner")->setEnabled(TRUE); +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Added: RLVa-1.0.0e + getChildView("BtnOwner")->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)); +// [/RLVa:KB] getChildView("LabelOwnerTitle")->setEnabled(TRUE); getChildView("LabelOwnerName")->setEnabled(TRUE); getChild<LLUICtrl>("LabelOwnerName")->setValue(name); @@ -539,6 +559,17 @@ void LLFloaterProperties::onClickCreator() if(!item) return; if(!item->getCreatorUUID().isNull()) { +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Added: RLVa-1.2.1b + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + { + const LLPermissions& perm = item->getPermissions(); + if ( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == item->getCreatorUUID()) ) || + (RlvUtil::isNearbyAgent(item->getCreatorUUID())) ) + { + return; + } + } +// [/RLVa:KB] LLAvatarActions::showProfile(item->getCreatorUUID()); } } @@ -554,6 +585,10 @@ void LLFloaterProperties::onClickOwner() } else { +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Modified: RLVa-1.0.0e + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + return; +// [/RLVa:KB] LLAvatarActions::showProfile(item->getPermissions().getOwner()); } } diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index 35b63c54803fde1765942cd98b507c7cf9962daa..1e9c093b419cda3fdff222d05104d93e4b54913d 100755 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -257,6 +257,14 @@ void LLFloaterReporter::getObjectInfo(const LLUUID& object_id) if (regionp) { getChild<LLUICtrl>("sim_field")->setValue(regionp->getName()); +// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) +/* + if ( (rlv_handler_t::isEnabled()) && (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ) + { + childSetText("sim_field", RlvStrings::getString(RLV_STRING_HIDDEN_REGION)); + } +*/ +// [/RLVa:KB] LLVector3d global_pos; global_pos.setVec(objectp->getPositionRegion()); setPosBox(global_pos); diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp index 07f5220ab7f8419cc50d5b0723c1d7f7e63a97dc..796710bfb074a389d292a94f5dd82c10be003597 100755 --- a/indra/newview/llfloatersettingsdebug.cpp +++ b/indra/newview/llfloatersettingsdebug.cpp @@ -209,6 +209,20 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) if (controlp) { +// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a + // If "HideFromEditor" was toggled while the floater is open then we need to manually disable access to the control + // NOTE: this runs per-frame so there's no need to explictly handle onCommitSettings() or onClickDefault() + bool fEnable = !controlp->isHiddenFromSettingsEditor(); + spinner1->setEnabled(fEnable); + spinner2->setEnabled(fEnable); + spinner3->setEnabled(fEnable); + spinner4->setEnabled(fEnable); + color_swatch->setEnabled(fEnable); + childSetEnabled("val_text", fEnable); + childSetEnabled("boolean_combo", fEnable); + childSetEnabled("default_btn", fEnable); +// [/RLVa:KB] + eControlType type = controlp->type(); //hide combo box only for non booleans, otherwise this will result in the combo box closing every frame diff --git a/indra/newview/llfloatersidepanelcontainer.cpp b/indra/newview/llfloatersidepanelcontainer.cpp index 5f9556a870d66810af487f69807501b362bf54c9..2101519af252d494ac62ac5a2185c8b26e8da570 100755 --- a/indra/newview/llfloatersidepanelcontainer.cpp +++ b/indra/newview/llfloatersidepanelcontainer.cpp @@ -39,6 +39,10 @@ //static const std::string LLFloaterSidePanelContainer::sMainPanelName("main_panel"); +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 +LLFloaterSidePanelContainer::validate_signal_t LLFloaterSidePanelContainer::mValidateSignal; +// [/RLVa:KB] + LLFloaterSidePanelContainer::LLFloaterSidePanelContainer(const LLSD& key, const Params& params) : LLFloater(key, params) { @@ -104,10 +108,25 @@ LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_na return panel; } +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 +bool LLFloaterSidePanelContainer::canShowPanel(const std::string& floater_name, const LLSD& key) +{ + return mValidateSignal(floater_name, sMainPanelName, key); +} + +bool LLFloaterSidePanelContainer::canShowPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key) +{ + return mValidateSignal(floater_name, panel_name, key); +} +// [/RLVa:KB] + void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const LLSD& key) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name); - if (floaterp) +// if (floaterp) +// [RLVa:KB] - Checked: 2013-04-16 (RLVa-1.4.8) + if ( (floaterp) && ((floaterp->getVisible()) || (LLFloaterReg::canShowInstance(floater_name, key))) && (canShowPanel(floater_name, key)) ) +// [/RLVa:KB] { floaterp->openChildPanel(sMainPanelName, key); } @@ -116,7 +135,10 @@ void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, con void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name); - if (floaterp) +// if (floaterp) +// [RLVa:KB] - Checked: 2013-04-16 (RLVa-1.4.8) + if ( (floaterp) && ((floaterp->getVisible()) || (LLFloaterReg::canShowInstance(floater_name, key))) && (canShowPanel(floater_name, panel_name, key)) ) +// [/RLVa:KB] { floaterp->openChildPanel(panel_name, key); } diff --git a/indra/newview/llfloatersidepanelcontainer.h b/indra/newview/llfloatersidepanelcontainer.h index 491723471fb1109211764fe9b6757234071b9cf4..0dfcefe0602f7bc2f0ef09a1467c2bab06448628 100755 --- a/indra/newview/llfloatersidepanelcontainer.h +++ b/indra/newview/llfloatersidepanelcontainer.h @@ -55,6 +55,11 @@ class LLFloaterSidePanelContainer : public LLFloater LLPanel* openChildPanel(const std::string& panel_name, const LLSD& params); +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 + static bool canShowPanel(const std::string& floater_name, const LLSD& key); + static bool canShowPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key); +// [/RLVa:KB] + static void showPanel(const std::string& floater_name, const LLSD& key); static void showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key); @@ -78,6 +83,15 @@ class LLFloaterSidePanelContainer : public LLFloater } return panel; } + +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 + // Used to determine whether a sidepanel can be shown +public: + typedef boost::signals2::signal<bool(const std::string&, const std::string&, const LLSD&), boost_boolean_combiner> validate_signal_t; + static boost::signals2::connection setValidateCallback(const validate_signal_t::slot_type& cb) { return mValidateSignal.connect(cb); } +private: + static validate_signal_t mValidateSignal; +// [/RLVa:KB] }; #endif // LL_LLFLOATERSIDEPANELCONTAINER_H diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 137b5446cfe41409b09d7557b8a43163e3013742..3d679cc886d75e3eb283bc043792c7737acd9711 100755 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -75,6 +75,10 @@ #include "llwindow.h" // copyTextToClipboard() #include <algorithm> +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) +#include "rlvhandler.h" +// [/RLVa:KB] + //--------------------------------------------------------------------------- // Constants //--------------------------------------------------------------------------- @@ -492,6 +496,10 @@ void LLFloaterWorldMap::draw() // getChildView("Clear")->setEnabled((BOOL)tracking_status); getChildView("Show Destination")->setEnabled((BOOL)tracking_status || LLWorldMap::getInstance()->isTracking()); getChildView("copy_slurl")->setEnabled((mSLURL.isValid()) ); +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + childSetEnabled("Go Home", + (!rlv_handler_t::isEnabled()) || !(gRlvHandler.hasBehaviour(RLV_BHVR_TPLM) && gRlvHandler.hasBehaviour(RLV_BHVR_TPLOC))); +// [/RLVa:KB] setMouseOpaque(TRUE); getDragHandle()->setMouseOpaque(TRUE); @@ -665,7 +673,10 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global) std::string tooltip(""); mTrackedStatus = LLTracker::TRACKING_LOCATION; - LLTracker::trackLocation(pos_global, full_name, tooltip); +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + LLTracker::trackLocation(pos_global, (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? full_name : RlvStrings::getString(RLV_STRING_HIDDEN).c_str(), tooltip); +// [/RLVa:KB] +// LLTracker::trackLocation(pos_global, full_name, tooltip); LLWorldMap::getInstance()->cancelTracking(); // The floater is taking over the tracking LLVector3d coord_pos = LLTracker::getTrackedPositionGlobal(); @@ -680,9 +691,25 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global) // enable/disable teleport destination coordinates void LLFloaterWorldMap::enableTeleportCoordsDisplay( bool enabled ) { - childSetEnabled("teleport_coordinate_x", enabled ); - childSetEnabled("teleport_coordinate_y", enabled ); - childSetEnabled("teleport_coordinate_z", enabled ); +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + LLUICtrl* pCtrl = getChild<LLUICtrl>("events_label"); + pCtrl->setVisible(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); + + pCtrl = getChild<LLUICtrl>("teleport_coordinate_x"); + pCtrl->setVisible(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); + pCtrl->setEnabled(enabled); + + pCtrl = getChild<LLUICtrl>("teleport_coordinate_y"); + pCtrl->setVisible(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); + pCtrl->setEnabled(enabled); + + pCtrl = getChild<LLUICtrl>("teleport_coordinate_z"); + pCtrl->setVisible(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); + pCtrl->setEnabled(enabled); +// [/RLVa:KB] +// childSetEnabled("teleport_coordinate_x", enabled ); +// childSetEnabled("teleport_coordinate_y", enabled ); +// childSetEnabled("teleport_coordinate_z", enabled ); } // update display of teleport destination coordinates - pos is in global coordinates @@ -721,7 +748,22 @@ void LLFloaterWorldMap::updateLocation() // Make sure we know where we are before setting the current user position std::string agent_sim_name; gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal( agentPos, agent_sim_name ); - if ( gotSimName ) +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { + mSetToUserPosition = FALSE; + + // Fill out the location field + getChild<LLUICtrl>("location")->setValue(RlvStrings::getString(RLV_STRING_HIDDEN_REGION)); + + // update the coordinate display with location of avatar in region + updateTeleportCoordsDisplay( agentPos ); + + mSLURL = LLSLURL(); + } + else if (gotSimName) +// [/RLVa:KB] +// if ( gotSimName ) { mSetToUserPosition = FALSE; @@ -766,7 +808,16 @@ void LLFloaterWorldMap::updateLocation() updateTeleportCoordsDisplay( coord_pos ); // simNameFromPosGlobal can fail, so don't give the user an invalid SLURL - if ( gotSimName ) +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { + mSLURL = LLSLURL(); + + childSetValue("location", RlvStrings::getString(RLV_STRING_HIDDEN_REGION)); + } + else if (gotSimName) +// [/RLVa:KB] +// if ( gotSimName ) { mSLURL = LLSLURL(sim_name, pos_global); } diff --git a/indra/newview/llgiveinventory.cpp b/indra/newview/llgiveinventory.cpp index 72bea8db104a125aea12ffa2f39e5dc57903b3ea..da4fefdc01dbea3df40c4c9b4fd8049cbee41d57 100755 --- a/indra/newview/llgiveinventory.cpp +++ b/indra/newview/llgiveinventory.cpp @@ -46,6 +46,11 @@ #include "llrecentpeople.h" #include "llviewerobjectlist.h" #include "llvoavatarself.h" +// [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.2a) +#include "llavatarnamecache.h" +#include "rlvhandler.h" +#include "rlvui.h" +// [/RLVa:KB] // MAX ITEMS is based on (sizeof(uuid)+2) * count must be < MTUBYTES // or 18 * count < 1200 => count < 1200/18 => 66. I've cut it down a @@ -315,6 +320,20 @@ void LLGiveInventory::logInventoryOffer(const LLUUID& to_agent, const LLUUID &im { gIMMgr->addSystemMessage(im_session_id, "inventory_item_offered", args); } +// [RLVa:KB] - Checked: 2010-05-26 (RLVa-1.2.2a) | Modified: RLVa-1.2.0h + else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(to_agent)) && + (!RlvUIEnabler::hasOpenProfile(to_agent)) ) + { + // Log to chat history if the user didn't drop on an IM session or a profile to avoid revealing the name of the recipient + std::string strMsgName = "inventory_item_offered-im"; LLSD args; LLAvatarName avName; + if (LLAvatarNameCache::get(to_agent, &avName)) + { + args["NAME"] = RlvStrings::getAnonym(avName); + strMsgName = "inventory_item_offered_rlv"; + } + gIMMgr->addSystemMessage(LLUUID::null, strMsgName, args); + } +// [/RLVa:KB] // If this item was given by drag-and-drop on avatar while IM panel was open, log this action in the IM panel chat. else if (LLIMModel::getInstance()->findIMSession(session_id)) { @@ -422,7 +441,15 @@ void LLGiveInventory::commitGiveInventoryItem(const LLUUID& to_agent, logInventoryOffer(to_agent, im_session_id); // add buddy to recent people list - LLRecentPeople::instance().add(to_agent); +// LLRecentPeople::instance().add(to_agent); +// [RLVa:KB] - Checked: 2010-04-21 (RLVa-1.2.2a) | Added: RLVa-1.2.0f + // Block the recent activity update if this was an in-world drop on an avatar (as opposed to a drop on an IM session or on a profile) + if ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (im_session_id.notNull()) || (!RlvUtil::isNearbyAgent(to_agent)) || + (RlvUIEnabler::hasOpenProfile(to_agent)) ) + { + LLRecentPeople::instance().add(to_agent); + } +// [/RLVa:KB] } // static @@ -488,7 +515,15 @@ bool LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent, << cat->getUUID() << llendl; // add buddy to recent people list - LLRecentPeople::instance().add(to_agent); +// LLRecentPeople::instance().add(to_agent); +// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.2a) | Added: RLVa-1.2.0f + // Block the recent activity update if this was an in-world drop on an avatar (as opposed to a drop on an IM session or on a profile) + if ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (im_session_id.notNull()) || (!RlvUtil::isNearbyAgent(to_agent)) || + (RlvUIEnabler::hasOpenProfile(to_agent)) ) + { + LLRecentPeople::instance().add(to_agent); + } +// [/RLVa:KB] // Test out how many items are being given. LLViewerInventoryCategory::cat_array_t cats; diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 60fa53f491c1d94b9d6e2018a5a1e330f2eb4260..841be9ff2941ab9c56daa2757b26f7e2b4a735c5 100755 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -62,6 +62,9 @@ #include "llresmgr.h" #include "pipeline.h" #include "llspatialpartition.h" +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) +#include "rlvhandler.h" +// [/RLVa:KB] // Height of the yellow selection highlight posts for land const F32 PARCEL_POST_HEIGHT = 0.666f; @@ -69,6 +72,18 @@ const F32 PARCEL_POST_HEIGHT = 0.666f; // Returns true if you got at least one object void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) { +// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c + // Block rectangle selection if: + // - prevented from editing and no exceptions are set (see below for the case where exceptions are set) + // - prevented from interacting at all + if ( (rlv_handler_t::isEnabled()) && + ( ((gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) && (!gRlvHandler.hasException(RLV_BHVR_EDIT))) || + (gRlvHandler.hasBehaviour(RLV_BHVR_INTERACT)) ) ) + { + return; + } +// [/RLVa:KB] + LLVector3 av_pos = gAgent.getPositionAgent(); F32 select_dist_squared = gSavedSettings.getF32("MaxSelectDistance"); select_dist_squared = select_dist_squared * select_dist_squared; @@ -133,6 +148,27 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) LLViewerCamera::getInstance()->setFar(new_far); LLViewerCamera::getInstance()->setNear(new_near); } +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-1.0.0g + if (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) + { + // We'll allow drag selection under fartouch, but only within the fartouch range + // (just copy/paste the code above us to make that work, thank you Lindens!) + LLVector3 relative_av_pos = av_pos; + relative_av_pos -= LLViewerCamera::getInstance()->getOrigin(); + + F32 new_far = relative_av_pos * LLViewerCamera::getInstance()->getAtAxis() + 1.5f; + F32 new_near = relative_av_pos * LLViewerCamera::getInstance()->getAtAxis() - 1.5f; + + new_near = llmax(new_near, 0.1f); + + LLViewerCamera::getInstance()->setFar(new_far); + LLViewerCamera::getInstance()->setNear(new_near); + + // Usurp these two + limit_select_distance = TRUE; + select_dist_squared = 1.5f * 1.5f; + } +// [/RLVa:KB] LLViewerCamera::getInstance()->setPerspective(FOR_SELECTION, center_x-width/2, center_y-height/2, width, height, limit_select_distance); @@ -207,6 +243,13 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) continue; } +// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c + if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canEdit(vobjp)) ) + { + continue; + } +// [/RLVa:KB] + S32 result = LLViewerCamera::getInstance()->sphereInFrustum(drawable->getPositionAgent(), drawable->getRadius()); if (result) { diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp index 302d21c2e42b16f24ca1b1ed628c412026b87280..f5185c4133dc692a7a0ed19b90d630db34aa6b1b 100755 --- a/indra/newview/llgroupactions.cpp +++ b/indra/newview/llgroupactions.cpp @@ -41,6 +41,12 @@ #include "llnotificationsutil.h" #include "llstatusbar.h" // can_afford_transaction() #include "groupchatlistener.h" +// [RLVa:KB] - Checked: 2011-03-28 (RLVa-1.3.0) +#include "llslurl.h" +#include "rlvactions.h" +#include "rlvcommon.h" +#include "rlvhandler.h" +// [/RLVa:KB] // // Globals @@ -208,6 +214,15 @@ void LLGroupActions::startCall(const LLUUID& group_id) return; } +// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) + if ( (!RlvActions::canStartIM(group_id)) && (!RlvActions::hasOpenGroupSession(group_id)) ) + { + make_ui_sound("UISndInvalidOp"); + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("group", group_id, "about").getSLURLString())); + return; + } +// [/RLVa:KB] + LLUUID session_id = gIMMgr->addSession(gdata.mName, IM_SESSION_GROUP_START, group_id, true); if (session_id == LLUUID::null) { @@ -281,7 +296,10 @@ bool LLGroupActions::onJoinGroup(const LLSD& notification, const LLSD& response) // static void LLGroupActions::leave(const LLUUID& group_id) { - if (group_id.isNull()) +// if (group_id.isNull()) +// [RLVa:KB] - Checked: 2011-03-28 (RLVa-1.4.1a) | Added: RLVa-1.3.0f + if ( (group_id.isNull()) || ((gAgent.getGroupID() == group_id) && (gRlvHandler.hasBehaviour(RLV_BHVR_SETGROUP))) ) +// [/RLVa:KB] { return; } @@ -333,6 +351,13 @@ void LLGroupActions::processLeaveGroupDataResponse(const LLUUID group_id) // static void LLGroupActions::activate(const LLUUID& group_id) { +// [RLVa:KB] - Checked: 2011-03-28 (RLVa-1.4.1a) | Added: RLVa-1.3.0f + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SETGROUP)) && (gRlvHandler.getAgentGroup() != group_id) ) + { + return; + } +// [/RLVa:KB] + LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ActivateGroup); msg->nextBlockFast(_PREHASH_AgentData); @@ -429,6 +454,15 @@ LLUUID LLGroupActions::startIM(const LLUUID& group_id) { if (group_id.isNull()) return LLUUID::null; +// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) + if ( (!RlvActions::canStartIM(group_id)) && (!RlvActions::hasOpenGroupSession(group_id)) ) + { + make_ui_sound("UISndInvalidOp"); + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("group", group_id, "about").getSLURLString())); + return LLUUID::null; + } +// [/RLVa:KB] + LLGroupData group_data; if (gAgent.getGroupData(group_id, group_data)) { diff --git a/indra/newview/llgrouplist.cpp b/indra/newview/llgrouplist.cpp index aba3d74d878152478e2354ab87a9cb479682f8a1..c801898cc1ecb93c56419f5ddfaf6f9d01bd90c8 100755 --- a/indra/newview/llgrouplist.cpp +++ b/indra/newview/llgrouplist.cpp @@ -43,6 +43,9 @@ #include "llviewercontrol.h" // for gSavedSettings #include "llviewermenu.h" // for gMenuHolder #include "llvoiceclient.h" +// [RLVa:KB] - Checked: 2011-03-28 (RLVa-1.3.0f) | Added: RLVa-1.3.0f +#include "rlvhandler.h" +// [/RLVa:KB] static LLDefaultChildRegistry::Register<LLGroupList> r("group_list"); S32 LLGroupListItem::sIconWidth = 0; @@ -279,8 +282,14 @@ bool LLGroupList::onContextMenuItemEnable(const LLSD& userdata) bool real_group_selected = selected_group_id.notNull(); // a "real" (not "none") group is selected // each group including "none" can be activated +// if (userdata.asString() == "activate") +// return gAgent.getGroupID() != selected_group_id; +// [RLVa:KB] - Checked: 2011-03-28 (RLVa-1.4.1a) | Added: RLVa-1.3.0f if (userdata.asString() == "activate") - return gAgent.getGroupID() != selected_group_id; + return (gAgent.getGroupID() != selected_group_id) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SETGROUP)); + else if (userdata.asString() == "leave") + return (real_group_selected) && ((gAgent.getGroupID() != selected_group_id) || (!gRlvHandler.hasBehaviour(RLV_BHVR_SETGROUP))); +// [/RLVa:KB] if (userdata.asString() == "call") return real_group_selected && LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking(); diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index 3c6bcd982995b9a19fb34ce228bb7241f5d6d259..ec7c7c6ff6ccfd4cbefb91c25e22c38914434154 100755 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -46,9 +46,11 @@ #include "llstatusbar.h" #include "llmenugl.h" #include "pipeline.h" +// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.4.0a) +#include "rlvhandler.h" +// [/RLVa:KB] #include <boost/tokenizer.hpp> - const F32 SPRING_STRENGTH = 0.7f; const F32 RESTORATION_SPRING_TIME_CONSTANT = 0.1f; const F32 HORIZONTAL_PADDING = 15.f; @@ -252,7 +254,30 @@ void LLHUDText::renderText() void LLHUDText::setString(const std::string &text_utf8) { mTextSegments.clear(); - addLine(text_utf8, mColor); +// addLine(text_utf8, mColor); +// [RLVa:KB] - Checked: 2010-03-02 (RLVa-1.4.0a) | Modified: RLVa-1.0.0f + // NOTE: setString() is called for debug and map beacons as well + if (rlv_handler_t::isEnabled()) + { + std::string text(text_utf8); + if (gRlvHandler.canShowHoverText(mSourceObject)) + { + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + RlvUtil::filterLocation(text); + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + RlvUtil::filterNames(text); + } + else + { + text = ""; + } + addLine(text, mColor); + } + else + { + addLine(text_utf8, mColor); + } +// [/RLVa:KB] } void LLHUDText::clearString() @@ -632,3 +657,15 @@ F32 LLHUDText::LLHUDTextSegment::getWidth(const LLFontGL* font) return width; } } + +// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.0.0f +void LLHUDText::refreshAllObjectText() +{ + for (TextObjectIterator itText = sTextObjects.begin(); itText != sTextObjects.end(); ++itText) + { + LLHUDText* pText = *itText; + if ( (pText) && (!pText->mObjText.empty()) && (pText->mSourceObject) && (LL_PCODE_VOLUME == pText->mSourceObject->getPCode()) ) + pText->setString(pText->mObjText); + } +} +// [/RLVa:KB] diff --git a/indra/newview/llhudtext.h b/indra/newview/llhudtext.h index 36015d51f0452fd583757928c388991885403efc..d5d81e13362e706894622ea3ba64d4a9ae819fec 100755 --- a/indra/newview/llhudtext.h +++ b/indra/newview/llhudtext.h @@ -124,6 +124,11 @@ class LLHUDText : public LLHUDObject static void reshape(); static void setDisplayText(BOOL flag) { sDisplayText = flag ; } +// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.0.0f + const std::string& getObjectText() const { return mObjText; } + void setObjectText(const std::string &utf8string) { mObjText = utf8string; } + static void refreshAllObjectText(); +// [/RLVa:KB] protected: LLHUDText(const U8 type); @@ -161,6 +166,9 @@ class LLHUDText : public LLHUDObject ETextAlignment mTextAlignment; EVertAlignment mVertAlignment; BOOL mHidden; +// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.0.0f + std::string mObjText; +// [/RLVa:KB] static BOOL sDisplayText ; static std::set<LLPointer<LLHUDText> > sTextObjects; diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 9ffbd1a6752ce9cde6488777024d9b436660aeca..c301dc2630f3a6cfcf27085c919b0617d462b68f 100755 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -68,7 +68,10 @@ #include "llviewerparcelmgr.h" #include "llconversationlog.h" #include "message.h" - +// [RLVa:KB] - Checked: 2013-05-10 (RLVa-1.4.9) +#include "rlvactions.h" +#include "rlvcommon.h" +// [/RLVa:KB] const static std::string ADHOC_NAME_SUFFIX(" Conference"); @@ -3582,6 +3585,20 @@ class LLViewerChatterBoxInvitation : public LLHTTPNode { return; } +// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0) + if ( (RlvActions::hasBehaviour(RLV_BHVR_RECVIM)) || (RlvActions::hasBehaviour(RLV_BHVR_RECVIMFROM)) ) + { + if (gAgent.isInGroup(session_id)) // Group chat: don't accept the invite if not an exception + { + if (!RlvActions::canReceiveIM(session_id)) + return; + } + else if (!RlvActions::canReceiveIM(from_id)) // Conference chat: don't block; censor if not an exception + { + message = RlvStrings::getString(RLV_STRING_BLOCKED_RECVIM); + } + } +// [/RLVa:KB] // standard message, not from system std::string saved; diff --git a/indra/newview/llinspectobject.cpp b/indra/newview/llinspectobject.cpp index a7b93b80306d98b93632f5bc6352eb301ed0c936..e9bf701a97a671b5c25f1b69589c8fc7f2973461 100755 --- a/indra/newview/llinspectobject.cpp +++ b/indra/newview/llinspectobject.cpp @@ -38,6 +38,10 @@ #include "llviewermedia.h" #include "llviewermediafocus.h" #include "llviewerobjectlist.h" // to select the requested object +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0c) +#include "rlvhandler.h" +#include "lltoolpie.h" +// [/RLVa:KB] // Linden libraries #include "llbutton.h" // setLabel(), not virtual! @@ -358,6 +362,10 @@ void LLInspectObject::updateButtons(LLSelectNode* nodep) || (parent && parent->flagHandleTouch())) { getChild<LLUICtrl>("touch_btn")->setVisible(true); +// [RLVa:KB] - Checked: 2010-11-12 (RLVa-1.2.1g) | Added: RLVa-1.2.1g + if (rlv_handler_t::isEnabled()) + getChild<LLUICtrl>("touch_btn")->setEnabled(gRlvHandler.canTouch(object)); +// [/RLVa:KB] updateTouchLabel(nodep); } else if ( enable_object_open() ) @@ -387,6 +395,15 @@ void LLInspectObject::updateSitLabel(LLSelectNode* nodep) { sit_btn->setLabel( getString("Sit") ); } + +// [RLVa:KB] - Checked: 2010-03-06 (RLVa-1.2.0c) | Added: RLVa-1.2.0a + // RELEASE-RLVa: [SL-2.0.0] Make sure we're examining the same object that handle_sit_or_stand() will request a sit for + if (rlv_handler_t::isEnabled()) + { + const LLPickInfo& pick = LLToolPie::getInstance()->getPick(); + sit_btn->setEnabled( (pick.mObjectID.notNull()) && (gRlvHandler.canSit(pick.getObject(), pick.mObjectOffset)) ); + } +// [/RLVa:KB] } void LLInspectObject::updateTouchLabel(LLSelectNode* nodep) @@ -482,10 +499,17 @@ void LLInspectObject::updateCreator(LLSelectNode* nodep) // a clickable link // Objects cannot be created by a group, so use agent URL format LLUUID creator_id = nodep->mPermissions->getCreator(); - std::string creator_url = - LLSLURL("agent", creator_id, "about").getSLURLString(); +// std::string creator_url = +// LLSLURL("agent", creator_id, "about").getSLURLString(); +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + // Only anonymize the creator if they're also the owner or if they're a nearby avie + bool fRlvHideCreator = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && + ((nodep->mPermissions->getOwner() == creator_id) || (RlvUtil::isNearbyAgent(creator_id))); + std::string creator_url = + LLSLURL("agent", creator_id, (!fRlvHideCreator) ? "about" : "rlvanonym").getSLURLString(); +// [/RLVa:KB] args["[CREATOR]"] = creator_url; - + // created by one user but owned by another std::string owner_url; LLUUID owner_id; @@ -498,7 +522,11 @@ void LLInspectObject::updateCreator(LLSelectNode* nodep) else { owner_id = nodep->mPermissions->getOwner(); - owner_url = LLSLURL("agent", owner_id, "about").getSLURLString(); +// owner_url = LLSLURL("agent", owner_id, "about").getSLURLString(); +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + bool fRlvHideOwner = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)); + owner_url = LLSLURL("agent", owner_id, (!fRlvHideOwner) ? "about" : "rlvanonym").getSLURLString(); +// [/RLVa:KB] } args["[OWNER]"] = owner_url; diff --git a/indra/newview/llinspectremoteobject.cpp b/indra/newview/llinspectremoteobject.cpp index a12ec390af477035e79523785c88b3b511d1ad58..bd4bae7b0280a108a65e8c786100351cdff541fc 100755 --- a/indra/newview/llinspectremoteobject.cpp +++ b/indra/newview/llinspectremoteobject.cpp @@ -35,6 +35,9 @@ #include "llui.h" #include "lluictrl.h" #include "llurlaction.h" +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.2a) +#include "rlvhandler.h" +// [/RLVa:KB] ////////////////////////////////////////////////////////////////////////////// // LLInspectRemoteObject @@ -66,6 +69,9 @@ class LLInspectRemoteObject : public LLInspect LLUUID mOwnerID; std::string mSLurl; std::string mName; +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + bool mRlvHideNames; +// [/RLVa:KB] bool mGroupOwned; }; @@ -75,6 +81,9 @@ LLInspectRemoteObject::LLInspectRemoteObject(const LLSD& sd) : mOwnerID(NULL), mSLurl(""), mName(""), +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + mRlvHideNames(false), +// [/RLVa:KB] mGroupOwned(false) { } @@ -107,6 +116,10 @@ void LLInspectRemoteObject::onOpen(const LLSD& data) mOwnerID = data["owner_id"].asUUID(); mGroupOwned = data["group_owned"].asBoolean(); mSLurl = data["slurl"].asString(); +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + if (data.has("rlv_shownames")) + mRlvHideNames = data["rlv_shownames"].asBoolean(); +// [/RLVa:KB] // update the inspector with the current object state update(); @@ -160,7 +173,10 @@ void LLInspectRemoteObject::update() } else { - owner = LLSLURL("agent", mOwnerID, "about").getSLURLString(); +// owner = LLSLURL("agent", mOwnerID, "about").getSLURLString(); +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + owner = LLSLURL("agent", mOwnerID, (!mRlvHideNames) ? "about" : "rlvanonym").getSLURLString(); +// [/RLVa:KB] } } else @@ -182,6 +198,14 @@ void LLInspectRemoteObject::update() // disable the Block button if we don't have the object ID (will this ever happen?) getChild<LLUICtrl>("block_btn")->setEnabled(! mObjectID.isNull()); + +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + if ( (rlv_handler_t::isEnabled()) && (RlvStrings::getString(RLV_STRING_HIDDEN_REGION) == mSLurl) ) + { + getChild<LLUICtrl>("object_slurl")->setValue(mSLurl); + getChild<LLUICtrl>("map_btn")->setEnabled(false); + } +// [/RLVa:KB] } ////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 44b387cd5d852072184d10dd2e615fb3b31ac74d..8aaec677b4cd3b1b50012d9f3744cf19ec7bca45 100755 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -74,6 +74,11 @@ #include "llvoavatarself.h" #include "llwearablelist.h" #include "lllandmarkactions.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1) +#include "rlvactions.h" +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] void copy_slurl_to_clipboard_callback_inv(const std::string& slurl); @@ -754,6 +759,20 @@ void LLInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags) addOpenRightClickMenuOption(items); items.push_back(std::string("Properties")); +// [RLVa:KB] - Checked: 2010-03-01 (RLVa-1.2.0b) | Modified: RLVa-1.1.0a + if (rlv_handler_t::isEnabled()) + { + const LLInventoryObject* pItem = getInventoryObject(); + if ( (pItem) && + ( ((LLAssetType::AT_NOTECARD == pItem->getType()) && (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWNOTE))) || + ((LLAssetType::AT_LSL_TEXT == pItem->getType()) && (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWSCRIPT))) || + ((LLAssetType::AT_TEXTURE == pItem->getType()) && (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWTEXTURE))) ) ) + { + disabled_items.push_back(std::string("Open")); + } + } +// [/RLVa:KB] + getClipboardEntries(true, items, disabled_items, flags); } hide_context_entries(menu, items, disabled_items); @@ -1682,6 +1701,13 @@ BOOL LLItemBridge::isItemRenameable() const return FALSE; } +// [RLVa:KB] - Checked: 2011-03-29 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g + if ( (rlv_handler_t::isEnabled()) && (!RlvFolderLocks::instance().canRenameItem(mUUID)) ) + { + return FALSE; + } +// [/RLVa:KB] + return (item->getPermissions().allowModifyBy(gAgent.getID())); } return FALSE; @@ -2436,6 +2462,14 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, } } } + +// [RLVa:KB] - Checked: 2011-03-29 (RLVa-1.3.0g) | Added: RLVa-1.3.0g + if ( (is_movable) && (rlv_handler_t::isEnabled()) && (RlvFolderLocks::instance().hasLockedFolder(RLV_LOCK_ANY)) ) + { + is_movable = RlvFolderLocks::instance().canMoveFolder(cat_id, mUUID); + } +// [/RLVa:KB] + // //-------------------------------------------------------------------------------- @@ -3994,6 +4028,24 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, { is_movable = FALSE; } + +// [RLVa:KB] - Checked: 2011-03-29 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g + if ( (rlv_handler_t::isEnabled()) && (is_movable) ) + { + if (move_is_into_current_outfit) + { + // RELEASE-RLVa: [RLVa-1.3.0] Keep sync'ed with code below => LLAppearanceMgr::wearItemOnAvatar() with "replace == true" + const LLViewerInventoryItem* pItem = dynamic_cast<const LLViewerInventoryItem*>(inv_item); + is_movable = rlvPredCanWearItem(pItem, RLV_WEAR_REPLACE); + } + if (is_movable) + { + is_movable = (!RlvFolderLocks::instance().hasLockedFolder(RLV_LOCK_ANY)) || + (RlvFolderLocks::instance().canMoveItem(inv_item->getUUID(), mUUID)); + } + } +// [/RLVa:KB] + if (move_is_into_trash) { is_movable &= inv_item->getIsLinkType() || !get_is_item_worn(inv_item->getUUID()); @@ -4730,6 +4782,16 @@ void LLCallingCardBridge::performAction(LLInventoryModel* model, std::string act { callingcard_name = av_name.getCompleteName(); } + +// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9) + if ( (!RlvActions::canStartIM(item->getCreatorUUID())) && (!RlvActions::hasOpenP2PSession(item->getCreatorUUID())) ) + { + make_ui_sound("UISndInvalidOp"); + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("agent", item->getCreatorUUID(), "completename").getSLURLString())); + return; + } +// [/RLVa:KB] + LLUUID session_id = gIMMgr->addSession(callingcard_name, IM_NOTHING_SPECIAL, item->getCreatorUUID()); if (session_id != LLUUID::null) { @@ -5310,6 +5372,16 @@ std::string LLObjectBridge::getLabelSuffix() const void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment, bool replace) { +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1) + // If no attachment point was specified, try looking it up from the item name + static LLCachedControl<bool> fRlvDeprecateAttachPt(gSavedSettings, "RLVaDebugDeprecateExplicitPoint"); + if ( (rlv_handler_t::isEnabled()) && (!fRlvDeprecateAttachPt) && + (!attachment) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY)) ) + { + attachment = RlvAttachPtLookup::getAttachPoint(item); + } +// [/RLVa:KB] + const LLUUID& item_id = item->getLinkedUUID(); // Check for duplicate request. @@ -5344,10 +5416,24 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach if (replace && (attachment && attachment->getNumObjects() > 0)) { +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1) + // Block if we can't "replace wear" what's currently there + if ( (rlv_handler_t::isEnabled()) && ((gRlvAttachmentLocks.canAttach(attachment) & RLV_WEAR_REPLACE) == 0) ) + { + return; + } +// [/RLVa:KB] LLNotificationsUtil::add("ReplaceAttachment", LLSD(), payload, confirm_attachment_rez); } else { +// [RLVa:KB] - Checked: 2010-08-07 (RLVa-1.2.0) + // Block wearing anything on a non-attachable attachment point + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.isLockedAttachmentPoint(attach_pt, RLV_LOCK_ADD)) ) + { + return; + } +// [/RLVa:KB] LLNotifications::instance().forceResponse(LLNotification::Params("ReplaceAttachment").payload(payload), 0/*YES*/); } } @@ -5370,26 +5456,25 @@ bool confirm_attachment_rez(const LLSD& notification, const LLSD& response) if (itemp) { - /* - { - U8 attachment_pt = notification["payload"]["attachment_point"].asInteger(); - - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_RezSingleAttachmentFromInv); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_ObjectData); - msg->addUUIDFast(_PREHASH_ItemID, itemp->getUUID()); - msg->addUUIDFast(_PREHASH_OwnerID, itemp->getPermissions().getOwner()); - msg->addU8Fast(_PREHASH_AttachmentPt, attachment_pt); - pack_permissions_slam(msg, itemp->getFlags(), itemp->getPermissions()); - msg->addStringFast(_PREHASH_Name, itemp->getName()); - msg->addStringFast(_PREHASH_Description, itemp->getDescription()); - msg->sendReliable(gAgent.getRegion()->getHost()); - return false; - } - */ +// /* +// { +// U8 attachment_pt = notification["payload"]["attachment_point"].asInteger(); +// LLMessageSystem* msg = gMessageSystem; +// msg->newMessageFast(_PREHASH_RezSingleAttachmentFromInv); +// msg->nextBlockFast(_PREHASH_AgentData); +// msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); +// msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); +// msg->nextBlockFast(_PREHASH_ObjectData); +// msg->addUUIDFast(_PREHASH_ItemID, itemp->getUUID()); +// msg->addUUIDFast(_PREHASH_OwnerID, itemp->getPermissions().getOwner()); +// msg->addU8Fast(_PREHASH_AttachmentPt, attachment_pt); +// pack_permissions_slam(msg, itemp->getFlags(), itemp->getPermissions()); +// msg->addStringFast(_PREHASH_Name, itemp->getName()); +// msg->addStringFast(_PREHASH_Description, itemp->getDescription()); +// msg->sendReliable(gAgent.getRegion()->getHost()); +// return false; +// } +// */ // Queue up attachments to be sent in next idle tick, this way the // attachments are batched up all into one message versus each attachment @@ -5441,6 +5526,10 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { items.push_back(std::string("Wearable And Object Separator")); items.push_back(std::string("Detach From Yourself")); +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a + if ( (rlv_handler_t::isEnabled()) && (!gRlvAttachmentLocks.canDetach(item)) ) + disabled_items.push_back(std::string("Detach From Yourself")); +// [/RLVa:KB] } else if (!isItemInTrash() && !isLinkedObjectInTrash() && !isLinkedObjectMissing() && !isCOFFolder()) { @@ -5459,6 +5548,17 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) disabled_items.push_back(std::string("Attach To")); disabled_items.push_back(std::string("Attach To HUD")); } +// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1a) | Modified: RLVa-1.2.1a + else if (rlv_handler_t::isEnabled()) + { + ERlvWearMask eWearMask = gRlvAttachmentLocks.canAttach(item); + if ((eWearMask & RLV_WEAR_REPLACE) == 0) + disabled_items.push_back(std::string("Wearable And Object Wear")); + if ((eWearMask & RLV_WEAR_ADD) == 0) + disabled_items.push_back(std::string("Wearable Add")); + } +// [/RLVa:KB] + LLMenuGL* attach_menu = menu.findChildMenuByName("Attach To", TRUE); LLMenuGL* attach_hud_menu = menu.findChildMenuByName("Attach To HUD", TRUE); if (attach_menu @@ -5705,18 +5805,37 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { disabled_items.push_back(std::string("Wearable And Object Wear")); disabled_items.push_back(std::string("Wearable Add")); +// [RLVa:KB] - Checked: 2010-04-04 (RLVa-1.2.0c) | Added: RLVa-1.2.0c + if ( (rlv_handler_t::isEnabled()) && (!gRlvWearableLocks.canRemove(item)) ) + disabled_items.push_back(std::string("Take Off")); +// [/RLVa:KB] } else { items.push_back(std::string("Wearable And Object Wear")); disabled_items.push_back(std::string("Take Off")); disabled_items.push_back(std::string("Wearable Edit")); + +// [RLVa:KB] - Checked: 2010-06-09 (RLVa-1.2.0g) | Modified: RLVa-1.2.0g + if (rlv_handler_t::isEnabled()) + { + ERlvWearMask eWearMask = gRlvWearableLocks.canWear(item); + if ((eWearMask & RLV_WEAR_REPLACE) == 0) + disabled_items.push_back(std::string("Wearable And Object Wear")); + if ((eWearMask & RLV_WEAR_ADD) == 0) + disabled_items.push_back(std::string("Wearable Add")); + } +// [/RLVa:KB] } if (LLWearableType::getAllowMultiwear(mWearableType)) { items.push_back(std::string("Wearable Add")); - if (gAgentWearables.getWearableCount(mWearableType) >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) +// if (gAgentWearables.getWearableCount(mWearableType) >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) +// [SL:KB] - Patch: Appearance-WearableDuplicateAssets | Checked: 2011-07-24 (Catznip-2.6.0e) | Added: Catznip-2.6.0e + if ( (gAgentWearables.getWearableCount(mWearableType) >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) || + (gAgentWearables.getWearableFromAssetID(item->getAssetUUID())) ) +// [/SL:KB] { disabled_items.push_back(std::string("Wearable Add")); } diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index c1314f6505b9d66741d814006549c6fba6fdda23..1febab2cbf39a591c1e1a80497cdb8d05b9c501d 100755 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -84,6 +84,10 @@ #include "llviewerwindow.h" #include "llvoavatarself.h" #include "llwearablelist.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] #include <boost/foreach.hpp> @@ -348,6 +352,14 @@ BOOL get_is_item_removable(const LLInventoryModel* model, const LLUUID& id) } } +// [RLVa:KB] - Checked: 2011-03-29 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g + if ( (rlv_handler_t::isEnabled()) && + (RlvFolderLocks::instance().hasLockedFolder(RLV_LOCK_ANY)) && (!RlvFolderLocks::instance().canRemoveItem(id)) ) + { + return FALSE; + } +// [/RLVa:KB] + const LLInventoryObject *obj = model->getItem(id); if (obj && obj->getIsLinkType()) { @@ -376,6 +388,14 @@ BOOL get_is_category_removable(const LLInventoryModel* model, const LLUUID& id) return FALSE; } +// [RLVa:KB] - Checked: 2011-03-29 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g + if ( ((rlv_handler_t::isEnabled()) && + (RlvFolderLocks::instance().hasLockedFolder(RLV_LOCK_ANY)) && (!RlvFolderLocks::instance().canRemoveFolder(id))) ) + { + return FALSE; + } +// [/RLVa:KB] + if (!isAgentAvatarValid()) return FALSE; const LLInventoryCategory* category = model->getCategory(id); @@ -411,6 +431,13 @@ BOOL get_is_category_renameable(const LLInventoryModel* model, const LLUUID& id) return FALSE; } +// [RLVa:KB] - Checked: 2011-03-29 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g + if ( (rlv_handler_t::isEnabled()) && (model == &gInventory) && (!RlvFolderLocks::instance().canRenameFolder(id)) ) + { + return FALSE; + } +// [/RLVa:KB] + LLViewerInventoryCategory* cat = model->getCategory(id); if (cat && !LLFolderType::lookupIsProtectedType(cat->getPreferredType()) && diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp old mode 100755 new mode 100644 index 935fe2b4d0e88c6c70c7e5f310ebaf7e4755f9e0..84dd5acff695aca17167d9adc24a20956fbe8e93 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -49,6 +49,10 @@ #include "llvoavatarself.h" #include "llgesturemgr.h" #include <typeinfo> +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] //#define DIFF_INVENTORY_FILES #ifdef DIFF_INVENTORY_FILES @@ -639,13 +643,38 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id, { cats.put(cat); } - collectDescendentsIf(cat->getUUID(), cats, items, include_trash, add); +// [RLVa:KB] - Checked: 2013-04-15 (RLVa-1.4.8) + collectDescendentsIf(cat->getUUID(), cats, items, include_trash, add, follow_folder_links); +// [/RLVa:KB] +// collectDescendentsIf(cat->getUUID(), cats, items, include_trash, add); } } LLViewerInventoryItem* item = NULL; item_array_t* item_array = get_ptr_in_map(mParentChildItemTree, id); + // Move onto items + if(item_array) + { + S32 count = item_array->count(); + for(S32 i = 0; i < count; ++i) + { + item = item_array->get(i); + if(add(NULL, item)) + { + items.put(item); + } + } + } + +// [RLVa:KB] - Checked: 2010-09-30 (RLVa-1.2.1d) | Added: RLVa-1.2.1d + // The problem is that we want some way for the functor to know that it's being asked to decide on a folder link + // but it won't know that until after it has encountered the folder link item (which doesn't happen until *after* + // it has already collected all items from it the way the code was originally laid out) + // This breaks the "finish collecting all folders before collecting items (top to bottom and then bottom to top)" + // assumption but no functor is (currently) relying on it (and likely never should since it's an implementation detail?) + // [Only LLAppearanceMgr actually ever passes in 'follow_folder_links == TRUE'] +// [/RLVa:KB] // Follow folder links recursively. Currently never goes more // than one level deep (for current outfit support) // Note: if making it fully recursive, need more checking against infinite loops. @@ -675,20 +704,6 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id, } } } - - // Move onto items - if(item_array) - { - S32 count = item_array->count(); - for(S32 i = 0; i < count; ++i) - { - item = item_array->get(i); - if(add(NULL, item)) - { - items.put(item); - } - } - } } void LLInventoryModel::addChangedMaskForLinks(const LLUUID& object_id, U32 mask) @@ -2782,6 +2797,14 @@ void LLInventoryModel::processSaveAssetIntoInventory(LLMessageSystem* msg, llinfos << "LLInventoryModel::processSaveAssetIntoInventory item" " not found: " << item_id << llendl; } + +// [RLVa:KB] - Checked: 2010-03-05 (RLVa-1.2.0a) | Added: RLVa-0.2.0e + if (rlv_handler_t::isEnabled()) + { + RlvAttachmentLockWatchdog::instance().onSavedAssetIntoInventory(item_id); + } +// [/RLVa:KB] + if(gViewerWindow) { gViewerWindow->getWindow()->decBusyCount(); @@ -2832,6 +2855,20 @@ void LLInventoryModel::processBulkUpdateInventory(LLMessageSystem* msg, void**) { if(tfolder->getParentUUID() == folderp->getParentUUID()) { +// [RLVa:KB] - Checked: 2010-04-18 (RLVa-1.2.0e) | Added: RLVa-1.2.0e + // NOTE-RLVa: not sure if this is a hack or a bug-fix :o + // -> if we rename the folder on the first BulkUpdateInventory message subsequent messages will still contain + // the old folder name and gInventory.updateCategory() below will "undo" the folder name change but on the + // viewer-side *only* so the folder name actually becomes out of sync with what's on the inventory server + // -> so instead we keep the name of the existing folder and only do it for #RLV/~ in case this causes issues + // -> a better solution would be to only do the rename *after* the transaction completes but there doesn't seem + // to be any way to accomplish that either *sighs* + if ( (rlv_handler_t::isEnabled()) && (!folderp->getName().empty()) && (tfolder->getName() != folderp->getName()) && + ((tfolder->getName().find(RLV_PUTINV_PREFIX) == 0)) ) + { + tfolder->rename(folderp->getName()); + } +// [/RLVa:KB] update[tfolder->getParentUUID()]; } else diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index e5b9e11d48d4c017becb103f8cd6d871075ad066..b223b36fb6fef243aae50f266c4c0861d706aaff 100755 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -50,6 +50,10 @@ #include "llviewerattachmenu.h" #include "llviewerfoldertype.h" #include "llvoavatarself.h" +// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9) +#include "rlvactions.h" +#include "rlvcommon.h" +// [/RLVa:KB] static LLDefaultChildRegistry::Register<LLInventoryPanel> r("inventory_panel"); @@ -1027,6 +1031,10 @@ bool LLInventoryPanel::beginIMSession() LLDynamicArray<LLUUID> members; EInstantMessage type = IM_SESSION_CONFERENCE_START; +// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9) + bool fRlvCanStartIM = true; +// [/RLVa:KB] + std::set<LLFolderViewItem*>::const_iterator iter; for (iter = selected_items.begin(); iter != selected_items.end(); iter++) { @@ -1066,6 +1074,9 @@ bool LLInventoryPanel::beginIMSession() id = item_array.get(i)->getCreatorUUID(); if(at.isBuddyOnline(id)) { +// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9) + fRlvCanStartIM &= RlvActions::canStartIM(id); +// [/RLVa:KB] members.put(id); } } @@ -1086,6 +1097,9 @@ bool LLInventoryPanel::beginIMSession() if(at.isBuddyOnline(id)) { +// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9) + fRlvCanStartIM &= RlvActions::canStartIM(id); +// [/RLVa:KB] members.put(id); } } @@ -1097,6 +1111,15 @@ bool LLInventoryPanel::beginIMSession() // the session_id is randomly generated UUID which will be replaced later // with a server side generated number +// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9) + if (!fRlvCanStartIM) + { + make_ui_sound("UISndInvalidOp"); + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTCONF); + return true; + } +// [/RLVa:KB] + if (name.empty()) { name = LLTrans::getString("conference-title"); @@ -1194,8 +1217,11 @@ LLInventoryPanel* LLInventoryPanel::getActiveInventoryPanel(BOOL auto_open) active_inv_floaterp->setMinimized(FALSE); } } - else if (auto_open) +// else if (auto_open) +// [RLVa:KB] - Checked: 2012-05-15 (RLVa-1.4.6) + else if ( (auto_open) && (LLFloaterReg::canShowInstance(floater_inventory->getInstanceName())) ) { +// [/RLVa:KB] floater_inventory->openFloater(); res = inventory_panel->getActivePanel(); diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 5022dba934415c8dc27ac55b0cd90d0779afd035..2d9e61904bf4c09f0854b20eb51509beba97d692 100755 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -63,6 +63,9 @@ #include "llviewermenu.h" #include "llurllineeditorctrl.h" #include "llagentui.h" +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.0d) +#include "rlvhandler.h" +// [/RLVa:KB] //============================================================================ /* @@ -628,16 +631,31 @@ void LLLocationInputCtrl::reshape(S32 width, S32 height, BOOL called_from_parent void LLLocationInputCtrl::onInfoButtonClicked() { +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.4.5) | Added: RLVa-1.2.0 + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + return; +// [/RLVa:KB] + LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "agent")); } void LLLocationInputCtrl::onForSaleButtonClicked() { +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.4.5) | Added: RLVa-1.2.0 + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + return; +// [/RLVa:KB] + handle_buy_land(); } void LLLocationInputCtrl::onAddLandmarkButtonClicked() { +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.4.5) | Added: RLVa-1.2.0 + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + return; +// [/RLVa:KB] + LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos(); // Landmark exists, open it for preview and edit if(landmark && landmark->getUUID().notNull()) @@ -765,6 +783,10 @@ void LLLocationInputCtrl::onTextEditorRightClicked(S32 x, S32 y, MASK mask) void LLLocationInputCtrl::refresh() { +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.4.5) | Added: RLVa-1.2.0 + mInfoBtn->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); +// [/RLVa:KB] + refreshLocation(); // update location string refreshParcelIcons(); updateAddLandmarkButton(); // indicate whether current parcel has been landmarked @@ -1042,6 +1064,9 @@ void LLLocationInputCtrl::enableAddLandmarkButton(bool val) // depending on whether current parcel has been landmarked. void LLLocationInputCtrl::updateAddLandmarkButton() { +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.4.5) | Added: RLVa-1.2.0 + mAddLandmarkBtn->setVisible(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); +// [/RLVa:KB] enableAddLandmarkButton(LLLandmarkActions::hasParcelLandmark()); } void LLLocationInputCtrl::updateAddLandmarkTooltip() @@ -1071,6 +1096,9 @@ void LLLocationInputCtrl::updateContextMenu(){ { landmarkItem->setLabel(LLTrans::getString("EditLandmarkNavBarMenu")); } +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.4.5) | Added: RLVa-1.2.0 + landmarkItem->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); +// [/RLVa:KB] } } void LLLocationInputCtrl::updateWidgetlayout() @@ -1126,17 +1154,23 @@ void LLLocationInputCtrl::onLocationContextMenuItemClicked(const LLSD& userdata) } else if (item == "landmark") { - LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos(); - - if(!landmark) +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.4.5) | Added: RLVa-1.2.0 + if (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) { - LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "create_landmark")); - } - else - { - LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "landmark").with("id",landmark->getUUID())); - +// [/RLVa:KB] + LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos(); + + if(!landmark) + { + LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "create_landmark")); + } + else + { + LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "landmark").with("id",landmark->getUUID())); + } +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.0d) | Added: RLVa-1.2.0d } +// [/RLVa:KB] } else if (item == "cut") { diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index 06bf2944172ca8ba125d8b65b8e02169c65571bf..c2560eaf00b2eb0302a142422afa17a655aa337a 100755 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -61,6 +61,9 @@ #include "llui.h" #include "pipeline.h" #include "llviewershadermgr.h" +// [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0a) +#include "rlvhandler.h" +// [/RLVa:KB] const S32 NUM_AXES = 3; const S32 MOUSE_DRAG_SLOP = 2; // pixels diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp old mode 100755 new mode 100644 diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp index eb6591eb39eeeb544a601091b2fefd7584156626..38b00059f5db88c3f813009b426e6c212a4172f7 100755 --- a/indra/newview/llmoveview.cpp +++ b/indra/newview/llmoveview.cpp @@ -50,6 +50,9 @@ #include "llviewerparcelmgr.h" #include "llviewerregion.h" #include "lltooltip.h" +// [RLVa:KB] - Checked: 2010-03-07 (RLVa-1.2.0c) +#include "rlvhandler.h" +// [/RLVa:KB] // // Constants @@ -140,7 +143,10 @@ BOOL LLFloaterMove::postBuild() initMovementMode(); - LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(LLFloaterMove::sUpdateFlyingStatus); +// LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(LLFloaterMove::sUpdateFlyingStatus); +// [RLVa:KB] - Checked: 2011-05-27 (RLVa-1.4.0a) | Added: RLVa-1.4.0a + LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(LLFloaterMove::sUpdateMovementStatus); +// [/RLVa:KB] return TRUE; } @@ -317,23 +323,32 @@ void LLFloaterMove::setMovementMode(const EMovementMode mode) { case MM_RUN: gAgent.setAlwaysRun(); - gAgent.setRunning(); +// gAgent.setRunning(); break; case MM_WALK: gAgent.clearAlwaysRun(); - gAgent.clearRunning(); +// gAgent.clearRunning(); break; default: //do nothing for other modes (MM_FLY) break; } // tell the simulator. - gAgent.sendWalkRun(gAgent.getAlwaysRun()); - - updateButtonsWithMovementMode(mode); +// gAgent.sendWalkRun(gAgent.getAlwaysRun()); +// +// updateButtonsWithMovementMode(mode); +// +// bool bHideModeButtons = MM_FLY == mode +// || (isAgentAvatarValid() && gAgentAvatarp->isSitting()); +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + // Running may have been restricted so update walk-vs-run from the agent's actual running state + if ( (MM_WALK == mode) || (MM_RUN == mode) ) + mCurrentMode = (gAgent.getRunning()) ? MM_RUN : MM_WALK; - bool bHideModeButtons = MM_FLY == mode - || (isAgentAvatarValid() && gAgentAvatarp->isSitting()); + updateButtonsWithMovementMode(mCurrentMode); + + bool bHideModeButtons = (MM_FLY == mCurrentMode) || (isAgentAvatarValid() && gAgentAvatarp->isSitting()); +// [/RLVa:KB] showModeButtons(!bHideModeButtons); @@ -436,12 +451,23 @@ void LLFloaterMove::setModeTitle(const EMovementMode mode) } //static -void LLFloaterMove::sUpdateFlyingStatus() +//void LLFloaterMove::sUpdateFlyingStatus() +//{ +// LLFloaterMove *floater = LLFloaterReg::findTypedInstance<LLFloaterMove>("moveview"); +// if (floater) floater->mModeControlButtonMap[MM_FLY]->setEnabled(gAgent.canFly()); +// +//} +// [RLVa:KB] - Checked: 2011-05-27 (RLVa-1.4.0a) | Added: RLVa-1.4.0a +void LLFloaterMove::sUpdateMovementStatus() { - LLFloaterMove *floater = LLFloaterReg::findTypedInstance<LLFloaterMove>("moveview"); - if (floater) floater->mModeControlButtonMap[MM_FLY]->setEnabled(gAgent.canFly()); - + LLFloaterMove* pFloater = LLFloaterReg::findTypedInstance<LLFloaterMove>("moveview"); + if (pFloater) + { + pFloater->mModeControlButtonMap[MM_RUN]->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_ALWAYSRUN)); + pFloater->mModeControlButtonMap[MM_FLY]->setEnabled(gAgent.canFly()); + } } +// [/RLVa:KB] void LLFloaterMove::showModeButtons(BOOL bShow) { @@ -481,7 +507,10 @@ void LLFloaterMove::onOpen(const LLSD& key) showModeButtons(FALSE); } - sUpdateFlyingStatus(); +// sUpdateFlyingStatus(); +// [RLVa:KB] - Checked: 2011-05-27 (RLVa-1.4.0a) | Added: RLVa-1.4.0a + sUpdateMovementStatus(); +// [/RLVa:KB] } void LLFloaterMove::setModeButtonToggleState(const EMovementMode mode) @@ -672,10 +701,17 @@ LLPanelStandStopFlying* LLPanelStandStopFlying::getStandStopFlyingPanel() void LLPanelStandStopFlying::onStandButtonClick() { - LLFirstUse::sit(false); +// [RLVa:KB] - Checked: 2010-03-07 (RLVa-1.2.0c) | Added: RLVa-1.2.0a + if ( (!rlv_handler_t::isEnabled()) || (gRlvHandler.canStand()) ) + { + LLFirstUse::sit(false); - LLSelectMgr::getInstance()->deselectAllForStandingUp(); - gAgent.setControlFlags(AGENT_CONTROL_STAND_UP); + LLSelectMgr::getInstance()->deselectAllForStandingUp(); + gAgent.setControlFlags(AGENT_CONTROL_STAND_UP); + } +// [/RLVa:KB] +// LLSelectMgr::getInstance()->deselectAllForStandingUp(); +// gAgent.setControlFlags(AGENT_CONTROL_STAND_UP); setFocus(FALSE); // EXT-482 mStandButton->setVisible(FALSE); // force visibility changing to avoid seeing Stand & Move buttons at once. diff --git a/indra/newview/llmoveview.h b/indra/newview/llmoveview.h index c525d9dfdb6580d1c5bb1ea62c89fe01a3840cb1..6f42db76a9dbab95aa4a399ba5bba462c0817cc7 100755 --- a/indra/newview/llmoveview.h +++ b/indra/newview/llmoveview.h @@ -59,7 +59,10 @@ class LLFloaterMove static void enableInstance(BOOL bEnable); /*virtual*/ void onOpen(const LLSD& key); - static void sUpdateFlyingStatus(); +// static void sUpdateFlyingStatus(); +// [RLVa:KB] - Checked: 2011-05-27 (RLVa-1.4.0a) | Added: RLVa-1.4.0a + static void sUpdateMovementStatus(); +// [/RLVa:KB] protected: void turnLeft(); diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 08b5eaedbbe9d5d899324b90a8ab3fc00de98081..c505dab7493d18ff5187e9a499f501e29e6d0c49 100755 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -60,6 +60,9 @@ #include "llviewerwindow.h" #include "llworld.h" #include "llworldmapview.h" // shared draw code +// [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.0f) +#include "rlvhandler.h" +// [/RLVa:KB] static LLDefaultChildRegistry::Register<LLNetMap> r1("net_map"); @@ -349,7 +352,11 @@ void LLNetMap::draw() pos_map = globalPosToView(positions[i]); - bool show_as_friend = (LLAvatarTracker::instance().getBuddyInfo(uuid) != NULL); +// [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f + bool show_as_friend = (LLAvatarTracker::instance().getBuddyInfo(uuid) != NULL) && + (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)); +// [/RLVa:KB] +// bool show_as_friend = (LLAvatarTracker::instance().getBuddyInfo(uuid) != NULL); LLColor4 color = show_as_friend ? map_avatar_friend_color : map_avatar_color; @@ -601,11 +608,29 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, MASK mask ) // If the cursor is near an avatar on the minimap, a mini-inspector will be // shown for the avatar, instead of the normal map tooltip. - if (handleToolTipAgent(mClosestAgentToCursor)) +// if (handleToolTipAgent(mClosestAgentToCursor)) +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + if ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (handleToolTipAgent(mClosestAgentToCursor)) ) +// [/RLVa:KB] { return TRUE; } +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + LLStringUtil::format_map_t args; + + LLAvatarName avName; + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && + (mClosestAgentToCursor.notNull()) && (LLAvatarNameCache::get(mClosestAgentToCursor, &avName)) ) + { + args["[AGENT]"] = RlvStrings::getAnonym(avName) + "\n"; + } + else + { + args["[AGENT]"] = ""; + } +// [/RLVa:KB] + LLRect sticky_rect; std::string region_name; LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal( viewPosToGlobal( x, y ) ); @@ -617,14 +642,17 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, MASK mask ) sticky_rect.mRight = sticky_rect.mLeft + 2 * SLOP; sticky_rect.mTop = sticky_rect.mBottom + 2 * SLOP; - region_name = region->getName(); +// region_name = region->getName(); +// [RLVa:KB] - Checked: 2010-10-19 (RLVa-1.2.2b) | Modified: RLVa-1.2.2b + region_name = ((!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? region->getName() : RlvStrings::getString(RLV_STRING_HIDDEN_REGION)); +// [/RLVa:KB] if (!region_name.empty()) { region_name += "\n"; } } - LLStringUtil::format_map_t args; +// LLStringUtil::format_map_t args; args["[REGION]"] = region_name; std::string msg = mToolTipMsg; LLStringUtil::format(msg, args); diff --git a/indra/newview/llnotificationalerthandler.cpp b/indra/newview/llnotificationalerthandler.cpp index 58a9b01a45944df8e232110ac02650f7eee0a33d..9d2810cb37b06d9356df9f46780aba2051dd6583 100755 --- a/indra/newview/llnotificationalerthandler.cpp +++ b/indra/newview/llnotificationalerthandler.cpp @@ -38,6 +38,10 @@ #include "lltoastalertpanel.h" +// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) +#include "rlvactions.h" +// [/RLVa:KB] + using namespace LLNotificationsUI; //-------------------------------------------------------------------------- @@ -88,8 +92,19 @@ bool LLAlertHandler::processNotification(const LLNotificationPtr& notification) LLUUID from_id = notification->getPayload()["from_id"]; - // firstly create session... - LLHandlerUtil::spawnIMSession(name, from_id); +// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) + // Don't spawn an IM session for non-chat related events: + // - LLHandlerUtil::logToIMP2P() below will still be called with to_file_only == false + // - LLHandlerUtil::logToIM() will eventually be called as a result and without an open IM session it will log the + // same message as it would for an open session whereas to_file_only == true would take a different code path + if ( (RlvActions::hasOpenP2PSession(from_id)) || (RlvActions::canStartIM(from_id)) ) + { +// [/RLVa:KB] + // firstly create session... + LLHandlerUtil::spawnIMSession(name, from_id); +// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) + } +// [/RLVa:KB] // ...then log message to have IM Well notified about new message LLHandlerUtil::logToIMP2P(notification); diff --git a/indra/newview/llnotificationhandler.h b/indra/newview/llnotificationhandler.h index bff4efa9eaebc8393b0ae5e2fe9f11ce439bed71..0c8efe8166f82d8f227675e1a4d01c03977445d5 100755 --- a/indra/newview/llnotificationhandler.h +++ b/indra/newview/llnotificationhandler.h @@ -346,16 +346,23 @@ class LLHandlerUtil */ static void updateIMFLoaterMesages(const LLUUID& session_id); - /** - * Updates messages of visible IM floater. - */ - static void updateVisibleIMFLoaterMesages(const LLNotificationPtr& notification); +// /** +// * Updates messages of visible IM floater. +// */ +// static void updateVisibleIMFLoaterMesages(const LLNotificationPtr& notification); /** * Decrements counter of IM messages. */ static void decIMMesageCounter(const LLNotificationPtr& notification); +// [SL:KB] - Patch: UI-Notifications | Checked: 2011-04-11 (Catznip-2.5.0a) | Added: Catznip-2.5.0a + /** + * Checks whether the user has opted to embed (certain) notifications in IM sessions + */ + static bool canEmbedNotificationInIM(const LLNotificationPtr& notification); +// [/SL:KB] + }; } diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index ef4d7356166546ffb31b6639e053f291b6e08821..58bbe730741479250b0ee96c309817b031260cf4 100755 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -265,15 +265,15 @@ void LLHandlerUtil::updateIMFLoaterMesages(const LLUUID& session_id) } } -// static -void LLHandlerUtil::updateVisibleIMFLoaterMesages(const LLNotificationPtr& notification) -{ - const std::string name = LLHandlerUtil::getSubstitutionName(notification); - LLUUID from_id = notification->getPayload()["from_id"]; - LLUUID session_id = spawnIMSession(name, from_id); - - updateIMFLoaterMesages(session_id); -} +//// static +//void LLHandlerUtil::updateVisibleIMFLoaterMesages(const LLNotificationPtr& notification) +//{ +// const std::string name = LLHandlerUtil::getSubstitutionName(notification); +// LLUUID from_id = notification->getPayload()["from_id"]; +// LLUUID session_id = spawnIMSession(name, from_id); +// +// updateIMFLoaterMesages(session_id); +//} // static void LLHandlerUtil::decIMMesageCounter(const LLNotificationPtr& notification) diff --git a/indra/newview/llnotificationofferhandler.cpp b/indra/newview/llnotificationofferhandler.cpp index 2657b84ef30379962260d45674ee1bd7d33604d2..dc16aea84d6f79a0e00ac834603ffd917a810f5a 100755 --- a/indra/newview/llnotificationofferhandler.cpp +++ b/indra/newview/llnotificationofferhandler.cpp @@ -36,6 +36,9 @@ #include "llscriptfloater.h" #include "llimview.h" #include "llnotificationsutil.h" +// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) +#include "rlvactions.h" +// [/RLVa:KB] using namespace LLNotificationsUI; @@ -108,9 +111,21 @@ bool LLOfferHandler::processNotification(const LLNotificationPtr& notification) notification->playSound(); } - LLHandlerUtil::spawnIMSession(name, from_id); - LLHandlerUtil::addNotifPanelToIM(notification); - +// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) + // Don't spawn an IM session for non-chat related events + if ( (RlvActions::hasOpenP2PSession(from_id)) || (RlvActions::canStartIM(from_id)) ) + { +// [/RLVa:KB] + LLHandlerUtil::spawnIMSession(name, from_id); + LLHandlerUtil::addNotifPanelToIM(notification); +// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) + } + else + { + // Since we didn't add this notification to an IM session we want it to get routed to the notification syswell + add_notif_to_im = false; + } +// [/RLVa:KB] } if (!notification->canShowToast()) @@ -177,9 +192,18 @@ bool LLOfferHandler::processNotification(const LLNotificationPtr& notification) } else { - if (notification->canLogToIM() - && notification->hasFormElements() - && !LLHandlerUtil::isIMFloaterOpened(notification)) +// if (notification->canLogToIM() +// && notification->hasFormElements() +// && !LLHandlerUtil::isIMFloaterOpened(notification)) +// [SL:KB] - Patch: UI-Notifications | Checked: 2013-05-09 (Catznip-3.5) + // The above test won't necessarily tell us whether the notification went into an IM or to the notification syswell + // -> the one and only time we need to decrease the unread IM count is when we've clicked any of the buttons on the *toast* + // -> since LLIMFloater::updateMessages() hides the toast when we open the IM (which resets the unread count to 0) we should + // *only* decrease the unread IM count if there's a visible toast since the unread count will be at 0 otherwise anyway + LLScreenChannel* pChannel = dynamic_cast<LLScreenChannel*>(mChannel.get()); + LLToast* pToast = (pChannel) ? pChannel->getToastByNotificationID(notification->getID()) : NULL; + if ( (pToast) && (!pToast->getCanBeStored()) ) +// [/SL:KB] { LLHandlerUtil::decIMMesageCounter(notification); } diff --git a/indra/newview/llpanelappearancetab.cpp b/indra/newview/llpanelappearancetab.cpp index 8fa8867c696fca1358eda2c37a006b8899bac65c..fdb331163b2c8e1487c143a4ec8657485cace9ce 100755 --- a/indra/newview/llpanelappearancetab.cpp +++ b/indra/newview/llpanelappearancetab.cpp @@ -32,6 +32,10 @@ #include "llinventoryfunctions.h" #include "llinventorymodel.h" #include "llviewerinventory.h" +// [RLVa:KB] - Checked: 2012-07-08 (RLVa-1.4.7) +#include "rlvcommon.h" +#include "rlvhandler.h" +// [/RLVa:KB] //virtual bool LLPanelAppearanceTab::canTakeOffSelected() @@ -46,6 +50,11 @@ bool LLPanelAppearanceTab::canTakeOffSelected() LLViewerInventoryItem* item = gInventory.getItem(*it); if (!item) continue; +// [RLVa:KB] - Checked: 2012-07-08 (RLVa-1.4.7) + if ( (rlv_handler_t::isEnabled()) && (rlvPredCanNotRemoveItem(item)) ) + return false; +// [/RLVa:KB] + if (is_worn(NULL, item)) return true; } return false; diff --git a/indra/newview/llpanelcontents.cpp b/indra/newview/llpanelcontents.cpp index 1a427338e5ae54c2cd11b41d743538bc1010388a..5c8b9746c7148a422beaf8572c7833341ffeb364 100755 --- a/indra/newview/llpanelcontents.cpp +++ b/indra/newview/llpanelcontents.cpp @@ -59,6 +59,10 @@ #include "llviewerregion.h" #include "llviewerwindow.h" #include "llworld.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] // // Imported globals @@ -118,6 +122,25 @@ void LLPanelContents::getState(LLViewerObject *objectp ) && ( objectp->permYouOwner() || ( !group_id.isNull() && gAgent.isInGroup(group_id) ))); // solves SL-23488 BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME ); +// [RLVa:KB] - Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-1.0.5a + if ( (rlv_handler_t::isEnabled()) && (editable) ) + { + // Don't allow creation of new scripts if it's non-detachable + if (objectp->isAttachment()) + editable = !gRlvAttachmentLocks.isLockedAttachment(objectp->getRootEdit()); + + // Don't allow creation of new scripts if we're @unsit=n or @sittp=n restricted and we're sitting on the selection + if ( (editable) && ((gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP))) ) + { + // Only check the first (non-)root object because nothing else would result in enabling the button (see below) + LLViewerObject* pObj = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(TRUE); + + editable = + (pObj) && (isAgentAvatarValid()) && ((!gAgentAvatarp->isSitting()) || (gAgentAvatarp->getRoot() != pObj->getRootEdit())); + } + } +// [/RLVa:KB] + // Edit script button - ok if object is editable and there's an unambiguous destination for the object. getChildView("button new script")->setEnabled( editable && @@ -154,6 +177,21 @@ void LLPanelContents::onClickNewScript(void *userdata) LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok); if(object) { +// [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c) | Modified: RLVa-1.0.5a + if (rlv_handler_t::isEnabled()) // Fallback code [see LLPanelContents::getState()] + { + if (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) + { + return; // Disallow creating new scripts in a locked attachment + } + else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP)) ) + { + if ( (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) && (gAgentAvatarp->getRoot() == object->getRootEdit()) ) + return; // .. or in a linkset the avie is sitting on under @unsit=n/@sittp=n + } + } +// [/RLVa:KB] + LLPermissions perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); perm.initMasks( diff --git a/indra/newview/llpanelland.cpp b/indra/newview/llpanelland.cpp index 5321ebc7773d5d8d825885840d38f06f57ab3522..e54b2401a2c81669f983c7c2473859e02ea9a1cc 100755 --- a/indra/newview/llpanelland.cpp +++ b/indra/newview/llpanelland.cpp @@ -44,6 +44,10 @@ #include "lluictrlfactory.h" +// [RLVa:KB] +#include "rlvhandler.h" +// [/RLVa:KB] + LLPanelLandSelectObserver* LLPanelLandInfo::sObserver = NULL; LLPanelLandInfo* LLPanelLandInfo::sInstance = NULL; @@ -224,6 +228,14 @@ void LLPanelLandInfo::refresh() //static void LLPanelLandInfo::onClickClaim() { +// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) +/* + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { + return; + } +*/ +// [/RLVa:KB] LLViewerParcelMgr::getInstance()->startBuyLand(); } diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index 88400e4ef2f0e8ba1b68ad735c0b961847e7b80f..f7e06a99d80fb557ffc97d3aba8d2e4d53edf9d7 100755 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -56,6 +56,9 @@ #include "lltoggleablemenu.h" #include "llviewermenu.h" #include "llviewerregion.h" +// [RLVa:KB] +#include "rlvhandler.h" +// [/RLVa:KB] // Not yet implemented; need to remove buildPanel() from constructor when we switch //static LLRegisterPanelClassWrapper<LLLandmarksPanel> t_landmarks("panel_landmarks"); @@ -766,15 +769,22 @@ void LLLandmarksPanel::onAddAction(const LLSD& userdata) const std::string command_name = userdata.asString(); if("add_landmark" == command_name) { - LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos(); - if(landmark) +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) { - LLNotificationsUtil::add("LandmarkAlreadyExists"); - } - else - { - LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "create_landmark")); +// [/RLVa:KB] + LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos(); + if(landmark) + { + LLNotificationsUtil::add("LandmarkAlreadyExists"); + } + else + { + LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "create_landmark")); + } +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 } +// [/RLVa:KB] } else if ("category" == command_name) { @@ -1040,6 +1050,12 @@ bool LLLandmarksPanel::isActionEnabled(const LLSD& userdata) const } return false; } +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + else if("add_landmark" == command_name) + { + return !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC); + } +// [/RLVa:KB] else { llwarns << "Unprocessed command has come: " << command_name << llendl; diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp index 25ef9a3d6a7f280efb1e2452c5e60382b0afbb0e..133ed21e7e0618d0f562a1c59b3c8e7b9d34524b 100755 --- a/indra/newview/llpanelobject.cpp +++ b/indra/newview/llpanelobject.cpp @@ -66,6 +66,10 @@ #include "llviewercontrol.h" #include "lluictrlfactory.h" //#include "llfirstuse.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "llvoavatarself.h" +// [/RLVa:KB] #include "lldrawpool.h" @@ -356,6 +360,14 @@ void LLPanelObject::getState( ) enable_rotate = FALSE; } +// [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c) | Modified: RLVa-1.0.0g + if ( (rlv_handler_t::isEnabled()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP))) ) + { + if ( (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) && (gAgentAvatarp->getRoot() == objectp->getRootEdit()) ) + enable_move = enable_scale = enable_rotate = FALSE; + } +// [/RLVa:KB] + LLVector3 vec; if (enable_move) { diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index d7130820ab0b6b0bd6e4a1d0905946edccce31fe..be7fd6fe33023bc8127a9d1d5629374464059433 100755 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -66,6 +66,10 @@ #include "llviewerregion.h" #include "llviewerobjectlist.h" #include "llviewermessage.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] const LLColor4U DEFAULT_WHITE(255, 255, 255); @@ -377,8 +381,16 @@ void LLTaskInvFVBridge::openItem() BOOL LLTaskInvFVBridge::isItemRenameable() const { - if(gAgent.isGodlike()) return TRUE; +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.5a LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); + if ( (rlv_handler_t::isEnabled()) && (object) && (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) ) + { + return FALSE; + } +// [/RLVa:KB] + + if(gAgent.isGodlike()) return TRUE; +// LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); if(object) { LLInventoryItem* item = (LLInventoryItem*)(object->getInventoryObject(mUUID)); @@ -393,7 +405,15 @@ BOOL LLTaskInvFVBridge::isItemRenameable() const BOOL LLTaskInvFVBridge::renameItem(const std::string& new_name) { +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.5a LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); + if ( (rlv_handler_t::isEnabled()) && (object) && (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) ) + { + return FALSE; + } +// [/RLVa:KB] + +// LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); if(object) { LLViewerInventoryItem* item = NULL; @@ -420,12 +440,45 @@ BOOL LLTaskInvFVBridge::isItemMovable() const // return TRUE; //} //return FALSE; +// [RLVa:KB] - Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-1.0.5a + if (rlv_handler_t::isEnabled()) + { + const LLViewerObject* pObj = gObjectList.findObject(mPanel->getTaskUUID()); + if (pObj) + { + if (gRlvAttachmentLocks.isLockedAttachment(pObj->getRootEdit())) + { + return FALSE; + } + else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP)) ) + { + if ( (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) && (gAgentAvatarp->getRoot() == pObj->getRootEdit()) ) + return FALSE; + } + } + } +// [/RLVa:KB] return TRUE; } BOOL LLTaskInvFVBridge::isItemRemovable() const { const LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); +// [RLVa:KB] - Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-1.0.5a + if ( (object) && (rlv_handler_t::isEnabled()) ) + { + if (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) + { + return FALSE; + } + else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP)) ) + { + if ( (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) && (gAgentAvatarp->getRoot() == object->getRootEdit()) ) + return FALSE; + } + } +// [/RLVa:KB] + if(object && (object->permModify() || object->permYouOwner())) { @@ -574,6 +627,13 @@ BOOL LLTaskInvFVBridge::startDrag(EDragAndDropType* type, LLUUID* id) const const LLPermissions& perm = inv->getPermissions(); bool can_copy = gAgent.allowOperation(PERM_COPY, perm, GP_OBJECT_MANIPULATE); +// [RLVa:KB] - Checked: 2009-10-10 (RLVa-1.2.1f) | Modified: RLVa-1.0.5a + // Kind of redundant due to the note below, but in case that ever gets fixed + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) ) + { + return FALSE; + } +// [/RLVa:KB] if (object->isAttachment() && !can_copy) { //RN: no copy contents of attachments cannot be dragged out @@ -693,16 +753,41 @@ void LLTaskInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { disabled_items.push_back(std::string("Task Open")); } +// [RLVa:KB] - Checked: 2010-03-01 (RLVa-1.2.0b) | Modified: RLVa-1.1.0a + else if (rlv_handler_t::isEnabled()) + { + LLViewerObject* pAttachObj = gObjectList.findObject(mPanel->getTaskUUID()); + bool fLocked = (pAttachObj) ? gRlvAttachmentLocks.isLockedAttachment(pAttachObj->getRootEdit()) : false; + if ( ((LLAssetType::AT_NOTECARD == item->getType()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_VIEWNOTE)) || (fLocked))) || + ((LLAssetType::AT_LSL_TEXT == item->getType()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_VIEWSCRIPT)) || (fLocked))) || + ((LLAssetType::AT_TEXTURE == item->getType()) && (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWTEXTURE))) ) + { + disabled_items.push_back(std::string("Task Open")); + } + } +// [/RLVa:KB] } items.push_back(std::string("Task Properties")); - if(isItemRenameable()) +// if(isItemRenameable()) +// { +// items.push_back(std::string("Task Rename")); +// } +// if(isItemRemovable()) +// { +// items.push_back(std::string("Task Remove")); +// } +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Added: RLVa-1.2.1f + items.push_back(std::string("Task Rename")); + items.push_back(std::string("Task Remove")); + if (!isItemRenameable()) { - items.push_back(std::string("Task Rename")); + disabled_items.push_back(std::string("Task Rename")); } - if(isItemRemovable()) + if (!isItemRemovable()) { - items.push_back(std::string("Task Remove")); + disabled_items.push_back(std::string("Task Remove")); } +// [/RLVa:KB] hide_context_entries(menu, items, disabled_items); } @@ -1101,6 +1186,13 @@ void LLTaskLSLBridge::openItem() { return; } +// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.1.0a + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) ) + { + RlvUtil::notifyBlockedViewXXX(LLAssetType::AT_SCRIPT); + return; + } +// [/RLVa:KB] if (object->permModify() || gAgent.isGodlike()) { LLLiveLSLEditor* preview = LLFloaterReg::showTypedInstance<LLLiveLSLEditor>("preview_scriptedit", LLSD(mUUID), TAKE_FOCUS_YES); @@ -1159,6 +1251,13 @@ void LLTaskNotecardBridge::openItem() { return; } +// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0b + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) ) + { + RlvUtil::notifyBlockedViewXXX(LLAssetType::AT_NOTECARD); + return; + } +// [/RLVa:KB] if(object->permModify() || gAgent.isGodlike()) { LLPreviewNotecard* preview = LLFloaterReg::showTypedInstance<LLPreviewNotecard>("preview_notecard", LLSD(mUUID), TAKE_FOCUS_YES); diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index c09d4393c81c79e3f9f2a5a8e9fd9fc2e0c7d92b..64f9bb6036b4c978a4d14ed26764d3ba99d1a1e0 100755 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -73,6 +73,9 @@ #include "llwearableitemslist.h" #include "llwearabletype.h" #include "llweb.h" +// [RLVa:KB] - Checked: 2010-09-16 (RLVa-1.2.1a) +#include "rlvhandler.h" +// [/RLVa:KB] static LLRegisterPanelClassWrapper<LLPanelOutfitEdit> t_outfit_edit("panel_outfit_edit"); @@ -600,6 +603,10 @@ void LLPanelOutfitEdit::toggleAddWearablesPanel() void LLPanelOutfitEdit::showAddWearablesPanel(bool show_add_wearables) { +// [RLVa:KB] - Checked: 2010-09-16 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + show_add_wearables = (show_add_wearables) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWINV)); +// [/RLVa:KB] + mAddWearablesPanel->setVisible(show_add_wearables); getChild<LLUICtrl>("show_add_wearables_btn")->setValue(show_add_wearables); diff --git a/indra/newview/llpaneloutfitsinventory.h b/indra/newview/llpaneloutfitsinventory.h index a7917b457c95934671c3aeadd407fe9821f82d86..77c8a472e078701b8831cbad666783376e7ddf57 100755 --- a/indra/newview/llpaneloutfitsinventory.h +++ b/indra/newview/llpaneloutfitsinventory.h @@ -56,6 +56,12 @@ class LLPanelOutfitsInventory : public LLPanel static LLSidepanelAppearance* getAppearanceSP(); +// [RLVa:KB] - Checked: 2010-08-24 (RLVa-1.4.0a) | Added: RLVa-1.2.1a + LLTabContainer* getAppearanceTabs() { return mAppearanceTabs; } + LLOutfitsList* getMyOutfitsPanel() { return mMyOutfitsPanel; } + LLPanelWearing* getCurrentOutfitPanel() { return mCurrentOutfitPanel; } +// [/RLVa:KB] + static LLPanelOutfitsInventory* findInstance(); protected: diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index f551fc96eed45eb26e32bd38619887de1734ca37..b01c196c2d72734b64e7acc3bd1d25790e626921 100755 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -74,6 +74,10 @@ #include "llagentui.h" #include "llslurl.h" +// [RLVa:KB] - Checked: 2010-06-04 (RLVa-1.2.2a) +#include "rlvhandler.h" +// [/RLVa:KB] + #define FRIEND_LIST_UPDATE_TIMEOUT 0.5 #define NEARBY_LIST_UPDATE_INTERVAL 1 @@ -614,6 +618,9 @@ BOOL LLPanelPeople::postBuild() mNearbyList->setNoItemsMsg(getString("no_one_near")); mNearbyList->setNoFilteredItemsMsg(getString("no_one_filtered_near")); mNearbyList->setShowIcons("NearbyListShowIcons"); +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d + mNearbyList->setRlvCheckShowNames(true); +// [/RLVa:KB] mMiniMap = (LLNetMap*)getChildView("Net Map",true); mMiniMap->setToolTipMsg(gSavedSettings.getBOOL("DoubleClickTeleport") ? getString("AltMiniMapToolTipMsg") : getString("MiniMapToolTipMsg")); @@ -883,6 +890,9 @@ void LLPanelPeople::updateFacebookList(bool visible) void LLPanelPeople::updateButtons() { std::string cur_tab = getActiveTabName(); +// [RLVa:KB] - Checked: 2013-05-06 (RLVa-1.4.9) + bool nearby_tab_active = (cur_tab == NEARBY_TAB_NAME); +// [/RLVa:KB] bool friends_tab_active = (cur_tab == FRIENDS_TAB_NAME); bool group_tab_active = (cur_tab == GROUP_TAB_NAME); //bool recent_tab_active = (cur_tab == RECENT_TAB_NAME); @@ -923,6 +933,11 @@ void LLPanelPeople::updateButtons() if (cur_panel->hasChild("add_friend_btn", TRUE)) cur_panel->getChildView("add_friend_btn")->setEnabled(item_selected && !is_friend && !is_self); +// cur_panel->getChildView("add_friend_btn")->setEnabled(!is_friend); +// [RLVa:KB] - Checked: 2010-07-20 (RLVa-1.2.2a) | Added: RLVa-1.2.0h +// cur_panel->getChildView("add_friend_btn")->setEnabled( +// !is_friend && ((!nearby_tab_active) || (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)))); +// [/RLBa:KB] if (friends_tab_active) { cur_panel->getChildView("friends_del_btn")->setEnabled(multiple_selected); @@ -934,6 +949,13 @@ void LLPanelPeople::updateButtons() } } } + +// [RLVa:KB] - Checked: 2010-06-04 (RLVa-1.2.2a) | Modified: RLVa-1.2.0d + if ( (nearby_tab_active) && (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ) + { + item_selected = multiple_selected = false; + } +// [/RLBa:KB] } std::string LLPanelPeople::getActiveTabName() const diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index c7141f36eeaec2c4a8e0e03de711b57c2f97fddc..9f906da95655e2e93d3537627d083536a3348e91 100755 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -58,6 +58,10 @@ class LLPanelPeople bool mTryToConnectToFbc; +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.0d) | Added: RLVa-1.2.0d + LLAvatarList* getNearbyList() { return mNearbyList; } +// [/RLVa:KB] + // internals class Updater; diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp index 131e8e9359122b1a9d0a701a2d4654590845d2b7..eb574f564d3f1f6b026900f9f08f4cbbac9d36b7 100755 --- a/indra/newview/llpanelpermissions.cpp +++ b/indra/newview/llpanelpermissions.cpp @@ -63,7 +63,10 @@ #include "roles_constants.h" #include "llgroupactions.h" #include "lltrans.h" - +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.2a) +#include "llslurl.h" +#include "rlvhandler.h" +// [/RLVa:KB] U8 string_value_to_click_action(std::string p_value); std::string click_action_to_string_value( U8 action); @@ -365,11 +368,18 @@ void LLPanelPermissions::refresh() // Update creator text field getChildView("Creator:")->setEnabled(TRUE); +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + BOOL creators_identical = FALSE; +// [/RLVa:KB] std::string creator_name; - LLSelectMgr::getInstance()->selectGetCreator(mCreatorID, creator_name); +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + creators_identical = LLSelectMgr::getInstance()->selectGetCreator(mCreatorID, creator_name); +// [/RLVa:KB] +// LLSelectMgr::getInstance()->selectGetCreator(mCreatorID, creator_name); - getChild<LLUICtrl>("Creator Name")->setValue(creator_name); - getChildView("Creator Name")->setEnabled(TRUE); +// getChild<LLUICtrl>("Creator Name")->setValue(creator_name); +// getChildView("Creator Name")->setEnabled(TRUE); +// [RLVa:KB] - Moved further down to avoid an annoying flicker when the text is set twice in a row // Update owner text field getChildView("Owner:")->setEnabled(TRUE); @@ -397,8 +407,28 @@ void LLPanelPermissions::refresh() } } } +// getChild<LLUICtrl>("Owner Name")->setValue(owner_name); +// getChildView("Owner Name")->setEnabled(TRUE); +// [RLVa:KB] - Moved further down to avoid an annoying flicker when the text is set twice in a row + +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + { + // Only anonymize the creator if all of the selection was created by the same avie who's also the owner or they're a nearby avie + if ( (creators_identical) && (mCreatorID != gAgent.getID()) && ((mCreatorID == mOwnerID) || (RlvUtil::isNearbyAgent(mCreatorID))) ) + creator_name = LLSLURL("agent", mCreatorID, "rlvanonym").getSLURLString(); + + // Only anonymize the owner name if all of the selection is owned by the same avie and isn't group owned + if ( (owners_identical) && (!LLSelectMgr::getInstance()->selectIsGroupOwned()) && (mOwnerID != gAgent.getID()) ) + owner_name = LLSLURL("agent", mOwnerID, "rlvanonym").getSLURLString(); + } + + getChild<LLUICtrl>("Creator Name")->setValue(creator_name); + getChildView("Creator Name")->setEnabled(TRUE); + getChild<LLUICtrl>("Owner Name")->setValue(owner_name); getChildView("Owner Name")->setEnabled(TRUE); +// [/RLVa:KB] // update group text field getChildView("Group:")->setEnabled(TRUE); diff --git a/indra/newview/llpanelplaceprofile.cpp b/indra/newview/llpanelplaceprofile.cpp index 5d9971c16c14ad562dc7a8e9aaa32b42bbf453c0..e91c7db04a8800ec43bad01c8ee12303eb803e2f 100755 --- a/indra/newview/llpanelplaceprofile.cpp +++ b/indra/newview/llpanelplaceprofile.cpp @@ -52,6 +52,9 @@ #include "llviewercontrol.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" +// [RLVa:KB] - Checked: 2010-09-02 (RLVa-1.2.1b) +#include "rlvhandler.h" +// [/RLVa:KB] static LLRegisterPanelClassWrapper<LLPanelPlaceProfile> t_place_profile("panel_place_profile"); @@ -590,7 +593,10 @@ void LLPanelPlaceProfile::displaySelectedParcelInfo(LLParcel* parcel, mLastSelectedRegionID = region->getRegionID(); LLPanelPlaceInfo::processParcelInfo(parcel_data); - mYouAreHerePanel->setVisible(is_current_parcel); +// mYouAreHerePanel->setVisible(is_current_parcel); +// [RLVa:KB] - Checked: 2010-09-02 (RLVa-1.4.5) | Added: RLVa-1.2.1 + mYouAreHerePanel->setVisible(is_current_parcel && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC))); +// [/RLVa:KB] getChild<LLAccordionCtrlTab>("sales_tab")->setVisible(for_sale); } @@ -657,6 +663,9 @@ void LLPanelPlaceProfile::updateYouAreHereBanner(void* userdata) BOOL display_banner = gAgent.getRegion()->getRegionID() == self->mLastSelectedRegionID && LLAgentUI::checkAgentDistance(self->mPosRegion, radius); - self->mYouAreHerePanel->setVisible(display_banner); +// self->mYouAreHerePanel->setVisible(display_banner); +// [RLVa:KB] - Checked: 2010-09-02 (RLVa-1.4.5) | Added: RLVa-1.2.1 + self->mYouAreHerePanel->setVisible(display_banner && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC))); +// [/RLVa:KB] } } diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h index d97f60ed229ab16320932951e9a13c896e9b7177..63690c0e533b961dcbea164b4130a660b4065944 100755 --- a/indra/newview/llpanelprofile.h +++ b/indra/newview/llpanelprofile.h @@ -52,13 +52,17 @@ class LLPanelProfile : public LLPanel S32 notifyParent(const LLSD& info); +// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.0f) | Added: RVLa-1.2.0f + const LLUUID& getAvatarId() const { return mAvatarId; } +// [/RLVa:KB] + protected: LLPanelProfile(); virtual void onTabSelected(const LLSD& param); - const LLUUID& getAvatarId() { return mAvatarId; } +// const LLUUID& getAvatarId() { return mAvatarId; } void setAvatarId(const LLUUID& avatar_id) { mAvatarId = avatar_id; } diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp index 9dd665198f6b7d165e505c14ff7113c126fd943f..c13da486ed0117f67f3a4c45fcd96908501cd627 100755 --- a/indra/newview/llpaneltopinfobar.cpp +++ b/indra/newview/llpaneltopinfobar.cpp @@ -44,6 +44,9 @@ #include "llviewermenu.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 +#include "rlvhandler.h" +// [/RLVa:KB] class LLPanelTopInfoBar::LLParcelChangeObserver : public LLParcelObserver { @@ -452,28 +455,47 @@ void LLPanelTopInfoBar::onContextMenuItemClicked(const LLSD::String& item) { if (item == "landmark") { - LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos(); - - if(landmark == NULL) - { - LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "create_landmark")); - } - else +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) { - LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "landmark").with("id",landmark->getUUID())); +// [/RLVa:KB] + LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos(); + + if(landmark == NULL) + { + LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "create_landmark")); + } + else + { + LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "landmark").with("id",landmark->getUUID())); + } +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 } +// [/RLVa:KB] } else if (item == "copy") { - LLSLURL slurl; - LLAgentUI::buildSLURL(slurl, false); - LLUIString location_str(slurl.getSLURLString()); +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { +// [/RLVa:KB] + LLSLURL slurl; + LLAgentUI::buildSLURL(slurl, false); + LLUIString location_str(slurl.getSLURLString()); - LLClipboard::instance().copyToClipboard(location_str,0,location_str.length()); + LLClipboard::instance().copyToClipboard(location_str,0,location_str.length()); +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + } +// [/RLVa:KB] } } void LLPanelTopInfoBar::onInfoButtonClicked() { +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + return; +// [/RLVa:KB] + LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "agent")); } diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index aa3ed22bee8b7b089e559e9187c0f0391a5da882..df39e4b8f2c02d20b0dfc7893a2891be779d720f 100755 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -40,6 +40,10 @@ #include "llwearableitemslist.h" #include "llsdserialize.h" #include "llclipboard.h" +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) +#include "rlvcommon.h" +#include "rlvhandler.h" +// [/RLVa:KB] // Context menu and Gear menu helper. static void edit_outfit() @@ -110,6 +114,9 @@ class LLWearingContextMenu : public LLListContextMenu bool bp_selected = false; // true if body parts selected bool clothes_selected = false; bool attachments_selected = false; +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + S32 rlv_locked_count = 0; +// [/RLVa:KB] // See what types of wearables are selected. for (uuid_vec_t::const_iterator it = mUUIDs.begin(); it != mUUIDs.end(); ++it) @@ -135,14 +142,27 @@ class LLWearingContextMenu : public LLListContextMenu { attachments_selected = true; } +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + if ( (rlv_handler_t::isEnabled()) && (!rlvPredCanRemoveItem(item)) ) + { + rlv_locked_count++; + } +// [/RLVa:KB] } // Enable/disable some menu items depending on the selection. +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + bool rlv_blocked = (mUUIDs.size() == rlv_locked_count); +// [/RLVa:KB] bool allow_detach = !bp_selected && !clothes_selected && attachments_selected; bool allow_take_off = !bp_selected && clothes_selected && !attachments_selected; menu->setItemVisible("take_off", allow_take_off); menu->setItemVisible("detach", allow_detach); +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + menu->setItemEnabled("take_off", !rlv_blocked); + menu->setItemEnabled("detach", !rlv_blocked); +// [/RLVa:KB] menu->setItemVisible("edit_outfit_separator", allow_take_off || allow_detach); } }; diff --git a/indra/newview/llparcelselection.h b/indra/newview/llparcelselection.h index 1cbdfc6f74bd5eeeedfccdeb5845b240c6ab9a19..b2d64b2d6c4c54266091686eb9f1f29dad97f99c 100755 --- a/indra/newview/llparcelselection.h +++ b/indra/newview/llparcelselection.h @@ -45,7 +45,10 @@ class LLParcelSelection : public LLRefCount // this can return NULL at any time, as parcel selection // might have been invalidated. - LLParcel* getParcel() { return mParcel; } +// [RLVa:KB] - Checked: 2012-02-09 (RLVa-1.4.5) | Modified: RLVa-1.4.5 + LLParcel* getParcel() const { return mParcel; } +// [/RLVa:KB] +// LLParcel* getParcel() { return mParcel; } // Return the number of grid units that are owned by you within // the selection (computed by server). diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index e533be7f246da3ab3393f3412eaab438afdf1f3e..7e23613d183f21833d0755124c88b236c3361638 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -87,6 +87,10 @@ #include "llviewercontrol.h" #include "llappviewer.h" #include "llfloatergotoline.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] const std::string HELLO_LSL = "default\n" @@ -1978,6 +1982,14 @@ void LLLiveLSLEditor::onRunningCheckboxClicked( LLUICtrl*, void* userdata ) //self->mRunningCheckbox->get(); if( object ) { +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.5a + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) ) + { + RlvUtil::notifyBlockedGeneric(); + return; + } +// [/RLVa:KB] + LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_SetScriptRunning); msg->nextBlockFast(_PREHASH_AgentData); @@ -2003,6 +2015,14 @@ void LLLiveLSLEditor::onReset(void *userdata) LLViewerObject* object = gObjectList.findObject( self->mObjectUUID ); if(object) { +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.5a + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) ) + { + RlvUtil::notifyBlockedGeneric(); + return; + } +// [/RLVa:KB] + LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ScriptReset); msg->nextBlockFast(_PREHASH_AgentData); @@ -2120,6 +2140,14 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/) return; } +// [RLVa:KB] - Checked: 2010-11-25 (RLVa-1.2.2b) | Modified: RLVa-1.2.2b + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.isLockedAttachment(object->getRootEdit())) ) + { + RlvUtil::notifyBlockedGeneric(); + return; + } +// [/RLVa:KB] + // get the latest info about it. We used to be losing the script // name on save, because the viewer object version of the item, // and the editor version would get out of synch. Here's a good @@ -2394,6 +2422,7 @@ void LLLiveLSLEditor::onLoad(void* userdata) void LLLiveLSLEditor::onSave(void* userdata, BOOL close_after_save) { LLLiveLSLEditor* self = (LLLiveLSLEditor*)userdata; + self->mCloseAfterSave = close_after_save; self->saveIfNeeded(); } diff --git a/indra/newview/llscreenchannel.cpp b/indra/newview/llscreenchannel.cpp index 168a941ec379fe10092caa913a4c5bfbafafe202..5d78081e65d8ed0787a8a32d03566fbb522db261 100755 --- a/indra/newview/llscreenchannel.cpp +++ b/indra/newview/llscreenchannel.cpp @@ -1104,8 +1104,17 @@ LLToast* LLScreenChannel::getToastByNotificationID(LLUUID id) std::vector<ToastElem>::iterator it = find(mStoredToastList.begin(), mStoredToastList.end(), id); +// if (it == mStoredToastList.end()) +// return NULL; +// [SL:KB] - Patch: UI-Notifications | Checked: 2011-04-11 (Catznip-2.5.0a) | Modified: Catznip-2.5.0a if (it == mStoredToastList.end()) - return NULL; + { + // If we can't find it among the stored toasts then widen it to "all visible toasts" + it = find(mToastList.begin(), mToastList.end(), id); + if (it == mToastList.end()) + return NULL; + } +// [/SL:KB] return it->getToast(); } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 7b397d46f31d501393dd497be626cac5b3b2f20c..a98c3fe9d66c126391297773a5506fa6618807fe 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -92,6 +92,9 @@ #include "pipeline.h" #include "llviewershadermgr.h" #include "llpanelface.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +// [/RLVa:KB] #include "llglheaders.h" LLViewerObject* getSelectedParentObject(LLViewerObject *object) ; @@ -655,6 +658,16 @@ bool LLSelectMgr::enableLinkObjects() new_value = LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, firstonly); } } +// [RLVa:KB] - Checked: 2011-03-19 (RLVa-1.3.0f) | Modified: RLVa-0.2.0g + if ( (new_value) && ((rlv_handler_t::isEnabled()) && (!gRlvHandler.canStand())) ) + { + // Allow only if the avie isn't sitting on any of the selected objects + LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection(); + RlvSelectIsSittingOn f(gAgentAvatarp); + if (hSel->getFirstRootNode(&f, TRUE) != NULL) + new_value = false; + } +// [/RLVa:KB] return new_value; } @@ -667,7 +680,16 @@ bool LLSelectMgr::enableUnlinkObjects() first_editable_object && !first_editable_object->isAttachment() && !first_editable_object->isPermanentEnforced() && ((root_object == NULL) || !root_object->isPermanentEnforced()); - +// [RLVa:KB] - Checked: 2011-03-19 (RLVa-1.3.0f) | Modified: RLVa-0.2.0g + if ( (new_value) && ((rlv_handler_t::isEnabled()) && (!gRlvHandler.canStand())) ) + { + // Allow only if the avie isn't sitting on any of the selected objects + LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection(); + RlvSelectIsSittingOn f(gAgentAvatarp); + if (hSel->getFirstRootNode(&f, TRUE) != NULL) + new_value = false; + } +// [/RLVa:KB] return new_value; } @@ -3407,6 +3429,16 @@ BOOL LLSelectMgr::selectGetPermissions(LLPermissions& result_perm) void LLSelectMgr::selectDelete() { +// [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0e) | Added: RLVa-1.2.0a + if ( (rlv_handler_t::isEnabled()) && (!rlvCanDeleteOrReturn()) ) + { + make_ui_sound("UISndInvalidOp"); + if (!gFloaterTools->getVisible()) + deselectAll(); + return; + } +// [/RLVa:KB] + S32 deleteable_count = 0; BOOL locked_but_deleteable_object = FALSE; @@ -3719,7 +3751,10 @@ struct LLDuplicateData void LLSelectMgr::selectDuplicate(const LLVector3& offset, BOOL select_copy) { - if (mSelectedObjects->isAttachment()) +// if (mSelectedObjects->isAttachment()) +// [RLVa:KB] - Checked: 2010-03-24 (RLVa-1.2.0e) | Added: RLVa-1.2.0a + if ( (mSelectedObjects->isAttachment()) || ((rlv_handler_t::isEnabled()) && (!rlvCanDeleteOrReturn())) ) +// [/RLVa:KB] { //RN: do not duplicate attachments make_ui_sound("UISndInvalidOp"); @@ -4173,11 +4208,39 @@ void LLSelectMgr::convertTransient() void LLSelectMgr::deselectAllIfTooFar() { +// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c + if ( (!mSelectedObjects->isEmpty()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_EDITOBJ))) ) + { + struct NotTransientOrFocusedMediaOrEditable : public LLSelectedNodeFunctor + { + bool apply(LLSelectNode* pNode) + { + const LLViewerObject* pObj = pNode->getObject(); + return (!pNode->isTransient()) && (pObj) && (!gRlvHandler.canEdit(pObj)) && + (pObj->getID() != LLViewerMediaFocus::getInstance()->getFocusedObjectID()); + } + } f; + if (mSelectedObjects->getFirstRootNode(&f, TRUE)) + deselectAll(); + } +// [/RLVa:KB] + if (mSelectedObjects->isEmpty() || mSelectedObjects->mSelectType == SELECT_TYPE_HUD) { return; } +// [RLVa:KB] - Checked: 2010-05-03 (RLVa-1.2.0g) | Modified: RLVa-1.1.0l +#ifdef RLV_EXTENSION_CMD_INTERACT + // [Fall-back code] Don't allow an active selection (except for HUD attachments - see above) when @interact=n restricted + if (gRlvHandler.hasBehaviour(RLV_BHVR_INTERACT)) + { + deselectAll(); + return; + } +#endif // RLV_EXTENSION_CMD_INTERACT +// [/RLVa:KB] + // HACK: Don't deselect when we're navigating to rate an object's // owner or creator. JC if (gMenuObject->getVisible()) @@ -4186,13 +4249,20 @@ void LLSelectMgr::deselectAllIfTooFar() } LLVector3d selectionCenter = getSelectionCenterGlobal(); - if (gSavedSettings.getBOOL("LimitSelectDistance") +// if (gSavedSettings.getBOOL("LimitSelectDistance") +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-0.2.0f + BOOL fRlvFartouch = gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH) && gFloaterTools->getVisible(); + if ( (gSavedSettings.getBOOL("LimitSelectDistance") || (fRlvFartouch) ) +// [/RLVa:KB] && (!mSelectedObjects->getPrimaryObject() || !mSelectedObjects->getPrimaryObject()->isAvatar()) && (mSelectedObjects->getPrimaryObject() != LLViewerMediaFocus::getInstance()->getFocusedObject()) && !mSelectedObjects->isAttachment() && !selectionCenter.isExactlyZero()) { - F32 deselect_dist = gSavedSettings.getF32("MaxSelectDistance"); +// F32 deselect_dist = gSavedSettings.getF32("MaxSelectDistance"); +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-0.2.0f + F32 deselect_dist = (!fRlvFartouch) ? gSavedSettings.getF32("MaxSelectDistance") : 1.5f; +// [/RLVa:KB] F32 deselect_dist_sq = deselect_dist * deselect_dist; LLVector3d select_delta = gAgent.getPositionGlobal() - selectionCenter; @@ -6613,7 +6683,10 @@ BOOL LLSelectMgr::canDoDelete() const can_delete = true; } } - +// [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0e) | Added: RLVa-1.2.0a + can_delete &= (!rlv_handler_t::isEnabled()) || (rlvCanDeleteOrReturn()); +// [/RLVa:KB] + return can_delete; } @@ -6645,7 +6718,12 @@ void LLSelectMgr::deselect() //----------------------------------------------------------------------------- BOOL LLSelectMgr::canDuplicate() const { - return const_cast<LLSelectMgr*>(this)->mSelectedObjects->getFirstCopyableObject() != NULL; // HACK: casting away constness - MG +// return const_cast<LLSelectMgr*>(this)->mSelectedObjects->getFirstCopyableObject() != NULL; // HACK: casting away constness - MG +// [RLVa:KB] - Checked: 2010-03-24 (RLVa-1.2.0e) | Added: RLVa-1.2.0a + return + (const_cast<LLSelectMgr*>(this)->mSelectedObjects->getFirstCopyableObject() != NULL) && + ( (!rlv_handler_t::isEnabled()) || (rlvCanDeleteOrReturn()) ); +// [/RLVa:KB] } //----------------------------------------------------------------------------- // duplicate() diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp index df413ab849aee3ebc3e3f713da1e3b51170ca3e6..1392c35ad7d3c01aab023d321866752a5e944293 100755 --- a/indra/newview/llsidepanelappearance.cpp +++ b/indra/newview/llsidepanelappearance.cpp @@ -543,3 +543,15 @@ void LLSidepanelAppearance::updateScrollingPanelList() mEditWearable->updateScrollingPanelList(); } } + +// [RLVa:KB] - Checked: 2010-09-16 (RLVa-1.2.1a) | Added: RLVa-1.2.1a +bool LLSidepanelAppearance::isOutfitEditPanelVisible() const +{ + return (mOutfitEdit) && (mOutfitEdit->getVisible()); +} + +bool LLSidepanelAppearance::isWearableEditPanelVisible() const +{ + return (mEditWearable) && (mEditWearable->getVisible()); +} +// [/RLVa:KB] diff --git a/indra/newview/llsidepanelappearance.h b/indra/newview/llsidepanelappearance.h index b0a6b9cf916da7107891a817d2132f965c4afc17..12b6db4e0c16ff4d9003725e24e26d094ddce453 100755 --- a/indra/newview/llsidepanelappearance.h +++ b/indra/newview/llsidepanelappearance.h @@ -66,6 +66,14 @@ class LLSidepanelAppearance : public LLPanel void updateToVisibility( const LLSD& new_visibility ); LLPanelEditWearable* getWearable(){ return mEditWearable; } +// [RLVa:KB] - Checked: 2010-09-16 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + bool isOutfitEditPanelVisible() const; + bool isWearableEditPanelVisible() const; + + LLPanelOutfitEdit* getOutfitEditPanel() { return mOutfitEdit; } + LLPanelEditWearable* getWearableEditPanel() { return mEditWearable; } +// [/RLVa:KB] + private: void onFilterEdit(const std::string& search_string); void onVisibilityChange ( const LLSD& new_visibility ); diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp index 92c2863ffdf49124f54c38ee7b28f74412e7e8ac..0a82b49e36351d31de0ae129830411d401d94cbf 100755 --- a/indra/newview/llsidepaneliteminfo.cpp +++ b/indra/newview/llsidepaneliteminfo.cpp @@ -43,7 +43,9 @@ #include "llviewercontrol.h" #include "llviewerinventory.h" #include "llviewerobjectlist.h" - +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.2a) +#include "rlvhandler.h" +// [/RLVa:KB] //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLItemPropertiesObserver @@ -340,9 +342,17 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) if (item->getCreatorUUID().notNull()) { LLUUID creator_id = item->getCreatorUUID(); - std::string name = - LLSLURL("agent", creator_id, "completename").getSLURLString(); - getChildView("BtnCreator")->setEnabled(TRUE); +// std::string name = +// LLSLURL("agent", creator_id, "completename").getSLURLString(); +// getChildView("BtnCreator")->setEnabled(TRUE); +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + // If the object creator matches the object owner we need to anonymize the creator field as well + bool fRlvFilterCreator = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && + ( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == creator_id) && (perm.getOwner() != gAgent.getID())) || + (RlvUtil::isNearbyAgent(item->getCreatorUUID())) ); + std::string name = LLSLURL("agent", creator_id, (!fRlvFilterCreator) ? "completename" : "rlvanonym").getSLURLString(); + getChildView("BtnCreator")->setEnabled(!fRlvFilterCreator); +// [/RLVa:KB] getChildView("LabelCreatorTitle")->setEnabled(TRUE); getChildView("LabelCreatorName")->setEnabled(FALSE); getChild<LLUICtrl>("LabelCreatorName")->setValue(name); @@ -368,9 +378,16 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) else { LLUUID owner_id = perm.getOwner(); - name = LLSLURL("agent", owner_id, "completename").getSLURLString(); +// name = LLSLURL("agent", owner_id, "completename").getSLURLString(); +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + bool fRlvFilterOwner = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (owner_id != gAgent.getID()); + name = LLSLURL("agent", owner_id, (!fRlvFilterOwner) ? "completename" : "rlvanonym").getSLURLString(); +// [/RLVa:KB] } - getChildView("BtnOwner")->setEnabled(TRUE); +// getChildView("BtnOwner")->setEnabled(TRUE); +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.2a) | Added: RLVa-1.0.0e + getChildView("BtnOwner")->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)); +// [/RLVa:KB] getChildView("LabelOwnerTitle")->setEnabled(TRUE); getChildView("LabelOwnerName")->setEnabled(FALSE); getChild<LLUICtrl>("LabelOwnerName")->setValue(name); @@ -699,6 +716,17 @@ void LLSidepanelItemInfo::onClickCreator() if(!item) return; if(!item->getCreatorUUID().isNull()) { +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.2a) | Added: RLVa-1.2.1b + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + { + const LLPermissions& perm = item->getPermissions(); + if ( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == item->getCreatorUUID()) && (perm.getOwner() != gAgent.getID())) || + (RlvUtil::isNearbyAgent(item->getCreatorUUID())) ) + { + return; + } + } +// [/RLVa:KB] LLAvatarActions::showProfile(item->getCreatorUUID()); } } @@ -714,6 +742,10 @@ void LLSidepanelItemInfo::onClickOwner() } else { +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.2a) | Modified: RLVa-1.0.0e + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (item->getPermissions().getOwner() != gAgent.getID()) ) + return; +// [/RLVa:KB] LLAvatarActions::showProfile(item->getPermissions().getOwner()); } } diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp index ad7c939728fe36b668a7f4d8283c13223a0289f4..9b0898635d6c2c95bba34b18984bb335ee69ee1f 100755 --- a/indra/newview/llsidepaneltaskinfo.cpp +++ b/indra/newview/llsidepaneltaskinfo.cpp @@ -64,6 +64,10 @@ #include "lltextbase.h" #include "llstring.h" #include "lltrans.h" +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.2a) +#include "llslurl.h" +#include "rlvhandler.h" +// [/RLVa:KB] ///---------------------------------------------------------------------------- /// Class llsidepaneltaskinfo @@ -370,11 +374,18 @@ void LLSidepanelTaskInfo::refresh() // Update creator text field getChildView("Creator:")->setEnabled(TRUE); +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + BOOL creators_identical = FALSE; +// [/RLVa:KB] std::string creator_name; - LLSelectMgr::getInstance()->selectGetCreator(mCreatorID, creator_name); +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + creators_identical = LLSelectMgr::getInstance()->selectGetCreator(mCreatorID, creator_name); +// [/RLVa:KB] +// LLSelectMgr::getInstance()->selectGetCreator(mCreatorID, creator_name); - getChild<LLUICtrl>("Creator Name")->setValue(creator_name); - getChildView("Creator Name")->setEnabled(TRUE); +// getChild<LLUICtrl>("Creator Name")->setValue(creator_name); +// getChildView("Creator Name")->setEnabled(TRUE); +// [RLVa:KB] - Moved further down to avoid an annoying flicker when the text is set twice in a row // Update owner text field getChildView("Owner:")->setEnabled(TRUE); @@ -402,8 +413,28 @@ void LLSidepanelTaskInfo::refresh() } } } +// getChild<LLUICtrl>("Owner Name")->setValue(owner_name); +// getChildView("Owner Name")->setEnabled(TRUE); +// [RLVa:KB] - Moved further down to avoid an annoying flicker when the text is set twice in a row + +// [RLVa:KB] - Checked: 2010-11-01 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + { + // Only anonymize the creator if all of the selection was created by the same avie who's also the owner or they're a nearby avie + if ( (creators_identical) && (mCreatorID != gAgent.getID()) && ((mCreatorID == mOwnerID) || (RlvUtil::isNearbyAgent(mCreatorID))) ) + creator_name = LLSLURL("agent", mCreatorID, "rlvanonym").getSLURLString(); + + // Only anonymize the owner name if all of the selection is owned by the same avie and isn't group owned + if ( (owners_identical) && (!LLSelectMgr::getInstance()->selectIsGroupOwned()) && (mOwnerID != gAgent.getID()) ) + owner_name = LLSLURL("agent", mOwnerID, "rlvanonym").getSLURLString(); + } + + getChild<LLUICtrl>("Creator Name")->setValue(creator_name); + getChildView("Creator Name")->setEnabled(TRUE); + getChild<LLUICtrl>("Owner Name")->setValue(owner_name); getChildView("Owner Name")->setEnabled(TRUE); +// [/RLVa:KB] // update group text field getChildView("Group:")->setEnabled(TRUE); diff --git a/indra/newview/llslurl.cpp b/indra/newview/llslurl.cpp index 3a822333200d19f04c31a0706c52d4ab1ea777c0..3c911cd75b2cc8212df1b9d3870a92452a340d50 100755 --- a/indra/newview/llslurl.cpp +++ b/indra/newview/llslurl.cpp @@ -34,6 +34,9 @@ #include "llviewernetwork.h" #include "llfiltersd2xmlrpc.h" #include "curl/curl.h" +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.0d) +#include "rlvhandler.h" +// [/RLVa:KB] const char* LLSLURL::SLURL_HTTP_SCHEME = "http"; const char* LLSLURL::SLURL_HTTPS_SCHEME = "https"; const char* LLSLURL::SLURL_SECONDLIFE_SCHEME = "secondlife"; @@ -382,8 +385,13 @@ std::string LLSLURL::getSLURLString() const S32 x = llround( (F32)mPosition[VX] ); S32 y = llround( (F32)mPosition[VY] ); S32 z = llround( (F32)mPosition[VZ] ); - return LLGridManager::getInstance()->getSLURLBase(mGrid) + - LLURI::escape(mRegion) + llformat("/%d/%d/%d",x,y,z); +// return LLGridManager::getInstance()->getSLURLBase(mGrid) + +// LLURI::escape(mRegion) + llformat("/%d/%d/%d",x,y,z); +// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.0d) | Added: RLVa-1.2.0d + return LLGridManager::getInstance()->getSLURLBase(mGrid) + + ( ((!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) || (!RlvUtil::isNearbyRegion(mRegion))) + ? (LLURI::escape(mRegion) + llformat("/%d/%d/%d",x,y,z)) : RlvStrings::getString(RLV_STRING_HIDDEN_REGION) ); +// [/RLVa:KB] } case APP: { diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 67a76460a71fcd0e6be3497946bc81c08ca31c76..c70d16f1ffd8a1c15f5d26e0dd6977707035c338 100755 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -193,6 +193,10 @@ #include "llvoicechannel.h" #include "llpathfindingmanager.h" +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0a) +#include "rlvhandler.h" +// [/RLVa:KB] + #include "lllogin.h" #include "llevents.h" #include "llstartuplistener.h" @@ -382,6 +386,13 @@ bool idle_startup() std::string lastGPU = gSavedSettings.getString("LastGPUString"); std::string thisGPU = LLFeatureManager::getInstance()->getGPUString(); +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0a) | Modified: RLVa-0.2.1d + if ( (gSavedSettings.controlExists(RLV_SETTING_MAIN)) && (gSavedSettings.getBOOL(RLV_SETTING_MAIN)) ) + { + rlv_handler_t::setEnabled(TRUE); + } +// [/RLVa:KB] + if (LLFeatureManager::getInstance()->isSafe()) { LLNotificationsUtil::add("DisplaySetToSafe"); @@ -988,6 +999,18 @@ bool idle_startup() // their last location, or some URL "-url //sim/x/y[/z]" // All accounts have both a home and a last location, and we don't support // more locations than that. Choose the appropriate one. JC +// [RLVa:KB] - Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-0.2.1d +#ifndef RLV_EXTENSION_STARTLOCATION + if (rlv_handler_t::isEnabled()) +#else + if ( (rlv_handler_t::isEnabled()) && (RlvSettings::getLoginLastLocation()) ) +#endif // RLV_EXTENSION_STARTLOCATION + { + // Force login at the last location + LLStartUp::setStartSLURL(LLSLURL(LLSLURL::SIM_LOCATION_LAST)); + } +// [/RLVa:KB] + switch (LLStartUp::getStartSLURL().getType()) { case LLSLURL::LOCATION: @@ -1803,6 +1826,14 @@ bool idle_startup() llinfos << "Creating Inventory Views" << llendl; LLFloaterReg::getInstance("inventory"); display_startup(); + +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0a) | Added: RLVa-1.1.0f + if (rlv_handler_t::isEnabled()) + { + // Regularly process a select subset of retained commands during logon + gIdleCallbacks.addFunction(RlvHandler::onIdleStartup, new LLTimer()); + } +// [/RLVa:KB] LLStartUp::setStartupState( STATE_MISC ); display_startup(); return FALSE; diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index ff69c6e9fd7d1f95b6ca8e7f71ad22f0576db784..e8e8bd3e884fef6cb0ccdad6b1b45f68d853922b 100755 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -86,7 +86,6 @@ // system includes #include <iomanip> - // // Globals // diff --git a/indra/newview/llteleporthistory.cpp b/indra/newview/llteleporthistory.cpp index 50a088b79979c260f6bfaff291ef8c9b9296ae49..8d6c6ec694d3d656a405976c48b6b1cfda03935e 100755 --- a/indra/newview/llteleporthistory.cpp +++ b/indra/newview/llteleporthistory.cpp @@ -39,6 +39,9 @@ #include "llviewerregion.h" #include "llworldmap.h" #include "llagentui.h" +// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) +#include "rlvhandler.h" +// [/RLVa:KB] ////////////////////////////////////////////////////////////////////////////// // LLTeleportHistoryItem @@ -149,8 +152,16 @@ void LLTeleportHistory::updateCurrentLocation(const LLVector3d& new_pos) mItems.erase (mItems.begin() + mCurrentItem + 1, mItems.end()); // Append an empty item to the history and make it current. - mItems.push_back(LLTeleportHistoryItem("", LLVector3d())); - mCurrentItem++; +// mItems.push_back(LLTeleportHistoryItem("", LLVector3d())); +// mCurrentItem++; +// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) | Added: RLVa-1.2.1b + // Only append a new item if the list is currently empty or if not @showloc=n restricted and the last entry wasn't zero'ed out + if ( (mItems.size() == 0) || ((!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) && (!mItems.back().mGlobalPos.isExactlyZero())) ) + { + mItems.push_back(LLTeleportHistoryItem("", LLVector3d())); + mCurrentItem++; + } +// [RLVa:KB] } // Update current history item. @@ -160,11 +171,23 @@ void LLTeleportHistory::updateCurrentLocation(const LLVector3d& new_pos) llassert(!"Invalid current teleport history item"); return; } - LLVector3 new_pos_local = gAgent.getPosAgentFromGlobal(new_pos); - mItems[mCurrentItem].mFullTitle = getCurrentLocationTitle(true, new_pos_local); - mItems[mCurrentItem].mTitle = getCurrentLocationTitle(false, new_pos_local); - mItems[mCurrentItem].mGlobalPos = new_pos; - mItems[mCurrentItem].mRegionID = gAgent.getRegion()->getRegionID(); + +// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) | Added: RLVa-1.2.1b + if (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { +// [/RLVa:KB] + LLVector3 new_pos_local = gAgent.getPosAgentFromGlobal(new_pos); + mItems[mCurrentItem].mFullTitle = getCurrentLocationTitle(true, new_pos_local); + mItems[mCurrentItem].mTitle = getCurrentLocationTitle(false, new_pos_local); + mItems[mCurrentItem].mGlobalPos = new_pos; + mItems[mCurrentItem].mRegionID = gAgent.getRegion()->getRegionID(); +// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) | Added: RLVa-1.2.1b + } + else + { + mItems[mCurrentItem] = LLTeleportHistoryItem(RlvStrings::getString(RLV_STRING_HIDDEN_PARCEL), LLVector3d::zero); + } +// [/RLVa:KB] } dump(); diff --git a/indra/newview/llteleporthistory.h b/indra/newview/llteleporthistory.h index e9c29c39bf3e945d91a57f4260d8ad705919f56d..401c340362b9a3092a6b3f94e6b3a6cc0c887721 100755 --- a/indra/newview/llteleporthistory.h +++ b/indra/newview/llteleporthistory.h @@ -234,6 +234,10 @@ class LLTeleportHistory: public LLSingleton<LLTeleportHistory> * Using this connection we get notified when a teleport fails. */ boost::signals2::connection mTeleportFailedConn; + +// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) | Added: RLVa-1.2.1b + friend class RlvUIEnabler; +// [/RLVa:KB] }; #endif diff --git a/indra/newview/llteleporthistorystorage.cpp b/indra/newview/llteleporthistorystorage.cpp index af5a047da4d974c4d77f5e0e78fcefc37977b4fa..d5884c31d57a347dc6951cea411cb648c3be92d1 100755 --- a/indra/newview/llteleporthistorystorage.cpp +++ b/indra/newview/llteleporthistorystorage.cpp @@ -33,6 +33,9 @@ #include "lldir.h" #include "llteleporthistory.h" #include "llagent.h" +// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) +#include "rlvhandler.h" +// [/RLVa:KB] // Max offset for two global positions to consider them as equal const F64 MAX_GLOBAL_POS_OFFSET = 5.0f; @@ -92,6 +95,13 @@ void LLTeleportHistoryStorage::onTeleportHistoryChange() } const LLTeleportHistoryItem &item = th->getItems()[th->getCurrentItemIndex()]; +// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) | Added: RLVa-1.2.1b + // Make sure we don't attempt to save zero'ed out teleport history items + if (item.mGlobalPos.isExactlyZero()) + { + return; + } +// [/RLVa:KB] addItem(item.mTitle, item.mGlobalPos); save(); @@ -116,6 +126,13 @@ bool LLTeleportHistoryStorage::compareByTitleAndGlobalPos(const LLTeleportHistor void LLTeleportHistoryStorage::addItem(const std::string title, const LLVector3d& global_pos, const LLDate& date) { +// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) | Added: RLVa-1.2.1b + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { + return; + } +// [/RLVa:KB] + LLTeleportHistoryPersistentItem item(title, global_pos, date); slurl_list_t::iterator item_iter = std::find_if(mItems.begin(), mItems.end(), diff --git a/indra/newview/llteleporthistorystorage.h b/indra/newview/llteleporthistorystorage.h index cf4c85a9910106a91c9f69be4cfe62dea049cb0a..f0131ac897ce9939438262c6de97e15618e1bf2b 100755 --- a/indra/newview/llteleporthistorystorage.h +++ b/indra/newview/llteleporthistorystorage.h @@ -108,7 +108,11 @@ class LLTeleportHistoryStorage: public LLSingleton<LLTeleportHistoryStorage> */ void goToItem(S32 idx); -private: +//private: +// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) | Added: RLVa-1.2.1b +protected: + friend class RlvUIEnabler; +// [/RLVa:KB] void load(); void dump() const; diff --git a/indra/newview/lltoastpanel.cpp b/indra/newview/lltoastpanel.cpp index a30f8419806e89e1840f3d3fe4ccd858f3cf1c1d..49dd1887c794e75169339b1004192c5a1f53043e 100755 --- a/indra/newview/lltoastpanel.cpp +++ b/indra/newview/lltoastpanel.cpp @@ -49,7 +49,10 @@ LLToastPanel::~LLToastPanel() std::string LLToastPanel::getTitle() { // *TODO: create Title and localize it. If it will be required. - return mNotification->getMessage(); +// return mNotification->getMessage(); +// [SL:KB] - Patch: UI-Notifications | Checked: 2011-04-11 (Catznip-2.5.0a) | Added: Catznip-2.5.0a + return (mNotification->hasLabel()) ? mNotification->getLabel() : mNotification->getMessage(); +// [/SL:KB] } //virtual diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 8bf021b0b269b9090df7155da319487a81d3006a..bcfb014040cfa140b6fd72e452b20c8f158bf628 100755 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -59,6 +59,10 @@ #include "llvoavatarself.h" #include "llworld.h" #include "llpanelface.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] // syntactic sugar #define callMemberFunction(object,ptrToMember) ((object).*(ptrToMember)) @@ -1284,6 +1288,15 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target, return; } + +// [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0e) | Modified: RLVa-1.2.0a + // Fallback in case there's a new code path that leads here (see behaviour notes) + if ( (rlv_handler_t::isEnabled()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) || (gRlvHandler.hasBehaviour(RLV_BHVR_INTERACT))) ) + { + return; + } +// [/RLVa:KB] + //llinfos << "Rezzing object" << llendl; make_ui_sound("UISndObjectRezIn"); LLViewerInventoryItem* item; @@ -1555,6 +1568,23 @@ EAcceptance LLToolDragAndDrop::willObjectAcceptInventory(LLViewerObject* obj, LL BOOL volume = (LL_PCODE_VOLUME == obj->getPCode()); BOOL attached = obj->isAttachment(); BOOL unrestricted = ((perm.getMaskBase() & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) ? TRUE : FALSE; + +// [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c) | Modified: RLVa-1.0.0c + if (rlv_handler_t::isEnabled()) + { + const LLViewerObject* pObjRoot = obj->getRootEdit(); + if (gRlvAttachmentLocks.isLockedAttachment(pObjRoot)) + { + return ACCEPT_NO_LOCKED; // Disallow inventory drops on a locked attachment + } + else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP)) ) + { + if ( (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) && (gAgentAvatarp->getRoot() == pObjRoot) ) + return ACCEPT_NO_LOCKED; // ... or on a linkset the avie is sitting on under @unsit=n/@sittp=n + } + } +// [/RLVa:KB] + if(attached && !unrestricted) { return ACCEPT_NO_LOCKED; @@ -1781,6 +1811,13 @@ EAcceptance LLToolDragAndDrop::dad3dRezAttachmentFromInv( return ACCEPT_NO; } +// [RLVa:KB] - Checked: 2013-02-13 (RLVa-1.4.8) + bool fReplace = !(mask & MASK_CONTROL); + if ( (rlv_handler_t::isEnabled()) && (!rlvPredCanWearItem(item, (fReplace) ? RLV_WEAR_REPLACE : RLV_WEAR_ADD)) ) + { + return ACCEPT_NO_LOCKED; + } +// [/RLVa:KB] if( drop ) { @@ -1789,7 +1826,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezAttachmentFromInv( // LLPointer<LLInventoryCallback> cb = new LLBoostFuncInventoryCallback(boost::bind(rez_attachment_cb, _1, (LLViewerJointAttachment*)0)); // [SL:KB] - Patch: Appearance-DnDWear | Checked: 2010-09-28 (Catznip-2.2) // Make this behave consistent with dad3dWearItem - LLPointer<LLInventoryCallback> cb = new LLBoostFuncInventoryCallback(boost::bind(rez_attachment_cb, _1, (LLViewerJointAttachment*)0, !(mask & MASK_CONTROL))); + LLPointer<LLInventoryCallback> cb = new LLBoostFuncInventoryCallback(boost::bind(rez_attachment_cb, _1, (LLViewerJointAttachment*)0, fReplace)); // [/SL:KB] copy_inventory_item( gAgent.getID(), @@ -1815,6 +1852,14 @@ EAcceptance LLToolDragAndDrop::dad3dRezAttachmentFromInv( EAcceptance LLToolDragAndDrop::dad3dRezObjectOnLand( LLViewerObject* obj, S32 face, MASK mask, BOOL drop) { +// [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0e) | Modified: RLVa-1.1.0l + // RELEASE-RLVa: [SL-2.2.0] Make sure the code below is the only code path to LLToolDragAndDrop::dad3dRezFromObjectOnLand() + if ( (rlv_handler_t::isEnabled()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) || (gRlvHandler.hasBehaviour(RLV_BHVR_INTERACT))) ) + { + return ACCEPT_NO_LOCKED; + } +// [/RLVa:KB] + if (mSource == SOURCE_WORLD) { return dad3dRezFromObjectOnLand(obj, face, mask, drop); @@ -1877,6 +1922,18 @@ EAcceptance LLToolDragAndDrop::dad3dRezObjectOnLand( EAcceptance LLToolDragAndDrop::dad3dRezObjectOnObject( LLViewerObject* obj, S32 face, MASK mask, BOOL drop) { +// [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0e) | Modified: RLVa-1.1.0l + // NOTE: if (mask & MASK_CONTROL) then it's a drop rather than a rez, so we let that pass through when @rez=n restricted + // (but not when @interact=n restricted unless the drop target is a HUD attachment) + // RELEASE-RLVa: [SL-2.2.0] Make sure the code below is the only code path to LLToolDragAndDrop::dad3dRezFromObjectOnObject() + if ( (rlv_handler_t::isEnabled()) && + ( ( (gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) && ((mask & MASK_CONTROL) == 0) ) || + ( (gRlvHandler.hasBehaviour(RLV_BHVR_INTERACT)) && (((mask & MASK_CONTROL) == 0) || (!obj->isHUDAttachment())) ) ) ) + { + return ACCEPT_NO_LOCKED; + } +// [/RLVa:KB] + // handle objects coming from object inventory if (mSource == SOURCE_WORLD) { @@ -2107,11 +2164,22 @@ EAcceptance LLToolDragAndDrop::dad3dWearItem( return ACCEPT_NO; } +// [RLVa:KB] - Checked: 2013-02-13 (RLVa-1.4.8) + bool fReplace = (!(mask & MASK_CONTROL)) || (LLAssetType::AT_BODYPART == item->getType()); // Body parts should always replace + if ( (rlv_handler_t::isEnabled()) && (!rlvPredCanWearItem(item, (fReplace) ? RLV_WEAR_REPLACE : RLV_WEAR_ADD)) ) + { + return ACCEPT_NO_LOCKED; + } +// [/RLVa:KB] + if( drop ) { // TODO: investigate wearables may not be loaded at this point EXT-8231 - LLAppearanceMgr::instance().wearItemOnAvatar(item->getUUID(),true, !(mask & MASK_CONTROL)); +// [RLVa:KB] - Checked: 2013-02-13 (RLVa-1.4.8) + LLAppearanceMgr::instance().wearItemOnAvatar(item->getUUID(), true, fReplace); +// [/RLVa:KB] +// LLAppearanceMgr::instance().wearItemOnAvatar(item->getUUID(),true, !(mask & MASK_CONTROL)); } return ACCEPT_YES_MULTI; } diff --git a/indra/newview/lltoolface.cpp b/indra/newview/lltoolface.cpp index a00ac10698a9798958d9d435e483c01463eef503..4b02174009d2017d29b4580f6c6a0083eba8c8a4 100755 --- a/indra/newview/lltoolface.cpp +++ b/indra/newview/lltoolface.cpp @@ -39,6 +39,9 @@ #include "llviewerobject.h" #include "llviewerwindow.h" #include "llfloatertools.h" +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) +#include "rlvhandler.h" +// [/RLVa:KB] // // Member functions @@ -90,6 +93,15 @@ void LLToolFace::pickCallback(const LLPickInfo& pick_info) return; } +// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c + if ( (rlv_handler_t::isEnabled()) && + ( (!gRlvHandler.canEdit(hit_obj)) || + ((gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) && (!gRlvHandler.canTouch(hit_obj, pick_info.mObjectOffset))) ) ) + { + return; + } +// [/RLVa:KB] + // ...clicked on a world object, try to pick the appropriate face if (pick_info.mKeyMask & MASK_SHIFT) diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp index 9907da0f0e7396604beb71b2d3d7eb08608bf0d2..a2627cadfe97cb5271cf00e7f2320a57f01dc1b8 100755 --- a/indra/newview/lltoolgrab.cpp +++ b/indra/newview/lltoolgrab.cpp @@ -56,6 +56,9 @@ #include "llviewerregion.h" #include "llvoavatarself.h" #include "llworld.h" +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) +#include "rlvhandler.h" +// [/RLVa:KB] const S32 SLOP_DIST_SQ = 4; @@ -157,7 +160,11 @@ void LLToolGrab::pickCallback(const LLPickInfo& pick_info) } // if not over object, do nothing - if (!objectp) +// if (!objectp) +// [RLVa:KB] - Checked: 2010-03-11 (RLVa-1.2.0e) | Added: RLVa-1.1.0l + // Block initiating a drag operation on an object that can't be touched + if ( (!objectp) || ((rlv_handler_t::isEnabled()) && (!gRlvHandler.canTouch(objectp, pick_info.mObjectOffset))) ) +// [/RLVa:KB] { LLToolGrab::getInstance()->setMouseCapture(TRUE); LLToolGrab::getInstance()->mMode = GRAB_NOOBJECT; @@ -418,6 +425,22 @@ BOOL LLToolGrab::handleHover(S32 x, S32 y, MASK mask) return TRUE; } +// [RLVa:KB] - Checked: 2010-03-11 (RLVa-1.2.0e) | Modified: RLVa-1.1.0l + // Block dragging an object beyond touch range when @fartouch=n restricted + if ( (rlv_handler_t::isEnabled()) && (GRAB_INACTIVE != mMode) && (GRAB_NOOBJECT != mMode) && (hasMouseCapture()) && + (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) && (!gRlvHandler.canTouch(mGrabPick.getObject(), mGrabPick.mObjectOffset)) ) + { + if (gGrabTransientTool) + { + // Prevent the grab tool from popping up as soon as we kill the drag operation + gBasicToolset->selectTool(gGrabTransientTool); + gGrabTransientTool = NULL; + } + setMouseCapture(FALSE); + return TRUE; + } +// [/RLVa:KB] + // Do the right hover based on mode switch( mMode ) { diff --git a/indra/newview/lltoolmgr.cpp b/indra/newview/lltoolmgr.cpp index a135ba70f510a8af2e13822e23d4107239be3669..78201816b7652c95fa631547d0157f54f7b2e297 100755 --- a/indra/newview/lltoolmgr.cpp +++ b/indra/newview/lltoolmgr.cpp @@ -55,7 +55,10 @@ #include "llviewerjoystick.h" #include "llviewermenu.h" #include "llviewerparcelmgr.h" - +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) +#include "rlvhandler.h" +#include "rlvui.h" +// [/RLVa:KB] // Used when app not active to avoid processing hover. LLTool* gToolNull = NULL; @@ -80,8 +83,12 @@ LLToolMgr::LLToolMgr() { // Not a panel, register these callbacks globally. LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Active", boost::bind(&LLToolMgr::inEdit, this)); - LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Enabled", boost::bind(&LLToolMgr::canEdit, this)); - LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Build.Toggle", boost::bind(&LLToolMgr::toggleBuildMode, this, _2)); +// LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Enabled", boost::bind(&LLToolMgr::canEdit, this)); +// LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Build.Toggle", boost::bind(&LLToolMgr::toggleBuildMode, this, _2)); +// [RLVa:KB] - Checked: 2010-09-11 (RLVa-1.2.1d) | Added: RLVa-1.2.1d + LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Enabled", boost::bind(&RlvUIEnabler::isBuildEnabled)); + LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Build.Toggle", boost::bind(&LLToolMgr::toggleBuildMode, this)); +// [/RLVa:KB] gToolNull = new LLTool(LLStringUtil::null); // Does nothing setCurrentTool(gToolNull); @@ -247,14 +254,17 @@ bool LLToolMgr::canEdit() return LLViewerParcelMgr::getInstance()->allowAgentBuild(); } -void LLToolMgr::toggleBuildMode(const LLSD& sdname) +//void LLToolMgr::toggleBuildMode(const LLSD& sdname) +// [RLVa:KB] - Checked: 2012-04-26 (RLVa-1.4.6) | Added: RLVa-1.4.6 +void LLToolMgr::toggleBuildMode() +// [/RLVa:KB] { - const std::string& param = sdname.asString(); - - if (param == "build" && !canEdit()) - { - return; - } +// const std::string& param = sdname.asString(); +// +// if (param == "build" && !canEdit()) +// { +// return; +// } LLFloaterReg::toggleInstanceOrBringToFront("build"); diff --git a/indra/newview/lltoolmgr.h b/indra/newview/lltoolmgr.h index e7d1c56c8315d52ab90fbb682cac7112c869e0ec..fb7689711363ec6561125b9241c61cd126e371d0 100755 --- a/indra/newview/lltoolmgr.h +++ b/indra/newview/lltoolmgr.h @@ -54,7 +54,10 @@ class LLToolMgr : public LLSingleton<LLToolMgr> bool inEdit(); bool canEdit(); - void toggleBuildMode(const LLSD& sdname); +// [RLVa:KB] - Checked: 2012-04-26 (RLVa-1.4.6) | Added: RLVa-1.4.6 + void toggleBuildMode(); +// [/RLVa:KB] +// void toggleBuildMode(const LLSD& sdname); /* Determines if we are in Build mode or not. */ bool inBuildMode(); diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 1c362c18e0d7ede5f872388f6b41c46b8cd573c1..64304b8c2ce769f56822bba700a96a497357f8e9 100755 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -69,6 +69,9 @@ #include "llui.h" #include "llweb.h" #include "pipeline.h" // setHighlightObject +// [RLVa:KB] - Checked: 2010-03-06 (RLVa-1.2.0c) +#include "rlvhandler.h" +// [/RLVa:KB] extern BOOL gDebugClicks; @@ -195,6 +198,15 @@ BOOL LLToolPie::handleLeftClickPick() // If it's a left-click, and we have a special action, do it. if (useClickAction(mask, object, parent)) { +// [RLVa:KB] - Checked: 2010-03-11 (RLVa-1.2.0e) | Modified: RLVa-1.1.0l + // Block left-click special actions when fartouch restricted + if ( (rlv_handler_t::isEnabled()) && + (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) && (!gRlvHandler.canTouch(object, mPick.mObjectOffset)) ) + { + return TRUE; + } +// [/RLVa:KB] + mClickAction = 0; if (object && object->getClickAction()) { @@ -316,6 +328,14 @@ BOOL LLToolPie::handleLeftClickPick() ((object->flagUsePhysics() || (parent && !parent->isAvatar() && parent->flagUsePhysics())) || touchable) ) { +// [RLVa:KB] - Checked: 2010-03-11 (RLVa-1.2.0e) | Modified: RLVa-1.1.0l + // Triggered by left-clicking on a touchable object + if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canTouch(object, mPick.mObjectOffset)) ) + { + return LLTool::handleMouseDown(x, y, mask); + } +// [/RLVa:KB] + gGrabTransientTool = this; mMouseButtonDown = false; LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolGrab::getInstance() ); @@ -430,7 +450,11 @@ ECursorType LLToolPie::cursorFromObject(LLViewerObject* object) { case CLICK_ACTION_SIT: { - if (isAgentAvatarValid() && !gAgentAvatarp->isSitting()) // not already sitting? +// if (isAgentAvatarValid() && !gAgentAvatarp->isSitting()) // not already sitting? +// [RLVa:KB] - Checked: 2010-03-06 (RLVa-1.2.0c) | Modified: RLVa-1.2.0g + if ( (isAgentAvatarValid() && !gAgentAvatarp->isSitting()) && + ((!rlv_handler_t::isEnabled()) || (gRlvHandler.canSit(object, LLToolPie::getInstance()->getHoverPick().mObjectOffset))) ) +// [/RLVa:KB] { cursor = UI_CURSOR_TOOLSIT; } @@ -543,6 +567,19 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) mHoverPick = gViewerWindow->pickImmediate(x, y, FALSE); LLViewerObject *parent = NULL; LLViewerObject *object = mHoverPick.getObject(); +// [RLVa:KB] - Checked: 2010-03-11 (RLVa-1.2.0e) | Modified: RLVa-1.1.0l + // Block all special click action cursors when: + // - @fartouch=n restricted and the object is out of range + // - @interact=n restricted and the object isn't a HUD attachment + if ( (object) && (rlv_handler_t::isEnabled()) && + ( ((gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH))) && (!gRlvHandler.canTouch(object, mHoverPick.mObjectOffset)) || + ((gRlvHandler.hasBehaviour(RLV_BHVR_INTERACT)) && (!object->isHUDAttachment())) ) ) + { + gViewerWindow->setCursor(UI_CURSOR_ARROW); + return TRUE; + } +// [/RLVa:KB] + if (object) { parent = object->getRootEdit(); @@ -596,7 +633,13 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) gViewerWindow->setCursor(cursor); lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl; } - +// [RLVa:KB] - Checked: 2010-03-11 (RLVa-1.2.0e) | Added: RLVa-1.1.0l + else if ( (object) && (rlv_handler_t::isEnabled()) && (!gRlvHandler.canTouch(object)) ) + { + // Block showing the "grab" or "touch" cursor if we can't touch the object (@fartouch=n is handled above) + gViewerWindow->setCursor(UI_CURSOR_ARROW); + } +// [/RLVa:KB] else if ((object && !object->isAvatar() && object->flagUsePhysics()) || (parent && !parent->isAvatar() && parent->flagUsePhysics())) { @@ -974,7 +1017,10 @@ BOOL LLToolPie::handleTooltipObject( LLViewerObject* hover_object, std::string l LLAvatarName av_name; if (LLAvatarNameCache::get(hover_object->getID(), &av_name)) { - final_name = av_name.getCompleteName(); +// final_name = av_name.getCompleteName(); +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + final_name = (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? av_name.getCompleteName() : RlvStrings::getAnonym(av_name); +// [/RLVa:KB] } else { @@ -983,17 +1029,29 @@ BOOL LLToolPie::handleTooltipObject( LLViewerObject* hover_object, std::string l // *HACK: We may select this object, so pretend it was clicked mPick = mHoverPick; - LLInspector::Params p; - p.fillFrom(LLUICtrlFactory::instance().getDefaultParams<LLInspector>()); - p.message(final_name); - p.image.name("Inspector_I"); - p.click_callback(boost::bind(showAvatarInspector, hover_object->getID())); - p.visible_time_near(6.f); - p.visible_time_far(3.f); - p.delay_time(gSavedSettings.getF32("AvatarInspectorTooltipDelay")); - p.wrap(false); - - LLToolTipMgr::instance().show(p); +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.2a) | Added: RLVa-1.2.0e + if ( (!rlv_handler_t::isEnabled()) || + ( (gRlvHandler.canTouch(hover_object, mHoverPick.mObjectOffset)) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ) ) + { +// [/RLVa:KB] + LLInspector::Params p; + p.fillFrom(LLUICtrlFactory::instance().getDefaultParams<LLInspector>()); + p.message(final_name); + p.image.name("Inspector_I"); + p.click_callback(boost::bind(showAvatarInspector, hover_object->getID())); + p.visible_time_near(6.f); + p.visible_time_far(3.f); + p.delay_time(gSavedSettings.getF32("AvatarInspectorTooltipDelay")); + p.wrap(false); + + LLToolTipMgr::instance().show(p); +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.2a) | Added: RLVa-1.2.0e + } + else + { + LLToolTipMgr::instance().show(final_name); + } +// [/RLVa:KB] } } else @@ -1096,22 +1154,34 @@ BOOL LLToolPie::handleTooltipObject( LLViewerObject* hover_object, std::string l { // We may select this object, so pretend it was clicked mPick = mHoverPick; - LLInspector::Params p; - p.fillFrom(LLUICtrlFactory::instance().getDefaultParams<LLInspector>()); - p.message(tooltip_msg); - p.image.name("Inspector_I"); - p.click_callback(boost::bind(showObjectInspector, hover_object->getID(), mHoverPick.mObjectFace)); - p.time_based_media(is_time_based_media); - p.web_based_media(is_web_based_media); - p.media_playing(is_media_playing); - p.click_playmedia_callback(boost::bind(playCurrentMedia, mHoverPick)); - p.click_homepage_callback(boost::bind(VisitHomePage, mHoverPick)); - p.visible_time_near(6.f); - p.visible_time_far(3.f); - p.delay_time(gSavedSettings.getF32("ObjectInspectorTooltipDelay")); - p.wrap(false); - - LLToolTipMgr::instance().show(p); +// [RLVa:KB] - Checked: 2010-11-12 (RLVa-1.2.1g) | Modified: RLVa-1.2.1g + if ( (!rlv_handler_t::isEnabled()) || (!gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) || + (gRlvHandler.canTouch(hover_object, mHoverPick.mObjectOffset)) ) + { +// [/RLVa:KB] + LLInspector::Params p; + p.fillFrom(LLUICtrlFactory::instance().getDefaultParams<LLInspector>()); + p.message(tooltip_msg); + p.image.name("Inspector_I"); + p.click_callback(boost::bind(showObjectInspector, hover_object->getID(), mHoverPick.mObjectFace)); + p.time_based_media(is_time_based_media); + p.web_based_media(is_web_based_media); + p.media_playing(is_media_playing); + p.click_playmedia_callback(boost::bind(playCurrentMedia, mHoverPick)); + p.click_homepage_callback(boost::bind(VisitHomePage, mHoverPick)); + p.visible_time_near(6.f); + p.visible_time_far(3.f); + p.delay_time(gSavedSettings.getF32("ObjectInspectorTooltipDelay")); + p.wrap(false); + + LLToolTipMgr::instance().show(p); +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Added: RLVa-1.2.0e + } + else + { + LLToolTipMgr::instance().show(tooltip_msg); + } +// [/RLVa:KB] } } } @@ -1123,6 +1193,11 @@ BOOL LLToolPie::handleToolTip(S32 local_x, S32 local_y, MASK mask) { if (!LLUI::sSettingGroups["config"]->getBOOL("ShowHoverTips")) return TRUE; if (!mHoverPick.isValid()) return TRUE; +// [RLVa:KB] - Checked: 2010-05-03 (RLVa-1.2.0g) | Modified: RLVa-1.2.0g +#ifdef RLV_EXTENSION_CMD_INTERACT + if (gRlvHandler.hasBehaviour(RLV_BHVR_INTERACT)) return TRUE; +#endif // RLV_EXTENSION_CMD_INTERACT +// [/RLVa:KB] LLViewerObject* hover_object = mHoverPick.getObject(); @@ -1647,16 +1722,29 @@ BOOL LLToolPie::handleRightClickPick() mute_msg = LLTrans::getString("MuteAvatar"); } - if (is_other_attachment) +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-1.1.0l + // Don't show the context menu on empty selection when fartouch restricted [see LLToolSelect::handleObjectSelection()] + if ( (!rlv_handler_t::isEnabled()) || (!LLSelectMgr::getInstance()->getSelection()->isEmpty()) || + (!gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) ) { - gMenuAttachmentOther->getChild<LLUICtrl>("Avatar Mute")->setValue(mute_msg); - gMenuAttachmentOther->show(x, y); +// [/RLVa:KB] + if (is_other_attachment) + { + gMenuAttachmentOther->getChild<LLUICtrl>("Avatar Mute")->setValue(mute_msg); + gMenuAttachmentOther->show(x, y); + } + else + { + gMenuAvatarOther->getChild<LLUICtrl>("Avatar Mute")->setValue(mute_msg); + gMenuAvatarOther->show(x, y); + } +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-1.1.0l } else { - gMenuAvatarOther->getChild<LLUICtrl>("Avatar Mute")->setValue(mute_msg); - gMenuAvatarOther->show(x, y); + make_ui_sound("UISndInvalidOp"); } +// [/RLVa:KB] } else if (object->isAttachment()) { @@ -1681,10 +1769,24 @@ BOOL LLToolPie::handleRightClickPick() mute_msg = LLTrans::getString("MuteObject2"); } - gMenuHolder->getChild<LLUICtrl>("Object Mute")->setValue(mute_msg); - gMenuObject->show(x, y); +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.el) | Modified: RLVa-1.1.0l + // Don't show the pie menu on empty selection when fartouch/interaction restricted + // (not entirely accurate in case of Tools / Select Only XXX [see LLToolSelect::handleObjectSelection()] + if ( (!rlv_handler_t::isEnabled()) || (!LLSelectMgr::getInstance()->getSelection()->isEmpty()) || + (!gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) ) + { +// [/RLVa:KB] + gMenuHolder->getChild<LLUICtrl>("Object Mute")->setValue(mute_msg); + gMenuObject->show(x, y); - showVisualContextMenuEffect(); + showVisualContextMenuEffect(); +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.el) | Modified: RLVa-1.1.0l + } + else + { + make_ui_sound("UISndInvalidOp"); + } +// [/RLVa:KB] } } else if (mPick.mParticleOwnerID.notNull()) diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index 68fe8bc4a5586d8c9371be629e1a669d3c4dd58c..213fc982a1abf644c712d1b09d06776aa3ffe945 100755 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -62,6 +62,9 @@ class LLToolPie : public LLTool, public LLSingleton<LLToolPie> virtual LLTool* getOverrideTool(MASK mask); LLPickInfo& getPick() { return mPick; } +// [RLVa:KB] - Checked: 2010-03-06 (RLVa-1.2.0c) | Added: RLVa-1.2.0a + LLPickInfo& getHoverPick() { return mHoverPick; } +// [/RLVa:KB] U8 getClickAction() { return mClickAction; } LLViewerObject* getClickActionObject() { return mClickActionObject; } LLObjectSelection* getLeftClickSelection() { return (LLObjectSelection*)mLeftClickSelection; } diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp index 641fbc50422e966a8dfa98b32fabb9e62faeea3f..c052a070c860a9cac8b6908be8d7144e835c4560 100755 --- a/indra/newview/lltoolplacer.cpp +++ b/indra/newview/lltoolplacer.cpp @@ -43,6 +43,9 @@ #include "llviewerwindow.h" #include "llworld.h" #include "llui.h" +// [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0a) +#include "rlvhandler.h" +// [/RLVa:KB] //Headers added for functions moved from viewer.cpp #include "llvograss.h" @@ -123,6 +126,14 @@ BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj, return FALSE; } +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-0.2.0f + // NOTE: don't use surface_pos_global since for prims it will be the center of the prim while we need center + offset + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) && (dist_vec_squared(gAgent.getPositionGlobal(), pick.mPosGlobal) > 1.5f * 1.5f) ) + { + return FALSE; + } +// [/RLVa:KB] + // Find the sim where the surface lives. LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(surface_pos_global); if (!regionp) @@ -240,7 +251,10 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics ) { flags |= FLAGS_USE_PHYSICS; } - if (create_selected) +// if (create_selected) +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Added: RLVa-1.0.0b + if ( (create_selected) && (!gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) ) +// [/RLVa:KB] { flags |= FLAGS_CREATE_SELECTED; } @@ -498,6 +512,13 @@ BOOL LLToolPlacer::placeObject(S32 x, S32 y, MASK mask) { BOOL added = TRUE; +// [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0e) | Modified: RLVa-1.1.0l + if ( (rlv_handler_t::isEnabled()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) || (gRlvHandler.hasBehaviour(RLV_BHVR_INTERACT))) ) + { + return TRUE; // Callers seem to expect a "did you handle it?" so we return TRUE rather than FALSE + } +// [/RLVa:KB] + if (gSavedSettings.getBOOL("CreateToolCopySelection")) { added = addDuplicate(x, y); diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index 7c604a04bf7b53f2e130028a5b0c3cc6c5c5a218..37d0a03f44cee2baede198a5c54a10f237ec607e 100755 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -45,6 +45,10 @@ #include "llviewerwindow.h" #include "llvoavatarself.h" #include "llworld.h" +// [RLVa:KB] - Checked: 2010-03-06 (RLVa-1.2.0c) +#include "rlvhandler.h" +#include "llfloaterreg.h" +// [/RLVa:KB] // Globals //extern BOOL gAllowSelectAvatar; @@ -78,6 +82,35 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi { object = object->getRootEdit(); } + +// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c + if ( (object) && (rlv_handler_t::isEnabled()) ) + { + if (!gRlvHandler.canEdit(object)) + { + if (!temp_select) + return LLSelectMgr::getInstance()->getSelection(); + else if (LLToolMgr::instance().inBuildMode()) + LLToolMgr::instance().toggleBuildMode(); + } + + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) && ((!object->isAttachment()) || (!object->permYouOwner())) && + (dist_vec_squared(gAgent.getPositionAgent(), object->getPositionRegion()) > 1.5f * 1.5f) ) + { + // NOTE: see behaviour notes for a rather lengthy explanation of why we're doing things this way + //if (dist_vec_squared(gAgent.getPositionAgent(), object->getPositionRegion() + pick.mObjectOffset) > 1.5f * 1.5f) + if (dist_vec_squared(gAgent.getPositionAgent(), pick.mIntersection) > 1.5f * 1.5f) + { + if ( (LLFloaterReg::instanceVisible("build")) && (pick.mKeyMask != MASK_SHIFT) && (pick.mKeyMask != MASK_CONTROL) ) + LLSelectMgr::getInstance()->deselectAll(); + return LLSelectMgr::getInstance()->getSelection(); + } + else if (LLToolMgr::instance().inBuildMode()) + LLToolMgr::instance().toggleBuildMode(); + } + } +// [/RLVa:KB] + BOOL select_owned = gSavedSettings.getBOOL("SelectOwnedOnly"); BOOL select_movable = gSavedSettings.getBOOL("SelectMovableOnly"); diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp index cbd16e873d639eba98fd422d44cd69881ae27e31..58921cd0f5f030eeb062f2360d584d8cf70afe9d 100755 --- a/indra/newview/lltracker.cpp +++ b/indra/newview/lltracker.cpp @@ -63,6 +63,10 @@ #include "llworldmapview.h" #include "llviewercontrol.h" +// [RLVa:KB] +#include "rlvhandler.h" +// [/RLVa:KB] + const F32 DESTINATION_REACHED_RADIUS = 3.0f; const F32 DESTINATION_VISITED_RADIUS = 6.0f; diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp old mode 100755 new mode 100644 diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h old mode 100755 new mode 100644 diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index b5aa0ac92aa489b045999356310fc38de1211a5a..e08244d03eab23013cde08e00ba021e55d485b4c 100755 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -41,6 +41,9 @@ #include "llworld.h" #include "lltoolmgr.h" #include "llviewerjoystick.h" +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) +#include "rlvhandler.h" +// [/RLVa:KB] // Linden library includes #include "lldrawable.h" @@ -349,7 +352,10 @@ void LLViewerCamera::setPerspective(BOOL for_selection, if (limit_select_distance) { // ...select distance from control - z_far = gSavedSettings.getF32("MaxSelectDistance"); +// z_far = gSavedSettings.getF32("MaxSelectDistance"); +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Added: RLVa-1.2.0e + z_far = (!gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) ? gSavedSettings.getF32("MaxSelectDistance") : 1.5; +// [/RLVa:KB] } else { diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index bbebeea3e0e22a5bd2d6e5de5e912224a1681baa..e21d1c1e7296c2822e8803b7bb484355dc5cd598 100755 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -77,6 +77,10 @@ #include "llwlparammanager.h" #include "llwaterparammanager.h" #include "llpostprocess.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] extern LLPointer<LLViewerTexture> gStartTexture; extern bool gShiftFrame; @@ -1057,7 +1061,11 @@ void render_hud_attachments() glh::matrix4f current_mod = glh_get_current_modelview(); // clamp target zoom level to reasonable values - gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); +// gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) | Modified: RLVa-1.0.0c + gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, (!gRlvAttachmentLocks.hasLockedHUD()) ? 0.1f : 0.85f, 1.f); +// [/RLVa:KB] + // smoothly interpolate current zoom level gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f)); diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 4ce049df03ffa1b6b62896aa456f351ab0224993..b781011635fb03b262f80f1b612ebc7eff16880b 100755 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -143,7 +143,9 @@ #include "llcommandhandler.h" // *NOTE: Please add files in alphabetical order to keep merges easy. - +// [RLVa:KB] - Checked: 2010-03-11 +#include "rlvfloaters.h" +// [/RLVa:KB] // handle secondlife:///app/openfloater/{NAME} URLs class LLFloaterOpenHandler : public LLCommandHandler { @@ -296,6 +298,11 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("reset_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterResetQueue>); LLFloaterReg::add("region_debug_console", "floater_region_debug_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionDebugConsole>); LLFloaterReg::add("region_info", "floater_region_info.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionInfo>); +// [RLVa:KB] - Checked: 2010-03-11 (RLVa-1.2.0e) | Added: RLVa-1.2.0a + LLFloaterReg::add("rlv_behaviours", "floater_rlv_behaviours.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<RlvFloaterBehaviours>); + LLFloaterReg::add("rlv_locks", "floater_rlv_locks.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<RlvFloaterLocks>); + LLFloaterReg::add("rlv_strings", "floater_rlv_strings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<RlvFloaterStrings>); +// [/RLVa:KB] LLFloaterReg::add("script_debug", "floater_script_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebug>); LLFloaterReg::add("script_debug_output", "floater_script_debug_panel.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebugOutput>); diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp index f6e840adcd803988264a97bd9c9c8f2b29b1ef81..98e9986ea56eee777928d7e4df4c0fa5c1ac8502 100755 --- a/indra/newview/llviewerjoystick.cpp +++ b/indra/newview/llviewerjoystick.cpp @@ -326,8 +326,11 @@ void LLViewerJoystick::handleRun(F32 inc) if (1 == mJoystickRun) { ++mJoystickRun; - gAgent.setRunning(); - gAgent.sendWalkRun(gAgent.getRunning()); +// gAgent.setRunning(); +// gAgent.sendWalkRun(gAgent.getRunning()); +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + gAgent.setTempRun(); +// [/RLVa:KB] } else if (0 == mJoystickRun) { @@ -342,8 +345,11 @@ void LLViewerJoystick::handleRun(F32 inc) --mJoystickRun; if (0 == mJoystickRun) { - gAgent.clearRunning(); - gAgent.sendWalkRun(gAgent.getRunning()); +// gAgent.clearRunning(); +// gAgent.sendWalkRun(gAgent.getRunning()); +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + gAgent.clearTempRun(); +// [/RLVa:KB] } } } diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index aa9de076b87f46adee7fa15fae458fe0b90528eb..6b384f61b96b6e1a066ce57345519935da20c88e 100755 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -42,6 +42,9 @@ #include "llvoavatarself.h" #include "llfloatercamera.h" #include "llinitparam.h" +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i +#include "rlvhandler.h" +// [/RLVa:KB] // // Constants @@ -92,14 +95,18 @@ static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode m { if (KEYSTATE_UP == s) { - if (gAgent.mDoubleTapRunMode == mode && - gAgent.getRunning() && - !gAgent.getAlwaysRun()) - { - // Turn off temporary running. - gAgent.clearRunning(); - gAgent.sendWalkRun(gAgent.getRunning()); - } +// if (gAgent.mDoubleTapRunMode == mode && +// gAgent.getRunning() && +// !gAgent.getAlwaysRun()) +// { +// // Turn off temporary running. +// gAgent.clearRunning(); +// gAgent.sendWalkRun(gAgent.getRunning()); +// } +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + if ( (gAgent.mDoubleTapRunMode == mode) && (gAgent.getTempRun()) ) + gAgent.clearTempRun(); +// [/RLVa:KB] } else if (gSavedSettings.getBOOL("AllowTapTapHoldRun") && KEYSTATE_DOWN == s && @@ -110,8 +117,11 @@ static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode m { // Same walk-key was pushed again quickly; this is a // double-tap so engage temporary running. - gAgent.setRunning(); - gAgent.sendWalkRun(gAgent.getRunning()); +// gAgent.setRunning(); +// gAgent.sendWalkRun(gAgent.getRunning()); +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + gAgent.setTempRun(); +// [/RLVa:KB] } // Pressing any walk-key resets the double-tap timer diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index ac2940fcfccf6652f21f620ec7cda53563118182..17ddfeb890237c8f45f7e8749bd8c47c9f030895 100755 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -127,6 +127,10 @@ #include "llwindow.h" #include "llpathfindingmanager.h" #include "boost/unordered_map.hpp" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] using namespace LLAvatarAppearanceDefines; @@ -1180,7 +1184,15 @@ class LLAdvancedToggleWireframe : public view_listener_t { bool handleEvent(const LLSD& userdata) { - gUseWireframe = !(gUseWireframe); +// [RLVa:KB] - Checked: 2013-05-11 (RLVa-1.4.9) + bool fRlvBlockWireframe = gRlvAttachmentLocks.hasLockedHUD(); + if ( (!gUseWireframe) && (fRlvBlockWireframe) ) + { + RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_WIREFRAME); + } + gUseWireframe = (!gUseWireframe) && (!fRlvBlockWireframe); +// [/RLVa:KB] +// gUseWireframe = !(gUseWireframe); gWindowResized = TRUE; LLPipeline::updateRenderDeferred(); gPipeline.resetVertexBuffers(); @@ -2540,6 +2552,15 @@ void handle_object_touch() LLPickInfo pick = LLToolPie::getInstance()->getPick(); +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Modified: RLVa-1.1.0l + // NOTE: fallback code since we really shouldn't be getting an active selection if we can't touch this + if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canTouch(object, pick.mObjectOffset)) ) + { + RLV_ASSERT(false); + return; + } +// [/RLVa:KB] + // *NOTE: Hope the packets arrive safely and in order or else // there will be some problems. // *TODO: Just fix this bad assumption. @@ -2582,6 +2603,13 @@ bool enable_object_touch(LLUICtrl* ctrl) LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); bool new_value = obj && obj->flagHandleTouch(); +// [RLVa:KB] - Checked: 2010-11-12 (RLVa-1.2.1g) | Added: RLVa-1.2.1g + if ( (rlv_handler_t::isEnabled()) && (new_value) ) + { + // RELEASE-RLVa: [RLVa-1.2.1] Make sure this stays in sync with handle_object_touch() + new_value = gRlvHandler.canTouch(obj, LLToolPie::getInstance()->getPick().mObjectOffset); + } +// [/RLVa:KB] std::string item_name = ctrl->getName(); init_default_item_label(item_name); @@ -2615,7 +2643,11 @@ bool enable_object_touch(LLUICtrl* ctrl) void handle_object_open() { - LLFloaterReg::showInstance("openobject"); +// [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) | Added: RLVa-1.2.0e + if (enable_object_open()) + LLFloaterReg::showInstance("openobject"); +// [/RLVa:KB] +// LLFloaterReg::showInstance("openobject"); } bool enable_object_open() @@ -2842,7 +2874,17 @@ bool enable_object_edit() } else if (LLSelectMgr::getInstance()->selectGetAllValidAndObjectsFound()) { - enable = true; +// enable = true; +// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c + bool fRlvCanEdit = (!gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) && (!gRlvHandler.hasBehaviour(RLV_BHVR_EDITOBJ)); + if (!fRlvCanEdit) + { + LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection(); + RlvSelectIsEditable f; + fRlvCanEdit = (hSel.notNull()) && ((hSel->getFirstRootNode(&f, TRUE)) == NULL); + } + enable = fRlvCanEdit; +// [/RLVa:KB] } return enable; @@ -2892,7 +2934,10 @@ class LLSelfEnableRemoveAllAttachments : public view_listener_t { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; - if (attachment->getNumObjects() > 0) +// if (attachment->getNumObjects() > 0) +// [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.0a) | Added: RLVa-1.2.0a + if ( (attachment->getNumObjects() > 0) && ((!rlv_handler_t::isEnabled()) || (gRlvAttachmentLocks.canDetach(attachment))) ) +// [/RLVa:KB] { new_value = true; break; @@ -2935,7 +2980,10 @@ bool enable_object_mute() bool is_linden = lastname && !LLStringUtil::compareStrings(lastname->getString(), "Linden"); bool is_self = avatar->isSelf(); - return !is_linden && !is_self; +// return !is_linden && !is_self; +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Added: RLVa-1.2.1b + return !is_linden && !is_self && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES); +// [/RLVa:KB] } else { @@ -3042,6 +3090,10 @@ class LLObjectMute : public view_listener_t LLVOAvatar* avatar = find_avatar_from_object(object); if (avatar) { +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Added: RLVa-1.0.0e + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + return true; +// [/RLVa:KB] id = avatar->getID(); LLNameValue *firstname = avatar->getNVPair("FirstName"); @@ -3195,7 +3247,10 @@ void handle_avatar_freeze(const LLSD& avatar_id) if (!fullname.empty()) { LLSD args; - args["AVATAR_NAME"] = fullname; +// args["AVATAR_NAME"] = fullname; +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.0e + args["AVATAR_NAME"] = (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : RlvStrings::getAnonym(fullname); +// [/RLVa:KB] LLNotificationsUtil::add("FreezeAvatarFullname", args, payload, @@ -3324,7 +3379,10 @@ void handle_avatar_eject(const LLSD& avatar_id) if (!fullname.empty()) { LLSD args; - args["AVATAR_NAME"] = fullname; +// args["AVATAR_NAME"] = fullname; +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.0e + args["AVATAR_NAME"] = (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : RlvStrings::getAnonym(fullname); +// [/RLVa:KB] LLNotificationsUtil::add("EjectAvatarFullname", args, payload, @@ -3344,7 +3402,10 @@ void handle_avatar_eject(const LLSD& avatar_id) if (!fullname.empty()) { LLSD args; - args["AVATAR_NAME"] = fullname; +// args["AVATAR_NAME"] = fullname; +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.0e + args["AVATAR_NAME"] = (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : RlvStrings::getAnonym(fullname); +// [/RLVa:KB] LLNotificationsUtil::add("EjectAvatarFullnameNoBan", args, payload, @@ -3575,7 +3636,10 @@ class LLSelfStandUp : public view_listener_t bool enable_standup_self() { - return isAgentAvatarValid() && gAgentAvatarp->isSitting(); +// [RLVa:KB] - Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-1.0.0g + return isAgentAvatarValid() && gAgentAvatarp->isSitting() && !gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT); +// [/RLVa:KB] +// return isAgentAvatarValid() && gAgentAvatarp->isSitting(); } class LLSelfSitDown : public view_listener_t @@ -3589,7 +3653,10 @@ class LLSelfSitDown : public view_listener_t bool enable_sitdown_self() { - return isAgentAvatarValid() && !gAgentAvatarp->isSitting() && !gAgent.getFlying(); +// [RLVa:KB] - Checked: 2010-08-28 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + return isAgentAvatarValid() && !gAgentAvatarp->isSitting() && !gAgent.getFlying() && !gRlvHandler.hasBehaviour(RLV_BHVR_SIT); +// [/RLVa:KB] +// return isAgentAvatarValid() && !gAgentAvatarp->isSitting() && !gAgent.getFlying(); } class LLCheckPanelPeopleTab : public view_listener_t @@ -3833,7 +3900,10 @@ class LLAvatarEnableAddFriend : public view_listener_t bool handleEvent(const LLSD& userdata) { LLVOAvatar* avatar = find_avatar_from_object(LLSelectMgr::getInstance()->getSelection()->getPrimaryObject()); - bool new_value = avatar && !LLAvatarActions::isFriend(avatar->getID()); +// bool new_value = avatar && !LLAvatarActions::isFriend(avatar->getID()); +// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f + bool new_value = avatar && !LLAvatarActions::isFriend(avatar->getID()) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)); +// [/RLVa:KB] return new_value; } }; @@ -3867,7 +3937,10 @@ class LLEditEnableCustomizeAvatar : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = gAgentWearables.areWearablesLoaded(); +// bool new_value = gAgentWearables.areWearablesLoaded(); +// [RLVa:KB] - Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-1.0.0g + bool new_value = gAgentWearables.areWearablesLoaded() && ((!rlv_handler_t::isEnabled()) || (gRlvHandler.canStand())); +// [/RLVa:KB] return new_value; } }; @@ -3891,6 +3964,16 @@ class LLEnableEditPhysics : public view_listener_t bool is_object_sittable() { +// [RLVa:KB] - Checked: 2010-03-06 (RLVa-1.2.0c) | Added: RLVa-1.1.0j + // RELEASE-RLVa: [SL-2.2.0] Make sure we're examining the same object that handle_sit_or_stand() will request a sit for + if (rlv_handler_t::isEnabled()) + { + const LLPickInfo& pick = LLToolPie::getInstance()->getPick(); + if ( (pick.mObjectID.notNull()) && (!gRlvHandler.canSit(pick.getObject(), pick.mObjectOffset)) ) + return false; + } +// [/RLVa:KB] + LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); if (object && object->getPCode() == LL_PCODE_VOLUME) @@ -3922,8 +4005,23 @@ void handle_object_sit_or_stand() // get object selection offset - if (object && object->getPCode() == LL_PCODE_VOLUME) +// if (object && object->getPCode() == LL_PCODE_VOLUME) +// [RLVa:KB] - Checked: 2010-03-06 (RLVa-1.2.0c) | Modified: RLVa-1.2.0c + if ( (object && object->getPCode() == LL_PCODE_VOLUME) && + ((!rlv_handler_t::isEnabled()) || (gRlvHandler.canSit(object, pick.mObjectOffset))) ) +// [/RLVa:KB] { +// [RLVa:KB] - Checked: 2010-08-29 (RLVa-1.2.1c) | Added: RLVa-1.2.1c + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_STANDTP)) && (isAgentAvatarValid()) ) + { + if (gAgentAvatarp->isSitting()) + { + gAgent.standUp(); + return; + } + gRlvHandler.setSitSource(gAgent.getPositionGlobal()); + } +// [/RLVa:KB] gMessageSystem->newMessageFast(_PREHASH_AgentRequestSit); gMessageSystem->nextBlockFast(_PREHASH_AgentData); @@ -3953,6 +4051,11 @@ class LLLandSit : public view_listener_t { bool handleEvent(const LLSD& userdata) { +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.2.1f + if ( (rlv_handler_t::isEnabled()) && ((!gRlvHandler.canStand()) || (gRlvHandler.hasBehaviour(RLV_BHVR_SIT))) ) + return true; +// [/RLVa:KB] + gAgent.standUp(); LLViewerParcelMgr::getInstance()->deselectLand(); @@ -4491,6 +4594,17 @@ void handle_take_copy() { if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) return; +// [RLVa:KB] - Checked: 2010-03-07 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a + if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canStand()) ) + { + // Allow only if the avie isn't sitting on any of the selected objects + LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection(); + RlvSelectIsSittingOn f(gAgentAvatarp); + if ( (hSel.notNull()) && (hSel->getFirstRootNode(&f, TRUE) != NULL) ) + return; + } +// [/RLVa:KB] + const LLUUID category_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_OBJECT); derez_objects(DRD_ACQUIRE_TO_AGENT_INVENTORY, category_id); } @@ -4505,7 +4619,10 @@ class LLObjectReturn : public view_listener_t bool handleEvent(const LLSD& userdata) { if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) return true; - +// [RLVa:KB] - Checked: 2010-03-24 (RLVa-1.4.0a) | Modified: RLVa-1.0.0b + if ( (rlv_handler_t::isEnabled()) && (!rlvCanDeleteOrReturn()) ) return true; +// [/RLVa:KB] + mObjectSelection = LLSelectMgr::getInstance()->getEditSelection(); // Save selected objects, so that we still know what to return after the confirmation dialog resets selection. @@ -4552,6 +4669,12 @@ class LLObjectEnableReturn : public view_listener_t // Do not enable if nothing selected return false; } +// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a + if ( (rlv_handler_t::isEnabled()) && (!rlvCanDeleteOrReturn()) ) + { + return false; + } +// [/RLVa:KB] #ifdef HACKED_GODLIKE_VIEWER bool new_value = true; #else @@ -4580,11 +4703,14 @@ void handle_take() { // we want to use the folder this was derezzed from if it's // available. Otherwise, derez to the normal place. - if(LLSelectMgr::getInstance()->getSelection()->isEmpty()) +// if(LLSelectMgr::getInstance()->getSelection()->isEmpty()) +// [RLVa:KB] - Checked: 2010-03-24 (RLVa-1.2.0e) | Modified: RLVa-1.0.0b + if ( (LLSelectMgr::getInstance()->getSelection()->isEmpty()) || ((rlv_handler_t::isEnabled()) && (!rlvCanDeleteOrReturn())) ) +// [/RLVa:KB] { return; } - + BOOL you_own_everything = TRUE; BOOL locked_but_takeable_object = FALSE; LLUUID category_id; @@ -4727,7 +4853,10 @@ bool confirm_take(const LLSD& notification, const LLSD& response, LLObjectSelect // one item selected can be copied to inventory. BOOL enable_take() { - if (sitting_on_selection()) +// if (sitting_on_selection()) +// [RLVa:KB] - Checked: 2010-03-24 (RLVa-1.2.0e) | Modified: RLVa-1.0.0b + if ( (sitting_on_selection()) || ((rlv_handler_t::isEnabled()) && (!rlvCanDeleteOrReturn())) ) +// [/RLVa:KB] { return FALSE; } @@ -5193,8 +5322,12 @@ class LLToolsReleaseKeys : public view_listener_t { bool handleEvent(const LLSD& userdata) { - gAgent.forceReleaseControls(); +// [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.0f) | Modified: RLVa-1.0.5a + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_REMOVE)) ) + return true; +// [/RLVa:KB] + gAgent.forceReleaseControls(); return true; } }; @@ -5203,7 +5336,11 @@ class LLToolsEnableReleaseKeys : public view_listener_t { bool handleEvent(const LLSD& userdata) { - return gAgent.anyControlGrabbed(); +// [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.0f) | Modified: RLVa-1.0.5a + return (gAgent.anyControlGrabbed()) && + ( (!rlv_handler_t::isEnabled()) || (!gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_REMOVE)) ); +// [/RLVa:KB] +// return gAgent.anyControlGrabbed(); } }; @@ -5600,6 +5737,11 @@ void show_debug_menus() gMenuBarView->setItemVisible("Advanced", debug); // gMenuBarView->setItemEnabled("Advanced", debug); // Don't disable Advanced keyboard shortcuts when hidden + +// [RLVa:KB] - Checked: 2011-08-16 (RLVa-1.4.0b) | Modified: RLVa-1.4.0b + // NOTE: this is supposed to execute whether RLVa is enabled or not + rlvMenuToggleVisible(); +// [/RLVa:KB] gMenuBarView->setItemVisible("Debug", qamode); gMenuBarView->setItemEnabled("Debug", qamode); @@ -5696,16 +5838,16 @@ class LLWorldAlwaysRun : public view_listener_t if (gAgent.getAlwaysRun()) { gAgent.clearAlwaysRun(); - gAgent.clearRunning(); +// gAgent.clearRunning(); } else { gAgent.setAlwaysRun(); - gAgent.setRunning(); +// gAgent.setRunning(); } // tell the simulator. - gAgent.sendWalkRun(gAgent.getAlwaysRun()); +// gAgent.sendWalkRun(gAgent.getAlwaysRun()); // Update Movement Controls according to AlwaysRun mode LLFloaterMove::setAlwaysRunMode(gAgent.getAlwaysRun()); @@ -5760,6 +5902,11 @@ class LLWorldCreateLandmark : public view_listener_t { bool handleEvent(const LLSD& userdata) { +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.4.5) | Added: RLVa-1.0.0 + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + return true; +// [/RLVa:KB] + LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "create_landmark")); return true; @@ -5770,12 +5917,24 @@ class LLWorldPlaceProfile : public view_listener_t { bool handleEvent(const LLSD& userdata) { +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + return true; +// [/RLVa:KB] + LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "agent")); return true; } }; +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 +bool enable_place_profile() +{ + return LLFloaterSidePanelContainer::canShowPanel("places", LLSD().with("type", "agent")); +} +// [/RLVa:KB] + void handle_look_at_selection(const LLSD& param) { const F32 PADDING_FACTOR = 1.75f; @@ -5845,7 +6004,10 @@ class LLAvatarInviteToGroup : public view_listener_t bool handleEvent(const LLSD& userdata) { LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); - if(avatar) +// if(avatar) +// [RLVa:KB] - Checked: 2010-06-04 (RLVa-1.2.0d) | Added: RLVa-1.2.0d + if ( (avatar) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ) +// [/RLVa:KB] { LLAvatarActions::inviteToGroup(avatar->getID()); } @@ -5858,7 +6020,10 @@ class LLAvatarAddFriend : public view_listener_t bool handleEvent(const LLSD& userdata) { LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); - if(avatar && !LLAvatarActions::isFriend(avatar->getID())) +// if(avatar && !LLAvatarActions::isFriend(avatar->getID())) +// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f + if ( (avatar && !LLAvatarActions::isFriend(avatar->getID())) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ) +// [/RLVa:KB] { request_friendship(avatar->getID()); } @@ -5899,7 +6064,10 @@ class LLAvatarAddContact : public view_listener_t bool handleEvent(const LLSD& userdata) { LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); - if(avatar) +// if(avatar) +// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f + if ( (avatar) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ) +// [/RLVa:KB] { create_inventory_callingcard(avatar->getID()); } @@ -5963,7 +6131,10 @@ bool enable_pay_avatar() { LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); LLVOAvatar* avatar = find_avatar_from_object(obj); - return (avatar != NULL); +// return (avatar != NULL); +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Added: RLVa-1.2.1b + return (avatar != NULL) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)); +// [/RLVa:KB] } bool enable_pay_object() @@ -5983,7 +6154,10 @@ bool enable_pay_object() bool enable_object_stand_up() { // 'Object Stand Up' menu item is enabled when agent is sitting on selection - return sitting_on_selection(); +// return sitting_on_selection(); +// [RLVa:KB] - Checked: 2010-07-24 (RLVa-1.2.0g) | Added: RLVa-1.2.0g + return sitting_on_selection() && ( (!rlv_handler_t::isEnabled()) || (gRlvHandler.canStand()) ); +// [/RLVa:KB] } bool enable_object_sit(LLUICtrl* ctrl) @@ -6008,6 +6182,17 @@ bool enable_object_sit(LLUICtrl* ctrl) gMenuHolder->childSetText(item_name, get_default_item_label(item_name)); } } + +// [RLVa:KB] - Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-1.2.0c + // RELEASE-RLVA: [SL-2.2.0] Make this match what happens in handle_object_sit_or_stand() + if (rlv_handler_t::isEnabled()) + { + const LLPickInfo& pick = LLToolPie::getInstance()->getPick(); + if (pick.mObjectID.notNull()) + sitting_on_sel = !gRlvHandler.canSit(pick.getObject(), pick.mObjectOffset); + } +// [/RLVa:KB] + return !sitting_on_sel && is_object_sittable(); } @@ -6257,7 +6442,10 @@ class LLShowAgentProfile : public view_listener_t } LLVOAvatar* avatar = find_avatar_from_object(agent_id); - if (avatar) +// if (avatar) +// [RLVa:KB] - Checked: 2010-06-04 (RLVa-1.2.0d) | Modified: RLVa-1.2.0d + if ( (avatar) && ((!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (gAgent.getID() == agent_id)) ) +// [/RLVa:KB] { LLAvatarActions::showProfile(avatar->getID()); } @@ -6406,6 +6594,19 @@ class LLObjectAttachToAvatar : public view_listener_t LLViewerJointAttachment* attachment_point = NULL; if (index > 0) attachment_point = get_if_there(gAgentAvatarp->mAttachmentPoints, index, (LLViewerJointAttachment*)NULL); + +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.2.1f + // RELEASE-RLVa: [SL-2.2.0] If 'index != 0' then the object will be "add attached" [see LLSelectMgr::sendAttach()] + if ( (rlv_handler_t::isEnabled()) && + ( ((!index) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY))) || // Can't wear on default + ((index) && ((RLV_WEAR_ADD & gRlvAttachmentLocks.canAttach(attachment_point)) == 0)) || // or non-attachable attachpt + (gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) ) ) // Attach on object == "Take" + { + setObjectSelection(NULL); // Clear the selection or it'll get stuck + return true; + } +// [/RLVa:KB] + confirmReplaceAttachment(0, attachment_point); } return true; @@ -6550,6 +6751,24 @@ class LLAttachmentDrop : public view_listener_t { bool handleEvent(const LLSD& userdata) { +// [RLVa:KB] - Checked: 2010-03-15 (RLVa-1.2.0e) | Modified: RLVa-1.0.5 + if (rlv_handler_t::isEnabled()) + { + if (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_REMOVE)) + { + // NOTE: copy/paste of the code in enable_detach() + LLObjectSelectionHandle hSelect = LLSelectMgr::getInstance()->getSelection(); + RlvSelectHasLockedAttach f; + if ( (hSelect->isAttachment()) && (hSelect->getFirstRootNode(&f, FALSE) != NULL) ) + return true; + } + if (gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) + { + return true; + } + } +// [/RLVa:KB] + LLSD payload; LLViewerObject *object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); @@ -6575,14 +6794,21 @@ class LLAttachmentDetachFromPoint : public view_listener_t { uuid_vec_t ids_to_remove; const LLViewerJointAttachment *attachment = get_if_there(gAgentAvatarp->mAttachmentPoints, user_data.asInteger(), (LLViewerJointAttachment*)NULL); - if (attachment->getNumObjects() > 0) +// if (attachment->getNumObjects() > 0) +// [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.0a) | Added: RLVa-1.2.0a + if ( (attachment->getNumObjects() > 0) && ((!rlv_handler_t::isEnabled()) || (gRlvAttachmentLocks.canDetach(attachment))) ) +// [/RLVa:KB] { for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator iter = attachment->mAttachedObjects.begin(); iter != attachment->mAttachedObjects.end(); iter++) { LLViewerObject *attached_object = (*iter); +// [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.0a) | Added: RLVa-1.2.0a + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.isLockedAttachment(attached_object)) ) + continue; ids_to_remove.push_back(attached_object->getAttachmentItemID()); +// [/RLVa:KB] } } if (!ids_to_remove.empty()) @@ -6595,6 +6821,10 @@ class LLAttachmentDetachFromPoint : public view_listener_t static bool onEnableAttachmentLabel(LLUICtrl* ctrl, const LLSD& data) { +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.2.1f + // RELEASE-RLVa: [SL-2.2.0] When attaching to a specific point the object will be "add attached" [see LLSelectMgr::sendAttach()] + bool fRlvEnable = true; +// [/RLVa:KB] std::string label; LLMenuItemGL* menu = dynamic_cast<LLMenuItemGL*>(ctrl); if (menu) @@ -6619,9 +6849,18 @@ static bool onEnableAttachmentLabel(LLUICtrl* ctrl, const LLSD& data) } } } + +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.2.1f + if (rlv_handler_t::isEnabled()) + fRlvEnable = (!gRlvAttachmentLocks.isLockedAttachmentPoint(attachment, RLV_LOCK_ADD)); +// [/RLVa:KB] + menu->setLabel(label); } - return true; +// return true; +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0a) | Added: RLVa-1.2.0a + return fRlvEnable; +// [/RLVa:KB] } class LLAttachmentDetach : public view_listener_t @@ -6660,6 +6899,17 @@ class LLAttachmentDetach : public view_listener_t return true; } +// [RLVa:KB] - Checked: 2010-03-15 (RLVa-1.2.0a) | Modified: RLVa-1.0.5 + // NOTE: copy/paste of the code in enable_detach() + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_REMOVE)) ) + { + LLObjectSelectionHandle hSelect = LLSelectMgr::getInstance()->getSelection(); + RlvSelectHasLockedAttach f; + if ( (hSelect->isAttachment()) && (hSelect->getFirstRootNode(&f, FALSE) != NULL) ) + return true; + } +// [/RLVa:KB] + LLAppearanceMgr::instance().removeItemFromAvatar(object->getAttachmentItemID()); return true; @@ -6736,7 +6986,10 @@ class LLAttachmentEnableDrop : public view_listener_t } //now check to make sure that the item is actually in the inventory before we enable dropping it - bool new_value = enable_detach() && can_build && item; +// bool new_value = enable_detach() && can_build && item; +// [RLVa:KB] - Checked: 2010-03-24 (RLVa-1.0.0b) | Modified: RLVa-1.0.0b + bool new_value = enable_detach() && can_build && item && (!gRlvHandler.hasBehaviour(RLV_BHVR_REZ)); +// [/RLVa:KB] return new_value; } @@ -6761,6 +7014,20 @@ BOOL enable_detach(const LLSD&) // ...if it's you, good to detach if (avatar->getID() == gAgent.getID()) { +// [RLVa:KB] - Checked: 2010-03-15 (RLVa-1.2.0a) | Modified: RLVa-1.0.5 + // NOTE: this code is reused as-is in LLAttachmentDetach::handleEvent() and LLAttachmentDrop::handleEvent() + // so any changes here should be reflected there as well + + // RELEASE-RLVa: [SL-2.2.0] LLSelectMgr::sendDetach() and LLSelectMgr::sendDropAttachment() call sendListToRegions with + // SEND_ONLY_ROOTS so we only need to examine the roots which saves us time + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_REMOVE)) ) + { + LLObjectSelectionHandle hSelect = LLSelectMgr::getInstance()->getSelection(); + RlvSelectHasLockedAttach f; + if ( (hSelect->isAttachment()) && (hSelect->getFirstRootNode(&f, FALSE) != NULL) ) + return FALSE; + } +// [/RLVa:KB] return TRUE; } @@ -6780,8 +7047,33 @@ class LLAttachmentEnableDetach : public view_listener_t }; // Used to tell if the selected object can be attached to your avatar. -BOOL object_selected_and_point_valid() +//BOOL object_selected_and_point_valid() +// [RLVa:KB] - Checked: 2010-03-16 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +BOOL object_selected_and_point_valid(const LLSD& sdParam) +// [/RLVa:KB] { +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.2.1f + if (rlv_handler_t::isEnabled()) + { + if (!isAgentAvatarValid()) + return FALSE; + + // RELEASE-RLVa: [SL-2.2.0] Look at the caller graph for this function on every new release + // - object_is_wearable() => dead code [sdParam == 0 => default attach point => OK!] + // - enabler set up in LLVOAvatarSelf::buildMenus() => Rezzed prim / Put On / "Attach To" [sdParam == idxAttachPt] + // - "Object.EnableWear" enable => Rezzed prim / Put On / "Wear" or "Add" [sdParam blank] + // RELEASE-RLVa: [SL-2.2.0] If 'idxAttachPt != 0' then the object will be "add attached" [see LLSelectMgr::sendAttach()] + const LLViewerJointAttachment* pAttachPt = + get_if_there(gAgentAvatarp->mAttachmentPoints, sdParam.asInteger(), (LLViewerJointAttachment*)NULL); + if ( ((!pAttachPt) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY))) || // Can't wear on default attach point + ((pAttachPt) && ((RLV_WEAR_ADD & gRlvAttachmentLocks.canAttach(pAttachPt)) == 0)) || // or non-attachable attach point + (gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) ) // Attach on object == "Take" + { + return FALSE; + } + } +// [/RLVa:KB] + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); for (LLObjectSelection::root_iterator iter = selection->root_begin(); iter != selection->root_end(); iter++) @@ -6810,9 +7102,12 @@ BOOL object_selected_and_point_valid() } +// [RLVa:KB] - Checked: 2010-03-16 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +/* BOOL object_is_wearable() { - if (!object_selected_and_point_valid()) +// if (!object_selected_and_point_valid()) + if (!object_selected_and_point_valid(LLSD(0))) { return FALSE; } @@ -6832,7 +7127,8 @@ BOOL object_is_wearable() } return FALSE; } - +*/ +// [/RLVa:KB] class LLAttachmentPointFilled : public view_listener_t { @@ -6842,7 +7138,12 @@ class LLAttachmentPointFilled : public view_listener_t LLVOAvatar::attachment_map_t::iterator found_it = gAgentAvatarp->mAttachmentPoints.find(user_data.asInteger()); if (found_it != gAgentAvatarp->mAttachmentPoints.end()) { - enable = found_it->second->getNumObjects() > 0; +// enable = found_it->second->getNumObjects() > 0; +// [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.0a) | Added: RLVa-1.2.0a + // Enable the option if there is at least one attachment on this attachment point that can be detached + enable = (found_it->second->getNumObjects() > 0) && + ((!rlv_handler_t::isEnabled()) || (gRlvAttachmentLocks.canDetach(found_it->second))); +// [/RLVa:KB] } return enable; } @@ -6853,7 +7154,10 @@ class LLAvatarSendIM : public view_listener_t bool handleEvent(const LLSD& userdata) { LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); - if(avatar) +// if(avatar) +// [RLVa:KB] - Checked: 2010-06-04 (RLVa-1.2.0d) | Added: RLVa-1.2.0d + if ( (avatar) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ) +// [/RLVa:KB] { LLAvatarActions::startIM(avatar->getID()); } @@ -6866,7 +7170,10 @@ class LLAvatarCall : public view_listener_t bool handleEvent(const LLSD& userdata) { LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); - if(avatar) +// if(avatar) +// [RLVa:KB] - Checked: 2010-06-04 (RLVa-1.2.0d) | Added: RLVa-1.2.0d + if ( (avatar) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ) +// [/RLVa:KB] { LLAvatarActions::startCall(avatar->getID()); } @@ -6874,6 +7181,13 @@ class LLAvatarCall : public view_listener_t } }; +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Added: RLVa-1.2.1b +bool enable_avatar_call() +{ + return (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (LLAvatarActions::canCall()); +} +// [/RLVa:KB] + namespace { struct QueueObjects : public LLSelectedObjectFunctor @@ -6936,6 +7250,17 @@ class LLToolsSelectedScriptAction : public view_listener_t { bool handleEvent(const LLSD& userdata) { +// [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.0f) | Modified: RLVa-1.0.5a + // We'll allow resetting the scripts of objects on a non-attachable attach point since they wouldn't be able to circumvent anything + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_REMOVE)) ) + { + LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection(); + RlvSelectHasLockedAttach f; + if ( (hSel->isAttachment()) && (hSel->getFirstNode(&f) != NULL) ) + return true; + } +// [/RLVa:KB] + std::string action = userdata.asString(); bool mono = false; std::string msg, name; @@ -7084,12 +7409,30 @@ void handle_selected_material_info() void handle_test_male(void*) { +// [RLVa:KB] - Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a + // TODO-RLVa: [RLVa-1.2.1] Is there any reason to still block this? + if ( (rlv_handler_t::isEnabled()) && + ((gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY)) || (gRlvWearableLocks.hasLockedWearableType(RLV_LOCK_ANY))) ) + { + return; + } +// [/RLVa:KB] + LLAppearanceMgr::instance().wearOutfitByName("Male Shape & Outfit"); //gGestureList.requestResetFromServer( TRUE ); } void handle_test_female(void*) { +// [RLVa:KB] - Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a + // TODO-RLVa: [RLVa-1.2.1] Is there any reason to still block this? + if ( (rlv_handler_t::isEnabled()) && + ((gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY)) || (gRlvWearableLocks.hasLockedWearableType(RLV_LOCK_ANY))) ) + { + return; + } +// [/RLVa:KB] + LLAppearanceMgr::instance().wearOutfitByName("Female Shape & Outfit"); //gGestureList.requestResetFromServer( FALSE ); } @@ -7247,6 +7590,22 @@ class LLSomethingSelectedNoHUD : public view_listener_t static bool is_editable_selected() { +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.0.5a + // RELEASE-RLVa: [SL-2.2.0] Check that this still isn't called by anything but script actions in the Build menu + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_REMOVE)) ) + { + LLObjectSelectionHandle hSelection = LLSelectMgr::getInstance()->getSelection(); + + // NOTE: this is called for 5 different menu items so we'll trade accuracy for efficiency and only + // examine root nodes (LLToolsSelectedScriptAction::handleEvent() will catch what we miss) + RlvSelectHasLockedAttach f; + if ( (hSelection->isAttachment()) && (hSelection->getFirstRootNode(&f)) ) + { + return false; + } + } +// [/RLVa:KB] + return (LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject() != NULL); } @@ -7291,7 +7650,11 @@ bool enable_object_take_copy() { virtual bool apply(LLViewerObject* obj) { - return (!obj->permCopy() || obj->isAttachment()); +// return (!obj->permCopy() || obj->isAttachment()); +// [RLVa:KB] - Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-1.0.0g + return (!obj->permCopy() || obj->isAttachment()) || + ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) && (isAgentAvatarValid()) && (gAgentAvatarp->getRoot() == obj) ); +// [/RLVa:KB] } } func; const bool firstonly = true; @@ -7396,7 +7759,10 @@ class LLWorldEnableCreateLandmark : public view_listener_t { bool handleEvent(const LLSD& userdata) { - return !LLLandmarkActions::landmarkAlreadyExists(); +// return !LLLandmarkActions::landmarkAlreadyExists(); +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.4.5) | Added: RLVa-1.2.1 + return (!LLLandmarkActions::landmarkAlreadyExists()) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); +// [/RLVa:KB] } }; @@ -7417,6 +7783,10 @@ class LLWorldEnableTeleportHome : public view_listener_t LLViewerRegion* regionp = gAgent.getRegion(); bool agent_on_prelude = (regionp && regionp->isPrelude()); bool enable_teleport_home = gAgent.isGodlike() || !agent_on_prelude; +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.2.1f + enable_teleport_home &= + (!rlv_handler_t::isEnabled()) || ((!gRlvHandler.hasBehaviour(RLV_BHVR_TPLM)) && (!gRlvHandler.hasBehaviour(RLV_BHVR_TPLOC))); +// [/RLVa:KB] return enable_teleport_home; } }; @@ -7867,7 +8237,10 @@ class LLViewHighlightTransparent : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLDrawPoolAlpha::sShowDebugAlpha = !LLDrawPoolAlpha::sShowDebugAlpha; +// LLDrawPoolAlpha::sShowDebugAlpha = !LLDrawPoolAlpha::sShowDebugAlpha; +// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c + LLDrawPoolAlpha::sShowDebugAlpha = (!LLDrawPoolAlpha::sShowDebugAlpha) && (!gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)); +// [/RLVa:KB] return true; } }; @@ -8079,6 +8452,11 @@ class LLViewShowHUDAttachments : public view_listener_t { bool handleEvent(const LLSD& userdata) { +// [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.1a) | Modified: RLVa-1.0.0c + if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.hasLockedHUD()) && (LLPipeline::sShowHUDAttachments) ) + return true; +// [/RLVa:KB] + LLPipeline::sShowHUDAttachments = !LLPipeline::sShowHUDAttachments; return true; } @@ -8099,8 +8477,15 @@ class LLEditEnableTakeOff : public view_listener_t { std::string clothing = userdata.asString(); LLWearableType::EType type = LLWearableType::typeNameToType(clothing); - if (type >= LLWearableType::WT_SHAPE && type < LLWearableType::WT_COUNT) +// if (type >= LLWearableType::WT_SHAPE && type < LLWearableType::WT_COUNT) +// [RLVa:KB] - Checked: 2010-03-20 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a + // NOTE: see below - enable if there is at least one wearable on this type that can be removed + if ( (type >= LLWearableType::WT_SHAPE && type < LLWearableType::WT_COUNT) && + ((!rlv_handler_t::isEnabled()) || (gRlvWearableLocks.canRemove(type))) ) +// [/RLVa:KB] + { return LLAgentWearables::selfHasWearable(type); + } return false; } }; @@ -8121,6 +8506,22 @@ class LLEditTakeOff : public view_listener_t { // MULTI-WEARABLES: assuming user wanted to remove top shirt. U32 wearable_index = gAgentWearables.getWearableCount(type) - 1; + +// [RLVa:KB] - Checked: 2010-06-09 (RLVa-1.2.0g) | Added: RLVa-1.2.0g + if ( (rlv_handler_t::isEnabled()) && (gRlvWearableLocks.hasLockedWearable(type)) ) + { + // We'll use the first wearable we come across that can be removed (moving from top to bottom) + for (; wearable_index >= 0; wearable_index--) + { + const LLViewerWearable* pWearable = gAgentWearables.getViewerWearable(type, wearable_index); + if (!gRlvWearableLocks.isLockedWearable(pWearable)) + break; + } + if (wearable_index < 0) + return true; // No wearable found that can be removed + } +// [/RLVa:KB] + LLUUID item_id = gAgentWearables.getWearableItemID(type,wearable_index); LLAppearanceMgr::instance().removeItemFromAvatar(item_id); } @@ -8164,6 +8565,11 @@ class LLWorldEnvSettings : public view_listener_t { bool handleEvent(const LLSD& userdata) { +// [RLVa:KB] - Checked: 2010-03-18 (RLVa-1.2.0a) | Modified: RLVa-1.0.0g + if (gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)) + return true; +// [/RLVa:KB] + std::string tod = userdata.asString(); if (tod == "editor") @@ -8188,6 +8594,12 @@ class LLWorldEnvSettings : public view_listener_t { LLEnvManagerNew::instance().setUseSkyPreset("Midnight"); } +// [RLVa:KB] - Checked: 2011-09-03 (RLVa-1.4.1a) | Added: RLVa-1.4.1a + else if ("default" == tod) + { + LLEnvManagerNew::instance().setUseRegionSettings(true); + } +// [/RLVa:KB] else { LLEnvManagerNew &envmgr = LLEnvManagerNew::instance(); @@ -8385,6 +8797,9 @@ void show_topinfobar_context_menu(LLView* ctrl, S32 x, S32 y) { landmark_item->setLabel(LLTrans::getString("EditLandmarkNavBarMenu")); } +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 + landmark_item->setEnabled(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); +// [/RLVa:KB] if(gMenuHolder->hasVisibleMenu()) { @@ -8535,6 +8950,9 @@ void initialize_menus() view_listener_t::addMenu(new LLWorldSetDoNotDisturb(), "World.SetDoNotDisturb"); view_listener_t::addMenu(new LLWorldEnableCreateLandmark(), "World.EnableCreateLandmark"); +// [RLVa:KB] + enable.add("World.EnablePlaceProfile", boost::bind(&enable_place_profile)); +// [/RLVa:KB] view_listener_t::addMenu(new LLWorldEnableSetHomeLocation(), "World.EnableSetHomeLocation"); view_listener_t::addMenu(new LLWorldEnableTeleportHome(), "World.EnableTeleportHome"); view_listener_t::addMenu(new LLWorldEnableBuyLand(), "World.EnableBuyLand"); @@ -8796,7 +9214,10 @@ void initialize_menus() commit.add("Avatar.ShowInspector", boost::bind(&handle_avatar_show_inspector)); view_listener_t::addMenu(new LLAvatarSendIM(), "Avatar.SendIM"); view_listener_t::addMenu(new LLAvatarCall(), "Avatar.Call"); - enable.add("Avatar.EnableCall", boost::bind(&LLAvatarActions::canCall)); +// enable.add("Avatar.EnableCall", boost::bind(&LLAvatarActions::canCall)); +// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Added: RLVa-1.2.1b + enable.add("Avatar.EnableCall", boost::bind(&enable_avatar_call)); +// [/RLVa:KB] view_listener_t::addMenu(new LLAvatarReportAbuse(), "Avatar.ReportAbuse"); view_listener_t::addMenu(new LLAvatarToggleMyProfile(), "Avatar.ToggleMyProfile"); enable.add("Avatar.IsMyProfileOpen", boost::bind(&my_profile_visible)); @@ -8829,7 +9250,10 @@ void initialize_menus() enable.add("Object.EnableOpen", boost::bind(&enable_object_open)); enable.add("Object.EnableTouch", boost::bind(&enable_object_touch, _1)); enable.add("Object.EnableDelete", boost::bind(&enable_object_delete)); - enable.add("Object.EnableWear", boost::bind(&object_selected_and_point_valid)); +// enable.add("Object.EnableWear", boost::bind(&object_selected_and_point_valid)); +// [RLVa:KB] - Checked: 2010-03-16 (RLVa-1.2.0a) | Added: RLVa-1.2.0a + enable.add("Object.EnableWear", boost::bind(&object_selected_and_point_valid, _2)); +// [/RLVa:KB] enable.add("Object.EnableStandUp", boost::bind(&enable_object_stand_up)); enable.add("Object.EnableSit", boost::bind(&enable_object_sit, _1)); @@ -8898,4 +9322,13 @@ void initialize_menus() view_listener_t::addMenu(new LLEditableSelected(), "EditableSelected"); view_listener_t::addMenu(new LLEditableSelectedMono(), "EditableSelectedMono"); view_listener_t::addMenu(new LLToggleUIHints(), "ToggleUIHints"); + +// [RLVa:KB] - Checked: 2010-04-23 (RLVa-1.2.0g) | Added: RLVa-1.2.0 + commit.add("RLV.ToggleEnabled", boost::bind(&rlvMenuToggleEnabled)); + enable.add("RLV.CheckEnabled", boost::bind(&rlvMenuCheckEnabled)); + if (rlv_handler_t::isEnabled()) + { + enable.add("RLV.EnableIfNot", boost::bind(&rlvMenuEnableIfNot, _2)); + } +// [/RLVa:KB] } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index ab9ea5618e87230640d52639022b1ef55c8c154f..c5c3e8c80ef77333f2f68b3bdae42ce12fb89e36 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -110,6 +110,12 @@ #include "llpanelblockedlist.h" #include "llpanelplaceprofile.h" #include "llviewerregion.h" +// [RLVa:KB] - Checked: 2010-03-09 (RLVa-1.2.0a) +#include "rlvactions.h" +#include "rlvhandler.h" +#include "rlvinventory.h" +#include "rlvui.h" +// [/RLVa:KB] #include <boost/algorithm/string/split.hpp> // #include <boost/regex.hpp> @@ -267,7 +273,18 @@ bool friendship_offer_callback(const LLSD& notification, const LLSD& response) // modified_form->setElementEnabled("Accept", false); // modified_form->setElementEnabled("Decline", false); // notification_ptr->updateForm(modified_form); - // notification_ptr->repost(); +// [SL:KB] - Patch: UI-Notifications | Checked: 2013-05-09 (Catznip-3.5) +// // Assume that any offer notification with "getCanBeStored() == true" is the result of RLVa routing it to the notifcation syswell +// /*const*/ LLNotificationsUI::LLScreenChannel* pChannel = LLNotificationsUI::LLChannelManager::instance().getNotificationScreenChannel(); +// /*const*/ LLNotificationsUI::LLToast* pToast = (pChannel) ? pChannel->getToastByNotificationID(notification["id"].asUUID()) : NULL; +// if ( (!pToast) || (!pToast->getCanBeStored()) ) +// { +// [/SL:KB] +// notification_ptr->repost(); +// [SL:KB] - Patch: UI-Notifications | Checked: 2013-05-09 (Catznip-3.5) +// } +// [/SL:KB] + } return false; @@ -1477,7 +1494,15 @@ void LLOfferInfo::send_auto_receive_response(void) if(IM_INVENTORY_OFFERED == mIM) { // add buddy to recent people list - LLRecentPeople::instance().add(mFromID); +// LLRecentPeople::instance().add(mFromID); +// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.2a) | Added: RLVa-1.2.0f + // RELEASE-RLVa: [RLVa-1.2.2] Make sure this stays in sync with the condition in inventory_offer_handler() + if ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (!RlvUtil::isNearbyAgent(mFromID)) || + (RlvUIEnabler::hasOpenIM(mFromID)) || ((RlvUIEnabler::hasOpenProfile(mFromID))) ) + { + LLRecentPeople::instance().add(mFromID); + } +// [/RLVa:KB] } } @@ -1547,6 +1572,19 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& // This is an offer from an agent. In this case, the back // end has already copied the items into your inventory, // so we can fetch it out of our inventory. +// [RLVa:KB] - Checked: 2010-04-18 (RLVa-1.2.0e) | Modified: RLVa-1.2.0e + if ( (rlv_handler_t::isEnabled()) && (!RlvSettings::getForbidGiveToRLV()) && (LLAssetType::AT_CATEGORY == mType) && + (RlvInventory::instance().getSharedRoot()) && (mDesc.find(RLV_PUTINV_PREFIX) == 0) ) + { + RlvGiveToRLVAgentOffer* pOfferObserver = new RlvGiveToRLVAgentOffer(mObjectID); + pOfferObserver->startFetch(); + if (pOfferObserver->isFinished()) + pOfferObserver->done(); + else + gInventory.addObserver(pOfferObserver); + } +// [/RLVa:KB] + if (gSavedSettings.getBOOL("ShowOfferedInventory")) { LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(mObjectID, from_string); @@ -1728,6 +1766,7 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const } else { +/* std::string full_name; if (gCacheName->getFullName(mFromID, full_name)) { @@ -1741,6 +1780,20 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const + mFromName + LLTrans::getString("'")+" " + LLTrans::getString("InvOfferOwnedByUnknownUser"); chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedByUnknownUser"); } +*/ +// [SL:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + std::string name_slurl = LLSLURL("agent", mFromID, "about").getSLURLString(); + +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + // RELEASE-RLVa: [RLVa-1.2.2] Make sure this stays in sync with the condition in inventory_offer_handler() + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(mFromID)) ) + name_slurl = LLSLURL("agent", mFromID, "rlvanonym").getSLURLString(); +// [/RLVa:KB] + + from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+ LLTrans::getString("'") + mFromName + + LLTrans::getString("'")+" " + LLTrans::getString("InvOfferOwnedBy") + name_slurl; + chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedBy") + " " + name_slurl; +// [/SL:KB] } } else @@ -1750,12 +1803,40 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const bool is_do_not_disturb = gAgent.isDoNotDisturb(); +// [RLVa:KB] - Checked: 2010-09-23 (RLVa-1.2.1e) | Added: RLVa-1.2.1e + bool fRlvNotifyAccepted = false; +// [/RLVa:KB] switch(button) { case IOR_ACCEPT: // ACCEPT. The math for the dialog works, because the accept // for inventory_offered, task_inventory_offer or // group_notice_inventory is 1 greater than the offer integer value. + +// [RLVa:KB] - Checked: 2010-09-23 (RLVa-1.2.1e) | Modified: RLVa-1.2.1e + // Only change the inventory offer's destination folder to the shared root if: + // - the user has enabled the feature + // - the inventory offer came from a script (and specifies a folder) + // - the name starts with the prefix - mDesc format: '[OBJECTNAME]' ( http://slurl.com/... ) + if ( (rlv_handler_t::isEnabled()) && + (IM_TASK_INVENTORY_OFFERED == mIM) && (LLAssetType::AT_CATEGORY == mType) && (mDesc.find(RLV_PUTINV_PREFIX) == 1) ) + { + fRlvNotifyAccepted = true; + if (!RlvSettings::getForbidGiveToRLV()) + { + const LLViewerInventoryCategory* pRlvRoot = RlvInventory::instance().getSharedRoot(); + if (pRlvRoot) + { + fRlvNotifyAccepted = false; // "accepted_in_rlv" is sent from RlvGiveToRLVTaskOffer *after* we have the folder + mFolderID = pRlvRoot->getUUID(); + + RlvGiveToRLVTaskOffer* pOfferObserver = new RlvGiveToRLVTaskOffer(mTransactionID); + gInventory.addObserver(pOfferObserver); + } + } + } +// [/RLVa:KB] + // Generates IM_INVENTORY_ACCEPTED, IM_TASK_INVENTORY_ACCEPTED, // or IM_GROUP_NOTICE_INVENTORY_ACCEPTED msg->addU8Fast(_PREHASH_Dialog, (U8)(mIM + 1)); @@ -1764,6 +1845,15 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const // send the message msg->sendReliable(mHost); +// [RLVa:KB] - Checked: 2010-09-23 (RLVa-1.2.1e) | Added: RLVa-1.2.1e + if (fRlvNotifyAccepted) + { + std::string::size_type idxToken = mDesc.find("' ( http://"); + if (std::string::npos != idxToken) + RlvBehaviourNotifyHandler::sendNotification("accepted_in_inv inv_offer " + mDesc.substr(1, idxToken - 1)); + } +// [/RLVa:KB] + //don't spam them if they are getting flooded if (check_offer_throttle(mFromName, true)) { @@ -1808,6 +1898,16 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const msg->addBinaryDataFast(_PREHASH_BinaryBucket, EMPTY_BINARY_BUCKET, EMPTY_BINARY_BUCKET_SIZE); // send the message msg->sendReliable(mHost); + +// [RLVa:KB] - Checked: 2010-09-23 (RLVa-1.2.1e) | Added: RLVa-1.2.1e + if ( (rlv_handler_t::isEnabled()) && + (IM_TASK_INVENTORY_OFFERED == mIM) && (LLAssetType::AT_CATEGORY == mType) && (mDesc.find(RLV_PUTINV_PREFIX) == 1) ) + { + std::string::size_type idxToken = mDesc.find("' ( http://"); + if (std::string::npos != idxToken) + RlvBehaviourNotifyHandler::sendNotification("declined inv_offer " + mDesc.substr(1, idxToken - 1)); + } +// [/RLVa:KB] if (gSavedSettings.getBOOL("LogInventoryDecline")) { @@ -1816,6 +1916,7 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const log_message_args["NAME"] = mFromName; log_message = LLTrans::getString("InvOfferDecline", log_message_args); + LLSD args; args["MESSAGE"] = log_message; LLNotificationsUtil::add("SystemMessageTip", args); @@ -1943,6 +2044,9 @@ void inventory_offer_handler(LLOfferInfo* info) } else { +// [SL:KB] - Patch: UI-Notifications | Checked: 2011-04-11 (Catznip-2.5.0a) | Added: Catznip-2.5.0a + args["NAME_LABEL"] = LLSLURL("agent", info->mFromID, "completename").getSLURLString(); +// [/SL:KB] args["NAME_SLURL"] = LLSLURL("agent", info->mFromID, "about").getSLURLString(); } std::string verb = "select?name=" + LLURI::escape(msg); @@ -1953,6 +2057,15 @@ void inventory_offer_handler(LLOfferInfo* info) // Object -> Agent Inventory Offer if (info->mFromObject) { +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + // Only filter if the object owner is a nearby agent + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(info->mFromID)) ) + { + payload["rlv_shownames"] = TRUE; + args["NAME_SLURL"] = LLSLURL("agent", info->mFromID, "rlvanonym").getSLURLString(); + } +// [/RLVa:KB] + // Inventory Slurls don't currently work for non agent transfers, so only display the object name. args["ITEM_SLURL"] = msg; // Note: sets inventory_task_offer_callback as the callback @@ -1967,6 +2080,17 @@ void inventory_offer_handler(LLOfferInfo* info) } else // Agent -> Agent Inventory Offer { +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + // Only filter if the offer is from a nearby agent and if there's no open IM session (doesn't necessarily have to be focused) + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(info->mFromID)) && + (!RlvUIEnabler::hasOpenIM(info->mFromID)) ) + { + payload["rlv_shownames"] = TRUE; + args["NAME"] = RlvStrings::getAnonym(info->mFromName); + args["NAME_SLURL"] = LLSLURL("agent", info->mFromID, "rlvanonym").getSLURLString(); + } +// [/RLVa:KB] + p.responder = info; // Note: sets inventory_offer_callback as the callback // *TODO fix memory leak @@ -2050,7 +2174,18 @@ bool lure_callback(const LLSD& notification, const LLSD& response) modified_form->setElementEnabled("Teleport", false); modified_form->setElementEnabled("Cancel", false); notification_ptr->updateForm(modified_form); - notification_ptr->repost(); + +// [SL:KB] - Patch: UI-Notifications | Checked: 2013-05-09 (Catznip-3.5) + // Assume that any offer notification with "getCanBeStored() == true" is the result of RLVa routing it to the notifcation syswell + /*const*/ LLNotificationsUI::LLScreenChannel* pChannel = LLNotificationsUI::LLChannelManager::instance().getNotificationScreenChannel(); + /*const*/ LLNotificationsUI::LLToast* pToast = (pChannel) ? pChannel->getToastByNotificationID(notification["id"].asUUID()) : NULL; + if ( (!pToast) || (!pToast->getCanBeStored()) ) + { +// [/SL:KB] + notification_ptr->repost(); +// [SL:KB] - Patch: UI-Notifications | Checked: 2013-05-09 (Catznip-3.5) + } +// [/SL:KB] } return false; @@ -2402,10 +2537,24 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // do nothing -- don't distract newbies in // Prelude with global IMs } +// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0) + else if ( (rlv_handler_t::isEnabled()) && (offline == IM_ONLINE) && ("@version" == message) && + (!is_muted) && ((!accept_im_from_only_friend) || (is_friend)) ) + { + RlvUtil::sendBusyMessage(from_id, RlvStrings::getVersion(), session_id); + } +// [/RLVa:KB] +// else if (offline == IM_ONLINE +// && is_do_not_disturb +// && from_id.notNull() //not a system message +// && to_id.notNull()) //not global message +// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0) else if (offline == IM_ONLINE && is_do_not_disturb && from_id.notNull() //not a system message - && to_id.notNull()) //not global message + && to_id.notNull() //not global message + && RlvActions::canReceiveIM(from_id)) +// [/RLVa:KB] { // return a standard "do not disturb" message, but only do it to online IM // (i.e. not other auto responses and not store-and-forward IM) @@ -2451,17 +2600,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) else { // standard message, not from system - std::string saved; - if(offline == IM_OFFLINE) - { - LLStringUtil::format_map_t args; - args["[LONG_TIMESTAMP]"] = formatted_time(timestamp); - saved = LLTrans::getString("Saved_message", args); - } - buffer = saved + message; - - LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL; - bool mute_im = is_muted; if(accept_im_from_only_friend && !is_friend && !is_linden) { @@ -2474,6 +2612,40 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) mute_im = true; } + +// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0) + // Don't block offline IMs, or IMs from Lindens + if ( (rlv_handler_t::isEnabled()) && (offline != IM_OFFLINE) && (!RlvActions::canReceiveIM(from_id)) && (!LLMuteList::getInstance()->isLinden(original_name) )) + { + if (!mute_im) + RlvUtil::sendBusyMessage(from_id, RlvStrings::getString(RLV_STRING_BLOCKED_RECVIM_REMOTE), session_id); + message = RlvStrings::getString(RLV_STRING_BLOCKED_RECVIM); + } +// [/RLVa:KB] + + std::string saved; + if(offline == IM_OFFLINE) + { + LLStringUtil::format_map_t args; + args["[LONG_TIMESTAMP]"] = formatted_time(timestamp); + saved = LLTrans::getString("Saved_message", args); + } + buffer = saved + message; + + LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL; + +// bool mute_im = is_muted; +// if(accept_im_from_only_friend&&!is_friend) +// { +// if (!gIMMgr->isNonFriendSessionNotified(session_id)) +// { +// std::string message = LLTrans::getString("IM_unblock_only_groups_friends"); +// gIMMgr->addMessage(session_id, from_id, name, message, IM_OFFLINE == offline); +// gIMMgr->addNotifiedNonFriendSessionID(session_id); +// } +// +// mute_im = true; +// } if (!mute_im) { gIMMgr->addMessage( @@ -2765,7 +2937,13 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) case IM_INVENTORY_ACCEPTED: { - args["NAME"] = LLSLURL("agent", from_id, "completename").getSLURLString();; +// args["NAME"] = LLSLURL("agent", from_id, "completename").getSLURLString();; +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + // Only anonymize the name if the agent is nearby, there isn't an open IM session to them and their profile isn't open + bool fRlvFilterName = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(from_id)) && + (!RlvUIEnabler::hasOpenProfile(from_id)) && (!RlvUIEnabler::hasOpenIM(from_id)); + args["NAME"] = LLSLURL("agent", from_id, (!fRlvFilterName) ? "completename" : "rlvanonym").getSLURLString();; +// [/RLVa:KB] LLSD payload; payload["from_id"] = from_id; // Passing the "SESSION_NAME" to use it for IM notification logging @@ -2776,7 +2954,13 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) } case IM_INVENTORY_DECLINED: { - args["NAME"] = LLSLURL("agent", from_id, "completename").getSLURLString();; +// args["NAME"] = LLSLURL("agent", from_id, "completename").getSLURLString();; +// [RLVa:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + // Only anonymize the name if the agent is nearby, there isn't an open IM session to them and their profile isn't open + bool fRlvFilterName = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(from_id)) && + (!RlvUIEnabler::hasOpenProfile(from_id)) && (!RlvUIEnabler::hasOpenIM(from_id)); + args["NAME"] = LLSLURL("agent", from_id, (!fRlvFilterName) ? "completename" : "rlvanonym").getSLURLString();; +// [/RLVa:KB] LLSD payload; payload["from_id"] = from_id; LLNotificationsUtil::add("InventoryDeclined", args, payload); @@ -2837,6 +3021,25 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) LLSD query_string; query_string["owner"] = from_id; +// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Added: RLVa-1.2.0f + if (rlv_handler_t::isEnabled()) + { + // NOTE: the chat message itself will be filtered in LLNearbyChatHandler::processChat() + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (!from_group) && (RlvUtil::isNearbyAgent(from_id)) ) + { + query_string["rlv_shownames"] = TRUE; + + RlvUtil::filterNames(name); + chat.mFromName = name; + } + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { + std::string::size_type idxPos = location.find('/'); + if ( (std::string::npos != idxPos) && (RlvUtil::isNearbyRegion(location.substr(0, idxPos))) ) + location = RlvStrings::getString(RLV_STRING_HIDDEN_REGION); + } + } +// [/RLVa:KB] query_string["slurl"] = location; query_string["name"] = name; if (from_group) @@ -2844,7 +3047,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) query_string["groupowned"] = "true"; } - chat.mURL = LLSLURL("objectim", session_id, "").getSLURLString(); +// chat.mURL = LLSLURL("objectim", session_id, "").getSLURLString(); +// [SL:KB] - Checked: 2010-11-02 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + chat.mURL = LLSLURL("objectim", session_id, LLURI::mapToQueryString(query_string)).getSLURLString(); +// [/SL:KB] chat.mText = message; // Note: lie to Nearby Chat, pretending that this is NOT an IM, because @@ -2990,11 +3196,22 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) case IM_LURE_USER: case IM_TELEPORT_REQUEST: { - if (is_muted) +// [RLVa:KB] - Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c + // If the lure sender is a specific @accepttp exception they will override muted and busy status + bool fRlvSummon = (rlv_handler_t::isEnabled()) && (gRlvHandler.isException(RLV_BHVR_ACCEPTTP, from_id)); +// [/RLVa:KB] + +// if (is_muted) +// [RLVa:KB] - Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c + if ( (is_muted) && (!fRlvSummon) ) +// [/RLVa:KB] { return; } - else if (is_do_not_disturb) +// else if (is_do_not_disturb) +// [RLVa:KB] - Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c + else if ( (is_do_not_disturb) && (!fRlvSummon) ) +// [/RLVa:KB] { send_do_not_disturb_message(msg, from_id); } @@ -3053,8 +3270,30 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) } } +// [RLVa:KB] - Checked: 2010-12-11 (RLVa-1.2.2c) | Modified: RLVa-1.2.2c + if (rlv_handler_t::isEnabled()) + { + if (!gRlvHandler.canTeleportViaLure(from_id)) + { + RlvUtil::sendBusyMessage(from_id, RlvStrings::getString(RLV_STRING_BLOCKED_TPLURE_REMOTE)); + if (is_do_not_disturb) + send_do_not_disturb_message(msg, from_id); + return; + } + + // Censor lure message if: 1) restricted from receiving IMs from the sender, or 2) @showloc=n restricted + if ( (!RlvActions::canReceiveIM(from_id)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ) + { + message = RlvStrings::getString(RLV_STRING_HIDDEN); + } + } +// [/RLVa:KB] + LLSD args; // *TODO: Translate -> [FIRST] [LAST] (maybe) +// [SL:KB] - Patch: UI-Notifications | Checked: 2011-04-11 (Catznip-2.5.0a) | Added: Catznip-2.5.0a + args["NAME_LABEL"] = LLSLURL("agent", from_id, "completename").getSLURLString(); +// [/SL:KB] args["NAME_SLURL"] = LLSLURL("agent", from_id, "about").getSLURLString(); args["MESSAGE"] = message; args["MATURITY_STR"] = region_access_str; @@ -3096,10 +3335,24 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) params.functor.name = "TeleportRequest"; } - params.substitutions = args; - params.payload = payload; - LLPostponedNotification::add<LLPostponedOfferNotification>( params, from_id, false); - } + params.substitutions = args; + params.payload = payload; + +// [RLVa:KB] - Checked: 2010-12-11 (RLVa-1.2.2c) | Modified: RLVa-1.2.2c + if ( (rlv_handler_t::isEnabled()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_ACCEPTTP)) || (fRlvSummon)) ) + { + gRlvHandler.setCanCancelTp(false); + if (is_do_not_disturb) + send_do_not_disturb_message(msg, from_id); + LLNotifications::instance().forceResponse(LLNotification::Params("TeleportOffered").payload(payload), 0); + } + else + { + LLPostponedNotification::add<LLPostponedOfferNotification>( params, from_id, false); + } +// [/RLVa:KB] +// LLPostponedNotification::add<LLPostponedOfferNotification>( params, from_id, false); + } } } break; @@ -3238,6 +3491,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) { send_do_not_disturb_message(msg, from_id); } +// [SL:KB] - Patch: UI-Notifications | Checked: 2011-04-11 (Catznip-2.5.0a) | Added: Catznip-2.5.0a + args["NAME_LABEL"] = LLSLURL("agent", from_id, "completename").getSLURLString(); +// [/SL:KB] args["NAME_SLURL"] = LLSLURL("agent", from_id, "about").getSLURLString(); if(message.empty()) { @@ -3529,9 +3785,14 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) chat.mPosAgent = chatter->getPositionAgent(); // Make swirly things only for talking objects. (not script debug messages, though) - if (chat.mSourceType == CHAT_SOURCE_OBJECT - && chat.mChatType != CHAT_TYPE_DEBUG_MSG - && gSavedSettings.getBOOL("EffectScriptChatParticles") ) +// if (chat.mSourceType == CHAT_SOURCE_OBJECT +// && chat.mChatType != CHAT_TYPE_DEBUG_MSG +// && gSavedSettings.getBOOL("EffectScriptChatParticles") ) +// [RLVa:KB] - Checked: 2010-03-09 (RLVa-1.2.0b) | Modified: RLVa-1.0.0g + if ( ((chat.mSourceType == CHAT_SOURCE_OBJECT) && (chat.mChatType != CHAT_TYPE_DEBUG_MSG)) && + (gSavedSettings.getBOOL("EffectScriptChatParticles")) && + ((!rlv_handler_t::isEnabled()) || (CHAT_TYPE_OWNER != chat.mChatType)) ) +// [/RLVa:KB] { LLPointer<LLViewerPartSourceChat> psc = new LLViewerPartSourceChat(chatter->getPositionAgent()); psc->setSourceObject(chatter); @@ -3561,6 +3822,75 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) color.setVec(1.f,1.f,1.f,1.f); msg->getStringFast(_PREHASH_ChatData, _PREHASH_Message, mesg); +// [RLVa:KB] - Checked: 2010-04-23 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f + if ( (rlv_handler_t::isEnabled()) && (CHAT_TYPE_START != chat.mChatType) && (CHAT_TYPE_STOP != chat.mChatType) ) + { + // NOTE: chatter can be NULL (may not have rezzed yet, or could be another avie's HUD attachment) + BOOL is_attachment = (chatter) ? chatter->isAttachment() : FALSE; + BOOL is_owned_by_me = (chatter) ? chatter->permYouOwner() : FALSE; + + // Filtering "rules": + // avatar => filter all avie text (unless it's this avie or they're an exemption) + // objects => filter everything except attachments this avie owns (never filter llOwnerSay chat) + if ( ( (CHAT_SOURCE_AGENT == chat.mSourceType) && (from_id != gAgent.getID()) ) || + ( (CHAT_SOURCE_OBJECT == chat.mSourceType) && ((!is_owned_by_me) || (!is_attachment)) && + (CHAT_TYPE_OWNER != chat.mChatType) ) ) + { + bool fIsEmote = RlvUtil::isEmote(mesg); + if ((!fIsEmote) && + (((gRlvHandler.hasBehaviour(RLV_BHVR_RECVCHAT)) && (!gRlvHandler.isException(RLV_BHVR_RECVCHAT, from_id))) || + ((gRlvHandler.hasBehaviour(RLV_BHVR_RECVCHATFROM)) && (gRlvHandler.isException(RLV_BHVR_RECVCHATFROM, from_id))) )) + { + if ( (gRlvHandler.filterChat(mesg, false)) && (!gSavedSettings.getBOOL("RestrainedLoveShowEllipsis")) ) + return; + } + else if ((fIsEmote) && + (((gRlvHandler.hasBehaviour(RLV_BHVR_RECVEMOTE)) && (!gRlvHandler.isException(RLV_BHVR_RECVEMOTE, from_id))) || + ((gRlvHandler.hasBehaviour(RLV_BHVR_RECVEMOTEFROM)) && (gRlvHandler.isException(RLV_BHVR_RECVEMOTEFROM, from_id))) )) + { + if (!gSavedSettings.getBOOL("RestrainedLoveShowEllipsis")) + return; + mesg = "/me ..."; + } + } + + // Filtering "rules": + // avatar => filter only their name (unless it's this avie) + // other => filter everything + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + { + if (CHAT_SOURCE_AGENT != chat.mSourceType) + { + RlvUtil::filterNames(chat.mFromName); + } + else if (chat.mFromID != gAgent.getID()) + { + chat.mFromName = RlvStrings::getAnonym(chat.mFromName); + chat.mRlvNamesFiltered = TRUE; + } + } + + // Create an "objectim" URL for objects if we're either @shownames or @showloc restricted + // (we need to do this now because we won't be have enough information to do it later on) + if ( (CHAT_SOURCE_OBJECT == chat.mSourceType) && + ((gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC))) ) + { + LLSD sdQuery; + sdQuery["name"] = chat.mFromName; + sdQuery["owner"] = owner_id; + + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (!is_owned_by_me) ) + sdQuery["rlv_shownames"] = true; + + const LLViewerRegion* pRegion = LLWorld::getInstance()->getRegionFromPosAgent(chat.mPosAgent); + if (pRegion) + sdQuery["slurl"] = LLSLURL(pRegion->getName(), chat.mPosAgent).getLocationString(); + + chat.mURL = LLSLURL("objectim", from_id, LLURI::mapToQueryString(sdQuery)).getSLURLString(); + } + } +// [/RLVa:KB] + BOOL ircstyle = FALSE; // Look for IRC-style emotes here so chatbubbles work @@ -3611,8 +3941,99 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) case CHAT_TYPE_WHISPER: chat.mText = LLTrans::getString("whisper") + " "; break; - case CHAT_TYPE_DEBUG_MSG: case CHAT_TYPE_OWNER: +// [RLVa:KB] - Checked: 2010-02-XX (RLVa-1.2.0a) | Modified: RLVa-1.1.0f + // TODO-RLVa: [RLVa-1.2.0] consider rewriting this before a RLVa-1.2.0 release + if ( (rlv_handler_t::isEnabled()) && (mesg.length() > 3) && (RLV_CMD_PREFIX == mesg[0]) && (CHAT_TYPE_OWNER == chat.mChatType) ) + { + mesg.erase(0, 1); + LLStringUtil::toLower(mesg); + + std::string strExecuted, strFailed, strRetained, *pstr; + + boost_tokenizer tokens(mesg, boost::char_separator<char>(",", "", boost::drop_empty_tokens)); + for (boost_tokenizer::iterator itToken = tokens.begin(); itToken != tokens.end(); ++itToken) + { + std::string strCmd = *itToken; + + ERlvCmdRet eRet = gRlvHandler.processCommand(from_id, strCmd, true); + if ( (RlvSettings::getDebug()) && + ( (!RlvSettings::getDebugHideUnsetDup()) || + ((RLV_RET_SUCCESS_UNSET != eRet) && (RLV_RET_SUCCESS_DUPLICATE != eRet)) ) ) + { + if ( RLV_RET_SUCCESS == (eRet & RLV_RET_SUCCESS) ) + pstr = &strExecuted; + else if ( RLV_RET_FAILED == (eRet & RLV_RET_FAILED) ) + pstr = &strFailed; + else if (RLV_RET_RETAINED == eRet) + pstr = &strRetained; + else + { + RLV_ASSERT(false); + pstr = &strFailed; + } + + const char* pstrSuffix = RlvStrings::getStringFromReturnCode(eRet); + if (pstrSuffix) + strCmd.append(" (").append(pstrSuffix).append(")"); + + if (!pstr->empty()) + pstr->push_back(','); + pstr->append(strCmd); + } + } + + if (RlvForceWear::instanceExists()) + RlvForceWear::instance().done(); + + if ( (!RlvSettings::getDebug()) || ((strExecuted.empty()) && (strFailed.empty()) && (strRetained.empty())) ) + return; + + // Silly people want comprehensive debug messages, blah :p + if ( (!strExecuted.empty()) && (strFailed.empty()) && (strRetained.empty()) ) + { + chat.mText = " executes: @"; + mesg = strExecuted; + } + else if ( (strExecuted.empty()) && (!strFailed.empty()) && (strRetained.empty()) ) + { + chat.mText = " failed: @"; + mesg = strFailed; + } + else if ( (strExecuted.empty()) && (strFailed.empty()) && (!strRetained.empty()) ) + { + chat.mText = " retained: @"; + mesg = strRetained; + } + else + { + chat.mText = ": @"; + if (!strExecuted.empty()) + mesg += "\n - executed: @" + strExecuted; + if (!strFailed.empty()) + mesg += "\n - failed: @" + strFailed; + if (!strRetained.empty()) + mesg += "\n - retained: @" + strRetained; + } + + break; + } +// [/RLVa:KB] +// [RLVa:KB] - Checked: 2010-03-09 (RLVa-1.2.0b) | Modified: RLVa-1.0.0g + // Copy/paste from above + if ( (rlv_handler_t::isEnabled()) && (chatter) && (chat.mSourceType == CHAT_SOURCE_OBJECT) && + (gSavedSettings.getBOOL("EffectScriptChatParticles")) ) + { + LLPointer<LLViewerPartSourceChat> psc = new LLViewerPartSourceChat(chatter->getPositionAgent()); + psc->setSourceObject(chatter); + psc->setColor(color); + //We set the particles to be owned by the object's owner, + //just in case they should be muted by the mute list + psc->setOwnerUUID(owner_id); + LLViewerPartSim::getInstance()->addPartSource(psc); + } +// [/RLVa:KB] + case CHAT_TYPE_DEBUG_MSG: case CHAT_TYPE_NORMAL: case CHAT_TYPE_DIRECT: break; @@ -3716,7 +4137,10 @@ void process_teleport_start(LLMessageSystem *msg, void**) // *NOTE: The server sends two StartTeleport packets when you are teleporting to a LM LLViewerMessage::getInstance()->mTeleportStartedSignal(); - if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) +// if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) +// [RLVa:KB] - Checked: 2010-04-07 (RLVa-1.2.0d) | Added: RLVa-0.2.0b + if ( (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) || (!gRlvHandler.getCanCancelTp()) ) +// [/RLVa:KB] { gViewerWindow->setProgressCancelButtonVisible(FALSE); } @@ -3758,7 +4182,10 @@ void process_teleport_progress(LLMessageSystem* msg, void**) } U32 teleport_flags = 0x0; msg->getU32("Info", "TeleportFlags", teleport_flags); - if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) +// if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) +// [RLVa:KB] - Checked: 2010-04-07 (RLVa-1.2.0d) | Added: RLVa-0.2.0b + if ( (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) || (!gRlvHandler.getCanCancelTp()) ) +// [/RLVa:KB] { gViewerWindow->setProgressCancelButtonVisible(FALSE); } @@ -4197,7 +4624,10 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) } // send walk-vs-run status - gAgent.sendWalkRun(gAgent.getRunning() || gAgent.getAlwaysRun()); +// gAgent.sendWalkRun(gAgent.getRunning() || gAgent.getAlwaysRun()); +// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + gAgent.sendWalkRun(); +// [/RLVa:KB] // If the server version has changed, display an info box and offer // to display the release notes, unless this is the initial log in. @@ -6096,6 +6526,15 @@ void process_alert_core(const std::string& message, BOOL modal) else { std::string new_msg =LLNotifications::instance().getGlobalString(text); +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if ( (new_msg == text) && (rlv_handler_t::isEnabled()) ) + { + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + RlvUtil::filterLocation(new_msg); + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + RlvUtil::filterNames(new_msg); + } +// [/RLVa:KB] args["MESSAGE"] = new_msg; LLNotificationsUtil::add("SystemMessage", args); } @@ -6104,6 +6543,15 @@ void process_alert_core(const std::string& message, BOOL modal) { LLSD args; std::string new_msg =LLNotifications::instance().getGlobalString(message); +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if ( (new_msg == message) && (rlv_handler_t::isEnabled()) ) + { + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + RlvUtil::filterLocation(new_msg); + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + RlvUtil::filterNames(new_msg); + } +// [/RLVa:KB] args["ERROR_MESSAGE"] = new_msg; LLNotificationsUtil::add("ErrorMessage", args); } @@ -6119,6 +6567,16 @@ void process_alert_core(const std::string& message, BOOL modal) std::string localized_msg; bool is_message_localized = LLTrans::findString(localized_msg, new_msg); +// [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if ( (new_msg == message) && (rlv_handler_t::isEnabled()) ) + { + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + RlvUtil::filterLocation(new_msg); + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) + RlvUtil::filterNames(new_msg); + } +// [/RLVa:KB] + args["MESSAGE"] = is_message_localized ? localized_msg : new_msg; LLNotificationsUtil::add("SystemMessageTip", args); } @@ -6274,7 +6732,7 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp if (viewregion) { // got the region, so include the region and 3d coordinates of the object - notice.setArg("[REGIONNAME]", viewregion->getName()); + notice.setArg("[REGIONNAME]", viewregion->getName()); std::string formatpos = llformat("%.1f, %.1f,%.1f", objpos[VX], objpos[VY], objpos[VZ]); notice.setArg("[REGIONPOS]", formatpos); @@ -6282,7 +6740,15 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp } } - if (!foundpos) +// [RLVa:KB] - Checked: 2010-04-23 (RLVa-1.2.0g) | Modified: RLVa-1.0.0a + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { + notice.setArg("[REGIONNAME]", RlvStrings::getString(RLV_STRING_HIDDEN_REGION)); + notice.setArg("[REGIONPOS]", RlvStrings::getString(RLV_STRING_HIDDEN)); + } + else if (!foundpos) +// [/RLVa:KB] +// if (!foundpos) { // unable to determine location of the object notice.setArg("[REGIONNAME]", "(unknown region)"); @@ -6296,7 +6762,11 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp std::string perms; for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++) { - if ((orig_questions & LSCRIPTRunTimePermissionBits[i]) && SCRIPT_QUESTION_IS_CAUTION[i]) +// if ((orig_questions & LSCRIPTRunTimePermissionBits[i]) && SCRIPT_QUESTION_IS_CAUTION[i]) +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + if ( (orig_questions & LSCRIPTRunTimePermissionBits[i]) && + ((SCRIPT_QUESTION_IS_CAUTION[i]) || (notification["payload"]["rlv_notify"].asBoolean())) ) +// [/RLVa:KB] { count++; caution = TRUE; @@ -6316,11 +6786,25 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp // log a chat message as long as at least one requested permission // is a caution permission +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) if (caution) { - LLChat chat(notice.getString()); - // LLFloaterChat::addChat(chat, FALSE, FALSE); + LLFloaterIMNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLFloaterIMNearbyChat>("nearby_chat"); + if(nearby_chat) + { + LLChat chat_msg(notice.getString()); + chat_msg.mFromName = SYSTEM_FROM; + chat_msg.mFromID = LLUUID::null; + chat_msg.mSourceType = CHAT_SOURCE_SYSTEM; + nearby_chat->addMessage(chat_msg); + } } +// [/RLVa:KB] +// if (caution) +// { +// LLChat chat(notice.getString()); +// // LLFloaterChat::addChat(chat, FALSE, FALSE); +// } } } @@ -6379,12 +6863,22 @@ bool script_question_cb(const LLSD& notification, const LLSD& response) msg->sendReliable(LLHost(notification["payload"]["sender"].asString())); // only log a chat message if caution prompts are enabled - if (gSavedSettings.getBOOL("PermissionsCautionEnabled")) +// if (gSavedSettings.getBOOL("PermissionsCautionEnabled")) +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + if ( (gSavedSettings.getBOOL("PermissionsCautionEnabled")) || (notification["payload"]["rlv_notify"].asBoolean()) ) +// [/RLVa:KB] { // log a chat message, if appropriate notify_cautioned_script_question(notification, response, orig, allowed); } +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + if ( (allowed) && (notification["payload"].has("rlv_blocked")) ) + { + RlvUtil::notifyBlocked(notification["payload"]["rlv_blocked"], LLSD().with("OBJECT", notification["payload"]["object_name"])); + } +// [/RLVa:KB] + if ( response["Mute"] ) // mute { script_question_mute(task_id,notification["payload"]["object_name"].asString()); @@ -6529,8 +7023,39 @@ void process_script_question(LLMessageSystem *msg, void **user_data) payload["object_name"] = object_name; payload["owner_name"] = owner_name; +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + if (rlv_handler_t::isEnabled()) + { + RlvUtil::filterScriptQuestions(questions, payload); + + if ( (questions) && (gRlvHandler.hasBehaviour(RLV_BHVR_ACCEPTPERMISSION)) ) + { + const LLViewerObject* pObj = gObjectList.findObject(taskid); + if (pObj) + { + if ( (pObj->permYouOwner()) && (!pObj->isAttachment()) ) + { + questions &= ~(LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TAKE_CONTROLS] | + LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_ATTACH]); + } + else + { + questions &= ~(LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TAKE_CONTROLS]); + } + payload["rlv_notify"] = !pObj->permYouOwner(); + } + } + } + + if ( (!caution) && (!questions) ) + { + LLNotifications::instance().forceResponse( + LLNotification::Params("ScriptQuestion").substitutions(args).payload(payload), 0/*YES*/); + } + else if (gSavedSettings.getBOOL("PermissionsCautionEnabled")) +// [/RLVa:KB] // check whether cautions are even enabled or not - if (gSavedSettings.getBOOL("PermissionsCautionEnabled")) +// if (gSavedSettings.getBOOL("PermissionsCautionEnabled")) { if (caution) { @@ -6892,6 +7417,22 @@ void send_lures(const LLSD& notification, const LLSD& response) LLAgentUI::buildSLURL(slurl); text.append("\r\n").append(slurl.getSLURLString()); +// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0) + if ( (RlvActions::hasBehaviour(RLV_BHVR_SENDIM)) || (RlvActions::hasBehaviour(RLV_BHVR_SENDIMTO)) ) + { + // Filter the lure message if one of the recipients of the lure can't be sent an IM to + for (LLSD::array_const_iterator it = notification["payload"]["ids"].beginArray(); + it != notification["payload"]["ids"].endArray(); ++it) + { + if (!RlvActions::canSendIM(it->asUUID())) + { + text = RlvStrings::getString(RLV_STRING_HIDDEN); + break; + } + } + } +// [/RLVa:KB] + LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_StartLure); msg->nextBlockFast(_PREHASH_AgentData); @@ -6969,13 +7510,29 @@ void handle_lure(const uuid_vec_t& ids) if (!gAgent.getRegion()) return; LLSD edit_args; - edit_args["REGION"] = gAgent.getRegion()->getName(); +// [RLVa:KB] - Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.0.0a + edit_args["REGION"] = + (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? gAgent.getRegion()->getName() : RlvStrings::getString(RLV_STRING_HIDDEN); +// [/RLVa:KB] +// edit_args["REGION"] = gAgent.getRegion()->getName(); LLSD payload; for (LLDynamicArray<LLUUID>::const_iterator it = ids.begin(); it != ids.end(); ++it) { +// [RLVa:KB] - Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.0.0a + // Only allow offering teleports if everyone is a @tplure exception or able to map this avie under @showloc=n + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { + const LLRelationship* pBuddyInfo = LLAvatarTracker::instance().getBuddyInfo(*it); + if ( (!gRlvHandler.isException(RLV_BHVR_TPLURE, *it, RLV_CHECK_PERMISSIVE)) && + ((!pBuddyInfo) || (!pBuddyInfo->isOnline()) || (!pBuddyInfo->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION))) ) + { + return; + } + } +// [/RLVa:KB] payload["ids"].append(*it); } if (gAgent.isGodlike()) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 7151a0d6ed1f76fed2c335d87c07cf6d3e4ef068..5d422a7a9b9f911b53b5896652796be63531ba6a 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -100,6 +100,10 @@ #include "lltrans.h" #include "llsdutil.h" #include "llmediaentry.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] //#define DEBUG_UPDATE_TYPE @@ -550,6 +554,12 @@ bool LLViewerObject::isReturnable() return false; } +// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Added: RLVa-1.4.0a + if ( (rlv_handler_t::isEnabled()) && (!rlvCanDeleteOrReturn(this)) ) + { + return false; + } +// [/RLVa:KB] std::vector<LLBBox> boxes; boxes.push_back(LLBBox(getPositionRegion(), getRotationRegion(), getScale() * -0.5f, getScale() * 0.5f).getAxisAligned()); for (child_list_t::iterator iter = mChildList.begin(); @@ -767,7 +777,10 @@ void LLViewerObject::addThisAndNonJointChildren(std::vector<LLViewerObject*>& ob } } -BOOL LLViewerObject::isChild(LLViewerObject *childp) const +//BOOL LLViewerObject::isChild(LLViewerObject *childp) const +// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Added: RLVa-1.4.0a +BOOL LLViewerObject::isChild(const LLViewerObject *childp) const +// [/RLVa:KB] { for (child_list_t::const_iterator iter = mChildList.begin(); iter != mChildList.end(); iter++) @@ -1256,6 +1269,12 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, coloru.mV[3] = 255 - coloru.mV[3]; mText->setColor(LLColor4(coloru)); mText->setString(temp_string); +// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.0.0f + if (rlv_handler_t::isEnabled()) + { + mText->setObjectText(temp_string); + } +// [/RLVa:KB] setChanged(MOVED | SILHOUETTE); } @@ -1636,6 +1655,12 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, coloru.mV[3] = 255 - coloru.mV[3]; mText->setColor(LLColor4(coloru)); mText->setString(temp_string); +// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.0.0f + if (rlv_handler_t::isEnabled()) + { + mText->setObjectText(temp_string); + } +// [/RLVa:KB] setChanged(TEXTURE); } @@ -1806,6 +1831,25 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, gObjectList.killObject(this); return retval; } +// [RLVa:KB] - Checked: 2010-03-16 (RLVa-1.1.0k) | Added: RLVa-1.1.0k + if ( (rlv_handler_t::isEnabled()) && (sent_parentp->isAvatar()) && (sent_parentp->getID() == gAgent.getID()) ) + { + // Rezzed object that's being worn as an attachment (we're assuming this will be due to llAttachToAvatar()) + S32 idxAttachPt = ATTACHMENT_ID_FROM_STATE(getState()); + if (gRlvAttachmentLocks.isLockedAttachmentPoint(idxAttachPt, RLV_LOCK_ADD)) + { + // If this will end up on an "add locked" attachment point then treat the attach as a user action + LLNameValue* nvItem = getNVPair("AttachItemID"); + if (nvItem) + { + LLUUID idItem(nvItem->getString()); + // URGENT-RLVa: [RLVa-1.2.0] At the moment llAttachToAvatar always seems to *add* + if (idItem.notNull()) + RlvAttachmentLockWatchdog::instance().onWearAttachment(idItem, RLV_WEAR_ADD); + } + } + } +// [/RLVa:KB] sent_parentp->addChild(this); // make sure this object gets a non-damped update if (sent_parentp->mDrawable.notNull()) @@ -5458,7 +5502,10 @@ BOOL LLViewerObject::permTransfer() const // given you modify rights to. JC BOOL LLViewerObject::allowOpen() const { - return !flagInventoryEmpty() && (permYouOwner() || permModify()); +// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c + return !flagInventoryEmpty() && (permYouOwner() || permModify()) && ((!rlv_handler_t::isEnabled()) || (gRlvHandler.canEdit(this))); +// [/RLVa:KB] +// return !flagInventoryEmpty() && (permYouOwner() || permModify()); } LLViewerObject::LLInventoryCallbackInfo::~LLInventoryCallbackInfo() diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index b035473c747e138df6d866a6126a626303c41809..bd550b5bc4ace28f52f791db52048e28247da6ed 100755 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -252,7 +252,10 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate S32 numChildren() const { return mChildList.size(); } void addThisAndAllChildren(std::vector<LLViewerObject*>& objects); void addThisAndNonJointChildren(std::vector<LLViewerObject*>& objects); - BOOL isChild(LLViewerObject *childp) const; +// BOOL isChild(LLViewerObject *childp) const; +// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Added: RLVa-1.4.0a + BOOL isChild(const LLViewerObject *childp) const; +// [/RLVa:KB] BOOL isSeat() const; @@ -364,7 +367,10 @@ class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate void sendShapeUpdate(); - U8 getState() { return mState; } +// U8 getState() { return mState; } +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0a) | Added: RLVa-1.2.0a + U8 getState() const { return mState; } +// [/RLVa:KB] F32 getAppAngle() const { return mAppAngle; } F32 getPixelArea() const { return mPixelArea; } diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp old mode 100755 new mode 100644 diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp old mode 100755 new mode 100644 index ff7642a773a4cc7a670fc78e21be57b10017a9ee..8d54d9ebb70d39716a7d231b0be02cb48c00f227 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -210,6 +210,10 @@ #include "llviewerwindowlistener.h" #include "llpaneltopinfobar.h" +// [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c) +#include "rlvhandler.h" +// [/RLVa:KB] + #if LL_WINDOWS #include <tchar.h> // For Unicode conversion methods #endif @@ -3637,6 +3641,15 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, { moveable_object_selected = TRUE; this_object_movable = TRUE; + +// [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c) | Modified: RLVa-0.2.0g + if ( (rlv_handler_t::isEnabled()) && + ((gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SITTP))) ) + { + if ((isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) && (gAgentAvatarp->getRoot() == object->getRootEdit())) + moveable_object_selected = this_object_movable = FALSE; + } +// [/RLVa:KB] } all_selected_objects_move = all_selected_objects_move && this_object_movable; all_selected_objects_modify = all_selected_objects_modify && object->permModify(); @@ -3922,6 +3935,13 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de found = gPipeline.lineSegmentIntersectInHUD(mh_start, mh_end, pick_transparent, face_hit, intersection, uv, normal, tangent); +// [RLVa:KB] - Checked: 2010-03-31 (RLVa-1.2.0c) | Modified: RLVa-1.2.0c + if ( (rlv_handler_t::isEnabled()) && (found) && + (LLToolCamera::getInstance()->hasMouseCapture()) && (gKeyboard->currentMask(TRUE) & MASK_ALT) ) + { + found = NULL; + } +// [/RLVa:KB] if (!found) // if not found in HUD, look in world: { found = gPipeline.lineSegmentIntersectInWorld(mw_start, mw_end, pick_transparent, @@ -3931,6 +3951,25 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de gDebugRaycastIntersection = *intersection; } } + +// [RLVa:KB] - Checked: 2010-01-02 (RLVa-1.1.0l) | Added: RLVa-1.1.0l +#ifdef RLV_EXTENSION_CMD_INTERACT + if ( (rlv_handler_t::isEnabled()) && (found) && (gRlvHandler.hasBehaviour(RLV_BHVR_INTERACT)) ) + { + // Allow picking if: + // - the drag-and-drop tool is active (allows inventory offers) + // - the camera tool is active + // - the pie tool is active *and* we picked our own avie (allows "mouse steering" and the self pie menu) + LLTool* pCurTool = LLToolMgr::getInstance()->getCurrentTool(); + if ( (LLToolDragAndDrop::getInstance() != pCurTool) && + (!LLToolCamera::getInstance()->hasMouseCapture()) && + ((LLToolPie::getInstance() != pCurTool) || (gAgent.getID() != found->getID())) ) + { + found = NULL; + } +#endif // RLV_EXTENSION_CMD_INTERACT +// [/RLVa:KB] + } } return found; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp old mode 100755 new mode 100644 index 4b4412d64b35ffbc46786a044f39a8e1fb4a6075..092318b07f394689d3f29008c90361c666d3e42e --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -94,6 +94,9 @@ #include "llanimstatelabels.h" #include "lltrans.h" #include "llappearancemgr.h" +// [RLVa:KB] - Checked: 2010-04-01 (RLVa-1.2.0c) +#include "rlvhandler.h" +// [/RLVa:KB] #include "llgesturemgr.h" //needed to trigger the voice gesticulations #include "llvoiceclient.h" @@ -2519,12 +2522,18 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) const F32 time_visible = mTimeVisible.getElapsedTimeF32(); const F32 NAME_SHOW_TIME = gSavedSettings.getF32("RenderNameShowTime"); // seconds const F32 FADE_DURATION = gSavedSettings.getF32("RenderNameFadeDuration"); // seconds +// [RLVa:KB] - Checked: 2010-04-04 (RLVa-1.2.2a) | Added: RLVa-0.2.0b + bool fRlvShowNames = gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES); +// [/RLVa:KB] BOOL visible_avatar = isVisible() || mNeedsAnimUpdate; BOOL visible_chat = gSavedSettings.getBOOL("UseChatBubbles") && (mChats.size() || mTyping); BOOL render_name = visible_chat || - (visible_avatar && - ((sRenderName == RENDER_NAME_ALWAYS) || - (sRenderName == RENDER_NAME_FADE && time_visible < NAME_SHOW_TIME))); + (visible_avatar && +// [RLVa:KB] - Checked: 2010-04-04 (RLVa-1.2.2a) | Added: RLVa-1.0.0h + ( (!fRlvShowNames) || (RlvSettings::getShowNameTags()) ) && +// [/RLVa:KB] + ((sRenderName == RENDER_NAME_ALWAYS) || + (sRenderName == RENDER_NAME_FADE && time_visible < NAME_SHOW_TIME))); // If it's your own avatar, don't draw in mouselook, and don't // draw if we're specifically hiding our own name. if (isSelf()) @@ -2554,7 +2563,18 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) new_name = TRUE; } - if (sRenderGroupTitles != mRenderGroupTitles) +// [RLVa:KB] - Checked: 2010-04-04 (RLVa-1.2.2a) | Added: RLVa-0.2.0b + if (fRlvShowNames) + { + if (mRenderGroupTitles) + { + mRenderGroupTitles = FALSE; + new_name = TRUE; + } + } + else if (sRenderGroupTitles != mRenderGroupTitles) +// [/RLVa] +// if (sRenderGroupTitles != mRenderGroupTitles) { mRenderGroupTitles = sRenderGroupTitles; new_name = TRUE; @@ -2621,6 +2641,9 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) // Avatars must have a first and last name if (!firstname || !lastname) return; +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + bool fRlvShowNames = gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES); +// [/RLVa:KB] bool is_away = mSignaledAnimations.find(ANIM_AGENT_AWAY) != mSignaledAnimations.end(); bool is_do_not_disturb = mSignaledAnimations.find(ANIM_AGENT_DO_NOT_DISTURB) != mSignaledAnimations.end(); bool is_appearance = mSignaledAnimations.find(ANIM_AGENT_CUSTOMIZE) != mSignaledAnimations.end(); @@ -2633,7 +2656,10 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) { is_muted = LLMuteList::getInstance()->isMuted(getID()); } - bool is_friend = LLAvatarTracker::instance().isBuddy(getID()); +// bool is_friend = LLAvatarTracker::instance().isBuddy(getID()); +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Added: RLVa-1.2.2a + bool is_friend = (!fRlvShowNames) && (LLAvatarTracker::instance().isBuddy(getID())); +// [/RLVa:KB] bool is_cloud = getIsCloud(); if (is_appearance != mNameAppearance) @@ -2698,7 +2724,10 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) LLFontGL::getFontSansSerifSmall()); } - if (sRenderGroupTitles +// if (sRenderGroupTitles +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + if (sRenderGroupTitles && !fRlvShowNames +// [/RLVa:KB] && title && title->getString() && title->getString()[0] != '\0') { std::string title_str = title->getString(); @@ -2720,25 +2749,42 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) clearNameTag(); } - // Might be blank if name not available yet, that's OK - if (show_display_names) +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + if ( (!fRlvShowNames) || (isSelf()) ) { - addNameTagLine(av_name.getDisplayName(), name_tag_color, LLFontGL::NORMAL, - LLFontGL::getFontSansSerif()); +// [/RLVa:KB] + // Might be blank if name not available yet, that's OK + if (show_display_names) + { + addNameTagLine(av_name.getDisplayName(), name_tag_color, LLFontGL::NORMAL, + LLFontGL::getFontSansSerif()); + } + // Suppress SLID display if display name matches exactly (ugh) + if (show_usernames && !av_name.isDisplayNameDefault()) + { + // *HACK: Desaturate the color + LLColor4 username_color = name_tag_color * 0.83f; + addNameTagLine(av_name.getUserName(), username_color, LLFontGL::NORMAL, + LLFontGL::getFontSansSerifSmall()); + } +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a } - // Suppress SLID display if display name matches exactly (ugh) - if (show_usernames && !av_name.isDisplayNameDefault()) + else { - // *HACK: Desaturate the color - LLColor4 username_color = name_tag_color * 0.83f; - addNameTagLine(av_name.getUserName(), username_color, LLFontGL::NORMAL, - LLFontGL::getFontSansSerifSmall()); + addNameTagLine(RlvStrings::getAnonym(av_name), name_tag_color, LLFontGL::NORMAL, LLFontGL::getFontSansSerif()); } +// [/RLVa:KB] } else { const LLFontGL* font = LLFontGL::getFontSansSerif(); std::string full_name = LLCacheName::buildFullName( firstname->getString(), lastname->getString() ); +// [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a + if ( (fRlvShowNames) && (!isSelf()) ) + { + full_name = RlvStrings::getAnonym(full_name); + } +// [/RLVa:KB] addNameTagLine(full_name, name_tag_color, LLFontGL::NORMAL, font); } @@ -5750,6 +5796,13 @@ void LLVOAvatar::sitDown(BOOL bSitting) { // Update Movement Controls according to own Sitting mode LLFloaterMove::setSittingMode(bSitting); + +// [RLVa:KB] - Checked: 2010-08-29 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c + if (rlv_handler_t::isEnabled()) + { + gRlvHandler.onSitOrStand(bSitting); + } +// [/RLVa:KB] } } diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h old mode 100755 new mode 100644 diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp old mode 100755 new mode 100644 index 9ce99444d9647e216699b11d2c0a530ea81e1b9c..7145b17c54f8810be093db9ffa0b17f338fa7770 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -63,6 +63,10 @@ #include "llsdutil.h" #include "llstartup.h" #include "llsdserialize.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] #if LL_MSVC // disable boost::lexical_cast warning @@ -156,6 +160,9 @@ LLVOAvatarSelf::LLVOAvatarSelf(const LLUUID& id, const LLPCode pcode, LLViewerRegion* regionp) : LLVOAvatar(id, pcode, regionp), +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + mAttachmentSignal(NULL), +// [/RLVa:KB] mScreenp(NULL), mLastRegionHandle(0), mRegionCrossingCount(0), @@ -224,6 +231,10 @@ void LLVOAvatarSelf::initInstance() mInitialBakeIDs[i] = LLUUID::null; } +// [RLVa:KB] - Checked: 2010-12-12 (RLVa-1.2.2c) | Added: RLVa-1.2.2c + RlvAttachPtLookup::initLookupTable(); +// [/RLVa:KB] + status &= buildMenus(); if (!status) { @@ -385,6 +396,7 @@ BOOL LLVOAvatarSelf::buildMenus() item_params.name =(item_params.label ); item_params.on_click.function_name = "Object.AttachToAvatar"; item_params.on_click.parameter = iter->first; + // [RLVa:KB] - No changes, but we do need the parameter to always be idxAttachPt for object_selected_and_point_valid() item_params.on_enable.function_name = "Object.EnableWear"; item_params.on_enable.parameter = iter->first; LLMenuItemCallGL* item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params); @@ -456,6 +468,7 @@ BOOL LLVOAvatarSelf::buildMenus() item_params.name =(item_params.label ); item_params.on_click.function_name = "Object.AttachToAvatar"; item_params.on_click.parameter = iter->first; + // [RLVa:KB] - No changes, but we do need the parameter to always be idxAttachPt for object_selected_and_point_valid() item_params.on_enable.function_name = "Object.EnableWear"; item_params.on_enable.parameter = iter->first; LLMenuItemCallGL* item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params); @@ -499,6 +512,7 @@ BOOL LLVOAvatarSelf::buildMenus() item_params.name =(item_params.label ); item_params.on_click.function_name = "Object.AttachToAvatar"; item_params.on_click.parameter = iter->first; + // [RLVa:KB] - No changes, but we do need the parameter to always be idxAttachPt for object_selected_and_point_valid() item_params.on_enable.function_name = "Object.EnableWear"; item_params.on_enable.parameter = iter->first; //* TODO: Skinning: @@ -565,6 +579,7 @@ BOOL LLVOAvatarSelf::buildMenus() item_params.label = LLTrans::getString(attachment->getName()); item_params.on_click.function_name = "Object.AttachToAvatar"; item_params.on_click.parameter = attach_index; + // [RLVa:KB] - No changes, but we do need the parameter to always be idxAttachPt for object_selected_and_point_valid() item_params.on_enable.function_name = "Object.EnableWear"; item_params.on_enable.parameter = attach_index; @@ -594,6 +609,10 @@ void LLVOAvatarSelf::cleanup() LLVOAvatarSelf::~LLVOAvatarSelf() { cleanup(); + +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + delete mAttachmentSignal; +// [/RLVa:KB] } /** @@ -1156,6 +1175,28 @@ LLViewerObject* LLVOAvatarSelf::getWornAttachment(const LLUUID& inv_item_id) return NULL; } +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) +boost::signals2::connection LLVOAvatarSelf::setAttachmentCallback(const attachment_signal_t::slot_type& cb) +{ + if (!mAttachmentSignal) + mAttachmentSignal = new attachment_signal_t(); + return mAttachmentSignal->connect(cb); +} +// [/RLVa:KB] +// [RLVa:KB] - Checked: 2010-03-14 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +LLViewerJointAttachment* LLVOAvatarSelf::getWornAttachmentPoint(const LLUUID& idItem) const +{ + const LLUUID& idItemBase = gInventory.getLinkedItemID(idItem); + for (attachment_map_t::const_iterator itAttachPt = mAttachmentPoints.begin(); itAttachPt != mAttachmentPoints.end(); ++itAttachPt) + { + LLViewerJointAttachment* pAttachPt = itAttachPt->second; + if (pAttachPt->getAttachedObject(idItemBase)) + return pAttachPt; + } + return NULL; +} +// [/RLVa:KB] + const std::string LLVOAvatarSelf::getAttachedPointName(const LLUUID& inv_item_id) const { const LLUUID& base_inv_item_id = gInventory.getLinkedItemID(inv_item_id); @@ -1194,6 +1235,22 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view // Clear any pending requests once the attachment arrives. removeAttachmentRequest(attachment_id); updateLODRiggedAttachments(); + +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) | Modified: RLVa-1.2.1a + // NOTE: RLVa event handlers should be invoked *after* LLVOAvatar::attachObject() calls LLViewerJointAttachment::addObject() + if (mAttachmentSignal) + { + (*mAttachmentSignal)(viewer_object, attachment, ACTION_ATTACH); + } + if (rlv_handler_t::isEnabled()) + { + RlvAttachmentLockWatchdog::instance().onAttach(viewer_object, attachment); + gRlvHandler.onAttach(viewer_object, attachment); + + if ( (attachment->getIsHUDAttachment()) && (!gRlvAttachmentLocks.hasLockedHUD()) ) + gRlvAttachmentLocks.updateLockedHUD(); + } +// [/RLVa:KB] } return attachment; @@ -1203,6 +1260,27 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) { const LLUUID attachment_id = viewer_object->getAttachmentItemID(); + +// [RLVa:KB] - Checked: 2010-03-05 (RLVa-1.2.0a) | Added: RLVa-1.2.0a + // NOTE: RLVa event handlers should be invoked *before* LLVOAvatar::detachObject() calls LLViewerJointAttachment::removeObject() + if (rlv_handler_t::isEnabled()) + { + for (attachment_map_t::const_iterator itAttachPt = mAttachmentPoints.begin(); itAttachPt != mAttachmentPoints.end(); ++itAttachPt) + { + const LLViewerJointAttachment* pAttachPt = itAttachPt->second; + if (pAttachPt->isObjectAttached(viewer_object)) + { + RlvAttachmentLockWatchdog::instance().onDetach(viewer_object, pAttachPt); + gRlvHandler.onDetach(viewer_object, pAttachPt); + } + if (mAttachmentSignal) + { + (*mAttachmentSignal)(viewer_object, pAttachPt, ACTION_DETACH); + } + } + } +// [/RLVa:KB] + if ( LLVOAvatar::detachObject(viewer_object) ) { LLVOAvatar::cleanupAttachedMesh( viewer_object ); @@ -1237,6 +1315,11 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) LLAppearanceMgr::instance().unregisterAttachment(attachment_id); } +// [RLVa:KB] - Checked: 2010-08-22 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + if ( (rlv_handler_t::isEnabled()) && (viewer_object->isHUDAttachment()) && (gRlvAttachmentLocks.hasLockedHUD()) ) + gRlvAttachmentLocks.updateLockedHUD(); +// [/RLVa:KB] + return TRUE; } return FALSE; @@ -1246,7 +1329,10 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) BOOL LLVOAvatarSelf::detachAttachmentIntoInventory(const LLUUID &item_id) { LLInventoryItem* item = gInventory.getItem(item_id); - if (item) +// if (item) +// [RLVa:KB] - Checked: 2010-09-04 (RLVa-1.2.1c) | Added: RLVa-1.2.1c + if ( (item) && ((!rlv_handler_t::isEnabled()) || (gRlvAttachmentLocks.canDetach(item))) ) +// [/RLVa:KB] { gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv); gMessageSystem->nextBlockFast(_PREHASH_ObjectData); diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index 3b7b6bac64a07ed801ef9aa9b4f5905cc687ff02..0d8e8104e0fffcae384e61aad50e72a43b068583 100755 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -314,14 +314,25 @@ class LLVOAvatarSelf : void addAttachmentRequest(const LLUUID& inv_item_id); void removeAttachmentRequest(const LLUUID& inv_item_id); LLViewerObject* getWornAttachment(const LLUUID& inv_item_id); +// [RLVa:KB] - Checked: 2009-12-18 (RLVa-1.1.0i) | Added: RLVa-1.1.0i + LLViewerJointAttachment* getWornAttachmentPoint(const LLUUID& inv_item_id) const; +// [/RLVa:KB] const std::string getAttachedPointName(const LLUUID& inv_item_id) const; /*virtual*/ const LLViewerJointAttachment *attachObject(LLViewerObject *viewer_object); /*virtual*/ BOOL detachObject(LLViewerObject *viewer_object); static BOOL detachAttachmentIntoInventory(const LLUUID& item_id); +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + enum EAttachAction { ACTION_ATTACH, ACTION_DETACH }; + typedef boost::signals2::signal<void (LLViewerObject*, const LLViewerJointAttachment*, EAttachAction)> attachment_signal_t; + boost::signals2::connection setAttachmentCallback(const attachment_signal_t::slot_type& cb); +// [/RLVa:KB] private: // Track attachments that have been requested but have not arrived yet. mutable std::map<LLUUID,LLTimer> mAttachmentRequests; +// [RLVa:KB] - Checked: 2012-07-28 (RLVa-1.4.7) + attachment_signal_t* mAttachmentSignal; +// [/RLVa:KB] //-------------------------------------------------------------------- // HUDs diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index d9efd23b436c72b702a5a995337de768adfc2f70..27c32cead11995aaa551d2b236363cbf92fb46f7 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -78,6 +78,10 @@ #include "llvoavatar.h" #include "llvocache.h" #include "llmaterialmgr.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] const S32 MIN_QUIET_FRAMES_COALESCE = 30; const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; @@ -4120,7 +4124,14 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LL_WARNS("RenderMaterials") << "Oh no! No binormals for this alpha blended face!" << LL_ENDL; } - if (facep->getViewerObject()->isSelected() && LLSelectMgr::getInstance()->mHideSelectedObjects) +// if (facep->getViewerObject()->isSelected() && LLSelectMgr::getInstance()->mHideSelectedObjects) +// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c + const LLViewerObject* pObj = facep->getViewerObject(); + if ( (pObj->isSelected() && LLSelectMgr::getInstance()->mHideSelectedObjects) && + ( (!rlv_handler_t::isEnabled()) || + ( ((!pObj->isHUDAttachment()) || (!gRlvAttachmentLocks.isLockedAttachment(pObj->getRootEdit()))) && + (gRlvHandler.canEdit(pObj)) ) ) ) +// [/RVLa:KB] { return; } diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index c196d70617d7d69aade31e05ea392cd6b3afbc3b..75ca6dcae721da8d79ac7bc3316ad0c210aa8236 100755 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -38,6 +38,10 @@ #include "lltransutil.h" #include "llviewerattachmenu.h" #include "llvoavatarself.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] class LLFindOutfitItems : public LLInventoryCollectFunctor { @@ -839,6 +843,13 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu bool can_be_worn = true; +// [RLVa:KB] - Checked: 2010-09-04 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + // We'll enable a menu option if at least one item in the selection is wearable/removable + bool rlvCanWearReplace = !rlv_handler_t::isEnabled(); + bool rlvCanWearAdd = !rlv_handler_t::isEnabled(); + bool rlvCanRemove = !rlv_handler_t::isEnabled(); +// [/RLVa:KB] + for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it) { LLUUID id = *it; @@ -879,6 +890,29 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu { can_be_worn = get_can_item_be_worn(item->getLinkedUUID()); } + +// [RLVa:KB] - Checked: 2010-09-04 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + if (rlv_handler_t::isEnabled()) + { + ERlvWearMask eWearMask = RLV_WEAR_LOCKED; + switch (item->getType()) + { + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_CLOTHING: + eWearMask = gRlvWearableLocks.canWear(item); + rlvCanRemove |= (is_worn) ? gRlvWearableLocks.canRemove(item) : false; + break; + case LLAssetType::AT_OBJECT: + eWearMask = gRlvAttachmentLocks.canAttach(item); + rlvCanRemove |= (is_worn) ? gRlvAttachmentLocks.canDetach(item) : false; + break; + default: + break; + } + rlvCanWearReplace |= ((eWearMask & RLV_WEAR_REPLACE) == RLV_WEAR_REPLACE); + rlvCanWearAdd |= ((eWearMask & RLV_WEAR_ADD) == RLV_WEAR_ADD); + } +// [/RLVa:KB] } // for bool standalone = mParent ? mParent->isStandalone() : false; @@ -886,10 +920,15 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu // *TODO: eliminate multiple traversals over the menu items setMenuItemVisible(menu, "wear_wear", n_already_worn == 0 && n_worn == 0 && can_be_worn); - setMenuItemEnabled(menu, "wear_wear", n_already_worn == 0 && n_worn == 0); +// setMenuItemEnabled(menu, "wear_wear", n_already_worn == 0 && n_worn == 0); setMenuItemVisible(menu, "wear_add", wear_add_visible); - setMenuItemEnabled(menu, "wear_add", canAddWearables(ids)); +// setMenuItemEnabled(menu, "wear_add", canAddWearables(ids)); setMenuItemVisible(menu, "wear_replace", n_worn == 0 && n_already_worn != 0 && can_be_worn); +// [RLVa:KB] - Checked: 2010-09-04 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + setMenuItemEnabled(menu, "wear_wear", n_already_worn == 0 && n_worn == 0 && rlvCanWearReplace); + setMenuItemEnabled(menu, "wear_add", canAddWearables(ids) && rlvCanWearAdd); + setMenuItemEnabled(menu, "wear_replace", rlvCanWearReplace); +// [/RLVa:KB] //visible only when one item selected and this item is worn setMenuItemVisible(menu, "edit", !standalone && mask & (MASK_CLOTHING|MASK_BODYPART) && n_worn == n_items && n_worn == 1); setMenuItemEnabled(menu, "edit", n_editable == 1 && n_worn == 1 && n_items == 1); @@ -900,7 +939,12 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu setMenuItemVisible(menu, "take_off", mask == MASK_CLOTHING && n_worn == n_items); setMenuItemVisible(menu, "detach", mask == MASK_ATTACHMENT && n_worn == n_items); setMenuItemVisible(menu, "take_off_or_detach", mask == (MASK_ATTACHMENT|MASK_CLOTHING)); - setMenuItemEnabled(menu, "take_off_or_detach", n_worn == n_items); +// setMenuItemEnabled(menu, "take_off_or_detach", n_worn == n_items); +// [RLVa:KB] - Checked: 2010-09-04 (RLVa-1.2.1a) | Added: RLVa-1.2.1a + setMenuItemEnabled(menu, "take_off", rlvCanRemove); + setMenuItemEnabled(menu, "detach", rlvCanRemove); + setMenuItemEnabled(menu, "take_off_or_detach", (n_worn == n_items) && (rlvCanRemove)); +// [/RLVa:KB] setMenuItemVisible(menu, "object_profile", !standalone); setMenuItemEnabled(menu, "object_profile", n_items == 1); setMenuItemVisible(menu, "--no options--", FALSE); diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp index ce9f61c0afedcfcb42c059737ba88d64ba7fb1f7..3f10415d99a97b610a9b67b1ccf9a9299f3943e0 100755 --- a/indra/newview/llwlparammanager.cpp +++ b/indra/newview/llwlparammanager.cpp @@ -61,6 +61,10 @@ #include "curl/curl.h" #include "llstreamtools.h" +// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +#include <boost/algorithm/string.hpp> +// [/RLVa:KB] + LLWLParamManager::LLWLParamManager() : //set the defaults for the controls @@ -644,6 +648,19 @@ void LLWLParamManager::getPresetNames(preset_name_list_t& region, preset_name_li } } +// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +const std::string& LLWLParamManager::findPreset(const std::string& strPresetName, LLEnvKey::EScope eScope) +{ + for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator itList = mParamList.begin(); itList != mParamList.end(); itList++) + { + const LLWLParamKey& wlKey = itList->first; + if ( (wlKey.scope == eScope) && (boost::iequals(wlKey.name, strPresetName)) ) + return wlKey.name; + } + return LLStringUtil::null; +} +// [/RLVa:KB] + void LLWLParamManager::getUserPresetNames(preset_name_list_t& user) const { preset_name_list_t region, sys; // unused diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h index e13aed98edfc507d5bec39592e9fdc8493cc67a1..43baae3d41f599f7f482ce775043b9cb22d1cb4a 100755 --- a/indra/newview/llwlparammanager.h +++ b/indra/newview/llwlparammanager.h @@ -287,6 +287,10 @@ class LLWLParamManager : public LLSingleton<LLWLParamManager> /// @return user and system preset names as a single list void getPresetNames(preset_name_list_t& region, preset_name_list_t& user, preset_name_list_t& sys) const; +// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a + const std::string& findPreset(const std::string& strPresetName, LLEnvKey::EScope eScope); +// [/RLVa:KB] + /// @return user preset names void getUserPresetNames(preset_name_list_t& user) const; diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index ae334d4bd24fa7612ec02062cb72a48764de1273..a1beb1b98ffe193446dd1357a8fdec1119c7f9a1 100755 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -55,6 +55,9 @@ #include "llviewerregion.h" #include "llviewerwindow.h" #include "lltrans.h" +// [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.0f) +#include "rlvhandler.h" +// [/RLVa:KB] #include "llglheaders.h" @@ -460,7 +463,10 @@ void LLWorldMapView::draw() { mesg = info->getName(); } - if (!mesg.empty()) +// if (!mesg.empty()) +// [RLVa:KB] - Checked: 2012-02-08 (RLVa-1.4.5) | Added: RLVa-1.4.5 + if ( (!mesg.empty()) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ) +// [/RLVa:KB] { font->renderUTF8( mesg, 0, @@ -994,7 +1000,10 @@ void LLWorldMapView::drawTracking(const LLVector3d& pos_global, const LLColor4& text_x = llclamp(text_x, half_text_width + TEXT_PADDING, getRect().getWidth() - half_text_width - TEXT_PADDING); text_y = llclamp(text_y + vert_offset, TEXT_PADDING + vert_offset, getRect().getHeight() - font->getLineHeight() - TEXT_PADDING - vert_offset); - if (label != "") +// if (label != "") +// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.4.5) | Added: RLVa-1.0.0 + if ( (label != "") && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ) +// [/RLVa:KB] { font->renderUTF8( label, 0, @@ -1054,7 +1063,12 @@ BOOL LLWorldMapView::handleToolTip( S32 x, S32 y, MASK mask ) { LLViewerRegion *region = gAgent.getRegion(); - std::string message = llformat("%s (%s)", info->getName().c_str(), info->getAccessString().c_str()); +// [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.4.5) | Modified: RLVa-1.4.5 + std::string message = llformat("%s (%s)", + (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? info->getName().c_str() : RlvStrings::getString(RLV_STRING_HIDDEN_REGION).c_str(), + info->getAccessString().c_str()); +// [/RLVa:KB] +// std::string message = llformat("%s (%s)", info->getName().c_str(), info->getAccessString().c_str()); if (!info->isDown()) { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5da8a78b1b423ed43a30dc6e4007364297a4d64e..a80ac863031f126754f10f1b4efdc37e8bc7527b 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -114,6 +114,10 @@ #include "llfloatertools.h" #include "llpanelface.h" #include "llpathfindingpathtool.h" +// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) +#include "rlvhandler.h" +#include "rlvlocks.h" +// [/RLVa:KB] #ifdef _DEBUG // Debug indices is disabled for now for debug performance - djs 4/24/02 @@ -3538,8 +3542,15 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) if (LLSelectMgr::getInstance()->mHideSelectedObjects) { - if (drawablep->getVObj().notNull() && - drawablep->getVObj()->isSelected()) +// if (drawablep->getVObj().notNull() && +// drawablep->getVObj()->isSelected()) +// [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.2.1f) | Modified: RLVa-1.2.1f + const LLViewerObject* pObj = drawablep->getVObj(); + if ( (pObj) && (pObj->isSelected()) && + ( (!rlv_handler_t::isEnabled()) || + ( ((!pObj->isHUDAttachment()) || (!gRlvAttachmentLocks.isLockedAttachment(pObj->getRootEdit()))) && + (gRlvHandler.canEdit(pObj)) ) ) ) +// [/RVLa:KB] { return; } diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8f91f5f9f749858adf6726fb6d248fff0aad663b --- /dev/null +++ b/indra/newview/rlvactions.cpp @@ -0,0 +1,81 @@ +/** + * + * Copyright (c) 2009-2013, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#include "llviewerprecompiledheaders.h" +#include "llimview.h" +#include "rlvactions.h" +#include "rlvhandler.h" + +// ============================================================================ +// RlvActions member functions +// + +// Checked: 2010-11-30 (RLVa-1.3.0) +bool RlvActions::canReceiveIM(const LLUUID& idSender) +{ + // User can receive an IM from "sender" (could be an agent or a group) if: + // - not generally restricted from receiving IMs (or the sender is an exception) + // - not specifically restricted from receiving an IM from the sender + return + (!rlv_handler_t::isEnabled()) || + ( ( (!gRlvHandler.hasBehaviour(RLV_BHVR_RECVIM)) || (gRlvHandler.isException(RLV_BHVR_RECVIM, idSender)) ) && + ( (!gRlvHandler.hasBehaviour(RLV_BHVR_RECVIMFROM)) || (!gRlvHandler.isException(RLV_BHVR_RECVIMFROM, idSender)) ) ); +} + +// Checked: 2010-11-30 (RLVa-1.3.0) +bool RlvActions::canSendIM(const LLUUID& idRecipient) +{ + // User can send an IM to "recipient" (could be an agent or a group) if: + // - not generally restricted from sending IMs (or the recipient is an exception) + // - not specifically restricted from sending an IM to the recipient + return + (!rlv_handler_t::isEnabled()) || + ( ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SENDIM)) || (gRlvHandler.isException(RLV_BHVR_SENDIM, idRecipient)) ) && + ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SENDIMTO)) || (!gRlvHandler.isException(RLV_BHVR_SENDIMTO, idRecipient)) ) ); +} + +// Checked: 2011-04-12 (RLVa-1.3.0) +bool RlvActions::canStartIM(const LLUUID& idRecipient) +{ + // User can start an IM session with "recipient" (could be an agent or a group) if: + // - not generally restricted from starting IM sessions (or the recipient is an exception) + // - not specifically restricted from starting an IM session with the recipient + return + (!rlv_handler_t::isEnabled()) || + ( ( (!gRlvHandler.hasBehaviour(RLV_BHVR_STARTIM)) || (gRlvHandler.isException(RLV_BHVR_STARTIM, idRecipient)) ) && + ( (!gRlvHandler.hasBehaviour(RLV_BHVR_STARTIMTO)) || (!gRlvHandler.isException(RLV_BHVR_STARTIMTO, idRecipient)) ) ); +} + +// Checked: 2013-05-10 (RLVa-1.4.9) +bool RlvActions::hasBehaviour(ERlvBehaviour eBhvr) +{ + return gRlvHandler.hasBehaviour(eBhvr); +} + +// Checked: 2013-05-09 (RLVa-1.4.9) +bool RlvActions::hasOpenP2PSession(const LLUUID& idAgent) +{ + const LLUUID idSession = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, idAgent); + return (idSession.notNull()) && (LLIMMgr::instance().hasSession(idSession)); +} + +// Checked: 2013-05-09 (RLVa-1.4.9) +bool RlvActions::hasOpenGroupSession(const LLUUID& idGroup) +{ + return (idGroup.notNull()) && (LLIMMgr::instance().hasSession(idGroup)); +} + +// ============================================================================ diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h new file mode 100644 index 0000000000000000000000000000000000000000..b586e2dbc1c73917a9c3b08948efd90174031a6f --- /dev/null +++ b/indra/newview/rlvactions.h @@ -0,0 +1,60 @@ +/** + * + * Copyright (c) 2009-2013, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#ifndef RLV_ACTIONS_H +#define RLV_ACTIONS_H + +#include "rlvdefines.h" + +// ============================================================================ +// RlvActions class declaration - developer-friendly non-RLVa code facing class, use in lieu of RlvHandler whenever possible +// + +class RlvActions +{ +public: + + /* + * Returns true if the user is allowed to receive IMs from the specified sender (can be an avatar or a group) + */ + static bool canReceiveIM(const LLUUID& idSender); + + /* + * Returns true if the user is allowed to send IMs to the specified recipient (can be an avatar or a group) + */ + static bool canSendIM(const LLUUID& idRecipient); + + /* + * Returns true if the user is allowed to start a - P2P or group - conversation with the specified UUID. + */ + static bool canStartIM(const LLUUID& idRecipient); // @startim and @startimto + + /* + * Convenience function to check for a behaviour without having to include rlvhandler.h. + * Do NOT call this function if speed is important (i.e. per-frame) + */ + static bool hasBehaviour(ERlvBehaviour eBhvr); + + /* + * Returns true if a - P2P or group - IM session is open with the specified UUID. + */ + static bool hasOpenP2PSession(const LLUUID& idAgent); + static bool hasOpenGroupSession(const LLUUID& idGroup); +}; + +// ============================================================================ + +#endif // RLV_ACTIONS_H diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ede9df1de0a6837abbe62d3f637f7dcc4815903e --- /dev/null +++ b/indra/newview/rlvcommon.cpp @@ -0,0 +1,733 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#include "llviewerprecompiledheaders.h" +#include "llagent.h" +#include "llagentui.h" +#include "llavatarnamecache.h" +#include "llinstantmessage.h" +#include "llnotificationsutil.h" +#include "llsdserialize.h" +#include "llviewerparcelmgr.h" +#include "llviewermenu.h" +#include "llviewerregion.h" +#include "llviewerstats.h" +#include "llworld.h" + +#include "rlvcommon.h" +#include "rlvhelper.h" +#include "rlvhandler.h" +#include "rlvlocks.h" + +#include "lscript_byteformat.h" +#include <boost/algorithm/string.hpp> + +// ============================================================================ +// RlvNotifications +// + +// Checked: 2009-11-13 (RLVa-1.1.0b) | Modified: RLVa-1.1.0b +/* +void RlvNotifications::warnGiveToRLV() +{ + if ( (gSavedSettings.getWarning(RLV_SETTING_FIRSTUSE_GIVETORLV)) && (RlvSettings::getForbidGiveToRLV()) ) + LLNotifications::instance().add(RLV_SETTING_FIRSTUSE_GIVETORLV, LLSD(), LLSD(), &RlvNotifications::onGiveToRLVConfirmation); +} +*/ + +// Checked: 2009-11-13 (RLVa-1.1.0b) | Modified: RLVa-1.1.0b +/* +void RlvNotifications::onGiveToRLVConfirmation(const LLSD& notification, const LLSD& response) +{ + gSavedSettings.setWarning(RLV_SETTING_FIRSTUSE_GIVETORLV, FALSE); + + S32 idxOption = LLNotification::getSelectedOption(notification, response); + if ( (0 == idxOption) || (1 == idxOption) ) + gSavedSettings.setBOOL(RLV_SETTING_FORBIDGIVETORLV, (idxOption == 1)); +} +*/ + +// ========================================================================= +// RlvSettings +// + +#ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS +bool RlvSettings::fCompositeFolders = false; +#endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS +bool RlvSettings::fCanOOC = true; +bool RlvSettings::fLegacyNaming = true; +bool RlvSettings::fNoSetEnv = false; +bool RlvSettings::fShowNameTags = false; + +// Checked: 2010-02-27 (RLVa-1.2.0a) | Modified: RLVa-1.1.0i +void RlvSettings::initClass() +{ + static bool fInitialized = false; + if (!fInitialized) + { + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + fCompositeFolders = rlvGetSetting<bool>(RLV_SETTING_ENABLECOMPOSITES, false); + if (gSavedSettings.controlExists(RLV_SETTING_ENABLECOMPOSITES)) + gSavedSettings.getControl(RLV_SETTING_ENABLECOMPOSITES)->getSignal()->connect(boost::bind(&onChangedSettingBOOL, _2, &fCompositeFolders)); + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + + fLegacyNaming = rlvGetSetting<bool>(RLV_SETTING_ENABLELEGACYNAMING, true); + if (gSavedSettings.controlExists(RLV_SETTING_ENABLELEGACYNAMING)) + gSavedSettings.getControl(RLV_SETTING_ENABLELEGACYNAMING)->getSignal()->connect(boost::bind(&onChangedSettingBOOL, _2, &fLegacyNaming)); + + fCanOOC = rlvGetSetting<bool>(RLV_SETTING_CANOOC, true); + fNoSetEnv = rlvGetSetting<bool>(RLV_SETTING_NOSETENV, false); + + fShowNameTags = rlvGetSetting<bool>(RLV_SETTING_SHOWNAMETAGS, false); + if (gSavedSettings.controlExists(RLV_SETTING_SHOWNAMETAGS)) + gSavedSettings.getControl(RLV_SETTING_SHOWNAMETAGS)->getSignal()->connect(boost::bind(&onChangedSettingBOOL, _2, &fShowNameTags)); + +#ifdef RLV_EXTENSION_STARTLOCATION + // Don't allow toggling RLVaLoginLastLocation from the debug settings floater + if (gSavedPerAccountSettings.controlExists(RLV_SETTING_LOGINLASTLOCATION)) + gSavedPerAccountSettings.getControl(RLV_SETTING_LOGINLASTLOCATION)->setHiddenFromSettingsEditor(true); +#endif // RLV_EXTENSION_STARTLOCATION + + if (gSavedSettings.controlExists(RLV_SETTING_TOPLEVELMENU)) + gSavedSettings.getControl(RLV_SETTING_TOPLEVELMENU)->getSignal()->connect(boost::bind(&onChangedMenuLevel)); + + fInitialized = true; + } +} + +#ifdef RLV_EXTENSION_STARTLOCATION + // Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-0.2.1d + void RlvSettings::updateLoginLastLocation() + { + if ( (!LLApp::isQuitting()) && (gSavedPerAccountSettings.controlExists(RLV_SETTING_LOGINLASTLOCATION)) ) + { + BOOL fValue = (gRlvHandler.hasBehaviour(RLV_BHVR_TPLOC)) || (!gRlvHandler.canStand()); + if (gSavedPerAccountSettings.getBOOL(RLV_SETTING_LOGINLASTLOCATION) != fValue) + { + gSavedPerAccountSettings.setBOOL(RLV_SETTING_LOGINLASTLOCATION, fValue); + gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE); + } + } + } +#endif // RLV_EXTENSION_STARTLOCATION + +// Checked: 2013-04-17 (RLVa-1.4.8) +bool RlvSettings::onChangedAvatarOffset(const LLSD& sdValue) +{ + if ( (isAgentAvatarValid()) && (!gAgentAvatarp->isUsingServerBakes()) ) + { + gAgentAvatarp->computeBodySize(); + } + return true; +} + +// Checked: 2011-08-16 (RLVa-1.4.0b) | Added: RLVa-1.4.0b +bool RlvSettings::onChangedMenuLevel() +{ + rlvMenuToggleVisible(); + return true; +} + +// Checked: 2010-02-27 (RLVa-1.2.0a) | Added: RLVa-1.1.0i +bool RlvSettings::onChangedSettingBOOL(const LLSD& sdValue, bool* pfSetting) +{ + if (pfSetting) + *pfSetting = sdValue.asBoolean(); + return true; +} + +// ============================================================================ +// RlvStrings +// + +std::vector<std::string> RlvStrings::m_Anonyms; +RlvStrings::string_map_t RlvStrings::m_StringMap; +std::string RlvStrings::m_StringMapPath; + +// Checked: 2011-11-08 (RLVa-1.5.0) +void RlvStrings::initClass() +{ + static bool fInitialized = false; + if (!fInitialized) + { + // Load the default string values + std::vector<std::string> files = gDirUtilp->findSkinnedFilenames(LLDir::XUI, RLV_STRINGS_FILE, LLDir::ALL_SKINS); + m_StringMapPath = (!files.empty()) ? files.front() : LLStringUtil::null; + for (auto itFile = files.cbegin(); itFile != files.cend(); ++itFile) + { + loadFromFile(*itFile, false); + } + + // Load the custom string overrides + loadFromFile(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, RLV_STRINGS_FILE), true); + + // Sanity check + if ( (m_StringMap.empty()) || (m_Anonyms.empty()) ) + { + RLV_ERRS << "Problem parsing RLVa string XML file" << RLV_ENDL; + return; + } + + fInitialized = true; + } +} + +// Checked: 2011-11-08 (RLVa-1.5.0) +void RlvStrings::loadFromFile(const std::string& strFilePath, bool fUserOverride) +{ + llifstream fileStream(strFilePath, std::ios::binary); LLSD sdFileData; + if ( (!fileStream.is_open()) || (!LLSDSerialize::fromXMLDocument(sdFileData, fileStream)) ) + return; + fileStream.close(); + + if (sdFileData.has("strings")) + { + const LLSD& sdStrings = sdFileData["strings"]; + for (LLSD::map_const_iterator itString = sdStrings.beginMap(); itString != sdStrings.endMap(); ++itString) + { + if ( (!itString->second.has("value")) || ((fUserOverride) && (!hasString(itString->first))) ) + continue; + + std::list<std::string>& listValues = m_StringMap[itString->first]; + if (!fUserOverride) + { + if (listValues.size() > 0) + listValues.pop_front(); + listValues.push_front(itString->second["value"].asString()); + } + else + { + while (listValues.size() > 1) + listValues.pop_back(); + listValues.push_back(itString->second["value"].asString()); + } + } + } + if (sdFileData.has("anonyms")) + { + const LLSD& sdAnonyms = sdFileData["anonyms"]; + for (LLSD::array_const_iterator itAnonym = sdAnonyms.beginArray(); itAnonym != sdAnonyms.endArray(); ++itAnonym) + { + m_Anonyms.push_back((*itAnonym).asString()); + } + } +} + +// Checked: 2011-11-08 (RLVa-1.5.0) +void RlvStrings::saveToFile(const std::string& strFilePath) +{ + LLSD sdFileData; + + LLSD& sdStrings = sdFileData["strings"]; + for (string_map_t::const_iterator itString = m_StringMap.begin(); itString != m_StringMap.end(); ++itString) + { + const std::list<std::string>& listValues = itString->second; + if (listValues.size() > 1) + sdStrings[itString->first]["value"] = listValues.back(); + } + + llofstream fileStream(strFilePath); + if (!fileStream.good()) + return; + + LLSDSerialize::toPrettyXML(sdFileData, fileStream); + fileStream.close(); +} + +// Checked: 2009-11-11 (RLVa-1.1.0a) | Modified: RLVa-1.1.0a +const std::string& RlvStrings::getAnonym(const std::string& strName) +{ + const char* pszName = strName.c_str(); U32 nHash = 0; + + // Test with 11,264 SL names showed a 3.33% - 3.82% occurance for each so we *should* get a very even spread + for (int idx = 0, cnt = strName.length(); idx < cnt; idx++) + nHash += pszName[idx]; + + return m_Anonyms[nHash % m_Anonyms.size()]; +} + +// Checked: 2011-11-08 (RLVa-1.5.0) +const std::string& RlvStrings::getString(const std::string& strStringName) +{ + static const std::string strMissing = "(Missing RLVa string)"; + string_map_t::const_iterator itString = m_StringMap.find(strStringName); + return (itString != m_StringMap.end()) ? itString->second.back() : strMissing; +} + +// Checked: 2009-11-25 (RLVa-1.1.0f) | Added: RLVa-1.1.0f +const char* RlvStrings::getStringFromReturnCode(ERlvCmdRet eRet) +{ + // TODO-RLVa: [2009-11-25] clean this up along with the calling code in process_chat_from_simulator() once we're happy with the output + switch (eRet) + { + case RLV_RET_SUCCESS_UNSET: + return "unset"; + case RLV_RET_SUCCESS_DUPLICATE: + return "duplicate"; + case RLV_RET_SUCCESS_DELAYED: + return "delayed"; + case RLV_RET_FAILED_SYNTAX: + return "thingy error"; + case RLV_RET_FAILED_OPTION: + return "invalid option"; + case RLV_RET_FAILED_PARAM: + return "invalid param"; + case RLV_RET_FAILED_LOCK: + return "locked command"; + case RLV_RET_FAILED_DISABLED: + return "disabled command"; + case RLV_RET_FAILED_UNKNOWN: + return "unknown command"; + case RLV_RET_FAILED_NOSHAREDROOT: + return "missing #RLV"; + case RLV_RET_DEPRECATED: + return "deprecated"; + // The following are identified by the chat verb + case RLV_RET_RETAINED: + case RLV_RET_SUCCESS: + case RLV_RET_FAILED: + break; + // The following shouldn't occur + case RLV_RET_UNKNOWN: + default: + RLV_ASSERT(false); + break; + }; + return NULL; +} + +// Checked: 2012-02-25 (RLVa-1.4.5) | Modified: RLVa-1.4.5 +std::string RlvStrings::getVersion(bool fLegacy) +{ + return llformat("%s viewer v%d.%d.%d (RLVa %d.%d.%d)", + ( (!fLegacy) ? "RestrainedLove" : "RestrainedLife" ), + RLV_VERSION_MAJOR, RLV_VERSION_MINOR, RLV_VERSION_PATCH, + RLVa_VERSION_MAJOR, RLVa_VERSION_MINOR, RLVa_VERSION_PATCH); +} + +// Checked: 2010-04-18 (RLVa-1.4.0a) | Added: RLVa-1.2.0e +std::string RlvStrings::getVersionAbout() +{ + return llformat("RLV v%d.%d.%d / RLVa v%d.%d.%d%c" , + RLV_VERSION_MAJOR, RLV_VERSION_MINOR, RLV_VERSION_PATCH, + RLVa_VERSION_MAJOR, RLVa_VERSION_MINOR, RLVa_VERSION_PATCH, 'a' + RLVa_VERSION_BUILD); +} + +// Checked: 2010-03-27 (RLVa-1.4.0a) | Modified: RLVa-1.1.0a +std::string RlvStrings::getVersionNum() +{ + return llformat("%d%02d%02d%02d", RLV_VERSION_MAJOR, RLV_VERSION_MINOR, RLV_VERSION_PATCH, RLV_VERSION_BUILD); +} + +// Checked: 2011-11-08 (RLVa-1.5.0) +bool RlvStrings::hasString(const std::string& strStringName, bool fCheckCustom) +{ + string_map_t::const_iterator itString = m_StringMap.find(strStringName); + return (itString != m_StringMap.end()) && ((!fCheckCustom) || (itString->second.size() > 0)); +} + +// Checked: 2011-11-08 (RLVa-1.5.0) +void RlvStrings::setCustomString(const std::string& strStringName, const std::string& strStringValue) +{ + if (!hasString(strStringName)) + return; + + std::list<std::string>& listValues = m_StringMap[strStringName]; + while (listValues.size() > 1) + listValues.pop_back(); + if (!strStringValue.empty()) + listValues.push_back(strStringValue); +} + +// ============================================================================ +// RlvUtil +// + +bool RlvUtil::m_fForceTp = false; + +// Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-1.0.0a +void RlvUtil::filterLocation(std::string& strUTF8Text) +{ + // Filter any mention of the surrounding region names + LLWorld::region_list_t regions = LLWorld::getInstance()->getRegionList(); + const std::string& strHiddenRegion = RlvStrings::getString(RLV_STRING_HIDDEN_REGION); + for (LLWorld::region_list_t::const_iterator itRegion = regions.begin(); itRegion != regions.end(); ++itRegion) + boost::ireplace_all(strUTF8Text, (*itRegion)->getName(), strHiddenRegion); + + // Filter any mention of the parcel name + LLViewerParcelMgr* pParcelMgr = LLViewerParcelMgr::getInstance(); + if (pParcelMgr) + boost::ireplace_all(strUTF8Text, pParcelMgr->getAgentParcelName(), RlvStrings::getString(RLV_STRING_HIDDEN_PARCEL)); +} + +// Checked: 2010-12-08 (RLVa-1.2.2c) | Modified: RLVa-1.2.2c +void RlvUtil::filterNames(std::string& strUTF8Text, bool fFilterLegacy) +{ + uuid_vec_t idAgents; + LLWorld::getInstance()->getAvatars(&idAgents, NULL); + for (int idxAgent = 0, cntAgent = idAgents.size(); idxAgent < cntAgent; idxAgent++) + { + LLAvatarName avName; + if (LLAvatarNameCache::get(idAgents[idxAgent], &avName)) + { + const std::string& strDisplayName = avName.getDisplayName(); + const std::string& strLegacyName = avName.getLegacyName(); + const std::string& strAnonym = RlvStrings::getAnonym(avName); + + // If the display name is a subset of the legacy name we need to filter that first, otherwise it's the other way around + if (boost::icontains(strLegacyName, strDisplayName)) + { + if (fFilterLegacy) + boost::ireplace_all(strUTF8Text, strLegacyName, strAnonym); + boost::ireplace_all(strUTF8Text, strDisplayName, strAnonym); + } + else + { + boost::ireplace_all(strUTF8Text, strDisplayName, strAnonym); + if (fFilterLegacy) + boost::ireplace_all(strUTF8Text, strLegacyName, strAnonym); + } + } + } +} + +// Checked: 2012-08-19 (RLVa-1.4.7) +void RlvUtil::filterScriptQuestions(S32& nQuestions, LLSD& sdPayload) +{ + // Check SCRIPT_PERMISSION_ATTACH + if ( (!gRlvAttachmentLocks.canAttach()) && (LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_ATTACH] & nQuestions) ) + { + // Notify the user that we blocked it since they're not allowed to wear any new attachments + sdPayload["rlv_blocked"] = RLV_STRING_BLOCKED_PERMATTACH; + nQuestions &= ~LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_ATTACH]; + } + + // Check SCRIPT_PERMISSION_TELEPORT + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_TPLOC)) && (LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TELEPORT] & nQuestions) ) + { + // Notify the user that we blocked it since they're not allowed to teleport + sdPayload["rlv_blocked"] = RLV_STRING_BLOCKED_PERMTELEPORT; + nQuestions &= ~LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_TELEPORT]; + } + + sdPayload["questions"] = nQuestions; +} + +// Checked: 2010-08-29 (RLVa-1.2.1c) | Added: RLVa-1.2.1c +void RlvUtil::forceTp(const LLVector3d& posDest) +{ + m_fForceTp = true; + gAgent.teleportViaLocationLookAt(posDest); + m_fForceTp = false; +} + +// Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f +bool RlvUtil::isNearbyAgent(const LLUUID& idAgent) +{ + // Sanity check since we call this with notification payloads as well and those strings tend to change from one release to another + RLV_ASSERT(idAgent.notNull()); + if ( (idAgent.notNull()) && (gAgent.getID() != idAgent) ) + { + std::vector<LLUUID> idAgents; + LLWorld::getInstance()->getAvatars(&idAgents, NULL); + + for (int idxAgent = 0, cntAgent = idAgents.size(); idxAgent < cntAgent; idxAgent++) + if (idAgents[idxAgent] == idAgent) + return true; + } + return false; +} + +// Checked: 2010-04-05 (RLVa-1.2.0d) | Modified: RLVa-1.2.0d +bool RlvUtil::isNearbyRegion(const std::string& strRegion) +{ + LLWorld::region_list_t regions = LLWorld::getInstance()->getRegionList(); + for (LLWorld::region_list_t::const_iterator itRegion = regions.begin(); itRegion != regions.end(); ++itRegion) + if ((*itRegion)->getName() == strRegion) + return true; + return false; +} + +// Checked: 2011-04-11 (RLVa-1.3.0h) | Modified: RLVa-1.3.0h +void RlvUtil::notifyBlocked(const std::string& strNotifcation, const LLSD& sdArgs) +{ + std::string strMsg = RlvStrings::getString(strNotifcation); + LLStringUtil::format(strMsg, sdArgs); + + LLSD sdNotify; + sdNotify["MESSAGE"] = strMsg; + LLNotificationsUtil::add("SystemMessageTip", sdNotify); +} + +// Checked: 2010-11-11 (RLVa-1.2.1g) | Added: RLVa-1.2.1g +void RlvUtil::notifyFailedAssertion(const std::string& strAssert, const std::string& strFile, int nLine) +{ + // Don't show the same assertion over and over, or if the user opted out + static std::string strAssertPrev, strFilePrev; static int nLinePrev; + if ( ((strAssertPrev == strAssert) && (strFile == strFilePrev) && (nLine == nLinePrev)) || + (!rlvGetSetting<bool>(RLV_SETTING_SHOWASSERTIONFAIL, true)) ) + { + return; + } + + strAssertPrev = strAssert; + strFilePrev = strFile; + nLinePrev = nLine; + + LLSD argsNotify; + argsNotify["MESSAGE"] = llformat("RLVa assertion failure: %s (%s - %d)", strAssert.c_str(), strFile.c_str(), nLine); + LLNotificationsUtil::add("SystemMessageTip", argsNotify); +} + +// Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0b +void RlvUtil::sendBusyMessage(const LLUUID& idTo, const std::string& strMsg, const LLUUID& idSession) +{ + // [See process_improved_im()] + std::string strFullName; + LLAgentUI::buildFullname(strFullName); + + pack_instant_message(gMessageSystem, gAgent.getID(), FALSE, gAgent.getSessionID(), idTo, strFullName, + strMsg, IM_ONLINE, IM_DO_NOT_DISTURB_AUTO_RESPONSE, idSession); + gAgent.sendReliableMessage(); +} + +// Checked: 2010-03-09 (RLVa-1.2.0a) | Modified: RLVa-1.0.1e +bool RlvUtil::sendChatReply(S32 nChannel, const std::string& strUTF8Text) +{ + if (!isValidReplyChannel(nChannel)) + return false; + + // Copy/paste from send_chat_from_viewer() + gMessageSystem->newMessageFast(_PREHASH_ChatFromViewer); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + gMessageSystem->nextBlockFast(_PREHASH_ChatData); + gMessageSystem->addStringFast(_PREHASH_Message, utf8str_truncate(strUTF8Text, MAX_MSG_STR_LEN)); + gMessageSystem->addU8Fast(_PREHASH_Type, CHAT_TYPE_SHOUT); + gMessageSystem->addS32("Channel", nChannel); + gAgent.sendReliableMessage(); + LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT); + + return true; +} + +// ============================================================================ +// Generic menu enablers +// + +// Checked: 2010-04-23 (RLVa-1.2.0g) | Modified: RLVa-1.2.0g +bool rlvMenuCheckEnabled() +{ + return rlv_handler_t::isEnabled(); +} + +// Checked: 2010-04-23 (RLVa-1.2.0g) | Modified: RLVa-1.2.0g +bool rlvMenuToggleEnabled() +{ + gSavedSettings.setBOOL(RLV_SETTING_MAIN, !rlv_handler_t::isEnabled()); + + LLSD args; + args["MESSAGE"] = + llformat("RestrainedLove Support will be %s after you restart", (rlv_handler_t::isEnabled()) ? "disabled" : "enabled" ); + LLNotificationsUtil::add("GenericAlert", args); + + return true; +} + +// Checked: 2011-08-16 (RLVa-1.4.0b) | Added: RLVa-1.4.0b +void rlvMenuToggleVisible() +{ + bool fTopLevel = rlvGetSetting(RLV_SETTING_TOPLEVELMENU, true); + bool fRlvEnabled = rlv_handler_t::isEnabled(); + + LLMenuGL* pRLVaMenuMain = gMenuBarView->findChildMenuByName("RLVa Main", FALSE); + LLMenuGL* pAdvancedMenu = gMenuBarView->findChildMenuByName("Advanced", FALSE); + LLMenuGL* pRLVaMenuEmbed = pAdvancedMenu->findChildMenuByName("RLVa Embedded", FALSE); + + gMenuBarView->setItemVisible("RLVa Main", (fRlvEnabled) && (fTopLevel)); + pAdvancedMenu->setItemVisible("RLVa Embedded", (fRlvEnabled) && (!fTopLevel)); + + if ( (rlv_handler_t::isEnabled()) && (pRLVaMenuMain) && (pRLVaMenuEmbed) && + ( ((fTopLevel) && (1 == pRLVaMenuMain->getItemCount())) || ((!fTopLevel) && (1 == pRLVaMenuEmbed->getItemCount())) ) ) + { + LLMenuGL* pMenuFrom = (fTopLevel) ? pRLVaMenuEmbed : pRLVaMenuMain; + LLMenuGL* pMenuTo = (fTopLevel) ? pRLVaMenuMain : pRLVaMenuEmbed; + while (LLMenuItemGL* pItem = pMenuFrom->getItem(1)) + { + pMenuFrom->removeChild(pItem); + pMenuTo->addChild(pItem); + pItem->updateBranchParent(pMenuTo); + } + } +} + +// Checked: 2010-04-23 (RLVa-1.2.0g) | Modified: RLVa-1.2.0g +bool rlvMenuEnableIfNot(const LLSD& sdParam) +{ + bool fEnable = true; + if (rlv_handler_t::isEnabled()) + { + ERlvBehaviour eBhvr = RlvCommand::getBehaviourFromString(sdParam.asString()); + fEnable = (eBhvr != RLV_BHVR_UNKNOWN) ? !gRlvHandler.hasBehaviour(eBhvr) : true; + } + return fEnable; +} + +// ============================================================================ +// Selection functors +// + +// Checked: 2011-05-28 (RLVa-1.4.6) | Modified: RLVa-1.4.0 +bool rlvCanDeleteOrReturn(const LLViewerObject* pObj) +{ + // Block if: @rez=n restricted and owned by us or a group *or* @unsit=n restricted and being sat on by us + return + ( (!gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) || ((!pObj->permYouOwner()) && (!pObj->permGroupOwner())) ) && + ( (!gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) || (!isAgentAvatarValid()) || (!pObj->getRootEdit()->isChild(gAgentAvatarp)) ); +} + +// Checked: 2011-05-28 (RLVa-1.4.6) | Modified: RLVa-1.4.0 +bool rlvCanDeleteOrReturn() +{ + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) || (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) ) + { + struct RlvCanDeleteOrReturn : public LLSelectedObjectFunctor + { + /*virtual*/ bool apply(LLViewerObject* pObj) { return rlvCanDeleteOrReturn(pObj); } + } f; + LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection(); + return (hSel.notNull()) && (0 != hSel->getRootObjectCount()) && (hSel->applyToRootObjects(&f, false)); + } + return true; +} + +// Checked: 2010-04-20 (RLVa-1.2.0f) | Modified: RLVa-0.2.0f +bool RlvSelectHasLockedAttach::apply(LLSelectNode* pNode) +{ + return (pNode->getObject()) ? gRlvAttachmentLocks.isLockedAttachment(pNode->getObject()->getRootEdit()) : false; +} + +// Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c +bool RlvSelectIsEditable::apply(LLSelectNode* pNode) +{ + const LLViewerObject* pObj = pNode->getObject(); + return (pObj) && (!gRlvHandler.canEdit(pObj)); +} + +// Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a +bool RlvSelectIsSittingOn::apply(LLSelectNode* pNode) +{ + return (pNode->getObject()) && (pNode->getObject()->getRootEdit()->isChild(m_pAvatar)); +} + +// ============================================================================ +// Predicates +// + +// Checked: 2010-11-11 (RLVa-1.2.1g) | Modified: RLVa-1.2.1g +bool rlvPredCanWearItem(const LLViewerInventoryItem* pItem, ERlvWearMask eWearMask) +{ + if ( (pItem) && (RlvForceWear::isWearableItem(pItem)) ) + { + if (RlvForceWear::isWearingItem(pItem)) + return true; // Special exception for currently worn items + switch (pItem->getType()) + { + case LLAssetType::AT_BODYPART: + // NOTE: only one body part of each type is allowed so the only way to wear one is if we can replace the current one + return (RLV_WEAR_LOCKED != (gRlvWearableLocks.canWear(pItem) & RLV_WEAR_REPLACE & eWearMask)); + case LLAssetType::AT_CLOTHING: + return (RLV_WEAR_LOCKED != (gRlvWearableLocks.canWear(pItem) & eWearMask)); + case LLAssetType::AT_OBJECT: + return (RLV_WEAR_LOCKED != (gRlvAttachmentLocks.canAttach(pItem) & eWearMask)); + case LLAssetType::AT_GESTURE: + return true; + default: + RLV_ASSERT(false); + } + } + return false; +} + +// Checked: 2010-03-22 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +bool rlvPredCanNotWearItem(const LLViewerInventoryItem* pItem, ERlvWearMask eWearMask) +{ + return !rlvPredCanWearItem(pItem, eWearMask); +} + +// Checked: 2010-03-22 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +bool rlvPredCanRemoveItem(const LLInventoryItem* pItem) +{ + if ( (pItem) && (RlvForceWear::isWearableItem(pItem)) ) + { + switch (pItem->getType()) + { + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_CLOTHING: + return gRlvWearableLocks.canRemove(pItem); + case LLAssetType::AT_OBJECT: + return gRlvAttachmentLocks.canDetach(pItem); + case LLAssetType::AT_GESTURE: + return true; + default: + RLV_ASSERT(false); + } + } + // HACK-RLVa: Until LL supports temporary attachment detection assume that no inventory item means a temporary + // attachment which are always removeable + return true; +} + +// Checked: 2010-03-22 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +bool rlvPredCanNotRemoveItem(const LLInventoryItem* pItem) +{ + return !rlvPredCanRemoveItem(pItem); +} + +// Checked: 2010-04-24 (RLVa-1.2.0f) | Added: RLVa-1.2.0f +RlvPredIsEqualOrLinkedItem::RlvPredIsEqualOrLinkedItem(const LLUUID& idItem) +{ + m_pItem = gInventory.getItem(idItem); +} + +// Checked: 2010-04-24 (RLVa-1.2.0f) | Added: RLVa-1.2.0f +bool RlvPredIsEqualOrLinkedItem::operator()(const LLViewerInventoryItem* pItem) const +{ + return (m_pItem) && (pItem) && (m_pItem->getLinkedUUID() == pItem->getLinkedUUID()); +} + +// ============================================================================ +// Various public helper functions +// + +// Checked: 2009-11-15 (RLVa-1.1.0c) | Added: RLVa-1.1.0c +/* +BOOL rlvEnableSharedWearEnabler(void* pParam) +{ + return false; + // Visually disable the "Enable Shared Wear" option when at least one attachment is non-detachable + return (!gRlvHandler.hasLockedAttachment(RLV_LOCK_REMOVE)); +} +*/ + +// Checked: 2010-11-01 (RLVa-1.2.2a) | Added: RLVa-1.2.2a +const std::string& rlvGetAnonym(const LLAvatarName& avName) +{ + return RlvStrings::getAnonym(avName); +} + +// ============================================================================ diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h new file mode 100644 index 0000000000000000000000000000000000000000..00afc2254ecfba2797d88b23702a6d6b1da05407 --- /dev/null +++ b/indra/newview/rlvcommon.h @@ -0,0 +1,304 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#ifndef RLV_COMMON_H +#define RLV_COMMON_H + +#include "llavatarname.h" +#include "llselectmgr.h" +#include "llviewercontrol.h" + +#include "rlvdefines.h" + +#ifdef LL_WINDOWS + #pragma warning (push) + #pragma warning (disable : 4702) // warning C4702: unreachable code +#endif +#include <boost/variant.hpp> +#ifdef LL_WINDOWS + #pragma warning (pop) +#endif + +// ============================================================================ +// Forward declarations +// + +// +// General viewer source +// +class LLInventoryItem; +class LLViewerInventoryCategory; +class LLViewerInventoryItem; +class LLViewerJointAttachment; +class LLViewerWearable; +class LLWearable; + +// +// RLVa-specific +// +class RlvCommand; +typedef std::list<RlvCommand> rlv_command_list_t; +class RlvObject; + +struct RlvException; +typedef boost::variant<std::string, LLUUID, S32, ERlvBehaviour> RlvExceptionOption; + +class RlvGCTimer; + +// ============================================================================ +// RlvSettings +// + +template<typename T> inline T rlvGetSetting(const std::string& strSetting, const T& defaultValue) +{ + RLV_ASSERT_DBG(gSavedSettings.controlExists(strSetting)); + return (gSavedSettings.controlExists(strSetting)) ? gSavedSettings.get<T>(strSetting) : defaultValue; +} + +template<typename T> inline T rlvGetPerUserSetting(const std::string& strSetting, const T& defaultValue) +{ + RLV_ASSERT_DBG(gSavedPerAccountSettings.controlExists(strSetting)); + return (gSavedPerAccountSettings.controlExists(strSetting)) ? gSavedPerAccountSettings.get<T>(strSetting) : defaultValue; +} + +class RlvSettings +{ +public: + static bool getDebug() { return rlvGetSetting<bool>(RLV_SETTING_DEBUG, false); } + static bool getCanOOC() { return fCanOOC; } + static bool getForbidGiveToRLV() { return rlvGetSetting<bool>(RLV_SETTING_FORBIDGIVETORLV, true); } + static bool getNoSetEnv() { return fNoSetEnv; } + + static std::string getWearAddPrefix() { return rlvGetSetting<std::string>(RLV_SETTING_WEARADDPREFIX, LLStringUtil::null); } + static std::string getWearReplacePrefix() { return rlvGetSetting<std::string>(RLV_SETTING_WEARREPLACEPREFIX, LLStringUtil::null); } + + static bool getDebugHideUnsetDup() { return rlvGetSetting<bool>(RLV_SETTING_DEBUGHIDEUNSETDUP, false); } + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + static BOOL getEnableComposites() { return fCompositeFolders; } + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + static bool getEnableLegacyNaming() { return fLegacyNaming; } + static bool getEnableSharedWear() { return rlvGetSetting<bool>(RLV_SETTING_ENABLESHAREDWEAR, false); } + static bool getHideLockedLayers() { return rlvGetSetting<bool>(RLV_SETTING_HIDELOCKEDLAYER, false); } + static bool getHideLockedAttach() { return rlvGetSetting<bool>(RLV_SETTING_HIDELOCKEDATTACH, false); } + static bool getHideLockedInventory() { return rlvGetSetting<bool>(RLV_SETTING_HIDELOCKEDINVENTORY, false); } + static bool getSharedInvAutoRename() { return rlvGetSetting<bool>(RLV_SETTING_SHAREDINVAUTORENAME, true); } + static bool getShowNameTags() { return fShowNameTags; } + + #ifdef RLV_EXTENSION_STARTLOCATION + static bool getLoginLastLocation() { return rlvGetPerUserSetting<bool>(RLV_SETTING_LOGINLASTLOCATION, true); } + static void updateLoginLastLocation(); + #endif // RLV_EXTENSION_STARTLOCATION + + static void initClass(); +protected: + static bool onChangedAvatarOffset(const LLSD& sdValue); + static bool onChangedMenuLevel(); + static bool onChangedSettingBOOL(const LLSD& sdValue, bool* pfSetting); + + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + static BOOL fCompositeFolders; + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + static bool fCanOOC; + static bool fLegacyNaming; + static bool fNoSetEnv; + static bool fShowNameTags; +}; + +// ============================================================================ +// RlvStrings +// + +class RlvStrings +{ +public: + static void initClass(); + static void loadFromFile(const std::string& strFilePath, bool fDefault); + static void saveToFile(const std::string& strFilePath); + + static const std::string& getAnonym(const LLAvatarName& avName); // @shownames + static const std::string& getAnonym(const std::string& strName); // @shownames + static const std::string& getString(const std::string& strStringName); + static const char* getStringFromReturnCode(ERlvCmdRet eRet); + static const std::string& getStringMapPath() { return m_StringMapPath; } + static std::string getVersion(bool fLegacy = false); // @version + static std::string getVersionAbout(); // Shown in Help / About + static std::string getVersionNum(); // @versionnum + static bool hasString(const std::string& strStringName, bool fCheckCustom = false); + static void setCustomString(const std::string& strStringName, const std::string& strStringValue); + +protected: + static std::vector<std::string> m_Anonyms; + typedef std::map<std::string, std::list<std::string> > string_map_t; + static string_map_t m_StringMap; + static std::string m_StringMapPath; +}; + +// ============================================================================ +// RlvUtil - Collection of (static) helper functions +// + +class RlvUtil +{ +public: + static bool isEmote(const std::string& strUTF8Text); + static bool isNearbyAgent(const LLUUID& idAgent); // @shownames + static bool isNearbyRegion(const std::string& strRegion); // @showloc + + static void filterLocation(std::string& strUTF8Text); // @showloc + static void filterNames(std::string& strUTF8Text, bool fFilterLegacy = true); // @shownames + static void filterScriptQuestions(S32& nQuestions, LLSD& sdPayload); + + static bool isForceTp() { return m_fForceTp; } + static void forceTp(const LLVector3d& posDest); // Ignores restrictions that might otherwise prevent tp'ing + + static void notifyBlocked(const std::string& strNotifcation, const LLSD& sdArgs = LLSD()); + static void notifyBlockedGeneric() { notifyBlocked(RLV_STRING_BLOCKED_GENERIC); } + static void notifyBlockedViewXXX(LLAssetType::EType assetType) { notifyBlocked(RLV_STRING_BLOCKED_VIEWXXX, LLSD().with("[TYPE]", LLAssetType::lookup(assetType))); } + static void notifyFailedAssertion(const std::string& strAssert, const std::string& strFile, int nLine); + + static void sendBusyMessage(const LLUUID& idTo, const std::string& strMsg, const LLUUID& idSession = LLUUID::null); + static bool isValidReplyChannel(S32 nChannel); + static bool sendChatReply(S32 nChannel, const std::string& strUTF8Text); + static bool sendChatReply(const std::string& strChannel, const std::string& strUTF8Text); + +protected: + static bool m_fForceTp; // @standtp +}; + +// ============================================================================ +// Extensibility classes +// + +class RlvCommandHandler +{ +public: + virtual ~RlvCommandHandler() {} + virtual bool onAddRemCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) { return false; } + virtual bool onClearCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) { return false; } + virtual bool onReplyCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) { return false; } + virtual bool onForceCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) { return false; } +}; +typedef bool (RlvCommandHandler::*rlvCommandHandler)(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet); + +// ============================================================================ +// Generic menu enablers +// + +bool rlvMenuCheckEnabled(); +bool rlvMenuToggleEnabled(); +void rlvMenuToggleVisible(); +bool rlvMenuEnableIfNot(const LLSD& sdParam); + +// ============================================================================ +// Selection functors +// + +bool rlvCanDeleteOrReturn(); +bool rlvCanDeleteOrReturn(const LLViewerObject* pObj); + +struct RlvSelectHasLockedAttach : public LLSelectedNodeFunctor +{ + RlvSelectHasLockedAttach() {} + virtual bool apply(LLSelectNode* pNode); +}; + +// Filters out selected objects that can't be editable (i.e. getFirstNode() will return NULL if the selection is fully editable) +struct RlvSelectIsEditable : public LLSelectedNodeFunctor +{ + RlvSelectIsEditable() {} + /*virtual*/ bool apply(LLSelectNode* pNode); +}; + +struct RlvSelectIsSittingOn : public LLSelectedNodeFunctor +{ + RlvSelectIsSittingOn(const LLVOAvatar* pAvatar) : m_pAvatar(pAvatar) {} + /*virtual*/ bool apply(LLSelectNode* pNode); +protected: + const LLVOAvatar* m_pAvatar; +}; + +// ============================================================================ +// Predicates +// + +bool rlvPredCanWearItem(const LLViewerInventoryItem* pItem, ERlvWearMask eWearMask); +bool rlvPredCanNotWearItem(const LLViewerInventoryItem* pItem, ERlvWearMask eWearMask); +bool rlvPredCanRemoveItem(const LLInventoryItem* pItem); +bool rlvPredCanNotRemoveItem(const LLInventoryItem* pItem); + +struct RlvPredCanWearItem +{ + RlvPredCanWearItem(ERlvWearMask eWearMask) : m_eWearMask(eWearMask) {} + bool operator()(const LLViewerInventoryItem* pItem) { return rlvPredCanWearItem(pItem, m_eWearMask); } +protected: + ERlvWearMask m_eWearMask; +}; + +struct RlvPredCanNotWearItem +{ + RlvPredCanNotWearItem(ERlvWearMask eWearMask) : m_eWearMask(eWearMask) {} + bool operator()(const LLViewerInventoryItem* pItem) { return rlvPredCanNotWearItem(pItem, m_eWearMask); } +protected: + ERlvWearMask m_eWearMask; +}; + +struct RlvPredIsEqualOrLinkedItem +{ + RlvPredIsEqualOrLinkedItem(const LLViewerInventoryItem* pItem) : m_pItem(pItem) {} + RlvPredIsEqualOrLinkedItem(const LLUUID& idItem); + bool operator()(const LLViewerInventoryItem* pItem) const; +protected: + const LLViewerInventoryItem* m_pItem; +}; + +template<typename T> struct RlvPredValuesEqual +{ + bool operator()(const T* pT2) const { return (pT1) && (pT2) && (*pT1 == *pT2); } + const T* pT1; +}; + +// ============================================================================ +// Inlined class member functions +// + +// Checked: 2010-10-31 (RLVa-1.2.2a) | Added: RLVa-1.2.2a +inline const std::string& RlvStrings::getAnonym(const LLAvatarName& avName) +{ + return getAnonym(avName.getDisplayName()); +} + +// Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.0.2a +inline bool RlvUtil::isEmote(const std::string& strUTF8Text) +{ + return (strUTF8Text.length() > 4) && ( (strUTF8Text.compare(0, 4, "/me ") == 0) || (strUTF8Text.compare(0, 4, "/me'") == 0) ); +} + +// Checked: 2010-03-09 (RLVa-1.2.0b) | Added: RLVa-1.0.2a +inline bool RlvUtil::isValidReplyChannel(S32 nChannel) +{ + return (nChannel > 0) && (CHAT_CHANNEL_DEBUG != nChannel); +} + +// Checked: 2009-08-05 (RLVa-1.0.1e) | Added: RLVa-1.0.0e +inline bool RlvUtil::sendChatReply(const std::string& strChannel, const std::string& strUTF8Text) +{ + S32 nChannel; + return (LLStringUtil::convertToS32(strChannel, nChannel)) ? sendChatReply(nChannel, strUTF8Text) : false; +} + +// ============================================================================ + +#endif // RLV_COMMON_H diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h new file mode 100644 index 0000000000000000000000000000000000000000..cc20f8924f2e97a0a8b7b6c072a6c99dd5bd64f4 --- /dev/null +++ b/indra/newview/rlvdefines.h @@ -0,0 +1,345 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#ifndef RLV_DEFINES_H +#define RLV_DEFINES_H + +// ============================================================================ +// Extensions +// + +// Extensions +#define RLV_EXTENSION_CMD_GETSETDEBUG_EX // Extends the debug variables accessible through @getdebug_xxx/@setdebug_xxx +#define RLV_EXTENSION_CMD_FINDFOLDERS // @findfolders:<option>=<channel> - @findfolder with multiple results +#define RLV_EXTENSION_FORCEWEAR_GESTURES // @attach*/detach* commands also (de)activate gestures +#define RLV_EXTENSION_STARTLOCATION // Reenables "Start Location" at login if not @tploc=n or @unsit=n restricted at last logoff +#define RLV_EXPERIMENTAL // Enables/disables experimental features en masse +#define RLV_EXPERIMENTAL_CMDS // Enables/disables experimental commands en masse + +// Experimental features +#ifdef RLV_EXPERIMENTAL + // Stable (will mature to RLV_EXTENSION_XXX in next release if no bugs are found) + + // Under testing (stable, but requires further testing - safe for public release but may be quirky) + #define RLV_EXTENSION_FORCEWEAR_FOLDERLINKS // @attach*/detach* commands will collect from folder links as well + + // Under development (don't include in public release) + #if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG +// #define RLV_EXPERIMENTAL_COMPOSITEFOLDERS + #endif // LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG +#endif // RLV_EXPERIMENTAL + +// Experimental commands (not part of the RLV API spec, disabled on public releases) +#ifdef RLV_EXPERIMENTAL_CMDS + #define RLV_EXTENSION_CMD_ALLOWIDLE // Forces "Away" status when idle (effect is the same as setting AllowIdleAFK to TRUE) + #define RLV_EXTENSION_CMD_GETCOMMAND // @getcommand:<option>=<channel> + #define RLV_EXTENSION_CMD_GETXXXNAMES // @get[add|rem]attachnames:<option>=<channel> and @get[add|rem]outfitnames=<channel> + #define RLV_EXTENSION_CMD_INTERACT // @interact=n + #define RLV_EXTENSION_CMD_TOUCHXXX // @touch:uuid=n|y, @touchworld[:<uuid>]=n|y, @touchattach[:<uuid>]=n|y, @touchud[:<uuid>]=n|y +#endif // RLV_EXPERIMENTAL_CMDS + +// ============================================================================ +// Defines +// + +// Version of the specifcation we support +const S32 RLV_VERSION_MAJOR = 2; +const S32 RLV_VERSION_MINOR = 7; +const S32 RLV_VERSION_PATCH = 0; +const S32 RLV_VERSION_BUILD = 0; + +// Implementation version +const S32 RLVa_VERSION_MAJOR = 1; +const S32 RLVa_VERSION_MINOR = 4; +const S32 RLVa_VERSION_PATCH = 9; +const S32 RLVa_VERSION_BUILD = 0; + +// Uncomment before a final release +//#define RLV_RELEASE + +// Defining these makes it easier if we ever need to change our tag +#define RLV_WARNS LL_WARNS("RLV") +#define RLV_INFOS LL_INFOS("RLV") +#define RLV_DEBUGS LL_DEBUGS("RLV") +#define RLV_ENDL LL_ENDL +#define RLV_VERIFY(f) if (!(f)) { RlvUtil::notifyFailedAssertion(#f, __FILE__, __LINE__); } + +#if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG + // Turn on extended debugging information + #define RLV_DEBUG + // Make sure we halt execution on errors + #define RLV_ERRS LL_ERRS("RLV") + // Keep our asserts separate from LL's + #define RLV_ASSERT(f) if (!(f)) { RLV_ERRS << "ASSERT (" << #f << ")" << RLV_ENDL; } + #define RLV_ASSERT_DBG(f) RLV_ASSERT(f) +#else + // Don't halt execution on errors in release + #define RLV_ERRS LL_WARNS("RLV") + // We don't want to check assertions in release builds + #ifndef RLV_RELEASE + #define RLV_ASSERT(f) RLV_VERIFY(f) + #define RLV_ASSERT_DBG(f) + #else + #define RLV_ASSERT(f) + #define RLV_ASSERT_DBG(f) + #endif // RLV_RELEASE +#endif // LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG + +#define RLV_ROOT_FOLDER "#RLV" +#define RLV_CMD_PREFIX '@' +#define RLV_PUTINV_PREFIX "#RLV/~" +#define RLV_SETROT_OFFSET F_PI_BY_TWO // @setrot is off by 90° with the rest of SL +#define RLV_STRINGS_FILE "rlva_strings.xml" + +#define RLV_FOLDER_FLAG_NOSTRIP "nostrip" +#define RLV_FOLDER_PREFIX_HIDDEN '.' +#define RLV_FOLDER_PREFIX_PUTINV '~' + +// ============================================================================ +// Enumeration declarations +// + +// NOTE: any changes to this enumeration should be reflected in RlvCommand::initLookupTable() +enum ERlvBehaviour { + RLV_BHVR_DETACH = 0, // "detach" + RLV_BHVR_ATTACH, // "attach" + RLV_BHVR_ADDATTACH, // "addattach" + RLV_BHVR_REMATTACH, // "remattach" + RLV_BHVR_ADDOUTFIT, // "addoutfit" + RLV_BHVR_REMOUTFIT, // "remoutfit" + RLV_BHVR_SHAREDWEAR, // "sharedwear" + RLV_BHVR_SHAREDUNWEAR, // "sharedunwear" + RLV_BHVR_UNSHAREDWEAR, // "unsharedwear" + RLV_BHVR_UNSHAREDUNWEAR, // "unsharedunwear" + RLV_BHVR_EMOTE, // "emote" + RLV_BHVR_SENDCHAT, // "sendchat" + RLV_BHVR_RECVCHAT, // "recvchat" + RLV_BHVR_RECVCHATFROM, // "recvchatfrom" + RLV_BHVR_RECVEMOTE, // "recvemote" + RLV_BHVR_RECVEMOTEFROM, // "recvemotefrom" + RLV_BHVR_REDIRCHAT, // "redirchat" + RLV_BHVR_REDIREMOTE, // "rediremote" + RLV_BHVR_CHATWHISPER, // "chatwhisper" + RLV_BHVR_CHATNORMAL, // "chatnormal" + RLV_BHVR_CHATSHOUT, // "chatshout" + RLV_BHVR_SENDCHANNEL, // "sendchannel" + RLV_BHVR_SENDIM, // "sendim" + RLV_BHVR_SENDIMTO, // "sendimto" + RLV_BHVR_RECVIM, // "recvim" + RLV_BHVR_RECVIMFROM, // "recvimfrom" + RLV_BHVR_STARTIM, // "startim" + RLV_BHVR_STARTIMTO, // "startimto" + RLV_BHVR_PERMISSIVE, // "permissive" + RLV_BHVR_NOTIFY, // "notify" + RLV_BHVR_SHOWINV, // "showinv" + RLV_BHVR_SHOWMINIMAP, // "showminimap" + RLV_BHVR_SHOWWORLDMAP, // "showworldmap" + RLV_BHVR_SHOWLOC, // "showloc" + RLV_BHVR_SHOWNAMES, // "shownames" + RLV_BHVR_SHOWHOVERTEXT, // "showhovertext" + RLV_BHVR_SHOWHOVERTEXTHUD, // "showhovertexthud" + RLV_BHVR_SHOWHOVERTEXTWORLD, // "showhovertextworld" + RLV_BHVR_SHOWHOVERTEXTALL, // "showhovertextall" + RLV_BHVR_TPLM, // "tplm" + RLV_BHVR_TPLOC, // "tploc" + RLV_BHVR_TPLURE, // "tplure" + RLV_BHVR_VIEWNOTE, // "viewnote" + RLV_BHVR_VIEWSCRIPT, // "viewscript" + RLV_BHVR_VIEWTEXTURE, // "viewtexture" + RLV_BHVR_ACCEPTPERMISSION, // "acceptpermission" + RLV_BHVR_ACCEPTTP, // "accepttp" + RLV_BHVR_ALLOWIDLE, // "allowidle" + RLV_BHVR_EDIT, // "edit" + RLV_BHVR_EDITOBJ, // "editobj" + RLV_BHVR_REZ, // "rez" + RLV_BHVR_FARTOUCH, // "fartouch" + RLV_BHVR_INTERACT, // "interact" + RLV_BHVR_TOUCHTHIS, // "touchthis" + RLV_BHVR_TOUCHATTACH, // "touchattach" + RLV_BHVR_TOUCHATTACHSELF, // "touchattachself" + RLV_BHVR_TOUCHATTACHOTHER, // "touchattachother" + RLV_BHVR_TOUCHHUD, // "touchhud" + RLV_BHVR_TOUCHWORLD, // "touchworld" + RLV_BHVR_TOUCHALL, // "touchall" + RLV_BHVR_TOUCHME, // "touchme" + RLV_BHVR_FLY, // "fly" + RLV_BHVR_SETGROUP, // "setgroup" + RLV_BHVR_UNSIT, // "unsit" + RLV_BHVR_SIT, // "sit" + RLV_BHVR_SITTP, // "sittp" + RLV_BHVR_STANDTP, // "standtp" + RLV_BHVR_SETDEBUG, // "setdebug" + RLV_BHVR_SETENV, // "setenv" + RLV_BHVR_ALWAYSRUN, // "alwaysrun" + RLV_BHVR_TEMPRUN, // "temprun" + RLV_BHVR_DETACHME, // "detachme" + RLV_BHVR_ATTACHOVER, // "attachover" + RLV_BHVR_ATTACHTHIS, // "attachthis" + RLV_BHVR_ATTACHTHISOVER, // "attachthisover" + RLV_BHVR_ATTACHTHISEXCEPT, // "attachthis_except" + RLV_BHVR_DETACHTHIS, // "detachthis" + RLV_BHVR_DETACHTHISEXCEPT, // "detachthis_except" + RLV_BHVR_ATTACHALL, // "attachall" + RLV_BHVR_ATTACHALLOVER, // "attachallover" + RLV_BHVR_DETACHALL, // "detachall" + RLV_BHVR_ATTACHALLTHIS, // "attachallthis" + RLV_BHVR_ATTACHALLTHISEXCEPT, // "attachallthis_except" + RLV_BHVR_ATTACHALLTHISOVER, // "attachallthisover" + RLV_BHVR_DETACHALLTHIS, // "detachallthis" + RLV_BHVR_DETACHALLTHISEXCEPT, // "detachallthis_except" + RLV_BHVR_ADJUSTHEIGHT, // "adjustheight" + RLV_BHVR_TPTO, // "tpto" + RLV_BHVR_VERSION, // "version" + RLV_BHVR_VERSIONNEW, // "versionnew" + RLV_BHVR_VERSIONNUM, // "versionnum" + RLV_BHVR_GETATTACH, // "getattach" + RLV_BHVR_GETATTACHNAMES, // "getattachnames" + RLV_BHVR_GETADDATTACHNAMES, // "getaddattachnames" + RLV_BHVR_GETREMATTACHNAMES, // "getremattachnames" + RLV_BHVR_GETOUTFIT, // "getoutfit" + RLV_BHVR_GETOUTFITNAMES, // "getoutfitnames" + RLV_BHVR_GETADDOUTFITNAMES, // "getaddoutfitnames" + RLV_BHVR_GETREMOUTFITNAMES, // "getremoutfitnames" + RLV_BHVR_FINDFOLDER, // "findfolder" + RLV_BHVR_FINDFOLDERS, // "findfolders" + RLV_BHVR_GETPATH, // "getpath" + RLV_BHVR_GETPATHNEW, // "getpathnew" + RLV_BHVR_GETINV, // "getinv" + RLV_BHVR_GETINVWORN, // "getinvworn" + RLV_BHVR_GETGROUP, // "getgroup" + RLV_BHVR_GETSITID, // "getsitid" + RLV_BHVR_GETCOMMAND, // "getcommand" + RLV_BHVR_GETSTATUS, // "getstatus" + RLV_BHVR_GETSTATUSALL, // "getstatusall" + + RLV_BHVR_COUNT, + RLV_BHVR_UNKNOWN +}; + +enum ERlvParamType { + RLV_TYPE_UNKNOWN, + RLV_TYPE_ADD, // <param> == "n"|"add" + RLV_TYPE_REMOVE, // <param> == "y"|"rem" + RLV_TYPE_FORCE, // <param> == "force" + RLV_TYPE_REPLY, // <param> == <number> + RLV_TYPE_CLEAR +}; + +enum ERlvCmdRet { + RLV_RET_UNKNOWN = 0x0000, // Unknown error (should only be used internally) + RLV_RET_RETAINED, // Command was retained + RLV_RET_SUCCESS = 0x0100, // Command executed succesfully + RLV_RET_SUCCESS_UNSET, // Command executed succesfully (RLV_TYPE_REMOVE for an unrestricted behaviour) + RLV_RET_SUCCESS_DUPLICATE, // Command executed succesfully (RLV_TYPE_ADD for an already restricted behaviour) + RLV_RET_SUCCESS_DELAYED, // Command parsed valid but will execute at a later time + RLV_RET_FAILED = 0x0200, // Command failed (general failure) + RLV_RET_FAILED_SYNTAX, // Command failed (syntax error) + RLV_RET_FAILED_OPTION, // Command failed (invalid option) + RLV_RET_FAILED_PARAM, // Command failed (invalid param) + RLV_RET_FAILED_LOCK, // Command failed (command is locked by another object) + RLV_RET_FAILED_DISABLED, // Command failed (command disabled by user) + RLV_RET_FAILED_UNKNOWN, // Command failed (unknown command) + RLV_RET_FAILED_NOSHAREDROOT, // Command failed (missing #RLV) + RLV_RET_DEPRECATED // Command has been deprecated +}; + +enum ERlvExceptionCheck +{ + RLV_CHECK_PERMISSIVE, // Exception can be set by any object + RLV_CHECK_STRICT, // Exception must be set by all objects holding the restriction + RLV_CHECK_DEFAULT // Permissive or strict will be determined by currently enforced restrictions +}; + +enum ERlvLockMask +{ + RLV_LOCK_ADD = 0x01, + RLV_LOCK_REMOVE = 0x02, + RLV_LOCK_ANY = RLV_LOCK_ADD | RLV_LOCK_REMOVE +}; + +enum ERlvWearMask +{ + RLV_WEAR_LOCKED = 0x00, // User can not wear the item at all + RLV_WEAR_ADD = 0x01, // User can wear the item in addition to what's already worn + RLV_WEAR_REPLACE = 0x02, // User can wear the item and replace what's currently worn + RLV_WEAR = 0x03 // Convenience: combines RLV_WEAR_ADD and RLV_WEAR_REPLACE +}; + +enum ERlvAttachGroupType +{ + RLV_ATTACHGROUP_HEAD = 0, + RLV_ATTACHGROUP_TORSO, + RLV_ATTACHGROUP_ARMS, + RLV_ATTACHGROUP_LEGS, + RLV_ATTACHGROUP_HUD, + RLV_ATTACHGROUP_COUNT, + RLV_ATTACHGROUP_INVALID +}; + +// ============================================================================ +// Settings +// + +#define RLV_SETTING_MAIN "RestrainedLove" +#define RLV_SETTING_DEBUG "RestrainedLoveDebug" +#define RLV_SETTING_CANOOC "RestrainedLoveCanOOC" +#define RLV_SETTING_FORBIDGIVETORLV "RestrainedLoveForbidGiveToRLV" +#define RLV_SETTING_NOSETENV "RestrainedLoveNoSetEnv" +#define RLV_SETTING_SHOWELLIPSIS "RestrainedLoveShowEllipsis" +#define RLV_SETTING_WEARADDPREFIX "RestrainedLoveStackWhenFolderBeginsWith" +#define RLV_SETTING_WEARREPLACEPREFIX "RestrainedLoveReplaceWhenFolderBeginsWith" + +#define RLV_SETTING_DEBUGHIDEUNSETDUP "RLVaDebugHideUnsetDuplicate" +#define RLV_SETTING_ENABLECOMPOSITES "RLVaEnableCompositeFolders" +#define RLV_SETTING_ENABLELEGACYNAMING "RLVaEnableLegacyNaming" +#define RLV_SETTING_ENABLESHAREDWEAR "RLVaEnableSharedWear" +#define RLV_SETTING_HIDELOCKEDLAYER "RLVaHideLockedLayers" +#define RLV_SETTING_HIDELOCKEDATTACH "RLVaHideLockedAttachments" +#define RLV_SETTING_HIDELOCKEDINVENTORY "RLVaHideLockedInventory" +#define RLV_SETTING_LOGINLASTLOCATION "RLVaLoginLastLocation" +#define RLV_SETTING_SHAREDINVAUTORENAME "RLVaSharedInvAutoRename" +#define RLV_SETTING_SHOWASSERTIONFAIL "RLVaShowAssertionFailures" +#define RLV_SETTING_SHOWNAMETAGS "RLVaShowNameTags" +#define RLV_SETTING_TOPLEVELMENU "RLVaTopLevelMenu" +#define RLV_SETTING_WEARREPLACEUNLOCKED "RLVaWearReplaceUnlocked" + +#define RLV_SETTING_FIRSTUSE_PREFIX "FirstRLV" +#define RLV_SETTING_FIRSTUSE_GIVETORLV RLV_SETTING_FIRSTUSE_PREFIX"GiveToRLV" + +// ============================================================================ +// Strings (see rlva_strings.xml) +// + +#define RLV_STRING_HIDDEN "hidden_generic" +#define RLV_STRING_HIDDEN_PARCEL "hidden_parcel" +#define RLV_STRING_HIDDEN_REGION "hidden_region" + +#define RLV_STRING_BLOCKED_GENERIC "blocked_generic" +#define RLV_STRING_BLOCKED_PERMATTACH "blocked_permattach" +#define RLV_STRING_BLOCKED_PERMTELEPORT "blocked_permteleport" +#define RLV_STRING_BLOCKED_RECVIM "blocked_recvim" +#define RLV_STRING_BLOCKED_RECVIM_REMOTE "blocked_recvim_remote" +#define RLV_STRING_BLOCKED_SENDIM "blocked_sendim" +#define RLV_STRING_BLOCKED_STARTCONF "blocked_startconf" +#define RLV_STRING_BLOCKED_STARTIM "blocked_startim" +#define RLV_STRING_BLOCKED_TELEPORT "blocked_teleport" +#define RLV_STRING_BLOCKED_TPLURE_REMOTE "blocked_tplure_remote" +#define RLV_STRING_BLOCKED_VIEWXXX "blocked_viewxxx" +#define RLV_STRING_BLOCKED_WIREFRAME "blocked_wireframe" + +// ============================================================================ + +#endif // RLV_DEFINES_H diff --git a/indra/newview/rlvextensions.cpp b/indra/newview/rlvextensions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b835df30f764c8d6df48a10a85abfe8d7422b1c5 --- /dev/null +++ b/indra/newview/rlvextensions.cpp @@ -0,0 +1,643 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#include "llviewerprecompiledheaders.h" +#include "llagent.h" +#include "llagentcamera.h" +#include "lldaycyclemanager.h" +#include "llviewercontrol.h" +#include "llvoavatarself.h" +#include "llwlparammanager.h" + +#include "rlvextensions.h" +#include "rlvhandler.h" +#include "rlvhelper.h" + +// ============================================================================ + +class RlvWindLightControl +{ +public: + enum EType { TYPE_COLOR, TYPE_COLOR_R, TYPE_FLOAT, TYPE_UNKNOWN }; + enum EColorComponent { COMPONENT_R, COMPONENT_G, COMPONENT_B, COMPONENT_I, COMPONENT_NONE }; +public: + RlvWindLightControl(WLColorControl* pCtrl, bool fColorR) : m_eType((!fColorR) ? TYPE_COLOR: TYPE_COLOR_R), m_pColourCtrl(pCtrl), m_pFloatCtrl(NULL) {} + RlvWindLightControl(WLFloatControl* pCtrl) : m_eType(TYPE_FLOAT), m_pColourCtrl(NULL), m_pFloatCtrl(pCtrl) {} + + EType getControlType() const { return m_eType; } + bool isColorType() const { return (TYPE_COLOR == m_eType) || (TYPE_COLOR_R == m_eType); } + bool isFloatType() const { return (TYPE_FLOAT == m_eType); } + // TYPE_COLOR and TYPE_COLOR_R + F32 getColorComponent(EColorComponent eComponent, bool& fError) const; + LLVector4 getColorVector(bool& fError) const; + bool setColorComponent(EColorComponent eComponent, F32 nValue); + // TYPE_FLOAT + F32 getFloat(bool& fError) const; + bool setFloat(F32 nValue); + + static EColorComponent getComponentFromCharacter(char ch); +protected: + EType m_eType; // Type of the WindLight control + WLColorControl* m_pColourCtrl; + WLFloatControl* m_pFloatCtrl; +}; + +// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +static F32 get_intensity_from_color(const LLVector4& v) +{ + return llmax(v.mV[0], v.mV[1], v.mV[2]); +} + +// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +F32 RlvWindLightControl::getColorComponent(EColorComponent eComponent, bool& fError) const +{ + switch (eComponent) + { + case COMPONENT_R: return getColorVector(fError).mV[0]; + case COMPONENT_G: return getColorVector(fError).mV[1]; + case COMPONENT_B: return getColorVector(fError).mV[2]; + case COMPONENT_I: return get_intensity_from_color(getColorVector(fError)); // SL-2.8: Always seems to be 1.0 so get it manually + default : RLV_ASSERT(false); fError = true; return 0.0; + } +} + +// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +RlvWindLightControl::EColorComponent RlvWindLightControl::getComponentFromCharacter(char ch) +{ + if (('r' == ch) || ('x' == ch)) + return COMPONENT_R; + else if (('g' == ch) || ('y' == ch)) + return COMPONENT_G; + else if (('b' == ch) || ('d' == ch)) + return COMPONENT_B; + else if ('i' == ch) + return COMPONENT_I; + return COMPONENT_NONE; +} + +// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +LLVector4 RlvWindLightControl::getColorVector(bool& fError) const +{ + if ((fError = !isColorType())) + return LLVector4(0, 0, 0, 0); + F32 nMult = (m_pColourCtrl->isSunOrAmbientColor) ? 3.0f : ((m_pColourCtrl->isBlueHorizonOrDensity) ? 2.0f : 1.0f); + return LLWLParamManager::getInstance()->mCurParams.getVector(m_pColourCtrl->mName, fError) / nMult; +} + +// Checked: 2011-08-28 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +bool RlvWindLightControl::setColorComponent(EColorComponent eComponent, F32 nValue) +{ + if (isColorType()) + { + nValue *= (m_pColourCtrl->isSunOrAmbientColor) ? 3.0f : ((m_pColourCtrl->isBlueHorizonOrDensity) ? 2.0f : 1.0f); + if (COMPONENT_I == eComponent) // (See: LLFloaterWindLight::onColorControlIMoved) + { + if (m_pColourCtrl->hasSliderName) + { + F32 curMax = llmax(m_pColourCtrl->r, m_pColourCtrl->g, m_pColourCtrl->b); + if ( (0.0f == nValue) || (0.0f == curMax) ) + { + m_pColourCtrl->r = m_pColourCtrl->g = m_pColourCtrl->b = m_pColourCtrl->i = nValue; + } + else + { + F32 nDelta = (nValue - curMax) / curMax; + m_pColourCtrl->r *= (1.0f + nDelta); + m_pColourCtrl->g *= (1.0f + nDelta); + m_pColourCtrl->b *= (1.0f + nDelta); + m_pColourCtrl->i = nValue; + } + } + } + else // (See: LLFloaterWindLight::onColorControlRMoved) + { + F32* pnValue = (COMPONENT_R == eComponent) ? &m_pColourCtrl->r : (COMPONENT_G == eComponent) ? &m_pColourCtrl->g : (COMPONENT_B == eComponent) ? &m_pColourCtrl->b : NULL; + if (pnValue) + *pnValue = nValue; + if (m_pColourCtrl->hasSliderName) + m_pColourCtrl->i = llmax(m_pColourCtrl->r, m_pColourCtrl->g, m_pColourCtrl->b); + } + m_pColourCtrl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); + } + return isColorType(); +} + +// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +F32 RlvWindLightControl::getFloat(bool& fError) const +{ + return (!(fError = (TYPE_FLOAT != m_eType))) ? LLWLParamManager::getInstance()->mCurParams.getVector(m_pFloatCtrl->mName, fError).mV[0] * m_pFloatCtrl->mult : 0.0; +} + +// Checked: 2011-08-28 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +bool RlvWindLightControl::setFloat(F32 nValue) +{ + if (TYPE_FLOAT == m_eType) + { + m_pFloatCtrl->x = nValue / m_pFloatCtrl->mult; + m_pFloatCtrl->update(LLWLParamManager::getInstance()->mCurParams); + LLWLParamManager::getInstance()->propagateParameters(); + } + return (TYPE_FLOAT == m_eType); +} + +// ============================================================================ + +class RlvWindLight : public LLSingleton<RlvWindLight> +{ + friend class LLSingleton<RlvWindLight>; +public: + RlvWindLight(); + + std::string getValue(const std::string& strSetting, bool& fError); + bool setValue(const std::string& strRlvName, const std::string& strValue); + +protected: + std::map<std::string, RlvWindLightControl> m_ControlLookupMap; +}; + +// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +RlvWindLight::RlvWindLight() +{ + LLWLParamManager* pWLParamMgr = LLWLParamManager::getInstance(); + + // TYPE_FLOAT + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("cloudcoverage", RlvWindLightControl(&pWLParamMgr->mCloudCoverage))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("cloudscale", RlvWindLightControl(&pWLParamMgr->mCloudScale))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("densitymultiplier", RlvWindLightControl(&pWLParamMgr->mDensityMult))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("distancemultiplier", RlvWindLightControl(&pWLParamMgr->mDistanceMult))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("maxaltitude", RlvWindLightControl(&pWLParamMgr->mMaxAlt))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("scenegamma", RlvWindLightControl(&pWLParamMgr->mWLGamma))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("hazedensity", RlvWindLightControl(&pWLParamMgr->mHazeDensity))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("hazehorizon", RlvWindLightControl(&pWLParamMgr->mHazeHorizon))); + // TYPE_COLOR + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("ambient", RlvWindLightControl(&pWLParamMgr->mAmbient, false))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("bluedensity", RlvWindLightControl(&pWLParamMgr->mBlueDensity, false))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("bluehorizon", RlvWindLightControl(&pWLParamMgr->mBlueHorizon, false))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("cloud", RlvWindLightControl(&pWLParamMgr->mCloudMain, false))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("cloudcolor", RlvWindLightControl(&pWLParamMgr->mCloudColor, false))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("clouddetail", RlvWindLightControl(&pWLParamMgr->mCloudDetail, false))); + m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("sunmooncolor", RlvWindLightControl(&pWLParamMgr->mSunlight, false))); +} + +// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +std::string RlvWindLight::getValue(const std::string& strSetting, bool& fError) +{ + LLWLParamManager* pWLParams = LLWLParamManager::getInstance(); + LLEnvManagerNew* pEnvMgr = LLEnvManagerNew::getInstance(); + + fError = false; // Assume we won't fail + if ("preset" == strSetting) + return (pEnvMgr->getUseFixedSky()) ? pEnvMgr->getSkyPresetName() : std::string(); + else if ("daycycle" == strSetting) + return (pEnvMgr->getUseDayCycle()) ? pEnvMgr->getDayCycleName() : std::string(); + + F32 nValue = 0.0f; + if ("daytime" == strSetting) + { + nValue = (pEnvMgr->getUseFixedSky()) ? pWLParams->mCurParams.getFloat("sun_angle", fError) / F_TWO_PI : -1.0f; + } + else if (("sunglowfocus" == strSetting) || ("sunglowsize" == strSetting)) + { + pWLParams->mGlow = pWLParams->mCurParams.getVector(pWLParams->mGlow.mName, fError); + RLV_ASSERT_DBG(!fError); + + if ("sunglowfocus" == strSetting) + nValue = -pWLParams->mGlow.b / 5.0f; + else + nValue = 2 - pWLParams->mGlow.r / 20.0f; + } + else if ("starbrightness" == strSetting) nValue = pWLParams->mCurParams.getStarBrightness(); + else if ("eastangle" == strSetting) nValue = pWLParams->mCurParams.getEastAngle() / F_TWO_PI; + else if ("sunmoonposition" == strSetting) nValue = pWLParams->mCurParams.getSunAngle() / F_TWO_PI; + else if ("cloudscrollx" == strSetting) nValue = pWLParams->mCurParams.getCloudScrollX() - 10.0f; + else if ("cloudscrolly" == strSetting) nValue = pWLParams->mCurParams.getCloudScrollY() - 10.0f; + else + { + std::map<std::string, RlvWindLightControl>::const_iterator itControl = m_ControlLookupMap.find(strSetting); + if (m_ControlLookupMap.end() != itControl) + { + switch (itControl->second.getControlType()) + { + case RlvWindLightControl::TYPE_FLOAT: + nValue = itControl->second.getFloat(fError); + break; + case RlvWindLightControl::TYPE_COLOR_R: + nValue = itControl->second.getColorComponent(RlvWindLightControl::COMPONENT_R, fError); + break; + default: + fError = true; + break; + } + } + else + { + // Couldn't find the exact name, check for a color control name + RlvWindLightControl::EColorComponent eComponent = RlvWindLightControl::getComponentFromCharacter(strSetting[strSetting.length() - 1]); + if (RlvWindLightControl::COMPONENT_NONE != eComponent) + itControl = m_ControlLookupMap.find(strSetting.substr(0, strSetting.length() - 1)); + if ( (m_ControlLookupMap.end() != itControl) && (itControl->second.isColorType()) ) + nValue = itControl->second.getColorComponent(eComponent, fError); + else + fError = true; + } + } + return llformat("%f", nValue); +} + +// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a +bool RlvWindLight::setValue(const std::string& strRlvName, const std::string& strValue) +{ + F32 nValue = 0.0f; + // Sanity check - make sure strValue specifies a number for all settings except "preset" and "daycycle" + if ( (RlvSettings::getNoSetEnv()) || + ( (!LLStringUtil::convertToF32(strValue, nValue)) && (("preset" != strRlvName) && ("daycycle" != strRlvName)) ) ) + { + return false; + } + + LLWLParamManager* pWLParams = LLWLParamManager::getInstance(); + LLEnvManagerNew* pEnvMgr = LLEnvManagerNew::getInstance(); + + if ("daytime" == strRlvName) + { + if (0.0f <= nValue) + { + pWLParams->mAnimator.deactivate(); + pWLParams->mAnimator.setDayTime(nValue); + pWLParams->mAnimator.update(pWLParams->mCurParams); + } + else + { + pEnvMgr->useRegionSettings(); + } + return true; + } + else if ("preset" == strRlvName) + { + std::string strPresetName = pWLParams->findPreset(strValue, LLEnvKey::SCOPE_LOCAL); + if (!strPresetName.empty()) + pEnvMgr->useSkyPreset(strPresetName); + return !strPresetName.empty(); + } + else if ("daycycle" == strRlvName) + { + std::string strPresetName = LLDayCycleManager::instance().findPreset(strValue); + if (!strPresetName.empty()) + pEnvMgr->useDayCycle(strValue, LLEnvKey::SCOPE_LOCAL); + return !strPresetName.empty(); + } + + bool fError = false; + pWLParams->mAnimator.deactivate(); + if (("sunglowfocus" == strRlvName) || ("sunglowsize" == strRlvName)) + { + pWLParams->mGlow = pWLParams->mCurParams.getVector(pWLParams->mGlow.mName, fError); + RLV_ASSERT_DBG(!fError); + + if ("sunglowfocus" == strRlvName) + pWLParams->mGlow.b = -nValue * 5; + else + pWLParams->mGlow.r = (2 - nValue) * 20; + + pWLParams->mGlow.update(pWLParams->mCurParams); + pWLParams->propagateParameters(); + return true; + } + else if ("starbrightness" == strRlvName) + { + pWLParams->mCurParams.setStarBrightness(nValue); + return true; + } + else if (("eastangle" == strRlvName) || ("sunmoonposition" == strRlvName)) + { + if ("eastangle" == strRlvName) + pWLParams->mCurParams.setEastAngle(F_TWO_PI * nValue); + else + pWLParams->mCurParams.setSunAngle(F_TWO_PI * nValue); + + // Set the sun vector + pWLParams->mLightnorm.r = -sin(pWLParams->mCurParams.getEastAngle()) * cos(pWLParams->mCurParams.getSunAngle()); + pWLParams->mLightnorm.g = sin(pWLParams->mCurParams.getSunAngle()); + pWLParams->mLightnorm.b = cos(pWLParams->mCurParams.getEastAngle()) * cos(pWLParams->mCurParams.getSunAngle()); + pWLParams->mLightnorm.i = 1.f; + + pWLParams->propagateParameters(); + return true; + } + else if ("cloudscrollx" == strRlvName) + { + pWLParams->mCurParams.setCloudScrollX(nValue + 10.0f); + return true; + } + else if ("cloudscrolly" == strRlvName) + { + pWLParams->mCurParams.setCloudScrollY(nValue + 10.0f); + return true; + } + + std::map<std::string, RlvWindLightControl>::iterator itControl = m_ControlLookupMap.find(strRlvName); + if (m_ControlLookupMap.end() != itControl) + { + switch (itControl->second.getControlType()) + { + case RlvWindLightControl::TYPE_FLOAT: + return itControl->second.setFloat(nValue); + case RlvWindLightControl::TYPE_COLOR_R: + return itControl->second.setColorComponent(RlvWindLightControl::COMPONENT_R, nValue); + default: + RLV_ASSERT(false); + } + } + else + { + // Couldn't find the exact name, check for a color control name + RlvWindLightControl::EColorComponent eComponent = RlvWindLightControl::getComponentFromCharacter(strRlvName[strRlvName.length() - 1]); + if (RlvWindLightControl::COMPONENT_NONE != eComponent) + itControl = m_ControlLookupMap.find(strRlvName.substr(0, strRlvName.length() - 1)); + if ( (m_ControlLookupMap.end() != itControl) && (itControl->second.isColorType()) ) + return itControl->second.setColorComponent(eComponent, nValue); + } + return false; +} + +// ============================================================================ + +std::map<std::string, S16> RlvExtGetSet::m_DbgAllowed; +std::map<std::string, std::string> RlvExtGetSet::m_PseudoDebug; + +// Checked: 2009-06-03 (RLVa-0.2.0h) | Modified: RLVa-0.2.0h +RlvExtGetSet::RlvExtGetSet() +{ + if (!m_DbgAllowed.size()) // m_DbgAllowed is static and should only be initialized once + { + m_DbgAllowed.insert(std::pair<std::string, S16>("AvatarSex", DBG_READ | DBG_WRITE | DBG_PSEUDO)); + m_DbgAllowed.insert(std::pair<std::string, S16>("RenderResolutionDivisor", DBG_READ | DBG_WRITE)); + #ifdef RLV_EXTENSION_CMD_GETSETDEBUG_EX + m_DbgAllowed.insert(std::pair<std::string, S16>(RLV_SETTING_FORBIDGIVETORLV, DBG_READ)); + m_DbgAllowed.insert(std::pair<std::string, S16>(RLV_SETTING_NOSETENV, DBG_READ)); + m_DbgAllowed.insert(std::pair<std::string, S16>("WindLightUseAtmosShaders", DBG_READ)); + #endif // RLV_EXTENSION_CMD_GETSETDEBUG_EX + + // Cache persistance of every setting + LLControlVariable* pSetting; + for (std::map<std::string, S16>::iterator itDbg = m_DbgAllowed.begin(); itDbg != m_DbgAllowed.end(); ++itDbg) + { + if ( ((pSetting = gSavedSettings.getControl(itDbg->first)) != NULL) && (pSetting->isPersisted()) ) + itDbg->second |= DBG_PERSIST; + } + } +} + +// Checked: 2009-05-17 (RLVa-0.2.0a) +bool RlvExtGetSet::onForceCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) +{ + return processCommand(rlvCmd, cmdRet); +} + +// Checked: 2009-05-17 (RLVa-0.2.0a) +bool RlvExtGetSet::onReplyCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) +{ + return processCommand(rlvCmd, cmdRet); +} + +// Checked: 2009-12-23 (RLVa-1.1.0k) | Modified: RLVa-1.1.0k +bool RlvExtGetSet::processCommand(const RlvCommand& rlvCmd, ERlvCmdRet& eRet) +{ + std::string strBehaviour = rlvCmd.getBehaviour(), strGetSet, strSetting; + int idxSetting = strBehaviour.find('_'); + if ( (strBehaviour.length() >= 6) && (-1 != idxSetting) && ((int)strBehaviour.length() > idxSetting + 1) ) + { + strSetting = strBehaviour.substr(idxSetting + 1); + strBehaviour.erase(idxSetting); // Get rid of "_<setting>" + + strGetSet = strBehaviour.substr(0, 3); + strBehaviour.erase(0, 3); // Get rid of get/set + + if ("debug" == strBehaviour) + { + if ( ("get" == strGetSet) && (RLV_TYPE_REPLY == rlvCmd.getParamType()) ) + { + RlvUtil::sendChatReply(rlvCmd.getParam(), onGetDebug(strSetting)); + eRet = RLV_RET_SUCCESS; + return true; + } + else if ( ("set" == strGetSet) && (RLV_TYPE_FORCE == rlvCmd.getParamType()) ) + { + if (!gRlvHandler.hasBehaviourExcept(RLV_BHVR_SETDEBUG, rlvCmd.getObjectID())) + eRet = onSetDebug(strSetting, rlvCmd.getOption()); + else + eRet = RLV_RET_FAILED_LOCK; + return true; + } + } + else if ("env" == strBehaviour) + { + bool fError = false; + if ( ("get" == strGetSet) && (RLV_TYPE_REPLY == rlvCmd.getParamType()) ) + { + RlvUtil::sendChatReply(rlvCmd.getParam(), RlvWindLight::instance().getValue(strSetting, fError)); + eRet = (!fError) ? RLV_RET_SUCCESS : RLV_RET_FAILED_UNKNOWN; + return true; + } + else if ( ("set" == strGetSet) && (RLV_TYPE_FORCE == rlvCmd.getParamType()) ) + { + if (!gRlvHandler.hasBehaviourExcept(RLV_BHVR_SETENV, rlvCmd.getObjectID())) + eRet = (RlvWindLight::instance().setValue(strSetting, rlvCmd.getOption())) ? RLV_RET_SUCCESS : RLV_RET_FAILED_UNKNOWN; + else + eRet = RLV_RET_FAILED_LOCK; + return true; + } + } + } + else if ("setrot" == rlvCmd.getBehaviour()) + { + // NOTE: if <option> is invalid (or missing) altogether then RLV-1.17 will rotate to 0.0 (which is actually PI / 4) + F32 nAngle = 0.0f; + if (LLStringUtil::convertToF32(rlvCmd.getOption(), nAngle)) + { + nAngle = RLV_SETROT_OFFSET - nAngle; + + gAgentCamera.startCameraAnimation(); + + LLVector3 at(LLVector3::x_axis); + at.rotVec(nAngle, LLVector3::z_axis); + at.normalize(); + gAgent.resetAxes(at); + + eRet = RLV_RET_SUCCESS; + } + else + { + eRet = RLV_RET_FAILED_OPTION; + } + return true; + } + return false; +} + +// Checked: 2009-06-03 (RLVa-0.2.0h) | Modified: RLVa-0.2.0h +bool RlvExtGetSet::findDebugSetting(std::string& strSetting, S16& flags) +{ + LLStringUtil::toLower(strSetting); // Convenience for non-RLV calls + + std::string strTemp; + for (std::map<std::string, S16>::const_iterator itSetting = m_DbgAllowed.begin(); itSetting != m_DbgAllowed.end(); ++itSetting) + { + strTemp = itSetting->first; + LLStringUtil::toLower(strTemp); + + if (strSetting == strTemp) + { + strSetting = itSetting->first; + flags = itSetting->second; + return true; + } + } + return false; +} + +// Checked: 2009-06-03 (RLVa-0.2.0h) | Added: RLVa-0.2.0h +S16 RlvExtGetSet::getDebugSettingFlags(const std::string& strSetting) +{ + std::map<std::string, S16>::const_iterator itSetting = m_DbgAllowed.find(strSetting); + return (itSetting != m_DbgAllowed.end()) ? itSetting->second : 0; +} + +// Checked: 2009-06-03 (RLVa-0.2.0h) | Modified: RLVa-0.2.0h +std::string RlvExtGetSet::onGetDebug(std::string strSetting) +{ + S16 dbgFlags; + if ( (findDebugSetting(strSetting, dbgFlags)) && ((dbgFlags & DBG_READ) == DBG_READ) ) + { + if ((dbgFlags & DBG_PSEUDO) == 0) + { + LLControlVariable* pSetting = gSavedSettings.getControl(strSetting); + if (pSetting) + { + switch (pSetting->type()) + { + case TYPE_U32: + return llformat("%u", gSavedSettings.getU32(strSetting)); + case TYPE_S32: + return llformat("%d", gSavedSettings.getS32(strSetting)); + case TYPE_BOOLEAN: + return llformat("%d", gSavedSettings.getBOOL(strSetting)); + default: + RLV_ERRS << "Unexpected debug setting type" << LL_ENDL; + break; + } + } + } + else + { + return onGetPseudoDebug(strSetting); + } + } + return std::string(); +} + +// Checked: 2009-10-03 (RLVa-1.0.4e) | Added: RLVa-1.0.4e +std::string RlvExtGetSet::onGetPseudoDebug(const std::string& strSetting) +{ + // Skip sanity checking because it's all done in RlvExtGetSet::onGetDebug() already + if ("AvatarSex" == strSetting) + { + std::map<std::string, std::string>::const_iterator itPseudo = m_PseudoDebug.find(strSetting); + if (itPseudo != m_PseudoDebug.end()) + { + return itPseudo->second; + } + else + { + if (isAgentAvatarValid()) + return llformat("%d", (gAgentAvatarp->getSex() == SEX_MALE)); // [See LLFloaterCustomize::LLFloaterCustomize()] + } + } + return std::string(); +} + +// Checked: 2009-10-10 (RLVa-1.0.4e) | Modified: RLVa-1.0.4e +ERlvCmdRet RlvExtGetSet::onSetDebug(std::string strSetting, const std::string& strValue) +{ + S16 dbgFlags; ERlvCmdRet eRet = RLV_RET_FAILED_UNKNOWN; + if ( (findDebugSetting(strSetting, dbgFlags)) && ((dbgFlags & DBG_WRITE) == DBG_WRITE) ) + { + eRet = RLV_RET_FAILED_OPTION; + if ((dbgFlags & DBG_PSEUDO) == 0) + { + LLControlVariable* pSetting = gSavedSettings.getControl(strSetting); + if (pSetting) + { + U32 u32Value; S32 s32Value; BOOL fValue; + switch (pSetting->type()) + { + case TYPE_U32: + if (LLStringUtil::convertToU32(strValue, u32Value)) + { + gSavedSettings.setU32(strSetting, u32Value); + eRet = RLV_RET_SUCCESS; + } + break; + case TYPE_S32: + if (LLStringUtil::convertToS32(strValue, s32Value)) + { + gSavedSettings.setS32(strSetting, s32Value); + eRet = RLV_RET_SUCCESS; + } + break; + case TYPE_BOOLEAN: + if (LLStringUtil::convertToBOOL(strValue, fValue)) + { + gSavedSettings.setBOOL(strSetting, fValue); + eRet = RLV_RET_SUCCESS; + } + break; + default: + RLV_ERRS << "Unexpected debug setting type" << LL_ENDL; + eRet = RLV_RET_FAILED; + break; + } + + // Default settings should persist if they were marked that way, but non-default settings should never persist + pSetting->setPersist( ((pSetting->isDefault()) && ((dbgFlags & DBG_PERSIST) == DBG_PERSIST)) ? LLControlVariable::PERSIST_NONDFT : LLControlVariable::PERSIST_NO ); + } + } + else + { + eRet = onSetPseudoDebug(strSetting, strValue); + } + } + return eRet; +} + +// Checked: 2009-10-10 (RLVa-1.0.4e) | Modified: RLVa-1.0.4e +ERlvCmdRet RlvExtGetSet::onSetPseudoDebug(const std::string& strSetting, const std::string& strValue) +{ + ERlvCmdRet eRet = RLV_RET_FAILED_OPTION; + if ("AvatarSex" == strSetting) + { + BOOL fValue; + if (LLStringUtil::convertToBOOL(strValue, fValue)) + { + m_PseudoDebug[strSetting] = strValue; + eRet = RLV_RET_SUCCESS; + } + } + return eRet; +} + +// ============================================================================ diff --git a/indra/newview/rlvextensions.h b/indra/newview/rlvextensions.h new file mode 100644 index 0000000000000000000000000000000000000000..7f161fd82522c7391d9b235988c2634d3a6ddcfd --- /dev/null +++ b/indra/newview/rlvextensions.h @@ -0,0 +1,57 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#ifndef RLV_EXTENSIONS_H +#define RLV_EXTENSIONS_H + +#include "rlvcommon.h" + +// ============================================================================ +/* + * RlvExtGetSet + * ============ + * Implements @get_XXX:<option>=<channel> and @set_XXX:<option>=force + * + */ + +class RlvExtGetSet : public RlvCommandHandler +{ +public: + RlvExtGetSet(); + virtual ~RlvExtGetSet() {} + + virtual bool onForceCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet); + virtual bool onReplyCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet); +protected: + std::string onGetDebug(std::string strSetting); + std::string onGetPseudoDebug(const std::string& strSetting); + ERlvCmdRet onSetDebug(std::string strSetting, const std::string& strValue); + ERlvCmdRet onSetPseudoDebug(const std::string& strSetting, const std::string& strValue); + + bool processCommand(const RlvCommand& rlvCmd, ERlvCmdRet& eRet); + +public: + enum { DBG_READ = 0x01, DBG_WRITE = 0x02, DBG_PERSIST = 0x04, DBG_PSEUDO = 0x08 }; + static std::map<std::string, S16> m_DbgAllowed; + static std::map<std::string, std::string> m_PseudoDebug; + + static bool findDebugSetting(/*[in,out]*/ std::string& strSetting, /*[out]*/ S16& flags); + static S16 getDebugSettingFlags(const std::string& strSetting); +}; + +// ============================================================================ + +#endif // RLV_EXTENSIONS_H diff --git a/indra/newview/rlvfloaters.cpp b/indra/newview/rlvfloaters.cpp new file mode 100644 index 0000000000000000000000000000000000000000..edb1bf21d264edcc52c9f516fec08810827f9601 --- /dev/null +++ b/indra/newview/rlvfloaters.cpp @@ -0,0 +1,666 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#include "llviewerprecompiledheaders.h" + +#include "llappearancemgr.h" +#include "llavatarnamecache.h" +#include "llclipboard.h" +#include "llcombobox.h" +#include "llinventoryfunctions.h" +#include "llnotificationsutil.h" +#include "llscrolllistctrl.h" +#include "llsdserialize.h" +#include "lltexteditor.h" +#include "llviewerjointattachment.h" +#include "llviewerobjectlist.h" +#include "llvoavatarself.h" + +#include "rlvfloaters.h" +#include "rlvhelper.h" +#include "rlvhandler.h" +#include "rlvlocks.h" + +// ============================================================================ +// Helper functions +// + +// Checked: 2012-07-14 (RLVa-1.4.7) +std::string rlvGetItemName(const LLViewerInventoryItem* pItem) +{ + if ( (pItem) && ((LLAssetType::AT_BODYPART == pItem->getType()) || (LLAssetType::AT_CLOTHING == pItem->getType())) ) + return llformat("%s (%s)", pItem->getName().c_str(), LLWearableType::getTypeName(pItem->getWearableType()).c_str()); + else if ( (pItem) && (LLAssetType::AT_OBJECT == pItem->getType()) && (isAgentAvatarValid()) ) + return llformat("%s (%s)", pItem->getName().c_str(), gAgentAvatarp->getAttachedPointName(pItem->getUUID()).c_str()); + return (pItem) ? pItem->getName() : LLStringUtil::null; +} + +// Checked: 2012-07-14 (RLVa-1.4.7) +std::string rlvGetItemType(const LLViewerInventoryItem* pItem) +{ + if (pItem) + { + switch (pItem->getType()) + { + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_CLOTHING: + return "Wearable"; + case LLAssetType::AT_OBJECT: + return "Attachment"; + default: + break; + } + } + return "Unknown"; +} + +// Checked: 2010-03-11 (RLVa-1.2.0a) | Modified: RLVa-1.2.0g +std::string rlvGetItemNameFromObjID(const LLUUID& idObj, bool fIncludeAttachPt = true) +{ + const LLViewerObject* pObj = gObjectList.findObject(idObj); + const LLViewerObject* pObjRoot = (pObj) ? pObj->getRootEdit() : NULL; + const LLViewerInventoryItem* pItem = ((pObjRoot) && (pObjRoot->isAttachment())) ? gInventory.getItem(pObjRoot->getAttachmentItemID()) : NULL; + + std::string strItemName = (pItem) ? pItem->getName() : idObj.asString(); + if ( (!fIncludeAttachPt) || (!pObj) || (!pObj->isAttachment()) || (!isAgentAvatarValid()) ) + return strItemName; + + const LLViewerJointAttachment* pAttachPt = + get_if_there(gAgentAvatarp->mAttachmentPoints, RlvAttachPtLookup::getAttachPointIndex(pObjRoot), (LLViewerJointAttachment*)NULL); + std::string strAttachPtName = (pAttachPt) ? pAttachPt->getName() : std::string("Unknown"); + return llformat("%s (%s%s)", strItemName.c_str(), strAttachPtName.c_str(), (pObj == pObjRoot) ? "" : ", child"); +} + +// Checked: 2011-05-23 (RLVa-1.3.0c) | Added: RLVa-1.3.0c +bool rlvGetShowException(ERlvBehaviour eBhvr) +{ + switch (eBhvr) + { + case RLV_BHVR_RECVCHAT: + case RLV_BHVR_RECVEMOTE: + case RLV_BHVR_SENDIM: + case RLV_BHVR_RECVIM: + case RLV_BHVR_STARTIM: + case RLV_BHVR_TPLURE: + case RLV_BHVR_ACCEPTTP: + return true; + default: + return false; + } +} + +// Checked: 2012-07-29 (RLVa-1.4.7) +std::string rlvLockMaskToString(ERlvLockMask eLockType) +{ + switch (eLockType) + { + case RLV_LOCK_ADD: + return "add"; + case RLV_LOCK_REMOVE: + return "rem"; + default: + return "unknown"; + } +} + +// Checked: 2012-07-29 (RLVa-1.4.7) +std::string rlvFolderLockPermissionToString(RlvFolderLocks::ELockPermission eLockPermission) +{ + switch (eLockPermission) + { + case RlvFolderLocks::PERM_ALLOW: + return "allow"; + case RlvFolderLocks::PERM_DENY: + return "deny"; + default: + return "unknown"; + } +} + +// Checked: 2012-07-29 (RLVa-1.4.7) +std::string rlvFolderLockScopeToString(RlvFolderLocks::ELockScope eLockScope) +{ + switch (eLockScope) + { + case RlvFolderLocks::SCOPE_NODE: + return "node"; + case RlvFolderLocks::SCOPE_SUBTREE: + return "subtree"; + default: + return "unknown"; + } +} + +// Checked: 2012-07-29 (RLVa-1.4.7) +std::string rlvFolderLockSourceToTarget(RlvFolderLocks::folderlock_source_t lockSource) +{ + switch (lockSource.first) + { + case RlvFolderLocks::ST_ATTACHMENT: + { + std::string strAttachName = rlvGetItemNameFromObjID(boost::get<LLUUID>(lockSource.second)); + return llformat("Attachment (%s)", strAttachName.c_str()); + } + case RlvFolderLocks::ST_ATTACHMENTPOINT: + { + const LLViewerJointAttachment* pAttachPt = RlvAttachPtLookup::getAttachPoint(boost::get<S32>(lockSource.second)); + return llformat("Attachment point (%s)", (pAttachPt) ? pAttachPt->getName().c_str() : "Unknown"); + } + case RlvFolderLocks::ST_FOLDER: + { + return "Folder: <todo>"; + } + case RlvFolderLocks::ST_ROOTFOLDER: + { + return "Root folder"; + } + case RlvFolderLocks::ST_SHAREDPATH: + { + const std::string& strPath = boost::get<std::string>(lockSource.second); + return llformat("Shared path (#RLV%s%s)", (!strPath.empty()) ? "/" : "", strPath.c_str()); + } + case RlvFolderLocks::ST_WEARABLETYPE: + { + const std::string& strTypeName = LLWearableType::getTypeName(boost::get<LLWearableType::EType>(lockSource.second)); + return llformat("Wearable type (%s)", strTypeName.c_str()); + } + default: + { + return "(Unknown)"; + } + } +} + +// ============================================================================ +// RlvFloaterBehaviours member functions +// + +// Checked: 2010-04-18 (RLVa-1.3.1c) | Modified: RLVa-1.2.0e +void RlvFloaterBehaviours::onOpen(const LLSD& sdKey) +{ + m_ConnRlvCommand = gRlvHandler.setCommandCallback(boost::bind(&RlvFloaterBehaviours::onCommand, this, _1, _2)); + + refreshAll(); +} + +// Checked: 2010-04-18 (RLVa-1.3.1c) | Modified: RLVa-1.2.0e +void RlvFloaterBehaviours::onClose(bool fQuitting) +{ + m_ConnRlvCommand.disconnect(); +} + +// Checked: 2010-04-18 (RLVa-1.3.1c) | Modified: RLVa-1.2.0e +void RlvFloaterBehaviours::onAvatarNameLookup(const LLUUID& idAgent, const LLAvatarName& avName) +{ + uuid_vec_t::iterator itLookup = std::find(m_PendingLookup.begin(), m_PendingLookup.end(), idAgent); + if (itLookup != m_PendingLookup.end()) + m_PendingLookup.erase(itLookup); + if (getVisible()) + refreshAll(); +} + +// Checked: 2011-05-26 (RLVa-1.3.1c) | Added: RLVa-1.3.1c +void RlvFloaterBehaviours::onBtnCopyToClipboard() +{ + std::ostringstream strRestrictions; + + strRestrictions << RlvStrings::getVersion() << "\n"; + + const RlvHandler::rlv_object_map_t* pObjects = gRlvHandler.getObjectMap(); + for (RlvHandler::rlv_object_map_t::const_iterator itObj = pObjects->begin(), endObj = pObjects->end(); itObj != endObj; ++itObj) + { + strRestrictions << "\n" << rlvGetItemNameFromObjID(itObj->first) << ":\n"; + + const rlv_command_list_t* pCommands = itObj->second.getCommandList(); + for (rlv_command_list_t::const_iterator itCmd = pCommands->begin(), endCmd = pCommands->end(); itCmd != endCmd; ++itCmd) + { + std::string strOption; LLUUID idOption; + if ( (itCmd->hasOption()) && (idOption.set(itCmd->getOption(), FALSE)) && (idOption.notNull()) ) + { + LLAvatarName avName; + if (gObjectList.findObject(idOption)) + strOption = rlvGetItemNameFromObjID(idOption, true); + else if (LLAvatarNameCache::get(idOption, &avName)) + strOption = (!avName.getAccountName().empty()) ? avName.getAccountName() : avName.getDisplayName(); + else if (!gCacheName->getGroupName(idOption, strOption)) + strOption = itCmd->getOption(); + } + + strRestrictions << " -> " << itCmd->asString(); + if ( (!strOption.empty()) && (strOption != itCmd->getOption()) ) + strRestrictions << " [" << strOption << "]"; + if (RLV_RET_SUCCESS != itCmd->getReturnType()) + strRestrictions << " (" << RlvStrings::getStringFromReturnCode(itCmd->getReturnType()) << ")"; + strRestrictions << "\n"; + } + } + + LLWString wstrRestrictions = utf8str_to_wstring(strRestrictions.str()); + LLClipboard::instance().copyToClipboard(wstrRestrictions, 0, wstrRestrictions.length()); +} + +// Checked: 2011-05-23 (RLVa-1.3.1c) | Modified: RLVa-1.3.1c +void RlvFloaterBehaviours::onCommand(const RlvCommand& rlvCmd, ERlvCmdRet eRet) +{ + if ( (RLV_TYPE_ADD == rlvCmd.getParamType()) || (RLV_TYPE_REMOVE == rlvCmd.getParamType()) ) + refreshAll(); +} + +// Checked: 2011-05-23 (RLVa-1.3.1c) | Added: RLVa-1.3.1c +BOOL RlvFloaterBehaviours::postBuild() +{ + getChild<LLUICtrl>("copy_btn")->setCommitCallback(boost::bind(&RlvFloaterBehaviours::onBtnCopyToClipboard, this)); + return TRUE; +} + +// Checked: 2011-05-23 (RLVa-1.3.1c) | Modified: RLVa-1.3.1c +void RlvFloaterBehaviours::refreshAll() +{ + LLCtrlListInterface* pBhvrList = childGetListInterface("behaviour_list"); + LLCtrlListInterface* pExceptList = childGetListInterface("exception_list"); + if ( (!pBhvrList) || (!pExceptList) ) + return; + pBhvrList->operateOnAll(LLCtrlListInterface::OP_DELETE); + pExceptList->operateOnAll(LLCtrlListInterface::OP_DELETE); + + if (!isAgentAvatarValid()) + return; + + // + // Set-up a row we can just reuse + // + LLSD sdBhvrRow; LLSD& sdBhvrColumns = sdBhvrRow["columns"]; + sdBhvrColumns[0] = LLSD().with("column", "behaviour").with("type", "text"); + sdBhvrColumns[1] = LLSD().with("column", "issuer").with("type", "text"); + + LLSD sdExceptRow; LLSD& sdExceptColumns = sdExceptRow["columns"]; + sdExceptColumns[0] = LLSD().with("column", "behaviour").with("type", "text"); + sdExceptColumns[1] = LLSD().with("column", "option").with("type", "text"); + sdExceptColumns[2] = LLSD().with("column", "issuer").with("type", "text"); + + // + // List behaviours + // + const RlvHandler::rlv_object_map_t* pObjects = gRlvHandler.getObjectMap(); + for (RlvHandler::rlv_object_map_t::const_iterator itObj = pObjects->begin(), endObj = pObjects->end(); itObj != endObj; ++itObj) + { + const std::string strIssuer = rlvGetItemNameFromObjID(itObj->first); + + const rlv_command_list_t* pCommands = itObj->second.getCommandList(); + for (rlv_command_list_t::const_iterator itCmd = pCommands->begin(), endCmd = pCommands->end(); itCmd != endCmd; ++itCmd) + { + std::string strOption; LLUUID idOption; + if ( (itCmd->hasOption()) && (idOption.set(itCmd->getOption(), FALSE)) && (idOption.notNull()) ) + { + LLAvatarName avName; + if (gObjectList.findObject(idOption)) + { + strOption = rlvGetItemNameFromObjID(idOption, true); + } + else if (LLAvatarNameCache::get(idOption, &avName)) + { + strOption = (!avName.getAccountName().empty()) ? avName.getAccountName() : avName.getDisplayName(); + } + else if (!gCacheName->getGroupName(idOption, strOption)) + { + if (m_PendingLookup.end() == std::find(m_PendingLookup.begin(), m_PendingLookup.end(), idOption)) + { + LLAvatarNameCache::get(idOption, boost::bind(&RlvFloaterBehaviours::onAvatarNameLookup, this, _1, _2)); + m_PendingLookup.push_back(idOption); + } + strOption = itCmd->getOption(); + } + } + + if ( (itCmd->hasOption()) && (rlvGetShowException(itCmd->getBehaviourType())) ) + { + // List under the "Exception" tab + sdExceptRow["enabled"] = gRlvHandler.isException(itCmd->getBehaviourType(), idOption); + sdExceptColumns[0]["value"] = itCmd->getBehaviour(); + sdExceptColumns[1]["value"] = strOption; + sdExceptColumns[2]["value"] = strIssuer; + pExceptList->addElement(sdExceptRow, ADD_BOTTOM); + } + else + { + // List under the "Restrictions" tab + sdBhvrRow["enabled"] = (RLV_RET_SUCCESS == itCmd->getReturnType()); + sdBhvrColumns[0]["value"] = (strOption.empty()) ? itCmd->asString() : itCmd->getBehaviour() + ":" + strOption; + sdBhvrColumns[1]["value"] = strIssuer; + pBhvrList->addElement(sdBhvrRow, ADD_BOTTOM); + } + } + } +} + +// ============================================================================ +// RlvFloaterLocks member functions +// + +// Checked: 2010-03-11 (RLVa-1.2.0) +void RlvFloaterLocks::onOpen(const LLSD& sdKey) +{ + m_ConnRlvCommand = gRlvHandler.setCommandCallback(boost::bind(&RlvFloaterLocks::onRlvCommand, this, _1, _2)); + + refreshAll(); +} + +// Checked: 2010-03-11 (RLVa-1.2.0) +void RlvFloaterLocks::onClose(bool fQuitting) +{ + m_ConnRlvCommand.disconnect(); +} + +// Checked: 2012-07-14 (RLVa-1.4.7) +BOOL RlvFloaterLocks::postBuild() +{ + getChild<LLUICtrl>("refresh_btn")->setCommitCallback(boost::bind(&RlvFloaterLocks::refreshAll, this)); + + return TRUE; +} + +// Checked: 2010-03-11 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +void RlvFloaterLocks::onRlvCommand(const RlvCommand& rlvCmd, ERlvCmdRet eRet) +{ + // Refresh on any successful @XXX=y|n command where XXX is any of the attachment or wearable locking behaviours + if ( (RLV_RET_SUCCESS == eRet) && ((RLV_TYPE_ADD == rlvCmd.getParamType()) || (RLV_TYPE_REMOVE == rlvCmd.getParamType())) ) + { + switch (rlvCmd.getBehaviourType()) + { + case RLV_BHVR_DETACH: + case RLV_BHVR_ADDATTACH: + case RLV_BHVR_REMATTACH: + case RLV_BHVR_ADDOUTFIT: + case RLV_BHVR_REMOUTFIT: + refreshAll(); + break; + default: + break; + } + } +} + +// Checked: 2010-03-18 (RLVa-1.2.0) +void RlvFloaterLocks::refreshAll() +{ + LLScrollListCtrl* pLockList = getChild<LLScrollListCtrl>("lock_list"); + pLockList->operateOnAll(LLCtrlListInterface::OP_DELETE); + + if (!isAgentAvatarValid()) + return; + + // + // Set-up a row we can just reuse + // + LLSD sdRow; + LLSD& sdColumns = sdRow["columns"]; + sdColumns[0]["column"] = "lock_type"; sdColumns[0]["type"] = "text"; + sdColumns[1]["column"] = "lock_addrem"; sdColumns[1]["type"] = "text"; + sdColumns[2]["column"] = "lock_target"; sdColumns[2]["type"] = "text"; + sdColumns[3]["column"] = "lock_origin"; sdColumns[3]["type"] = "text"; + + // + // List attachment locks + // + sdColumns[0]["value"] = "Attachment"; + sdColumns[1]["value"] = "rem"; + + const RlvAttachmentLocks::rlv_attachobjlock_map_t& attachObjRem = gRlvAttachmentLocks.getAttachObjLocks(); + for (RlvAttachmentLocks::rlv_attachobjlock_map_t::const_iterator itAttachObj = attachObjRem.begin(); + itAttachObj != attachObjRem.end(); ++itAttachObj) + { + sdColumns[2]["value"] = rlvGetItemNameFromObjID(itAttachObj->first); + sdColumns[3]["value"] = rlvGetItemNameFromObjID(itAttachObj->second); + + pLockList->addElement(sdRow, ADD_BOTTOM); + } + + // + // List attachment point locks + // + sdColumns[0]["value"] = "Attachment Point"; + + sdColumns[1]["value"] = "add"; + const RlvAttachmentLocks::rlv_attachptlock_map_t& attachPtAdd = gRlvAttachmentLocks.getAttachPtLocks(RLV_LOCK_ADD); + for (RlvAttachmentLocks::rlv_attachptlock_map_t::const_iterator itAttachPt = attachPtAdd.begin(); + itAttachPt != attachPtAdd.end(); ++itAttachPt) + { + const LLViewerJointAttachment* pAttachPt = + get_if_there(gAgentAvatarp->mAttachmentPoints, itAttachPt->first, (LLViewerJointAttachment*)NULL); + sdColumns[2]["value"] = pAttachPt->getName(); + sdColumns[3]["value"] = rlvGetItemNameFromObjID(itAttachPt->second); + + pLockList->addElement(sdRow, ADD_BOTTOM); + } + + sdColumns[1]["value"] = "rem"; + const RlvAttachmentLocks::rlv_attachptlock_map_t& attachPtRem = gRlvAttachmentLocks.getAttachPtLocks(RLV_LOCK_REMOVE); + for (RlvAttachmentLocks::rlv_attachptlock_map_t::const_iterator itAttachPt = attachPtRem.begin(); + itAttachPt != attachPtRem.end(); ++itAttachPt) + { + const LLViewerJointAttachment* pAttachPt = + get_if_there(gAgentAvatarp->mAttachmentPoints, itAttachPt->first, (LLViewerJointAttachment*)NULL); + sdColumns[2]["value"] = pAttachPt->getName(); + sdColumns[3]["value"] = rlvGetItemNameFromObjID(itAttachPt->second); + + pLockList->addElement(sdRow, ADD_BOTTOM); + } + + // + // List wearable type locks + // + sdColumns[0]["value"] = "Wearable Type"; + + sdColumns[1]["value"] = "add"; + const RlvWearableLocks::rlv_wearabletypelock_map_t& wearableTypeAdd = gRlvWearableLocks.getWearableTypeLocks(RLV_LOCK_ADD); + for (RlvWearableLocks::rlv_wearabletypelock_map_t::const_iterator itWearableType = wearableTypeAdd.begin(); + itWearableType != wearableTypeAdd.end(); ++itWearableType) + { + sdColumns[2]["value"] = LLWearableType::getTypeLabel(itWearableType->first); + sdColumns[3]["value"] = rlvGetItemNameFromObjID(itWearableType->second); + + pLockList->addElement(sdRow, ADD_BOTTOM); + } + + sdColumns[1]["value"] = "rem"; + const RlvWearableLocks::rlv_wearabletypelock_map_t& wearableTypeRem = gRlvWearableLocks.getWearableTypeLocks(RLV_LOCK_REMOVE); + for (RlvWearableLocks::rlv_wearabletypelock_map_t::const_iterator itWearableType = wearableTypeRem.begin(); + itWearableType != wearableTypeRem.end(); ++itWearableType) + { + sdColumns[2]["value"] = LLWearableType::getTypeName(itWearableType->first); + sdColumns[3]["value"] = rlvGetItemNameFromObjID(itWearableType->second); + + pLockList->addElement(sdRow, ADD_BOTTOM); + } + + // + // List "nostrip" (soft) locks + // + sdColumns[1]["value"] = "nostrip"; + sdColumns[3]["value"] = "(Agent)"; + + LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items; + LLFindWearablesEx f(true, true); + gInventory.collectDescendentsIf(LLAppearanceMgr::instance().getCOF(), folders, items, FALSE, f); + + for (LLInventoryModel::item_array_t::const_iterator itItem = items.begin(); itItem != items.end(); ++itItem) + { + const LLViewerInventoryItem* pItem = *itItem; + if (!RlvForceWear::instance().isStrippable(pItem->getUUID())) + { + sdColumns[0]["value"] = rlvGetItemType(pItem); + sdColumns[2]["value"] = rlvGetItemName(pItem); + + pLockList->addElement(sdRow, ADD_BOTTOM); + } + } + + // + // List folder locks + // + { + // Folder lock descriptors + const RlvFolderLocks::folderlock_list_t& folderLocks = RlvFolderLocks::instance().getFolderLocks(); + for (RlvFolderLocks::folderlock_list_t::const_iterator itFolderLock = folderLocks.begin(); + itFolderLock != folderLocks.end(); ++itFolderLock) + { + const RlvFolderLocks::folderlock_descr_t* pLockDescr = *itFolderLock; + if (pLockDescr) + { + sdColumns[0]["value"] = "Folder Descriptor"; + sdColumns[1]["value"] = + rlvLockMaskToString(pLockDescr->eLockType) + "/" + + rlvFolderLockPermissionToString(pLockDescr->eLockPermission) + "/" + + rlvFolderLockScopeToString(pLockDescr->eLockScope); + sdColumns[2]["value"] = rlvFolderLockSourceToTarget(pLockDescr->lockSource); + sdColumns[3]["value"] = rlvGetItemNameFromObjID(pLockDescr->idRlvObj); + + pLockList->addElement(sdRow, ADD_BOTTOM); + } + } + } + + { + // Folder locked attachments and wearables + uuid_vec_t idItems; + const uuid_vec_t& folderLockAttachmentsIds = RlvFolderLocks::instance().getAttachmentLookups(); + idItems.insert(idItems.end(), folderLockAttachmentsIds.begin(), folderLockAttachmentsIds.end()); + const uuid_vec_t& folderLockWearabels = RlvFolderLocks::instance().getWearableLookups(); + idItems.insert(idItems.end(), folderLockWearabels.begin(), folderLockWearabels.end()); + + for (uuid_vec_t::const_iterator itItemId = idItems.begin(); itItemId != idItems.end(); ++itItemId) + { + const LLViewerInventoryItem* pItem = gInventory.getItem(*itItemId); + if (pItem) + { + sdColumns[0]["value"] = rlvGetItemType(pItem); + sdColumns[1]["value"] = rlvLockMaskToString(RLV_LOCK_REMOVE); + sdColumns[2]["value"] = rlvGetItemName(pItem); + sdColumns[3]["value"] = "<Folder Lock>"; + + pLockList->addElement(sdRow, ADD_BOTTOM); + } + } + } +} + +// ============================================================================ +// RlvFloaterStrings member functions +// + +// Checked: 2011-11-08 (RLVa-1.5.0) +RlvFloaterStrings::RlvFloaterStrings(const LLSD& sdKey) + : LLFloater(sdKey) + , m_fDirty(false) + , m_pStringList(NULL) +{ +} + +// Checked: 2011-11-08 (RLVa-1.5.0) +BOOL RlvFloaterStrings::postBuild() +{ + // Set up the UI controls + m_pStringList = findChild<LLComboBox>("string_list"); + m_pStringList->setCommitCallback(boost::bind(&RlvFloaterStrings::checkDirty, this, true)); + + LLUICtrl* pDefaultBtn = findChild<LLUICtrl>("default_btn"); + pDefaultBtn->setCommitCallback(boost::bind(&RlvFloaterStrings::onStringRevertDefault, this)); + + // Read all string metadata from the default strings file + llifstream fileStream(RlvStrings::getStringMapPath(), std::ios::binary); LLSD sdFileData; + if ( (fileStream.is_open()) && (LLSDSerialize::fromXMLDocument(sdFileData, fileStream)) ) + { + m_sdStringsInfo = sdFileData["strings"]; + fileStream.close(); + } + + // Populate the combo box + for (LLSD::map_const_iterator itString = m_sdStringsInfo.beginMap(); itString != m_sdStringsInfo.endMap(); ++itString) + { + const LLSD& sdStringInfo = itString->second; + if ( (!sdStringInfo.has("customizable")) || (!sdStringInfo["customizable"].asBoolean()) ) + continue; + m_pStringList->add( (sdStringInfo.has("label")) ? sdStringInfo["label"].asString() : itString->first, itString->first); + } + + refresh(); + + return TRUE; +} + +// Checked: 2011-11-08 (RLVa-1.5.0) +void RlvFloaterStrings::onClose(bool fQuitting) +{ + checkDirty(false); + if (m_fDirty) + { + // Save the custom string overrides + RlvStrings::saveToFile(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, RLV_STRINGS_FILE)); + + // Remind the user their changes require a relog to take effect + LLNotificationsUtil::add("RLVChangeStrings"); + } +} + +// Checked: 2011-11-08 (RLVa-1.5.0) +void RlvFloaterStrings::onStringRevertDefault() +{ + if (!m_strStringCurrent.empty()) + { + RlvStrings::setCustomString(m_strStringCurrent, LLStringUtil::null); + m_fDirty = true; + } + refresh(); +} + +// Checked: 2011-11-08 (RLVa-1.5.0) +void RlvFloaterStrings::checkDirty(bool fRefresh) +{ + LLTextEditor* pStringValue = findChild<LLTextEditor>("string_value"); + if (!pStringValue->isPristine()) + { + RlvStrings::setCustomString(m_strStringCurrent, pStringValue->getText()); + m_fDirty = true; + } + + if (fRefresh) + { + refresh(); + } +} + +// Checked: 2011-11-08 (RLVa-1.5.0) +void RlvFloaterStrings::refresh() +{ + m_strStringCurrent = (-1 != m_pStringList->getCurrentIndex()) ? m_pStringList->getSelectedValue().asString() : LLStringUtil::null; + + LLTextEditor* pStringDescr = findChild<LLTextEditor>("string_descr"); + pStringDescr->clear(); + LLTextEditor* pStringValue = findChild<LLTextEditor>("string_value"); + pStringValue->setEnabled(!m_strStringCurrent.empty()); + pStringValue->clear(); + if (!m_strStringCurrent.empty()) + { + if (m_sdStringsInfo[m_strStringCurrent].has("description")) + pStringDescr->setText(m_sdStringsInfo[m_strStringCurrent]["description"].asString()); + pStringValue->setText(RlvStrings::getString(m_strStringCurrent)); + pStringValue->makePristine(); + } + + findChild<LLUICtrl>("default_btn")->setEnabled(!m_strStringCurrent.empty()); +} + +// ============================================================================ diff --git a/indra/newview/rlvfloaters.h b/indra/newview/rlvfloaters.h new file mode 100644 index 0000000000000000000000000000000000000000..11a029be50ba477d92abf3c52356b499a5c998ea --- /dev/null +++ b/indra/newview/rlvfloaters.h @@ -0,0 +1,123 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#ifndef RLV_FLOATERS_H +#define RLV_FLOATERS_H + +#include "llfloater.h" + +#include "rlvdefines.h" +#include "rlvcommon.h" + +// ============================================================================ +// RlvFloaterLocks class declaration +// + +class RlvFloaterBehaviours : public LLFloater +{ + friend class LLFloaterReg; +private: + RlvFloaterBehaviours(const LLSD& sdKey) : LLFloater(sdKey) {} + + /* + * LLFloater overrides + */ +public: + /*virtual*/ void onOpen(const LLSD& sdKey); + /*virtual*/ void onClose(bool fQuitting); + /*virtual*/ BOOL postBuild(); + + /* + * Member functions + */ +protected: + void onAvatarNameLookup(const LLUUID& idAgent, const LLAvatarName& avName); + void onBtnCopyToClipboard(); + void onCommand(const RlvCommand& rlvCmd, ERlvCmdRet eRet); + void refreshAll(); + + /* + * Member variables + */ +protected: + boost::signals2::connection m_ConnRlvCommand; + uuid_vec_t m_PendingLookup; +}; + +// ============================================================================ +// RlvFloaterLocks class declaration +// + +class RlvFloaterLocks : public LLFloater +{ + friend class LLFloaterReg; +private: + RlvFloaterLocks(const LLSD& sdKey) : LLFloater(sdKey) {} + + /* + * LLFloater overrides + */ +public: + /*virtual*/ void onOpen(const LLSD& sdKey); + /*virtual*/ void onClose(bool fQuitting); + /*virtual*/ BOOL postBuild(); + + /* + * Member functions + */ +protected: + void onRlvCommand(const RlvCommand& rlvCmd, ERlvCmdRet eRet); + void refreshAll(); + + /* + * Member variables + */ +protected: + boost::signals2::connection m_ConnRlvCommand; +}; + +// ============================================================================ +// RlvFloaterStrings class declaration +// + +class RlvFloaterStrings : public LLFloater +{ + friend class LLFloaterReg; +private: + RlvFloaterStrings(const LLSD& sdKey); + + // LLFloater overrides +public: + /*virtual*/ void onClose(bool fQuitting); + /*virtual*/ BOOL postBuild(); + + // Member functions +protected: + void onStringRevertDefault(); + void checkDirty(bool fRefresh); + void refresh(); + + // Member variables +protected: + bool m_fDirty; + std::string m_strStringCurrent; + LLComboBox* m_pStringList; + LLSD m_sdStringsInfo; +}; + +// ============================================================================ + +#endif // RLV_FLOATERS_H diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp new file mode 100644 index 0000000000000000000000000000000000000000..22dadacf5f24f38e0655cadc121cbfa720520076 --- /dev/null +++ b/indra/newview/rlvhandler.cpp @@ -0,0 +1,2270 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#include "llviewerprecompiledheaders.h" +#include "llagent.h" +#include "llappearancemgr.h" +#include "llappviewer.h" +#include "llgroupactions.h" +#include "llhudtext.h" +#include "llstartup.h" +#include "llviewermessage.h" +#include "llviewerobjectlist.h" +#include "llviewerparcelmgr.h" +#include "llviewerregion.h" + +#include "rlvhandler.h" +#include "rlvinventory.h" +#include "rlvlocks.h" +#include "rlvui.h" +#include "rlvextensions.h" + +#include <boost/algorithm/string.hpp> + +// ============================================================================ +// Static variable initialization +// + +BOOL RlvHandler::m_fEnabled = FALSE; + +rlv_handler_t gRlvHandler; + +// ============================================================================ +// Command specific helper functions +// + +// Checked: 2009-08-04 (RLVa-1.0.1d) | Added: RLVa-1.0.1d +static bool rlvParseNotifyOption(const std::string& strOption, S32& nChannel, std::string& strFilter) +{ + boost_tokenizer tokens(strOption, boost::char_separator<char>(";", "", boost::keep_empty_tokens)); + boost_tokenizer::const_iterator itTok = tokens.begin(); + + // Extract and sanity check the first token (required) which is the channel + if ( (itTok == tokens.end()) || (!LLStringUtil::convertToS32(*itTok, nChannel)) || (!RlvUtil::isValidReplyChannel(nChannel)) ) + return false; + + // Second token (optional) is the filter + strFilter.clear(); + if (++itTok != tokens.end()) + { + strFilter = *itTok; + ++itTok; + } + + return (itTok == tokens.end()); +} + +// ============================================================================ +// Constructor/destructor +// + +// Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.0.1d +RlvHandler::RlvHandler() : m_fCanCancelTp(true), m_posSitSource(), m_pGCTimer(NULL) +{ + gAgent.addListener(this, "new group"); + + // Array auto-initialization to 0 is non-standard? (Compiler warning in VC-8.0) + memset(m_Behaviours, 0, sizeof(S16) * RLV_BHVR_COUNT); +} + +// Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.0.1d +RlvHandler::~RlvHandler() +{ + gAgent.removeListener(this); + + //delete m_pGCTimer; // <- deletes itself +} + +// ============================================================================ +// Behaviour related functions +// + +bool RlvHandler::hasBehaviourExcept(ERlvBehaviour eBhvr, const std::string& strOption, const LLUUID& idObj) const +{ + for (rlv_object_map_t::const_iterator itObj = m_Objects.begin(); itObj != m_Objects.end(); ++itObj) + if ( (idObj != itObj->second.getObjectID()) && (itObj->second.hasBehaviour(eBhvr, strOption, false)) ) + return true; + return false; +} + +// Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h +bool RlvHandler::hasBehaviourRoot(const LLUUID& idObjRoot, ERlvBehaviour eBhvr, const std::string& strOption) const +{ + for (rlv_object_map_t::const_iterator itObj = m_Objects.begin(); itObj != m_Objects.end(); ++itObj) + if ( (idObjRoot == itObj->second.getRootID()) && (itObj->second.hasBehaviour(eBhvr, strOption, false)) ) + return true; + return false; +} + +// ============================================================================ +// Behaviour exception handling +// + +// Checked: 2009-10-04 (RLVa-1.0.4a) | Modified: RLVa-1.0.4a +void RlvHandler::addException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption) +{ + m_Exceptions.insert(std::pair<ERlvBehaviour, RlvException>(eBhvr, RlvException(idObj, eBhvr, varOption))); +} + +// Checked: 2009-10-04 (RLVa-1.0.4c) | Modified: RLVa-1.0.4c +bool RlvHandler::isException(ERlvBehaviour eBhvr, const RlvExceptionOption& varOption, ERlvExceptionCheck typeCheck) const +{ + // We need to "strict check" exceptions only if: the restriction is actually in place *and* (isPermissive(eBhvr) == FALSE) + if (RLV_CHECK_DEFAULT == typeCheck) + typeCheck = ( (hasBehaviour(eBhvr)) && (!isPermissive(eBhvr)) ) ? RLV_CHECK_STRICT : RLV_CHECK_PERMISSIVE; + + uuid_vec_t objList; + if (RLV_CHECK_STRICT == typeCheck) + { + // If we're "strict checking" then we need the UUID of every object that currently has 'eBhvr' restricted + for (rlv_object_map_t::const_iterator itObj = m_Objects.begin(); itObj != m_Objects.end(); ++itObj) + if (itObj->second.hasBehaviour(eBhvr, !hasBehaviour(RLV_BHVR_PERMISSIVE))) + objList.push_back(itObj->first); + } + + for (rlv_exception_map_t::const_iterator itException = m_Exceptions.lower_bound(eBhvr), + endException = m_Exceptions.upper_bound(eBhvr); itException != endException; ++itException) + { + if (itException->second.varOption == varOption) + { + // For permissive checks we just return on the very first match + if (RLV_CHECK_PERMISSIVE == typeCheck) + return true; + + // For strict checks we don't return until the list is empty (every object with 'eBhvr' restricted also contains the exception) + uuid_vec_t::iterator itList = std::find(objList.begin(), objList.end(), itException->second.idObject); + if (itList != objList.end()) + objList.erase(itList); + if (objList.empty()) + return true; + } + } + return false; +} + +// Checked: 2009-10-04 (RLVa-1.0.4a) | Modified: RLVa-1.0.4a +bool RlvHandler::isPermissive(ERlvBehaviour eBhvr) const +{ + return (RlvCommand::hasStrictVariant(eBhvr)) + ? !((hasBehaviour(RLV_BHVR_PERMISSIVE)) || (isException(RLV_BHVR_PERMISSIVE, eBhvr, RLV_CHECK_PERMISSIVE))) + : true; +} + +// Checked: 2009-10-04 (RLVa-1.0.4a) | Modified: RLVa-1.0.4a +void RlvHandler::removeException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption) +{ + for (rlv_exception_map_t::iterator itException = m_Exceptions.lower_bound(eBhvr), + endException = m_Exceptions.upper_bound(eBhvr); itException != endException; ++itException) + { + if ( (itException->second.idObject == idObj) && (itException->second.varOption == varOption) ) + { + m_Exceptions.erase(itException); + break; + } + } +} + +// ============================================================================ +// Command processing functions +// + +// Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.1.0f +void RlvHandler::addCommandHandler(RlvCommandHandler* pCmdHandler) +{ + if ( (pCmdHandler) && (std::find(m_CommandHandlers.begin(), m_CommandHandlers.end(), pCmdHandler) == m_CommandHandlers.end()) ) + m_CommandHandlers.push_back(pCmdHandler); +} + +// Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.1.0f +void RlvHandler::removeCommandHandler(RlvCommandHandler* pCmdHandler) +{ + if (pCmdHandler) + m_CommandHandlers.remove(pCmdHandler); +} + +// Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.1.0a +void RlvHandler::clearCommandHandlers() +{ + std::list<RlvCommandHandler*>::const_iterator itHandler = m_CommandHandlers.begin(); + while (itHandler != m_CommandHandlers.end()) + { + delete *itHandler; + ++itHandler; + } + m_CommandHandlers.clear(); +} + +// Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.1.0f +bool RlvHandler::notifyCommandHandlers(rlvCommandHandler f, const RlvCommand& rlvCmd, ERlvCmdRet& eRet, bool fNotifyAll) const +{ + std::list<RlvCommandHandler*>::const_iterator itHandler = m_CommandHandlers.begin(); bool fContinue = true; eRet = RLV_RET_UNKNOWN; + while ( (itHandler != m_CommandHandlers.end()) && ((fContinue) || (fNotifyAll)) ) + { + ERlvCmdRet eCmdRet = RLV_RET_UNKNOWN; + if ((fContinue = !((*itHandler)->*f)(rlvCmd, eCmdRet)) == false) + eRet = eCmdRet; + ++itHandler; + } + RLV_ASSERT( (fContinue) || (eRet != RLV_RET_UNKNOWN) ); + return !fContinue; +} + +// Checked: 2009-11-25 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f +ERlvCmdRet RlvHandler::processCommand(const RlvCommand& rlvCmd, bool fFromObj) +{ + #ifdef RLV_DEBUG + RLV_INFOS << "[" << rlvCmd.getObjectID() << "]: " << rlvCmd.asString() << RLV_ENDL; + #endif // RLV_DEBUG + + if (!rlvCmd.isValid()) + { + #ifdef RLV_DEBUG + RLV_INFOS << "\t-> invalid syntax" << RLV_ENDL; + #endif // RLV_DEBUG + return RLV_RET_FAILED_SYNTAX; + } + + // Using a stack for executing commands solves a few problems: + // - if we passed RlvObject::m_idObj for idObj somewhere and process a @clear then idObj points to invalid/cleared memory at the end + // - if command X triggers command Y along the way then getCurrentCommand()/getCurrentObject() still return Y even when finished + m_CurCommandStack.push(&rlvCmd); m_CurObjectStack.push(rlvCmd.getObjectID()); + const LLUUID& idCurObj = m_CurObjectStack.top(); + + ERlvCmdRet eRet = RLV_RET_UNKNOWN; + switch (rlvCmd.getParamType()) + { + case RLV_TYPE_ADD: // Checked: 2009-11-26 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f + { + if ( (m_Behaviours[rlvCmd.getBehaviourType()]) && + ( (RLV_BHVR_SETDEBUG == rlvCmd.getBehaviourType()) || (RLV_BHVR_SETENV == rlvCmd.getBehaviourType()) ) ) + { + // Some restrictions can only be held by one single object to avoid deadlocks + #ifdef RLV_DEBUG + RLV_INFOS << "\t- " << rlvCmd.getBehaviour() << " is already set by another object => discarding" << RLV_ENDL; + #endif // RLV_DEBUG + eRet = RLV_RET_FAILED_LOCK; + break; + } + + rlv_object_map_t::iterator itObj = m_Objects.find(idCurObj); bool fAdded = false; + if (itObj != m_Objects.end()) + { + RlvObject& rlvObj = itObj->second; + fAdded = rlvObj.addCommand(rlvCmd); + } + else + { + RlvObject rlvObj(idCurObj); + fAdded = rlvObj.addCommand(rlvCmd); + m_Objects.insert(std::pair<LLUUID, RlvObject>(idCurObj, rlvObj)); + } + + #ifdef RLV_DEBUG + RLV_INFOS << "\t- " << ( (fAdded) ? "adding behaviour" : "skipping duplicate" ) << RLV_ENDL; + #endif // RLV_DEBUG + + if (fAdded) { // If FALSE then this was a duplicate, there's no need to handle those + if (!m_pGCTimer) + m_pGCTimer = new RlvGCTimer(); + eRet = processAddRemCommand(rlvCmd); + m_Objects.find(idCurObj)->second.setCommandRet(rlvCmd, eRet); // HACK-RLVa: find a better way of doing this +// notifyBehaviourObservers(rlvCmd, !fFromObj); + } + else + { + eRet = RLV_RET_SUCCESS_DUPLICATE; + } + } + break; + case RLV_TYPE_REMOVE: // Checked: 2009-11-26 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f + { + rlv_object_map_t::iterator itObj = m_Objects.find(idCurObj); bool fRemoved = false; + if (itObj != m_Objects.end()) + fRemoved = itObj->second.removeCommand(rlvCmd); + + #ifdef RLV_DEBUG + RLV_INFOS << "\t- " << ( (fRemoved) ? "removing behaviour" + : "skipping remove (unset behaviour or unknown object)") << RLV_ENDL; + #endif // RLV_DEBUG + + if (fRemoved) { // Don't handle non-sensical removes + eRet = processAddRemCommand(rlvCmd); +// notifyBehaviourObservers(rlvCmd, !fFromObj); + + if (0 == itObj->second.m_Commands.size()) + { + #ifdef RLV_DEBUG + RLV_INFOS << "\t- command list empty => removing " << idCurObj << RLV_ENDL; + #endif // RLV_DEBUG + m_Objects.erase(itObj); + } + } + else + { + eRet = RLV_RET_SUCCESS_UNSET; + } + } + break; + case RLV_TYPE_CLEAR: // Checked: 2009-11-25 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f + eRet = processClearCommand(rlvCmd); + break; + case RLV_TYPE_FORCE: // Checked: 2009-11-26 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f + eRet = processForceCommand(rlvCmd); + break; + case RLV_TYPE_REPLY: // Checked: 2009-11-25 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f + eRet = processReplyCommand(rlvCmd); + break; + case RLV_TYPE_UNKNOWN: // Checked: 2009-11-25 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f + default: + eRet = RLV_RET_FAILED_PARAM; + break; + } + RLV_ASSERT(RLV_RET_UNKNOWN != eRet); + + m_OnCommand(rlvCmd, eRet, !fFromObj); + + #ifdef RLV_DEBUG + RLV_INFOS << "\t--> command " << ((eRet & RLV_RET_SUCCESS) ? "succeeded" : "failed") << RLV_ENDL; + #endif // RLV_DEBUG + + m_CurCommandStack.pop(); m_CurObjectStack.pop(); + return eRet; +} + +// Checked: 2009-11-25 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f +ERlvCmdRet RlvHandler::processCommand(const LLUUID& idObj, const std::string& strCommand, bool fFromObj) +{ + if (STATE_STARTED != LLStartUp::getStartupState()) + { + m_Retained.push_back(RlvCommand(idObj, strCommand)); + return RLV_RET_RETAINED; + } + return processCommand(RlvCommand(idObj, strCommand), fFromObj); +} + +// Checked: 2010-02-27 (RLVa-1.2.0a) | Modified: RLVa-1.1.0f +void RlvHandler::processRetainedCommands(ERlvBehaviour eBhvrFilter /*=RLV_BHVR_UNKNOWN*/, ERlvParamType eTypeFilter /*=RLV_TYPE_UNKNOWN*/) +{ + rlv_command_list_t::iterator itCmd = m_Retained.begin(), itCurCmd; + while (itCmd != m_Retained.end()) + { + itCurCmd = itCmd++; // Point the loop iterator ahead + + const RlvCommand& rlvCmd = *itCurCmd; + if ( ((RLV_BHVR_UNKNOWN == eBhvrFilter) || (rlvCmd.getBehaviourType() == eBhvrFilter)) && + ((RLV_TYPE_UNKNOWN == eTypeFilter) || (rlvCmd.getParamType() == eTypeFilter)) ) + { + processCommand(rlvCmd, true); + m_Retained.erase(itCurCmd); + } + } +} + +ERlvCmdRet RlvHandler::processClearCommand(const RlvCommand& rlvCmd) +{ + const std::string& strFilter = rlvCmd.getParam(); std::string strCmdRem; + + rlv_object_map_t::const_iterator itObj = m_Objects.find(rlvCmd.getObjectID()); + if (itObj != m_Objects.end()) // No sense in clearing if we don't have any commands for this object + { + const RlvObject& rlvObj = itObj->second; bool fContinue = true; + for (rlv_command_list_t::const_iterator itCmd = rlvObj.m_Commands.begin(), itCurCmd; + ((fContinue) && (itCmd != rlvObj.m_Commands.end())); ) + { + itCurCmd = itCmd++; // Point itCmd ahead so it won't get invalidated if/when we erase a command + + const RlvCommand& rlvCmdRem = *itCurCmd; strCmdRem = rlvCmdRem.asString(); + if ( (strFilter.empty()) || (std::string::npos != strCmdRem.find(strFilter)) ) + { + fContinue = (rlvObj.m_Commands.size() > 1); // rlvObj will become invalid once we remove the last command + processCommand(rlvCmd.getObjectID(), strCmdRem.append("=y"), false); + } + } + } + + // Let our observers know about clear commands + ERlvCmdRet eRet = RLV_RET_SUCCESS; + notifyCommandHandlers(&RlvCommandHandler::onClearCommand, rlvCmd, eRet, true); + + return RLV_RET_SUCCESS; // Don't fail clear commands even if the object didn't exist since it confuses people +} + +// ============================================================================ +// Externally invoked event handlers +// + +// Checked: 2011-05-22 (RLVa-1.4.1a) | Added: RLVa-1.3.1b +bool RlvHandler::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& sdUserdata) +{ + // If the user managed to change their active group (= newly joined or created group) we need to reactivate the previous one + if ( (hasBehaviour(RLV_BHVR_SETGROUP)) && ("new group" == event->desc()) && (m_idAgentGroup != gAgent.getGroupID()) ) + { + // [Copy/paste from LLGroupActions::activate()] + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_ActivateGroup); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->addUUIDFast(_PREHASH_GroupID, m_idAgentGroup); + gAgent.sendReliableMessage(); + return true; + } + else + { + m_idAgentGroup = gAgent.getGroupID(); + } + return false; +} + +// Checked: 2010-08-29 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c +void RlvHandler::onSitOrStand(bool fSitting) +{ + #ifdef RLV_EXTENSION_STARTLOCATION + if (rlv_handler_t::isEnabled()) + { + RlvSettings::updateLoginLastLocation(); + } + #endif // RLV_EXTENSION_STARTLOCATION + + if ( (hasBehaviour(RLV_BHVR_STANDTP)) && (!fSitting) && (!m_posSitSource.isExactlyZero()) ) + { + // NOTE: we need to do this due to the way @standtp triggers a forced teleport: + // - when standing we're called from LLVOAvatar::sitDown() which is called from LLVOAvatar::getOffObject() + // -> at the time sitDown() is called the avatar's parent is still the linkset it was sitting on so "isRoot()" on the avatar will + // return FALSE and we will crash in LLVOAvatar::getRenderPosition() when trying to teleport + // -> postponing the teleport until the next idle tick will ensure that everything has all been properly cleaned up + doOnIdleOneTime(boost::bind(RlvUtil::forceTp, m_posSitSource)); + m_posSitSource.setZero(); + } +} + +// Checked: 2010-03-11 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvHandler::onAttach(const LLViewerObject* pAttachObj, const LLViewerJointAttachment* pAttachPt) +{ + // Assertion - pAttachObj is never NULL always specifies the root + RLV_ASSERT( (pAttachObj) && (pAttachObj == pAttachObj->getRootEdit()) ); + // Sanity check - we need to be called *after* LLViewerJointAttachment::addObject() + RLV_ASSERT( (pAttachPt) && (pAttachPt->isObjectAttached(pAttachObj)) ); + if ( (!pAttachObj) || (!pAttachPt) || (!pAttachPt->isObjectAttached(pAttachObj)) ) + return; + + // Check if we already have an RlvObject instance for this object or one of its child prims + for (rlv_object_map_t::iterator itObj = m_Objects.begin(); itObj != m_Objects.end(); ++itObj) + { + // Only if we haven't been able to find this object (= attachment that rezzed in) or if it's a rezzed prim attached from in-world + if ( (!itObj->second.m_fLookup) || (!itObj->second.m_idxAttachPt) ) + { + const LLViewerObject* pObj = gObjectList.findObject(itObj->first); + if ( (pObj) && (pObj->getRootEdit()->getID() == pAttachObj->getID()) ) + { + // Reset any lookup information we might have for this object + itObj->second.m_fLookup = true; + itObj->second.m_idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(pAttachObj); + itObj->second.m_idRoot = pAttachObj->getID(); + + // We need to check this object for an active "@detach=n" and actually lock it down now that it's been attached somewhere + if (itObj->second.hasBehaviour(RLV_BHVR_DETACH, false)) + gRlvAttachmentLocks.addAttachmentLock(pAttachObj->getID(), itObj->second.getObjectID()); + } + } + } + + // Fetch the inventory item if it isn't already (we need it in case of a reattach-on-detach) and rename it if appropriate + if ( (STATE_STARTED == LLStartUp::getStartupState()) && (gInventory.isInventoryUsable()) ) + { + RlvRenameOnWearObserver* pFetcher = new RlvRenameOnWearObserver(pAttachObj->getAttachmentItemID()); + pFetcher->startFetch(); + if (pFetcher->isFinished()) + pFetcher->done(); + else + gInventory.addObserver(pFetcher); + } +} + +// Checked: 2010-03-11 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvHandler::onDetach(const LLViewerObject* pAttachObj, const LLViewerJointAttachment* pAttachPt) +{ + // Assertion - pAttachObj is never NULL always specifies the root + RLV_ASSERT( (pAttachObj) && (pAttachObj == pAttachObj->getRootEdit()) ); + // Sanity check - we need to be called *before* LLViewerJointAttachment::removeObject() + RLV_ASSERT( (pAttachPt) && (pAttachPt->isObjectAttached(pAttachObj)) ); + if ( (!pAttachObj) || (!pAttachPt) || (!pAttachPt->isObjectAttached(pAttachObj)) ) + return; + + // If the attachment is no longer attached then then the user "Drop"'ed this attachment somehow + if (!pAttachObj->isAttachment()) + { + // Check if we have any RlvObject instances for this object (or any of its child prims) + for (rlv_object_map_t::iterator itObj = m_Objects.begin(); itObj != m_Objects.end(); ++itObj) + { + if ( (itObj->second.m_fLookup) && (itObj->second.m_idRoot == pAttachObj->getID()) ) + { + // Clear the attachment point lookup since it's now an in-world prim + itObj->second.m_idxAttachPt = false; + + // If this object has an active "@detach=n" then we need to release the attachment lock since it's no longer attached + if (itObj->second.hasBehaviour(RLV_BHVR_DETACH, false)) + gRlvAttachmentLocks.removeAttachmentLock(pAttachObj->getID(), itObj->second.getObjectID()); + } + } + } + else + { + // If it's still attached then we need to clean up any restrictions this object (or one of its child prims) may still have set + rlv_object_map_t::iterator itObj = m_Objects.begin(), itCurObj; + while (itObj != m_Objects.end()) + { + itCurObj = itObj++; // @clear will invalidate our iterator so point it ahead now +#ifdef RLV_DEBUG + bool itObj = true; + RLV_ASSERT(itObj); // Little hack to push itObj out of scope and prevent it from being accidentally used below +#endif // RLV_DEBUG + + // NOTE: ObjectKill seems to happen in reverse (child prims are killed before the root is) so we can't use gObjectList here + if (itCurObj->second.m_idRoot == pAttachObj->getID()) + { + RLV_INFOS << "Clearing " << itCurObj->first.asString() << ":" << RLV_ENDL; + processCommand(itCurObj->second.getObjectID(), "clear", true); + RLV_INFOS << "\t-> done" << RLV_ENDL; + } + } + } +} + +// Checked: 2010-03-13 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +bool RlvHandler::onGC() +{ + rlv_object_map_t::iterator itObj = m_Objects.begin(), itCurObj; + while (itObj != m_Objects.end()) + { + itCurObj = itObj++; // @clear will invalidate our iterator so point it ahead now +#ifdef RLV_DEBUG + bool itObj = true; + RLV_ASSERT(itObj); +#endif // RLV_DEBUG + + // Temporary sanity check + RLV_ASSERT(itCurObj->first == itCurObj->second.getObjectID()); + + const LLViewerObject* pObj = gObjectList.findObject(itCurObj->second.getObjectID()); + if (!pObj) + { + // If the RlvObject once existed in gObjectList and now doesn't then expire it right away + // If the RlvObject never existed in gObjectList and still doesn't then increase its "lookup misses" counter + // but if that reaches 20 (we run every 30 seconds so that's about 10 minutes) then we'll expire it too + if ( (itCurObj->second.m_fLookup) || (++itCurObj->second.m_nLookupMisses > 20) ) + { + RLV_INFOS << "Garbage collecting " << itCurObj->first.asString() << ":" << RLV_ENDL; + processCommand(itCurObj->first, "clear", true); + RLV_INFOS << "\t-> done" << RLV_ENDL; + } + } + else + { + // Assertion: if the GC encounters an RlvObject instance that hasn't existed in gObjectList up until now then + // it has to be a rezzed prim (if it was an attachment then RlvHandler::onAttach() should have caught it) + RLV_ASSERT( (itCurObj->second.m_fLookup) || (!pObj->isAttachment()) ); + if (!itCurObj->second.m_fLookup) + { + RLV_INFOS << "Resolved missing object " << itCurObj->first.asString() << RLV_ENDL; + itCurObj->second.m_fLookup = true; + itCurObj->second.m_idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(pObj); + itCurObj->second.m_idRoot = pObj->getRootEdit()->getID(); + + // NOTE: the following code should NEVER run (see assertion above), but just to be double-triple safety sure + // -> if it does run it likely means that there's a @detach=n in a *child* prim that we couldn't look up in onAttach() + // -> since RLV doesn't currently support @detach=n from child prims it's actually not such a big deal right now but still + if ( (pObj->isAttachment()) && (itCurObj->second.hasBehaviour(RLV_BHVR_DETACH, false)) ) + gRlvAttachmentLocks.addAttachmentLock(pObj->getID(), itCurObj->second.getObjectID()); + } + } + } + + RLV_ASSERT(gRlvAttachmentLocks.verifyAttachmentLocks()); // Verify that we haven't leaked any attachment locks somehow + + return (0 != m_Objects.size()); // GC will kill itself if it has nothing to do +} + +// Checked: 2009-11-26 (RLVa-1.1.0f) | Added: RLVa-1.1.0f +void RlvHandler::onIdleStartup(void* pParam) +{ + LLTimer* pTimer = (LLTimer*)pParam; + if (LLStartUp::getStartupState() < STATE_STARTED) + { + // We don't want to run this *too* often + if ( (LLStartUp::getStartupState() >= STATE_MISC) && (pTimer->getElapsedTimeF32() >= 2.0) ) + { + gRlvHandler.processRetainedCommands(RLV_BHVR_VERSION, RLV_TYPE_REPLY); + gRlvHandler.processRetainedCommands(RLV_BHVR_VERSIONNEW, RLV_TYPE_REPLY); + gRlvHandler.processRetainedCommands(RLV_BHVR_VERSIONNUM, RLV_TYPE_REPLY); + pTimer->reset(); + } + } + else + { + // Clean-up + gIdleCallbacks.deleteFunction(onIdleStartup, pParam); + delete pTimer; + } +} + +// Checked: 2010-03-09 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +void RlvHandler::onLoginComplete() +{ + RlvInventory::instance().fetchWornItems(); + RlvInventory::instance().fetchSharedInventory(); + + #ifdef RLV_EXTENSION_STARTLOCATION + RlvSettings::updateLoginLastLocation(); + #endif // RLV_EXTENSION_STARTLOCATION + + LLViewerParcelMgr::getInstance()->setTeleportFailedCallback(boost::bind(&RlvHandler::onTeleportFailed, this)); + LLViewerParcelMgr::getInstance()->setTeleportFinishedCallback(boost::bind(&RlvHandler::onTeleportFinished, this, _1)); + + processRetainedCommands(); +} + +// Checked: 2010-04-05 (RLVa-1.2.0d) | Added: RLVa-1.2.0d +void RlvHandler::onTeleportFailed() +{ + setCanCancelTp(true); +} + +// Checked: 2010-04-05 (RLVa-1.2.0d) | Added: RLVa-1.2.0d +void RlvHandler::onTeleportFinished(const LLVector3d& posArrival) +{ + setCanCancelTp(true); +} + +// ============================================================================ +// String/chat censoring functions +// + +// Checked: 2010-03-06 (RLVa-1.2.0c) | Added: RLVa-1.1.0j +bool RlvHandler::canSit(LLViewerObject* pObj, const LLVector3& posOffset /*= LLVector3::zero*/) const +{ + // The user can sit on the specified object if: + // - not prevented from sitting + // - not prevented from standing up or not currently sitting + // - not standtp restricted or not currently sitting (if the user is sitting and tried to sit elsewhere the tp would just kick in) + // - not a regular sit (i.e. due to @sit:<uuid>=force) + // - not @sittp=n or @fartouch=n restricted or if they clicked on a point within 1.5m of the avie's current position + return + ( (pObj) && (LL_PCODE_VOLUME == pObj->getPCode()) ) && + (!hasBehaviour(RLV_BHVR_SIT)) && + ( ((!hasBehaviour(RLV_BHVR_UNSIT)) && (!hasBehaviour(RLV_BHVR_STANDTP))) || + ((isAgentAvatarValid()) && (!gAgentAvatarp->isSitting())) ) && + ( ( (NULL != getCurrentCommand()) && (RLV_BHVR_SIT == getCurrentCommand()->getBehaviourType()) ) || + ( (!hasBehaviour(RLV_BHVR_SITTP)) && (!hasBehaviour(RLV_BHVR_FARTOUCH)) ) || + (dist_vec_squared(gAgent.getPositionGlobal(), pObj->getPositionGlobal() + LLVector3d(posOffset)) < 1.5f * 1.5f) ); +} + +// Checked: 2010-03-07 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +bool RlvHandler::canStand() const +{ + // NOTE: return FALSE only if we're @unsit=n restricted and the avie is currently sitting on something and TRUE for everything else + return (!hasBehaviour(RLV_BHVR_UNSIT)) || ((isAgentAvatarValid()) && (!gAgentAvatarp->isSitting())); +} + +// Checked: 2010-04-11 (RLVa-1.3.0h) | Modified: RLVa-1.3.0h +bool RlvHandler::canTouch(const LLViewerObject* pObj, const LLVector3& posOffset /*=LLVector3::zero*/) const +{ + const LLUUID& idRoot = (pObj) ? pObj->getRootEdit()->getID() : LLUUID::null; + bool fCanTouch = (idRoot.notNull()) && ((pObj->isHUDAttachment()) || (!hasBehaviour(RLV_BHVR_TOUCHALL))) && + ((!hasBehaviour(RLV_BHVR_TOUCHTHIS)) || (!isException(RLV_BHVR_TOUCHTHIS, idRoot, RLV_CHECK_PERMISSIVE))); + + if (fCanTouch) + { + if ( (!pObj->isAttachment()) || (!pObj->permYouOwner()) ) + { + // Rezzed prim or attachment worn by another avie + fCanTouch = + ( (!hasBehaviour(RLV_BHVR_TOUCHWORLD)) || (isException(RLV_BHVR_TOUCHWORLD, idRoot, RLV_CHECK_PERMISSIVE)) ) && + ( (!pObj->isAttachment()) || (!hasBehaviour(RLV_BHVR_TOUCHATTACHOTHER)) ) && + ( (!hasBehaviour(RLV_BHVR_FARTOUCH)) || + (dist_vec_squared(gAgent.getPositionGlobal(), pObj->getPositionGlobal() + LLVector3d(posOffset)) <= 1.5f * 1.5f) ); + } + else if (!pObj->isHUDAttachment()) + { + // Regular attachment worn by this avie + fCanTouch = + ((!hasBehaviour(RLV_BHVR_TOUCHATTACH)) || (isException(RLV_BHVR_TOUCHATTACH, idRoot, RLV_CHECK_PERMISSIVE))) && + ((!hasBehaviour(RLV_BHVR_TOUCHATTACHSELF)) || (isException(RLV_BHVR_TOUCHATTACH, idRoot, RLV_CHECK_PERMISSIVE))); + } +#ifdef RLV_EXTENSION_CMD_TOUCHXXX + else + { + // HUD attachment + fCanTouch = (!hasBehaviour(RLV_BHVR_TOUCHHUD)) || (isException(RLV_BHVR_TOUCHHUD, idRoot, RLV_CHECK_PERMISSIVE)); + } +#endif // RLV_EXTENSION_CMD_TOUCHXXX + } + if ( (!fCanTouch) && (hasBehaviour(RLV_BHVR_TOUCHME)) ) + fCanTouch = hasBehaviourRoot(idRoot, RLV_BHVR_TOUCHME); + return fCanTouch; +} + +size_t utf8str_strlen(const std::string& utf8) +{ + const char* pUTF8 = utf8.c_str(); size_t length = 0; + for (int idx = 0, cnt = utf8.length(); idx < cnt ;idx++) + { + // We're looking for characters that don't start with 10 as their high bits + if ((pUTF8[idx] & 0xC0) != 0x80) + length++; + } + return length; +} + +std::string utf8str_chtruncate(const std::string& utf8, size_t length) +{ + if (0 == length) + return std::string(); + if (utf8.length() <= length) + return utf8; + + const char* pUTF8 = utf8.c_str(); int idx = 0; + while ( (pUTF8[idx]) && (length > 0) ) + { + // We're looking for characters that don't start with 10 as their high bits + if ((pUTF8[idx] & 0xC0) != 0x80) + length--; + idx++; + } + + return utf8.substr(0, idx); +} + +// Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.0.0f +bool RlvHandler::filterChat(std::string& strUTF8Text, bool fFilterEmote) const +{ + if (strUTF8Text.empty()) + return false; + + bool fFilter = false; + if (RlvUtil::isEmote(strUTF8Text)) // Check if it's an emote + { + if (fFilterEmote) // Emote filtering depends on fFilterEmote + { + if ( (strUTF8Text.find_first_of("\"()*=^_?~") != std::string::npos) || + (strUTF8Text.find(" -") != std::string::npos) || (strUTF8Text.find("- ") != std::string::npos) || + (strUTF8Text.find("''") != std::string::npos) ) + { + fFilter = true; // Emote contains illegal character (or character sequence) + } + else if (!hasBehaviour(RLV_BHVR_EMOTE)) + { + int idx = strUTF8Text.find('.'); // Truncate at 20 characters or at the dot (whichever is shorter) + strUTF8Text = utf8str_chtruncate(strUTF8Text, ( (idx > 0) && (idx < 20) ) ? idx + 1 : 20); + } + } + } + else if (strUTF8Text[0] == '/') // Not an emote, but starts with a '/' + { + fFilter = (utf8str_strlen(strUTF8Text) > 7);// Allow as long if it's 6 characters or less + } + else if ( (!RlvSettings::getCanOOC()) || + (strUTF8Text.length() < 4) || (strUTF8Text.compare(0, 2, "((")) || (strUTF8Text.compare(strUTF8Text.length() - 2, 2, "))")) ) + { + fFilter = true; // Regular chat (not OOC) + } + + if (fFilter) + strUTF8Text = (gSavedSettings.getBOOL("RestrainedLoveShowEllipsis")) ? "..." : ""; + return fFilter; +} + +// Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c +bool RlvHandler::hasException(ERlvBehaviour eBhvr) const +{ + return (m_Exceptions.find(eBhvr) != m_Exceptions.end()); +} + +// Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0a +bool RlvHandler::redirectChatOrEmote(const std::string& strUTF8Text) const +{ + // Sanity check - @redirchat only for chat and @rediremote only for emotes + ERlvBehaviour eBhvr = (!RlvUtil::isEmote(strUTF8Text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE; + if ( (strUTF8Text.empty()) || (!hasBehaviour(eBhvr)) ) + return false; + + if (RLV_BHVR_REDIRCHAT == eBhvr) + { + std::string strText = strUTF8Text; + if (!filterChat(strText, false)) + return false; // @sendchat wouldn't filter it so @redirchat won't redirect it either + } + + for (rlv_exception_map_t::const_iterator itRedir = m_Exceptions.lower_bound(eBhvr), + endRedir = m_Exceptions.upper_bound(eBhvr); itRedir != endRedir; ++itRedir) + { + S32 nChannel = boost::get<S32>(itRedir->second.varOption); + if ( (!hasBehaviour(RLV_BHVR_SENDCHANNEL)) || (isException(RLV_BHVR_SENDCHANNEL, nChannel)) ) + RlvUtil::sendChatReply(nChannel, strUTF8Text); + } + + return true; +} + +// ============================================================================ +// Composite folders +// + +#ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + // Checked: 2009-12-18 (RLVa-1.1.0k) | Modified: RLVa-1.1.0i + bool RlvHandler::getCompositeInfo(const LLInventoryCategory* pFolder, std::string* pstrName) const + { + if (pFolder) + { + // Composite folder naming: ^\.?[Folder] + const std::string& cstrFolder = pFolder->getName(); + std::string::size_type idxStart = cstrFolder.find('['), idxEnd = cstrFolder.find(']', idxStart); + if ( ((0 == idxStart) || (1 == idxStart)) && (idxEnd - idxStart > 1) ) + { + if (pstrName) + pstrName->assign(cstrFolder.substr(idxStart + 1, idxEnd - idxStart - 1)); + return true; + } + } + return false; + } + + // Checked: 2009-12-18 (RLVa-1.1.0k) | Modified: RLVa-1.1.0i + bool RlvHandler::getCompositeInfo(const LLUUID& idItem, std::string* pstrName, LLViewerInventoryCategory** ppFolder) const + { +/* + LLViewerInventoryCategory* pRlvRoot; LLViewerInventoryItem* pItem; + if ( (idItem.notNull()) && ((pRlvRoot = getSharedRoot()) != NULL) && + (gInventory.isObjectDescendentOf(idItem, pRlvRoot->getUUID())) && ((pItem = gInventory.getItem(idItem)) != NULL) ) + { + // We know it's an item in a folder under the shared root (we need its parent if it's a folded folder) + LLViewerInventoryCategory* pFolder = gInventory.getCategory(pItem->getParentUUID()); + if (isFoldedFolder(pFolder, true, false)) // Don't check if the folder is a composite folder + pFolder = gInventory.getCategory(pFolder->getParentUUID()); + + if ( (pFolder) && (getCompositeInfo(pFolder, pstrName)) ) + { + if (ppFolder) + *ppFolder = pFolder; + return true; + } + } +*/ + return false; + } +#endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + +#ifdef RLV_EXPERIMENTAL_COMPOSITE_FOLDING + // Checked: + inline bool RlvHandler::isHiddenCompositeItem(const LLUUID& idItem, const std::string& cstrItemType) const + { + // An item that's part of a composite folder will be hidden from @getoutfit and @getattach if: + // (1) the composite name specifies either a wearable layer or an attachment point + // (2) the specified wearable layer or attachment point is worn and resides in the folder + // (3) cstrItemType isn't the specified wearable layer or attach point + // + // Example: #RLV/Separates/Shoes/ChiChi Pumps/.[shoes] with items: "Shoe Base", "Shoe (left foot)" and "Shoe (right foot)" + // -> as long as "Shoe Base" is worn, @getattach should not reflect "left foot", nor "right foot" + std::string strComposite; LLViewerInventoryCategory* pFolder; + LLWearableType::EType type; S32 idxAttachPt; + if ( (getCompositeInfo(idItem, &strComposite, &pFolder)) && (cstrItemType != strComposite) ) + { + LLUUID idCompositeItem; + if ((type = LLWearable::typeNameToType(strComposite)) != WT_INVALID) + { + idCompositeItem = gAgent.getWearableItem(type); + } + else if ((idxAttachPt = getAttachPointIndex(strComposite, true)) != 0) + { + LLVOAvatar* pAvatar; LLViewerJointAttachment* pAttachmentPt; + if ( ((pAvatar = gAgent.getAvatarObject()) != NULL) && + ((pAttachmentPt = get_if_there(pAvatar->mAttachmentPoints, idxAttachPt, (LLViewerJointAttachment*)NULL)) != NULL) ) + { + idCompositeItem = pAttachmentPt->getItemID(); + } + } + + if ( (idCompositeItem.notNull()) && (gInventory.isObjectDescendentOf(idCompositeItem, pFolder->getUUID())) ) + return true; + } + return false; + } +#endif // RLV_EXPERIMENTAL_COMPOSITEFOLDING + +#ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + // Checked: 2009-12-18 (RLVa-1.1.0k) | Modified: RLVa-1.1.0i + bool RlvHandler::canTakeOffComposite(const LLInventoryCategory* pFolder) const + { + // Sanity check - if there's no folder or no avatar then there is nothing to take off + LLVOAvatarSelf* pAvatar = gAgent.getAvatarObject(); + if ( (!pFolder) || (!pAvatar) ) + return false; + // Sanity check - if nothing is locked then we can definitely take it off + if ( (!gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_REMOVE)) || + (!gRlvWearableLocks.hasLockedWearableType(RLV_LOCK_REMOVE)) ) + { + return true; + } + +/* + LLInventoryModel::cat_array_t folders; + LLInventoryModel::item_array_t items; + RlvWearableItemCollector functor(pFolder->getUUID(), true, false); + gInventory.collectDescendentsIf(pFolder->getUUID(), folders, items, FALSE, functor); + + for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++) + { + const LLViewerInventoryItem* pItem = items.get(idxItem); + switch (pItem->getType()) + { + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_CLOTHING: + { + LLWearable* pWearable = gAgent.getWearableFromWearableItem(pItem->getUUID()); + if ( (pWearable) && (!isRemovable(pWearable->getType())) ) + return false; // If one wearable in the folder is non-removeable then the entire folder should be + } + break; + case LLAssetType::AT_OBJECT: + { + LLViewerObject* pObj = pAvatar->getWornAttachment(pItem->getUUID()); + if ( (pObj != NULL) && (isLockedAttachment(pObj, RLV_LOCK_REMOVE)) ) + return false; // If one attachment in the folder is non-detachable then the entire folder should be + } + break; + default: + break; + } + } +*/ + return true; + } + + // Checked: 2009-12-18 (RLVa-1.1.0k) | Modified: RLVa-1.1.0i + bool RlvHandler::canWearComposite(const LLInventoryCategory* pFolder) const + { + // Sanity check - if there's no folder or no avatar then there is nothing to wear + LLVOAvatar* pAvatar = gAgent.getAvatarObject(); + if ( (!pFolder) || (!pAvatar) ) + return false; + // Sanity check - if nothing is locked then we can definitely wear it + if ( (!gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY)) || (!gRlvWearableLocks.hacLockedWearableType(RLV_LOCK_ANY)) ) + return true; + +/* + LLInventoryModel::cat_array_t folders; + LLInventoryModel::item_array_t items; + RlvWearableItemCollector functor(pFolder->getUUID(), true, false); + gInventory.collectDescendentsIf(pFolder->getUUID(), folders, items, FALSE, functor); + + for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++) + { + LLViewerInventoryItem* pItem = items.get(idxItem); + + if (RlvForceWear::isWearingItem(pItem)) + continue; // Don't examine any items we're already wearing + + // A wearable layer or attachment point: + // - can't be "add locked" + // - can't be worn and "remove locked" + // - can't be worn and have its item belong to a *different* composite folder that we can't take off + switch (pItem->getType()) + { + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_CLOTHING: + { + // NOTE: without its asset we don't know what type the wearable is so we need to look at the item's flags instead + LLWearableType::EType wtType = (LLWearableType::EType)(pItem->getFlags() & LLInventoryItem::II_FLAGS_WEARABLES_MASK); + LLViewerInventoryCategory* pFolder; + if ( (!isWearable(wtType)) || + ( (gAgent.getWearable(wtType)) && (!isRemovable(wtType)) ) || + ( (gRlvHandler.getCompositeInfo(gAgent.getWearableItem(wtType), NULL, &pFolder)) && + (pFolder->getUUID() != pItem->getParentUUID()) && (!gRlvHandler.canTakeOffComposite(pFolder)) ) ) + { + return false; + } + } + break; + case LLAssetType::AT_OBJECT: + { + // If we made it here then *something* is add/remove locked so we absolutely need to know its attachment point + LLViewerJointAttachment* pAttachPt = getAttachPoint(pItem, true); + LLViewerInventoryCategory* pFolder; + if ( (!pAttachPt) || (isLockedAttachment(pAttachPt, RLV_LOCK_ADD)) || + ( (pAttachPt->getObject()) && (isLockedAttachment(pAttachPt, RLV_LOCK_REMOVE)) ) || + ( (gRlvHandler.getCompositeInfo(pAttachPt->getItemID(), NULL, &pFolder)) && + (pFolder->getUUID() != pItem->getParentUUID()) && (!gRlvHandler.canTakeOffComposite(pFolder)) ) ) + { + return false; + } + } + break; + default: + break; + } + } +*/ + return true; + } +#endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + +// ============================================================================ +// Initialization helper functions +// + +// Checked: 2010-02-27 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +BOOL RlvHandler::setEnabled(BOOL fEnable) +{ + // TODO-RLVa: [RLVa-1.2.1] Allow toggling at runtime if we haven't seen any llOwnerSay("@...."); + if (m_fEnabled == fEnable) + return fEnable; + + if (fEnable) + { + RLV_INFOS << "Enabling Restrained Love API support - " << RlvStrings::getVersion() << RLV_ENDL; + m_fEnabled = TRUE; + + // Initialize the command lookup table + RlvCommand::initLookupTable(); + + // Initialize static classes + RlvSettings::initClass(); + RlvStrings::initClass(); + + gRlvHandler.addCommandHandler(new RlvExtGetSet()); + + // Make sure we get notified when login is successful + if (LLStartUp::getStartupState() < STATE_STARTED) + LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&RlvHandler::onLoginComplete, &gRlvHandler)); + else + gRlvHandler.onLoginComplete(); + + // Set up RlvUIEnabler + RlvUIEnabler::getInstance(); + + // Reset to show assertions if the viewer version changed + if (gSavedSettings.getString("LastRunVersion") != gLastRunVersion) + gSavedSettings.setBOOL("RLVaShowAssertionFailures", TRUE); + } + + return m_fEnabled; +} + +BOOL RlvHandler::canDisable() +{ + return FALSE; +} + +void RlvHandler::clearState() +{ +/* + // TODO-RLVa: should restore all RLV controlled debug variables to their defaults + + // Issue @clear on behalf of every object that has a currently active RLV restriction (even if it's just an exception) + LLUUID idObj; LLViewerObject* pObj; bool fDetachable; + while (m_Objects.size()) + { + idObj = m_Objects.begin()->first; // Need a copy since after @clear the data it points to will no longer exist + fDetachable = ((pObj = gObjectList.findObject(idObj)) != NULL) ? isLockedAttachment(pObj, RLV_LOCK_REMOVE) : true; + + processCommand(idObj, "clear", false); + if (!fDetachable) + processCommand(idObj, "detachme=force", false); + } + + // Sanity check - these should all be empty after we issue @clear on the last object + if ( (!m_Objects.empty()) || !(m_Exceptions.empty()) || (!m_AttachAdd.empty()) || (!m_AttachRem.empty()) ) + { + RLV_ERRS << "Object, exception or attachment map not empty after clearing state!" << LL_ENDL; + m_Objects.clear(); + m_Exceptions.clear(); + m_AttachAdd.clear(); + m_AttachRem.clear(); + } + + // These all need manual clearing + memset(m_LayersAdd, 0, sizeof(S16) * WT_COUNT); + memset(m_LayersRem, 0, sizeof(S16) * WT_COUNT); + memset(m_Behaviours, 0, sizeof(S16) * RLV_BHVR_COUNT); + m_Retained.clear(); + clearCommandHandlers(); // <- calls delete on all registered command handlers + + // Clear dynamically allocated memory + delete m_pGCTimer; + m_pGCTimer = NULL; +*/ +} + +// ============================================================================ +// Command handlers (RLV_TYPE_ADD and RLV_TYPE_REMOVE) +// + +#define VERIFY_OPTION(x) { if (!(x)) { eRet = RLV_RET_FAILED_OPTION; break; } } +#define VERIFY_OPTION_REF(x) { if (!(x)) { eRet = RLV_RET_FAILED_OPTION; break; } fRefCount = true; } + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd) +{ + // NOTE: - at this point the command has already been: + // * added to the RlvObject + // * removed from the RlvObject (which still exists at this point even if this is the last restriction) + // - the object's UUID may or may not exist in gObjectList (see handling of @detach=n|y) + ERlvBehaviour eBhvr = rlvCmd.getBehaviourType(); ERlvParamType eType = rlvCmd.getParamType(); + + ERlvCmdRet eRet = RLV_RET_SUCCESS; bool fRefCount = false; const std::string& strOption = rlvCmd.getOption(); + switch (eBhvr) + { + case RLV_BHVR_DETACH: // @detach[:<option>]=n|y + eRet = onAddRemDetach(rlvCmd, fRefCount); + break; + case RLV_BHVR_ADDATTACH: // @addattach[:<option>]=n|y + case RLV_BHVR_REMATTACH: // @addattach[:<option>]=n|y + eRet = onAddRemAttach(rlvCmd, fRefCount); + break; + case RLV_BHVR_ATTACHTHIS: // @attachthis[:<option>]=n|y + case RLV_BHVR_DETACHTHIS: // @detachthis[:<option>]=n|y + case RLV_BHVR_ATTACHALLTHIS: // @attachtallhis[:<option>]=n|y + case RLV_BHVR_DETACHALLTHIS: // @detachallthis[:<option>]=n|y + eRet = onAddRemFolderLock(rlvCmd, fRefCount); + break; + case RLV_BHVR_ATTACHTHISEXCEPT: // @attachthisexcept[:<option>]=n|y + case RLV_BHVR_DETACHTHISEXCEPT: // @detachthisexcept[:<option>]=n|y + case RLV_BHVR_ATTACHALLTHISEXCEPT: // @attachallthisexcept[:<option>]=n|y + case RLV_BHVR_DETACHALLTHISEXCEPT: // @detachallthisexcept[:<option>]=n|y + eRet = onAddRemFolderLockException(rlvCmd, fRefCount); + break; + case RLV_BHVR_SETENV: // @setenv=n|y - Checked: 2011-09-04 (RLVa-1.4.1a) | Modified: RLVa-1.4.1a + { + if (RlvSettings::getNoSetEnv()) + { + eRet = RLV_RET_FAILED_DISABLED; + break; + } + VERIFY_OPTION_REF(strOption.empty()); + } + break; + case RLV_BHVR_ADDOUTFIT: // @addoutfit[:<layer>]=n|y - Checked: 2010-08-29 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c + case RLV_BHVR_REMOUTFIT: // @remoutfit[:<layer>]=n|y - Checked: 2010-08-29 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c + { + // If there's an option it should specify a wearable type name (reference count on no option *and* a valid option) + RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption()); + VERIFY_OPTION_REF( (rlvCmdOption.isEmpty()) || (rlvCmdOption.isWearableType()) ); + + // We need to flush any queued force-wear commands before changing the restrictions + if (RlvForceWear::instanceExists()) + RlvForceWear::instance().done(); + + ERlvLockMask eLock = (RLV_BHVR_ADDOUTFIT == eBhvr) ? RLV_LOCK_ADD : RLV_LOCK_REMOVE; + for (int idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++) + { + if ( (rlvCmdOption.isEmpty()) || ((LLWearableType::EType)idxType == rlvCmdOption.getWearableType()) ) + { + if (RLV_TYPE_ADD == eType) + gRlvWearableLocks.addWearableTypeLock((LLWearableType::EType)idxType, rlvCmd.getObjectID(), eLock); + else + gRlvWearableLocks.removeWearableTypeLock((LLWearableType::EType)idxType, rlvCmd.getObjectID(), eLock); + } + } + } + break; + case RLV_BHVR_SHAREDWEAR: // @sharedwear=n|y - Checked: 2011-03-28 (RLVa-1.3.0g) | Added: RLVa-1.3.0g + case RLV_BHVR_SHAREDUNWEAR: // @sharedunwear=n|y - Checked: 2011-03-28 (RLVa-1.3.0g) | Added: RLVa-1.3.0g + { + VERIFY_OPTION_REF(strOption.empty()); + + RlvFolderLocks::folderlock_source_t lockSource(RlvFolderLocks::ST_SHAREDPATH, LLStringUtil::null); + RlvFolderLocks::ELockScope eLockScope = RlvFolderLocks::SCOPE_SUBTREE; + ERlvLockMask eLockType = (RLV_BHVR_SHAREDUNWEAR == eBhvr) ? RLV_LOCK_REMOVE : RLV_LOCK_ADD; + + if (RLV_TYPE_ADD == eType) + RlvFolderLocks::instance().addFolderLock(lockSource, RlvFolderLocks::PERM_DENY, eLockScope, rlvCmd.getObjectID(), eLockType); + else + RlvFolderLocks::instance().removeFolderLock(lockSource, RlvFolderLocks::PERM_DENY, eLockScope, rlvCmd.getObjectID(), eLockType); + } + break; + case RLV_BHVR_UNSHAREDWEAR: // @unsharedwear=n|y - Checked: 2011-03-28 (RLVa-1.3.0g) | Added: RLVa-1.3.0g + case RLV_BHVR_UNSHAREDUNWEAR: // @unsharedunwear=n|y - Checked: 2011-03-28 (RLVa-1.3.0g) | Added: RLVa-1.3.0g + { + VERIFY_OPTION_REF(strOption.empty()); + + // Lock down the inventory root + RlvFolderLocks::folderlock_source_t lockSource(RlvFolderLocks::ST_ROOTFOLDER, 0); + RlvFolderLocks::ELockScope eLockScope = RlvFolderLocks::SCOPE_SUBTREE; + ERlvLockMask eLockType = (RLV_BHVR_UNSHAREDUNWEAR == eBhvr) ? RLV_LOCK_REMOVE : RLV_LOCK_ADD; + + if (RLV_TYPE_ADD == eType) + RlvFolderLocks::instance().addFolderLock(lockSource, RlvFolderLocks::PERM_DENY, eLockScope, rlvCmd.getObjectID(), eLockType); + else + RlvFolderLocks::instance().removeFolderLock(lockSource, RlvFolderLocks::PERM_DENY, eLockScope, rlvCmd.getObjectID(), eLockType); + + // Add the #RLV shared folder as an exception + lockSource = RlvFolderLocks::folderlock_source_t(RlvFolderLocks::ST_SHAREDPATH, LLStringUtil::null); + if (RLV_TYPE_ADD == eType) + RlvFolderLocks::instance().addFolderLock(lockSource, RlvFolderLocks::PERM_ALLOW, eLockScope, rlvCmd.getObjectID(), eLockType); + else + RlvFolderLocks::instance().removeFolderLock(lockSource, RlvFolderLocks::PERM_ALLOW, eLockScope, rlvCmd.getObjectID(), eLockType); + } + break; + case RLV_BHVR_REDIRCHAT: // @redirchat:<channel>=n|y - Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.1.0h + case RLV_BHVR_REDIREMOTE: // @rediremote:<channel>=n|y - Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.1.0h + { + // There should be an option which should specify a valid reply channel (if there's an empty option the command is invalid) + S32 nChannel = 0; + VERIFY_OPTION_REF( (LLStringUtil::convertToS32(strOption, nChannel)) && (RlvUtil::isValidReplyChannel(nChannel)) ); + + if (RLV_TYPE_ADD == eType) + addException(rlvCmd.getObjectID(), eBhvr, nChannel); + else + removeException(rlvCmd.getObjectID(), eBhvr, nChannel); + } + break; + case RLV_BHVR_SENDCHANNEL: // @sendchannel[:<channel>]=n|y - Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.1.0h + { + // If there's an option then it should be a valid (= positive and non-zero) chat channel + S32 nChannel = 0; + if ( (LLStringUtil::convertToS32(strOption, nChannel)) && (nChannel > 0) ) + { + if (RLV_TYPE_ADD == eType) + addException(rlvCmd.getObjectID(), eBhvr, nChannel); + else + removeException(rlvCmd.getObjectID(), eBhvr, nChannel); + break; + } + VERIFY_OPTION_REF(strOption.empty()); + } + break; + case RLV_BHVR_NOTIFY: // @notify:<params>=add|rem - Checked: 2010-03-03 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a + { + // There should be an option that we can successfully parse (if there's an empty option the command is invalid) + S32 nChannel; std::string strFilter; + VERIFY_OPTION_REF( (!strOption.empty()) && (rlvParseNotifyOption(strOption, nChannel, strFilter)) ); + + if (RLV_TYPE_ADD == eType) + RlvBehaviourNotifyHandler::getInstance()->addNotify(rlvCmd.getObjectID(), nChannel, strFilter); + else + RlvBehaviourNotifyHandler::getInstance()->removeNotify(rlvCmd.getObjectID(), nChannel, strFilter); + } + break; + case RLV_BHVR_SHOWHOVERTEXT: // @showhovertext:<uuid>=n|y - Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.1.0h + { + // There should be an option and it should specify a valid UUID + LLUUID idException(strOption); + VERIFY_OPTION_REF(idException.notNull()); + + if (RLV_TYPE_ADD == eType) + addException(rlvCmd.getObjectID(), eBhvr, idException); + else + removeException(rlvCmd.getObjectID(), eBhvr, idException); + + // Clear/restore the object's hover text as needed + LLViewerObject* pObj = gObjectList.findObject(idException); + if ( (pObj) && (pObj->mText.notNull()) && (!pObj->mText->getObjectText().empty()) ) + pObj->mText->setString( (RLV_TYPE_ADD == eType) ? "" : pObj->mText->getObjectText()); + } + break; + // The following block is only valid if there's no option + case RLV_BHVR_SHOWLOC: // @showloc=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_SHOWNAMES: // @shownames=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_EMOTE: // @emote=n|y - Checked: 2010-03-26 (RLVa-1.2.0b) + case RLV_BHVR_SENDCHAT: // @sendchat=n|y - Checked: 2010-03-26 (RLVa-1.2.0b) + case RLV_BHVR_CHATWHISPER: // @chatwhisper=n|y - Checked: 2010-03-26 (RLVa-1.2.0b) + case RLV_BHVR_CHATNORMAL: // @chatnormal=n|y - Checked: 2010-03-26 (RLVa-1.2.0b) + case RLV_BHVR_CHATSHOUT: // @chatshout=n|y - Checked: 2010-03-26 (RLVa-1.2.0b) + case RLV_BHVR_PERMISSIVE: // @permissive=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_SHOWINV: // @showinv=n|y - Checked: 2010-03-01 (RLVa-1.2.0a) + case RLV_BHVR_SHOWMINIMAP: // @showminimap=n|y - Checked: 2010-02-28 (RLVa-1.2.0a) + case RLV_BHVR_SHOWWORLDMAP: // @showworldmap=n|y - Checked: 2010-02-28 (RLVa-1.2.0a) + case RLV_BHVR_SHOWHOVERTEXTHUD: // @showhovertexthud=n|y - Checked: 2010-03-27 (RLVa-1.2.0b) + case RLV_BHVR_SHOWHOVERTEXTWORLD: // @showhovertextworld=n|y - Checked: 2010-03-27 (RLVa-1.2.0b) + case RLV_BHVR_SHOWHOVERTEXTALL: // @showhovertextall=n|y - Checked: 2010-03-27 (RLVa-1.2.0b) + case RLV_BHVR_STANDTP: // @standtp=n|y - Checked: 2010-08-29 (RLVa-1.2.1c) + case RLV_BHVR_TPLM: // @tplm=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_TPLOC: // @tploc=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_VIEWNOTE: // @viewnote=n|y - Checked: 2010-03-27 (RLVa-1.2.0b) + case RLV_BHVR_VIEWSCRIPT: // @viewscript=n|y - Checked: 2010-03-27 (RLVa-1.2.0b) + case RLV_BHVR_VIEWTEXTURE: // @viewtexture=n|y - Checked: 2010-03-27 (RLVa-1.2.0b) + case RLV_BHVR_ACCEPTPERMISSION: // @acceptpermission=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h +#ifdef RLV_EXTENSION_CMD_ALLOWIDLE + case RLV_BHVR_ALLOWIDLE: // @allowidle=n|y - Checked: 2010-05-03 (RLVa-1.2.0g) | Modified: RLVa-1.1.0h +#endif // RLV_EXTENSION_CMD_ALLOWIDLE + case RLV_BHVR_REZ: // @rez=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_FARTOUCH: // @fartouch=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h +#ifdef RLV_EXTENSION_CMD_INTERACT + case RLV_BHVR_INTERACT: // @interact=n|y - Checked: 2010-01-01 (RLVa-1.1.0l) | Added: RLVa-1.1.0l +#endif // RLV_EXTENSION_CMD_INTERACT + case RLV_BHVR_TOUCHATTACHSELF: // @touchattachself=n|y - Checked: 2011-01-21 (RLVa-1.3.0e) | Added: RLVa-1.3.0e + case RLV_BHVR_TOUCHATTACHOTHER: // @touchattachother=n|y - Checked: 2011-01-21 (RLVa-1.3.0e) | Added: RLVa-1.3.0e + case RLV_BHVR_TOUCHALL: // @touchall=n|y - Checked: 2011-01-21 (RLVa-1.3.0e) | Added: RLVa-1.3.0e + case RLV_BHVR_TOUCHME: // @touchme=n|y - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h + case RLV_BHVR_FLY: // @fly=n|y - Checked: 2010-03-02 (RLVa-1.2.0a) + case RLV_BHVR_SETGROUP: // @setgroup=n|y - Checked: 2011-05-22 (RLVa-1.4.1a) | Added: RLVa-1.3.1b + case RLV_BHVR_ALWAYSRUN: // @alwaysrun=n|y - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + case RLV_BHVR_TEMPRUN: // @temprun=n|y - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i + case RLV_BHVR_UNSIT: // @unsit=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_SIT: // @sit=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_SITTP: // @sittp=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_SETDEBUG: // @setdebug=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + VERIFY_OPTION_REF(strOption.empty()); + break; + // The following block is only valid if there's no option (= restriction) or if it specifies a valid UUID (= behaviour exception) + case RLV_BHVR_RECVCHAT: // @recvchat[:<uuid>]=n|y - Checked: 2010-03-26 (RLVa-1.2.0b) + case RLV_BHVR_RECVEMOTE: // @recvemote[:<uuid>]=n|y - Checked: 2010-03-26 (RLVa-1.2.0b) + case RLV_BHVR_SENDIM: // @sendim[:<uuid>]=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_RECVIM: // @recvim[:<uuid>]=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_STARTIM: // @startim[:<uuid>]=n|y - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h + case RLV_BHVR_TPLURE: // @tplure[:<uuid>]=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_ACCEPTTP: // @accepttp[:<uuid>]=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h + case RLV_BHVR_TOUCHATTACH: // @touchattach[:<uuid>=n|y - Checked: 2010-01-01 (RLVa-1.1.0l) | Added: RLVa-1.1.0l +#ifdef RLV_EXTENSION_CMD_TOUCHXXX + case RLV_BHVR_TOUCHHUD: // @touchhud[:<uuid>=n|y - Checked: 2010-01-01 (RLVa-1.1.0l) | Added: RLVa-1.1.0l +#endif // RLV_EXTENSION_CMD_TOUCHXXX + case RLV_BHVR_TOUCHWORLD: // @touchworld[:<uuid>=n|y - Checked: 2010-01-01 (RLVa-1.1.0l) | Added: RLVa-1.1.0l + case RLV_BHVR_EDIT: // @edit[:<uuid>]=n|y - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c + { + LLUUID idException(strOption); + if (idException.notNull()) // If there's an option then it should specify a valid UUID + { + if (RLV_TYPE_ADD == eType) + addException(rlvCmd.getObjectID(), eBhvr, idException); + else + removeException(rlvCmd.getObjectID(), eBhvr, idException); + break; + } + VERIFY_OPTION_REF(strOption.empty()); + } + break; + // + // The following block is only valid if there an option that specifies a valid UUID (reference-counted per option) + // + case RLV_BHVR_RECVCHATFROM: // @recvchatfrom:<uuid>=n|y - Checked: 2010-11-30 (RLVa-1.3.0c) | Added: RLVa-1.3.0c + case RLV_BHVR_RECVEMOTEFROM: // @recvemotefrom:<uuid>=n|y - Checked: 2010-11-30 (RLVa-1.3.0c) | Added: RLVa-1.3.0c + case RLV_BHVR_SENDIMTO: // @sendimto:<uuid>=n|y - Checked: 2010-11-30 (RLVa-1.3.0c) | Added: RLVa-1.3.0c + case RLV_BHVR_RECVIMFROM: // @recvimfrom:<uuid>=n|y - Checked: 2010-11-30 (RLVa-1.3.0c) | Added: RLVa-1.3.0c + case RLV_BHVR_STARTIMTO: // @startimto:<uuid>=n|y - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h + case RLV_BHVR_EDITOBJ: // @editobj:<uuid>=n|y - Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c + case RLV_BHVR_TOUCHTHIS: // @touchthis:<uuid>=n|y - Checked: 2010-01-01 (RLVa-1.1.0l) | Added: RLVa-1.1.0l + { + // There should be an option and it should specify a valid UUID + LLUUID idException(strOption); + VERIFY_OPTION_REF(idException.notNull()); + + if (RLV_TYPE_ADD == eType) + addException(rlvCmd.getObjectID(), eBhvr, idException); + else + removeException(rlvCmd.getObjectID(), eBhvr, idException); + } + break; + // + // Unknown or invalid + // + case RLV_BHVR_UNKNOWN: + // Pass unknown commands on to registered command handlers + return (notifyCommandHandlers(&RlvCommandHandler::onAddRemCommand, rlvCmd, eRet, false)) ? eRet : RLV_RET_FAILED_UNKNOWN; + default: + // Fail with "Invalid param" if none of the above handled it + eRet = RLV_RET_FAILED_PARAM; + break; + } + + // If this command represents a behaviour restriction that's been added/removed then we need to do some additional processing + if ( (RLV_RET_SUCCESS == eRet) && (fRefCount) ) + { + if (RLV_TYPE_ADD == eType) + { + if (rlvCmd.isStrict()) + addException(rlvCmd.getObjectID(), RLV_BHVR_PERMISSIVE, eBhvr); + m_Behaviours[eBhvr]++; + } + else + { + if (rlvCmd.isStrict()) + removeException(rlvCmd.getObjectID(), RLV_BHVR_PERMISSIVE, eBhvr); + m_Behaviours[eBhvr]--; + } + + m_OnBehaviour(eBhvr, eType); + if ( ((RLV_TYPE_ADD == eType) && (1 == m_Behaviours[eBhvr])) || ((RLV_TYPE_REMOVE == eType) && (0 == m_Behaviours[eBhvr])) ) + m_OnBehaviourToggle(eBhvr, eType); + } + + return eRet; +} + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +ERlvCmdRet RlvHandler::onAddRemAttach(const RlvCommand& rlvCmd, bool& fRefCount) +{ + RLV_ASSERT( (RLV_TYPE_ADD == rlvCmd.getParamType()) || (RLV_TYPE_REMOVE == rlvCmd.getParamType()) ); + RLV_ASSERT( (RLV_BHVR_ADDATTACH == rlvCmd.getBehaviourType()) || (RLV_BHVR_REMATTACH == rlvCmd.getBehaviourType()) ); + + // Sanity check - if there's an option it should specify a valid attachment point name + S32 idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(rlvCmd.getOption()); + if ( (!idxAttachPt) && (!rlvCmd.getOption().empty()) ) + return RLV_RET_FAILED_OPTION; + + if (!isAgentAvatarValid()) + return RLV_RET_FAILED; + + // We need to flush any queued force-wear commands before changing the restrictions + if (RlvForceWear::instanceExists()) + RlvForceWear::instance().done(); + + ERlvLockMask eLock = (RLV_BHVR_REMATTACH == rlvCmd.getBehaviourType()) ? RLV_LOCK_REMOVE : RLV_LOCK_ADD; + for (LLVOAvatar::attachment_map_t::const_iterator itAttach = gAgentAvatarp->mAttachmentPoints.begin(); + itAttach != gAgentAvatarp->mAttachmentPoints.end(); ++itAttach) + { + if ( (0 == idxAttachPt) || (itAttach->first == idxAttachPt) ) + { + if (RLV_TYPE_ADD == rlvCmd.getParamType()) + gRlvAttachmentLocks.addAttachmentPointLock(itAttach->first, rlvCmd.getObjectID(), eLock); + else + gRlvAttachmentLocks.removeAttachmentPointLock(itAttach->first, rlvCmd.getObjectID(), eLock); + } + } + + fRefCount = rlvCmd.getOption().empty(); // Only reference count global locks + return RLV_RET_SUCCESS; +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +ERlvCmdRet RlvHandler::onAddRemDetach(const RlvCommand& rlvCmd, bool& fRefCount) +{ + RLV_ASSERT( (RLV_TYPE_ADD == rlvCmd.getParamType()) || (RLV_TYPE_REMOVE == rlvCmd.getParamType()) ); + RLV_ASSERT(RLV_BHVR_DETACH == rlvCmd.getBehaviourType()); + + // We need to flush any queued force-wear commands before changing the restrictions + if (RlvForceWear::instanceExists()) + RlvForceWear::instance().done(); + + if (rlvCmd.getOption().empty()) // @detach=n|y - RLV_LOCK_REMOVE locks an attachment *object* + { + // The object may or may not exist (it may not have rezzed yet, or it may have already been killed): + // * @detach=n: - if it has rezzed then we'll already have looked up what we need (see next line if it's not an attachment) + // - if it hasn't rezzed yet then it's a @detach=n from a non-attachment and RlvHandler::onAttach() takes care of it + // * @detach=y: - if it ever rezzed as an attachment we'll have cached the UUID of its root + // - if it never rezzed as an attachment there won't be a lock to remove + rlv_object_map_t::const_iterator itObj = m_Objects.find(rlvCmd.getObjectID()); + if ( (itObj != m_Objects.end()) && (itObj->second.m_fLookup) && (itObj->second.m_idxAttachPt) ) + { + if (RLV_TYPE_ADD == rlvCmd.getParamType()) + gRlvAttachmentLocks.addAttachmentLock(itObj->second.m_idRoot, itObj->first); + else + gRlvAttachmentLocks.removeAttachmentLock(itObj->second.m_idRoot, itObj->first); + } + } + else // @detach:<attachpt>=n|y - RLV_LOCK_ADD and RLV_LOCK_REMOVE locks an attachment *point* + { + // The attachment point index should always be non-zero for @detach:<attachpt>=n|y + S32 idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(rlvCmd.getOption()); + if (0 == idxAttachPt) + return RLV_RET_FAILED_OPTION; + + if (RLV_TYPE_ADD == rlvCmd.getParamType()) + gRlvAttachmentLocks.addAttachmentPointLock(idxAttachPt, rlvCmd.getObjectID(), (ERlvLockMask)(RLV_LOCK_ADD | RLV_LOCK_REMOVE)); + else + gRlvAttachmentLocks.removeAttachmentPointLock(idxAttachPt, rlvCmd.getObjectID(), (ERlvLockMask)(RLV_LOCK_ADD | RLV_LOCK_REMOVE)); + } + + fRefCount = false; // Don't reference count @detach[:<option>]=n + return RLV_RET_SUCCESS; +} + +// Checked: 2010-11-30 (RLVa-1.3.0b) | Added: RLVa-1.3.0b +ERlvCmdRet RlvHandler::onAddRemFolderLock(const RlvCommand& rlvCmd, bool& fRefCount) +{ + RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption()); + + RlvFolderLocks::folderlock_source_t lockSource; + if (rlvCmdOption.isEmpty()) + { + lockSource = RlvFolderLocks::folderlock_source_t(RlvFolderLocks::ST_ATTACHMENT, rlvCmd.getObjectID()); + } + else if (rlvCmdOption.isSharedFolder()) + { + lockSource = RlvFolderLocks::folderlock_source_t(RlvFolderLocks::ST_SHAREDPATH, rlvCmd.getOption()); + } + else if (rlvCmdOption.isAttachmentPoint()) + { + lockSource = RlvFolderLocks::folderlock_source_t(RlvFolderLocks::ST_ATTACHMENTPOINT, RlvAttachPtLookup::getAttachPointIndex(rlvCmdOption.getAttachmentPoint())); + } + else if (rlvCmdOption.isWearableType()) + { + lockSource = RlvFolderLocks::folderlock_source_t(RlvFolderLocks::ST_WEARABLETYPE, rlvCmdOption.getWearableType()); + } + else + { + fRefCount = false; // Don't reference count failure + return RLV_RET_FAILED_OPTION; + } + + ERlvBehaviour eBhvr = rlvCmd.getBehaviourType(); + + // Determine the lock type + ERlvLockMask eLockType = ((RLV_BHVR_ATTACHTHIS == eBhvr) || (RLV_BHVR_ATTACHALLTHIS == eBhvr)) ? RLV_LOCK_ADD : RLV_LOCK_REMOVE; + + // Determine the folder lock options from the issued behaviour + RlvFolderLocks::ELockPermission eLockPermission = RlvFolderLocks::PERM_DENY; + RlvFolderLocks::ELockScope eLockScope = + ((RLV_BHVR_ATTACHALLTHIS == eBhvr) || (RLV_BHVR_DETACHALLTHIS == eBhvr)) ? RlvFolderLocks::SCOPE_SUBTREE : RlvFolderLocks::SCOPE_NODE; + + if (RLV_TYPE_ADD == rlvCmd.getParamType()) + RlvFolderLocks::instance().addFolderLock(lockSource, eLockPermission, eLockScope, rlvCmd.getObjectID(), eLockType); + else + RlvFolderLocks::instance().removeFolderLock(lockSource, eLockPermission, eLockScope, rlvCmd.getObjectID(), eLockType); + + fRefCount = true; + return RLV_RET_SUCCESS; +} + +// Checked: 2011-03-27 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +ERlvCmdRet RlvHandler::onAddRemFolderLockException(const RlvCommand& rlvCmd, bool& fRefCount) +{ + // Sanity check - the option should specify a shared folder path + RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption()); + if (!rlvCmdOption.isSharedFolder()) + return RLV_RET_FAILED_OPTION; + + ERlvBehaviour eBhvr = rlvCmd.getBehaviourType(); + + // Determine the lock type + ERlvLockMask eLockType = + ((RLV_BHVR_ATTACHTHISEXCEPT == eBhvr) || (RLV_BHVR_ATTACHALLTHISEXCEPT == eBhvr)) ? RLV_LOCK_ADD : RLV_LOCK_REMOVE; + + // Determine the folder lock options from the issued behaviour + RlvFolderLocks::ELockPermission eLockPermission = RlvFolderLocks::PERM_ALLOW; + RlvFolderLocks::ELockScope eLockScope = + ((RLV_BHVR_ATTACHALLTHISEXCEPT == eBhvr) || (RLV_BHVR_DETACHALLTHISEXCEPT == eBhvr)) ? RlvFolderLocks::SCOPE_SUBTREE : RlvFolderLocks::SCOPE_NODE; + + RlvFolderLocks::folderlock_source_t lockSource(RlvFolderLocks::ST_SHAREDPATH, rlvCmd.getOption()); + if (RLV_TYPE_ADD == rlvCmd.getParamType()) + RlvFolderLocks::instance().addFolderLock(lockSource, eLockPermission, eLockScope, rlvCmd.getObjectID(), eLockType); + else + RlvFolderLocks::instance().removeFolderLock(lockSource, eLockPermission, eLockScope, rlvCmd.getObjectID(), eLockType); + + fRefCount = true; + return RLV_RET_SUCCESS; +} + +// ============================================================================ +// Command handlers (RLV_TYPE_FORCE) +// + +// Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.1.0j +ERlvCmdRet RlvHandler::processForceCommand(const RlvCommand& rlvCmd) const +{ + RLV_ASSERT(RLV_TYPE_FORCE == rlvCmd.getParamType()); + + ERlvCmdRet eRet = RLV_RET_SUCCESS; + switch (rlvCmd.getBehaviourType()) + { + case RLV_BHVR_DETACH: // @detach[:<option>]=force - Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c + case RLV_BHVR_REMATTACH: // @remattach[:<option>]=force + { + RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption()); + if (rlvCmdOption.isSharedFolder()) + eRet = onForceWear(rlvCmdOption.getSharedFolder(), RLV_BHVR_DETACH); + else + eRet = onForceRemAttach(rlvCmd); + } + break; + case RLV_BHVR_REMOUTFIT: // @remoutfit[:<option>]=force + { + RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption()); + if (rlvCmdOption.isSharedFolder()) + eRet = onForceWear(rlvCmdOption.getSharedFolder(), RLV_BHVR_DETACH); + else + eRet = onForceRemOutfit(rlvCmd); + } + break; + case RLV_BHVR_SETGROUP: // @setgroup:<uuid|name>=force - Checked: 2011-03-28 (RLVa-1.4.1a) | Added: RLVa-1.3.0f + eRet = onForceGroup(rlvCmd); + break; + case RLV_BHVR_UNSIT: // @unsit=force - Checked: 2010-03-18 (RLVa-1.2.0c) | Modified: RLVa-0.2.0g + { + VERIFY_OPTION(rlvCmd.getOption().empty()); + if ( (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) && (!hasBehaviourExcept(RLV_BHVR_UNSIT, rlvCmd.getObjectID())) ) + { + gAgent.setControlFlags(AGENT_CONTROL_STAND_UP); + send_agent_update(TRUE, TRUE); // See behaviour notes on why we have to force an agent update here + } + } + break; + case RLV_BHVR_SIT: // @sit:<option>=force + eRet = onForceSit(rlvCmd); + break; + case RLV_BHVR_ADJUSTHEIGHT: // @adjustheight:<options>=force + eRet = RLV_RET_DEPRECATED; + break; + case RLV_BHVR_TPTO: // @tpto:<option>=force - Checked: 2011-03-28 (RLVa-1.3.0f) | Modified: RLVa-1.3.0f + { + RlvCommandOptionTpTo rlvCmdOption(rlvCmd); + VERIFY_OPTION( (rlvCmdOption.isValid()) && (!rlvCmdOption.m_posGlobal.isNull()) ); + gAgent.teleportViaLocation(rlvCmdOption.m_posGlobal); + } + break; + case RLV_BHVR_ATTACH: + case RLV_BHVR_ATTACHOVER: + case RLV_BHVR_ATTACHALL: + case RLV_BHVR_ATTACHALLOVER: + case RLV_BHVR_DETACHALL: + { + RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption()); + VERIFY_OPTION(rlvCmdOption.isSharedFolder()); + + eRet = onForceWear(rlvCmdOption.getSharedFolder(), rlvCmd.getBehaviourType()); + } + break; + case RLV_BHVR_ATTACHTHIS: + case RLV_BHVR_ATTACHTHISOVER: + case RLV_BHVR_DETACHTHIS: + case RLV_BHVR_ATTACHALLTHIS: + case RLV_BHVR_ATTACHALLTHISOVER: + case RLV_BHVR_DETACHALLTHIS: + { + RlvCommandOptionGetPath rlvGetPathOption(rlvCmd, boost::bind(&RlvHandler::onForceWearCallback, this, _1, rlvCmd.getBehaviourType())); + VERIFY_OPTION(rlvGetPathOption.isValid()); + eRet = (!rlvGetPathOption.isCallback()) ? RLV_RET_SUCCESS : RLV_RET_SUCCESS_DELAYED; + } + break; + case RLV_BHVR_DETACHME: // @detachme=force - Checked: 2010-09-04 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c + { + VERIFY_OPTION(rlvCmd.getOption().empty()); + // NOTE: @detachme should respect locks but shouldn't respect things like nostrip + const LLViewerObject* pAttachObj = gObjectList.findObject(rlvCmd.getObjectID()); + if ( (pAttachObj) && (pAttachObj->isAttachment()) ) + { + LLVOAvatarSelf::detachAttachmentIntoInventory(pAttachObj->getAttachmentItemID()); + } + } + break; + case RLV_BHVR_UNKNOWN: + // Pass unknown commands on to registered command handlers + return (notifyCommandHandlers(&RlvCommandHandler::onForceCommand, rlvCmd, eRet, false)) ? eRet : RLV_RET_FAILED_UNKNOWN; + default: + // Fail with "Invalid param" if none of the above handled it + eRet = RLV_RET_FAILED_PARAM; + break; + } + return eRet; +} + +// Checked: 2010-08-29 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c +ERlvCmdRet RlvHandler::onForceRemAttach(const RlvCommand& rlvCmd) const +{ + RLV_ASSERT(RLV_TYPE_FORCE == rlvCmd.getParamType()); + RLV_ASSERT( (RLV_BHVR_REMATTACH == rlvCmd.getBehaviourType()) || (RLV_BHVR_DETACH == rlvCmd.getBehaviourType()) ); + + if (!isAgentAvatarValid()) + return RLV_RET_FAILED; + + RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption()); + // @remattach:<attachpt>=force - force detach single attachment point + if (rlvCmdOption.isAttachmentPoint()) + { + RlvForceWear::instance().forceDetach(rlvCmdOption.getAttachmentPoint()); + return RLV_RET_SUCCESS; + } + // @remattach:<group>=force - force detach attachments points belonging to <group> + // @remattach=force - force detach all attachments points + else if ( (rlvCmdOption.isAttachmentPointGroup()) || (rlvCmdOption.isEmpty()) ) + { + for (LLVOAvatar::attachment_map_t::const_iterator itAttach = gAgentAvatarp->mAttachmentPoints.begin(); + itAttach != gAgentAvatarp->mAttachmentPoints.end(); ++itAttach) + { + const LLViewerJointAttachment* pAttachPt = itAttach->second; + if ( (pAttachPt) && (pAttachPt->getNumObjects()) && + ((rlvCmdOption.isEmpty()) || (rlvAttachGroupFromIndex(pAttachPt->getGroup()) == rlvCmdOption.getAttachmentPointGroup())) ) + { + RlvForceWear::instance().forceDetach(pAttachPt); + } + } + return RLV_RET_SUCCESS; + } + return RLV_RET_FAILED_OPTION; +} + +// Checked: 2010-08-29 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c +ERlvCmdRet RlvHandler::onForceRemOutfit(const RlvCommand& rlvCmd) const +{ + RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption()); + if ( (!rlvCmdOption.isWearableType()) && (!rlvCmdOption.isEmpty()) ) + return RLV_RET_FAILED_OPTION; + + for (int idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++) + { + if ( (rlvCmdOption.isEmpty()) || ((LLWearableType::EType)idxType == rlvCmdOption.getWearableType())) + RlvForceWear::instance().forceRemove((LLWearableType::EType)idxType); + } + return RLV_RET_SUCCESS; +} + +// Checked: 2011-07-23 (RLVa-1.4.1a) | Modified: RLVa-1.4.1a +ERlvCmdRet RlvHandler::onForceGroup(const RlvCommand& rlvCmd) const +{ + if (hasBehaviourExcept(RLV_BHVR_SETGROUP, rlvCmd.getObjectID())) + { + return RLV_RET_FAILED_LOCK; + } + + LLUUID idGroup; bool fValid = false; + if (idGroup.set(rlvCmd.getOption())) + { + fValid = (idGroup.isNull()) || (gAgent.isInGroup(idGroup, true)); + } + else + { + for (S32 idxGroup = 0, cntGroup = gAgent.mGroups.count(); (idxGroup < cntGroup) && (idGroup.isNull()); idxGroup++) + if (boost::iequals(gAgent.mGroups.get(idxGroup).mName, rlvCmd.getOption())) + idGroup = gAgent.mGroups.get(idxGroup).mID; + fValid = (idGroup.notNull()) || ("none" == rlvCmd.getOption()); + } + + if (fValid) + { + m_idAgentGroup = idGroup; + LLGroupActions::activate(idGroup); + } + + return (fValid) ? RLV_RET_SUCCESS : RLV_RET_FAILED_OPTION; +} + +// Checked: 2010-03-18 (RLVa-1.2.0c) | Modified: RLVa-1.1.0j +ERlvCmdRet RlvHandler::onForceSit(const RlvCommand& rlvCmd) const +{ + LLViewerObject* pObj = NULL; LLUUID idTarget(rlvCmd.getOption()); + // Sanity checking - we need to know about the object and it should identify a prim/linkset + if ( (idTarget.isNull()) || ((pObj = gObjectList.findObject(idTarget)) == NULL) || (LL_PCODE_VOLUME != pObj->getPCode()) ) + return RLV_RET_FAILED_OPTION; + + if (!canSit(pObj)) + return RLV_RET_FAILED_LOCK; + else if ( (hasBehaviour(RLV_BHVR_STANDTP)) && (isAgentAvatarValid()) ) + { + if (gAgentAvatarp->isSitting()) + return RLV_RET_FAILED_LOCK; + m_posSitSource = gAgent.getPositionGlobal(); + } + + // Copy/paste from handle_sit_or_stand() [see http://wiki.secondlife.com/wiki/AgentRequestSit] + gMessageSystem->newMessageFast(_PREHASH_AgentRequestSit); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + gMessageSystem->nextBlockFast(_PREHASH_TargetObject); + gMessageSystem->addUUIDFast(_PREHASH_TargetID, pObj->mID); + // Offset: "a rough position in local coordinates for the edge to sit on" + // (we might not even be looking at the object so I don't think we can supply the offset to an edge) + gMessageSystem->addVector3Fast(_PREHASH_Offset, LLVector3::zero); + pObj->getRegion()->sendReliableMessage(); + + return RLV_RET_SUCCESS; +} + +// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c +ERlvCmdRet RlvHandler::onForceWear(const LLViewerInventoryCategory* pFolder, ERlvBehaviour eBhvr) const +{ + if ( (pFolder) && (!RlvInventory::instance().isSharedFolder(pFolder->getUUID())) ) + return RLV_RET_FAILED_OPTION; + + RlvForceWear::EWearAction eAction = RlvForceWear::ACTION_WEAR_REPLACE; + if ( (RLV_BHVR_ATTACHOVER == eBhvr) || (RLV_BHVR_ATTACHTHISOVER == eBhvr) || + (RLV_BHVR_ATTACHALLOVER == eBhvr) || (RLV_BHVR_ATTACHALLTHISOVER == eBhvr) ) + { + eAction = RlvForceWear::ACTION_WEAR_ADD; + } + else if ( (RLV_BHVR_DETACH == eBhvr) || (RLV_BHVR_DETACHTHIS == eBhvr) || + (RLV_BHVR_DETACHALL == eBhvr) || (RLV_BHVR_DETACHALLTHIS == eBhvr) ) + { + eAction = RlvForceWear::ACTION_REMOVE; + } + + RlvForceWear::EWearFlags eFlags = RlvForceWear::FLAG_DEFAULT; + if ( (RLV_BHVR_ATTACHALL == eBhvr) || (RLV_BHVR_ATTACHALLOVER == eBhvr) || (RLV_BHVR_DETACHALL == eBhvr) || + (RLV_BHVR_ATTACHALLTHIS == eBhvr) || (RLV_BHVR_ATTACHALLTHISOVER == eBhvr) || (RLV_BHVR_DETACHALLTHIS == eBhvr) ) + { + eFlags = (RlvForceWear::EWearFlags)(eFlags | RlvForceWear::FLAG_MATCHALL); + } + + RlvForceWear::instance().forceFolder(pFolder, eAction, eFlags); + return RLV_RET_SUCCESS; +} + +void RlvHandler::onForceWearCallback(const uuid_vec_t& idItems, ERlvBehaviour eBhvr) const +{ + LLInventoryModel::cat_array_t folders; + if (RlvInventory::instance().getPath(idItems, folders)) + { + for (S32 idxFolder = 0, cntFolder = folders.count(); idxFolder < cntFolder; idxFolder++) + onForceWear(folders.get(idxFolder), eBhvr); + + // If we're not executing a command then we're a delayed callback and need to manually call done() + if ( (!getCurrentCommand()) && (RlvForceWear::instanceExists()) ) + RlvForceWear::instance().done(); + } +} + +// ============================================================================ +// Command handlers (RLV_TYPE_REPLY) +// + +// Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.1.0f +ERlvCmdRet RlvHandler::processReplyCommand(const RlvCommand& rlvCmd) const +{ + RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType()); + + // Sanity check - <param> should specify a - valid - reply channel + S32 nChannel; + if ( (!LLStringUtil::convertToS32(rlvCmd.getParam(), nChannel)) || (!RlvUtil::isValidReplyChannel(nChannel)) ) + return RLV_RET_FAILED_PARAM; + + ERlvCmdRet eRet = RLV_RET_SUCCESS; std::string strReply; + switch (rlvCmd.getBehaviourType()) + { + case RLV_BHVR_VERSION: // @version=<channel> - Checked: 2010-03-27 (RLVa-1.4.0a) + case RLV_BHVR_VERSIONNEW: // @versionnew=<channel> - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.2.0b + // NOTE: RLV will respond even if there's an option + strReply = RlvStrings::getVersion(RLV_BHVR_VERSION == rlvCmd.getBehaviourType()); + break; + case RLV_BHVR_VERSIONNUM: // @versionnum=<channel> - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.0.4b + // NOTE: RLV will respond even if there's an option + strReply = RlvStrings::getVersionNum(); + break; + case RLV_BHVR_GETATTACH: // @getattach[:<layer>]=<channel> + eRet = onGetAttach(rlvCmd, strReply); + break; +#ifdef RLV_EXTENSION_CMD_GETXXXNAMES + case RLV_BHVR_GETATTACHNAMES: // @getattachnames[:<grp>]=<channel> + case RLV_BHVR_GETADDATTACHNAMES:// @getaddattachnames[:<grp>]=<channel> + case RLV_BHVR_GETREMATTACHNAMES:// @getremattachnames[:<grp>]=<channel> + eRet = onGetAttachNames(rlvCmd, strReply); + break; +#endif // RLV_EXTENSION_CMD_GETXXXNAMES + case RLV_BHVR_GETOUTFIT: // @getoutfit[:<layer>]=<channel> + eRet = onGetOutfit(rlvCmd, strReply); + break; +#ifdef RLV_EXTENSION_CMD_GETXXXNAMES + case RLV_BHVR_GETOUTFITNAMES: // @getoutfitnames=<channel> + case RLV_BHVR_GETADDOUTFITNAMES:// @getaddoutfitnames=<channel> + case RLV_BHVR_GETREMOUTFITNAMES:// @getremoutfitnames=<channel> + eRet = onGetOutfitNames(rlvCmd, strReply); + break; +#endif // RLV_EXTENSION_CMD_GETXXXNAMES + case RLV_BHVR_FINDFOLDER: // @findfolder:<criteria>=<channel> +#ifdef RLV_EXTENSION_CMD_FINDFOLDERS + case RLV_BHVR_FINDFOLDERS: // @findfolders:<criteria>=<channel> +#endif // RLV_EXTENSION_CMD_FINDFOLDERS + eRet = onFindFolder(rlvCmd, strReply); + break; + case RLV_BHVR_GETPATH: // @getpath[:<option>]=<channel> + case RLV_BHVR_GETPATHNEW: // @getpathnew[:<option>]=<channel> + eRet = onGetPath(rlvCmd, strReply); + break; + case RLV_BHVR_GETINV: // @getinv[:<path>]=<channel> + eRet = onGetInv(rlvCmd, strReply); + break; + case RLV_BHVR_GETINVWORN: // @getinvworn[:<path>]=<channel> + eRet = onGetInvWorn(rlvCmd, strReply); + break; + case RLV_BHVR_GETGROUP: // @getgroup=<channel> - Checked: 2011-03-28 (RLVa-1.4.1a) | Added: RLVa-1.3.0f + strReply = (gAgent.getGroupID().notNull()) ? gAgent.getGroupName() : "none"; + break; + case RLV_BHVR_GETSITID: // @getsitid=<channel> - Checked: 2010-03-09 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a + { + // NOTE: RLV-1.16.1 returns a NULL UUID if we're not sitting + LLUUID idSitObj; + if ( (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) ) + { + const LLViewerObject* pSeatObj = dynamic_cast<LLViewerObject*>(gAgentAvatarp->getRoot()); + if (pSeatObj) + idSitObj = pSeatObj->getID(); + } + strReply = idSitObj.asString(); + } + break; +#ifdef RLV_EXTENSION_CMD_GETCOMMAND + case RLV_BHVR_GETCOMMAND: // @getcommand:<option>=<channel> - Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c + { + RlvCommand::bhvr_map_t cmdList; + if (RlvCommand::getCommands(cmdList, rlvCmd.getOption())) + for (RlvCommand::bhvr_map_t::const_iterator itCmd = cmdList.begin(); itCmd != cmdList.end(); ++itCmd) + strReply.append("/").append(itCmd->first); + } + break; +#endif // RLV_EXTENSION_CMD_GETCOMMAND + case RLV_BHVR_GETSTATUS: // @getstatus[:<option>]=<channel> - Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.1.0f + { + // NOTE: specification says response should start with '/' but RLV-1.16.1 returns an empty string when no rules are set + rlv_object_map_t::const_iterator itObj = m_Objects.find(rlvCmd.getObjectID()); + if (itObj != m_Objects.end()) + strReply = itObj->second.getStatusString(rlvCmd.getOption()); + } + break; + case RLV_BHVR_GETSTATUSALL: // @getstatusall[:<option>]=<channel> - Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.1.0f + { + // NOTE: specification says response should start with '/' but RLV-1.16.1 returns an empty string when no rules are set + for (rlv_object_map_t::const_iterator itObj = m_Objects.begin(); itObj != m_Objects.end(); ++itObj) + strReply += itObj->second.getStatusString(rlvCmd.getOption()); + } + break; + case RLV_BHVR_UNKNOWN: + // Pass unknown commands on to registered command handlers + return (notifyCommandHandlers(&RlvCommandHandler::onReplyCommand, rlvCmd, eRet, false)) ? eRet : RLV_RET_FAILED_UNKNOWN; + default: + // Fail with "Invalid param" if none of the above handled it + return RLV_RET_FAILED_PARAM; + } + + // If we made it this far then: + // - the command was handled successfully so we send off the response + // - the command failed but we still send off an - empty - response to keep the issuing script from blocking + RlvUtil::sendChatReply(nChannel, strReply); + + return eRet; +} + +// Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.1.0f +ERlvCmdRet RlvHandler::onFindFolder(const RlvCommand& rlvCmd, std::string& strReply) const +{ + RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType()); + RLV_ASSERT( (RLV_BHVR_FINDFOLDER == rlvCmd.getBehaviourType()) || (RLV_BHVR_FINDFOLDERS == rlvCmd.getBehaviourType()) ); + + // (Compatibility: RLV 1.16.1 returns the first random folder it finds while we return a blank on no option) + if (rlvCmd.getOption().empty()) + return RLV_RET_FAILED_OPTION; + + LLInventoryModel::cat_array_t folders; + if (RlvInventory::instance().findSharedFolders(rlvCmd.getOption(), folders)) + { + if (RLV_BHVR_FINDFOLDER == rlvCmd.getBehaviourType()) + { + // We need to return an "in depth" result so whoever has the most '/' is our lucky winner + // (maxSlashes needs to be initialized to -1 since children of the #RLV folder won't have '/' in their shared path) + int maxSlashes = -1, curSlashes; std::string strFolderName; + for (S32 idxFolder = 0, cntFolder = folders.count(); idxFolder < cntFolder; idxFolder++) + { + strFolderName = RlvInventory::instance().getSharedPath(folders.get(idxFolder)); + + curSlashes = std::count(strFolderName.begin(), strFolderName.end(), '/'); + if (curSlashes > maxSlashes) + { + maxSlashes = curSlashes; + strReply = strFolderName; + } + } + } + else if (RLV_BHVR_FINDFOLDERS == rlvCmd.getBehaviourType()) + { + for (S32 idxFolder = 0, cntFolder = folders.count(); idxFolder < cntFolder; idxFolder++) + { + if (!strReply.empty()) + strReply.push_back(','); + strReply += RlvInventory::instance().getSharedPath(folders.get(idxFolder)); + } + } + } + return RLV_RET_SUCCESS; +} + +// Checked: 2010-03-19 (RLVa-1.4.0a) | Modified: RLVa-1.1.0e +ERlvCmdRet RlvHandler::onGetAttach(const RlvCommand& rlvCmd, std::string& strReply) const +{ + RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType()); + RLV_ASSERT(RLV_BHVR_GETATTACH == rlvCmd.getBehaviourType()); + + if (!isAgentAvatarValid()) + return RLV_RET_FAILED; + + // Sanity check - <option> should specify an attachment point or be empty + S32 idxAttachPt = 0; + if ( (rlvCmd.hasOption()) && ((idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(rlvCmd.getOption())) == 0) ) + return RLV_RET_FAILED_OPTION; + + // If we're fetching all worn attachments then the reply should start with 0 + if (0 == idxAttachPt) + strReply.push_back('0'); + + for (LLVOAvatar::attachment_map_t::const_iterator itAttach = gAgentAvatarp->mAttachmentPoints.begin(); + itAttach != gAgentAvatarp->mAttachmentPoints.end(); ++itAttach) + { + const LLViewerJointAttachment* pAttachPt = itAttach->second; + if ( (0 == idxAttachPt) || (itAttach->first == idxAttachPt) ) + { + bool fWorn = (pAttachPt->getNumObjects() > 0) && + ( (!RlvSettings::getHideLockedAttach()) || (RlvForceWear::isForceDetachable(pAttachPt, true, rlvCmd.getObjectID())) ); + strReply.push_back( (fWorn) ? '1' : '0' ); + } + } + return RLV_RET_SUCCESS; +} + +// Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a +ERlvCmdRet RlvHandler::onGetAttachNames(const RlvCommand& rlvCmd, std::string& strReply) const +{ + RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType()); + RLV_ASSERT( (RLV_BHVR_GETATTACHNAMES == rlvCmd.getBehaviourType()) || (RLV_BHVR_GETADDATTACHNAMES == rlvCmd.getBehaviourType()) || + (RLV_BHVR_GETREMATTACHNAMES == rlvCmd.getBehaviourType()) ); + + if (!isAgentAvatarValid()) + return RLV_RET_FAILED; + + ERlvAttachGroupType eAttachGroup = rlvAttachGroupFromString(rlvCmd.getOption()); + for (LLVOAvatar::attachment_map_t::const_iterator itAttach = gAgentAvatarp->mAttachmentPoints.begin(); + itAttach != gAgentAvatarp->mAttachmentPoints.end(); ++itAttach) + { + const LLViewerJointAttachment* pAttachPt = itAttach->second; + if ( (RLV_ATTACHGROUP_INVALID == eAttachGroup) || (rlvAttachGroupFromIndex(pAttachPt->getGroup()) == eAttachGroup) ) + { + bool fAdd = false; + switch (rlvCmd.getBehaviourType()) + { + case RLV_BHVR_GETATTACHNAMES: // Every attachment point that has an attached object + fAdd = (pAttachPt->getNumObjects() > 0); + break; + case RLV_BHVR_GETADDATTACHNAMES: // Every attachment point that can be attached to (wear replace OR wear add) + fAdd = (gRlvAttachmentLocks.canAttach(pAttachPt) & RLV_WEAR); + break; + case RLV_BHVR_GETREMATTACHNAMES: // Every attachment point that has at least one attachment that can be force-detached + fAdd = RlvForceWear::isForceDetachable(pAttachPt); + break; + default: + break; + } + + if (fAdd) + { + if (!strReply.empty()) + strReply.push_back(','); + strReply.append(pAttachPt->getName()); + } + } + } + return RLV_RET_SUCCESS; +} + +// Checked: 2010-03-09 (RLVa-1.2.0a) | Modified: RLVa-1.1.0f +ERlvCmdRet RlvHandler::onGetInv(const RlvCommand& rlvCmd, std::string& strReply) const +{ + RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType()); + RLV_ASSERT(RLV_BHVR_GETINV == rlvCmd.getBehaviourType()); + + const LLViewerInventoryCategory* pFolder = RlvInventory::instance().getSharedFolder(rlvCmd.getOption()); + if (!pFolder) + return (RlvInventory::instance().getSharedRoot() != NULL) ? RLV_RET_FAILED_OPTION : RLV_RET_FAILED_NOSHAREDROOT; + + LLInventoryModel::cat_array_t* pFolders; LLInventoryModel::item_array_t* pItems; + gInventory.getDirectDescendentsOf(pFolder->getUUID(), pFolders, pItems); + if (!pFolders) + return RLV_RET_FAILED; + + for (S32 idxFolder = 0, cntFolder = pFolders->count(); idxFolder < cntFolder; idxFolder++) + { + // Return all folders that: + // - aren't hidden + // - aren't a folded folder (only really matters when "Enable Legacy Naming" is enabled - see related blog post) + // (we can skip checking for .<composite> folders since the ones we'll want to hide start with '.' anyway) + const std::string& strFolder = pFolders->get(idxFolder)->getName(); + if ( (!strFolder.empty()) && (RLV_FOLDER_PREFIX_HIDDEN != strFolder[0]) && + (!RlvInventory::isFoldedFolder(pFolders->get(idxFolder).get(), false)) ) + { + if (!strReply.empty()) + strReply.push_back(','); + strReply += strFolder; + } + } + return RLV_RET_SUCCESS; +} + +struct rlv_wear_info { U32 cntWorn, cntTotal, cntChildWorn, cntChildTotal; }; + +// Checked: 2010-04-05 (RLVa-1.2.0d) | Modified: RLVa-1.1.0f +ERlvCmdRet RlvHandler::onGetInvWorn(const RlvCommand& rlvCmd, std::string& strReply) const +{ + // Sanity check - gAgentAvatarp can't be NULL [see RlvForceWear::isWearingItem()] + if (!isAgentAvatarValid()) + return RLV_RET_FAILED; + // Sanity check - folder should exist + LLViewerInventoryCategory* pFolder = RlvInventory::instance().getSharedFolder(rlvCmd.getOption()); + if (!pFolder) + return (RlvInventory::instance().getSharedRoot() != NULL) ? RLV_RET_FAILED_OPTION : RLV_RET_FAILED_NOSHAREDROOT; + + // Collect everything @attachall would be attaching + LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items; + RlvWearableItemCollector f(pFolder, RlvForceWear::ACTION_WEAR_REPLACE, RlvForceWear::FLAG_MATCHALL); + gInventory.collectDescendentsIf(pFolder->getUUID(), folders, items, FALSE, f, TRUE); + + rlv_wear_info wi = {0}; + + // Add all the folders to a lookup map + std::map<LLUUID, rlv_wear_info> mapFolders; + mapFolders.insert(std::pair<LLUUID, rlv_wear_info>(pFolder->getUUID(), wi)); + for (S32 idxFolder = 0, cntFolder = folders.count(); idxFolder < cntFolder; idxFolder++) + mapFolders.insert(std::pair<LLUUID, rlv_wear_info>(folders.get(idxFolder)->getUUID(), wi)); + + // Iterate over all the found items + LLViewerInventoryItem* pItem; std::map<LLUUID, rlv_wear_info>::iterator itFolder; + for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++) + { + pItem = items.get(idxItem); + if (!RlvForceWear::isWearableItem(pItem)) + continue; + + // The "folded parent" is the folder this item should be considered a direct descendent of (may or may not match actual parent) + const LLUUID& idParent = f.getFoldedParent(pItem->getParentUUID()); + + // Walk up the tree: sooner or later one of the parents will be a folder in the map + LLViewerInventoryCategory* pParent = gInventory.getCategory(idParent); + while ( (itFolder = mapFolders.find(pParent->getUUID())) == mapFolders.end() ) + pParent = gInventory.getCategory(pParent->getParentUUID()); + + U32 &cntWorn = (idParent == pParent->getUUID()) ? itFolder->second.cntWorn : itFolder->second.cntChildWorn, + &cntTotal = (idParent == pParent->getUUID()) ? itFolder->second.cntTotal : itFolder->second.cntChildTotal; + + if (RlvForceWear::isWearingItem(pItem)) + cntWorn++; + cntTotal++; + } + + // Extract the result for the main folder + itFolder = mapFolders.find(pFolder->getUUID()); + wi.cntWorn = itFolder->second.cntWorn; + wi.cntTotal = itFolder->second.cntTotal; + mapFolders.erase(itFolder); + + // Build the result for each child folder + for (itFolder = mapFolders.begin(); itFolder != mapFolders.end(); ++itFolder) + { + rlv_wear_info& wiFolder = itFolder->second; + + wi.cntChildWorn += wiFolder.cntWorn + wiFolder.cntChildWorn; + wi.cntChildTotal += wiFolder.cntTotal + wiFolder.cntChildTotal; + + strReply += llformat(",%s|%d%d", gInventory.getCategory(itFolder->first)->getName().c_str(), + (0 == wiFolder.cntTotal) ? 0 : (0 == wiFolder.cntWorn) ? 1 : (wiFolder.cntWorn != wiFolder.cntTotal) ? 2 : 3, + (0 == wiFolder.cntChildTotal) ? 0 : (0 == wiFolder.cntChildWorn) ? 1 : (wiFolder.cntChildWorn != wiFolder.cntChildTotal) ? 2 : 3 + ); + } + + // Now just prepend the root and done + strReply = llformat("|%d%d", (0 == wi.cntTotal) ? 0 : (0 == wi.cntWorn) ? 1 : (wi.cntWorn != wi.cntTotal) ? 2 : 3, + (0 == wi.cntChildTotal) ? 0 : (0 == wi.cntChildWorn) ? 1 : (wi.cntChildWorn != wi.cntChildTotal) ? 2: 3) + strReply; + + return RLV_RET_SUCCESS; +} + +// Checked: 2010-03-19 (RLVa-1.4.0a) | Modified: RLVa-1.2.0a +ERlvCmdRet RlvHandler::onGetOutfit(const RlvCommand& rlvCmd, std::string& strReply) const +{ + RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType()); + RLV_ASSERT(RLV_BHVR_GETOUTFIT == rlvCmd.getBehaviourType()); + + // (Compatibility: RLV-1.16.1 will execute @getoutfit=<channel> if <layer> is invalid while we just return failure) + LLWearableType::EType wtType = LLWearableType::WT_INVALID; + if ( (rlvCmd.hasOption()) && ((wtType = LLWearableType::typeNameToType(rlvCmd.getOption())) == LLWearableType::WT_INVALID) ) + return RLV_RET_FAILED_OPTION; + + const LLWearableType::EType wtRlvTypes[] = + { + LLWearableType::WT_GLOVES, LLWearableType::WT_JACKET, LLWearableType::WT_PANTS, LLWearableType::WT_SHIRT, + LLWearableType::WT_SHOES, LLWearableType::WT_SKIRT, LLWearableType::WT_SOCKS, LLWearableType::WT_UNDERPANTS, + LLWearableType::WT_UNDERSHIRT, LLWearableType::WT_SKIN, LLWearableType::WT_EYES, LLWearableType::WT_HAIR, + LLWearableType::WT_SHAPE, LLWearableType::WT_ALPHA, LLWearableType::WT_TATTOO, LLWearableType::WT_PHYSICS + }; + + for (int idxType = 0, cntType = sizeof(wtRlvTypes) / sizeof(LLWearableType::EType); idxType < cntType; idxType++) + { + if ( (LLWearableType::WT_INVALID == wtType) || (wtRlvTypes[idxType] == wtType) ) + { + // We never hide body parts, even if they're "locked" and we're hiding locked layers + // (nor do we hide a layer if the issuing object is the only one that has this layer locked) + bool fWorn = (gAgentWearables.getWearableCount(wtRlvTypes[idxType]) > 0) && + ( (!RlvSettings::getHideLockedLayers()) || + (LLAssetType::AT_BODYPART == LLWearableType::getAssetType(wtRlvTypes[idxType])) || + (RlvForceWear::isForceRemovable(wtRlvTypes[idxType], true, rlvCmd.getObjectID())) ); + strReply.push_back( (fWorn) ? '1' : '0' ); + } + } + return RLV_RET_SUCCESS; +} + +// Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a +ERlvCmdRet RlvHandler::onGetOutfitNames(const RlvCommand& rlvCmd, std::string& strReply) const +{ + RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType()); + RLV_ASSERT( (RLV_BHVR_GETOUTFITNAMES == rlvCmd.getBehaviourType()) || (RLV_BHVR_GETADDOUTFITNAMES == rlvCmd.getBehaviourType()) || + (RLV_BHVR_GETREMOUTFITNAMES == rlvCmd.getBehaviourType()) ); + + // Sanity check - all these commands are optionless + if (rlvCmd.hasOption()) + return RLV_RET_FAILED_OPTION; + + for (int idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++) + { + bool fAdd = false; LLWearableType::EType wtType = (LLWearableType::EType)idxType; + switch (rlvCmd.getBehaviourType()) + { + case RLV_BHVR_GETOUTFITNAMES: // Every layer that has at least one worn wearable + fAdd = (gAgentWearables.getWearableCount(wtType) > 0); + break; + case RLV_BHVR_GETADDOUTFITNAMES: // Every layer that can be worn on (wear replace OR wear add) + fAdd = (gRlvWearableLocks.canWear(wtType) & RLV_WEAR); + break; + case RLV_BHVR_GETREMOUTFITNAMES: // Every layer that has at least one wearable that can be force-removed + fAdd = RlvForceWear::isForceRemovable(wtType); + break; + default: + break; + } + + if (fAdd) + { + if (!strReply.empty()) + strReply.push_back(','); + strReply.append(LLWearableType::getTypeName(wtType)); + } + } + return RLV_RET_SUCCESS; +} + +// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c +ERlvCmdRet RlvHandler::onGetPath(const RlvCommand& rlvCmd, std::string& strReply) const +{ + RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType()); + RLV_ASSERT( (RLV_BHVR_GETPATH == rlvCmd.getBehaviourType()) || (RLV_BHVR_GETPATHNEW == rlvCmd.getBehaviourType()) ); + + RlvCommandOptionGetPath rlvGetPathOption(rlvCmd); + if (!rlvGetPathOption.isValid()) + return RLV_RET_FAILED_OPTION; + + LLInventoryModel::cat_array_t folders; + if (RlvInventory::instance().getPath(rlvGetPathOption.getItemIDs(), folders)) + { + if (RLV_BHVR_GETPATH == rlvCmd.getBehaviourType()) + { + strReply = RlvInventory::instance().getSharedPath(folders.get(0)); + } + else if (RLV_BHVR_GETPATHNEW == rlvCmd.getBehaviourType()) + { + for (S32 idxFolder = 0, cntFolder = folders.count(); idxFolder < cntFolder; idxFolder++) + { + if (!strReply.empty()) + strReply.push_back(','); + strReply += RlvInventory::instance().getSharedPath(folders.get(idxFolder)); + } + } + } + return RLV_RET_SUCCESS; +} + +// ============================================================================ diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h new file mode 100644 index 0000000000000000000000000000000000000000..21d907a32252ae465c0e7c01537440547b57fad2 --- /dev/null +++ b/indra/newview/rlvhandler.h @@ -0,0 +1,276 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#ifndef RLV_HANDLER_H +#define RLV_HANDLER_H + +#include <stack> + +#include "rlvcommon.h" +#if LL_GNUC +#include "rlvhelper.h" // Needed to make GCC happy +#endif // LL_GNUC + +// ============================================================================ + +class RlvHandler : public LLOldEvents::LLSimpleListener +{ +public: + RlvHandler(); + ~RlvHandler(); + + // -------------------------------- + + /* + * Rule checking functions + */ + // NOTE: - to check @detach=n -> (see RlvAttachmentLocks) + // - to check @addattach=n -> (see RlvAttachmentLocks) + // - to check @remattach=n -> (see RlvAttachmentLocks) + // - to check @addoutfit=n -> (see RlvWearableLocks) + // - to check @remoutfit=n -> (see RlvWearableLocks) + // - to check exceptions -> isException() +public: + // Returns TRUE is at least one object contains the specified behaviour (and optional option) + bool hasBehaviour(ERlvBehaviour eBhvr) const { return (eBhvr < RLV_BHVR_COUNT) ? (0 != m_Behaviours[eBhvr]) : false; } + bool hasBehaviour(ERlvBehaviour eBhvr, const std::string& strOption) const; + // Returns TRUE if at least one object (except the specified one) contains the specified behaviour (and optional option) + bool hasBehaviourExcept(ERlvBehaviour eBhvr, const LLUUID& idObj) const; + bool hasBehaviourExcept(ERlvBehaviour eBhvr, const std::string& strOption, const LLUUID& idObj) const; + // Returns TRUE if at least one object in the linkset with specified root ID contains the specified behaviour (and optional option) + bool hasBehaviourRoot(const LLUUID& idObjRoot, ERlvBehaviour eBhvr, const std::string& strOption = LLStringUtil::null) const; + + // Adds or removes an exception for the specified behaviour + void addException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption); + void removeException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption); + // Returns TRUE if the specified behaviour has an added exception + bool hasException(ERlvBehaviour eBhvr) const; + // Returns TRUE if the specified option was added as an exception for the specified behaviour + bool isException(ERlvBehaviour eBhvr, const RlvExceptionOption& varOption, ERlvExceptionCheck typeCheck = RLV_CHECK_DEFAULT) const; + // Returns TRUE if the specified behaviour should behave "permissive" (rather than "strict"/"secure") + bool isPermissive(ERlvBehaviour eBhvr) const; + + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + // Returns TRUE if the composite folder doesn't contain any "locked" items + bool canTakeOffComposite(const LLInventoryCategory* pFolder) const; + // Returns TRUE if the composite folder doesn't replace any "locked" items + bool canWearComposite(const LLInventoryCategory* pFolder) const; + // Returns TRUE if the folder is a composite folder and optionally returns the name + bool getCompositeInfo(const LLInventoryCategory* pFolder, std::string* pstrName) const; + // Returns TRUE if the inventory item belongs to a composite folder and optionally returns the name and composite folder + bool getCompositeInfo(const LLUUID& idItem, std::string* pstrName, LLViewerInventoryCategory** ppFolder) const; + // Returns TRUE if the folder is a composite folder + bool isCompositeFolder(const LLInventoryCategory* pFolder) const { return getCompositeInfo(pFolder, NULL); } + // Returns TRUE if the inventory item belongs to a composite folder + bool isCompositeDescendent(const LLUUID& idItem) const { return getCompositeInfo(idItem, NULL, NULL); } + // Returns TRUE if the inventory item is part of a folded composite folder and should be hidden from @getoufit or @getattach + bool isHiddenCompositeItem(const LLUUID& idItem, const std::string& strItemType) const; + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + + // -------------------------------- + + /* + * Helper functions + */ +public: + // Accessors + const LLUUID& getAgentGroup() const { return m_idAgentGroup; } // @setgroup + bool getCanCancelTp() const { return m_fCanCancelTp; } // @accepttp and @tpto + void setCanCancelTp(bool fAllow) { m_fCanCancelTp = fAllow; } // @accepttp and @tpto + const LLVector3d& getSitSource() const { return m_posSitSource; } // @standtp + void setSitSource(const LLVector3d& posSource) { m_posSitSource = posSource; } // @standtp + + // Command specific helper functions + bool canEdit(const LLViewerObject* pObj) const; // @edit and @editobj + bool canShowHoverText(const LLViewerObject* pObj) const; // @showhovertext* command family + bool canSit(LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero) const; + bool canStand() const; + bool canTeleportViaLure(const LLUUID& idAgent) const; + bool canTouch(const LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero) const; // @touch + bool filterChat(std::string& strUTF8Text, bool fFilterEmote) const; // @sendchat, @recvchat and @redirchat + bool redirectChatOrEmote(const std::string& strUTF8Test) const; // @redirchat and @rediremote + + // Command processing helper functions + ERlvCmdRet processCommand(const LLUUID& idObj, const std::string& strCommand, bool fFromObj); + void processRetainedCommands(ERlvBehaviour eBhvrFilter = RLV_BHVR_UNKNOWN, ERlvParamType eTypeFilter = RLV_TYPE_UNKNOWN); + + // Returns a pointer to the currently executing command (do *not* save this pointer) + const RlvCommand* getCurrentCommand() const { return (!m_CurCommandStack.empty()) ? m_CurCommandStack.top() : NULL; } + // Returns the UUID of the object we're currently executing a command for + const LLUUID& getCurrentObject() const { return (!m_CurObjectStack.empty()) ? m_CurObjectStack.top() : LLUUID::null; } + + // Initialization + static BOOL canDisable(); + static BOOL isEnabled() { return m_fEnabled; } + static BOOL setEnabled(BOOL fEnable); +protected: + void clearState(); + + // -------------------------------- + + /* + * Event handling + */ +public: + // The behaviour signal is triggered whenever a command is successfully processed and resulted in adding or removing a behaviour + typedef boost::signals2::signal<void (ERlvBehaviour, ERlvParamType)> rlv_behaviour_signal_t; + boost::signals2::connection setBehaviourCallback(const rlv_behaviour_signal_t::slot_type& cb ) { return m_OnBehaviour.connect(cb); } + boost::signals2::connection setBehaviourToggleCallback(const rlv_behaviour_signal_t::slot_type& cb ) { return m_OnBehaviourToggle.connect(cb); } + // The command signal is triggered whenever a command is processed + typedef boost::signals2::signal<void (const RlvCommand&, ERlvCmdRet, bool)> rlv_command_signal_t; + boost::signals2::connection setCommandCallback(const rlv_command_signal_t::slot_type& cb ) { return m_OnCommand.connect(cb); } + + void addCommandHandler(RlvCommandHandler* pHandler); + void removeCommandHandler(RlvCommandHandler* pHandler); +protected: + void clearCommandHandlers(); + bool notifyCommandHandlers(rlvCommandHandler f, const RlvCommand& rlvCmd, ERlvCmdRet& eRet, bool fNotifyAll) const; + + // Externally invoked event handlers +public: + bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& sdUserdata); // Implementation of public LLSimpleListener + void onAttach(const LLViewerObject* pAttachObj, const LLViewerJointAttachment* pAttachPt); + void onDetach(const LLViewerObject* pAttachObj, const LLViewerJointAttachment* pAttachPt); + bool onGC(); + void onLoginComplete(); + void onSitOrStand(bool fSitting); + void onTeleportFailed(); + void onTeleportFinished(const LLVector3d& posArrival); + static void onIdleStartup(void* pParam); + + /* + * Command processing + */ +protected: + ERlvCmdRet processCommand(const RlvCommand& rlvCmd, bool fFromObj); + ERlvCmdRet processClearCommand(const RlvCommand& rlvCmd); + + // Command handlers (RLV_TYPE_ADD and RLV_TYPE_CLEAR) + ERlvCmdRet processAddRemCommand(const RlvCommand& rlvCmd); + ERlvCmdRet onAddRemAttach(const RlvCommand& rlvCmd, bool& fRefCount); + ERlvCmdRet onAddRemDetach(const RlvCommand& rlvCmd, bool& fRefCount); + ERlvCmdRet onAddRemFolderLock(const RlvCommand& rlvCmd, bool& fRefCount); + ERlvCmdRet onAddRemFolderLockException(const RlvCommand& rlvCmd, bool& fRefCount); + // Command handlers (RLV_TYPE_FORCE) + ERlvCmdRet processForceCommand(const RlvCommand& rlvCmd) const; + ERlvCmdRet onForceRemAttach(const RlvCommand& rlvCmd) const; + ERlvCmdRet onForceRemOutfit(const RlvCommand& rlvCmd) const; + ERlvCmdRet onForceGroup(const RlvCommand& rlvCmd) const; + ERlvCmdRet onForceSit(const RlvCommand& rlvCmd) const; + ERlvCmdRet onForceWear(const LLViewerInventoryCategory* pFolder, ERlvBehaviour eBhvr) const; + void onForceWearCallback(const uuid_vec_t& idItems, ERlvBehaviour eBhvr) const; + // Command handlers (RLV_TYPE_REPLY) + ERlvCmdRet processReplyCommand(const RlvCommand& rlvCmd) const; + ERlvCmdRet onFindFolder(const RlvCommand& rlvCmd, std::string& strReply) const; + ERlvCmdRet onGetAttach(const RlvCommand& rlvCmd, std::string& strReply) const; + ERlvCmdRet onGetAttachNames(const RlvCommand& rlvCmd, std::string& strReply) const; + ERlvCmdRet onGetInv(const RlvCommand& rlvCmd, std::string& strReply) const; + ERlvCmdRet onGetInvWorn(const RlvCommand& rlvCmd, std::string& strReply) const; + ERlvCmdRet onGetOutfit(const RlvCommand& rlvCmd, std::string& strReply) const; + ERlvCmdRet onGetOutfitNames(const RlvCommand& rlvCmd, std::string& strReply) const; + ERlvCmdRet onGetPath(const RlvCommand& rlvCmd, std::string& strReply) const; + + // -------------------------------- + + /* + * Member variables + */ +public: + typedef std::map<LLUUID, RlvObject> rlv_object_map_t; + typedef std::multimap<ERlvBehaviour, RlvException> rlv_exception_map_t; +protected: + rlv_object_map_t m_Objects; // Map of objects that have active restrictions (idObj -> RlvObject) + rlv_exception_map_t m_Exceptions; // Map of currently active restriction exceptions (ERlvBehaviour -> RlvException) + S16 m_Behaviours[RLV_BHVR_COUNT]; + + rlv_command_list_t m_Retained; + RlvGCTimer* m_pGCTimer; + + std::stack<const RlvCommand*> m_CurCommandStack;// Convenience (see @tpto) + std::stack<LLUUID> m_CurObjectStack; // Convenience (see @tpto) + + rlv_behaviour_signal_t m_OnBehaviour; + rlv_behaviour_signal_t m_OnBehaviourToggle; + rlv_command_signal_t m_OnCommand; + mutable std::list<RlvCommandHandler*> m_CommandHandlers; + + static BOOL m_fEnabled; // Use setEnabled() to toggle this + + bool m_fCanCancelTp; // @accepttp=n and @tpto=force + mutable LLVector3d m_posSitSource; // @standtp=n (mutable because onForceXXX handles are all declared as const) + mutable LLUUID m_idAgentGroup; // @setgroup=n + + friend class RlvSharedRootFetcher; // Fetcher needs access to m_fFetchComplete + friend class RlvGCTimer; // Timer clear its own point at destruction + + // -------------------------------- + + /* + * Internal access functions used by unit tests + */ +public: + const rlv_object_map_t* getObjectMap() const { return &m_Objects; } + //const rlv_exception_map_t* getExceptionMap() const { return &m_Exceptions; } +}; + +typedef RlvHandler rlv_handler_t; +extern rlv_handler_t gRlvHandler; + +// ============================================================================ +// Inlined member functions +// + +// Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c +inline bool RlvHandler::canEdit(const LLViewerObject* pObj) const +{ + // The specified object can be edited if: + // - not generally restricted from editing (or the object's root is an exception) + // - not specifically restricted from editing this object's root + return + (pObj) && + ((!hasBehaviour(RLV_BHVR_EDIT)) || (isException(RLV_BHVR_EDIT, pObj->getRootEdit()->getID()))) && + ((!hasBehaviour(RLV_BHVR_EDITOBJ)) || (!isException(RLV_BHVR_EDITOBJ, pObj->getRootEdit()->getID()))); +} + +// Checked: 2010-03-27 (RLVa-1.4.0a) | Modified: RLVa-1.0.0f +inline bool RlvHandler::canShowHoverText(const LLViewerObject *pObj) const +{ + return ( (!pObj) || (LL_PCODE_VOLUME != pObj->getPCode()) || + !( (hasBehaviour(RLV_BHVR_SHOWHOVERTEXTALL)) || + ( (hasBehaviour(RLV_BHVR_SHOWHOVERTEXTWORLD)) && (!pObj->isHUDAttachment()) ) || + ( (hasBehaviour(RLV_BHVR_SHOWHOVERTEXTHUD)) && (pObj->isHUDAttachment()) ) || + (isException(RLV_BHVR_SHOWHOVERTEXT, pObj->getID(), RLV_CHECK_PERMISSIVE)) ) ); +} + +// Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c +inline bool RlvHandler::canTeleportViaLure(const LLUUID& idAgent) const +{ + return ((!hasBehaviour(RLV_BHVR_TPLURE)) || (isException(RLV_BHVR_TPLURE, idAgent))) && (canStand()); +} + +inline bool RlvHandler::hasBehaviour(ERlvBehaviour eBhvr, const std::string& strOption) const +{ + return hasBehaviourExcept(eBhvr, strOption, LLUUID::null); +} + +inline bool RlvHandler::hasBehaviourExcept(ERlvBehaviour eBhvr, const LLUUID& idObj) const +{ + return hasBehaviourExcept(eBhvr, LLStringUtil::null, idObj); +} + +// ============================================================================ + +#endif // RLV_HANDLER_H diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6bfc6137c0e03bebc0af6d6cca3aa48da43d2e06 --- /dev/null +++ b/indra/newview/rlvhelper.cpp @@ -0,0 +1,1227 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#include "llviewerprecompiledheaders.h" +#include "llagent.h" +#include "llagentwearables.h" +#include "llappearancemgr.h" +#include "llattachmentsmgr.h" +#include "llgesturemgr.h" +#include "llnotificationsutil.h" +#include "llviewerobject.h" +#include "llviewerobjectlist.h" +#include "llwlparammanager.h" + +#include "rlvhelper.h" +#include "rlvhandler.h" +#include "rlvinventory.h" + +#include <boost/algorithm/string.hpp> + +// ============================================================================ +// RlvCommmand +// + +RlvCommand::bhvr_map_t RlvCommand::m_BhvrMap; + +// Checked: 2009-12-27 (RLVa-1.1.0k) | Modified: RLVa-1.1.0k +RlvCommand::RlvCommand(const LLUUID& idObj, const std::string& strCommand) + : m_fValid(false), m_idObj(idObj), m_eBehaviour(RLV_BHVR_UNKNOWN), m_fStrict(false), m_eParamType(RLV_TYPE_UNKNOWN), m_eRet(RLV_RET_UNKNOWN) +{ + if ((m_fValid = parseCommand(strCommand, m_strBehaviour, m_strOption, m_strParam))) + { + S32 nTemp = 0; + if ( ("n" == m_strParam) || ("add" == m_strParam) ) + m_eParamType = RLV_TYPE_ADD; + else if ( ("y" == m_strParam) || ("rem" == m_strParam) ) + m_eParamType = RLV_TYPE_REMOVE; + else if (m_strBehaviour == "clear") // clear is the odd one out so just make it its own type + m_eParamType = RLV_TYPE_CLEAR; + else if ("force" == m_strParam) + m_eParamType = RLV_TYPE_FORCE; + else if (LLStringUtil::convertToS32(m_strParam, nTemp)) // Assume it's a reply command if we can convert <param> to an S32 + m_eParamType = RLV_TYPE_REPLY; + else + { + m_eParamType = RLV_TYPE_UNKNOWN; + m_fValid = false; + } + } + + if (!m_fValid) + { + m_strBehaviour = m_strOption = m_strParam = ""; + return; + } + + // HACK: all those @*overorreplace synonyms are rather tedious (and error-prone) to deal with so replace them their equivalent + if ( (RLV_TYPE_FORCE == m_eParamType) && + (m_strBehaviour.length() > 13) && (m_strBehaviour.length() - 13 == m_strBehaviour.rfind("overorreplace")) ) + { + m_strBehaviour.erase(m_strBehaviour.length() - 13, 13); + } + // HACK: all those @addoutfit* synonyms are rather tedious (and error-prone) to deal with so replace them their @attach* equivalent + if ( (RLV_TYPE_FORCE == m_eParamType) && (0 == m_strBehaviour.find("addoutfit")) ) + { + m_strBehaviour.replace(0, 9, "attach"); + } + m_eBehaviour = getBehaviourFromString(m_strBehaviour, &m_fStrict); +} + + +bool RlvCommand::parseCommand(const std::string& strCommand, std::string& strBehaviour, std::string& strOption, std::string& strParam) +{ + // (See behaviour notes for the command parsing truth table) + + // Format: <behaviour>[:<option>]=<param> + int idxParam = strCommand.find('='); + int idxOption = (idxParam > 0) ? strCommand.find(':') : -1; + if (idxOption > idxParam - 1) + idxOption = -1; + + // If <behaviour> is missing it's always an improperly formatted command + if ( (0 == idxOption) || (0 == idxParam) ) + return false; + + strBehaviour = strCommand.substr(0, (-1 != idxOption) ? idxOption : idxParam); + strOption = strParam = ""; + + // If <param> is missing it's an improperly formatted command + if ( (-1 == idxParam) || ((int)strCommand.length() - 1 == idxParam) ) + { + // Unless "<behaviour> == "clear" AND (idxOption == 0)" + // OR <behaviour> == "clear" AND (idxParam != 0) [see table above] + if ( ("clear" == strBehaviour) && ( (!idxOption) || (idxParam) ) ) + return true; + return false; + } + + if ( (-1 != idxOption) && (idxOption + 1 != idxParam) ) + strOption = strCommand.substr(idxOption + 1, idxParam - idxOption - 1); + strParam = strCommand.substr(idxParam + 1); + + return true; +} + +// Checked: 2009-12-05 (RLVa-1.1.0h) | Added: RLVa-1.1.0h +ERlvBehaviour RlvCommand::getBehaviourFromString(const std::string& strBhvr, bool* pfStrict /*=NULL*/) +{ + std::string::size_type idxStrict = strBhvr.find("_sec"); + bool fStrict = (std::string::npos != idxStrict) && (idxStrict + 4 == strBhvr.length()); + if (pfStrict) + *pfStrict = fStrict; + + RLV_ASSERT(m_BhvrMap.size() > 0); + bhvr_map_t::const_iterator itBhvr = m_BhvrMap.find( (!fStrict) ? strBhvr : strBhvr.substr(0, idxStrict)); + if ( (itBhvr != m_BhvrMap.end()) && ((!fStrict) || (hasStrictVariant(itBhvr->second))) ) + return itBhvr->second; + return RLV_BHVR_UNKNOWN; +} + +// Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c +bool RlvCommand::getCommands(bhvr_map_t& cmdList, const std::string &strMatch) +{ + if (strMatch.empty()) + return false; + cmdList.clear(); + + RLV_ASSERT(m_BhvrMap.size() > 0); + for (bhvr_map_t::const_iterator itBhvr = m_BhvrMap.begin(); itBhvr != m_BhvrMap.end(); ++itBhvr) + { + std::string strCmd = itBhvr->first; ERlvBehaviour eBhvr = itBhvr->second; + if (std::string::npos != strCmd.find(strMatch)) + cmdList.insert(std::pair<std::string, ERlvBehaviour>(strCmd, eBhvr)); + if ( (hasStrictVariant(eBhvr)) && (std::string::npos != strCmd.append("_sec").find(strMatch)) ) + cmdList.insert(std::pair<std::string, ERlvBehaviour>(strCmd, eBhvr)); + } + return (0 != cmdList.size()); +} + +// Checked: 2010-02-27 (RLVa-1.2.0a) | Modified: RLVa-1.1.0h +void RlvCommand::initLookupTable() +{ + static bool fInitialized = false; + if (!fInitialized) + { + // NOTE: keep this matched with the enumeration at all times + std::string arBehaviours[RLV_BHVR_COUNT] = + { + "detach", "attach", "addattach", "remattach", "addoutfit", "remoutfit", "sharedwear", "sharedunwear", + "unsharedwear", "unsharedunwear", "emote", "sendchat", "recvchat", "recvchatfrom", "recvemote", "recvemotefrom", + "redirchat", "rediremote", "chatwhisper", "chatnormal", "chatshout", "sendchannel", "sendim", "sendimto", + "recvim", "recvimfrom", "startim", "startimto", "permissive", "notify", "showinv", "showminimap", "showworldmap", "showloc", + "shownames", "showhovertext", "showhovertexthud", "showhovertextworld", "showhovertextall", "tplm", "tploc", "tplure", + "viewnote", "viewscript", "viewtexture", "acceptpermission", "accepttp", "allowidle", "edit", "editobj", "rez", "fartouch", + "interact", "touchthis", "touchattach", "touchattachself", "touchattachother", "touchhud", "touchworld", "touchall", + "touchme", "fly", "setgroup", "unsit", "sit", "sittp", "standtp", "setdebug", "setenv", "alwaysrun", "temprun", "detachme", + "attachover", "attachthis", "attachthisover", "attachthis_except", "detachthis", "detachthis_except", "attachall", + "attachallover", "detachall", "attachallthis", "attachallthis_except", "attachallthisover", "detachallthis", + "detachallthis_except", "adjustheight", "tpto", "version", "versionnew", "versionnum", "getattach", "getattachnames", + "getaddattachnames", "getremattachnames", "getoutfit", "getoutfitnames", "getaddoutfitnames", "getremoutfitnames", + "findfolder", "findfolders", "getpath", "getpathnew", "getinv", "getinvworn", "getgroup", "getsitid", "getcommand", + "getstatus", "getstatusall" + }; + + for (int idxBvhr = 0; idxBvhr < RLV_BHVR_COUNT; idxBvhr++) + m_BhvrMap.insert(std::pair<std::string, ERlvBehaviour>(arBehaviours[idxBvhr], (ERlvBehaviour)idxBvhr)); + + fInitialized = true; + } +} + +// ============================================================================ +// RlvCommandOption structures +// + +// Checked: 2010-09-28 (RLVa-1.2.1c) | Added: RLVa-1.2.1c +RlvCommandOptionGeneric::RlvCommandOptionGeneric(const std::string& strOption) +{ + LLWearableType::EType wtType(LLWearableType::WT_INVALID); LLUUID idOption; ERlvAttachGroupType eAttachGroup(RLV_ATTACHGROUP_INVALID); + LLViewerJointAttachment* pAttachPt = NULL; LLViewerInventoryCategory* pFolder = NULL; + + if (!(m_fEmpty = strOption.empty())) // <option> could be an empty string + { + if ( ((wtType = LLWearableType::typeNameToType(strOption)) != LLWearableType::WT_INVALID) && (wtType != LLWearableType::WT_NONE) ) + m_varOption = wtType; // ... or specify a (valid) clothing layer + else if ((pAttachPt = RlvAttachPtLookup::getAttachPoint(strOption)) != NULL) + m_varOption = pAttachPt; // ... or specify an attachment point + else if ( ((UUID_STR_LENGTH - 1) == strOption.length()) && (idOption.set(strOption)) ) + m_varOption = idOption; // ... or specify an UUID + else if ((pFolder = RlvInventory::instance().getSharedFolder(strOption)) != NULL) + m_varOption = pFolder; // ... or specify a shared folder path + else if ((eAttachGroup = rlvAttachGroupFromString(strOption)) != RLV_ATTACHGROUP_INVALID) + m_varOption = eAttachGroup; // ... or specify an attachment point group + else + m_varOption = strOption; // ... or it might just be a string + } + m_fValid = true; +} + +// Checked: 2012-07-28 (RLVa-1.4.7) +class RlvCommandOptionGetPathCallback +{ +public: + RlvCommandOptionGetPathCallback(const LLUUID& idAttachObj, RlvCommandOptionGetPath::getpath_callback_t cb) + : mObjectId(idAttachObj), mCallback(cb) + { + if (isAgentAvatarValid()) + mAttachmentConnection = gAgentAvatarp->setAttachmentCallback(boost::bind(&RlvCommandOptionGetPathCallback::onAttachment, this, _1, _3)); + gIdleCallbacks.addFunction(&onIdle, this); + } + + ~RlvCommandOptionGetPathCallback() + { + if (mAttachmentConnection.connected()) + mAttachmentConnection.disconnect(); + gIdleCallbacks.deleteFunction(&onIdle, this); + } + + void onAttachment(LLViewerObject* pAttachObj, LLVOAvatarSelf::EAttachAction eAction) + { + if ( (LLVOAvatarSelf::ACTION_ATTACH == eAction) && (pAttachObj->getID() == mObjectId) ) + { + uuid_vec_t idItems(1, pAttachObj->getAttachmentItemID()); + mCallback(idItems); + delete this; + } + } + + static void onIdle(void* pData) + { + RlvCommandOptionGetPathCallback* pInstance = reinterpret_cast<RlvCommandOptionGetPathCallback*>(pData); + if (pInstance->mExpirationTimer.getElapsedTimeF32() > 30.0f) + delete pInstance; + } + +protected: + LLUUID mObjectId; + RlvCommandOptionGetPath::getpath_callback_t mCallback; + boost::signals2::connection mAttachmentConnection; + LLFrameTimer mExpirationTimer; +}; + +// Checked: 2010-11-30 (RLVa-1.3.0b) | Modified: RLVa-1.3.0b +RlvCommandOptionGetPath::RlvCommandOptionGetPath(const RlvCommand& rlvCmd, getpath_callback_t cb) + : m_fCallback(false) +{ + m_fValid = true; // Assume the option will be a valid one until we find out otherwise + + // @getpath[:<option>]=<channel> => <option> is transformed to a list of inventory item UUIDs to get the path of + RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption()); + if (rlvCmdOption.isWearableType()) // <option> can be a clothing layer + { + getItemIDs(rlvCmdOption.getWearableType(), m_idItems); + } + else if (rlvCmdOption.isAttachmentPoint()) // ... or it can specify an attachment point + { + getItemIDs(rlvCmdOption.getAttachmentPoint(), m_idItems); + } + else if (rlvCmdOption.isEmpty()) // ... or it can be empty (in which case we act on the object that issued the command) + { + const LLViewerObject* pObj = gObjectList.findObject(rlvCmd.getObjectID()); + if (pObj) + { + if (pObj->isAttachment()) + m_idItems.push_back(pObj->getAttachmentItemID()); + } + else if (!cb.empty()) + { + new RlvCommandOptionGetPathCallback(rlvCmd.getObjectID(), cb); + m_fCallback = true; + return; + } + } + else // ... but anything else isn't a valid option + { + m_fValid = false; + return; + } + + if (!cb.empty()) + { + cb(getItemIDs()); + } +} + +// Checked: 2013-10-12 (RLVa-1.4.9) +bool RlvCommandOptionGetPath::getItemIDs(const LLViewerJointAttachment* pAttachPt, uuid_vec_t& idItems) +{ + uuid_vec_t::size_type cntItemsPrev = idItems.size(); + + LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items; + RlvFindAttachmentsOnPoint f(pAttachPt); + gInventory.collectDescendentsIf(LLAppearanceMgr::instance().getCOF(), folders, items, false, f); + for (LLInventoryModel::item_array_t::const_iterator itItem = items.begin(); itItem != items.end(); ++itItem) + { + const LLViewerInventoryItem* pItem = *itItem; + if (pItem) + idItems.push_back(pItem->getLinkedUUID()); + } + + return (cntItemsPrev != idItems.size()); +} + +// Checked: 2013-10-12 (RLVa-1.4.9) +bool RlvCommandOptionGetPath::getItemIDs(LLWearableType::EType wtType, uuid_vec_t& idItems) +{ + uuid_vec_t::size_type cntItemsPrev = idItems.size(); + + LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items; + LLFindWearablesOfType f(wtType); + gInventory.collectDescendentsIf(LLAppearanceMgr::instance().getCOF(), folders, items, false, f); + for (LLInventoryModel::item_array_t::const_iterator itItem = items.begin(); itItem != items.end(); ++itItem) + { + const LLViewerInventoryItem* pItem = *itItem; + if (pItem) + idItems.push_back(pItem->getLinkedUUID()); + } + + return (cntItemsPrev != idItems.size()); +} + +// Checked: 2011-03-28 (RLVa-1.3.0f) | Added: RLVa-1.3.0f +RlvCommandOptionTpTo::RlvCommandOptionTpTo(const RlvCommand &rlvCmd) +{ + std::vector<std::string> cmdTokens; + boost::split(cmdTokens, rlvCmd.getOption(), boost::is_any_of(std::string("/"))); + + m_fValid = (3 == cmdTokens.size()); + for (int idxAxis = 0; (idxAxis < 3) && (m_fValid); idxAxis++) + m_fValid &= (bool)LLStringUtil::convertToF64(cmdTokens[idxAxis], m_posGlobal[idxAxis]); +} + +// ========================================================================= +// RlvObject +// + +RlvObject::RlvObject(const LLUUID& idObj) : m_idObj(idObj), m_nLookupMisses(0) +{ + LLViewerObject* pObj = gObjectList.findObject(idObj); + m_fLookup = (NULL != pObj); + m_idxAttachPt = (pObj) ? ATTACHMENT_ID_FROM_STATE(pObj->getState()) : 0; + m_idRoot = (pObj) ? pObj->getRootEdit()->getID() : LLUUID::null; +} + +bool RlvObject::addCommand(const RlvCommand& rlvCmd) +{ + RLV_ASSERT(RLV_TYPE_ADD == rlvCmd.getParamType()); + + // Don't add duplicate commands for this object (ie @detach=n followed by another @detach=n later on) + for (rlv_command_list_t::iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) + { + if ( (itCmd->getBehaviour() == rlvCmd.getBehaviour()) && (itCmd->getOption() == rlvCmd.getOption()) && + (itCmd->isStrict() == rlvCmd.isStrict() ) ) + { + return false; + } + } + + // Now that we know it's not a duplicate, add it to the end of the list + m_Commands.push_back(rlvCmd); + + return true; +} + +bool RlvObject::removeCommand(const RlvCommand& rlvCmd) +{ + RLV_ASSERT(RLV_TYPE_REMOVE == rlvCmd.getParamType()); + + for (rlv_command_list_t::iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) + { + //if (*itCmd == rlvCmd) <- commands will never be equal since one is an add and the other is a remove *rolls eyes* + if ( (itCmd->getBehaviour() == rlvCmd.getBehaviour()) && (itCmd->getOption() == rlvCmd.getOption()) && + (itCmd->isStrict() == rlvCmd.isStrict() ) ) + { + m_Commands.erase(itCmd); + return true; + } + } + return false; // Command was never added so nothing to remove now +} + +// Checked: 2011-05-23 (RLVa-1.3.1c) | Added: RLVa-1.3.1c +void RlvObject::setCommandRet(const RlvCommand& rlvCmd, ERlvCmdRet eRet) +{ + for (rlv_command_list_t::iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) + { + if (*itCmd == rlvCmd) + { + itCmd->m_eRet = eRet; + break; + } + } +} + +bool RlvObject::hasBehaviour(ERlvBehaviour eBehaviour, bool fStrictOnly) const +{ + for (rlv_command_list_t::const_iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) + if ( (itCmd->getBehaviourType() == eBehaviour) && (itCmd->getOption().empty()) && ((!fStrictOnly) || (itCmd->isStrict())) ) + return true; + return false; +} + +bool RlvObject::hasBehaviour(ERlvBehaviour eBehaviour, const std::string& strOption, bool fStrictOnly) const +{ + for (rlv_command_list_t::const_iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) + if ( (itCmd->getBehaviourType() == eBehaviour) && (itCmd->getOption() == strOption) && ((!fStrictOnly) || (itCmd->isStrict())) ) + return true; + return false; +} + +// Checked: 2009-11-27 (RLVa-1.1.0f) | Modified: RLVa-1.1.0f +std::string RlvObject::getStatusString(const std::string& strMatch) const +{ + std::string strStatus, strCmd; + + for (rlv_command_list_t::const_iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) + { + strCmd = itCmd->asString(); + if ( (strMatch.empty()) || (std::string::npos != strCmd.find(strMatch)) ) + { + strStatus.push_back('/'); + strStatus += strCmd; + } + } + + return strStatus; +} + +// ============================================================================ +// RlvForceWear +// + +// Checked: 2010-04-05 (RLVa-1.2.0d) | Modified: RLVa-1.2.0d +bool RlvForceWear::isWearingItem(const LLInventoryItem* pItem) +{ + if (pItem) + { + switch (pItem->getActualType()) + { + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_CLOTHING: + return gAgentWearables.isWearingItem(pItem->getUUID()); + case LLAssetType::AT_OBJECT: + return (isAgentAvatarValid()) && (gAgentAvatarp->isWearingAttachment(pItem->getUUID())); + case LLAssetType::AT_GESTURE: + return LLGestureMgr::instance().isGestureActive(pItem->getUUID()); + case LLAssetType::AT_LINK: + return isWearingItem(gInventory.getItem(pItem->getLinkedUUID())); + default: + break; + } + } + return false; +} + +// Checked: 2010-03-21 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvForceWear::forceFolder(const LLViewerInventoryCategory* pFolder, EWearAction eAction, EWearFlags eFlags) +{ + // [See LLWearableBridge::wearOnAvatar(): don't wear anything until initial wearables are loaded, can destroy clothing items] + if (!gAgentWearables.areWearablesLoaded()) + { + LLNotificationsUtil::add("CanNotChangeAppearanceUntilLoaded"); + return; + } + if (!isAgentAvatarValid()) + return; + + // Grab a list of all the items we'll be wearing/attaching + LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items; + RlvWearableItemCollector f(pFolder, eAction, eFlags); + gInventory.collectDescendentsIf(pFolder->getUUID(), folders, items, FALSE, f, TRUE); + + // TRUE if we've already encountered this LLWearableType::EType (used only on wear actions and only for AT_CLOTHING) + bool fSeenWType[LLWearableType::WT_COUNT] = { false }; + + EWearAction eCurAction = eAction; + for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++) + { + LLViewerInventoryItem* pRlvItem = items.get(idxItem); + LLViewerInventoryItem* pItem = (LLAssetType::AT_LINK == pRlvItem->getActualType()) ? pRlvItem->getLinkedItem() : pRlvItem; + + // If it's wearable it should be worn on detach +// if ( (ACTION_DETACH == eAction) && (isWearableItem(pItem)) && (!isWearingItem(pItem)) ) +// continue; + + // Each folder can specify its own EWearAction override + if (isWearAction(eAction)) + eCurAction = f.getWearAction(pRlvItem->getParentUUID()); + else + eCurAction = eAction; + + // NOTES: * if there are composite items then RlvWearableItemCollector made sure they can be worn (or taken off depending) + // * some scripts issue @remattach=force,attach:worn-items=force so we need to attach items even if they're currently worn + switch (pItem->getType()) + { + case LLAssetType::AT_BODYPART: + RLV_ASSERT(isWearAction(eAction)); // RlvWearableItemCollector shouldn't be supplying us with body parts on detach + case LLAssetType::AT_CLOTHING: + if (isWearAction(eAction)) + { + // The first time we encounter any given clothing type we use 'eCurAction' (replace or add) + // The second time we encounter a given clothing type we'll always add (rather than replace the previous iteration) + eCurAction = (!fSeenWType[pItem->getWearableType()]) ? eCurAction : ACTION_WEAR_ADD; + + ERlvWearMask eWearMask = gRlvWearableLocks.canWear(pRlvItem); + if ( ((ACTION_WEAR_REPLACE == eCurAction) && (eWearMask & RLV_WEAR_REPLACE)) || + ((ACTION_WEAR_ADD == eCurAction) && (eWearMask & RLV_WEAR_ADD)) ) + { + // The check for whether we're replacing a currently worn composite item happens in onWearableArrived() + if (!isAddWearable(pItem)) + addWearable(pRlvItem, eCurAction); + fSeenWType[pItem->getWearableType()] = true; + } + } + else + { + const LLViewerWearable* pWearable = gAgentWearables.getWearableFromItemID(pItem->getUUID()); + if ( (pWearable) && (isForceRemovable(pWearable, false)) ) + remWearable(pWearable); + } + break; + + case LLAssetType::AT_OBJECT: + if (isWearAction(eAction)) + { + ERlvWearMask eWearMask = gRlvAttachmentLocks.canAttach(pRlvItem); + if ( ((ACTION_WEAR_REPLACE == eCurAction) && (eWearMask & RLV_WEAR_REPLACE)) || + ((ACTION_WEAR_ADD == eCurAction) && (eWearMask & RLV_WEAR_ADD)) ) + { + if (!isAddAttachment(pRlvItem)) + { + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + // We still need to check whether we're about to replace a currently worn composite item + // (which we're not if we're just reattaching an attachment we're already wearing) + LLViewerInventoryCategory* pCompositeFolder = NULL; + if ( (pAttachPt->getObject()) && (RlvSettings::getEnableComposites()) && + (pAttachPt->getItemID() != pItem->getUUID()) && + (gRlvHandler.getCompositeInfo(pAttachPt->getItemID(), NULL, &pCompositeFolder)) ) + { + // If we can't take off the composite folder this item would replace then don't allow it to get attached + if (gRlvHandler.canTakeOffComposite(pCompositeFolder)) + { + forceFolder(pCompositeFolder, ACTION_DETACH, FLAG_DEFAULT); + addAttachment(pRlvItem); + } + } + else + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + { + addAttachment(pRlvItem, eCurAction); + } + } + } + } + else + { + const LLViewerObject* pAttachObj = gAgentAvatarp->getWornAttachment(pItem->getUUID()); + if ( (pAttachObj) && (isForceDetachable(pAttachObj, false)) ) + remAttachment(pAttachObj); + } + break; + + #ifdef RLV_EXTENSION_FORCEWEAR_GESTURES + case LLAssetType::AT_GESTURE: + if (isWearAction(eAction)) + { + if (std::find_if(m_addGestures.begin(), m_addGestures.end(), RlvPredIsEqualOrLinkedItem(pRlvItem)) == m_addGestures.end()) + m_addGestures.push_back(pRlvItem); + } + else + { + if (std::find_if(m_remGestures.begin(), m_remGestures.end(), RlvPredIsEqualOrLinkedItem(pRlvItem)) == m_remGestures.end()) + m_remGestures.push_back(pRlvItem); + } + break; + #endif // RLV_EXTENSION_FORCEWEAR_GESTURES + + default: + break; + } + } +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +bool RlvForceWear::isForceDetachable(const LLViewerObject* pAttachObj, bool fCheckComposite /*=true*/, const LLUUID& idExcept /*=LLUUID::null*/) +{ + // Attachment can be detached by an RLV command if: + // - it's not "remove locked" by anything (or anything except the object specified by pExceptObj) + // - it's strippable + // - composite folders are disabled *or* it isn't part of a composite folder that has at least one item locked + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + LLViewerInventoryCategory* pFolder = NULL; + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + return + ( + (pAttachObj) && (pAttachObj->isAttachment()) + && ( (idExcept.isNull()) ? (!gRlvAttachmentLocks.isLockedAttachment(pAttachObj)) + : (!gRlvAttachmentLocks.isLockedAttachmentExcept(pAttachObj, idExcept)) ) + && (isStrippable(pAttachObj->getAttachmentItemID())) + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + && ( (!fCheckComposite) || (!RlvSettings::getEnableComposites()) || + (!gRlvHandler.getCompositeInfo(pAttachPt->getItemID(), NULL, &pFolder)) || (gRlvHandler.canTakeOffComposite(pFolder)) ) + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + ); +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +bool RlvForceWear::isForceDetachable(const LLViewerJointAttachment* pAttachPt, bool fCheckComposite /*=true*/, const LLUUID& idExcept /*=LLUUID::null*/) +{ + // Attachment point can be detached by an RLV command if there's at least one attachment that can be removed + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) + { + if (isForceDetachable(*itAttachObj, fCheckComposite, idExcept)) + return true; + } + return false; +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.1.0i +void RlvForceWear::forceDetach(const LLViewerObject* pAttachObj) +{ + // Sanity check - no need to process duplicate removes + if ( (!pAttachObj) || (isRemAttachment(pAttachObj)) ) + return; + + if (isForceDetachable(pAttachObj)) + { + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + LLViewerInventoryCategory* pFolder = NULL; + if ( (RlvSettings::getEnableComposites()) && + (gRlvHandler.getCompositeInfo(pAttachPt->getItemID(), NULL, &pFolder)) ) + { + // Attachment belongs to a composite folder so detach the entire folder (if we can take it off) + if (gRlvHandler.canTakeOffComposite(pFolder)) + forceFolder(pFolder, ACTION_DETACH, FLAG_DEFAULT); + } + else + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + { + remAttachment(pAttachObj); + } + } +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +void RlvForceWear::forceDetach(const LLViewerJointAttachment* pAttachPt) +{ + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) + { + forceDetach(*itAttachObj); + } +} + +// Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a +bool RlvForceWear::isForceRemovable(const LLViewerWearable* pWearable, bool fCheckComposite /*=true*/, const LLUUID& idExcept /*=LLUUID::null*/) +{ + // Wearable can be removed by an RLV command if: + // - its asset type is AT_CLOTHING + // - it's not "remove locked" by anything (or anything except the object specified by idExcept) + // - it's strippable + // - composite folders are disabled *or* it isn't part of a composite folder that has at least one item locked + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + LLViewerInventoryCategory* pFolder = NULL; + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + return + ( + (pWearable) && (LLAssetType::AT_CLOTHING == pWearable->getAssetType()) + && ( (idExcept.isNull()) ? !gRlvWearableLocks.isLockedWearable(pWearable) + : !gRlvWearableLocks.isLockedWearableExcept(pWearable, idExcept) ) + && (isStrippable(pWearable->getItemID())) + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + && ( (!fCheckComposite) || (!RlvSettings::getEnableComposites()) || + (!gRlvHandler.getCompositeInfo(pWearable->getItemID(), NULL, &pFolder)) || (gRlvHandler.canTakeOffComposite(pFolder)) ) + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + ); +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +bool RlvForceWear::isForceRemovable(LLWearableType::EType wtType, bool fCheckComposite /*=true*/, const LLUUID& idExcept /*=LLUUID::null*/) +{ + // Wearable type can be removed by an RLV command if there's at least one currently worn wearable that can be removed + for (U32 idxWearable = 0, cntWearable = gAgentWearables.getWearableCount(wtType); idxWearable < cntWearable; idxWearable++) + if (isForceRemovable(gAgentWearables.getViewerWearable(wtType, idxWearable), fCheckComposite, idExcept)) + return true; + return false; +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvForceWear::forceRemove(const LLViewerWearable* pWearable) +{ + // Sanity check - no need to process duplicate removes + if ( (!pWearable) || (isRemWearable(pWearable)) ) + return; + + if (isForceRemovable(pWearable)) + { + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + LLViewerInventoryCategory* pFolder = NULL; + if ( (RlvSettings::getEnableComposites()) && + (gRlvHandler.getCompositeInfo(gAgent.getWearableItem(wtType), NULL, &pFolder)) ) + { + // Wearable belongs to a composite folder so detach the entire folder (if we can take it off) + if (gRlvHandler.canTakeOffComposite(pFolder)) + forceFolder(pFolder, ACTION_DETACH, FLAG_DEFAULT); + } + else + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + { + remWearable(pWearable); + } + } +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +void RlvForceWear::forceRemove(LLWearableType::EType wtType) +{ + for (U32 idxWearable = 0, cntWearable = gAgentWearables.getWearableCount(wtType); idxWearable < cntWearable; idxWearable++) + forceRemove(gAgentWearables.getViewerWearable(wtType, idxWearable)); +} + +// Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a +bool RlvForceWear::isStrippable(const LLInventoryItem* pItem) +{ + // An item is exempt from @detach or @remoutfit if: + // - its name contains "nostrip" (anywhere in the name) + // - its parent folder contains "nostrip" (anywhere in the name) + if (pItem) + { + // If the item is an inventory link then we first examine its target before examining the link itself (and never its name) + if (LLAssetType::AT_LINK == pItem->getActualType()) + { + if (!isStrippable(pItem->getLinkedUUID())) + return false; + } + else + { + if (std::string::npos != pItem->getName().find(RLV_FOLDER_FLAG_NOSTRIP)) + return false; + } + + LLViewerInventoryCategory* pFolder = gInventory.getCategory(pItem->getParentUUID()); + while (pFolder) + { + if (std::string::npos != pFolder->getName().find(RLV_FOLDER_FLAG_NOSTRIP)) + return false; + // If the item's parent is a folded folder then we need to check its parent as well + if ( (gInventory.getRootFolderID() != pFolder->getParentUUID()) && (RlvInventory::isFoldedFolder(pFolder, true)) ) + pFolder = gInventory.getCategory(pFolder->getParentUUID()); + else + pFolder = NULL; + } + } + return true; +} + +// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c +void RlvForceWear::addAttachment(const LLViewerInventoryItem* pItem, EWearAction eAction) +{ + // Remove it from 'm_remAttachments' if it's queued for detaching + const LLViewerObject* pAttachObj = (isAgentAvatarValid()) ? gAgentAvatarp->getWornAttachment(pItem->getLinkedUUID()) : NULL; + if ( (pAttachObj) && (isRemAttachment(pAttachObj)) ) + m_remAttachments.erase(std::remove(m_remAttachments.begin(), m_remAttachments.end(), pAttachObj), m_remAttachments.end()); + + S32 idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(pItem, true); + if (ACTION_WEAR_ADD == eAction) + { + // Insert it at the back if it's not already there + idxAttachPt |= ATTACHMENT_ADD; + if (!isAddAttachment(pItem)) + { + addattachments_map_t::iterator itAddAttachments = m_addAttachments.find(idxAttachPt); + if (itAddAttachments == m_addAttachments.end()) + { + m_addAttachments.insert(addattachment_pair_t(idxAttachPt, LLInventoryModel::item_array_t())); + itAddAttachments = m_addAttachments.find(idxAttachPt); + } + itAddAttachments->second.push_back((LLViewerInventoryItem*)pItem); + } + } + else if (ACTION_WEAR_REPLACE == eAction) + { + // Replace all pending attachments on this attachment point with the specified item (don't clear if it's the default attach point) + addattachments_map_t::iterator itAddAttachments = m_addAttachments.find(idxAttachPt | ATTACHMENT_ADD); + if ( (0 != idxAttachPt) && (itAddAttachments != m_addAttachments.end()) ) + itAddAttachments->second.clear(); + + itAddAttachments = m_addAttachments.find(idxAttachPt); + if (itAddAttachments == m_addAttachments.end()) + { + m_addAttachments.insert(addattachment_pair_t(idxAttachPt, LLInventoryModel::item_array_t())); + itAddAttachments = m_addAttachments.find(idxAttachPt); + } + + if (0 != idxAttachPt) + itAddAttachments->second.clear(); + itAddAttachments->second.push_back((LLViewerInventoryItem*)pItem); + } +} + +// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c +void RlvForceWear::remAttachment(const LLViewerObject* pAttachObj) +{ + // Remove it from 'm_addAttachments' if it's queued for attaching + const LLViewerInventoryItem* pItem = (pAttachObj->isAttachment()) ? gInventory.getItem(pAttachObj->getAttachmentItemID()) : NULL; + if (pItem) + { + addattachments_map_t::iterator itAddAttachments = m_addAttachments.begin(); + while (itAddAttachments != m_addAttachments.end()) + { + LLInventoryModel::item_array_t& wearItems = itAddAttachments->second; + if (std::find_if(wearItems.begin(), wearItems.end(), RlvPredIsEqualOrLinkedItem(pItem)) != wearItems.end()) + wearItems.erase(std::remove_if(wearItems.begin(), wearItems.end(), RlvPredIsEqualOrLinkedItem(pItem)), wearItems.end()); + + if (wearItems.empty()) + m_addAttachments.erase(itAddAttachments++); + else + ++itAddAttachments; + } + } + + // Add it to 'm_remAttachments' if it's not already there + if (!isRemAttachment(pAttachObj)) + { + m_remAttachments.push_back(const_cast<LLViewerObject*>(pAttachObj)); + } +} + +// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c +void RlvForceWear::addWearable(const LLViewerInventoryItem* pItem, EWearAction eAction) +{ + const LLViewerWearable* pWearable = gAgentWearables.getWearableFromItemID(pItem->getLinkedUUID()); + // When replacing remove all currently worn wearables of this type *unless* the item is currently worn + if ( (ACTION_WEAR_REPLACE == eAction) && (!pWearable) ) + forceRemove(pItem->getWearableType()); + // Remove it from 'm_remWearables' if it's pending removal + if ( (pWearable) && (isRemWearable(pWearable)) ) + m_remWearables.erase(std::remove(m_remWearables.begin(), m_remWearables.end(), pWearable), m_remWearables.end()); + + addwearables_map_t::iterator itAddWearables = m_addWearables.find(pItem->getWearableType()); + if (itAddWearables == m_addWearables.end()) + { + m_addWearables.insert(addwearable_pair_t(pItem->getWearableType(), LLInventoryModel::item_array_t())); + itAddWearables = m_addWearables.find(pItem->getWearableType()); + } + + if (ACTION_WEAR_ADD == eAction) // Add it at the back if it's not already there + { + if (!isAddWearable(pItem)) + itAddWearables->second.push_back((LLViewerInventoryItem*)pItem); + } + else if (ACTION_WEAR_REPLACE == eAction) // Replace all pending wearables of this type with the specified item + { + itAddWearables->second.clear(); + itAddWearables->second.push_back((LLViewerInventoryItem*)pItem); + } +} + +// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c +void RlvForceWear::remWearable(const LLViewerWearable* pWearable) +{ + // Remove it from 'm_addWearables' if it's queued for wearing + const LLViewerInventoryItem* pItem = gInventory.getItem(pWearable->getItemID()); + if ( (pItem) && (isAddWearable(pItem)) ) + { + addwearables_map_t::iterator itAddWearables = m_addWearables.find(pItem->getWearableType()); + + LLInventoryModel::item_array_t& wearItems = itAddWearables->second; + wearItems.erase(std::remove_if(wearItems.begin(), wearItems.end(), RlvPredIsEqualOrLinkedItem(pItem)), wearItems.end()); + if (wearItems.empty()) + m_addWearables.erase(itAddWearables); + } + + // Add it to 'm_remWearables' if it's not already there + if (!isRemWearable(pWearable)) + m_remWearables.push_back(pWearable); +} + +// Checked: 2010-09-18 (RLVa-1.2.1) +void RlvForceWear::done() +{ + // Sanity check - don't go through all the motions below only to find out there's nothing to actually do + if ( (m_remWearables.empty()) && (m_remAttachments.empty()) && (m_remGestures.empty()) && + (m_addWearables.empty()) && (m_addAttachments.empty()) && (m_addGestures.empty()) ) + { + return; + } + + LLAppearanceMgr* pAppearanceMgr = LLAppearanceMgr::getInstance(); + + // + // Process removals + // + + // Wearables + if (m_remWearables.size()) + { + for (std::list<const LLViewerWearable*>::const_iterator itWearable = m_remWearables.begin(); itWearable != m_remWearables.end(); ++itWearable) + pAppearanceMgr->removeItemFromAvatar((*itWearable)->getItemID()); + m_remWearables.clear(); + } + + // Gestures + if (m_remGestures.size()) + { + // NOTE: LLGestureMgr::deactivateGesture() will call LLAppearanceMgr::removeCOFItemLinks() for us + for (S32 idxItem = 0, cntItem = m_remGestures.count(); idxItem < cntItem; idxItem++) + LLGestureMgr::instance().deactivateGesture(m_remGestures.get(idxItem)->getUUID()); + m_remGestures.clear(); + } + + // Attachments + if (m_remAttachments.size()) + { + // Don't bother with COF if all we're doing is detaching some attachments (keeps people from rebaking on every @remattach=force) + LLAgentWearables::userRemoveMultipleAttachments(m_remAttachments); + + for (std::vector<LLViewerObject*>::const_iterator itAttachObj = m_remAttachments.begin(); + itAttachObj != m_remAttachments.end(); ++itAttachObj) + { + pAppearanceMgr->removeCOFItemLinks((*itAttachObj)->getAttachmentItemID()); + } + + m_remAttachments.clear(); + } + + // + // Process additions + // + + // Wearables need to be split into AT_BODYPART and AT_CLOTHING for COF + LLInventoryModel::item_array_t addBodyParts, addClothing; + for (addwearables_map_t::const_iterator itAddWearables = m_addWearables.begin(); itAddWearables != m_addWearables.end(); ++itAddWearables) + { + const LLInventoryModel::item_array_t& wearItems = itAddWearables->second; + for (S32 idxItem = 0, cntItem = wearItems.count(); idxItem < cntItem; idxItem++) + { + LLViewerInventoryItem* pItem = wearItems.get(idxItem); + if (!pAppearanceMgr->isLinkInCOF(pItem->getUUID())) // It's important to examine COF here and *not* gAgentWearables + { + if (LLAssetType::AT_BODYPART == pItem->getType()) + addBodyParts.push_back(pItem); + else + addClothing.push_back(pItem); + } + } + } + m_addWearables.clear(); + + // Until LL provides a way for updateCOF to selectively attach add/replace we have to deal with attachments ourselves + for (addattachments_map_t::const_iterator itAddAttachments = m_addAttachments.begin(); + itAddAttachments != m_addAttachments.end(); ++itAddAttachments) + { + const LLInventoryModel::item_array_t& wearItems = itAddAttachments->second; + for (S32 idxItem = 0, cntItem = wearItems.count(); idxItem < cntItem; idxItem++) + { + const LLUUID& idItem = wearItems.get(idxItem)->getLinkedUUID(); + if (gAgentAvatarp->attachmentWasRequested(idItem)) + continue; + gAgentAvatarp->addAttachmentRequest(idItem); + + LLAttachmentsMgr::instance().addAttachment(idItem, itAddAttachments->first & ~ATTACHMENT_ADD, itAddAttachments->first & ATTACHMENT_ADD); + } + } + m_addAttachments.clear(); + + // If there are additions we need to call LLAppearanceManager::updateCOF(), otherwise LLAppearanceManager::updateAppearanceFromCOF() + if ( (!addBodyParts.empty()) || (!addClothing.empty()) || (!m_addGestures.empty()) ) + { + LLInventoryModel::item_array_t addAttachments; + pAppearanceMgr->updateCOF(addBodyParts, addClothing, addAttachments, m_addGestures, true); + + m_addGestures.clear(); + } + + // Since RlvForceWear is a singleton now we want to be sure there aren't any leftovers + RLV_ASSERT( (m_remWearables.empty()) && (m_remAttachments.empty()) && (m_remGestures.empty()) ); + RLV_ASSERT( (m_addWearables.empty()) && (m_addAttachments.empty()) && (m_addGestures.empty()) ); +} + +// Checked: 2010-02-17 (RLVa-1.1.0o) | Modified: RLVa-1.1.0o +/* +void RlvForceWear::onWearableArrived(LLWearable* pWearable, void* pParam) +{ + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + // If this wearable will end up replacing a currently worn one that belongs to a composite folder then we need to detach the composite + LLViewerInventoryCategory* pFolder = NULL; + if ( (RlvSettings::getEnableComposites()) && (pWearable) && (gAgent.getWearable(pWearable->getType())) ) + { + // If we're just rewearing the same item we're already wearing then we're not replacing a composite folder + LLWearableHoldingPattern* pWearData = (LLWearableHoldingPattern*)pParam; LLUUID idItem; + for (LLWearableHoldingPattern::found_list_t::const_iterator itWearable = pWearData->mFoundList.begin(); + itWearable != pWearData->mFoundList.end(); ++itWearable) + { + LLFoundData* pFound = *itWearable; + if (pWearable->getID() == pFound->mAssetID) + { + idItem = pFound->mItemID; + break; + } + } + if ( (idItem.notNull()) && (idItem != gAgent.getWearableItem(pWearable->getType())) && + (gRlvHandler.getCompositeInfo(gAgent.getWearableItem(pWearable->getType()), NULL, &pFolder)) ) + { + RlvForceWear rlvWear; + rlvWear.forceFolder(pFolder, ACTION_DETACH, FLAG_DEFAULT); + rlvWear.done(); + } + } + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + + wear_inventory_category_on_avatar_loop(pWearable, pParam); +} +*/ + +// ============================================================================ +// RlvBehaviourNotifyObserver +// + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +RlvBehaviourNotifyHandler::RlvBehaviourNotifyHandler() +{ + // NOTE: the reason we use rlv_command_signal_t instead of the better-suited rlv_behaviour_signal_t is because + // RLV will notify scripts about "invalid" commands so we need to as well + m_ConnCommand = gRlvHandler.setCommandCallback(boost::bind(&RlvBehaviourNotifyHandler::onCommand, this, _1, _2, _3)); +} + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvBehaviourNotifyHandler::onCommand(const RlvCommand& rlvCmd, ERlvCmdRet eRet, bool fInternal) +{ + if (fInternal) + return; + + switch (rlvCmd.getParamType()) + { + case RLV_TYPE_ADD: + case RLV_TYPE_REMOVE: + sendNotification(rlvCmd.asString(), "=" + rlvCmd.getParam()); + break; + case RLV_TYPE_CLEAR: + sendNotification(rlvCmd.asString()); + break; + default: + break; + } +} + +// Checked: 2011-03-31 (RLVa-1.3.0f) | Modify: RLVa-1.3.0f +void RlvBehaviourNotifyHandler::sendNotification(const std::string& strText, const std::string& strSuffix) +{ + if (instanceExists()) + { + RlvBehaviourNotifyHandler* pThis = getInstance(); + + // NOTE: notifications have two parts (which are concatenated without token) where only the first part is subject to the filter + for (std::multimap<LLUUID, notifyData>::const_iterator itNotify = pThis->m_Notifications.begin(); + itNotify != pThis->m_Notifications.end(); ++itNotify) + { + if ( (itNotify->second.strFilter.empty()) || (boost::icontains(strText, itNotify->second.strFilter)) ) + RlvUtil::sendChatReply(itNotify->second.nChannel, "/" + strText + strSuffix); + } + } +} + +// Checked: 2011-03-31 (RLVa-1.3.0f) | Added: RLVa-1.3.0f +void RlvBehaviourNotifyHandler::onWear(LLWearableType::EType eType, bool fAllowed) +{ + sendNotification(llformat("worn %s %s", (fAllowed) ? "legally" : "illegally", LLWearableType::getTypeName(eType).c_str())); +} + +// Checked: 2011-03-31 (RLVa-1.3.0f) | Added: RLVa-1.3.0f +void RlvBehaviourNotifyHandler::onTakeOff(LLWearableType::EType eType, bool fAllowed) +{ + sendNotification(llformat("unworn %s %s", (fAllowed) ? "legally" : "illegally", LLWearableType::getTypeName(eType).c_str())); +} + +// Checked: 2011-03-31 (RLVa-1.3.0f) | Added: RLVa-1.3.0f +void RlvBehaviourNotifyHandler::onAttach(const LLViewerJointAttachment* pAttachPt, bool fAllowed) +{ + sendNotification(llformat("attached %s %s", (fAllowed) ? "legally" : "illegally", pAttachPt->getName().c_str())); +} + +// Checked: 2011-03-31 (RLVa-1.3.0f) | Added: RLVa-1.3.0f +void RlvBehaviourNotifyHandler::onDetach(const LLViewerJointAttachment* pAttachPt, bool fAllowed) +{ + sendNotification(llformat("detached %s %s", (fAllowed) ? "legally" : "illegally", pAttachPt->getName().c_str())); +} + +// Checked: 2011-03-31 (RLVa-1.3.0f) | Added: RLVa-1.3.0f +void RlvBehaviourNotifyHandler::onReattach(const LLViewerJointAttachment* pAttachPt, bool fAllowed) +{ + sendNotification(llformat("reattached %s %s", (fAllowed) ? "legally" : "illegally", pAttachPt->getName().c_str())); +} + +// ========================================================================= +// Various helper classes/timers/functors +// + +// Checked: 2010-03-13 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +BOOL RlvGCTimer::tick() +{ + bool fContinue = gRlvHandler.onGC(); + if (!fContinue) + gRlvHandler.m_pGCTimer = NULL; + return !fContinue; +} + +// ============================================================================ +// Various helper functions +// + +// ============================================================================ +// Attachment group helper functions +// + +// Has to match the order of ERlvAttachGroupType +const std::string cstrAttachGroups[RLV_ATTACHGROUP_COUNT] = { "head", "torso", "arms", "legs", "hud" }; + +// Checked: 2009-10-19 (RLVa-1.1.0e) | Added: RLVa-1.1.0e +ERlvAttachGroupType rlvAttachGroupFromIndex(S32 idxGroup) +{ + switch (idxGroup) + { + case 0: // Right Hand + case 1: // Right Arm + case 3: // Left Arm + case 4: // Left Hand + return RLV_ATTACHGROUP_ARMS; + case 2: // Head + return RLV_ATTACHGROUP_HEAD; + case 5: // Left Leg + case 7: // Right Leg + return RLV_ATTACHGROUP_LEGS; + case 6: // Torso + return RLV_ATTACHGROUP_TORSO; + case 8: // HUD + return RLV_ATTACHGROUP_HUD; + default: + return RLV_ATTACHGROUP_INVALID; + } +} + +// Checked: 2009-10-19 (RLVa-1.1.0e) | Added: RLVa-1.1.0e +ERlvAttachGroupType rlvAttachGroupFromString(const std::string& strGroup) +{ + for (int idx = 0; idx < RLV_ATTACHGROUP_COUNT; idx++) + if (cstrAttachGroups[idx] == strGroup) + return (ERlvAttachGroupType)idx; + return RLV_ATTACHGROUP_INVALID; +} + +// ========================================================================= +// String helper functions +// + +// Checked: 2009-07-29 (RLVa-1.0.1b) | Added: RLVa-1.0.1b +std::string rlvGetFirstParenthesisedText(const std::string& strText, std::string::size_type* pidxMatch /*=NULL*/) +{ + if (pidxMatch) + *pidxMatch = std::string::npos; // Assume we won't find anything + + std::string::size_type idxIt, idxStart; int cntLevel = 1; + if ((idxStart = strText.find_first_of('(')) == std::string::npos) + return std::string(); + + const char* pstrText = strText.c_str(); idxIt = idxStart; + while ( (cntLevel > 0) && (++idxIt < strText.length()) ) + { + if ('(' == pstrText[idxIt]) + cntLevel++; + else if (')' == pstrText[idxIt]) + cntLevel--; + } + + if (idxIt < strText.length()) + { + if (pidxMatch) + *pidxMatch = idxStart; // Return the character index of the starting '(' + return strText.substr(idxStart + 1, idxIt - idxStart - 1); + } + return std::string(); +} + +// Checked: 2009-07-29 (RLVa-1.0.1b) | Added: RLVa-1.0.1b +std::string rlvGetLastParenthesisedText(const std::string& strText, std::string::size_type* pidxStart /*=NULL*/) +{ + if (pidxStart) + *pidxStart = std::string::npos; // Assume we won't find anything + + // Extracts the last - matched - parenthesised text from the input string + std::string::size_type idxIt, idxEnd; int cntLevel = 1; + if ((idxEnd = strText.find_last_of(')')) == std::string::npos) + return std::string(); + + const char* pstrText = strText.c_str(); idxIt = idxEnd; + while ( (cntLevel > 0) && (--idxIt >= 0) && (idxIt < strText.length()) ) + { + if (')' == pstrText[idxIt]) + cntLevel++; + else if ('(' == pstrText[idxIt]) + cntLevel--; + } + + if ( (idxIt >= 0) && (idxIt < strText.length()) ) // NOTE: allow for std::string::size_type to be signed or unsigned + { + if (pidxStart) + *pidxStart = idxIt; // Return the character index of the starting '(' + return strText.substr(idxIt + 1, idxEnd - idxIt - 1); + } + return std::string(); +} + +// ========================================================================= diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h new file mode 100644 index 0000000000000000000000000000000000000000..d49ad1cf43d78fed9dff63ca5b394fbc4c309fe2 --- /dev/null +++ b/indra/newview/rlvhelper.h @@ -0,0 +1,455 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#ifndef RLV_HELPER_H +#define RLV_HELPER_H + +#include "lleventtimer.h" +#include "llinventorymodel.h" +#include "llviewerinventory.h" +#include "llwearabletype.h" +#include "llwlparamset.h" + +#include "rlvdefines.h" +#include "rlvcommon.h" + +// ============================================================================ +// RlvCommand +// + +class RlvCommand +{ +public: + explicit RlvCommand(const LLUUID& idObj, const std::string& strCommand); + + /* + * Member functions + */ +public: + std::string asString() const; + const std::string& getBehaviour() const { return m_strBehaviour; } + ERlvBehaviour getBehaviourType() const { return m_eBehaviour; } + const LLUUID& getObjectID() const { return m_idObj; } + const std::string& getOption() const { return m_strOption; } + const std::string& getParam() const { return m_strParam; } + ERlvParamType getParamType() const { return m_eParamType; } + ERlvCmdRet getReturnType() const { return m_eRet; } + bool hasOption() const { return !m_strOption.empty(); } + bool isStrict() const { return m_fStrict; } + bool isValid() const { return m_fValid; } + + typedef std::map<std::string, ERlvBehaviour> bhvr_map_t; + static ERlvBehaviour getBehaviourFromString(const std::string& strBhvr, bool* pfStrict = NULL); + static bool getCommands(bhvr_map_t& cmdList, const std::string& strMatch); + static const std::string& getStringFromBehaviour(ERlvBehaviour eBhvr); + static bool hasStrictVariant(ERlvBehaviour eBhvr); + + static void initLookupTable(); +protected: + static bool parseCommand(const std::string& strCommand, std::string& strBehaviour, std::string& strOption, std::string& strParam); + + /* + * Operators + */ +public: + bool operator ==(const RlvCommand&) const; + + /* + * Member variables + */ +protected: + bool m_fValid; + LLUUID m_idObj; + std::string m_strBehaviour; + ERlvBehaviour m_eBehaviour; + bool m_fStrict; + std::string m_strOption; + std::string m_strParam; + ERlvParamType m_eParamType; + ERlvCmdRet m_eRet; + + static bhvr_map_t m_BhvrMap; + + friend class RlvHandler; + friend class RlvObject; +}; + +// ============================================================================ +// RlvCommandOption (and derived classed) +// + +struct RlvCommandOption +{ +protected: + RlvCommandOption() : m_fValid(false) {} +public: + virtual ~RlvCommandOption() {} + +public: + virtual bool isEmpty() const { return false; } + virtual bool isValid() const { return m_fValid; } +protected: + bool m_fValid; +}; + +struct RlvCommandOptionGeneric : public RlvCommandOption +{ + explicit RlvCommandOptionGeneric(const std::string& strOption); + + bool isAttachmentPoint() const { return (!isEmpty()) && (typeid(LLViewerJointAttachment*) == m_varOption.type()); } + bool isAttachmentPointGroup() const { return (!isEmpty()) && (typeid(ERlvAttachGroupType) == m_varOption.type()); } + bool isEmpty() const { return m_fEmpty; } + bool isSharedFolder() const { return (!isEmpty()) && (typeid(LLViewerInventoryCategory*) == m_varOption.type()); } + bool isString() const { return (!isEmpty()) && (typeid(std::string) == m_varOption.type()); } + bool isUUID() const { return (!isEmpty()) && (typeid(LLUUID) == m_varOption.type()); } + bool isWearableType() const { return (!isEmpty()) && (typeid(LLWearableType::EType) == m_varOption.type()); } + + LLViewerJointAttachment* getAttachmentPoint() const + { return (isAttachmentPoint()) ? boost::get<LLViewerJointAttachment*>(m_varOption) : NULL; } + ERlvAttachGroupType getAttachmentPointGroup() const + { return (isAttachmentPointGroup()) ? boost::get<ERlvAttachGroupType>(m_varOption) : RLV_ATTACHGROUP_INVALID; } + LLViewerInventoryCategory* getSharedFolder() const + { return (isSharedFolder()) ? boost::get<LLViewerInventoryCategory*>(m_varOption) : NULL; } + const std::string& getString() const + { return (isString()) ? boost::get<std::string>(m_varOption) : LLStringUtil::null; } + const LLUUID& getUUID() const + { return (isUUID()) ? boost::get<LLUUID>(m_varOption) : LLUUID::null; } + LLWearableType::EType getWearableType() const + { return (isWearableType()) ? boost::get<LLWearableType::EType>(m_varOption) : LLWearableType::WT_INVALID; } + +protected: + bool m_fEmpty; + boost::variant<LLViewerJointAttachment*, ERlvAttachGroupType, LLViewerInventoryCategory*, std::string, LLUUID, LLWearableType::EType> m_varOption; +}; + +struct RlvCommandOptionGetPath : public RlvCommandOption +{ + typedef boost::function<void(const uuid_vec_t&)> getpath_callback_t; + RlvCommandOptionGetPath(const RlvCommand& rlvCmd, getpath_callback_t cb = NULL); + + bool isCallback() const { return m_fCallback; } + /*virtual*/ bool isEmpty() const { return m_idItems.empty(); } + const uuid_vec_t& getItemIDs() const { return m_idItems; } + + // NOTE: Both functions are COF-based rather than items gathered from mAttachedObjects or gAgentWearables + static bool getItemIDs(const LLViewerJointAttachment* pAttachPt, uuid_vec_t& idItems); + static bool getItemIDs(LLWearableType::EType wtType, uuid_vec_t& idItems); + +protected: + bool m_fCallback; // TRUE if a callback is schedueled + uuid_vec_t m_idItems; +}; + +struct RlvCommandOptionTpTo : public RlvCommandOption +{ + RlvCommandOptionTpTo(const RlvCommand& rlvCmd); + + LLVector3d m_posGlobal; +}; + +// ============================================================================ +// RlvObject +// + +class RlvObject +{ +public: + RlvObject(const LLUUID& idObj); + + /* + * Member functions + */ +public: + bool addCommand(const RlvCommand& rlvCmd); + bool removeCommand(const RlvCommand& rlvCmd); + void setCommandRet(const RlvCommand& rlvCmd, ERlvCmdRet eRet); + + std::string getStatusString(const std::string& strMatch) const; + bool hasBehaviour(ERlvBehaviour eBehaviour, bool fStrictOnly) const; + bool hasBehaviour(ERlvBehaviour eBehaviour, const std::string& strOption, bool fStrictOnly) const; + + const rlv_command_list_t* getCommandList() const { return &m_Commands; } + + const LLUUID& getObjectID() const { return m_idObj; } + const LLUUID& getRootID() const { return m_idRoot; } + + /* + * Member variables + */ +protected: + S32 m_idxAttachPt; // The object's attachment point (or 0 if it's not an attachment) + LLUUID m_idObj; // The object's UUID + LLUUID m_idRoot; // The UUID of the object's root (may or may not be different from m_idObj) + bool m_fLookup; // TRUE if the object existed in gObjectList at one point in time + S16 m_nLookupMisses; // Count of unsuccessful lookups in gObjectList by the GC + rlv_command_list_t m_Commands; // List of behaviours held by this object (in the order they were received) + + friend class RlvHandler; +}; + +// ============================================================================ +// RlvForceWear +// + +class RlvForceWear : public LLSingleton<RlvForceWear> +{ +protected: + RlvForceWear() {} + +public: + // Folders + enum EWearAction { ACTION_WEAR_REPLACE, ACTION_WEAR_ADD, ACTION_REMOVE }; + enum EWearFlags { FLAG_NONE = 0x00, FLAG_MATCHALL = 0x01, FLAG_DEFAULT = FLAG_NONE }; + void forceFolder(const LLViewerInventoryCategory* pFolder, EWearAction eAction, EWearFlags eFlags); + + // Generic + static bool isWearAction(EWearAction eAction) { return (ACTION_WEAR_REPLACE == eAction) || (ACTION_WEAR_ADD == eAction); } + static bool isWearableItem(const LLInventoryItem* pItem); + static bool isWearingItem(const LLInventoryItem* pItem); + + // Nostrip + static bool isStrippable(const LLUUID& idItem) { return isStrippable(gInventory.getItem(idItem)); } + static bool isStrippable(const LLInventoryItem* pItem); + + // Attachments + static bool isForceDetachable(const LLViewerObject* pAttachObj, bool fCheckComposite = true, const LLUUID& idExcept = LLUUID::null); + static bool isForceDetachable(const LLViewerJointAttachment* pAttachPt, bool fCheckComposite = true, const LLUUID& idExcept = LLUUID::null); + void forceDetach(const LLViewerObject* pAttachObj); + void forceDetach(const LLViewerJointAttachment* ptAttachPt); + + // Wearables + static bool isForceRemovable(const LLViewerWearable* pWearable, bool fCheckComposite = true, const LLUUID& idExcept = LLUUID::null); + static bool isForceRemovable(LLWearableType::EType wtType, bool fCheckComposite = true, const LLUUID& idExcept = LLUUID::null); + void forceRemove(const LLViewerWearable* pWearable); + void forceRemove(LLWearableType::EType wtType); + +public: + void done(); +protected: + void addAttachment(const LLViewerInventoryItem* pItem, EWearAction eAction); + void remAttachment(const LLViewerObject* pAttachObj); + void addWearable(const LLViewerInventoryItem* pItem, EWearAction eAction); + void remWearable(const LLViewerWearable* pWearable); + + // Convenience (prevents long lines that run off the screen elsewhere) + bool isAddAttachment(const LLViewerInventoryItem* pItem) const + { + bool fFound = false; + for (addattachments_map_t::const_iterator itAddAttachments = m_addAttachments.begin(); + (!fFound) && (itAddAttachments != m_addAttachments.end()); ++itAddAttachments) + { + const LLInventoryModel::item_array_t& wearItems = itAddAttachments->second; + fFound = (std::find_if(wearItems.begin(), wearItems.end(), RlvPredIsEqualOrLinkedItem(pItem)) != wearItems.end()); + } + return fFound; + } + bool isRemAttachment(const LLViewerObject* pAttachObj) const + { + return std::find(m_remAttachments.begin(), m_remAttachments.end(), pAttachObj) != m_remAttachments.end(); + } + bool isAddWearable(const LLViewerInventoryItem* pItem) const + { + bool fFound = false; + for (addwearables_map_t::const_iterator itAddWearables = m_addWearables.begin(); + (!fFound) && (itAddWearables != m_addWearables.end()); ++itAddWearables) + { + const LLInventoryModel::item_array_t& wearItems = itAddWearables->second; + fFound = (std::find_if(wearItems.begin(), wearItems.end(), RlvPredIsEqualOrLinkedItem(pItem)) != wearItems.end()); + } + return fFound; + } + bool isRemWearable(const LLViewerWearable* pWearable) const + { + return std::find(m_remWearables.begin(), m_remWearables.end(), pWearable) != m_remWearables.end(); + } + +protected: + typedef std::pair<LLWearableType::EType, LLInventoryModel::item_array_t> addwearable_pair_t; + typedef std::map<LLWearableType::EType, LLInventoryModel::item_array_t> addwearables_map_t; + addwearables_map_t m_addWearables; + typedef std::pair<S32, LLInventoryModel::item_array_t> addattachment_pair_t; + typedef std::map<S32, LLInventoryModel::item_array_t> addattachments_map_t; + addattachments_map_t m_addAttachments; + LLInventoryModel::item_array_t m_addGestures; + std::vector<LLViewerObject*> m_remAttachments; // This should match the definition of LLAgentWearables::llvo_vec_t + std::list<const LLViewerWearable*> m_remWearables; + LLInventoryModel::item_array_t m_remGestures; + +private: + friend class LLSingleton<RlvForceWear>; +}; + +// ============================================================================ +// RlvBehaviourNotifyObserver +// + +class RlvBehaviourNotifyHandler : public LLSingleton<RlvBehaviourNotifyHandler> +{ + friend class LLSingleton<RlvBehaviourNotifyHandler>; +protected: + RlvBehaviourNotifyHandler(); + virtual ~RlvBehaviourNotifyHandler() { if (m_ConnCommand.connected()) m_ConnCommand.disconnect(); } + +public: + void addNotify(const LLUUID& idObj, S32 nChannel, const std::string& strFilter) + { + m_Notifications.insert(std::pair<LLUUID, notifyData>(idObj, notifyData(nChannel, strFilter))); + } + void removeNotify(const LLUUID& idObj, S32 nChannel, const std::string& strFilter) + { + for (std::multimap<LLUUID, notifyData>::iterator itNotify = m_Notifications.lower_bound(idObj), + endNotify = m_Notifications.upper_bound(idObj); itNotify != endNotify; ++itNotify) + { + if ( (itNotify->second.nChannel == nChannel) && (itNotify->second.strFilter == strFilter) ) + { + m_Notifications.erase(itNotify); + break; + } + } + if (m_Notifications.empty()) + delete this; // Delete ourself if we have nothing to do + } + static void sendNotification(const std::string& strText, const std::string& strSuffix = LLStringUtil::null); + + /* + * Event handlers + */ +public: + static void onWear(LLWearableType::EType eType, bool fAllowed); + static void onTakeOff(LLWearableType::EType eType, bool fAllowed); + static void onAttach(const LLViewerJointAttachment* pAttachPt, bool fAllowed); + static void onDetach(const LLViewerJointAttachment* pAttachPt, bool fAllowed); + static void onReattach(const LLViewerJointAttachment* pAttachPt, bool fAllowed); +protected: + void onCommand(const RlvCommand& rlvCmd, ERlvCmdRet eRet, bool fInternal); + +protected: + struct notifyData + { + S32 nChannel; + std::string strFilter; + notifyData(S32 channel, const std::string& filter) : nChannel(channel), strFilter(filter) {} + }; + std::multimap<LLUUID, notifyData> m_Notifications; + boost::signals2::connection m_ConnCommand; +}; + +// ============================================================================ +// RlvException +// + +struct RlvException +{ +public: + LLUUID idObject; // UUID of the object that added the exception + ERlvBehaviour eBehaviour; // Behaviour the exception applies to + RlvExceptionOption varOption; // Exception data (type is dependent on eBehaviour) + + RlvException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& option) : idObject(idObj), eBehaviour(eBhvr), varOption(option) {} +private: + RlvException(); +}; + +// ============================================================================ +// Various helper classes/timers/functors +// + +class RlvGCTimer : public LLEventTimer +{ +public: + RlvGCTimer() : LLEventTimer(30.0) {} + virtual BOOL tick(); +}; + +class RlvCallbackTimerOnce : public LLEventTimer +{ +public: + typedef boost::function<void ()> nullary_func_t; +public: + RlvCallbackTimerOnce(F32 nPeriod, nullary_func_t cb) : LLEventTimer(nPeriod), m_Callback(cb) {} + /*virtual*/ BOOL tick() + { + m_Callback(); + return TRUE; + } +protected: + nullary_func_t m_Callback; +}; + +inline void rlvCallbackTimerOnce(F32 nPeriod, RlvCallbackTimerOnce::nullary_func_t cb) +{ + // Timer will automatically delete itself after the callback + new RlvCallbackTimerOnce(nPeriod, cb); +} + +// ============================================================================ +// Various helper functions +// + +ERlvAttachGroupType rlvAttachGroupFromIndex(S32 idxGroup); +ERlvAttachGroupType rlvAttachGroupFromString(const std::string& strGroup); + +std::string rlvGetFirstParenthesisedText(const std::string& strText, std::string::size_type* pidxMatch = NULL); +std::string rlvGetLastParenthesisedText(const std::string& strText, std::string::size_type* pidxStart = NULL); + +// ============================================================================ +// Inlined class member functions +// + +// Checked: 2009-09-19 (RLVa-1.0.3d) +inline std::string RlvCommand::asString() const +{ + // NOTE: @clear=<param> should be represented as clear:<param> + return (m_eParamType != RLV_TYPE_CLEAR) + ? (!m_strOption.empty()) ? (std::string(m_strBehaviour)).append(":").append(m_strOption) : (std::string(m_strBehaviour)) + : (!m_strParam.empty()) ? (std::string(m_strBehaviour)).append(":").append(m_strParam) : (std::string(m_strBehaviour)); +} + +inline bool RlvCommand::operator ==(const RlvCommand& rhs) const +{ + // The specification notes that "@detach=n" is semantically identical to "@detach=add" (same for "y" and "rem" + return (m_strBehaviour == rhs.m_strBehaviour) && (m_strOption == rhs.m_strOption) && + ( (RLV_TYPE_UNKNOWN != m_eParamType) ? (m_eParamType == rhs.m_eParamType) : (m_strParam == rhs.m_strParam) ); +} + +inline bool RlvCommand::hasStrictVariant(ERlvBehaviour eBhvr) +{ + switch (eBhvr) + { + case RLV_BHVR_RECVCHAT: + case RLV_BHVR_RECVEMOTE: + case RLV_BHVR_RECVIM: + case RLV_BHVR_SENDIM: + case RLV_BHVR_TPLURE: + case RLV_BHVR_SENDCHANNEL: + return true; + default: + return false; + } +} + +// Checked: 2010-04-05 (RLVa-1.2.0d) | Modified: RLVa-1.2.0d +inline bool RlvForceWear::isWearableItem(const LLInventoryItem* pItem) +{ + LLAssetType::EType assetType = (pItem) ? pItem->getType() : LLAssetType::AT_NONE; + return + (LLAssetType::AT_BODYPART == assetType) || (LLAssetType::AT_CLOTHING == assetType) || + (LLAssetType::AT_OBJECT == assetType) || (LLAssetType::AT_GESTURE == assetType); +} + +// ============================================================================ + +#endif // RLV_HELPER_H diff --git a/indra/newview/rlvinventory.cpp b/indra/newview/rlvinventory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..48ef6000279e2d4e665a1674c966efbe76921726 --- /dev/null +++ b/indra/newview/rlvinventory.cpp @@ -0,0 +1,805 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#include "llviewerprecompiledheaders.h" +#include "llagent.h" +#include "llappearancemgr.h" +#include "llinventoryobserver.h" +#include "llstartup.h" +#include "llviewerfoldertype.h" +#include "llviewerobject.h" +#include "llvoavatarself.h" + +#include "rlvdefines.h" +#include "rlvcommon.h" +#include "rlvlocks.h" +#include "rlvinventory.h" +#include "rlvhandler.h" + +#include "boost/algorithm/string.hpp" + +// ============================================================================ +// Static variable initialization +// + +const std::string RlvInventory::cstrSharedRoot = RLV_ROOT_FOLDER; + +// ============================================================================ +// Helper classes +// + +// TODO-RLVa: [RLVa-1.2.1] This class really shouldn't be calling "fetchSharedLinks" directly so find a better way +class RlvSharedInventoryFetcher : public LLInventoryFetchDescendentsObserver +{ +public: + RlvSharedInventoryFetcher(const uuid_vec_t& idFolders): LLInventoryFetchDescendentsObserver(idFolders) {} + virtual ~RlvSharedInventoryFetcher() {} + + virtual void done() + { + RLV_INFOS << "Shared folders fetch completed" << LL_ENDL; + RlvInventory::instance().m_fFetchComplete = true; + RlvInventory::instance().fetchSharedLinks(); + + gInventory.removeObserver(this); + delete this; + } +}; + +// ============================================================================ +// RlvInventory member functions +// + +// Checked: 2011-03-28 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g +RlvInventory::RlvInventory() + : m_fFetchStarted(false), m_fFetchComplete(false) +{ +} + +// Checked: 2011-03-28 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +RlvInventory::~RlvInventory() +{ + if (gInventory.containsObserver(this)) + gInventory.removeObserver(this); +} + +// Checked: 2011-03-28 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +void RlvInventory::changed(U32 mask) +{ + const LLInventoryModel::changed_items_t& idsChanged = gInventory.getChangedIDs(); + if (std::find(idsChanged.begin(), idsChanged.end(), m_idRlvRoot) != idsChanged.end()) + { + gInventory.removeObserver(this); + + LLUUID idRlvRootPrev = m_idRlvRoot; + m_idRlvRoot.setNull(); + + if (idRlvRootPrev != getSharedRootID()) + m_OnSharedRootIDChanged(); + } +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.0.0h +void RlvInventory::fetchSharedInventory() +{ + // Sanity check - don't fetch if we're already fetching, or if we don't have a shared root + const LLViewerInventoryCategory* pRlvRoot = getSharedRoot(); + if ( (m_fFetchStarted) || (!pRlvRoot) ) + return; + + // Grab all the folders under the shared root + LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items; + gInventory.collectDescendents(pRlvRoot->getUUID(), folders, items, FALSE); + + // Add them to the "to fetch" list + uuid_vec_t idFolders; + idFolders.push_back(pRlvRoot->getUUID()); + for (S32 idxFolder = 0, cntFolder = folders.count(); idxFolder < cntFolder; idxFolder++) + idFolders.push_back(folders.get(idxFolder)->getUUID()); + + // Now fetch them all in one go + RlvSharedInventoryFetcher* pFetcher = new RlvSharedInventoryFetcher(idFolders); + + RLV_INFOS << "Starting fetch of " << idFolders.size() << " shared folders" << RLV_ENDL; + pFetcher->startFetch(); + m_fFetchStarted = true; + + if (pFetcher->isFinished()) + pFetcher->done(); + else + gInventory.addObserver(pFetcher); +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.0.0h +void RlvInventory::fetchSharedLinks() +{ + // TOFIX-RLVa: [RLVa-1.2.1] Finish adding support for AT_LINK_FOLDER + const LLViewerInventoryCategory* pRlvRoot = getSharedRoot(); + if (!pRlvRoot) + return; + + // Grab all the inventory links under the shared root + LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items; RlvIsLinkType f; + gInventory.collectDescendentsIf(pRlvRoot->getUUID(), folders, items, FALSE, f, FALSE); + + // Add them to the "to fetch" list based on link type + uuid_vec_t idFolders, idItems; + for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++) + { + const LLViewerInventoryItem* pItem = items.get(idxItem); + switch (pItem->getActualType()) + { + case LLAssetType::AT_LINK: + idItems.push_back(pItem->getLinkedUUID()); + break; + case LLAssetType::AT_LINK_FOLDER: + idFolders.push_back(pItem->getLinkedUUID()); + break; + default: + break;; + } + } + + RLV_INFOS << "Starting link target fetch of " << idItems.size() << " items and " << idFolders.size() << " folders" << RLV_ENDL; + + // Fetch all the link item targets + LLInventoryFetchItemsObserver itemFetcher(idItems); + itemFetcher.startFetch(); + + // Fetch all the link folder targets + // TODO! +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvInventory::fetchWornItems() +{ + uuid_vec_t idItems; + + // Fetch all currently worn clothing layers and body parts + for (int type = 0; type < LLWearableType::WT_COUNT; type++) + { + // RELEASE-RLVa: [SL-2.0.0] Needs rewriting once 'LLAgentWearables::MAX_WEARABLES_PER_TYPE > 1' + const LLUUID& idItem = gAgentWearables.getWearableItemID((LLWearableType::EType)type, 0); + if (idItem.notNull()) + idItems.push_back(idItem); + } + + // Fetch all currently worn attachments + if (isAgentAvatarValid()) + { + for (LLVOAvatar::attachment_map_t::const_iterator itAttachPt = gAgentAvatarp->mAttachmentPoints.begin(); + itAttachPt != gAgentAvatarp->mAttachmentPoints.end(); ++itAttachPt) + { + const LLViewerJointAttachment* pAttachPt = itAttachPt->second; + if (pAttachPt) + { + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) + { + const LLViewerObject* pAttachObj = (*itAttachObj); + if ( (pAttachObj) && (pAttachObj->getAttachmentItemID().notNull()) ) + idItems.push_back(pAttachObj->getAttachmentItemID()); + } + } + } + } + + LLInventoryFetchItemsObserver itemFetcher(idItems); + itemFetcher.startFetch(); +} + +// Checked: 2010-04-07 (RLVa-1.2.0a) | Modified: RLVa-1.0.0h +bool RlvInventory::findSharedFolders(const std::string& strCriteria, LLInventoryModel::cat_array_t& folders) const +{ + // Sanity check - can't do anything without a shared root + const LLViewerInventoryCategory* pRlvRoot = RlvInventory::instance().getSharedRoot(); + if (!pRlvRoot) + return false; + + folders.clear(); + LLInventoryModel::item_array_t items; + RlvCriteriaCategoryCollector f(strCriteria); + gInventory.collectDescendentsIf(pRlvRoot->getUUID(), folders, items, FALSE, f); + + return (folders.count() != 0); +} + +// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c +bool RlvInventory::getPath(const uuid_vec_t& idItems, LLInventoryModel::cat_array_t& folders) const +{ + // Sanity check - can't do anything without a shared root + const LLViewerInventoryCategory* pRlvRoot = RlvInventory::instance().getSharedRoot(); + if (!pRlvRoot) + return false; + + folders.clear(); + for (uuid_vec_t::const_iterator itItem = idItems.begin(); itItem != idItems.end(); ++itItem) + { + const LLInventoryItem* pItem = gInventory.getItem(*itItem); + if ( (pItem) && (gInventory.isObjectDescendentOf(pItem->getUUID(), pRlvRoot->getUUID())) ) + { + // If the containing folder is a folded folder we need its parent + LLViewerInventoryCategory* pFolder = gInventory.getCategory(pItem->getParentUUID()); + if (RlvInventory::instance().isFoldedFolder(pFolder, true)) + pFolder = gInventory.getCategory(pFolder->getParentUUID()); + folders.push_back(pFolder); + } + } + + return (folders.count() != 0); +} + +// Checked: 2011-10-06 (RLVa-1.4.2a) | Modified: RLVa-1.4.2a +const LLUUID& RlvInventory::getSharedRootID() const +{ + if ( (m_idRlvRoot.isNull()) && (gInventory.isInventoryUsable()) ) + { + LLInventoryModel::cat_array_t* pFolders; LLInventoryModel::item_array_t* pItems; + gInventory.getDirectDescendentsOf(gInventory.getRootFolderID(), pFolders, pItems); + if (pFolders) + { + // NOTE: we might have multiple #RLV folders (pick the first one with sub-folders; otherwise the last one with no sub-folders) + const LLViewerInventoryCategory* pFolder; + for (S32 idxFolder = 0, cntFolder = pFolders->count(); idxFolder < cntFolder; idxFolder++) + { + if ( ((pFolder = pFolders->get(idxFolder)) != NULL) && (cstrSharedRoot == pFolder->getName()) ) + { + m_idRlvRoot = pFolder->getUUID(); + if (getDirectDescendentsFolderCount(pFolder) > 0) + break; + } + } + if ( (m_idRlvRoot.notNull()) && (!gInventory.containsObserver((RlvInventory*)this)) ) + gInventory.addObserver((RlvInventory*)this); + } + } + return m_idRlvRoot; +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.0.1a +LLViewerInventoryCategory* RlvInventory::getSharedFolder(const LLUUID& idParent, const std::string& strFolderName) const +{ + LLInventoryModel::cat_array_t* pFolders; LLInventoryModel::item_array_t* pItems; + gInventory.getDirectDescendentsOf(idParent, pFolders, pItems); + if ( (!pFolders) || (strFolderName.empty()) ) + return NULL; + + // If we can't find an exact match then we'll settle for a "contains" match + LLViewerInventoryCategory* pPartial = NULL; + + //LLStringUtil::toLower(strFolderName); <- everything was already converted to lower case before + + std::string strName; + for (S32 idxFolder = 0, cntFolder = pFolders->count(); idxFolder < cntFolder; idxFolder++) + { + LLViewerInventoryCategory* pFolder = pFolders->get(idxFolder); + + strName = pFolder->getName(); + if (strName.empty()) + continue; + LLStringUtil::toLower(strName); + + if (strFolderName == strName) + return pFolder; // Found an exact match, no need to keep on going + else if ( (!pPartial) && (RLV_FOLDER_PREFIX_HIDDEN != strName[0]) && (std::string::npos != strName.find(strFolderName)) ) + pPartial = pFolder; // Found a partial (non-hidden) match, but we might still find an exact one (first partial match wins) + } + + return pPartial; +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-0.2.0e +LLViewerInventoryCategory* RlvInventory::getSharedFolder(const std::string& strPath) const +{ + // Sanity check - no shared root => no shared folder + LLViewerInventoryCategory* pRlvRoot = getSharedRoot(), *pFolder = pRlvRoot; + if (!pRlvRoot) + return NULL; + + // Walk the path (starting at the root) + boost_tokenizer tokens(strPath, boost::char_separator<char>("/", "", boost::drop_empty_tokens)); + for (boost_tokenizer::const_iterator itToken = tokens.begin(); itToken != tokens.end(); ++itToken) + { + pFolder = getSharedFolder(pFolder->getUUID(), *itToken); + if (!pFolder) + return NULL; // No such folder + } + + return pFolder; // If strPath was empty or just a bunch of //// then: pFolder == pRlvRoot +} + +// Checked: 2010-03-02 (RLVa-1.2.0a) | Modified: RLVa-0.2.0g +std::string RlvInventory::getSharedPath(const LLViewerInventoryCategory* pFolder) const +{ + // Sanity check - no shared root or no folder => no path + const LLViewerInventoryCategory* pRlvRoot = getSharedRoot(); + if ( (!pRlvRoot) || (!pFolder) || (pRlvRoot->getUUID() == pFolder->getUUID()) ) + return std::string(); + + const LLUUID& idRLV = pRlvRoot->getUUID(); + const LLUUID& idRoot = gInventory.getRootFolderID(); + std::string strPath; + + // Walk up the tree until we reach the top + RLV_ASSERT(gInventory.isObjectDescendentOf(pFolder->getUUID(), pRlvRoot->getUUID())); + while (pFolder) + { + strPath = "/" + pFolder->getName() + strPath; + + const LLUUID& idParent = pFolder->getParentUUID(); + if (idRLV == idParent) // Reached the shared root, we're done + break; + else if (idRoot == idParent) // We reached the agent's inventory root (indicative of a logic error elsewhere) + return std::string(); + + pFolder = gInventory.getCategory(idParent); + } + + return strPath.erase(0, 1); +} + +// Checked: 2011-10-06 (RLVa-1.4.2a) | Added: RLVa-1.4.2a +S32 RlvInventory::getDirectDescendentsFolderCount(const LLInventoryCategory* pFolder) +{ + LLInventoryModel::cat_array_t* pFolders = NULL; LLInventoryModel::item_array_t* pItems = NULL; + if (pFolder) + gInventory.getDirectDescendentsOf(pFolder->getUUID(), pFolders, pItems); + return (pFolders) ? pFolders->size() : 0; +} + +// Checked: 2009-05-26 (RLVa-0.2.0d) | Modified: RLVa-0.2.0d +S32 RlvInventory::getDirectDescendentsItemCount(const LLInventoryCategory* pFolder, LLAssetType::EType filterType) +{ + S32 cntType = 0; + if (pFolder) + { + LLInventoryModel::cat_array_t* pFolders; LLInventoryModel::item_array_t* pItems; + gInventory.getDirectDescendentsOf(pFolder->getUUID(), pFolders, pItems); + + if (pItems) + { + for (S32 idxItem = 0, cntItem = pItems->count(); idxItem < cntItem; idxItem++) + if (pItems->get(idxItem)->getType() == filterType) + cntType++; + } + } + return cntType; +} + +// ============================================================================ +// RlvRenameOnWearObserver member functions +// + +// Checked: 2010-03-14 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +void RlvRenameOnWearObserver::done() +{ + gInventory.removeObserver(this); + + // We shouldn't be messing with inventory items during LLInventoryModel::notifyObservers() + doOnIdleOneTime(boost::bind(&RlvRenameOnWearObserver::doneIdle, this)); +} + +// Checked: 2010-03-14 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +void RlvRenameOnWearObserver::doneIdle() +{ + const LLViewerInventoryCategory* pRlvRoot = NULL; + if ( (RlvSettings::getEnableSharedWear()) || (!RlvSettings::getSharedInvAutoRename()) || (LLStartUp::getStartupState() < STATE_STARTED) || + (!isAgentAvatarValid()) || ((pRlvRoot = RlvInventory::instance().getSharedRoot()) == NULL) ) + { + delete this; + return; + } + + const LLViewerJointAttachment* pAttachPt = NULL; S32 idxAttachPt = 0; + RLV_ASSERT(mComplete.size() > 0); // Catch instances where we forgot to call startFetch() + for (uuid_vec_t::const_iterator itItem = mComplete.begin(); itItem != mComplete.end(); ++itItem) + { + const LLUUID& idAttachItem = *itItem; + + // If the item resides under #RLV we'll rename it directly; otherwise settle for "renaming" all of its links residing under #RLV + LLInventoryModel::item_array_t items; + if (gInventory.isObjectDescendentOf(idAttachItem, pRlvRoot->getUUID())) + items.push_back(gInventory.getItem(idAttachItem)); + else + items = gInventory.collectLinkedItems(idAttachItem, pRlvRoot->getUUID()); + if (items.empty()) + continue; + + if ( ((pAttachPt = gAgentAvatarp->getWornAttachmentPoint(idAttachItem)) == NULL) || + ((idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(pAttachPt)) == 0) ) + { + RLV_ASSERT(false); + continue; + } + + for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++) + { + LLViewerInventoryItem* pItem = items.get(idxItem); + if (!pItem) + continue; + + S32 idxAttachPtItem = RlvAttachPtLookup::getAttachPointIndex(pItem); + if ( (idxAttachPt == idxAttachPtItem) || (idxAttachPtItem) ) + continue; + + std::string strAttachPt = pAttachPt->getName(); + LLStringUtil::toLower(strAttachPt); + + // If we can modify the item then we rename it directly, otherwise we create a new folder and move it + if (pItem->getPermissions().allowModifyBy(gAgent.getID())) + { + std::string strName = pItem->getName(); + LLStringUtil::truncate(strName, DB_INV_ITEM_NAME_STR_LEN - strAttachPt.length() - 3); + + strName += " (" + strAttachPt + ")"; + + pItem->rename(strName); + pItem->updateServer(FALSE); + gInventory.addChangedMask(LLInventoryObserver::LABEL, pItem->getUUID()); + } + else + { + // Don't do anything if the item is a direct descendant of the shared root, or a folded folder + LLViewerInventoryCategory* pFolder = gInventory.getCategory(pItem->getParentUUID()); + if ( (pFolder) && (pFolder->getUUID() != pRlvRoot->getUUID()) && (!RlvInventory::isFoldedFolder(pFolder, false)) ) + { + std::string strFolderName = ".(" + strAttachPt + ")"; + + // Rename the item's parent folder if it's called "New Folder", isn't directly under #RLV and contains exactly 1 object + if ( (LLViewerFolderType::lookupNewCategoryName(LLFolderType::FT_NONE) == pFolder->getName()) && + (pFolder->getParentUUID() != pRlvRoot->getUUID()) && + (1 == RlvInventory::getDirectDescendentsItemCount(pFolder, LLAssetType::AT_OBJECT)) ) + { + pFolder->rename(strFolderName); + pFolder->updateServer(FALSE); + gInventory.addChangedMask(LLInventoryObserver::LABEL, pFolder->getUUID()); + } + else + { + // "No modify" item with a non-renameable parent: create a new folder named and move the item into it + LLUUID idFolder = gInventory.createNewCategory(pFolder->getUUID(), LLFolderType::FT_NONE, strFolderName, + &RlvRenameOnWearObserver::onCategoryCreate, new LLUUID(pItem->getUUID())); + if (idFolder.notNull()) + { + // Not using the new 'CreateInventoryCategory' cap so manually invoke the callback + RlvRenameOnWearObserver::onCategoryCreate(LLSD().with("folder_id", idFolder), new LLUUID(pItem->getUUID())); + } + } + } + } + } + } + gInventory.notifyObservers(); + + delete this; +} + +// Checked: 2012-03-22 (RLVa-1.4.6) | Added: RLVa-1.4.6 +void RlvRenameOnWearObserver::onCategoryCreate(const LLSD& sdData, void* pParam) +{ + LLUUID idFolder = sdData["folder_id"].asUUID(); + LLUUID* pidItem = (LLUUID*)pParam; + + if ( (idFolder.notNull()) && (pidItem) && (pidItem->notNull()) ) + move_inventory_item(gAgent.getID(), gAgent.getSessionID(), *pidItem, idFolder, std::string(), NULL); + + delete pidItem; +} + +// ============================================================================ +// "Give to #RLV" helper classes +// + +// Checked: 2010-04-18 (RLVa-1.2.0e) | Added: RLVa-1.2.0e +void RlvGiveToRLVTaskOffer::changed(U32 mask) +{ + if (mask & LLInventoryObserver::ADD) + { + LLMessageSystem* pMsg = gMessageSystem; + if ( (pMsg->getMessageName()) && (0 == strcmp(pMsg->getMessageName(), "BulkUpdateInventory")) ) + { + LLUUID idTransaction; + pMsg->getUUIDFast(_PREHASH_AgentData, _PREHASH_TransactionID, idTransaction); + if(m_idTransaction == idTransaction) + { + LLUUID idInvObject; + for(S32 idxBlock = 0, cntBlock = pMsg->getNumberOfBlocksFast(_PREHASH_FolderData); idxBlock < cntBlock; idxBlock++) + { + pMsg->getUUIDFast(_PREHASH_FolderData, _PREHASH_FolderID, idInvObject, idxBlock); + if ( (idInvObject.notNull()) && (std::find(m_Folders.begin(), m_Folders.end(), idInvObject) == m_Folders.end()) ) + m_Folders.push_back(idInvObject); + } + + done(); + } + } + } +} + +// Checked: 2010-04-18 (RLVa-1.2.0e) | Added: RLVa-1.2.0e +void RlvGiveToRLVTaskOffer::done() +{ + gInventory.removeObserver(this); + + // We shouldn't be messing with inventory items during LLInventoryModel::notifyObservers() + doOnIdleOneTime(boost::bind(&RlvGiveToRLVTaskOffer::doneIdle, this)); +} + +// Checked: 2010-04-18 (RLVa-1.2.0e) | Added: RLVa-1.2.0e +void RlvGiveToRLVTaskOffer::doneIdle() +{ + const LLViewerInventoryCategory* pRlvRoot = RlvInventory::instance().getSharedRoot(); + if (pRlvRoot) + { + for (folder_ref_t::const_iterator itFolder = m_Folders.begin(); itFolder != m_Folders.end(); ++itFolder) + { + const LLViewerInventoryCategory* pFolder = gInventory.getCategory(*itFolder); + if (!pFolder) + continue; + + std::string strFolder = pFolder->getName(); + if ( (pRlvRoot->getUUID() == pFolder->getParentUUID() ) && (strFolder.find(RLV_PUTINV_PREFIX) == 0)) + { + LLPointer<LLViewerInventoryCategory> pNewFolder = new LLViewerInventoryCategory(pFolder); + pNewFolder->rename(strFolder.erase(0, strFolder.find(RLV_FOLDER_PREFIX_PUTINV))); + pNewFolder->updateServer(FALSE); + gInventory.updateCategory(pNewFolder); + + RlvBehaviourNotifyHandler::sendNotification("accepted_in_rlv inv_offer " + pNewFolder->getName()); + + gInventory.notifyObservers(); + break; + } + } + } + delete this; +} + +// Checked: 2010-04-18 (RLVa-1.2.0e) | Modified: RLVa-1.2.0e +void RlvGiveToRLVAgentOffer::done() +{ + gInventory.removeObserver(this); + + // We shouldn't be messing with inventory items during LLInventoryModel::notifyObservers() + doOnIdleOneTime(boost::bind(&RlvGiveToRLVAgentOffer::doneIdle, this)); +} + +// Checked: 2010-04-18 (RLVa-1.2.0e) | Modified: RLVa-1.2.0e +void RlvGiveToRLVAgentOffer::doneIdle() +{ + const LLViewerInventoryCategory* pRlvRoot = RlvInventory::instance().getSharedRoot(); + const LLViewerInventoryCategory* pFolder = (mComplete.size()) ? gInventory.getCategory(mComplete[0]) : NULL; + if ( (pRlvRoot) && (pFolder) ) + { + std::string strName = pFolder->getName(); + if (strName.find(RLV_PUTINV_PREFIX) == 0) + { + LLInventoryModel::update_list_t update; + LLInventoryModel::LLCategoryUpdate updOldParent(pFolder->getParentUUID(), -1); + update.push_back(updOldParent); + LLInventoryModel::LLCategoryUpdate updNewParent(pRlvRoot->getUUID(), 1); + update.push_back(updNewParent); + gInventory.accountForUpdate(update); + + LLPointer<LLViewerInventoryCategory> pNewFolder = new LLViewerInventoryCategory(pFolder); + pNewFolder->setParent(pRlvRoot->getUUID()); + pNewFolder->updateParentOnServer(FALSE); + pNewFolder->rename(strName.erase(0, strName.find(RLV_FOLDER_PREFIX_PUTINV))); + pNewFolder->updateServer(FALSE); + gInventory.updateCategory(pNewFolder); + + gInventory.notifyObservers(); + } + } + delete this; +} + +// ============================================================================ +// RlvWearableItemCollector +// + +// Checked: 2010-09-25 (RLVa-1.2.1c) | Added: RLVa-1.2.1c +RlvWearableItemCollector::RlvWearableItemCollector(const LLInventoryCategory* pFolder, RlvForceWear::EWearAction eAction, RlvForceWear::EWearFlags eFlags) + : m_idFolder(pFolder->getUUID()), m_eWearAction(eAction), m_eWearFlags(eFlags), + m_strWearAddPrefix(RlvSettings::getWearAddPrefix()), m_strWearReplacePrefix(RlvSettings::getWearReplacePrefix()) +{ + m_Wearable.push_back(m_idFolder); + + // Wear prefixes can't/shouldn't start with '.' + if ( (m_strWearAddPrefix.length() > 1) && (RLV_FOLDER_PREFIX_HIDDEN == m_strWearAddPrefix[0]) ) + m_strWearAddPrefix.clear(); + if ( (m_strWearReplacePrefix.length() > 1) && (RLV_FOLDER_PREFIX_HIDDEN == m_strWearReplacePrefix[0]) ) + m_strWearReplacePrefix.clear(); + + // If there's a prefix on the "root" folder then it will override what we were passed in the constructor + m_eWearAction = getWearActionNormal(pFolder); + m_WearActionMap.insert(std::pair<LLUUID, RlvForceWear::EWearAction>(m_idFolder, m_eWearAction)); +} + +// Checked: 2010-09-25 (RLVa-1.2.1c) | Added: RLVa-1.2.1c +RlvForceWear::EWearAction RlvWearableItemCollector::getWearActionNormal(const LLInventoryCategory* pFolder) +{ + RLV_ASSERT_DBG(!RlvInventory::isFoldedFolder(pFolder, false)); + if ( (RlvForceWear::ACTION_WEAR_REPLACE == m_eWearAction) && (!m_strWearAddPrefix.empty()) && + (boost::algorithm::starts_with(pFolder->getName(), m_strWearAddPrefix))) + { + return RlvForceWear::ACTION_WEAR_ADD; + } + else if ( (RlvForceWear::ACTION_WEAR_ADD == m_eWearAction) && (!m_strWearReplacePrefix.empty()) && + (boost::algorithm::starts_with(pFolder->getName(), m_strWearReplacePrefix)) ) + { + return RlvForceWear::ACTION_WEAR_REPLACE; + } + return (pFolder->getUUID() != m_idFolder) ? getWearAction(pFolder->getParentUUID()) : m_eWearAction; +} + +// Checked: 2010-04-07 (RLVa-1.2.0d) | Added: RLVa-0.2.0e +const LLUUID& RlvWearableItemCollector::getFoldedParent(const LLUUID& idFolder) const +{ + std::map<LLUUID, LLUUID>::const_iterator itFolder = m_FoldingMap.end(), itCur = m_FoldingMap.find(idFolder); + while (itCur != m_FoldingMap.end()) + { + itFolder = itCur; + itCur = m_FoldingMap.find(itFolder->second); + } + return (m_FoldingMap.end() == itFolder) ? idFolder : itFolder->second; +} + +// Checked: 2010-09-25 (RLVa-1.2.1c) | Added: RLVa-1.2.1c +RlvForceWear::EWearAction RlvWearableItemCollector::getWearAction(const LLUUID& idFolder) const +{ + LLUUID idCurFolder(idFolder); std::map<LLUUID, RlvForceWear::EWearAction>::const_iterator itCurFolder; + while ((itCurFolder = m_WearActionMap.find(idCurFolder)) == m_WearActionMap.end()) + { + const LLViewerInventoryCategory* pFolder = gInventory.getCategory(idCurFolder); + if ((!pFolder) || (gInventory.getRootFolderID() == pFolder->getParentUUID())) + break; + idCurFolder = pFolder->getParentUUID(); + } + return (itCurFolder != m_WearActionMap.end()) ? itCurFolder->second : m_eWearAction; +} + +// Checked: 2010-09-30 (RLVa-1.2.1d) | Modified: RLVa-1.2.1d +bool RlvWearableItemCollector::onCollectFolder(const LLInventoryCategory* pFolder) +{ + // We treat folder links differently since they won't exist in the wearable folder list yet and their ancestry isn't relevant + bool fLinkedFolder = isLinkedFolder(pFolder->getUUID()); + if ( (!fLinkedFolder) && (m_Wearable.end() == std::find(m_Wearable.begin(), m_Wearable.end(), pFolder->getParentUUID())) ) + return false; // Not a linked folder or the child of a wearable folder + + const std::string& strFolder = pFolder->getName(); + if (strFolder.empty()) // Shouldn't happen but does... naughty Lindens + return false; + + bool fAttach = RlvForceWear::isWearAction(m_eWearAction); + bool fMatchAll = (!fLinkedFolder) && (m_eWearFlags & RlvForceWear::FLAG_MATCHALL); + + if ( (!fLinkedFolder) && (RlvInventory::isFoldedFolder(pFolder, false)) ) // Check for folder that should get folded under its parent + { + if ( (!fAttach) || (1 == RlvInventory::getDirectDescendentsItemCount(pFolder, LLAssetType::AT_OBJECT)) ) + { // When attaching there should only be 1 attachment in it + m_Folded.push_front(pFolder->getUUID()); + m_FoldingMap.insert(std::pair<LLUUID, LLUUID>(pFolder->getUUID(), pFolder->getParentUUID())); + } + } + else if ( (RLV_FOLDER_PREFIX_HIDDEN != strFolder[0]) && // Collect from any non-hidden child folder for *all + ( (fMatchAll) || (fLinkedFolder) ) && // ... and collect from linked folders + (!isLinkedFolder(pFolder->getParentUUID())) ) // ... but never from non-folded linked folder descendents + { + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + if ( (!RlvSettings::getEnableComposites()) || // ... if we're not checking composite folders + (!gRlvHandler.isCompositeFolder(pFolder)) || // ... or if it's not a composite folder + ((m_fAttach) && (gRlvHandler.canWearComposite(pFolder))) || // ... or if we're attaching and can attach it OR + (!m_fAttach) && (gRlvHandler.canTakeOffComposite(pFolder)) ) // ... or if we're detaching and can detach it + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + { + m_Wearable.push_front(pFolder->getUUID()); + m_WearActionMap.insert(std::pair<LLUUID, RlvForceWear::EWearAction>(pFolder->getUUID(), getWearActionNormal(pFolder))); + } + return (!fLinkedFolder) && (pFolder->getParentUUID() == m_idFolder); // Convenience for @getinvworn + } + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + else if ( (RlvSettings::getEnableComposites()) && + (RLV_FOLDER_PREFIX_HIDDEN == strFolder[0]) && // Hidden folder that's a... + (gRlvHandler.isCompositeFolder(pFolder)) && // ... composite folder which we... + ( ((m_fAttach) && (gRlvHandler.canWearComposite(pFolder))) || // ... are attaching and can attach OR + (!m_fAttach) && (gRlvHandler.canTakeOffComposite(pFolder)) ) ) // ... are detaching and can detach + { + m_Wearable.push_front(pFolder->getUUID()); + m_FoldingMap.insert(std::pair<LLUUID, LLUUID>(pFolder->getUUID(), idParent)); + } + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + + return false; +} + +// Checked: 2010-09-30 (RLVa-1.2.1d) | Modified: RLVa-1.2.1d +bool RlvWearableItemCollector::onCollectItem(const LLInventoryItem* pItem) +{ + bool fAttach = RlvForceWear::isWearAction(m_eWearAction); + + if ( (!fAttach) && (!RlvForceWear::isStrippable(pItem)) ) // Don't process "nostrip" items on detach + return false; + + const LLUUID& idParent = pItem->getParentUUID(); bool fRet = false; + switch (pItem->getType()) + { + case LLAssetType::AT_BODYPART: + if (!fAttach) + break; // Don't process body parts on detach + case LLAssetType::AT_CLOTHING: + fRet = ( (m_Wearable.end() != std::find(m_Wearable.begin(), m_Wearable.end(), idParent)) || + ( (fAttach) && (m_Folded.end() != std::find(m_Folded.begin(), m_Folded.end(), idParent)) && + (RlvForceWear::isStrippable(pItem)) ) ); + break; + case LLAssetType::AT_OBJECT: + fRet = ( (m_Wearable.end() != std::find(m_Wearable.begin(), m_Wearable.end(), idParent)) || + (m_Folded.end() != std::find(m_Folded.begin(), m_Folded.end(), idParent)) ) && + ( (!fAttach) || (RlvAttachPtLookup::hasAttachPointName(pItem)) || (RlvSettings::getEnableSharedWear()) ); + break; + #ifdef RLV_EXTENSION_FORCEWEAR_GESTURES + case LLAssetType::AT_GESTURE: + fRet = (m_Wearable.end() != std::find(m_Wearable.begin(), m_Wearable.end(), idParent)); + break; + #endif // RLV_EXTENSION_FORCEWEAR_GESTURES + #ifdef RLV_EXTENSION_FORCEWEAR_FOLDERLINKS + case LLAssetType::AT_CATEGORY: + if (LLAssetType::AT_LINK_FOLDER == pItem->getActualType()) + { + const LLUUID& idLinkedFolder = pItem->getLinkedUUID(); + LLViewerInventoryCategory* pLinkedFolder = gInventory.getCategory(idLinkedFolder); + // Link can't point to an outfit folder, or start a second level of indirection, or have the base folder as an ancestor + if ( (pLinkedFolder) && (LLFolderType::FT_OUTFIT != pLinkedFolder->getPreferredType()) && + (gInventory.isObjectDescendentOf(pItem->getUUID(), m_idFolder)) && + (!gInventory.isObjectDescendentOf(idLinkedFolder, m_idFolder)) ) + { + // Fold the contents of the linked folder under the folder the link is a child of + m_FoldingMap.insert(std::pair<LLUUID, LLUUID>(idLinkedFolder, pItem->getParentUUID())); + m_Linked.push_front(idLinkedFolder); + } + } + break; + #endif // RLV_EXTENSION_FORCEWEAR_FOLDERLINKS + default: + break; + } + return fRet; +} + +// Checked: 2010-03-20 (RLVa-1.2.0a) | Modified: RLVa-0.2.0d +bool RlvWearableItemCollector::operator()(LLInventoryCategory* pFolder, LLInventoryItem* pItem) +{ + // NOTE: this is used for more than was originally intended so only modify if you're sure it won't break something obscure + return (pFolder) ? onCollectFolder(pFolder) : ( (pItem) ? onCollectItem(pItem) : false ); +} + +// ============================================================================ +// General purpose inventory helper classes +// + +// Checked: 2013-10-12 (RLVa-1.4.9) +bool RlvFindAttachmentsOnPoint::operator()(LLInventoryCategory* pFolder, LLInventoryItem* pItem) +{ +#ifndef RLV_DEPRECATE_ATTACHPTNAMING + // First check if the item is attached to the attachment point; fall back to the item name otherwise + return (pItem) && (LLAssetType::AT_OBJECT == pItem->getType()) && + ( ((m_pAttachPt) && (m_pAttachPt->getAttachedObject(pItem->getLinkedUUID()))) || (RlvAttachPtLookup::getAttachPoint(pItem) == m_pAttachPt) ); +#else + return (pItem) && (LLAssetType::AT_OBJECT == pItem->getType()) && (m_pAttachPt) && (m_pAttachPt->getAttachedObject(pItem->getLinkedUUID())); +#endif // RLV_DEPRECATE_LEGACY_ATTACHPT +} + +// ============================================================================ diff --git a/indra/newview/rlvinventory.h b/indra/newview/rlvinventory.h new file mode 100644 index 0000000000000000000000000000000000000000..1899ece4e0597798260e4b0ba4c4c30eb814a3c3 --- /dev/null +++ b/indra/newview/rlvinventory.h @@ -0,0 +1,310 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#ifndef RLV_INVENTORY_H +#define RLV_INVENTORY_H + +#include "llinventoryfunctions.h" +#include "llinventorymodel.h" +#include "llinventoryobserver.h" +#include "llsingleton.h" +#include "llviewerinventory.h" + +#include "rlvhelper.h" +#include "rlvlocks.h" + +// ============================================================================ +// RlvInventory class declaration +// + +class RlvInventory : public LLSingleton<RlvInventory>, public LLInventoryObserver +{ +protected: + RlvInventory(); +public: + ~RlvInventory(); + + // LLInventoryObserver override + /*virtual*/ void changed(U32 mask); + + /* + * #RLV Shared inventory + */ +public: + typedef boost::signals2::signal<void (void)> callback_signal_t; + void addSharedRootIDChangedCallback(const callback_signal_t::slot_type& cb) { m_OnSharedRootIDChanged.connect(cb); } + // Find all folders that match a supplied criteria (clears the output array) + bool findSharedFolders(const std::string& strCriteria, LLInventoryModel::cat_array_t& folders) const; + // Gets the shared path for any shared items present in idItems (clears the output array) + bool getPath(const uuid_vec_t& idItems, LLInventoryModel::cat_array_t& folders) const; + // Returns a pointer to the shared root folder (if there is one) + LLViewerInventoryCategory* getSharedRoot() const; + const LLUUID& getSharedRootID() const; + // Returns a subfolder of idParent that starts with strFolderName (exact match > partial match) + LLViewerInventoryCategory* getSharedFolder(const LLUUID& idParent, const std::string& strFolderName) const; + // Looks up a folder from a path (relative to the shared root) + LLViewerInventoryCategory* getSharedFolder(const std::string& strPath) const; + // Returns the path of the supplied folder (relative to the shared root) + std::string getSharedPath(const LLViewerInventoryCategory* pFolder) const; + // Returns TRUE if the supplied folder is a descendent of the #RLV folder + bool isSharedFolder(const LLUUID& idFolder); + + /* + * Inventory fetching + */ +public: + void fetchSharedInventory(); + void fetchWornItems(); +protected: + void fetchSharedLinks(); + + /* + * General purpose helper functions + */ +public: + // Returns the number of sub-folders of the specified folder + static S32 getDirectDescendentsFolderCount(const LLInventoryCategory* pFolder); + // Returns the number of direct descendents of the specified folder that have the specified type asset type + static S32 getDirectDescendentsItemCount(const LLInventoryCategory* pFolder, LLAssetType::EType filterType); + // Returns the folder the items of the specified folder should folded into (can be the folder itself) + static const LLUUID& getFoldedParent(const LLUUID& idFolder, bool fCheckComposite); + // A "folded folder" is a folder whose items logically belong to the grandparent rather than the parent + static bool isFoldedFolder(const LLInventoryCategory* pFolder, bool fCheckComposite); + + /* + * Member variables + */ +protected: + bool m_fFetchStarted; // TRUE if we fired off an inventory fetch + bool m_fFetchComplete; // TRUE if everything was fetched + mutable LLUUID m_idRlvRoot; + callback_signal_t m_OnSharedRootIDChanged; + +private: + static const std::string cstrSharedRoot; + friend class RlvSharedInventoryFetcher; + friend class LLSingleton<RlvInventory>; +}; + +// ============================================================================ +// RlvRenameOnWearObserver - Handles "auto-rename-on-wear" for (linked) items living under #RLV +// + +class RlvRenameOnWearObserver : public LLInventoryFetchItemsObserver +{ +public: + RlvRenameOnWearObserver(const LLUUID& idItem) : LLInventoryFetchItemsObserver(idItem) {} + virtual ~RlvRenameOnWearObserver() {} + virtual void done(); +protected: + void doneIdle(); + static void onCategoryCreate(const LLSD& sdData, void* pParam); +}; + +// ============================================================================ +// "Give to #RLV" helper classes +// + +// [See LLInventoryTransactionObserver which says it's not entirely complete?] +// NOTE: the offer may span mulitple BulkUpdateInventory messages so if we're no longer around then (ie due to "delete this") then +// we'll miss those; in this specific case we only care about the *folder* though and that will be in the very first message +class RlvGiveToRLVTaskOffer : public LLInventoryObserver +{ +public: + RlvGiveToRLVTaskOffer(const LLUUID& idTransaction) : m_idTransaction(idTransaction) {} + /*virtual*/ void changed(U32 mask); +protected: + /*virtual*/ void done(); + void doneIdle(); + + typedef std::vector<LLUUID> folder_ref_t; + folder_ref_t m_Folders; + LLUUID m_idTransaction; +}; + +class RlvGiveToRLVAgentOffer : public LLInventoryFetchDescendentsObserver +{ +public: + RlvGiveToRLVAgentOffer(const LLUUID& idFolder) : LLInventoryFetchDescendentsObserver(idFolder) {} + /*virtual*/ void done(); +protected: + void doneIdle(); +}; + +// ============================================================================ +// RlvCriteriaCategoryCollector - Criteria based folder matching filter used by @findfolder and @findfolders +// + +class RlvCriteriaCategoryCollector : public LLInventoryCollectFunctor +{ +public: + RlvCriteriaCategoryCollector(const std::string& strCriteria) + { + std::string::size_type idxIt, idxLast = 0; + while (idxLast < strCriteria.length()) + { + idxIt = strCriteria.find("&&", idxLast); + if (std::string::npos == idxIt) + idxIt = strCriteria.length(); + if (idxIt != idxLast) + m_Criteria.push_back(strCriteria.substr(idxLast, idxIt - idxLast)); + idxLast = idxIt + 2; + } + } + virtual ~RlvCriteriaCategoryCollector() {} + + virtual bool operator()(LLInventoryCategory* pFolder, LLInventoryItem* pItem) + { + if ( (!pFolder) || (m_Criteria.empty()) ) // We're only interested in matching folders, we don't care about items + return false; // (if there are no criteria then we don't want to return a match) + + std::string strFolderName = pFolder->getName(); + LLStringUtil::toLower(strFolderName); + + // NOTE: hidden or "give to #RLV" folders can never be a match + if ( (strFolderName.empty()) || + (RLV_FOLDER_PREFIX_HIDDEN == strFolderName[0]) || (RLV_FOLDER_PREFIX_PUTINV == strFolderName[0]) ) + { + return false; + } + + for (std::list<std::string>::const_iterator itCrit = m_Criteria.begin(); itCrit != m_Criteria.end(); ++itCrit) + if (std::string::npos == strFolderName.find(*itCrit)) + return false; + return true; + } + +protected: + std::list<std::string> m_Criteria; +}; + +// ============================================================================ +// RlvWearableItemCollector - Inventory item filter used by attach/detach/attachall/detachall/getinvworn +// + +class RlvWearableItemCollector : public LLInventoryCollectFunctor +{ +public: + RlvWearableItemCollector(const LLInventoryCategory* pFolder, RlvForceWear::EWearAction eAction, RlvForceWear::EWearFlags eFlags); + virtual ~RlvWearableItemCollector() {} + + virtual bool operator()(LLInventoryCategory* pFolder, LLInventoryItem* pItem); + + const LLUUID& getFoldedParent(const LLUUID& idFolder) const; + RlvForceWear::EWearAction getWearAction(const LLUUID& idFolder) const; + RlvForceWear::EWearAction getWearActionNormal(const LLInventoryCategory* pFolder); + RlvForceWear::EWearAction getWearActionFolded(const LLInventoryCategory* pFolder); + bool isLinkedFolder(const LLUUID& idFolder); +protected: + const LLUUID m_idFolder; + RlvForceWear::EWearAction m_eWearAction; + RlvForceWear::EWearFlags m_eWearFlags; + + bool onCollectFolder(const LLInventoryCategory* pFolder); + bool onCollectItem(const LLInventoryItem* pItem); + + std::list<LLUUID> m_Folded; + std::list<LLUUID> m_Linked; + std::list<LLUUID> m_Wearable; + std::map<LLUUID, LLUUID> m_FoldingMap; + std::map<LLUUID, RlvForceWear::EWearAction> m_WearActionMap; + + std::string m_strWearAddPrefix; + std::string m_strWearReplacePrefix; +}; + +// ============================================================================ +// General purpose inventory helper classes +// + +class RlvIsLinkType : public LLInventoryCollectFunctor +{ +public: + RlvIsLinkType() {} + /*virtual*/ ~RlvIsLinkType() {} + virtual bool operator()(LLInventoryCategory* pFolder, LLInventoryItem* pItem) { return (pItem) && (pItem->getIsLinkType()); } +}; + +// If the attachment item is linked in COF but isn't worn (or just detached) the function will return inconsistent information +class RlvFindAttachmentsOnPoint : public LLInventoryCollectFunctor +{ +public: + RlvFindAttachmentsOnPoint(const LLViewerJointAttachment* pAttachPt) : m_pAttachPt(pAttachPt) {} + /*virtual*/ ~RlvFindAttachmentsOnPoint() {} + virtual bool operator()(LLInventoryCategory* pFolder, LLInventoryItem* pItem); +protected: + const LLViewerJointAttachment* m_pAttachPt; +}; + +// ============================================================================ +// RlvInventory inlined member functions +// + +// Checked: 2011-03-28 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g +inline LLViewerInventoryCategory* RlvInventory::getSharedRoot() const +{ + const LLUUID& idRlvRoot = getSharedRootID(); + return (idRlvRoot.notNull()) ? gInventory.getCategory(idRlvRoot) : NULL; +} + +// Checked: 2011-11-26 (RLVa-1.5.4a) | Added: RLVa-1.5.4a +inline const LLUUID& RlvInventory::getFoldedParent(const LLUUID& idFolder, bool fCheckComposite) +{ + LLViewerInventoryCategory* pFolder = gInventory.getCategory(idFolder); + while ((pFolder) && (isFoldedFolder(pFolder, fCheckComposite))) + pFolder = gInventory.getCategory(pFolder->getParentUUID()); + return (pFolder) ? pFolder->getUUID() : LLUUID::null; +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +inline bool RlvInventory::isFoldedFolder(const LLInventoryCategory* pFolder, bool fCheckComposite) +{ + return + // If legacy naming isn't enabled we can return early if the folder name doesn't start with a '.' (= the most common case) + (pFolder) && ( (RlvSettings::getEnableLegacyNaming()) || (RLV_FOLDER_PREFIX_HIDDEN == pFolder->getName().at(0)) ) && + ( + // .(<attachpt>) type folder + (0 != RlvAttachPtLookup::getAttachPointIndex(pFolder)) + // .(nostrip) folder + || ( (pFolder) && (".("RLV_FOLDER_FLAG_NOSTRIP")" == pFolder->getName()) ) + // Composite folder (if composite folders are enabled and we're asked to look for them) + #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS + || ( (fCheckComposite) && (RlvSettings::getEnableComposites()) && + (pFolder) && (RLV_FOLDER_PREFIX_HIDDEN == pFolder->getName().at(0)) && (isCompositeFolder(pFolder)) ) + #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS + ); +} + +// Checked: 2010-08-29 (RLVa-1.2.0c) | Added: RLVa-1.2.0c +inline bool RlvInventory::isSharedFolder(const LLUUID& idFolder) +{ + const LLViewerInventoryCategory* pRlvRoot = getSharedRoot(); + return (pRlvRoot) ? (pRlvRoot->getUUID() != idFolder) && (gInventory.isObjectDescendentOf(idFolder, pRlvRoot->getUUID())) : false; +} + +// ============================================================================ +// RlvWearableItemCollector inlined member functions +// + +// Checked: 2010-09-30 (RLVa-1.2.1d) | Added: RLVa-1.2.1d +inline bool RlvWearableItemCollector::isLinkedFolder(const LLUUID& idFolder) +{ + return (!m_Linked.empty()) && (m_Linked.end() != std::find(m_Linked.begin(), m_Linked.end(), idFolder)); +} + +// ============================================================================ + +#endif // RLV_INVENTORY_H diff --git a/indra/newview/rlvlocks.cpp b/indra/newview/rlvlocks.cpp new file mode 100644 index 0000000000000000000000000000000000000000..de8140a51bd76ac229a59c665bd05e5eb213621b --- /dev/null +++ b/indra/newview/rlvlocks.cpp @@ -0,0 +1,1323 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#include "llviewerprecompiledheaders.h" +#include "llagent.h" +#include "llappearancemgr.h" +#include "llattachmentsmgr.h" +#include "llinventoryobserver.h" +#include "lloutfitobserver.h" +#include "llviewerobjectlist.h" +#include "pipeline.h" + +#include "rlvlocks.h" +#include "rlvhelper.h" +#include "rlvinventory.h" + +// ============================================================================ +// RlvAttachPtLookup member functions +// + +std::map<std::string, S32> RlvAttachPtLookup::m_AttachPtLookupMap; + +// Checked: 2010-03-02 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvAttachPtLookup::initLookupTable() +{ + static bool fInitialized = false; + if (!fInitialized) + { + if ( (gAgentAvatarp) && (gAgentAvatarp->mAttachmentPoints.size() > 0) ) + { + std::string strAttachPtName; + for (LLVOAvatar::attachment_map_t::const_iterator itAttach = gAgentAvatarp->mAttachmentPoints.begin(); + itAttach != gAgentAvatarp->mAttachmentPoints.end(); ++itAttach) + { + const LLViewerJointAttachment* pAttachPt = itAttach->second; + if (pAttachPt) + { + strAttachPtName = pAttachPt->getName(); + LLStringUtil::toLower(strAttachPtName); + m_AttachPtLookupMap.insert(std::pair<std::string, S32>(strAttachPtName, itAttach->first)); + + // HACK: the RLV API randomly renames "Avatar Center" to "Root" so make sure we add it (but keep the official name) + if ("avatar center" == strAttachPtName) + { + m_AttachPtLookupMap.insert(std::pair<std::string, S32>("root", itAttach->first)); + } + } + } + fInitialized = true; + } + } +} + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Added: RLVa-0.2.2a +S32 RlvAttachPtLookup::getAttachPointIndex(const LLViewerJointAttachment* pAttachPt) +{ + if (isAgentAvatarValid()) + { + for (LLVOAvatar::attachment_map_t::const_iterator itAttach = gAgentAvatarp->mAttachmentPoints.begin(); + itAttach != gAgentAvatarp->mAttachmentPoints.end(); ++itAttach) + { + if (itAttach->second == pAttachPt) + return itAttach->first; + } + } + return 0; +} + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Modified: RLVa-1.0.1b +S32 RlvAttachPtLookup::getAttachPointIndex(const LLInventoryCategory* pFolder) +{ + if (!pFolder) + return 0; + + // RLVa-1.0.1 added support for legacy matching (See http://rlva.catznip.com/blog/2009/07/attachment-point-naming-convention/) + if (RlvSettings::getEnableLegacyNaming()) + return getAttachPointIndexLegacy(pFolder); + + // Otherwise the only valid way to specify an attachment point in a folder name is: ^\.\(\s+attachpt\s+\) + std::string::size_type idxMatch; + std::string strAttachPt = rlvGetFirstParenthesisedText(pFolder->getName(), &idxMatch); + LLStringUtil::trim(strAttachPt); + + return ( (1 == idxMatch) && (RLV_FOLDER_PREFIX_HIDDEN == pFolder->getName().at(0)) ) ? getAttachPointIndex(strAttachPt) : 0; +} + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +S32 RlvAttachPtLookup::getAttachPointIndex(const LLInventoryItem* pItem, bool fFollowLinks /*=true*/) +{ + // Sanity check - if it's not an object then it can't have an attachment point + if ( (!pItem) || (LLAssetType::AT_OBJECT != pItem->getType()) ) + return 0; + + // If the item is an inventory link then we first examine its target before examining the link itself + if ( (LLAssetType::AT_LINK == pItem->getActualType()) && (fFollowLinks) ) + { + S32 idxAttachPt = getAttachPointIndex(gInventory.getItem(pItem->getLinkedUUID()), false); + if (idxAttachPt) + return idxAttachPt; + } + + // The attachment point should be placed at the end of the item's name, surrounded by parenthesis + // (if there is no such text then strAttachPt will be an empty string which is fine since it means we'll look at the item's parent) + // (if the item is an inventory link then we only look at its containing folder and never examine its name) + std::string strAttachPt = + (LLAssetType::AT_LINK != pItem->getActualType()) ? rlvGetLastParenthesisedText(pItem->getName()) : LLStringUtil::null; + LLStringUtil::trim(strAttachPt); + + // If the item is modify : we look at the item's name first and only then at the containing folder + // If the item is no modify: we look at the containing folder's name first and only then at the item itself + S32 idxAttachPt = 0; + if (pItem->getPermissions().allowModifyBy(gAgent.getID())) + { + idxAttachPt = (!strAttachPt.empty()) ? getAttachPointIndex(strAttachPt) : 0; + if (!idxAttachPt) + idxAttachPt = getAttachPointIndex(gInventory.getCategory(pItem->getParentUUID())); + } + else + { + idxAttachPt = getAttachPointIndex(gInventory.getCategory(pItem->getParentUUID())); + if ( (!idxAttachPt) && (!strAttachPt.empty()) ) + idxAttachPt = getAttachPointIndex(strAttachPt); + } + return idxAttachPt; +} + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Added: RLVa-1.0.1b +S32 RlvAttachPtLookup::getAttachPointIndexLegacy(const LLInventoryCategory* pFolder) +{ + // Hopefully some day this can just be deprecated (see http://rlva.catznip.com/blog/2009/07/attachment-point-naming-convention/) + if ( (!pFolder) || (pFolder->getName().empty()) ) + return 0; + + // Check for a (...) block *somewhere* in the name + std::string::size_type idxMatch; + std::string strAttachPt = rlvGetFirstParenthesisedText(pFolder->getName(), &idxMatch); + if (!strAttachPt.empty()) + { + // Could be "(attachpt)", ".(attachpt)" or "Folder name (attachpt)" + if ( (0 != idxMatch) && ((1 != idxMatch) || (RLV_FOLDER_PREFIX_HIDDEN == pFolder->getName().at(0)) ) && // No '(' or '.(' start + (idxMatch + strAttachPt.length() + 1 != pFolder->getName().length()) ) // or there's extra text + { + // It's definitely not one of the first two so assume it's the last form (in which case we need the last paranthesised block) + strAttachPt = rlvGetLastParenthesisedText(pFolder->getName()); + } + } + else + { + // There's no paranthesised block, but it could still be "attachpt" or ".attachpt" (just strip away the '.' from the last one) + strAttachPt = pFolder->getName(); + if (RLV_FOLDER_PREFIX_HIDDEN == strAttachPt[0]) + strAttachPt.erase(0, 1); + } + return getAttachPointIndex(strAttachPt); +} + +// ============================================================================ +// RlvAttachmentLocks member functions +// + +RlvAttachmentLocks gRlvAttachmentLocks; + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvAttachmentLocks::addAttachmentLock(const LLUUID& idAttachObj, const LLUUID& idRlvObj) +{ +/* + // Sanity check - make sure it's an object we know about + if ( (m_Objects.find(idRlvObj) == m_Objects.end()) || (!idxAttachPt) ) + return; // If (idxAttachPt) == 0 then: (pObj == NULL) || (pObj->isAttachment() == FALSE) +*/ + +#ifndef RLV_RELEASE + LLViewerObject* pDbgObj = gObjectList.findObject(idAttachObj); + // Assertion: the object specified by idAttachObj exists/is rezzed, is an attachment and always specifies the root + RLV_VERIFY( (pDbgObj) && (pDbgObj->isAttachment()) && (pDbgObj == pDbgObj->getRootEdit()) ); +#endif // RLV_RELEASE + + m_AttachObjRem.insert(std::pair<LLUUID, LLUUID>(idAttachObj, idRlvObj)); + updateLockedHUD(); +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvAttachmentLocks::addAttachmentPointLock(S32 idxAttachPt, const LLUUID& idRlvObj, ERlvLockMask eLock) +{ +/* + // Sanity check - make sure it's an object we know about + if ( (m_Objects.find(idRlvObj) == m_Objects.end()) || (!idxAttachPt) ) + return; // If (idxAttachPt) == 0 then: (pObj == NULL) || (pObj->isAttachment() == FALSE) +*/ + + // NOTE: m_AttachPtXXX can contain duplicate <idxAttachPt, idRlvObj> pairs (ie @detach:spine=n,detach=n from an attachment on spine) + if (eLock & RLV_LOCK_REMOVE) + { + m_AttachPtRem.insert(std::pair<S32, LLUUID>(idxAttachPt, idRlvObj)); + updateLockedHUD(); + } + if (eLock & RLV_LOCK_ADD) + m_AttachPtAdd.insert(std::pair<S32, LLUUID>(idxAttachPt, idRlvObj)); +} + +// Checked: 2011-05-22 (RLVa-1.3.1b) | Added: RLVa-1.3.1b +bool RlvAttachmentLocks::canAttach() const +{ + if (isAgentAvatarValid()) + { + for (LLVOAvatar::attachment_map_t::const_iterator itAttachPt = gAgentAvatarp->mAttachmentPoints.begin(); + itAttachPt != gAgentAvatarp->mAttachmentPoints.end(); ++itAttachPt) + { + if (!isLockedAttachmentPoint(itAttachPt->first, RLV_LOCK_ADD)) + return true; + } + } + return false; +} + +// Checked: 2010-08-07 (RLVa-1.2.0i) | Modified: RLVa-1.2.0i +bool RlvAttachmentLocks::canDetach(const LLViewerJointAttachment* pAttachPt, bool fDetachAll /*=false*/) const +{ + // (fDetachAll) | (isLockedAttachment) + // =================================== + // F | F => unlocked attachment => return true + // F | T => locked attachment => keep going + // T | F => unlocked attachment => keep going + // T | T => locked attachment => return false + // -> inside the loop : (A xor (not B)) condition and return !fDetachAll + // -> outside the loop: return fDetachAll + // fDetachAll == false : return false => all attachments are locked + // fDetachAll == true : return true => all attachments are unlocked + if (pAttachPt) + { + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) + { + if ( (fDetachAll) ^ (!isLockedAttachment(*itAttachObj)) ) + return !fDetachAll; + } + } + return (pAttachPt) && (fDetachAll); +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +bool RlvAttachmentLocks::hasLockedAttachment(const LLViewerJointAttachment* pAttachPt) const +{ + if (pAttachPt) + { + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) + { + if (isLockedAttachment(*itAttachObj)) + return true; + } + } + return false; +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +bool RlvAttachmentLocks::isLockedAttachmentExcept(const LLViewerObject* pObj, const LLUUID& idRlvObj) const +{ + if (idRlvObj.isNull()) + return isLockedAttachment(pObj); + + // If pObj is valid then it should always specify a root since we store root UUIDs in m_AttachObjRem + RLV_ASSERT( (!pObj) || (pObj == pObj->getRootEdit()) ); + + // Loop over every object that has the specified attachment locked (but ignore any locks owned by idRlvObj) + for (rlv_attachobjlock_map_t::const_iterator itAttachObj = m_AttachObjRem.lower_bound(pObj->getID()), + endAttachObj = m_AttachObjRem.upper_bound(pObj->getID()); itAttachObj != endAttachObj; ++itAttachObj) + { + if (itAttachObj->second != idRlvObj) + return true; + } + return isLockedAttachmentPointExcept(RlvAttachPtLookup::getAttachPointIndex(pObj), RLV_LOCK_REMOVE, idRlvObj); +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.0.5b +bool RlvAttachmentLocks::isLockedAttachmentPointExcept(S32 idxAttachPt, ERlvLockMask eLock, const LLUUID& idRlvObj) const +{ + if (idRlvObj.isNull()) + return isLockedAttachmentPoint(idxAttachPt, eLock); + + // Loop over every object that has the specified attachment point locked (but ignore any locks owned by idRlvObj) + if (eLock & RLV_LOCK_REMOVE) + { + for (rlv_attachptlock_map_t::const_iterator itAttachPt = m_AttachPtRem.lower_bound(idxAttachPt), + endAttachPt = m_AttachPtRem.upper_bound(idxAttachPt); itAttachPt != endAttachPt; ++itAttachPt) + { + if (itAttachPt->second != idRlvObj) + return true; + } + } + if (eLock & RLV_LOCK_ADD) + { + for (rlv_attachptlock_map_t::const_iterator itAttachPt = m_AttachPtAdd.lower_bound(idxAttachPt), + endAttachPt = m_AttachPtAdd.upper_bound(idxAttachPt); itAttachPt != endAttachPt; ++itAttachPt) + { + if (itAttachPt->second != idRlvObj) + return true; + } + } + return false; +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvAttachmentLocks::removeAttachmentLock(const LLUUID& idAttachObj, const LLUUID& idRlvObj) +{ +/* + // Sanity check - make sure it's an object we know about + if ( (m_Objects.find(idRlvObj) == m_Objects.end()) || (!idxAttachPt) ) + return; // If (idxAttachPt) == 0 then: (pObj == NULL) || (pObj->isAttachment() == FALSE) +*/ + +#ifndef RLV_RELEASE + // NOTE: pObj *can* be NULL [see comments for @detach=n in RlvHandler::onAddRemDetach()] + const LLViewerObject* pDbgObj = gObjectList.findObject(idAttachObj); + // Assertion: if the object exists then it's an attachment and always specifies the root + RLV_VERIFY( (!pDbgObj) || ((pDbgObj->isAttachment()) && (pDbgObj == pDbgObj->getRootEdit())) ); +#endif // RLV_RELEASE + + // NOTE: try to remove the lock even if pObj isn't an attachment (ie in case the user was able to "Drop" it) + RLV_ASSERT( m_AttachObjRem.lower_bound(idAttachObj) != m_AttachObjRem.upper_bound(idAttachObj) ); // The lock should always exist + for (rlv_attachobjlock_map_t::iterator itAttachObj = m_AttachObjRem.lower_bound(idAttachObj), + endAttachObj = m_AttachObjRem.upper_bound(idAttachObj); itAttachObj != endAttachObj; ++itAttachObj) + { + if (idRlvObj == itAttachObj->second) + { + m_AttachObjRem.erase(itAttachObj); + updateLockedHUD(); + break; + } + } +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +void RlvAttachmentLocks::removeAttachmentPointLock(S32 idxAttachPt, const LLUUID& idRlvObj, ERlvLockMask eLock) +{ +/* + // Sanity check - make sure it's an object we know about + if ( (m_Objects.find(idRlvObj) == m_Objects.end()) || (!idxAttachPt) ) + return; // If (idxAttachPt) == 0 then: (pObj == NULL) || (pObj->isAttachment() == FALSE) +*/ + + if (eLock & RLV_LOCK_REMOVE) + { + RLV_ASSERT( m_AttachPtRem.lower_bound(idxAttachPt) != m_AttachPtRem.upper_bound(idxAttachPt) ); // The lock should always exist + for (rlv_attachptlock_map_t::iterator itAttachPt = m_AttachPtRem.lower_bound(idxAttachPt), + endAttachPt = m_AttachPtRem.upper_bound(idxAttachPt); itAttachPt != endAttachPt; ++itAttachPt) + { + if (idRlvObj == itAttachPt->second) + { + m_AttachPtRem.erase(itAttachPt); + updateLockedHUD(); + break; + } + } + } + if (eLock & RLV_LOCK_ADD) + { + RLV_ASSERT( m_AttachPtAdd.lower_bound(idxAttachPt) != m_AttachPtAdd.upper_bound(idxAttachPt) ); // The lock should always exist + for (rlv_attachptlock_map_t::iterator itAttachPt = m_AttachPtAdd.lower_bound(idxAttachPt), + endAttachPt = m_AttachPtAdd.upper_bound(idxAttachPt); itAttachPt != endAttachPt; ++itAttachPt) + { + if (idRlvObj == itAttachPt->second) + { + m_AttachPtAdd.erase(itAttachPt); + break; + } + } + } +} + +// Checked: 2010-08-22 (RLVa-1.2.1a) | Modified: RLVa-1.2.1a +void RlvAttachmentLocks::updateLockedHUD() +{ + if (!isAgentAvatarValid()) + return; + + m_fHasLockedHUD = false; + for (LLVOAvatar::attachment_map_t::const_iterator itAttachPt = gAgentAvatarp->mAttachmentPoints.begin(); + itAttachPt != gAgentAvatarp->mAttachmentPoints.end(); ++itAttachPt) + { + const LLViewerJointAttachment* pAttachPt = itAttachPt->second; + if ( (pAttachPt) && (pAttachPt->getIsHUDAttachment()) && (hasLockedAttachment(pAttachPt)) ) + { + m_fHasLockedHUD = true; + break; + } + } + + // Reset HUD visibility and wireframe options if at least one HUD attachment is locked + if (m_fHasLockedHUD) + { + LLPipeline::sShowHUDAttachments = TRUE; + gUseWireframe = FALSE; + } +} + +// Checked: 2010-03-11 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +bool RlvAttachmentLocks::verifyAttachmentLocks() +{ + bool fSuccess = true; + + // Verify attachment locks + rlv_attachobjlock_map_t::iterator itAttachObj = m_AttachObjRem.begin(), itCurrentObj; + while (itAttachObj != m_AttachObjRem.end()) + { + itCurrentObj = itAttachObj++; + + // If the attachment no longer exists (or is no longer attached) then we shouldn't be holding a lock to it + const LLViewerObject* pAttachObj = gObjectList.findObject(itCurrentObj->first); + if ( (!pAttachObj) || (!pAttachObj->isAttachment()) ) + { + m_AttachObjRem.erase(itCurrentObj); + fSuccess = false; + } + } + + return fSuccess; +} + +// ============================================================================ +// RlvAttachmentLockWatchdog member functions +// + +// Checked: 2010-09-23 (RLVa-1.2.1d) | Added: RLVa-1.2.1d +bool RlvAttachmentLockWatchdog::RlvWearInfo::isAddLockedAttachPt(S32 idxAttachPt) const +{ + // If idxAttachPt has no entry in attachPts then the attachment point wasn't RLV_LOCK_ADD restricted at the time we were instantiated + // [See RlvAttachmentLockWatchdog::onWearAttachment()] + return (attachPts.find(idxAttachPt) != attachPts.end()); +} + +// Checked: 2010-09-23 (RLVa-1.2.1d) | Added: RLVa-1.2.1d +void RlvAttachmentLockWatchdog::RlvWearInfo::dumpInstance() const +{ + const LLViewerInventoryItem* pItem = gInventory.getItem(idItem); + std::string strItemId = idItem.asString(); + + std::string strTemp = llformat("Wear %s '%s' (%s)", + (RLV_WEAR_ADD == eWearAction) ? "add" : "replace", (pItem) ? pItem->getName().c_str() : "missing", strItemId.c_str()); + RLV_INFOS << strTemp.c_str() << RLV_ENDL; + + if (!attachPts.empty()) + { + std::string strEmptyAttachPt; + for (std::map<S32, uuid_vec_t>::const_iterator itAttachPt = attachPts.begin(); itAttachPt != attachPts.end(); ++itAttachPt) + { + const LLViewerJointAttachment* pAttachPt = + get_if_there(gAgentAvatarp->mAttachmentPoints, itAttachPt->first, (LLViewerJointAttachment*)NULL); + if (!itAttachPt->second.empty()) + { + for (uuid_vec_t::const_iterator itAttach = itAttachPt->second.begin(); itAttach != itAttachPt->second.end(); ++itAttach) + { + pItem = gInventory.getItem(*itAttach); + strItemId = (*itAttach).asString(); + + strTemp = llformat(" -> %s : %s (%s)", + pAttachPt->getName().c_str(), (pItem) ? pItem->getName().c_str() : "missing", strItemId.c_str()); + RLV_INFOS << strTemp.c_str() << RLV_ENDL; + } + } + else + { + if (!strEmptyAttachPt.empty()) + strEmptyAttachPt += ", "; + strEmptyAttachPt += pAttachPt->getName(); + } + } + if (!strEmptyAttachPt.empty()) + RLV_INFOS << " -> " << strEmptyAttachPt << " : empty" << RLV_ENDL; + } + else + { + RLV_INFOS << " -> no attachment point information" << RLV_ENDL; + } +} + +// Checked: 2010-07-28 (RLVa-1.2.0i) | Modified: RLVa-1.2.0i +void RlvAttachmentLockWatchdog::detach(const LLViewerObject* pAttachObj) +{ + if (pAttachObj) + { + gMessageSystem->newMessage("ObjectDetach"); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + + gMessageSystem->nextBlockFast(_PREHASH_ObjectData); + gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, pAttachObj->getLocalID()); + if (std::find(m_PendingDetach.begin(), m_PendingDetach.end(), pAttachObj->getAttachmentItemID()) == m_PendingDetach.end()) + m_PendingDetach.push_back(pAttachObj->getAttachmentItemID()); + + gMessageSystem->sendReliable(gAgent.getRegionHost() ); + + // HACK-RLVa: force the region to send out an ObjectUpdate for the old attachment so obsolete viewers will remember it exists + S32 idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(pAttachObj); + const LLViewerJointAttachment* pAttachPt = + (isAgentAvatarValid()) ? get_if_there(gAgentAvatarp->mAttachmentPoints, (S32)idxAttachPt, (LLViewerJointAttachment*)NULL) : NULL; + if ( (pAttachPt) && (!pAttachPt->getIsHUDAttachment()) && (pAttachPt->mAttachedObjects.size() > 1) ) + { + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) + { + if (pAttachObj != *itAttachObj) + { + LLSelectMgr::instance().deselectAll(); + LLSelectMgr::instance().selectObjectAndFamily(*itAttachObj); + LLSelectMgr::instance().deselectAll(); + break; + } + } + } + } +} + +// Checked: 2011-06-13 (RLVa-1.3.1b) | Modified: RLVa-1.3.1b +void RlvAttachmentLockWatchdog::detach(S32 idxAttachPt, const uuid_vec_t& idsAttachObjExcept) +{ + const LLViewerJointAttachment* pAttachPt = RlvAttachPtLookup::getAttachPoint(idxAttachPt); + if (!pAttachPt) + return; + + std::vector<const LLViewerObject*> attachObjs; + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) + { + const LLViewerObject* pAttachObj = *itAttachObj; + if (idsAttachObjExcept.end() == std::find(idsAttachObjExcept.begin(), idsAttachObjExcept.end(), pAttachObj->getID())) + attachObjs.push_back(pAttachObj); + } + + if (!attachObjs.empty()) + { + gMessageSystem->newMessage("ObjectDetach"); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + + for (std::vector<const LLViewerObject*>::const_iterator itAttachObj = attachObjs.begin(); itAttachObj != attachObjs.end(); ++itAttachObj) + { + const LLViewerObject* pAttachObj = *itAttachObj; + gMessageSystem->nextBlockFast(_PREHASH_ObjectData); + gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, pAttachObj->getLocalID()); + if (m_PendingDetach.end() == std::find(m_PendingDetach.begin(), m_PendingDetach.end(), pAttachObj->getAttachmentItemID())) + m_PendingDetach.push_back(pAttachObj->getAttachmentItemID()); + } + + gMessageSystem->sendReliable(gAgent.getRegionHost()); + + // HACK-RLVa: force the region to send out an ObjectUpdate for the old attachment so obsolete viewers will remember it exists + if ( (!pAttachPt->getIsHUDAttachment()) && (pAttachPt->mAttachedObjects.size() > attachObjs.size()) ) + { + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) + { + if (std::find(attachObjs.begin(), attachObjs.end(), *itAttachObj) == attachObjs.end()) + { + LLSelectMgr::instance().deselectAll(); + LLSelectMgr::instance().selectObjectAndFamily(*itAttachObj); + LLSelectMgr::instance().deselectAll(); + break; + } + } + } + } +} + +// Checked: 2010-09-23 (RLVa-1.2.1d) | Modified: RLVa-1.2.1d +void RlvAttachmentLockWatchdog::onAttach(const LLViewerObject* pAttachObj, const LLViewerJointAttachment* pAttachPt) +{ + S32 idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(pAttachObj); + const LLUUID& idAttachItem = (pAttachObj) ? pAttachObj->getAttachmentItemID() : LLUUID::null; + RLV_ASSERT( (!isAgentAvatarValid()) || ((idxAttachPt) && (idAttachItem.notNull())) ); + if ( (!idxAttachPt) || (idAttachItem.isNull()) ) + return; + + // Check if the attachment point has a pending "reattach" + rlv_attach_map_t::iterator itAttach = m_PendingAttach.lower_bound(idxAttachPt), itAttachEnd = m_PendingAttach.upper_bound(idxAttachPt); + if (itAttach != itAttachEnd) + { + bool fPendingReattach = false; + for (; itAttach != itAttachEnd; ++itAttach) + { + if (idAttachItem == itAttach->second.idItem) + { + fPendingReattach = true; + RlvBehaviourNotifyHandler::onReattach(pAttachPt, true); + m_PendingAttach.erase(itAttach); + break; + } + } + if (!fPendingReattach) + { + detach(pAttachObj); + RlvBehaviourNotifyHandler::onAttach(pAttachPt, false); + } + return; + } + + // Check if the attach was allowed at the time it was requested + rlv_wear_map_t::iterator itWear = m_PendingWear.find(idAttachItem); bool fAttachAllowed = true; + if (itWear != m_PendingWear.end()) + { + // We'll need to return the attachment point to its previous state if it was non-attachable + if (itWear->second.isAddLockedAttachPt(idxAttachPt)) + { + // Get the saved state of the attachment point (but do nothing if the item itself was already worn then) + std::map<S32, uuid_vec_t>::iterator itAttachPrev = itWear->second.attachPts.find(idxAttachPt); + RLV_ASSERT(itAttachPrev != itWear->second.attachPts.end()); + if (std::find(itAttachPrev->second.begin(), itAttachPrev->second.end(), idAttachItem) == itAttachPrev->second.end()) + { + // If it was empty we need to detach everything on the attachment point; if it wasn't we need to restore it to what it was + if (itAttachPrev->second.empty()) + { + detach(idxAttachPt); + } + else + { + // Iterate over all the current attachments and force detach any that shouldn't be there + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) + { + const LLViewerObject* pAttachObj = *itAttachObj; + + uuid_vec_t::iterator itAttach = + std::find(itAttachPrev->second.begin(), itAttachPrev->second.end(), pAttachObj->getAttachmentItemID()); + if (itAttach == itAttachPrev->second.end()) + detach(pAttachObj); + else + itAttachPrev->second.erase(itAttach); + } + + // Whatever is left is something that needs to be reattached + for (uuid_vec_t::const_iterator itAttach = itAttachPrev->second.begin(); + itAttach != itAttachPrev->second.end(); ++itAttach) + { + m_PendingAttach.insert(std::pair<S32, RlvReattachInfo>(idxAttachPt, RlvReattachInfo(*itAttach))); + } + } + fAttachAllowed = false; + } + } + else if (RLV_WEAR_REPLACE == itWear->second.eWearAction) + { + // Now that we know where this attaches to, check if we can actually perform a "replace" + uuid_vec_t idsAttachObjExcept; + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + ((itAttachObj != pAttachPt->mAttachedObjects.end()) && (fAttachAllowed)); ++itAttachObj) + { + if ( (pAttachObj != *itAttachObj) && (gRlvAttachmentLocks.isLockedAttachment(*itAttachObj)) ) + { + // Fail if we encounter a non-detachable attachment (unless we're only replacing detachable attachments) + if (gSavedSettings.getBOOL("RLVaWearReplaceUnlocked")) + idsAttachObjExcept.push_back((*itAttachObj)->getID()); + else + fAttachAllowed = false; + } + } + + if (fAttachAllowed) + { + idsAttachObjExcept.push_back(pAttachObj->getID()); // Replace == allowed: detach everything except the new attachment + detach(idxAttachPt, idsAttachObjExcept); // or detach all *unlocked* attachments except the new attachment + } + else + { + detach(pAttachObj); // Replace != allowed: detach the new attachment + } + } + m_PendingWear.erase(itWear); // No need to start the timer since it should be running already if '!m_PendingWear.empty()' + } + RlvBehaviourNotifyHandler::onAttach(pAttachPt, fAttachAllowed); +} + +// Checked: 2010-07-28 (RLVa-1.2.0i) | Modified: RLVa-1.2.0i +void RlvAttachmentLockWatchdog::onDetach(const LLViewerObject* pAttachObj, const LLViewerJointAttachment* pAttachPt) +{ + S32 idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(pAttachPt); + const LLUUID& idAttachItem = (pAttachObj) ? pAttachObj->getAttachmentItemID() : LLUUID::null; + RLV_ASSERT( (!isAgentAvatarValid()) || ((idxAttachPt) && (idAttachItem.notNull())) ); + if ( (!idxAttachPt) || (idAttachItem.isNull()) ) + return; + + // If it's an attachment that's pending force-detach then we don't want to do anything (even if it's currently "remove locked") + rlv_detach_map_t::iterator itDetach = std::find(m_PendingDetach.begin(), m_PendingDetach.end(), idAttachItem); + if (itDetach != m_PendingDetach.end()) + { + m_PendingDetach.erase(itDetach); + RlvBehaviourNotifyHandler::onDetach(pAttachPt, true); + return; + } + + // If the attachment is currently "remove locked" then we should reattach it (unless it's already pending reattach) + bool fDetachAllowed = true; + if (gRlvAttachmentLocks.isLockedAttachment(pAttachObj)) + { + bool fPendingAttach = false; + for (rlv_attach_map_t::const_iterator itReattach = m_PendingAttach.lower_bound(idxAttachPt), + itReattachEnd = m_PendingAttach.upper_bound(idxAttachPt); itReattach != itReattachEnd; ++itReattach) + { + if (itReattach->second.idItem == idAttachItem) + { + fPendingAttach = true; + break; + } + } + + // TODO-RLVa: [RLVa-1.2.1] we should re-add the item to COF as well to make sure it'll reattach when the user relogs + // -> check the call order in LLVOAvatarSelf::detachObject() since COF removal happens *after* we're called + if (!fPendingAttach) + { + m_PendingAttach.insert(std::pair<S32, RlvReattachInfo>(idxAttachPt, RlvReattachInfo(idAttachItem))); + startTimer(); + } + fDetachAllowed = false; + } + RlvBehaviourNotifyHandler::onDetach(pAttachPt, fDetachAllowed); +} + +// Checked: 2010-03-05 (RLVa-1.2.0a) | Modified: RLVa-1.0.5b +void RlvAttachmentLockWatchdog::onSavedAssetIntoInventory(const LLUUID& idItem) +{ + for (rlv_attach_map_t::iterator itAttach = m_PendingAttach.begin(); itAttach != m_PendingAttach.end(); ++itAttach) + { + if ( (!itAttach->second.fAssetSaved) && (idItem == itAttach->second.idItem) ) + { + LLAttachmentsMgr::instance().addAttachment(itAttach->second.idItem, itAttach->first, true, true); + itAttach->second.tsAttach = LLFrameTimer::getElapsedSeconds(); + } + } +} + +// Checked: 2010-03-05 (RLVa-1.2.0a) | Modified: RLVa-1.0.5b +BOOL RlvAttachmentLockWatchdog::onTimer() +{ + // RELEASE-RLVa: [SL-2.0.0] This will need rewriting for "ENABLE_MULTIATTACHMENTS" + F64 tsCurrent = LLFrameTimer::getElapsedSeconds(); + + // Garbage collect (failed) wear requests older than 60 seconds + rlv_wear_map_t::iterator itWear = m_PendingWear.begin(); + while (itWear != m_PendingWear.end()) + { + if (itWear->second.tsWear + 60 < tsCurrent) + m_PendingWear.erase(itWear++); + else + ++itWear; + } + + // Walk over the pending reattach list + rlv_attach_map_t::iterator itAttach = m_PendingAttach.begin(); + while (itAttach != m_PendingAttach.end()) + { + // Sanity check - make sure the item is still in the user's inventory + if (gInventory.getItem(itAttach->second.idItem) == NULL) + { + m_PendingAttach.erase(itAttach++); + continue; + } + + // Force an attach if we haven't gotten a SavedAssetIntoInventory message after 15 seconds + // (or if it's been 30 seconds since we last tried to reattach the item) + bool fAttach = false; + if ( (!itAttach->second.fAssetSaved) && (itAttach->second.tsDetach + 15 < tsCurrent) ) + { + itAttach->second.fAssetSaved = true; + fAttach = true; + } + else if ( (itAttach->second.fAssetSaved) && (itAttach->second.tsAttach + 30 < tsCurrent) ) + { + fAttach = true; + } + + if (fAttach) + { + LLAttachmentsMgr::instance().addAttachment(itAttach->second.idItem, itAttach->first, true, true); + itAttach->second.tsAttach = tsCurrent; + } + + ++itAttach; + } + + return ( (m_PendingAttach.empty()) && (m_PendingDetach.empty()) && (m_PendingWear.empty()) ); +} + +// Checked: 2010-07-28 (RLVa-1.2.0i) | Modified: RLVa-1.2.0i +void RlvAttachmentLockWatchdog::onWearAttachment(const LLUUID& idItem, ERlvWearMask eWearAction) +{ + // We only need to keep track of user wears if there's actually anything locked + RLV_ASSERT(idItem.notNull()); + if ( (idItem.isNull()) || (!isAgentAvatarValid()) || (!gRlvAttachmentLocks.hasLockedAttachmentPoint(RLV_LOCK_ANY)) ) + return; + + // If the attachment point this will end up being attached to is: + // - unlocked : nothing should happen (from RLVa's point of view) + // - RLV_LOCK_ADD: the new attachment should get detached and the current one(s) reattached (unless it's currently empty) + // - RLV_LOCK_REM: + // o eWearAction == RLV_WEAR_ADD : nothing should happen (from RLVa's point of view) + // o eWearAction == RLV_WEAR_REPLACE : examine whether the new attachment can indeed replace/detach the old one + RlvWearInfo infoWear(idItem, eWearAction); + RLV_ASSERT( (RLV_WEAR_ADD == eWearAction) || (RLV_WEAR_REPLACE == eWearAction) ); // One of the two, but never both + for (LLVOAvatar::attachment_map_t::const_iterator itAttachPt = gAgentAvatarp->mAttachmentPoints.begin(); + itAttachPt != gAgentAvatarp->mAttachmentPoints.end(); ++itAttachPt) + { + const LLViewerJointAttachment* pAttachPt = itAttachPt->second; + // We only need to know which attachments were present for RLV_LOCK_ADD locked attachment points (and not RLV_LOCK_REM locked ones) + if (gRlvAttachmentLocks.isLockedAttachmentPoint(pAttachPt, RLV_LOCK_ADD)) + { + uuid_vec_t attachObjs; + for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); + itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) + { + const LLViewerObject* pAttachObj = *itAttachObj; + if (std::find(m_PendingDetach.begin(), m_PendingDetach.end(), pAttachObj->getAttachmentItemID()) != m_PendingDetach.end()) + continue; // Exclude attachments that are pending a force-detach + attachObjs.push_back(pAttachObj->getAttachmentItemID()); + } + infoWear.attachPts.insert(std::pair<S32, uuid_vec_t>(itAttachPt->first, attachObjs)); + } + } + + m_PendingWear.insert(std::pair<LLUUID, RlvWearInfo>(idItem, infoWear)); +#ifdef RLV_DEBUG + infoWear.dumpInstance(); +#endif // RLV_RELEASE + startTimer(); +} + +// ============================================================================ +// RlvWearableLocks member functions +// + +RlvWearableLocks gRlvWearableLocks; + +// Checked: 2010-03-18 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +void RlvWearableLocks::addWearableTypeLock(LLWearableType::EType eType, const LLUUID& idRlvObj, ERlvLockMask eLock) +{ +/* + // Sanity check - make sure it's an object we know about + if ( (m_Objects.find(idRlvObj) == m_Objects.end()) || (!idxAttachPt) ) + return; // If (idxAttachPt) == 0 then: (pObj == NULL) || (pObj->isAttachment() == FALSE) +*/ + + // NOTE: m_WearableTypeXXX can contain duplicate <eType, idRlvObj> pairs (ie @remoutfit:shirt=n,remoutfit=n from the same object) + if (eLock & RLV_LOCK_REMOVE) + m_WearableTypeRem.insert(std::pair<LLWearableType::EType, LLUUID>(eType, idRlvObj)); + if (eLock & RLV_LOCK_ADD) + m_WearableTypeAdd.insert(std::pair<LLWearableType::EType, LLUUID>(eType, idRlvObj)); +} + +// Checked: 2010-03-19 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +bool RlvWearableLocks::canRemove(LLWearableType::EType eType) const +{ + // NOTE: we return TRUE if the wearable type has at least one wearable that can be removed by the user + for (U32 idxWearable = 0, cntWearable = gAgentWearables.getWearableCount(eType); idxWearable < cntWearable; idxWearable++) + if (!isLockedWearable(gAgentWearables.getViewerWearable(eType, idxWearable))) + return true; + return false; +} + +// Checked: 2010-03-19 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +bool RlvWearableLocks::hasLockedWearable(LLWearableType::EType eType) const +{ + // NOTE: we return TRUE if there is at least 1 non-removable wearable currently worn on this wearable type + for (U32 idxWearable = 0, cntWearable = gAgentWearables.getWearableCount(eType); idxWearable < cntWearable; idxWearable++) + if (isLockedWearable(gAgentWearables.getViewerWearable(eType, idxWearable))) + return true; + return false; +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +bool RlvWearableLocks::isLockedWearableExcept(const LLViewerWearable* pWearable, const LLUUID& idRlvObj) const +{ + if (idRlvObj.isNull()) + return isLockedWearable(pWearable); + + // TODO-RLVa: [RLVa-1.2.1] We don't have the ability to lock a specific wearable yet so rewrite this when we do + return (pWearable) && (isLockedWearableTypeExcept(pWearable->getType(), RLV_LOCK_REMOVE, idRlvObj)); +} + +// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +bool RlvWearableLocks::isLockedWearableTypeExcept(LLWearableType::EType eType, ERlvLockMask eLock, const LLUUID& idRlvObj) const +{ + if (idRlvObj.isNull()) + return isLockedWearableType(eType, eLock); + + // Loop over every object that marked the specified wearable type eLock type locked and skip over anything owned by idRlvObj + if (eLock & RLV_LOCK_REMOVE) + { + for (rlv_wearabletypelock_map_t::const_iterator itWearableType = m_WearableTypeRem.lower_bound(eType), + endWearableType = m_WearableTypeRem.upper_bound(eType); itWearableType != endWearableType; ++itWearableType) + { + if (itWearableType->second != idRlvObj) + return true; + } + } + if (eLock & RLV_LOCK_ADD) + { + for (rlv_wearabletypelock_map_t::const_iterator itWearableType = m_WearableTypeAdd.lower_bound(eType), + endWearableType = m_WearableTypeAdd.upper_bound(eType); itWearableType != endWearableType; ++itWearableType) + { + if (itWearableType->second != idRlvObj) + return true; + } + } + return false; +} + +// Checked: 2010-03-18 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +void RlvWearableLocks::removeWearableTypeLock(LLWearableType::EType eType, const LLUUID& idRlvObj, ERlvLockMask eLock) +{ +/* + // Sanity check - make sure it's an object we know about + if ( (m_Objects.find(idRlvObj) == m_Objects.end()) || (!idxAttachPt) ) + return; // If (idxAttachPt) == 0 then: (pObj == NULL) || (pObj->isAttachment() == FALSE) +*/ + + if (eLock & RLV_LOCK_REMOVE) + { + RLV_ASSERT( m_WearableTypeRem.lower_bound(eType) != m_WearableTypeRem.upper_bound(eType) ); // The lock should always exist + for (rlv_wearabletypelock_map_t::iterator itWearableType = m_WearableTypeRem.lower_bound(eType), + endWearableType = m_WearableTypeRem.upper_bound(eType); itWearableType != endWearableType; ++itWearableType) + { + if (idRlvObj == itWearableType->second) + { + m_WearableTypeRem.erase(itWearableType); + break; + } + } + } + if (eLock & RLV_LOCK_ADD) + { + RLV_ASSERT( m_WearableTypeAdd.lower_bound(eType) != m_WearableTypeAdd.upper_bound(eType) ); // The lock should always exist + for (rlv_wearabletypelock_map_t::iterator itWearableType = m_WearableTypeAdd.lower_bound(eType), + endWearableType = m_WearableTypeAdd.upper_bound(eType); itWearableType != endWearableType; ++itWearableType) + { + if (idRlvObj == itWearableType->second) + { + m_WearableTypeAdd.erase(itWearableType); + break; + } + } + } +} + +// ============================================================================ +// RlvFolderLocks member functions +// + +class RlvLockedDescendentsCollector : public LLInventoryCollectFunctor +{ +public: + RlvLockedDescendentsCollector(int eSourceTypeMask, RlvFolderLocks::ELockPermission ePermMask, ERlvLockMask eLockTypeMask) + : m_eSourceTypeMask(eSourceTypeMask), m_ePermMask(ePermMask), m_eLockTypeMask(eLockTypeMask) {} + /*virtual*/ ~RlvLockedDescendentsCollector() {} + /*virtual*/ bool operator()(LLInventoryCategory* pFolder, LLInventoryItem* pItem) + { + return (pFolder) && (RlvFolderLocks::instance().isLockedFolderEntry(pFolder->getUUID(), m_eSourceTypeMask, m_ePermMask, m_eLockTypeMask)); + } +protected: + RlvFolderLocks::ELockPermission m_ePermMask; + int m_eSourceTypeMask; + ERlvLockMask m_eLockTypeMask; +}; + +// Checked: 2011-03-28 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g +RlvFolderLocks::RlvFolderLocks() + : m_fLookupDirty(false), m_fLockedRoot(false), m_cntLockAdd(0), m_cntLockRem(0) +{ + LLOutfitObserver::instance().addCOFChangedCallback(boost::bind(&RlvFolderLocks::onNeedsLookupRefresh, this)); + RlvInventory::instance().addSharedRootIDChangedCallback(boost::bind(&RlvFolderLocks::onNeedsLookupRefresh, this)); +} + +// Checked: 2011-03-27 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g +void RlvFolderLocks::addFolderLock(const folderlock_source_t& lockSource, ELockPermission ePerm, ELockScope eScope, + const LLUUID& idRlvObj, ERlvLockMask eLockType) +{ + // Sanity check - eLockType can be RLV_LOCK_ADD or RLV_LOCK_REMOVE but not both + RLV_ASSERT( (RLV_LOCK_ADD == eLockType) || (RLV_LOCK_REMOVE == eLockType) ); + + // NOTE: m_FolderXXX can contain duplicate folderlock_descr_t + m_FolderLocks.push_back(new folderlock_descr_t(idRlvObj, eLockType, lockSource, ePerm, eScope)); + + if (PERM_DENY == ePerm) + { + if (RLV_LOCK_REMOVE == eLockType) + m_cntLockRem++; + else if (RLV_LOCK_ADD == eLockType) + m_cntLockAdd++; + } + m_fLookupDirty = true; +} + +// Checked: 2011-03-28 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g +bool RlvFolderLocks::getLockedFolders(const folderlock_source_t& lockSource, LLInventoryModel::cat_array_t& lockFolders) const +{ + S32 cntFolders = lockFolders.count(); + switch (lockSource.first) + { + case ST_ATTACHMENT: + { + RLV_ASSERT(typeid(LLUUID) == lockSource.second.type()) + const LLViewerObject* pObj = gObjectList.findObject(boost::get<LLUUID>(lockSource.second)); + if ( (pObj) && (pObj->isAttachment()) ) + { + const LLViewerInventoryItem* pItem = gInventory.getItem(pObj->getAttachmentItemID()); + if ( (pItem) && (RlvInventory::instance().isSharedFolder(pItem->getParentUUID())) ) + { + LLViewerInventoryCategory* pItemFolder = gInventory.getCategory(pItem->getParentUUID()); + if (pItemFolder) + lockFolders.push_back(pItemFolder); + } + } + } + break; + case ST_FOLDER: + { + RLV_ASSERT(typeid(LLUUID) == lockSource.second.type()) + LLViewerInventoryCategory* pFolder = gInventory.getCategory(boost::get<LLUUID>(lockSource.second)); + if (pFolder) + lockFolders.push_back(pFolder); + } + break; + case ST_ROOTFOLDER: + { + LLViewerInventoryCategory* pFolder = gInventory.getCategory(gInventory.getRootFolderID()); + if (pFolder) + lockFolders.push_back(pFolder); + } + break; + case ST_SHAREDPATH: + { + RLV_ASSERT(typeid(std::string) == lockSource.second.type()) + LLViewerInventoryCategory* pSharedFolder = RlvInventory::instance().getSharedFolder(boost::get<std::string>(lockSource.second)); + if (pSharedFolder) + lockFolders.push_back(pSharedFolder); + } + break; + case ST_ATTACHMENTPOINT: + case ST_WEARABLETYPE: + { + RLV_ASSERT( ((ST_ATTACHMENTPOINT == lockSource.first) && (typeid(S32) == lockSource.second.type())) || + ((ST_WEARABLETYPE == lockSource.first) && (typeid(LLWearableType::EType) == lockSource.second.type())) ); + + uuid_vec_t idItems; + if (ST_ATTACHMENTPOINT == lockSource.first) + RlvCommandOptionGetPath::getItemIDs(RlvAttachPtLookup::getAttachPoint(boost::get<S32>(lockSource.second)), idItems); + else if (ST_WEARABLETYPE == lockSource.first) + RlvCommandOptionGetPath::getItemIDs(boost::get<LLWearableType::EType>(lockSource.second), idItems); + + LLInventoryModel::cat_array_t itemFolders; + if (RlvInventory::instance().getPath(idItems, itemFolders)) + lockFolders.insert(lockFolders.end(), itemFolders.begin(), itemFolders.end()); + } + break; + default: + return false; + }; + return cntFolders != lockFolders.count(); +} + +// Checked: 2011-11-26 (RLVa-1.5.4a) | Modified: RLVa-1.5.4a +bool RlvFolderLocks::getLockedItems(const LLUUID& idFolder, LLInventoryModel::item_array_t& lockItems) const +{ + S32 cntItems = lockItems.count(); + + LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items; + LLFindWearablesEx f(true, true); // Collect all worn items + gInventory.collectDescendentsIf(idFolder, folders, items, FALSE, f); + + // Generally several of the worn items will belong to the same folder so we'll cache the results of each lookup + std::map<LLUUID, bool> folderLookups; std::map<LLUUID, bool>::const_iterator itLookup; + + bool fItemLocked = false; + for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++) + { + LLViewerInventoryItem* pItem = items.get(idxItem); + if (LLAssetType::AT_LINK == pItem->getActualType()) + pItem = pItem->getLinkedItem(); + if (!pItem) + continue; + + // Check the actual item's parent folder + const LLUUID& idItemParent = RlvInventory::getFoldedParent(pItem->getParentUUID(), true); + if ((itLookup = folderLookups.find(idItemParent)) != folderLookups.end()) + { + fItemLocked = itLookup->second; + } + else + { + fItemLocked = isLockedFolder(idItemParent, RLV_LOCK_REMOVE); + folderLookups.insert(std::pair<LLUUID, bool>(idItemParent, fItemLocked)); + } + + // Check the parent folders of any links to this item that exist under #RLV + if (!fItemLocked) + { + LLInventoryModel::item_array_t itemLinks = + gInventory.collectLinkedItems(pItem->getUUID(), RlvInventory::instance().getSharedRootID()); + for (LLInventoryModel::item_array_t::iterator itItemLink = itemLinks.begin(); + (itItemLink < itemLinks.end()) && (!fItemLocked); ++itItemLink) + { + LLViewerInventoryItem* pItemLink = *itItemLink; + + const LLUUID& idItemLinkParent = (pItemLink) ? RlvInventory::getFoldedParent(pItemLink->getParentUUID(), true) : LLUUID::null; + if ((itLookup = folderLookups.find(idItemLinkParent)) != folderLookups.end()) + { + fItemLocked = itLookup->second; + } + else + { + fItemLocked = isLockedFolder(idItemLinkParent, RLV_LOCK_REMOVE); + folderLookups.insert(std::pair<LLUUID, bool>(idItemLinkParent, fItemLocked)); + } + } + } + + if (fItemLocked) + lockItems.push_back(pItem); + } + + return cntItems != lockItems.count(); +} + +// Checked: 2011-03-29 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +bool RlvFolderLocks::hasLockedFolderDescendent(const LLUUID& idFolder, int eSourceTypeMask, ELockPermission ePermMask, + ERlvLockMask eLockTypeMask, bool fCheckSelf) const +{ + if (!hasLockedFolder(eLockTypeMask)) + return false; + if (m_fLookupDirty) + refreshLockedLookups(); + if ( (fCheckSelf) && (isLockedFolderEntry(idFolder, eSourceTypeMask, ePermMask, RLV_LOCK_ANY)) ) + return true; + + LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items; + RlvLockedDescendentsCollector f(eSourceTypeMask, ePermMask, eLockTypeMask); + gInventory.collectDescendentsIf(idFolder, folders, items, FALSE, f, FALSE); + return !folders.empty(); +} + +// Checked: 2011-03-29 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +bool RlvFolderLocks::isLockedFolderEntry(const LLUUID& idFolder, int eSourceTypeMask, ELockPermission ePermMask, ERlvLockMask eLockTypeMask) const +{ + for (folderlock_map_t::const_iterator itFolderLock = m_LockedFolderMap.lower_bound(idFolder), + endFolderLock = m_LockedFolderMap.upper_bound(idFolder); itFolderLock != endFolderLock; ++itFolderLock) + { + const folderlock_descr_t* pLockDescr = itFolderLock->second; + if ( (pLockDescr->lockSource.first & eSourceTypeMask) && (pLockDescr->eLockPermission & ePermMask) && + (pLockDescr->eLockType & eLockTypeMask) ) + { + return true; + } + } + return false; +} + +// Checked: 2011-03-27 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g +bool RlvFolderLocks::isLockedFolder(LLUUID idFolder, ERlvLockMask eLockTypeMask, int eSourceTypeMask, folderlock_source_t* plockSource) const +{ + // Sanity check - if there are no folder locks then we don't have to actually do anything + if (!hasLockedFolder(eLockTypeMask)) + return false; + + // Folded folders will be locked if their "parent" is locked + idFolder = RlvInventory::getFoldedParent(idFolder, true); + if (idFolder.isNull()) + return false; + + if (m_fLookupDirty) + refreshLockedLookups(); + + // Walk up the folder tree and check if anything has 'idFolder' locked + std::list<LLUUID> idsRlvObjRem, idsRlvObjAdd; const LLUUID& idFolderRoot = gInventory.getRootFolderID(); LLUUID idFolderCur = idFolder; + while (idFolderRoot != idFolderCur) + { + // Iterate over any folder locks for 'idFolderCur' + for (folderlock_map_t::const_iterator itFolderLock = m_LockedFolderMap.lower_bound(idFolderCur), + endFolderLock = m_LockedFolderMap.upper_bound(idFolderCur); itFolderLock != endFolderLock; ++itFolderLock) + { + const folderlock_descr_t* pLockDescr = itFolderLock->second; + + // We can skip over the current lock if: + // - the current lock type doesn't match eLockTypeMask + // - it's a node lock and the current folder doesn't match + // - we encountered a PERM_ALLOW lock from the current lock owner before which supercedes any subsequent locks + // - the lock source type doesn't match the mask passed in eSourceTypeMask + ERlvLockMask eCurLockType = (ERlvLockMask)(pLockDescr->eLockType & eLockTypeMask); + std::list<LLUUID>* pidRlvObjList = (RLV_LOCK_REMOVE == eCurLockType) ? &idsRlvObjRem : &idsRlvObjAdd; + if ( (0 == eCurLockType) || ((SCOPE_NODE == pLockDescr->eLockScope) && (idFolder != idFolderCur)) || + (pidRlvObjList->end() != std::find(pidRlvObjList->begin(), pidRlvObjList->end(), pLockDescr->idRlvObj)) || + (0 == (pLockDescr->eLockType & eSourceTypeMask)) ) + { + continue; + } + + if (PERM_DENY == pLockDescr->eLockPermission) + { + if (plockSource) + *plockSource = pLockDescr->lockSource; + return true; // Folder is explicitly denied, indicate locked folder to our caller + } + else if (PERM_ALLOW == pLockDescr->eLockPermission) + { + pidRlvObjList->push_back(pLockDescr->idRlvObj); // Folder is explicitly allowed, save the owner so we can skip it from now on + } + } + + // Move up to the folder tree + const LLViewerInventoryCategory* pParent = gInventory.getCategory(idFolderCur); + idFolderCur = (pParent) ? pParent->getParentUUID() : idFolderRoot; + } + // If we didn't encounter an explicit deny lock with no exception then the folder is locked if the entire inventory is locked down + return (m_fLockedRoot) && (idsRlvObjRem.empty()) && (idsRlvObjAdd.empty()); +} + +// Checked: 2010-11-30 (RLVa-1.3.0b) | Added: RLVa-1.3.0b +void RlvFolderLocks::onNeedsLookupRefresh() +{ + // NOTE: when removeFolderLock() removes the last folder lock we still want to refresh everything so mind the conditional OR assignment + m_fLookupDirty |= !m_FolderLocks.empty(); +} + +// Checked: 2011-03-27 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +void RlvFolderLocks::refreshLockedLookups() const +{ + // + // Refresh locked folders + // + m_fLockedRoot = false; + m_LockedFolderMap.clear(); + for (folderlock_list_t::const_iterator itFolderLock = m_FolderLocks.begin(); itFolderLock != m_FolderLocks.end(); ++itFolderLock) + { + const folderlock_descr_t* pLockDescr = *itFolderLock; + + LLInventoryModel::cat_array_t lockedFolders; const LLUUID& idFolderRoot = gInventory.getRootFolderID(); + if (getLockedFolders(pLockDescr->lockSource, lockedFolders)) + { + for (S32 idxFolder = 0, cntFolder = lockedFolders.count(); idxFolder < cntFolder; idxFolder++) + { + const LLViewerInventoryCategory* pFolder = lockedFolders.get(idxFolder); + if (idFolderRoot != pFolder->getUUID()) + m_LockedFolderMap.insert(std::pair<LLUUID, const folderlock_descr_t*>(pFolder->getUUID(), pLockDescr)); + else + m_fLockedRoot |= (SCOPE_SUBTREE == pLockDescr->eLockScope); + } + } + } + m_fLookupDirty = false; + + // + // Refresh locked items (iterate over COF and filter out any items residing in a RLV_LOCK_REMOVE locked PERM_DENY folder) + // + m_LockedAttachmentRem.clear(); + m_LockedWearableRem.clear(); + + LLInventoryModel::item_array_t lockedItems; + if (getLockedItems(LLAppearanceMgr::instance().getCOF(), lockedItems)) + { + for (S32 idxItem = 0, cntItem = lockedItems.count(); idxItem < cntItem; idxItem++) + { + const LLViewerInventoryItem* pItem = lockedItems.get(idxItem); + switch (pItem->getType()) + { + case LLAssetType::AT_BODYPART: + case LLAssetType::AT_CLOTHING: + m_LockedWearableRem.push_back(pItem->getLinkedUUID()); + break; + case LLAssetType::AT_OBJECT: + m_LockedAttachmentRem.push_back(pItem->getLinkedUUID()); + break; + default: + RLV_ASSERT(true); + break; + } + } + } + + // Remove any duplicate items we may have picked up + std::sort(m_LockedAttachmentRem.begin(), m_LockedAttachmentRem.end()); + m_LockedAttachmentRem.erase(std::unique(m_LockedAttachmentRem.begin(), m_LockedAttachmentRem.end()), m_LockedAttachmentRem.end()); + std::sort(m_LockedWearableRem.begin(), m_LockedWearableRem.end()); + m_LockedWearableRem.erase(std::unique(m_LockedWearableRem.begin(), m_LockedWearableRem.end()), m_LockedWearableRem.end()); +} + +// Checked: 2011-03-27 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g +void RlvFolderLocks::removeFolderLock(const folderlock_source_t& lockSource, ELockPermission ePerm, ELockScope eScope, + const LLUUID& idRlvObj, ERlvLockMask eLockType) +{ + // Sanity check - eLockType can be RLV_LOCK_ADD or RLV_LOCK_REMOVE but not both + RLV_ASSERT( (RLV_LOCK_ADD == eLockType) || (RLV_LOCK_REMOVE == eLockType) ); + + folderlock_descr_t lockDescr(idRlvObj, eLockType, lockSource, ePerm, eScope); RlvPredValuesEqual<folderlock_descr_t> f = { &lockDescr }; + folderlock_list_t::iterator itFolderLock = std::find_if(m_FolderLocks.begin(), m_FolderLocks.end(), f); + RLV_ASSERT( m_FolderLocks.end() != itFolderLock ); // The lock should always exist + if (m_FolderLocks.end() != itFolderLock) + { + delete *itFolderLock; + m_FolderLocks.erase(itFolderLock); + + if (PERM_DENY == ePerm) + { + if (RLV_LOCK_REMOVE == eLockType) + m_cntLockRem--; + else if (RLV_LOCK_ADD == eLockType) + m_cntLockAdd--; + } + m_fLookupDirty = true; + } +} + +// ============================================================================ diff --git a/indra/newview/rlvlocks.h b/indra/newview/rlvlocks.h new file mode 100644 index 0000000000000000000000000000000000000000..4ae13a70cc77524497d7ba1d054c27713a22b24f --- /dev/null +++ b/indra/newview/rlvlocks.h @@ -0,0 +1,710 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#ifndef RLV_LOCKS_H +#define RLV_LOCKS_H + +#include "llagentconstants.h" +#include "llagentwearables.h" +#include "lleventtimer.h" +#include "llvoavatarself.h" +#include "llviewerwearable.h" + +#include "rlvdefines.h" +#include "rlvcommon.h" + +// ============================================================================ +// RlvAttachPtLookup class declaration +// + +class RlvAttachPtLookup +{ +public: + static LLViewerJointAttachment* getAttachPoint(S32 idxAttachPt); + static LLViewerJointAttachment* getAttachPoint(const std::string& strText); + static LLViewerJointAttachment* getAttachPoint(const LLInventoryItem* pItem); + + static S32 getAttachPointIndex(std::string strText); + static S32 getAttachPointIndex(const LLViewerObject* pAttachObj); + static S32 getAttachPointIndex(const LLViewerJointAttachment* pAttachPt); + static S32 getAttachPointIndex(const LLInventoryCategory* pFolder); + static S32 getAttachPointIndex(const LLInventoryItem* pItem, bool fFollowLinks = true); + + static bool hasAttachPointName(const LLInventoryItem* pItem) { return (0 != getAttachPointIndex(pItem)); } +private: + static S32 getAttachPointIndexLegacy(const LLInventoryCategory* pFolder); + +public: + static void initLookupTable(); +private: + static std::map<std::string, S32> m_AttachPtLookupMap; +}; + +// ============================================================================ +// RlvAttachmentLocks class declaration +// + +// TODO-RLVa: [RLVa-1.2.1] Once everything is working for SL-2.0 thin out the member functions since a few of them are duplicates/unneeded +class RlvAttachmentLocks +{ +public: + RlvAttachmentLocks() : m_fHasLockedHUD(false) {} + +public: + // Adds an RLV_LOCK_REMOVE lock (held by idRlvObj) for the attachment + void addAttachmentLock(const LLUUID& idAttachObj, const LLUUID& idRlvObj); + // Adds an eLock type lock (held by idRlvObj) for the attachment point + void addAttachmentPointLock(S32 idxAttachPt, const LLUUID& idRlvObj, ERlvLockMask eLock); + + // Returns TRUE if there is at least 1 non-detachable attachment currently attached to the attachment point + bool hasLockedAttachment(const LLViewerJointAttachment* pAttachPt) const; + // Returns TRUE if there is at least 1 eLock type locked attachment point (RLV_LOCK_ANY = RLV_LOCK_ADD *or* RLV_LOCK_REMOVE) + // - RLV_LOCK_REMOVE: specific attachment locked *or* any attachment point locked (regardless of whether it currently has attachments) + bool hasLockedAttachmentPoint(ERlvLockMask eLock) const; + // Returns TRUE if there is at least 1 non-detachable HUD attachment + bool hasLockedHUD() const { return m_fHasLockedHUD; } + + // Returns TRUE if the attachment is RLV_LOCK_REMOVE locked + bool isLockedAttachment(const LLViewerObject* pAttachObj) const; + // Returns TRUE if the attachment point is RLV_LOCK_REMOVE locked by anything other than idRlvObj + bool isLockedAttachmentExcept(const LLViewerObject* pObj, const LLUUID& idRlvObj) const; + // Returns TRUE if the attachment point is eLock type locked (RLV_LOCK_ANY = RLV_LOCK_ADD *or* RLV_LOCK_REMOVE) + bool isLockedAttachmentPoint(S32 idxAttachPt, ERlvLockMask eLock) const; + bool isLockedAttachmentPoint(const LLViewerJointAttachment* pAttachPt, ERlvLockMask eLock) const; + + // Removes an RLV_LOCK_REMOVE lock (held by idRlvObj) for the attachment + void removeAttachmentLock(const LLUUID& idAttachObj, const LLUUID& idRlvObj); + // Removes an eLock type lock (held by idRlvObj) for the attachment point + void removeAttachmentPointLock(S32 idxAttachPt, const LLUUID& idRlvObj, ERlvLockMask eLock); + + // Refreshes locked HUD attachment state + void updateLockedHUD(); + // Iterates over all current attachment and attachment point locks and verifies their status (returns TRUE if verification succeeded) + bool verifyAttachmentLocks(); + +protected: + // Returns TRUE if the attachment point is eLock type locked by anything other than idRlvObj + bool isLockedAttachmentPointExcept(S32 idxAttachPt, ERlvLockMask eLock, const LLUUID& idRlvObj) const; + + /* + * canAttach/canDetach trivial helper functions (note that a more approriate name might be userCanAttach/userCanDetach) + */ +public: + // Returns TRUE if there is at least one attachment point that can be attached to + bool canAttach() const; + // Returns TRUE if the inventory item can be attached by the user (and optionally provides the attachment point - which may be NULL) + ERlvWearMask canAttach(const LLInventoryItem* pItem, LLViewerJointAttachment** ppAttachPtOut = NULL) const; + // Returns TRUE if the attachment point can be attached to by the user + ERlvWearMask canAttach(const LLViewerJointAttachment* pAttachPt) const; + + // Returns TRUE if the inventory item can be detached by the user + bool canDetach(const LLInventoryItem* pItem) const; + // Returns TRUE if the attachment point has at least one attachment that can be detached by the user + bool canDetach(const LLViewerJointAttachment* pAttachPt, bool fDetachAll = false) const; + + /* + * Member variables + */ +public: + typedef std::multimap<LLUUID, LLUUID> rlv_attachobjlock_map_t; + typedef std::multimap<S32, LLUUID> rlv_attachptlock_map_t; + // Accessors for RlvFloaterLocks + const rlv_attachptlock_map_t& getAttachPtLocks(ERlvLockMask eLock) { return (RLV_LOCK_ADD == eLock) ? m_AttachPtAdd : m_AttachPtRem; } + const rlv_attachobjlock_map_t& getAttachObjLocks() { return m_AttachObjRem; } +private: + rlv_attachptlock_map_t m_AttachPtAdd; // Map of attachment points that can't be attached to (idxAttachPt -> idObj) + rlv_attachptlock_map_t m_AttachPtRem; // Map of attachment points whose attachments can't be detached (idxAttachPt -> idObj) + rlv_attachobjlock_map_t m_AttachObjRem; // Map of attachments that can't be detached (idAttachObj -> idObj) + + bool m_fHasLockedHUD; +}; + +extern RlvAttachmentLocks gRlvAttachmentLocks; + +// ============================================================================ +// RlvAttachmentLockWatchdog - Self contained class that automagically takes care of enforcing attachment locks (ie reattach-on-detach) +// + +// TODO-RLVa: [RLVa-1.2.1] This class really looks rather cluttered so look into cleaning it up/simplifying it a bit +class RlvAttachmentLockWatchdog : public LLSingleton<RlvAttachmentLockWatchdog> +{ + friend class LLSingleton<RlvAttachmentLockWatchdog>; +protected: + RlvAttachmentLockWatchdog() : m_pTimer(NULL) {} + ~RlvAttachmentLockWatchdog() { delete m_pTimer; } + + /* + * Member functions + */ +protected: + // NOTE: detach does *not* respect attachment locks so use with care + void detach(const LLViewerObject* pAttachObj); + void detach(S32 idxAttachPt) { uuid_vec_t idsAttachObjExcept; detach(idxAttachPt, idsAttachObjExcept); } + void detach(S32 idxAttachPt, const uuid_vec_t& idsAttachObjExcept); + + void startTimer() { if (!m_pTimer) m_pTimer = new RlvAttachmentLockWatchdogTimer(this); } + + /* + * Event handlers + */ +public: + void onAttach(const LLViewerObject* pAttachObj, const LLViewerJointAttachment* pAttachPt); + void onDetach(const LLViewerObject* pAttachObj, const LLViewerJointAttachment* pAttachPt); + void onSavedAssetIntoInventory(const LLUUID& idItem); + BOOL onTimer(); + void onWearAttachment(const LLInventoryItem* pItem, ERlvWearMask eWearAction); + void onWearAttachment(const LLUUID& idItem, ERlvWearMask eWearAction); + + /* + * Member variables + */ +protected: + typedef std::list<LLUUID> rlv_detach_map_t; + rlv_detach_map_t m_PendingDetach; + + struct RlvReattachInfo + { + RlvReattachInfo(const LLUUID& itemid) : idItem(itemid), fAssetSaved(false), tsAttach(0) + { tsDetach = LLFrameTimer::getElapsedSeconds(); } + + LLUUID idItem; + bool fAssetSaved; + F64 tsDetach; + F64 tsAttach; + protected: + RlvReattachInfo(); + }; + typedef std::multimap<S32, RlvReattachInfo> rlv_attach_map_t; + rlv_attach_map_t m_PendingAttach; + + struct RlvWearInfo + { + RlvWearInfo(const LLUUID& itemid, ERlvWearMask wearaction) : idItem(itemid), eWearAction(wearaction) + { tsWear = LLFrameTimer::getElapsedSeconds(); } + + bool isAddLockedAttachPt(S32 idxAttachPt) const; + void dumpInstance() const; + + LLUUID idItem; + ERlvWearMask eWearAction; + F64 tsWear; + std::map<S32, uuid_vec_t> attachPts; + protected: + RlvWearInfo(); + }; + typedef std::map<LLUUID, RlvWearInfo> rlv_wear_map_t; + rlv_wear_map_t m_PendingWear; + + class RlvAttachmentLockWatchdogTimer : public LLEventTimer + { + public: + RlvAttachmentLockWatchdogTimer(RlvAttachmentLockWatchdog* pWatchdog) : LLEventTimer(10), m_pWatchdog(pWatchdog) {} + virtual ~RlvAttachmentLockWatchdogTimer() { m_pWatchdog->m_pTimer = NULL; } + virtual BOOL tick() { return m_pWatchdog->onTimer(); } + RlvAttachmentLockWatchdog* m_pWatchdog; + } *m_pTimer; +}; + +// ============================================================================ +// RlvWearableLocks class declaration - modelled on RlvAttachmentLocks (attach pt = wearable type - attachment = wearable) +// + +class RlvWearableLocks +{ +public: + // Adds an eLock type lock (held by idRlvObj) for the wearable type + void addWearableTypeLock(LLWearableType::EType eType, const LLUUID& idRlvObj, ERlvLockMask eLock); + + // Returns TRUE if there is at least 1 non-removable wearable currently worn on this wearable type + bool hasLockedWearable(LLWearableType::EType eType) const; + // Returns TRUE if there is at least 1 eLock type locked wearable type (RLV_LOCK_ANY = RLV_LOCK_ADD *or* RLV_LOCK_REMOVE) + // - RLV_LOCK_REMOVE: specific wearable locked *or* any wearable type locked (regardless of whether it currently has wearables) + bool hasLockedWearableType(ERlvLockMask eLock) const; + + // Removes an eLock type lock (held by idRlvObj) for the wearable type + void removeWearableTypeLock(LLWearableType::EType eType, const LLUUID& idRlvObj, ERlvLockMask eLock); + + // Returns TRUE if the wearable is RLV_LOCK_REMOVE locked + bool isLockedWearable(const LLViewerWearable* pWearable) const; + // Returns TRUE if the wearable is RLV_LOCK_REMOVE locked by anything other than idRlvObj + bool isLockedWearableExcept(const LLViewerWearable* pWearable, const LLUUID& idRlvObj) const; + + // NOTE: isLockedWearableType doesn't check if a worn wearable is a specific wearable lock so don't let these be called by the outside +protected: + // Returns TRUE if the wearable type is eLock type locked + bool isLockedWearableType(LLWearableType::EType eType, ERlvLockMask eLock) const; + // Returns TRUE if the wearable type is eLock type locked by anything other than idRlvObj + bool isLockedWearableTypeExcept(LLWearableType::EType eType, ERlvLockMask eLock, const LLUUID& idRlvObj) const; + + /* + * canWear/canRemove trivial helper functions (note that a more approriate name might be userCanWear/userCanRemove) + */ +public: + // Returns whether the inventory item can be worn by the user + ERlvWearMask canWear(const LLViewerInventoryItem* pItem) const; + // Returns whether the wearable type can be worn to by the user + ERlvWearMask canWear(LLWearableType::EType eType) const; + + // Returns TRUE if the inventory item can be removed by the user + bool canRemove(const LLInventoryItem* pItem) const; + // Returns TRUE if the wearable type has at least one wearable that can be removed by the user + bool canRemove(LLWearableType::EType eType) const; + + /* + * Member variables + */ +public: + typedef std::multimap<LLWearableType::EType, LLUUID> rlv_wearabletypelock_map_t; + // Accessors for RlvFloaterLocks + const rlv_wearabletypelock_map_t& getWearableTypeLocks(ERlvLockMask eLock) { return (RLV_LOCK_ADD == eLock) ? m_WearableTypeAdd : m_WearableTypeRem; } +protected: + rlv_wearabletypelock_map_t m_WearableTypeAdd; + rlv_wearabletypelock_map_t m_WearableTypeRem; +}; + +extern RlvWearableLocks gRlvWearableLocks; + +// ============================================================================ +// RlvFolderLocks class declaration +// + +class RlvFolderLocks : public LLSingleton<RlvFolderLocks> +{ + friend class RlvLockedDescendentsCollector; +public: + RlvFolderLocks(); + + // Specifies the source of a folder lock + enum ELockSourceType + { + ST_ATTACHMENT = 0x01, ST_ATTACHMENTPOINT = 0x02, ST_FOLDER = 0x04, ST_ROOTFOLDER = 0x08, + ST_SHAREDPATH = 0x10, ST_WEARABLETYPE = 0x20, ST_NONE= 0x00, ST_MASK_ANY = 0xFF + }; + typedef boost::variant<LLUUID, std::string, S32, LLWearableType::EType> lock_source_t; + typedef std::pair<ELockSourceType, lock_source_t> folderlock_source_t; + // Specifies options for the folder lock + enum ELockPermission { PERM_ALLOW = 0x1, PERM_DENY = 0x2, PERM_MASK_ANY = 0x3 }; + enum ELockScope { SCOPE_NODE, SCOPE_SUBTREE } ; + + struct folderlock_descr_t + { + LLUUID idRlvObj; + ERlvLockMask eLockType; + folderlock_source_t lockSource; + ELockPermission eLockPermission; + ELockScope eLockScope; + + folderlock_descr_t(const LLUUID& rlvObj, ERlvLockMask lockType, folderlock_source_t source, ELockPermission perm, ELockScope scope); + bool operator ==(const folderlock_descr_t& rhs) const; + }; + +public: + // Adds an eLock type lock (held by idRlvObj) for the specified folder source (with ePerm and eScope lock options) + void addFolderLock(const folderlock_source_t& lockSource, ELockPermission ePerm, ELockScope eScope, const LLUUID& idRlvObj, ERlvLockMask eLockType); + + // Returns TRUE if there is at least 1 non-detachable attachment as a result of a RLV_LOCK_REMOVE folder PERM_DENY lock + bool hasLockedAttachment() const; + // Returns TRUE if there is at least 1 eLock type PERM_DENY locked folder (RLV_LOCK_ANY = RLV_LOCK_ADD *or* RLV_LOCK_REMOVE) + bool hasLockedFolder(ERlvLockMask eLockTypeMask) const; + // Returns TRUE if the folder has a descendent folder lock with the specified charateristics + bool hasLockedFolderDescendent(const LLUUID& idFolder, int eSourceTypeMask, ELockPermission ePermMask, + ERlvLockMask eLockTypeMask, bool fCheckSelf) const; + // Returns TRUE if there is at least 1 non-removable wearable as a result of a RLV_LOCK_REMOVE folder PERM_DENY lock + bool hasLockedWearable() const; + // Returns TRUE if the attachment (specified by item UUID) is non-detachable as a result of a RLV_LOCK_REMOVE folder PERM_DENY lock + bool isLockedAttachment(const LLUUID& idItem) const; + // Returns TRUE if the folder is locked as a result of a RLV_LOCK_REMOVE folder PERM_DENY lock + bool isLockedFolder(LLUUID idFolder, ERlvLockMask eLock, int eSourceTypeMask = ST_MASK_ANY, folderlock_source_t* plockSource = NULL) const; + // Returns TRUE if the wearable (specified by item UUID) is non-removable as a result of a RLV_LOCK_REMOVE folder PERM_DENY lock + bool isLockedWearable(const LLUUID& idItem) const; + + // Removes an eLock type lock (held by idRlvObj) for the specified folder source (with ePerm and eScope lock options) + void removeFolderLock(const folderlock_source_t& lockSource, ELockPermission ePerm, ELockScope eScope, const LLUUID& idRlvObj, ERlvLockMask eLockType); + +protected: + // Returns TRUE if the folder has an explicit folder lock entry with the specified charateristics + bool isLockedFolderEntry(const LLUUID& idFolder, int eSourceTypeMask, ELockPermission ePermMask, ERlvLockMask eLockTypeMask) const; + + /* + * canXXX helper functions (note that a more approriate name might be userCanXXX) + */ +public: + bool canMoveFolder(const LLUUID& idFolder, const LLUUID& idFolderDest) const; + bool canRemoveFolder(const LLUUID& idFolder) const; + bool canRenameFolder(const LLUUID& idFolder) const; + bool canMoveItem(const LLUUID& idItem, const LLUUID& idFolderDest) const; + bool canRemoveItem(const LLUUID& idItem) const; + bool canRenameItem(const LLUUID& idItem) const; + + /* + * Cached item/folder look-up helper functions + */ +protected: + bool getLockedFolders(const folderlock_source_t& lockSource, LLInventoryModel::cat_array_t& lockFolders) const; + bool getLockedItems(const LLUUID& idFolder, LLInventoryModel::item_array_t& lockItems) const; + void onNeedsLookupRefresh(); + void refreshLockedLookups() const; + + /* + * Member variables + */ +public: + typedef std::list<const folderlock_descr_t*> folderlock_list_t; + // Accessors for RlvFloaterLocks + const folderlock_list_t& getFolderLocks() { return m_FolderLocks; } + const uuid_vec_t& getAttachmentLookups() { return m_LockedAttachmentRem; } + const uuid_vec_t& getWearableLookups() { return m_LockedWearableRem; } +protected: + // Map of folder locks (idRlvObj -> lockDescr) + folderlock_list_t m_FolderLocks; // List of add and remove locked folder descriptions + S32 m_cntLockAdd; // Number of RLV_LOCK_ADD locked folders in m_FolderLocks + S32 m_cntLockRem; // Number of RLV_LOCK_REMOVE locked folders in m_FolderLocks + + // Cached item look-up variables + typedef std::multimap<LLUUID, const folderlock_descr_t*> folderlock_map_t; + mutable bool m_fLookupDirty; + mutable bool m_fLockedRoot; + mutable uuid_vec_t m_LockedAttachmentRem; + mutable folderlock_map_t m_LockedFolderMap; + mutable uuid_vec_t m_LockedWearableRem; +private: + friend class LLSingleton<RlvFolderLocks>; +}; + +// ============================================================================ +// RlvAttachPtLookup inlined member functions +// + +// Checked: 2010-11-30 (RLVa-1.4.0b) | Added: RLVa-1.4.0b +inline LLViewerJointAttachment* RlvAttachPtLookup::getAttachPoint(S32 idxAttachPt) +{ + return (isAgentAvatarValid()) ? get_if_there(gAgentAvatarp->mAttachmentPoints, idxAttachPt, (LLViewerJointAttachment*)NULL) : NULL; +} + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Modified: RLVa-0.2.0d +inline LLViewerJointAttachment* RlvAttachPtLookup::getAttachPoint(const std::string& strText) +{ + return (isAgentAvatarValid()) ? get_if_there(gAgentAvatarp->mAttachmentPoints, getAttachPointIndex(strText), (LLViewerJointAttachment*)NULL) : NULL; +} + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Modified: RLVa-1.0.1b +inline LLViewerJointAttachment* RlvAttachPtLookup::getAttachPoint(const LLInventoryItem* pItem) +{ + return (isAgentAvatarValid()) ? get_if_there(gAgentAvatarp->mAttachmentPoints, getAttachPointIndex(pItem), (LLViewerJointAttachment*)NULL) : NULL; +} + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +inline S32 RlvAttachPtLookup::getAttachPointIndex(std::string strText) +{ + LLStringUtil::toLower(strText); + RLV_ASSERT(m_AttachPtLookupMap.size() > 0); + std::map<std::string, S32>::const_iterator itAttachPt = m_AttachPtLookupMap.find(strText); + return (itAttachPt != m_AttachPtLookupMap.end()) ? itAttachPt->second : 0; +} + +// Checked: 2010-03-03 (RLVa-1.2.0a) | Modified: RLVa-0.2.0d +inline S32 RlvAttachPtLookup::getAttachPointIndex(const LLViewerObject* pObj) +{ + return (pObj) ? ATTACHMENT_ID_FROM_STATE(pObj->getState()) : 0; +} + +// ============================================================================ +// RlvAttachmentLocks inlined member functions +// + +// Checked: 2011-05-22 (RLVa-1.3.1b) | Modified: RLVa-1.3.1b +inline ERlvWearMask RlvAttachmentLocks::canAttach(const LLInventoryItem* pItem, LLViewerJointAttachment** ppAttachPtOut /*=NULL*/) const +{ + // The specified item can be attached if: + // - it doesn't specify an attachment point and there is at least one attachment point that can be attached to + // - the attachment point it specifies can be attached to + LLViewerJointAttachment* pAttachPt = RlvAttachPtLookup::getAttachPoint(pItem); + if (ppAttachPtOut) + *ppAttachPtOut = pAttachPt; + return ((canAttach()) && (pItem) && (!RlvFolderLocks::instance().isLockedFolder(pItem->getParentUUID(), RLV_LOCK_ADD))) + ? ((!pAttachPt) ? RLV_WEAR : canAttach(pAttachPt)) : RLV_WEAR_LOCKED; +} + +// Checked: 2010-08-07 (RLVa-1.2.0i) | Modified: RLVa-1.2.0i +inline ERlvWearMask RlvAttachmentLocks::canAttach(const LLViewerJointAttachment* pAttachPt) const +{ + // Non-attachable attachment point => RLV_WEAR_LOCKED + // One or more locked attachment(s) => RLV_WEAR_ADD + // Unlocked attachment(s) => RLV_WEAR_ADD | RLV_WEAR_REPLACE + // Empty attachment point => RLV_WEAR_ADD | RLV_WEAR_REPLACE + RLV_ASSERT(pAttachPt); // TODO-RLVa: [RLVa-1.2.1] Maybe it's better to just return something similar like above? + return + (ERlvWearMask)(((pAttachPt) && (!isLockedAttachmentPoint(pAttachPt, RLV_LOCK_ADD))) + ? ((canDetach(pAttachPt, true)) ? RLV_WEAR_REPLACE : 0) | RLV_WEAR_ADD + : RLV_WEAR_LOCKED); +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Added: RLVa-1.0.5a +inline bool RlvAttachmentLocks::canDetach(const LLInventoryItem* pItem) const +{ + const LLViewerObject* pAttachObj = + ((pItem) && (isAgentAvatarValid())) ? gAgentAvatarp->getWornAttachment(pItem->getLinkedUUID()) : NULL; + return (pAttachObj) && (!isLockedAttachment(pAttachObj)); +} + +// Checked: 2010-11-30 (RLVa-1.3.0b) | Modified: RLVa-1.3.0b +inline bool RlvAttachmentLocks::hasLockedAttachmentPoint(ERlvLockMask eLock) const +{ + // Remove locks are more common so check those first + return + ((eLock & RLV_LOCK_REMOVE) && ((!m_AttachPtRem.empty()) || (!m_AttachObjRem.empty()) || (RlvFolderLocks::instance().hasLockedAttachment()))) || + ((eLock & RLV_LOCK_ADD) && (!m_AttachPtAdd.empty()) ); +} + +// Checked: 2010-11-30 (RLVa-1.3.0b) | Modified: RLVa-1.3.0b +inline bool RlvAttachmentLocks::isLockedAttachment(const LLViewerObject* pAttachObj) const +{ + // If pObj is valid then it should always specify a root since we store root UUIDs in m_AttachObjRem + RLV_ASSERT( (!pAttachObj) || (pAttachObj == pAttachObj->getRootEdit()) ); + + // Object is locked if: + // - it's specifically marked as non-detachable (ie @detach=n) + // - it's attached to an attachment point that is RLV_LOCK_REMOVE locked (ie @remattach:<attachpt>=n) + // - it's part of a locked folder + return + (pAttachObj) && (pAttachObj->isAttachment()) && + ( (m_AttachObjRem.find(pAttachObj->getID()) != m_AttachObjRem.end()) || + (isLockedAttachmentPoint(RlvAttachPtLookup::getAttachPointIndex(pAttachObj), RLV_LOCK_REMOVE)) || + (RlvFolderLocks::instance().isLockedAttachment(pAttachObj->getAttachmentItemID())) ); +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Added: RLVa-1.0.5a +inline bool RlvAttachmentLocks::isLockedAttachmentPoint(S32 idxAttachPt, ERlvLockMask eLock) const +{ + return + ( (eLock & RLV_LOCK_REMOVE) && (m_AttachPtRem.find(idxAttachPt) != m_AttachPtRem.end()) ) || + ( (eLock & RLV_LOCK_ADD) && (m_AttachPtAdd.find(idxAttachPt) != m_AttachPtAdd.end()) ); +} + +// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a +inline bool RlvAttachmentLocks::isLockedAttachmentPoint(const LLViewerJointAttachment* pAttachPt, ERlvLockMask eLock) const +{ + return (pAttachPt) && (isLockedAttachmentPoint(RlvAttachPtLookup::getAttachPointIndex(pAttachPt), eLock)); +} + +// ============================================================================ +// RlvWearableLocks inlined member functions +// + +// Checked: 2010-03-19 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +inline bool RlvWearableLocks::canRemove(const LLInventoryItem* pItem) const +{ + // The specified item can be removed if its wearable can be removed + RLV_ASSERT( (pItem) && (LLInventoryType::IT_WEARABLE == pItem->getInventoryType()) ); + const LLViewerWearable* pWearable = (pItem) ? gAgentWearables.getWearableFromItemID(pItem->getLinkedUUID()) : NULL; + return (pWearable) && (!isLockedWearable(pWearable)); +} + +// Checked: 2011-03-27 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g +inline ERlvWearMask RlvWearableLocks::canWear(const LLViewerInventoryItem* pItem) const +{ + // The specified item can be worn if the wearable type it specifies can be worn on + RLV_ASSERT( (pItem) && (LLInventoryType::IT_WEARABLE == pItem->getInventoryType()) ); + return ((pItem) && (!RlvFolderLocks::instance().isLockedFolder(pItem->getParentUUID(), RLV_LOCK_ADD))) + ? canWear(pItem->getWearableType()) : RLV_WEAR_LOCKED; +} + +// Checked: 2010-05-14 (RLVa-1.2.0g) | Modified: RLVa-1.2.0g +inline ERlvWearMask RlvWearableLocks::canWear(LLWearableType::EType eType) const +{ + // The specified wearable type can be worn on if: + // - the wearable type itself isn't RLV_LOCK_ADD locked => RLV_WEAR_ADD + // (and there are less than the maximum amount currently worn) + // - it doesn't have any non-removable wearables => RLV_WEAR_REPLACE | RLV_WEAR_ADD = RLV_WEAR + // TODO-RLVa: [RLVa-1.2.1] We don't have the ability to lock a specific wearable yet so rewrite this when we do + return (!isLockedWearableType(eType, RLV_LOCK_ADD)) + ? ((!hasLockedWearable(eType)) + ? RLV_WEAR + : (gAgentWearables.getWearableCount(eType) < LLAgentWearables::MAX_CLOTHING_PER_TYPE) ? RLV_WEAR_ADD : RLV_WEAR_LOCKED) + : RLV_WEAR_LOCKED; +} + +// Checked: 2010-03-18 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a +inline bool RlvWearableLocks::hasLockedWearableType(ERlvLockMask eLock) const +{ + // Remove locks are more common so check those first + // TODO-RLVa: [RLVa-1.2.1] We don't have the ability to lock a specific wearable yet so rewrite this when we do + return ( (eLock & RLV_LOCK_REMOVE) && (!m_WearableTypeRem.empty()) ) || ( (eLock & RLV_LOCK_ADD) && (!m_WearableTypeAdd.empty()) ); +} + +// Checked: 2010-11-30 (RLVa-1.3.0b) | Modified: RLVa-1.2.0a +inline bool RlvWearableLocks::isLockedWearable(const LLViewerWearable* pWearable) const +{ + // Wearable is locked if: + // - it's specifically marked as non-removable + // - it's worn on a wearable type that is RLV_LOCK_REMOVE locked + // - it's part of a locked folder + // TODO-RLVa: [RLVa-1.2.1] We don't have the ability to lock a specific wearable yet so rewrite this when we do + RLV_ASSERT(pWearable); + return + (pWearable) && + ( (isLockedWearableType(pWearable->getType(), RLV_LOCK_REMOVE)) || (RlvFolderLocks::instance().isLockedWearable(pWearable->getItemID())) ); +} + +// Checked: 2010-03-19 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +inline bool RlvWearableLocks::isLockedWearableType(LLWearableType::EType eType, ERlvLockMask eLock) const +{ + return + ( (eLock & RLV_LOCK_REMOVE) && (m_WearableTypeRem.find(eType) != m_WearableTypeRem.end()) ) || + ( (eLock & RLV_LOCK_ADD) && (m_WearableTypeAdd.find(eType) != m_WearableTypeAdd.end()) ); +} + +// ============================================================================ +// RlvAttachmentLockWatchdog inlined member functions +// + +// Checked: 2010-08-07 (RLVa-1.2.0i) | Added: RLVa-1.2.0i +inline void RlvAttachmentLockWatchdog::onWearAttachment(const LLInventoryItem* pItem, ERlvWearMask eWearAction) +{ + onWearAttachment(pItem->getLinkedUUID(), eWearAction); +} + +// ============================================================================ +// RlvFolderLocks member functions +// + +// Checked: 2011-03-27 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +inline RlvFolderLocks::folderlock_descr_t::folderlock_descr_t(const LLUUID& rlvObj, ERlvLockMask lockType, folderlock_source_t source, + ELockPermission perm, ELockScope scope) + : idRlvObj(rlvObj), eLockType(lockType), lockSource(source), eLockPermission(perm), eLockScope(scope) +{ +} + +// Checked: 2011-03-27 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +inline bool RlvFolderLocks::folderlock_descr_t::operator ==(const folderlock_descr_t& rhs) const +{ + return (idRlvObj == rhs.idRlvObj) && (eLockType == rhs.eLockType) && (lockSource == rhs.lockSource) && + (eLockPermission == rhs.eLockPermission) && (eLockScope == rhs.eLockScope); +} + +// Checked: 2011-03-29 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +inline bool RlvFolderLocks::canMoveFolder(const LLUUID& idFolder, const LLUUID& idFolderDest) const +{ + // Block moving the folder to destination if: + // - the folder (or one of its descendents) is explicitly locked + // - folder and destination are subject to different locks + // -> Possible combinations: + // * folder locked + destination unlocked => block move + // * folder unlocked + destination locked => block move + // * folder locked + destination locked => allow move only if both are subject to the same folder lock + // * folder unlocked + destination unlocked => allow move (special case of above since both locks are equal when there is none) + // => so the above becomes (isLockedFolder(A) == isLockedFolder(B)) && (lockA == lockB) + folderlock_source_t lockSource(ST_NONE, 0), lockSourceDest(ST_NONE, 0); + return + (!hasLockedFolderDescendent(idFolder, ST_MASK_ANY, PERM_MASK_ANY, RLV_LOCK_ANY, true)) && + ( (isLockedFolder(idFolder, RLV_LOCK_ANY, ST_MASK_ANY, &lockSource) == isLockedFolder(idFolderDest, RLV_LOCK_ANY, ST_MASK_ANY, &lockSourceDest)) && + (lockSource == lockSourceDest) ); +} + +// Checked: 2011-03-29 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +inline bool RlvFolderLocks::canRemoveFolder(const LLUUID& idFolder) const +{ + // Block removing a folder if: + // - the folder (or one of its descendents) is explicitly locked + // - the folder itself is locked (but disregard root folder locks) + return + (!hasLockedFolderDescendent(idFolder, ST_MASK_ANY, PERM_MASK_ANY, RLV_LOCK_ANY, true)) && + (!isLockedFolder(idFolder, RLV_LOCK_ANY, ST_MASK_ANY & ~ST_ROOTFOLDER)); +} + +// Checked: 2011-03-29 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +inline bool RlvFolderLocks::canRenameFolder(const LLUUID& idFolder) const +{ + // Block renaming a folder if: + // - the folder (or one of its descendents) is explicitly locked by: + // -> a "shared path" => renaming the folder would change the shared path and hence invalidate the lock + // -> an attachment point -| + // -> an attachment |--> renaming the folder to a "dot" (=invisible) folder would invalidate the lock + // -> a wearable type -| + return !hasLockedFolderDescendent(idFolder, ST_SHAREDPATH | ST_ATTACHMENT | ST_ATTACHMENTPOINT | ST_WEARABLETYPE, PERM_MASK_ANY, RLV_LOCK_ANY, true); +} + +// Checked: 2011-03-30 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +inline bool RlvFolderLocks::canMoveItem(const LLUUID& idItem, const LLUUID& idFolderDest) const +{ + // Block moving the folder to destination if: + // - folder and destination are subject to different locks [see canMoveFolder() for more details] + const LLViewerInventoryItem* pItem = gInventory.getItem(idItem); const LLUUID& idFolder = (pItem) ? pItem->getParentUUID() : LLUUID::null; + int maskSource = ST_MASK_ANY & ~ST_ROOTFOLDER; folderlock_source_t lockSource(ST_NONE, 0), lockSourceDest(ST_NONE, 0); + return + (idFolder.notNull()) && + (isLockedFolder(idFolder, RLV_LOCK_ANY, maskSource, &lockSource) == isLockedFolder(idFolderDest, RLV_LOCK_ANY, maskSource, &lockSourceDest)) && + (lockSource == lockSourceDest); +} + +// Checked: 2011-03-30 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +inline bool RlvFolderLocks::canRemoveItem(const LLUUID& idItem) const +{ + // Block removing items from locked folders (but disregard root folder locks) + const LLViewerInventoryItem* pItem = gInventory.getItem(idItem); const LLUUID& idFolder = (pItem) ? pItem->getParentUUID() : LLUUID::null; + int maskSource = ST_MASK_ANY & ~ST_ROOTFOLDER; + return (idFolder.notNull()) && (!isLockedFolder(idFolder, RLV_LOCK_ANY, maskSource)); +} + +// Checked: 2011-03-30 (RLVa-1.3.0g) | Added: RLVa-1.3.0g +inline bool RlvFolderLocks::canRenameItem(const LLUUID& idItem) const +{ + // Items can always be renamed, regardless of folder locks + return true; +} + +// Checked: 2010-11-30 (RLVa-1.3.0g) | Added: RLVa-1.3.0b +inline bool RlvFolderLocks::hasLockedAttachment() const +{ + if (m_fLookupDirty) + refreshLockedLookups(); + return !m_LockedAttachmentRem.empty(); +} + +// Checked: 2011-03-27 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g +inline bool RlvFolderLocks::hasLockedFolder(ERlvLockMask eLock) const +{ + // Remove locks are more common so check those first + return ((eLock & RLV_LOCK_REMOVE) && (m_cntLockRem)) || ((eLock & RLV_LOCK_ADD) && (m_cntLockAdd)); +} + +// Checked: 2010-11-30 (RLVa-1.3.0g) | Added: RLVa-1.3.0b +inline bool RlvFolderLocks::hasLockedWearable() const +{ + if (m_fLookupDirty) + refreshLockedLookups(); + return !m_LockedWearableRem.empty(); +} + +// Checked: 2010-11-30 (RLVa-1.3.0g) | Added: RLVa-1.3.0b +inline bool RlvFolderLocks::isLockedAttachment(const LLUUID& idItem) const +{ + if (m_fLookupDirty) + refreshLockedLookups(); + return (std::find(m_LockedAttachmentRem.begin(), m_LockedAttachmentRem.end(), idItem) != m_LockedAttachmentRem.end()); +} + +// Checked: 2010-11-30 (RLVa-1.3.0g) | Added: RLVa-1.3.0b +inline bool RlvFolderLocks::isLockedWearable(const LLUUID& idItem) const +{ + if (m_fLookupDirty) + refreshLockedLookups(); + return (std::find(m_LockedWearableRem.begin(), m_LockedWearableRem.end(), idItem) != m_LockedWearableRem.end()); +} + +// ============================================================================ + +#endif // RLV_LOCKS_H diff --git a/indra/newview/rlvui.cpp b/indra/newview/rlvui.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4fced69a1a84dea4bd8a0b94cb0f0d2871924bca --- /dev/null +++ b/indra/newview/rlvui.cpp @@ -0,0 +1,616 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#include "llviewerprecompiledheaders.h" +#include "llagent.h" +#include "llavataractions.h" // LLAvatarActions::profileVisible() +#include "llavatarlist.h" // Avatar list control used by the "Nearby" tab in the "People" sidebar panel +#include "llavatarnamecache.h" +#include "llenvmanager.h" +#include "llfloatersidepanelcontainer.h" +#include "llhudtext.h" // LLHUDText::refreshAllObjectText() +#include "llimview.h" // LLIMMgr::computeSessionID() +#include "llmoveview.h" // Movement panel (contains "Stand" and "Stop Flying" buttons) +#include "llnavigationbar.h" // Navigation bar +#include "lloutfitslist.h" // "My Outfits" sidebar panel +#include "llpaneloutfitsinventory.h" // "My Appearance" sidebar panel +#include "llpanelpeople.h" // "People" sidebar panel +#include "llpanelwearing.h" // "Current Outfit" sidebar panel +#include "llparcel.h" +#include "llsidepanelappearance.h" +#include "lltabcontainer.h" +#include "llteleporthistory.h" +#include "llteleporthistorystorage.h" +#include "lltoolmgr.h" +#include "llviewerparcelmgr.h" +#include "llvoavatar.h" +#include "roles_constants.h" // Group "powers" + +#include "rlvui.h" +#include "rlvhandler.h" +#include "rlvextensions.h" + +// ============================================================================ + +// Checked: 2010-02-28 (RLVa-1.4.0a) | Added: RLVa-1.2.0a +RlvUIEnabler::RlvUIEnabler() +{ + // Connect us to the behaviour toggle signal + gRlvHandler.setBehaviourToggleCallback(boost::bind(&RlvUIEnabler::onBehaviourToggle, this, _1, _2)); + + // onRefreshHoverText() + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWLOC, boost::bind(&RlvUIEnabler::onRefreshHoverText, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWNAMES, boost::bind(&RlvUIEnabler::onRefreshHoverText, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWHOVERTEXTALL, boost::bind(&RlvUIEnabler::onRefreshHoverText, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWHOVERTEXTWORLD, boost::bind(&RlvUIEnabler::onRefreshHoverText, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWHOVERTEXTHUD, boost::bind(&RlvUIEnabler::onRefreshHoverText, this))); + + // onToggleMovement + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_FLY, boost::bind(&RlvUIEnabler::onToggleMovement, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_ALWAYSRUN, boost::bind(&RlvUIEnabler::onToggleMovement, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_TEMPRUN, boost::bind(&RlvUIEnabler::onToggleMovement, this))); + + // onToggleViewXXX + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_VIEWNOTE, boost::bind(&RlvUIEnabler::onToggleViewXXX, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_VIEWSCRIPT, boost::bind(&RlvUIEnabler::onToggleViewXXX, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_VIEWTEXTURE, boost::bind(&RlvUIEnabler::onToggleViewXXX, this))); + + // onToggleXXX + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_EDIT, boost::bind(&RlvUIEnabler::onToggleEdit, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SENDIM, boost::bind(&RlvUIEnabler::onToggleSendIM, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SETDEBUG, boost::bind(&RlvUIEnabler::onToggleSetDebug, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SETENV, boost::bind(&RlvUIEnabler::onToggleSetEnv, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWINV, boost::bind(&RlvUIEnabler::onToggleShowInv, this, _1))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWLOC, boost::bind(&RlvUIEnabler::onToggleShowLoc, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWMINIMAP, boost::bind(&RlvUIEnabler::onToggleShowMinimap, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWNAMES, boost::bind(&RlvUIEnabler::onToggleShowNames, this, _1))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWWORLDMAP, boost::bind(&RlvUIEnabler::onToggleShowWorldMap, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_UNSIT, boost::bind(&RlvUIEnabler::onToggleUnsit, this))); + + // onToggleTp + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_TPLOC, boost::bind(&RlvUIEnabler::onToggleTp, this))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_TPLM, boost::bind(&RlvUIEnabler::onToggleTp, this))); + + // onUpdateLoginLastLocation + #ifdef RLV_EXTENSION_STARTLOCATION + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_TPLOC, boost::bind(&RlvUIEnabler::onUpdateLoginLastLocation, this, _1))); + m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_UNSIT, boost::bind(&RlvUIEnabler::onUpdateLoginLastLocation, this, _1))); + #endif // RLV_EXTENSION_STARTLOCATION +} + +// Checked: 2010-02-28 (RLVa-1.4.0a) | Added: RLVa-1.2.0a +void RlvUIEnabler::onBehaviourToggle(ERlvBehaviour eBhvr, ERlvParamType eType) +{ + bool fQuitting = LLApp::isQuitting(); + for (behaviour_handler_map_t::const_iterator itHandler = m_Handlers.lower_bound(eBhvr), endHandler = m_Handlers.upper_bound(eBhvr); + itHandler != endHandler; ++itHandler) + { + itHandler->second(fQuitting); + } +} + +// ============================================================================ + +// Checked: 2010-03-02 (RLVa-1.4.0a) | Added: RLVa-1.2.0a +void RlvUIEnabler::onRefreshHoverText() +{ + // Refresh all hover text each time any of the monitored behaviours get set or unset + LLHUDText::refreshAllObjectText(); +} + +// Checked: 2010-03-17 (RLVa-1.2.0a) | Added: RLVa-1.2.0a +void RlvUIEnabler::onToggleEdit() +{ + bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_EDIT); + + if (!fEnable) + { + // Turn off "View / Highlight Transparent" + LLDrawPoolAlpha::sShowDebugAlpha = FALSE; + + // Hide the beacons floater if it's currently visible + if (LLFloaterReg::instanceVisible("beacons")) + LLFloaterReg::hideInstance("beacons"); + + // Hide the build floater if it's currently visible + if (LLFloaterReg::instanceVisible("build")) + LLToolMgr::instance().toggleBuildMode(); + } + + // Start or stop filtering opening the beacons floater + if (!fEnable) + addGenericFloaterFilter("beacons"); + else + removeGenericFloaterFilter("beacons"); +} + +// Checked: 2010-03-02 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a +void RlvUIEnabler::onToggleMovement() +{ + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_FLY)) && (gAgent.getFlying()) ) + gAgent.setFlying(FALSE); + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_ALWAYSRUN)) && (gAgent.getAlwaysRun()) ) + gAgent.clearAlwaysRun(); + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_TEMPRUN)) && (gAgent.getTempRun()) ) + gAgent.clearTempRun(); + + // Force an update since the status only updates when the current parcel changes [see LLFloaterMove::postBuild()] + LLFloaterMove::sUpdateMovementStatus(); +} + +// Checked: 2013-05-11 (RLVa-1.4.9) +void RlvUIEnabler::onToggleSendIM() +{ + bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_SENDIM); + gSavedPerAccountSettings.getControl("DoNotDisturbModeResponse")->setHiddenFromSettingsEditor(!fEnable); +} + +// Checked: 2011-05-28 (RLVa-1.4.0a) | Added: RLVa-1.4.0a +void RlvUIEnabler::onToggleSetDebug() +{ + bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_SETDEBUG); + for (std::map<std::string, S16>::const_iterator itSetting = RlvExtGetSet::m_DbgAllowed.begin(); + itSetting != RlvExtGetSet::m_DbgAllowed.end(); ++itSetting) + { + if (itSetting->second & RlvExtGetSet::DBG_WRITE) + gSavedSettings.getControl(itSetting->first)->setHiddenFromSettingsEditor(!fEnable); + } +} + +// Checked: 2011-09-04 (RLVa-1.4.1a) | Modified: RLVa-1.4.1a +void RlvUIEnabler::onToggleSetEnv() +{ + bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV); + + const std::string strEnvFloaters[] = + { "env_post_process", "env_settings", "env_delete_preset", "env_edit_sky", "env_edit_water", "env_edit_day_cycle" }; + for (int idxFloater = 0, cntFloater = sizeof(strEnvFloaters) / sizeof(std::string); idxFloater < cntFloater; idxFloater++) + { + if (!fEnable) + { + // Hide the floater if it's currently visible + if (LLFloaterReg::instanceVisible(strEnvFloaters[idxFloater])) + LLFloaterReg::hideInstance(strEnvFloaters[idxFloater]); + + addGenericFloaterFilter(strEnvFloaters[idxFloater]); + } + else + { + removeGenericFloaterFilter(strEnvFloaters[idxFloater]); + } + } + + // Don't allow toggling "Basic Shaders" and/or "Atmopsheric Shaders" through the debug settings under @setenv=n + gSavedSettings.getControl("VertexShaderEnable")->setHiddenFromSettingsEditor(!fEnable); + gSavedSettings.getControl("WindLightUseAtmosShaders")->setHiddenFromSettingsEditor(!fEnable); + + // Restore the user's WindLight preferences when releasing + if (fEnable) + LLEnvManagerNew::instance().usePrefs(); +} + +// Checked: 2011-11-04 (RLVa-1.4.4a) | Modified: RLVa-1.4.4a +void RlvUIEnabler::onToggleShowInv(bool fQuitting) +{ + if (fQuitting) + return; // Nothing to do if the viewer is shutting down + + bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWINV); + + // + // When disabling, close any inventory floaters that may be open + // + if (!fEnable) + { + LLFloaterReg::const_instance_list_t lFloaters = LLFloaterReg::getFloaterList("inventory"); + for (LLFloaterReg::const_instance_list_t::const_iterator itFloater = lFloaters.begin(); itFloater != lFloaters.end(); ++itFloater) + (*itFloater)->closeFloater(); + } + + // + // Enable/disable the "My Outfits" panel on the "My Appearance" sidebar tab + // + LLPanelOutfitsInventory* pAppearancePanel = LLPanelOutfitsInventory::findInstance(); + RLV_ASSERT(pAppearancePanel); + if (pAppearancePanel) + { + LLTabContainer* pAppearanceTabs = pAppearancePanel->getAppearanceTabs(); + LLOutfitsList* pMyOutfitsPanel = pAppearancePanel->getMyOutfitsPanel(); + if ( (pAppearanceTabs) && (pMyOutfitsPanel) ) + { + S32 idxTab = pAppearanceTabs->getIndexForPanel(pMyOutfitsPanel); + RLV_ASSERT(-1 != idxTab); + pAppearanceTabs->enableTabButton(idxTab, fEnable); + + // When disabling, switch to the COF tab if "My Outfits" is currently active + if ( (!fEnable) && (pAppearanceTabs->getCurrentPanelIndex() == idxTab) ) + pAppearanceTabs->selectTabPanel(pAppearancePanel->getCurrentOutfitPanel()); + } + + LLSidepanelAppearance* pCOFPanel = pAppearancePanel->getAppearanceSP(); + RLV_ASSERT(pCOFPanel); + if ( (!fEnable) && (pCOFPanel) && (pCOFPanel->isOutfitEditPanelVisible()) ) + { + // TODO-RLVa: we should really just be collapsing the "Add more..." inventory panel (and disable the button) + pCOFPanel->showOutfitsInventoryPanel(); + } + } + + // + // Filter (or stop filtering) opening new inventory floaters + // + if (!fEnable) + addGenericFloaterFilter("inventory"); + else + removeGenericFloaterFilter("inventory"); +} + +// Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f +void RlvUIEnabler::onToggleShowLoc() +{ + bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC); + + // RELEASE-RLVa: [SL-2.0.1] Check that the code below still evaluates to *only* LLNavigationBar::instance().mCmbLocation->refresh() + LLNavigationBar::instance().handleLoginComplete(); + + if (!fEnable) + { + // Hide the "About Land" floater if it's currently visible + if (LLFloaterReg::instanceVisible("about_land")) + LLFloaterReg::hideInstance("about_land"); + // Hide the "Region / Estate" floater if it's currently visible + if (LLFloaterReg::instanceVisible("region_info")) + LLFloaterReg::hideInstance("region_info"); + // Hide the "God Tools" floater if it's currently visible + if (LLFloaterReg::instanceVisible("god_tools")) + LLFloaterReg::hideInstance("god_tools"); + + // + // Manipulate the teleport history + // + + // If the last entry in the persistent teleport history matches the current teleport history entry then we should remove it + LLTeleportHistory* pTpHistory = LLTeleportHistory::getInstance(); + LLTeleportHistoryStorage* pTpHistoryStg = LLTeleportHistoryStorage::getInstance(); + RLV_ASSERT( (pTpHistory) && (pTpHistoryStg) && (pTpHistory->getItems().size() > 0) && (pTpHistory->getCurrentItemIndex() >= 0) ); + if ( (pTpHistory) && (pTpHistory->getItems().size() > 0) && (pTpHistory->getCurrentItemIndex() >= 0) && + (pTpHistoryStg) && (pTpHistory->getItems().size() > 0) ) + { + const LLTeleportHistoryItem& tpItem = pTpHistory->getItems().back(); + const LLTeleportHistoryPersistentItem& tpItemStg = pTpHistoryStg->getItems().back(); + if (pTpHistoryStg->compareByTitleAndGlobalPos(tpItemStg, LLTeleportHistoryPersistentItem(tpItem.mTitle, tpItem.mGlobalPos))) + { + // TODO-RLVa: [RLVa-1.2.2] Is there a reason why LLTeleportHistoryStorage::removeItem() doesn't trigger history changed? + pTpHistoryStg->removeItem(pTpHistoryStg->getItems().size() - 1); + pTpHistoryStg->mHistoryChangedSignal(-1); + } + } + + // Clear the current location in the teleport history + if (pTpHistory) + pTpHistory->updateCurrentLocation(gAgent.getPositionGlobal()); + } + else + { + // Reset the current location in the teleport history (also takes care of adding it to the persistent teleport history) + LLTeleportHistory* pTpHistory = LLTeleportHistory::getInstance(); + if ( (pTpHistory) && (NULL != gAgent.getRegion()) ) + pTpHistory->updateCurrentLocation(gAgent.getPositionGlobal()); + } + + // Start or stop filtering the "About Land" and "Region / Estate" floaters + if ( (!fEnable) && (!m_ConnFloaterShowLoc.connected()) ) + { + m_ConnFloaterShowLoc = LLFloaterReg::setValidateCallback(boost::bind(&RlvUIEnabler::filterFloaterShowLoc, this, _1, _2)); + m_ConnPanelShowLoc = LLFloaterSidePanelContainer::setValidateCallback(boost::bind(&RlvUIEnabler::filterPanelShowLoc, this, _1, _2, _3)); + } + else if ( (fEnable) && (m_ConnFloaterShowLoc.connected()) ) + { + m_ConnFloaterShowLoc.disconnect(); + m_ConnPanelShowLoc.disconnect(); + } +} + +// Checked: 2010-02-28 (RLVa-1.4.0a) | Added: RLVa-1.2.0a +void RlvUIEnabler::onToggleShowMinimap() +{ + bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWMINIMAP); + + // Start or stop filtering showing the mini-map floater + if (!fEnable) + addGenericFloaterFilter("mini_map"); + else + removeGenericFloaterFilter("mini_map"); + + // Hide the mini-map floater if it's currently visible (or restore it if it was previously visible) + static bool fPrevVisibile = false; + if ( (!fEnable) && ((fPrevVisibile = LLFloaterReg::instanceVisible("mini_map"))) ) + LLFloaterReg::hideInstance("mini_map"); + else if ( (fEnable) && (fPrevVisibile) ) + LLFloaterReg::showInstance("mini_map"); + + // Break/reestablish the visibility connection for the nearby people panel embedded minimap instance + LLPanel* pPeoplePanel = LLFloaterSidePanelContainer::getPanel("people", "panel_people"); + LLPanel* pNetMapPanel = (pPeoplePanel) ? pPeoplePanel->findChild<LLPanel>("Net Map Panel", TRUE) : NULL; + RLV_ASSERT( (pPeoplePanel) && (pNetMapPanel) ); + if (pNetMapPanel) + { + pNetMapPanel->setMakeVisibleControlVariable( (fEnable) ? gSavedSettings.getControl("NearbyListShowMap").get() : NULL); + // Reestablishing the visiblity connection will show the panel if needed so we only need to take care of hiding it when needed + if ( (!fEnable) && (pNetMapPanel->getVisible()) ) + pNetMapPanel->setVisible(false); + } +} + +// Checked: 2010-12-08 (RLVa-1.4.0a) | Modified: RLVa-1.2.2c +void RlvUIEnabler::onToggleShowNames(bool fQuitting) +{ + if (fQuitting) + return; // Nothing to do if the viewer is shutting down + + bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES); + + // Refresh the nearby people list + LLPanelPeople* pPeoplePanel = LLFloaterSidePanelContainer::getPanel<LLPanelPeople>("people", "panel_people"); + RLV_ASSERT( (pPeoplePanel) && (pPeoplePanel->getNearbyList()) ); + if ( (pPeoplePanel) && (pPeoplePanel->getNearbyList()) ) + pPeoplePanel->getNearbyList()->updateAvatarNames(); + +// // Refresh the speaker list +// LLCallFloater* pCallFloater = LLFloaterReg::findTypedInstance<LLCallFloater>("voice_controls"); +// if (pCallFloater) +// pCallFloater->getAvatarCallerList()->updateAvatarNames(); + + // Force the use of the "display name" cache so we can filter both display and legacy names (or return back to the user's preference) + if (!fEnable) + { + LLAvatarNameCache::setForceDisplayNames(true); + } + else + { + LLAvatarNameCache::setForceDisplayNames(false); + LLAvatarNameCache::setUseDisplayNames(gSavedSettings.getBOOL("UseDisplayNames")); + } + LLVOAvatar::invalidateNameTags(); // See handleDisplayNamesOptionChanged() +} + +// Checked: 2010-02-28 (RLVa-1.4.0a) | Added: RLVa-1.2.0a +void RlvUIEnabler::onToggleShowWorldMap() +{ + bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWWORLDMAP); + + // Hide the world map if it's currently visible + if ( (!fEnable) && (LLFloaterReg::instanceVisible("world_map")) ) + LLFloaterReg::hideInstance("world_map"); + + // Start or stop filtering opening the world map + if (!fEnable) + addGenericFloaterFilter("world_map"); + else + removeGenericFloaterFilter("world_map"); +} + +// Checked: 2010-08-22 (RLVa-1.2.1a) | Added: RLVa-1.2.1a +void RlvUIEnabler::onToggleTp() +{ + // Disable the navigation bar "Home" button if both @tplm=n *and* @tploc=n restricted + LLButton* pNavBarHomeBtn = LLNavigationBar::getInstance()->findChild<LLButton>("home_btn"); + RLV_ASSERT(pNavBarHomeBtn); + if (pNavBarHomeBtn) + pNavBarHomeBtn->setEnabled(!(gRlvHandler.hasBehaviour(RLV_BHVR_TPLM) && gRlvHandler.hasBehaviour(RLV_BHVR_TPLOC))); +} + +// Checked: 2010-03-01 (RLVa-1.2.0c) | Added: RLVa-1.2.0a +void RlvUIEnabler::onToggleUnsit() +{ + bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT); + + LLPanelStandStopFlying* pPanelStand = LLPanelStandStopFlying::getInstance(); + RLV_ASSERT(pPanelStand); + if (pPanelStand) + { + LLButton* pBtnStand = pPanelStand->findChild<LLButton>("stand_btn"); + RLV_ASSERT(pBtnStand); + if (pBtnStand) + pBtnStand->setEnabled(fEnable); + } +} + +// Checked: 2010-03-01 (RLVa-1.2.0b) | Added: RLVa-1.2.0a +void RlvUIEnabler::onToggleViewXXX() +{ + // If any of the three are still active then we keep filtering + bool fHasViewXXX = (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWNOTE)) || + (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWSCRIPT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWTEXTURE)); + + // Start or stop filtering opening the preview floaters + if ( (fHasViewXXX) && (!m_ConnFloaterViewXXX.connected()) ) + m_ConnFloaterViewXXX = LLFloaterReg::setValidateCallback(boost::bind(&RlvUIEnabler::filterFloaterViewXXX, this, _1, _2)); + else if ( (!fHasViewXXX) && (m_ConnFloaterViewXXX.connected()) ) + m_ConnFloaterViewXXX.disconnect(); +} + +// Checked: 2010-04-01 (RLVa-1.2.0c) | Added: RLVa-1.2.0c +void RlvUIEnabler::onUpdateLoginLastLocation(bool fQuitting) +{ + if (!fQuitting) + RlvSettings::updateLoginLastLocation(); +} + +// ============================================================================ + +// Checked: 2010-02-28 (RLVa-1.4.0a) | Added: RLVa-1.2.0a +void RlvUIEnabler::addGenericFloaterFilter(const std::string& strFloaterName) +{ + m_FilteredFloaters.insert(strFloaterName); + + if (!m_ConnFloaterGeneric.connected()) + m_ConnFloaterGeneric = LLFloaterReg::setValidateCallback(boost::bind(&RlvUIEnabler::filterFloaterGeneric, this, _1, _2)); +} + +// Checked: 2010-02-28 (RLVa-1.4.0a) | Added: RLVa-1.2.0a +void RlvUIEnabler::removeGenericFloaterFilter(const std::string& strFloaterName) +{ + std::multiset<std::string>::iterator itFloater = m_FilteredFloaters.find(strFloaterName); + RLV_ASSERT_DBG(itFloater != m_FilteredFloaters.end()); + m_FilteredFloaters.erase(itFloater); + + RLV_ASSERT_DBG(m_ConnFloaterGeneric.connected()); + if (m_FilteredFloaters.empty()) + m_ConnFloaterGeneric.disconnect(); +} + +// Checked: 2010-02-28 (RLVa-1.4.0a) | Added: RLVa-1.2.0a +bool RlvUIEnabler::filterFloaterGeneric(const std::string& strName, const LLSD&) +{ + return m_FilteredFloaters.end() == m_FilteredFloaters.find(strName); +} + +// Checked: 2010-04-22 (RLVa-1.4.5) | Added: RLVa-1.2.0 +bool RlvUIEnabler::filterFloaterShowLoc(const std::string& strName, const LLSD&) +{ + if ("about_land" == strName) + return canViewParcelProperties(); + else if ("region_info" == strName) + return canViewRegionProperties(); + else if ("god_tools" == strName) + return false; + return true; +} + +// Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 +bool RlvUIEnabler::filterPanelShowLoc(const std::string& strFloater, const std::string&, const LLSD& sdKey) +{ + if ("places" == strFloater) + { + const std::string strType = sdKey["type"].asString(); + if ("create_landmark" == strType) + return false; + else if ("agent" == strType) + return canViewParcelProperties(); + } + return true; +} + +// Checked: 2010-03-01 (RLVa-1.2.0b) | Added: RLVa-1.2.0a +bool RlvUIEnabler::filterFloaterViewXXX(const std::string& strName, const LLSD&) +{ + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWNOTE)) && ("preview_notecard" == strName) ) + { + RlvUtil::notifyBlockedViewXXX(LLAssetType::AT_NOTECARD); + return false; + } + else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWSCRIPT)) && (("preview_script" == strName) || ("preview_scriptedit" == strName)) ) + { + RlvUtil::notifyBlockedViewXXX(LLAssetType::AT_SCRIPT); + return false; + } + else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWTEXTURE)) && ("preview_texture" == strName) ) + { + RlvUtil::notifyBlockedViewXXX(LLAssetType::AT_TEXTURE); + return false; + } + return true; +} + +// ============================================================================ + +// Checked: 2012-02-09 (RLVa-1.4.5) | Modified: RLVa-1.4.5 +bool RlvUIEnabler::canViewParcelProperties() +{ + // We'll allow "About Land" as long as the user has the ability to return prims (through ownership or through group powers) + bool fShow = !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC); + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { + // RELEASE-RLVa: [SL-3.2] Check that opening the "About Land" floater still sets focus to the current parcel is none is selected + const LLParcel* pParcel = NULL; + if (LLViewerParcelMgr::getInstance()->selectionEmpty()) + { + pParcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); + } + else + { + LLParcelSelection* pParcelSel = LLViewerParcelMgr::getInstance()->getFloatingParcelSelection(); + if (pParcelSel->hasOthersSelected()) + return false; + pParcel = pParcelSel->getParcel(); + } + + // Ideally we could just use LLViewerParcelMgr::isParcelOwnedByAgent(), but that has that sneaky exemption for "god-like" + if (pParcel) + { + const LLUUID& idOwner = pParcel->getOwnerID(); + if ( (idOwner != gAgent.getID()) ) + { + S32 count = gAgent.mGroups.count(); + for (S32 i = 0; i < count; ++i) + { + if (gAgent.mGroups.get(i).mID == idOwner) + { + fShow = ((gAgent.mGroups.get(i).mPowers & GP_LAND_RETURN) > 0); + break; + } + } + } + else + { + fShow = true; + } + } + } + return fShow; +} + +// Checked: 2010-04-20 (RLVa-1.4.5) | Modified: RLVa-1.2.0 +bool RlvUIEnabler::canViewRegionProperties() +{ + // We'll allow "Region / Estate" if the user is either the region owner or an estate manager + bool fShow = !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC); + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) + { + // [See LLRegion::canManageEstate() but without the "god-like" exception] + const LLViewerRegion* pRegion = gAgent.getRegion(); + if (pRegion) + fShow = (pRegion->isEstateManager()) || (pRegion->getOwner() == gAgent.getID()); + } + return fShow; +} + +// Checked: 2010-04-20 (RLVa-1.2.0f) | Added: RLVa-1.2.0f +bool RlvUIEnabler::hasOpenIM(const LLUUID& idAgent) +{ + LLUUID idSession = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, idAgent); + return (NULL != LLFloaterReg::findInstance("impanel", idSession)); +} + +// Checked: 2011-11-04 (RLVa-1.4.4a) | Modified: RLVa-1.4.4a +bool RlvUIEnabler::hasOpenProfile(const LLUUID& idAgent) +{ + // -> SL-2.1.0 added the ability to "share" inventory by dropping it on the avatar picker floater so we should check for that + // -> we can drag/drop inventory onto calling cards but probably noone knows about it and it would be too involved to check for that + // TODO-RLVa: [RLVa-1.2.1] Check the avatar picker as well + + // Check if the user has the specified agent's profile open + return LLAvatarActions::profileVisible(idAgent); +} + +// Checked: 2010-09-11 (RLVa-1.2.1d) | Added: RLVa-1.2.1d +bool RlvUIEnabler::isBuildEnabled() +{ + return (gAgent.canEditParcel()) && ((!gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) || (!gRlvHandler.hasBehaviour(RLV_BHVR_REZ))); +} + +// ============================================================================ diff --git a/indra/newview/rlvui.h b/indra/newview/rlvui.h new file mode 100644 index 0000000000000000000000000000000000000000..e768bb068c4b7cb35f270f7561acab1df0245d32 --- /dev/null +++ b/indra/newview/rlvui.h @@ -0,0 +1,102 @@ +/** + * + * Copyright (c) 2009-2011, Kitty Barnett + * + * The source code in this file is provided to you under the terms of the + * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt + * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt + * + * By copying, modifying or distributing this software, you acknowledge that + * you have read and understood your obligations described above, and agree to + * abide by those obligations. + * + */ + +#ifndef RLV_UI_H +#define RLV_UI_H + +#include "llfloaterreg.h" +#include "llsingleton.h" + +#include "rlvdefines.h" + +// ============================================================================ +// RlvUIEnabler - self-contained class that handles disabling or reenabling certain aspects of the viewer's UI +// + +class RlvUIEnabler : public LLSingleton<RlvUIEnabler> +{ +protected: + RlvUIEnabler(); + friend class LLSingleton<RlvUIEnabler>; + friend class RlvHandler; + + /* + * Signal callbacks + */ +public: + void onBehaviourToggle(ERlvBehaviour eBhvr, ERlvParamType eType); // RlvHandler::rlv_behaviour_signal_t + + /* + * Behaviour handlers + */ +protected: + void onRefreshHoverText(); // showloc, shownames, showhovertext(all|world|hud) + void onToggleEdit(); // edit + void onToggleMovement(); // fly, alwaysrun and temprun + void onToggleSendIM(); // sendim + void onToggleSetDebug(); // setdebug + void onToggleSetEnv(); // setenv + void onToggleShowInv(bool fQuitting); // showinv + void onToggleShowLoc(); // showloc + void onToggleShowMinimap(); // showminimap + void onToggleShowNames(bool fQuitting); // shownames + void onToggleShowWorldMap(); // showworldmap + void onToggleTp(); // tploc and tplm + void onToggleUnsit(); // unsit + void onToggleViewXXX(); // viewnote, viewscript, viewtexture + void onUpdateLoginLastLocation(bool fQuitting); // tploc and unsit + + /* + * Floater and sidebar validation callbacks + */ +protected: + void addGenericFloaterFilter(const std::string& strFloaterName); + void removeGenericFloaterFilter(const std::string& strFloaterName); + + bool filterFloaterGeneric(const std::string&, const LLSD&); + boost::signals2::connection m_ConnFloaterGeneric; + bool filterFloaterShowLoc(const std::string&, const LLSD& ); + boost::signals2::connection m_ConnFloaterShowLoc; // showloc + bool filterFloaterViewXXX(const std::string&, const LLSD&); + boost::signals2::connection m_ConnFloaterViewXXX; // viewnote, viewscript, viewtexture + + bool filterPanelShowLoc(const std::string&, const std::string&, const LLSD& ); + boost::signals2::connection m_ConnPanelShowLoc; // showloc + + /* + * Helper functions + */ +public: + static bool canViewParcelProperties(); // showloc + static bool canViewRegionProperties(); // showloc + static bool hasOpenIM(const LLUUID& idAgent); // shownames + static bool hasOpenProfile(const LLUUID& idAgent); // shownames + static bool isBuildEnabled(); // edit and rez + + /* + * Member variables + */ +protected: + typedef boost::function<void(bool)> behaviour_handler_t; + typedef std::multimap<ERlvBehaviour, behaviour_handler_t> behaviour_handler_map_t; + behaviour_handler_map_t m_Handlers; + + std::multiset<std::string> m_FilteredFloaters; +}; + +// ============================================================================ + +#endif // RLV_UI_H diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml index 703015af20081678693a8f0d72ad20312f1dd2e4..6c4d0979ce5a2cf5a9e405709752ed68ec146c0e 100755 --- a/indra/newview/skins/default/xui/en/floater_about.xml +++ b/indra/newview/skins/default/xui/en/floater_about.xml @@ -48,6 +48,7 @@ Windows Graphics Driver Version: [GRAPHICS_DRIVER_VERSION] name="AboutLibs"> OpenGL Version: [OPENGL_VERSION] +RestrainedLove API: [RLV_VERSION] libcurl Version: [LIBCURL_VERSION] J2C Decoder Version: [J2C_VERSION] Audio Driver Version: [AUDIO_DRIVER_VERSION] diff --git a/indra/newview/skins/default/xui/en/floater_map.xml b/indra/newview/skins/default/xui/en/floater_map.xml index b8893e11d90207b5430afd4630aadccc0f57fc44..ad66f37d3cb8b1ee6b96fe3dee63b9f3d9d58604 100755 --- a/indra/newview/skins/default/xui/en/floater_map.xml +++ b/indra/newview/skins/default/xui/en/floater_map.xml @@ -14,9 +14,10 @@ save_rect="true" save_visibility="true" width="200"> + <!-- RLVa shows the anonymized name on the regular tooltip when @shownames=n restricted (rather than show the avatar inspector) --> <floater.string name="ToolTipMsg"> - [REGION](Double-click to open Map, shift-drag to pan) + [AGENT][REGION](Double-click to open Map, shift-drag to pan) </floater.string> <floater.string name="AltToolTipMsg"> diff --git a/indra/newview/skins/default/xui/en/floater_rlv_behaviours.xml b/indra/newview/skins/default/xui/en/floater_rlv_behaviours.xml new file mode 100644 index 0000000000000000000000000000000000000000..fb373ce5b3408dc5ffd9a3d2cddab58d29b9b937 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_rlv_behaviours.xml @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + open_positioning="cascading" + can_close="true" + can_minimize="true" + can_resize="true" + height="300" + min_height="300" + min_width="300" + name="rlv_behaviours" + save_rect="true" + save_visibility="false" + single_instance="true" + title="ACTIVE RLV RESTRICTIONS" + width="300"> + <tab_container + follows="all" + layout="topleft" + left="8" + name="behaviour_tab" + height="266" + right="-8" + tab_height="23" + tab_min_width="120" + tab_position="top" + top="0" > + <panel + follows="all" height="265" + label="RESTRICTIONS" + layout="topleft" + name="behaviour_panel" + top="0"> + <scroll_list + draw_border="false" + draw_heading="true" + draw_stripes="true" + follows="all" + height="266" + layout="topleft" + multi_select="false" + name="behaviour_list" + tool_tip="List of current RLVa restrictions." + top_pad="0" > + <scroll_list.columns label="Restriction" name="behaviour" width="70" /> + <scroll_list.columns label="Object Name" name="issuer" /> + </scroll_list> + </panel> + <panel + follows="all" height="265" + label="EXCEPTIONS" + layout="topleft" + name="exception_panel" + top="0"> + <scroll_list + draw_border="false" + draw_heading="true" + draw_stripes="true" + follows="all" + height="266" + layout="topleft" + multi_select="false" + name="exception_list" + tool_tip="List of current RLVa exceptions." + top_pad="0" > + <scroll_list.columns label="Exception" name="behaviour" width="70" /> + <scroll_list.columns label="Source" name="option" width="105" /> + <scroll_list.columns label="Object Name" name="issuer" /> + </scroll_list> + </panel> + </tab_container> + <panel + background_visible="false" + follows="left|right|bottom" + height="25" + label="bottom_panel" + layout="topleft" + name="bottom_panel" + top_pad="0"> + <button + image_hover_unselected="Toolbar_Left_Over" + image_overlay="Copy" + image_overlay_alignment="left" + image_selected="Toolbar_Left_Selected" + image_unselected="Toolbar_Left_Off" + label="Copy to Clipboard" + left="0" + name="copy_btn" + top="1" + width="129" /> + <icon + follows="left|right" + image_name="Toolbar_Right_Off" + left_pad="1" + name="dummy_icon" + top="1" + width="153" /> + </panel> +</floater> diff --git a/indra/newview/skins/default/xui/en/floater_rlv_locks.xml b/indra/newview/skins/default/xui/en/floater_rlv_locks.xml new file mode 100644 index 0000000000000000000000000000000000000000..d6665bcef2a6d5dfc4b585b5c84f220d31ae9386 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_rlv_locks.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + can_close="true" + can_minimize="true" + can_resize="true" + height="200" + min_height="200" + min_width="500" + name="rlvLocks" + save_rect="true" + save_visibility="false" + single_instance="true" + positioning="cascading" + reuse_instance="true" + title="ACTIVE RLV LOCKS" + width="500"> + <panel + class="panel_rlvLocks" + filename="panel_rlv_locks.xml" + layout="topleft" + left="9" + name="panel_rlvLocks" + right="-8" + top="0" /> +</floater> \ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/floater_rlv_strings.xml b/indra/newview/skins/default/xui/en/floater_rlv_strings.xml new file mode 100644 index 0000000000000000000000000000000000000000..a492f8a809735f022ebb278a9a5d3b8297d5c9a7 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_rlv_strings.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + can_minimize="false" + height="215" + layout="topleft" + legacy_header_height="18" + name="rlva_strings" + title="RLVa Strings" + width="350"> + <combo_box + allow_text_entry="false" + follows="top|left" + height="22" + layout="topleft" + left="15" + max_chars="255" + name="string_list" + top="25" + width="320" /> + <text_editor + enabled="false" + height="60" + layout="topleft" + left_delta="0" + name="string_descr" + top_pad="5" + width="320" + word_wrap="true" /> + <text_editor + enabled="true" + height="60" + layout="topleft" + left_delta="0" + name="string_value" + top_pad="5" + width="320" + word_wrap="true" /> + <button + enabled="false" + height="22" + label="Reset to default" + layout="topleft" + left_delta="0" + name="default_btn" + top_pad="5" + width="150" > + <button.commit_callback + function="ClickDefault" /> + </button> +</floater> diff --git a/indra/newview/skins/default/xui/en/menu_attachment_other.xml b/indra/newview/skins/default/xui/en/menu_attachment_other.xml index ba91b0b5d9489a7aa9fcb1e55bdcd87b58cf57f8..91516d3ec178e33e58ce9bff7e4470e9216074df 100755 --- a/indra/newview/skins/default/xui/en/menu_attachment_other.xml +++ b/indra/newview/skins/default/xui/en/menu_attachment_other.xml @@ -9,6 +9,9 @@ <menu_item_call.on_click function="ShowAgentProfile" parameter="hit object" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="shownames" /> </menu_item_call> <menu_item_call enabled="false" @@ -24,6 +27,9 @@ name="Send IM..."> <menu_item_call.on_click function="Avatar.SendIM" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="shownames" /> </menu_item_call> <menu_item_call label="Call" @@ -36,8 +42,11 @@ <menu_item_call label="Invite to Group" name="Invite..."> - <menu_item_call.on_click + <menu_item_call.on_click function="Avatar.InviteToGroup" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="shownames" /> </menu_item_call> <menu_item_separator /> <menu_item_call diff --git a/indra/newview/skins/default/xui/en/menu_avatar_other.xml b/indra/newview/skins/default/xui/en/menu_avatar_other.xml index 8bd013f14b2d132da86ee484f76dc502ea94b129..ccf23ed7da39e9f0d5c43adea146c5be16a2ac2f 100755 --- a/indra/newview/skins/default/xui/en/menu_avatar_other.xml +++ b/indra/newview/skins/default/xui/en/menu_avatar_other.xml @@ -9,6 +9,9 @@ <menu_item_call.on_click function="ShowAgentProfile" parameter="hit object" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="shownames" /> </menu_item_call> <menu_item_call enabled="false" @@ -24,6 +27,9 @@ name="Send IM..."> <menu_item_call.on_click function="Avatar.SendIM" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="shownames" /> </menu_item_call> <menu_item_call label="Call" @@ -36,8 +42,11 @@ <menu_item_call label="Invite to Group" name="Invite..."> - <menu_item_call.on_click + <menu_item_call.on_click function="Avatar.InviteToGroup" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="shownames" /> </menu_item_call> <menu_item_separator /> diff --git a/indra/newview/skins/default/xui/en/menu_land.xml b/indra/newview/skins/default/xui/en/menu_land.xml index 2ad5cbbe951cd561d4b72ab58fa5afb16380842b..3a7f24fdf5bcd30725cd7fad0ff7a4e760886ea9 100755 --- a/indra/newview/skins/default/xui/en/menu_land.xml +++ b/indra/newview/skins/default/xui/en/menu_land.xml @@ -8,6 +8,9 @@ <menu_item_call.on_click function="Floater.Show" parameter="about_land" /> + <menu_item_call.on_enable + function="Floater.CanShow" + parameter="about_land" /> </menu_item_call> <!-- <menu_item_call label="Go Here" diff --git a/indra/newview/skins/default/xui/en/menu_place_add_button.xml b/indra/newview/skins/default/xui/en/menu_place_add_button.xml index e3a39a1242748c8b73874fc851b73cdd77f1db4a..bdd4e230b949b0327f107364c1ab29eabd5aae83 100755 --- a/indra/newview/skins/default/xui/en/menu_place_add_button.xml +++ b/indra/newview/skins/default/xui/en/menu_place_add_button.xml @@ -23,5 +23,8 @@ <on_click function="Places.LandmarksGear.Add.Action" parameter="add_landmark" /> + <on_enable + function="Places.LandmarksGear.Enable" + parameter="add_landmark" /> </menu_item_call> </menu> diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml index 1aeb166e01570aaccb4ead89d93c7a887e3a4cad..4d59ab06317bfc97007a222ff866d8a76d0aa63e 100755 --- a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml +++ b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml @@ -13,6 +13,9 @@ <on_click function="Places.LandmarksGear.Add.Action" parameter="add_landmark" /> + <on_enable + function="Places.LandmarksGear.Enable" + parameter="add_landmark" /> </menu_item_call> <menu_item_call label="Add Folder" diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml b/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml index ff5fdd3795322d5c3582f0b7ff7d73b3240c6d29..28c74a3d5d1813b75f8966bb9e51e2b9bfe0b95e 100755 --- a/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml +++ b/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml @@ -48,6 +48,9 @@ <on_click function="Places.LandmarksGear.Add.Action" parameter="add_landmark" /> + <on_enable + function="Places.LandmarksGear.Enable" + parameter="add_landmark" /> </menu_item_call> <menu_item_call label="Add Folder" diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index d635b8ee93e3c39c02e9e5440ff3f61493d6c939..e78689713fb47e5cfbb1ac5f3ebf7d412569375f 100755 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -469,6 +469,8 @@ name="Place Profile"> <menu_item_call.on_click function="World.PlaceProfile" /> + <menu_item_call.on_enable + function="World.EnablePlaceProfile" /> </menu_item_call> <menu_item_call label="About land" @@ -476,6 +478,9 @@ <menu_item_call.on_click function="Floater.Show" parameter="about_land" /> + <menu_item_call.on_enable + function="Floater.CanShow" + parameter="about_land" /> </menu_item_call> <menu_item_call label="Region / Estate" @@ -483,6 +488,9 @@ <menu_item_call.on_click function="Floater.Show" parameter="region_info" /> + <menu_item_call.on_enable + function="Floater.CanShow" + parameter="region_info" /> </menu_item_call> <menu_item_call label="My land holdings..." @@ -612,6 +620,9 @@ <menu_item_call.on_click function="World.EnvSettings" parameter="sunrise" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> </menu_item_call> <menu_item_call label="Midday" @@ -620,6 +631,9 @@ <menu_item_call.on_click function="World.EnvSettings" parameter="noon" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> </menu_item_call> <menu_item_call label="Sunset" @@ -628,6 +642,9 @@ <menu_item_call.on_click function="World.EnvSettings" parameter="sunset" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> </menu_item_call> <menu_item_call label="Midnight" @@ -635,6 +652,20 @@ <menu_item_call.on_click function="World.EnvSettings" parameter="midnight" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> + </menu_item_call> + <menu_item_separator/> + <menu_item_call + label="Estate Time" + name="Revert to Region Default"> + <menu_item_call.on_click + function="World.EnvSettings" + parameter="default" /> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> </menu_item_call> <menu_item_separator/> <menu_item_call @@ -659,6 +690,9 @@ <menu_item_call.on_click function="World.EnvSettings" parameter="editor"/> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> </menu_item_call> <menu_item_separator/> @@ -672,6 +706,9 @@ <menu_item_call.on_click function="World.EnvPreset" parameter="new_water"/> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> </menu_item_call> <menu_item_call label="Edit preset..." @@ -679,7 +716,10 @@ <menu_item_call.on_click function="World.EnvPreset" parameter="edit_water"/> - </menu_item_call> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> + </menu_item_call> <menu_item_call label="Delete preset..." name="delete_water_preset"> @@ -701,14 +741,20 @@ <menu_item_call.on_click function="World.EnvPreset" parameter="new_sky"/> - </menu_item_call> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> + </menu_item_call> <menu_item_call label="Edit preset..." name="edit_sky_preset"> <menu_item_call.on_click function="World.EnvPreset" parameter="edit_sky"/> - </menu_item_call> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> + </menu_item_call> <menu_item_call label="Delete preset..." name="delete_sky_preset"> @@ -730,14 +776,20 @@ <menu_item_call.on_click function="World.EnvPreset" parameter="new_day_cycle"/> - </menu_item_call> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> + </menu_item_call> <menu_item_call label="Edit preset..." name="edit_day_preset"> <menu_item_call.on_click function="World.EnvPreset" parameter="edit_day_cycle"/> - </menu_item_call> + <menu_item_call.on_enable + function="RLV.EnableIfNot" + parameter="setenv" /> + </menu_item_call> <menu_item_call label="Delete preset..." name="delete_day_preset"> @@ -1403,6 +1455,194 @@ parameter="sl_about" /> </menu_item_call> </menu> + <menu + create_jump_keys="true" + label="RLVa" + name="RLVa Main" + tear_off="true" + visible="true"> + <menu + label="Debug" + name="Debug" + tear_off="true"> + <menu_item_check + label="Show Top-level RLVa Menu" + name="Show Top-level RLVa Menu"> + <menu_item_check.on_check + function="CheckControl" + parameter="RLVaTopLevelMenu" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RLVaTopLevelMenu" /> + </menu_item_check> + <menu_item_separator/> + <menu_item_check + label="Show Debug Messages" + name="Show Debug Messages"> + <menu_item_check.on_check + function="CheckControl" + parameter="RestrainedLoveDebug" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RestrainedLoveDebug" /> + </menu_item_check> + <menu_item_check + label="Hide Unset or Duplicate Messages" + name="Hide Unset or Duplicate Messages"> + <menu_item_check.on_check + function="CheckControl" + parameter="RLVaDebugHideUnsetDuplicate" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RLVaDebugHideUnsetDuplicate" /> + </menu_item_check> + <menu_item_check + label="Show Assertion Failures" + name="Show Assertion Failures"> + <menu_item_check.on_check + function="CheckControl" + parameter="RLVaShowAssertionFailures" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RLVaShowAssertionFailures" /> + </menu_item_check> + <menu_item_separator/> + <menu_item_check + label="Hide Locked Layers" + name="Hide Locked Layers"> + <menu_item_check.on_check + function="CheckControl" + parameter="RLVaHideLockedLayers" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RLVaHideLockedLayers" /> + </menu_item_check> + <menu_item_check + label="Hide Locked Attachments" + name="Hide Locked Attachments"> + <menu_item_check.on_check + function="CheckControl" + parameter="RLVaHideLockedAttachments" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RLVaHideLockedAttachments" /> + </menu_item_check> + <menu_item_separator/> + <menu_item_check + label="Enable Legacy Naming" + name="Enable Legacy Naming"> + <menu_item_check.on_check + function="CheckControl" + parameter="RLVaEnableLegacyNaming" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RLVaEnableLegacyNaming" /> + </menu_item_check> + <menu_item_check + label="Enable Shared Wear" + name="Enable Shared Wear"> + <menu_item_check.on_check + function="CheckControl" + parameter="RLVaEnableSharedWear" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RLVaEnableSharedWear" /> + </menu_item_check> + <menu_item_check + label="Rename Shared Items on Wear" + name="Rename Shared Items on Wear"> + <menu_item_check.on_check + function="CheckControl" + parameter="RLVaSharedInvAutoRename" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RLVaSharedInvAutoRename" /> + </menu_item_check> + <menu_item_separator/> + <menu_item_check + label="Locks..." + name="Locks"> + <menu_item_check.on_check + function="Floater.Visible" + parameter="rlv_locks" /> + <menu_item_check.on_click + function="Floater.Toggle" + parameter="rlv_locks" /> + </menu_item_check> + </menu> + <menu_item_separator/> + <menu_item_check + label="Allow OOC Chat" + name="Allow OOC Chat"> + <menu_item_check.on_check + function="CheckControl" + parameter="RestrainedLoveCanOOC" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RestrainedLoveCanOOC" /> + </menu_item_check> + <menu_item_check + label="Forbid Give to #RLV" + name="Forbid Give to #RLV"> + <menu_item_check.on_check + function="CheckControl" + parameter="RestrainedLoveForbidGiveToRLV" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RestrainedLoveForbidGiveToRLV" /> + </menu_item_check> + <menu_item_check + label="Show Filtered Chat" + name="Show Filtered Chat"> + <menu_item_check.on_check + function="CheckControl" + parameter="RestrainedLoveShowEllipsis" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RestrainedLoveShowEllipsis" /> + </menu_item_check> + <menu_item_check + label="Show Name Tags" + name="Show Name Tags"> + <menu_item_check.on_check + function="CheckControl" + parameter="RLVaShowNameTags" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RLVaShowNameTags" /> + </menu_item_check> + <menu_item_check + label="Wear Replaces Unlocked" + name="Wear Replaces Unlocked"> + <menu_item_check.on_check + function="CheckControl" + parameter="RLVaWearReplaceUnlocked" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="RLVaWearReplaceUnlocked" /> + </menu_item_check> + <menu_item_separator /> + <menu_item_check + label="Restrictions..." + name="Restrictions"> + <menu_item_check.on_check + function="Floater.Visible" + parameter="rlv_behaviours" /> + <menu_item_check.on_click + function="Floater.Toggle" + parameter="rlv_behaviours" /> + </menu_item_check> + <menu_item_check + label="Strings..." + name="Strings"> + <menu_item_check.on_check + function="Floater.Visible" + parameter="rlv_strings" /> + <menu_item_check.on_click + function="Floater.Toggle" + parameter="rlv_strings" /> + </menu_item_check> + </menu> <menu create_jump_keys="true" label="Advanced" @@ -1853,6 +2093,11 @@ parameter="flexible" /> </menu_item_check> </menu> + <menu + label="RLVa" + name="RLVa Embedded" + tear_off="true" + visible="true" /> <menu_item_check label="Use Plugin Read Thread" name="Use Plugin Read Thread"> @@ -2009,7 +2254,14 @@ </menu> <!--Shortcuts--> <menu_item_separator/> - + <menu_item_check + label="RestrainedLove API" + name="RLV API"> + <menu_item_check.on_check + function="RLV.CheckEnabled" /> + <menu_item_check.on_click + function="RLV.ToggleEnabled" /> + </menu_item_check> <menu_item_call label="Show Debug Settings" name="Debug Settings"> diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index e7c89db06907e31966b1eab3297c69c85208a2bc..48161db708f69164fe0ea9a946309dbbf7f18be0 100755 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -6602,6 +6602,7 @@ Your object named <nolink>[OBJECTFROMNAME]</nolink> has given you th <notification icon="notify.tga" name="UserGiveItem" + label="Inventory offer from [NAME_LABEL]" log_to_im ="true" type="offer" sound="UISndNewIncomingIMSession"> @@ -6659,6 +6660,7 @@ Your object named <nolink>[OBJECTFROMNAME]</nolink> has given you th <notification icon="notify.tga" name="TeleportOffered" + label="Teleport offer from [NAME_LABEL]" log_to_im="true" log_to_chat="false" type="offer" @@ -6774,6 +6776,7 @@ Offer a teleport? <notification icon="notify.tga" name="OfferFriendship" + label="Friendship offer from [NAME_LABEL]" log_to_im="true" type="offer"> <tag>friendship</tag> @@ -6807,6 +6810,7 @@ Offer a teleport? <notification icon="notify.tga" name="OfferFriendshipNoMessage" + label="Friendship offer from [NAME_LABEL]" persist="true" type="notify"> <tag>friendship</tag> @@ -10155,6 +10159,13 @@ An internal error prevented us from properly updating your viewer. The L$ balan <tag>fail</tag> Cannot create large prims that intersect other players. Please re-try when other players have moved. </notification> + + <notification + icon="alertmodal.tga" + name="RLVChangeStrings" + type="alertmodal"> +Changes won't take effect until after you restart [APP_NAME]. + </notification> <notification icon="alertmodal.tga" diff --git a/indra/newview/skins/default/xui/en/panel_people.xml b/indra/newview/skins/default/xui/en/panel_people.xml index dc0e4a594752055fd9512085094a22c13acaf36c..664d431acda6ea3daac967e009797fcfa8343c5c 100755 --- a/indra/newview/skins/default/xui/en/panel_people.xml +++ b/indra/newview/skins/default/xui/en/panel_people.xml @@ -183,6 +183,7 @@ Looking for people to hang out with? Try the [secondlife:///app/worldmap World M layout="topleft" min_dim="100" mouse_opaque="false" + name="Net Map Panel" user_resize="true" visibility_control="NearbyListShowMap" width="313"> diff --git a/indra/newview/skins/default/xui/en/panel_rlv_locks.xml b/indra/newview/skins/default/xui/en/panel_rlv_locks.xml new file mode 100644 index 0000000000000000000000000000000000000000..d6755b2c922f64e083f7c8715add5d0d4bb9dd30 --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_rlv_locks.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + follows="all" + height="200" + label="ACTIVE RLV LOCKS" + layout="topleft" + name="panel_rlvLocks" + top="0" + width="500"> + <scroll_list + draw_border="false" + draw_heading="true" + draw_stripes="true" + follows="all" + height="167" + layout="topleft" + multi_select="false" + name="lock_list" + top_pad="0" > + <scroll_list.columns label="Lock Type" name="lock_type" width="100" /> + <scroll_list.columns label="Method" name="lock_addrem" width="60" /> + <scroll_list.columns label="Target Object / Point" name="lock_target" /> + <scroll_list.columns label="Lock Origin" name="lock_origin" width="150" /> + </scroll_list> + <panel + background_visible="false" + follows="left|right|bottom" + height="25" + label="bottom_panel" + layout="topleft" + name="bottom_panel" + top_pad="0" > + <button + image_hover_unselected="Toolbar_Left_Over" + image_overlay="Refresh_Off" + image_overlay_alignment="left" + image_selected="Toolbar_Left_Selected" + image_unselected="Toolbar_Left_Off" + label="Refresh" + left="0" + name="refresh_btn" + top="1" + width="74" /> + <icon + follows="left|right" + image_name="Toolbar_Right_Off" + left_pad="1" + name="dummy_icon" + top="1" + width="425" /> + </panel> +</panel> \ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/rlva_strings.xml b/indra/newview/skins/default/xui/en/rlva_strings.xml new file mode 100644 index 0000000000000000000000000000000000000000..bf55539891ea8b7ac3571445c0027e2cfe583a14 --- /dev/null +++ b/indra/newview/skins/default/xui/en/rlva_strings.xml @@ -0,0 +1,149 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<llsd> +<map> + + <key>strings</key> + <map> + <!-- Primarily used when @showloc restricted --> + <key>hidden_generic</key> + <map> + <key>value</key> + <string>(Hidden)</string> + </map> + <key>hidden_parcel</key> + <map> + <key>value</key> + <string>(Hidden parcel)</string> + </map> + <key>hidden_region</key> + <map> + <key>value</key> + <string>(Hidden region)</string> + </map> + + <!-- Received/sent IMs will be replaced by the matching string when @recvim/sendim restricted --> + <key>blocked_recvim</key> + <map> + <key>value</key> + <string>*** IM blocked by your viewer</string> + <key>description</key> + <string>Shown in place of the original message when an incoming IM is blocked</string> + <key>label</key> + <string>Blocked incoming IM message (local)</string> + <key>customizable</key> + <boolean>1</boolean> + </map> + <key>blocked_sendim</key> + <map> + <key>value</key> + <string>*** IM blocked by sender's viewer</string> + <key>description</key> + <string>Shown (and sent to the remote party) when an outgoing IM is blocked</string> + <key>label</key> + <string>Blocked outgoing IM message (local + remote)</string> + <key>customizable</key> + <boolean>1</boolean> + </map> + + <!-- Shown as notifications --> + <key>blocked_generic</key> + <map> + <key>value</key> + <string>Unable to perform action due to RLV restrictions</string> + </map> + <key>blocked_permattach</key> + <map> + <key>value</key> + <string>Attempt to attach '[OBJECT]' was denied due to RLV restrictions</string> + </map> + <key>blocked_permteleport</key> + <map> + <key>value</key> + <string>[OBJECT]' was denied permission to teleport you due to RLV restrictions</string> + </map> + <key>blocked_startim</key> + <map> + <key>value</key> + <string>Unable to start IM session with [RECIPIENT] due to RLV restrictions</string> + </map> + <key>blocked_startconf</key> + <map> + <key>value</key> + <string>Unable to start conference with [RECIPIENT] due to RLV restrictions</string> + </map> + <key>blocked_teleport</key> + <map> + <key>value</key> + <string>Unable to initiate teleport due to RLV restrictions</string> + </map> + <key>blocked_viewxxx</key> + <map> + <key>value</key> + <string>Unable to open [TYPE] due to RLV restrictions</string> + </map> + <key>blocked_wireframe</key> + <map> + <key>value</key> + <string>Unable to enable wireframe mode due to RLV restrictions</string> + </map> + + <!-- Sent as "Busy" messages to the remote party --> + <key>blocked_recvim_remote</key> + <map> + <key>value</key> + <string>The Resident you messaged is prevented from reading your instant messages at the moment, please try again later.</string> + <key>description</key> + <string>Sent to the remote party when their IM was blocked</string> + <key>label</key> + <string>Blocked incoming IM message (remote)</string> + <key>customizable</key> + <boolean>1</boolean> + </map> + <key>blocked_tplure_remote</key> + <map> + <key>value</key> + <string>The Resident you invited is prevented from accepting teleport offers. Please try again later.</string> + <key>description</key> + <string>Sent to the remote party when their teleport offer was blocked</string> + <key>label</key> + <string>Blocked teleport offer (remote)</string> + <key>customizable</key> + <boolean>1</boolean> + </map> + </map> + + <!-- Generic names used to replace resident names when @shownames restricted --> + <key>anonyms</key> + <array> + <string>A resident</string> + <string>This resident</string> + <string>That resident</string> + <string>An individual</string> + <string>This individual</string> + <string>That individual</string> + <string>A person</string> + <string>This person</string> + <string>That person</string> + <string>A stranger</string> + <string>This stranger</string> + <string>That stranger</string> + <string>A being</string> + <string>This being</string> + <string>That being</string> + <string>An agent</string> + <string>This agent</string> + <string>That agent</string> + <string>A soul</string> + <string>This soul</string> + <string>That soul</string> + <string>Somebody</string> + <string>Some people</string> + <string>Someone</string> + <string>Mysterious one</string> + <string>An unknown being</string> + <string>Unidentified one</string> + <string>An unknown person</string> + </array> + +</map> +</llsd> diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 8ac95beddb329738c229bdfe0db4e27cd097f77e..46df1b372e6ae8ea5eaa1c2badfe16f5ef438ed7 100755 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3435,6 +3435,9 @@ If you continue to receive this message, contact the [SUPPORT_SITE]. <string name="inventory_item_offered-im"> Inventory item offered </string> + <string name="inventory_item_offered_rlv"> + Inventory item offered to [NAME] + </string> <string name="share_alert"> Drag items from inventory here </string> diff --git a/indra/newview/tests/llslurl_test.cpp b/indra/newview/tests/llslurl_test.cpp index 86229ad636b1b7ced88daed66d231177e6a23257..3e00e2661132409bf54ba2b73f216e7fd07af426 100755 --- a/indra/newview/tests/llslurl_test.cpp +++ b/indra/newview/tests/llslurl_test.cpp @@ -31,6 +31,35 @@ #include "../llslurl.h" #include "../../llxml/llcontrol.h" #include "llsdserialize.h" + +// [RLVa:KB] - Checked: 2010-11-12 (RLVa-1.2.2a) | Added: RLVa-1.2.2a +// Stub implementation to get the test to compile properly +#include "../rlvhandler.h" + +const std::string& RlvStrings::getString(const std::string& strStringName) +{ + static const std::string strMissing = "(Missing RLVa string)"; + return strMissing; +} + +bool RlvUtil::isNearbyRegion(const std::string& strRegion) +{ + return false; +} + +RlvHandler::RlvHandler() : m_pGCTimer(NULL), m_pWLSnapshot(NULL) +{ + // Array auto-initialization to 0 is non-standard? (Compiler warning in VC-8.0) + memset(m_Behaviours, 0, sizeof(S16) * RLV_BHVR_COUNT); +} + +RlvHandler::~RlvHandler() +{ +} + +RlvHandler gRlvHandler; +// [/RLVa:KB] + //---------------------------------------------------------------------------- // Mock objects for the dependencies of the code we're testing diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp old mode 100755 new mode 100644 diff --git a/indra/viewer_components/updater/scripts/windows/update_install.bat b/indra/viewer_components/updater/scripts/windows/update_install.bat index 96687226a8d3d243cdb268707a4eecefbb1d33e1..ecb6e357b41d507036fbcaa755be92d4fd8a9269 100644 --- a/indra/viewer_components/updater/scripts/windows/update_install.bat +++ b/indra/viewer_components/updater/scripts/windows/update_install.bat @@ -1,3 +1,3 @@ -start /WAIT %1 /SKIP_DIALOGS -IF ERRORLEVEL 1 ECHO %3 > %2 -DEL %1 +start /WAIT %1 /SKIP_DIALOGS +IF ERRORLEVEL 1 ECHO %3 > %2 +DEL %1