Files
Ansariel 0ecfbc3de9 Merge remote-tracking branch 'LGPL/master'
# Conflicts:
#	autobuild.xml
#	indra/cmake/CMakeLists.txt
#	indra/cmake/GoogleMock.cmake
#	indra/llappearance/llwearable.cpp
#	indra/llcharacter/llmultigesture.cpp
#	indra/llcharacter/llmultigesture.h
#	indra/llimage/llimage.cpp
#	indra/llimage/llimagepng.cpp
#	indra/llimage/llimageworker.cpp
#	indra/llmessage/tests/llmockhttpclient.h
#	indra/llrender/llfontfreetype.cpp
#	indra/llui/llcombobox.cpp
#	indra/llui/llfolderview.cpp
#	indra/llui/llfolderviewmodel.h
#	indra/llui/lllineeditor.cpp
#	indra/llui/lllineeditor.h
#	indra/llui/lltextbase.cpp
#	indra/llui/lltextbase.h
#	indra/llui/lltexteditor.cpp
#	indra/llui/lltextvalidate.cpp
#	indra/llui/lltextvalidate.h
#	indra/llui/lluictrl.h
#	indra/llui/llview.cpp
#	indra/llwindow/llwindowmacosx.cpp
#	indra/newview/app_settings/settings.xml
#	indra/newview/llappearancemgr.cpp
#	indra/newview/llappearancemgr.h
#	indra/newview/llavatarpropertiesprocessor.h
#	indra/newview/llbreadcrumbview.cpp
#	indra/newview/llbreadcrumbview.h
#	indra/newview/llbreastmotion.cpp
#	indra/newview/llbreastmotion.h
#	indra/newview/llconversationmodel.h
#	indra/newview/lldensityctrl.cpp
#	indra/newview/lldensityctrl.h
#	indra/newview/llface.inl
#	indra/newview/llfloatereditsky.cpp
#	indra/newview/llfloatereditwater.cpp
#	indra/newview/llfloateremojipicker.h
#	indra/newview/llfloaterimsessiontab.cpp
#	indra/newview/llfloaterprofiletexture.cpp
#	indra/newview/llfloaterprofiletexture.h
#	indra/newview/llgesturemgr.cpp
#	indra/newview/llgesturemgr.h
#	indra/newview/llgroupactions.cpp
#	indra/newview/llimpanel.cpp
#	indra/newview/llinventorybridge.cpp
#	indra/newview/llinventorybridge.h
#	indra/newview/llinventoryclipboard.cpp
#	indra/newview/llinventoryclipboard.h
#	indra/newview/llinventoryfunctions.cpp
#	indra/newview/llinventoryfunctions.h
#	indra/newview/llinventorygallery.cpp
#	indra/newview/lllistbrowser.cpp
#	indra/newview/lllistbrowser.h
#	indra/newview/llpaneleditwearable.cpp
#	indra/newview/llpanelobjectinventory.cpp
#	indra/newview/llpanelprofile.cpp
#	indra/newview/llpreviewgesture.cpp
#	indra/newview/llsavedsettingsglue.cpp
#	indra/newview/llsavedsettingsglue.h
#	indra/newview/lltooldraganddrop.cpp
#	indra/newview/llurllineeditorctrl.cpp
#	indra/newview/llvectorperfoptions.cpp
#	indra/newview/llvectorperfoptions.h
#	indra/newview/llviewermenu.cpp
#	indra/newview/llviewerparceloverlay.cpp
#	indra/newview/llviewertexlayer.cpp
#	indra/newview/llviewertexturelist.cpp
#	indra/newview/macmain.h
2024-05-16 14:10:55 +02:00

181 lines
6.1 KiB
C++

