From de52689954f575914cc91745808fa6cd6ece021a Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Fri, 14 Sep 2018 08:14:05 +0300 Subject: SL-1956 added support for temporary bans to parcel ban list --- indra/newview/CMakeLists.txt | 2 + indra/newview/llfloaterbanduration.cpp | 92 +++++++++++++++++++ indra/newview/llfloaterbanduration.h | 52 +++++++++++ indra/newview/llfloaterland.cpp | 75 +++++++++++----- indra/newview/llfloaterland.h | 1 + indra/newview/llviewerfloaterreg.cpp | 2 + .../skins/default/xui/en/floater_about_land.xml | 28 +++++- .../skins/default/xui/en/floater_ban_duration.xml | 100 +++++++++++++++++++++ 8 files changed, 329 insertions(+), 23 deletions(-) create mode 100644 indra/newview/llfloaterbanduration.cpp create mode 100644 indra/newview/llfloaterbanduration.h create mode 100644 indra/newview/skins/default/xui/en/floater_ban_duration.xml (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 2fc722d4c3..de4bb6cf06 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -207,6 +207,7 @@ set(viewer_SOURCE_FILES llfloateravatarpicker.cpp llfloateravatarrendersettings.cpp llfloateravatartextures.cpp + llfloaterbanduration.cpp llfloaterbeacons.cpp llfloaterbigpreview.cpp llfloaterbuildoptions.cpp @@ -829,6 +830,7 @@ set(viewer_HEADER_FILES llfloateravatarpicker.h llfloateravatarrendersettings.h llfloateravatartextures.h + llfloaterbanduration.h llfloaterbeacons.h llfloaterbigpreview.h llfloaterbuildoptions.h diff --git a/indra/newview/llfloaterbanduration.cpp b/indra/newview/llfloaterbanduration.cpp new file mode 100644 index 0000000000..6ba6c30cab --- /dev/null +++ b/indra/newview/llfloaterbanduration.cpp @@ -0,0 +1,92 @@ +/** +* @file llfloaterbanduration.cpp +* +* $LicenseInfo:firstyear=2004&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2018, 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$ +*/ + +#include "llviewerprecompiledheaders.h" +#include "llfloaterbanduration.h" + +#include "llfloaterreg.h" +#include "llspinctrl.h" +#include "llradiogroup.h" + +LLFloaterBanDuration::LLFloaterBanDuration(const LLSD& target) + : LLFloater(target) +{ +} + +BOOL LLFloaterBanDuration::postBuild() +{ + childSetAction("ok_btn", boost::bind(&LLFloaterBanDuration::onClickBan, this)); + childSetAction("cancel_btn", boost::bind(&LLFloaterBanDuration::onClickCancel, this)); + + getChild("ban_duration_radio")->setCommitCallback(boost::bind(&LLFloaterBanDuration::onClickRadio, this)); + getChild("ban_duration_radio")->setSelectedIndex(0); + getChild("ban_hours")->setEnabled(FALSE); + + return TRUE; +} + +LLFloaterBanDuration* LLFloaterBanDuration::show(select_callback_t callback, uuid_vec_t ids) +{ + LLFloaterBanDuration* floater = LLFloaterReg::showTypedInstance("ban_duration"); + if (!floater) + { + LL_WARNS() << "Cannot instantiate ban duration floater" << LL_ENDL; + return NULL; + } + + floater->mSelectionCallback = callback; + floater->mAvatar_ids = ids; + + return floater; +} + +void LLFloaterBanDuration::onClickRadio() +{ + getChild("ban_hours")->setEnabled(getChild("ban_duration_radio")->getSelectedIndex() != 0); +} + +void LLFloaterBanDuration::onClickCancel() +{ + closeFloater(); +} + +void LLFloaterBanDuration::onClickBan() +{ + if (mSelectionCallback) + { + S32 time = 0; + if (getChild("ban_duration_radio")->getSelectedIndex() != 0) + { + LLSpinCtrl* hours_spin = getChild("ban_hours"); + if (hours_spin) + { + time = LLDate::now().secondsSinceEpoch() + (hours_spin->getValue().asInteger() * 3600); + } + } + mSelectionCallback(mAvatar_ids, time); + } + closeFloater(); +} + diff --git a/indra/newview/llfloaterbanduration.h b/indra/newview/llfloaterbanduration.h new file mode 100644 index 0000000000..e8ec7cc669 --- /dev/null +++ b/indra/newview/llfloaterbanduration.h @@ -0,0 +1,52 @@ +/** +* @file llfloaterbanduration.h +* +* $LicenseInfo:firstyear=2004&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2018, 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$ +*/ + + +#ifndef LL_FLOATERBANDURATION_H +#define LL_FLOATERBANDURATION_H + +#include "llfloater.h" + +class LLFloaterBanDuration : public LLFloater +{ + typedef boost::function select_callback_t; + +public: + LLFloaterBanDuration(const LLSD& target); + BOOL postBuild(); + static LLFloaterBanDuration* show(select_callback_t callback, uuid_vec_t id); + +private: + ~LLFloaterBanDuration() {}; + void onClickBan(); + void onClickCancel(); + void onClickRadio(); + + uuid_vec_t mAvatar_ids; + select_callback_t mSelectionCallback; +}; + +#endif // LL_FLOATERBANDURATION_H + diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 88b3fb7b96..2ecb6f21cd 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -46,6 +46,7 @@ #include "llfloaterreg.h" #include "llfloateravatarpicker.h" #include "llfloaterauction.h" +#include "llfloaterbanduration.h" #include "llfloatergroups.h" #include "llfloaterscriptlimits.h" #include "llavataractions.h" @@ -2502,33 +2503,49 @@ void LLPanelLandAccess::refresh() cit != parcel->mBanList.end(); ++cit) { const LLAccessEntry& entry = (*cit).second; - std::string prefix; + std::string duration; if (entry.mTime != 0) { LLStringUtil::format_map_t args; S32 now = time(NULL); - S32 seconds = entry.mTime - now; + S32 seconds = entry.mTime - now; if (seconds < 0) seconds = 0; - prefix.assign(" ("); - if (seconds >= 120) + + if (seconds >= 7200) { - args["[MINUTES]"] = llformat("%d", (seconds/60)); - std::string buf = parent_floater->getString ("Minutes", args); - prefix.append(buf); + args["[HOURS]"] = llformat("%d", (seconds / 7200)); + duration = parent_floater->getString("Hours", args); + } + if (seconds >= 3600) + { + duration = "1 " + parent_floater->getString("Hour"); + } + else if (seconds >= 120) + { + args["[MINUTES]"] = llformat("%d", (seconds / 60)); + duration = parent_floater->getString("Minutes", args); } else if (seconds >= 60) { - prefix.append("1 " + parent_floater->getString("Minute")); + duration = "1 " + parent_floater->getString("Minute"); } else { args["[SECONDS]"] = llformat("%d", seconds); - std::string buf = parent_floater->getString ("Seconds", args); - prefix.append(buf); + duration = parent_floater->getString("Seconds", args); } - prefix.append(" " + parent_floater->getString("Remaining") + ") "); } - mListBanned->addNameItem(entry.mID, ADD_DEFAULT, TRUE, "", prefix); + else + { + duration = parent_floater->getString("Always"); + } + LLSD item; + item["id"] = entry.mID; + LLSD& columns = item["columns"]; + columns[0]["column"] = "name"; // to be populated later + columns[1]["column"] = "duration"; + columns[1]["value"] = duration; + mListBanned->addElement(item); } mListBanned->sortByName(TRUE); } @@ -2880,7 +2897,7 @@ void LLPanelLandAccess::onClickAddBanned() LLView * button = findChild("add_banned"); LLFloater * root_floater = gFloaterView->getParentFloater(this); LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show( - boost::bind(&LLPanelLandAccess::callbackAvatarCBBanned, this, _1), FALSE, FALSE, FALSE, root_floater->getName(), button); + boost::bind(&LLPanelLandAccess::callbackAvatarCBBanned, this, _1), TRUE, FALSE, FALSE, root_floater->getName(), button); if (picker) { root_floater->addDependentFloater(picker); @@ -2890,23 +2907,41 @@ void LLPanelLandAccess::onClickAddBanned() // static void LLPanelLandAccess::callbackAvatarCBBanned(const uuid_vec_t& ids) { - if (!ids.empty()) + LLFloater * root_floater = gFloaterView->getParentFloater(this); + LLFloaterBanDuration* duration_floater = LLFloaterBanDuration::show( + boost::bind(&LLPanelLandAccess::callbackAvatarCBBanned2, this, _1, _2), ids); + if (duration_floater) { - LLUUID id = ids[0]; - LLParcel* parcel = mParcel->getParcel(); - if (parcel && parcel->addToBanList(id, 0)) + root_floater->addDependentFloater(duration_floater); + } +} + +void LLPanelLandAccess::callbackAvatarCBBanned2(const uuid_vec_t& ids, S32 duration) +{ + LLParcel* parcel = mParcel->getParcel(); + if (!parcel) return; + + U32 lists_to_update = 0; + + for (uuid_vec_t::const_iterator it = ids.begin(); it < ids.end(); it++) + { + LLUUID id = *it; + if (parcel->addToBanList(id, duration)) { - U32 lists_to_update = AL_BAN; + lists_to_update |= AL_BAN; // agent was successfully added to ban list // but we also need to check access list to ensure that agent will not be in two lists simultaneously if (parcel->removeFromAccessList(id)) { lists_to_update |= AL_ACCESS; } - LLViewerParcelMgr::getInstance()->sendParcelAccessListUpdate(lists_to_update); - refresh(); } } + if (lists_to_update > 0) + { + LLViewerParcelMgr::getInstance()->sendParcelAccessListUpdate(lists_to_update); + refresh(); + } } // static diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index 0540ddb880..e846d42666 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -378,6 +378,7 @@ public: void onClickAddAccess(); void onClickAddBanned(); void callbackAvatarCBBanned(const uuid_vec_t& ids); + void callbackAvatarCBBanned2(const uuid_vec_t& ids, S32 duration); void callbackAvatarCBAccess(const uuid_vec_t& ids); protected: diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 0ebacddd9b..af687b97b1 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -40,6 +40,7 @@ #include "llfloateravatarpicker.h" #include "llfloateravatarrendersettings.h" #include "llfloateravatartextures.h" +#include "llfloaterbanduration.h" #include "llfloaterbigpreview.h" #include "llfloaterbeacons.h" #include "llfloaterbuildoptions.h" @@ -200,6 +201,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("avatar_render_settings", "floater_avatar_render_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("avatar_textures", "floater_avatar_textures.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("ban_duration", "floater_ban_duration.xml", &LLFloaterReg::build); LLFloaterReg::add("beacons", "floater_beacons.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("bulk_perms", "floater_bulk_perms.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("buy_currency", "floater_buy_currency.xml", &LLFloaterBuyCurrency::buildFloater); diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml index 535af317d9..841b11e3bc 100644 --- a/indra/newview/skins/default/xui/en/floater_about_land.xml +++ b/indra/newview/skins/default/xui/en/floater_about_land.xml @@ -21,6 +21,14 @@ name="maturity_icon_adult"> "Parcel_R_Dark" + + [HOURS] hrs. + + + hr. + [MINUTES] min. @@ -37,6 +45,10 @@ name="Remaining"> remaining + + Always + - Always banned ([COUNT], max [MAX]) + Banned ([COUNT], max [MAX]) + width="230"> + + + + + -- cgit v1.2.3