diff options
author | Ansariel <ansariel.hiller@phoenixviewer.com> | 2024-05-22 19:04:52 +0200 |
---|---|---|
committer | Ansariel <ansariel.hiller@phoenixviewer.com> | 2024-05-22 19:04:52 +0200 |
commit | 1b67dd855c41f5a0cda7ec2a68d98071986ca703 (patch) | |
tree | ab243607f74f78200787bba5b9b88f07ef1b966f /indra/newview/llpanelmediasettingssecurity.cpp | |
parent | 6d6eabca44d08d5b97bfe3e941d2b9687c2246ea (diff) | |
parent | e1623bb276f83a43ce7a197e388720c05bdefe61 (diff) |
Merge remote-tracking branch 'origin/main' into DRTVWR-600-maint-A
# Conflicts:
# autobuild.xml
# indra/cmake/CMakeLists.txt
# indra/cmake/GoogleMock.cmake
# indra/llaudio/llaudioengine_fmodstudio.cpp
# indra/llaudio/llaudioengine_fmodstudio.h
# indra/llaudio/lllistener_fmodstudio.cpp
# indra/llaudio/lllistener_fmodstudio.h
# indra/llaudio/llstreamingaudio_fmodstudio.cpp
# indra/llaudio/llstreamingaudio_fmodstudio.h
# indra/llcharacter/llmultigesture.cpp
# indra/llcharacter/llmultigesture.h
# indra/llimage/llimage.cpp
# indra/llimage/llimagepng.cpp
# indra/llimage/llimageworker.cpp
# indra/llimage/tests/llimageworker_test.cpp
# indra/llmessage/tests/llmockhttpclient.h
# indra/llprimitive/llgltfmaterial.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.cpp
# 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/llimpanel.cpp
# indra/newview/llimpanel.h
# 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/llpanelobjectinventory.cpp
# indra/newview/llpanelprofile.cpp
# indra/newview/llpanelprofile.h
# 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/llviewerparceloverlay.cpp
# indra/newview/llviewertexlayer.cpp
# indra/newview/llviewertexturelist.cpp
# indra/newview/macmain.h
# indra/test/test.cpp
Diffstat (limited to 'indra/newview/llpanelmediasettingssecurity.cpp')
-rw-r--r-- | indra/newview/llpanelmediasettingssecurity.cpp | 712 |
1 files changed, 356 insertions, 356 deletions
diff --git a/indra/newview/llpanelmediasettingssecurity.cpp b/indra/newview/llpanelmediasettingssecurity.cpp index d6ee15b7b9..82ee9c8fb2 100644 --- a/indra/newview/llpanelmediasettingssecurity.cpp +++ b/indra/newview/llpanelmediasettingssecurity.cpp @@ -1,356 +1,356 @@ -/** - * @file llpanelmediasettingssecurity.cpp - * @brief LLPanelMediaSettingsSecurity class implementation - * - * $LicenseInfo:firstyear=2009&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$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llpanelmediasettingssecurity.h" - -#include "llfloaterreg.h" -#include "llpanelcontents.h" -#include "llcheckboxctrl.h" -#include "llnotificationsutil.h" -#include "llscrolllistctrl.h" -#include "llscrolllistitem.h" -#include "lluictrlfactory.h" -#include "llwindow.h" -#include "llviewerwindow.h" -#include "llsdutil.h" -#include "llselectmgr.h" -#include "llmediaentry.h" -#include "lltextbox.h" -#include "llfloaterwhitelistentry.h" -#include "llfloatermediasettings.h" - -//////////////////////////////////////////////////////////////////////////////// -// -LLPanelMediaSettingsSecurity::LLPanelMediaSettingsSecurity() : - mParent( NULL ) -{ - mCommitCallbackRegistrar.add("Media.whitelistAdd", boost::bind(&LLPanelMediaSettingsSecurity::onBtnAdd, this)); - mCommitCallbackRegistrar.add("Media.whitelistDelete", boost::bind(&LLPanelMediaSettingsSecurity::onBtnDel, this)); - - // build dialog from XML - buildFromFile( "panel_media_settings_security.xml"); -} - -//////////////////////////////////////////////////////////////////////////////// -// -bool LLPanelMediaSettingsSecurity::postBuild() -{ - mEnableWhiteList = getChild< LLCheckBoxCtrl >( LLMediaEntry::WHITELIST_ENABLE_KEY ); - mWhiteListList = getChild< LLScrollListCtrl >( LLMediaEntry::WHITELIST_KEY ); - mHomeUrlFailsWhiteListText = getChild<LLTextBox>( "home_url_fails_whitelist" ); - - setDefaultBtn("whitelist_add"); - - return true; -} - -//////////////////////////////////////////////////////////////////////////////// -// virtual -LLPanelMediaSettingsSecurity::~LLPanelMediaSettingsSecurity() -{ -} - -//////////////////////////////////////////////////////////////////////////////// -// -void LLPanelMediaSettingsSecurity::draw() -{ - // housekeeping - LLPanel::draw(); -} - -//////////////////////////////////////////////////////////////////////////////// -// static -void LLPanelMediaSettingsSecurity::initValues( void* userdata, const LLSD& media_settings , bool editable) -{ - LLPanelMediaSettingsSecurity *self =(LLPanelMediaSettingsSecurity *)userdata; - std::string base_key( "" ); - std::string tentative_key( "" ); - - struct - { - std::string key_name; - LLUICtrl* ctrl_ptr; - std::string ctrl_type; - - } data_set [] = - { - { LLMediaEntry::WHITELIST_ENABLE_KEY, self->mEnableWhiteList, "LLCheckBoxCtrl" }, - { LLMediaEntry::WHITELIST_KEY, self->mWhiteListList, "LLScrollListCtrl" }, - { "", NULL , "" } - }; - - for( int i = 0; data_set[ i ].key_name.length() > 0; ++i ) - { - base_key = std::string( data_set[ i ].key_name ); - tentative_key = base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ); - - bool enabled_overridden = false; - - // TODO: CP - I bet there is a better way to do this using Boost - if ( media_settings[ base_key ].isDefined() ) - { - if ( data_set[ i ].ctrl_type == "LLCheckBoxCtrl" ) - { - static_cast< LLCheckBoxCtrl* >( data_set[ i ].ctrl_ptr )-> - setValue( media_settings[ base_key ].asBoolean() ); - } - else - if ( data_set[ i ].ctrl_type == "LLScrollListCtrl" ) - { - // get control - LLScrollListCtrl* list = static_cast< LLScrollListCtrl* >( data_set[ i ].ctrl_ptr ); - list->deleteAllItems(); - - // points to list of white list URLs - LLSD url_list = media_settings[ base_key ]; - - // better be the whitelist - llassert(data_set[ i ].ctrl_ptr == self->mWhiteListList); - - // If tentative, don't add entries - if (media_settings[ tentative_key ].asBoolean()) - { - self->mWhiteListList->setEnabled(false); - enabled_overridden = true; - } - else { - // iterate over them and add to scroll list - LLSD::array_iterator iter = url_list.beginArray(); - while( iter != url_list.endArray() ) - { - std::string entry = *iter; - self->addWhiteListEntry( entry ); - ++iter; - } - } - }; - if ( ! enabled_overridden) data_set[ i ].ctrl_ptr->setEnabled(editable); - data_set[ i ].ctrl_ptr->setTentative( media_settings[ tentative_key ].asBoolean() ); - }; - }; - - // initial update - hides/shows status messages etc. - self->updateWhitelistEnableStatus(); -} - -//////////////////////////////////////////////////////////////////////////////// -// static -void LLPanelMediaSettingsSecurity::clearValues( void* userdata , bool editable) -{ - LLPanelMediaSettingsSecurity *self =(LLPanelMediaSettingsSecurity *)userdata; - self->mEnableWhiteList->clear(); - self->mWhiteListList->deleteAllItems(); - self->mEnableWhiteList->setEnabled(editable); - self->mWhiteListList->setEnabled(editable); -} - -//////////////////////////////////////////////////////////////////////////////// -// -void LLPanelMediaSettingsSecurity::preApply() -{ - // no-op -} - -//////////////////////////////////////////////////////////////////////////////// -// -void LLPanelMediaSettingsSecurity::getValues( LLSD &fill_me_in, bool include_tentative ) -{ - if (include_tentative || !mEnableWhiteList->getTentative()) - fill_me_in[LLMediaEntry::WHITELIST_ENABLE_KEY] = (LLSD::Boolean)mEnableWhiteList->getValue(); - - if (include_tentative || !mWhiteListList->getTentative()) - { - // iterate over white list and extract items - std::vector< LLScrollListItem* > whitelist_items = mWhiteListList->getAllData(); - std::vector< LLScrollListItem* >::iterator iter = whitelist_items.begin(); - - // *NOTE: need actually set the key to be an emptyArray(), or the merge - // we do with this LLSD will think there's nothing to change. - fill_me_in[LLMediaEntry::WHITELIST_KEY] = LLSD::emptyArray(); - while( iter != whitelist_items.end() ) - { - LLScrollListCell* cell = (*iter)->getColumn( ENTRY_COLUMN ); - std::string whitelist_url = cell->getValue().asString(); - - fill_me_in[ LLMediaEntry::WHITELIST_KEY ].append( whitelist_url ); - ++iter; - }; - } -} - -//////////////////////////////////////////////////////////////////////////////// -// -void LLPanelMediaSettingsSecurity::postApply() -{ - // no-op -} - -/////////////////////////////////////////////////////////////////////////////// -// Try to make a valid URL if a fragment ( -// white list list box widget and build a list to test against. Can also -const std::string LLPanelMediaSettingsSecurity::makeValidUrl( const std::string& src_url ) -{ - // use LLURI to determine if we have a valid scheme - LLURI candidate_url( src_url ); - if ( candidate_url.scheme().empty() ) - { - // build a URL comprised of default scheme and the original fragment - const std::string default_scheme( "http://" ); - return default_scheme + src_url; - }; - - // we *could* test the "default scheme" + "original fragment" URL again - // using LLURI to see if it's valid but I think the outcome is the same - // in either case - our only option is to return the original URL - - // we *think* the original url passed in was valid - return src_url; -} - -/////////////////////////////////////////////////////////////////////////////// -// wrapper for testing a URL against the whitelist. We grab entries from -// white list list box widget and build a list to test against. -bool LLPanelMediaSettingsSecurity::urlPassesWhiteList( const std::string& test_url ) -{ - // If the whitlelist list is tentative, it means we have multiple settings. - // In that case, we have no choice but to return true - if ( mWhiteListList->getTentative() ) return true; - - // the checkUrlAgainstWhitelist(..) function works on a vector - // of strings for the white list entries - in this panel, the white list - // is stored in the widgets themselves so we need to build something compatible. - std::vector< std::string > whitelist_strings; - whitelist_strings.clear(); // may not be required - I forget what the spec says. - - // step through whitelist widget entries and grab them as strings - std::vector< LLScrollListItem* > whitelist_items = mWhiteListList->getAllData(); - std::vector< LLScrollListItem* >::iterator iter = whitelist_items.begin(); - while( iter != whitelist_items.end() ) - { - LLScrollListCell* cell = (*iter)->getColumn( ENTRY_COLUMN ); - std::string whitelist_url = cell->getValue().asString(); - - whitelist_strings.push_back( whitelist_url ); - - ++iter; - }; - - // possible the URL is just a fragment so we validize it - const std::string valid_url = makeValidUrl( test_url ); - - // indicate if the URL passes whitelist - return LLMediaEntry::checkUrlAgainstWhitelist( valid_url, whitelist_strings ); -} - -/////////////////////////////////////////////////////////////////////////////// -// -void LLPanelMediaSettingsSecurity::updateWhitelistEnableStatus() -{ - // get the value for home URL and make it a valid URL - const std::string valid_url = makeValidUrl( mParent->getHomeUrl() ); - - // now check to see if the home url passes the whitelist in its entirity - if ( urlPassesWhiteList( valid_url ) ) - { - mEnableWhiteList->setEnabled( true ); - mHomeUrlFailsWhiteListText->setVisible( false ); - } - else - { - mEnableWhiteList->set( false ); - mEnableWhiteList->setEnabled( false ); - mHomeUrlFailsWhiteListText->setVisible( true ); - }; -} - -/////////////////////////////////////////////////////////////////////////////// -// Add an entry to the whitelist scrollbox and indicate if the current -// home URL passes this entry or not using an icon -void LLPanelMediaSettingsSecurity::addWhiteListEntry( const std::string& entry ) -{ - // grab the home url - std::string home_url( "" ); - if ( mParent ) - home_url = mParent->getHomeUrl(); - - // try to make a valid URL based on what the user entered - missing scheme for example - const std::string valid_url = makeValidUrl( home_url ); - - // check the home url against this single whitelist entry - std::vector< std::string > whitelist_entries; - whitelist_entries.push_back( entry ); - bool home_url_passes_entry = LLMediaEntry::checkUrlAgainstWhitelist( valid_url, whitelist_entries ); - - // build an icon cell based on whether or not the home url pases it or not - LLSD row; - if ( home_url_passes_entry || home_url.empty() ) - { - row[ "columns" ][ ICON_COLUMN ][ "type" ] = "icon"; - row[ "columns" ][ ICON_COLUMN ][ "value" ] = ""; - row[ "columns" ][ ICON_COLUMN ][ "width" ] = 20; - } - else - { - row[ "columns" ][ ICON_COLUMN ][ "type" ] = "icon"; - row[ "columns" ][ ICON_COLUMN ][ "value" ] = "Parcel_Exp_Color"; - row[ "columns" ][ ICON_COLUMN ][ "width" ] = 20; - }; - - // always add in the entry itself - row[ "columns" ][ ENTRY_COLUMN ][ "type" ] = "text"; - row[ "columns" ][ ENTRY_COLUMN ][ "value" ] = entry; - - // add to the white list scroll box - mWhiteListList->addElement( row ); -}; - -/////////////////////////////////////////////////////////////////////////////// -// static -void LLPanelMediaSettingsSecurity::onBtnAdd( void* userdata ) -{ - LLFloaterReg::showInstance("whitelist_entry"); -} - -/////////////////////////////////////////////////////////////////////////////// -// static -void LLPanelMediaSettingsSecurity::onBtnDel( void* userdata ) -{ - LLPanelMediaSettingsSecurity *self =(LLPanelMediaSettingsSecurity *)userdata; - - self->mWhiteListList->deleteSelectedItems(); - - // contents of whitelist changed so recheck it against home url - self->updateWhitelistEnableStatus(); -} - -//////////////////////////////////////////////////////////////////////////////// -// -void LLPanelMediaSettingsSecurity::setParent( LLFloaterMediaSettings* parent ) -{ - mParent = parent; -}; +/**
+ * @file llpanelmediasettingssecurity.cpp
+ * @brief LLPanelMediaSettingsSecurity class implementation
+ *
+ * $LicenseInfo:firstyear=2009&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$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llpanelmediasettingssecurity.h"
+
+#include "llfloaterreg.h"
+#include "llpanelcontents.h"
+#include "llcheckboxctrl.h"
+#include "llnotificationsutil.h"
+#include "llscrolllistctrl.h"
+#include "llscrolllistitem.h"
+#include "lluictrlfactory.h"
+#include "llwindow.h"
+#include "llviewerwindow.h"
+#include "llsdutil.h"
+#include "llselectmgr.h"
+#include "llmediaentry.h"
+#include "lltextbox.h"
+#include "llfloaterwhitelistentry.h"
+#include "llfloatermediasettings.h"
+
+////////////////////////////////////////////////////////////////////////////////
+//
+LLPanelMediaSettingsSecurity::LLPanelMediaSettingsSecurity() :
+ mParent( NULL )
+{
+ mCommitCallbackRegistrar.add("Media.whitelistAdd", boost::bind(&LLPanelMediaSettingsSecurity::onBtnAdd, this));
+ mCommitCallbackRegistrar.add("Media.whitelistDelete", boost::bind(&LLPanelMediaSettingsSecurity::onBtnDel, this));
+
+ // build dialog from XML
+ buildFromFile( "panel_media_settings_security.xml");
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+bool LLPanelMediaSettingsSecurity::postBuild()
+{
+ mEnableWhiteList = getChild< LLCheckBoxCtrl >( LLMediaEntry::WHITELIST_ENABLE_KEY );
+ mWhiteListList = getChild< LLScrollListCtrl >( LLMediaEntry::WHITELIST_KEY );
+ mHomeUrlFailsWhiteListText = getChild<LLTextBox>( "home_url_fails_whitelist" );
+
+ setDefaultBtn("whitelist_add");
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// virtual
+LLPanelMediaSettingsSecurity::~LLPanelMediaSettingsSecurity()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+void LLPanelMediaSettingsSecurity::draw()
+{
+ // housekeeping
+ LLPanel::draw();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// static
+void LLPanelMediaSettingsSecurity::initValues( void* userdata, const LLSD& media_settings , bool editable)
+{
+ LLPanelMediaSettingsSecurity *self =(LLPanelMediaSettingsSecurity *)userdata;
+ std::string base_key( "" );
+ std::string tentative_key( "" );
+
+ struct
+ {
+ std::string key_name;
+ LLUICtrl* ctrl_ptr;
+ std::string ctrl_type;
+
+ } data_set [] =
+ {
+ { LLMediaEntry::WHITELIST_ENABLE_KEY, self->mEnableWhiteList, "LLCheckBoxCtrl" },
+ { LLMediaEntry::WHITELIST_KEY, self->mWhiteListList, "LLScrollListCtrl" },
+ { "", NULL , "" }
+ };
+
+ for( int i = 0; data_set[ i ].key_name.length() > 0; ++i )
+ {
+ base_key = std::string( data_set[ i ].key_name );
+ tentative_key = base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX );
+
+ bool enabled_overridden = false;
+
+ // TODO: CP - I bet there is a better way to do this using Boost
+ if ( media_settings[ base_key ].isDefined() )
+ {
+ if ( data_set[ i ].ctrl_type == "LLCheckBoxCtrl" )
+ {
+ static_cast< LLCheckBoxCtrl* >( data_set[ i ].ctrl_ptr )->
+ setValue( media_settings[ base_key ].asBoolean() );
+ }
+ else
+ if ( data_set[ i ].ctrl_type == "LLScrollListCtrl" )
+ {
+ // get control
+ LLScrollListCtrl* list = static_cast< LLScrollListCtrl* >( data_set[ i ].ctrl_ptr );
+ list->deleteAllItems();
+
+ // points to list of white list URLs
+ LLSD url_list = media_settings[ base_key ];
+
+ // better be the whitelist
+ llassert(data_set[ i ].ctrl_ptr == self->mWhiteListList);
+
+ // If tentative, don't add entries
+ if (media_settings[ tentative_key ].asBoolean())
+ {
+ self->mWhiteListList->setEnabled(false);
+ enabled_overridden = true;
+ }
+ else {
+ // iterate over them and add to scroll list
+ LLSD::array_iterator iter = url_list.beginArray();
+ while( iter != url_list.endArray() )
+ {
+ std::string entry = *iter;
+ self->addWhiteListEntry( entry );
+ ++iter;
+ }
+ }
+ };
+ if ( ! enabled_overridden) data_set[ i ].ctrl_ptr->setEnabled(editable);
+ data_set[ i ].ctrl_ptr->setTentative( media_settings[ tentative_key ].asBoolean() );
+ };
+ };
+
+ // initial update - hides/shows status messages etc.
+ self->updateWhitelistEnableStatus();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// static
+void LLPanelMediaSettingsSecurity::clearValues( void* userdata , bool editable)
+{
+ LLPanelMediaSettingsSecurity *self =(LLPanelMediaSettingsSecurity *)userdata;
+ self->mEnableWhiteList->clear();
+ self->mWhiteListList->deleteAllItems();
+ self->mEnableWhiteList->setEnabled(editable);
+ self->mWhiteListList->setEnabled(editable);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+void LLPanelMediaSettingsSecurity::preApply()
+{
+ // no-op
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+void LLPanelMediaSettingsSecurity::getValues( LLSD &fill_me_in, bool include_tentative )
+{
+ if (include_tentative || !mEnableWhiteList->getTentative())
+ fill_me_in[LLMediaEntry::WHITELIST_ENABLE_KEY] = (LLSD::Boolean)mEnableWhiteList->getValue();
+
+ if (include_tentative || !mWhiteListList->getTentative())
+ {
+ // iterate over white list and extract items
+ std::vector< LLScrollListItem* > whitelist_items = mWhiteListList->getAllData();
+ std::vector< LLScrollListItem* >::iterator iter = whitelist_items.begin();
+
+ // *NOTE: need actually set the key to be an emptyArray(), or the merge
+ // we do with this LLSD will think there's nothing to change.
+ fill_me_in[LLMediaEntry::WHITELIST_KEY] = LLSD::emptyArray();
+ while( iter != whitelist_items.end() )
+ {
+ LLScrollListCell* cell = (*iter)->getColumn( ENTRY_COLUMN );
+ std::string whitelist_url = cell->getValue().asString();
+
+ fill_me_in[ LLMediaEntry::WHITELIST_KEY ].append( whitelist_url );
+ ++iter;
+ };
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+void LLPanelMediaSettingsSecurity::postApply()
+{
+ // no-op
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Try to make a valid URL if a fragment (
+// white list list box widget and build a list to test against. Can also
+const std::string LLPanelMediaSettingsSecurity::makeValidUrl( const std::string& src_url )
+{
+ // use LLURI to determine if we have a valid scheme
+ LLURI candidate_url( src_url );
+ if ( candidate_url.scheme().empty() )
+ {
+ // build a URL comprised of default scheme and the original fragment
+ const std::string default_scheme( "http://" );
+ return default_scheme + src_url;
+ };
+
+ // we *could* test the "default scheme" + "original fragment" URL again
+ // using LLURI to see if it's valid but I think the outcome is the same
+ // in either case - our only option is to return the original URL
+
+ // we *think* the original url passed in was valid
+ return src_url;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// wrapper for testing a URL against the whitelist. We grab entries from
+// white list list box widget and build a list to test against.
+bool LLPanelMediaSettingsSecurity::urlPassesWhiteList( const std::string& test_url )
+{
+ // If the whitlelist list is tentative, it means we have multiple settings.
+ // In that case, we have no choice but to return true
+ if ( mWhiteListList->getTentative() ) return true;
+
+ // the checkUrlAgainstWhitelist(..) function works on a vector
+ // of strings for the white list entries - in this panel, the white list
+ // is stored in the widgets themselves so we need to build something compatible.
+ std::vector< std::string > whitelist_strings;
+ whitelist_strings.clear(); // may not be required - I forget what the spec says.
+
+ // step through whitelist widget entries and grab them as strings
+ std::vector< LLScrollListItem* > whitelist_items = mWhiteListList->getAllData();
+ std::vector< LLScrollListItem* >::iterator iter = whitelist_items.begin();
+ while( iter != whitelist_items.end() )
+ {
+ LLScrollListCell* cell = (*iter)->getColumn( ENTRY_COLUMN );
+ std::string whitelist_url = cell->getValue().asString();
+
+ whitelist_strings.push_back( whitelist_url );
+
+ ++iter;
+ };
+
+ // possible the URL is just a fragment so we validize it
+ const std::string valid_url = makeValidUrl( test_url );
+
+ // indicate if the URL passes whitelist
+ return LLMediaEntry::checkUrlAgainstWhitelist( valid_url, whitelist_strings );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+void LLPanelMediaSettingsSecurity::updateWhitelistEnableStatus()
+{
+ // get the value for home URL and make it a valid URL
+ const std::string valid_url = makeValidUrl( mParent->getHomeUrl() );
+
+ // now check to see if the home url passes the whitelist in its entirity
+ if ( urlPassesWhiteList( valid_url ) )
+ {
+ mEnableWhiteList->setEnabled( true );
+ mHomeUrlFailsWhiteListText->setVisible( false );
+ }
+ else
+ {
+ mEnableWhiteList->set( false );
+ mEnableWhiteList->setEnabled( false );
+ mHomeUrlFailsWhiteListText->setVisible( true );
+ };
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Add an entry to the whitelist scrollbox and indicate if the current
+// home URL passes this entry or not using an icon
+void LLPanelMediaSettingsSecurity::addWhiteListEntry( const std::string& entry )
+{
+ // grab the home url
+ std::string home_url( "" );
+ if ( mParent )
+ home_url = mParent->getHomeUrl();
+
+ // try to make a valid URL based on what the user entered - missing scheme for example
+ const std::string valid_url = makeValidUrl( home_url );
+
+ // check the home url against this single whitelist entry
+ std::vector< std::string > whitelist_entries;
+ whitelist_entries.push_back( entry );
+ bool home_url_passes_entry = LLMediaEntry::checkUrlAgainstWhitelist( valid_url, whitelist_entries );
+
+ // build an icon cell based on whether or not the home url pases it or not
+ LLSD row;
+ if ( home_url_passes_entry || home_url.empty() )
+ {
+ row[ "columns" ][ ICON_COLUMN ][ "type" ] = "icon";
+ row[ "columns" ][ ICON_COLUMN ][ "value" ] = "";
+ row[ "columns" ][ ICON_COLUMN ][ "width" ] = 20;
+ }
+ else
+ {
+ row[ "columns" ][ ICON_COLUMN ][ "type" ] = "icon";
+ row[ "columns" ][ ICON_COLUMN ][ "value" ] = "Parcel_Exp_Color";
+ row[ "columns" ][ ICON_COLUMN ][ "width" ] = 20;
+ };
+
+ // always add in the entry itself
+ row[ "columns" ][ ENTRY_COLUMN ][ "type" ] = "text";
+ row[ "columns" ][ ENTRY_COLUMN ][ "value" ] = entry;
+
+ // add to the white list scroll box
+ mWhiteListList->addElement( row );
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// static
+void LLPanelMediaSettingsSecurity::onBtnAdd( void* userdata )
+{
+ LLFloaterReg::showInstance("whitelist_entry");
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// static
+void LLPanelMediaSettingsSecurity::onBtnDel( void* userdata )
+{
+ LLPanelMediaSettingsSecurity *self =(LLPanelMediaSettingsSecurity *)userdata;
+
+ self->mWhiteListList->deleteSelectedItems();
+
+ // contents of whitelist changed so recheck it against home url
+ self->updateWhitelistEnableStatus();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+void LLPanelMediaSettingsSecurity::setParent( LLFloaterMediaSettings* parent )
+{
+ mParent = parent;
+};
|