/**
* @file floatermedialists.cpp
* @brief Floater to edit media white/blacklists - implementation
*
* $LicenseInfo:firstyear=2011&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2011, Sione Lomu
* Copyright (C) 2011, The Phoenix Firestorm Project, 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
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "floatermedialists.h"
#include "llfloaterreg.h"
#include "llnotificationsutil.h"
#include "llscrolllistctrl.h"
#include "lltrans.h"
#include "llviewerparcelmedia.h"
FloaterMediaLists::FloaterMediaLists(const LLSD& key) :
LLFloater(key)
{
}
bool FloaterMediaLists::postBuild()
{
mWhitelistSLC = getChild<LLScrollListCtrl>("whitelist");
mBlacklistSLC = getChild<LLScrollListCtrl>("blacklist");
childSetAction("add_whitelist", boost::bind(&FloaterMediaLists::onWhitelistAdd, this));
childSetAction("remove_whitelist", boost::bind(&FloaterMediaLists::onWhitelistRemove, this));
childSetAction("add_blacklist", boost::bind(&FloaterMediaLists::onBlacklistAdd, this));
childSetAction("remove_blacklist", boost::bind(&FloaterMediaLists::onBlacklistRemove, this));
for (LLSD::array_iterator p_itr = LLViewerParcelMedia::getInstance()->mMediaFilterList.beginArray();
p_itr != LLViewerParcelMedia::getInstance()->mMediaFilterList.endArray();
++p_itr)
{
LLSD itr = (*p_itr);
LLSD element;
element["columns"][0]["column"] = "list";
element["columns"][0]["value"] = itr["domain"].asString();
if (itr["action"].asString() == "allow")
{
mWhitelistSLC->addElement(element);
}
else if (itr["action"].asString() == "deny")
{
mBlacklistSLC->addElement(element);
}
}
mWhitelistSLC->sortByColumn("list", true);
mBlacklistSLC->sortByColumn("list", true);
return true;
}
void FloaterMediaLists::onWhitelistAdd()
{
LLSD payload, args;
args["LIST"] = LLTrans::getString("MediaFilterWhitelist");
payload["whitelist"] = true;
LLNotificationsUtil::add("AddToMediaList", args, payload, &FloaterMediaLists::handleAddDomainCallback);
}
void FloaterMediaLists::onWhitelistRemove()
{
LLScrollListItem* selected = mWhitelistSLC->getFirstSelected();
if (selected)
{
std::string domain = mWhitelistSLC->getSelectedItemLabel();
LLViewerParcelMedia* inst = LLViewerParcelMedia::getInstance();
for (S32 i = 0; i < (S32)inst->mMediaFilterList.size(); ++i)
{
if (inst->mMediaFilterList[i]["domain"].asString() == domain)
{
inst->mMediaFilterList.erase(i);
inst->saveDomainFilterList();
//HACK: should really see if the URL being deleted
// is the same as the saved one
inst->mMediaLastURL = "";
inst->mAudioLastURL = "";
inst->mMediaReFilter = true;
break;
}
}
mWhitelistSLC->deleteSelectedItems();
}
}
void FloaterMediaLists::onBlacklistAdd()
{
LLSD payload, args;
args["LIST"] = LLTrans::getString("MediaFilterBlacklist");
payload["whitelist"] = false;
LLNotificationsUtil::add("AddToMediaList", args, payload, &FloaterMediaLists::handleAddDomainCallback);
}
void FloaterMediaLists::onBlacklistRemove()
{
LLScrollListItem* selected = mBlacklistSLC->getFirstSelected();
if (selected)
{
std::string domain = mBlacklistSLC->getSelectedItemLabel();
LLViewerParcelMedia* inst = LLViewerParcelMedia::getInstance();
for (S32 i = 0; i < (S32)inst->mMediaFilterList.size(); ++i)
{
if (inst->mMediaFilterList[i]["domain"].asString() == domain)
{
inst->mMediaFilterList.erase(i);
inst->saveDomainFilterList();
//HACK: should really see if the URL being deleted
// is the same as the saved one
inst->mMediaLastURL = "";
inst->mAudioLastURL = "";
inst->mMediaReFilter = true;
break;
}
}
mBlacklistSLC->deleteSelectedItems();
}
}
//static
bool FloaterMediaLists::handleAddDomainCallback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (option == 0)
{
LLViewerParcelMedia* inst = LLViewerParcelMedia::getInstance();
const std::string domain = inst->extractDomain(response["url"].asString());
if (domain.empty())
{
LL_INFOS("MediaFilter") << "No domain specified" << LL_ENDL;
return false;
}
bool whitelist = notification["payload"]["whitelist"].asBoolean();
LLSD newmedia;
newmedia["domain"] = domain;
newmedia["action"] = (whitelist ? "allow" : "deny");
inst->mMediaFilterList.append(newmedia);
inst->saveDomainFilterList();
LLFloater* floater = LLFloaterReg::findInstance("media_lists");
if (floater)
{
LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>(whitelist ? "whitelist" : "blacklist");
LLSD element;
element["columns"][0]["column"] = "list";
element["columns"][0]["value"] = domain;
list->addElement(element);
list->sortByColumn("list", true);
}
}
return false;
}